functype 0.8.85 → 0.9.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.
package/README.md CHANGED
@@ -228,26 +228,27 @@ const promise = Task().toPromise(taskResult) // Promise<string>
228
228
  ### Branded Types
229
229
 
230
230
  ```typescript
231
- import { Brand } from "functype/branded"
232
-
233
- // Create branded types for stronger type safety
234
- type UserId = Brand<string, "UserId">
235
- type Email = Brand<string, "Email">
236
-
237
- // Create factory functions with validation
238
- const UserId = (id: string): UserId => {
239
- if (!/^U\d{6}$/.test(id)) {
240
- throw new Error("Invalid user ID format")
241
- }
242
- return id as UserId
243
- }
231
+ import { Brand, ValidatedBrand } from "functype/branded"
244
232
 
245
- const Email = (email: string): Email => {
246
- if (!/^[^@]+@[^@]+\.[^@]+$/.test(email)) {
247
- throw new Error("Invalid email format")
248
- }
249
- return email as Email
250
- }
233
+ // Create branded types for stronger type safety (with instance methods!)
234
+ type UserId = Brand<"UserId", string>
235
+ type Email = Brand<"Email", string>
236
+
237
+ // Simple branding
238
+ const userId = Brand("UserId", "U123456")
239
+ console.log(userId.unbrand()) // "U123456"
240
+ console.log(userId.toString()) // "UserId(U123456)"
241
+
242
+ // Runtime-validated branding for safer input handling
243
+ const EmailValidator = ValidatedBrand("Email", (s: string) => /^[^@]+@[^@]+\.[^@]+$/.test(s))
244
+ const UserIdValidator = ValidatedBrand("UserId", (s: string) => /^U\d{6}$/.test(s))
245
+
246
+ // Safe creation with Option/Either return types
247
+ const email = EmailValidator.of("user@example.com") // Some(Brand<"Email", string>)
248
+ const invalidEmail = EmailValidator.of("invalid") // None
249
+
250
+ const userResult = UserIdValidator.from("U123456") // Right(Brand<"UserId", string>)
251
+ const userError = UserIdValidator.from("invalid") // Left("Invalid UserId: validation failed")
251
252
 
252
253
  // Type safety in action
253
254
  function getUserByEmail(email: Email): User {
@@ -331,6 +332,46 @@ console.log(numberType(42)) // "positive"
331
332
  console.log(numberType(-5)) // "negative"
332
333
  ```
333
334
 
335
+ ### Advanced Pattern Matching
336
+
337
+ Match supports exhaustive matching, nested patterns, and guards:
338
+
339
+ ```typescript
340
+ import { Match } from "functype"
341
+
342
+ // Exhaustive matching with compile-time checking
343
+ type Status = "idle" | "loading" | "success" | "error"
344
+ const result = Match<Status, string>("success")
345
+ .case("idle", "Waiting...")
346
+ .case("loading", "Loading...")
347
+ .case("success", "Done!")
348
+ .case("error", "Failed!")
349
+ .exhaustive() // Compile error if any case is missing
350
+
351
+ // Nested pattern matching
352
+ type User = {
353
+ name: string
354
+ age: number
355
+ role: "admin" | "user"
356
+ preferences?: { theme: "light" | "dark" }
357
+ }
358
+
359
+ const message = Match<User, string>(user)
360
+ .case({ role: "admin", age: (n) => n >= 18, preferences: { theme: "dark" } }, "Adult admin with dark mode")
361
+ .case({ role: "user" }, (u) => `Regular user: ${u.name}`)
362
+ .when((u) => u.age < 18, "Minor user - restricted access")
363
+ .default("Unknown user type")
364
+
365
+ // Reusable pattern matchers
366
+ const classifier = Match.builder<Animal, string>()
367
+ .when((a) => a.canFly, "Flying creature")
368
+ .case({ legs: 0 }, "Legless")
369
+ .case({ legs: 2 }, "Biped")
370
+ .case({ legs: 4 }, "Quadruped")
371
+ .default("Other")
372
+ .build()
373
+ ```
374
+
334
375
  ## Fold
335
376
 
336
377
  Functype includes a powerful `fold` operation for pattern matching and extracting values:
@@ -575,16 +616,56 @@ For more details, see the [Error Formatting Guide](docs/error-formatting.md).
575
616
 
576
617
  ## Roadmap / TODO
577
618
 
578
- ### Missing Functionality
579
-
580
- - [ ] Add lazy evaluation structures (LazyList/Stream)
581
- - [ ] Implement Validation type for applicative validation
582
- - [ ] Add Reader/State/IO monads for more functional patterns
583
- - [ ] Implement lens/optics for immutable updates
584
- - [ ] Expand concurrent execution utilities beyond FPromise.all
619
+ ### High Priority
620
+
621
+ - [x] Complete LazyList Implementation
622
+ - Add Foldable interface (fold, foldLeft, foldRight)
623
+ - Add Pipe interface for composition
624
+ - Add Serializable for persistence
625
+ - Add Typeable support
626
+ - [ ] Implement NonEmptyList<A>
627
+ - List guaranteed to have at least one element
628
+ - Prevents empty list errors at compile time
629
+ - Full standard interface implementation
630
+ - Methods like `head` return `A` instead of `Option<A>`
631
+
632
+ ### Medium Priority
633
+
634
+ - [ ] Implement ValidatedNel<E, A> for validation with error accumulation
635
+ - Unlike Either, collects multiple errors
636
+ - Uses NonEmptyList for error collection
637
+ - Applicative instance combines errors
638
+ - [x] Enhance Pattern Matching
639
+ - ✓ Add exhaustiveness checking at compile time
640
+ - ✓ Support nested pattern matching
641
+ - ✓ Add guard clauses (when conditions)
642
+ - ✓ Support destructuring patterns
643
+ - ✓ Consolidated into unified Match implementation
644
+ - [ ] Implement IO<A> monad for functional side effects
645
+ - Lazy execution of effects
646
+ - Composable IO operations
647
+ - Integration with Task for async IO
648
+
649
+ ### Low Priority
650
+
651
+ - [x] Complete Tuple Implementation
652
+ - ✓ Add Foldable for tuple operations
653
+ - ✓ Add Pipe interface for composition
654
+ - ✓ Add Serializable for persistence
655
+ - ✓ Add Companion pattern with utility methods
656
+ - ✓ Added specialized pair() and triple() constructors
657
+ - [ ] Implement Lens<S, A> for immutable updates
658
+ - Composable property access
659
+ - Type-safe nested updates
660
+ - Works with all functype data structures
661
+ - [ ] Add Reader/State monads for dependency injection and state management
662
+
663
+ ### Completed Functionality
664
+
665
+ - [x] Add lazy evaluation structures (LazyList implemented, needs interface completion)
585
666
  - [x] Add a proper Foldable type class interface
586
667
  - [x] Implement Matchable type class for pattern matching
587
- - [ ] Implement Applicative and other functional type classes
668
+ - [x] Implement Applicative and other functional type classes (for most types)
588
669
 
589
670
  ### Performance Optimizations
590
671
 
@@ -1,4 +1,4 @@
1
- import { T as Type, a as Typeable } from './Typeable-BBXrKPTY.js';
1
+ import { T as Type, a as Typeable, S as Serializable, F as Foldable, P as Pipe } from './Serializable-D9GKEo30.js';
2
2
 
3
3
  /**
4
4
  * Creates a Some variant of Option containing a value.
@@ -348,33 +348,6 @@ interface Extractable<T extends Type> {
348
348
  orUndefined(): T | undefined;
349
349
  }
350
350
 
351
- /**
352
- * Foldable type class represents data structures that can be folded to a summary value.
353
- *
354
- * @typeParam A - The type of elements in the data structure
355
- */
356
- interface Foldable<A> {
357
- /**
358
- * Pattern matches over the structure, applying specific handlers for each variant
359
- * @param onEmpty - Function to apply if the structure is empty or has no value
360
- * @param onValue - Function to apply if the structure has a value
361
- * @returns The result of applying the appropriate function
362
- */
363
- fold<B>(onEmpty: () => B, onValue: (value: A) => B): B;
364
- /**
365
- * Left-associative fold using the provided zero value and operation
366
- * @param z - Zero/identity value
367
- * @returns A function that takes an operation to apply
368
- */
369
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
370
- /**
371
- * Right-associative fold using the provided zero value and operation
372
- * @param z - Zero/identity value
373
- * @returns A function that takes an operation to apply
374
- */
375
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
376
- }
377
-
378
351
  /**
379
352
  * Pattern matching interface for functional data types.
380
353
  *
@@ -414,32 +387,6 @@ declare const MatchableUtils: {
414
387
  when: <A, R>(predicate: (value: A) => boolean, handler: (value: A) => R) => (value: A) => R | undefined;
415
388
  };
416
389
 
417
- /**
418
- * Pipe interface for functional data structures
419
- * @typeParam T - The type of value to pipe
420
- */
421
- interface Pipe<T extends Type> {
422
- /**
423
- * Pipes the value through the provided function
424
- * @param f - The function to apply to the value
425
- * @returns The result of applying the function to the value
426
- * @typeParam U - The return type of the function
427
- */
428
- pipe<U extends Type>(f: (value: T) => U): U;
429
- }
430
-
431
- /**
432
- * Methods for different serialization formats
433
- */
434
- interface SerializationMethods<T> {
435
- toJSON(): string;
436
- toYAML(): string;
437
- toBinary(): string;
438
- }
439
- interface Serializable<T> {
440
- serialize(): SerializationMethods<T>;
441
- }
442
-
443
390
  /**
444
391
  * Universal operations that work on any container (single-value or collection).
445
392
  * These operations make sense for Option, Either, Try, List, Set, etc.
@@ -706,4 +653,4 @@ declare const Either: {
706
653
  fromBinary: <L extends Type, R extends Type>(binary: string) => Either<L, R>;
707
654
  };
708
655
 
709
- export { type Applicative as A, type Collection as C, Either as E, type Foldable as F, List as L, type Matchable as M, None as N, Option as O, type Pipe as P, Right as R, type Serializable as S, type Traversable as T, type FunctypeBase as a, type Extractable as b, type TestEither as c, Left as d, isLeft as e, TypeCheckRight as f, TypeCheckLeft as g, tryCatchAsync as h, isRight as i, type Functype as j, type FunctypeCollection as k, MatchableUtils as l, Some as m, OptionConstructor as n, type SerializationMethods as o, Set as p, type CollectionOps as q, type ContainerOps as r, type AsyncMonad as s, tryCatch as t, type Functor as u, type Monad as v };
656
+ export { type Applicative as A, type Collection as C, Either as E, type FunctypeBase as F, List as L, type Matchable as M, None as N, Option as O, Right as R, Some as S, type Traversable as T, type Extractable as a, type TestEither as b, Left as c, isLeft as d, TypeCheckRight as e, TypeCheckLeft as f, tryCatchAsync as g, type Functype as h, isRight as i, type FunctypeCollection as j, MatchableUtils as k, OptionConstructor as l, Set as m, type CollectionOps as n, type ContainerOps as o, type AsyncMonad as p, type Functor as q, type Monad as r, tryCatch as t };
@@ -0,0 +1,67 @@
1
+ type Type = unknown;
2
+
3
+ type TypeableParams<Tag extends string, T> = {
4
+ _tag: Tag;
5
+ impl: T;
6
+ };
7
+ type ExtractTag<T> = T extends Typeable<infer Tag, unknown> ? Tag : never;
8
+ type Typeable<Tag extends string, T = object> = T & {
9
+ readonly _tag: Tag;
10
+ };
11
+ declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
12
+ declare function isTypeable<T>(value: unknown, tag: string): value is T;
13
+
14
+ /**
15
+ * Foldable type class represents data structures that can be folded to a summary value.
16
+ *
17
+ * @typeParam A - The type of elements in the data structure
18
+ */
19
+ interface Foldable<A> {
20
+ /**
21
+ * Pattern matches over the structure, applying specific handlers for each variant
22
+ * @param onEmpty - Function to apply if the structure is empty or has no value
23
+ * @param onValue - Function to apply if the structure has a value
24
+ * @returns The result of applying the appropriate function
25
+ */
26
+ fold<B>(onEmpty: () => B, onValue: (value: A) => B): B;
27
+ /**
28
+ * Left-associative fold using the provided zero value and operation
29
+ * @param z - Zero/identity value
30
+ * @returns A function that takes an operation to apply
31
+ */
32
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
33
+ /**
34
+ * Right-associative fold using the provided zero value and operation
35
+ * @param z - Zero/identity value
36
+ * @returns A function that takes an operation to apply
37
+ */
38
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
39
+ }
40
+
41
+ /**
42
+ * Pipe interface for functional data structures
43
+ * @typeParam T - The type of value to pipe
44
+ */
45
+ interface Pipe<T extends Type> {
46
+ /**
47
+ * Pipes the value through the provided function
48
+ * @param f - The function to apply to the value
49
+ * @returns The result of applying the function to the value
50
+ * @typeParam U - The return type of the function
51
+ */
52
+ pipe<U extends Type>(f: (value: T) => U): U;
53
+ }
54
+
55
+ /**
56
+ * Methods for different serialization formats
57
+ */
58
+ interface SerializationMethods<T> {
59
+ toJSON(): string;
60
+ toYAML(): string;
61
+ toBinary(): string;
62
+ }
63
+ interface Serializable<T> {
64
+ serialize(): SerializationMethods<T>;
65
+ }
66
+
67
+ export { type ExtractTag as E, type Foldable as F, type Pipe as P, type Serializable as S, type Type as T, Typeable as a, type SerializationMethods as b, type TypeableParams as c, isTypeable as i };
@@ -7,11 +7,14 @@ type ExtractBrand<T> = T extends Brand<infer K, unknown> ? K : never;
7
7
  */
8
8
  type Brand<K extends string, T> = T & {
9
9
  readonly __brand: K;
10
+ readonly unbrand: () => T;
11
+ readonly unwrap: () => T;
10
12
  };
11
13
  /**
12
- * Helper to create a branded type
14
+ * Helper to create a branded type with instance methods
15
+ * @param brand - The brand name
13
16
  * @param value - The value to brand
14
- * @returns The branded value
17
+ * @returns The branded value with unbrand/unwrap methods
15
18
  */
16
19
  declare function Brand<K extends string, T>(brand: K, value: T): Brand<K, T>;
17
20
  /**
@@ -1,2 +1,2 @@
1
- export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
1
+ export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'../chunk-V6LFV5LW.mjs';//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,43 @@
1
+ import {a,b as b$1}from'./chunk-BQJB6CCW.mjs';import {a as a$1}from'./chunk-V6LFV5LW.mjs';import se from'safe-stable-stringify';var J=Set;var P=t=>{let e=new J(t),r={_tag:"Set",[Symbol.iterator]:()=>e[Symbol.iterator](),add:n=>P([...e,n]),remove:n=>{let o=new J(e);return o.delete(n),P(o)},contains:n=>e.has(n),has:n=>e.has(n),map:n=>P(Array.from(e).map(n)),ap:n=>{let o=new J;for(let a of e)for(let s of n)o.add(s(a));return P(o)},flatMap:n=>{let o=new J;for(let a of e)for(let s of n(a))o.add(s);return P(o)},flatMapAsync:async n=>{let o=new J;for(let a of e){let s=await n(a);for(let i of s)o.add(i);}return P(o)},fold:(n,o)=>{if(e.size===0)return n();let a=Array.from(e);if(a.length===0)return n();let s=a[0];return s===void 0?n():o(s)},foldLeft:n=>o=>{let a=n;for(let s of e)a=o(a,s);return a},foldRight:n=>o=>Array.from(e).reduceRight((s,i)=>o(i,s),n),get size(){return e.size},get isEmpty(){return e.size===0},reduce:n=>{let o=Array.from(e);if(o.length===0)throw new Error("Cannot reduce empty Set");return o.reduce(n)},reduceRight:n=>{let o=Array.from(e);if(o.length===0)throw new Error("Cannot reduceRight empty Set");return o.reduceRight(n)},count:n=>{let o=0;for(let a of e)n(a)&&o++;return o},find:n=>{for(let o of e)if(n(o))return f(o);return f(null)},exists:n=>{for(let o of e)if(n(o))return true;return false},forEach:n=>{e.forEach(n);},filter:n=>{let o=new J;for(let a of e)n(a)&&o.add(a);return P(o)},filterNot:n=>{let o=new J;for(let a of e)n(a)||o.add(a);return P(o)},drop:n=>P(Array.from(e).slice(n)),dropRight:n=>P(Array.from(e).slice(0,-n)),dropWhile:n=>{let o=Array.from(e),a=o.findIndex(s=>!n(s));return P(a===-1?[]:o.slice(a))},flatten:()=>{let n=new J;for(let o of e)if(Array.isArray(o))for(let a of o)n.add(a);else if(o&&typeof o=="object"&&Symbol.iterator in o)for(let a of o)n.add(a);else n.add(o);return P(n)},get head(){return Array.from(e)[0]},get headOption(){let n=Array.from(e)[0];return f(n)},toList:()=>m(Array.from(e)),toSet:()=>r,toArray:()=>Array.from(e),toString:()=>`Set(${Array.from(e).toString()})`,toValue:()=>({_tag:"Set",value:Array.from(e)}),pipe:n=>n(Array.from(e)),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Set",value:Array.from(e)}),toYAML:()=>`_tag: Set
2
+ value: ${JSON.stringify(Array.from(e))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Set",value:Array.from(e)})).toString("base64")})};return r},qe=t=>P(t),we={fromJSON:t=>{let e=JSON.parse(t);return Q(e.value)},fromYAML:t=>{let r=t.split(`
3
+ `)[1]?.split(": ")[1];if(!r)return Q([]);let n=JSON.parse(r);return Q(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return we.fromJSON(e)}},Q=a(qe,we);function ce({_tag:t,impl:e}){return {...e,_tag:t}}function ye(t,e){return !t||typeof t!="object"||!("_tag"in t)?false:e?t._tag===e:true}var U=t=>{let e=Array.from(t||[]),r={_tag:"List",[Symbol.iterator]:()=>e[Symbol.iterator](),get size(){return e.length},get length(){return e.length},map:n=>U(e.map(n)),ap:n=>U(e.flatMap(o=>Array.from(n).map(a=>a(o)))),flatMap:n=>U(e.flatMap(o=>Array.from(n(o)))),flatMapAsync:async n=>{let o=await Promise.all(e.map(async a=>await n(a)));return U(o.flatMap(a=>Array.from(a)))},forEach:n=>e.forEach(n),contains:n=>e.includes(n),count:n=>e.filter(n).length,exists:n=>e.some(n),filter:n=>U(e.filter(n)),filterNot:n=>U(e.filter(o=>!n(o))),filterType:n=>U(e.filter(o=>ye(o,n))),find:(n,o)=>{let a=e.find(s=>n(s)&&(o?ye(s,o):true));return f(a)},get head(){return e[0]},get headOption(){return e.length>0?f(e[0]):b()},get isEmpty(){return e.length===0},toArray:()=>[...e],reduce:n=>e.reduce(n),reduceRight:n=>e.reduceRight(n),fold:(n,o)=>{if(e.length===0)return n();let a=e[0];return o(a)},foldLeft:n=>o=>e.reduce(o,n),foldRight:n=>o=>e.reduceRight((a,s)=>o(s,a),n),match:n=>e.length===0?n.Empty():n.NonEmpty([...e]),remove:n=>U(e.filter(o=>o!==n)),removeAt:n=>n<0||n>=e.length?r:U([...e.slice(0,n),...e.slice(n+1)]),add:n=>U([...e,n]),get:n=>f(e[n]),concat:n=>U([...e,...n.toArray()]),drop:n=>U(e.slice(n)),dropRight:n=>U(e.slice(0,-n)),dropWhile:n=>U(e.slice(e.findIndex(o=>!n(o)))),flatten:()=>U(e.flatMap(n=>Array.isArray(n)?n:[n])),toList:()=>r,toSet:()=>Q(e),toString:()=>`List(${se(e)})`,toValue:()=>({_tag:"List",value:e}),pipe:n=>n([...e]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"List",value:e}),toYAML:()=>`_tag: List
4
+ value: ${se(e)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"List",value:e})).toString("base64")})};return r},Ye=t=>U(t),Se={fromJSON:t=>{let e=JSON.parse(t);return m(e.value)},fromYAML:t=>{let r=t.split(`
5
+ `)[1]?.split(": ")[1];if(!r)return m([]);let n=JSON.parse(r);return m(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Se.fromJSON(e)}},m=a(Ye,Se);var Be=t=>({_tag:"Right",value:t,isLeft:()=>false,isRight:()=>true,get:()=>t,getOrElse:e=>t,getOrThrow:()=>t,orElse:e=>c(t),orNull:()=>t,orUndefined:()=>t,map:e=>c(e(t)),ap:e=>e._tag==="Right"?c(e.value(t)):p(e.value),mapAsync:e=>e(t).then(r=>c(r)).catch(r=>Promise.resolve(p(r))),merge:e=>e.isLeft()?p(e.value):c([t,e.value]),flatMap:e=>e(t),flatMapAsync:e=>e(t).catch(r=>p(r)),toOption:()=>w(t),toList:()=>m([t]),toJSON:function(){return {_tag:"Right",value:t}},toString:()=>`Right(${se(t)})`,[Symbol.iterator]:function*(){yield t;},yield:function*(){yield t;},traverse:e=>{let r=e(t);return r.isLeft()?p(r.value):c([r.value])},lazyMap:function*(e){yield c(e(t));},tap:e=>(e(t),c(t)),tapLeft:e=>c(t),mapLeft:e=>c(t),bimap:(e,r)=>c(r(t)),fold:(e,r)=>r(t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),match:e=>e.Right(t),swap:()=>p(t),then:(e,r)=>Promise.resolve(t).then(e,r),toValue:()=>({_tag:"Right",value:t}),pipeEither:(e,r)=>r(t),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Right",value:t}),toYAML:()=>`_tag: Right
6
+ value: ${se(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Right",value:t})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?w(t):b(),exists:e=>e(t),forEach:e=>e(t)}),Oe=t=>({_tag:"Left",value:t,isLeft:()=>true,isRight:()=>false,get:()=>{throw new Error(`Cannot call get() on Left(${se(t)})`)},getOrElse:e=>e,getOrThrow:e=>{throw e||t},orElse:e=>e,orNull:()=>null,orUndefined:()=>{},map:e=>p(t),ap:e=>p(t),mapAsync:e=>Promise.resolve(p(t)),merge:e=>p(t),flatMap:e=>p(t),flatMapAsync:e=>Promise.resolve(p(t)),toOption:()=>b(),toList:()=>m(),toJSON:function(){return {_tag:"Left",value:t}},toString:()=>`Left(${se(t)})`,[Symbol.iterator]:function*(){},yield:function*(){},traverse:e=>p(t),lazyMap:function*(e){yield p(t);},tap:e=>p(t),tapLeft:e=>(e(t),p(t)),mapLeft:e=>p(e(t)),bimap:(e,r)=>p(e(t)),fold:(e,r)=>e(t),foldLeft:e=>r=>e,foldRight:e=>r=>e,match:e=>e.Left(t),swap:()=>c(t),then:(e,r)=>Promise.reject(t).then(null,r),toValue:()=>({_tag:"Left",value:t}),pipeEither:(e,r)=>e(t),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Left",value:t}),toYAML:()=>`_tag: Left
7
+ value: ${se(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Left",value:t})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:e=>false,reduce:e=>{throw new Error("Cannot reduce a Left")},reduceRight:e=>{throw new Error("Cannot reduceRight a Left")},count:e=>0,find:e=>b(),exists:e=>false,forEach:e=>{}}),c=t=>Be(t),p=t=>Oe(t),_t=t=>t.isRight(),It=t=>t.isLeft(),Mt=(t,e)=>{try{return c(t())}catch(r){return p(e(r))}},Qe=t=>Be(t);console.assert(Qe);var He=t=>Oe(t);console.assert(He);var zt=async(t,e)=>{try{let r=await t();return c(r)}catch(r){return p(e(r))}},ve={sequence:t=>{let e=[];for(let r of t){if(r.isLeft())return p(r.value);e.push(r.value);}return c(e)},traverse:(t,e)=>ve.sequence(t.map(e)),fromNullable:(t,e)=>t==null?p(e):c(t),fromPredicate:(t,e,r)=>e(t)?c(t):p(r),ap:(t,e)=>t.flatMap(r=>e.map(r)),fromPromise:async(t,e)=>{try{let r=await t;return c(r)}catch(r){return p(e(r))}},fromJSON:t=>{let e=JSON.parse(t);return e._tag==="Right"?c(e.value):p(e.value)},fromYAML:t=>{let e=t.split(`
8
+ `),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)throw new Error("Invalid YAML format for Either");let o=JSON.parse(n);return r==="Right"?c(o):p(o)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return ve.fromJSON(e)}};function I(t,e){return {brand:t,validate:e,of:r=>e(r)?f(a$1(t,r)):f.none(),from:r=>e(r)?c(a$1(t,r)):p(`Invalid ${t}: validation failed`),unsafeOf:r=>{if(!e(r))throw new Error(`Invalid ${t}: validation failed`);return a$1(t,r)},is:r=>{try{return e(r)}catch{return false}},refine:(r,n)=>I(r,o=>e(o.unbrand())&&n(o))}}var Ge=I("PositiveNumber",t=>t>0),Dt=I("NonNegativeNumber",t=>t>=0),Jt=I("IntegerNumber",t=>Number.isInteger(t)),Wt=Ge.refine("PositiveInteger",t=>Number.isInteger(t)),jt=I("NonEmptyString",t=>t.length>0),qt=I("EmailAddress",t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)),Yt=I("UrlString",t=>{try{return new URL(t),!0}catch{return !1}}),Qt=I("UUID",t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)),Ht=I("ISO8601Date",t=>!isNaN(Date.parse(t))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(t));function Gt(t,e,r){return I(t,n=>n>=e&&n<=r)}function Zt(t,e,r){return I(t,n=>n.length>=e&&n.length<=r)}function Xt(t,e){return I(t,r=>e.test(r))}var me=t=>{let e=n=>typeof n=="function"?n():n,r={when:(n,o)=>t.resolved?r:n?me({resolved:true,value:e(o)}):r,elseWhen:(n,o)=>t.resolved?r:n?me({resolved:true,value:e(o)}):r,else:n=>t.resolved?t.value:e(n),getOrThrow:()=>{if(!t.resolved)throw new Error("Conditional expression has no matching condition");return t.value}};return r},Pe=()=>me({resolved:false}),Ze={of:()=>Pe(),match:t=>e=>{let r=e[t];if(r===void 0)throw new Error(`No case defined for value: ${String(t)}`);return typeof r=="function"?r():r},lazy:()=>{let t={resolved:false},e={when:(r,n)=>(t.resolved||r()&&(t.resolved=true,t.value=n()),e),elseWhen:(r,n)=>(t.resolved||r()&&(t.resolved=true,t.value=n()),e),else:r=>t.resolved?t.value:r()};return e}},rr=a(Pe,Ze);var ee=(t,e)=>e===t?true:typeof e=="function"?e(t):e&&typeof e=="object"&&"_"in e?e._(t):typeof e=="object"&&e!==null&&typeof t=="object"&&t!==null?Object.entries(e).every(([r,n])=>{let o=t[r];return ee(o,n)}):false,H=t=>{let e=(o,a)=>typeof o=="function"?o(a):o,r=()=>{for(let{pattern:o,result:a}of t.patterns)if(ee(t.value,o))return {matched:true,result:e(a,t.value)};return {matched:false}},n={case:(o,a)=>{if(t.resolved)return n;let s={...t,patterns:[...t.patterns,{pattern:o,result:a}]};return ee(t.value,o)?H({...s,resolved:true,result:e(a,t.value)}):H(s)},caseValue:(o,a)=>{if(t.resolved)return n;if(t.value===o){let s=typeof a=="function"?a():a;return H({...t,resolved:true,result:s})}return n},caseValues:(o,a)=>{if(t.resolved)return n;if(o.includes(t.value)){let s=typeof a=="function"?a():a;return H({...t,resolved:true,result:s})}return n},when:(o,a)=>n.case(o,a),caseAny:(o,a)=>{if(t.resolved)return n;for(let s of o)if(ee(t.value,s))return H({...t,resolved:true,result:e(a,t.value),patterns:[...t.patterns,{pattern:s,result:a}]});return H({...t,patterns:[...t.patterns,...o.map(s=>({pattern:s,result:a}))]})},default:o=>t.resolved?t.result:e(o,t.value),exhaustive:()=>{let o=r();if(!o.matched)throw new Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(t.value)}`);return o.result},getOrThrow:o=>{let a=r();if(!a.matched)throw new Error(o||`No matching pattern for value: ${JSON.stringify(t.value)}`);return a.result},toOption:()=>{let o=r();return o.matched?f(o.result):f.none()}};return n},Xe=t=>H({value:t,resolved:false,patterns:[]}),et={exhaustive:t=>e=>{let r=t[e];if(r===void 0)throw new Error(`No case defined for value: ${String(e)}`);return r},partial:t=>({withDefault:e=>r=>{let n=t[r];return n!==void 0?typeof n=="function"?n(r):n:typeof e=="function"?e(r):e}}),withGuards:t=>({withDefault:e=>r=>{for(let[n,o]of t)if(n(r))return typeof o=="function"?o(r):o;return typeof e=="function"?e(r):e}}),struct:()=>{let t=[],e={case:(r,n)=>(t.push({pattern:r,handler:n}),e),build:()=>r=>{for(let{pattern:n,handler:o}of t)if(ee(r,n))return o(r);throw new Error(`No matching pattern for value: ${JSON.stringify(r)}`)}};return e},builder:()=>{let t=[],e,r={case:(n,o)=>(t.push({pattern:n,result:o}),r),when:(n,o)=>(t.push({pattern:n,result:o}),r),default:n=>(e=n,{build:()=>o=>{for(let{pattern:a,result:s}of t)if(ee(o,a))return typeof s=="function"?s(o):s;if(e!==void 0)return typeof e=="function"?e(o):e;throw new Error(`No matching pattern for value: ${JSON.stringify(o)}`)}})};return r}},sr=a(Xe,et);function te(t,e){return {...ce({_tag:t,impl:e}),toString(){return `${t}()`}}}var Te="Throwable",L=class t extends Error{constructor(r,n){super(r,{cause:n?.cause});this._tag=Te;this.name=n?.taskInfo?.name||Te,Object.defineProperties(this,{_tag:{value:Te,writable:false,configurable:false},data:{value:n?.data,writable:false,configurable:false},taskInfo:{value:n?.taskInfo,writable:false,configurable:false},name:{value:n?.taskInfo?.name||Te,writable:false,configurable:false}}),n?.cause&&Object.defineProperty(this,"cause",{value:n.cause,writable:false,configurable:false}),n?.stack?this.stack=n.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}static apply(r,n,o){if(r instanceof Error){let u=new t(r.message,{data:n,cause:r.cause||void 0,stack:r.stack||void 0,taskInfo:o});for(let l of Object.keys(r))l in u||(u[l]=r[l]);return u}if(r&&typeof r=="object"){let u=r,l=typeof u.message=="string"?u.message:typeof u.error=="string"?u.error:`Object error: ${JSON.stringify(u,Object.getOwnPropertyNames(u).filter(g=>u[g]!==void 0))}`,E=new t(l,{data:n||u,taskInfo:o});for(let g of Object.keys(u))g in E||(E[g]=u[g]);return E}if(typeof r=="function"){let u=r.name||"anonymous function",l=r.toString().substring(0,100)+(r.toString().length>100?"...":"");return new t(`Function error: ${u}`,{data:n||{functionType:typeof r,functionName:u,functionString:l},taskInfo:o})}let a=typeof r,s=r===null?"null":r===void 0?"undefined":String(r);if(a==="number"){let u=r,l=Number.isNaN(u)?"Number error: NaN":Number.isFinite(u)?`Number error: ${u}`:`Number error: ${u>0?"Infinity":"-Infinity"}`;return new t(l,{data:n||{errorType:a,errorValue:u,originalError:r},taskInfo:o})}if(a==="bigint")return new t(`BigInt error: ${r}n`,{data:n||{errorType:a,errorValue:String(r),originalError:r},taskInfo:o});if(a==="boolean")return new t(`Boolean error: ${r}`,{data:n||{errorType:a,errorValue:r,originalError:r},taskInfo:o});if(a==="symbol"){let u=r.description||"unnamed symbol";return new t(`Symbol error: Symbol(${u})`,{data:n||{errorType:a,symbolDescription:u,originalError:r},taskInfo:o})}let i=typeof r=="string"?r:`${a.charAt(0).toUpperCase()+a.slice(1)} error: ${s}`;return new t(i,{data:n||{errorType:a,errorValue:s,originalError:r},taskInfo:o})}};var R=t=>{let e=new Promise((r,n)=>{try{t(r,n);}catch(o){n(o);}});return {_tag:"FPromise",map:r=>R((n,o)=>{e.then(a=>{try{n(r(a));}catch(s){o(s);}}).catch(o);}),flatMap:r=>R((n,o)=>{e.then(a=>{try{let s=r(a);"_tag"in s&&s._tag==="FPromise"?s.then(n,o):Promise.resolve(s).then(n,o);}catch(s){o(s);}}).catch(o);}),flatMapAsync:async r=>{let n=await e,o=r(n);return o instanceof Promise?o:new Promise((a,s)=>{o.then(a,s);})},tap:r=>R((n,o)=>{e.then(a=>{try{r(a),n(a);}catch(s){o(s);}}).catch(o);}),mapError:r=>R((n,o)=>{e.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};o(r(a,s));}catch(s){o(s);}});}),tapError:r=>R((n,o)=>{e.then(n).catch(a=>{try{r(a),o(a);}catch(s){o(s);}});}),recover:r=>R(n=>{e.then(n).catch(()=>n(r));}),recoverWith:r=>R(n=>{e.then(n).catch(o=>{try{n(r(o));}catch{n(null);}});}),recoverWithF:r=>R((n,o)=>{e.then(n).catch(a=>{try{r(a).then(n,o);}catch(s){o(s);}});}),filterError:(r,n)=>R((o,a)=>{e.then(o).catch(s=>{if(r(s))try{n(s).then(o,a);}catch(i){a(i);}else a(s);});}),logError:r=>R((n,o)=>{e.then(n).catch(a=>{try{let s={originalError:a,stack:a instanceof Error?a.stack:void 0,timestamp:Date.now()};r(a,s);}catch{}finally{o(a);}});}),then:(r,n)=>e.then(r,n),toPromise:()=>e,toEither:()=>e,fold:(r,n)=>R((o,a)=>{e.then(s=>{try{o(n(s));}catch(i){a(i);}}).catch(s=>{try{o(r(s));}catch(i){a(i);}});})}},tt={resolve:t=>R(e=>e(t)),reject:t=>R((e,r)=>r(t)),from:t=>R((e,r)=>{t.then(e).catch(r);}),fromEither:t=>t.isRight()?R(e=>e(t.value)):R((e,r)=>r(t.value)),all:t=>R((e,r)=>{Promise.all(t.map(n=>n instanceof Promise?n:Promise.resolve(n))).then(e).catch(r);}),allSettled:t=>R(e=>{let r=[],n=0;if(t.length===0){e([]);return}t.forEach((o,a)=>{Promise.resolve(o).then(s=>{r[a]=c(s),n++,n===t.length&&e(r);}).catch(s=>{r[a]=p(s),n++,n===t.length&&e(r);});});}),race:t=>R((e,r)=>{Promise.race(t).then(e,r);}),any:t=>R((e,r)=>{if(typeof Promise.any=="function")Promise.any(t).then(e,r);else {let n=0,o=[];if(t.length===0){r(new AggregateError([],"All promises were rejected"));return}t.forEach((a,s)=>{Promise.resolve(a).then(e).catch(i=>{o[s]=i,n++,n===t.length&&r(new AggregateError(o,"All promises were rejected"));});});}}),retryWithBackoff:(t,e)=>{let{maxRetries:r,baseDelay:n=100,shouldRetry:o=()=>true}=e;return R((a,s)=>{let i=0,u=()=>{t().toPromise().then(a).catch(l=>{if(i++,i<=r&&o(l,i)){let E=n*Math.pow(2,i-1);setTimeout(u,E);}else s(l);});};u();})}},ge=a(R,tt);function rt(t){return t instanceof Error&&typeof t=="object"&&true&&t._tag==="Throwable"}var Ne=(t,e,r)=>{let n=r?.name||"TaskException",o=r?.description||"Unspecified TaskException",a={name:n,description:o},s=L.apply(t,e,a);return {...te("TaskException",p(s)),_task:a}},_e=(t,e)=>{let r=e?.name||"TaskResult",n=e?.description||"Unspecified TaskResult";return {...te("TaskResult",c(t)),_task:{name:r,description:n}}},Ee=()=>{let t=new AbortController,e=[];return {token:{get isCancelled(){return t.signal.aborted},get signal(){return t.signal},onCancel(n){t.signal.aborted?n():e.push(n);}},cancel(){t.signal.aborted||(t.abort(),e.forEach(n=>{try{n();}catch(o){console.error("Error in cancellation callback:",o);}}));}}},nt=t=>{let e=t?.name||"Task",r=t?.description||"",n={Async:(o,a=u=>u,s=()=>{},i)=>ge(async(u,l)=>{let E=false,g=null,F=()=>{};if(i){if(i.isCancelled){try{await s();}catch(A){l(L.apply(A,void 0,{name:e,description:r}));return}l(L.apply(new Error("Task was cancelled before execution started"),void 0,{name:e,description:r}));return}let v=()=>{E=true,g=new Error("Task was cancelled during execution");};i.onCancel(v),F=()=>{};}try{let v=await o();if(E){try{await s();}catch(A){l(L.apply(A,void 0,{name:e,description:r}));return}l(g?L.apply(g,void 0,{name:e,description:r}):L.apply(new Error("Task was cancelled during execution"),void 0,{name:e,description:r}));return}try{await s();}catch(A){l(L.apply(A,void 0,{name:e,description:r}));return}u(v);}catch(v){if(E){try{await s();}catch(A){l(L.apply(A,void 0,{name:e,description:r}));return}l(g?L.apply(g,void 0,{name:e,description:r}):L.apply(new Error("Task was cancelled during execution"),void 0,{name:e,description:r}));return}try{await s();}catch(A){l(L.apply(A,void 0,{name:e,description:r}));return}try{if(v instanceof Error&&rt(v)){let A=new Error(`${e}: ${v.message}`),G=L.apply(A,void 0,{name:e,description:r});Object.defineProperty(G,"cause",{value:v,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{a(v);}catch(j){console.error("Error in error handler:",j);}}),l(G);}else {let A=await a(v);l(L.apply(A,void 0,{name:e,description:r}));}}catch(A){l(L.apply(A,void 0,{name:e,description:r}));}}finally{F();}}),Sync:(o,a=i=>i,s=()=>{})=>{try{return _e(o(),{name:e,description:r})}catch(i){return Ne(a(i),void 0,{name:e,description:r})}finally{s();}},AsyncWithProgress:(o,a,s=l=>l,i=()=>{},u)=>{let l=E=>{let g=Math.max(0,Math.min(100,E));g<=100&&a(g);};return n.Async(()=>o(l),s,i,u)}};return {...te("Task",n),_type:"Task"}},Ie={success:(t,e)=>_e(t,e),fail:(t,e,r)=>Ne(t,e,r),getErrorChain:t=>{if(!t)return [];let e=[t],r=t;for(;r&&r.cause;){let n=r.cause;if(n)e.push(n),r=n;else break;if(e.length>100)break}return e},formatErrorChain:(t,e)=>{let r=Ie.getErrorChain(t),n=e?.separator||`
9
+ `;return r.map((o,a)=>{if(!o)return `${a>0?"\u21B3 ":""}Unknown error`;let s=o.taskInfo,i=e?.includeTasks&&s?.name?`[${s.name}] `:"",u=o.message||"No message",l=`${a>0?"\u21B3 ":""}${i}${u}`;return e?.includeStackTrace&&o.stack&&(l+=`
10
+ ${o.stack.split(`
11
+ `).slice(1).join(`
12
+ `)}`),l}).join(n)},fromPromise:(t,e)=>(...r)=>V(e||{name:"PromiseTask",description:"Task from Promise"}).Async(()=>t(...r),o=>o),toPromise:t=>new Promise((e,r)=>{t.isRight()?e(t.value):r(t.value);}),race:(t,e,r)=>{let n=r?.name||"TaskRace",o=r?.description||"Race between multiple tasks";return V({name:n,description:o}).Async(async()=>{let s=[...t],i;if(typeof e=="number"&&e>0){let u=ge((l,E)=>{i=setTimeout(()=>{E(new Error(`Task race timed out after ${e}ms`));},e);});s.push(u);}try{return await new Promise((u,l)=>{s.forEach(E=>{E.then(g=>u(g),g=>l(g));});})}finally{i&&clearTimeout(i);}},s=>s)},fromNodeCallback:(t,e)=>{let r=e?.name||"NodeCallbackTask",n=e?.description||"Task from Node.js callback function",o={name:r,description:n};return (...a)=>V(o).Async(()=>new Promise((s,i)=>{try{t(...a,(u,l)=>{u?i(u):s(l);});}catch(u){i(u);}}),s=>s)},createCancellationTokenSource:Ee,cancellable:(t,e)=>{let r=Ee();return {task:V(e).Async(()=>t(r.token),o=>o,()=>{},r.token),cancel:()=>r.cancel()}},withProgress:(t,e=()=>{},r)=>{let n=Ee(),o=0,a=i=>{o=Math.max(0,Math.min(100,i)),e(o);};return {task:V(r).Async(()=>t(a,n.token),i=>i,()=>{},n.token),cancel:()=>n.cancel(),currentProgress:()=>o}}},V=a(nt,Ie);var Me={includeTasks:true,includeStackTrace:false,separator:`
13
+ `,includeData:false,maxStackFrames:3,title:"Error",colors:false};function ze(t){let e=new WeakSet;return JSON.stringify(t,(r,n)=>{if(typeof n=="bigint")return n.toString()+"n";if(typeof n=="object"&&n!==null){if(e.has(n))return "[Circular Reference]";e.add(n);}return r==="stack"&&typeof n=="string"?fe(n):n},2)}function fe(t){if(!t)return "";if(!t)return t;let e=t.split(`
14
+ `),r=e[0],n=e.slice(1).map(o=>o.trim());return [r,...n].join(`
15
+ `)}function br(t,e){let r={...Me,...e},n=t instanceof Error?t:L.apply(t),o=V?.getErrorChain?V.getErrorChain(n):[n],a=r.colors?`\x1B[31m${r.title}:\x1B[0m ${n.message}`:`${r.title}: ${n.message}`,s=o.map((u,l)=>{let E=" ".repeat(l),g=l>0?"\u21B3 ":"",F=u.taskInfo,v=r.includeTasks&&F?.name?r.colors?`\x1B[36m[${F.name}]\x1B[0m `:`[${F.name}] `:"",A=`${E}${g}${v}${u.message}`;if(r.includeStackTrace&&u.stack){let j=fe(u.stack).split(`
16
+ `).slice(1),Z=r.maxStackFrames??Me.maxStackFrames??3,ue=j.slice(0,Z).map(le=>`${E} ${r.colors?"\x1B[90m":""}${le}${r.colors?"\x1B[0m":""}`).join(`
17
+ `);A+=`
18
+ ${ue}`,j.length>Z&&(A+=`
19
+ ${E} ${r.colors?"\x1B[90m":""}...${j.length-Z} more stack frames${r.colors?"\x1B[0m":""}`);}return A}).join(r.separator),i=`${a}
20
+
21
+ ${s}`;if(r.includeData){let u=n.data;if(u){let l=r.colors?`
22
+
23
+ \x1B[33mContext:\x1B[0m
24
+ ${ze(u)}`:`
25
+
26
+ Context:
27
+ ${ze(u)}`;i+=l;}}return i}function kr(){return function(e){if(!e)return e;let r=e instanceof Error?e:new Error(String(e)),n={message:r.message,name:r.name||"Error",stack:r.stack?fe(r.stack):void 0};if(r.taskInfo&&(n.taskInfo=r.taskInfo),r.data&&(n.data=r.data),typeof V?.getErrorChain=="function")try{let o=V.getErrorChain(r);o.length>1&&(n.errorChain=V.formatErrorChain(r,{includeTasks:!0}),n.structuredErrorChain=o.map(a=>({message:a.message,name:a.name,taskInfo:a.taskInfo,stack:a.stack?fe(a.stack):void 0})));}catch{}return Object.getOwnPropertyNames(r).forEach(o=>{if(!n[o]){let a=r[o];n[o]=a;}}),n}}var Ur=t=>{let e=new Error(t);return e.name="ParseError",e};var C=(t,e,r,n)=>{let o=L.apply(e,r,{name:t,description:e});return Object.assign(o,{code:t,message:e,status:ot(t),context:r,timestamp:new Date().toISOString(),traceId:n?.traceId})},ot=t=>({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})[t],at={validation:(t,e,r)=>C("VALIDATION_FAILED",`Validation failed: ${t} ${r}`,{field:t,value:e,rule:r}),network:(t,e,r)=>C("NETWORK_ERROR",`Network error: ${e} ${t}${r?` (${r})`:""}`,{url:t,method:e,statusCode:r}),auth:(t,e)=>C("AUTH_REQUIRED",`Authentication required: ${t}${e?` (role: ${e})`:""}`,{resource:t,requiredRole:e}),notFound:(t,e)=>C("NOT_FOUND",`Not found: ${t} with id ${e}`,{resource:t,id:e}),permission:(t,e,r)=>C("PERMISSION_DENIED",`Permission denied: cannot ${t} ${e}`,{action:t,resource:e,userId:r}),rateLimit:(t,e,r)=>C("RATE_LIMITED",`Rate limit exceeded: ${t} requests per ${e}`,{limit:t,window:e,retryAfter:r}),internal:t=>C("INTERNAL_ERROR",`Internal server error: ${t}`,{errorId:t,timestamp:new Date().toISOString()}),badRequest:(t,e)=>C("BAD_REQUEST",`Bad request: ${t}`,{reason:t,expected:e}),conflict:(t,e)=>C("CONFLICT",`Conflict: ${t} already exists with value ${e}`,{resource:t,conflictingValue:e}),timeout:(t,e)=>C("TIMEOUT",`Request timeout: ${e} exceeded ${t}ms`,{duration:t,operation:e}),isTypedError:t=>typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&"status"in t&&"context"in t&&"_tag"in t&&t._tag==="Throwable",hasCode:(t,e)=>t.code===e},x=Object.assign(C,at);var k=t=>{let e={_tag:"LazyList",[Symbol.iterator]:()=>t[Symbol.iterator](),map:r=>k(function*(){for(let n of t)yield r(n);}()),flatMap:r=>k(function*(){for(let n of t)yield*r(n);}()),filter:r=>k(function*(){for(let n of t)r(n)&&(yield n);}()),take:r=>k(function*(){let n=0;for(let o of t){if(n>=r)break;yield o,n++;}}()),drop:r=>k(function*(){let n=0;for(let o of t)n>=r&&(yield o),n++;}()),takeWhile:r=>k(function*(){for(let n of t){if(!r(n))break;yield n;}}()),dropWhile:r=>k(function*(){let n=true;for(let o of t)n&&r(o)||(n=false,yield o);}()),concat:r=>k(function*(){yield*t,yield*r;}()),zip:r=>k(function*(){let n=t[Symbol.iterator](),o=r[Symbol.iterator]();for(;;){let a=n.next(),s=o.next();if(a.done||s.done)break;yield [a.value,s.value];}}()),toList:()=>m(Array.from(t)),toArray:()=>Array.from(t),forEach:r=>{for(let n of t)r(n);},reduce:(r,n)=>{let o=n;for(let a of t)o=r(o,a);return o},find:r=>{for(let n of t)if(r(n))return f(n);return f.none()},some:r=>{for(let n of t)if(r(n))return true;return false},every:r=>{for(let n of t)if(!r(n))return false;return true},count:()=>{let r=0;for(let n of t)r++;return r},first:()=>{let n=t[Symbol.iterator]().next();return n.done?f.none():f(n.value)},last:()=>{let r,n=false;for(let o of t)r=o,n=true;return n?f(r):f.none()},fold:(r,n)=>{let a=t[Symbol.iterator]().next();return a.done?r():n(a.value)},foldLeft:r=>n=>{let o=r;for(let a of t)o=n(o,a);return o},foldRight:r=>n=>Array.from(t).reduceRight((a,s)=>n(s,a),r),pipe:r=>r(e),serialize:()=>{let r=Array.from(t);return {toJSON:()=>JSON.stringify({_tag:"LazyList",value:r}),toYAML:()=>`_tag: LazyList
28
+ value: ${se(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"LazyList",value:r})).toString("base64")}},toString:()=>{let n=[],o=0,a=false;for(let i of t)if(o<10)n.push(i),o++;else {a=true;break}let s=n.map(i=>String(i)).join(", ");return a?`LazyList(${s}, ...)`:`LazyList(${s})`}};return e},it=t=>k(t),ut={empty:()=>k([]),of:t=>k([t]),from:(...t)=>k(t),iterate:(t,e)=>k(function*(){let r=t;for(;;)yield r,r=e(r);}()),generate:t=>k(function*(){for(;;)yield t();}()),range:(t,e,r=1)=>k(function*(){if(r===0)throw new Error("Step cannot be zero");if(r>0)for(let n=t;n<e;n+=r)yield n;else for(let n=t;n>e;n+=r)yield n;}()),repeat:(t,e)=>k(function*(){if(e===void 0)for(;;)yield t;else for(let r=0;r<e;r++)yield t;}()),cycle:t=>k(function*(){let e=Array.from(t);if(e.length!==0)for(;;)yield*e;}())},Ir=a(it,ut);var N={rule:t=>e=>{if(t==="email")return typeof e!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?p(x.validation("value",e,"must be a valid email")):c(e);if(t==="url")try{return new URL(String(e)),c(e)}catch{return p(x.validation("value",e,"must be a valid URL"))}if(t==="uuid")return typeof e!="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(e)?p(x.validation("value",e,"must be a valid UUID")):c(e);if(t==="required")return e==null||e===""?p(x.validation("value",e,"is required")):c(e);if(t==="numeric")return typeof e!="number"&&!/^\d+$/.test(String(e))?p(x.validation("value",e,"must be numeric")):c(e);if(t==="alpha")return typeof e!="string"||!/^[a-zA-Z]+$/.test(e)?p(x.validation("value",e,"must contain only letters")):c(e);if(t==="alphanumeric")return typeof e!="string"||!/^[a-zA-Z0-9]+$/.test(e)?p(x.validation("value",e,"must be alphanumeric")):c(e);if(t.startsWith("min:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n<r?p(x.validation("value",e,`must be at least ${r}`)):c(e)}if(t.startsWith("max:")){let r=Number(t.split(":")[1]),n=Number(e);return isNaN(n)||n>r?p(x.validation("value",e,`must be at most ${r}`)):c(e)}if(t.startsWith("minLength:")){let r=Number(t.split(":")[1]);return String(e).length<r?p(x.validation("value",e,`must be at least ${r} characters`)):c(e)}if(t.startsWith("maxLength:")){let r=Number(t.split(":")[1]);return String(e).length>r?p(x.validation("value",e,`must be at most ${r} characters`)):c(e)}if(t.startsWith("pattern:")){let r=t.substring(8);return new RegExp(r).test(String(e))?c(e):p(x.validation("value",e,`must match pattern ${r}`))}if(t.startsWith("in:")){let r=t.substring(3).split(",");return r.includes(String(e))?c(e):p(x.validation("value",e,`must be one of: ${r.join(", ")}`))}if(t.startsWith("notIn:")){let r=t.substring(6).split(",");return r.includes(String(e))?p(x.validation("value",e,`must not be one of: ${r.join(", ")}`)):c(e)}if(t==="date"){let r=new Date(String(e));return isNaN(r.getTime())?p(x.validation("value",e,"must be a valid date")):c(e)}if(t==="future"){let r=new Date(String(e));return isNaN(r.getTime())||r<=new Date?p(x.validation("value",e,"must be a future date")):c(e)}if(t==="past"){let r=new Date(String(e));return isNaN(r.getTime())||r>=new Date?p(x.validation("value",e,"must be a past date")):c(e)}return c(e)},combine:(...t)=>e=>{for(let r of t){let n=r(e);if(n.isLeft())return n}return c(e)},custom:(t,e)=>r=>t(r)?c(r):p(x.validation("value",r,e)),form:(t,e)=>{let r=[],n={};for(let[o,a]of Object.entries(t)){let s=e[o],i=a(s);if(i.isLeft()){let u=i.fold(E=>E,()=>{throw new Error("Should not be left")}),l=x.validation(o,s,u.context.rule);r.push(l);}else n[o]=i.get();}return r.length>0?p(m(r)):c(n)}},lt={...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(t=>typeof t=="string"&&t.trim().length>0,"must not be empty"))}},$r=Object.assign(N.rule,lt);var Yr={toOption:t=>t.fold(()=>b(),e=>w(e)),toList:t=>t.fold(()=>m([]),e=>m([e])),toEither:(t,e)=>t.fold(()=>p(e),r=>c(r)),isEmpty:t=>t.fold(()=>true,()=>false),size:t=>t.fold(()=>0,()=>1)};var de=t=>({_tag:"Success",error:void 0,isSuccess:()=>true,isFailure:()=>false,get:()=>t,getOrElse:e=>t,getOrThrow:e=>t,orElse:e=>de(t),orNull:()=>t,orUndefined:()=>t,orThrow:e=>t,toEither:()=>c(t),map:e=>Ae(()=>e(t)),ap:e=>e.map(r=>r(t)),flatMap:e=>e(t),flatMapAsync:async e=>e(t),fold:(e,r)=>r(t),match:e=>e.Success(t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toString:()=>`Success(${se(t)})`,toValue:()=>({_tag:"Success",value:t}),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Success",value:t}),toYAML:()=>`_tag: Success
29
+ value: ${se(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Success",value:t})).toString("base64")}),get size(){return 1},get isEmpty(){return false},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?f(t):f(void 0),exists:e=>e(t),forEach:e=>e(t)}),$=t=>({_tag:"Failure",error:t,isSuccess:()=>false,isFailure:()=>true,get:()=>{throw t},getOrElse:e=>e,getOrThrow:e=>{throw e||t},orElse:e=>e,orNull:()=>null,orUndefined:()=>{},orThrow:e=>{throw e},toEither:()=>p(t),map:e=>$(t),ap:e=>$(t),flatMap:e=>$(t),flatMapAsync:async e=>$(t),fold:(e,r)=>e(t),match:e=>e.Failure(t),foldLeft:e=>r=>e,foldRight:e=>r=>e,toString:()=>`Failure(${se(t)}))`,toValue:()=>({_tag:"Failure",value:t}),pipe:e=>{throw t},serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Failure",error:t.message,stack:t.stack}),toYAML:()=>`_tag: Failure
30
+ error: ${t.message}
31
+ stack: ${t.stack}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Failure",error:t.message,stack:t.stack})).toString("base64")}),get size(){return 0},get isEmpty(){return true},contains:e=>false,reduce:e=>{throw new Error("Cannot reduce a Failure")},reduceRight:e=>{throw new Error("Cannot reduceRight a Failure")},count:e=>0,find:e=>f(null),exists:e=>false,forEach:e=>{}}),pt=t=>{try{return de(t())}catch(e){return $(e instanceof Error?e:new Error(String(e)))}},Fe={fromJSON:t=>{let e=JSON.parse(t);if(e._tag==="Success")return de(e.value);{let r=new Error(e.error);return e.stack&&(r.stack=e.stack),$(r)}},fromYAML:t=>{let e=t.split(`
32
+ `),r=e[0]?.split(": ")[1];if(!r)return $(new Error("Invalid YAML format for Try"));if(r==="Success"){let n=e[1]?.split(": ")[1];if(!n)return $(new Error("Invalid YAML format for Try Success"));let o=JSON.parse(n);return de(o)}else {let n=e[1]?.split(": ")[1];if(!n)return $(new Error("Invalid YAML format for Try Failure"));let o=e[2]?.split(": "),a=o&&o.length>1?o.slice(1).join(": "):void 0,s=new Error(n);return a&&(s.stack=a),$(s)}},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Fe.fromJSON(e)}},Ae=a(pt,Fe);var q=t=>t!==null&&typeof t=="object"&&(t._tag==="Some"||t._tag==="None"),K=t=>t!==null&&typeof t=="object"&&t._tag==="List",re=t=>t!==null&&typeof t=="object"&&(t._tag==="Left"||t._tag==="Right"),ne=t=>t!==null&&typeof t=="object"&&(t._tag==="Success"||t._tag==="Failure"),S=()=>{let t=(s,i)=>{if(q(s))return s.map(u=>i(u));if(K(s))return s.map(u=>i(u));if(re(s))return s.map(u=>i(u));if(ne(s))return s.map(u=>i(u));throw new Error(`Unsupported functor type: ${JSON.stringify(s)}`)},e=s=>{if(q(s))return s.get();if(K(s)){let i=s.toArray();if(i.length>0&&K(i[0])){let u=[];for(let l of i)K(l)&&u.push(...l.toArray());return m(u)}return s.flatten()}if(re(s))return s.isRight()?s.fold(()=>null,i=>i):s;if(ne(s))return s.isSuccess()?s.get():s;throw new Error(`Unsupported functor type for flatten: ${JSON.stringify(s)}`)},r=(s,i)=>{if(q(s))return s.flatMap(u=>i(u));if(K(s))return s.flatMap(u=>i(u));if(re(s))return s.flatMap(u=>i(u));if(ne(s))return s.flatMap(u=>i(u));throw new Error(`Unsupported functor type for flatMap: ${JSON.stringify(s)}`)},n=(s,i)=>{if(q(s)&&q(i))return s.flatMap(u=>i.map(l=>u(l)));if(K(s)&&K(i))return s.flatMap(u=>i.map(l=>u(l)));if(re(s)&&re(i))return s.flatMap(u=>i.map(l=>u(l)));if(ne(s)&&ne(i))return s.flatMap(u=>i.map(l=>u(l)));throw new Error(`Unsupported functor type for ap: ${JSON.stringify(s)}`)},o=s=>{if(q(s)){let i=s;if(i.isEmpty)return m([f.none()]);let u=i.get();if(K(u))return u.map(l=>f(l));throw new Error("Unsupported inner container type for sequence")}if(K(s)){let u=s.toArray();if(u.length===0)return f.none();let l=u[0];if(q(l)){for(let g of u)if(g.isEmpty)return f.none();let E=u.map(g=>g.get());return f(m(E))}throw new Error("Unsupported inner container type for sequence")}throw new Error(`Unsupported outer container type for sequence: ${JSON.stringify(s)}`)};return {...te("HKT",{map:t,flatten:e,flatMap:r,ap:n,sequence:o,traverse:(s,i)=>o(t(s,u=>i(u)))}),_type:"HKT"}};S.map=(t,e)=>S().map(t,e);S.flatten=t=>S().flatten(t);S.flatMap=(t,e)=>S().flatMap(t,e);S.ap=(t,e)=>S().ap(t,e);S.sequence=t=>S().sequence(t);S.traverse=(t,e)=>S().traverse(t,e);S.isOption=q;S.isList=K;S.isEither=re;S.isTry=ne;function sn(t){return {id:t,isSame:r=>r.id===t}}var Y=t=>{let e=false,r,n,o=false,a=()=>{if(!e)try{r=t(),e=!0;}catch(i){throw n=i,o=true,e=true,i}if(o)throw n;return r};return {_tag:"Lazy",get isEvaluated(){return e},get:a,getOrElse:i=>{try{return a()}catch{return i}},getOrNull:()=>{try{return a()}catch{return null}},orNull:()=>{try{return a()}catch{return null}},getOrThrow:i=>{try{return a()}catch(u){throw i||u}},orElse:i=>M(()=>{try{return a()}catch{return i.get()}}),orUndefined:()=>{try{return a()}catch{return}},map:i=>M(()=>i(a())),ap:i=>M(()=>i.get()(a())),mapAsync:async i=>{let u=a(),l=await i(u);return M(()=>l)},flatMap:i=>M(()=>i(a()).get()),flatMapAsync:async i=>{let u=a(),l=await i(u);return M(()=>l.get())},filter:i=>M(()=>{let u=a();return i(u)?w(u):b}),recover:i=>M(()=>{try{return a()}catch(u){return i(u)}}),recoverWith:i=>M(()=>{try{return a()}catch(u){return i(u).get()}}),toOption:()=>{try{return w(a())}catch{return b}},toEither:()=>{try{return c(a())}catch(i){return p(i)}},toEitherWith:i=>{try{return c(a())}catch(u){return p(i(u))}},toTry:()=>Ae(()=>a()),tap:i=>M(()=>{let u=a();return i(u),u}),tapError:i=>M(()=>{try{return a()}catch(u){throw i(u),u}}),fold:i=>i(a()),foldWith:(i,u)=>{try{return u(a())}catch(l){return i(l)}},foldLeft:i=>u=>u(i,a()),foldRight:i=>u=>u(a(),i),match:i=>i.Lazy(a()),toString:()=>e&&!o?`Lazy(${se(r)})`:e&&o?`Lazy(<error: ${n instanceof Error?n.message:String(n)}>)`:"Lazy(<not evaluated>)",toValue:()=>e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false},get size(){try{return a(),1}catch{return 0}},get isEmpty(){try{return a(),!1}catch{return true}},contains:i=>{try{return a()===i}catch{return false}},reduce:i=>a(),reduceRight:i=>a(),count:i=>{try{return i(a())?1:0}catch{return 0}},find:i=>{try{let u=a();return i(u)?w(u):b}catch{return b}},exists:i=>{try{return i(a())}catch{return false}},forEach:i=>{try{i(a());}catch{}},pipe:i=>i(a()),serialize:()=>({toJSON:()=>JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false}),toYAML:()=>e&&!o?`_tag: Lazy
33
+ evaluated: true
34
+ value: ${se(r)}`:`_tag: Lazy
35
+ evaluated: false`,toBinary:()=>Buffer.from(JSON.stringify(e&&!o?{_tag:"Lazy",evaluated:true,value:r}:{_tag:"Lazy",evaluated:false})).toString("base64")}),typeable:"Lazy"}},ct={of:t=>Y(t),fromValue:t=>Y(()=>t),fromOption:(t,e)=>Y(()=>t._tag==="Some"?t.value:e()),fromTry:t=>Y(()=>t.get()),fromEither:t=>Y(()=>t.fold(e=>{throw e},e=>e)),fromPromise:t=>Y(()=>{throw new Error("Promise not yet resolved. Use await on the promise before creating Lazy.")}),fail:t=>Y(()=>{throw t})},M=a(Y,ct);var ie=Map;var W=t=>{let r={values:new ie(t)},n=()=>Array.from(r.values.entries()).map(([T,y])=>b$1([T,y])),o=T=>W(new ie(r.values).set(T.toArray()[0],T.toArray()[1]).entries()),a=T=>{let y=new ie(r.values);return y.delete(T)?W(y.entries()):W(r.values.entries())},s=T=>{let y=T.toArray();return r.values.get(y[0])===y[1]},i=()=>r.values.size,u=T=>W(Array.from(r.values.entries()).map(([y,_])=>[y,T(_)])),l=T=>{let y=W(r.values.entries()).toList();return W(y.flatMap(T).toArray())},E=T=>{let y=[];for(let[_,X]of r.values.entries()){let ae=T.get(_);ae._tag==="Some"&&ae.value&&y.push([_,ae.value(X)]);}return W(y)},g=async T=>{let y=new ie;for(let[_,X]of r.values.entries()){let ae=await T(X);for(let Je of ae.toList()){let[We,je]=Je.toArray();y.set(We,je);}}return W(y.entries())},F=T=>m(n()).reduce(T),v=T=>m(n()).reduceRight(T),A=T=>y=>m(n()).foldLeft(T)(y),G=T=>y=>m(n()).foldRight(T)(y),j=T=>f(r.values.get(T)),Z=(T,y)=>f(r.values.get(T)).getOrElse(y),oe=()=>r.values.size===0,ue=(T,y)=>f(r.values.get(T)).orElse(y),le=(T,y)=>{if(oe())return T();let _=n();if(_.length===0)return T();let X=_[0];return X===void 0?T():y(X)},be=()=>m(n()),d=()=>Q(n()),B=()=>`Map(${n().toString()})`,O=T=>oe()?T.Empty():T.NonEmpty(n());return {_tag:"Map",[Symbol.iterator]:()=>r.values.entries(),add:o,remove:a,contains:s,get size(){return i()},map:u,ap:E,flatMap:l,flatMapAsync:g,reduce:F,reduceRight:v,foldLeft:A,foldRight:G,fold:le,match:O,get:j,getOrElse:Z,get isEmpty(){return oe()},orElse:ue,toList:be,toSet:d,toString:B,toValue:()=>({_tag:"Map",value:Array.from(r.values.entries())}),pipe:T=>T(Array.from(r.values.entries())),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())}),toYAML:()=>`_tag: Map
36
+ value: ${JSON.stringify(Array.from(r.values.entries()))}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Map",value:Array.from(r.values.entries())})).toString("base64")})}},Tt=t=>W(t),Ce={fromJSON:t=>{let e=JSON.parse(t);return Re(e.value)},fromYAML:t=>{let r=t.split(`
37
+ `)[1]?.split(": ")[1];if(!r)return Re([]);let n=JSON.parse(r);return Re(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return Ce.fromJSON(e)}},Re=a(Tt,Ce);var ft={default:t=>e=>t(e),when:(t,e)=>r=>t(r)?e(r):void 0};function Le(t){let e=t;return {get(){return e},set(n){e=n;},update(n){e=n(e);},getAndSet(n){let o=e;return e=n,o},updateAndGet(n){return e=n(e),e},getAndUpdate(n){let o=e;return e=n(e),o},compareAndSet(n,o){return e===n?(e=o,true):false},modify(n){let[o,a]=n(e);return e=o,a}}}Le.of=Le;function In(t){let e=ce({_tag:t._tag,impl:t.impl});return {...e,toValue:()=>({_tag:e._tag,value:t.value})}}var z=(t=[])=>{let e="Stack",r=[...t],n=()=>r.length,o=()=>r.length===0;return {_tag:e,get size(){return n()},get isEmpty(){return o()},contains:d=>r.includes(d),reduce:d=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduce(d)},reduceRight:d=>{if(r.length===0)throw new Error("Cannot reduce an empty stack");return r.reduceRight(d)},push:d=>z([...r,d]),pop:()=>{if(o())return [z([]),f(null)];let d=[...r],B=d.pop();return [z(d),f(B)]},peek:()=>o()?f(null):f(r[r.length-1]),map:d=>z(r.map(d)),flatMap:d=>o()?z([]):r.reduce((B,O)=>d(O).toArray().reduce((y,_)=>y.push(_),B),z([])),ap:d=>{let B=[];return r.forEach(O=>{d.toArray().forEach(T=>{B.push(T(O));});}),z(B)},flatMapAsync:async d=>o()?z([]):(await Promise.all(r.map(async O=>await d(O)))).reduce((O,T)=>T.toArray().reduce((y,_)=>y.push(_),O),z([])),toList:()=>m(r),toArray:()=>[...r],toString:()=>`Stack(${r.join(", ")})`,fold:(d,B)=>{if(o())return d();let O=r[r.length-1];return O!==void 0?B(O):d()},foldLeft:d=>B=>r.reduce(B,d),foldRight:d=>B=>r.reduceRight((O,T)=>B(T,O),d),match:d=>o()?d.Empty():d.NonEmpty([...r]),toValue:()=>({_tag:"Stack",value:r}),pipe:d=>d([...r]),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Stack",value:r}),toYAML:()=>`_tag: Stack
38
+ value: ${JSON.stringify(r)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Stack",value:r})).toString("base64")})}},dt=(t=[])=>z(t),$e={empty:()=>z([]),of:t=>z([t]),fromJSON:t=>{let e=JSON.parse(t);return xe(e.value)},fromYAML:t=>{let r=t.split(`
39
+ `)[1]?.split(": ")[1];if(!r)return xe([]);let n=JSON.parse(r);return xe(n)},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return $e.fromJSON(e)}},xe=a(dt,$e);var w=t=>({_tag:"Some",value:t,isEmpty:false,get:()=>t,getOrElse:()=>t,getOrThrow:()=>t,orElse:e=>w(t),orNull:()=>t,orUndefined:()=>t,map:e=>w(e(t)),ap:e=>e._tag==="Some"&&e.value?w(e.value(t)):D,filter(e){return e(t)?w(t):D},count:e=>e(t)?1:0,find:e=>e(t)?w(t):D,exists:e=>e(t),forEach:e=>e(t),fold:(e,r)=>r(t),match:e=>e.Some(t),flatMap:e=>e(t),flatMapAsync:async e=>await e(t),reduce:e=>e(void 0,t),reduceRight:e=>e(void 0,t),foldLeft:e=>r=>r(e,t),foldRight:e=>r=>r(t,e),toList:()=>m([t]),contains:e=>e===t,size:1,toEither:e=>c(t),toString:()=>`Some(${se(t)})`,toValue:()=>({_tag:"Some",value:t}),pipe:e=>e(t),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"Some",value:t}),toYAML:()=>`_tag: Some
40
+ value: ${se(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"Some",value:t})).toString("base64")})}),D={_tag:"None",value:void 0,isEmpty:true,get:()=>{throw new Error("Cannot call get() on None")},getOrElse:t=>t,getOrThrow(t){throw t},orElse:t=>t,orNull:()=>null,orUndefined:()=>{},map:t=>D,ap:t=>D,filter(t){return D},count:t=>0,find:t=>D,exists:t=>false,forEach:t=>{},flatMap:t=>D,flatMapAsync:async t=>D,reduce:()=>{},reduceRight:()=>{},fold:(t,e)=>t(),match:t=>t.None(),foldLeft:t=>()=>t,foldRight:t=>()=>t,toList:()=>m([]),contains:()=>false,size:0,toEither:t=>p(t),toString:()=>"None",toValue:()=>({_tag:"None",value:void 0}),pipe:t=>t(void 0),serialize:()=>({toJSON:()=>JSON.stringify({_tag:"None",value:null}),toYAML:()=>`_tag: None
41
+ value: null`,toBinary:()=>Buffer.from(JSON.stringify({_tag:"None",value:null})).toString("base64")})},b=()=>D,yt=t=>t!=null?w(t):b(),De={from:t=>f(t),none:()=>b(),fromJSON:t=>{let e=JSON.parse(t);return e._tag==="Some"?w(e.value):b()},fromYAML:t=>{let e=t.split(`
42
+ `),r=e[0]?.split(": ")[1],n=e[1]?.split(": ")[1];if(!r||!n)return b();let o=n==="null"?null:JSON.parse(n);return r==="Some"?w(o):b()},fromBinary:t=>{let e=Buffer.from(t,"base64").toString();return De.fromJSON(e)}},f=a(yt,De);export{sn as $,Ht as A,Gt as B,Zt as C,Xt as D,rr as E,sr as F,te as G,Te as H,L as I,tt as J,ge as K,rt as L,Ne as M,_e as N,Ee as O,V as P,ze as Q,fe as R,br as S,kr as T,Ur as U,x as V,Ir as W,$r as X,Yr as Y,Ae as Z,S as _,w as a,M as aa,b,ie as ba,yt as c,Re as ca,f as d,ft as da,Q as e,Le as ea,ce as f,In as fa,ye as g,xe as ga,m as h,c as i,p as j,_t as k,It as l,Mt as m,Qe as n,He as o,zt as p,ve as q,I as r,Ge as s,Dt as t,Jt as u,Wt as v,jt as w,qt as x,Yt as y,Qt as z};//# sourceMappingURL=chunk-4EYCKDDF.mjs.map
43
+ //# sourceMappingURL=chunk-4EYCKDDF.mjs.map