@athrio/loom 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cache-Dv3Qogvb.js +1048 -0
- package/dist/Cache-Dv3Qogvb.js.map +1 -0
- package/dist/{LoomServer-BZL6KQOM.js → LoomServer-JbCtLtxV.js} +4 -2
- package/dist/{LoomServer-BZL6KQOM.js.map → LoomServer-JbCtLtxV.js.map} +1 -1
- package/dist/LoomStore-BGlpRj6W.js +8857 -0
- package/dist/LoomStore-BGlpRj6W.js.map +1 -0
- package/dist/NodeServices-CtEw3D6F.js +1564 -0
- package/dist/NodeServices-CtEw3D6F.js.map +1 -0
- package/dist/{LoomStore-BBRhdzet.js → SqlClient-BHo_uVyk.js} +10062 -46501
- package/dist/SqlClient-BHo_uVyk.js.map +1 -0
- package/dist/SqlError-BwVJTsti.js +408 -0
- package/dist/SqlError-BwVJTsti.js.map +1 -0
- package/dist/design-S_129JVC.js +18524 -0
- package/dist/design-S_129JVC.js.map +1 -0
- package/dist/dist-3ptbWhlX.js +202 -0
- package/dist/dist-3ptbWhlX.js.map +1 -0
- package/dist/dist-CKhPOkpR.js +27469 -0
- package/dist/dist-CKhPOkpR.js.map +1 -0
- package/dist/dist-kscTHM4c.js +151 -0
- package/dist/dist-kscTHM4c.js.map +1 -0
- package/dist/identity-DvFsrt2d.js +95 -0
- package/dist/identity-DvFsrt2d.js.map +1 -0
- package/dist/main.js +260 -1535
- package/dist/main.js.map +1 -1
- package/dist/overlay.js +80 -0
- package/dist/store-CtvrwAS8.js +3 -0
- package/dist/store-DgMmJ7v9.js +229 -0
- package/dist/store-DgMmJ7v9.js.map +1 -0
- package/dist/ui.html +103 -0
- package/dist/ui.js +79 -0
- package/package.json +3 -1
- package/dist/LoomStore-BBRhdzet.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-CKhPOkpR.js","names":["predicate.isBigInt","Option.none","Option.some","order.BigInt","Equ.BigInt","Schema.encodeEffect","Schema.NonEmptyArray","Channel.fromTransform","Effect.succeed","Effect.flatMap","Schema.decodeEffect","Channel.pipeTo","effect.ConsoleRef","core.withFiber","effect.sync","clear","effect.acquireRelease","core.isEffect","effect.acquireUseRelease","TypeId","make","Effect.map","Effect.sync","Effect.clockWith","Effect.succeed","Effect.fail","PlatformError.badArgument","TypeId","make","effect.causePrettyError","references.CurrentErrorReporters","layer","Layer.effect","Effect.withFiber","Effect.fnUntraced","Effect.isEffect","Effect.void","TypeId","Predicate.hasProperty","Proto","makeUnsafe","Deferred.makeUnsafe","make","Effect.acquireRelease","Effect.sync","Effect.void","Deferred.into","Effect.asVoid","Fiber.interruptAs","internalFiberId","Deferred.done","Exit.void","makeRuntime","Effect.flatMap","runtime","makeRuntimePromise","runtimePromise","isInternalInterruption","Cause.filterInterruptors","setUnsafe","Exit.isFailure","Cause.hasInterruptsOnly","set","getUnsafe","Option.none","Option.fromUndefinedOr","get","Effect.suspend","Effect.succeed","clear","Effect.uninterruptibleMask","Effect.andThen","constInterruptedFiber","Effect.runFork","Effect.interrupt","run","Effect.isEffect","runImpl","Effect.withFiber","Effect.runForkWith","Effect.map","Effect.context","Exit.isSuccess","Cause.squash","join","Deferred.await","awaitEmpty","Fiber.await","TypeId","Predicate.hasProperty","Proto","Iterable.empty","makeUnsafe","make","Effect.acquireRelease","Effect.sync","MutableHashMap.empty","Deferred.makeUnsafe","Effect.suspend","Effect.void","Fiber.interruptAll","MutableHashMap.values","Deferred.into","makeRuntime","Effect.flatMap","runtime","makeRuntimePromise","runtimePromise","internalFiberId","isInternalInterruption","Cause.filterInterruptors","setUnsafe","MutableHashMap.get","Option.isSome","Exit.isFailure","Cause.hasInterruptsOnly","set","getUnsafe","Option.none","get","Effect.succeed","MutableHashMap.has","has","remove","Fiber.interruptAs","clear","Fiber.interruptAllAs","constInterruptedFiber","Effect.runFork","Effect.interrupt","run","Effect.isEffect","runImpl","Effect.withFiber","Effect.runForkWith","Effect.map","Effect.context","Exit.isSuccess","Cause.squash","size","MutableHashMap.size","join","Deferred.await","awaitEmpty","Effect.whileLoop","Fiber.await","Iterable.headUnsafe","TypeId","Predicate.hasProperty","Proto","Iterable.empty","makeUnsafe","make","Effect.acquireRelease","Effect.sync","Deferred.makeUnsafe","Effect.suspend","Effect.void","Fiber.interruptAll","Deferred.into","Effect.flatMap","Cause.filterInterruptors","Exit.isFailure","Cause.hasInterruptsOnly","add","clear","Fiber.interruptAllAs","Effect.runFork","Effect.interrupt","Effect.isEffect","Effect.withFiber","Effect.runForkWith","Effect.succeed","Effect.map","Effect.context","Exit.isSuccess","Cause.squash","size","Deferred.await","Effect.whileLoop","Fiber.await","Iterable.headUnsafe","TypeId","Data.Class","Equal.symbol","Equal.equals","Hash.symbol","hash","Hash.string","Hash.number","Hash.hash","Data.TaggedError","Option.some","Option.none","reverse","Option.isSome","Option.fromUndefinedOr","Option.isNone","values","entries","symbol","value","TypeId","make","Proto","Iterable.map","PrimaryKey.value","Hash.string","add","remove","has","get","TypeId","make","context","Effect.context","RcMap.make","Effect.contextWith","Layer.buildWithMemoMap","Context.get","Scope.Scope","Layer.effectContext","RcMap.get","RcMap.invalidate","Context.Service","Layer.effect","Layer.provide","Layer.unwrap","Effect.map","Effect.flatMap","TypeId","Predicate.hasProperty","effect.CurrentLoggers","effect.LogToStderr","map","effect.loggerMake","effect.ConsoleRef","Formatter.format","effect.formatLabel","Array.ensure","effect.causePretty","effect.formatLogSpan","make","effect.defaultLogger","effect.structuredMessage","Formatter.formatJson","effect.flatMap","effect.scope","effect.suspend","effect.void","effect.uninterruptibleMask","effect.sleep","effect.andThen","effect.forever","effect.forkDetach","effect.scopeAddFinalizerExit","effect.fiberInterrupt","effect.addFinalizer","effect.as","effect.consolePretty","effect.tracerLogger","Layer.effect","effect.fnUntraced","effect.gen","FileSystem.FileSystem","effect.ignore","TypeId","make","Layer.makeMemoMapUnsafe","Scope.makeUnsafe","Scope.forkUnsafe","Fiber.runIn","Effect.withFiber","Effect.runFork","Effect.tap","Layer.buildWithMemoMap","Effect.sync","Effect.flatten","Fiber.await","Effect.runPromise","Effect.suspend","Effect.die","Scope.close","Exit.void","Effect.runForkWith","Effect.runCallback","Effect.runCallbackWith","Effect.runSyncExit","Effect.runSyncExitWith","Effect.runSync","Effect.runSyncWith","Effect.runPromiseExit","Effect.runPromiseExitWith","Effect.runPromiseWith","Effect.flatMap","Effect.provideContext","TypeId","Result.isSuccess","Result.succeed","type","value","Result.fail","valueTags","tagsExhaustive","typeTags","withReturnType","when","whenOr","whenAnd","discriminator","discriminatorStartsWith","discriminators","discriminatorsExhaustive","exhaustive","tag","tagStartsWith","tags","not","nonEmptyString","is","any","defined","instanceOf","orElse","result","Result.isResult","orElseAbsurd","option","Result.match","Option.none","Option.some","internal.type","value","internal.value","internal.valueTags","internal.typeTags","internal.withReturnType","internal.when","internal.whenOr","internal.whenAnd","internal.discriminator","internal.discriminatorStartsWith","internal.discriminators","internal.discriminatorsExhaustive","internal.tag","internal.tagStartsWith","internal.tags","internal.tagsExhaustive","internal.not","internal.nonEmptyString","internal.is","string","Predicate.isString","Predicate.isNumber","internal.any","internal.defined","boolean","Predicate.isBoolean","Predicate.isUndefined","Predicate.isNull","Predicate.isBigInt","Predicate.isSymbol","Predicate.isDate","Predicate.isObject","internal.instanceOf","internal.orElse","internal.orElseAbsurd","internal.result","internal.option","internal.exhaustive","TypeId","format","fromHashMap","empty","MutableHashMap.empty","fromIterable","MutableHashMap.fromIterable","make","add","MutableHashMap.set","has","MutableHashMap.has","remove","MutableHashMap.remove","size","MutableHashMap.size","clear","MutableHashMap.clear","Optic.makeIso","makeUnsafe","Effect.succeed","Effect.void","Effect.asSome","MutableHashMap.empty","Effect.callback","Effect.never","Option.getOrElse","MutableHashMap.get","Effect.sync","Effect.uninterruptibleMask","Effect.flatMap","Effect.ensuring","Effect.suspend","Option.none","make","available","capacity","take","release","withPermits","withPermit","TypeId","make","Effect.flatMap","Effect.uninterruptibleMask","Effect.fnUntraced","Effect.context","Context.get","Scope.Scope","Effect.updateContext","Context.merge","Semaphore.makeUnsafe","Latch.makeUnsafe","Scope.addFinalizer","shutdown","Effect.tap","Effect.forkDetach","Fiber.interrupt","get","Effect.suspend","Effect.interrupt","Effect.scope","Effect.ensuring","Effect.sync","Scope.addFinalizerExit","Effect.void","Effect.onInterrupt","Effect.forkIn","Effect.interruptible","Iterable.headUnsafe","invalidate","Effect.uninterruptible","Effect.asVoid","Effect.succeed","Effect.replicateEffect","Effect.acquireUseRelease","Scope.make","Scope.provide","Effect.exit","Effect.catchCause","Scope.close","Effect.as","Effect.undefined","Queue.unbounded","Duration.toMillis","Duration.fromInputUnsafe","Effect.delay","Queue.take","Effect.forever","Queue.offer","Iterable.head","Iterable.filter","Effect.withFiber","Effect.logWithLevel","random.Random","Effect.withFiber","Effect.succeed","Effect.fail","Cause.NoSuchElementError","Effect.provideService","Predicate.isUndefined","Predicate.isString","makeUnsafe","MutableRef.make","make","Effect.sync","get","set","MutableRef.set","getAndSet","getAndUpdate","getAndUpdateSome","setAndGet","modify","modifySome","update","updateAndGet","updateSome","updateSomeAndGet","getUnsafe","Schema.ErrorClass","Schema.String","Context.Service","TypeId","makeWith","make","Effect.yieldNow","MutableHashMap.empty","MutableHashMap.get","Effect.sync","Effect.callback","effect.getCurrentFiber","effect.forkUnsafe","effect.void","Effect.forEach","Effect.matchCause","Effect.sleep","Effect.acquireUseRelease","never","Effect.never","effect.race","Effect.suspend","Context.getOption","Tracer.ParentSpan","Effect.withSpan","Cache.makeWith","internal.request","Effect.onExit","MutableHashMap.size","Effect.void","MutableHashMap.keys","Persistence.Persistence","Effect.fnUntraced","Iterable.map","Effect.provideContext","Arr.isArrayNonEmpty","Effect.catchCause","Exit.failCause","TypeId","Proto","makeUnsafe","Semaphore.makeUnsafe","Ref.makeUnsafe","make","Effect.sync","getUnsafe","get","getAndSet","Ref.getAndSet","getAndUpdate","Ref.getAndUpdate","getAndUpdateEffect","Effect.suspend","Effect.map","getAndUpdateSome","Ref.getAndUpdateSome","getAndUpdateSomeEffect","Effect.flatMap","Option.isNone","Effect.succeed","modify","Ref.modify","modifyEffect","modifySome","Ref.modifySome","modifySomeEffect","set","Ref.set","setAndGet","Ref.setAndGet","update","Ref.update","updateEffect","updateAndGet","Ref.updateAndGet","updateAndGetEffect","updateSome","Ref.updateSome","updateSomeEffect","updateSomeAndGet","Ref.updateSomeAndGet","updateSomeAndGetEffect","TypeId","Proto","makeUnsafe","Synchronized.makeUnsafe","Scope.makeUnsafe","Scope.provide","Effect.tapCause","Scope.close","Exit.failCause","Effect.addFinalizer","Effect.uninterruptible","getUnsafe","get","Effect.sync","make","Effect.suspend","Effect.as","set","Exit.void","TypeId","Proto","makeUnsafe","Effect.contextWith","Effect.updateContext","Context.merge","Effect.map","ScopedRef.fromAcquire","Effect.exit","Effect.tap","Effect.forkScoped","Effect.repeat","refresh","get","Effect.flatMap","ScopedRef.get","ScopedRef.set","Exit.succeed","Exit.isSuccess","Cause.hasInterruptsOnly","Cause.squash","Effect.isEffect","Effect.runFork","Effect.tapCause","Effect.void","Effect.logError","InternalRepresentation.fromASTBlacklist","Schema.Null","Schema.Number","Schema.Boolean","Schema.BigInt","Schema.Symbol","Schema.String","Schema.Unknown","Schema.encodeTo","Schema.Record","SchemaGetter.passthrough","SchemaGetter.transformOptional","Option.flatMap","Rec.isEmptyRecord","Option.none","Option.some","Schema.tag","Schema.optional","Schema.RegExp","Schema.UndefinedOr","Schema.Literals","Schema.suspend","Schema.Union","Schema.Struct","Schema.NonEmptyArray","Schema.Array","Schema.Finite","Schema.Tuple","Schema.PropertyKey","Schema.Date","InternalRepresentation.fromAST","InternalRepresentation.fromASTs","Predicate.isObject","Schema.Error","Schema.File","Schema.FormData","Schema.ReadonlyMap","Schema.ReadonlySet","Schema.Uint8Array","Schema.URL","Schema.URLSearchParams","Schema.Option","Schema.Result","Schema.Redacted","Schema.TimeZone","Schema.TimeZoneNamed","Schema.TimeZoneOffset","Schema.DateTimeUtc","Schema.DateTimeZoned","Schema.BigDecimal","Schema.Chunk","Schema.Cause","Schema.CauseReason","Schema.Duration","Schema.Exit","Schema.Json","Schema.MutableJson","Schema.HashMap","Schema.HashSet","Schema.Undefined","Schema.Void","Schema.Never","Schema.Any","Schema.fromJsonString","Schema.Literal","Schema.UniqueSymbol","Schema.ObjectKeyword","Schema.Enum","Schema.TemplateLiteral","Schema.optionalKey","Arr.isArrayNonEmpty","Schema.TupleWithRest","Schema.mutableKey","Schema.StructWithRest","Schema.makeFilterGroup","Arr.map","Schema.isStringFinite","Schema.isStringBigInt","Schema.isStringSymbol","Schema.isMinLength","Schema.isMaxLength","Schema.isLengthBetween","Schema.isPattern","Schema.isTrimmed","Schema.isUUID","Schema.isGUID","Schema.isULID","Schema.isBase64","Schema.isBase64Url","Schema.isStartsWith","Schema.isEndsWith","Schema.isIncludes","Schema.isUppercased","Schema.isLowercased","Schema.isCapitalized","Schema.isUncapitalized","Schema.isFinite","Schema.isInt","Schema.isMultipleOf","Schema.isGreaterThan","Schema.isGreaterThanOrEqualTo","Schema.isLessThan","Schema.isLessThanOrEqualTo","Schema.isBetween","Schema.isGreaterThanBigInt","Schema.isGreaterThanOrEqualToBigInt","Schema.isLessThanBigInt","Schema.isLessThanOrEqualToBigInt","Schema.isBetweenBigInt","Schema.isMinProperties","Schema.isMaxProperties","Schema.isPropertiesLengthBetween","Schema.isPropertyNames","Schema.isUnique","Schema.isDateValid","Schema.isGreaterThanDate","Schema.isGreaterThanOrEqualToDate","Schema.isLessThanDate","Schema.isLessThanOrEqualToDate","Schema.isBetweenDate","Schema.isMinSize","Schema.isMaxSize","Schema.isSizeBetween","InternalRepresentation.toJsonSchemaDocument","InternalRepresentation.toJsonSchemaMultiDocument","Rec.mapEntries","Rec.filter","format","SchemaAST.mapOrSame","Arr.isReadonlyArrayNonEmpty","SchemaTransformation.transform","Schema.instanceOf","Schema.link","Schema.encodeTo","TypeId","effect.contextWith","Context.get","Scope.Scope","Proto","effect.updateContext","Context.merge","MutableHashMap.empty","Duration.fromInputUnsafe","effect.as","Scope.addFinalizer","core.withFiber","make","Duration.infinity","get","effect.uninterruptibleMask","effect.interrupt","MutableHashMap.get","Option.isSome","Deferred.await","Scope.makeUnsafe","Deferred.makeUnsafe","effect.flatMap","Scope.close","effect.exitVoid","Scope.provide","effect.onExit","Duration.isFinite","effect.ClockRef","Duration.toMillis","effect.void","MutableHashMap.size","Arr.empty","effect.forkUnsafe","effect.fiberAwaitAll","effect.asSome","effect.succeedNone","Option.isNone","effect.undefined","effect.succeed","effect.uninterruptible","effect.map","effect.exitIsSuccess","Option.some","Option.none","set","core.exitSucceed","has","Predicate.isNotUndefined","effect.suspend","effect.catch_","effect.fnUntraced","Fiber.getCurrent","MutableHashMap.has","effect.exit","size","effect.sync","keys","values","entries","Arr.map","core.isExit","effect.exitIsFailure","TypeId","make","Layer.succeed","Effect.succeed","Sink.drain","Stream.empty","TypeId","make","Effect.map","PubSub.unbounded","Semaphore.makeUnsafe","changes","Stream.fromPubSub","getUnsafe","get","Effect.sync","getAndSet","getAndUpdate","Option.isNone","Effect.succeed","Effect.suspend","modify","set","update","updateAndGet","predicate.isSymbol","TypeId","Schema.ErrorClass","Predicate.hasProperty","make","Hash.symbol","hash","Hash.hash","Hash.combine","Equal.symbol","Equal.equals","format","empty","fromIterable","insert","make","size","isEmpty","keys","values","entries","reduce","map","filter","filterMap","Result.isSuccess","compact","Option.isSome","forEach","keysWithPrefix","valuesWithPrefix","entriesWithPrefix","toEntriesWithPrefix","get","Option.none","Option.fromUndefinedOr","has","getUnsafe","Option.isNone","remove","removeMany","insertMany","modify","longestPrefixOf","Option.some","empty","TR.empty","fromIterable","TR.fromIterable","make","TR.make","TR.insert","keys","TR.keys","values","TR.values","entries","TR.entries","toEntries","TR.keysWithPrefix","TR.valuesWithPrefix","TR.entriesWithPrefix","TR.toEntriesWithPrefix","TR.longestPrefixOf","size","TR.size","get","TR.get","has","TR.has","isEmpty","TR.isEmpty","TR.getUnsafe","remove","TR.remove","reduce","TR.reduce","map","TR.map","filter","TR.filter","filterMap","TR.filterMap","compact","TR.compact","forEach","TR.forEach","modify","TR.modify","removeMany","TR.removeMany","TR.insertMany","TypeId","make","Effect.sync","makeUnsafe","modify","Effect.flatMap","Effect.tx","update","get","set","TypeId","format","make","Effect.map","TxRef.make","empty","Chunk.empty","fromIterable","Chunk.fromIterable","modify","TxRef.modify","update","TxRef.update","get","TxRef.get","set","TxRef.set","Chunk.append","Chunk.prepend","size","Chunk.size","isEmpty","Chunk.isEmpty","isNonEmpty","Chunk.isNonEmpty","take","Chunk.take","Chunk.drop","map","Chunk.map","filter","Chunk.filter","Chunk.appendAll","Chunk.prependAll","Effect.gen","Effect.tx","TypeId","make","Effect.map","TxRef.make","O.none","Effect.gen","TxRef.get","O.isNone","Effect.txRetry","Res.isSuccess","Effect.fail","Effect.tx","poll","TxRef.modify","O.isSome","O.some","Res.succeed","fail","Res.fail","TypeId","format","empty","Effect.gen","TxRef.make","HashMap.empty","make","HashMap.make","fromIterable","HashMap.fromIterable","get","TxRef.get","HashMap.get","set","TxRef.update","HashMap.set","has","HashMap.has","remove","TxRef.set","HashMap.remove","Effect.tx","clear","size","HashMap.size","isEmpty","HashMap.isEmpty","isNonEmpty","Effect.map","modify","Option.isSome","Option.none","HashMap.keys","HashMap.toValues","HashMap.toEntries","union","HashMap.union","HashMap.removeMany","HashMap.setMany","HashMap.getHash","HashMap.hasHash","map","HashMap.map","filter","HashMap.filter","reduce","HashMap.reduce","HashMap.filterMap","HashMap.hasBy","HashMap.findFirst","some","HashMap.some","every","HashMap.every","Effect.forEach","HashMap.compact","TypeId","format","empty","Effect.gen","TxRef.make","HashSet.empty","make","HashSet.make","fromIterable","HashSet.fromIterable","TxRef.update","HashSet.add","TxRef.get","HashSet.has","TxRef.set","HashSet.remove","Effect.tx","size","HashSet.size","isEmpty","HashSet.isEmpty","clear","HashSet.union","HashSet.intersection","HashSet.difference","HashSet.isSubset","HashSet.some","HashSet.every","HashSet.map","HashSet.filter","HashSet.reduce","TypeId","C.toArray","C.fromIterable","Effect.map","TxRef.make","C.empty","make","size","TxRef.get","C.size","isEmpty","peek","Effect.gen","C.head","O.isNone","Effect.txRetry","Effect.tx","offer","TxRef.update","offerAll","take","TxRef.set","C.drop","takeAll","TxRef.modify","O.none","O.some","C.take","C.filter","TypeId","bounded","Effect.gen","TxChunk.empty","TxRef.make","Effect.tx","unbounded","dropping","sliding","TxRef.get","size","TxChunk.append","TxChunk.drop","Effect.txRetry","Effect.failCause","isEmpty","TxChunk.get","Chunk.head","Option.isNone","TxRef.set","Option.none","Option.some","Chunk.toArray","TxChunk.set","Chunk.empty","Chunk.take","TxChunk.size","TxChunk.isEmpty","isFull","Effect.succeed","Effect.map","Effect.withFiber","Cause.interrupt","Cause.fail","Cause.Done","shutdown","Effect.ignore","isShutdown","TypeId","Effect.gen","TxRef.make","Effect.tx","capacity","TxRef.get","TxQueue.size","Effect.map","TxQueue.isFull","TxQueue.offer","Effect.acquireRelease","TxRef.update","TxQueue.shutdown","TxQueue.bounded","TxQueue.dropping","TxQueue.sliding","TxQueue.unbounded","TxRef.set","Effect.txRetry","TypeId","make","Effect.gen","TxRef.make","Effect.tx","Effect.withFiber","TxRef.get","Option.isSome","Effect.txRetry","Option.getOrElse","HashMap.get","TxRef.set","HashMap.set","Option.some","HashMap.remove","Option.isNone","Option.none","Effect.acquireRelease","Effect.acquireUseRelease","HashMap.size","TypeId","make","Effect.gen","Effect.die","TxRef.make","Effect.tx","TxRef.get","Effect.succeed","Effect.txRetry","TxRef.set","TxRef.modify","TxRef.update","Effect.acquireUseRelease","Effect.acquireRelease","Effect.gen","TxRef.make","TxPubSub.unbounded","Effect.tx","TxRef.get","TxRef.set","TxPubSub.publish","Effect.acquireRelease","TxPubSub.acquireSubscriber","TxQueue.offer","TxPubSub.releaseSubscriber","Stream.unwrap","Effect.map","Stream.fromEffectRepeat","TxQueue.take"],"sources":["../../../node_modules/effect/dist/BigInt.js","../../../node_modules/effect/dist/ChannelSchema.js","../../../node_modules/effect/dist/Console.js","../../../node_modules/effect/dist/Crypto.js","../../../node_modules/effect/dist/Differ.js","../../../node_modules/effect/dist/ErrorReporter.js","../../../node_modules/effect/dist/FiberHandle.js","../../../node_modules/effect/dist/FiberMap.js","../../../node_modules/effect/dist/FiberSet.js","../../../node_modules/effect/dist/Graph.js","../../../node_modules/effect/dist/PrimaryKey.js","../../../node_modules/effect/dist/HashRing.js","../../../node_modules/effect/dist/HKT.js","../../../node_modules/effect/dist/LayerMap.js","../../../node_modules/effect/dist/Logger.js","../../../node_modules/effect/dist/ManagedRuntime.js","../../../node_modules/effect/dist/internal/matcher.js","../../../node_modules/effect/dist/Match.js","../../../node_modules/effect/dist/MutableHashSet.js","../../../node_modules/effect/dist/Newtype.js","../../../node_modules/effect/dist/NonEmptyIterable.js","../../../node_modules/effect/dist/Ordering.js","../../../node_modules/effect/dist/PartitionedSemaphore.js","../../../node_modules/effect/dist/Pool.js","../../../node_modules/effect/dist/Random.js","../../../node_modules/effect/dist/Ref.js","../../../node_modules/effect/dist/unstable/persistence/Persistence.js","../../../node_modules/effect/dist/RequestResolver.js","../../../node_modules/effect/dist/SynchronizedRef.js","../../../node_modules/effect/dist/ScopedRef.js","../../../node_modules/effect/dist/Resource.js","../../../node_modules/effect/dist/Runtime.js","../../../node_modules/effect/dist/SchemaRepresentation.js","../../../node_modules/effect/dist/SchemaUtils.js","../../../node_modules/effect/dist/ScopedCache.js","../../../node_modules/effect/dist/Stdio.js","../../../node_modules/effect/dist/SubscriptionRef.js","../../../node_modules/effect/dist/Symbol.js","../../../node_modules/effect/dist/Terminal.js","../../../node_modules/effect/dist/internal/trie.js","../../../node_modules/effect/dist/Trie.js","../../../node_modules/effect/dist/TxRef.js","../../../node_modules/effect/dist/TxChunk.js","../../../node_modules/effect/dist/TxDeferred.js","../../../node_modules/effect/dist/TxHashMap.js","../../../node_modules/effect/dist/TxHashSet.js","../../../node_modules/effect/dist/TxPriorityQueue.js","../../../node_modules/effect/dist/TxQueue.js","../../../node_modules/effect/dist/TxPubSub.js","../../../node_modules/effect/dist/TxReentrantLock.js","../../../node_modules/effect/dist/TxSemaphore.js","../../../node_modules/effect/dist/TxSubscriptionRef.js","../../../node_modules/effect/dist/Types.js","../../../node_modules/effect/dist/Unify.js","../../../node_modules/effect/dist/index.js"],"sourcesContent":["/**\n * Works with JavaScript `bigint` values.\n *\n * This module exposes the native `BigInt` constructor together with helpers for\n * checking, arithmetic, comparison, range checks, safe parsing and conversions\n * that return `Option`, integer square roots, aggregation, ordering,\n * equivalence, reducers, and combiners.\n *\n * @since 2.0.0\n */\nimport * as Combiner from \"./Combiner.js\";\nimport * as Equ from \"./Equivalence.js\";\nimport { dual } from \"./Function.js\";\nimport * as Option from \"./Option.js\";\nimport * as order from \"./Order.js\";\nimport * as predicate from \"./Predicate.js\";\nimport * as Reducer from \"./Reducer.js\";\n/**\n * Exposes the global bigint constructor for JavaScript bigint coercion.\n *\n * **When to use**\n *\n * Use to access native JavaScript bigint constructor coercion from the Effect\n * module namespace.\n *\n * **Gotchas**\n *\n * This follows native `BigInt` coercion rules. It throws for invalid strings or\n * non-integral numbers, and whitespace-only strings coerce to `0n`.\n *\n * @see {@link fromString} for parsing strings into an `Option`\n * @see {@link fromNumber} for converting safe integers into an `Option`\n *\n * **Example** (Constructing bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * const bigInt = BigInt.BigInt(123)\n * console.log(bigInt) // 123n\n *\n * const fromString = BigInt.BigInt(\"456\")\n * console.log(fromString) // 456n\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const BigInt = globalThis.BigInt;\nconst bigint0 = /*#__PURE__*/BigInt(0);\nconst bigint1 = /*#__PURE__*/BigInt(1);\nconst bigint2 = /*#__PURE__*/BigInt(2);\n/**\n * Checks whether a value is a `bigint`.\n *\n * **When to use**\n *\n * Use to validate unknown input and narrow it to `bigint`.\n *\n * **Example** (Checking for bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.isBigInt(1n), true)\n * assert.deepStrictEqual(BigInt.isBigInt(1), false)\n * ```\n *\n * @category guards\n * @since 2.0.0\n */\nexport const isBigInt = predicate.isBigInt;\n/**\n * Provides an addition operation on `bigint`s.\n *\n * **When to use**\n *\n * Use when you need a binary addition function for piping or higher-order APIs\n * instead of the infix addition operator.\n *\n * **Example** (Adding bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.sum(2n, 3n), 5n)\n * ```\n *\n * @see {@link sumAll} for summing an iterable of `bigint` values\n *\n * @category math\n * @since 2.0.0\n */\nexport const sum = /*#__PURE__*/dual(2, (self, that) => self + that);\n/**\n * Provides a multiplication operation on `bigint`s.\n *\n * **When to use**\n *\n * Use to multiply two `bigint` values.\n *\n * **Example** (Multiplying bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.multiply(2n, 3n), 6n)\n * ```\n *\n * @see {@link multiplyAll} for multiplying an iterable of `bigint` values\n *\n * @category math\n * @since 2.0.0\n */\nexport const multiply = /*#__PURE__*/dual(2, (self, that) => self * that);\n/**\n * Provides a subtraction operation on `bigint`s.\n *\n * **When to use**\n *\n * Use to subtract one `bigint` value from another.\n *\n * **Example** (Subtracting bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.subtract(2n, 3n), -1n)\n * ```\n *\n * @category math\n * @since 2.0.0\n */\nexport const subtract = /*#__PURE__*/dual(2, (self, that) => self - that);\n/**\n * Divides one `bigint` by another safely.\n *\n * **When to use**\n *\n * Use to divide `bigint` values while representing division by zero as\n * `Option.none`.\n *\n * **Details**\n *\n * Uses JavaScript `bigint` division, so non-exact quotients are truncated\n * toward zero. Returns `Option.none()` when the divisor is `0n`.\n *\n * **Example** (Dividing bigints safely)\n *\n * ```ts\n * import { BigInt, Option } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.divide(6n, 3n), Option.some(2n))\n * assert.deepStrictEqual(BigInt.divide(6n, 0n), Option.none())\n * ```\n *\n * @see {@link divideUnsafe} for division that throws when the divisor is `0n`\n * @see {@link remainder} for the JavaScript remainder operation\n *\n * @category math\n * @since 2.0.0\n */\nexport const divide = /*#__PURE__*/dual(2, (self, that) => that === bigint0 ? Option.none() : Option.some(self / that));\n/**\n * Divides one `bigint` by another, throwing if the divisor is zero.\n *\n * **When to use**\n *\n * Use to divide `bigint` values where the divisor is known to be non-zero and\n * division by zero should be a thrown exception.\n *\n * **Details**\n *\n * Uses JavaScript `bigint` division, so non-exact quotients are truncated\n * toward zero.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` when the divisor is `0n`.\n *\n * **Example** (Dividing bigints unsafely)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.divideUnsafe(6n, 3n), 2n)\n * assert.deepStrictEqual(BigInt.divideUnsafe(6n, 4n), 1n)\n * ```\n *\n * @see {@link divide} for division that returns `Option.none` when the divisor is `0n`\n *\n * @category math\n * @since 4.0.0\n */\nexport const divideUnsafe = /*#__PURE__*/dual(2, (self, that) => self / that);\n/**\n * Returns the result of adding `1n` to a `bigint`.\n *\n * **When to use**\n *\n * Use to increment a `bigint` counter by one.\n *\n * **Example** (Incrementing a bigint)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.increment(2n), 3n)\n * ```\n *\n * @category math\n * @since 2.0.0\n */\nexport const increment = n => n + bigint1;\n/**\n * Returns the result of subtracting `1n` from a `bigint`.\n *\n * **When to use**\n *\n * Use to decrement a `bigint` counter by one.\n *\n * **Example** (Decrementing a bigint)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.decrement(3n), 2n)\n * ```\n *\n * @category math\n * @since 2.0.0\n */\nexport const decrement = n => n - bigint1;\n/**\n * Provides an `Order` instance for `bigint` that allows comparing and sorting BigInt values.\n *\n * **When to use**\n *\n * Use when you need to sort or compare bigint values through APIs that accept\n * an ordering instance.\n *\n * **Example** (Comparing bigints with Order)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * const a = 123n\n * const b = 456n\n * const c = 123n\n *\n * console.log(BigInt.Order(a, b)) // -1 (a < b)\n * console.log(BigInt.Order(b, a)) // 1 (b > a)\n * console.log(BigInt.Order(a, c)) // 0 (a === c)\n * ```\n *\n * @category instances\n * @since 2.0.0\n */\nexport const Order = order.BigInt;\n/**\n * Equivalence instance for bigints using strict equality (`===`).\n *\n * **When to use**\n *\n * Use when checking bigint equality through APIs that accept an equivalence\n * relation.\n *\n * **Example** (Comparing bigints for equivalence)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * console.log(BigInt.Equivalence(1n, 1n)) // true\n * console.log(BigInt.Equivalence(1n, 2n)) // false\n * ```\n *\n * @category instances\n * @since 2.0.0\n */\nexport const Equivalence = Equ.BigInt;\n/**\n * Returns `true` if the first argument is less than the second, otherwise `false`.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is strictly less than another.\n *\n * **Example** (Checking less-than comparisons)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.isLessThan(2n, 3n), true)\n * assert.deepStrictEqual(BigInt.isLessThan(3n, 3n), false)\n * assert.deepStrictEqual(BigInt.isLessThan(4n, 3n), false)\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThan = /*#__PURE__*/order.isLessThan(Order);\n/**\n * Returns a function that checks if a given `bigint` is less than or equal to the provided one.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is less than or equal to another.\n *\n * **Example** (Checking less-than-or-equal comparisons)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.isLessThanOrEqualTo(2n, 3n), true)\n * assert.deepStrictEqual(BigInt.isLessThanOrEqualTo(3n, 3n), true)\n * assert.deepStrictEqual(BigInt.isLessThanOrEqualTo(4n, 3n), false)\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThanOrEqualTo = /*#__PURE__*/order.isLessThanOrEqualTo(Order);\n/**\n * Returns `true` if the first argument is greater than the second, otherwise `false`.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is strictly greater than another.\n *\n * **Example** (Checking greater-than comparisons)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.isGreaterThan(2n, 3n), false)\n * assert.deepStrictEqual(BigInt.isGreaterThan(3n, 3n), false)\n * assert.deepStrictEqual(BigInt.isGreaterThan(4n, 3n), true)\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThan = /*#__PURE__*/order.isGreaterThan(Order);\n/**\n * Returns a function that checks if a given `bigint` is greater than or equal to the provided one.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is greater than or equal to another.\n *\n * **Example** (Checking greater-than-or-equal comparisons)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.isGreaterThanOrEqualTo(2n, 3n), false)\n * assert.deepStrictEqual(BigInt.isGreaterThanOrEqualTo(3n, 3n), true)\n * assert.deepStrictEqual(BigInt.isGreaterThanOrEqualTo(4n, 3n), true)\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThanOrEqualTo = /*#__PURE__*/order.isGreaterThanOrEqualTo(Order);\n/**\n * Checks whether a `bigint` is between a `minimum` and `maximum` value (inclusive).\n *\n * **When to use**\n *\n * Use to test whether a `bigint` falls inside an inclusive range.\n *\n * **Example** (Checking whether a bigint is within bounds)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const between = BigInt.between({ minimum: 0n, maximum: 5n })\n *\n * assert.deepStrictEqual(between(3n), true)\n * assert.deepStrictEqual(between(-1n), false)\n * assert.deepStrictEqual(between(6n), false)\n * ```\n *\n * @see {@link clamp} for forcing a `bigint` into an inclusive range\n *\n * @category predicates\n * @since 2.0.0\n */\nexport const between = /*#__PURE__*/order.isBetween(Order);\n/**\n * Restricts the given `bigint` to be within the range specified by the `minimum` and `maximum` values.\n *\n * **When to use**\n *\n * Use to force a `bigint` into an inclusive range.\n *\n * **Details**\n *\n * If the `bigint` is less than the minimum, the function returns the minimum.\n * If the `bigint` is greater than the maximum, the function returns the\n * maximum. Otherwise, it returns the original `bigint`.\n *\n * **Example** (Clamping a bigint to bounds)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const clamp = BigInt.clamp({ minimum: 1n, maximum: 5n })\n *\n * assert.equal(clamp(3n), 3n)\n * assert.equal(clamp(0n), 1n)\n * assert.equal(clamp(6n), 5n)\n * ```\n *\n * @see {@link between} for checking whether a `bigint` is already inside a range\n *\n * @category math\n * @since 2.0.0\n */\nexport const clamp = /*#__PURE__*/order.clamp(Order);\n/**\n * Returns the minimum between two `bigint`s.\n *\n * **When to use**\n *\n * Use to select the smaller of two `bigint` values.\n *\n * **Example** (Finding the minimum bigint)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.min(2n, 3n), 2n)\n * ```\n *\n * @see {@link max} for selecting the larger value\n *\n * @category math\n * @since 2.0.0\n */\nexport const min = /*#__PURE__*/order.min(Order);\n/**\n * Returns the maximum between two `bigint`s.\n *\n * **When to use**\n *\n * Use to select the larger of two `bigint` values.\n *\n * **Example** (Finding the maximum bigint)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.max(2n, 3n), 3n)\n * ```\n *\n * @see {@link min} for selecting the smaller value\n *\n * @category math\n * @since 2.0.0\n */\nexport const max = /*#__PURE__*/order.max(Order);\n/**\n * Determines the sign of a given `bigint`.\n *\n * **When to use**\n *\n * Use to classify a `bigint` as negative, zero, or positive.\n *\n * **Example** (Determining bigint signs)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.sign(-5n), -1)\n * assert.deepStrictEqual(BigInt.sign(0n), 0)\n * assert.deepStrictEqual(BigInt.sign(5n), 1)\n * ```\n *\n * @category math\n * @since 2.0.0\n */\nexport const sign = n => order.BigInt(n, bigint0);\n/**\n * Determines the absolute value of a given `bigint`.\n *\n * **When to use**\n *\n * Use to remove the sign from a `bigint` while preserving its magnitude.\n *\n * **Example** (Calculating absolute values)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.abs(-5n), 5n)\n * assert.deepStrictEqual(BigInt.abs(0n), 0n)\n * assert.deepStrictEqual(BigInt.abs(5n), 5n)\n * ```\n *\n * @category math\n * @since 2.0.0\n */\nexport const abs = n => n < bigint0 ? -n : n;\n/**\n * Determines the greatest common divisor of two `bigint`s.\n *\n * **When to use**\n *\n * Use to compute the greatest common divisor of two integer values.\n *\n * **Example** (Calculating greatest common divisors)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.gcd(2n, 3n), 1n)\n * assert.deepStrictEqual(BigInt.gcd(2n, 4n), 2n)\n * assert.deepStrictEqual(BigInt.gcd(16n, 24n), 8n)\n * ```\n *\n * @see {@link lcm} for computing the least common multiple\n *\n * @category math\n * @since 2.0.0\n */\nexport const gcd = /*#__PURE__*/dual(2, (self, that) => {\n while (that !== bigint0) {\n const t = that;\n that = self % that;\n self = t;\n }\n return self;\n});\n/**\n * Determines the least common multiple of two `bigint`s.\n *\n * **When to use**\n *\n * Use to compute the least common multiple of two integer values.\n *\n * **Example** (Calculating least common multiples)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.lcm(2n, 3n), 6n)\n * assert.deepStrictEqual(BigInt.lcm(2n, 4n), 4n)\n * assert.deepStrictEqual(BigInt.lcm(16n, 24n), 48n)\n * ```\n *\n * @see {@link gcd} for computing the greatest common divisor\n *\n * @category math\n * @since 2.0.0\n */\nexport const lcm = /*#__PURE__*/dual(2, (self, that) => self * that / gcd(self, that));\n/**\n * Returns the integer square root of a non-negative `bigint`.\n *\n * **When to use**\n *\n * Use when you need to compute an integer square root for a `bigint` that has\n * already been validated as non-negative, and you want negative input to throw\n * instead of returning `Option.none`.\n *\n * **Details**\n *\n * For non-perfect squares, returns the largest `bigint` whose square is less\n * than or equal to the input.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` if the input is negative.\n *\n * **Example** (Calculating square roots unsafely)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.sqrtUnsafe(4n), 2n)\n * assert.deepStrictEqual(BigInt.sqrtUnsafe(9n), 3n)\n * assert.deepStrictEqual(BigInt.sqrtUnsafe(16n), 4n)\n * ```\n *\n * @see {@link sqrt} for returning `Option.none` when the input is negative\n *\n * @category math\n * @since 4.0.0\n */\nexport const sqrtUnsafe = n => {\n if (n < bigint0) {\n throw new RangeError(\"Cannot take the square root of a negative number\");\n }\n if (n < bigint2) {\n return n;\n }\n let x = n / bigint2;\n while (x * x > n) {\n x = (n / x + x) / bigint2;\n }\n return x;\n};\n/**\n * Computes the integer square root of a `bigint` safely.\n *\n * **When to use**\n *\n * Use to compute an integer square root while representing negative input as\n * `Option.none`.\n *\n * **Details**\n *\n * For non-perfect squares, returns the largest `bigint` whose square is less\n * than or equal to the input. Returns `Option.none()` when the input is\n * negative.\n *\n * **Example** (Calculating square roots safely)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * BigInt.sqrt(4n) // Option.some(2n)\n * BigInt.sqrt(9n) // Option.some(3n)\n * BigInt.sqrt(16n) // Option.some(4n)\n * BigInt.sqrt(-1n) // Option.none()\n * ```\n *\n * @see {@link sqrtUnsafe} for square root computation that throws on negative input\n *\n * @category math\n * @since 2.0.0\n */\nexport const sqrt = n => isGreaterThanOrEqualTo(n, bigint0) ? Option.some(sqrtUnsafe(n)) : Option.none();\n/**\n * Takes an `Iterable` of `bigint`s and returns their sum as a single `bigint`. Returns `0n` for an empty iterable.\n *\n * **When to use**\n *\n * Use when you want an immediate aggregate from an iterable instead of a\n * folding reducer owned by another API.\n *\n * **Example** (Summing iterable bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.sumAll([2n, 3n, 4n]), 9n)\n * ```\n *\n * @see {@link sum} for adding two `bigint` values\n * @see {@link ReducerSum} for summing through APIs that consume a `Reducer`\n *\n * @category math\n * @since 2.0.0\n */\nexport const sumAll = collection => {\n let out = bigint0;\n for (const n of collection) {\n out += n;\n }\n return out;\n};\n/**\n * Takes an `Iterable` of `bigint`s and returns their product as a single `bigint`. Returns `1n` for an empty iterable.\n *\n * **When to use**\n *\n * Use to multiply all `bigint` values in an iterable.\n *\n * **Example** (Multiplying iterable bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * assert.deepStrictEqual(BigInt.multiplyAll([2n, 3n, 4n]), 24n)\n * ```\n *\n * @see {@link multiply} for multiplying two `bigint` values\n * @see {@link ReducerMultiply} for multiplying through APIs that consume a `Reducer`\n *\n * @category math\n * @since 2.0.0\n */\nexport const multiplyAll = collection => {\n let out = bigint1;\n for (const n of collection) {\n if (n === bigint0) {\n return bigint0;\n }\n out *= n;\n }\n return out;\n};\n/**\n * Converts a `bigint` to a `number` safely.\n *\n * **When to use**\n *\n * Use to convert a `bigint` to a JavaScript number only when it is a safe\n * integer.\n *\n * **Details**\n *\n * If the `bigint` is outside the safe integer range for JavaScript (`Number.MAX_SAFE_INTEGER`\n * and `Number.MIN_SAFE_INTEGER`), it returns `Option.none()`.\n *\n * **Example** (Converting bigints to numbers)\n *\n * ```ts\n * import { BigInt as BI } from \"effect\"\n *\n * BI.toNumber(42n) // Option.some(42)\n * BI.toNumber(BigInt(Number.MAX_SAFE_INTEGER) + 1n) // Option.none()\n * BI.toNumber(BigInt(Number.MIN_SAFE_INTEGER) - 1n) // Option.none()\n * ```\n *\n * @see {@link fromNumber} for converting a safe integer number to `bigint`\n *\n * @category converting\n * @since 2.0.0\n */\nexport const toNumber = b => {\n if (b > BigInt(Number.MAX_SAFE_INTEGER) || b < BigInt(Number.MIN_SAFE_INTEGER)) {\n return Option.none();\n }\n return Option.some(Number(b));\n};\n/**\n * Parses a string into a `bigint` safely.\n *\n * **When to use**\n *\n * Use to parse a string as a `bigint` without throwing on invalid input.\n *\n * **Details**\n *\n * If the string is empty or contains characters that cannot be converted into a\n * `bigint`, it returns `Option.none()`.\n *\n * **Example** (Parsing strings as bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * BigInt.fromString(\"42\") // Option.some(42n)\n * BigInt.fromString(\" \") // Option.none()\n * BigInt.fromString(\"a\") // Option.none()\n * ```\n *\n * @see {@link BigInt} for native constructor coercion that throws on invalid input\n *\n * @category converting\n * @since 2.4.12\n */\nexport const fromString = s => {\n try {\n return s.trim() === \"\" ? Option.none() : Option.some(BigInt(s));\n } catch {\n return Option.none();\n }\n};\n/**\n * Converts a number to a `bigint`.\n *\n * **When to use**\n *\n * Use to convert a JavaScript number to `bigint` only when it is a safe integer.\n *\n * **Details**\n *\n * If the number is outside the safe integer range for JavaScript\n * (`Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER`) or if the number is\n * not a valid `bigint`, it returns `Option.none()`.\n *\n * **Example** (Converting numbers to bigints)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * BigInt.fromNumber(42) // Option.some(42n)\n *\n * BigInt.fromNumber(Number.MAX_SAFE_INTEGER + 1) // Option.none()\n * BigInt.fromNumber(Number.MIN_SAFE_INTEGER - 1) // Option.none()\n * ```\n *\n * @see {@link toNumber} for converting `bigint` values back to safe integer numbers\n * @see {@link BigInt} for native constructor coercion\n *\n * @category converting\n * @since 2.4.12\n */\nexport function fromNumber(n) {\n if (n > Number.MAX_SAFE_INTEGER || n < Number.MIN_SAFE_INTEGER) {\n return Option.none();\n }\n try {\n return Option.some(BigInt(n));\n } catch {\n return Option.none();\n }\n}\n/**\n * Returns the JavaScript remainder of dividing one `bigint` by another.\n *\n * **When to use**\n *\n * Use when you want native remainder semantics, including signed remainders and\n * a thrown division-by-zero error.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` when the divisor is `0n`.\n *\n * **Example** (Calculating remainders)\n *\n * ```ts\n * import { BigInt } from \"effect\"\n *\n * BigInt.remainder(10n, 3n) // 1n\n *\n * BigInt.remainder(15n, 4n) // 3n\n * ```\n *\n * @see {@link divide} for quotient calculation with division-by-zero represented as `Option.none`\n *\n * @category math\n * @since 4.0.0\n */\nexport const remainder = /*#__PURE__*/dual(2, (self, divisor) => self % divisor);\n/**\n * Reducer for combining `bigint`s using addition.\n *\n * **When to use**\n *\n * Use to sum many `bigint` values through APIs that consume a `Reducer`.\n *\n * **Details**\n *\n * The initial value is `0n`, so `combineAll([])` returns `0n`.\n *\n * @see {@link sumAll} for summing an iterable directly\n * @see {@link ReducerMultiply} for multiplying `bigint` values\n *\n * @category math\n * @since 4.0.0\n */\nexport const ReducerSum = /*#__PURE__*/Reducer.make((a, b) => a + b, bigint0);\n/**\n * Reducer for combining `bigint`s using multiplication.\n *\n * **When to use**\n *\n * Use to multiply many `bigint` values through APIs that consume a `Reducer`.\n *\n * **Details**\n *\n * The initial value is `1n`, so `combineAll([])` returns `1n`.\n *\n * @see {@link multiplyAll} for multiplying an iterable directly\n * @see {@link ReducerSum} for summing `bigint` values\n *\n * @category math\n * @since 4.0.0\n */\nexport const ReducerMultiply = /*#__PURE__*/Reducer.make((a, b) => a * b, bigint1, collection => {\n let acc = bigint1;\n for (const n of collection) {\n if (n === bigint0) return bigint0;\n acc *= n;\n }\n return acc;\n});\n/**\n * Combiner that returns the maximum `bigint`.\n *\n * **When to use**\n *\n * Use to keep the largest `bigint` when an API consumes a `Combiner`.\n *\n * @see {@link CombinerMin} for keeping the smallest `bigint`\n * @see {@link max} for comparing two `bigint` values directly\n *\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMax = /*#__PURE__*/Combiner.max(Order);\n/**\n * Combiner that returns the minimum `bigint`.\n *\n * **When to use**\n *\n * Use to keep the smallest `bigint` through APIs that consume a `Combiner`.\n *\n * @see {@link CombinerMax} for keeping the largest `bigint`\n * @see {@link min} for comparing two `bigint` values directly\n *\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMin = /*#__PURE__*/Combiner.min(Order);\n//# sourceMappingURL=BigInt.js.map","import * as Channel from \"./Channel.js\";\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport * as Schema from \"./Schema.js\";\n/**\n * Creates a channel that encodes non-empty chunks of schema values into the\n * schema's encoded representation.\n *\n * **When to use**\n *\n * Use to encode typed channel input into the schema's encoded representation\n * before passing chunks to an encoded downstream boundary.\n *\n * **Details**\n *\n * Encoding failures are emitted as `SchemaError`, and any encoding services\n * required by the schema become channel requirements.\n *\n * @see {@link encodeUnknown} for encoded output chunks that should be typed as `unknown`\n * @see {@link decode} for the inverse channel that decodes encoded chunks into schema values\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const encode = schema => () => {\n const encode = Schema.encodeEffect(Schema.NonEmptyArray(schema));\n return Channel.fromTransform((upstream, _scope) => Effect.succeed(Effect.flatMap(upstream, chunk => encode(chunk))));\n};\n/**\n * Creates an `encode` channel variant whose encoded output chunks are typed as\n * `unknown`.\n *\n * **When to use**\n *\n * Use when a channel boundary should encode typed input chunks while the encoded\n * output representation is intentionally untyped.\n *\n * @see {@link encode} for the variant that preserves the schema encoded type\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const encodeUnknown = encode;\n/**\n * Creates a channel that decodes non-empty chunks from the schema's encoded\n * representation into schema values.\n *\n * **When to use**\n *\n * Use to validate and decode encoded channel output into typed schema values\n * before application code consumes it.\n *\n * **Details**\n *\n * Decoding failures are emitted as `SchemaError`, and any decoding services\n * required by the schema become channel requirements.\n *\n * @see {@link decodeUnknown} for boundaries where the encoded input side is intentionally untyped\n * @see {@link encode} for the inverse adapter that encodes typed schema values\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const decode = schema => () => {\n const decode = Schema.decodeEffect(Schema.NonEmptyArray(schema));\n return Channel.fromTransform((upstream, _scope) => Effect.succeed(Effect.flatMap(upstream, chunk => decode(chunk))));\n};\n/**\n * Creates a `decode` channel variant for schema-decoding channel boundaries.\n *\n * **When to use**\n *\n * Use when you need an intentionally unknown or untyped encoded input while\n * keeping only the decoded output statically typed according to the schema.\n *\n * **Details**\n *\n * The channel decodes non-empty encoded chunks into schema values, emits\n * `SchemaError` when decoding fails, and requires the schema's decoding\n * services.\n *\n * @see {@link decode} for the typed variant that preserves the schema's encoded type\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const decodeUnknown = decode;\n/**\n * Wraps a channel so callers work with typed input and output chunks while the\n * wrapped channel uses encoded chunks.\n *\n * **When to use**\n *\n * Use to expose typed input and output at a bidirectional channel boundary\n * while the wrapped channel continues to operate on schema-encoded chunks.\n *\n * **Details**\n *\n * Values sent into the resulting channel are encoded with `inputSchema` before\n * reaching the wrapped channel. Values emitted by the wrapped channel are\n * decoded with `outputSchema` before they are emitted downstream. Schema\n * failures are surfaced as `SchemaError`.\n *\n * @see {@link duplexUnknown} for the variant whose encoded side is intentionally untyped\n * @see {@link encode} for encoding typed chunks at one-way channel boundaries\n * @see {@link decode} for decoding encoded chunks at one-way channel boundaries\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const duplex = /*#__PURE__*/dual(2, (self, options) => encode(options.inputSchema)().pipe(Channel.pipeTo(self), Channel.pipeTo(decode(options.outputSchema)())));\n/**\n * Wraps a bidirectional channel whose encoded chunks are typed as `unknown`.\n *\n * **When to use**\n *\n * Use when you need a bidirectional channel to cross an encoded boundary whose\n * chunk types are intentionally erased, while callers send and receive\n * schema-typed chunks.\n *\n * **Details**\n *\n * The resulting channel accepts typed input chunks, encodes them with\n * `inputSchema`, decodes unknown output chunks with `outputSchema`, and\n * surfaces schema failures as `SchemaError`.\n *\n * @see {@link duplex} for the variant that preserves the schema encoded types on the wrapped channel\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const duplexUnknown = duplex;\n//# sourceMappingURL=ChannelSchema.js.map","import { dual } from \"./Function.js\";\nimport * as core from \"./internal/core.js\";\nimport * as effect from \"./internal/effect.js\";\n/**\n * Context reference for the current console service in the Effect system, allowing access to the active console implementation from within the Effect context.\n *\n * **When to use**\n *\n * Use when you need an effect to run against a provided console implementation,\n * such as tests or alternate runtimes, rather than the default console.\n *\n * **Details**\n *\n * When no override is provided, the reference resolves to `globalThis.console`.\n *\n * **Example** (Accessing the current console)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Console.consoleWith((console) =>\n * Effect.sync(() => {\n * console.log(\"Hello from current console!\")\n * })\n * )\n * ```\n *\n * @see {@link consoleWith} for using the current console service inside an effect\n *\n * @category references\n * @since 2.0.0\n */\nexport const Console = effect.ConsoleRef;\n/**\n * Creates an Effect that provides access to the current console service and lets you perform operations with it within an Effect context.\n *\n * **Example** (Accessing the current console service)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Console.consoleWith((console) =>\n * Effect.sync(() => {\n * console.log(\"Hello, world!\")\n * console.error(\"This is an error message\")\n * })\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const consoleWith = f => core.withFiber(fiber => f(fiber.getRef(Console)));\n/**\n * Writes the supplied assertion message to the console as an error when `condition` is false; when `condition` is true, no console output is produced.\n *\n * **Example** (Logging failed assertions)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.assert(2 + 2 === 4, \"Math is working correctly\")\n * yield* Console.assert(2 + 2 === 5, \"This will be logged as an error\")\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const assert = (condition, ...args) => consoleWith(console => effect.sync(() => {\n console.assert(condition, ...args);\n}));\n/**\n * Runs the current console service's clear operation.\n *\n * **When to use**\n *\n * Use to request that the active console implementation clear its visible\n * output.\n *\n * **Gotchas**\n *\n * The clearing behavior depends on the active console implementation and host\n * environment.\n *\n * **Example** (Clearing console output)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.log(\"This will be cleared\")\n * yield* Console.clear\n * yield* Console.log(\"This appears after clearing\")\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const clear = /*#__PURE__*/consoleWith(console => effect.sync(() => {\n console.clear();\n}));\n/**\n * Logs and increments the counter associated with `label`, using the console's default counter when no label is provided.\n *\n * **Example** (Counting repeated calls)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.count(\"my-counter\")\n * yield* Console.count(\"my-counter\") // Will show: my-counter: 2\n * yield* Console.count() // Default counter\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const count = label => consoleWith(console => effect.sync(() => {\n console.count(label);\n}));\n/**\n * Resets the counter associated with the specified label back to zero.\n *\n * **Example** (Resetting a counter)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.count(\"my-counter\")\n * yield* Console.count(\"my-counter\") // Will show: my-counter: 2\n * yield* Console.countReset(\"my-counter\")\n * yield* Console.count(\"my-counter\") // Will show: my-counter: 1\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const countReset = label => consoleWith(console => effect.sync(() => {\n console.countReset(label);\n}));\n/**\n * Writes a debug message through the current `Console` service.\n *\n * **Details**\n *\n * The arguments are passed to the service's `debug` method when the returned\n * Effect is executed. Any filtering behavior depends on the active console\n * implementation.\n *\n * **Example** (Writing debug messages)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.debug(\"Debug info:\", { userId: 123, action: \"login\" })\n * yield* Console.debug(\"Processing step\", 1, \"of\", 5)\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const debug = (...args) => consoleWith(console => effect.sync(() => {\n console.debug(...args);\n}));\n/**\n * Displays an interactive list of the properties of the specified object, optionally using console-specific inspection options for debugging complex data structures.\n *\n * **Example** (Inspecting an object)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const obj = { name: \"John\", age: 30, nested: { city: \"New York\" } }\n * yield* Console.dir(obj)\n * yield* Console.dir(obj, { depth: 2, colors: true })\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const dir = (item, options) => consoleWith(console => effect.sync(() => {\n console.dir(item, options);\n}));\n/**\n * Displays an interactive tree of descendant XML or HTML elements, which is particularly useful for inspecting DOM elements in browser environments.\n *\n * **Example** (Inspecting XML-like data)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.dirxml(\"<user id=\\\"1\\\">Ada</user>\")\n * })\n *\n * Effect.runSync(program)\n * // <user id=\"1\">Ada</user>\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const dirxml = (...args) => consoleWith(console => effect.sync(() => {\n console.dirxml(...args);\n}));\n/**\n * Writes an error-level message to the console, typically displayed with error\n * styling by the active console implementation.\n *\n * **Example** (Writing error messages)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.error(\"Something went wrong!\")\n * yield* Console.error(\"Error details:\", {\n * code: 500,\n * message: \"Internal Server Error\"\n * })\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const error = (...args) => consoleWith(console => effect.sync(() => {\n console.error(...args);\n}));\n/**\n * Creates a scoped console group, optionally collapsed and labeled, and closes it automatically when the Effect scope is finalized.\n *\n * **Example** (Grouping scoped output)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * yield* Console.group({ label: \"User Processing\" })\n * yield* Console.log(\"Loading user data...\")\n * yield* Console.log(\"Validating user...\")\n * yield* Console.log(\"User processed successfully\")\n * })\n * )\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const group = options => consoleWith(console => effect.acquireRelease(effect.sync(() => {\n if (options?.collapsed) {\n console.groupCollapsed(options.label);\n } else {\n console.group(options?.label);\n }\n}), () => effect.sync(() => {\n console.groupEnd();\n})));\n/**\n * Writes an informational message to the console, typically displayed with info\n * styling by the active console implementation.\n *\n * **Example** (Writing informational messages)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.info(\"Application started successfully\")\n * yield* Console.info(\"Server configuration:\", {\n * port: 3000,\n * env: \"development\"\n * })\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const info = (...args) => consoleWith(console => effect.sync(() => {\n console.info(...args);\n}));\n/**\n * Logs a general-purpose message to the console.\n *\n * **Example** (Writing log messages)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.log(\"Hello, world!\")\n * yield* Console.log(\"User data:\", { name: \"John\", age: 30 })\n * yield* Console.log(\"Processing\", 42, \"items\")\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const log = (...args) => consoleWith(console => effect.sync(() => {\n console.log(...args);\n}));\n/**\n * Displays tabular data as a formatted table in the console, optionally limited to selected properties.\n *\n * **Example** (Displaying tabular data)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const users = [\n * { name: \"John\", age: 30, city: \"New York\" },\n * { name: \"Jane\", age: 25, city: \"London\" },\n * { name: \"Bob\", age: 35, city: \"Paris\" }\n * ]\n * yield* Console.table(users)\n * yield* Console.table(users, [\"name\", \"age\"]) // Only show specific columns\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const table = (tabularData, properties) => consoleWith(console => effect.sync(() => {\n console.table(tabularData, properties);\n}));\n/**\n * Starts a scoped timer for `label` and automatically ends it when the Effect scope is finalized.\n *\n * **Example** (Timing scoped work)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * yield* Console.time(\"operation-timer\")\n * yield* Effect.sleep(\"1 second\")\n * yield* Console.log(\"Operation completed\")\n * // Timer ends automatically when scope closes\n * })\n * )\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const time = label => consoleWith(console => effect.acquireRelease(effect.sync(() => {\n console.time(label);\n}), () => effect.sync(() => {\n console.timeEnd(label);\n})));\n/**\n * Logs the elapsed time for an existing timer without stopping it, allowing progress reports for long-running operations.\n *\n * **Example** (Logging timer progress)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * yield* Console.time(\"long-operation\")\n * yield* Effect.sleep(\"500 millis\")\n * yield* Console.timeLog(\"long-operation\", \"Halfway done\")\n * yield* Effect.sleep(\"500 millis\")\n * // Timer ends when scope closes\n * })\n * )\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const timeLog = (label, ...args) => consoleWith(console => effect.sync(() => {\n console.timeLog(label, ...args);\n}));\n/**\n * Writes the current stack trace to the console to show how the current point in\n * the code was reached.\n *\n * **Example** (Writing stack traces)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.trace(\"Debug trace point\")\n * yield* Console.trace(\"Function call:\", { functionName: \"processData\" })\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const trace = (...args) => consoleWith(console => effect.sync(() => {\n console.trace(...args);\n}));\n/**\n * Writes a warning-level message to the console, typically displayed with\n * warning styling by the active console implementation.\n *\n * **Example** (Writing warning messages)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.warn(\"This feature is deprecated\")\n * yield* Console.warn(\"Performance warning:\", {\n * slowQuery: \"SELECT * FROM large_table\"\n * })\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const warn = (...args) => consoleWith(console => effect.sync(() => {\n console.warn(...args);\n}));\n/**\n * Runs an Effect inside an optionally labeled or collapsed console group, starting the group before execution and ending it after the Effect completes.\n *\n * **Example** (Wrapping an effect in a group)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.withGroup(\n * Effect.gen(function*() {\n * yield* Console.log(\"Step 1: Initialize\")\n * yield* Console.log(\"Step 2: Process\")\n * yield* Console.log(\"Step 3: Complete\")\n * }),\n * { label: \"Processing Steps\", collapsed: false }\n * )\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const withGroup = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, options) => consoleWith(console => effect.acquireUseRelease(effect.sync(() => {\n if (options?.collapsed) {\n console.groupCollapsed(options.label);\n } else {\n console.group(options?.label);\n }\n}), () => self, () => effect.sync(() => {\n console.groupEnd();\n}))));\n/**\n * Runs an Effect with a console timer, starting the timer before execution and ending it after the Effect completes.\n *\n * **Example** (Timing an effect)\n *\n * ```ts\n * import { Console, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * yield* Console.withTime(\n * Effect.gen(function*() {\n * yield* Effect.sleep(\"1 second\")\n * yield* Console.log(\"Operation completed\")\n * }),\n * \"my-operation\"\n * )\n * })\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const withTime = /*#__PURE__*/dual(args => core.isEffect(args[0]), (self, label) => consoleWith(console => effect.acquireUseRelease(effect.sync(() => {\n console.time(label);\n}), () => self, () => effect.sync(() => {\n console.timeEnd(label);\n}))));\n//# sourceMappingURL=Console.js.map","/**\n * Defines a platform-independent service for cryptographic operations.\n *\n * Runtime packages provide concrete implementations backed by the host\n * platform's cryptography APIs. This module defines the service interface and a\n * constructor from random-byte and digest primitives. The service provides\n * secure random bytes and numbers, UUIDv4 and UUIDv7 generation, shuffling, and\n * SHA message digests.\n *\n * @since 4.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as PlatformError from \"./PlatformError.js\";\nconst TypeId = \"~effect/platform/Crypto\";\n/**\n * Service tag for platform cryptography.\n *\n * **When to use**\n *\n * Use when you need to provide or retrieve the full platform cryptography\n * service from an effect's context.\n *\n * **Details**\n *\n * Providing this service supplies platform-agnostic cryptographic operations\n * such as hashing, UUID generation, and secure random values.\n *\n * @see {@link make} for constructing a Crypto service from primitive operations\n *\n * @category services\n * @since 4.0.0\n */\nexport const Crypto = /*#__PURE__*/Context.Service(\"effect/Crypto\");\n/**\n * Creates a `Crypto` service from the primitive implementation, deriving the\n * random generator helpers and UUID generation from those primitives.\n *\n * **When to use**\n *\n * Use to build a Crypto service for a platform integration, test layer, or\n * custom runtime from primitive random-byte and digest operations.\n *\n * **Details**\n *\n * The constructor derives random numbers, booleans, integer ranges, shuffling,\n * and UUID generation from `impl.randomBytes`. Digest operations delegate to\n * `impl.digest`.\n *\n * **Gotchas**\n *\n * `impl.randomBytes` must return cryptographically secure bytes of the\n * requested length. UUID formatting mutates the byte array returned for UUID\n * generation, so the implementation should return a fresh array for each call.\n *\n * **Example** (Creating a Crypto service)\n *\n * ```ts\n * import { Crypto, Effect, Layer } from \"effect\"\n *\n * const TestCrypto = Layer.succeed(\n * Crypto.Crypto,\n * Crypto.make({\n * randomBytes: (size) => new Uint8Array(size),\n * digest: (_algorithm, data) => Effect.succeed(data)\n * })\n * )\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = impl => {\n const randomBytesUnsafe = impl.randomBytes;\n const randomBytes = size => Effect.map(validateSize(\"randomBytes\", size), randomBytesUnsafe);\n const nextDoubleUnsafe = () => {\n const bytes = randomBytesUnsafe(7);\n const value = (bytes[0] & 0x1f) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6];\n return value / 2 ** 53;\n };\n const nextIntUnsafe = () => Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;\n return Crypto.of({\n [TypeId]: TypeId,\n randomBytes,\n nextDoubleUnsafe,\n nextIntUnsafe,\n digest: impl.digest,\n random: Effect.sync(() => nextDoubleUnsafe()),\n randomBoolean: Effect.sync(() => nextDoubleUnsafe() > 0.5),\n randomInt: Effect.sync(() => nextIntUnsafe()),\n randomBetween: (min, max) => Effect.sync(() => nextDoubleUnsafe() * (max - min) + min),\n randomIntBetween(min, max, options) {\n const extra = options?.halfOpen === true ? 0 : 1;\n return Effect.sync(() => {\n const minInt = Math.ceil(min);\n const maxInt = Math.floor(max);\n return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt;\n });\n },\n randomShuffle: elements => Effect.sync(() => {\n const buffer = Array.from(elements);\n for (let i = buffer.length - 1; i >= 1; i = i - 1) {\n const index = Math.min(i, Math.floor(nextDoubleUnsafe() * (i + 1)));\n const value = buffer[i];\n buffer[i] = buffer[index];\n buffer[index] = value;\n }\n return buffer;\n }),\n randomUUIDv4: Effect.sync(() => formatUUIDv4(randomBytesUnsafe(16))),\n randomUUIDv7: Effect.clockWith(clock => Effect.succeed(formatUUIDv7(clock.currentTimeMillisUnsafe(), randomBytesUnsafe(16))))\n });\n};\nconst validateSize = (method, size) => Number.isSafeInteger(size) && size >= 0 ? Effect.succeed(size) : Effect.fail(PlatformError.badArgument({\n module: \"Crypto\",\n method,\n description: \"size must be a non-negative safe integer\"\n}));\nconst hex = byte => byte.toString(16).padStart(2, \"0\");\nconst formatUUID = bytes => {\n const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)];\n return segments.map(segment => Array.from(segment, hex).join(\"\")).join(\"-\");\n};\nconst formatUUIDv4 = bytes => {\n bytes[6] = bytes[6] & 0x0f | 0x40;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n return formatUUID(bytes);\n};\nconst maxUUIDv7Timestamp = 2 ** 48 - 1;\nconst formatUUIDv7 = (timestampMillis, bytes) => {\n const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxUUIDv7Timestamp);\n bytes[0] = Math.floor(timestamp / 2 ** 40);\n bytes[1] = Math.floor(timestamp / 2 ** 32) & 0xff;\n bytes[2] = Math.floor(timestamp / 2 ** 24) & 0xff;\n bytes[3] = Math.floor(timestamp / 2 ** 16) & 0xff;\n bytes[4] = Math.floor(timestamp / 2 ** 8) & 0xff;\n bytes[5] = timestamp & 0xff;\n bytes[6] = bytes[6] & 0x0f | 0x70;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n return formatUUID(bytes);\n};\n//# sourceMappingURL=Crypto.js.map","/**\n * Interfaces for describing changes to a value as patches. A\n * `Differ<T, Patch>` compares an old and new value, creates a patch for the\n * difference, combines patches in order, and applies a patch to an old value to\n * produce an updated value.\n *\n * @since 4.0.0\n */\nexport {};\n//# sourceMappingURL=Differ.js.map","import * as Effect from \"./Effect.js\";\nimport * as effect from \"./internal/effect.js\";\nimport * as references from \"./internal/references.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as LogLevel from \"./LogLevel.js\";\n/**\n * Runtime type identifier attached to `ErrorReporter` values.\n *\n * **Details**\n *\n * This marker is part of the runtime representation of `ErrorReporter`\n * implementations. Most code should create reporters with `make` and register\n * them with `layer`.\n *\n * @category type IDs\n * @since 4.0.0\n */\nexport const TypeId = \"~effect/ErrorReporter\";\n/**\n * Creates an `ErrorReporter` from a callback.\n *\n * **When to use**\n *\n * Use to define how reported failures are forwarded to a logging, monitoring,\n * or error-tracking backend.\n *\n * **Details**\n *\n * The returned reporter automatically deduplicates causes and individual\n * errors (the same object is never reported twice), skips interruptions,\n * and resolves the `ignore`, `severity`, and `attributes` annotations on\n * each error before invoking your callback.\n *\n * **Example** (Forwarding errors to the console)\n *\n * ```ts\n * import { ErrorReporter } from \"effect\"\n *\n * // Forward every failure to the console\n * const consoleReporter = ErrorReporter.make(\n * ({ error, severity, attributes }) => {\n * console.error(`[${severity}]`, error.message, attributes)\n * }\n * )\n * ```\n *\n * @see {@link layer} for registering reporters in the environment\n * @see {@link report} for manually reporting a `Cause`\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = report => {\n const reported = new WeakSet();\n return {\n [TypeId]: TypeId,\n report(options) {\n if (reported.has(options.cause)) return;\n reported.add(options.cause);\n for (let i = 0; i < options.cause.reasons.length; i++) {\n const reason = options.cause.reasons[i];\n if (reason._tag === \"Interrupt\") continue;\n const original = reason._tag === \"Fail\" ? reason.error : reason.defect;\n const isObject = typeof original === \"object\" && original !== null;\n if (isObject) {\n if (reported.has(original)) continue;\n reported.add(original);\n }\n if (isIgnored(original)) continue;\n const pretty = effect.causePrettyError(original, reason.annotations);\n report({\n ...options,\n error: pretty,\n severity: isObject ? getSeverity(original) : \"Info\",\n attributes: isObject ? getAttributes(original) : emptyAttributes\n });\n }\n }\n };\n};\n/**\n * Context reference that holds the set of active error reporters for the\n * current fiber. Defaults to an empty set (no reporting).\n *\n * **When to use**\n *\n * Use when you need to read or replace the current set of error reporters\n * directly.\n *\n * @category references\n * @since 4.0.0\n */\nexport const CurrentErrorReporters = references.CurrentErrorReporters;\n/**\n * Creates a `Layer` that registers one or more `ErrorReporter`s.\n *\n * **When to use**\n *\n * Use to provide one or more error reporters to effects that perform error\n * reporting.\n *\n * **Details**\n *\n * Reporters can be plain `ErrorReporter` values or effectful\n * `Effect<ErrorReporter>` values that are resolved when the layer is built. By\n * default the provided reporters **replace** any previously registered\n * reporters. Set `mergeWithExisting: true` to add them alongside existing ones.\n *\n * **Example** (Providing error reporters)\n *\n * ```ts\n * import { Effect, ErrorReporter } from \"effect\"\n *\n * const consoleReporter = ErrorReporter.make(({ error, severity }) => {\n * console.error(`[${severity}]`, error.message)\n * })\n *\n * const metricsReporter = ErrorReporter.make(({ severity }) => {\n * // increment an error counter by severity\n * })\n *\n * // Replace all existing reporters\n * const ReporterLive = ErrorReporter.layer([\n * consoleReporter,\n * metricsReporter\n * ])\n *\n * // Add to existing reporters instead of replacing\n * const ReporterMerged = ErrorReporter.layer(\n * [metricsReporter],\n * { mergeWithExisting: true }\n * )\n *\n * const program = Effect.fail(\"boom\").pipe(\n * Effect.withErrorReporting,\n * Effect.provide(ReporterLive)\n * )\n * ```\n *\n * @see {@link make} for creating an `ErrorReporter` from a callback\n * @see {@link CurrentErrorReporters} for low-level access to the current reporters\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layer = (reporters, options) => Layer.effect(CurrentErrorReporters, Effect.withFiber(Effect.fnUntraced(function* (fiber) {\n const currentReporters = new Set(options?.mergeWithExisting === true ? fiber.getRef(references.CurrentErrorReporters) : []);\n for (const reporter of reporters) {\n currentReporters.add(Effect.isEffect(reporter) ? yield* reporter : reporter);\n }\n return currentReporters;\n})));\n/**\n * Runs all registered error reporters on the current fiber for a `Cause`.\n *\n * **When to use**\n *\n * Use to report a failure for observability without failing the current fiber.\n *\n * **Example** (Reporting a cause manually)\n *\n * ```ts\n * import { Cause, Effect, ErrorReporter } from \"effect\"\n *\n * // Log the cause for monitoring, then continue with a fallback\n * const program = Effect.gen(function*() {\n * const cause = Cause.fail(\"something went wrong\")\n * yield* ErrorReporter.report(cause)\n * return \"fallback value\"\n * })\n * ```\n *\n * @category Reporting\n * @since 4.0.0\n */\nexport const report = cause => Effect.withFiber(fiber => {\n effect.reportCauseUnsafe(fiber, cause);\n return Effect.void;\n});\n/**\n * Defines the runtime property key used to mark an object error as ignored by error\n * reporting.\n *\n * **When to use**\n *\n * Use to suppress reporting for expected object errors, such as HTTP 404\n * responses.\n *\n * **Details**\n *\n * Set `error[ErrorReporter.ignore]` to `true` to prevent the error from being\n * forwarded to reporters. This is useful for expected failures such as HTTP 404\n * responses.\n *\n * **Example** (Marking errors as ignored)\n *\n * ```ts\n * import { Data, ErrorReporter } from \"effect\"\n *\n * class NotFoundError extends Data.TaggedError(\"NotFoundError\")<{}> {\n * readonly [ErrorReporter.ignore] = true\n * }\n * ```\n *\n * @see {@link isIgnored} for checking whether a value carries this annotation\n * @see {@link Reportable} for the annotation contract recognized on object\n * errors\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const ignore = \"~effect/ErrorReporter/ignore\";\n/**\n * Returns `true` if the given value has the `ErrorReporter.ignore` annotation\n * set to `true`.\n *\n * **When to use**\n *\n * Use to check whether an error value is annotated to be skipped before\n * forwarding it to error reporting code.\n *\n * @see {@link ignore} for the annotation key this predicate reads\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const isIgnored = u => typeof u === \"object\" && u !== null && ignore in u && u[ignore] === true;\n/**\n * Defines the runtime property key used to override the severity level of an object error.\n *\n * **When to use**\n *\n * Use to annotate object errors with the severity reporter callbacks should\n * receive.\n *\n * **Details**\n *\n * Set `error[ErrorReporter.severity]` to a valid `LogLevel.Severity` value.\n * Missing or invalid values fall back to `\"Info\"`.\n *\n * **Example** (Setting error severity annotations)\n *\n * ```ts\n * import { Data, ErrorReporter } from \"effect\"\n *\n * class DeprecationWarning extends Data.TaggedError(\"DeprecationWarning\")<{}> {\n * readonly [ErrorReporter.severity] = \"Warn\" as const\n * }\n * ```\n *\n * @see {@link getSeverity} for reading the severity stored under this key\n * @see {@link Reportable} for the annotation contract recognized on object\n * errors\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const severity = \"~effect/ErrorReporter/severity\";\n/**\n * Reads the `ErrorReporter.severity` annotation from an error object,\n * falling back to `\"Info\"` when the annotation is unset or invalid.\n *\n * **When to use**\n *\n * Use to inspect the severity that reporter callbacks will receive for an\n * object error.\n *\n * @see {@link severity} for the annotation key used to override severity\n * @see {@link Reportable} for the annotation properties recognized on object errors\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const getSeverity = error => {\n if (severity in error && LogLevel.values.includes(error[severity])) {\n return error[severity];\n }\n return \"Info\";\n};\n/**\n * Defines the runtime property key used to attach extra key/value metadata to an object\n * error report.\n *\n * **When to use**\n *\n * Use to attach domain metadata to object errors so reporter callbacks receive\n * it with the reported failure.\n *\n * **Details**\n *\n * Set `error[ErrorReporter.attributes]` to a record of metadata that should be\n * forwarded to reporters alongside the error.\n *\n * **Example** (Setting error attributes)\n *\n * ```ts\n * import { Data, ErrorReporter } from \"effect\"\n *\n * class PaymentError extends Data.TaggedError(\"PaymentError\")<{\n * readonly orderId: string\n * }> {\n * readonly [ErrorReporter.attributes] = {\n * orderId: this.orderId\n * }\n * }\n * ```\n *\n * @see {@link ignore} for suppressing reports for expected object errors\n * @see {@link severity} for overriding reporter severity\n * @see {@link getAttributes} for reading the metadata stored under this key\n * @see {@link Reportable} for the annotation contract recognized on object\n * errors\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const attributes = \"~effect/ErrorReporter/attributes\";\n/**\n * Reads the `ErrorReporter.attributes` annotation from an error object,\n * returning an empty record when unset.\n *\n * **When to use**\n *\n * Use to inspect the attributes that reporter callbacks will receive for an\n * object error.\n *\n * **Details**\n *\n * Returns the value stored under `ErrorReporter.attributes`, or the module's\n * shared empty record when the annotation is absent.\n *\n * **Gotchas**\n *\n * The annotation value is returned as-is; this helper does not validate or\n * clone it.\n *\n * @see {@link attributes} for the annotation key used to attach metadata\n * @see {@link Reportable} for the annotation properties recognized on object errors\n *\n * @category annotations\n * @since 4.0.0\n */\nexport const getAttributes = error => {\n return attributes in error ? error[attributes] : emptyAttributes;\n};\nconst emptyAttributes = {};\n//# sourceMappingURL=ErrorReporter.js.map","/**\n * Manages at most one fiber inside a scope.\n *\n * A `FiberHandle<A, E>` can hold one `Fiber<A, E>`. Installing a new fiber\n * interrupts the previous one unless the operation is configured with\n * `onlyIfMissing`, and closing the owning scope interrupts the current fiber.\n * This module includes constructors for handles and scoped runtimes, helpers\n * for setting, reading, clearing, and running fibers, and operations for joining\n * the current fiber or waiting until the handle is empty.\n *\n * @since 2.0.0\n */\nimport * as Cause from \"./Cause.js\";\nimport * as Deferred from \"./Deferred.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport * as Filter from \"./Filter.js\";\nimport { dual } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Option from \"./Option.js\";\nimport * as Predicate from \"./Predicate.js\";\nconst TypeId = \"~effect/FiberHandle\";\n/**\n * Returns `true` if a value is a `FiberHandle` by checking for the\n * `FiberHandle` runtime marker.\n *\n * **Example** (Checking fiber handles)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * console.log(FiberHandle.isFiberHandle(handle)) // true\n * console.log(FiberHandle.isFiberHandle(\"not a handle\")) // false\n * })\n * ```\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isFiberHandle = u => Predicate.hasProperty(u, TypeId);\nconst Proto = {\n [TypeId]: TypeId,\n ...PipeInspectableProto,\n toJSON() {\n return {\n _id: \"FiberHandle\",\n state: this.state\n };\n }\n};\nconst makeUnsafe = () => {\n const self = Object.create(Proto);\n self.state = {\n _tag: \"Open\",\n fiber: undefined\n };\n self.deferred = Deferred.makeUnsafe();\n return self;\n};\n/**\n * Creates a scoped `FiberHandle` that can store a single fiber.\n *\n * **Details**\n *\n * When the associated `Scope` is closed, the contained fiber will be\n * interrupted. You can add a fiber to the handle using `FiberHandle.run`, and\n * the fiber will be automatically removed from the `FiberHandle` when it\n * completes.\n *\n * **Example** (Creating a scoped fiber handle)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // run some effects\n * yield* FiberHandle.run(handle, Effect.never)\n * // this will interrupt the previous fiber\n * yield* FiberHandle.run(handle, Effect.never)\n *\n * yield* Effect.sleep(1000)\n * }).pipe(\n * Effect.scoped // The fiber will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = () => Effect.acquireRelease(Effect.sync(() => makeUnsafe()), handle => {\n const state = handle.state;\n if (state._tag === \"Closed\") return Effect.void;\n handle.state = {\n _tag: \"Closed\"\n };\n return state.fiber ? Deferred.into(Effect.asVoid(Fiber.interruptAs(state.fiber, internalFiberId)), handle.deferred) : Deferred.done(handle.deferred, Exit.void);\n});\n/**\n * Creates a scoped run function that forks effects into a new `FiberHandle`.\n *\n * **Details**\n *\n * Each call returns the forked fiber, stores it in the handle, and interrupts\n * the previous fiber unless `onlyIfMissing` is set. The managed fiber is\n * interrupted when the handle's scope closes.\n *\n * **Example** (Running effects with a fiber handle)\n *\n * ```ts\n * import { Effect, Fiber, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const run = yield* FiberHandle.makeRuntime<never>()\n *\n * // Run effects and get fibers back\n * const fiberA = run(Effect.succeed(\"first\"))\n * const fiberB = run(Effect.succeed(\"second\"))\n *\n * // The second fiber will interrupt the first\n * const resultA = yield* Fiber.await(fiberA)\n * const resultB = yield* Fiber.await(fiberB)\n * }).pipe(Effect.scoped)\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeRuntime = () => Effect.flatMap(make(), self => runtime(self)());\n/**\n * Creates a scoped run function that forks effects into a new `FiberHandle`\n * and returns a `Promise` for each effect result.\n *\n * **When to use**\n *\n * Use when integrating a scoped `FiberHandle` runner with Promise-based APIs\n * and Promise rejection from squashed failures is the desired boundary.\n *\n * **Details**\n *\n * Each call stores the fiber in the handle and interrupts the previous fiber\n * unless `onlyIfMissing` is set. The returned Promise resolves with the\n * effect's success value or rejects with the squashed failure cause.\n *\n * **Example** (Running effects as promises)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const run = yield* FiberHandle.makeRuntimePromise()\n *\n * // Run effects and get promises back\n * const promise = run(Effect.succeed(\"hello\"))\n * const result = yield* Effect.promise(() => promise)\n * console.log(result) // \"hello\"\n * }).pipe(Effect.scoped)\n * ```\n *\n * @category constructors\n * @since 3.13.0\n */\nexport const makeRuntimePromise = () => Effect.flatMap(make(), self => runtimePromise(self)());\nconst internalFiberId = -1;\nconst isInternalInterruption = /*#__PURE__*/Filter.toPredicate(/*#__PURE__*/Filter.compose(Cause.filterInterruptors, /*#__PURE__*/Filter.has(internalFiberId)));\n/**\n * Sets the fiber in a FiberHandle. When the fiber completes, it will be removed from the FiberHandle.\n * If a fiber is already running, it will be interrupted unless `options.onlyIfMissing` is set.\n *\n * **When to use**\n *\n * Use when an existing forked fiber must be installed synchronously into a\n * handle and immediate interruption of replaced or closed fibers is acceptable.\n *\n * **Example** (Setting a fiber unsafely)\n *\n * ```ts\n * import { Effect, Fiber, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n * const fiber = Effect.runFork(Effect.succeed(\"hello\"))\n *\n * // Set the fiber directly (unsafe)\n * FiberHandle.setUnsafe(handle, fiber)\n *\n * // The fiber is now managed by the handle\n * const result = yield* Fiber.await(fiber)\n * console.log(result) // \"hello\"\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const setUnsafe = /*#__PURE__*/dual(args => isFiberHandle(args[0]), (self, fiber, options) => {\n if (self.state._tag === \"Closed\") {\n fiber.interruptUnsafe(internalFiberId);\n return;\n } else if (self.state.fiber !== undefined) {\n if (options?.onlyIfMissing === true) {\n fiber.interruptUnsafe(internalFiberId);\n return;\n } else if (self.state.fiber === fiber) {\n return;\n }\n self.state.fiber.interruptUnsafe(internalFiberId);\n self.state.fiber = undefined;\n }\n self.state.fiber = fiber;\n fiber.addObserver(exit => {\n if (self.state._tag === \"Open\" && fiber === self.state.fiber) {\n self.state.fiber = undefined;\n }\n if (Exit.isFailure(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !Cause.hasInterruptsOnly(exit.cause))) {\n Deferred.doneUnsafe(self.deferred, exit);\n }\n });\n});\n/**\n * Sets the fiber in the `FiberHandle`.\n *\n * **Details**\n *\n * When the fiber completes, it will be removed from the `FiberHandle`. If a\n * fiber already exists in the `FiberHandle`, it will be interrupted unless\n * `options.onlyIfMissing` is set.\n *\n * **Example** (Setting a fiber safely)\n *\n * ```ts\n * import { Effect, Fiber, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n * const fiber = Effect.runFork(Effect.succeed(\"hello\"))\n *\n * // Set the fiber safely\n * yield* FiberHandle.set(handle, fiber)\n *\n * // The fiber is now managed by the handle\n * const result = yield* Fiber.await(fiber)\n * console.log(result) // \"hello\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(args => isFiberHandle(args[0]), (self, fiber, options) => Effect.sync(() => setUnsafe(self, fiber, {\n onlyIfMissing: options?.onlyIfMissing,\n propagateInterruption: options?.propagateInterruption\n})));\n/**\n * Retrieves the fiber from the FiberHandle synchronously.\n *\n * **When to use**\n *\n * Use when synchronous inspection of the current fiber is needed and an\n * `Option` result is enough outside the Effect workflow.\n *\n * **Example** (Reading the current fiber unsafely)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // No fiber initially\n * const emptyFiber = FiberHandle.getUnsafe(handle)\n * console.log(emptyFiber._tag === \"None\") // true\n *\n * // Add a fiber\n * yield* FiberHandle.run(handle, Effect.succeed(\"hello\"))\n * const fiber = FiberHandle.getUnsafe(handle)\n * console.log(fiber._tag === \"Some\") // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport function getUnsafe(self) {\n return self.state._tag === \"Closed\" ? Option.none() : Option.fromUndefinedOr(self.state.fiber);\n}\n/**\n * Retrieves the fiber from the FiberHandle effectfully.\n *\n * **Example** (Reading the current fiber)\n *\n * ```ts\n * import { Effect, Fiber, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // Add a fiber\n * yield* FiberHandle.run(handle, Effect.succeed(\"hello\"))\n *\n * // Get the current fiber if present\n * const fiber = yield* FiberHandle.get(handle)\n * if (fiber._tag === \"Some\") {\n * const result = yield* Fiber.await(fiber.value)\n * console.log(result) // \"hello\"\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport function get(self) {\n return Effect.suspend(() => Effect.succeed(getUnsafe(self)));\n}\n/**\n * Interrupts the fiber currently stored in the `FiberHandle`, if any, and\n * leaves the handle empty.\n *\n * **Example** (Clearing a fiber handle)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // Add a fiber\n * yield* FiberHandle.run(handle, Effect.never)\n *\n * // Clear the handle, interrupting the fiber\n * yield* FiberHandle.clear(handle)\n *\n * // The handle is now empty\n * const fiber = FiberHandle.getUnsafe(handle)\n * console.log(fiber) // Option.none()\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const clear = self => Effect.uninterruptibleMask(restore => {\n if (self.state._tag === \"Closed\" || self.state.fiber === undefined) {\n return Effect.void;\n }\n return Effect.andThen(restore(Fiber.interruptAs(self.state.fiber, internalFiberId)), Effect.sync(() => {\n if (self.state._tag === \"Open\") {\n self.state.fiber = undefined;\n }\n }));\n});\nconst constInterruptedFiber = /*#__PURE__*/function () {\n let fiber = undefined;\n return () => {\n if (fiber === undefined) {\n fiber = Effect.runFork(Effect.interrupt);\n }\n return fiber;\n };\n}();\n/**\n * Forks an Effect and stores the resulting fiber in the `FiberHandle`.\n *\n * **Details**\n *\n * The handle manages only one fiber: running a new effect interrupts the\n * previous fiber unless `onlyIfMissing` is set. When the managed fiber\n * completes, it is removed from the handle.\n *\n * **Example** (Running an effect in a fiber handle)\n *\n * ```ts\n * import { Effect, Fiber, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // Run an effect and get the fiber\n * const fiber = yield* FiberHandle.run(handle, Effect.succeed(\"hello\"))\n * const result = yield* Fiber.await(fiber)\n * console.log(result) // \"hello\"\n *\n * // Running another effect will interrupt the previous one\n * const fiber2 = yield* FiberHandle.run(handle, Effect.succeed(\"world\"))\n * const result2 = yield* Fiber.await(fiber2)\n * console.log(result2) // \"world\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const run = function () {\n const self = arguments[0];\n if (Effect.isEffect(arguments[1])) {\n return runImpl(self, arguments[1], arguments[2]);\n }\n const options = arguments[1];\n return effect => runImpl(self, effect, options);\n};\nconst runImpl = (self, effect, options) => Effect.withFiber(parent => {\n if (self.state._tag === \"Closed\") {\n return Effect.interrupt;\n } else if (self.state.fiber !== undefined && options?.onlyIfMissing === true) {\n return Effect.sync(constInterruptedFiber);\n }\n const fiber = Effect.runForkWith(parent.context)(effect);\n setUnsafe(self, fiber, options);\n return Effect.succeed(fiber);\n});\n/**\n * Captures the current runtime and returns a function for forking effects into\n * an existing `FiberHandle`.\n *\n * **Details**\n *\n * Each call returns the forked fiber, stores it in the handle, and interrupts\n * the previous fiber unless `onlyIfMissing` is set.\n *\n * **Example** (Capturing a runtime for fiber handles)\n *\n * ```ts\n * import { Context, Effect, FiberHandle } from \"effect\"\n *\n * interface Users {\n * readonly _: unique symbol\n * }\n * const Users = Context.Service<Users, {\n * getAll: Effect.Effect<Array<unknown>>\n * }>(\"Users\")\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n * const run = yield* FiberHandle.runtime(handle)<Users>()\n *\n * // run an effect and set the fiber in the handle\n * run(Effect.andThen(Users, (_) => _.getAll))\n *\n * // this will interrupt the previous fiber\n * run(Effect.andThen(Users, (_) => _.getAll))\n * }).pipe(\n * Effect.scoped // The fiber will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const runtime = self => () => Effect.map(Effect.context(), services => {\n const runFork = Effect.runForkWith(services);\n return (effect, options) => {\n if (self.state._tag === \"Closed\") {\n return constInterruptedFiber();\n } else if (self.state.fiber !== undefined && options?.onlyIfMissing === true) {\n return constInterruptedFiber();\n }\n const fiber = runFork(effect, options);\n setUnsafe(self, fiber, options);\n return fiber;\n };\n});\n/**\n * Captures the current runtime and returns a function for running effects in\n * an existing `FiberHandle` as Promises.\n *\n * **Details**\n *\n * Each call stores the forked fiber in the handle and interrupts the previous\n * fiber unless `onlyIfMissing` is set. The Promise resolves with the effect's\n * success value or rejects with the squashed failure cause.\n *\n * **Example** (Capturing a runtime for promises)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n * const runPromise = yield* FiberHandle.runtimePromise(handle)<never>()\n *\n * // Run an effect and get a promise\n * const promise = runPromise(Effect.succeed(\"hello\"))\n * const result = yield* Effect.promise(() => promise)\n * console.log(result) // \"hello\"\n * })\n * ```\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const runtimePromise = self => () => Effect.map(runtime(self)(), runFork => (effect, options) => new Promise((resolve, reject) => runFork(effect, options).addObserver(exit => {\n if (Exit.isSuccess(exit)) {\n resolve(exit.value);\n } else {\n reject(Cause.squash(exit.cause));\n }\n})));\n/**\n * Waits for the `FiberHandle` to fail or close.\n *\n * **Details**\n *\n * The returned Effect fails with the first managed fiber failure that is not\n * ignored by the handle's interruption rules. Normal successful completion of\n * a managed fiber only removes it from the handle; use `awaitEmpty` to wait\n * for the current fiber to finish.\n *\n * **Example** (Propagating fiber failures)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n * yield* FiberHandle.set(handle, Effect.runFork(Effect.fail(\"error\")))\n *\n * // parent fiber will fail with \"error\"\n * yield* FiberHandle.join(handle)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const join = self => Deferred.await(self.deferred);\n/**\n * Waits for the fiber in the FiberHandle to complete.\n *\n * **Example** (Waiting for a fiber to complete)\n *\n * ```ts\n * import { Effect, FiberHandle } from \"effect\"\n *\n * Effect.gen(function*() {\n * const handle = yield* FiberHandle.make()\n *\n * // Start a long-running effect\n * yield* FiberHandle.run(handle, Effect.sleep(1000))\n *\n * // Wait for the fiber to complete\n * yield* FiberHandle.awaitEmpty(handle)\n *\n * console.log(\"Fiber completed\")\n * })\n * ```\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const awaitEmpty = self => Effect.suspend(() => {\n if (self.state._tag === \"Closed\" || self.state.fiber === undefined) {\n return Effect.void;\n }\n return Fiber.await(self.state.fiber);\n});\n//# sourceMappingURL=FiberHandle.js.map","/**\n * Manages fibers by key inside a scope.\n *\n * A `FiberMap<K, A, E>` owns a map of running fibers, interrupts them when its\n * scope closes, and automatically removes each entry when the corresponding\n * fiber completes. Use it when a program needs to start, replace, join, or\n * interrupt background work by a stable key while keeping all fibers tied to\n * one scope.\n *\n * @since 2.0.0\n */\nimport * as Cause from \"./Cause.js\";\nimport * as Deferred from \"./Deferred.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport * as Filter from \"./Filter.js\";\nimport { constVoid, dual } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport * as Option from \"./Option.js\";\nimport * as Predicate from \"./Predicate.js\";\nconst TypeId = \"~effect/FiberMap\";\n/**\n * Returns `true` if a value is a `FiberMap`.\n *\n * **Details**\n *\n * This is a type guard that checks for the `FiberMap` runtime marker.\n *\n * **Example** (Checking if a value is a FiberMap)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * console.log(FiberMap.isFiberMap(map)) // true\n * console.log(FiberMap.isFiberMap({})) // false\n * console.log(FiberMap.isFiberMap(null)) // false\n * })\n * ```\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isFiberMap = u => Predicate.hasProperty(u, TypeId);\nconst Proto = {\n [TypeId]: TypeId,\n [Symbol.iterator]() {\n if (this.state._tag === \"Closed\") {\n return Iterable.empty();\n }\n return this.state.backing[Symbol.iterator]();\n },\n ...PipeInspectableProto,\n toJSON() {\n return {\n _id: \"FiberMap\",\n state: this.state\n };\n }\n};\nconst makeUnsafe = (backing, deferred) => {\n const self = Object.create(Proto);\n self.state = {\n _tag: \"Open\",\n backing\n };\n self.deferred = deferred;\n return self;\n};\n/**\n * Creates a scoped `FiberMap` for storing fibers by key.\n *\n * **Details**\n *\n * When the associated Scope is closed, all fibers in the map will be\n * interrupted. You can add fibers to the map using `FiberMap.set` or\n * `FiberMap.run`, and the fibers will be automatically removed from the\n * `FiberMap` when they complete.\n *\n * **Example** (Creating a scoped FiberMap)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // run some effects and add the fibers to the map\n * yield* FiberMap.run(map, \"fiber a\", Effect.never)\n * yield* FiberMap.run(map, \"fiber b\", Effect.never)\n *\n * yield* Effect.sleep(1000)\n * }).pipe(\n * Effect.scoped // The fibers will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = () => Effect.acquireRelease(Effect.sync(() => makeUnsafe(MutableHashMap.empty(), Deferred.makeUnsafe())), map => Effect.suspend(() => {\n const state = map.state;\n if (state._tag === \"Closed\") return Effect.void;\n map.state = {\n _tag: \"Closed\"\n };\n return Fiber.interruptAll(MutableHashMap.values(state.backing)).pipe(Deferred.into(map.deferred));\n}));\n/**\n * Creates a scoped run function that forks effects into a new `FiberMap`.\n *\n * **Details**\n *\n * Each call stores the forked fiber under the supplied key and returns that\n * fiber. If the key already has a fiber, the previous fiber is interrupted\n * unless `onlyIfMissing` is set. All managed fibers are interrupted when the\n * map's scope closes.\n *\n * **Example** (Creating a scoped runtime)\n *\n * ```ts\n * import { Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const run = yield* FiberMap.makeRuntime<never, string>()\n *\n * // Run effects and get back fibers\n * const fiber1 = run(\"task1\", Effect.succeed(\"Hello\"))\n * const fiber2 = run(\"task2\", Effect.succeed(\"World\"))\n *\n * // Join the fibers to get their successful values\n * const result1 = yield* Fiber.join(fiber1)\n * const result2 = yield* Fiber.join(fiber2)\n *\n * console.log(result1, result2) // \"Hello\", \"World\"\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeRuntime = () => Effect.flatMap(make(), self => runtime(self)());\n/**\n * Creates a scoped run function that forks effects into a new `FiberMap` and\n * returns a `Promise` for each effect result.\n *\n * **When to use**\n *\n * Use when keyed fibers must be managed in a scoped map while exposing their\n * results through Promise-based APIs.\n *\n * **Details**\n *\n * Each call stores the fiber under the supplied key, interrupting any previous\n * fiber for that key unless `onlyIfMissing` is set. The returned Promise\n * resolves with the effect's success value or rejects with the squashed failure\n * cause.\n *\n * **Example** (Creating a promise runtime)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const run = yield* FiberMap.makeRuntimePromise<never, string>()\n *\n * // Run effects and get back promises\n * const promise1 = run(\"task1\", Effect.succeed(\"Hello\"))\n * const promise2 = run(\"task2\", Effect.succeed(\"World\"))\n *\n * // Convert to Effect and await\n * const result1 = yield* Effect.promise(() => promise1)\n * const result2 = yield* Effect.promise(() => promise2)\n *\n * console.log(result1, result2) // \"Hello\", \"World\"\n * })\n * ```\n *\n * @category constructors\n * @since 3.13.0\n */\nexport const makeRuntimePromise = () => Effect.flatMap(make(), self => runtimePromise(self)());\nconst internalFiberId = -1;\nconst isInternalInterruption = /*#__PURE__*/Filter.toPredicate(/*#__PURE__*/Filter.compose(Cause.filterInterruptors, /*#__PURE__*/Filter.has(internalFiberId)));\n/**\n * Adds a fiber to the `FiberMap` under a key using a synchronous, unsafe\n * mutation.\n *\n * **When to use**\n *\n * Use when an existing forked fiber must be installed under a key immediately\n * and synchronous interruption of the replaced fiber is acceptable.\n *\n * **Details**\n *\n * When the fiber completes, it is removed from the map. If the key already has\n * a fiber, that previous fiber is interrupted unless `onlyIfMissing` is set;\n * in that case the new fiber is interrupted and the existing entry is kept.\n *\n * **Example** (Adding a fiber unsafely)\n *\n * ```ts\n * import { Deferred, Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const deferred = yield* Deferred.make<string>()\n *\n * // Create a fiber and add it to the map\n * const fiber = yield* Effect.forkChild(Deferred.await(deferred))\n * FiberMap.setUnsafe(map, \"greeting\", fiber)\n *\n * yield* Deferred.succeed(deferred, \"Hello\")\n *\n * // Join the fiber to get its successful value\n * const result = yield* Fiber.join(fiber)\n * console.log(result) // \"Hello\"\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const setUnsafe = /*#__PURE__*/dual(args => isFiberMap(args[0]), (self, key, fiber, options) => {\n if (self.state._tag === \"Closed\") {\n fiber.interruptUnsafe(internalFiberId);\n return;\n }\n const previous = MutableHashMap.get(self.state.backing, key);\n if (previous._tag === \"Some\") {\n if (options?.onlyIfMissing === true) {\n fiber.interruptUnsafe(internalFiberId);\n return;\n } else if (previous.value === fiber) {\n return;\n }\n previous.value.interruptUnsafe(internalFiberId);\n }\n MutableHashMap.set(self.state.backing, key, fiber);\n fiber.addObserver(exit => {\n if (self.state._tag === \"Closed\") {\n return;\n }\n const current = MutableHashMap.get(self.state.backing, key);\n if (Option.isSome(current) && fiber === current.value) {\n MutableHashMap.remove(self.state.backing, key);\n }\n if (Exit.isFailure(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !Cause.hasInterruptsOnly(exit.cause))) {\n Deferred.doneUnsafe(self.deferred, exit);\n }\n });\n});\n/**\n * Adds a fiber to the `FiberMap` under a key.\n *\n * **Details**\n *\n * When the fiber completes, it is removed from the map. If the key already has\n * a fiber, that previous fiber is interrupted unless `onlyIfMissing` is set;\n * in that case the new fiber is interrupted and the existing entry is kept.\n *\n * This is the Effect-wrapped version of `setUnsafe`.\n *\n * **Example** (Adding a fiber)\n *\n * ```ts\n * import { Deferred, Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const deferred = yield* Deferred.make<string>()\n *\n * // Create a fiber and add it to the map using Effect\n * const fiber = yield* Effect.forkChild(Deferred.await(deferred))\n * yield* FiberMap.set(map, \"greeting\", fiber)\n *\n * yield* Deferred.succeed(deferred, \"Hello\")\n *\n * // Join the fiber to get its successful value\n * const result = yield* Fiber.join(fiber)\n * console.log(result) // \"Hello\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(args => isFiberMap(args[0]), (self, key, fiber, options) => Effect.sync(() => setUnsafe(self, key, fiber, options)));\n/**\n * Retrieves a fiber from the FiberMap synchronously.\n *\n * **When to use**\n *\n * Use when synchronous keyed lookup of a fiber in a `FiberMap` is needed and an\n * `Option` result is enough outside the Effect workflow.\n *\n * **Example** (Retrieving a fiber unsafely)\n *\n * ```ts\n * import { Deferred, Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const deferred = yield* Deferred.make<string>()\n *\n * // Add a fiber to the map\n * const fiber = yield* Effect.forkChild(Deferred.await(deferred))\n * FiberMap.setUnsafe(map, \"greeting\", fiber)\n *\n * // Retrieve the fiber\n * const retrieved = FiberMap.getUnsafe(map, \"greeting\")\n * if (retrieved._tag === \"Some\") {\n * yield* Deferred.succeed(deferred, \"Hello\")\n *\n * const result = yield* Fiber.join(retrieved.value)\n * console.log(result) // \"Hello\"\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getUnsafe = /*#__PURE__*/dual(2, (self, key) => {\n return self.state._tag === \"Closed\" ? Option.none() : MutableHashMap.get(self.state.backing, key);\n});\n/**\n * Retrieves a fiber from the FiberMap effectfully.\n *\n * **Details**\n *\n * Returns an `Option` wrapped in `Effect`.\n *\n * **Example** (Retrieving a fiber)\n *\n * ```ts\n * import { Deferred, Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const deferred = yield* Deferred.make<string>()\n *\n * // Add a fiber to the map\n * const fiber = yield* Effect.forkChild(Deferred.await(deferred))\n * yield* FiberMap.set(map, \"greeting\", fiber)\n *\n * // Retrieve the fiber with error handling\n * const retrieved = yield* FiberMap.get(map, \"greeting\")\n * if (retrieved._tag === \"Some\") {\n * yield* Deferred.succeed(deferred, \"Hello\")\n *\n * const result = yield* Fiber.join(retrieved.value)\n * console.log(result) // \"Hello\"\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const get = /*#__PURE__*/dual(2, (self, key) => Effect.suspend(() => Effect.succeed(getUnsafe(self, key))));\n/**\n * Checks whether a key exists in the FiberMap.\n *\n * **Example** (Checking if a key exists unsafely)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Add a fiber to the map\n * yield* FiberMap.run(map, \"task1\", Effect.never)\n *\n * // Check if keys exist\n * console.log(FiberMap.hasUnsafe(map, \"task1\")) // true\n * console.log(FiberMap.hasUnsafe(map, \"task2\")) // false\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const hasUnsafe = /*#__PURE__*/dual(2, (self, key) => self.state._tag === \"Closed\" ? false : MutableHashMap.has(self.state.backing, key));\n/**\n * Checks whether a key exists in the FiberMap.\n * This is the Effect-wrapped version of `hasUnsafe`.\n *\n * **Example** (Checking if a key exists)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Add a fiber to the map\n * yield* FiberMap.run(map, \"task1\", Effect.never)\n *\n * // Check if keys exist using Effect\n * const exists1 = yield* FiberMap.has(map, \"task1\")\n * const exists2 = yield* FiberMap.has(map, \"task2\")\n *\n * console.log(exists1) // true\n * console.log(exists2) // false\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, key) => Effect.sync(() => hasUnsafe(self, key)));\n/**\n * Removes a fiber from the FiberMap, interrupting it if it exists.\n *\n * **Example** (Removing a fiber)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Add some fibers to the map\n * yield* FiberMap.run(map, \"task1\", Effect.never)\n * yield* FiberMap.run(map, \"task2\", Effect.never)\n *\n * console.log(yield* FiberMap.size(map)) // 2\n *\n * // Remove a specific fiber (this will interrupt it)\n * yield* FiberMap.remove(map, \"task1\")\n *\n * console.log(yield* FiberMap.size(map)) // 1\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const remove = /*#__PURE__*/dual(2, (self, key) => Effect.suspend(() => {\n if (self.state._tag === \"Closed\") {\n return Effect.void;\n }\n const fiber = MutableHashMap.get(self.state.backing, key);\n if (fiber._tag === \"None\") {\n return Effect.void;\n }\n return Fiber.interruptAs(fiber.value, internalFiberId);\n}));\n/**\n * Removes all fibers from the FiberMap, interrupting them.\n *\n * **Example** (Clearing all fibers)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Add some fibers to the map\n * yield* FiberMap.run(map, \"task1\", Effect.never)\n * yield* FiberMap.run(map, \"task2\", Effect.never)\n * yield* FiberMap.run(map, \"task3\", Effect.never)\n *\n * console.log(yield* FiberMap.size(map)) // 3\n *\n * // Clear all fibers (this will interrupt all of them)\n * yield* FiberMap.clear(map)\n *\n * console.log(yield* FiberMap.size(map)) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const clear = self => Effect.suspend(() => {\n if (self.state._tag === \"Closed\") {\n return Effect.void;\n }\n return Fiber.interruptAllAs(MutableHashMap.values(self.state.backing), internalFiberId);\n});\nconst constInterruptedFiber = /*#__PURE__*/function () {\n let fiber = undefined;\n return () => {\n if (fiber === undefined) {\n fiber = Effect.runFork(Effect.interrupt);\n }\n return fiber;\n };\n}();\n/**\n * Forks an Effect and stores the resulting fiber in the `FiberMap` under a key.\n *\n * **Details**\n *\n * When the fiber completes, it is removed from the map. If the key already has\n * a fiber, the previous fiber is interrupted unless `onlyIfMissing` is set.\n *\n * **Example** (Forking effects into a map)\n *\n * ```ts\n * import { Effect, Fiber, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Run effects and add the fibers to the map\n * const fiber1 = yield* FiberMap.run(map, \"task1\", Effect.succeed(\"Hello\"))\n * const fiber2 = yield* FiberMap.run(map, \"task2\", Effect.succeed(\"World\"))\n *\n * // Join the fibers to get their successful values\n * const result1 = yield* Fiber.join(fiber1)\n * const result2 = yield* Fiber.join(fiber2)\n *\n * console.log(result1, result2) // \"Hello\", \"World\"\n * console.log(yield* FiberMap.size(map)) // 0 (fibers are removed after completion)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const run = function () {\n const self = arguments[0];\n if (Effect.isEffect(arguments[2])) {\n return runImpl(self, arguments[1], arguments[2], arguments[3]);\n }\n const key = arguments[1];\n const options = arguments[2];\n return effect => runImpl(self, key, effect, options);\n};\nconst runImpl = (self, key, effect, options) => Effect.withFiber(parent => {\n if (self.state._tag === \"Closed\") {\n return Effect.interrupt;\n } else if (options?.onlyIfMissing === true && hasUnsafe(self, key)) {\n return Effect.sync(constInterruptedFiber);\n }\n const fiber = Effect.runForkWith(parent.context)(effect);\n setUnsafe(self, key, fiber, options);\n return Effect.succeed(fiber);\n});\n/**\n * Captures the current runtime and returns a function for forking effects into\n * an existing `FiberMap`.\n *\n * **Details**\n *\n * Each call stores the forked fiber under the supplied key. If that key already\n * has a fiber, the previous fiber is interrupted unless `onlyIfMissing` is set.\n *\n * **Example** (Capturing a runtime)\n *\n * ```ts\n * import { Context, Effect, FiberMap } from \"effect\"\n *\n * interface Users {\n * readonly _: unique symbol\n * }\n * const Users = Context.Service<Users, {\n * getAll: Effect.Effect<Array<unknown>>\n * }>(\"Users\")\n *\n * Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const run = yield* FiberMap.runtime(map)<Users>()\n *\n * // run some effects and add the fibers to the map\n * run(\"effect-a\", Effect.andThen(Users, (_) => _.getAll))\n * run(\"effect-b\", Effect.andThen(Users, (_) => _.getAll))\n * }).pipe(\n * Effect.scoped // The fibers will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const runtime = self => () => Effect.map(Effect.context(), services => {\n const runFork = Effect.runForkWith(services);\n return (key, effect, options) => {\n if (self.state._tag === \"Closed\") {\n return constInterruptedFiber();\n } else if (options?.onlyIfMissing === true && hasUnsafe(self, key)) {\n return constInterruptedFiber();\n }\n const fiber = runFork(effect, options);\n setUnsafe(self, key, fiber, options);\n return fiber;\n };\n});\n/**\n * Captures the current runtime and returns a function for running effects in\n * an existing `FiberMap` as Promises.\n *\n * **Details**\n *\n * Each call stores the forked fiber under the supplied key, interrupting any\n * previous fiber for that key unless `onlyIfMissing` is set. The Promise\n * resolves with the effect's success value or rejects with the squashed failure\n * cause.\n *\n * **Example** (Running effects as promises)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n * const runPromise = yield* FiberMap.runtimePromise(map)<never>()\n *\n * // Create promises that will be backed by fibers in the map\n * const promise1 = runPromise(\"task1\", Effect.succeed(\"Hello\"))\n * const promise2 = runPromise(\"task2\", Effect.succeed(\"World\"))\n *\n * // Convert promises back to Effects and await\n * const result1 = yield* Effect.promise(() => promise1)\n * const result2 = yield* Effect.promise(() => promise2)\n *\n * console.log(result1, result2) // \"Hello\", \"World\"\n * })\n * ```\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const runtimePromise = self => () => Effect.map(runtime(self)(), runFork => (key, effect, options) => new Promise((resolve, reject) => runFork(key, effect, options).addObserver(exit => {\n if (Exit.isSuccess(exit)) {\n resolve(exit.value);\n } else {\n reject(Cause.squash(exit.cause));\n }\n})));\n/**\n * Gets the number of fibers currently in the FiberMap.\n *\n * **Example** (Checking the map size)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * console.log(yield* FiberMap.size(map)) // 0\n *\n * // Add some fibers\n * yield* FiberMap.run(map, \"task1\", Effect.never)\n * yield* FiberMap.run(map, \"task2\", Effect.never)\n *\n * console.log(yield* FiberMap.size(map)) // 2\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const size = self => Effect.sync(() => self.state._tag === \"Closed\" ? 0 : MutableHashMap.size(self.state.backing));\n/**\n * Waits for the `FiberMap` to fail or close.\n *\n * **Details**\n *\n * The returned Effect fails with the first managed fiber failure that is not\n * ignored by the map's interruption rules. Normal successful completion\n * removes fibers from the map; use `awaitEmpty` to wait until the map has no\n * fibers.\n *\n * **Example** (Joining failing fibers)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * Effect.gen(function*() {\n * const map = yield* FiberMap.make()\n * yield* FiberMap.set(map, \"a\", Effect.runFork(Effect.fail(\"error\")))\n *\n * // parent fiber will fail with \"error\"\n * yield* FiberMap.join(map)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const join = self => Deferred.await(self.deferred);\n/**\n * Waits for the FiberMap to be empty.\n * This will wait for all currently running fibers to complete.\n *\n * **Example** (Waiting for an empty map)\n *\n * ```ts\n * import { Effect, FiberMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const map = yield* FiberMap.make<string>()\n *\n * // Add some fibers that will complete after a delay\n * yield* FiberMap.run(map, \"task1\", Effect.sleep(1000))\n * yield* FiberMap.run(map, \"task2\", Effect.sleep(2000))\n *\n * console.log(\"Waiting for all fibers to complete...\")\n *\n * // Wait for the map to be empty\n * yield* FiberMap.awaitEmpty(map)\n *\n * console.log(\"All fibers completed!\")\n * console.log(yield* FiberMap.size(map)) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const awaitEmpty = self => Effect.whileLoop({\n while: () => self.state._tag === \"Open\" && MutableHashMap.size(self.state.backing) > 0,\n body: () => Fiber.await(Iterable.headUnsafe(self)[1]),\n step: constVoid\n});\n//# sourceMappingURL=FiberMap.js.map","/**\n * Manages many fibers together inside one scope.\n *\n * A `FiberSet<A, E>` tracks running fibers, removes each fiber when it\n * completes, and interrupts all still-running fibers when the owning scope\n * closes. This module includes scoped runtime constructors plus helpers for\n * adding, clearing, running, counting, joining, and waiting for managed fibers.\n *\n * @since 2.0.0\n */\nimport * as Cause from \"./Cause.js\";\nimport * as Deferred from \"./Deferred.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport * as Filter from \"./Filter.js\";\nimport { constVoid, dual } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport * as Predicate from \"./Predicate.js\";\nconst TypeId = \"~effect/FiberSet\";\n/**\n * Checks whether a value is a FiberSet.\n *\n * **Example** (Checking if a value is a FiberSet)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * console.log(FiberSet.isFiberSet(set)) // true\n * console.log(FiberSet.isFiberSet({})) // false\n * })\n * ```\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isFiberSet = u => Predicate.hasProperty(u, TypeId);\nconst Proto = {\n [TypeId]: TypeId,\n [Symbol.iterator]() {\n if (this.state._tag === \"Closed\") {\n return Iterable.empty();\n }\n return this.state.backing[Symbol.iterator]();\n },\n ...PipeInspectableProto,\n toJSON() {\n return {\n _id: \"FiberMap\",\n state: this.state\n };\n }\n};\nconst makeUnsafe = (backing, deferred) => {\n const self = Object.create(Proto);\n self.state = {\n _tag: \"Open\",\n backing\n };\n self.deferred = deferred;\n return self;\n};\n/**\n * Creates a scoped `FiberSet` for storing fibers.\n *\n * **Details**\n *\n * When the associated Scope is closed, all fibers in the set will be\n * interrupted. You can add fibers to the set using `FiberSet.add` or\n * `FiberSet.run`, and the fibers will be automatically removed from the\n * FiberSet when they complete.\n *\n * **Example** (Creating a scoped FiberSet)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * // run some effects and add the fibers to the set\n * yield* FiberSet.run(set, Effect.never)\n * yield* FiberSet.run(set, Effect.never)\n *\n * yield* Effect.sleep(1000)\n * }).pipe(\n * Effect.scoped // The fibers will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = () => Effect.acquireRelease(Effect.sync(() => makeUnsafe(new Set(), Deferred.makeUnsafe())), set => Effect.suspend(() => {\n const state = set.state;\n if (state._tag === \"Closed\") return Effect.void;\n set.state = {\n _tag: \"Closed\"\n };\n const fibers = state.backing;\n return Fiber.interruptAll(fibers).pipe(Deferred.into(set.deferred));\n}));\n/**\n * Creates a scoped run function that forks effects into a new `FiberSet`.\n *\n * **Details**\n *\n * Each call returns the forked fiber and adds it to the set. Managed fibers are\n * removed when they complete and are interrupted when the set's scope closes.\n *\n * **Example** (Creating a scoped runtime)\n *\n * ```ts\n * import { Effect, Fiber, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const runFork = yield* FiberSet.makeRuntime()\n *\n * // Fork effects using the runtime\n * const fiber1 = runFork(Effect.succeed(\"hello\"))\n * const fiber2 = runFork(Effect.succeed(\"world\"))\n *\n * const result1 = yield* Fiber.await(fiber1)\n * const result2 = yield* Fiber.await(fiber2)\n *\n * console.log(result1, result2) // \"hello\" \"world\"\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeRuntime = () => Effect.flatMap(make(), self => runtime(self)());\n/**\n * Creates a scoped run function that forks effects into a new `FiberSet` and\n * returns a `Promise` for each effect result.\n *\n * **When to use**\n *\n * Use when many scoped fibers should be tracked as a set while exposing each\n * result through Promise-based APIs.\n *\n * **Details**\n *\n * Managed fibers are removed when they complete and are interrupted when the\n * set's scope closes. Each Promise resolves with the effect's success value or\n * rejects with the squashed failure cause.\n *\n * **Example** (Creating a promise runtime)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const runPromise = yield* FiberSet.makeRuntimePromise()\n *\n * // Run effects as promises\n * const promise1 = runPromise(Effect.succeed(\"hello\"))\n * const promise2 = runPromise(Effect.succeed(\"world\"))\n *\n * const result1 = yield* Effect.promise(() => promise1)\n * const result2 = yield* Effect.promise(() => promise2)\n *\n * console.log(result1, result2) // \"hello\" \"world\"\n * })\n * ```\n *\n * @category constructors\n * @since 3.13.0\n */\nexport const makeRuntimePromise = () => Effect.flatMap(make(), self => runtimePromise(self)());\nconst internalFiberId = -1;\nconst isInternalInterruption = /*#__PURE__*/Filter.toPredicate(/*#__PURE__*/Filter.compose(Cause.filterInterruptors, /*#__PURE__*/Filter.has(internalFiberId)));\n/**\n * Adds an existing fiber to the `FiberSet` using a synchronous, unsafe\n * mutation.\n *\n * **When to use**\n *\n * Use when an already forked fiber must be registered immediately and\n * synchronous interruption on a closed set is acceptable.\n *\n * **Details**\n *\n * When the fiber completes, it is removed from the set. If the set is already\n * closed, the supplied fiber is interrupted immediately. Non-interruption\n * failures are recorded for `FiberSet.join`.\n *\n * **Example** (Adding a fiber unsafely)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n * const fiber = yield* Effect.forkChild(Effect.succeed(\"hello\"))\n *\n * // Unsafe add - doesn't return an Effect\n * FiberSet.addUnsafe(set, fiber)\n *\n * // The fiber is now managed by the set\n * console.log(yield* FiberSet.size(set)) // 1\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const addUnsafe = /*#__PURE__*/dual(args => isFiberSet(args[0]), (self, fiber, options) => {\n if (self.state._tag === \"Closed\") {\n fiber.interruptUnsafe(internalFiberId);\n return;\n } else if (self.state.backing.has(fiber)) {\n return;\n }\n self.state.backing.add(fiber);\n fiber.addObserver(exit => {\n if (self.state._tag === \"Closed\") {\n return;\n }\n self.state.backing.delete(fiber);\n if (Exit.isFailure(exit) && (options?.propagateInterruption === true ? !isInternalInterruption(exit.cause) : !Cause.hasInterruptsOnly(exit.cause))) {\n Deferred.doneUnsafe(self.deferred, exit);\n }\n });\n});\n/**\n * Adds a fiber to the FiberSet. When the fiber completes, it will be removed.\n *\n * **Example** (Adding a fiber)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n * const fiber = yield* Effect.forkChild(Effect.succeed(\"hello\"))\n *\n * // Add the fiber to the set\n * yield* FiberSet.add(set, fiber)\n *\n * // The fiber is now managed by the set\n * console.log(yield* FiberSet.size(set)) // 1\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const add = /*#__PURE__*/dual(args => isFiberSet(args[0]), (self, fiber, options) => Effect.sync(() => addUnsafe(self, fiber, options)));\n/**\n * Interrupts all fibers in the `FiberSet` and clears the set.\n *\n * **Example** (Clearing all fibers)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * // Add some fibers\n * yield* FiberSet.run(set, Effect.never)\n * yield* FiberSet.run(set, Effect.never)\n *\n * console.log(yield* FiberSet.size(set)) // 2\n *\n * // Clear all fibers\n * yield* FiberSet.clear(set)\n *\n * console.log(yield* FiberSet.size(set)) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const clear = self => Effect.suspend(() => {\n if (self.state._tag === \"Closed\") {\n return Effect.void;\n }\n return Fiber.interruptAllAs(self.state.backing, internalFiberId);\n});\nconst constInterruptedFiber = /*#__PURE__*/function () {\n let fiber = undefined;\n return () => {\n if (fiber === undefined) {\n fiber = Effect.runFork(Effect.interrupt);\n }\n return fiber;\n };\n}();\n/**\n * Forks an Effect and add the forked fiber to the FiberSet.\n * When the fiber completes, it will be removed from the FiberSet.\n *\n * **Example** (Forking effects into a set)\n *\n * ```ts\n * import { Effect, Fiber, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * // Fork and add to set\n * const fiber1 = yield* FiberSet.run(set, Effect.succeed(\"hello\"))\n * const fiber2 = yield* FiberSet.run(set, Effect.succeed(\"world\"))\n *\n * // Get results\n * const result1 = yield* Fiber.await(fiber1)\n * const result2 = yield* Fiber.await(fiber2)\n *\n * console.log(result1, result2) // \"hello\" \"world\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const run = function () {\n const self = arguments[0];\n if (!Effect.isEffect(arguments[1])) {\n const options = arguments[1];\n return effect => runImpl(self, effect, options);\n }\n return runImpl(self, arguments[1], arguments[2]);\n};\nconst runImpl = (self, effect, options) => Effect.withFiber(parent => {\n if (self.state._tag === \"Closed\") {\n return Effect.sync(constInterruptedFiber);\n }\n const fiber = Effect.runForkWith(parent.context)(effect);\n addUnsafe(self, fiber, options);\n return Effect.succeed(fiber);\n});\n/**\n * Captures a `Runtime` and uses it to fork effects into the `FiberSet`.\n *\n * **Example** (Capturing a runtime)\n *\n * ```ts\n * import { Context, Effect, FiberSet } from \"effect\"\n *\n * interface Users {\n * readonly _: unique symbol\n * }\n * const Users = Context.Service<Users, {\n * getAll: Effect.Effect<Array<unknown>>\n * }>(\"Users\")\n *\n * Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n * const run = yield* FiberSet.runtime(set)<Users>()\n *\n * // run some effects and add the fibers to the set\n * run(Effect.andThen(Users, (_) => _.getAll))\n * }).pipe(\n * Effect.scoped // The fibers will be interrupted when the scope is closed\n * )\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const runtime = self => () => Effect.map(Effect.context(), services => {\n const runFork = Effect.runForkWith(services);\n return (effect, options) => {\n if (self.state._tag === \"Closed\") {\n return constInterruptedFiber();\n }\n const fiber = runFork(effect, options);\n addUnsafe(self, fiber);\n return fiber;\n };\n});\n/**\n * Captures a `Runtime` and returns a Promise-based runner that forks effects\n * into the `FiberSet`.\n *\n * **When to use**\n *\n * Use when you need to bridge effects to `Promise` values while still tracking\n * their fibers in a `FiberSet`.\n *\n * **Details**\n *\n * The returned run function returns a `Promise` for each effect result.\n *\n * **Example** (Running effects as promises)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n * const runPromise = yield* FiberSet.runtimePromise(set)()\n *\n * // Run effects as promises\n * const promise1 = runPromise(Effect.succeed(\"hello\"))\n * const promise2 = runPromise(Effect.succeed(\"world\"))\n *\n * const result1 = yield* Effect.promise(() => promise1)\n * const result2 = yield* Effect.promise(() => promise2)\n *\n * console.log(result1, result2) // \"hello\" \"world\"\n * })\n * ```\n *\n * @see {@link runtime} for a runner that returns the forked `Fiber`\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const runtimePromise = self => () => Effect.map(runtime(self)(), runFork => (effect, options) => new Promise((resolve, reject) => runFork(effect, options).addObserver(exit => {\n if (Exit.isSuccess(exit)) {\n resolve(exit.value);\n } else {\n reject(Cause.squash(exit.cause));\n }\n})));\n/**\n * Gets the number of fibers currently in the FiberSet.\n *\n * **Example** (Checking the set size)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * console.log(yield* FiberSet.size(set)) // 0\n *\n * // Add some fibers\n * yield* FiberSet.run(set, Effect.never)\n * yield* FiberSet.run(set, Effect.never)\n *\n * console.log(yield* FiberSet.size(set)) // 2\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const size = self => Effect.sync(() => self.state._tag === \"Closed\" ? 0 : self.state.backing.size);\n/**\n * Joins all fibers in the FiberSet. If any fiber in the set terminates with a failure,\n * the returned Effect will terminate with the first failure that occurred.\n *\n * **Example** (Joining failing fibers)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n * yield* FiberSet.add(set, Effect.runFork(Effect.fail(\"error\")))\n *\n * // parent fiber will fail with \"error\"\n * yield* FiberSet.join(set)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const join = self => Deferred.await(self.deferred);\n/**\n * Waits until the fiber set is empty.\n *\n * **Example** (Waiting for an empty set)\n *\n * ```ts\n * import { Effect, FiberSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set = yield* FiberSet.make()\n *\n * // Add some fibers that will complete\n * yield* FiberSet.run(set, Effect.sleep(100))\n * yield* FiberSet.run(set, Effect.sleep(200))\n *\n * // Wait for all fibers to complete\n * yield* FiberSet.awaitEmpty(set)\n *\n * console.log(yield* FiberSet.size(set)) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 3.13.0\n */\nexport const awaitEmpty = self => Effect.whileLoop({\n while: () => self.state._tag === \"Open\" && self.state.backing.size > 0,\n body: () => Fiber.await(Iterable.headUnsafe(self)),\n step: constVoid\n});\n//# sourceMappingURL=FiberSet.js.map","/**\n * Models relationships between indexed nodes and edges.\n *\n * This module provides immutable and scoped-mutable graph data structures. A\n * graph can be directed or undirected, and it can store user-defined data on\n * both nodes and edges. The module includes traversal, analysis, path-finding,\n * transformation, and diagram export utilities.\n *\n * @since 4.0.0\n */\nimport * as Data from \"./Data.js\";\nimport * as Equal from \"./Equal.js\";\nimport { dual } from \"./Function.js\";\nimport * as Hash from \"./Hash.js\";\nimport { NodeInspectSymbol } from \"./Inspectable.js\";\nimport * as Option from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nconst TypeId = \"~effect/collections/Graph\";\n/**\n * Represents edge data containing source, target, and user data.\n *\n * **When to use**\n *\n * Use as the graph edge value that carries source node, target node, and stored\n * edge data together.\n *\n * @see {@link getEdge} for reading a single edge by identifier\n * @see {@link addEdge} for adding edges to a graph\n * @see {@link edges} for iterating graph edges\n *\n * @category models\n * @since 3.18.0\n */\nexport class Edge extends Data.Class {}\n// =============================================================================\n// Proto Objects\n// =============================================================================\n/** @internal */\nconst ProtoGraph = {\n [TypeId]: TypeId,\n [Symbol.iterator]() {\n return this.nodes[Symbol.iterator]();\n },\n [NodeInspectSymbol]() {\n return this.toJSON();\n },\n [Equal.symbol](that) {\n if (isGraph(that)) {\n if (this.nodes.size !== that.nodes.size || this.edges.size !== that.edges.size || this.type !== that.type) {\n return false;\n }\n // Compare nodes\n for (const [nodeIndex, nodeData] of this.nodes) {\n if (!that.nodes.has(nodeIndex)) {\n return false;\n }\n const otherNodeData = that.nodes.get(nodeIndex);\n if (!Equal.equals(nodeData, otherNodeData)) {\n return false;\n }\n }\n // Compare edges\n for (const [edgeIndex, edgeData] of this.edges) {\n if (!that.edges.has(edgeIndex)) {\n return false;\n }\n const otherEdge = that.edges.get(edgeIndex);\n if (!Equal.equals(edgeData, otherEdge)) {\n return false;\n }\n }\n return true;\n }\n return false;\n },\n [Hash.symbol]() {\n let hash = Hash.string(\"Graph\");\n hash = hash ^ Hash.string(this.type);\n hash = hash ^ Hash.number(this.nodes.size);\n hash = hash ^ Hash.number(this.edges.size);\n for (const [nodeIndex, nodeData] of this.nodes) {\n hash = hash ^ Hash.hash(nodeIndex) + Hash.hash(nodeData);\n }\n for (const [edgeIndex, edgeData] of this.edges) {\n hash = hash ^ Hash.hash(edgeIndex) + Hash.hash(edgeData);\n }\n return hash;\n },\n toJSON() {\n return {\n _id: \"Graph\",\n nodeCount: this.nodes.size,\n edgeCount: this.edges.size,\n type: this.type\n };\n },\n toString() {\n return `Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`;\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n// =============================================================================\n// Errors\n// =============================================================================\n// TODO: Do we need safe variants for these?\n/**\n * Error thrown by graph operations when the requested graph structure is\n * invalid, such as referencing a missing node or using unsupported edge\n * weights.\n *\n * **When to use**\n *\n * Use when handling failures thrown by graph operations that reject invalid\n * graph structure or unsupported algorithm inputs.\n *\n * @category errors\n * @since 3.18.0\n */\nexport class GraphError extends /*#__PURE__*/Data.TaggedError(\"GraphError\") {}\n/** @internal */\nconst missingNode = node => new GraphError({\n message: `Node ${node} does not exist`\n});\n// =============================================================================\n// Constructors\n// =============================================================================\n/**\n * Returns `true` if a value has the graph runtime type identifier, narrowing\n * it to a `Graph`.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a graph value.\n *\n * **Gotchas**\n *\n * This guard checks the shared graph runtime type identifier and does not\n * distinguish immutable graphs from mutable graphs.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isGraph = u => hasProperty(u, TypeId);\n/**\n * Creates a directed graph, optionally with initial mutations.\n *\n * **Example** (Creating a directed graph)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Directed graph with initial nodes and edges\n * const graph = Graph.directed<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, \"A->B\")\n * Graph.addEdge(mutable, b, c, \"B->C\")\n * })\n * ```\n *\n * @category constructors\n * @since 3.18.0\n */\nexport const directed = mutate => {\n const graph = Object.create(ProtoGraph);\n graph.type = \"directed\";\n graph.nodes = new Map();\n graph.edges = new Map();\n graph.adjacency = new Map();\n graph.reverseAdjacency = new Map();\n graph.nextNodeIndex = 0;\n graph.nextEdgeIndex = 0;\n graph.acyclic = Option.some(true);\n graph.mutable = false;\n if (mutate) {\n const mutable = beginMutation(graph);\n mutate(mutable);\n return endMutation(mutable);\n }\n return graph;\n};\n/**\n * Creates an undirected graph, optionally with initial mutations.\n *\n * **Example** (Creating an undirected graph)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Undirected graph with initial nodes and edges\n * const graph = Graph.undirected<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, \"A-B\")\n * Graph.addEdge(mutable, b, c, \"B-C\")\n * })\n * ```\n *\n * @category constructors\n * @since 3.18.0\n */\nexport const undirected = mutate => {\n const graph = Object.create(ProtoGraph);\n graph.type = \"undirected\";\n graph.nodes = new Map();\n graph.edges = new Map();\n graph.adjacency = new Map();\n graph.reverseAdjacency = new Map();\n graph.nextNodeIndex = 0;\n graph.nextEdgeIndex = 0;\n graph.acyclic = Option.some(true);\n graph.mutable = false;\n if (mutate) {\n const mutable = beginMutation(graph);\n mutate(mutable);\n return endMutation(mutable);\n }\n return graph;\n};\n// =============================================================================\n// Scoped Mutable API\n// =============================================================================\n/**\n * Creates a mutable scope for safe graph mutations by copying the data structure.\n *\n * **Example** (Beginning a mutation scope)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>()\n * const mutable = Graph.beginMutation(graph)\n * // Now mutable can be safely modified without affecting original graph\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const beginMutation = graph => {\n // Copy adjacency maps with deep cloned arrays\n const adjacency = new Map();\n const reverseAdjacency = new Map();\n for (const [nodeIndex, edges] of graph.adjacency) {\n adjacency.set(nodeIndex, [...edges]);\n }\n for (const [nodeIndex, edges] of graph.reverseAdjacency) {\n reverseAdjacency.set(nodeIndex, [...edges]);\n }\n const mutable = Object.create(ProtoGraph);\n mutable.type = graph.type;\n mutable.nodes = new Map(graph.nodes);\n mutable.edges = new Map(graph.edges);\n mutable.adjacency = adjacency;\n mutable.reverseAdjacency = reverseAdjacency;\n mutable.nextNodeIndex = graph.nextNodeIndex;\n mutable.nextEdgeIndex = graph.nextEdgeIndex;\n mutable.acyclic = graph.acyclic;\n mutable.mutable = true;\n return mutable;\n};\n/**\n * Converts a mutable graph back to an immutable graph, ending the mutation scope.\n *\n * **Example** (Ending a mutation scope)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>()\n * const mutable = Graph.beginMutation(graph)\n * // ... perform mutations on mutable ...\n * const newGraph = Graph.endMutation(mutable)\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const endMutation = mutable => {\n const graph = Object.create(ProtoGraph);\n graph.type = mutable.type;\n graph.nodes = new Map(mutable.nodes);\n graph.edges = new Map(mutable.edges);\n graph.adjacency = mutable.adjacency;\n graph.reverseAdjacency = mutable.reverseAdjacency;\n graph.nextNodeIndex = mutable.nextNodeIndex;\n graph.nextEdgeIndex = mutable.nextEdgeIndex;\n graph.acyclic = mutable.acyclic;\n graph.mutable = false;\n return graph;\n};\n/**\n * Performs scoped mutations on a graph, automatically managing the mutation lifecycle.\n *\n * **Example** (Applying scoped mutations)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>()\n * const newGraph = Graph.mutate(graph, (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"A\")\n * const nodeB = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, nodeA, nodeB, 1)\n * })\n *\n * console.log(Graph.nodeCount(newGraph)) // 2\n * console.log(Graph.edgeCount(newGraph)) // 1\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const mutate = /*#__PURE__*/dual(2, (graph, f) => {\n const mutable = beginMutation(graph);\n f(mutable);\n return endMutation(mutable);\n});\n// =============================================================================\n// Basic Node Operations\n// =============================================================================\n/**\n * Adds a new node to a mutable graph and returns its index.\n *\n * **When to use**\n *\n * Use to allocate a new node in a mutable graph before storing edges or\n * querying it by index.\n *\n * **Details**\n *\n * The returned index is allocated from the graph's next node index. The mutable\n * graph stores the node data and initializes empty incoming and outgoing edge\n * indexes for the new node.\n *\n * **Gotchas**\n *\n * `NodeIndex` values are identifiers and are not reused after removals.\n *\n * **Example** (Adding nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const result = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * console.log(nodeA) // NodeIndex with value 0\n * console.log(nodeB) // NodeIndex with value 1\n * })\n * ```\n *\n * @see {@link mutate} for obtaining a mutable graph from an immutable graph\n * @see {@link addEdge} for connecting existing nodes\n * @see {@link removeNode} for removing nodes from a mutable graph\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const addNode = (mutable, data) => {\n const nodeIndex = mutable.nextNodeIndex;\n // Add node data\n mutable.nodes.set(nodeIndex, data);\n // Initialize empty adjacency lists\n mutable.adjacency.set(nodeIndex, []);\n mutable.reverseAdjacency.set(nodeIndex, []);\n // Update graph allocators\n mutable.nextNodeIndex = mutable.nextNodeIndex + 1;\n return nodeIndex;\n};\n/**\n * Gets the data associated with a node index safely, if it exists.\n *\n * **Example** (Getting node data)\n *\n * ```ts\n * import { Graph, Option } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * Graph.addNode(mutable, \"Node A\")\n * })\n *\n * const nodeIndex = 0\n * const nodeData = Graph.getNode(graph, nodeIndex)\n *\n * if (Option.isSome(nodeData)) {\n * console.log(nodeData.value) // \"Node A\"\n * }\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const getNode = /*#__PURE__*/dual(2, (graph, nodeIndex) => graph.nodes.has(nodeIndex) ? Option.some(graph.nodes.get(nodeIndex)) : Option.none());\n/**\n * Checks whether a node with the given index exists in the graph.\n *\n * **Example** (Checking node existence)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * Graph.addNode(mutable, \"Node A\")\n * })\n *\n * const nodeIndex = 0\n * const exists = Graph.hasNode(graph, nodeIndex)\n * console.log(exists) // true\n *\n * const nonExistentIndex = 999\n * const notExists = Graph.hasNode(graph, nonExistentIndex)\n * console.log(notExists) // false\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const hasNode = /*#__PURE__*/dual(2, (graph, nodeIndex) => graph.nodes.has(nodeIndex));\n/**\n * Returns the number of nodes in the graph.\n *\n * **Example** (Counting nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const emptyGraph = Graph.directed<string, number>()\n * console.log(Graph.nodeCount(emptyGraph)) // 0\n *\n * const graphWithNodes = Graph.mutate(emptyGraph, (mutable) => {\n * Graph.addNode(mutable, \"Node A\")\n * Graph.addNode(mutable, \"Node B\")\n * Graph.addNode(mutable, \"Node C\")\n * })\n *\n * console.log(Graph.nodeCount(graphWithNodes)) // 3\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const nodeCount = graph => graph.nodes.size;\n/**\n * Finds the first node that matches the given predicate.\n *\n * **Example** (Finding the first matching node)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * Graph.addNode(mutable, \"Node A\")\n * Graph.addNode(mutable, \"Node B\")\n * Graph.addNode(mutable, \"Node C\")\n * })\n *\n * const result = Graph.findNode(graph, (data) => data.startsWith(\"Node B\"))\n * console.log(result) // Option.some(1)\n *\n * const notFound = Graph.findNode(graph, (data) => data === \"Node D\")\n * console.log(notFound) // Option.none()\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const findNode = /*#__PURE__*/dual(2, (graph, predicate) => {\n for (const [index, data] of graph.nodes) {\n if (predicate(data)) {\n return Option.some(index);\n }\n }\n return Option.none();\n});\n/**\n * Finds all nodes that match the given predicate.\n *\n * **Example** (Finding matching nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * Graph.addNode(mutable, \"Start A\")\n * Graph.addNode(mutable, \"Node B\")\n * Graph.addNode(mutable, \"Start C\")\n * })\n *\n * const result = Graph.findNodes(graph, (data) => data.startsWith(\"Start\"))\n * console.log(result) // [0, 2]\n *\n * const empty = Graph.findNodes(graph, (data) => data === \"Not Found\")\n * console.log(empty) // []\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const findNodes = /*#__PURE__*/dual(2, (graph, predicate) => {\n const results = [];\n for (const [index, data] of graph.nodes) {\n if (predicate(data)) {\n results.push(index);\n }\n }\n return results;\n});\n/**\n * Finds the first edge that matches the given predicate.\n *\n * **Example** (Finding the first matching edge)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 10)\n * Graph.addEdge(mutable, nodeB, nodeC, 20)\n * })\n *\n * const result = Graph.findEdge(graph, (data) => data > 15)\n * console.log(result) // Option.some(1)\n *\n * const notFound = Graph.findEdge(graph, (data) => data > 100)\n * console.log(notFound) // Option.none()\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const findEdge = /*#__PURE__*/dual(2, (graph, predicate) => {\n for (const [edgeIndex, edgeData] of graph.edges) {\n if (predicate(edgeData.data, edgeData.source, edgeData.target)) {\n return Option.some(edgeIndex);\n }\n }\n return Option.none();\n});\n/**\n * Finds all edges that match the given predicate.\n *\n * **Example** (Finding matching edges)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 10)\n * Graph.addEdge(mutable, nodeB, nodeC, 20)\n * Graph.addEdge(mutable, nodeC, nodeA, 30)\n * })\n *\n * const result = Graph.findEdges(graph, (data) => data >= 20)\n * console.log(result) // [1, 2]\n *\n * const empty = Graph.findEdges(graph, (data) => data > 100)\n * console.log(empty) // []\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const findEdges = /*#__PURE__*/dual(2, (graph, predicate) => {\n const results = [];\n for (const [edgeIndex, edgeData] of graph.edges) {\n if (predicate(edgeData.data, edgeData.source, edgeData.target)) {\n results.push(edgeIndex);\n }\n }\n return results;\n});\n/**\n * Updates a single node's data by applying a transformation function.\n *\n * **Example** (Updating node data)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * Graph.addNode(mutable, \"Node A\")\n * Graph.addNode(mutable, \"Node B\")\n * Graph.updateNode(mutable, 0, (data) => data.toUpperCase())\n * })\n *\n * const nodeData = Graph.getNode(graph, 0)\n * console.log(nodeData) // Option.some(\"NODE A\")\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const updateNode = (mutable, index, f) => {\n if (!mutable.nodes.has(index)) {\n return;\n }\n const currentData = mutable.nodes.get(index);\n const newData = f(currentData);\n mutable.nodes.set(index, newData);\n};\n/**\n * Updates a single edge's data by applying a transformation function.\n *\n * **Example** (Updating edge data)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const result = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const edgeIndex = Graph.addEdge(mutable, nodeA, nodeB, 10)\n * Graph.updateEdge(mutable, edgeIndex, (data) => data * 2)\n * })\n *\n * const edgeData = Graph.getEdge(result, 0)\n * console.log(edgeData) // Option.some(new Graph.Edge({ source: 0, target: 1, data: 20 }))\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const updateEdge = (mutable, edgeIndex, f) => {\n if (!mutable.edges.has(edgeIndex)) {\n return;\n }\n const currentEdge = mutable.edges.get(edgeIndex);\n const newData = f(currentEdge.data);\n mutable.edges.set(edgeIndex, new Edge({\n ...currentEdge,\n data: newData\n }));\n};\n/**\n * Transforms every node's data in a mutable graph in place using the provided\n * mapping function.\n *\n * **Details**\n *\n * Node indices and edges are preserved; only the stored node data is replaced.\n *\n * **Example** (Mapping node data)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * Graph.addNode(mutable, \"node a\")\n * Graph.addNode(mutable, \"node b\")\n * Graph.addNode(mutable, \"node c\")\n * Graph.mapNodes(mutable, (data) => data.toUpperCase())\n * })\n *\n * const nodeData = Graph.getNode(graph, 0)\n * console.log(nodeData) // Option.some(\"NODE A\")\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const mapNodes = (mutable, f) => {\n // Transform existing node data in place\n for (const [index, data] of mutable.nodes) {\n const newData = f(data);\n mutable.nodes.set(index, newData);\n }\n};\n/**\n * Transforms all edge data in a mutable graph using the provided mapping function.\n *\n * **Example** (Mapping edge data)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 10)\n * Graph.addEdge(mutable, b, c, 20)\n * Graph.mapEdges(mutable, (data) => data * 2)\n * })\n *\n * const edgeData = Graph.getEdge(graph, 0)\n * console.log(edgeData) // Option.some(new Graph.Edge({ source: 0, target: 1, data: 20 }))\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const mapEdges = (mutable, f) => {\n // Transform existing edge data in place\n for (const [index, edgeData] of mutable.edges) {\n const newData = f(edgeData.data);\n mutable.edges.set(index, {\n ...edgeData,\n data: newData\n });\n }\n};\n/**\n * @internal\n */\nconst rebuildAdjacency = mutable => {\n mutable.adjacency.clear();\n mutable.reverseAdjacency.clear();\n for (const nodeIndex of mutable.nodes.keys()) {\n mutable.adjacency.set(nodeIndex, []);\n mutable.reverseAdjacency.set(nodeIndex, []);\n }\n for (const [edgeIndex, edgeData] of mutable.edges) {\n mutable.adjacency.get(edgeData.source).push(edgeIndex);\n mutable.reverseAdjacency.get(edgeData.target).push(edgeIndex);\n if (mutable.type === \"undirected\") {\n mutable.adjacency.get(edgeData.target).push(edgeIndex);\n mutable.reverseAdjacency.get(edgeData.source).push(edgeIndex);\n }\n }\n};\n/**\n * Swaps source and target nodes for every edge in a mutable graph.\n *\n * **Example** (Reversing edge directions)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1) // A -> B\n * Graph.addEdge(mutable, b, c, 2) // B -> C\n * Graph.reverse(mutable) // Now B -> A, C -> B\n * })\n *\n * const edge0 = Graph.getEdge(graph, 0)\n * console.log(edge0) // Option.some(new Graph.Edge({ source: 1, target: 0, data: 1 }))\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const reverse = mutable => {\n if (mutable.type === \"undirected\") {\n return;\n }\n // Reverse all edges by swapping source and target\n for (const [index, edgeData] of mutable.edges) {\n mutable.edges.set(index, new Edge({\n source: edgeData.target,\n target: edgeData.source,\n data: edgeData.data\n }));\n }\n rebuildAdjacency(mutable);\n // Invalidate cycle flag since edge directions changed\n mutable.acyclic = Option.none();\n};\n/**\n * Filters and optionally transforms nodes in a mutable graph using a predicate function.\n * Nodes that return Option.none are removed along with all their connected edges.\n *\n * **Example** (Filtering and mapping nodes)\n *\n * ```ts\n * import { Graph, Option } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"active\")\n * const b = Graph.addNode(mutable, \"inactive\")\n * const c = Graph.addNode(mutable, \"active\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 2)\n *\n * // Keep only \"active\" nodes and transform to uppercase\n * Graph.filterMapNodes(\n * mutable,\n * (data) =>\n * data === \"active\" ? Option.some(data.toUpperCase()) : Option.none()\n * )\n * })\n *\n * console.log(Graph.nodeCount(graph)) // 2 (only \"active\" nodes remain)\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const filterMapNodes = (mutable, f) => {\n const nodesToRemove = [];\n // First pass: identify nodes to remove and transform data for nodes to keep\n for (const [index, data] of mutable.nodes) {\n const result = f(data);\n if (Option.isSome(result)) {\n // Transform node data\n mutable.nodes.set(index, result.value);\n } else {\n // Mark for removal\n nodesToRemove.push(index);\n }\n }\n // Second pass: remove filtered out nodes and their edges\n for (const nodeIndex of nodesToRemove) {\n removeNode(mutable, nodeIndex);\n }\n};\n/**\n * Filters and optionally transforms edges in a mutable graph using a predicate function.\n * Edges that return Option.none are removed from the graph.\n *\n * **Example** (Filtering and mapping edges)\n *\n * ```ts\n * import { Graph, Option } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 5)\n * Graph.addEdge(mutable, b, c, 15)\n * Graph.addEdge(mutable, c, a, 25)\n *\n * // Keep only edges with weight >= 10 and double their weight\n * Graph.filterMapEdges(\n * mutable,\n * (data) => data >= 10 ? Option.some(data * 2) : Option.none()\n * )\n * })\n *\n * console.log(Graph.edgeCount(graph)) // 2 (edges with weight 5 removed)\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const filterMapEdges = (mutable, f) => {\n const edgesToRemove = [];\n // First pass: identify edges to remove and transform data for edges to keep\n for (const [index, edgeData] of mutable.edges) {\n const result = f(edgeData.data);\n if (Option.isSome(result)) {\n // Transform edge data\n mutable.edges.set(index, {\n ...edgeData,\n data: result.value\n });\n } else {\n // Mark for removal\n edgesToRemove.push(index);\n }\n }\n // Second pass: remove filtered out edges\n for (const edgeIndex of edgesToRemove) {\n removeEdge(mutable, edgeIndex);\n }\n};\n/**\n * Filters nodes by removing those that don't match the predicate.\n * This function modifies the mutable graph in place.\n *\n * **Example** (Filtering nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * Graph.addNode(mutable, \"active\")\n * Graph.addNode(mutable, \"inactive\")\n * Graph.addNode(mutable, \"pending\")\n * Graph.addNode(mutable, \"active\")\n *\n * // Keep only \"active\" nodes\n * Graph.filterNodes(mutable, (data) => data === \"active\")\n * })\n *\n * console.log(Graph.nodeCount(graph)) // 2 (only \"active\" nodes remain)\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const filterNodes = (mutable, predicate) => {\n const nodesToRemove = [];\n // Identify nodes to remove\n for (const [index, data] of mutable.nodes) {\n if (!predicate(data)) {\n nodesToRemove.push(index);\n }\n }\n // Remove filtered out nodes (this also removes connected edges)\n for (const nodeIndex of nodesToRemove) {\n removeNode(mutable, nodeIndex);\n }\n};\n/**\n * Filters edges by removing those that don't match the predicate.\n * This function modifies the mutable graph in place.\n *\n * **Example** (Filtering edges)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n *\n * Graph.addEdge(mutable, a, b, 5)\n * Graph.addEdge(mutable, b, c, 15)\n * Graph.addEdge(mutable, c, a, 25)\n *\n * // Keep only edges with weight >= 10\n * Graph.filterEdges(mutable, (data) => data >= 10)\n * })\n *\n * console.log(Graph.edgeCount(graph)) // 2 (edge with weight 5 removed)\n * ```\n *\n * @category transforming\n * @since 3.18.0\n */\nexport const filterEdges = (mutable, predicate) => {\n const edgesToRemove = [];\n // Identify edges to remove\n for (const [index, edgeData] of mutable.edges) {\n if (!predicate(edgeData.data)) {\n edgesToRemove.push(index);\n }\n }\n // Remove filtered out edges\n for (const edgeIndex of edgesToRemove) {\n removeEdge(mutable, edgeIndex);\n }\n};\n// =============================================================================\n// Cycle Flag Management (Internal)\n// =============================================================================\n/** @internal */\nconst invalidateCycleFlagOnRemoval = mutable => {\n // Only invalidate if the graph had cycles (removing edges/nodes cannot introduce cycles in acyclic graphs).\n if (mutable.acyclic._tag === \"Some\" && mutable.acyclic.value === false) {\n mutable.acyclic = Option.none();\n }\n};\n/** @internal */\nconst invalidateCycleFlagOnAddition = mutable => {\n // Only invalidate if the graph was acyclic (adding edges cannot remove cycles from cyclic graphs).\n if (mutable.acyclic._tag === \"Some\" && mutable.acyclic.value === true) {\n mutable.acyclic = Option.none();\n }\n};\n// =============================================================================\n// Edge Operations\n// =============================================================================\n/**\n * Adds a new edge to a mutable graph and returns its index.\n *\n * **When to use**\n *\n * Use to connect two existing nodes in a mutable graph while storing edge data\n * and receiving the new edge identifier.\n *\n * **Details**\n *\n * Creates an `Edge` with the source, target, and data at the next edge index,\n * updates adjacency indexes, and increments the graph's next edge index.\n * Undirected graphs register the same edge for both endpoints.\n *\n * **Gotchas**\n *\n * The source and target nodes must already exist in the mutable graph; missing\n * endpoints throw a `GraphError`.\n *\n * **Example** (Adding edges)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const result = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const edge = Graph.addEdge(mutable, nodeA, nodeB, 42)\n * console.log(edge) // EdgeIndex with value 0\n * })\n * ```\n *\n * @see {@link mutate} for obtaining a mutable graph from an immutable graph\n * @see {@link addNode} for creating node indexes before connecting them\n * @see {@link getEdge} for reading the returned edge\n * @see {@link removeEdge} for removing an edge from a mutable graph\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const addEdge = (mutable, source, target, data) => {\n // Validate that both nodes exist\n if (!mutable.nodes.has(source)) {\n throw missingNode(source);\n }\n if (!mutable.nodes.has(target)) {\n throw missingNode(target);\n }\n const edgeIndex = mutable.nextEdgeIndex;\n // Create edge data\n const edgeData = new Edge({\n source,\n target,\n data\n });\n mutable.edges.set(edgeIndex, edgeData);\n // Update adjacency lists\n const sourceAdjacency = mutable.adjacency.get(source);\n if (sourceAdjacency !== undefined) {\n sourceAdjacency.push(edgeIndex);\n }\n const targetReverseAdjacency = mutable.reverseAdjacency.get(target);\n if (targetReverseAdjacency !== undefined) {\n targetReverseAdjacency.push(edgeIndex);\n }\n // For undirected graphs, add reverse connections\n if (mutable.type === \"undirected\") {\n const targetAdjacency = mutable.adjacency.get(target);\n if (targetAdjacency !== undefined) {\n targetAdjacency.push(edgeIndex);\n }\n const sourceReverseAdjacency = mutable.reverseAdjacency.get(source);\n if (sourceReverseAdjacency !== undefined) {\n sourceReverseAdjacency.push(edgeIndex);\n }\n }\n // Update allocators\n mutable.nextEdgeIndex = mutable.nextEdgeIndex + 1;\n // Only invalidate cycle flag if the graph was acyclic\n // Adding edges cannot remove cycles from cyclic graphs\n invalidateCycleFlagOnAddition(mutable);\n return edgeIndex;\n};\n/**\n * Removes a node and all its incident edges from a mutable graph.\n *\n * **Example** (Removing a node)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const result = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * Graph.addEdge(mutable, nodeA, nodeB, 42)\n *\n * // Remove nodeA and all edges connected to it\n * Graph.removeNode(mutable, nodeA)\n * })\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const removeNode = (mutable, nodeIndex) => {\n // Check if node exists\n if (!mutable.nodes.has(nodeIndex)) {\n return; // Node doesn't exist, nothing to remove\n }\n // Collect all incident edges for removal\n const edgesToRemove = [];\n // Get outgoing edges\n const outgoingEdges = mutable.adjacency.get(nodeIndex);\n if (outgoingEdges !== undefined) {\n for (const edge of outgoingEdges) {\n edgesToRemove.push(edge);\n }\n }\n // Get incoming edges\n const incomingEdges = mutable.reverseAdjacency.get(nodeIndex);\n if (incomingEdges !== undefined) {\n for (const edge of incomingEdges) {\n edgesToRemove.push(edge);\n }\n }\n // Remove all incident edges\n for (const edgeIndex of edgesToRemove) {\n removeEdgeInternal(mutable, edgeIndex);\n }\n // Remove the node itself\n mutable.nodes.delete(nodeIndex);\n mutable.adjacency.delete(nodeIndex);\n mutable.reverseAdjacency.delete(nodeIndex);\n // Only invalidate cycle flag if the graph wasn't already known to be acyclic\n // Removing nodes cannot introduce cycles in an acyclic graph\n invalidateCycleFlagOnRemoval(mutable);\n};\n/**\n * Removes an edge from a mutable graph.\n *\n * **Example** (Removing an edge)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const result = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const edge = Graph.addEdge(mutable, nodeA, nodeB, 42)\n *\n * // Remove the edge\n * Graph.removeEdge(mutable, edge)\n * })\n * ```\n *\n * @category mutations\n * @since 3.18.0\n */\nexport const removeEdge = (mutable, edgeIndex) => {\n const wasRemoved = removeEdgeInternal(mutable, edgeIndex);\n // Only invalidate cycle flag if an edge was actually removed\n // and only if the graph wasn't already known to be acyclic\n if (wasRemoved) {\n invalidateCycleFlagOnRemoval(mutable);\n }\n};\n/** @internal */\nconst removeEdgeInternal = (mutable, edgeIndex) => {\n // Get edge data\n const edge = mutable.edges.get(edgeIndex);\n if (edge === undefined) {\n return false; // Edge doesn't exist, no mutation occurred\n }\n const {\n source,\n target\n } = edge;\n // Remove from adjacency lists\n const sourceAdjacency = mutable.adjacency.get(source);\n if (sourceAdjacency !== undefined) {\n const index = sourceAdjacency.indexOf(edgeIndex);\n if (index !== -1) {\n sourceAdjacency.splice(index, 1);\n }\n }\n const targetReverseAdjacency = mutable.reverseAdjacency.get(target);\n if (targetReverseAdjacency !== undefined) {\n const index = targetReverseAdjacency.indexOf(edgeIndex);\n if (index !== -1) {\n targetReverseAdjacency.splice(index, 1);\n }\n }\n // For undirected graphs, remove reverse connections\n if (mutable.type === \"undirected\") {\n const targetAdjacency = mutable.adjacency.get(target);\n if (targetAdjacency !== undefined) {\n const index = targetAdjacency.indexOf(edgeIndex);\n if (index !== -1) {\n targetAdjacency.splice(index, 1);\n }\n }\n const sourceReverseAdjacency = mutable.reverseAdjacency.get(source);\n if (sourceReverseAdjacency !== undefined) {\n const index = sourceReverseAdjacency.indexOf(edgeIndex);\n if (index !== -1) {\n sourceReverseAdjacency.splice(index, 1);\n }\n }\n }\n // Remove edge data\n mutable.edges.delete(edgeIndex);\n return true; // Edge was successfully removed\n};\n// =============================================================================\n// Edge Query Operations\n// =============================================================================\n/**\n * Gets the edge data associated with an edge index safely, if it exists.\n *\n * **Example** (Getting edge data)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * Graph.addEdge(mutable, nodeA, nodeB, 42)\n * })\n *\n * const edgeIndex = 0\n * const edgeData = Graph.getEdge(graph, edgeIndex)\n *\n * if (edgeData._tag === \"Some\") {\n * console.log(edgeData.value.data) // 42\n * console.log(edgeData.value.source) // 0\n * console.log(edgeData.value.target) // 1\n * }\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const getEdge = /*#__PURE__*/dual(2, (graph, edgeIndex) => Option.fromUndefinedOr(graph.edges.get(edgeIndex)));\n/**\n * Checks whether an edge exists between two nodes in the graph.\n *\n * **Example** (Checking edge existence)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 42)\n * })\n *\n * const nodeA = 0\n * const nodeB = 1\n * const nodeC = 2\n *\n * const hasAB = Graph.hasEdge(graph, nodeA, nodeB)\n * console.log(hasAB) // true\n *\n * const hasAC = Graph.hasEdge(graph, nodeA, nodeC)\n * console.log(hasAC) // false\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const hasEdge = /*#__PURE__*/dual(3, (graph, source, target) => {\n const adjacencyList = graph.adjacency.get(source);\n if (adjacencyList === undefined) {\n return false;\n }\n // Check if any edge in the adjacency list connects to the target\n for (const edgeIndex of adjacencyList) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n const neighbor = graph.type === \"undirected\" && edge.target === source ? edge.source : edge.target;\n if (neighbor === target) {\n return true;\n }\n }\n }\n return false;\n});\n/**\n * Returns the number of edges in the graph.\n *\n * **Example** (Counting edges)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const emptyGraph = Graph.directed<string, number>()\n * console.log(Graph.edgeCount(emptyGraph)) // 0\n *\n * const graphWithEdges = Graph.mutate(emptyGraph, (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 1)\n * Graph.addEdge(mutable, nodeB, nodeC, 2)\n * Graph.addEdge(mutable, nodeC, nodeA, 3)\n * })\n *\n * console.log(Graph.edgeCount(graphWithEdges)) // 3\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const edgeCount = graph => graph.edges.size;\nconst getDirectedNeighbors = (graph, nodeIndex, direction) => {\n const adjacencyMap = direction === \"incoming\" ? graph.reverseAdjacency : graph.adjacency;\n const adjacencyList = adjacencyMap.get(nodeIndex);\n if (adjacencyList === undefined) {\n return [];\n }\n const result = [];\n for (const edgeIndex of adjacencyList) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n result.push(direction === \"incoming\" ? edge.source : edge.target);\n }\n }\n return result;\n};\n/**\n * Returns the neighboring node indices for a node.\n *\n * **Details**\n *\n * For directed graphs, neighbors are the targets of outgoing edges. For\n * undirected graphs, neighbors are the other endpoints of incident edges.\n *\n * **Example** (Getting outgoing neighbors)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 1)\n * Graph.addEdge(mutable, nodeA, nodeC, 2)\n * })\n *\n * const nodeA = 0\n * const nodeB = 1\n * const nodeC = 2\n *\n * const neighborsA = Graph.neighbors(graph, nodeA)\n * console.log(neighborsA) // [1, 2]\n *\n * const neighborsB = Graph.neighbors(graph, nodeB)\n * console.log(neighborsB) // []\n * ```\n *\n * @category getters\n * @since 3.18.0\n */\nexport const neighbors = /*#__PURE__*/dual(2, (graph, nodeIndex) => {\n // For undirected graphs, use the specialized helper that returns the other endpoint\n if (graph.type === \"undirected\") {\n return getUndirectedNeighbors(graph, nodeIndex);\n }\n return getDirectedNeighbors(graph, nodeIndex, \"outgoing\");\n});\n/**\n * Returns the outgoing neighbor node indices for a node in a directed graph.\n *\n * **When to use**\n *\n * Use when you need the nodes reached by following outgoing edges from a node in\n * a directed graph.\n *\n * **Gotchas**\n *\n * Throws a `GraphError` when used with an undirected graph.\n *\n * @see {@link predecessors} for incoming neighbors in a directed graph\n * @see {@link neighbors} for generic neighbor lookup across graph kinds\n *\n * @category queries\n * @since 4.0.0\n */\nexport const successors = /*#__PURE__*/dual(2, (graph, nodeIndex) => {\n if (graph.type === \"undirected\") {\n throw new GraphError({\n message: \"Cannot get successors of undirected graph\"\n });\n }\n return getDirectedNeighbors(graph, nodeIndex, \"outgoing\");\n});\n/**\n * Returns the incoming neighbor node indices for a node in a directed graph.\n *\n * **When to use**\n *\n * Use when you need the nodes that reach a node by following incoming edges in a\n * directed graph.\n *\n * **Gotchas**\n *\n * Throws a `GraphError` when used with an undirected graph.\n *\n * @see {@link successors} for outgoing neighbors in a directed graph\n * @see {@link neighbors} for generic neighbor lookup across graph kinds\n *\n * @category queries\n * @since 4.0.0\n */\nexport const predecessors = /*#__PURE__*/dual(2, (graph, nodeIndex) => {\n if (graph.type === \"undirected\") {\n throw new GraphError({\n message: \"Cannot get predecessors of undirected graph\"\n });\n }\n return getDirectedNeighbors(graph, nodeIndex, \"incoming\");\n});\n/**\n * Gets directed neighbors of a node in a specific direction.\n *\n * **When to use**\n *\n * Use when maintaining existing code that already passes an explicit traversal\n * direction. New code should prefer `successors` or `predecessors`.\n *\n * **Gotchas**\n *\n * Throws a `GraphError` when used with an undirected graph.\n *\n * **Example** (Traversing directed neighbors)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, \"A->B\")\n * })\n *\n * const nodeA = 0\n * const nodeB = 1\n *\n * // Get outgoing neighbors (nodes that nodeA points to)\n * const outgoing = Graph.neighborsDirected(graph, nodeA, \"outgoing\")\n *\n * // Get incoming neighbors (nodes that point to nodeB)\n * const incoming = Graph.neighborsDirected(graph, nodeB, \"incoming\")\n * ```\n *\n * @deprecated Use {@link successors} for outgoing neighbors or {@link predecessors} for incoming neighbors.\n * @see {@link successors} for outgoing neighbors in a directed graph\n * @see {@link predecessors} for incoming neighbors in a directed graph\n * @category queries\n * @since 3.18.0\n */\nexport const neighborsDirected = /*#__PURE__*/dual(3, (graph, nodeIndex, direction) => {\n if (graph.type === \"undirected\") {\n throw new GraphError({\n message: \"Cannot get directed neighbors of undirected graph\"\n });\n }\n return getDirectedNeighbors(graph, nodeIndex, direction);\n});\n/**\n * Exports a graph to GraphViz DOT format for visualization.\n *\n * **Example** (Exporting GraphViz DOT)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {\n * const nodeA = Graph.addNode(mutable, \"Node A\")\n * const nodeB = Graph.addNode(mutable, \"Node B\")\n * const nodeC = Graph.addNode(mutable, \"Node C\")\n * Graph.addEdge(mutable, nodeA, nodeB, 1)\n * Graph.addEdge(mutable, nodeB, nodeC, 2)\n * Graph.addEdge(mutable, nodeC, nodeA, 3)\n * })\n *\n * const dot = Graph.toGraphViz(graph)\n * console.log(dot)\n * // digraph G {\n * // \"0\" [label=\"Node A\"];\n * // \"1\" [label=\"Node B\"];\n * // \"2\" [label=\"Node C\"];\n * // \"0\" -> \"1\" [label=\"1\"];\n * // \"1\" -> \"2\" [label=\"2\"];\n * // \"2\" -> \"0\" [label=\"3\"];\n * // }\n * ```\n *\n * @category converting\n * @since 3.18.0\n */\nexport const toGraphViz = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, options) => {\n const {\n edgeLabel = data => String(data),\n graphName = \"G\",\n nodeLabel = data => String(data)\n } = options ?? {};\n const isDirected = graph.type === \"directed\";\n const graphType = isDirected ? \"digraph\" : \"graph\";\n const edgeOperator = isDirected ? \"->\" : \"--\";\n const lines = [];\n lines.push(`${graphType} ${graphName} {`);\n // Add nodes\n for (const [nodeIndex, nodeData] of graph.nodes) {\n const label = nodeLabel(nodeData).replace(/\"/g, \"\\\\\\\"\");\n lines.push(` \"${nodeIndex}\" [label=\"${label}\"];`);\n }\n // Add edges\n for (const [, edgeData] of graph.edges) {\n const label = edgeLabel(edgeData.data).replace(/\"/g, \"\\\\\\\"\");\n lines.push(` \"${edgeData.source}\" ${edgeOperator} \"${edgeData.target}\" [label=\"${label}\"];`);\n }\n lines.push(\"}\");\n return lines.join(\"\\n\");\n});\n/**\n * Escapes special characters in labels for Mermaid syntax compatibility.\n */\nconst escapeMermaidLabel = label => {\n // Escape special characters for Mermaid using HTML entity codes\n // According to: https://mermaid.js.org/syntax/flowchart.html#special-characters-that-break-syntax\n return label.replace(/#/g, \"#35;\").replace(/\"/g, \"#quot;\").replace(/</g, \"#lt;\").replace(/>/g, \"#gt;\").replace(/&/g, \"#amp;\").replace(/\\[/g, \"#91;\").replace(/\\]/g, \"#93;\").replace(/\\{/g, \"#123;\").replace(/\\}/g, \"#125;\").replace(/\\(/g, \"#40;\").replace(/\\)/g, \"#41;\").replace(/\\|/g, \"#124;\").replace(/\\\\/g, \"#92;\").replace(/\\n/g, \"<br/>\");\n};\n/**\n * Formats a Mermaid node with the specified shape and label.\n */\nconst formatMermaidNode = (nodeId, label, shape) => {\n switch (shape) {\n case \"rectangle\":\n return `${nodeId}[\"${label}\"]`;\n case \"rounded\":\n return `${nodeId}(\"${label}\")`;\n case \"circle\":\n return `${nodeId}((\"${label}\"))`;\n case \"diamond\":\n return `${nodeId}{\"${label}\"}`;\n case \"hexagon\":\n return `${nodeId}{{\"${label}\"}}`;\n case \"stadium\":\n return `${nodeId}([\"${label}\"])`;\n case \"subroutine\":\n return `${nodeId}[[\"${label}\"]]`;\n case \"cylindrical\":\n return `${nodeId}[(\"${label}\")]`;\n default:\n return `${nodeId}[\"${label}\"]`;\n // Default rectangle\n }\n};\n/**\n * Exports a graph to Mermaid diagram format for visualization.\n *\n * **Details**\n *\n * Mermaid is a popular diagram-as-code tool that generates flowcharts and other\n * visualizations from text-based definitions. This function converts Effect Graph\n * structures to valid Mermaid syntax for use in documentation, web applications,\n * and visualization tools.\n *\n * **Example** (Exporting a directed Mermaid diagram)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Basic directed graph export\n * const graph = Graph.directed<string, number>((mutable) => {\n * const app = Graph.addNode(mutable, \"App\")\n * const db = Graph.addNode(mutable, \"Database\")\n * const cache = Graph.addNode(mutable, \"Cache\")\n * Graph.addEdge(mutable, app, db, 1)\n * Graph.addEdge(mutable, app, cache, 2)\n * })\n *\n * const mermaid = Graph.toMermaid(graph)\n * console.log(mermaid)\n * // flowchart TD\n * // 0[\"App\"]\n * // 1[\"Database\"]\n * // 2[\"Cache\"]\n * // 0 -->|\"1\"| 1\n * // 0 -->|\"2\"| 2\n * ```\n *\n * **Example** (Exporting an undirected Mermaid diagram)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Undirected graph with custom labels and direction\n * const socialGraph = Graph.undirected<{ name: string }, string>((mutable) => {\n * const alice = Graph.addNode(mutable, { name: \"Alice\" })\n * const bob = Graph.addNode(mutable, { name: \"Bob\" })\n * const charlie = Graph.addNode(mutable, { name: \"Charlie\" })\n * Graph.addEdge(mutable, alice, bob, \"friends\")\n * Graph.addEdge(mutable, bob, charlie, \"colleagues\")\n * })\n *\n * const mermaid = Graph.toMermaid(socialGraph, {\n * nodeLabel: (person) => person.name,\n * edgeLabel: (relationship) => relationship,\n * direction: \"LR\"\n * })\n * console.log(mermaid)\n * // graph LR\n * // 0[\"Alice\"]\n * // 1[\"Bob\"]\n * // 2[\"Charlie\"]\n * // 0 ---|\"friends\"| 1\n * // 1 ---|\"colleagues\"| 2\n * ```\n *\n * **Example** (Customizing Mermaid node shapes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Advanced styling with node shapes for flowchart\n * const workflow = Graph.directed<{ type: string; name: string }, string>(\n * (mutable) => {\n * const start = Graph.addNode(mutable, { type: \"start\", name: \"Begin\" })\n * const process = Graph.addNode(mutable, {\n * type: \"process\",\n * name: \"Process Data\"\n * })\n * const decision = Graph.addNode(mutable, {\n * type: \"decision\",\n * name: \"Valid?\"\n * })\n * const end = Graph.addNode(mutable, { type: \"end\", name: \"Complete\" })\n * Graph.addEdge(mutable, start, process, \"\")\n * Graph.addEdge(mutable, process, decision, \"\")\n * Graph.addEdge(mutable, decision, end, \"yes\")\n * }\n * )\n *\n * const mermaid = Graph.toMermaid(workflow, {\n * nodeLabel: (node) => node.name,\n * nodeShape: (node) => {\n * switch (node.type) {\n * case \"start\":\n * return \"stadium\"\n * case \"process\":\n * return \"rectangle\"\n * case \"decision\":\n * return \"diamond\"\n * case \"end\":\n * return \"stadium\"\n * default:\n * return \"rectangle\"\n * }\n * }\n * })\n * console.log(mermaid)\n * // flowchart TD\n * // 0([\"Begin\"])\n * // 1[\"Process Data\"]\n * // 2{\"Valid?\"}\n * // 3([\"Complete\"])\n * // 0 --> 1\n * // 1 --> 2\n * // 2 --> 3\n * ```\n *\n * **Example** (Visualizing dependency graphs)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Real-world example: Software dependency graph\n * interface Dependency {\n * name: string\n * version: string\n * type: \"library\" | \"framework\" | \"tool\"\n * }\n *\n * const dependencyGraph = Graph.directed<Dependency, string>((mutable) => {\n * const app = Graph.addNode(mutable, {\n * name: \"MyApp\",\n * version: \"1.0.0\",\n * type: \"library\"\n * })\n * const react = Graph.addNode(mutable, {\n * name: \"React\",\n * version: \"18.0.0\",\n * type: \"framework\"\n * })\n * const lodash = Graph.addNode(mutable, {\n * name: \"Lodash\",\n * version: \"4.17.0\",\n * type: \"library\"\n * })\n * const webpack = Graph.addNode(mutable, {\n * name: \"Webpack\",\n * version: \"5.0.0\",\n * type: \"tool\"\n * })\n *\n * Graph.addEdge(mutable, app, react, \"depends on\")\n * Graph.addEdge(mutable, app, lodash, \"depends on\")\n * Graph.addEdge(mutable, app, webpack, \"builds with\")\n * })\n *\n * const dependencyDiagram = Graph.toMermaid(dependencyGraph, {\n * nodeLabel: (dep) => `${dep.name}\\\\nv${dep.version}`,\n * edgeLabel: (edge) => edge,\n * nodeShape: (dep) =>\n * dep.type === \"framework\" ?\n * \"hexagon\" :\n * dep.type === \"tool\"\n * ? \"diamond\"\n * : \"rectangle\",\n * direction: \"TB\"\n * })\n *\n * console.log(dependencyDiagram)\n * // flowchart TB\n * // 0[\"MyApp\\nv1.0.0\"]\n * // 1{{\"React\\nv18.0.0\"}}\n * // 2[\"Lodash\\nv4.17.0\"]\n * // 3{\"Webpack\\nv5.0.0\"}\n * // 0 -->|\"depends on\"| 1\n * // 0 -->|\"depends on\"| 2\n * // 0 -->|\"builds with\"| 3\n * ```\n *\n * @category converting\n * @since 3.18.0\n */\nexport const toMermaid = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, options) => {\n // Extract and validate options with defaults\n const {\n diagramType,\n direction = \"TD\",\n edgeLabel = data => String(data),\n nodeLabel = data => String(data),\n nodeShape = () => \"rectangle\"\n } = options ?? {};\n // Auto-detect diagram type if not specified\n const finalDiagramType = diagramType ?? (graph.type === \"directed\" ? \"flowchart\" : \"graph\");\n // Generate diagram header\n const lines = [];\n lines.push(`${finalDiagramType} ${direction}`);\n // Add nodes\n for (const [nodeIndex, nodeData] of graph.nodes) {\n const nodeId = String(nodeIndex);\n const label = escapeMermaidLabel(nodeLabel(nodeData));\n const shape = nodeShape(nodeData);\n const formattedNode = formatMermaidNode(nodeId, label, shape);\n lines.push(` ${formattedNode}`);\n }\n // Add edges\n const edgeOperator = finalDiagramType === \"flowchart\" ? \"-->\" : \"---\";\n for (const [, edgeData] of graph.edges) {\n const sourceId = String(edgeData.source);\n const targetId = String(edgeData.target);\n const label = escapeMermaidLabel(edgeLabel(edgeData.data));\n if (label) {\n lines.push(` ${sourceId} ${edgeOperator}|\"${label}\"| ${targetId}`);\n } else {\n lines.push(` ${sourceId} ${edgeOperator} ${targetId}`);\n }\n }\n return lines.join(\"\\n\");\n});\n// =============================================================================\n// Graph Structure Analysis Algorithms\n// =============================================================================\n/**\n * Checks whether the graph is acyclic (contains no cycles).\n *\n * **Details**\n *\n * Uses depth-first search to detect back edges, which indicate cycles.\n * For directed graphs, any back edge creates a cycle. For undirected graphs,\n * a back edge that doesn't go to the immediate parent creates a cycle.\n *\n * **Example** (Checking cycles)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Acyclic directed graph (DAG)\n * const dag = Graph.directed<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, \"A->B\")\n * Graph.addEdge(mutable, b, c, \"B->C\")\n * })\n * console.log(Graph.isAcyclic(dag)) // true\n *\n * // Cyclic directed graph\n * const cyclic = Graph.directed<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, \"A->B\")\n * Graph.addEdge(mutable, b, a, \"B->A\") // Creates cycle\n * })\n * console.log(Graph.isAcyclic(cyclic)) // false\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const isAcyclic = graph => {\n // Use existing cycle flag if available\n if (Option.isSome(graph.acyclic)) {\n return graph.acyclic.value;\n }\n if (graph.type === \"undirected\") {\n const visited = new Set();\n for (const startNode of graph.nodes.keys()) {\n if (visited.has(startNode)) {\n continue;\n }\n visited.add(startNode);\n const stack = [{\n node: startNode,\n parent: null\n }];\n while (stack.length > 0) {\n const {\n node,\n parent\n } = stack.pop();\n const nodeNeighbors = getUndirectedNeighbors(graph, node);\n for (const neighbor of nodeNeighbors) {\n if (!visited.has(neighbor)) {\n visited.add(neighbor);\n stack.push({\n node: neighbor,\n parent: node\n });\n } else if (neighbor !== parent) {\n graph.acyclic = Option.some(false);\n return false;\n }\n }\n }\n }\n graph.acyclic = Option.some(true);\n return true;\n }\n // Stack-safe DFS cycle detection using iterative approach\n const visited = new Set();\n const recursionStack = new Set();\n // Get all nodes to handle disconnected components\n for (const startNode of graph.nodes.keys()) {\n if (visited.has(startNode)) {\n continue; // Already processed this component\n }\n // Iterative DFS with explicit stack\n const stack = [[startNode, [], 0, true]];\n while (stack.length > 0) {\n const [node, neighbors, neighborIndex, isFirstVisit] = stack[stack.length - 1];\n // First visit to this node\n if (isFirstVisit) {\n if (recursionStack.has(node)) {\n // Back edge found - cycle detected\n graph.acyclic = Option.some(false);\n return false;\n }\n if (visited.has(node)) {\n stack.pop();\n continue;\n }\n visited.add(node);\n recursionStack.add(node);\n // Get neighbors for this node\n const nodeNeighbors = getDirectedNeighbors(graph, node, \"outgoing\");\n stack[stack.length - 1] = [node, nodeNeighbors, 0, false];\n continue;\n }\n // Process next neighbor\n if (neighborIndex < neighbors.length) {\n const neighbor = neighbors[neighborIndex];\n stack[stack.length - 1] = [node, neighbors, neighborIndex + 1, false];\n if (recursionStack.has(neighbor)) {\n // Back edge found - cycle detected\n graph.acyclic = Option.some(false);\n return false;\n }\n if (!visited.has(neighbor)) {\n stack.push([neighbor, [], 0, true]);\n }\n } else {\n // Done with this node - backtrack\n recursionStack.delete(node);\n stack.pop();\n }\n }\n }\n // Cache the result\n graph.acyclic = Option.some(true);\n return true;\n};\n/**\n * Checks whether an undirected graph is bipartite.\n *\n * **Details**\n *\n * A bipartite graph is one whose vertices can be divided into two disjoint sets\n * such that no two vertices within the same set are adjacent. Uses BFS coloring\n * to determine bipartiteness.\n *\n * **Example** (Checking bipartite graphs)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * // Bipartite graph (alternating coloring possible)\n * const bipartite = Graph.undirected<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * const d = Graph.addNode(mutable, \"D\")\n * Graph.addEdge(mutable, a, b, \"edge\") // Set 1: {A, C}, Set 2: {B, D}\n * Graph.addEdge(mutable, b, c, \"edge\")\n * Graph.addEdge(mutable, c, d, \"edge\")\n * })\n * console.log(Graph.isBipartite(bipartite)) // true\n *\n * // Non-bipartite graph (odd cycle)\n * const triangle = Graph.undirected<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, \"edge\")\n * Graph.addEdge(mutable, b, c, \"edge\")\n * Graph.addEdge(mutable, c, a, \"edge\") // Triangle (3-cycle)\n * })\n * console.log(Graph.isBipartite(triangle)) // false\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const isBipartite = graph => {\n const coloring = new Map();\n const discovered = new Set();\n let isBipartiteGraph = true;\n // Get all nodes to handle disconnected components\n for (const startNode of graph.nodes.keys()) {\n if (!discovered.has(startNode)) {\n // Start BFS coloring from this component\n const queue = [startNode];\n coloring.set(startNode, 0); // Color start node with 0\n discovered.add(startNode);\n while (queue.length > 0 && isBipartiteGraph) {\n const current = queue.shift();\n const currentColor = coloring.get(current);\n const neighborColor = currentColor === 0 ? 1 : 0;\n // Get all neighbors for undirected graph\n const nodeNeighbors = getUndirectedNeighbors(graph, current);\n for (const neighbor of nodeNeighbors) {\n if (!discovered.has(neighbor)) {\n // Color unvisited neighbor with opposite color\n coloring.set(neighbor, neighborColor);\n discovered.add(neighbor);\n queue.push(neighbor);\n } else {\n // Check if neighbor has the same color (conflict)\n if (coloring.get(neighbor) === currentColor) {\n isBipartiteGraph = false;\n break;\n }\n }\n }\n }\n // Early exit if not bipartite\n if (!isBipartiteGraph) {\n break;\n }\n }\n }\n return isBipartiteGraph;\n};\n/**\n * Get neighbors for undirected graphs by checking both adjacency and reverse adjacency.\n * For undirected graphs, we need to find the other endpoint of each edge incident to the node.\n */\nconst getUndirectedNeighbors = (graph, nodeIndex) => {\n const neighbors = new Set();\n // Check edges where this node is the source\n const adjacencyList = graph.adjacency.get(nodeIndex);\n if (adjacencyList !== undefined) {\n for (const edgeIndex of adjacencyList) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n // For undirected graphs, the neighbor is the other endpoint\n const otherNode = edge.source === nodeIndex ? edge.target : edge.source;\n neighbors.add(otherNode);\n }\n }\n }\n return Array.from(neighbors);\n};\nconst getTraversalNeighbors = (graph, nodeIndex, direction) => graph.type === \"undirected\" ? getUndirectedNeighbors(graph, nodeIndex) : getDirectedNeighbors(graph, nodeIndex, direction);\nconst getTraversableNeighbor = (graph, current, edge) => graph.type === \"undirected\" && edge.target === current ? edge.source : edge.target;\n/**\n * Finds connected components in an undirected graph.\n * Each component is represented as an array of node indices.\n *\n * **Example** (Finding connected components)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.undirected<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * const d = Graph.addNode(mutable, \"D\")\n * Graph.addEdge(mutable, a, b, \"edge\") // Component 1: A-B\n * Graph.addEdge(mutable, c, d, \"edge\") // Component 2: C-D\n * })\n *\n * const components = Graph.connectedComponents(graph)\n * console.log(components) // [[0, 1], [2, 3]]\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const connectedComponents = graph => {\n const visited = new Set();\n const components = [];\n for (const startNode of graph.nodes.keys()) {\n if (!visited.has(startNode)) {\n // DFS to find all nodes in this component\n const component = [];\n const stack = [startNode];\n while (stack.length > 0) {\n const current = stack.pop();\n if (!visited.has(current)) {\n visited.add(current);\n component.push(current);\n // Add all unvisited neighbors to stack\n const nodeNeighbors = getUndirectedNeighbors(graph, current);\n for (const neighbor of nodeNeighbors) {\n if (!visited.has(neighbor)) {\n stack.push(neighbor);\n }\n }\n }\n }\n components.push(component);\n }\n }\n return components;\n};\n/**\n * Finds strongly connected components in a directed graph using Kosaraju's algorithm.\n * Each SCC is represented as an array of node indices.\n *\n * **Gotchas**\n *\n * Throws a `GraphError` when used with an undirected graph.\n *\n * **Example** (Finding strongly connected components)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, string>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, \"A->B\")\n * Graph.addEdge(mutable, b, c, \"B->C\")\n * Graph.addEdge(mutable, c, a, \"C->A\") // Creates SCC: A-B-C\n * })\n *\n * const sccs = Graph.stronglyConnectedComponents(graph)\n * console.log(sccs) // [[0, 1, 2]]\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const stronglyConnectedComponents = graph => {\n if (graph.type === \"undirected\") {\n throw new GraphError({\n message: \"Cannot find strongly connected components of undirected graph\"\n });\n }\n const visited = new Set();\n const finishOrder = [];\n for (const startNode of graph.nodes.keys()) {\n if (visited.has(startNode)) {\n continue;\n }\n const stack = [[startNode, [], 0, true]];\n while (stack.length > 0) {\n const [node, nodeNeighbors, neighborIndex, isFirstVisit] = stack[stack.length - 1];\n if (isFirstVisit) {\n if (visited.has(node)) {\n stack.pop();\n continue;\n }\n visited.add(node);\n const nodeNeighborsList = getDirectedNeighbors(graph, node, \"outgoing\");\n stack[stack.length - 1] = [node, nodeNeighborsList, 0, false];\n continue;\n }\n // Process next neighbor\n if (neighborIndex < nodeNeighbors.length) {\n const neighbor = nodeNeighbors[neighborIndex];\n stack[stack.length - 1] = [node, nodeNeighbors, neighborIndex + 1, false];\n if (!visited.has(neighbor)) {\n stack.push([neighbor, [], 0, true]);\n }\n } else {\n // Done with this node - add to finish order (post-order)\n finishOrder.push(node);\n stack.pop();\n }\n }\n }\n // Step 2: Stack-safe DFS on transpose graph in reverse finish order\n visited.clear();\n const sccs = [];\n for (let i = finishOrder.length - 1; i >= 0; i--) {\n const startNode = finishOrder[i];\n if (visited.has(startNode)) {\n continue;\n }\n const scc = [];\n const stack = [startNode];\n while (stack.length > 0) {\n const node = stack.pop();\n if (visited.has(node)) {\n continue;\n }\n visited.add(node);\n scc.push(node);\n // Use reverse adjacency (transpose graph)\n const reverseAdjacency = graph.reverseAdjacency.get(node);\n if (reverseAdjacency !== undefined) {\n for (const edgeIndex of reverseAdjacency) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n const predecessor = edge.source;\n if (!visited.has(predecessor)) {\n stack.push(predecessor);\n }\n }\n }\n }\n }\n sccs.push(scc);\n }\n return sccs;\n};\nconst validateNonNegativeEdgeWeights = (graph, cost, algorithm) => {\n const edgeWeights = new Map();\n for (const [edgeIndex, edgeData] of graph.edges) {\n const weight = cost(edgeData.data);\n if (weight < 0 || Number.isNaN(weight)) {\n throw new GraphError({\n message: `${algorithm} requires non-negative edge weights`\n });\n }\n edgeWeights.set(edgeIndex, weight);\n }\n return edgeWeights;\n};\n/**\n * Finds the shortest path from the configured source node to the target node\n * using Dijkstra's algorithm.\n *\n * **Details**\n *\n * Edge costs must be non-negative. Returns `Option.none()` when the target is\n * not reachable, and throws a `GraphError` when either endpoint is missing or a\n * negative edge cost is encountered.\n *\n * **Example** (Finding shortest paths with Dijkstra)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 5)\n * Graph.addEdge(mutable, a, c, 10)\n * Graph.addEdge(mutable, b, c, 2)\n * })\n *\n * const result = Graph.dijkstra(graph, {\n * source: 0,\n * target: 2,\n * cost: (edgeData) => edgeData\n * })\n *\n * if (result._tag === \"Some\") {\n * console.log(result.value.path) // [0, 1, 2] - shortest path A->B->C\n * console.log(result.value.distance) // 7 - total distance\n * }\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const dijkstra = /*#__PURE__*/dual(2, (graph, config) => {\n // Validate that source and target nodes exist\n if (!graph.nodes.has(config.source)) {\n throw missingNode(config.source);\n }\n if (!graph.nodes.has(config.target)) {\n throw missingNode(config.target);\n }\n const edgeWeights = validateNonNegativeEdgeWeights(graph, config.cost, \"Dijkstra's algorithm\");\n // Early return if source equals target\n if (config.source === config.target) {\n return Option.some({\n path: [config.source],\n distance: 0,\n costs: []\n });\n }\n // Distance tracking and priority queue simulation\n const distances = new Map();\n const previous = new Map();\n const visited = new Set();\n // Initialize distances\n // Iterate directly over node keys\n for (const node of graph.nodes.keys()) {\n distances.set(node, node === config.source ? 0 : Infinity);\n previous.set(node, null);\n }\n // Simple priority queue using array (can be optimized with proper heap)\n const priorityQueue = [{\n node: config.source,\n distance: 0\n }];\n while (priorityQueue.length > 0) {\n // Find minimum distance node (priority queue extract-min)\n let minIndex = 0;\n for (let i = 1; i < priorityQueue.length; i++) {\n if (priorityQueue[i].distance < priorityQueue[minIndex].distance) {\n minIndex = i;\n }\n }\n const current = priorityQueue.splice(minIndex, 1)[0];\n const currentNode = current.node;\n // Skip if already visited (can happen with duplicate entries)\n if (visited.has(currentNode)) {\n continue;\n }\n visited.add(currentNode);\n // Early termination if we reached the target\n if (currentNode === config.target) {\n break;\n }\n // Get current distance\n const currentDistance = distances.get(currentNode);\n // Examine all outgoing edges\n const adjacencyList = graph.adjacency.get(currentNode);\n if (adjacencyList !== undefined) {\n for (const edgeIndex of adjacencyList) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n const neighbor = getTraversableNeighbor(graph, currentNode, edge);\n const cost = edgeWeights.get(edgeIndex);\n const newDistance = currentDistance + cost;\n const neighborDistance = distances.get(neighbor);\n // Relaxation step\n if (newDistance < neighborDistance) {\n distances.set(neighbor, newDistance);\n previous.set(neighbor, {\n node: currentNode,\n edgeData: edge.data\n });\n // Add to priority queue if not visited\n if (!visited.has(neighbor)) {\n priorityQueue.push({\n node: neighbor,\n distance: newDistance\n });\n }\n }\n }\n }\n }\n }\n // Check if target is reachable\n const distance = distances.get(config.target);\n if (distance === Infinity) {\n return Option.none(); // No path exists\n }\n // Reconstruct path\n const path = [];\n const costs = [];\n let currentNode = config.target;\n while (currentNode !== null) {\n path.unshift(currentNode);\n const prev = previous.get(currentNode);\n if (prev !== null) {\n costs.unshift(prev.edgeData);\n currentNode = prev.node;\n } else {\n currentNode = null;\n }\n }\n return Option.some({\n path,\n distance,\n costs\n });\n});\n/**\n * Finds shortest paths between all pairs of nodes using the Floyd-Warshall\n * algorithm.\n *\n * **Details**\n *\n * Computes distances, reconstructed node paths, and edge-data paths for every\n * source and target pair in O(V^3) time. Negative edge weights are allowed, but\n * a `GraphError` is thrown if any negative cycle is detected.\n *\n * **Example** (Finding all-pairs shortest paths)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 3)\n * Graph.addEdge(mutable, b, c, 2)\n * Graph.addEdge(mutable, a, c, 7)\n * })\n *\n * const result = Graph.floydWarshall(graph, (edgeData) => edgeData)\n * const distanceAToC = result.distances.get(0)?.get(2) // 5 (A->B->C)\n * const pathAToC = result.paths.get(0)?.get(2) // [0, 1, 2]\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const floydWarshall = /*#__PURE__*/dual(2, (graph, cost) => {\n // Get all nodes for Floyd-Warshall algorithm (needs array for nested iteration)\n const allNodes = Array.from(graph.nodes.keys());\n // Initialize distance matrix\n const distances = new Map();\n const next = new Map();\n const edgeMatrix = new Map();\n // Initialize with infinity for all pairs\n for (const i of allNodes) {\n distances.set(i, new Map());\n next.set(i, new Map());\n edgeMatrix.set(i, new Map());\n for (const j of allNodes) {\n distances.get(i).set(j, i === j ? 0 : Infinity);\n next.get(i).set(j, null);\n edgeMatrix.get(i).set(j, null);\n }\n }\n // Set edge weights\n for (const [, edgeData] of graph.edges) {\n const weight = cost(edgeData.data);\n const i = edgeData.source;\n const j = edgeData.target;\n // Use minimum weight if multiple edges exist\n const currentWeight = distances.get(i).get(j);\n if (weight < currentWeight) {\n distances.get(i).set(j, weight);\n next.get(i).set(j, j);\n edgeMatrix.get(i).set(j, edgeData.data);\n }\n if (graph.type === \"undirected\") {\n const reverseWeight = distances.get(j).get(i);\n if (weight < reverseWeight) {\n distances.get(j).set(i, weight);\n next.get(j).set(i, i);\n edgeMatrix.get(j).set(i, edgeData.data);\n }\n }\n }\n // Floyd-Warshall main loop\n for (const k of allNodes) {\n for (const i of allNodes) {\n for (const j of allNodes) {\n const distIK = distances.get(i).get(k);\n const distKJ = distances.get(k).get(j);\n const distIJ = distances.get(i).get(j);\n if (distIK !== Infinity && distKJ !== Infinity && distIK + distKJ < distIJ) {\n distances.get(i).set(j, distIK + distKJ);\n next.get(i).set(j, next.get(i).get(k));\n }\n }\n }\n }\n // Check for negative cycles\n for (const i of allNodes) {\n if (distances.get(i).get(i) < 0) {\n throw new GraphError({\n message: `Negative cycle detected involving node ${i}`\n });\n }\n }\n // Build result paths and edge weights\n const paths = new Map();\n const costs = new Map();\n for (const i of allNodes) {\n paths.set(i, new Map());\n costs.set(i, new Map());\n for (const j of allNodes) {\n if (i === j) {\n paths.get(i).set(j, [i]);\n costs.get(i).set(j, []);\n } else if (distances.get(i).get(j) === Infinity) {\n paths.get(i).set(j, null);\n costs.get(i).set(j, []);\n } else {\n // Reconstruct path iteratively\n const path = [];\n const weights = [];\n let current = i;\n path.push(current);\n while (current !== j) {\n const nextNode = next.get(current).get(j);\n if (nextNode === null) break;\n const edgeData = edgeMatrix.get(current).get(nextNode);\n if (edgeData !== null) {\n weights.push(edgeData);\n }\n current = nextNode;\n path.push(current);\n }\n paths.get(i).set(j, path);\n costs.get(i).set(j, weights);\n }\n }\n }\n return {\n distances,\n paths,\n costs\n };\n});\n/**\n * Finds the shortest path from the configured source node to the target node\n * using the A* pathfinding algorithm.\n *\n * **Details**\n *\n * The edge-cost function must return non-negative weights, and the heuristic\n * should be consistent to preserve shortest-path guarantees. Returns\n * `Option.none()` when the target is not reachable, and throws a `GraphError`\n * when either endpoint is missing or a negative edge cost is encountered.\n *\n * **Example** (Finding shortest paths with A-star)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<{ x: number; y: number }, number>((mutable) => {\n * const a = Graph.addNode(mutable, { x: 0, y: 0 })\n * const b = Graph.addNode(mutable, { x: 1, y: 0 })\n * const c = Graph.addNode(mutable, { x: 2, y: 0 })\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 1)\n * })\n *\n * // Manhattan distance heuristic\n * const heuristic = (\n * nodeData: { x: number; y: number },\n * targetData: { x: number; y: number }\n * ) => Math.abs(nodeData.x - targetData.x) + Math.abs(nodeData.y - targetData.y)\n *\n * const result = Graph.astar(graph, {\n * source: 0,\n * target: 2,\n * cost: (edgeData) => edgeData,\n * heuristic\n * })\n *\n * if (result._tag === \"Some\") {\n * console.log(result.value.path) // [0, 1, 2] - shortest path\n * console.log(result.value.distance) // 2 - total distance\n * }\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const astar = /*#__PURE__*/dual(2, (graph, config) => {\n // Validate that source and target nodes exist\n if (!graph.nodes.has(config.source)) {\n throw missingNode(config.source);\n }\n if (!graph.nodes.has(config.target)) {\n throw missingNode(config.target);\n }\n const edgeWeights = validateNonNegativeEdgeWeights(graph, config.cost, \"A* algorithm\");\n // Early return if source equals target\n if (config.source === config.target) {\n return Option.some({\n path: [config.source],\n distance: 0,\n costs: []\n });\n }\n // Get target node data for heuristic calculations\n const targetNodeData = getNode(graph, config.target);\n if (Option.isNone(targetNodeData)) {\n throw new GraphError({\n message: `Missing node data for target node ${config.target}`\n });\n }\n // Distance tracking (g-score) and f-score (g + h)\n const gScore = new Map();\n const fScore = new Map();\n const previous = new Map();\n const visited = new Set();\n // Initialize scores\n // Iterate directly over node keys\n for (const node of graph.nodes.keys()) {\n gScore.set(node, node === config.source ? 0 : Infinity);\n fScore.set(node, Infinity);\n previous.set(node, null);\n }\n // Calculate initial f-score for source\n const sourceNodeData = getNode(graph, config.source);\n if (Option.isSome(sourceNodeData)) {\n const h = config.heuristic(sourceNodeData.value, targetNodeData.value);\n fScore.set(config.source, h);\n }\n // Priority queue using f-score (total estimated cost)\n const openSet = [{\n node: config.source,\n fScore: fScore.get(config.source)\n }];\n while (openSet.length > 0) {\n // Find node with lowest f-score\n let minIndex = 0;\n for (let i = 1; i < openSet.length; i++) {\n if (openSet[i].fScore < openSet[minIndex].fScore) {\n minIndex = i;\n }\n }\n const current = openSet.splice(minIndex, 1)[0];\n const currentNode = current.node;\n // Skip if already visited\n if (visited.has(currentNode)) {\n continue;\n }\n visited.add(currentNode);\n // Early termination if we reached the target\n if (currentNode === config.target) {\n break;\n }\n // Get current g-score\n const currentGScore = gScore.get(currentNode);\n // Examine all outgoing edges\n const adjacencyList = graph.adjacency.get(currentNode);\n if (adjacencyList !== undefined) {\n for (const edgeIndex of adjacencyList) {\n const edge = graph.edges.get(edgeIndex);\n if (edge !== undefined) {\n const neighbor = getTraversableNeighbor(graph, currentNode, edge);\n const weight = edgeWeights.get(edgeIndex);\n const tentativeGScore = currentGScore + weight;\n const neighborGScore = gScore.get(neighbor);\n // If this path to neighbor is better than any previous one\n if (tentativeGScore < neighborGScore) {\n // Update g-score and previous\n gScore.set(neighbor, tentativeGScore);\n previous.set(neighbor, {\n node: currentNode,\n edgeData: edge.data\n });\n // Calculate f-score using heuristic\n const neighborNodeData = getNode(graph, neighbor);\n if (Option.isSome(neighborNodeData)) {\n const h = config.heuristic(neighborNodeData.value, targetNodeData.value);\n const f = tentativeGScore + h;\n fScore.set(neighbor, f);\n // Add to open set if not visited\n if (!visited.has(neighbor)) {\n openSet.push({\n node: neighbor,\n fScore: f\n });\n }\n }\n }\n }\n }\n }\n }\n // Check if target is reachable\n const distance = gScore.get(config.target);\n if (distance === Infinity) {\n return Option.none(); // No path exists\n }\n // Reconstruct path\n const path = [];\n const costs = [];\n let currentNode = config.target;\n while (currentNode !== null) {\n path.unshift(currentNode);\n const prev = previous.get(currentNode) ?? null;\n if (prev !== null) {\n costs.unshift(prev.edgeData);\n currentNode = prev.node;\n } else {\n currentNode = null;\n }\n }\n return Option.some({\n path,\n distance,\n costs\n });\n});\n/**\n * Finds the shortest path from the configured source node to the target node\n * using the Bellman-Ford algorithm.\n *\n * **Details**\n *\n * Negative edge weights are allowed. Returns `Option.none()` when the target is\n * unreachable or when a negative cycle affects the path to the target. Throws a\n * `GraphError` when either endpoint is missing.\n *\n * **Example** (Finding shortest paths with Bellman-Ford)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, -1) // Negative weight allowed\n * Graph.addEdge(mutable, b, c, 3)\n * Graph.addEdge(mutable, a, c, 5)\n * })\n *\n * const result = Graph.bellmanFord(graph, {\n * source: 0,\n * target: 2,\n * cost: (edgeData) => edgeData\n * })\n *\n * if (result._tag === \"Some\") {\n * console.log(result.value.path) // [0, 1, 2] - shortest path A->B->C\n * console.log(result.value.distance) // 2 - total distance\n * }\n * ```\n *\n * @category algorithms\n * @since 3.18.0\n */\nexport const bellmanFord = /*#__PURE__*/dual(2, (graph, config) => {\n // Validate that source and target nodes exist\n if (!graph.nodes.has(config.source)) {\n throw missingNode(config.source);\n }\n if (!graph.nodes.has(config.target)) {\n throw missingNode(config.target);\n }\n // Early return if source equals target\n if (config.source === config.target) {\n return Option.some({\n path: [config.source],\n distance: 0,\n costs: []\n });\n }\n // Initialize distances and predecessors\n const distances = new Map();\n const previous = new Map();\n // Iterate directly over node keys\n for (const node of graph.nodes.keys()) {\n distances.set(node, node === config.source ? 0 : Infinity);\n previous.set(node, null);\n }\n // Collect all edges for relaxation\n const edges = [];\n for (const [, edgeData] of graph.edges) {\n const weight = config.cost(edgeData.data);\n edges.push({\n source: edgeData.source,\n target: edgeData.target,\n weight,\n edgeData: edgeData.data\n });\n if (graph.type === \"undirected\" && edgeData.source !== edgeData.target) {\n edges.push({\n source: edgeData.target,\n target: edgeData.source,\n weight,\n edgeData: edgeData.data\n });\n }\n }\n // Relax edges up to V-1 times\n const nodeCount = graph.nodes.size;\n for (let i = 0; i < nodeCount - 1; i++) {\n let hasUpdate = false;\n for (const edge of edges) {\n const sourceDistance = distances.get(edge.source);\n const targetDistance = distances.get(edge.target);\n // Relaxation step\n if (sourceDistance !== Infinity && sourceDistance + edge.weight < targetDistance) {\n distances.set(edge.target, sourceDistance + edge.weight);\n previous.set(edge.target, {\n node: edge.source,\n edgeData: edge.edgeData\n });\n hasUpdate = true;\n }\n }\n // Early termination if no updates\n if (!hasUpdate) {\n break;\n }\n }\n // Check for negative cycles\n for (const edge of edges) {\n const sourceDistance = distances.get(edge.source);\n const targetDistance = distances.get(edge.target);\n if (sourceDistance !== Infinity && sourceDistance + edge.weight < targetDistance) {\n // Negative cycle detected - check if it affects the path to target\n const affectedNodes = new Set();\n const queue = [edge.target];\n while (queue.length > 0) {\n const node = queue.shift();\n if (affectedNodes.has(node)) continue;\n affectedNodes.add(node);\n // Add all nodes reachable from this node\n for (const neighbor of getTraversalNeighbors(graph, node, \"outgoing\")) {\n queue.push(neighbor);\n }\n }\n // If target is affected by a negative cycle, no shortest path exists.\n if (affectedNodes.has(config.target)) {\n return Option.none();\n }\n }\n }\n // Check if target is reachable\n const distance = distances.get(config.target);\n if (distance === Infinity) {\n return Option.none(); // No path exists\n }\n // Reconstruct path\n const path = [];\n const costs = [];\n let currentNode = config.target;\n while (currentNode !== null) {\n path.unshift(currentNode);\n const prev = previous.get(currentNode);\n if (prev !== null) {\n costs.unshift(prev.edgeData);\n currentNode = prev.node;\n } else {\n currentNode = null;\n }\n }\n return Option.some({\n path,\n distance,\n costs\n });\n});\n/**\n * Represents an iterable wrapper used by graph traversal and listing APIs.\n *\n * **Details**\n *\n * A `Walker` yields `[index, data]` pairs lazily and can be viewed as just the\n * indices, just the values, or mapped entries with `indices`, `values`,\n * `entries`, and `visit`.\n *\n * **Example** (Working with node walkers)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * // Both traversal and element iterators return NodeWalker\n * const dfsNodes: Graph.NodeWalker<string> = Graph.dfs(graph, { start: [0] })\n * const allNodes: Graph.NodeWalker<string> = Graph.nodes(graph)\n *\n * // Common interface for working with node iterables\n * function processNodes<N>(nodeIterable: Graph.NodeWalker<N>): Array<number> {\n * return Array.from(Graph.indices(nodeIterable))\n * }\n *\n * // Access node data using values() or entries()\n * const nodeData = Array.from(Graph.values(dfsNodes)) // [\"A\", \"B\"]\n * const nodeEntries = Array.from(Graph.entries(allNodes)) // [[0, \"A\"], [1, \"B\"]]\n * ```\n *\n * @category models\n * @since 3.18.0\n */\nexport class Walker {\n // @ts-ignore\n [Symbol.iterator];\n /**\n * Visits each element and maps it to a value using the provided function.\n *\n * **Details**\n *\n * Takes a function that receives the index and data,\n * and returns an iterable of the mapped values. Skips elements that\n * no longer exist in the graph.\n *\n * **Example** (Visiting walker elements)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const dfs = Graph.dfs(graph, { start: [0] })\n *\n * // Map to just the node data\n * const values = Array.from(dfs.visit((index, data) => data))\n * console.log(values) // [\"A\", \"B\"]\n *\n * // Map to custom objects\n * const custom = Array.from(\n * dfs.visit((index, data) => ({ id: index, name: data }))\n * )\n * console.log(custom) // [{ id: 0, name: \"A\" }, { id: 1, name: \"B\" }]\n * ```\n *\n * @since 4.0.0\n */\n visit;\n constructor(\n /**\n * Visits each element and maps it to a value using the provided function.\n *\n * Takes a function that receives the index and data,\n * and returns an iterable of the mapped values. Skips elements that\n * no longer exist in the graph.\n *\n * **Example** (Visiting walker elements)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const dfs = Graph.dfs(graph, { start: [0] })\n *\n * // Map to just the node data\n * const values = Array.from(dfs.visit((index, data) => data))\n * console.log(values) // [\"A\", \"B\"]\n *\n * // Map to custom objects\n * const custom = Array.from(\n * dfs.visit((index, data) => ({ id: index, name: data }))\n * )\n * console.log(custom) // [{ id: 0, name: \"A\" }, { id: 1, name: \"B\" }]\n * ```\n *\n * @category iterators\n * @since 4.0.0\n */\n visit) {\n this.visit = visit;\n this[Symbol.iterator] = visit((index, data) => [index, data])[Symbol.iterator];\n }\n}\n/**\n * Returns an iterator over the indices in the walker.\n *\n * **Example** (Iterating walker indices)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const dfs = Graph.dfs(graph, { start: [0] })\n * const indices = Array.from(Graph.indices(dfs))\n * console.log(indices) // [0, 1]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const indices = walker => walker.visit((index, _) => index);\n/**\n * Returns an iterator over the values (data) in the walker.\n *\n * **Example** (Iterating walker values)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const dfs = Graph.dfs(graph, { start: [0] })\n * const values = Array.from(Graph.values(dfs))\n * console.log(values) // [\"A\", \"B\"]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const values = walker => walker.visit((_, data) => data);\n/**\n * Returns an iterator over [index, data] entries in the walker.\n *\n * **Example** (Iterating walker entries)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const dfs = Graph.dfs(graph, { start: [0] })\n * const entries = Array.from(Graph.entries(dfs))\n * console.log(entries) // [[0, \"A\"], [1, \"B\"]]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const entries = walker => walker.visit((index, data) => [index, data]);\n/**\n * Creates a lazy depth-first traversal iterator from the configured start\n * nodes.\n *\n * **Details**\n *\n * If no start nodes are supplied, the iterator is empty. The `direction` option\n * chooses whether to follow outgoing or incoming edges. Throws a `GraphError`\n * if any configured start node does not exist.\n *\n * **Example** (Traversing depth-first)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 1)\n * })\n *\n * // Start from a specific node\n * const dfs1 = Graph.dfs(graph, { start: [0] })\n * for (const nodeIndex of Graph.indices(dfs1)) {\n * console.log(nodeIndex) // Traverses in DFS order: 0, 1, 2\n * }\n *\n * // Empty iterator (no starting nodes)\n * const dfs2 = Graph.dfs(graph)\n * // Can be used programmatically\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const dfs = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, config = {}) => {\n const start = config.start ?? [];\n const direction = config.direction ?? \"outgoing\";\n // Validate that all start nodes exist\n for (const nodeIndex of start) {\n if (!hasNode(graph, nodeIndex)) {\n throw missingNode(nodeIndex);\n }\n }\n return new Walker(f => ({\n [Symbol.iterator]: () => {\n const stack = [...start];\n const discovered = new Set();\n const nextMapped = () => {\n while (stack.length > 0) {\n const current = stack.pop();\n if (discovered.has(current)) {\n continue;\n }\n discovered.add(current);\n const nodeDataOption = getNode(graph, current);\n if (Option.isNone(nodeDataOption)) {\n continue;\n }\n const neighbors = getTraversalNeighbors(graph, current, direction);\n for (let i = neighbors.length - 1; i >= 0; i--) {\n const neighbor = neighbors[i];\n if (!discovered.has(neighbor)) {\n stack.push(neighbor);\n }\n }\n return {\n done: false,\n value: f(current, nodeDataOption.value)\n };\n }\n return {\n done: true,\n value: undefined\n };\n };\n return {\n next: nextMapped\n };\n }\n }));\n});\n/**\n * Creates a lazy breadth-first traversal iterator from the configured start\n * nodes.\n *\n * **Details**\n *\n * If no start nodes are supplied, the iterator is empty. The `direction` option\n * chooses whether to follow outgoing or incoming edges. Throws a `GraphError`\n * if any configured start node does not exist.\n *\n * **Example** (Traversing breadth-first)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 1)\n * })\n *\n * // Start from a specific node\n * const bfs1 = Graph.bfs(graph, { start: [0] })\n * for (const nodeIndex of Graph.indices(bfs1)) {\n * console.log(nodeIndex) // Traverses in BFS order: 0, 1, 2\n * }\n *\n * // Empty iterator (no starting nodes)\n * const bfs2 = Graph.bfs(graph)\n * // Can be used programmatically\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const bfs = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, config = {}) => {\n const start = config.start ?? [];\n const direction = config.direction ?? \"outgoing\";\n // Validate that all start nodes exist\n for (const nodeIndex of start) {\n if (!hasNode(graph, nodeIndex)) {\n throw missingNode(nodeIndex);\n }\n }\n return new Walker(f => ({\n [Symbol.iterator]: () => {\n const queue = [...start];\n const discovered = new Set();\n const nextMapped = () => {\n while (queue.length > 0) {\n const current = queue.shift();\n if (!discovered.has(current)) {\n discovered.add(current);\n const neighbors = getTraversalNeighbors(graph, current, direction);\n for (const neighbor of neighbors) {\n if (!discovered.has(neighbor)) {\n queue.push(neighbor);\n }\n }\n const nodeData = getNode(graph, current);\n if (Option.isSome(nodeData)) {\n return {\n done: false,\n value: f(current, nodeData.value)\n };\n }\n return nextMapped();\n }\n }\n return {\n done: true,\n value: undefined\n };\n };\n return {\n next: nextMapped\n };\n }\n }));\n});\n/**\n * Creates a new topological sort iterator with optional configuration.\n *\n * **Details**\n *\n * The iterator uses Kahn's algorithm to lazily produce nodes in topological order.\n * Throws an error if the graph contains cycles.\n *\n * **Example** (Sorting topologically)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 1)\n * })\n *\n * // Standard topological sort\n * const topo1 = Graph.topo(graph)\n * for (const nodeIndex of Graph.indices(topo1)) {\n * console.log(nodeIndex) // 0, 1, 2 (topological order)\n * }\n *\n * // With initial nodes\n * const topo2 = Graph.topo(graph, { initials: [0] })\n *\n * // Check before sorting a cyclic graph\n * const cyclicGraph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, a, 2) // Creates cycle\n * })\n *\n * if (!Graph.isAcyclic(cyclicGraph)) {\n * console.log(\"cyclic graph\") // cyclic graph\n * }\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const topo = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, config = {}) => {\n if (graph.type === \"undirected\") {\n throw new GraphError({\n message: \"Cannot perform topological sort on undirected graph\"\n });\n }\n // Check if graph is acyclic first\n if (!isAcyclic(graph)) {\n throw new GraphError({\n message: \"Cannot perform topological sort on cyclic graph\"\n });\n }\n const initials = config.initials ?? [];\n // Validate that all initial nodes exist\n for (const nodeIndex of initials) {\n if (!hasNode(graph, nodeIndex)) {\n throw missingNode(nodeIndex);\n }\n }\n return new Walker(f => ({\n [Symbol.iterator]: () => {\n const inDegree = new Map();\n const remaining = new Set();\n const initialSet = new Set(initials);\n const queue = [...initials];\n // Initialize in-degree counts\n for (const [nodeIndex] of graph.nodes) {\n inDegree.set(nodeIndex, 0);\n remaining.add(nodeIndex);\n }\n // Calculate in-degrees\n for (const [, edgeData] of graph.edges) {\n const currentInDegree = inDegree.get(edgeData.target) || 0;\n inDegree.set(edgeData.target, currentInDegree + 1);\n }\n for (const nodeIndex of initials) {\n if (inDegree.get(nodeIndex) !== 0) {\n throw new GraphError({\n message: `Initial node ${nodeIndex} has incoming edges`\n });\n }\n }\n // Add remaining zero in-degree nodes after prioritized initials.\n for (const [nodeIndex, degree] of inDegree) {\n if (degree === 0 && !initialSet.has(nodeIndex)) {\n queue.push(nodeIndex);\n }\n }\n const nextMapped = () => {\n while (queue.length > 0) {\n const current = queue.shift();\n if (remaining.has(current)) {\n remaining.delete(current);\n // Process outgoing edges, reducing in-degree of targets\n const neighbors = getDirectedNeighbors(graph, current, \"outgoing\");\n for (const neighbor of neighbors) {\n if (remaining.has(neighbor)) {\n const currentInDegree = inDegree.get(neighbor) || 0;\n const newInDegree = currentInDegree - 1;\n inDegree.set(neighbor, newInDegree);\n // If in-degree becomes 0, add to queue\n if (newInDegree === 0) {\n queue.push(neighbor);\n }\n }\n }\n const nodeData = getNode(graph, current);\n if (Option.isSome(nodeData)) {\n return {\n done: false,\n value: f(current, nodeData.value)\n };\n }\n return nextMapped();\n }\n }\n return {\n done: true,\n value: undefined\n };\n };\n return {\n next: nextMapped\n };\n }\n }));\n});\n/**\n * Creates a lazy depth-first postorder traversal iterator from the configured\n * start nodes.\n *\n * **Details**\n *\n * Nodes are emitted after their reachable descendants have been processed. If\n * no start nodes are supplied, the iterator is empty. The `direction` option\n * chooses whether to follow outgoing or incoming edges.\n *\n * **Example** (Traversing in postorder)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const root = Graph.addNode(mutable, \"root\")\n * const child1 = Graph.addNode(mutable, \"child1\")\n * const child2 = Graph.addNode(mutable, \"child2\")\n * Graph.addEdge(mutable, root, child1, 1)\n * Graph.addEdge(mutable, root, child2, 1)\n * })\n *\n * // Postorder: children before parents\n * const postOrder = Graph.dfsPostOrder(graph, { start: [0] })\n * for (const node of postOrder) {\n * console.log(node) // 1, 2, 0\n * }\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const dfsPostOrder = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, config = {}) => {\n const start = config.start ?? [];\n const direction = config.direction ?? \"outgoing\";\n // Validate that all start nodes exist\n for (const nodeIndex of start) {\n if (!hasNode(graph, nodeIndex)) {\n throw missingNode(nodeIndex);\n }\n }\n return new Walker(f => ({\n [Symbol.iterator]: () => {\n const stack = [];\n const discovered = new Set();\n const finished = new Set();\n // Initialize stack with start nodes\n for (let i = start.length - 1; i >= 0; i--) {\n stack.push({\n node: start[i],\n visitedChildren: false\n });\n }\n const nextMapped = () => {\n while (stack.length > 0) {\n const current = stack[stack.length - 1];\n if (!discovered.has(current.node)) {\n discovered.add(current.node);\n current.visitedChildren = false;\n }\n if (!current.visitedChildren) {\n current.visitedChildren = true;\n const neighbors = getTraversalNeighbors(graph, current.node, direction);\n for (let i = neighbors.length - 1; i >= 0; i--) {\n const neighbor = neighbors[i];\n if (!discovered.has(neighbor) && !finished.has(neighbor)) {\n stack.push({\n node: neighbor,\n visitedChildren: false\n });\n }\n }\n } else {\n const nodeToEmit = stack.pop().node;\n if (!finished.has(nodeToEmit)) {\n finished.add(nodeToEmit);\n const nodeData = getNode(graph, nodeToEmit);\n if (Option.isSome(nodeData)) {\n return {\n done: false,\n value: f(nodeToEmit, nodeData.value)\n };\n }\n return nextMapped();\n }\n }\n }\n return {\n done: true,\n value: undefined\n };\n };\n return {\n next: nextMapped\n };\n }\n }));\n});\n/**\n * Creates an iterator over all node indices in the graph.\n *\n * **Details**\n *\n * The iterator produces node indices in the order they were added to the graph.\n * This provides access to all nodes regardless of connectivity.\n *\n * **Example** (Iterating all nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1)\n * })\n *\n * const indices = Array.from(Graph.indices(Graph.nodes(graph)))\n * console.log(indices) // [0, 1, 2]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const nodes = graph => new Walker(f => ({\n [Symbol.iterator]() {\n const nodeMap = graph.nodes;\n const iterator = nodeMap.entries();\n return {\n next() {\n const result = iterator.next();\n if (result.done) {\n return {\n done: true,\n value: undefined\n };\n }\n const [nodeIndex, nodeData] = result.value;\n return {\n done: false,\n value: f(nodeIndex, nodeData)\n };\n }\n };\n }\n}));\n/**\n * Creates an iterator over all edge indices in the graph.\n *\n * **Details**\n *\n * The iterator produces edge indices in the order they were added to the graph.\n * This provides access to all edges regardless of connectivity.\n *\n * **Example** (Iterating all edges)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const a = Graph.addNode(mutable, \"A\")\n * const b = Graph.addNode(mutable, \"B\")\n * const c = Graph.addNode(mutable, \"C\")\n * Graph.addEdge(mutable, a, b, 1)\n * Graph.addEdge(mutable, b, c, 2)\n * })\n *\n * const indices = Array.from(Graph.indices(Graph.edges(graph)))\n * console.log(indices) // [0, 1]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const edges = graph => new Walker(f => ({\n [Symbol.iterator]() {\n const edgeMap = graph.edges;\n const iterator = edgeMap.entries();\n return {\n next() {\n const result = iterator.next();\n if (result.done) {\n return {\n done: true,\n value: undefined\n };\n }\n const [edgeIndex, edgeData] = result.value;\n return {\n done: false,\n value: f(edgeIndex, edgeData)\n };\n }\n };\n }\n}));\n/**\n * Creates an iterator over external nodes (nodes without edges in the specified direction).\n *\n * **Details**\n *\n * External nodes have no outgoing edges (`direction: \"outgoing\"`) or no\n * incoming edges (`direction: \"incoming\"`). These are useful for finding\n * sources, sinks, or isolated nodes.\n *\n * **Example** (Iterating external nodes)\n *\n * ```ts\n * import { Graph } from \"effect\"\n *\n * const graph = Graph.directed<string, number>((mutable) => {\n * const source = Graph.addNode(mutable, \"source\") // 0 - no incoming\n * const middle = Graph.addNode(mutable, \"middle\") // 1 - has both\n * const sink = Graph.addNode(mutable, \"sink\") // 2 - no outgoing\n * const isolated = Graph.addNode(mutable, \"isolated\") // 3 - no edges\n *\n * Graph.addEdge(mutable, source, middle, 1)\n * Graph.addEdge(mutable, middle, sink, 2)\n * })\n *\n * // Nodes with no outgoing edges (sinks + isolated)\n * const sinks = Array.from(\n * Graph.indices(Graph.externals(graph, { direction: \"outgoing\" }))\n * )\n * console.log(sinks) // [2, 3]\n *\n * // Nodes with no incoming edges (sources + isolated)\n * const sources = Array.from(\n * Graph.indices(Graph.externals(graph, { direction: \"incoming\" }))\n * )\n * console.log(sources) // [0, 3]\n * ```\n *\n * @category iterators\n * @since 3.18.0\n */\nexport const externals = /*#__PURE__*/dual(args => isGraph(args[0]), (graph, config = {}) => {\n const direction = config.direction ?? \"outgoing\";\n return new Walker(f => ({\n [Symbol.iterator]: () => {\n const nodeMap = graph.nodes;\n const adjacencyMap = direction === \"incoming\" ? graph.reverseAdjacency : graph.adjacency;\n const nodeIterator = nodeMap.entries();\n const nextMapped = () => {\n let current = nodeIterator.next();\n while (!current.done) {\n const [nodeIndex, nodeData] = current.value;\n const adjacencyList = adjacencyMap.get(nodeIndex);\n // Node is external if it has no edges in the specified direction\n if (adjacencyList === undefined || adjacencyList.length === 0) {\n return {\n done: false,\n value: f(nodeIndex, nodeData)\n };\n }\n current = nodeIterator.next();\n }\n return {\n done: true,\n value: undefined\n };\n };\n return {\n next: nextMapped\n };\n }\n }));\n});\n//# sourceMappingURL=Graph.js.map","/**\n * The `PrimaryKey` module defines a small protocol for values that can expose\n * a stable, string-based identifier. A value participates by implementing a\n * method at {@link symbol}; consumers can check unknown values with\n * {@link isPrimaryKey} and read the key with {@link value}.\n *\n * @since 2.0.0\n */\nimport { hasProperty } from \"./Predicate.js\";\n/**\n * Defines the unique identifier used to identify objects that implement the `PrimaryKey` interface.\n *\n * **When to use**\n *\n * Use to implement the `PrimaryKey` protocol as a computed property key on\n * classes or object literals that expose a stable string identifier.\n *\n * @see {@link PrimaryKey} for the protocol interface that declares the method keyed by this symbol\n * @see {@link value} for reading the string key from a `PrimaryKey` value\n * @see {@link isPrimaryKey} for checking whether an unknown value carries this method\n *\n * @category symbols\n * @since 2.0.0\n */\nexport const symbol = \"~effect/interfaces/PrimaryKey\";\n/**\n * Checks whether a value implements the `PrimaryKey` protocol.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a `PrimaryKey`.\n *\n * **Details**\n *\n * This is a structural guard for the `PrimaryKey.symbol` property.\n *\n * **Gotchas**\n *\n * This guard does not call the method or verify that it returns a string.\n *\n * @see {@link PrimaryKey} for the protocol being checked\n * @see {@link value} for extracting the string value after narrowing\n *\n * @category models\n * @since 4.0.0\n */\nexport const isPrimaryKey = u => hasProperty(u, symbol);\n/**\n * Extracts the string value from a `PrimaryKey`.\n *\n * **When to use**\n *\n * Use to read the stable string identifier from a value that implements\n * `PrimaryKey`.\n *\n * **Example** (Reading primary key values)\n *\n * ```ts\n * import { PrimaryKey } from \"effect\"\n *\n * class OrderId implements PrimaryKey.PrimaryKey {\n * constructor(private timestamp: number, private sequence: number) {}\n *\n * [PrimaryKey.symbol](): string {\n * return `order_${this.timestamp}_${this.sequence}`\n * }\n * }\n *\n * const orderId = new OrderId(1640995200000, 1)\n * console.log(PrimaryKey.value(orderId)) // \"order_1640995200000_1\"\n *\n * // Can also be used with simple string-based implementations\n * const simpleKey = {\n * [PrimaryKey.symbol]: () => \"simple-key-123\"\n * }\n * console.log(PrimaryKey.value(simpleKey)) // \"simple-key-123\"\n * ```\n *\n * @category accessors\n * @since 2.0.0\n */\nexport const value = self => self[symbol]();\n//# sourceMappingURL=PrimaryKey.js.map","/**\n * Assigns string inputs to nodes with weighted consistent hashing.\n *\n * A hash ring minimizes remapping when nodes are added, removed, or reweighted.\n * This makes it useful for routing requests, partitioning keys, and\n * distributing shards across service instances or storage backends. This module\n * can create rings, add or remove nodes by `PrimaryKey`, route an input string\n * to a node, and compute shard assignments.\n *\n * @since 4.0.0\n */\nimport { dual } from \"./Function.js\";\nimport * as Hash from \"./Hash.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as PrimaryKey from \"./PrimaryKey.js\";\nconst TypeId = \"~effect/cluster/HashRing\";\n/**\n * Checks whether a value is a `HashRing`.\n *\n * **When to use**\n *\n * Use to narrow an `unknown` value before treating it as a `HashRing`, such as\n * values crossing an untyped boundary.\n *\n * **Details**\n *\n * The guard checks for the module's internal `TypeId` property and narrows to\n * `HashRing<any>`.\n *\n * **Gotchas**\n *\n * This is a structural type-id check; it does not validate the ring's `nodes`,\n * `ring`, or weight state.\n *\n * @see {@link HashRing} for the type narrowed by this guard\n * @see {@link make} for creating an empty `HashRing`\n *\n * @category guards\n * @since 3.19.0\n */\nexport const isHashRing = u => hasProperty(u, TypeId);\n/**\n * Creates an empty `HashRing`.\n *\n * **When to use**\n *\n * Use to create an empty weighted consistent-hashing ring with the default or\n * custom virtual-point density.\n *\n * **Details**\n *\n * `baseWeight` controls how many virtual points are added for a node with\n * weight `1`; it defaults to `128` and is clamped to at least `1`.\n *\n * @see {@link add} for registering one node after creation\n * @see {@link addMany} for registering several nodes after creation\n *\n * @category constructors\n * @since 3.19.0\n */\nexport const make = options => {\n const self = Object.create(Proto);\n self.baseWeight = Math.max(options?.baseWeight ?? 128, 1);\n self.totalWeightCache = 0;\n self.nodes = new Map();\n self.ring = [];\n return self;\n};\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n [Symbol.iterator]() {\n return Iterable.map(this.nodes.values(), ([n]) => n)[Symbol.iterator]();\n },\n toJSON() {\n return {\n _id: \"HashRing\",\n baseWeight: this.baseWeight,\n nodes: this.ring.map(([, n]) => this.nodes.get(n)[0])\n };\n }\n};\n/**\n * Adds new nodes to the ring. If a node already exists in the ring, it\n * will be updated. For example, you can use this to update the node's weight.\n *\n * **When to use**\n *\n * Use to register or update several nodes in a `HashRing` at the same weight.\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const addMany = /*#__PURE__*/dual(args => isHashRing(args[0]), (self, nodes, options) => {\n const weight = Math.max(options?.weight ?? 1, 0.1);\n const keys = [];\n let toRemove;\n for (const node of nodes) {\n const key = PrimaryKey.value(node);\n const entry = self.nodes.get(key);\n if (entry) {\n if (entry[1] === weight) continue;\n toRemove ??= new Set();\n toRemove.add(key);\n self.totalWeightCache -= entry[1];\n self.totalWeightCache += weight;\n entry[1] = weight;\n } else {\n self.nodes.set(key, [node, weight]);\n self.totalWeightCache += weight;\n }\n keys.push(key);\n }\n if (toRemove) {\n self.ring = self.ring.filter(([, n]) => !toRemove.has(n));\n }\n addNodesToRing(self, keys, Math.round(weight * self.baseWeight));\n return self;\n});\nfunction addNodesToRing(self, keys, weight) {\n for (let i = weight; i > 0; i--) {\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n self.ring.push([Hash.string(`${key}:${i}`), key]);\n }\n }\n self.ring.sort((a, b) => a[0] - b[0]);\n}\n/**\n * Adds a new node to the ring. If the node already exists in the ring, it\n * will be updated. For example, you can use this to update the node's weight.\n *\n * **When to use**\n *\n * Use to register one node in a `HashRing` so lookups and shard assignments can\n * return it, or update that node's weight.\n *\n * **Details**\n *\n * Nodes are matched by `PrimaryKey.value`. The weight defaults to `1` and is\n * clamped to at least `0.1`.\n *\n * **Gotchas**\n *\n * This mutates and returns the same ring instance.\n *\n * @see {@link addMany} for adding or updating several nodes\n * @see {@link remove} for unregistering a node\n * @see {@link has} for checking primary-key membership\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const add = /*#__PURE__*/dual(args => isHashRing(args[0]), (self, node, options) => addMany(self, [node], options));\n/**\n * Removes the node from the ring. No-op's if the node does not exist.\n *\n * **When to use**\n *\n * Use to remove a node that has left the pool so future lookups and shard\n * assignments stop returning it.\n *\n * **Details**\n *\n * Removal matches by `PrimaryKey.value`, so any value with the same primary key\n * removes the same ring member.\n *\n * **Gotchas**\n *\n * This mutates and returns the same ring instance.\n *\n * @see {@link add} for registering or updating a node\n * @see {@link has} for checking membership by primary key\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const remove = /*#__PURE__*/dual(2, (self, node) => {\n const key = PrimaryKey.value(node);\n const entry = self.nodes.get(key);\n if (entry) {\n self.nodes.delete(key);\n self.ring = self.ring.filter(([, n]) => n !== key);\n self.totalWeightCache -= entry[1];\n }\n return self;\n});\n/**\n * Checks whether the ring contains a node with the same `PrimaryKey` value.\n *\n * **When to use**\n *\n * Use when you need to know whether registering a node would update an existing\n * ring member because another node already has the same primary-key identity.\n *\n * **Details**\n *\n * Membership is checked with `self.nodes.has(PrimaryKey.value(node))`, so\n * matching is by primary key, not object identity or weight.\n *\n * @see {@link add} for registering or updating nodes\n * @see {@link remove} for removing nodes by the same primary-key identity\n * @see {@link get} for routing an input string to a node\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, node) => self.nodes.has(PrimaryKey.value(node)));\n/**\n * Gets the node which should handle the given input. Returns undefined if\n * the hashring has no elements with weight.\n *\n * **When to use**\n *\n * Use to route a single string input key to the current ring member responsible\n * for that key.\n *\n * @see {@link getShards} for assigning fixed shard indexes instead of routing\n * one input string at a time\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const get = (self, input) => {\n if (self.ring.length === 0) {\n return undefined;\n }\n const index = getIndexForInput(self, Hash.string(input))[0];\n const node = self.ring[index][1];\n return self.nodes.get(node)[0];\n};\n/**\n * Computes a balanced shard distribution across the nodes in the ring.\n *\n * **When to use**\n *\n * Use to precompute ownership for a fixed number of shard indexes across the\n * current ring members.\n *\n * @category combinators\n * @since 3.19.0\n */\nexport const getShards = (self, count) => {\n if (self.ring.length === 0) {\n return undefined;\n }\n const shards = new Array(count);\n // for tracking how many shards have been allocated to each node\n const allocations = new Map();\n // for tracking which shards still need to be allocated\n const remaining = new Set();\n // for tracking which nodes have reached the max allocation\n const exclude = new Set();\n // First pass - allocate the closest nodes, skipping nodes that have reached\n // max\n const distances = new Array(count);\n for (let shard = 0; shard < count; shard++) {\n const hash = shardHashes[shard] ??= Hash.string(`shard-${shard}`);\n const [index, distance] = getIndexForInput(self, hash);\n const node = self.ring[index][1];\n distances[shard] = [shard, node, distance];\n remaining.add(shard);\n }\n distances.sort((a, b) => a[2] - b[2]);\n for (let i = 0; i < count; i++) {\n const [shard, node] = distances[i];\n if (exclude.has(node)) continue;\n const [value, weight] = self.nodes.get(node);\n shards[shard] = value;\n remaining.delete(shard);\n const nodeCount = (allocations.get(node) ?? 0) + 1;\n allocations.set(node, nodeCount);\n const maxPerNode = Math.max(1, Math.floor(count * (weight / self.totalWeightCache)));\n if (nodeCount >= maxPerNode) {\n exclude.add(node);\n }\n }\n // Second pass - allocate any remaining shards, skipping nodes that have\n // reached max\n let allAtMax = exclude.size === self.nodes.size;\n remaining.forEach(shard => {\n const index = getIndexForInput(self, shardHashes[shard], allAtMax ? undefined : exclude)[0];\n const node = self.ring[index][1];\n const [value, weight] = self.nodes.get(node);\n shards[shard] = value;\n if (allAtMax) return;\n const nodeCount = (allocations.get(node) ?? 0) + 1;\n allocations.set(node, nodeCount);\n const maxPerNode = Math.max(1, Math.floor(count * (weight / self.totalWeightCache)));\n if (nodeCount >= maxPerNode) {\n exclude.add(node);\n if (exclude.size === self.nodes.size) {\n allAtMax = true;\n }\n }\n });\n return shards;\n};\nconst shardHashes = [];\nfunction getIndexForInput(self, hash, exclude) {\n const ring = self.ring;\n const len = ring.length;\n let mid;\n let lo = 0;\n let hi = len - 1;\n while (lo <= hi) {\n mid = (lo + hi) / 2 >>> 0;\n if (ring[mid][0] >= hash) {\n hi = mid - 1;\n } else {\n lo = mid + 1;\n }\n }\n const a = lo === len ? lo - 1 : lo;\n const distA = Math.abs(ring[a][0] - hash);\n if (exclude === undefined) {\n const b = lo - 1;\n if (b < 0) {\n return [a, distA];\n }\n const distB = Math.abs(ring[b][0] - hash);\n return distA <= distB ? [a, distA] : [b, distB];\n } else if (!exclude.has(ring[a][1])) {\n return [a, distA];\n }\n const range = Math.max(lo, len - lo);\n for (let i = 1; i < range; i++) {\n let index = lo - i;\n if (index >= 0 && index < len && !exclude.has(ring[index][1])) {\n return [index, Math.abs(ring[index][0] - hash)];\n }\n index = lo + i;\n if (index >= 0 && index < len && !exclude.has(ring[index][1])) {\n return [index, Math.abs(ring[index][0] - hash)];\n }\n }\n return [a, distA];\n}\n//# sourceMappingURL=HashRing.js.map","export {};\n//# sourceMappingURL=HKT.js.map","/**\n * Caches scoped services selected by key and built from layers.\n *\n * A `LayerMap<K, I, E>` turns a key into a cached service `Context<I>` and\n * exposes that context as either a `Layer` or a scoped effect. Entries can be\n * invalidated explicitly or released after they sit unused. This is useful for\n * keyed resource families such as tenant clients, regional connections, or\n * environment-specific services.\n *\n * @since 3.14.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport { identity } from \"./Function.js\";\nimport { getStackTraceLimit, setStackTraceLimit } from \"./internal/stackTraceLimit.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as RcMap from \"./RcMap.js\";\nimport * as Scope from \"./Scope.js\";\nconst TypeId = \"~effect/LayerMap\";\n/**\n * Creates a `LayerMap` that dynamically provides resources based on a key.\n *\n * **Example** (Creating a layer map)\n *\n * ```ts\n * import { Context, Effect, Layer, LayerMap } from \"effect\"\n *\n * // Define a service key\n * const DatabaseService = Context.Service<{\n * readonly query: (sql: string) => Effect.Effect<string>\n * }>(\"Database\")\n *\n * // Create a LayerMap that provides different database configurations\n * const program = Effect.gen(function*() {\n * const layerMap = yield* LayerMap.make(\n * (env: string) =>\n * Layer.succeed(DatabaseService)({\n * query: Effect.fn(\"DatabaseService.query\")((sql) => Effect.succeed(`${env}: ${sql}`))\n * }),\n * { idleTimeToLive: \"5 seconds\" }\n * )\n *\n * // Get a layer for a specific environment\n * const devLayer = layerMap.get(\"development\")\n *\n * // Use the layer to provide the service\n * const result = yield* Effect.provide(\n * Effect.gen(function*() {\n * const db = yield* DatabaseService\n * return yield* db.query(\"SELECT * FROM users\")\n * }),\n * devLayer\n * )\n *\n * console.log(result) // \"development: SELECT * FROM users\"\n * })\n * ```\n *\n * @category constructors\n * @since 3.14.0\n */\nexport const make = /*#__PURE__*/Effect.fnUntraced(function* (lookup, options) {\n const context = yield* Effect.context();\n const memoMap = Layer.CurrentMemoMap.forkOrCreate(context);\n const rcMap = yield* RcMap.make({\n lookup: key => Effect.contextWith(_ => Layer.buildWithMemoMap(lookup(key), memoMap, Context.get(_, Scope.Scope))),\n idleTimeToLive: options?.idleTimeToLive\n });\n return identity({\n [TypeId]: TypeId,\n rcMap,\n get: key => Layer.effectContext(RcMap.get(rcMap, key)),\n contextEffect: key => RcMap.get(rcMap, key),\n invalidate: key => RcMap.invalidate(rcMap, key)\n });\n});\n/**\n * Creates a `LayerMap` from a record of predefined layers.\n *\n * **Details**\n *\n * The record keys become the keys accepted by the returned `LayerMap`, and the\n * record values are the layers built for those keys.\n *\n * **Example** (Creating a layer map from a record)\n *\n * ```ts\n * import { Context, Effect, Layer, LayerMap } from \"effect\"\n *\n * // Define service keys\n * const DevDatabase = Context.Service<{\n * readonly query: (sql: string) => Effect.Effect<string>\n * }>(\"DevDatabase\")\n *\n * const ProdDatabase = Context.Service<{\n * readonly query: (sql: string) => Effect.Effect<string>\n * }>(\"ProdDatabase\")\n *\n * // Create predefined layers\n * const layers = {\n * development: Layer.succeed(DevDatabase)({\n * query: Effect.fn(\"DevDatabase.query\")((sql) => Effect.succeed(`DEV: ${sql}`))\n * }),\n * production: Layer.succeed(ProdDatabase)({\n * query: Effect.fn(\"ProdDatabase.query\")((sql) => Effect.succeed(`PROD: ${sql}`))\n * })\n * } as const\n *\n * // Create a LayerMap from the record\n * const program = Effect.gen(function*() {\n * const layerMap = yield* LayerMap.fromRecord(layers, {\n * idleTimeToLive: \"10 seconds\"\n * })\n *\n * // Get layers by key\n * const devLayer = layerMap.get(\"development\")\n * const prodLayer = layerMap.get(\"production\")\n *\n * console.log(\"LayerMap created from record\")\n * })\n * ```\n *\n * @category constructors\n * @since 3.14.0\n */\nexport const fromRecord = (layers, options) => make(key => layers[key], {\n ...options,\n preloadKeys: options?.preload ? Object.keys(layers) : undefined\n});\n/**\n * Create a `LayerMap` service that provides a dynamic set of resources based on\n * a key.\n *\n * **Example** (Defining a layer map service)\n *\n * ```ts\n * import { Console, Context, Effect, Layer, LayerMap } from \"effect\"\n *\n * // Define a service key\n * const Greeter = Context.Service<{\n * readonly greet: Effect.Effect<string>\n * }>(\"Greeter\")\n *\n * // Create a service that wraps a LayerMap\n * class GreeterMap extends LayerMap.Service<GreeterMap>()(\"GreeterMap\", {\n * // Define the lookup function for the layer map\n * lookup: (name: string) =>\n * Layer.succeed(Greeter)({\n * greet: Effect.succeed(`Hello, ${name}!`)\n * }),\n *\n * // If a layer is not used for a certain amount of time, it can be removed\n * idleTimeToLive: \"5 seconds\"\n * }) {}\n *\n * // Usage\n * const program = Effect.gen(function*() {\n * // Access and use the Greeter service\n * const greeter = yield* Greeter\n * yield* Console.log(yield* greeter.greet)\n * }).pipe(\n * // Use the GreeterMap service to provide a variant of the Greeter service\n * Effect.provide(GreeterMap.get(\"John\"))\n * ).pipe(\n * // Provide the GreeterMap layer\n * Effect.provide(GreeterMap.layer)\n * )\n * ```\n *\n * @category services\n * @since 3.14.0\n */\nexport const Service = () => (id, options) => {\n const Err = globalThis.Error;\n const limit = getStackTraceLimit();\n setStackTraceLimit(2);\n const creationError = new Err();\n setStackTraceLimit(limit);\n function TagClass() {}\n const TagClass_ = TagClass;\n Object.setPrototypeOf(TagClass, Object.getPrototypeOf(Context.Service(id)));\n TagClass.key = id;\n Object.defineProperty(TagClass, \"stack\", {\n get() {\n return creationError.stack;\n }\n });\n TagClass_.layerNoDeps = Layer.effect(TagClass_)(\"lookup\" in options ? make(options.lookup, options) : fromRecord(options.layers, options));\n TagClass_.layer = options.dependencies && options.dependencies.length > 0 ? Layer.provide(TagClass_.layerNoDeps, options.dependencies) : TagClass_.layerNoDeps;\n TagClass_.get = key => Layer.unwrap(Effect.map(TagClass_, layerMap => layerMap.get(key)));\n TagClass_.contextEffect = key => Effect.flatMap(TagClass_, layerMap => layerMap.contextEffect(key));\n TagClass_.invalidate = key => Effect.flatMap(TagClass_, layerMap => layerMap.invalidate(key));\n return TagClass;\n};\n//# sourceMappingURL=LayerMap.js.map","/**\n * Defines loggers and log-event data for Effect programs.\n *\n * A `Logger<Message, Output>` receives each log event as `Options` and turns it\n * into output such as a formatted string, structured object, console write,\n * file write, JSON line, or trace span event. This module also includes active\n * logger references, console routing helpers, built-in formatters, batching,\n * file logging, and layers for installing loggers.\n *\n * @since 2.0.0\n */\nimport * as Array from \"./Array.js\";\nimport * as FileSystem from \"./FileSystem.js\";\nimport * as Formatter from \"./Formatter.js\";\nimport { dual } from \"./Function.js\";\nimport { isEffect, withFiber } from \"./internal/core.js\";\nimport * as effect from \"./internal/effect.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as Predicate from \"./Predicate.js\";\nimport { CurrentLogAnnotations, CurrentLogSpans } from \"./References.js\";\nconst TypeId = \"~effect/Logger\";\n/**\n * Returns `true` if the specified value is a `Logger`, otherwise returns `false`.\n *\n * **Example** (Checking logger values)\n *\n * ```ts\n * import { Logger } from \"effect\"\n *\n * const myLogger = Logger.make((options) => {\n * console.log(options.message)\n * })\n *\n * console.log(Logger.isLogger(myLogger)) // true\n * console.log(Logger.isLogger(\"not a logger\")) // false\n * console.log(Logger.isLogger({ log: () => {} })) // false\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isLogger = u => Predicate.hasProperty(u, TypeId);\n/**\n * Context reference containing the active loggers for the current fiber.\n *\n * **Details**\n *\n * By default this set includes the default logger and the tracer logger.\n * Providing `Logger.layer` replaces or merges with this set depending on its\n * options.\n *\n * **Example** (Accessing current loggers)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Access current loggers from fiber context\n * const program = Effect.gen(function*() {\n * const currentLoggers = yield* Effect.service(Logger.CurrentLoggers)\n * console.log(`Number of active loggers: ${currentLoggers.size}`)\n *\n * // Add a custom logger to the set\n * const customLogger = Logger.make((options) => {\n * console.log(`Custom: ${options.message}`)\n * })\n *\n * yield* Effect.log(\"Hello from custom logger\").pipe(\n * Effect.provide(Logger.layer([customLogger]))\n * )\n * })\n * ```\n *\n * @category references\n * @since 4.0.0\n */\nexport const CurrentLoggers = effect.CurrentLoggers;\n/**\n * Context reference that routes the built-in default logger and TTY pretty\n * console logger to stderr.\n *\n * **When to use**\n *\n * Use to route built-in logger output to stderr while keeping stdout reserved\n * for protocol messages or data output.\n *\n * **Details**\n *\n * The reference defaults to `false`. Providing `true` makes the affected\n * loggers call `console.error` instead of `console.log`.\n *\n * @see {@link defaultLogger} for the runtime logger affected by this reference\n * @see {@link consolePretty} for the TTY-mode pretty console logger affected by this reference\n * @see {@link withConsoleError} for routing a specific formatter logger to `console.error`\n *\n * @category references\n * @since 4.0.0\n */\nexport const LogToStderr = effect.LogToStderr;\n/**\n * Transforms the output of a `Logger` using the provided function.\n *\n * **When to use**\n *\n * Use when an existing logger's output should be transformed without recreating the\n * logging logic.\n *\n * **Example** (Transforming logger output)\n *\n * ```ts\n * import { Logger } from \"effect\"\n *\n * // Create a logger that outputs objects\n * const structuredLogger = Logger.make((options) => ({\n * level: options.logLevel,\n * message: options.message,\n * timestamp: options.date.toISOString()\n * }))\n *\n * // Transform the output to JSON strings\n * const jsonStringLogger = Logger.map(\n * structuredLogger,\n * (output) => JSON.stringify(output)\n * )\n *\n * // Transform to uppercase messages\n * const uppercaseLogger = Logger.map(\n * structuredLogger,\n * (output) => ({ ...output, message: String(output.message).toUpperCase() })\n * )\n * ```\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map = /*#__PURE__*/dual(2, (self, f) => effect.loggerMake(options => f(self.log(options))));\n/**\n * Returns a new `Logger` that writes all output of the specified `Logger` to\n * the console using `console.log`.\n *\n * **When to use**\n *\n * Use when a logger's string or object output should be routed to `console.log` for\n * development or debugging.\n *\n * **Example** (Writing logger output with console.log)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Create a custom formatter\n * const customFormatter = Logger.make((options) =>\n * `[${options.date.toISOString()}] ${options.logLevel}: ${options.message}`\n * )\n *\n * // Route to console\n * const consoleLogger = Logger.withConsoleLog(customFormatter)\n *\n * const program = Effect.log(\"Hello World\").pipe(\n * Effect.provide(Logger.layer([consoleLogger]))\n * )\n * ```\n *\n * @category logging\n * @since 2.0.0\n */\nexport const withConsoleLog = self => effect.loggerMake(options => {\n const console = options.fiber.getRef(effect.ConsoleRef);\n return console.log(self.log(options));\n});\n/**\n * Returns a new `Logger` that writes all output of the specified `Logger` to\n * the console using `console.error`.\n *\n * **When to use**\n *\n * Use when logger output should be routed to `console.error`, such as error logs that\n * should appear on stderr instead of stdout.\n *\n * **Example** (Writing logger output with console.error)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Create an error-specific formatter\n * const errorFormatter = Logger.make((options) =>\n * `ERROR [${options.date.toISOString()}]: ${options.message}`\n * )\n *\n * // Route to console.error\n * const errorLogger = Logger.withConsoleError(errorFormatter)\n *\n * const program = Effect.logError(\"Database connection failed\").pipe(\n * Effect.provide(Logger.layer([errorLogger]))\n * )\n * ```\n *\n * @category logging\n * @since 2.0.0\n */\nexport const withConsoleError = self => effect.loggerMake(options => {\n const console = options.fiber.getRef(effect.ConsoleRef);\n return console.error(self.log(options));\n});\n/**\n * Returns a new `Logger` that writes all output of the specified `Logger` to\n * the console.\n *\n * **Details**\n *\n * Will use the appropriate console method (i.e. `console.log`, `console.error`,\n * etc.) based upon the current `LogLevel`.\n *\n * `Debug` uses `console.debug`, `Info` uses `console.info`, `Trace` uses\n * `console.trace`, `Warn` uses `console.warn`, `Error` and `Fatal` use\n * `console.error`, and all other levels use `console.log`.\n *\n * **Example** (Writing logs with level-based console methods)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * const formatter = Logger.make((options) =>\n * `[${options.logLevel}] ${options.message}`\n * )\n *\n * const leveledLogger = Logger.withLeveledConsole(formatter)\n *\n * const program = Effect.gen(function*() {\n * yield* Effect.logInfo(\"Info message\") // -> console.info\n * yield* Effect.logWarning(\"Warning\") // -> console.warn\n * yield* Effect.logError(\"Error occurred\") // -> console.error\n * yield* Effect.logDebug(\"Debug info\") // -> console.debug\n * }).pipe(\n * Effect.provide(Logger.layer([leveledLogger]))\n * )\n * ```\n *\n * @category logging\n * @since 3.8.0\n */\nexport const withLeveledConsole = self => effect.loggerMake(options => {\n const console = options.fiber.getRef(effect.ConsoleRef);\n const output = self.log(options);\n switch (options.logLevel) {\n case \"Debug\":\n return console.debug(output);\n case \"Info\":\n return console.info(output);\n case \"Trace\":\n return console.trace(output);\n case \"Warn\":\n return console.warn(output);\n case \"Error\":\n case \"Fatal\":\n return console.error(output);\n default:\n return console.log(output);\n }\n});\n/**\n * Match strings that do not contain any whitespace characters, double quotes,\n * or equal signs.\n */\nconst textOnly = /^[^\\s\"=]*$/;\n/**\n * Escapes double quotes in a string.\n */\nconst escapeDoubleQuotes = s => `\"${s.replace(/\\\\([\\s\\S])|(\")/g, \"\\\\$1$2\")}\"`;\n/**\n * Formats the identifier of a `Fiber` by prefixing it with a hash tag.\n */\nconst formatFiberId = fiberId => `#${fiberId}`;\n/**\n * Used by both {@link formatSimple} and {@link formatLogFmt} to render a log\n * message.\n *\n * @internal\n */\nconst format = (quoteValue, space) => ({\n cause,\n date,\n fiber,\n logLevel,\n message\n}) => {\n const formatUnknown = value => typeof value === \"string\" ? value : Formatter.format(value, {\n space\n });\n const formatValue = value => value.match(textOnly) ? value : quoteValue(value);\n const format = (label, value) => `${effect.formatLabel(label)}=${formatValue(value)}`;\n const append = (label, value) => \" \" + format(label, value);\n let out = format(\"timestamp\", date.toISOString());\n out += append(\"level\", logLevel);\n out += append(\"fiber\", formatFiberId(fiber.id));\n const messages = Array.ensure(message);\n for (let i = 0; i < messages.length; i++) {\n out += append(\"message\", formatUnknown(messages[i]));\n }\n if (cause.reasons.length > 0) {\n out += append(\"cause\", effect.causePretty(cause));\n }\n const now = date.getTime();\n const spans = fiber.getRef(CurrentLogSpans);\n for (const span of spans) {\n out += \" \" + effect.formatLogSpan(span, now);\n }\n const annotations = fiber.getRef(CurrentLogAnnotations);\n for (const [label, value] of Object.entries(annotations)) {\n out += append(label, formatUnknown(value));\n }\n return out;\n};\n/**\n * Creates a new `Logger` from a log function.\n *\n * **Details**\n *\n * The log function receives an options object containing the message, log level,\n * cause, fiber information, and timestamp, and should return the desired output.\n *\n * **Example** (Creating loggers from functions)\n *\n * ```ts\n * import { Effect, Logger, References } from \"effect\"\n *\n * // Simple text logger\n * const textLogger = Logger.make((options) =>\n * `${options.date.toISOString()} [${options.logLevel}] ${options.message}`\n * )\n *\n * // Structured object logger\n * const objectLogger = Logger.make((options) => ({\n * timestamp: options.date.toISOString(),\n * level: options.logLevel,\n * message: options.message,\n * fiberId: options.fiber.id,\n * annotations: options.fiber.getRef(References.CurrentLogAnnotations)\n * }))\n *\n * // Custom filtering logger\n * const filteredLogger = Logger.make((options) => {\n * if (options.logLevel === \"Debug\") {\n * return // Skip debug messages\n * }\n * return `${options.logLevel}: ${options.message}`\n * })\n *\n * const program = Effect.log(\"Hello World\").pipe(\n * Effect.provide(Logger.layer([textLogger]))\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = effect.loggerMake;\n/**\n * The default logging implementation used by the Effect runtime.\n *\n * **Example** (Referencing the default logger)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the default logger (automatically used by Effect runtime)\n * const program = Effect.gen(function*() {\n * yield* Effect.log(\"This uses the default logger\")\n * yield* Effect.logInfo(\"Info message\")\n * yield* Effect.logError(\"Error message\")\n * })\n *\n * // Explicitly use the default logger\n * const withDefaultLogger = Effect.log(\"Explicit default\").pipe(\n * Effect.provide(Logger.layer([Logger.defaultLogger]))\n * )\n *\n * // Compare with custom logger\n * const customLogger = Logger.make((options) => {\n * console.log(`CUSTOM: ${options.message}`)\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const defaultLogger = effect.defaultLogger;\n/**\n * A `Logger` which outputs logs as a string.\n *\n * **Details**\n *\n * For example, a simple log entry is rendered as\n * `timestamp=2025-01-03T14:22:47.570Z level=INFO fiber=#1 message=hello`.\n *\n * **Example** (Formatting logs as simple strings)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the simple format logger\n * const simpleLoggerProgram = Effect.log(\"Hello Simple Format\").pipe(\n * Effect.provide(Logger.layer([Logger.formatSimple]))\n * )\n *\n * // Combine with console output\n * const consoleSimpleLogger = Logger.withConsoleLog(Logger.formatSimple)\n *\n * const program = Effect.gen(function*() {\n * yield* Effect.log(\"Application started\")\n * yield* Effect.logInfo(\"Processing data\")\n * yield* Effect.logWarning(\"Memory usage high\")\n * }).pipe(\n * Effect.provide(Logger.layer([consoleSimpleLogger]))\n * )\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const formatSimple = /*#__PURE__*/effect.loggerMake(/*#__PURE__*/format(escapeDoubleQuotes));\n/**\n * A `Logger` which outputs logs using the [logfmt](https://brandur.org/logfmt)\n * style.\n *\n * **Details**\n *\n * For example, a logfmt entry is rendered as\n * `timestamp=2025-01-03T14:22:47.570Z level=INFO fiber=#1 message=hello`.\n *\n * **Example** (Formatting logs as logfmt)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the logfmt format logger\n * const logfmtLoggerProgram = Effect.log(\"Hello LogFmt Format\").pipe(\n * Effect.provide(Logger.layer([Logger.formatLogFmt]))\n * )\n *\n * // Perfect for structured logging systems\n * const structuredProgram = Effect.gen(function*() {\n * yield* Effect.log(\"User login\", { userId: 123, method: \"OAuth\" })\n * yield* Effect.logInfo(\"Request processed\", {\n * duration: 45,\n * status: \"success\"\n * })\n * }).pipe(\n * Effect.provide(Logger.layer([Logger.withConsoleLog(Logger.formatLogFmt)]))\n * )\n *\n * // Good for log aggregation systems like Splunk, ELK\n * const productionLogger = Logger.formatLogFmt\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const formatLogFmt = /*#__PURE__*/effect.loggerMake(/*#__PURE__*/format(JSON.stringify, 0));\n/**\n * A `Logger` which outputs logs using a structured format.\n *\n * **Details**\n *\n * For example, a structured entry can contain `message: [ \"hello\" ]`,\n * `level: \"INFO\"`, `timestamp: \"2025-01-03T14:25:39.666Z\"`,\n * `annotations: { key: \"value\" }`, `spans: { label: 0 }`, and\n * `fiberId: \"#1\"`.\n *\n * **Example** (Formatting logs as structured objects)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the structured format logger\n * const structuredLoggerProgram = Effect.log(\"Hello Structured Format\").pipe(\n * Effect.provide(Logger.layer([Logger.formatStructured]))\n * )\n *\n * // Perfect for JSON processing and analytics\n * const analyticsProgram = Effect.gen(function*() {\n * yield* Effect.log(\"User action\", { action: \"click\", element: \"button\" })\n * yield* Effect.logInfo(\"API call\", { endpoint: \"/users\", duration: 150 })\n * }).pipe(\n * Effect.annotateLogs(\"sessionId\", \"abc123\"),\n * Effect.withLogSpan(\"request\"),\n * Effect.provide(Logger.layer([Logger.formatStructured]))\n * )\n *\n * // Process structured output\n * const processingLogger = Logger.map(Logger.formatStructured, (output) => {\n * // Process the structured object\n * const enhanced = { ...output, processed: true }\n * return enhanced\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const formatStructured = /*#__PURE__*/effect.loggerMake(({\n cause,\n date,\n fiber,\n logLevel,\n message\n}) => {\n const annotationsObj = {};\n const spansObj = {};\n const annotations = fiber.getRef(CurrentLogAnnotations);\n for (const [key, value] of Object.entries(annotations)) {\n annotationsObj[key] = effect.structuredMessage(value);\n }\n const now = date.getTime();\n const spans = fiber.getRef(CurrentLogSpans);\n for (const [label, timestamp] of spans) {\n spansObj[label] = now - timestamp;\n }\n const messageArr = Array.ensure(message);\n return {\n message: messageArr.length === 1 ? effect.structuredMessage(messageArr[0]) : messageArr.map(effect.structuredMessage),\n level: logLevel.toUpperCase(),\n timestamp: date.toISOString(),\n cause: cause.reasons.length > 0 ? effect.causePretty(cause) : undefined,\n annotations: annotationsObj,\n spans: spansObj,\n fiberId: formatFiberId(fiber.id)\n };\n});\n/**\n * A `Logger` which outputs logs using a structured format serialized as JSON\n * on a single line.\n *\n * **Details**\n *\n * For example, a JSON entry can render as `{\"message\":[\"hello\"],\"level\":\"INFO\",\n * \"timestamp\":\"2025-01-03T14:28:57.508Z\",\"annotations\":{\"key\":\"value\"},\n * \"spans\":{\"label\":0},\"fiberId\":\"#1\"}`.\n *\n * **Example** (Formatting logs as JSON)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the JSON format logger\n * const jsonLoggerProgram = Effect.log(\"Hello JSON Format\").pipe(\n * Effect.provide(Logger.layer([Logger.formatJson]))\n * )\n *\n * // Perfect for log aggregation and processing systems\n * const productionProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Server started\", { port: 3000, env: \"production\" })\n * yield* Effect.logInfo(\"Request received\", {\n * method: \"GET\",\n * path: \"/api/users\"\n * })\n * yield* Effect.logError(\"Database error\", { error: \"Connection timeout\" })\n * }).pipe(\n * Effect.annotateLogs(\"service\", \"api-server\"),\n * Effect.withLogSpan(\"request-processing\"),\n * Effect.provide(Logger.layer([Logger.formatJson]))\n * )\n *\n * // Adapt the JSON string before giving it to an output sink\n * const envelopedJsonLogger = Logger.map(\n * Logger.formatJson,\n * (jsonString) => `{\"service\":\"api-server\",\"entry\":${jsonString}}`\n * )\n *\n * const envelopedConsoleLogger = Logger.withConsoleLog(envelopedJsonLogger)\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const formatJson = /*#__PURE__*/map(formatStructured, Formatter.formatJson);\n/**\n * Creates a scoped logger that batches the output of another logger.\n *\n * **Details**\n *\n * The returned effect starts a scoped background process that periodically\n * passes buffered outputs to `flush`. When the scope closes, the background\n * process is interrupted and any remaining buffered entries are flushed.\n *\n * **Example** (Batching logger output)\n *\n * ```ts\n * import { Duration, Effect, Logger } from \"effect\"\n *\n * // Create a batched logger that flushes every 5 seconds\n * const batchedLogger = Logger.batched(Logger.formatJson, {\n * window: Duration.seconds(5),\n * flush: (messages) =>\n * Effect.sync(() => {\n * console.log(`Flushing ${messages.length} log entries:`)\n * messages.forEach((msg, i) => console.log(`${i + 1}. ${msg}`))\n * })\n * })\n *\n * const program = Effect.gen(function*() {\n * const logger = yield* batchedLogger\n *\n * yield* Effect.provide(\n * Effect.all([\n * Effect.log(\"Event 1\"),\n * Effect.log(\"Event 2\"),\n * Effect.log(\"Event 3\"),\n * Effect.sleep(Duration.seconds(6)), // Trigger flush\n * Effect.log(\"Event 4\")\n * ]),\n * Logger.layer([logger])\n * )\n * })\n *\n * // Remote batch logging example\n * const remoteBatchLogger = Logger.batched(Logger.formatStructured, {\n * window: Duration.seconds(10),\n * flush: (entries) =>\n * Effect.sync(() => {\n * // Send batch to remote logging service\n * console.log(`Sending ${entries.length} log entries to remote service`)\n * })\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const batched = /*#__PURE__*/dual(2, (self, options) => effect.flatMap(effect.scope, scope => {\n let buffer = [];\n const flush = effect.suspend(() => {\n if (buffer.length === 0) {\n return effect.void;\n }\n const arr = buffer;\n buffer = [];\n return options.flush(arr);\n });\n return effect.uninterruptibleMask(restore => restore(effect.sleep(options.window).pipe(effect.andThen(flush), effect.forever)).pipe(effect.forkDetach, effect.flatMap(fiber => effect.scopeAddFinalizerExit(scope, () => effect.fiberInterrupt(fiber))), effect.andThen(effect.addFinalizer(() => flush)), effect.as(effect.loggerMake(options => {\n buffer.push(self.log(options));\n }))));\n}));\n/**\n * A `Logger` which outputs logs in a \"pretty\" format and writes them to the\n * console.\n *\n * **Details**\n *\n * For example, pretty output can render as\n * `[09:37:17.579] INFO (#1) label=0ms: hello` followed by an annotation line\n * such as `key: value`.\n *\n * **Example** (Logging with pretty console output)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the pretty console logger with default settings\n * const basicPretty = Effect.log(\"Hello Pretty Format\").pipe(\n * Effect.provide(Logger.layer([Logger.consolePretty()]))\n * )\n *\n * // Configure pretty logger options\n * const customPretty = Logger.consolePretty({\n * colors: true,\n * stderr: false,\n * mode: \"tty\",\n * formatDate: (date) => date.toLocaleTimeString()\n * })\n *\n * // Perfect for development environment\n * const developmentProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Application starting\")\n * yield* Effect.logInfo(\"Database connected\")\n * yield* Effect.logWarning(\"High memory usage detected\")\n * }).pipe(\n * Effect.annotateLogs(\"environment\", \"development\"),\n * Effect.withLogSpan(\"startup\"),\n * Effect.provide(Logger.layer([customPretty]))\n * )\n *\n * // Disable colors for CI/CD environments\n * const ciLogger = Logger.consolePretty({ colors: false })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const consolePretty = effect.consolePretty;\n/**\n * A `Logger` which outputs logs using the [logfmt](https://brandur.org/logfmt)\n * style and writes them to the console.\n *\n * **Details**\n *\n * For example, a console logfmt entry is rendered as\n * `timestamp=2025-01-03T14:22:47.570Z level=INFO fiber=#1 message=info`.\n *\n * **Example** (Logging logfmt output to the console)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the console logfmt logger\n * const logfmtProgram = Effect.log(\"Hello LogFmt Console\").pipe(\n * Effect.provide(Logger.layer([Logger.consoleLogFmt]))\n * )\n *\n * // Great for production environments\n * const productionProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Server started\", { port: 8080, version: \"1.0.0\" })\n * yield* Effect.logInfo(\"Request processed\", { userId: 123, duration: 45 })\n * yield* Effect.logError(\"Validation failed\", {\n * field: \"email\",\n * value: \"invalid\"\n * })\n * }).pipe(\n * Effect.annotateLogs(\"service\", \"api\"),\n * Effect.withLogSpan(\"request-handler\"),\n * Effect.provide(Logger.layer([Logger.consoleLogFmt]))\n * )\n *\n * // Combine with other loggers\n * const multiLoggerLive = Logger.layer([\n * Logger.consoleLogFmt,\n * Logger.consolePretty()\n * ])\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const consoleLogFmt = /*#__PURE__*/withConsoleLog(formatLogFmt);\n/**\n * A `Logger` which outputs logs using a structured format and writes them to\n * the console.\n *\n * **Details**\n *\n * For example, console structured output can contain\n * `message: [ \"info\", \"message\" ]`, `level: \"INFO\"`,\n * `timestamp: \"2025-01-03T14:25:39.666Z\"`,\n * `annotations: { key: \"value\" }`, `spans: { label: 0 }`, and\n * `fiberId: \"#1\"`.\n *\n * **Example** (Logging structured output to the console)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the console structured logger\n * const structuredProgram = Effect.log(\"Hello Structured Console\").pipe(\n * Effect.provide(Logger.layer([Logger.consoleStructured]))\n * )\n *\n * // Perfect for development debugging\n * const debugProgram = Effect.gen(function*() {\n * yield* Effect.log(\"User event\", {\n * userId: 123,\n * action: \"login\",\n * ip: \"192.168.1.1\"\n * })\n * yield* Effect.logInfo(\"API call\", {\n * endpoint: \"/users\",\n * method: \"GET\",\n * duration: 120\n * })\n * }).pipe(\n * Effect.annotateLogs(\"requestId\", \"req-123\"),\n * Effect.withLogSpan(\"authentication\"),\n * Effect.provide(Logger.layer([Logger.consoleStructured]))\n * )\n *\n * // Easy to parse and inspect object structure\n * const inspectionProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Complex data\", {\n * user: { id: 1, name: \"John\" },\n * metadata: { source: \"api\", version: 2 }\n * })\n * }).pipe(\n * Effect.provide(Logger.layer([Logger.consoleStructured]))\n * )\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const consoleStructured = /*#__PURE__*/withConsoleLog(formatStructured);\n/**\n * A `Logger` which outputs logs using a structured format serialized as JSON\n * on a single line and writes them to the console.\n *\n * **Details**\n *\n * For example, console JSON output can render as\n * `{\"message\":[\"hello\"],\"level\":\"INFO\",\"timestamp\":\"2025-01-03T14:28:57.508Z\",\n * \"annotations\":{\"key\":\"value\"},\"spans\":{\"label\":0},\"fiberId\":\"#1\"}`.\n *\n * **Example** (Logging JSON output to the console)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Use the console JSON logger\n * const jsonProgram = Effect.log(\"Hello JSON Console\").pipe(\n * Effect.provide(Logger.layer([Logger.consoleJson]))\n * )\n *\n * // Perfect for production logging and log aggregation\n * const productionProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Server started\", { port: 3000, env: \"production\" })\n * yield* Effect.logInfo(\"Request\", {\n * method: \"POST\",\n * url: \"/api/users\",\n * body: { name: \"Alice\" }\n * })\n * yield* Effect.logError(\"Database error\", {\n * error: \"Connection timeout\",\n * retryCount: 3\n * })\n * }).pipe(\n * Effect.annotateLogs(\"service\", \"user-api\"),\n * Effect.annotateLogs(\"version\", \"1.2.3\"),\n * Effect.withLogSpan(\"request-processing\"),\n * Effect.provide(Logger.layer([Logger.consoleJson]))\n * )\n *\n * // Easy to pipe to log aggregation services\n * const productionSetup = Logger.layer([\n * Logger.consoleJson, // For stdout JSON logs\n * Logger.consolePretty() // For local debugging\n * ])\n *\n * // Ideal for containerized environments (Docker, Kubernetes)\n * const containerProgram = Effect.log(\"Container ready\", {\n * containerId: \"abc123\",\n * image: \"myapp:latest\"\n * }).pipe(\n * Effect.provide(Logger.layer([Logger.consoleJson]))\n * )\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const consoleJson = /*#__PURE__*/withConsoleLog(formatJson);\n/**\n * A `Logger` which includes log messages as tracer span events.\n *\n * **Details**\n *\n * This logger integrates logging with distributed tracing by recording\n * all log messages as events on the current trace span, making them visible\n * in tracing tools like OpenTelemetry, Jaeger, or Zipkin.\n *\n * This logger is included in the default set of loggers for all Effect programs,\n * so log messages automatically appear as span events unless you override the\n * default loggers.\n *\n * **Example** (Recording logs as trace span events)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Tracer logger is included by default - logs automatically become span events\n * const defaultProgram = Effect.gen(function*() {\n * yield* Effect.log(\"This automatically becomes a span event\")\n * yield* Effect.logInfo(\"Processing data\")\n * })\n *\n * // Explicitly combine tracer logger with other loggers\n * const observabilityProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Operation started\")\n * yield* Effect.logInfo(\"Processing data\")\n * yield* Effect.logError(\"Error occurred\")\n * }).pipe(\n * Effect.withLogSpan(\"data-processing\"),\n * Effect.provide(Logger.layer([\n * Logger.tracerLogger,\n * Logger.consoleJson\n * ]))\n * )\n *\n * // Perfect for correlating logs with traces in distributed systems\n * const distributedProgram = Effect.gen(function*() {\n * yield* Effect.log(\"Step 1: Fetching user data\")\n * yield* Effect.sleep(\"100 millis\")\n * yield* Effect.log(\"Step 2: Processing payment\")\n * yield* Effect.sleep(\"200 millis\")\n * yield* Effect.log(\"Step 3: Sending confirmation\")\n * }).pipe(\n * Effect.withLogSpan(\"payment-workflow\"),\n * Effect.annotateLogs(\"userId\", \"user-123\"),\n * Effect.provide(Logger.layer([Logger.tracerLogger]))\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const tracerLogger = effect.tracerLogger;\n/**\n * Creates a `Layer` which will overwrite the current set of loggers with the\n * specified array of `loggers`.\n *\n * **Details**\n *\n * If the specified array of `loggers` should be _merged_ with the current set\n * of loggers (instead of overwriting them), set `mergeWithExisting` to `true`.\n *\n * **Example** (Providing logger layers)\n *\n * ```ts\n * import { Effect, Logger } from \"effect\"\n *\n * // Single logger layer\n * const JsonLoggerLive = Logger.layer([Logger.consoleJson])\n *\n * // Multiple loggers layer\n * const MultiLoggerLive = Logger.layer([\n * Logger.consoleJson,\n * Logger.consolePretty(),\n * Logger.formatStructured\n * ])\n *\n * // Merge with existing loggers\n * const AdditionalLoggerLive = Logger.layer(\n * [Logger.consoleJson],\n * { mergeWithExisting: true }\n * )\n *\n * // Using multiple logger formats\n * const jsonLogger = Logger.consoleJson\n * const prettyLogger = Logger.consolePretty()\n *\n * const CustomLoggerLive = Logger.layer([jsonLogger, prettyLogger])\n *\n * const program = Effect.log(\"Application started\").pipe(\n * Effect.provide(CustomLoggerLive)\n * )\n * ```\n *\n * @category context\n * @since 4.0.0\n */\nexport const layer = (loggers, options) => Layer.effect(CurrentLoggers, withFiber(effect.fnUntraced(function* (fiber) {\n const currentLoggers = new Set(options?.mergeWithExisting === true ? fiber.getRef(effect.CurrentLoggers) : []);\n for (const logger of loggers) {\n currentLoggers.add(isEffect(logger) ? yield* logger : logger);\n }\n return currentLoggers;\n})));\n/**\n * Creates a scoped logger that writes string logger output to a file.\n *\n * **Details**\n *\n * The returned effect requires `FileSystem` and `Scope`. The file logger batches\n * string output, writes each batch to the specified path, and flushes remaining\n * entries when the scope closes.\n *\n * **Example** (Writing JSON logs to a file)\n *\n * ```ts\n * import { Effect, Layer, Logger } from \"effect\"\n * import { NodeFileSystem, NodeRuntime } from \"@effect/platform-node\"\n *\n * const fileLogger = Logger.formatJson.pipe(\n * Logger.toFile(\"/tmp/log.txt\")\n * )\n * const LoggerLive = Logger.layer([fileLogger]).pipe(\n * Layer.provide(NodeFileSystem.layer)\n * )\n *\n * Effect.log(\"a\").pipe(\n * Effect.andThen(Effect.log(\"b\")),\n * Effect.andThen(Effect.log(\"c\")),\n * Effect.provide(LoggerLive),\n * NodeRuntime.runMain\n * )\n * ```\n *\n * **Example** (Writing logs to files)\n *\n * ```ts\n * import { Duration, Effect, Logger } from \"effect\"\n * import { NodeFileSystem } from \"@effect/platform-node\"\n *\n * // Basic file logging. The scope keeps the file open while logs are emitted\n * // and flushes pending entries when it closes.\n * const basicFileLogger = Effect.scoped(\n * Effect.gen(function*() {\n * const fileLogger = yield* Logger.formatJson.pipe(\n * Logger.toFile(\"/tmp/app.log\")\n * )\n *\n * yield* Effect.log(\"Application started\").pipe(\n * Effect.provide(Logger.layer([fileLogger]))\n * )\n * })\n * ).pipe(\n * Effect.provide(NodeFileSystem.layer)\n * )\n *\n * // File logger with custom batch window\n * const batchedFileLogger = Effect.scoped(\n * Effect.gen(function*() {\n * const fileLogger = yield* Logger.formatLogFmt.pipe(\n * Logger.toFile(\"/var/log/myapp.log\", {\n * flag: \"a\",\n * batchWindow: Duration.seconds(5)\n * })\n * )\n *\n * yield* Effect.all([\n * Effect.log(\"Event 1\"),\n * Effect.log(\"Event 2\"),\n * Effect.log(\"Event 3\")\n * ]).pipe(\n * Effect.provide(Logger.layer([fileLogger]))\n * )\n * })\n * ).pipe(\n * Effect.provide(NodeFileSystem.layer)\n * )\n *\n * // Multiple loggers: console + file\n * const multiLogger = Effect.scoped(\n * Effect.gen(function*() {\n * const fileLogger = yield* Logger.formatJson.pipe(\n * Logger.toFile(\"/tmp/production.log\")\n * )\n *\n * const loggerLive = Logger.layer([\n * Logger.consolePretty(),\n * fileLogger\n * ])\n *\n * yield* Effect.log(\"Production event\").pipe(\n * Effect.provide(loggerLive)\n * )\n * })\n * ).pipe(\n * Effect.provide(NodeFileSystem.layer)\n * )\n * ```\n *\n * @category file\n * @since 4.0.0\n */\nexport const toFile = /*#__PURE__*/dual(args => isLogger(args[0]), (self, path, options) => effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const logFile = yield* fs.open(path, {\n flag: \"a+\",\n ...options\n });\n const encoder = new TextEncoder();\n return yield* batched(self, {\n window: options?.batchWindow ?? 1000,\n flush: output => effect.ignore(logFile.write(encoder.encode(output.join(\"\\n\") + \"\\n\")))\n });\n}));\n//# sourceMappingURL=Logger.js.map","import * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport * as Layer from \"./Layer.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Scope from \"./Scope.js\";\nconst TypeId = \"~effect/ManagedRuntime\";\n/**\n * Checks whether the provided argument is a `ManagedRuntime`.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a `ManagedRuntime`.\n *\n * **Details**\n *\n * The guard checks the internal `ManagedRuntime` marker property. It does not\n * build the layer or inspect the runtime's services.\n *\n * **Gotchas**\n *\n * Disposed runtimes still carry the marker, so this guard does not prove the\n * runtime is still usable.\n *\n * @see {@link make} for creating managed runtimes this guard recognizes\n *\n * @category guards\n * @since 3.9.0\n */\nexport const isManagedRuntime = input => hasProperty(input, TypeId);\n/**\n * Creates a `ManagedRuntime` from a layer.\n *\n * **When to use**\n *\n * Use to create a reusable runtime from a `Layer` for application entry points\n * or integration code that runs many effects without rebuilding services.\n *\n * **Details**\n *\n * The layer is built lazily on first use and its context is cached for\n * subsequent runs. Resources acquired by the layer are owned by the runtime and\n * are released when `dispose` or `disposeEffect` is run. `options.memoMap` can\n * be used to share layer memoization with other layer builds.\n *\n * **Gotchas**\n *\n * Dispose the runtime when it is no longer needed. A runtime cannot be reused\n * after disposal.\n *\n * **Example** (Creating a managed runtime)\n *\n * ```ts\n * import { Context, Effect, Layer, ManagedRuntime } from \"effect\"\n *\n * class Notifications extends Context.Service<Notifications, {\n * readonly notify: (message: string) => Effect.Effect<void>\n * }>()(\"Notifications\") {\n * static readonly layer = Layer.succeed(this)({\n * notify: Effect.fn(\"Notifications.notify\")((message) =>\n * Effect.sync(() => console.log(message))\n * )\n * })\n * }\n *\n * const runtime = ManagedRuntime.make(Notifications.layer)\n *\n * const program = Effect.flatMap(\n * Notifications,\n * (_) => _.notify(\"Hello, world!\")\n * ).pipe(Effect.ensuring(runtime.disposeEffect))\n *\n * runtime.runPromise(program)\n * // Hello, world!\n * ```\n *\n * @see {@link ManagedRuntime} for the returned runtime interface\n * @see {@link Layer.MemoMap} for shared layer memoization\n * @see {@link Layer.build} for lower-level scoped layer construction\n *\n * @category runtime class\n * @since 2.0.0\n */\nexport const make = (layer, options) => {\n const memoMap = options?.memoMap ?? Layer.makeMemoMapUnsafe();\n const scope = Scope.makeUnsafe(\"parallel\");\n const layerScope = Scope.forkUnsafe(scope, \"sequential\");\n const defaultRunOptions = {\n onFiberStart: Fiber.runIn(scope)\n };\n const mergeRunOptions = options => options ? {\n ...options,\n onFiberStart: options.onFiberStart ? fiber => {\n defaultRunOptions.onFiberStart(fiber);\n options.onFiberStart(fiber);\n } : defaultRunOptions.onFiberStart\n } : defaultRunOptions;\n let buildFiber;\n const contextEffect = Effect.withFiber(fiber => {\n if (!buildFiber) {\n buildFiber = Effect.runFork(Effect.tap(Layer.buildWithMemoMap(layer, memoMap, layerScope), context => Effect.sync(() => {\n self.cachedContext = context;\n })), {\n ...defaultRunOptions,\n scheduler: fiber.currentScheduler\n });\n }\n return Effect.flatten(Fiber.await(buildFiber));\n });\n const self = {\n [TypeId]: TypeId,\n memoMap,\n scope,\n contextEffect: contextEffect,\n cachedContext: undefined,\n context() {\n return self.cachedContext === undefined ? Effect.runPromise(self.contextEffect) : Promise.resolve(self.cachedContext);\n },\n dispose() {\n return Effect.runPromise(self.disposeEffect);\n },\n disposeEffect: Effect.suspend(() => {\n ;\n self.contextEffect = Effect.die(\"ManagedRuntime disposed\");\n self.cachedContext = undefined;\n return Scope.close(self.scope, Exit.void);\n }),\n runFork(effect, options) {\n return self.cachedContext === undefined ? Effect.runFork(provide(self, effect), mergeRunOptions(options)) : Effect.runForkWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runCallback(effect, options) {\n return self.cachedContext === undefined ? Effect.runCallback(provide(self, effect), mergeRunOptions(options)) : Effect.runCallbackWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runSyncExit(effect) {\n return self.cachedContext === undefined ? Effect.runSyncExit(provide(self, effect)) : Effect.runSyncExitWith(self.cachedContext)(effect);\n },\n runSync(effect) {\n return self.cachedContext === undefined ? Effect.runSync(provide(self, effect)) : Effect.runSyncWith(self.cachedContext)(effect);\n },\n runPromiseExit(effect, options) {\n return self.cachedContext === undefined ? Effect.runPromiseExit(provide(self, effect), mergeRunOptions(options)) : Effect.runPromiseExitWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runPromise(effect, options) {\n return self.cachedContext === undefined ? Effect.runPromise(provide(self, effect), mergeRunOptions(options)) : Effect.runPromiseWith(self.cachedContext)(effect, mergeRunOptions(options));\n }\n };\n return self;\n};\nfunction provide(managed, effect) {\n return Effect.flatMap(managed.contextEffect, context => Effect.provideContext(effect, context));\n}\n//# sourceMappingURL=ManagedRuntime.js.map","import { dual, identity } from \"../Function.js\";\nimport * as Option from \"../Option.js\";\nimport { pipeArguments } from \"../Pipeable.js\";\nimport * as Result from \"../Result.js\";\n/** @internal */\nexport const TypeId = \"~effect/match/Match/Matcher\";\nconst TypeMatcherProto = {\n [TypeId]: {\n _input: identity,\n _filters: identity,\n _remaining: identity,\n _result: identity,\n _return: identity\n },\n _tag: \"TypeMatcher\",\n add(_case) {\n return makeTypeMatcher([...this.cases, _case]);\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nfunction makeTypeMatcher(cases) {\n const matcher = Object.create(TypeMatcherProto);\n matcher.cases = cases;\n return matcher;\n}\nconst ValueMatcherProto = {\n [TypeId]: {\n _input: identity,\n _filters: identity,\n _result: identity,\n _return: identity\n },\n _tag: \"ValueMatcher\",\n add(_case) {\n if (Result.isSuccess(this.value)) {\n return this;\n }\n if (_case._tag === \"When\" && _case.guard(this.provided) === true) {\n return makeValueMatcher(this.provided, Result.succeed(_case.evaluate(this.provided)));\n } else if (_case._tag === \"Not\" && _case.guard(this.provided) === false) {\n return makeValueMatcher(this.provided, Result.succeed(_case.evaluate(this.provided)));\n }\n return this;\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nfunction makeValueMatcher(provided, value) {\n const matcher = Object.create(ValueMatcherProto);\n matcher.provided = provided;\n matcher.value = value;\n return matcher;\n}\nconst makeWhen = (guard, evaluate) => ({\n _tag: \"When\",\n guard,\n evaluate\n});\nconst makeNot = (guard, evaluate) => ({\n _tag: \"Not\",\n guard,\n evaluate\n});\nconst makePredicate = pattern => {\n if (typeof pattern === \"function\") {\n return pattern;\n } else if (Array.isArray(pattern)) {\n const predicates = pattern.map(makePredicate);\n const len = predicates.length;\n return u => {\n if (!Array.isArray(u)) {\n return false;\n }\n for (let i = 0; i < len; i++) {\n if (predicates[i](u[i]) === false) {\n return false;\n }\n }\n return true;\n };\n } else if (pattern !== null && typeof pattern === \"object\") {\n const keysAndPredicates = Object.entries(pattern).map(([k, p]) => [k, makePredicate(p)]);\n const len = keysAndPredicates.length;\n return u => {\n if (typeof u !== \"object\" || u === null) {\n return false;\n }\n for (let i = 0; i < len; i++) {\n const [key, predicate] = keysAndPredicates[i];\n if (!(key in u) || predicate(u[key]) === false) {\n return false;\n }\n }\n return true;\n };\n }\n return u => u === pattern;\n};\nconst makeOrPredicate = patterns => {\n const predicates = patterns.map(makePredicate);\n const len = predicates.length;\n return u => {\n for (let i = 0; i < len; i++) {\n if (predicates[i](u) === true) {\n return true;\n }\n }\n return false;\n };\n};\nconst makeAndPredicate = patterns => {\n const predicates = patterns.map(makePredicate);\n const len = predicates.length;\n return u => {\n for (let i = 0; i < len; i++) {\n if (predicates[i](u) === false) {\n return false;\n }\n }\n return true;\n };\n};\n/** @internal */\nexport const type = () => makeTypeMatcher([]);\n/** @internal */\nexport const value = i => makeValueMatcher(i, Result.fail(i));\n/** @internal */\nexport const valueTags = /*#__PURE__*/dual(2, (input, fields) => {\n const match = tagsExhaustive(fields)(makeTypeMatcher([]));\n return match(input);\n});\n/** @internal */\nexport const typeTags = () => fields => {\n const match = tagsExhaustive(fields)(makeTypeMatcher([]));\n return input => match(input);\n};\n/** @internal */\nexport const withReturnType = () => self => self;\n/** @internal */\nexport const when = (pattern, f) => self => self.add(makeWhen(makePredicate(pattern), f));\n/** @internal */\nexport const whenOr = (...args) => self => {\n const onMatch = args[args.length - 1];\n const patterns = args.slice(0, -1);\n return self.add(makeWhen(makeOrPredicate(patterns), onMatch));\n};\n/** @internal */\nexport const whenAnd = (...args) => self => {\n const onMatch = args[args.length - 1];\n const patterns = args.slice(0, -1);\n return self.add(makeWhen(makeAndPredicate(patterns), onMatch));\n};\n/** @internal */\nexport const discriminator = field => (...pattern) => {\n const f = pattern[pattern.length - 1];\n const values = pattern.slice(0, -1);\n const pred = values.length === 1 ? _ => _ != null && _[field] === values[0] : _ => _ != null && values.includes(_[field]);\n return self => self.add(makeWhen(pred, f));\n};\n/** @internal */\nexport const discriminatorStartsWith = field => (pattern, f) => {\n const pred = _ => _ != null && typeof _[field] === \"string\" && _[field].startsWith(pattern);\n return self => self.add(makeWhen(pred, f));\n};\n/** @internal */\nexport const discriminators = field => fields => {\n const predicate = makeWhen(arg => arg != null && arg[field] in fields, data => fields[data[field]](data));\n return self => self.add(predicate);\n};\n/** @internal */\nexport const discriminatorsExhaustive = field => fields => {\n const addCases = discriminators(field)(fields);\n return matcher => exhaustive(addCases(matcher));\n};\n/** @internal */\nexport const tag = /*#__PURE__*/discriminator(\"_tag\");\n/** @internal */\nexport const tagStartsWith = /*#__PURE__*/discriminatorStartsWith(\"_tag\");\n/** @internal */\nexport const tags = /*#__PURE__*/discriminators(\"_tag\");\n/** @internal */\nexport const tagsExhaustive = /*#__PURE__*/discriminatorsExhaustive(\"_tag\");\n/** @internal */\nexport const not = (pattern, f) => self => self.add(makeNot(makePredicate(pattern), f));\n/** @internal */\nexport const nonEmptyString = u => typeof u === \"string\" && u.length > 0;\n/** @internal */\nexport const is = (...literals) => {\n const len = literals.length;\n return u => {\n for (let i = 0; i < len; i++) {\n if (u === literals[i]) {\n return true;\n }\n }\n return false;\n };\n};\n/** @internal */\nexport const any = () => true;\n/** @internal */\nexport const defined = u => u !== undefined && u !== null;\n/** @internal */\nexport const instanceOf = constructor => u => u instanceof constructor;\n/** @internal */\nexport const orElse = f => self => {\n const toResult = result(self);\n if (Result.isResult(toResult)) {\n return toResult._tag === \"Success\" ? toResult.success : f(toResult.failure);\n }\n // @ts-expect-error\n return input => {\n const a = toResult(input);\n return Result.isSuccess(a) ? a.success : f(a.failure);\n };\n};\n/** @internal */\nexport const orElseAbsurd = self => orElse(() => {\n throw new Error(\"effect/Match/orElseAbsurd: absurd\");\n})(self);\n/** @internal */\nexport const result = self => {\n if (self._tag === \"ValueMatcher\") {\n return self.value;\n }\n const len = self.cases.length;\n if (len === 1) {\n const _case = self.cases[0];\n return input => {\n if (_case._tag === \"When\" && _case.guard(input) === true) {\n return Result.succeed(_case.evaluate(input));\n } else if (_case._tag === \"Not\" && _case.guard(input) === false) {\n return Result.succeed(_case.evaluate(input));\n }\n return Result.fail(input);\n };\n }\n return input => {\n for (let i = 0; i < len; i++) {\n const _case = self.cases[i];\n if (_case._tag === \"When\" && _case.guard(input) === true) {\n return Result.succeed(_case.evaluate(input));\n } else if (_case._tag === \"Not\" && _case.guard(input) === false) {\n return Result.succeed(_case.evaluate(input));\n }\n }\n return Result.fail(input);\n };\n};\n/** @internal */\nexport const option = self => {\n const toResult = result(self);\n if (Result.isResult(toResult)) {\n return Result.match(toResult, {\n onFailure: () => Option.none(),\n onSuccess: Option.some\n });\n }\n return input => Result.match(toResult(input), {\n onFailure: () => Option.none(),\n onSuccess: Option.some\n });\n};\nconst getExhaustiveAbsurdErrorMessage = \"effect/match/Match/exhaustive: absurd\";\n/** @internal */\nexport const exhaustive = self => {\n const toResult = result(self);\n if (Result.isResult(toResult)) {\n if (Result.isSuccess(toResult)) {\n return toResult.success;\n }\n throw new Error(getExhaustiveAbsurdErrorMessage);\n }\n return u => {\n // @ts-expect-error\n const result = toResult(u);\n if (Result.isSuccess(result)) {\n return result.success;\n }\n throw new Error(getExhaustiveAbsurdErrorMessage);\n };\n};\n//# sourceMappingURL=matcher.js.map","/**\n * Builds pattern matchers for TypeScript values.\n *\n * `Match` lets you add ordered cases and then finish them with a result,\n * fallback, `Option`, or exhaustive check. Use `Match.type` to define a\n * reusable matcher for a type, or `Match.value` to match one value immediately.\n * Cases can match literal values, predicates, object shapes, tags, negated\n * patterns, and common checks such as strings, numbers, records, and class\n * instances.\n *\n * @since 4.0.0\n */\nimport * as internal from \"./internal/matcher.js\";\nimport * as Predicate from \"./Predicate.js\";\nconst TypeId = internal.TypeId;\n/**\n * Creates a matcher for a specific type.\n *\n * **When to use**\n *\n * Use to build a reusable matcher function for values of a known input type.\n *\n * **Details**\n *\n * This function defines a `Matcher` that operates on a given type, allowing you\n * to specify conditions for handling different cases. Once the matcher is\n * created, you can use pattern-matching functions like {@link when} to define\n * how different values should be processed.\n *\n * **Example** (Matching Numbers and Strings)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * // Create a matcher for values that are either strings or numbers\n * //\n * // ┌─── (u: string | number) => string\n * // ▼\n * const match = Match.type<string | number>().pipe(\n * // Match when the value is a number\n * Match.when(Match.number, (n) => `number: ${n}`),\n * // Match when the value is a string\n * Match.when(Match.string, (s) => `string: ${s}`),\n * // Ensure all possible cases are handled\n * Match.exhaustive\n * )\n *\n * console.log(match(0))\n * // Output: \"number: 0\"\n *\n * console.log(match(\"hello\"))\n * // Output: \"string: hello\"\n * ```\n *\n * @see {@link value} for creating a matcher from a specific value.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const type = internal.type;\n/**\n * Creates a matcher from a specific value.\n *\n * **When to use**\n *\n * Use to match one concrete input immediately.\n *\n * **Details**\n *\n * This function allows you to define a `Matcher` directly from a given value,\n * rather than from a type. This is useful when working with known values,\n * enabling structured pattern matching on objects, primitives, or any data\n * structure.\n *\n * Once the matcher is created, you can use pattern-matching functions like\n * {@link when} to define how different cases should be handled.\n *\n * **Example** (Matching an Object by Property)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const input = { name: \"John\", age: 30 }\n *\n * // Create a matcher for the specific object\n * const result = Match.value(input).pipe(\n * // Match when the 'name' property is \"John\"\n * Match.when(\n * { name: \"John\" },\n * (user) => `${user.name} is ${user.age} years old`\n * ),\n * // Provide a fallback if no match is found\n * Match.orElse(() => \"Oh, not John\")\n * )\n *\n * console.log(result)\n * // Output: \"John is 30 years old\"\n * ```\n *\n * @see {@link type} for creating a matcher from a specific type.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const value = internal.value;\n/**\n * Creates a match function for a specific value with discriminated union handling.\n *\n * **Details**\n *\n * This function provides a convenient way to pattern match on discriminated unions\n * by providing an object that maps each `_tag` value to its corresponding handler.\n * It's similar to a switch statement but with better type safety and exhaustiveness checking.\n *\n * **Example** (Matching value tags)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type Status = { readonly _tag: \"Success\"; readonly data: string }\n *\n * const success: Status = { _tag: \"Success\", data: \"Hello\" }\n *\n * // Simple valueTags usage\n * const message = Match.valueTags(success, {\n * Success: (result) => `Success: ${result.data}`\n * })\n *\n * console.log(message) // \"Success: Hello\"\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const valueTags = internal.valueTags;\n/**\n * Creates a type-safe match function for discriminated unions based on `_tag` field.\n *\n * **Details**\n *\n * This function allows you to define exhaustive pattern matching for discriminated unions\n * by providing handlers for each possible `_tag` value. It ensures type safety and\n * can optionally enforce a specific return type across all branches.\n *\n * **Example** (Matching type tags)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type Result =\n * | { readonly _tag: \"Success\"; readonly data: string }\n * | { readonly _tag: \"Error\"; readonly message: string }\n * | { readonly _tag: \"Loading\" }\n *\n * // Create a matcher with specific return type\n * const formatResult = Match.typeTags<Result, string>()({\n * Success: (result) => `Data: ${result.data}`,\n * Error: (result) => `Error: ${result.message}`,\n * Loading: () => \"Loading...\"\n * })\n *\n * console.log(formatResult({ _tag: \"Success\", data: \"Hello World\" }))\n * // Output: \"Data: Hello World\"\n *\n * console.log(formatResult({ _tag: \"Error\", message: \"Network failed\" }))\n * // Output: \"Error: Network failed\"\n *\n * // Create a matcher with inferred return type\n * const processResult = Match.typeTags<Result>()({\n * Success: (result) => ({ type: \"ok\", value: result.data }),\n * Error: (result) => ({ type: \"error\", error: result.message }),\n * Loading: () => ({ type: \"pending\" })\n * })\n *\n * console.log(processResult({ _tag: \"Loading\" }))\n * // Output: { type: \"pending\" }\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const typeTags = internal.typeTags;\n/**\n * Ensures that all branches of a matcher return a specific type.\n *\n * **Details**\n *\n * This function enforces a consistent return type across all pattern-matching\n * branches. By specifying a return type, TypeScript will check that every\n * matching condition produces a value of the expected type.\n *\n * **Important:** This function must be the first step in the matcher pipeline.\n * If used later, TypeScript will not enforce type consistency correctly.\n *\n * **Example** (Validating return type consistency)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const match = Match.type<{ a: number } | { b: string }>().pipe(\n * // Ensure all branches return a string\n * Match.withReturnType<string>(),\n * // ❌ Type error: 'number' is not assignable to type 'string'\n * // @ts-expect-error\n * Match.when({ a: Match.number }, (_) => _.a),\n * // ✅ Correct: returns a string\n * Match.when({ b: Match.string }, (_) => _.b),\n * Match.exhaustive\n * )\n * ```\n *\n * @category utility types\n * @since 4.0.0\n */\nexport const withReturnType = internal.withReturnType;\n/**\n * Defines a condition for matching values.\n *\n * **When to use**\n *\n * Use to add one positive pattern case to a `Match.type` or `Match.value`\n * pipeline when a direct value, predicate, or structured object pattern should\n * run a handler for matching input.\n *\n * **Details**\n *\n * Supports both direct value comparisons and predicate functions. If the\n * pattern matches, the associated function is executed and the matched input is\n * removed from the remaining cases tracked by the matcher.\n *\n * **Example** (Matching with values and predicates)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * // Create a matcher for objects with an \"age\" property\n * const match = Match.type<{ age: number }>().pipe(\n * // Match when age is greater than 18\n * Match.when(\n * { age: (age: number) => age > 18 },\n * (user: { age: number }) => `Age: ${user.age}`\n * ),\n * // Match when age is exactly 18\n * Match.when({ age: 18 }, () => \"You can vote\"),\n * // Fallback case for all other ages\n * Match.orElse((user: { age: number }) => `${user.age} is too young`)\n * )\n *\n * console.log(match({ age: 20 }))\n * // Output: \"Age: 20\"\n *\n * console.log(match({ age: 18 }))\n * // Output: \"You can vote\"\n *\n * console.log(match({ age: 4 }))\n * // Output: \"4 is too young\"\n * ```\n *\n * @see {@link whenOr} for handling any one of several patterns with the same handler\n * @see {@link whenAnd} for requiring all provided patterns to match before running a handler\n * @see {@link not} for handling inputs that do not match a pattern\n * @see {@link orElse} for providing a fallback when no pattern case matches\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const when = internal.when;\n/**\n * Matches one of multiple patterns in a single condition.\n *\n * **Details**\n *\n * This function allows defining a condition where a value matches any of the\n * provided patterns. If a match is found, the associated function is executed.\n * It simplifies cases where multiple patterns share the same handling logic.\n *\n * Unlike {@link when}, which requires separate conditions for each pattern,\n * this function enables combining them into a single statement, making the\n * matcher more concise.\n *\n * **Example** (Matching one of several patterns)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type ErrorType =\n * | { readonly _tag: \"NetworkError\"; readonly message: string }\n * | { readonly _tag: \"TimeoutError\"; readonly duration: number }\n * | { readonly _tag: \"ValidationError\"; readonly field: string }\n *\n * const handleError = Match.type<ErrorType>().pipe(\n * Match.whenOr(\n * { _tag: \"NetworkError\" },\n * { _tag: \"TimeoutError\" },\n * () => \"Retry the request\"\n * ),\n * Match.when({ _tag: \"ValidationError\" }, (_) => `Invalid field: ${_.field}`),\n * Match.exhaustive\n * )\n *\n * console.log(handleError({ _tag: \"NetworkError\", message: \"No connection\" }))\n * // Output: \"Retry the request\"\n *\n * console.log(handleError({ _tag: \"ValidationError\", field: \"email\" }))\n * // Output: \"Invalid field: email\"\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const whenOr = internal.whenOr;\n/**\n * Matches a value that satisfies all provided patterns.\n *\n * **Details**\n *\n * This function allows defining a condition where a value must match all the\n * given patterns simultaneously. If the value satisfies every pattern, the\n * associated function is executed.\n *\n * Unlike {@link when}, which matches a single pattern at a time, this function\n * ensures that multiple conditions are met before executing the callback. It is\n * useful when checking for values that need to fulfill multiple criteria at\n * once.\n *\n * **Example** (Matching all provided patterns)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type User = { readonly age: number; readonly role: \"admin\" | \"user\" }\n *\n * const checkUser = Match.type<User>().pipe(\n * Match.whenAnd(\n * { age: (n) => n >= 18 },\n * { role: \"admin\" },\n * () => \"Admin access granted\"\n * ),\n * Match.orElse(() => \"Access denied\")\n * )\n *\n * console.log(checkUser({ age: 20, role: \"admin\" }))\n * // Output: \"Admin access granted\"\n *\n * console.log(checkUser({ age: 20, role: \"user\" }))\n * // Output: \"Access denied\"\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const whenAnd = internal.whenAnd;\n/**\n * Matches values based on a specified discriminant field.\n *\n * **When to use**\n *\n * Use to match one or more exact values of a discriminator field.\n *\n * **Details**\n *\n * This function is used to define pattern matching on objects that follow a\n * **discriminated union** structure, where a specific field (e.g., `type`,\n * `kind`, `_tag`) determines the variant of the object. It allows matching\n * multiple values of the discriminant and provides a function to handle the\n * matched cases.\n *\n * **Example** (Matching on a discriminator field)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<\n * { type: \"A\"; a: string } | { type: \"B\"; b: number } | {\n * type: \"C\"\n * c: boolean\n * }\n * >(),\n * Match.discriminator(\"type\")(\"A\", \"B\", (_) => `A or B: ${_.type}`),\n * Match.discriminator(\"type\")(\"C\", (_) => `C(${_.c})`),\n * Match.exhaustive\n * )\n * ```\n *\n * @see {@link discriminators} for defining several discriminator handlers at once\n * @see {@link discriminatorStartsWith} for matching string discriminator values by prefix\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const discriminator = internal.discriminator;\n/**\n * Matches values where a specified field starts with a given prefix.\n *\n * **When to use**\n *\n * Use to match string discriminator values by prefix instead of exact value.\n *\n * **Details**\n *\n * Instead of checking for exact matches, this helper matches values that share\n * a common prefix. For example, if the discriminant field contains hierarchical\n * names like `\"A\"`, `\"A.A\"`, and `\"B\"`, a single `\"A\"` rule can match both\n * `\"A\"` and `\"A.A\"`.\n *\n * **Example** (Matching discriminator prefixes)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<{ type: \"A\" } | { type: \"B\" } | { type: \"A.A\" } | {}>(),\n * Match.discriminatorStartsWith(\"type\")(\"A\", (_) => 1 as const),\n * Match.discriminatorStartsWith(\"type\")(\"B\", (_) => 2 as const),\n * Match.orElse((_) => 3 as const)\n * )\n *\n * console.log(match({ type: \"A\" })) // 1\n * console.log(match({ type: \"B\" })) // 2\n * console.log(match({ type: \"A.A\" })) // 1\n * ```\n *\n * @see {@link discriminator} for matching exact discriminator values\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const discriminatorStartsWith = internal.discriminatorStartsWith;\n/**\n * Matches values based on a field that serves as a discriminator, mapping each\n * possible value to a corresponding handler.\n *\n * **When to use**\n *\n * Use to define several discriminator handlers at once without finalizing the\n * matcher.\n *\n * **Details**\n *\n * This function simplifies working with discriminated unions by letting you\n * define a set of handlers for each possible value of a given field. Instead of\n * chaining multiple calls to {@link discriminator}, this function allows\n * defining all possible cases at once using an object where the keys are the\n * possible values of the field, and the values are the corresponding handler\n * functions.\n *\n * **Example** (Mapping discriminator handlers)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<\n * { type: \"A\"; a: string } | { type: \"B\"; b: number } | {\n * type: \"C\"\n * c: boolean\n * }\n * >(),\n * Match.discriminators(\"type\")({\n * A: (a) => a.a,\n * B: (b) => b.b,\n * C: (c) => c.c\n * }),\n * Match.exhaustive\n * )\n * ```\n *\n * @see {@link discriminator} for adding one discriminator case to a matcher pipeline\n * @see {@link discriminatorsExhaustive} for handling every discriminator value and finalizing the matcher\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const discriminators = internal.discriminators;\n/**\n * Matches values by a discriminator field and requires every possible case to\n * be handled.\n *\n * **When to use**\n *\n * Use to define an exhaustive discriminator handler map that finalizes the\n * matcher.\n *\n * **Details**\n *\n * This is the exhaustive variant of {@link discriminators}. Each possible\n * discriminator value must have a corresponding handler, so the matcher is\n * finalized directly and does not require `Match.exhaustive` at the end of the\n * pipeline.\n *\n * **Example** (Handling all discriminator cases)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<\n * { type: \"A\"; a: string } | { type: \"B\"; b: number } | {\n * type: \"C\"\n * c: boolean\n * }\n * >(),\n * Match.discriminatorsExhaustive(\"type\")({\n * A: (a) => a.a,\n * B: (b) => b.b,\n * C: (c) => c.c\n * })\n * )\n * ```\n *\n * @see {@link discriminators} for defining discriminator handlers without finalizing the matcher\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const discriminatorsExhaustive = internal.discriminatorsExhaustive;\n/**\n * Matches discriminated union members by their `_tag` field.\n *\n * **When to use**\n *\n * Use to handle one or more `_tag` cases with the same matcher branch.\n *\n * **Details**\n *\n * This helper follows the Effect convention that discriminated unions use\n * `\"_tag\"` as their discriminator field. Use {@link discriminator} for a\n * different discriminator field.\n *\n * **Example** (Matching a discriminated union by tag)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type Event =\n * | { readonly _tag: \"fetch\" }\n * | { readonly _tag: \"success\"; readonly data: string }\n * | { readonly _tag: \"error\"; readonly error: Error }\n * | { readonly _tag: \"cancel\" }\n *\n * const match = Match.type<Event>().pipe(\n * // Match either \"fetch\" or \"success\"\n * Match.tag(\"fetch\", \"success\", () => `Ok!`),\n * // Match \"error\" and extract the error message\n * Match.tag(\"error\", (event) => `Error: ${event.error.message}`),\n * // Match \"cancel\"\n * Match.tag(\"cancel\", () => \"Cancelled\"),\n * Match.exhaustive\n * )\n *\n * console.log(match({ _tag: \"success\", data: \"Hello\" }))\n * // Output: \"Ok!\"\n *\n * console.log(match({ _tag: \"error\", error: new Error(\"Oops!\") }))\n * // Output: \"Error: Oops!\"\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const tag = internal.tag;\n/**\n * Matches values where the `_tag` field starts with a given prefix.\n *\n * **Details**\n *\n * This function allows you to match on values in a **discriminated union**\n * based on whether the `_tag` field starts with a specified prefix. It is\n * useful for handling hierarchical or namespaced tags, where multiple related\n * cases share a common prefix.\n *\n * **Example** (Matching tag prefixes)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<{ _tag: \"A\" } | { _tag: \"B\" } | { _tag: \"A.A\" } | {}>(),\n * Match.tagStartsWith(\"A\", (_) => 1 as const),\n * Match.tagStartsWith(\"B\", (_) => 2 as const),\n * Match.orElse((_) => 3 as const)\n * )\n *\n * console.log(match({ _tag: \"A\" })) // 1\n * console.log(match({ _tag: \"B\" })) // 2\n * console.log(match({ _tag: \"A.A\" })) // 1\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const tagStartsWith = internal.tagStartsWith;\n/**\n * Matches values based on their `_tag` field, mapping each tag to a\n * corresponding handler.\n *\n * **Details**\n *\n * This function provides a way to handle discriminated unions by mapping `_tag`\n * values to specific functions. Each handler receives the matched value and\n * returns a transformed result. If all possible tags are handled, you can\n * enforce exhaustiveness using `Match.exhaustive` to ensure no case is missed.\n *\n * **Example** (Mapping tag handlers)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<\n * { _tag: \"A\"; a: string } | { _tag: \"B\"; b: number } | {\n * _tag: \"C\"\n * c: boolean\n * }\n * >(),\n * Match.tags({\n * A: (a) => a.a,\n * B: (b) => b.b,\n * C: (c) => c.c\n * }),\n * Match.exhaustive\n * )\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const tags = internal.tags;\n/**\n * Matches values based on their `_tag` field and requires handling of all\n * possible cases.\n *\n * **Details**\n *\n * This function is designed for **discriminated unions** where every possible\n * `_tag` value must have a corresponding handler. Unlike {@link tags}, this\n * function ensures **exhaustiveness**, meaning all cases must be explicitly\n * handled. If a `_tag` value is missing from the mapping, TypeScript will\n * report an error.\n *\n * **Example** (Handling all tag cases)\n *\n * ```ts\n * import { Match, pipe } from \"effect\"\n *\n * const match = pipe(\n * Match.type<\n * { _tag: \"A\"; a: string } | { _tag: \"B\"; b: number } | {\n * _tag: \"C\"\n * c: boolean\n * }\n * >(),\n * Match.tagsExhaustive({\n * A: (a) => a.a,\n * B: (b) => b.b,\n * C: (c) => c.c\n * })\n * )\n * ```\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const tagsExhaustive = internal.tagsExhaustive;\n/**\n * Creates a pattern that excludes a specific value while allowing all others.\n *\n * **When to use**\n *\n * Use to add a negative pattern case for inputs that should match when another\n * pattern does not.\n *\n * **Details**\n *\n * Any excluded value bypasses the provided function and continues matching\n * through later cases.\n *\n * **Example** (Ignoring a specific value)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * // Create a matcher for string or number values\n * const match = Match.type<string | number>().pipe(\n * // Match any value except \"hi\", returning \"ok\"\n * Match.not(\"hi\", () => \"ok\"),\n * // Fallback case for when the value is \"hi\"\n * Match.orElse(() => \"fallback\")\n * )\n *\n * console.log(match(\"hello\"))\n * // Output: \"ok\"\n *\n * console.log(match(\"hi\"))\n * // Output: \"fallback\"\n * ```\n *\n * @see {@link when} for adding a positive pattern case\n *\n * @category Defining patterns\n * @since 4.0.0\n */\nexport const not = internal.not;\n/**\n * Matches non-empty strings.\n *\n * **When to use**\n *\n * Use to match strings whose length is greater than zero.\n *\n * **Details**\n *\n * This predicate matches any string that contains at least one character,\n * effectively filtering out empty strings (\"\").\n *\n * **Example** (Matching non-empty strings)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const processInput = Match.type<string>()\n * .pipe(\n * Match.when(Match.nonEmptyString, (str) => `Valid input: ${str}`),\n * Match.orElse(() => \"Input cannot be empty\")\n * )\n *\n * console.log(processInput(\"hello\"))\n * // Output: \"Valid input: hello\"\n *\n * console.log(processInput(\"\"))\n * // Output: \"Input cannot be empty\"\n *\n * console.log(processInput(\" \"))\n * // Output: \"Valid input: \" (whitespace-only strings are considered non-empty)\n * ```\n *\n * @see {@link string} for matching any string\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const nonEmptyString = internal.nonEmptyString;\n/**\n * Matches a specific set of literal values (e.g., `Match.is(\"a\", 42, true)`).\n *\n * **When to use**\n *\n * Use to match one of several literal primitive or null values.\n *\n * **Details**\n *\n * This function creates a predicate that matches any of the provided literal values.\n * It's useful for matching against multiple specific values in a single pattern.\n *\n * **Example** (Matching literal values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const handleStatus = Match.type<string | number>()\n * .pipe(\n * Match.when(Match.is(\"success\", \"ok\", 200), () => \"Operation successful\"),\n * Match.when(Match.is(\"error\", \"failed\", 500), () => \"Operation failed\"),\n * Match.when(Match.is(0, false, null), () => \"Falsy value\"),\n * Match.orElse((value) => `Unknown status: ${value}`)\n * )\n *\n * console.log(handleStatus(\"success\"))\n * // Output: \"Operation successful\"\n *\n * console.log(handleStatus(200))\n * // Output: \"Operation successful\"\n *\n * console.log(handleStatus(\"failed\"))\n * // Output: \"Operation failed\"\n *\n * console.log(handleStatus(0))\n * // Output: \"Falsy value\"\n *\n * console.log(handleStatus(\"pending\"))\n * // Output: \"Unknown status: pending\"\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const is = internal.is;\n/**\n * Matches values of type `string`.\n *\n * **Details**\n *\n * This predicate refines unknown values to strings, allowing pattern matching\n * on string types. It's commonly used in type-based matchers to handle string cases.\n *\n * **Example** (Matching string values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const processValue = Match.type<string | number | boolean>().pipe(\n * Match.when(Match.string, (str) => `String: ${str.toUpperCase()}`),\n * Match.when(Match.number, (num) => `Number: ${num * 2}`),\n * Match.when(Match.boolean, (bool) => `Boolean: ${bool ? \"yes\" : \"no\"}`),\n * Match.exhaustive\n * )\n *\n * console.log(processValue(\"hello\")) // \"String: HELLO\"\n * console.log(processValue(42)) // \"Number: 84\"\n * console.log(processValue(true)) // \"Boolean: yes\"\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const string = Predicate.isString;\n/**\n * Matches values of type `number`.\n *\n * **When to use**\n *\n * Use to match primitive number values, including `NaN` and infinities.\n *\n * **Details**\n *\n * This predicate refines unknown values to numbers, allowing pattern matching\n * on numeric types. It matches all number values including integers, floats,\n * `Infinity`, `-Infinity`, and `NaN`.\n *\n * **Example** (Matching number values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const categorizeNumber = Match.type<unknown>().pipe(\n * Match.when(Match.number, (num) => {\n * if (Number.isNaN(num)) return \"Not a number\"\n * if (!Number.isFinite(num)) return \"Infinite\"\n * if (Number.isInteger(num)) return `Integer: ${num}`\n * return `Float: ${num.toFixed(2)}`\n * }),\n * Match.orElse(() => \"Not a number type\")\n * )\n *\n * console.log(categorizeNumber(42)) // \"Integer: 42\"\n * console.log(categorizeNumber(3.14)) // \"Float: 3.14\"\n * console.log(categorizeNumber(NaN)) // \"Not a number\"\n * console.log(categorizeNumber(\"hello\")) // \"Not a number type\"\n * ```\n *\n * @see {@link bigint} for matching primitive bigint values\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const number = Predicate.isNumber;\n/**\n * Matches any value without restrictions.\n *\n * **When to use**\n *\n * Use to define an explicit catch-all pattern when the handler should receive\n * the unmatched value.\n *\n * **Details**\n *\n * This predicate matches every input, including `undefined`, `null`, objects,\n * primitives, and functions.\n *\n * **Gotchas**\n *\n * `Match.any` should usually be last because cases are checked in order and\n * the first matching case wins.\n *\n * **Example** (Matching any remaining value)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const describeValue = Match.type<unknown>()\n * .pipe(\n * Match.when(Match.string, (str) => `String: ${str}`),\n * Match.when(Match.number, (num) => `Number: ${num}`),\n * Match.when(Match.boolean, (bool) => `Boolean: ${bool}`),\n * Match.when(Match.any, (value) => `Other: ${typeof value}`),\n * Match.exhaustive\n * )\n *\n * console.log(describeValue(\"hello\"))\n * // Output: \"String: hello\"\n *\n * console.log(describeValue(42))\n * // Output: \"Number: 42\"\n *\n * console.log(describeValue([1, 2, 3]))\n * // Output: \"Other: object\"\n *\n * console.log(describeValue(null))\n * // Output: \"Other: object\"\n * ```\n *\n * @see {@link defined} for matching only non-nullish values\n * @see {@link orElse} for providing a fallback after earlier cases\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const any = internal.any;\n/**\n * Matches any defined (non-null and non-undefined) value.\n *\n * **When to use**\n *\n * Use to exclude only `null` and `undefined` from a match branch.\n *\n * **Details**\n *\n * This predicate matches values that are neither `null` nor `undefined`,\n * effectively filtering out nullish values while preserving all other types.\n *\n * **Example** (Matching defined values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const processValue = Match.type<string | number | null | undefined>()\n * .pipe(\n * Match.when(Match.defined, (value) => `Defined value: ${value}`),\n * Match.orElse(() => \"Value is null or undefined\")\n * )\n *\n * console.log(processValue(\"hello\"))\n * // Output: \"Defined value: hello\"\n *\n * console.log(processValue(42))\n * // Output: \"Defined value: 42\"\n *\n * console.log(processValue(0))\n * // Output: \"Defined value: 0\"\n *\n * console.log(processValue(\"\"))\n * // Output: \"Defined value: \"\n *\n * console.log(processValue(null))\n * // Output: \"Value is null or undefined\"\n *\n * console.log(processValue(undefined))\n * // Output: \"Value is null or undefined\"\n * ```\n *\n * @see {@link any} for matching every value without excluding nullish inputs\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const defined = internal.defined;\n/**\n * Matches values of type `boolean`.\n *\n * **When to use**\n *\n * Use to match primitive boolean values.\n *\n * **Details**\n *\n * This predicate refines unknown values to booleans, allowing pattern matching\n * on boolean types. It only matches the primitive boolean values `true` and `false`.\n *\n * **Example** (Matching boolean values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const describeTruthiness = Match.type<unknown>().pipe(\n * Match.when(\n * Match.boolean,\n * (bool) => bool ? \"Definitely true\" : \"Definitely false\"\n * ),\n * Match.when(0, () => \"Falsy number\"),\n * Match.when(\"\", () => \"Empty string\"),\n * Match.when(Match.null, () => \"Null value\"),\n * Match.orElse(() => \"Some other truthy value\")\n * )\n *\n * console.log(describeTruthiness(true)) // \"Definitely true\"\n * console.log(describeTruthiness(false)) // \"Definitely false\"\n * console.log(describeTruthiness(0)) // \"Falsy number\"\n * console.log(describeTruthiness(1)) // \"Some other truthy value\"\n * ```\n *\n * @see {@link is} for matching specific literal boolean values\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const boolean = Predicate.isBoolean;\nconst _undefined = Predicate.isUndefined;\nexport {\n/**\n * Matches the value `undefined`.\n *\n * **When to use**\n *\n * Use when a matcher should handle only inputs with no defined value.\n *\n * **Details**\n *\n * This refinement is backed by `Predicate.isUndefined`, which checks\n * `input === undefined`.\n *\n * @see {@link defined} for matching non-nullish values\n * @see {@link is} for matching literal values\n *\n * @category predicates\n * @since 4.0.0\n */\n_undefined as undefined };\nconst _null = Predicate.isNull;\nexport {\n/**\n * Matches the value `null`.\n *\n * **When to use**\n *\n * Use to handle only the `null` literal in a match branch.\n *\n * **Details**\n *\n * This refinement is backed by `Predicate.isNull`, which checks\n * `input === null`.\n *\n * @see {@link defined} for matching non-nullish values\n * @see {@link is} for matching literal values\n *\n * @category predicates\n * @since 4.0.0\n */\n_null as null };\n/**\n * Matches values of type `bigint`.\n *\n * **When to use**\n *\n * Use to match primitive bigint values.\n *\n * **Details**\n *\n * This predicate refines unknown values to bigints, allowing pattern matching\n * on bigint types. BigInts are used for representing integers with arbitrary precision.\n *\n * **Example** (Matching bigint values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const processLargeNumber = Match.type<unknown>().pipe(\n * Match.when(Match.bigint, (big) => {\n * if (big > 9007199254740991n) {\n * return `Large integer: ${big.toString()}`\n * }\n * return `BigInt: ${big.toString()}`\n * }),\n * Match.when(Match.number, (num) => `Regular number: ${num}`),\n * Match.orElse(() => \"Not a numeric type\")\n * )\n *\n * console.log(processLargeNumber(123n)) // \"BigInt: 123\"\n * console.log(processLargeNumber(9007199254740992n)) // \"Large integer: 9007199254740992\"\n * console.log(processLargeNumber(123)) // \"Regular number: 123\"\n * console.log(processLargeNumber(\"123\")) // \"Not a numeric type\"\n * ```\n *\n * @see {@link number} for matching primitive number values\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const bigint = Predicate.isBigInt;\n/**\n * Matches values of type `symbol`.\n *\n * **Details**\n *\n * This predicate refines unknown values to symbols, allowing pattern matching\n * on symbol types. Symbols are unique identifiers that are often used as\n * object keys or for creating private properties.\n *\n * **Example** (Matching symbol values)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const mySymbol = Symbol(\"my-symbol\")\n * const globalSymbol = Symbol.for(\"global-symbol\")\n *\n * const handleSymbol = Match.type<unknown>().pipe(\n * Match.when(Match.symbol, (sym) => {\n * const description = sym.description\n * if (description) {\n * return `Symbol with description: ${description}`\n * }\n * return \"Symbol without description\"\n * }),\n * Match.orElse(() => \"Not a symbol\")\n * )\n *\n * console.log(handleSymbol(mySymbol)) // \"Symbol with description: my-symbol\"\n * console.log(handleSymbol(Symbol())) // \"Symbol without description\"\n * console.log(handleSymbol(\"string\")) // \"Not a symbol\"\n * ```\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const symbol = Predicate.isSymbol;\n/**\n * Matches values that are instances of `Date`.\n *\n * **When to use**\n *\n * Use to match `Date` instances.\n *\n * **Details**\n *\n * This predicate refines unknown values to Date instances, allowing pattern\n * matching on Date objects. It only matches actual Date instances, not\n * date strings or timestamps.\n *\n * **Example** (Matching Date instances)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const processDateValue = Match.type<unknown>().pipe(\n * Match.when(Match.date, (date) => {\n * if (isNaN(date.getTime())) {\n * return \"Invalid date\"\n * }\n * return `Date: ${date.toISOString().split(\"T\")[0]}`\n * }),\n * Match.when(Match.string, (str) => `Date string: ${str}`),\n * Match.orElse(() => \"Not a date-related value\")\n * )\n *\n * console.log(processDateValue(new Date(\"2024-01-01\"))) // \"Date: 2024-01-01\"\n * console.log(processDateValue(new Date(\"invalid\"))) // \"Invalid date\"\n * console.log(processDateValue(\"2024-01-01\")) // \"Date string: 2024-01-01\"\n * console.log(processDateValue(1704067200000)) // \"Not a date-related value\"\n * ```\n *\n * @see {@link instanceOf} for matching instances of any constructor\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const date = Predicate.isDate;\n/**\n * Matches non-null objects other than arrays.\n *\n * **When to use**\n *\n * Use to match broad non-null, non-array object values.\n *\n * **Details**\n *\n * This predicate uses `Predicate.isObject`: it returns `true` for values whose\n * runtime type is `\"object\"`, are not `null`, and are not arrays. It can match\n * `Date`, `RegExp`, and class instances; use `instanceOf` or a more specific\n * pattern when those cases need to be distinguished.\n *\n * **Example** (Matching record objects)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const analyzeValue = Match.type<unknown>().pipe(\n * Match.when(Match.record, (obj) => {\n * const keys = Object.keys(obj)\n * const valueCount = keys.length\n * return `Object with ${valueCount} properties: [${keys.join(\", \")}]`\n * }),\n * Match.when(\n * Match.instanceOf(Array),\n * (arr) => `Array with ${arr.length} items`\n * ),\n * Match.orElse(() => \"Not an object\")\n * )\n *\n * console.log(analyzeValue({ name: \"Alice\", age: 30 })) // \"Object with 2 properties: [name, age]\"\n * console.log(analyzeValue([1, 2, 3])) // \"Array with 3 items\"\n * console.log(analyzeValue(null)) // \"Not an object\"\n * console.log(analyzeValue(\"hello\")) // \"Not an object\"\n * ```\n *\n * @see {@link instanceOf} for matching a specific constructor\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const record = Predicate.isObject;\n/**\n * Matches instances of a given class.\n *\n * **When to use**\n *\n * Use to match values that are instances of a constructor with type-safe\n * narrowing.\n *\n * **Details**\n *\n * This predicate checks if a value is an instance of the specified constructor,\n * providing type-safe matching for class instances and built-in objects.\n *\n * **Example** (Matching class instances)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * class CustomError extends Error {\n * constructor(message: string, public code: number) {\n * super(message)\n * }\n * }\n *\n * const handleValue = Match.type<unknown>()\n * .pipe(\n * Match.when(\n * Match.instanceOf(CustomError),\n * (err) => `Custom error: ${err.message} (code: ${err.code})`\n * ),\n * Match.when(\n * Match.instanceOf(Error),\n * (err) => `Standard error: ${err.message}`\n * ),\n * Match.when(\n * Match.instanceOf(Array),\n * (arr) => `Array with ${arr.length} items`\n * ),\n * Match.when(\n * Match.instanceOf(Map),\n * (map) => `Map with ${map.size} entries`\n * ),\n * Match.orElse((value) => `Other: ${typeof value}`)\n * )\n *\n * console.log(handleValue(new CustomError(\"Failed\", 404))) // \"Custom error: Failed (code: 404)\"\n * console.log(handleValue(new Error(\"Generic error\"))) // \"Standard error: Generic error\"\n * console.log(handleValue([1, 2, 3])) // \"Array with 3 items\"\n * console.log(handleValue(new Map([[\"count\", 1]]))) // \"Map with 1 entries\"\n * ```\n *\n * @see {@link instanceOfUnsafe} for constructor matching without the same type-safety guarantee\n * @see {@link record} for matching broad non-null, non-array objects\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const instanceOf = internal.instanceOf;\n/**\n * Checks whether a value is an instance of a constructor without type-safe narrowing.\n *\n * **When to use**\n *\n * Use when you need constructor matching to use the unsafe refinement type.\n *\n * **Details**\n *\n * This predicate checks if a value is an instance of the specified constructor\n * but doesn't provide the same type safety guarantees as the regular `instanceOf`.\n * Use this when you need more flexibility but understand the type safety implications.\n *\n * **Example** (Matching class instances unsafely)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * class CustomError extends Error {\n * constructor(message: string, public code: number) {\n * super(message)\n * }\n * }\n *\n * // When you need to match instances but handle type narrowing manually\n * const handleError = Match.type<unknown>().pipe(\n * Match.when(Match.instanceOfUnsafe(CustomError), (err: any) => {\n * // Manual type assertion needed\n * const customErr = err as CustomError\n * return `Custom error ${customErr.code}: ${customErr.message}`\n * }),\n * Match.orElse(() => \"Not a CustomError\")\n * )\n * ```\n *\n * @see {@link instanceOf} for type-safe constructor matching\n *\n * @category predicates\n * @since 4.0.0\n */\nexport const instanceOfUnsafe = internal.instanceOf;\n/**\n * Provides a fallback value when no patterns match.\n *\n * **When to use**\n *\n * Use to finalize a matcher with a fallback for unmatched input.\n *\n * **Details**\n *\n * This function ensures that a matcher always returns a valid result, even if\n * no defined patterns match. It acts as a default case, similar to the\n * `default` clause in a `switch` statement or the final `else` in an `if-else`\n * chain.\n *\n * **Example** (Providing a default value when no patterns match)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * // Create a matcher for string or number values\n * const match = Match.type<string | number>().pipe(\n * // Match when the value is \"a\"\n * Match.when(\"a\", () => \"ok\"),\n * // Fallback when no patterns match\n * Match.orElse(() => \"fallback\")\n * )\n *\n * console.log(match(\"a\"))\n * // Output: \"ok\"\n *\n * console.log(match(\"b\"))\n * // Output: \"fallback\"\n * ```\n *\n * @see {@link option} for finalizing unmatched input as `Option.none`\n * @see {@link result} for returning unmatched input as a `Result` failure\n * @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible\n *\n * @category completion\n * @since 4.0.0\n */\nexport const orElse = internal.orElse;\n// TODO(4.0): Rename to \"orThrow\"? Like Result.getOrThrow\n/**\n * Returns a matcher that throws an error if no pattern matches.\n *\n * **When to use**\n *\n * Use to finalize a matcher when every remaining unmatched case should be\n * impossible.\n *\n * **Details**\n *\n * This function finalizes a matcher by ensuring that if no patterns match, an\n * error is thrown. It is useful when all cases should be covered, and any\n * unexpected input should trigger an error instead of returning a default\n * value.\n *\n * When used, this function removes the need for an explicit fallback case and\n * ensures that an unmatched value is never silently ignored.\n *\n * **Example** (Throwing on unmatched input)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * const strictMatcher = Match.type<\"a\" | \"b\">().pipe(\n * Match.when(\"a\", () => \"Found A\"),\n * Match.when(\"b\", () => \"Found B\"),\n * // Will throw if input is neither \"a\" nor \"b\"\n * Match.orElseAbsurd\n * )\n *\n * console.log(strictMatcher(\"a\")) // \"Found A\"\n * console.log(strictMatcher(\"b\")) // \"Found B\"\n *\n * // This would throw an error at runtime:\n * // strictMatcher(\"c\" as any) // throws\n * ```\n *\n * @see {@link exhaustive} for compile-time exhaustive matcher finalization\n * @see {@link orElse} for providing a fallback for unmatched input\n *\n * @category completion\n * @since 4.0.0\n */\nexport const orElseAbsurd = internal.orElseAbsurd;\n/**\n * Wraps the match result in a `Result`, distinguishing matched and unmatched\n * cases.\n *\n * **Details**\n *\n * This function ensures that the result of a matcher is always wrapped in an\n * `Result`, allowing clear differentiation between successful matches\n * (`Ok(value)`) and cases where no pattern matched (`Err(unmatched\n * value)`).\n *\n * This approach is particularly useful when handling optional values or when an\n * unmatched case should be explicitly handled rather than returning a default\n * value or throwing an error.\n *\n * **Example** (Extracting a user role with `Match.result`)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type User = { readonly role: \"admin\" | \"editor\" | \"viewer\" }\n *\n * // Create a matcher to extract user roles\n * const getRole = Match.type<User>().pipe(\n * Match.when({ role: \"admin\" }, () => \"Has full access\"),\n * Match.when({ role: \"editor\" }, () => \"Can edit content\"),\n * Match.result // Wrap the result in an Result\n * )\n *\n * console.log(getRole({ role: \"admin\" }))\n * // Output: { _id: 'Result', _tag: 'Ok', ok: 'Has full access' }\n *\n * console.log(getRole({ role: \"viewer\" }))\n * // Output: { _id: 'Result', _tag: 'Err', err: { role: 'viewer' } }\n * ```\n *\n * @category completion\n * @since 4.0.0\n */\nexport const result = internal.result;\n/**\n * Wraps the match result in an `Option`, representing an optional match.\n *\n * **When to use**\n *\n * Use to finalize a matcher when unmatched input is expected and should become\n * `Option.none`.\n *\n * **Details**\n *\n * This function ensures that the result of a matcher is wrapped in an `Option`,\n * making it easy to handle cases where no pattern matches. If a match is found,\n * it returns `Some(value)`, otherwise, it returns `None`.\n *\n * This is useful in cases where a missing match is expected and should be\n * handled explicitly rather than throwing an error or returning a default\n * value.\n *\n * **Example** (Extracting a user role with `Match.option`)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * type User = { readonly role: \"admin\" | \"editor\" | \"viewer\" }\n *\n * // Create a matcher to extract user roles\n * const getRole = Match.type<User>().pipe(\n * Match.when({ role: \"admin\" }, () => \"Has full access\"),\n * Match.when({ role: \"editor\" }, () => \"Can edit content\"),\n * Match.option // Wrap the result in an Option\n * )\n *\n * console.log(getRole({ role: \"admin\" }))\n * // Output: { _id: 'Option', _tag: 'Some', value: 'Has full access' }\n *\n * console.log(getRole({ role: \"viewer\" }))\n * // Output: { _id: 'Option', _tag: 'None' }\n * ```\n *\n * @see {@link result} for preserving unmatched input as a `Result` failure\n * @see {@link orElse} for replacing unmatched input with a fallback value\n *\n * @category completion\n * @since 4.0.0\n */\nexport const option = internal.option;\n/**\n * Completes a matcher that handles every remaining input case.\n *\n * **When to use**\n *\n * Use to require TypeScript to reject incomplete matcher definitions before the\n * matcher is turned into a function.\n *\n * **Details**\n *\n * If any case is still unmatched, the matcher does not type-check as\n * exhaustive.\n *\n * **Example** (Ensuring all cases are covered)\n *\n * ```ts\n * import { Match } from \"effect\"\n *\n * // Create a matcher for string or number values\n * const match = Match.type<string | number>().pipe(\n * // Match when the value is a number\n * Match.when(Match.number, (n) => `number: ${n}`),\n * // Mark the match as exhaustive, ensuring all cases are handled\n * // TypeScript will throw an error if any case is missing\n * // @ts-expect-error Type 'string' is not assignable to type 'never'\n * Match.exhaustive\n * )\n * ```\n *\n * @category completion\n * @since 4.0.0\n */\nexport const exhaustive = internal.exhaustive;\nconst SafeRefinementId = \"~effect/match/Match/SafeRefinement\";\nconst Fail = /*#__PURE__*/Symbol.for(\"effect/Fail\");\n//# sourceMappingURL=Match.js.map","/**\n * Stores unique values in a mutable hash set.\n *\n * `MutableHashSet` updates the same collection in place and supports fast\n * membership checks, insertion, removal, clearing, and iteration. It is built\n * on `MutableHashMap`: each set value is stored as a map key, so uniqueness\n * follows the same hashing and equality rules as the underlying mutable hash\n * map.\n *\n * @since 2.0.0\n */\nimport { format } from \"./Formatter.js\";\nimport * as Dual from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nconst TypeId = \"~effect/collections/MutableHashSet\";\n/**\n * Checks whether the specified value is a `MutableHashSet`, `false` otherwise.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a mutable hash set.\n *\n * **Details**\n *\n * The check looks for the `MutableHashSet` runtime marker.\n *\n * **Gotchas**\n *\n * Native `Set` values do not satisfy this check.\n *\n * @see {@link MutableHashSet} for the mutable hash set interface\n *\n * @category refinements\n * @since 4.0.0\n */\nexport const isMutableHashSet = value => hasProperty(value, TypeId);\nconst MutableHashSetProto = {\n [TypeId]: TypeId,\n [Symbol.iterator]() {\n return Array.from(this.keyMap).map(([_]) => _)[Symbol.iterator]();\n },\n toString() {\n return `MutableHashSet(${format(Array.from(this))})`;\n },\n toJSON() {\n return {\n _id: \"MutableHashSet\",\n values: toJson(Array.from(this))\n };\n },\n [NodeInspectSymbol]() {\n return this.toJSON();\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst fromHashMap = keyMap => {\n const set = Object.create(MutableHashSetProto);\n set.keyMap = keyMap;\n return set;\n};\n/**\n * Creates an empty MutableHashSet.\n *\n * **When to use**\n *\n * Use to create a fresh mutable set before adding values over time.\n *\n * **Details**\n *\n * Each call returns a new empty set backed by an empty `MutableHashMap`.\n *\n * **Example** (Creating an empty set)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.empty<string>()\n *\n * // Add some values\n * MutableHashSet.add(set, \"apple\")\n * MutableHashSet.add(set, \"banana\")\n * MutableHashSet.add(set, \"apple\") // Duplicate, no effect\n *\n * console.log(MutableHashSet.size(set)) // 2\n * console.log(Array.from(set)) // [\"apple\", \"banana\"]\n * ```\n *\n * @see {@link make} for creating a set from explicit values\n * @see {@link fromIterable} for creating a set from an iterable of values\n * @see {@link clear} for emptying an existing mutable set\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const empty = () => fromHashMap(MutableHashMap.empty());\n/**\n * Creates a MutableHashSet from an iterable collection of values.\n * Duplicates are automatically removed.\n *\n * **When to use**\n *\n * Use to build a mutable hash set from any iterable of values.\n *\n * **Example** (Creating a set from an iterable)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const values = [\"apple\", \"banana\", \"apple\", \"cherry\", \"banana\"]\n * const set = MutableHashSet.fromIterable(values)\n *\n * console.log(MutableHashSet.size(set)) // 3\n * console.log(Array.from(set)) // [\"apple\", \"banana\", \"cherry\"]\n *\n * // Works with any iterable\n * const fromSet = MutableHashSet.fromIterable(new Set([1, 2, 3]))\n * console.log(MutableHashSet.size(fromSet)) // 3\n *\n * // From string characters\n * const fromString = MutableHashSet.fromIterable(\"hello\")\n * console.log(Array.from(fromString)) // [\"h\", \"e\", \"l\", \"o\"]\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromIterable = keys => fromHashMap(MutableHashMap.fromIterable(Array.from(keys).map(k => [k, true])));\n/**\n * Creates a MutableHashSet from a variable number of values.\n * Duplicates are automatically removed.\n *\n * **When to use**\n *\n * Use to build a mutable hash set from explicit values.\n *\n * **Example** (Creating a set from values)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.make(\"apple\", \"banana\", \"apple\", \"cherry\")\n *\n * console.log(MutableHashSet.size(set)) // 3\n * console.log(Array.from(set)) // [\"apple\", \"banana\", \"cherry\"]\n *\n * // With numbers\n * const numbers = MutableHashSet.make(1, 2, 3, 2, 1)\n * console.log(MutableHashSet.size(numbers)) // 3\n * console.log(Array.from(numbers)) // [1, 2, 3]\n *\n * // Mixed types\n * const mixed = MutableHashSet.make(\"hello\", 42, true, \"hello\")\n * console.log(MutableHashSet.size(mixed)) // 3\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = (...keys) => fromIterable(keys);\n/**\n * Adds a value to the MutableHashSet, mutating the set in place.\n * If the value already exists, the set remains unchanged.\n *\n * **When to use**\n *\n * Use to insert a value into a mutable set while keeping uniqueness.\n *\n * **Example** (Adding values)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.empty<string>()\n *\n * // Add new values\n * MutableHashSet.add(set, \"apple\")\n * MutableHashSet.add(set, \"banana\")\n *\n * console.log(MutableHashSet.size(set)) // 2\n * console.log(MutableHashSet.has(set, \"apple\")) // true\n *\n * // Add duplicate (no effect)\n * MutableHashSet.add(set, \"apple\")\n * console.log(MutableHashSet.size(set)) // 2\n *\n * // Pipe-able version\n * const addFruit = MutableHashSet.add(\"cherry\")\n * addFruit(set)\n * console.log(MutableHashSet.size(set)) // 3\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const add = /*#__PURE__*/Dual.dual(2, (self, key) => (MutableHashMap.set(self.keyMap, key, true), self));\n/**\n * Checks whether the MutableHashSet contains the specified value.\n *\n * **When to use**\n *\n * Use to test whether a mutable set currently contains a value.\n *\n * **Details**\n *\n * Membership follows the same hashing and equality rules as the underlying\n * `MutableHashMap`.\n *\n * **Example** (Checking for a value)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.make(\"apple\", \"banana\", \"cherry\")\n *\n * console.log(MutableHashSet.has(set, \"apple\")) // true\n * console.log(MutableHashSet.has(set, \"grape\")) // false\n *\n * // Pipe-able version\n * const hasApple = MutableHashSet.has(\"apple\")\n * console.log(hasApple(set)) // true\n *\n * // Check after adding\n * MutableHashSet.add(set, \"grape\")\n * console.log(MutableHashSet.has(set, \"grape\")) // true\n * ```\n *\n * @see {@link add} for adding a value to the set\n * @see {@link remove} for removing a value from the set\n *\n * @category elements\n * @since 2.0.0\n */\nexport const has = /*#__PURE__*/Dual.dual(2, (self, key) => MutableHashMap.has(self.keyMap, key));\n/**\n * Removes the specified value from the MutableHashSet, mutating the set in place.\n * If the value doesn't exist, the set remains unchanged.\n *\n * **When to use**\n *\n * Use to delete a value from a mutable set if it is present.\n *\n * **Example** (Removing a value)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.make(\"apple\", \"banana\", \"cherry\")\n *\n * console.log(MutableHashSet.size(set)) // 3\n *\n * // Remove existing value\n * MutableHashSet.remove(set, \"banana\")\n * console.log(MutableHashSet.size(set)) // 2\n * console.log(MutableHashSet.has(set, \"banana\")) // false\n *\n * // Remove non-existent value (no effect)\n * MutableHashSet.remove(set, \"grape\")\n * console.log(MutableHashSet.size(set)) // 2\n *\n * // Pipe-able version\n * const removeFruit = MutableHashSet.remove(\"apple\")\n * removeFruit(set)\n * console.log(MutableHashSet.size(set)) // 1\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const remove = /*#__PURE__*/Dual.dual(2, (self, key) => (MutableHashMap.remove(self.keyMap, key), self));\n/**\n * Returns the number of unique values in the MutableHashSet.\n *\n * **When to use**\n *\n * Use to read how many unique values are currently stored in the set.\n *\n * **Example** (Checking set size)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.empty<string>()\n * console.log(MutableHashSet.size(set)) // 0\n *\n * MutableHashSet.add(set, \"apple\")\n * MutableHashSet.add(set, \"banana\")\n * MutableHashSet.add(set, \"apple\") // Duplicate\n * console.log(MutableHashSet.size(set)) // 2\n *\n * MutableHashSet.remove(set, \"apple\")\n * console.log(MutableHashSet.size(set)) // 1\n *\n * MutableHashSet.clear(set)\n * console.log(MutableHashSet.size(set)) // 0\n * ```\n *\n * @category elements\n * @since 2.0.0\n */\nexport const size = self => MutableHashMap.size(self.keyMap);\n/**\n * Removes all values from the MutableHashSet, mutating the set in place.\n * The set becomes empty after this operation.\n *\n * **When to use**\n *\n * Use to empty a mutable set while keeping the same set instance.\n *\n * **Example** (Clearing all values)\n *\n * ```ts\n * import { MutableHashSet } from \"effect\"\n *\n * const set = MutableHashSet.make(\"apple\", \"banana\", \"cherry\")\n *\n * console.log(MutableHashSet.size(set)) // 3\n *\n * // Clear all values\n * MutableHashSet.clear(set)\n *\n * console.log(MutableHashSet.size(set)) // 0\n * console.log(MutableHashSet.has(set, \"apple\")) // false\n * console.log(Array.from(set)) // []\n *\n * // Can still add new values after clearing\n * MutableHashSet.add(set, \"new\")\n * console.log(MutableHashSet.size(set)) // 1\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const clear = self => (MutableHashMap.clear(self.keyMap), self);\n//# sourceMappingURL=MutableHashSet.js.map","import { cast } from \"./Function.js\";\nimport * as Optic from \"./Optic.js\";\nconst TypeId = \"~effect/Newtype\";\n/**\n * Unwraps a newtype value, returning the underlying carrier value.\n *\n * **When to use**\n *\n * Use when you need the carrier value from an existing newtype without\n * constructing a new newtype value at the same call site.\n *\n * **Details**\n *\n * This has zero runtime cost because it is an identity cast.\n *\n * **Example** (Unwrapping a newtype)\n *\n * ```ts\n * import { Newtype } from \"effect\"\n *\n * interface Label extends Newtype.Newtype<\"Label\", string> {}\n *\n * const iso = Newtype.makeIso<Label>()\n * const label = iso.set(\"hello\")\n *\n * const raw: string = Newtype.value(label) // \"hello\"\n * ```\n *\n * @see {@link makeIso} — two-way conversion (wrap and unwrap)\n *\n * @category getters\n * @since 4.0.0\n */\nexport const value = cast;\n/**\n * Creates an `Optic.Iso` for a newtype, providing both wrapping (`set`) and\n * unwrapping (`get`).\n *\n * **When to use**\n *\n * Use as the primary way to construct and deconstruct newtype values.\n *\n * **Details**\n *\n * The returned iso composes with other optics via the standard `Optic` API.\n * Both directions have zero runtime cost because they are identity casts.\n *\n * **Example** (Wrapping and unwrapping with an iso)\n *\n * ```ts\n * import { Newtype } from \"effect\"\n *\n * interface Label extends Newtype.Newtype<\"Label\", string> {}\n *\n * const labelIso = Newtype.makeIso<Label>()\n *\n * const label: Label = labelIso.set(\"world\")\n * const str: string = labelIso.get(label) // \"world\"\n * ```\n *\n * @see {@link value} — unwrap only\n *\n * @category constructors\n * @since 4.0.0\n */\nexport function makeIso() {\n return Optic.makeIso(value, cast);\n}\n/**\n * Lifts an `Equivalence` for the carrier type into an `Equivalence` for the\n * newtype.\n *\n * **When to use**\n *\n * Use when you need equality for newtype-wrapped values to behave like\n * equality for the wrapped carrier value, without manually unwrapping.\n *\n * **Details**\n *\n * The returned equivalence delegates to the provided carrier equivalence and\n * has zero runtime cost beyond the underlying equivalence check.\n *\n * **Example** (Comparing newtypes)\n *\n * ```ts\n * import { Equivalence, Newtype } from \"effect\"\n *\n * interface Label extends Newtype.Newtype<\"Label\", string> {}\n *\n * const eq = Newtype.makeEquivalence<Label>(Equivalence.String)\n * const iso = Newtype.makeIso<Label>()\n *\n * eq(iso.set(\"a\"), iso.set(\"a\")) // true\n * eq(iso.set(\"a\"), iso.set(\"b\")) // false\n * ```\n *\n * @see {@link makeOrder} — lift an `Order` for the carrier\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeEquivalence = cast;\n/**\n * Lifts an `Order` for the carrier type into an `Order` for the newtype.\n *\n * **When to use**\n *\n * Use when you need to sort newtype-wrapped values according to the ordering\n * of the wrapped carrier value, without manually unwrapping.\n *\n * **Details**\n *\n * The returned order delegates to the provided carrier order.\n *\n * **Example** (Ordering newtypes)\n *\n * ```ts\n * import { Newtype, Order } from \"effect\"\n *\n * interface Score extends Newtype.Newtype<\"Score\", number> {}\n *\n * const ord = Newtype.makeOrder<Score>(Order.Number)\n * const iso = Newtype.makeIso<Score>()\n *\n * ord(iso.set(1), iso.set(2)) // -1\n * ```\n *\n * @see {@link makeEquivalence} — lift an `Equivalence` for the carrier\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeOrder = cast;\n/**\n * Lifts a `Combiner` for the carrier type into a `Combiner` for the newtype.\n *\n * **When to use**\n *\n * Use when you need to combine newtype-wrapped values with the carrier's\n * combining logic, without manually unwrapping.\n *\n * **Details**\n *\n * The returned combiner delegates to the provided carrier combiner.\n *\n * **Example** (Combining newtypes)\n *\n * ```ts\n * import { Combiner, Newtype } from \"effect\"\n *\n * interface Amount extends Newtype.Newtype<\"Amount\", number> {}\n *\n * const sum = Combiner.make<number>((a, b) => a + b)\n * const combiner = Newtype.makeCombiner<Amount>(sum)\n * const iso = Newtype.makeIso<Amount>()\n *\n * const total = combiner.combine(iso.set(10), iso.set(20))\n * Newtype.value(total) // 30\n * ```\n *\n * @see {@link makeReducer} — lift a `Reducer` for the carrier\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeCombiner = cast;\n/**\n * Lifts a `Reducer` for the carrier type into a `Reducer` for the newtype.\n *\n * **When to use**\n *\n * Use when you need to reduce a collection of newtype-wrapped values with the\n * carrier's reducer, without manually unwrapping.\n *\n * **Details**\n *\n * The returned reducer delegates to the provided carrier reducer.\n *\n * **Example** (Reducing newtypes)\n *\n * ```ts\n * import { Newtype, Reducer } from \"effect\"\n *\n * interface Score extends Newtype.Newtype<\"Score\", number> {}\n *\n * const sum = Reducer.make<number>((a, b) => a + b, 0)\n * const reducer = Newtype.makeReducer<Score>(sum)\n * const iso = Newtype.makeIso<Score>()\n *\n * const total = reducer.combineAll([iso.set(1), iso.set(2), iso.set(3)])\n * Newtype.value(total) // 6\n * ```\n *\n * @see {@link makeCombiner} — lift a `Combiner` for the carrier\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeReducer = cast;\n//# sourceMappingURL=Newtype.js.map","/**\n * The `NonEmptyIterable` module provides a type-level representation of any\n * JavaScript `Iterable` that is known to contain at least one element. A\n * `NonEmptyIterable<A>` can be consumed anywhere an `Iterable<A>` is expected,\n * while also carrying the guarantee that reading the first element is safe.\n *\n * @since 2.0.0\n */\n/**\n * Extracts the first element and remaining elements from a non-empty iterable safely.\n *\n * **When to use**\n *\n * Use to split a non-empty iterable into its first element and an iterator for\n * the remaining elements.\n *\n * **Details**\n *\n * This function provides a safe way to deconstruct a `NonEmptyIterable` into its\n * head (first element) and tail (remaining elements as an iterator). Since the\n * iterable is guaranteed to be non-empty, the first element is always available.\n *\n * **Example** (Extracting first and remaining elements)\n *\n * ```ts\n * import { Array, Chunk, NonEmptyIterable } from \"effect\"\n *\n * // Helper to make iterator iterable for Array.from\n * const iteratorToIterable = <T>(iterator: Iterator<T>): Iterable<T> => ({\n * [Symbol.iterator]() {\n * return iterator\n * }\n * })\n *\n * // With NonEmptyArray from Array.make (cast to NonEmptyIterable)\n * const numbers = Array.make(\n * 1,\n * 2,\n * 3,\n * 4,\n * 5\n * ) as unknown as NonEmptyIterable.NonEmptyIterable<number>\n * const [first, rest] = NonEmptyIterable.unprepend(numbers)\n * console.log(first) // 1\n * console.log(globalThis.Array.from(iteratorToIterable(rest))) // [2, 3, 4, 5]\n *\n * // With strings (assert when known to be non-empty)\n * const text = \"hello\" as unknown as NonEmptyIterable.NonEmptyIterable<string>\n * const [firstChar, restChars] = NonEmptyIterable.unprepend(text)\n * console.log(firstChar) // \"h\"\n * console.log(globalThis.Array.from(iteratorToIterable(restChars)).join(\"\")) // \"ello\"\n *\n * // With Sets (assert when known to be non-empty)\n * const uniqueNumbers = new Set([\n * 10,\n * 20,\n * 30\n * ]) as unknown as NonEmptyIterable.NonEmptyIterable<number>\n * const [firstUnique, restUnique] = NonEmptyIterable.unprepend(uniqueNumbers)\n * console.log(firstUnique) // 10 (or any element, Set order is not guaranteed)\n * console.log(globalThis.Array.from(iteratorToIterable(restUnique))) // [20, 30] (in some order)\n *\n * // With Maps (assert when known to be non-empty)\n * const keyValuePairs = new Map([[\"a\", 1], [\"b\", 2], [\n * \"c\",\n * 3\n * ]]) as unknown as NonEmptyIterable.NonEmptyIterable<[string, number]>\n * const [firstPair, restPairs] = NonEmptyIterable.unprepend(keyValuePairs)\n * console.log(firstPair) // [\"a\", 1]\n * console.log(globalThis.Array.from(iteratorToIterable(restPairs))) // [[\"b\", 2], [\"c\", 3]]\n *\n * // With custom generators\n * function* fibonacci(): Generator<number> {\n * let a = 1, b = 1\n * yield a\n * for (let i = 0; i < 10; i++) {\n * yield b\n * const next = a + b\n * a = b\n * b = next\n * }\n * }\n *\n * const generator = Chunk.fromIterable(\n * fibonacci()\n * ) as unknown as NonEmptyIterable.NonEmptyIterable<number>\n * const [firstFib, restFib] = NonEmptyIterable.unprepend(generator)\n * console.log(firstFib) // 1\n * console.log(globalThis.Array.from(iteratorToIterable(restFib))) // [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n *\n * // Practical usage: implementing reduce for non-empty iterables\n * function reduceNonEmpty<A, B>(\n * data: NonEmptyIterable.NonEmptyIterable<A>,\n * f: (acc: B, current: A) => B,\n * initial: B\n * ): B {\n * const [first, rest] = NonEmptyIterable.unprepend(data)\n * let result = f(initial, first)\n *\n * // Convert iterator to iterable for iteration\n * const iterable = {\n * [Symbol.iterator]() {\n * return rest\n * }\n * }\n * for (const item of iterable) {\n * result = f(result, item)\n * }\n *\n * return result\n * }\n *\n * const data = Array.make(\n * 1,\n * 2,\n * 3,\n * 4\n * ) as unknown as NonEmptyIterable.NonEmptyIterable<number>\n * const sum = reduceNonEmpty(data, (acc, x) => acc + x, 0) // 10\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const unprepend = self => {\n const iterator = self[Symbol.iterator]();\n const next = iterator.next();\n if (next.done) {\n throw new Error(\"BUG: NonEmptyIterator should not be empty - please report an issue at https://github.com/Effect-TS/effect/issues\");\n }\n return [next.value, iterator];\n};\n//# sourceMappingURL=NonEmptyIterable.js.map","import { dual } from \"./Function.js\";\nimport * as Reducer_ from \"./Reducer.js\";\n/**\n * Reverses the ordering of the input Ordering.\n * This is useful for creating descending sort orders from ascending ones.\n *\n * **When to use**\n *\n * Use to flip an ordering result when reversing sort direction or comparison\n * priority.\n *\n * **Example** (Reversing comparison order)\n *\n * ```ts\n * import { Ordering } from \"effect\"\n *\n * // Basic reversal\n * console.log(Ordering.reverse(1)) // -1 (greater becomes less)\n * console.log(Ordering.reverse(-1)) // 1 (less becomes greater)\n * console.log(Ordering.reverse(0)) // 0 (equal stays equal)\n *\n * // Creating descending sort from ascending comparison\n * const compareNumbers = (a: number, b: number): Ordering.Ordering =>\n * a < b ? -1 : a > b ? 1 : 0\n *\n * const compareDescending = (a: number, b: number): Ordering.Ordering =>\n * Ordering.reverse(compareNumbers(a, b))\n *\n * const numbers = [3, 1, 4, 1, 5]\n * numbers.sort(compareNumbers) // [1, 1, 3, 4, 5] (ascending)\n * numbers.sort(compareDescending) // [5, 4, 3, 1, 1] (descending)\n *\n * // Useful for toggling sort direction\n * const createSorter = (ascending: boolean) => (a: number, b: number) => {\n * const ordering = compareNumbers(a, b)\n * return ascending ? ordering : Ordering.reverse(ordering)\n * }\n * ```\n *\n * @category transforming\n * @since 2.0.0\n */\nexport const reverse = o => o === -1 ? 1 : o === 1 ? -1 : 0;\n/**\n * Matches an `Ordering` value and returns the branch selected by that ordering.\n *\n * **When to use**\n *\n * Use to branch on the three possible comparison outcomes in one expression.\n *\n * **Example** (Pattern matching on orderings)\n *\n * ```ts\n * import { Function, Ordering } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const toMessage = Ordering.match({\n * onLessThan: Function.constant(\"less than\"),\n * onEqual: Function.constant(\"equal\"),\n * onGreaterThan: Function.constant(\"greater than\")\n * })\n *\n * assert.deepStrictEqual(toMessage(-1), \"less than\")\n * assert.deepStrictEqual(toMessage(0), \"equal\")\n * assert.deepStrictEqual(toMessage(1), \"greater than\")\n * ```\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const match = /*#__PURE__*/dual(2, (self, {\n onEqual,\n onGreaterThan,\n onLessThan\n}) => self === -1 ? onLessThan() : self === 0 ? onEqual() : onGreaterThan());\n/**\n * Reducer for combining `Ordering`s.\n *\n * **When to use**\n *\n * Use to combine multiple comparison results in priority order, such as\n * checking secondary criteria only when earlier criteria compare as equal.\n *\n * **Details**\n *\n * If any of the `Ordering`s is non-zero, the result is the first non-zero `Ordering`.\n * If all the `Ordering`s are zero, the result is zero.\n *\n * **Gotchas**\n *\n * `combineAll` stops consuming the iterable as soon as it finds a non-zero\n * `Ordering`.\n *\n * @category ordering\n * @since 4.0.0\n */\nexport const Reducer = /*#__PURE__*/Reducer_.make((self, that) => self !== 0 ? self : that, 0, collection => {\n let ordering = 0;\n for (ordering of collection) {\n if (ordering !== 0) {\n return ordering;\n }\n }\n return ordering;\n});\n//# sourceMappingURL=Ordering.js.map","/**\n * The `PartitionedSemaphore` module provides a semaphore for limiting\n * concurrency across a shared permit pool while keeping waiters grouped by\n * partition key. A `PartitionedSemaphore<K>` is useful when many independent\n * groups of work compete for the same bounded resource and each group should\n * make progress without one busy group monopolizing released permits.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport * as Option from \"./Option.js\";\n/**\n * Runtime type identifier used to mark values that implement\n * `PartitionedSemaphore`.\n *\n * **Details**\n *\n * This marker is part of the runtime representation of partitioned semaphore\n * values.\n *\n * @category type IDs\n * @since 4.0.0\n */\nexport const PartitionedTypeId = \"~effect/PartitionedSemaphore\";\n/**\n * Constructs a `PartitionedSemaphore` synchronously, outside of `Effect`.\n *\n * **When to use**\n *\n * Use when you need to construct a partitioned semaphore synchronously outside\n * an `Effect` workflow.\n *\n * **Details**\n *\n * Negative permit counts are clamped to `0`. Non-finite permit counts create\n * an unbounded semaphore whose acquire and release operations complete\n * immediately.\n *\n * @see {@link make} for creating a partitioned semaphore inside `Effect`\n *\n * @category constructors\n * @since 3.19.4\n */\nexport const makeUnsafe = options => {\n const maxPermits = Math.max(0, options.permits);\n if (!Number.isFinite(maxPermits)) {\n return {\n [PartitionedTypeId]: PartitionedTypeId,\n capacity: maxPermits,\n available: Effect.succeed(maxPermits),\n take: () => Effect.void,\n release: () => Effect.succeed(maxPermits),\n withPermits: () => effect => effect,\n withPermit: () => effect => effect,\n withPermitsIfAvailable: () => effect => Effect.asSome(effect)\n };\n }\n let totalPermits = maxPermits;\n let waitingPermits = 0;\n const partitions = MutableHashMap.empty();\n let iterator = partitions[Symbol.iterator]();\n const releaseUnsafe = permits => {\n while (permits > 0) {\n if (waitingPermits === 0) {\n totalPermits = Math.min(maxPermits, totalPermits + permits);\n return totalPermits;\n }\n let state = iterator.next();\n if (state.done) {\n iterator = partitions[Symbol.iterator]();\n state = iterator.next();\n if (state.done) {\n return totalPermits;\n }\n }\n const waiter = state.value[1].values().next().value;\n if (waiter === undefined) {\n continue;\n }\n waiter.permits -= 1;\n waitingPermits -= 1;\n if (waiter.permits === 0) {\n waiter.resume();\n }\n permits -= 1;\n }\n return totalPermits;\n };\n const take = (key, permits) => {\n if (permits <= 0) {\n return Effect.void;\n }\n return Effect.callback(resume => {\n if (maxPermits < permits) {\n resume(Effect.never);\n return;\n }\n if (totalPermits >= permits) {\n totalPermits -= permits;\n resume(Effect.void);\n return;\n }\n const needed = permits - totalPermits;\n const taken = permits - needed;\n if (totalPermits > 0) {\n totalPermits = 0;\n }\n waitingPermits += needed;\n const waiters = Option.getOrElse(MutableHashMap.get(partitions, key), () => {\n const set = new Set();\n MutableHashMap.set(partitions, key, set);\n return set;\n });\n const entry = {\n permits: needed,\n resume: () => {\n cleanup();\n resume(Effect.void);\n }\n };\n const cleanup = () => {\n waiters.delete(entry);\n if (waiters.size === 0) {\n MutableHashMap.remove(partitions, key);\n }\n };\n waiters.add(entry);\n return Effect.sync(() => {\n cleanup();\n waitingPermits -= entry.permits;\n if (taken > 0) {\n releaseUnsafe(taken);\n }\n });\n });\n };\n const withPermits = (key, permits) => effect => {\n if (permits <= 0) {\n return effect;\n }\n const takePermits = take(key, permits);\n return Effect.uninterruptibleMask(restore => Effect.flatMap(restore(takePermits), () => Effect.ensuring(restore(effect), Effect.sync(() => {\n releaseUnsafe(permits);\n }))));\n };\n const tryTake = permits => {\n if (permits <= 0) {\n return true;\n }\n if (maxPermits < permits || totalPermits < permits) {\n return false;\n }\n totalPermits -= permits;\n return true;\n };\n return {\n [PartitionedTypeId]: PartitionedTypeId,\n capacity: maxPermits,\n available: Effect.sync(() => totalPermits),\n take,\n release: permits => Effect.sync(() => releaseUnsafe(permits)),\n withPermits,\n withPermit: key => withPermits(key, 1),\n withPermitsIfAvailable: permits => effect => {\n if (permits <= 0) {\n return Effect.asSome(effect);\n }\n return Effect.suspend(() => {\n if (!tryTake(permits)) {\n return Effect.succeed(Option.none());\n }\n return Effect.ensuring(Effect.asSome(effect), Effect.sync(() => {\n releaseUnsafe(permits);\n }));\n });\n }\n };\n};\n/**\n * Creates a `PartitionedSemaphore` inside an `Effect`.\n *\n * **When to use**\n *\n * Use when semaphore construction should stay inside an `Effect` workflow.\n *\n * **Details**\n *\n * The `permits` option sets the shared permit capacity. The resulting\n * semaphore tracks waiters by partition key and distributes released permits\n * across waiting partitions in round-robin order.\n *\n * **Gotchas**\n *\n * Negative permit counts are clamped to `0`. Non-finite permit counts create\n * an unbounded semaphore.\n *\n * @see {@link makeUnsafe} for synchronous construction\n *\n * @category constructors\n * @since 3.19.4\n */\nexport const make = options => Effect.sync(() => makeUnsafe(options));\n/**\n * Gets the current number of available permits.\n *\n * **When to use**\n *\n * Use to inspect a snapshot of how many permits are currently free.\n *\n * **Details**\n *\n * Running the returned effect reads the semaphore's current availability.\n * Taking permits decreases availability, and releasing permits can increase it\n * up to the semaphore capacity.\n *\n * **Gotchas**\n *\n * Reading availability does not reserve permits.\n *\n * @see {@link capacity} for the fixed total permit capacity\n * @see {@link release} for returning permits to the shared pool\n * @see {@link withPermitsIfAvailable} for running only when permits are immediately available\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const available = self => self.available;\n/**\n * Gets the total capacity.\n *\n * **When to use**\n *\n * Use to inspect the fixed number of permits configured for the semaphore.\n *\n * **Details**\n *\n * Capacity is stored when the semaphore is created and does not change as\n * permits are acquired or released.\n *\n * @see {@link available} for the current number of free permits\n *\n * @category getters\n * @since 4.0.0\n */\nexport const capacity = self => self.capacity;\n/**\n * Returns an effect that acquires the requested number of permits for the\n * given partition key.\n *\n * **When to use**\n *\n * Use when you need manual permit acquisition for a partition and want to\n * control acquisition and release as separate effects.\n *\n * **Details**\n *\n * If enough permits are available, the effect completes immediately. Otherwise\n * it waits until released permits are assigned to this partition.\n *\n * **Gotchas**\n *\n * Requests for more permits than the semaphore capacity never complete.\n * Requests for zero or a negative number of permits complete without acquiring\n * anything.\n *\n * @see {@link release} for manually returning permits to the shared pool\n * @see {@link withPermits} for automatic acquire and release around an effect\n * @see {@link withPermit} for acquiring exactly one permit around an effect\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const take = /*#__PURE__*/dual(3, (self, key, permits) => self.take(key, permits));\n/**\n * Returns an effect that releases permits back to the shared pool and returns\n * the current available permit count.\n *\n * **When to use**\n *\n * Use when you need to return permits acquired with `take` in a lower-level\n * partitioned permit protocol with explicit release control.\n *\n * **Details**\n *\n * Released permits are first assigned to waiting partitions in round-robin\n * order. Only permits not needed by waiters increase the available count,\n * which is capped at the semaphore capacity.\n *\n * @see {@link take} for manual acquisition\n * @see {@link withPermits} for automatic acquire and release around an effect\n * @see {@link available} for reading the permit count without releasing\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const release = /*#__PURE__*/dual(2, (self, permits) => self.release(permits));\n/**\n * Runs an effect after acquiring permits for a partition, then releases those\n * permits when the effect exits.\n *\n * **When to use**\n *\n * Use to guard weighted partitioned work with automatic permit acquisition and\n * release around an effect.\n *\n * **Details**\n *\n * Permit acquisition may wait according to `take` semantics. Once acquired,\n * the permits are released even if the wrapped effect fails or is interrupted.\n *\n * **Gotchas**\n *\n * Requests for more permits than the semaphore capacity never complete.\n * Requests for zero or a negative number of permits run the effect without\n * acquiring anything.\n *\n * @see {@link withPermit} for the single-permit variant\n * @see {@link withPermitsIfAvailable} for running only when permits are\n * immediately available\n * @see {@link take} for manual acquisition\n * @see {@link release} for manual release\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const withPermits = (...args) => {\n if (args.length === 3) {\n const [self, key, permits] = args;\n return effect => self.withPermits(key, permits)(effect);\n }\n const [self, key, permits, effect] = args;\n return self.withPermits(key, permits)(effect);\n};\n/**\n * Runs an effect after acquiring one permit for a partition, then releases the\n * permit when the effect exits.\n *\n * **When to use**\n *\n * Use to guard partitioned work with exactly one permit and automatic release\n * when the effect exits.\n *\n * **Details**\n *\n * This is the single-permit variant of `withPermits`. The permit is released\n * even if the wrapped effect fails or is interrupted.\n *\n * @see {@link withPermits} for acquiring a weighted number of permits\n * @see {@link withPermitsIfAvailable} for running only when permits are\n * immediately available\n * @see {@link take} for manual acquisition\n * @see {@link release} for manual release\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const withPermit = (...args) => {\n if (args.length === 2) {\n const [self, key] = args;\n return effect => self.withPermit(key)(effect);\n }\n const [self, key, effect] = args;\n return self.withPermit(key)(effect);\n};\n/**\n * Runs an effect only when the requested permits can be acquired immediately,\n * returning the result in `Some`.\n *\n * **When to use**\n *\n * Use when guarded work should run only if the shared permit pool can provide\n * the requested permits immediately.\n *\n * **Details**\n *\n * If the permits are not available, the effect is not run and the result is\n * `None`. When permits are acquired, they are released after the wrapped\n * effect completes, fails, or is interrupted. Requests for zero or a negative\n * number of permits run the effect and return `Some`.\n *\n * @see {@link withPermits} for the keyed variant that waits until permits are\n * available for a partition\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const withPermitsIfAvailable = (...args) => {\n if (args.length === 2) {\n const [self, permits] = args;\n return effect => self.withPermitsIfAvailable(permits)(effect);\n }\n const [self, permits, effect] = args;\n return self.withPermitsIfAvailable(permits)(effect);\n};\n//# sourceMappingURL=PartitionedSemaphore.js.map","import { Clock } from \"./Clock.js\";\nimport * as Context from \"./Context.js\";\nimport * as Duration from \"./Duration.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport { dual, identity } from \"./Function.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport * as Latch from \"./Latch.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Queue from \"./Queue.js\";\nimport { UnhandledLogLevel } from \"./References.js\";\nimport * as Scope from \"./Scope.js\";\nimport * as Semaphore from \"./Semaphore.js\";\nconst TypeId = \"~effect/Pool\";\n/**\n * Returns `true` if the specified value is a `Pool`, `false` otherwise.\n *\n * **When to use**\n *\n * Use to validate unknown values at runtime boundaries before treating them as\n * `Pool` values.\n *\n * **Details**\n *\n * This predicate narrows the input to `Pool<unknown, unknown>`.\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isPool = u => hasProperty(u, TypeId);\n/**\n * Makes a new pool of the specified fixed size.\n *\n * **When to use**\n *\n * Use when you need a fixed-size pool with no growth or shrinkage.\n *\n * **Details**\n *\n * The pool is returned in a `Scope`, which governs the lifetime of the pool.\n * When the pool is shutdown because the `Scope` is closed, the individual\n * items allocated by the pool will be released in some unspecified order.\n *\n * By setting the `concurrency` parameter, you can control the level of concurrent\n * access per pool item. By default, the number of permits is set to `1`.\n *\n * `targetUtilization` determines when to create new pool items. It is a value\n * between 0 and 1, where 1 means only create new pool items when all the existing\n * items are fully utilized.\n *\n * A `targetUtilization` of 0.5 will create new pool items when the existing items are\n * 50% utilized.\n *\n * @see {@link makeWithTTL} for pools with min/max sizes and a TTL-based shrinking policy\n * @see {@link makeWithStrategy} for pools with a custom resizing and reclamation strategy\n * @category constructors\n * @since 2.0.0\n */\nexport const make = options => makeWithStrategy({\n ...options,\n min: options.size,\n max: options.size,\n strategy: strategyNoop()\n});\n/**\n * Creates a scoped pool with minimum and maximum sizes and a time-to-live\n * policy for shrinking unused excess items.\n *\n * **When to use**\n *\n * Use to create an elastic scoped pool that can grow up to a maximum size and\n * later reclaim unused excess items.\n *\n * **Details**\n *\n * The returned pool requires `Scope`; when that scope is closed, allocated\n * items are released in an unspecified order. `concurrency` controls how many\n * fibers may use each pool item at once and defaults to `1`.\n *\n * `targetUtilization` controls when new items are created and is clamped by the\n * pool implementation. A value of `1` waits until existing items are fully\n * utilized before creating more items.\n *\n * `timeToLiveStrategy` controls when excess items expire: `\"creation\"` measures\n * from item creation, while `\"usage\"` measures from pool usage. The default is\n * `\"usage\"`.\n *\n * **Example** (Creating a connection pool)\n *\n * ```ts\n * import { Duration, Effect, Pool } from \"effect\"\n *\n * interface Connection {\n * readonly execute: (sql: string) => Effect.Effect<ReadonlyArray<string>>\n * readonly close: Effect.Effect<void>\n * }\n *\n * const acquireDBConnection = Effect.acquireRelease(\n * Effect.succeed({\n * execute: (sql) => Effect.succeed([`executed: ${sql}`]),\n * close: Effect.void\n * } satisfies Connection),\n * (connection) => connection.close\n * )\n *\n * const program = Effect.scoped(\n * Effect.flatMap(\n * Pool.makeWithTTL({\n * acquire: acquireDBConnection,\n * min: 10,\n * max: 20,\n * timeToLive: Duration.seconds(60)\n * }),\n * (pool) => Effect.flatMap(Pool.get(pool), (connection) => connection.execute(\"select 1\"))\n * )\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeWithTTL = options => Effect.flatMap(options.timeToLiveStrategy === \"creation\" ? strategyCreationTTL(options.timeToLive) : strategyUsageTTL(options.timeToLive), strategy => makeWithStrategy({\n ...options,\n strategy\n}));\n/**\n * Creates a scoped pool using a custom resizing and reclamation strategy.\n *\n * **When to use**\n *\n * Use to build a pool whose item lifecycle is controlled by an explicit\n * `Strategy`, such as custom background resizing, replacement, or reclamation.\n *\n * **Details**\n *\n * The returned pool requires `Scope`; closing the scope shuts down the pool and\n * releases allocated items.\n *\n * @see {@link make} for fixed-size pools without custom resizing or reclamation\n * @see {@link makeWithTTL} for min/max pools that shrink excess items with a TTL policy\n * @see {@link Strategy} for the custom strategy contract consumed by this constructor\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeWithStrategy = options => Effect.uninterruptibleMask(Effect.fnUntraced(function* (restore) {\n const services = yield* Effect.context();\n const scope = Context.get(services, Scope.Scope);\n const acquire = Effect.updateContext(options.acquire, input => Context.merge(services, input));\n const concurrency = options.concurrency ?? 1;\n const config = {\n acquire,\n concurrency,\n minSize: options.min,\n maxSize: options.max,\n strategy: options.strategy,\n targetUtilization: Math.min(Math.max(options.targetUtilization ?? 1, 0.1), 1)\n };\n const state = {\n scope,\n isShuttingDown: false,\n semaphore: Semaphore.makeUnsafe(concurrency * options.max),\n resizeSemaphore: Semaphore.makeUnsafe(1),\n items: new Set(),\n available: new Set(),\n availableLatch: Latch.makeUnsafe(false),\n invalidated: new Set(),\n waiters: 0\n };\n const self = {\n [TypeId]: TypeId,\n config,\n state,\n pipe() {\n return pipeArguments(this, arguments);\n }\n };\n yield* Scope.addFinalizer(scope, shutdown(self));\n yield* Effect.tap(Effect.forkDetach(restore(resize(self))), fiber => Scope.addFinalizer(scope, Fiber.interrupt(fiber)));\n yield* Effect.tap(Effect.forkDetach(restore(options.strategy.run(self))), fiber => Scope.addFinalizer(scope, Fiber.interrupt(fiber)));\n return self;\n}));\nconst shutdown = /*#__PURE__*/Effect.fnUntraced(function* (self) {\n if (self.state.isShuttingDown) return;\n self.state.isShuttingDown = true;\n const size = self.state.items.size;\n const semaphore = Semaphore.makeUnsafe(size);\n for (const item of self.state.items) {\n if (item.refCount > 0) {\n item.finalizer = Effect.tap(item.finalizer, semaphore.release(1));\n self.state.invalidated.add(item);\n yield* semaphore.take(1);\n } else {\n self.state.items.delete(item);\n self.state.available.delete(item);\n self.state.invalidated.delete(item);\n yield* item.finalizer;\n }\n }\n yield* semaphore.releaseAll;\n self.state.availableLatch.openUnsafe();\n yield* semaphore.take(size);\n});\n/**\n * Retrieves an item from the pool in a scoped effect.\n *\n * **When to use**\n *\n * Use to borrow a pooled resource for the lifetime of the current scope so it\n * is automatically returned when that scope closes.\n *\n * **Details**\n *\n * The returned effect waits for an available item when the pool is at capacity.\n * If acquiring a new item fails, the effect fails with the acquisition error.\n *\n * **Gotchas**\n *\n * Retrying a failed `get` can repeat the acquisition attempt.\n *\n * @see {@link invalidate} for removing an unhealthy item from future reuse\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.suspend(() => {\n if (self.state.isShuttingDown) {\n return Effect.interrupt;\n }\n return Effect.flatMap(getPoolItem(self), item => item.exit);\n});\nconst getPoolItem = self => Effect.uninterruptibleMask(restore => restore(self.state.semaphore.take(1)).pipe(Effect.flatMap(() => Effect.scope), Effect.flatMap(scope => getPoolItemInner(self).pipe(Effect.ensuring(Effect.sync(() => self.state.waiters--)), Effect.tap(item => {\n if (item.exit._tag === \"Failure\") {\n self.state.items.delete(item);\n self.state.invalidated.delete(item);\n self.state.available.delete(item);\n return self.state.semaphore.release(1);\n }\n item.refCount++;\n self.state.available.delete(item);\n if (item.refCount < self.config.concurrency) {\n self.state.available.add(item);\n }\n return Scope.addFinalizerExit(scope, () => Effect.flatMap(Effect.suspend(() => {\n item.refCount--;\n if (self.state.invalidated.has(item)) {\n return invalidatePoolItem(self, item);\n }\n self.state.available.add(item);\n return Effect.void;\n }), () => self.state.semaphore.release(1)));\n}), Effect.onInterrupt(() => self.state.semaphore.release(1))))));\nconst getPoolItemInner = /*#__PURE__*/Effect.fnUntraced(function* (self) {\n self.state.waiters++;\n if (self.state.isShuttingDown) {\n return yield* Effect.interrupt;\n } else if (targetSize(self) > activeSize(self)) {\n while (true) {\n yield* self.state.resizeSemaphore.withPermitsIfAvailable(1)(Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope));\n if (self.state.isShuttingDown) {\n return yield* Effect.interrupt;\n } else if (self.state.available.size > 0) {\n return Iterable.headUnsafe(self.state.available);\n }\n self.state.availableLatch.closeUnsafe();\n yield* self.state.availableLatch.await;\n }\n }\n return Iterable.headUnsafe(self.state.available);\n});\n/**\n * Invalidates the specified item so the pool can remove it and reallocate the\n * item, lazily if needed.\n *\n * **When to use**\n *\n * Use to prevent a pooled item from being reused after it becomes unsuitable,\n * such as a stale connection or a resource that failed a health check.\n *\n * **Gotchas**\n *\n * The item is matched with strict equality. Passing an equivalent but different\n * object instance does nothing.\n *\n * @see {@link get} for retrieving scoped items from the pool\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const invalidate = /*#__PURE__*/dual(2, (self, item) => Effect.suspend(() => {\n if (self.state.isShuttingDown) return Effect.void;\n for (const poolItem of self.state.items) {\n if (poolItem.exit._tag === \"Success\" && poolItem.exit.value === item) {\n poolItem.disableReclaim = true;\n return Effect.uninterruptible(invalidatePoolItem(self, poolItem));\n }\n }\n return Effect.void;\n}));\nconst invalidatePoolItem = (self, poolItem) => Effect.suspend(() => {\n if (!self.state.items.has(poolItem)) {\n return Effect.void;\n } else if (poolItem.refCount === 0) {\n self.state.items.delete(poolItem);\n self.state.available.delete(poolItem);\n self.state.invalidated.delete(poolItem);\n return Effect.asVoid(Effect.flatMap(poolItem.finalizer, () => Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope)));\n }\n self.state.invalidated.add(poolItem);\n self.state.available.delete(poolItem);\n return Effect.void;\n});\nconst resize = self => self.state.resizeSemaphore.withPermits(1)(resizeLoop(self));\nconst resizeLoop = self => Effect.suspend(() => {\n const active = activeSize(self);\n const target = targetSize(self);\n if (active >= target) {\n return Effect.void;\n }\n const toAcquire = target - active;\n return self.config.strategy.reclaim(self).pipe(Effect.flatMap(item => item ? Effect.succeed(item) : allocate(self)), Effect.replicateEffect(toAcquire, {\n concurrency: toAcquire\n }), Effect.tap(self.state.availableLatch.open), Effect.flatMap(items => items.some(_ => _.exit._tag === \"Failure\") ? Effect.void : resizeLoop(self)));\n});\nconst allocate = self => Effect.acquireUseRelease(Scope.make(), scope => self.config.acquire.pipe(Scope.provide(scope), Effect.exit, Effect.flatMap(exit => {\n const item = {\n exit,\n finalizer: Effect.catchCause(Scope.close(scope, exit), reportUnhandledError),\n refCount: 0,\n disableReclaim: false\n };\n self.state.items.add(item);\n self.state.available.add(item);\n return Effect.as(exit._tag === \"Success\" ? self.config.strategy.onAcquire(item) : Effect.flatMap(item.finalizer, () => self.config.strategy.onAcquire(item)), item);\n})), (scope, exit) => exit._tag === \"Failure\" ? Scope.close(scope, exit) : Effect.void);\nconst currentUsage = self => {\n let count = self.state.waiters;\n for (const item of self.state.items) {\n count += item.refCount;\n }\n return count;\n};\nconst targetSize = self => {\n if (self.state.isShuttingDown) return 0;\n const utilization = currentUsage(self) / self.config.targetUtilization;\n const target = Math.ceil(utilization / self.config.concurrency);\n return Math.min(Math.max(self.config.minSize, target), self.config.maxSize);\n};\nconst activeSize = self => {\n return self.state.items.size - self.state.invalidated.size;\n};\n// -----------------------------------------------------------------------------\n// Strategy\n// -----------------------------------------------------------------------------\nconst strategyNoop = () => ({\n run: _ => Effect.void,\n onAcquire: _ => Effect.void,\n reclaim: _ => Effect.undefined\n});\nconst strategyCreationTTL = /*#__PURE__*/Effect.fnUntraced(function* (ttl) {\n const clock = yield* Clock;\n const queue = yield* Queue.unbounded();\n const ttlMillis = Duration.toMillis(Duration.fromInputUnsafe(ttl));\n const creationTimes = new WeakMap();\n return identity({\n run: pool => {\n const process = item => Effect.suspend(() => {\n if (!pool.state.items.has(item) || pool.state.invalidated.has(item)) {\n return Effect.void;\n }\n const now = clock.currentTimeMillisUnsafe();\n const created = creationTimes.get(item);\n const remaining = ttlMillis - (now - created);\n return remaining > 0 ? Effect.delay(process(item), remaining) : invalidatePoolItem(pool, item);\n });\n return Queue.take(queue).pipe(Effect.tap(process), Effect.forever({\n disableYield: true\n }));\n },\n onAcquire: item => Effect.suspend(() => {\n creationTimes.set(item, clock.currentTimeMillisUnsafe());\n return Queue.offer(queue, item);\n }),\n reclaim: _ => Effect.undefined\n });\n});\nconst strategyUsageTTL = /*#__PURE__*/Effect.fnUntraced(function* (ttl) {\n const queue = yield* Queue.unbounded();\n return identity({\n run: pool => {\n const process = Effect.suspend(() => {\n const excess = activeSize(pool) - targetSize(pool);\n if (excess <= 0) return Effect.void;\n return Queue.take(queue).pipe(Effect.tap(item => invalidatePoolItem(pool, item)), Effect.flatMap(() => process));\n });\n return process.pipe(Effect.delay(ttl), Effect.forever({\n disableYield: true\n }));\n },\n onAcquire: item => Queue.offer(queue, item),\n reclaim(pool) {\n return Effect.suspend(() => {\n if (pool.state.invalidated.size === 0) {\n return Effect.undefined;\n }\n const item = Iterable.head(Iterable.filter(pool.state.invalidated, item => !item.disableReclaim));\n if (item._tag === \"None\") {\n return Effect.undefined;\n }\n pool.state.invalidated.delete(item.value);\n if (item.value.refCount < pool.config.concurrency) {\n pool.state.available.add(item.value);\n }\n return Effect.as(Queue.offer(queue, item.value), item.value);\n });\n }\n });\n});\nconst reportUnhandledError = cause => Effect.withFiber(fiber => {\n const unhandledLogLevel = fiber.getRef(UnhandledLogLevel);\n if (unhandledLogLevel) {\n return Effect.logWithLevel(unhandledLogLevel)(\"Unhandled error in pool finalizer\", cause);\n }\n return Effect.void;\n});\n//# sourceMappingURL=Pool.js.map","import * as Cause from \"./Cause.js\";\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport * as random from \"./internal/random.js\";\nimport * as Predicate from \"./Predicate.js\";\n/**\n * Represents a service for generating pseudo-random numbers.\n *\n * **When to use**\n *\n * Use to access or provide the random-number generator service used by Effect\n * programs.\n *\n * **Gotchas**\n *\n * The default implementation is based on `Math.random` and is not\n * cryptographically secure. Replace the service with a cryptographically secure\n * implementation before using these generators for security-sensitive values.\n *\n * **Example** (Accessing the random service)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const float = yield* Random.next\n * const integer = yield* Random.nextInt\n * const inRange = yield* Random.nextIntBetween(1, 100)\n *\n * console.log(\"Float:\", float)\n * console.log(\"Integer:\", integer)\n * console.log(\"In range:\", inRange)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const Random = random.Random;\nconst randomWith = f => Effect.withFiber(fiber => Effect.succeed(f(fiber.getRef(Random))));\n/**\n * Generates a random number between 0 (inclusive) and 1 (exclusive).\n *\n * **When to use**\n *\n * Use to generate a pseudo-random floating-point number in the standard\n * `[0, 1)` range.\n *\n * **Example** (Generating a random number)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const randomDouble = yield* Random.next\n * console.log(\"Random double:\", randomDouble)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const next = /*#__PURE__*/randomWith(r => r.nextDoubleUnsafe());\n/**\n * Generates a random boolean value.\n *\n * **When to use**\n *\n * Use to make a pseudo-random true-or-false choice.\n *\n * **Example** (Generating a random boolean)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const value = yield* Random.nextBoolean\n * console.log(\"Random boolean:\", value)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const nextBoolean = /*#__PURE__*/randomWith(r => r.nextDoubleUnsafe() > 0.5);\n/**\n * Generates a random integer between `Number.MIN_SAFE_INTEGER` (inclusive)\n * and `Number.MAX_SAFE_INTEGER` (inclusive).\n *\n * **When to use**\n *\n * Use to generate a pseudo-random safe integer across the full safe-integer\n * range.\n *\n * **Example** (Generating a random integer)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const randomInt = yield* Random.nextInt\n * console.log(\"Random integer:\", randomInt)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const nextInt = /*#__PURE__*/randomWith(r => r.nextIntUnsafe());\n/**\n * Generates a random number between `min` (inclusive) and `max` (exclusive).\n *\n * **When to use**\n *\n * Use to generate a pseudo-random floating-point number within a numeric range.\n *\n * **Example** (Generating a bounded random number)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const randomDouble = yield* Random.nextBetween(0, 1)\n * console.log(\"Random double: \", randomDouble)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 4.0.0\n */\nexport const nextBetween = (min, max) => randomWith(r => r.nextDoubleUnsafe() * (max - min) + min);\n/**\n * Generates a random integer between `min` and `max`.\n *\n * **When to use**\n *\n * Use to generate a pseudo-random integer within a rounded numeric range.\n *\n * **Details**\n *\n * The lower bound is rounded up with `Math.ceil` and the upper bound is\n * rounded down with `Math.floor`. By default the range is inclusive; set\n * `options.halfOpen: true` to exclude the upper bound.\n *\n * **Example** (Generating a bounded random integer)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const diceRoll1 = yield* Random.nextIntBetween(1, 6)\n * const diceRoll2 = yield* Random.nextIntBetween(1, 6, {\n * halfOpen: true\n * })\n * const diceRoll3 = yield* Random.nextIntBetween(0, 10)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const nextIntBetween = (min, max, options) => {\n const extra = options?.halfOpen === true ? 0 : 1;\n return randomWith(r => {\n const minInt = Math.ceil(min);\n const maxInt = Math.floor(max);\n return Math.floor(r.nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt;\n });\n};\n/**\n * Uses the pseudo-random number generator to shuffle the specified iterable.\n *\n * **When to use**\n *\n * Use to randomly reorder an iterable using the active `Random` service.\n *\n * **Example** (Shuffling values)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const values = yield* Random.shuffle([1, 2, 3, 4, 5])\n * console.log(values)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 2.0.0\n */\nexport const shuffle = elements => randomWith(r => {\n const buffer = Array.from(elements);\n for (let i = buffer.length - 1; i >= 1; i = i - 1) {\n const index = Math.min(i, Math.floor(r.nextDoubleUnsafe() * (i + 1)));\n const value = buffer[i];\n buffer[i] = buffer[index];\n buffer[index] = value;\n }\n return buffer;\n});\n/**\n * Gets a random element from an iterable.\n *\n * **When to use**\n *\n * Use to select one value uniformly from a collection using the active `Random`\n * service.\n *\n * **Details**\n *\n * If the input type is known to be non-empty, the returned effect cannot fail.\n * Otherwise, empty iterables fail with `Cause.NoSuchElementError`.\n *\n * **Example** (Choosing a random value)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const value = yield* Random.choice([\"red\", \"green\", \"blue\"] as const)\n * console.log(value)\n * })\n * ```\n *\n * @category Random Number Generators\n * @since 3.6.0\n */\nexport const choice = elements => {\n const buffer = Array.from(elements);\n return buffer.length === 0 ? Effect.fail(new Cause.NoSuchElementError(\"Cannot select a random element from an empty array\")) : randomWith(r => buffer[Math.min(buffer.length - 1, Math.floor(r.nextDoubleUnsafe() * buffer.length))]);\n};\n/**\n * Seeds the pseudo-random number generator with the specified value.\n *\n * **When to use**\n *\n * Use to run an effect with a deterministic pseudo-random sequence.\n *\n * **Details**\n *\n * Using the same seed produces the same random sequence, which is useful for\n * tests and reproducible simulations.\n *\n * **Gotchas**\n *\n * Use an unpredictable seed when uniqueness or unpredictability matters.\n *\n * **Example** (Seeding random generation)\n *\n * ```ts\n * import { Effect, Random } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const value1 = yield* Random.next\n * const value2 = yield* Random.next\n * console.log(value1, value2)\n * })\n *\n * // Same seed produces same sequence\n * const seeded1 = program.pipe(Random.withSeed(\"my-seed\"))\n * const seeded2 = program.pipe(Random.withSeed(\"my-seed\"))\n *\n * // Both will output identical values\n * Effect.runPromise(seeded1)\n * Effect.runPromise(seeded2)\n * ```\n *\n * @category Seeding\n * @since 4.0.0\n */\nexport const withSeed = /*#__PURE__*/dual(2, (self, seed) => Effect.provideService(self, Random, ISAAC_CSPRNG(seed)));\n/*///////////////////////////////////////////////////////////////////////////////////////////////////\nThis is a derivative work copyright (c) 2025 Effectful Technologies Inc, under MIT license.\nThis is a derivative work copyright (c) 2018, William P. \"Mac\" McMeans, under BSD license.\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n3. Neither the name of isaacCSPRNG nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\nOriginal work copyright (c) 2012 Yves-Marie K. Rinquin, under MIT license.\nhttps://github.com/rubycon/isaac.js\n///////////////////////////////////////////////////////////////////////////////////////////////////*/\nfunction ISAAC_CSPRNG(userSeed) {\n // Internal State\n const memory = new Array(256);\n const result = new Array(256);\n let accumulator = 0;\n let lastResult = 0;\n let generation = 0;\n let counter = 0;\n // Initial Seed\n const internalSeed = Predicate.isUndefined(userSeed) ? getInitialSeed() : userSeed;\n seed(internalSeed);\n function getInitialSeed() {\n const uint32a = new Uint32Array(2);\n crypto.getRandomValues(uint32a);\n return uint32a[0] + uint32a[1];\n }\n function reset() {\n accumulator = 0;\n lastResult = 0;\n counter = 0;\n for (let i = 0; i < 256; ++i) {\n memory[i] = 0;\n result[i] = 0;\n }\n generation = 0;\n }\n function seed(userSeed) {\n // The golden ratio ( 2654435769 )\n // See https://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine\n const magicNumber = 0x9e3779b9;\n let a = magicNumber;\n let b = magicNumber;\n let c = magicNumber;\n let d = magicNumber;\n let e = magicNumber;\n let f = magicNumber;\n let g = magicNumber;\n let h = magicNumber;\n let i = 0;\n let seed;\n if (Predicate.isString(userSeed)) {\n seed = toIntArray(userSeed);\n } else {\n seed = [userSeed];\n }\n reset();\n for (i = 0; i < seed.length; i++) {\n result[i & 0xff] += seed[i];\n }\n function mix() {\n a ^= b << 11;\n d = add32(d, a);\n b = add32(b, c);\n b ^= c >>> 2;\n e = add32(e, b);\n c = add32(c, d);\n c ^= d << 8;\n f = add32(f, c);\n d = add32(d, e);\n d ^= e >>> 16;\n g = add32(g, d);\n e = add32(e, f);\n e ^= f << 10;\n h = add32(h, e);\n f = add32(f, g);\n f ^= g >>> 4;\n a = add32(a, f);\n g = add32(g, h);\n g ^= h << 8;\n b = add32(b, g);\n h = add32(h, a);\n h ^= a >>> 9;\n c = add32(c, h);\n a = add32(a, b);\n }\n // Scramble the seed\n for (i = 0; i < 4; i++) {\n mix();\n }\n for (i = 0; i < 256; i += 8) {\n // Use all the information in the seed\n a = add32(a, result[i]);\n b = add32(b, result[i + 1]);\n c = add32(c, result[i + 2]);\n d = add32(d, result[i + 3]);\n e = add32(e, result[i + 4]);\n f = add32(f, result[i + 5]);\n g = add32(g, result[i + 6]);\n h = add32(h, result[i + 7]);\n mix();\n // Fill in the memory with messy stuff\n memory[i] = a;\n memory[i + 1] = b;\n memory[i + 2] = c;\n memory[i + 3] = d;\n memory[i + 4] = e;\n memory[i + 5] = f;\n memory[i + 6] = g;\n memory[i + 7] = h;\n }\n // Second pass to make sure seed affects memory\n for (i = 0; i < 256; i += 8) {\n a = add32(a, memory[i]);\n b = add32(b, memory[i + 1]);\n c = add32(c, memory[i + 2]);\n d = add32(d, memory[i + 3]);\n e = add32(e, memory[i + 4]);\n f = add32(f, memory[i + 5]);\n g = add32(g, memory[i + 6]);\n h = add32(h, memory[i + 7]);\n mix();\n // Fill in the memory with messy stuff (again)\n memory[i] = a;\n memory[i + 1] = b;\n memory[i + 2] = c;\n memory[i + 3] = d;\n memory[i + 4] = e;\n memory[i + 5] = f;\n memory[i + 6] = g;\n memory[i + 7] = h;\n }\n pnrg();\n generation = 256;\n }\n function pnrg(n) {\n let i = 0;\n let x = 0;\n let y = 0;\n n = Predicate.isUndefined(n) ? 1 : Math.abs(Math.floor(n));\n while (n--) {\n counter = add32(counter, 1);\n lastResult = add32(lastResult, counter);\n for (i = 0; i < 256; i++) {\n switch (i & 3) {\n case 0:\n {\n accumulator ^= accumulator << 13;\n break;\n }\n case 1:\n {\n accumulator ^= accumulator >>> 6;\n break;\n }\n case 2:\n {\n accumulator ^= accumulator << 2;\n break;\n }\n case 3:\n {\n accumulator ^= accumulator >>> 16;\n break;\n }\n }\n accumulator = add32(memory[i + 128 & 0xff], accumulator);\n x = memory[i];\n memory[i] = add32(memory[x >>> 2 & 0xff], add32(accumulator, lastResult));\n y = memory[i];\n result[i] = add32(memory[y >>> 10 & 0xff], x);\n lastResult = result[i];\n }\n }\n }\n /**\n * Returns a signed, random integer in the range [-2^31, 2^31).\n */\n function nextInt32() {\n if (!generation--) {\n pnrg();\n generation = 255;\n }\n return result[generation];\n }\n function nextIntUnsafe() {\n return Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;\n }\n /**\n * Returns a 53-bit fraction in the range [0, 1).\n */\n function nextDoubleUnsafe() {\n const hi = nextInt32() >>> 0 & 0x1FFFFF; // take top 21 bits\n const lo = nextInt32() >>> 0; // full 32 bits\n // 53-bit integer\n const combined = hi * 4294967296 + lo;\n return combined / 0x20000000000000; // [0, 1)\n }\n return {\n nextIntUnsafe,\n nextDoubleUnsafe\n };\n}\n/**\n * 32-bit addition with overflow handling (JavaScript numbers are 53-bit).\n *\n * Example: add32(0xFFFFFFFF, 0x00000001) = 0x00000000 (wraps around)\n */\nfunction add32(x, y) {\n // Add lower 16 bits separately to handle carry\n // Example: x=0x12345678, y=0xABCDEF01\n // lsb = (0x5678 + 0xEF01) = 0x14579\n const lsb = (x & 0xffff) + (y & 0xffff);\n // Add upper 16 bits + carry from lower addition\n // msb = (0x1234 + 0xABCD + (0x14579 >>> 16)) = (0x1234 + 0xABCD + 0x1) = 0xBE02\n const msb = (x >>> 16) + (y >>> 16) + (lsb >>> 16);\n // Combine: upper 16 bits | lower 16 bits (masked to prevent double carry)\n // return (0xBE02 << 16) | (0x14579 & 0xffff) = 0xBE024579\n return msb << 16 | lsb & 0xffff;\n}\nconst seedEncoder = /*#__PURE__*/new TextEncoder();\n/**\n * Convert a string to UTF-8 encoded 32-bit integers (little-endian).\n */\nfunction toIntArray(seed) {\n const bytes = seedEncoder.encode(seed);\n const result = [];\n for (let index = 0; index < bytes.length; index += 4) {\n result.push((bytes[index] ?? 0) << 0 | (bytes[index + 1] ?? 0) << 8 | (bytes[index + 2] ?? 0) << 16 | (bytes[index + 3] ?? 0) << 24);\n }\n return result;\n}\n//# sourceMappingURL=Random.js.map","/**\n * Stores fiber-safe mutable state inside Effect programs.\n *\n * A `Ref<A>` holds one value and exposes reads, writes, and atomic\n * transformations as effects, so state changes compose with Effect's\n * concurrency model. This module includes constructors, safe and unsafe reads,\n * set and get-and-set helpers, update and modify helpers, and conditional\n * update variants that leave the value unchanged when an `Option.none` result\n * is returned.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual, identity } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as MutableRef from \"./MutableRef.js\";\nconst TypeId = \"~effect/Ref\";\nconst RefProto = {\n [TypeId]: {\n _A: identity\n },\n ...PipeInspectableProto,\n toJSON() {\n return {\n _id: \"Ref\",\n ref: this.ref\n };\n }\n};\n/**\n * Creates a new Ref with the specified initial value (unsafe version).\n *\n * **When to use**\n *\n * Use when you need immediate synchronous construction and can guarantee\n * that creating the `Ref` outside of `Effect` is safe.\n *\n * **Gotchas**\n *\n * Prefer `Ref.make` for Effect-wrapped creation in Effect programs.\n *\n * **Example** (Creating a ref unsafely)\n *\n * ```ts\n * import { Ref } from \"effect\"\n *\n * // Create a ref directly without Effect\n * const counter = Ref.makeUnsafe(0)\n *\n * // Get the current value\n * const value = Ref.getUnsafe(counter)\n * console.log(value) // 0\n *\n * // Note: This is unsafe and should be used carefully\n * // Prefer Ref.make for Effect-wrapped creation\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeUnsafe = value => {\n const self = Object.create(RefProto);\n self.ref = MutableRef.make(value);\n return self;\n};\n/**\n * Creates a new Ref with the specified initial value.\n *\n * **When to use**\n *\n * Use to create a `Ref` for shared mutable state inside an Effect program.\n *\n * **Example** (Creating a ref)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* Ref.make(42)\n * const value = yield* Ref.get(ref)\n * console.log(value) // 42\n * })\n * ```\n *\n * @see {@link makeUnsafe} for synchronous construction outside Effect code\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = value => Effect.sync(() => makeUnsafe(value));\n/**\n * Gets the current value of the Ref.\n *\n * **When to use**\n *\n * Use to read the current `Ref` value without changing it.\n *\n * **Example** (Getting the current value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* Ref.make(42)\n * const value = yield* Ref.get(ref)\n * console.log(value) // 42\n * })\n * ```\n *\n * @see {@link set} for replacing the current value\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.sync(() => self.ref.current);\n/**\n * Sets the value of the Ref to the specified value.\n *\n * **When to use**\n *\n * Use to replace the current `Ref` value with a known value.\n *\n * **Example** (Setting a value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* Ref.make(0)\n * yield* Ref.set(ref, 42)\n * const value = yield* Ref.get(ref)\n * console.log(value) // 42\n * })\n *\n * // Using multiple operations\n * const program2 = Effect.gen(function*() {\n * const ref = yield* Ref.make(0)\n * yield* Ref.set(ref, 100)\n * const value = yield* Ref.get(ref)\n * console.log(value) // 100\n * })\n * ```\n *\n * @see {@link getAndSet} for setting while returning the previous value\n * @see {@link setAndGet} for setting while returning the new value\n *\n * @category setters\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, value) => Effect.sync(() => MutableRef.set(self.ref, value)));\n/**\n * Gets the current value of the Ref, sets it to the specified value, and returns the previous value atomically.\n *\n * **When to use**\n *\n * Use to replace a plain `Ref` value while returning the previous value.\n *\n * **Example** (Replacing a value atomically)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* Ref.make(\"initial\")\n *\n * // Get current value and set new value atomically\n * const previous = yield* Ref.getAndSet(ref, \"updated\")\n * console.log(previous) // \"initial\"\n *\n * const current = yield* Ref.get(ref)\n * console.log(current) // \"updated\"\n * })\n * ```\n *\n * @see {@link set} for setting without returning the previous value\n * @see {@link getAndUpdate} for deriving the new value from the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndSet = /*#__PURE__*/dual(2, (self, value) => Effect.sync(() => {\n const current = self.ref.current;\n self.ref.current = value;\n return current;\n}));\n/**\n * Gets the current value of the Ref, updates it with the given function, and returns the previous value atomically.\n *\n * **When to use**\n *\n * Use to derive a new `Ref` value while returning the previous value.\n *\n * **Example** (Updating and returning the previous value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(10)\n *\n * // Get current value and update it atomically\n * const previous = yield* Ref.getAndUpdate(counter, (n) => n * 2)\n * console.log(previous) // 10\n *\n * const current = yield* Ref.get(counter)\n * console.log(current) // 20\n * })\n * ```\n *\n * @see {@link update} for updating without returning the previous value\n * @see {@link updateAndGet} for returning the new value instead\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdate = /*#__PURE__*/dual(2, (self, f) => Effect.sync(() => {\n const current = self.ref.current;\n self.ref.current = f(current);\n return current;\n}));\n/**\n * Gets the current value of the Ref and updates it atomically with the given partial function.\n *\n * **When to use**\n *\n * Use to return the previous `Ref` value while applying a conditional update.\n *\n * **Details**\n *\n * If the partial function returns `Option.some`, the Ref is updated with the\n * new value. If it returns `Option.none`, the Ref is left unchanged. The effect\n * always returns the value that was in the Ref before the attempted update.\n *\n * **Example** (Conditionally updating and returning the previous value)\n *\n * ```ts\n * import { Effect, Option, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n *\n * // Only update if value is greater than 3\n * const previous1 = yield* Ref.getAndUpdateSome(\n * counter,\n * (n) => n > 3 ? Option.some(n * 2) : Option.none()\n * )\n * console.log(previous1) // 5\n *\n * const current1 = yield* Ref.get(counter)\n * console.log(current1) // 10\n *\n * // Try to update again (won't update since 10 > 3 is true but let's say condition is n < 3)\n * const previous2 = yield* Ref.getAndUpdateSome(\n * counter,\n * (n) => n < 3 ? Option.some(n * 2) : Option.none()\n * )\n * console.log(previous2) // 10\n *\n * const current2 = yield* Ref.get(counter)\n * console.log(current2) // 10 (unchanged)\n * })\n * ```\n *\n * @see {@link getAndUpdate} for always applying an update\n * @see {@link updateSome} for conditional updates without returning the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdateSome = /*#__PURE__*/dual(2, (self, pf) => Effect.sync(() => {\n const current = self.ref.current;\n const option = pf(current);\n if (option._tag === \"Some\") {\n self.ref.current = option.value;\n }\n return current;\n}));\n/**\n * Sets the value of the Ref atomically to the specified value and returns the new value.\n *\n * **When to use**\n *\n * Use when you want to set a `Ref` value and immediately get it back in one\n * atomic operation.\n *\n * **Example** (Setting and returning the new value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* Ref.make(10)\n *\n * // Set new value and get it back in one operation\n * const newValue = yield* Ref.setAndGet(ref, 42)\n * console.log(newValue) // 42\n *\n * // Verify the ref contains the new value\n * const current = yield* Ref.get(ref)\n * console.log(current) // 42\n * })\n *\n * // Useful for sequential operations\n * const program2 = Effect.gen(function*() {\n * const counter = yield* Ref.make(0)\n *\n * const newValue = yield* Ref.setAndGet(counter, 20)\n * console.log(newValue) // 20\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const setAndGet = /*#__PURE__*/dual(2, (self, value) => Effect.sync(() => self.ref.current = value));\n/**\n * Modifies the value of the Ref atomically using the given function.\n *\n * **When to use**\n *\n * Use to compute both a separate return value and the next stored `Ref` value\n * in one atomic update.\n *\n * **Details**\n *\n * The function receives the current value and returns a tuple of\n * `[result, newValue]`. The Ref is updated with `newValue`, and `result` is\n * returned by the effect.\n *\n * **Example** (Modifying a value atomically)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(10)\n *\n * // Modify the ref and return some computation result\n * const result = yield* Ref.modify(counter, (n) => [\n * `Previous value was ${n}`, // Return value\n * n * 2 // New ref value\n * ])\n *\n * console.log(result) // \"Previous value was 10\"\n *\n * const current = yield* Ref.get(counter)\n * console.log(current) // 20\n * })\n *\n * // Example with more complex computation\n * const program2 = Effect.gen(function*() {\n * const state = yield* Ref.make({ count: 0, total: 0 })\n *\n * const incremented = yield* Ref.modify(state, (s) => [\n * s.count, // Return previous count\n * { count: s.count + 1, total: s.total + s.count + 1 } // New state\n * ])\n *\n * console.log(incremented) // 0\n * })\n * ```\n *\n * @see {@link updateAndGet} for returning the new stored value\n * @see {@link modifySome} for optionally updating while returning a separate result\n *\n * @category setters\n * @since 2.0.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, f) => Effect.sync(() => {\n const [b, a] = f(self.ref.current);\n self.ref.current = a;\n return b;\n}));\n/**\n * Computes a result atomically and optionally updates the value of the `Ref`.\n *\n * **When to use**\n *\n * Use to compute a return value while optionally updating a plain `Ref`.\n *\n * **Details**\n *\n * The callback receives the current value and returns `[result, nextValue]`,\n * where `nextValue` is an `Option`. If `nextValue` is `Option.some(value)`,\n * the `Ref` is updated to `value`; if it is `Option.none()`, the `Ref` is left\n * unchanged. The returned effect always succeeds with `result`.\n *\n * **Example** (Conditionally modifying a value)\n *\n * ```ts\n * import { Effect, Option, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n *\n * // Only modify if value is greater than 3\n * const result1 = yield* Ref.modifySome(\n * counter,\n * (n) =>\n * n > 3\n * ? [`incremented ${n}`, Option.some(n + 10)]\n * : [\"no change\", Option.none()]\n * )\n *\n * console.log(result1) // \"incremented 5\"\n *\n * const current1 = yield* Ref.get(counter)\n * console.log(current1) // 15\n *\n * // Try to modify with a condition that fails\n * const result2 = yield* Ref.modifySome(\n * counter,\n * (n) =>\n * n < 10\n * ? [`decremented ${n}`, Option.some(n - 5)]\n * : [\"no change\", Option.none()]\n * )\n *\n * console.log(result2) // \"no change\"\n *\n * const current2 = yield* Ref.get(counter)\n * console.log(current2) // 15 (unchanged)\n * })\n * ```\n *\n * @see {@link modify} for always storing a new value\n * @see {@link updateSome} for optional updates without a separate return value\n *\n * @category setters\n * @since 2.0.0\n */\nexport const modifySome = /*#__PURE__*/dual(2, (self, pf) => modify(self, value => {\n const [b, option] = pf(value);\n return [b, option._tag === \"None\" ? value : option.value];\n}));\n/**\n * Updates the value of the Ref atomically using the given function.\n *\n * **When to use**\n *\n * Use to apply a `Ref` state transition without returning a value.\n *\n * **Example** (Updating a value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n *\n * // Update the value\n * yield* Ref.update(counter, (n) => n * 2)\n *\n * const value = yield* Ref.get(counter)\n * console.log(value) // 10\n * })\n *\n * // Using multiple operations\n * const program2 = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n * yield* Ref.update(counter, (n: number) => n + 10)\n * const value = yield* Ref.get(counter)\n * console.log(value) // 15\n * })\n * ```\n *\n * @see {@link updateAndGet} for returning the new value\n * @see {@link getAndUpdate} for returning the previous value\n *\n * @category setters\n * @since 2.0.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, f) => Effect.sync(() => {\n self.ref.current = f(self.ref.current);\n}));\n/**\n * Updates the value of the Ref atomically using the given function and returns the new value.\n *\n * **When to use**\n *\n * Use to apply a `Ref` state transition and return the new stored value.\n *\n * **Example** (Updating and returning the new value)\n *\n * ```ts\n * import { Effect, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n *\n * // Update and get the new value in one operation\n * const newValue = yield* Ref.updateAndGet(counter, (n) => n * 3)\n * console.log(newValue) // 15\n *\n * // Verify the ref contains the new value\n * const current = yield* Ref.get(counter)\n * console.log(current) // 15\n * })\n * ```\n *\n * @see {@link update} for updating without returning the new value\n * @see {@link getAndUpdate} for returning the previous value instead\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateAndGet = /*#__PURE__*/dual(2, (self, f) => Effect.sync(() => self.ref.current = f(self.ref.current)));\n/**\n * Updates the value of the Ref atomically using the given partial function.\n *\n * **When to use**\n *\n * Use to apply a conditional `Ref` update without returning a value.\n *\n * **Details**\n *\n * If the partial function returns `Option.some`, the Ref is updated with the\n * new value. If it returns `Option.none`, the Ref is left unchanged.\n *\n * **Example** (Conditionally updating a value)\n *\n * ```ts\n * import { Effect, Option, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(5)\n *\n * // Only update if value is even\n * yield* Ref.updateSome(\n * counter,\n * (n) => n % 2 === 0 ? Option.some(n * 2) : Option.none()\n * )\n *\n * let current = yield* Ref.get(counter)\n * console.log(current) // 5 (unchanged because 5 is odd)\n *\n * // Set to even number and try again\n * yield* Ref.set(counter, 6)\n * yield* Ref.updateSome(\n * counter,\n * (n) => n % 2 === 0 ? Option.some(n * 2) : Option.none()\n * )\n *\n * current = yield* Ref.get(counter)\n * console.log(current) // 12 (updated because 6 is even)\n * })\n * ```\n *\n * @see {@link update} for always applying an update\n * @see {@link updateSomeAndGet} for returning the resulting current value\n *\n * @category setters\n * @since 2.0.0\n */\nexport const updateSome = /*#__PURE__*/dual(2, (self, f) => Effect.sync(() => {\n const option = f(self.ref.current);\n if (option._tag === \"Some\") {\n self.ref.current = option.value;\n }\n}));\n/**\n * Updates the value of the Ref atomically using the given partial function and returns the current value.\n *\n * **When to use**\n *\n * Use to apply a conditional `Ref` update and return the resulting current\n * value.\n *\n * **Details**\n *\n * If the partial function returns `Option.some`, the Ref is updated with the\n * new value. If it returns `Option.none`, the Ref is left unchanged. The effect\n * returns the current value of the Ref after the potential update.\n *\n * **Example** (Conditionally updating and returning the current value)\n *\n * ```ts\n * import { Effect, Option, Ref } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* Ref.make(10)\n *\n * // Only update if value is greater than 5\n * const result1 = yield* Ref.updateSomeAndGet(\n * counter,\n * (n) => n > 5 ? Option.some(n / 2) : Option.none()\n * )\n * console.log(result1) // 5 (updated and returned)\n *\n * // Try to update again with same condition\n * const result2 = yield* Ref.updateSomeAndGet(\n * counter,\n * (n) => n > 5 ? Option.some(n / 2) : Option.none()\n * )\n * console.log(result2) // 5 (unchanged because 5 is not > 5)\n * })\n * ```\n *\n * @see {@link updateSome} for conditional updates without returning a value\n * @see {@link updateAndGet} for always updating and returning the new value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateSomeAndGet = /*#__PURE__*/dual(2, (self, pf) => Effect.sync(() => {\n const option = pf(self.ref.current);\n if (option._tag === \"Some\") {\n self.ref.current = option.value;\n }\n return self.ref.current;\n}));\n/**\n * Gets the current value of the Ref synchronously (unsafe version).\n *\n * **When to use**\n *\n * Use when you need immediate synchronous access and can guarantee that\n * reading the `Ref` outside of `Effect` is safe.\n *\n * **Gotchas**\n *\n * Prefer `Ref.get` for Effect-wrapped access in Effect programs.\n *\n * **Example** (Reading a ref unsafely)\n *\n * ```ts\n * import { Ref } from \"effect\"\n *\n * // Create a ref directly\n * const counter = Ref.makeUnsafe(42)\n *\n * // Get the value synchronously\n * const value = Ref.getUnsafe(counter)\n * console.log(value) // 42\n *\n * // Note: This is unsafe and should be used carefully\n * // Prefer Ref.get for Effect-wrapped access\n * ```\n *\n * @category getters\n * @since 4.0.0\n */\nexport const getUnsafe = self => self.ref.current;\n//# sourceMappingURL=Ref.js.map","/**\n * Stores encoded results for `Persistable` requests.\n *\n * The `Persistence` service creates scoped stores keyed by each request's\n * `PrimaryKey`. Stores read and write schema-encoded `Exit` values with\n * optional TTLs, letting request workflows reuse expensive or idempotent results\n * across fibers, process restarts, or workers that share a backing store.\n *\n * @since 4.0.0\n */\nimport * as Arr from \"../../Array.js\";\nimport * as Clock from \"../../Clock.js\";\nimport * as Context from \"../../Context.js\";\nimport * as Duration from \"../../Duration.js\";\nimport * as Effect from \"../../Effect.js\";\nimport * as Exit from \"../../Exit.js\";\nimport { identity } from \"../../Function.js\";\nimport * as Layer from \"../../Layer.js\";\nimport * as PrimaryKey from \"../../PrimaryKey.js\";\nimport * as Schema from \"../../Schema.js\";\nimport * as SqlClient from \"../sql/SqlClient.js\";\nimport * as KeyValueStore from \"./KeyValueStore.js\";\nimport * as Persistable from \"./Persistable.js\";\nimport * as Redis from \"./Redis.js\";\nconst ErrorTypeId = \"~effect/persistence/Persistence/PersistenceError\";\n/**\n * Error raised by persistence and backing-store operations.\n *\n * @category errors\n * @since 4.0.0\n */\nexport class PersistenceError extends /*#__PURE__*/Schema.ErrorClass(ErrorTypeId)({\n _tag: /*#__PURE__*/Schema.tag(\"PersistenceError\"),\n message: Schema.String,\n cause: /*#__PURE__*/Schema.optional(/*#__PURE__*/Schema.Defect())\n}) {\n /**\n * Marks this value as a persistence error for runtime guards.\n *\n * @since 4.0.0\n */\n [ErrorTypeId] = ErrorTypeId;\n}\n/**\n * Service for creating scoped stores of persisted `Persistable` request\n * results.\n *\n * @category models\n * @since 4.0.0\n */\nexport class Persistence extends /*#__PURE__*/Context.Service()(\"effect/persistence/Persistence\") {}\n/**\n * Service for creating raw backing stores for persistence store ids.\n *\n * @category BackingPersistence\n * @since 4.0.0\n */\nexport class BackingPersistence extends /*#__PURE__*/Context.Service()(\"effect/persistence/BackingPersistence\") {}\n/**\n * Provides `Persistence` from `BackingPersistence`.\n *\n * **Details**\n *\n * The layer serializes and deserializes `Persistable` exits, applies\n * per-entry TTLs, and skips writes whose TTL is zero or negative.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.effect(Persistence)(/*#__PURE__*/Effect.gen(function* () {\n const backing = yield* BackingPersistence;\n const scope = yield* Effect.scope;\n return Persistence.of({\n make: Effect.fnUntraced(function* (options) {\n const storage = yield* backing.make(options.storeId);\n const timeToLive = options.timeToLive ?? (() => Duration.infinity);\n return identity({\n get: key => Effect.flatMap(storage.get(PrimaryKey.value(key)), result => result ? Persistable.deserializeExit(key, result) : Effect.undefined),\n getMany: Effect.fnUntraced(function* (keys) {\n const primaryKeys = Arr.empty();\n const persistables = Arr.empty();\n for (const key of keys) {\n primaryKeys.push(PrimaryKey.value(key));\n persistables.push(key);\n }\n if (!Arr.isArrayNonEmpty(primaryKeys)) return [];\n const results = yield* storage.getMany(primaryKeys);\n if (results.length !== primaryKeys.length) {\n return yield* new PersistenceError({\n message: `Expected ${primaryKeys.length} results but got ${results.length} from backing store`\n });\n }\n const out = new Array(primaryKeys.length);\n let toRemove;\n for (let i = 0; i < results.length; i++) {\n const key = persistables[i];\n const result = results[i];\n if (result === undefined) {\n out[i] = undefined;\n continue;\n }\n const eff = Persistable.deserializeExit(key, result);\n const exit = Exit.isExit(eff) ? eff : yield* Effect.exit(eff);\n if (Exit.isFailure(exit)) {\n toRemove ??= [];\n toRemove.push(PrimaryKey.value(key));\n out[i] = undefined;\n continue;\n }\n out[i] = exit.value;\n }\n if (toRemove) {\n for (let i = 0; i < toRemove.length; i++) {\n yield* Effect.forkIn(storage.remove(toRemove[i]), scope);\n }\n }\n return out;\n }),\n set(key, value) {\n const ttl = Duration.fromInputUnsafe(timeToLive(value, key));\n if (Duration.isZero(ttl) || Duration.isNegative(ttl)) return Effect.void;\n return Persistable.serializeExit(key, value).pipe(Effect.flatMap(encoded => storage.set(PrimaryKey.value(key), encoded, Duration.isFinite(ttl) ? ttl : undefined)));\n },\n setMany: Effect.fnUntraced(function* (entries) {\n const encodedEntries = Arr.empty();\n for (const [key, value] of entries) {\n const ttl = Duration.fromInputUnsafe(timeToLive(value, key));\n if (Duration.isZero(ttl) || Duration.isNegative(ttl)) continue;\n const encoded = Persistable.serializeExit(key, value);\n const exit = Exit.isExit(encoded) ? encoded : yield* Effect.exit(encoded);\n if (Exit.isFailure(exit)) {\n return yield* exit;\n }\n encodedEntries.push([PrimaryKey.value(key), exit.value, Duration.isFinite(ttl) ? ttl : undefined]);\n }\n if (!Arr.isArrayNonEmpty(encodedEntries)) return;\n return yield* storage.setMany(encodedEntries);\n }),\n remove: key => storage.remove(PrimaryKey.value(key)),\n clear: storage.clear\n });\n })\n });\n}));\n/**\n * Provides an in-memory `BackingPersistence` grouped by store id.\n *\n * **Details**\n *\n * Entries are process-local and expire according to their stored TTL.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerBackingMemory = /*#__PURE__*/Layer.sync(BackingPersistence)(() => {\n const stores = new Map();\n const getStore = storeId => {\n let store = stores.get(storeId);\n if (store === undefined) {\n store = new Map();\n stores.set(storeId, store);\n }\n return store;\n };\n return BackingPersistence.of({\n make: storeId => Effect.clockWith(clock => {\n const map = getStore(storeId);\n const unsafeGet = key => {\n const value = map.get(key);\n if (value === undefined) {\n return undefined;\n } else if (value[1] !== null && value[1] <= clock.currentTimeMillisUnsafe()) {\n map.delete(key);\n return undefined;\n }\n return value[0];\n };\n return Effect.succeed({\n get: key => Effect.sync(() => unsafeGet(key)),\n getMany: keys => Effect.sync(() => Arr.map(keys, unsafeGet)),\n set: (key, value, ttl) => Effect.sync(() => map.set(key, [value, unsafeTtlToExpires(clock, ttl)])),\n setMany: entries => Effect.sync(() => {\n for (const [key, value, ttl] of entries) {\n map.set(key, [value, unsafeTtlToExpires(clock, ttl)]);\n }\n }),\n remove: key => Effect.sync(() => map.delete(key)),\n clear: Effect.sync(() => map.clear())\n });\n })\n });\n});\n/**\n * Provides SQL-backed persistence using one table per store id.\n *\n * **Details**\n *\n * Each table is created if needed and stores JSON-encoded values with optional\n * expiration timestamps.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerBackingSqlMultiTable = /*#__PURE__*/Layer.effect(BackingPersistence)(/*#__PURE__*/Effect.gen(function* () {\n const sql = (yield* SqlClient.SqlClient).withoutTransforms();\n return BackingPersistence.of({\n make: Effect.fnUntraced(function* (storeId) {\n const clock = yield* Clock.Clock;\n const table = sql(`effect_persistence_${storeId}`);\n yield* sql.onDialectOrElse({\n mysql: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n id VARCHAR(191) PRIMARY KEY,\n value TEXT NOT NULL,\n expires BIGINT\n )\n `,\n pg: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n id TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n expires BIGINT\n )\n `,\n mssql: () => sql`\n IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${table} AND xtype='U')\n CREATE TABLE ${table} (\n id NVARCHAR(450) PRIMARY KEY,\n value NVARCHAR(MAX) NOT NULL,\n expires BIGINT\n )\n `,\n // sqlite\n orElse: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n id TEXT PRIMARY KEY,\n value TEXT NOT NULL,\n expires INTEGER\n )\n `\n }).pipe(Effect.orDie);\n // Cleanup expired entries on startup\n yield* Effect.ignore(sql`DELETE FROM ${table} WHERE expires IS NOT NULL AND expires <= ${clock.currentTimeMillisUnsafe()}`);\n const upsert = sql.onDialectOrElse({\n pg: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON CONFLICT (id) DO UPDATE SET value=EXCLUDED.value, expires=EXCLUDED.expires\n `.unprepared,\n mysql: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON DUPLICATE KEY UPDATE value=VALUES(value), expires=VALUES(expires)\n `.unprepared,\n // sqlite\n orElse: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON CONFLICT(id) DO UPDATE SET value=excluded.value, expires=excluded.expires\n `.unprepared\n });\n const wrapString = sql.onDialectOrElse({\n mssql: () => s => `N'${s}'`,\n orElse: () => s => `'${s}'`\n });\n return identity({\n get: key => sql`SELECT value FROM ${table} WHERE id = ${key} AND (expires IS NULL OR expires > ${clock.currentTimeMillisUnsafe()})`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to get key ${key} from backing store`,\n cause\n })), Effect.flatMap(rows => {\n if (rows.length === 0) {\n return Effect.undefined;\n }\n try {\n return Effect.succeed(JSON.parse(rows[0].value));\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to parse value for key ${key} from backing store`,\n cause\n }));\n }\n })),\n getMany: keys => sql`SELECT id, value FROM ${table} WHERE id IN (${sql.literal(keys.map(wrapString).join(\", \"))}) AND (expires IS NULL OR expires > ${clock.currentTimeMillisUnsafe()})`.unprepared.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to getMany from backing store`,\n cause\n })), Effect.flatMap(rows => {\n const out = new Array(keys.length);\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const index = keys.indexOf(row.id);\n if (index === -1) continue;\n try {\n out[index] = JSON.parse(row.value);\n } catch {\n // ignore\n }\n }\n return Effect.succeed(out);\n })),\n set: (key, value, ttl) => Effect.suspend(() => {\n try {\n return upsert([{\n id: key,\n value: JSON.stringify(value),\n expires: unsafeTtlToExpires(clock, ttl)\n }]).pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to set key ${key} in backing store`,\n cause\n })), Effect.asVoid);\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to serialize value for key ${key} to backing store`,\n cause\n }));\n }\n }),\n setMany: entries => Effect.suspend(() => {\n try {\n const encoded = entries.map(([key, value, ttl]) => ({\n id: key,\n value: JSON.stringify(value),\n expires: unsafeTtlToExpires(clock, ttl)\n }));\n return upsert(encoded).pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to setMany in backing store`,\n cause\n })), Effect.asVoid);\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to serialize values into backing store`,\n cause\n }));\n }\n }),\n remove: key => sql`DELETE FROM ${table} WHERE id = ${key}`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to remove key ${key} from backing store`,\n cause\n })), Effect.asVoid),\n clear: sql`DELETE FROM ${table}`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to clear backing store`,\n cause\n })), Effect.asVoid)\n });\n })\n });\n}));\n/**\n * Provides SQL-backed persistence using a shared `effect_persistence` table.\n *\n * **Details**\n *\n * Rows are partitioned by `store_id` and store JSON-encoded values with\n * optional expiration timestamps.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerBackingSql = /*#__PURE__*/Layer.effect(BackingPersistence)(/*#__PURE__*/Effect.gen(function* () {\n const sql = (yield* SqlClient.SqlClient).withoutTransforms();\n const table = sql(\"effect_persistence\");\n yield* sql.onDialectOrElse({\n mysql: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n store_id VARCHAR(191) NOT NULL,\n id VARCHAR(191) NOT NULL,\n value TEXT NOT NULL,\n expires BIGINT,\n PRIMARY KEY (store_id, id)\n )\n `,\n pg: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n store_id TEXT NOT NULL,\n id TEXT NOT NULL,\n value TEXT NOT NULL,\n expires BIGINT,\n PRIMARY KEY (store_id, id)\n )\n `,\n mssql: () => sql`\n IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${table} AND xtype='U')\n CREATE TABLE ${table} (\n store_id NVARCHAR(191) NOT NULL,\n id NVARCHAR(191) NOT NULL,\n value NVARCHAR(MAX) NOT NULL,\n expires BIGINT,\n PRIMARY KEY (store_id, id)\n )\n `,\n // sqlite\n orElse: () => sql`\n CREATE TABLE IF NOT EXISTS ${table} (\n store_id TEXT NOT NULL,\n id TEXT NOT NULL,\n value TEXT NOT NULL,\n expires INTEGER,\n PRIMARY KEY (store_id, id)\n )\n `\n }).pipe(Effect.orDie);\n const upsert = sql.onDialectOrElse({\n pg: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON CONFLICT (store_id, id) DO UPDATE SET value=EXCLUDED.value, expires=EXCLUDED.expires\n `.unprepared,\n mysql: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON DUPLICATE KEY UPDATE value=VALUES(value), expires=VALUES(expires)\n `.unprepared,\n mssql: () => entries => Effect.forEach(entries, entry => sql`\n MERGE ${table} AS target\n USING (SELECT ${entry.store_id} AS store_id, ${entry.id} AS id, ${entry.value} AS value, ${entry.expires} AS expires) AS source\n ON target.store_id = source.store_id AND target.id = source.id\n WHEN MATCHED THEN UPDATE SET value = source.value, expires = source.expires\n WHEN NOT MATCHED THEN INSERT (store_id, id, value, expires)\n VALUES (source.store_id, source.id, source.value, source.expires);\n `, {\n discard: true\n }),\n // sqlite\n orElse: () => entries => sql`\n INSERT INTO ${table} ${sql.insert(entries)}\n ON CONFLICT(store_id, id) DO UPDATE SET value=excluded.value, expires=excluded.expires\n `.unprepared\n });\n const wrapString = sql.onDialectOrElse({\n mssql: () => s => `N'${s}'`,\n orElse: () => s => `'${s}'`\n });\n return BackingPersistence.of({\n make: Effect.fnUntraced(function* (storeId) {\n const clock = yield* Clock.Clock;\n // Cleanup expired entries on startup\n yield* Effect.ignore(sql`DELETE FROM ${table} WHERE store_id = ${storeId} AND expires IS NOT NULL AND expires <= ${clock.currentTimeMillisUnsafe()}`);\n return identity({\n get: key => sql`SELECT value FROM ${table} WHERE store_id = ${storeId} AND id = ${key} AND (expires IS NULL OR expires > ${clock.currentTimeMillisUnsafe()})`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to get key ${key} from backing store`,\n cause\n })), Effect.flatMap(rows => {\n if (rows.length === 0) {\n return Effect.undefined;\n }\n try {\n return Effect.succeed(JSON.parse(rows[0].value));\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to parse value for key ${key} from backing store`,\n cause\n }));\n }\n })),\n getMany: keys => sql`SELECT id, value FROM ${table} WHERE store_id = ${storeId} AND id IN (${sql.literal(keys.map(wrapString).join(\", \"))}) AND (expires IS NULL OR expires > ${clock.currentTimeMillisUnsafe()})`.unprepared.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to getMany from backing store`,\n cause\n })), Effect.flatMap(rows => {\n const out = new Array(keys.length);\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const index = keys.indexOf(row.id);\n if (index === -1) continue;\n try {\n out[index] = JSON.parse(row.value);\n } catch {\n // ignore\n }\n }\n return Effect.succeed(out);\n })),\n set: (key, value, ttl) => Effect.suspend(() => {\n try {\n return upsert([{\n store_id: storeId,\n id: key,\n value: JSON.stringify(value),\n expires: unsafeTtlToExpires(clock, ttl)\n }]).pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to set key ${key} in backing store`,\n cause\n })), Effect.asVoid);\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to serialize value for key ${key} to backing store`,\n cause\n }));\n }\n }),\n setMany: entries => Effect.suspend(() => {\n try {\n const encoded = entries.map(([key, value, ttl]) => ({\n store_id: storeId,\n id: key,\n value: JSON.stringify(value),\n expires: unsafeTtlToExpires(clock, ttl)\n }));\n return upsert(encoded).pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to setMany in backing store`,\n cause\n })), Effect.asVoid);\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to serialize values into backing store`,\n cause\n }));\n }\n }),\n remove: key => sql`DELETE FROM ${table} WHERE store_id = ${storeId} AND id = ${key}`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to remove key ${key} from backing store`,\n cause\n })), Effect.asVoid),\n clear: sql`DELETE FROM ${table} WHERE store_id = ${storeId}`.pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to clear backing store`,\n cause\n })), Effect.asVoid)\n });\n })\n });\n}));\n/**\n * Provides Redis-backed persistence.\n *\n * **Details**\n *\n * Each store id is used as a key prefix, values are JSON-encoded, and finite\n * TTLs are stored with Redis expiration.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerBackingRedis = /*#__PURE__*/Layer.effect(BackingPersistence)(/*#__PURE__*/Effect.gen(function* () {\n const redis = yield* Redis.Redis;\n const setMany = redis.eval(setManyRedis);\n return BackingPersistence.of({\n make: prefix => Effect.sync(() => {\n const prefixed = key => `${prefix}:${key}`;\n const parse = str => {\n if (str === null) {\n return Effect.undefined;\n }\n try {\n return Effect.succeed(JSON.parse(str));\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to parse value from Redis`,\n cause\n }));\n }\n };\n return identity({\n get: key => Effect.flatMap(Effect.mapError(redis.send(\"GET\", prefixed(key)), ({\n cause\n }) => new PersistenceError({\n message: `Failed to get key ${key} from Redis`,\n cause\n })), parse),\n getMany: keys => Effect.flatMap(Effect.mapError(redis.send(\"mget\", ...keys.map(prefixed)), ({\n cause\n }) => new PersistenceError({\n message: `Failed to getMany from Redis`,\n cause\n })), values => {\n const out = new Array(keys.length);\n for (let i = 0; i < keys.length; i++) {\n const value = values[i];\n try {\n out[i] = value === null ? undefined : JSON.parse(value);\n } catch {\n // TODO: remove bad entries?\n out[i] = undefined;\n }\n }\n return Effect.succeed(out);\n }),\n set: (key, value, ttl) => Effect.mapError(ttl === undefined ? redis.send(\"SET\", prefixed(key), JSON.stringify(value)) : redis.send(\"SET\", prefixed(key), JSON.stringify(value), \"PX\", String(Duration.toMillis(ttl))), ({\n cause\n }) => new PersistenceError({\n message: `Failed to set key ${key} in Redis`,\n cause\n })),\n setMany: entries => Effect.suspend(() => {\n const sets = new Map();\n const expires = new Map();\n for (const [key, value, ttl] of entries) {\n const pkey = prefixed(key);\n sets.set(pkey, JSON.stringify(value));\n if (ttl) {\n expires.set(pkey, Duration.toMillis(ttl));\n }\n }\n return Effect.mapError(setMany({\n sets,\n expires\n }), ({\n cause\n }) => new PersistenceError({\n message: `Failed to setMany in Redis`,\n cause\n }));\n }),\n remove: key => Effect.mapError(redis.send(\"DEL\", prefixed(key)), ({\n cause\n }) => new PersistenceError({\n message: `Failed to remove key ${key} from Redis`,\n cause\n })),\n clear: redis.send(\"KEYS\", `${prefix}:*`).pipe(Effect.flatMap(keys => redis.send(\"DEL\", ...keys)), Effect.mapError(({\n cause\n }) => new PersistenceError({\n message: `Failed to clear keys from Redis`,\n cause\n })))\n });\n })\n });\n}));\nconst setManyRedis = /*#__PURE__*/Redis.script(options => [...options.sets.keys(), ...options.expires.keys(), options.sets.size, options.expires.size, ...options.sets.values(), ...options.expires.values()], {\n numberOfKeys: options => options.sets.size + options.expires.size,\n lua: `\nlocal num_sets = tonumber(ARGV[1])\nlocal num_expires = tonumber(ARGV[2])\nlocal index = 3\n\nfor i = 1, num_sets do\n local key = KEYS[i]\n local value = ARGV[index]\n redis.call(\"SET\", key, value)\n index = index + 1\nend\n\nfor i = 1, num_expires do\n local key = KEYS[num_sets + i]\n local expire = tonumber(ARGV[index])\n redis.call(\"PEXPIRE\", key, expire)\n index = index + 1\nend\n`\n});\n/**\n * Provides `BackingPersistence` using a `KeyValueStore`.\n *\n * **Details**\n *\n * Each store id becomes a key prefix, and values are stored as JSON with\n * optional expiration timestamps.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerBackingKvs = /*#__PURE__*/Layer.effect(BackingPersistence)(/*#__PURE__*/Effect.gen(function* () {\n const backing = yield* KeyValueStore.KeyValueStore;\n const clock = yield* Clock.Clock;\n return BackingPersistence.of({\n make: storeId => Effect.sync(() => {\n const store = KeyValueStore.prefix(backing, storeId);\n const get = key => Effect.flatMap(Effect.mapError(store.get(key), error => new PersistenceError({\n message: `Failed to get key ${key} from backing store`,\n cause: error\n })), str => {\n if (str === undefined) {\n return Effect.undefined;\n }\n try {\n const parsed = JSON.parse(str);\n if (!Array.isArray(parsed)) return Effect.undefined;\n const [value, expires] = parsed;\n if (expires !== null && expires <= clock.currentTimeMillisUnsafe()) {\n return Effect.as(Effect.ignore(store.remove(key)), undefined);\n }\n return Effect.succeed(value);\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to parse value for key ${key} from backing store`,\n cause\n }));\n }\n });\n return identity({\n get,\n getMany: keys => Effect.forEach(keys, get, {\n concurrency: \"unbounded\"\n }),\n set: (key, value, ttl) => Effect.suspend(() => {\n try {\n return Effect.mapError(store.set(key, JSON.stringify([value, unsafeTtlToExpires(clock, ttl)])), cause => new PersistenceError({\n message: `Failed to set key ${key} in backing store`,\n cause\n }));\n } catch (cause) {\n return Effect.fail(new PersistenceError({\n message: `Failed to serialize value for key ${key} to backing store`,\n cause\n }));\n }\n }),\n setMany: entries => Effect.forEach(entries, ([key, value, ttl]) => {\n const expires = unsafeTtlToExpires(clock, ttl);\n if (expires === null) return Effect.void;\n const encoded = JSON.stringify([value, expires]);\n return store.set(key, encoded);\n }, {\n concurrency: \"unbounded\",\n discard: true\n }).pipe(Effect.mapError(cause => new PersistenceError({\n message: `Failed to setMany in backing store`,\n cause\n }))),\n remove: key => Effect.mapError(store.remove(key), cause => new PersistenceError({\n message: `Failed to remove key ${key} from backing store`,\n cause\n })),\n clear: Effect.mapError(store.clear, cause => new PersistenceError({\n message: `Failed to clear backing store`,\n cause\n }))\n });\n })\n });\n}));\n/**\n * Provides `Persistence` backed by the current `KeyValueStore`.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerKvs = /*#__PURE__*/layer.pipe(/*#__PURE__*/Layer.provide(layerBackingKvs));\n/**\n * Provides `Persistence` backed by process-local in-memory storage.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerMemory = /*#__PURE__*/layer.pipe(/*#__PURE__*/Layer.provide(layerBackingMemory));\n/**\n * Provides `Persistence` backed by the current `Redis` service.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerRedis = /*#__PURE__*/layer.pipe(/*#__PURE__*/Layer.provide(layerBackingRedis));\n/**\n * Provides `Persistence` backed by SQL with one table per store id.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerSqlMultiTable = /*#__PURE__*/layer.pipe(/*#__PURE__*/Layer.provide(layerBackingSqlMultiTable));\n/**\n * Provides `Persistence` backed by SQL using a shared persistence table.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerSql = /*#__PURE__*/layer.pipe(/*#__PURE__*/Layer.provide(layerBackingSql));\n/**\n * Converts a TTL to an absolute expiration timestamp in milliseconds.\n *\n * **Details**\n *\n * Returns `null` for no TTL and uses `clock.currentTimeMillisUnsafe`, so it is\n * intended for backing-store internals.\n *\n * @category converting\n * @since 4.0.0\n */\nexport const unsafeTtlToExpires = (clock, ttl) => ttl ? clock.currentTimeMillisUnsafe() + Duration.toMillis(ttl) : null;\n//# sourceMappingURL=Persistence.js.map","import * as Arr from \"./Array.js\";\nimport * as Cache from \"./Cache.js\";\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport { constTrue, dual, identity } from \"./Function.js\";\nimport { exitFail, exitSucceed } from \"./internal/core.js\";\nimport * as effect from \"./internal/effect.js\";\nimport * as internal from \"./internal/request.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Tracer from \"./Tracer.js\";\nimport * as Persistence from \"./unstable/persistence/Persistence.js\";\nconst TypeId = \"~effect/RequestResolver\";\nconst RequestResolverProto = {\n [TypeId]: {\n _A: identity,\n _R: identity\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n/**\n * Returns `true` if the specified value is a `RequestResolver`, `false` otherwise.\n *\n * **When to use**\n *\n * Use to narrow unknown values before passing them to APIs that require a\n * `RequestResolver`.\n *\n * @see {@link RequestResolver} for the type narrowed by this guard\n *\n * @category guards\n * @since 2.0.0\n */\nexport const isRequestResolver = u => hasProperty(u, TypeId);\n/**\n * Creates a request resolver with fine-grained\n * control over its behavior.\n *\n * **When to use**\n *\n * Use when you need to supply the resolver batching primitives directly,\n * including the batch key, optional pre-check, delay effect, collection cutoff,\n * and batch runner.\n *\n * **Details**\n *\n * `batchKey` groups request entries, `delay` schedules batch execution,\n * `collectWhile` can end collection early, and `runAll` receives a non-empty\n * batch for one key.\n *\n * **Gotchas**\n *\n * Accepted entries must be completed. If `runAll` succeeds with incomplete\n * entries, waiting requests fail. If `preCheck` returns `false`, the entry is\n * not batched, so it must be completed or linked to another completion path.\n *\n * @see {@link make} for constructing a resolver from a batch runner\n * @see {@link makeGrouped} for constructing a resolver that groups requests by key\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeWith = options => {\n const self = Object.create(RequestResolverProto);\n self.batchKey = options.batchKey;\n self.preCheck = options.preCheck;\n self.delay = options.delay;\n self.collectWhile = options.collectWhile;\n self.runAll = options.runAll;\n return self;\n};\nconst defaultKeyObject = {};\nconst defaultKey = _request => defaultKeyObject;\n/**\n * Constructs a request resolver with the specified method to run requests.\n *\n * **Example** (Creating a request resolver)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * // Define a request type\n * interface GetUserRequest extends Request.Request<string, Error> {\n * readonly _tag: \"GetUserRequest\"\n * readonly id: number\n * }\n * const GetUserRequest = Request.tagged<GetUserRequest>(\"GetUserRequest\")\n *\n * // Create a resolver that handles the requests\n * const UserResolver = RequestResolver.make<GetUserRequest>((entries) =>\n * Effect.sync(() => {\n * for (const entry of entries) {\n * // Complete each request with a result\n * entry.completeUnsafe(Exit.succeed(`User ${entry.request.id}`))\n * }\n * })\n * )\n *\n * // Use the resolver to handle requests\n * const getUserEffect = Effect.request(GetUserRequest({ id: 123 }), UserResolver)\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = runAll => makeWith({\n batchKey: defaultKey,\n delay: Effect.yieldNow,\n collectWhile: constTrue,\n runAll\n});\n/**\n * Constructs a request resolver with the requests grouped by a calculated key.\n *\n * **Details**\n *\n * The key can use the Equal trait to determine if two keys are equal.\n *\n * **Example** (Grouping requests by key)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetUserByRole extends Request.Request<string, Error> {\n * readonly _tag: \"GetUserByRole\"\n * readonly role: string\n * readonly id: number\n * }\n * const GetUserByRole = Request.tagged<GetUserByRole>(\"GetUserByRole\")\n *\n * // Group requests by role for efficient batch processing\n * const UserByRoleResolver = RequestResolver.makeGrouped<GetUserByRole, string>({\n * key: ({ request }) => request.role,\n * resolver: (entries, role) =>\n * Effect.sync(() => {\n * console.log(`Processing ${entries.length} requests for role: ${role}`)\n * for (const entry of entries) {\n * entry.completeUnsafe(\n * Exit.succeed(`User ${entry.request.id} with role ${role}`)\n * )\n * }\n * })\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeGrouped = options => makeWith({\n batchKey: hashGroupKey(options.key),\n delay: Effect.yieldNow,\n collectWhile: constTrue,\n runAll: options.resolver\n});\nconst hashGroupKey = get => {\n const groupKeys = MutableHashMap.empty();\n return entry => {\n const key = get(entry);\n const okey = MutableHashMap.get(groupKeys, key);\n if (okey._tag === \"Some\") {\n return okey.value;\n }\n MutableHashMap.set(groupKeys, key, key);\n return key;\n };\n};\n/**\n * Constructs a request resolver from a pure function.\n *\n * **Example** (Creating a resolver from a pure function)\n *\n * ```ts\n * import { Effect, Request, RequestResolver } from \"effect\"\n *\n * interface GetSquareRequest extends Request.Request<number> {\n * readonly _tag: \"GetSquareRequest\"\n * readonly value: number\n * }\n * const GetSquareRequest = Request.tagged<GetSquareRequest>(\"GetSquareRequest\")\n *\n * // Create a resolver from a pure function\n * const SquareResolver = RequestResolver.fromFunction<GetSquareRequest>(\n * (entry) => entry.request.value * entry.request.value\n * )\n *\n * // Usage\n * const getSquareEffect = Effect.request(\n * GetSquareRequest({ value: 5 }),\n * SquareResolver\n * )\n * // Will resolve to 25\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromFunction = f => make(entries => Effect.sync(() => {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n entry.completeUnsafe(exitSucceed(f(entry)));\n }\n}));\n/**\n * Constructs a request resolver from a pure function that takes a list of requests\n * and returns a list of results of the same size. Each item in the result\n * list must correspond to the item at the same index in the request list.\n *\n * **Example** (Batching pure request handling)\n *\n * ```ts\n * import { Effect, Request, RequestResolver } from \"effect\"\n *\n * interface GetDoubleRequest extends Request.Request<number> {\n * readonly _tag: \"GetDoubleRequest\"\n * readonly value: number\n * }\n * const GetDoubleRequest = Request.tagged<GetDoubleRequest>(\"GetDoubleRequest\")\n *\n * // Create a resolver that processes multiple requests in a batch\n * const DoubleResolver = RequestResolver.fromFunctionBatched<GetDoubleRequest>(\n * (entries) => entries.map((entry) => entry.request.value * 2)\n * )\n *\n * // Usage with multiple requests\n * const effects = [1, 2, 3].map((value) =>\n * Effect.request(GetDoubleRequest({ value }), DoubleResolver)\n * )\n * const batchedEffect = Effect.all(effects) // [2, 4, 6]\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromFunctionBatched = f => make(entries => Effect.sync(() => {\n let i = 0;\n for (const result of f(entries)) {\n const entry = entries[i++];\n entry.completeUnsafe(exitSucceed(result));\n }\n}));\n/**\n * Constructs a request resolver from an effectual function.\n *\n * **Example** (Creating a resolver from an effectful function)\n *\n * ```ts\n * import { Effect, Request, RequestResolver } from \"effect\"\n *\n * interface GetUserFromAPIRequest extends Request.Request<string> {\n * readonly _tag: \"GetUserFromAPIRequest\"\n * readonly id: number\n * }\n * const GetUserFromAPIRequest = Request.tagged<GetUserFromAPIRequest>(\n * \"GetUserFromAPIRequest\"\n * )\n *\n * // Create a resolver that uses effects (like HTTP calls)\n * const UserAPIResolver = RequestResolver.fromEffect<GetUserFromAPIRequest>(\n * (entry) =>\n * Effect.gen(function*() {\n * // Simulate an API call\n * yield* Effect.sleep(\"100 millis\")\n * // Just return the result without error handling for simplicity\n * return `User ${entry.request.id} from API`\n * })\n * )\n *\n * // Usage\n * const getUserEffect = Effect.request(\n * GetUserFromAPIRequest({ id: 123 }),\n * UserAPIResolver\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromEffect = f => {\n effect.interruptChildrenPatch(); // ensure middleware is registered\n return make(entries => Effect.callback(resume => {\n const parent = effect.getCurrentFiber();\n let done = 0;\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const fiber = effect.forkUnsafe(parent, f(entry), true);\n fiber.addObserver(exit => {\n entry.completeUnsafe(exit);\n done++;\n if (done === entries.length) {\n resume(effect.void);\n }\n });\n }\n }));\n};\n/**\n * Constructs a request resolver from a list of tags paired to functions, that takes\n * a list of requests and returns a list of results of the same size. Each item\n * in the result list must correspond to the item at the same index in the\n * request list.\n *\n * **Example** (Handling tagged request batches)\n *\n * ```ts\n * import { Effect, RequestResolver } from \"effect\"\n * import type { Request } from \"effect\"\n *\n * interface GetUser extends Request.Request<string, Error> {\n * readonly _tag: \"GetUser\"\n * readonly id: number\n * }\n *\n * interface GetPost extends Request.Request<string, Error> {\n * readonly _tag: \"GetPost\"\n * readonly id: number\n * }\n *\n * type MyRequest = GetUser | GetPost\n *\n * // Create a resolver that handles different request types\n * const MyResolver = RequestResolver.fromEffectTagged<MyRequest>()({\n * GetUser: (requests) =>\n * Effect.succeed(requests.map((req) => `User ${req.request.id}`)),\n * GetPost: (requests) =>\n * Effect.succeed(requests.map((req) => `Post ${req.request.id}`))\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromEffectTagged = () => fns => make(entries => {\n const grouped = new Map();\n for (let i = 0, len = entries.length; i < len; i++) {\n const group = grouped.get(entries[i].request._tag);\n if (group) {\n group.push(entries[i]);\n } else {\n grouped.set(entries[i].request._tag, [entries[i]]);\n }\n }\n return Effect.forEach(grouped, ([tag, requests]) => Effect.matchCause(fns[tag](requests), {\n onFailure: cause => {\n for (let i = 0; i < requests.length; i++) {\n const entry = requests[i];\n entry.completeUnsafe(exitFail(cause));\n }\n },\n onSuccess: res => {\n for (let i = 0; i < res.length; i++) {\n const entry = requests[i];\n entry.completeUnsafe(exitSucceed(res[i]));\n }\n }\n }), {\n concurrency: \"unbounded\",\n discard: true\n });\n});\n/**\n * Sets the batch delay effect for this request resolver.\n *\n * **Example** (Setting an effectful batch delay)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * const resolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.sync(() => {\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(\"data\"))\n * }\n * })\n * )\n *\n * // Set a custom delay effect (e.g., with logging)\n * const resolverWithCustomDelay = RequestResolver.setDelayEffect(\n * resolver,\n * Effect.gen(function*() {\n * yield* Effect.log(\"Waiting before processing batch...\")\n * yield* Effect.sleep(\"50 millis\")\n * })\n * )\n * ```\n *\n * @category delay\n * @since 4.0.0\n */\nexport const setDelayEffect = /*#__PURE__*/dual(2, (self, delay) => makeWith({\n ...self,\n delay\n}));\n/**\n * Sets the batch delay window for this request resolver to the specified duration.\n *\n * **Example** (Setting a batch delay)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * const resolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.sync(() => {\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(\"data\"))\n * }\n * })\n * )\n *\n * // Add a 100ms delay to batch requests together\n * const delayedResolver = RequestResolver.setDelay(resolver, \"100 millis\")\n *\n * // Can also use number for milliseconds\n * const delayedResolver2 = RequestResolver.setDelay(resolver, 100)\n * ```\n *\n * @category delay\n * @since 4.0.0\n */\nexport const setDelay = /*#__PURE__*/dual(2, (self, duration) => makeWith({\n ...self,\n delay: Effect.sleep(duration)\n}));\n/**\n * Wraps request resolver execution between `before` and `after` effects.\n *\n * **Example** (Running effects around request resolution)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * const resolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.sync(() => {\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(\"data\"))\n * }\n * })\n * )\n *\n * // Add setup and cleanup around request execution\n * const resolverWithAround = RequestResolver.around(\n * resolver,\n * (entries) =>\n * Effect.gen(function*() {\n * yield* Effect.log(`Starting batch of ${entries.length} requests`)\n * return entries.length\n * }),\n * (entries, initialSize) =>\n * Effect.gen(function*() {\n * yield* Effect.log(\n * `Batch completed with ${entries.length} requests (started with ${initialSize})`\n * )\n * })\n * )\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const around = /*#__PURE__*/dual(3, (self, before, after) => makeWith({\n ...self,\n runAll: (entries, key) => Effect.acquireUseRelease(before(entries), () => self.runAll(entries, key), a => after(entries, a))\n}));\n/**\n * Creates a request resolver that never executes requests.\n *\n * **When to use**\n *\n * Use as a resolver value for request types that are statically impossible and\n * should never be issued.\n *\n * **Gotchas**\n *\n * If this resolver is used for an actual request, the request waits forever\n * unless the fiber is interrupted.\n *\n * @see {@link make} for constructing a resolver that executes batches and completes request entries\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const never = /*#__PURE__*/make(() => Effect.never);\n/**\n * Returns a request resolver that collects at most `n` requests into each\n * batch.\n *\n * **Details**\n *\n * When more than `n` requests are waiting for the same resolver and batch key,\n * the current batch is run and additional requests are collected into later\n * batches.\n *\n * **Example** (Limiting parallel request batches)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * readonly id: number\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * const resolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.sync(() => {\n * console.log(`Processing batch of ${entries.length} requests`)\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(`data-${entry.request.id}`))\n * }\n * })\n * )\n *\n * // Limit batches to maximum 5 requests\n * const limitedResolver = RequestResolver.batchN(resolver, 5)\n *\n * // When more than 5 requests are made, they'll be split into multiple batches\n * const requests = Array.from(\n * { length: 12 },\n * (_, i) => Effect.request(GetDataRequest({ id: i }), limitedResolver)\n * )\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const batchN = /*#__PURE__*/dual(2, (self, n) => makeWith({\n ...self,\n collectWhile: requests => requests.size < n\n}));\n/**\n * Transforms a request resolver by grouping requests using the specified key\n * function.\n *\n * **Example** (Grouping resolver requests)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetUserRequest extends Request.Request<string> {\n * readonly _tag: \"GetUserRequest\"\n * readonly userId: number\n * readonly department: string\n * }\n * const GetUserRequest = Request.tagged<GetUserRequest>(\"GetUserRequest\")\n *\n * const resolver = RequestResolver.make<GetUserRequest>((entries) =>\n * Effect.sync(() => {\n * console.log(`Processing ${entries.length} users`)\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(`User ${entry.request.userId}`))\n * }\n * })\n * )\n *\n * // Group requests by department for more efficient processing\n * const groupedResolver = RequestResolver.grouped(\n * resolver,\n * ({ request }) => request.department\n * )\n *\n * // Requests for the same department will be batched together\n * const requests = [\n * Effect.request(\n * GetUserRequest({ userId: 1, department: \"Engineering\" }),\n * groupedResolver\n * ),\n * Effect.request(\n * GetUserRequest({ userId: 2, department: \"Engineering\" }),\n * groupedResolver\n * ),\n * Effect.request(\n * GetUserRequest({ userId: 3, department: \"Marketing\" }),\n * groupedResolver\n * )\n * ]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const grouped = /*#__PURE__*/dual(2, (self, f) => makeWith({\n ...self,\n batchKey: hashGroupKey(f)\n}));\n/**\n * Returns a request resolver that sends each batch to both resolvers and\n * completes with the first resolver to finish.\n *\n * **Details**\n *\n * The losing resolver run is interrupted after the winning resolver completes\n * the batch.\n *\n * **Example** (Racing request resolvers)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * readonly id: number\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * // Fast resolver (simulating cache)\n * const fastResolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.gen(function*() {\n * yield* Effect.sleep(\"10 millis\")\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(`fast-${entry.request.id}`))\n * }\n * })\n * )\n *\n * // Slow resolver (simulating database)\n * const slowResolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.gen(function*() {\n * yield* Effect.sleep(\"100 millis\")\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(`slow-${entry.request.id}`))\n * }\n * })\n * )\n *\n * // Race resolvers - will use whichever completes first\n * const racingResolver = RequestResolver.race(fastResolver, slowResolver)\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const race = /*#__PURE__*/dual(2, (self, that) => make((requests, key) => effect.race(self.runAll(requests, key), that.runAll(requests, key))));\n/**\n * Adds a tracing span to the request resolver, which will also add any span\n * links from the request's.\n *\n * **Example** (Adding a tracing span)\n *\n * ```ts\n * import { Effect, Exit, Request, RequestResolver } from \"effect\"\n *\n * interface GetDataRequest extends Request.Request<string> {\n * readonly _tag: \"GetDataRequest\"\n * readonly id: number\n * }\n * const GetDataRequest = Request.tagged<GetDataRequest>(\"GetDataRequest\")\n *\n * const resolver = RequestResolver.make<GetDataRequest>((entries) =>\n * Effect.sync(() => {\n * for (const entry of entries) {\n * entry.completeUnsafe(Exit.succeed(`data-${entry.request.id}`))\n * }\n * })\n * )\n *\n * // Add tracing span with custom name and attributes\n * const tracedResolver = RequestResolver.withSpan(\n * resolver,\n * \"user-data-resolver\",\n * {\n * attributes: {\n * \"resolver.type\": \"user-data\",\n * \"resolver.version\": \"1.0\"\n * }\n * }\n * )\n *\n * // Spans will automatically include batch size and request links\n * const effect = Effect.request(GetDataRequest({ id: 123 }), tracedResolver)\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const withSpan = /*#__PURE__*/dual(args => isRequestResolver(args[0]), (self, name, options) => makeWith({\n ...self,\n runAll: (entries, key) => Effect.suspend(() => {\n const opts = typeof options === \"function\" ? options(entries) : options;\n const links = opts?.links ? opts.links.slice() : [];\n const seen = new Set();\n for (const entry of entries) {\n const span = Context.getOption(entry.context, Tracer.ParentSpan);\n if (span._tag === \"None\" || seen.has(span.value)) continue;\n seen.add(span.value);\n links.push({\n span: span.value,\n attributes: {}\n });\n }\n return Effect.withSpan(self.runAll(entries, key), name, {\n ...options,\n links,\n attributes: {\n batchSize: entries.length,\n ...opts?.attributes\n }\n });\n })\n}));\n/**\n * Wraps a request resolver in a cache, allowing it to cache results up to a\n * specified capacity and optional time-to-live.\n *\n * **When to use**\n *\n * Use to turn a request resolver into a first-class `Cache` when callers need\n * cache lookup, refresh, invalidation, or inspection around request results.\n *\n * **Details**\n *\n * The request value is the cache key. Cache misses run the resolver via\n * `Effect.request`, `timeToLive` receives the request `Exit` and the request,\n * and `requireServicesAt` controls whether services are required at lookup time\n * or construction time.\n *\n * **Gotchas**\n *\n * Cache hits depend on the request value's equality semantics.\n *\n * @see {@link withCache} for keeping caching behind a resolver used with `Effect.request`\n * @see {@link persisted} for storing persistable request results outside process memory\n * @see {@link Cache.Cache} for operations available on the returned cache\n *\n * @category caching\n * @since 4.0.0\n */\nexport const asCache = /*#__PURE__*/dual(2, (self, options) => Cache.makeWith(req => internal.request(req, self), {\n capacity: options.capacity,\n timeToLive: options.timeToLive,\n requireServicesAt: options.requireServicesAt ?? \"lookup\"\n}));\n/**\n * Adds a bounded in-memory cache to a request resolver.\n *\n * **When to use**\n *\n * Use to reuse completed results for repeated equal request values while still\n * passing a `RequestResolver` to `Effect.request`.\n *\n * **Details**\n *\n * Running the returned effect creates the cache and returns a wrapped resolver.\n * The cache stores completed success or failure results by request equality up\n * to `capacity`. The `strategy` option controls eviction order and defaults to\n * `\"lru\"`; `\"fifo\"` keeps insertion order.\n *\n * **Gotchas**\n *\n * Entries do not expire by time, and completed failures are cached the same as\n * successes. Request equality controls cache hits.\n *\n * @see {@link asCache} for exposing the resolver as a `Cache` with time-to-live and service lookup controls\n * @see {@link persisted} for backing persistable requests with the configured persistence store\n *\n * @category caching\n * @since 4.0.0\n */\nexport const withCache = /*#__PURE__*/dual(2, (self, options) => Effect.sync(() => {\n const strategy = options.strategy ?? \"lru\";\n const cache = MutableHashMap.empty();\n return makeWith({\n ...self,\n runAll(entries, key) {\n return Effect.onExit(self.runAll(entries, key), () => {\n let toRemove = MutableHashMap.size(cache) - options.capacity;\n if (toRemove <= 0) return Effect.void;\n for (const k of MutableHashMap.keys(cache)) {\n MutableHashMap.remove(cache, k);\n toRemove--;\n if (toRemove <= 0) break;\n }\n return Effect.void;\n });\n },\n preCheck(entry) {\n const ocached = MutableHashMap.get(cache, entry.request);\n if (ocached._tag === \"None\") {\n const cached = {\n entry,\n exit: undefined\n };\n MutableHashMap.set(cache, entry.request, cached);\n const prevComplete = entry.completeUnsafe;\n entry.completeUnsafe = function (exit) {\n cached.exit = exit;\n prevComplete(exit);\n };\n return true;\n }\n const cached = ocached.value;\n if (cached.exit) {\n if (strategy === \"lru\") {\n MutableHashMap.remove(cache, cached.entry.request);\n MutableHashMap.set(cache, cached.entry.request, cached);\n }\n entry.completeUnsafe(cached.exit);\n } else {\n cached.entry.uninterruptible = true;\n const prevComplete = cached.entry.completeUnsafe;\n cached.entry.completeUnsafe = function (exit) {\n prevComplete(exit);\n entry.completeUnsafe(exit);\n };\n }\n return false;\n }\n });\n}));\n/**\n * Wraps a request resolver with persistent storage for persistable requests.\n *\n * **When to use**\n *\n * Use to keep a `RequestResolver` interface while reusing completed\n * `Persistable` request results through a `Persistence` store.\n *\n * **Details**\n *\n * Cached results are loaded from the configured persistence store before\n * running the underlying resolver. Missing entries are resolved normally and\n * written back to the store. Entries marked stale by `staleWhileRevalidate`\n * receive the stored result and are also resolved again so the refreshed result\n * can be written back to the store. Creating the persisted resolver requires\n * `Persistence.Persistence` and `Scope`.\n *\n * @see {@link withCache} for in-memory resolver caching that does not require persistable request values or a persistence store\n * @see {@link asCache} for exposing resolver results through a `Cache` instead of returning another resolver\n *\n * @category Persistence\n * @since 4.0.0\n */\nexport const persisted = /*#__PURE__*/dual(2, /*#__PURE__*/Effect.fnUntraced(function* (self, options) {\n const store = yield* (yield* Persistence.Persistence).make(options);\n return makeWith({\n ...self,\n runAll: Effect.fnUntraced(function* (entries, key) {\n const results = yield* store.getMany(Iterable.map(entries, _ => _.request)).pipe(Effect.provideContext(entries[0].context));\n const leftover = [];\n const toPersist = new Map();\n for (let i = 0; i < results.length; i++) {\n const entry = entries[i];\n const exit = results[i];\n if (exit === undefined || options.staleWhileRevalidate && options.staleWhileRevalidate(exit, entry.request)) {\n const prevComplete = entry.completeUnsafe;\n entry.completeUnsafe = function (exit) {\n toPersist.set(entry.request, exit);\n prevComplete(exit);\n };\n leftover.push(entry);\n if (exit === undefined) continue;\n }\n entry.completeUnsafe(exit);\n }\n if (!Arr.isArrayNonEmpty(leftover)) {\n return;\n }\n yield* Effect.catchCause(self.runAll(leftover, key), cause => {\n for (let i = 0; i < leftover.length; i++) {\n const entry = leftover[i];\n if (!toPersist.has(entry.request)) continue;\n entry.completeUnsafe(Exit.failCause(cause));\n }\n return Effect.void;\n });\n yield* store.setMany(toPersist).pipe(Effect.provideContext(entries[0].context));\n })\n });\n}));\n//# sourceMappingURL=RequestResolver.js.map","/**\n * Stores mutable state whose updates run one at a time.\n *\n * A `SynchronizedRef<A>` behaves like a `Ref<A>` for reading and simple state\n * storage, but update and modify operations are serialized so each change sees\n * a consistent current value. This is especially useful when the next value is\n * computed by an effect, because the effectful transition is still protected\n * from concurrent updates. This module includes constructors, reads, writes,\n * updates, partial updates, and effectful update helpers.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Option from \"./Option.js\";\nimport * as Ref from \"./Ref.js\";\nimport * as Semaphore from \"./Semaphore.js\";\nconst TypeId = \"~effect/SynchronizedRef\";\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n toJSON() {\n return {\n _id: \"SynchronizedRef\",\n value: this.backing.ref.current\n };\n }\n};\n/**\n * Creates a `SynchronizedRef` synchronously from an initial value.\n *\n * **When to use**\n *\n * Use when you need synchronous `SynchronizedRef` construction outside an\n * Effect workflow.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeUnsafe = value => {\n const self = Object.create(Proto);\n self.semaphore = Semaphore.makeUnsafe(1);\n self.backing = Ref.makeUnsafe(value);\n return self;\n};\n/**\n * Creates a `SynchronizedRef` from an initial value, wrapped in an `Effect`.\n *\n * **When to use**\n *\n * Use to create a `SynchronizedRef` inside an Effect program when later updates\n * may run effects and must be serialized.\n *\n * **Details**\n *\n * The returned effect constructs a fresh `SynchronizedRef` by delegating to\n * `makeUnsafe` when the effect is evaluated.\n *\n * @see {@link makeUnsafe} for synchronous construction when the caller controls safe initialization\n * @see {@link Ref.make} for a plain `Ref` when updates do not need effectful synchronization\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = value => Effect.sync(() => makeUnsafe(value));\n/**\n * Reads the current value synchronously, bypassing the `Effect` API and the\n * ref's semaphore.\n *\n * **When to use**\n *\n * Use when you need immediate synchronous access to a `SynchronizedRef` value\n * in low-level code that can safely read outside an `Effect`.\n *\n * @see {@link get} for the Effect-wrapped read when composing inside Effect programs\n *\n * @category getters\n * @since 4.0.0\n */\nexport const getUnsafe = self => self.backing.ref.current;\n/**\n * Returns an `Effect` that reads the current value of the `SynchronizedRef`.\n *\n * **When to use**\n *\n * Use to read the current value of a `SynchronizedRef` inside an `Effect`\n * program without changing it.\n *\n * @see {@link getUnsafe} for synchronous reads when the caller controls safe access outside `Effect`\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.sync(() => getUnsafe(self));\n/**\n * Sets a new value atomically and returns the previous value, serialized by the\n * ref's semaphore.\n *\n * **When to use**\n *\n * Use to replace a `SynchronizedRef` with a known value when the previous value\n * is also needed.\n *\n * @see {@link set} for setting a value without returning the previous value\n * @see {@link setAndGet} for setting a value and returning the new value\n * @see {@link getAndUpdate} for deriving the new value from the current value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndSet = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Ref.getAndSet(self.backing, value)));\n/**\n * Updates the current value atomically with a function and returns the previous\n * value, serialized by the ref's semaphore.\n *\n * **When to use**\n *\n * Use to run a pure `SynchronizedRef` state update when the previous stored\n * value is also needed.\n *\n * @see {@link update} for updating without returning a value\n * @see {@link updateAndGet} for updating and returning the new value\n * @see {@link getAndUpdateEffect} for effectful updates that return the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdate = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Ref.getAndUpdate(self.backing, f)));\n/**\n * Runs an effectful update atomically while holding the ref's semaphore, sets\n * the new value if the effect succeeds, and returns the previous value.\n *\n * **When to use**\n *\n * Use when you need an effectful `SynchronizedRef` state transition to return\n * the previous stored value.\n *\n * @see {@link getAndUpdate} for pure updates that return the previous value\n * @see {@link updateEffect} for effectful updates without returning a value\n * @see {@link updateAndGetEffect} for effectful updates that return the new value\n * @see {@link modifyEffect} for effectful updates with a custom return value\n * @see {@link getAndUpdateSomeEffect} for conditional effectful updates that return the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdateEffect = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.map(f(value), newValue => {\n self.backing.ref.current = newValue;\n return value;\n });\n})));\n/**\n * Applies a partial update atomically and returns the previous value. If the\n * function returns `Option.some`, the ref is updated; if it returns\n * `Option.none`, the ref is left unchanged.\n *\n * **When to use**\n *\n * Use to return the previous `SynchronizedRef` value while applying a pure\n * conditional update.\n *\n * @see {@link getAndUpdate} for always applying a pure update\n * @see {@link updateSome} for applying a pure conditional update without returning the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdateSome = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Ref.getAndUpdateSome(self, pf)));\n/**\n * Runs an effectful partial update atomically while holding the ref's semaphore\n * and returns the previous value. `Option.some` updates the ref; `Option.none`\n * leaves it unchanged.\n *\n * **When to use**\n *\n * Use to return the previous `SynchronizedRef` value while running an effectful\n * conditional update.\n *\n * @see {@link getAndUpdateSome} for the pure conditional variant\n * @see {@link updateSomeEffect} for effectful conditional updates without returning the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const getAndUpdateSomeEffect = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.flatMap(pf(value), option => {\n if (Option.isNone(option)) {\n return Effect.succeed(value);\n }\n self.backing.ref.current = option.value;\n return Effect.succeed(value);\n });\n})));\n/**\n * Computes a return value and a new ref value atomically, stores the new value,\n * and returns the computed result.\n *\n * **When to use**\n *\n * Use to derive a separate result and the next stored `SynchronizedRef` value\n * from the same current value in one serialized pure update.\n *\n * @see {@link modifyEffect} for effectfully deriving both the result and next stored value\n * @see {@link modifySome} for deriving a result and optionally updating the stored value\n * @see {@link updateAndGet} for returning the new stored value instead of a separate result\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Ref.modify(self.backing, f)));\n/**\n * Runs an effectful modification atomically while holding the ref's semaphore,\n * stores the new value if the effect succeeds, and returns the computed result.\n *\n * **When to use**\n *\n * Use to effectfully compute both a separate return value and the next stored\n * `SynchronizedRef` value in one serialized update.\n *\n * @see {@link modify} for the pure variant\n * @see {@link updateEffect} for effectfully storing a new value without a separate result\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const modifyEffect = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.map(f(value), ([b, a]) => {\n self.backing.ref.current = a;\n return b;\n });\n})));\n/**\n * Computes a return value and an optional new ref value atomically.\n * `Option.some` updates the ref; `Option.none` leaves it unchanged.\n *\n * **When to use**\n *\n * Use to compute a return value while optionally updating a `SynchronizedRef`\n * under its semaphore.\n *\n * @see {@link modify} for always storing a new value\n * @see {@link updateSome} for optional updates without a separate return value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const modifySome = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Ref.modifySome(self.backing, pf)));\n/**\n * Runs an effectful modification atomically while holding the ref's semaphore.\n * The effect computes a return value and an optional new ref value;\n * `Option.some` updates the ref and `Option.none` leaves it unchanged.\n *\n * **When to use**\n *\n * Use to effectfully compute a return value while optionally updating the\n * stored `SynchronizedRef` value.\n *\n * @see {@link modifySome} for the pure variant\n * @see {@link updateSomeEffect} for effectful optional updates without a separate return value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const modifySomeEffect = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.flatMap(pf(value), ([b, maybeA]) => {\n if (Option.isNone(maybeA)) {\n return Effect.succeed(b);\n }\n self.backing.ref.current = maybeA.value;\n return Effect.succeed(b);\n });\n})));\n/**\n * Sets the value of the `SynchronizedRef`, serialized by the ref's semaphore.\n *\n * **When to use**\n *\n * Use to replace the current value of a `SynchronizedRef` with a known value\n * while keeping the write serialized with other synchronized updates.\n *\n * @see {@link getAndSet} for replacing the value when the previous value is needed\n * @see {@link setAndGet} for replacing the value when the new value should be returned\n * @see {@link update} for deriving the next value from the current value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Ref.set(self.backing, value)));\n/**\n * Sets the value of the `SynchronizedRef` and returns the new value.\n *\n * **When to use**\n *\n * Use to replace the current `SynchronizedRef` value with a known value and\n * return that new value.\n *\n * @see {@link set} for setting without returning a value\n * @see {@link getAndSet} for setting while returning the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const setAndGet = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Ref.setAndGet(self.backing, value)));\n/**\n * Updates the value of the `SynchronizedRef` with a function, serialized by the\n * ref's semaphore.\n *\n * **When to use**\n *\n * Use to apply a pure state transition to a `SynchronizedRef` as a serialized\n * `Effect`.\n *\n * @see {@link updateEffect} for effectfully deriving the next value\n * @see {@link updateAndGet} for returning the new stored value\n * @see {@link getAndUpdate} for returning the previous stored value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Ref.update(self.backing, f)));\n/**\n * Runs an effectful update while holding the ref's semaphore and stores the new\n * value if the effect succeeds.\n *\n * **When to use**\n *\n * Use to run an effectful state transition on a `SynchronizedRef` when storing\n * the new value is the only result you need.\n *\n * @see {@link update} for a pure state transition\n * @see {@link getAndUpdateEffect} for returning the previous stored value\n * @see {@link updateAndGetEffect} for returning the new stored value\n * @see {@link modifyEffect} for returning a separate result while storing a new value\n * @see {@link updateSomeEffect} for effectfully applying only some state transitions\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateEffect = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.map(f(value), newValue => {\n self.backing.ref.current = newValue;\n });\n})));\n/**\n * Updates the value of the `SynchronizedRef` with a function and returns the\n * new value.\n *\n * **When to use**\n *\n * Use to apply a pure `SynchronizedRef` state transition and return the new\n * stored value.\n *\n * @see {@link update} for updating without returning the new value\n * @see {@link getAndUpdate} for updating while returning the previous value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateAndGet = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Ref.updateAndGet(self.backing, f)));\n/**\n * Runs an effectful update while holding the ref's semaphore, stores the new\n * value if the effect succeeds, and returns that new value.\n *\n * **When to use**\n *\n * Use to run an effectful `SynchronizedRef` state transition and return the new\n * stored value.\n *\n * @see {@link updateEffect} for effectful updates without returning the new value\n * @see {@link updateAndGet} for the pure variant\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateAndGetEffect = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.map(f(value), newValue => {\n self.backing.ref.current = newValue;\n return newValue;\n });\n})));\n/**\n * Applies a partial update to the current value. `Option.some` stores the new\n * value; `Option.none` leaves the ref unchanged.\n *\n * **When to use**\n *\n * Use to apply a pure conditional `SynchronizedRef` update without returning a\n * value.\n *\n * @see {@link update} for always applying a pure update\n * @see {@link updateSomeAndGet} for returning the resulting current value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateSome = /*#__PURE__*/dual(2, (self, f) => self.semaphore.withPermit(Ref.updateSome(self.backing, f)));\n/**\n * Runs an effectful partial update while holding the ref's semaphore.\n * `Option.some` stores the new value; `Option.none` leaves the ref unchanged.\n *\n * **When to use**\n *\n * Use to run an effectful conditional `SynchronizedRef` update without\n * returning a value.\n *\n * @see {@link updateSome} for the pure conditional variant\n * @see {@link updateEffect} for effectful updates that always store a new value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateSomeEffect = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.map(pf(value), option => {\n if (Option.isNone(option)) {\n return;\n }\n self.backing.ref.current = option.value;\n });\n})));\n/**\n * Applies a partial update and returns the resulting current value.\n * `Option.some` stores and returns the new value; `Option.none` returns the\n * unchanged value.\n *\n * **When to use**\n *\n * Use to apply a pure conditional `SynchronizedRef` update and return the\n * resulting current value.\n *\n * @see {@link updateSome} for conditional updates without returning a value\n * @see {@link updateAndGet} for always applying a pure update and returning the new value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateSomeAndGet = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Ref.updateSomeAndGet(self.backing, pf)));\n/**\n * Runs an effectful partial update while holding the ref's semaphore and\n * returns the resulting current value. `Option.some` stores and returns the new\n * value; `Option.none` returns the unchanged value.\n *\n * **When to use**\n *\n * Use to run an effectful conditional `SynchronizedRef` update and return the\n * resulting current value.\n *\n * @see {@link updateSomeEffect} for effectful conditional updates without returning a value\n * @see {@link updateAndGetEffect} for effectful updates that always store and return a new value\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const updateSomeAndGetEffect = /*#__PURE__*/dual(2, (self, pf) => self.semaphore.withPermit(Effect.suspend(() => {\n const value = getUnsafe(self);\n return Effect.flatMap(pf(value), option => {\n if (Option.isNone(option)) {\n return Effect.succeed(value);\n }\n self.backing.ref.current = option.value;\n return Effect.succeed(option.value);\n });\n})));\n//# sourceMappingURL=SynchronizedRef.js.map","/**\n * Stores a current value together with the scope that owns it.\n *\n * A `ScopedRef<A>` is useful for resource-backed values such as clients,\n * connections, subscriptions, or handles. Replacing the value acquires the\n * replacement in a new scope and releases the resources owned by the previous\n * value. Reads can be effectful or synchronous, and updates are synchronized so\n * only one replacement happens at a time.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport { dual } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Scope from \"./Scope.js\";\nimport * as Synchronized from \"./SynchronizedRef.js\";\nconst TypeId = \"~effect/ScopedRef\";\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n toJSON() {\n return {\n _id: \"ScopedRef\",\n value: this.backing.backing.ref.current[1]\n };\n }\n};\nconst makeUnsafe = (scope, value) => {\n const self = Object.create(Proto);\n self.backing = Synchronized.makeUnsafe([scope, value]);\n return self;\n};\n/**\n * Creates a new `ScopedRef` from an effect that acquires the initial value.\n *\n * **When to use**\n *\n * Use when creating a `ScopedRef` whose initial value requires acquiring\n * resources that must be released.\n *\n * @see {@link make} for creating a `ScopedRef` from a value that does not require resource acquisition\n * @category constructors\n * @since 2.0.0\n */\nexport const fromAcquire = /*#__PURE__*/Effect.fnUntraced(function* (acquire) {\n const scope = Scope.makeUnsafe();\n const value = yield* acquire.pipe(Scope.provide(scope), Effect.tapCause(cause => Scope.close(scope, Exit.failCause(cause))));\n const self = makeUnsafe(scope, value);\n yield* Effect.addFinalizer(exit => Scope.close(self.backing.backing.ref.current[0], exit));\n return self;\n}, Effect.uninterruptible);\n/**\n * Retrieves the current value of the scoped reference synchronously.\n *\n * **When to use**\n *\n * Use when you need immediate synchronous access to the current `ScopedRef`\n * value and can guarantee that reading outside the `Effect` API is safe.\n *\n * @see {@link get} for Effect-wrapped access in Effect programs\n *\n * @category getters\n * @since 4.0.0\n */\nexport const getUnsafe = self => self.backing.backing.ref.current[1];\n/**\n * Retrieves the current value of the scoped reference effectfully.\n *\n * **When to use**\n *\n * Use to read the value currently stored in a `ScopedRef` inside an `Effect`\n * workflow.\n *\n * @see {@link getUnsafe} for reading the current value synchronously when an unsafe read is acceptable\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.sync(() => getUnsafe(self));\n/**\n * Creates a new `ScopedRef` from the specified value.\n *\n * **When to use**\n *\n * Use to create a `ScopedRef` when the initial value is already available or\n * can be produced without acquiring resources.\n *\n * **Details**\n *\n * The `evaluate` function runs when the returned effect runs. The returned\n * effect requires a `Scope`, and the reference closes the currently stored\n * value's scope when that outer scope closes.\n *\n * **Gotchas**\n *\n * Do not use `make` for an initial value whose creation acquires resources; use\n * `fromAcquire` so acquisition and finalization are tracked.\n *\n * @see {@link fromAcquire} for creating a `ScopedRef` from an effect that acquires the initial value\n * @see {@link set} for replacing the current value with a newly acquired value\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = evaluate => Effect.suspend(() => {\n const scope = Scope.makeUnsafe();\n const value = evaluate();\n const self = makeUnsafe(scope, value);\n return Effect.as(Effect.addFinalizer(exit => Scope.close(self.backing.backing.ref.current[0], exit)), self);\n});\n/**\n * Sets the value of this reference to a newly acquired scoped value, releasing\n * any resources associated with the old value.\n *\n * **When to use**\n *\n * Use to replace the current value of an existing `ScopedRef` with a newly\n * acquired scoped value while releasing resources for the previous value.\n *\n * **Details**\n *\n * This method will not return until either the reference is successfully\n * changed to the new value, with old resources released, or until the attempt\n * to acquire a new value fails.\n *\n * @category setters\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(2, /*#__PURE__*/Effect.fnUntraced(function* (self, acquire) {\n yield* Scope.close(self.backing.backing.ref.current[0], Exit.void);\n const scope = Scope.makeUnsafe();\n const value = yield* acquire.pipe(Scope.provide(scope), Effect.tapCause(cause => Scope.close(scope, Exit.failCause(cause))));\n self.backing.backing.ref.current = [scope, value];\n}, Effect.uninterruptible, (effect, self) => self.backing.semaphore.withPermit(effect)));\n//# sourceMappingURL=ScopedRef.js.map","/**\n * Stores refreshable scoped values.\n *\n * A `Resource<A, E>` keeps the latest successful or failed acquisition result.\n * It can be read repeatedly, refreshed manually, or refreshed automatically on a\n * schedule. Resource acquisition runs in a scope, so replacements and final\n * cleanup release the resources owned by previous values.\n *\n * @since 2.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport { identity } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as ScopedRef from \"./ScopedRef.js\";\nconst TypeId = \"~effect/Resource\";\n/**\n * Returns `true` if the specified value is a `Resource`.\n *\n * **When to use**\n *\n * Use to validate unknown values at runtime boundaries before treating them as\n * `Resource` values.\n *\n * **Details**\n *\n * This predicate narrows the input to `Resource<unknown, unknown>`.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isResource = u => hasProperty(u, TypeId);\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n toJSON() {\n return {\n _id: \"Resource\"\n };\n }\n};\nconst makeUnsafe = (scopedRef, acquire) => {\n const self = Object.create(Proto);\n self.scopedRef = scopedRef;\n self.acquire = acquire;\n return self;\n};\n/**\n * Creates a `Resource` that must be refreshed manually.\n *\n * **When to use**\n *\n * Use when you need manual control over resource refresh timing rather than an\n * automatic schedule.\n *\n * @see {@link auto} for schedule-driven automatic refreshes\n * @see {@link refresh} to manually trigger a resource refresh\n * @category constructors\n * @since 2.0.0\n */\nexport const manual = acquire => Effect.contextWith(context => {\n const providedAcquire = Effect.updateContext(acquire, input => Context.merge(context, input));\n return Effect.map(ScopedRef.fromAcquire(Effect.exit(providedAcquire)), scopedRef => makeUnsafe(scopedRef, providedAcquire));\n});\n/**\n * Creates a `Resource` that refreshes automatically according to the supplied\n * schedule.\n *\n * **When to use**\n *\n * Use when a resource should refresh in the background according to a schedule\n * for the lifetime of its scope.\n *\n * @see {@link manual} for caller-controlled refresh timing\n * @see {@link refresh} to trigger a refresh explicitly\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const auto = (acquire, policy) => Effect.tap(manual(acquire), self => Effect.forkScoped(Effect.repeat(refresh(self), policy)));\n/**\n * Retrieves the current value stored in this resource.\n *\n * **When to use**\n *\n * Use to read the value currently cached by a `Resource`.\n *\n * **Gotchas**\n *\n * If the resource currently stores a failed acquisition result, the returned\n * effect fails with the stored error.\n *\n * @see {@link refresh} to re-run acquisition and update the stored value before a later read\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.flatMap(ScopedRef.get(self.scopedRef), identity);\n/**\n * Re-runs this resource's acquisition effect and updates the current value.\n *\n * **When to use**\n *\n * Use to force an existing `Resource` to reacquire its value at a\n * caller-controlled point.\n *\n * **Details**\n *\n * When acquisition succeeds, refreshing replaces the value stored in the\n * resource's scoped reference and releases resources associated with the\n * previous value.\n *\n * **Gotchas**\n *\n * If acquisition fails, the returned effect fails and the previously stored\n * result is left as what `get` reads.\n *\n * @see {@link get} for reading the current stored value\n * @see {@link manual} for resources refreshed only by caller action\n * @see {@link auto} for schedule-driven automatic refreshes\n *\n * @category resource management\n * @since 2.0.0\n */\nexport const refresh = self => ScopedRef.set(self.scopedRef, Effect.map(self.acquire, Exit.succeed));\n//# sourceMappingURL=Resource.js.map","/**\n * Helpers for turning an `Effect` program into a host application's main entry\n * point. This module is the low-level layer used by platform adapters to run a\n * main effect, observe its fiber, report unhandled failures, and translate the\n * resulting `Exit` into an application or process exit code. It provides\n * `makeRunMain`, the default teardown behavior, and error markers for custom\n * exit codes and already-reported failures. Application code usually calls the\n * platform-provided runner instead of using this module directly.\n *\n * @since 4.0.0\n */\nimport * as Cause from \"effect/Cause\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport { constVoid, dual } from \"effect/Function\";\n/**\n * The default teardown function that determines exit codes from an Effect exit.\n *\n * **When to use**\n *\n * Use as the standard teardown for main programs with conventional process\n * exit codes and support for {@link errorExitCode}.\n *\n * **Details**\n *\n * This teardown follows these exit-code rules:\n *\n * - `0` for successful completion.\n * - `130` for interruption-only failures.\n * - The squashed error's {@link errorExitCode} value for other failures when\n * present.\n * - `1` for other failures.\n *\n * **Gotchas**\n *\n * The `130` code is used only when the Cause contains interruptions and no\n * other failure reasons. Mixed causes use the squashed error path instead.\n *\n * **Example** (Referencing default teardown)\n *\n * ```ts\n * import { Exit, Runtime } from \"effect\"\n *\n * const logExitCode = (exit: Exit.Exit<any, any>) => {\n * Runtime.defaultTeardown(exit, (code) => {\n * console.log(`Exit code: ${code}`)\n * })\n * }\n *\n * logExitCode(Exit.succeed(42))\n * // Output: Exit code: 0\n *\n * logExitCode(Exit.fail(\"error\"))\n * // Output: Exit code: 1\n *\n * logExitCode(Exit.interrupt(123))\n * // Output: Exit code: 130\n * ```\n *\n * @see {@link errorExitCode} for customizing failure exit codes\n *\n * @category running\n * @since 4.0.0\n */\nexport const defaultTeardown = (exit, onExit) => {\n if (Exit.isSuccess(exit)) return onExit(0);\n if (Cause.hasInterruptsOnly(exit.cause)) return onExit(130);\n return onExit(getErrorExitCode(Cause.squash(exit.cause)));\n};\n/**\n * Creates a platform-specific main program runner that handles Effect execution lifecycle.\n *\n * **When to use**\n *\n * Use when building a runtime adapter for a host platform.\n *\n * **Details**\n *\n * The runner executes Effect programs as main entry points. The provided\n * function receives a forked fiber and a teardown callback so it can install\n * platform-specific signal handling, fiber observers, and final exit behavior.\n *\n * Most applications should use a platform-provided runner, such as\n * `NodeRuntime.runMain`, rather than constructing one directly.\n *\n * `disableErrorReporting` disables the automatic log emitted for unreported\n * non-interruption failures. It does not change exit-code calculation or the\n * custom teardown callback.\n *\n * **Gotchas**\n *\n * The setup function is responsible for observing the fiber and eventually\n * invoking teardown. `makeRunMain` also tries to keep the host process alive\n * with a long interval while the main fiber is running; if the host blocks\n * timers, the runner still starts but cannot use that keep-alive fallback.\n *\n * **Example** (Creating platform runners)\n *\n * ```ts\n * import { Effect, Fiber, Runtime } from \"effect\"\n *\n * // Create a simple runner for a hypothetical platform\n * const runMain = Runtime.makeRunMain(({ fiber, teardown }) => {\n * // Set up signal handling\n * const handleSignal = () => {\n * Effect.runSync(Fiber.interrupt(fiber))\n * }\n *\n * // Add signal listeners (platform-specific)\n * // process.on('SIGINT', handleSignal)\n * // process.on('SIGTERM', handleSignal)\n *\n * // Handle fiber completion\n * fiber.addObserver((exit) => {\n * teardown(exit, (code) => {\n * console.log(`Program finished with exit code: ${code}`)\n * // process.exit(code)\n * })\n * })\n * })\n *\n * // Use the runner\n * const program = Effect.gen(function*() {\n * yield* Effect.log(\"Starting program\")\n * yield* Effect.sleep(1000)\n * yield* Effect.log(\"Program completed\")\n * return \"success\"\n * })\n *\n * // Run with default options\n * runMain(program)\n *\n * // Run with custom teardown\n * runMain(program, {\n * teardown: (exit, onExit) => {\n * console.log(\"Custom teardown logic\")\n * Runtime.defaultTeardown(exit, onExit)\n * }\n * })\n * ```\n *\n * @category running\n * @since 4.0.0\n */\nexport const makeRunMain = f => dual(args => Effect.isEffect(args[0]), (effect, options) => {\n const fiber = options?.disableErrorReporting === true ? Effect.runFork(effect) : Effect.runFork(Effect.tapCause(effect, cause => {\n if (Cause.hasInterruptsOnly(cause)) return Effect.void;\n const isReported = getErrorReported(Cause.squash(cause));\n return isReported ? Effect.logError(cause) : Effect.void;\n }));\n try {\n const keepAlive = globalThis.setInterval(constVoid, 2_147_483_647);\n fiber.addObserver(() => {\n clearInterval(keepAlive);\n });\n } catch {}\n const teardown = options?.teardown ?? defaultTeardown;\n return f({\n fiber,\n teardown\n });\n});\n/**\n * Allows associating an exit code with an error for determining the process\n * exit code on failure.\n *\n * **When to use**\n *\n * Use when error classes should map failures to a specific process exit code\n * when handled by {@link defaultTeardown}.\n *\n * **Details**\n *\n * Attach this marker as a readonly property on an error object. When the main\n * program fails, {@link defaultTeardown} squashes the Cause and reads the marker\n * from the resulting error value.\n *\n * **Gotchas**\n *\n * The marker is read from the squashed failure value. If a Cause contains\n * multiple failures, the selected squashed error determines the exit code.\n *\n * **Example** (Setting a process exit code)\n *\n * ```ts\n * import { Data, Effect, Runtime } from \"effect\"\n * import { NodeRuntime } from \"@effect/platform-node\"\n *\n * class MyError extends Data.TaggedError(\"MyError\") {\n * readonly [Runtime.errorExitCode] = 42\n * }\n *\n * // If the program fails with MyError, the process will exit with code 42\n * NodeRuntime.runMain(Effect.fail(new MyError()))\n * ```\n *\n * @see {@link errorReported} for controlling automatic error logging\n * @see {@link defaultTeardown} for the default failure exit-code rules that read this marker\n * @see {@link getErrorExitCode} for reading the marker from unknown error values\n *\n * @category symbols\n * @since 4.0.0\n */\nexport const errorExitCode = \"~effect/Runtime/errorExitCode\";\n/**\n * Reads the runtime exit-code marker from an unknown error value.\n *\n * **When to use**\n *\n * Use to read a custom failure exit code from an unknown error value, falling\n * back to the default failure code.\n *\n * **Details**\n *\n * Returns the numeric `[Runtime.errorExitCode]` property when it is present on\n * an object. Otherwise returns `1`, the default failure exit code used by\n * `defaultTeardown`.\n *\n * **Gotchas**\n *\n * Non-object values, missing markers, and non-number marker values all return\n * `1`.\n *\n * @see {@link errorExitCode} for the marker read by this function\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const getErrorExitCode = u => {\n if (typeof u === \"object\" && u !== null && errorExitCode in u) {\n const code = u[errorExitCode];\n if (typeof code === \"number\") {\n return code;\n }\n }\n return 1;\n};\n/**\n * Defines the runtime marker that controls default `runMain` error logging for an error.\n *\n * **When to use**\n *\n * Use when you need error classes reported by application code to avoid being\n * logged again by the default main runner.\n *\n * **Details**\n *\n * Set `[Runtime.errorReported]` to `false` on an error object to suppress the\n * runtime log because the error has already been reported. Omitted or\n * non-boolean values are treated as `true`, so failures are logged by default.\n *\n * **Gotchas**\n *\n * This marker controls only automatic error logging. It does not change the\n * failure Cause or the process exit code.\n * `makeRunMain` reads the marker from `Cause.squash(cause)`, so for causes\n * with multiple failures, the squashed error determines whether default logging\n * is suppressed.\n *\n * **Example** (Suppressing error reporting)\n *\n * ```ts\n * import { Data, Effect, Runtime } from \"effect\"\n * import { NodeRuntime } from \"@effect/platform-node\"\n *\n * class MyError extends Data.TaggedError(\"MyError\") {\n * readonly [Runtime.errorReported] = false\n * }\n *\n * // If the program fails with MyError, the process will exit with code 1 but\n * // no error will be logged.\n * NodeRuntime.runMain(Effect.fail(new MyError()))\n * ```\n *\n * @see {@link errorExitCode} for controlling failure exit codes\n * @see {@link getErrorReported} for reading the marker from unknown error values\n *\n * @category symbols\n * @since 4.0.0\n */\nexport const errorReported = \"~effect/Runtime/errorReported\";\n/**\n * Reads the runtime error-reporting marker from an unknown error value.\n *\n * **When to use**\n *\n * Use to read whether an unknown error value should be treated as already\n * reported by the default main runner.\n *\n * **Details**\n *\n * Returns a boolean `[Runtime.errorReported]` property when it is present on an\n * object. Otherwise returns `true`, so failures are logged by default.\n *\n * **Gotchas**\n *\n * Non-object values, missing markers, and non-boolean marker values all return\n * `true`.\n *\n * @see {@link errorReported} for the marker read by this function\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const getErrorReported = u => {\n if (typeof u === \"object\" && u !== null && errorReported in u) {\n const isReported = u[errorReported];\n if (typeof isReported === \"boolean\") {\n return isReported;\n }\n }\n return true;\n};\n//# sourceMappingURL=Runtime.js.map","/**\n * Plain data structures for describing schemas in a serializable form. A\n * `Representation` is not the original `Schema` object; it is a JSON-friendly\n * description of the schema's types, fields, unions, checks, annotations, and\n * references.\n *\n * This module defines the representation node types, document types, and\n * codecs used to validate those documents. It can build representation\n * documents from schema ASTs, turn representation documents back into schemas,\n * convert them to and from JSON Schema documents, and generate TypeScript code\n * artifacts for schema definitions.\n *\n * @since 4.0.0\n */\nimport * as Arr from \"./Array.js\";\nimport { format, formatPropertyKey } from \"./Formatter.js\";\nimport { collectBrands } from \"./internal/schema/annotations.js\";\nimport * as InternalRepresentation from \"./internal/schema/representation.js\";\nimport { unescapeToken } from \"./JsonPointer.js\";\nimport * as Option from \"./Option.js\";\nimport * as Predicate from \"./Predicate.js\";\nimport * as Rec from \"./Record.js\";\nimport * as Schema from \"./Schema.js\";\nimport * as SchemaAST from \"./SchemaAST.js\";\nimport * as SchemaGetter from \"./SchemaGetter.js\";\n// -----------------------------------------------------------------------------\n// schemas\n// -----------------------------------------------------------------------------\nconst Representation$ref = /*#__PURE__*/Schema.suspend(() => $Representation);\nconst toJsonAnnotationsBlacklist = /*#__PURE__*/new Set([...InternalRepresentation.fromASTBlacklist, \"expected\", \"contentMediaType\", \"contentSchema\"]);\n/**\n * Schema for {@link PrimitiveTree}.\n *\n * **When to use**\n *\n * Use to validate recursive annotation metadata trees whose leaves are `null`,\n * `number`, `boolean`, `bigint`, `symbol`, or `string`.\n *\n * @see {@link PrimitiveTree} for the recursive tree type accepted by this codec\n * @see {@link $Annotations} for the annotation codec that filters values through this codec\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $PrimitiveTree = /*#__PURE__*/Schema.Tree(/*#__PURE__*/Schema.Union([Schema.Null, Schema.Number,\n// allows NaN, Infinity, -Infinity\nSchema.Boolean, Schema.BigInt, Schema.Symbol, Schema.String]));\nconst isPrimitiveTree = /*#__PURE__*/Schema.is($PrimitiveTree);\n/**\n * Schema for serializing public `Schema.Annotations.Annotations` values. It\n * filters out internal annotation keys and non-primitive values during\n * encoding.\n *\n * **When to use**\n *\n * Use to serialize schema annotations in representation schemas while retaining\n * only primitive-tree metadata.\n *\n * **Details**\n *\n * Decoding is passthrough. Encoding removes internal annotation keys and values\n * that are not accepted by `$PrimitiveTree`.\n *\n * @see {@link $PrimitiveTree} for the codec used to filter annotation values\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Annotations = /*#__PURE__*/Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.encodeTo(Schema.Record(Schema.String, $PrimitiveTree), {\n decode: SchemaGetter.passthrough(),\n encode: SchemaGetter.transformOptional(Option.flatMap(r => {\n const out = {};\n for (const [k, v] of Object.entries(r)) {\n if (!toJsonAnnotationsBlacklist.has(k) && isPrimitiveTree(v)) {\n out[k] = v;\n }\n }\n return Rec.isEmptyRecord(out) ? Option.none() : Option.some(out);\n }))\n})).annotate({\n identifier: \"Annotations\"\n});\n/**\n * Schema for the {@link Null} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Null = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Null\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Null\"\n});\n/**\n * Schema for the {@link Undefined} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Undefined = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Undefined\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Undefined\"\n});\n/**\n * Schema for the {@link Void} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Void = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Void\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Void\"\n});\n/**\n * Schema for the {@link Never} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Never = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Never\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Never\"\n});\n/**\n * Schema for the {@link Unknown} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Unknown = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Unknown\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Unknown\"\n});\n/**\n * Schema for the {@link Any} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Any = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Any\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Any\"\n});\nconst $IsStringFinite = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isStringFinite\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsStringFinite\"\n});\nconst $IsStringBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isStringBigInt\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsStringBigInt\"\n});\nconst $IsStringSymbol = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isStringSymbol\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsStringSymbol\"\n});\nconst $IsTrimmed = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isTrimmed\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsTrimmed\"\n});\nconst $IsUUID = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isUUID\"),\n regExp: Schema.RegExp,\n version: Schema.UndefinedOr(Schema.Literals([1, 2, 3, 4, 5, 6, 7, 8]))\n}).annotate({\n identifier: \"IsUUID\"\n});\nconst $IsGUID = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGUID\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsGUID\"\n});\nconst $IsULID = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isULID\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsULID\"\n});\nconst $IsBase64 = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isBase64\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsBase64\"\n});\nconst $IsBase64Url = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isBase64Url\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsBase64Url\"\n});\nconst $IsStartsWith = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isStartsWith\"),\n startsWith: Schema.String,\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsStartsWith\"\n});\nconst $IsEndsWith = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isEndsWith\"),\n endsWith: Schema.String,\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsEndsWith\"\n});\nconst $IsIncludes = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isIncludes\"),\n includes: Schema.String,\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsIncludes\"\n});\nconst $IsUppercased = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isUppercased\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsUppercased\"\n});\nconst $IsLowercased = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLowercased\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsLowercased\"\n});\nconst $IsCapitalized = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isCapitalized\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsCapitalized\"\n});\nconst $IsUncapitalized = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isUncapitalized\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsUncapitalized\"\n});\nconst NonNegativeInt = /*#__PURE__*/Schema.Int.check(/*#__PURE__*/Schema.isGreaterThanOrEqualTo(0));\nconst $IsMinLength = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMinLength\"),\n minLength: NonNegativeInt\n}).annotate({\n identifier: \"IsMinLength\"\n});\nconst $IsMaxLength = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMaxLength\"),\n maxLength: NonNegativeInt\n}).annotate({\n identifier: \"IsMaxLength\"\n});\nconst $IsLengthBetween = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLengthBetween\"),\n minimum: NonNegativeInt,\n maximum: NonNegativeInt\n}).annotate({\n identifier: \"IsLengthBetween\"\n});\nconst $IsPattern = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isPattern\"),\n regExp: Schema.RegExp\n}).annotate({\n identifier: \"IsPattern\"\n});\n/**\n * Schema for {@link StringMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $StringMeta = /*#__PURE__*/Schema.Union([$IsStringFinite, $IsStringBigInt, $IsStringSymbol, $IsTrimmed, $IsUUID, $IsGUID, $IsULID, $IsBase64, $IsBase64Url, $IsStartsWith, $IsEndsWith, $IsIncludes, $IsUppercased, $IsLowercased, $IsCapitalized, $IsUncapitalized, $IsMinLength, $IsMaxLength, $IsPattern, $IsLengthBetween]).annotate({\n identifier: \"StringMeta\"\n});\nfunction makeCheck(meta, identifier) {\n const Check$ref = Schema.suspend(() => Check);\n const Check = Schema.Union([Schema.Struct({\n _tag: Schema.tag(\"Filter\"),\n annotations: Schema.optional($Annotations),\n meta\n }).annotate({\n identifier: `${identifier}Filter`\n }), Schema.Struct({\n _tag: Schema.tag(\"FilterGroup\"),\n annotations: Schema.optional($Annotations),\n checks: Schema.NonEmptyArray(Check$ref)\n }).annotate({\n identifier: `${identifier}FilterGroup`\n })]).annotate({\n identifier: `${identifier}Check`\n });\n return Check;\n}\n/**\n * Schema for the {@link String} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $String = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"String\"),\n annotations: Schema.optional($Annotations),\n checks: Schema.Array(makeCheck($StringMeta, \"String\")),\n contentMediaType: Schema.optional(Schema.String),\n contentSchema: Schema.optional(Representation$ref)\n}).annotate({\n identifier: \"String\"\n});\nconst $IsInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isInt\")\n}).annotate({\n identifier: \"IsInt\"\n});\nconst $IsMultipleOf = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMultipleOf\"),\n divisor: Schema.Finite\n}).annotate({\n identifier: \"IsMultipleOf\"\n});\nconst $IsFinite = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isFinite\")\n}).annotate({\n identifier: \"IsFinite\"\n});\nconst $IsGreaterThan = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThan\"),\n exclusiveMinimum: Schema.Finite\n}).annotate({\n identifier: \"IsGreaterThan\"\n});\nconst $IsGreaterThanOrEqualTo = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThanOrEqualTo\"),\n minimum: Schema.Finite\n}).annotate({\n identifier: \"IsGreaterThanOrEqualTo\"\n});\nconst $IsLessThan = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThan\"),\n exclusiveMaximum: Schema.Finite\n}).annotate({\n identifier: \"IsLessThan\"\n});\nconst $IsLessThanOrEqualTo = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThanOrEqualTo\"),\n maximum: Schema.Finite\n}).annotate({\n identifier: \"IsLessThanOrEqualTo\"\n});\nconst $IsBetween = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isBetween\"),\n minimum: Schema.Finite,\n maximum: Schema.Finite,\n exclusiveMinimum: Schema.optional(Schema.Boolean),\n exclusiveMaximum: Schema.optional(Schema.Boolean)\n}).annotate({\n identifier: \"IsBetween\"\n});\n/**\n * Schema for {@link NumberMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $NumberMeta = /*#__PURE__*/Schema.Union([$IsInt, $IsMultipleOf, $IsFinite, $IsGreaterThan, $IsGreaterThanOrEqualTo, $IsLessThan, $IsLessThanOrEqualTo, $IsBetween]).annotate({\n identifier: \"NumberMeta\"\n});\n/**\n * Schema for the {@link Number} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Number = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Number\"),\n annotations: Schema.optional($Annotations),\n checks: Schema.Array(makeCheck($NumberMeta, \"Number\"))\n}).annotate({\n identifier: \"Number\"\n});\n/**\n * Schema for the {@link Boolean} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Boolean = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Boolean\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Boolean\"\n});\nconst $IsGreaterThanBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThanBigInt\"),\n exclusiveMinimum: Schema.BigInt\n}).annotate({\n identifier: \"IsGreaterThanBigInt\"\n});\nconst $IsGreaterThanOrEqualToBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThanOrEqualToBigInt\"),\n minimum: Schema.BigInt\n}).annotate({\n identifier: \"IsGreaterThanOrEqualToBigInt\"\n});\nconst $IsLessThanBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThanBigInt\"),\n exclusiveMaximum: Schema.BigInt\n}).annotate({\n identifier: \"IsLessThanBigInt\"\n});\nconst $IsLessThanOrEqualToBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThanOrEqualToBigInt\"),\n maximum: Schema.BigInt\n}).annotate({\n identifier: \"IsLessThanOrEqualToBigInt\"\n});\nconst $IsBetweenBigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isBetweenBigInt\"),\n minimum: Schema.BigInt,\n maximum: Schema.BigInt,\n exclusiveMinimum: Schema.optional(Schema.Boolean),\n exclusiveMaximum: Schema.optional(Schema.Boolean)\n}).annotate({\n identifier: \"IsBetweenBigInt\"\n});\nconst $BigIntMeta = /*#__PURE__*/Schema.Union([$IsGreaterThanBigInt, $IsGreaterThanOrEqualToBigInt, $IsLessThanBigInt, $IsLessThanOrEqualToBigInt, $IsBetweenBigInt]).annotate({\n identifier: \"BigIntMeta\"\n});\n/**\n * Schema for the {@link BigInt} representation node.\n *\n * **When to use**\n *\n * Use to encode, decode, or validate serialized `BigInt` representation nodes,\n * not application `bigint` values.\n *\n * **Details**\n *\n * Accepts representation nodes with `_tag: \"BigInt\"`, optional annotations,\n * and bigint-specific validation metadata in `checks`.\n *\n * @see {@link BigIntMeta} for the metadata accepted by the `checks` array\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $BigInt = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"BigInt\"),\n annotations: Schema.optional($Annotations),\n checks: Schema.Array(makeCheck($BigIntMeta, \"BigInt\"))\n}).annotate({\n identifier: \"BigInt\"\n});\n/**\n * Schema for the {@link Symbol} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Symbol = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Symbol\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Symbol\"\n});\n/**\n * Schema for the literal value types allowed in a {@link Literal} node\n * (string, finite number, boolean, or bigint).\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $LiteralValue = /*#__PURE__*/Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]).annotate({\n identifier: \"LiteralValue\"\n});\n/**\n * Schema for the {@link Literal} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Literal = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Literal\"),\n annotations: Schema.optional($Annotations),\n literal: $LiteralValue\n}).annotate({\n identifier: \"Literal\"\n});\n/**\n * Schema for the {@link UniqueSymbol} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $UniqueSymbol = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"UniqueSymbol\"),\n annotations: Schema.optional($Annotations),\n symbol: Schema.Symbol\n}).annotate({\n identifier: \"UniqueSymbol\"\n});\n/**\n * Schema for the {@link ObjectKeyword} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $ObjectKeyword = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"ObjectKeyword\"),\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"ObjectKeyword\"\n});\n/**\n * Schema for the {@link Enum} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Enum = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Enum\"),\n annotations: Schema.optional($Annotations),\n enums: Schema.Array(Schema.Tuple([Schema.String, Schema.Union([Schema.String, Schema.Number // NaN, Infinity, -Infinity are allowed enum values\n ])]))\n}).annotate({\n identifier: \"Enum\"\n});\n/**\n * Schema for the {@link TemplateLiteral} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $TemplateLiteral = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"TemplateLiteral\"),\n annotations: Schema.optional($Annotations),\n parts: Schema.Array(Representation$ref)\n}).annotate({\n identifier: \"TemplateLiteral\"\n});\n/**\n * Schema for the {@link Element} type (positional tuple element).\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Element = /*#__PURE__*/Schema.Struct({\n isOptional: Schema.Boolean,\n type: Representation$ref,\n annotations: Schema.optional($Annotations)\n}).annotate({\n identifier: \"Element\"\n});\nconst $IsUnique = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isUnique\")\n}).annotate({\n identifier: \"IsUnique\"\n});\nconst $ArraysMeta = /*#__PURE__*/Schema.Union([$IsMinLength, $IsMaxLength, $IsLengthBetween, $IsUnique]).annotate({\n identifier: \"ArraysMeta\"\n});\n/**\n * Schema for the {@link Arrays} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Arrays = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Arrays\"),\n annotations: Schema.optional($Annotations),\n elements: Schema.Array($Element),\n rest: Schema.Array(Representation$ref),\n checks: Schema.Array(makeCheck($ArraysMeta, \"Arrays\"))\n}).annotate({\n identifier: \"Arrays\"\n});\n/**\n * Schema for the {@link PropertySignature} type.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $PropertySignature = /*#__PURE__*/Schema.Struct({\n annotations: Schema.optional($Annotations),\n name: Schema.PropertyKey,\n type: Representation$ref,\n isOptional: Schema.Boolean,\n isMutable: Schema.Boolean\n}).annotate({\n identifier: \"PropertySignature\"\n});\n/**\n * Schema for the {@link IndexSignature} type.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $IndexSignature = /*#__PURE__*/Schema.Struct({\n parameter: Representation$ref,\n type: Representation$ref\n}).annotate({\n identifier: \"IndexSignature\"\n});\nconst $IsMinProperties = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMinProperties\"),\n minProperties: NonNegativeInt\n}).annotate({\n identifier: \"IsMinProperties\"\n});\nconst $IsMaxProperties = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMaxProperties\"),\n maxProperties: NonNegativeInt\n}).annotate({\n identifier: \"IsMaxProperties\"\n});\nconst $IsPropertiesLengthBetween = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isPropertiesLengthBetween\"),\n minimum: NonNegativeInt,\n maximum: NonNegativeInt\n}).annotate({\n identifier: \"IsPropertiesLengthBetween\"\n});\nconst $IsPropertyNames = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isPropertyNames\"),\n propertyNames: Representation$ref\n}).annotate({\n identifier: \"IsPropertyNames\"\n});\n/**\n * Schema for {@link ObjectsMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $ObjectsMeta = /*#__PURE__*/Schema.Union([$IsMinProperties, $IsMaxProperties, $IsPropertiesLengthBetween, $IsPropertyNames]).annotate({\n identifier: \"ObjectsMeta\"\n});\n/**\n * Schema for the {@link Objects} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Objects = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Objects\"),\n annotations: Schema.optional($Annotations),\n propertySignatures: Schema.Array($PropertySignature),\n indexSignatures: Schema.Array($IndexSignature),\n checks: Schema.Array(makeCheck($ObjectsMeta, \"Objects\"))\n}).annotate({\n identifier: \"Objects\"\n});\n/**\n * Schema for the {@link Union} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Union = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Union\"),\n annotations: Schema.optional($Annotations),\n types: Schema.Array(Representation$ref),\n mode: Schema.Literals([\"anyOf\", \"oneOf\"])\n}).annotate({\n identifier: \"Union\"\n});\n/**\n * Schema for the {@link Reference} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Reference = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Reference\"),\n $ref: Schema.String\n}).annotate({\n identifier: \"Reference\"\n});\nconst $IsDateValid = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isDateValid\")\n}).annotate({\n identifier: \"IsDateValid\"\n});\nconst $IsGreaterThanDate = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThanDate\"),\n exclusiveMinimum: Schema.Date\n}).annotate({\n identifier: \"IsGreaterThanDate\"\n});\nconst $IsGreaterThanOrEqualToDate = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isGreaterThanOrEqualToDate\"),\n minimum: Schema.Date\n}).annotate({\n identifier: \"IsGreaterThanOrEqualToDate\"\n});\nconst $IsLessThanDate = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThanDate\"),\n exclusiveMaximum: Schema.Date\n}).annotate({\n identifier: \"IsLessThanDate\"\n});\nconst $IsLessThanOrEqualToDate = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isLessThanOrEqualToDate\"),\n maximum: Schema.Date\n}).annotate({\n identifier: \"IsLessThanOrEqualToDate\"\n});\nconst $IsBetweenDate = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isBetweenDate\"),\n minimum: Schema.Date,\n maximum: Schema.Date,\n exclusiveMinimum: Schema.optional(Schema.Boolean),\n exclusiveMaximum: Schema.optional(Schema.Boolean)\n}).annotate({\n identifier: \"IsBetweenDate\"\n});\n/**\n * Schema for {@link DateMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $DateMeta = /*#__PURE__*/Schema.Union([$IsDateValid, $IsGreaterThanDate, $IsGreaterThanOrEqualToDate, $IsLessThanDate, $IsLessThanOrEqualToDate, $IsBetweenDate]).annotate({\n identifier: \"DateMeta\"\n});\nconst $IsMinSize = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMinSize\"),\n minSize: NonNegativeInt\n}).annotate({\n identifier: \"IsMinSize\"\n});\nconst $IsMaxSize = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isMaxSize\"),\n maxSize: NonNegativeInt\n}).annotate({\n identifier: \"IsMaxSize\"\n});\nconst $IsSizeBetween = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"isSizeBetween\"),\n minimum: NonNegativeInt,\n maximum: NonNegativeInt\n}).annotate({\n identifier: \"IsSizeBetween\"\n});\n/**\n * Schema for {@link SizeMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $SizeMeta = /*#__PURE__*/Schema.Union([$IsMinSize, $IsMaxSize, $IsSizeBetween]).annotate({\n identifier: \"SizeMeta\"\n});\n/**\n * Schema for {@link DeclarationMeta}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $DeclarationMeta = /*#__PURE__*/Schema.Union([$DateMeta, $SizeMeta]).annotate({\n identifier: \"DeclarationMeta\"\n});\n/**\n * Schema for the {@link Declaration} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Declaration = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Declaration\"),\n annotations: Schema.optional($Annotations),\n typeParameters: Schema.Array(Representation$ref),\n checks: Schema.Array(makeCheck($DeclarationMeta, \"Declaration\")),\n encodedSchema: Representation$ref\n}).annotate({\n identifier: \"Declaration\"\n});\n/**\n * Schema for the {@link Suspend} representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Suspend = /*#__PURE__*/Schema.Struct({\n _tag: Schema.tag(\"Suspend\"),\n annotations: Schema.optional($Annotations),\n checks: Schema.Tuple([]),\n thunk: Representation$ref\n}).annotate({\n identifier: \"Suspend\"\n});\n/**\n * Schema for the full {@link Representation} union. It recursively validates\n * and encodes any representation node.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Representation = /*#__PURE__*/Schema.Union([$Null, $Undefined, $Void, $Never, $Unknown, $Any, $String, $Number, $Boolean, $BigInt, $Symbol, $Literal, $UniqueSymbol, $ObjectKeyword, $Enum, $TemplateLiteral, $Arrays, $Objects, $Union, $Reference, $Declaration, $Suspend]).annotate({\n identifier: \"Schema\"\n});\n/**\n * Schema for {@link Document}.\n *\n * **When to use**\n *\n * Use to validate or serialize a single schema representation document with\n * `Schema.decodeUnknownSync` or `Schema.encodeSync`.\n *\n * **Gotchas**\n *\n * This codec validates document structure but does not resolve `$ref` keys\n * against `references`.\n *\n * @see {@link DocumentFromJson} for the JSON-string codec wrapper\n * @see {@link $MultiDocument} for validating documents with multiple root representations\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $Document = /*#__PURE__*/Schema.Struct({\n representation: $Representation,\n references: Schema.Record(Schema.String, $Representation)\n}).annotate({\n identifier: \"Document\"\n});\n/**\n * Schema for {@link MultiDocument}.\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const $MultiDocument = /*#__PURE__*/Schema.Struct({\n representations: Schema.NonEmptyArray($Representation),\n references: Schema.Record(Schema.String, $Representation)\n}).annotate({\n identifier: \"MultiDocument\"\n});\n// -----------------------------------------------------------------------------\n// APIs\n// -----------------------------------------------------------------------------\n/**\n * Converts a Schema AST into a {@link Document}.\n *\n * **When to use**\n *\n * Use when you have a single Schema AST and need a schema representation\n * document.\n *\n * **Details**\n *\n * Shared/recursive sub-schemas are extracted into the `references` map.\n *\n * **Example** (Converting a Schema to a Document)\n *\n * ```ts\n * import { Schema, SchemaRepresentation } from \"effect\"\n *\n * const Person = Schema.Struct({\n * name: Schema.String,\n * age: Schema.Number\n * })\n *\n * const doc = SchemaRepresentation.fromAST(Person.ast)\n * console.log(doc.representation._tag)\n * // \"Objects\"\n * ```\n *\n * @see {@link Document}\n * @see {@link fromASTs}\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const fromAST = InternalRepresentation.fromAST;\n/**\n * Converts one or more Schema ASTs into a {@link MultiDocument}.\n *\n * **When to use**\n *\n * Use when you have multiple Schema ASTs and need one schema representation\n * `MultiDocument` with shared references.\n *\n * **Details**\n *\n * All schemas share a single `references` map.\n *\n * @see {@link MultiDocument}\n * @see {@link fromAST}\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const fromASTs = InternalRepresentation.fromASTs;\n/**\n * Schema that decodes a {@link Document} from JSON and encodes it back.\n *\n * **When to use**\n *\n * Use when you need a JSON codec for schema representation documents with\n * `Schema.decodeUnknownSync` or `Schema.encodeSync`.\n *\n * **Example** (Round-tripping a Document through JSON)\n *\n * ```ts\n * import { Schema, SchemaRepresentation } from \"effect\"\n *\n * const doc = SchemaRepresentation.fromAST(Schema.String.ast)\n * const json = Schema.encodeSync(SchemaRepresentation.DocumentFromJson)(doc)\n * const back = Schema.decodeUnknownSync(SchemaRepresentation.DocumentFromJson)(json)\n * ```\n *\n * @see {@link $Document}\n * @see {@link MultiDocumentFromJson}\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const DocumentFromJson = /*#__PURE__*/Schema.toCodecJson($Document);\n/**\n * Schema for `MultiDocument` values encoded as JSON.\n *\n * @see {@link $MultiDocument}\n * @see {@link DocumentFromJson}\n *\n * @category schemas\n * @since 4.0.0\n */\nexport const MultiDocumentFromJson = /*#__PURE__*/Schema.toCodecJson($MultiDocument);\n/**\n * Wraps a single {@link Document} as a {@link MultiDocument} with one\n * representation.\n *\n * **When to use**\n *\n * Use when you need to pass a single schema representation `Document` where an\n * API expects a `MultiDocument`.\n *\n * @see {@link Document}\n * @see {@link MultiDocument}\n *\n * @category transforming\n * @since 4.0.0\n */\nexport function toMultiDocument(document) {\n return {\n representations: [document.representation],\n references: document.references\n };\n}\n/**\n * Default {@link Reviver} for {@link toSchema} that handles built-in Effect\n * types, including Option, Result, Redacted, Cause, Exit, ReadonlyMap, HashMap,\n * ReadonlySet, Date, Duration, URL, and RegExp.\n *\n * **When to use**\n *\n * Use when you need the default `options.reviver` for {@link toSchema} to\n * reconstruct runtime schemas for built-in Effect declarations.\n *\n * **Details**\n *\n * The reviver returns `undefined` for unrecognized declarations, causing\n * fallback to `encodedSchema`.\n *\n * @see {@link toSchema}\n * @see {@link Reviver}\n *\n * @category transforming\n * @since 4.0.0\n */\nexport const toSchemaDefaultReviver = (s, recur) => {\n const typeConstructor = s.annotations?.typeConstructor;\n if (Predicate.isObject(typeConstructor) && typeof typeConstructor._tag === \"string\") {\n const typeParameters = s.typeParameters.map(recur);\n switch (typeConstructor._tag) {\n // built-in types\n case \"Date\":\n return Schema.Date;\n case \"Error\":\n return Schema.Error(typeConstructor.options);\n case \"File\":\n return Schema.File;\n case \"FormData\":\n return Schema.FormData;\n case \"ReadonlyMap\":\n return Schema.ReadonlyMap(typeParameters[0], typeParameters[1]);\n case \"ReadonlySet\":\n return Schema.ReadonlySet(typeParameters[0]);\n case \"RegExp\":\n return Schema.RegExp;\n case \"Uint8Array\":\n return Schema.Uint8Array;\n case \"URL\":\n return Schema.URL;\n case \"URLSearchParams\":\n return Schema.URLSearchParams;\n // effect types\n case \"effect/Option\":\n return Schema.Option(typeParameters[0]);\n case \"effect/Result\":\n return Schema.Result(typeParameters[0], typeParameters[1]);\n case \"effect/Redacted\":\n return Schema.Redacted(typeParameters[0], typeConstructor.options);\n case \"effect/DateTime.TimeZone\":\n return Schema.TimeZone;\n case \"effect/DateTime.TimeZone.Named\":\n return Schema.TimeZoneNamed;\n case \"effect/DateTime.TimeZone.Offset\":\n return Schema.TimeZoneOffset;\n case \"effect/DateTime.Utc\":\n return Schema.DateTimeUtc;\n case \"effect/DateTime.Zoned\":\n return Schema.DateTimeZoned;\n case \"effect/BigDecimal\":\n return Schema.BigDecimal;\n case \"effect/Chunk\":\n return Schema.Chunk(typeParameters[0]);\n case \"effect/Cause\":\n return Schema.Cause(typeParameters[0], typeParameters[1]);\n case \"effect/Cause/Failure\":\n return Schema.CauseReason(typeParameters[0], typeParameters[1]);\n case \"effect/Duration\":\n return Schema.Duration;\n case \"effect/Exit\":\n return Schema.Exit(typeParameters[0], typeParameters[1], typeParameters[2]);\n case \"effect/Json\":\n return Schema.Json;\n case \"effect/MutableJson\":\n return Schema.MutableJson;\n case \"effect/HashMap\":\n return Schema.HashMap(typeParameters[0], typeParameters[1]);\n case \"effect/HashSet\":\n return Schema.HashSet(typeParameters[0]);\n }\n }\n};\n/**\n * Creates a runtime Schema from a {@link Document}.\n *\n * **When to use**\n *\n * Use when you have a serialized or computed schema representation document and\n * need a runtime Schema for decoding/encoding.\n *\n * **Details**\n *\n * Pass `options.reviver`, such as {@link toSchemaDefaultReviver}, to handle\n * {@link Declaration} nodes for types like `Date` and `Option`. Without a\n * reviver, declarations fall back to their `encodedSchema`. Circular references\n * are handled via lazy `Schema.suspend`.\n *\n * **Gotchas**\n *\n * This throws if a `$ref` is not found in `document.references`.\n *\n * **Example** (Reconstructing a Schema)\n *\n * ```ts\n * import { Schema, SchemaRepresentation } from \"effect\"\n *\n * const doc = SchemaRepresentation.fromAST(\n * Schema.Struct({ name: Schema.String }).ast\n * )\n *\n * const schema = SchemaRepresentation.toSchema(doc)\n * console.log(JSON.stringify(Schema.toJsonSchemaDocument(schema), null, 2))\n * ```\n *\n * @see {@link Document}\n * @see {@link Reviver}\n * @see {@link toSchemaDefaultReviver}\n *\n * @category Runtime Generation\n * @since 4.0.0\n */\nexport function toSchema(document, options) {\n const slots = new Map();\n return recur(document.representation);\n function recur(r) {\n let out = on(r);\n if (\"annotations\" in r && r.annotations) out = out.annotate(r.annotations);\n out = toSchemaChecks(out, r);\n return out;\n }\n function getSlot(identifier) {\n const existing = slots.get(identifier);\n if (existing) return existing;\n // Create the slot *before* resolving, so self-references can see it.\n const slot = {\n state: 0,\n value: undefined,\n ref: Schema.suspend(() => {\n if (slot.value === undefined) {\n return Schema.Unknown;\n }\n return slot.value;\n })\n };\n slots.set(identifier, slot);\n return slot;\n }\n function resolveReference($ref) {\n const definition = document.references[$ref];\n if (definition === undefined) {\n throw new Error(`Reference ${$ref} not found`);\n }\n const slot = getSlot($ref);\n if (slot.state === 2) {\n // Already built: return the built schema directly\n return slot.value;\n }\n if (slot.state === 1) {\n // Circular: we're currently building this identifier.\n return slot.ref;\n }\n // First time: build it.\n slot.state = 1;\n try {\n slot.value = recur(definition);\n slot.state = 2;\n return slot.value;\n } catch (e) {\n // Leave the slot in a safe state so future thunks don't silently succeed.\n slot.state = 0;\n slot.value = undefined;\n throw e;\n }\n }\n function on(r) {\n switch (r._tag) {\n case \"Declaration\":\n return options?.reviver?.(r, recur) ?? recur(r.encodedSchema);\n case \"Reference\":\n return resolveReference(r.$ref);\n case \"Suspend\":\n return recur(r.thunk);\n case \"Null\":\n return Schema.Null;\n case \"Undefined\":\n return Schema.Undefined;\n case \"Void\":\n return Schema.Void;\n case \"Never\":\n return Schema.Never;\n case \"Unknown\":\n return Schema.Unknown;\n case \"Any\":\n return Schema.Any;\n case \"String\":\n {\n const contentMediaType = r.contentMediaType;\n const contentSchema = r.contentSchema;\n if (contentMediaType === \"application/json\" && contentSchema !== undefined) {\n return Schema.fromJsonString(recur(contentSchema));\n }\n return Schema.String;\n }\n case \"Number\":\n return Schema.Number;\n case \"Boolean\":\n return Schema.Boolean;\n case \"BigInt\":\n return Schema.BigInt;\n case \"Symbol\":\n return Schema.Symbol;\n case \"Literal\":\n return Schema.Literal(r.literal);\n case \"UniqueSymbol\":\n return Schema.UniqueSymbol(r.symbol);\n case \"ObjectKeyword\":\n return Schema.ObjectKeyword;\n case \"Enum\":\n return Schema.Enum(Object.fromEntries(r.enums));\n case \"TemplateLiteral\":\n {\n const parts = r.parts.map(recur);\n return Schema.TemplateLiteral(parts);\n }\n case \"Arrays\":\n {\n const elements = r.elements.map(e => {\n const s = recur(e.type);\n return e.isOptional ? Schema.optionalKey(s) : s;\n });\n const rest = r.rest.map(recur);\n if (Arr.isArrayNonEmpty(rest)) {\n if (r.elements.length === 0 && r.rest.length === 1) {\n return Schema.Array(rest[0]);\n }\n return Schema.TupleWithRest(Schema.Tuple(elements), rest);\n }\n return Schema.Tuple(elements);\n }\n case \"Objects\":\n {\n const fields = {};\n for (const ps of r.propertySignatures) {\n const s = recur(ps.type);\n const withOptional = ps.isOptional ? Schema.optionalKey(s) : s;\n fields[ps.name] = ps.isMutable ? Schema.mutableKey(withOptional) : withOptional;\n }\n const indexSignatures = r.indexSignatures.map(is => Schema.Record(recur(is.parameter), recur(is.type)));\n if (Arr.isArrayNonEmpty(indexSignatures)) {\n if (r.propertySignatures.length === 0 && indexSignatures.length === 1) {\n return indexSignatures[0];\n }\n return Schema.StructWithRest(Schema.Struct(fields), indexSignatures);\n }\n return Schema.Struct(fields);\n }\n case \"Union\":\n {\n if (r.types.length === 0) return Schema.Never;\n if (r.types.every(t => t._tag === \"Literal\")) {\n if (r.types.length === 1) {\n return Schema.Literal(r.types[0].literal);\n }\n return Schema.Literals(r.types.map(t => t.literal));\n }\n return Schema.Union(r.types.map(recur), {\n mode: r.mode\n });\n }\n }\n }\n function toSchemaChecks(top, schema) {\n switch (schema._tag) {\n default:\n return top;\n case \"String\":\n case \"Number\":\n case \"BigInt\":\n case \"Arrays\":\n case \"Objects\":\n case \"Declaration\":\n {\n const checks = schema.checks.map(toSchemaCheck);\n return Arr.isArrayNonEmpty(checks) ? top.check(...checks) : top;\n }\n }\n }\n function toSchemaCheck(check) {\n switch (check._tag) {\n case \"Filter\":\n return toSchemaFilter(check);\n case \"FilterGroup\":\n {\n return Schema.makeFilterGroup(Arr.map(check.checks, toSchemaCheck), check.annotations);\n }\n }\n }\n function toSchemaFilter(filter) {\n const a = filter.annotations;\n switch (filter.meta._tag) {\n // String Meta\n case \"isStringFinite\":\n return Schema.isStringFinite(a);\n case \"isStringBigInt\":\n return Schema.isStringBigInt(a);\n case \"isStringSymbol\":\n return Schema.isStringSymbol(a);\n case \"isMinLength\":\n return Schema.isMinLength(filter.meta.minLength, a);\n case \"isMaxLength\":\n return Schema.isMaxLength(filter.meta.maxLength, a);\n case \"isLengthBetween\":\n return Schema.isLengthBetween(filter.meta.minimum, filter.meta.maximum, a);\n case \"isPattern\":\n return Schema.isPattern(filter.meta.regExp, a);\n case \"isTrimmed\":\n return Schema.isTrimmed(a);\n case \"isUUID\":\n return Schema.isUUID(filter.meta.version, a);\n case \"isGUID\":\n return Schema.isGUID(a);\n case \"isULID\":\n return Schema.isULID(a);\n case \"isBase64\":\n return Schema.isBase64(a);\n case \"isBase64Url\":\n return Schema.isBase64Url(a);\n case \"isStartsWith\":\n return Schema.isStartsWith(filter.meta.startsWith, a);\n case \"isEndsWith\":\n return Schema.isEndsWith(filter.meta.endsWith, a);\n case \"isIncludes\":\n return Schema.isIncludes(filter.meta.includes, a);\n case \"isUppercased\":\n return Schema.isUppercased(a);\n case \"isLowercased\":\n return Schema.isLowercased(a);\n case \"isCapitalized\":\n return Schema.isCapitalized(a);\n case \"isUncapitalized\":\n return Schema.isUncapitalized(a);\n // Number Meta\n case \"isFinite\":\n return Schema.isFinite(a);\n case \"isInt\":\n return Schema.isInt(a);\n case \"isMultipleOf\":\n return Schema.isMultipleOf(filter.meta.divisor, a);\n case \"isGreaterThan\":\n return Schema.isGreaterThan(filter.meta.exclusiveMinimum, a);\n case \"isGreaterThanOrEqualTo\":\n return Schema.isGreaterThanOrEqualTo(filter.meta.minimum, a);\n case \"isLessThan\":\n return Schema.isLessThan(filter.meta.exclusiveMaximum, a);\n case \"isLessThanOrEqualTo\":\n return Schema.isLessThanOrEqualTo(filter.meta.maximum, a);\n case \"isBetween\":\n return Schema.isBetween(filter.meta, a);\n // BigInt Meta\n case \"isGreaterThanBigInt\":\n return Schema.isGreaterThanBigInt(filter.meta.exclusiveMinimum, a);\n case \"isGreaterThanOrEqualToBigInt\":\n return Schema.isGreaterThanOrEqualToBigInt(filter.meta.minimum, a);\n case \"isLessThanBigInt\":\n return Schema.isLessThanBigInt(filter.meta.exclusiveMaximum, a);\n case \"isLessThanOrEqualToBigInt\":\n return Schema.isLessThanOrEqualToBigInt(filter.meta.maximum, a);\n case \"isBetweenBigInt\":\n return Schema.isBetweenBigInt(filter.meta, a);\n // Object Meta\n case \"isMinProperties\":\n return Schema.isMinProperties(filter.meta.minProperties, a);\n case \"isMaxProperties\":\n return Schema.isMaxProperties(filter.meta.maxProperties, a);\n case \"isPropertiesLengthBetween\":\n return Schema.isPropertiesLengthBetween(filter.meta.minimum, filter.meta.maximum, a);\n case \"isPropertyNames\":\n return Schema.isPropertyNames(recur(filter.meta.propertyNames), a);\n // Arrays Meta\n case \"isUnique\":\n return Schema.isUnique(a);\n // Date Meta\n case \"isDateValid\":\n return Schema.isDateValid(a);\n case \"isGreaterThanDate\":\n return Schema.isGreaterThanDate(filter.meta.exclusiveMinimum, a);\n case \"isGreaterThanOrEqualToDate\":\n return Schema.isGreaterThanOrEqualToDate(filter.meta.minimum, a);\n case \"isLessThanDate\":\n return Schema.isLessThanDate(filter.meta.exclusiveMaximum, a);\n case \"isLessThanOrEqualToDate\":\n return Schema.isLessThanOrEqualToDate(filter.meta.maximum, a);\n case \"isBetweenDate\":\n return Schema.isBetweenDate(filter.meta, a);\n // Size Meta\n case \"isMinSize\":\n return Schema.isMinSize(filter.meta.minSize, a);\n case \"isMaxSize\":\n return Schema.isMaxSize(filter.meta.maxSize, a);\n case \"isSizeBetween\":\n return Schema.isSizeBetween(filter.meta.minimum, filter.meta.maximum, a);\n }\n }\n}\n/**\n * Converts a {@link Document} to a Draft 2020-12 JSON Schema document.\n *\n * **When to use**\n *\n * Use when you need to produce a standard JSON Schema document from a schema\n * representation `Document`.\n *\n * **Gotchas**\n *\n * JSON Schema generation is best-effort. Some Effect schema representation\n * semantics cannot be represented exactly in JSON Schema, and importing an\n * emitted JSON Schema may produce an equivalent approximation rather than the\n * original representation shape.\n *\n * **Example** (Generating JSON Schema)\n *\n * ```ts\n * import { Schema, SchemaRepresentation } from \"effect\"\n *\n * const doc = SchemaRepresentation.fromAST(Schema.String.ast)\n * const jsonSchema = SchemaRepresentation.toJsonSchemaDocument(doc)\n * console.log(jsonSchema.schema.type)\n * // \"string\"\n * ```\n *\n * @see {@link Document}\n * @see {@link toJsonSchemaMultiDocument}\n * @see {@link fromJsonSchemaDocument}\n *\n * @category transforming\n * @since 4.0.0\n */\nexport const toJsonSchemaDocument = InternalRepresentation.toJsonSchemaDocument;\n/**\n * Converts a {@link MultiDocument} to a Draft 2020-12 JSON Schema\n * multi-document.\n *\n * **When to use**\n *\n * Use when you need to export related schema representation documents together\n * so shared definitions stay in multi-document JSON Schema form.\n *\n * **Gotchas**\n *\n * JSON Schema generation is best-effort. Some Effect schema representation\n * semantics cannot be represented exactly in JSON Schema, and importing an\n * emitted JSON Schema may produce equivalent approximations rather than the\n * original representation shapes.\n *\n * @see {@link MultiDocument}\n * @see {@link toJsonSchemaDocument}\n * @see {@link fromJsonSchemaMultiDocument}\n *\n * @category transforming\n * @since 4.0.0\n */\nexport const toJsonSchemaMultiDocument = InternalRepresentation.toJsonSchemaMultiDocument;\n/**\n * Constructs a {@link Code} value from a runtime expression string and a\n * TypeScript type string.\n *\n * @see {@link Code}\n *\n * @category Code Generation\n * @since 4.0.0\n */\nexport function makeCode(runtime, Type) {\n return {\n runtime,\n Type\n };\n}\n/**\n * Generates TypeScript code strings from a {@link MultiDocument}.\n *\n * **When to use**\n *\n * Use when you need to produce source code for Effect Schema definitions from a\n * schema representation `MultiDocument`.\n *\n * **Details**\n *\n * `options.reviver` can customize code generation for {@link Declaration}\n * nodes. Return `undefined` to fall back to the default logic, which uses\n * `generation` annotations or the encoded schema. References are\n * topologically sorted so non-recursive definitions are emitted before their\n * dependents. `$ref` keys are converted to sanitized JavaScript identifiers.\n *\n * **Example** (Generating TypeScript code)\n *\n * ```ts\n * import { Schema, SchemaRepresentation } from \"effect\"\n *\n * const Person = Schema.Struct({\n * name: Schema.String,\n * age: Schema.Int\n * })\n *\n * const multi = SchemaRepresentation.toMultiDocument(\n * SchemaRepresentation.fromAST(Person.ast)\n * )\n * const codeDoc = SchemaRepresentation.toCodeDocument(multi)\n * console.log(codeDoc.codes[0].runtime)\n * // Schema.Struct({ ... })\n * ```\n *\n * @see {@link CodeDocument}\n * @see {@link MultiDocument}\n * @see {@link Reviver}\n *\n * @category Code Generation\n * @since 4.0.0\n */\nexport function toCodeDocument(multiDocument, options) {\n const artifacts = [];\n const ts = topologicalSort(multiDocument.references);\n // Phase 1: Build sanitization map with collision handling\n const sanitizedReferenceMap = new Map();\n const uniqueSanitizedReferences = new Set();\n const referenceCount = new Map();\n // Process all references first to build the map\n const allRefs = [...ts.nonRecursives.map(({\n $ref\n }) => $ref), ...Object.keys(ts.recursives)];\n for (const ref of allRefs) {\n ensureUniqueSanitized(ref);\n }\n // Phase 2: Use the map when processing references\n const nonRecursives = ts.nonRecursives.map(({\n $ref,\n representation\n }) => ({\n $ref: sanitizedReferenceMap.get($ref),\n code: recur(representation)\n }));\n const recursives = Rec.mapEntries(ts.recursives, (representation, $ref) => [sanitizedReferenceMap.get($ref), recur(representation)]);\n const codes = multiDocument.representations.map(recur);\n return {\n codes,\n references: {\n nonRecursives: nonRecursives.filter(({\n $ref\n }) => (referenceCount.get($ref) ?? 0) > 0),\n recursives: Rec.filter(recursives, (_, $ref) => (referenceCount.get($ref) ?? 0) > 0)\n },\n artifacts\n };\n function ensureUniqueSanitized(originalRef) {\n // Check if already mapped (consistency)\n const sanitized = sanitizedReferenceMap.get(originalRef);\n if (sanitized !== undefined) {\n return sanitized;\n }\n // Find unique sanitized name\n const seed = sanitizeJavaScriptIdentifier(originalRef);\n let candidate = seed;\n let suffix = 0;\n while (uniqueSanitizedReferences.has(candidate)) {\n candidate = `${seed}${++suffix}`;\n }\n uniqueSanitizedReferences.add(candidate);\n sanitizedReferenceMap.set(originalRef, candidate);\n return candidate;\n }\n function addSymbol(s) {\n const identifier = ensureUniqueSanitized(\"_symbol\");\n const key = globalThis.Symbol.keyFor(s);\n const description = s.description;\n const generation = key === undefined ? makeCode(`Symbol(${description === undefined ? \"\" : format(description)})`, `typeof ${identifier}`) : makeCode(`Symbol.for(${format(key)})`, `typeof ${identifier}`);\n artifacts.push({\n _tag: \"Symbol\",\n identifier,\n generation\n });\n return identifier;\n }\n function addEnum(s) {\n const identifier = ensureUniqueSanitized(\"_Enum\");\n artifacts.push({\n _tag: \"Enum\",\n identifier,\n generation: makeCode(`enum ${identifier} { ${s.enums.map(([name, value]) => `${format(name)}: ${format(value)}`).join(\", \")} }`, `typeof ${identifier}`)\n });\n return identifier;\n }\n function addImport(importDeclaration) {\n if (!artifacts.some(a => a._tag === \"Import\" && a.importDeclaration === importDeclaration)) {\n artifacts.push({\n _tag: \"Import\",\n importDeclaration\n });\n }\n }\n function recur(s) {\n const g = on(s);\n switch (s._tag) {\n default:\n return makeCode(g.runtime + toRuntimeAnnotate(s.annotations) + toRuntimeBrand(s.annotations), g.Type + toTypeBrand(s.annotations));\n case \"Reference\":\n return g;\n case \"Declaration\":\n case \"String\":\n case \"Number\":\n case \"BigInt\":\n case \"Arrays\":\n case \"Objects\":\n case \"Suspend\":\n return makeCode(g.runtime + toRuntimeAnnotate(s.annotations) + toRuntimeBrand(s.annotations) + toRuntimeChecks(s.checks), g.Type + toTypeBrand(s.annotations) + toTypeChecks(s.checks));\n }\n }\n function on(s) {\n switch (s._tag) {\n case \"Declaration\":\n {\n // if there is a reviver, use it to generate the generation\n if (options?.reviver !== undefined) {\n // the reviver can return `undefined` to indicate that the generation should be generated by the default logic\n const out = options.reviver(s, recur);\n if (out !== undefined) {\n return out;\n }\n }\n // otherwise, use the generation from the annotations\n const generation = s.annotations?.generation;\n if (Predicate.isObject(generation) && typeof generation.runtime === \"string\" && typeof generation.Type === \"string\") {\n const typeParameters = s.typeParameters.map(recur);\n if (typeof generation.importDeclaration === \"string\") {\n addImport(generation.importDeclaration);\n }\n return makeCode(replacePlaceholders(generation.runtime, typeParameters.map(p => p.runtime)), replacePlaceholders(generation.Type, typeParameters.map(p => p.Type)));\n }\n // otherwise, use the generation from the encoded schema\n return recur(s.encodedSchema);\n }\n case \"Reference\":\n {\n const sanitized = ensureUniqueSanitized(s.$ref);\n referenceCount.set(sanitized, (referenceCount.get(sanitized) ?? 0) + 1);\n return makeCode(sanitized, sanitized);\n }\n case \"Suspend\":\n {\n const thunk = recur(s.thunk);\n return makeCode(`Schema.suspend((): Schema.Codec<${thunk.Type}> => ${thunk.runtime})`, thunk.Type);\n }\n case \"Null\":\n return makeCode(`Schema.Null`, \"null\");\n case \"Undefined\":\n return makeCode(`Schema.Undefined`, \"undefined\");\n case \"Void\":\n return makeCode(`Schema.Void`, \"void\");\n case \"Never\":\n return makeCode(`Schema.Never`, \"never\");\n case \"Unknown\":\n return makeCode(`Schema.Unknown`, \"unknown\");\n case \"Any\":\n return makeCode(`Schema.Any`, \"any\");\n case \"Number\":\n return makeCode(`Schema.Number`, \"number\");\n case \"Boolean\":\n return makeCode(`Schema.Boolean`, \"boolean\");\n case \"BigInt\":\n return makeCode(`Schema.BigInt`, \"bigint\");\n case \"Symbol\":\n return makeCode(`Schema.Symbol`, \"symbol\");\n case \"String\":\n {\n const contentMediaType = s.contentMediaType;\n const contentSchema = s.contentSchema;\n if (contentMediaType === \"application/json\" && contentSchema !== undefined) {\n return makeCode(`Schema.fromJsonString(${recur(contentSchema)})`, \"string\");\n } else {\n return makeCode(`Schema.String`, \"string\");\n }\n }\n case \"Literal\":\n {\n const literal = format(s.literal);\n return makeCode(`Schema.Literal(${literal})`, literal);\n }\n case \"UniqueSymbol\":\n {\n const identifier = addSymbol(s.symbol);\n return makeCode(`Schema.UniqueSymbol(${identifier})`, `typeof ${identifier}`);\n }\n case \"ObjectKeyword\":\n return makeCode(`Schema.ObjectKeyword`, \"object\");\n case \"Enum\":\n {\n const identifier = addEnum(s);\n return makeCode(`Schema.Enum(${identifier})`, `typeof ${identifier}`);\n }\n case \"TemplateLiteral\":\n {\n const parts = s.parts.map(recur);\n const type = toTypeParts(s.parts).map(p => \"`\" + p + \"`\").join(\" | \");\n return makeCode(`Schema.TemplateLiteral([${parts.map(p => p.runtime).join(\", \")}])`, type);\n }\n case \"Arrays\":\n {\n const elements = s.elements.map(e => {\n return {\n isOptional: e.isOptional,\n type: recur(e.type),\n annotations: e.annotations\n };\n });\n const rest = s.rest.map(recur);\n if (Arr.isArrayNonEmpty(rest)) {\n const item = rest[0];\n if (elements.length === 0 && rest.length === 1) {\n return makeCode(`Schema.Array(${item.runtime})`, `ReadonlyArray<${item.Type}>`);\n }\n const post = rest.slice(1);\n return makeCode(`Schema.TupleWithRest(Schema.Tuple([${elements.map(e => toRuntimeIsOptional(e.isOptional, e.type.runtime) + toRuntimeAnnotateKey(e.annotations)).join(\", \")}]), [${rest.map(r => r.runtime).join(\", \")}])`, `readonly [${elements.map(e => toTypeIsOptional(e.isOptional, e.type.Type)).join(\", \")}, ...Array<${item.Type}>${post.length > 0 ? `, ${post.map(p => p.Type).join(\", \")}` : \"\"}]`);\n }\n return makeCode(`Schema.Tuple([${elements.map(e => toRuntimeIsOptional(e.isOptional, e.type.runtime) + toRuntimeAnnotateKey(e.annotations)).join(\", \")}])`, `readonly [${elements.map(e => toTypeIsOptional(e.isOptional, e.type.Type)).join(\", \")}]`);\n }\n case \"Objects\":\n {\n const pss = s.propertySignatures.map(p => {\n const isSymbol = typeof p.name === \"symbol\";\n const name = isSymbol ? addSymbol(p.name) : formatPropertyKey(p.name);\n const nameType = toTypeIsOptional(p.isOptional, toTypeIsMutable(p.isMutable, isSymbol ? `[typeof ${name}]` : name));\n const type = recur(p.type);\n return makeCode(`${isSymbol ? `[${name}]` : name}: ${toRuntimeIsOptional(p.isOptional, toRuntimeIsMutable(p.isMutable, type.runtime))}` + toRuntimeAnnotateKey(p.annotations), `${nameType}: ${type.Type}`);\n });\n const iss = s.indexSignatures.map(is => {\n return {\n parameter: recur(is.parameter),\n type: recur(is.type)\n };\n });\n if (iss.length === 0) {\n // 1) Only properties -> Struct\n return makeCode(`Schema.Struct({ ${pss.map(p => p.runtime).join(\", \")} })`, `{ ${pss.map(p => p.Type).join(\", \")} }`);\n } else if (pss.length === 0 && iss.length === 1) {\n // 2) Only one index signature and no properties -> Record\n return makeCode(`Schema.Record(${iss[0].parameter.runtime}, ${iss[0].type.runtime})`, `{ readonly [x: ${iss[0].parameter.Type}]: ${iss[0].type.Type} }`);\n } else {\n // 3) Properties + index signatures -> StructWithRest\n return makeCode(`Schema.StructWithRest(Schema.Struct({ ${pss.map(p => p.runtime).join(\", \")} }), [${iss.map(is => `Schema.Record(${is.parameter.runtime}, ${is.type.runtime})`).join(\", \")}])`, `{ ${pss.map(p => p.Type).join(\", \")}, ${iss.map(is => `readonly [x: ${is.parameter.Type}]: ${is.type.Type}`).join(\", \")} }`);\n }\n }\n case \"Union\":\n {\n if (s.types.length === 0) {\n return makeCode(\"Schema.Never\", \"never\");\n }\n if (s.types.every(t => t._tag === \"Literal\")) {\n const literals = s.types.map(l => format(l.literal));\n if (literals.length === 1) {\n return makeCode(`Schema.Literal(${literals[0]})`, literals[0]);\n }\n return makeCode(`Schema.Literals([${literals.join(\", \")}])`, literals.join(\" | \"));\n }\n const mode = s.mode === \"anyOf\" ? \"\" : `, { mode: \"oneOf\" }`;\n const types = s.types.map(t => recur(t));\n return makeCode(`Schema.Union([${types.map(t => t.runtime).join(\", \")}]${mode})`, types.map(t => t.Type).join(\" | \"));\n }\n }\n }\n function toTypeBrand(annotations) {\n const brands = collectBrands(annotations);\n if (brands.length === 0) return \"\";\n addImport(`import type * as Brand from \"effect/Brand\"`);\n return brands.map(b => ` & Brand.Brand<${format(b)}>`).join(\"\");\n }\n function toTypeChecks(checks) {\n return checks.map(c => toTypeCheck(c)).join(\"\");\n }\n function toTypeCheck(check) {\n switch (check._tag) {\n case \"Filter\":\n return toTypeBrand(check.annotations);\n case \"FilterGroup\":\n {\n return toTypeChecks(check.checks);\n }\n }\n }\n function toRuntimeChecks(checks) {\n return checks.map(c => `.check(${toRuntimeCheck(c)})` + toRuntimeBrand(c.annotations)).join(\"\");\n }\n function toRuntimeCheck(check) {\n switch (check._tag) {\n case \"Filter\":\n return toRuntimeFilter(check);\n case \"FilterGroup\":\n {\n const a = toRuntimeAnnotations(check.annotations);\n const ca = a === \"\" ? \"\" : `, ${a}`;\n return `Schema.makeFilterGroup([${check.checks.map(c => toRuntimeCheck(c)).join(\", \")}]${ca})`;\n }\n }\n }\n function toRuntimeFilter(filter) {\n const a = toRuntimeAnnotations(filter.annotations);\n const ca = a === \"\" ? \"\" : `, ${a}`;\n switch (filter.meta._tag) {\n case \"isTrimmed\":\n case \"isGUID\":\n case \"isULID\":\n case \"isBase64\":\n case \"isBase64Url\":\n case \"isUppercased\":\n case \"isLowercased\":\n case \"isCapitalized\":\n case \"isUncapitalized\":\n case \"isFinite\":\n case \"isInt\":\n case \"isUnique\":\n case \"isDateValid\":\n return `Schema.${filter.meta._tag}(${a})`;\n case \"isStringFinite\":\n case \"isStringBigInt\":\n case \"isStringSymbol\":\n case \"isPattern\":\n return `Schema.${filter.meta._tag}(${toRuntimeRegExp(filter.meta.regExp)}${ca})`;\n case \"isMinLength\":\n return `Schema.isMinLength(${filter.meta.minLength}${ca})`;\n case \"isMaxLength\":\n return `Schema.isMaxLength(${filter.meta.maxLength}${ca})`;\n case \"isLengthBetween\":\n return `Schema.isLengthBetween(${filter.meta.minimum}, ${filter.meta.maximum}${ca})`;\n case \"isUUID\":\n return `Schema.isUUID(${filter.meta.version}${ca})`;\n case \"isStartsWith\":\n return `Schema.isStartsWith(${format(filter.meta.startsWith)}${ca})`;\n case \"isEndsWith\":\n return `Schema.isEndsWith(${format(filter.meta.endsWith)}${ca})`;\n case \"isIncludes\":\n return `Schema.isIncludes(${format(filter.meta.includes)}${ca})`;\n case \"isGreaterThan\":\n case \"isGreaterThanBigInt\":\n case \"isGreaterThanDate\":\n return `Schema.${filter.meta._tag}(${toRuntimeValue(filter.meta.exclusiveMinimum)}${ca})`;\n case \"isGreaterThanOrEqualTo\":\n case \"isGreaterThanOrEqualToBigInt\":\n case \"isGreaterThanOrEqualToDate\":\n return `Schema.${filter.meta._tag}(${toRuntimeValue(filter.meta.minimum)}${ca})`;\n case \"isLessThan\":\n case \"isLessThanBigInt\":\n case \"isLessThanDate\":\n return `Schema.${filter.meta._tag}(${toRuntimeValue(filter.meta.exclusiveMaximum)}${ca})`;\n case \"isLessThanOrEqualTo\":\n case \"isLessThanOrEqualToBigInt\":\n case \"isLessThanOrEqualToDate\":\n return `Schema.${filter.meta._tag}(${toRuntimeValue(filter.meta.maximum)}${ca})`;\n case \"isBetween\":\n case \"isBetweenBigInt\":\n case \"isBetweenDate\":\n return `Schema.${filter.meta._tag}({ minimum: ${toRuntimeValue(filter.meta.minimum)}, maximum: ${toRuntimeValue(filter.meta.maximum)}, exclusiveMinimum: ${toRuntimeValue(filter.meta.exclusiveMinimum)}, exclusiveMaximum: ${toRuntimeValue(filter.meta.exclusiveMaximum)}${ca})`;\n case \"isMultipleOf\":\n return `Schema.isMultipleOf(${filter.meta.divisor}${ca})`;\n case \"isMinProperties\":\n return `Schema.isMinProperties(${filter.meta.minProperties}${ca})`;\n case \"isMaxProperties\":\n return `Schema.isMaxProperties(${filter.meta.maxProperties}${ca})`;\n case \"isPropertiesLengthBetween\":\n return `Schema.isPropertiesLengthBetween(${filter.meta.minimum}, ${filter.meta.maximum}${ca})`;\n case \"isPropertyNames\":\n return `Schema.isPropertyNames(${recur(filter.meta.propertyNames).runtime}${ca})`;\n case \"isMinSize\":\n return `Schema.isMinSize(${filter.meta.minSize}${ca})`;\n case \"isMaxSize\":\n return `Schema.isMaxSize(${filter.meta.maxSize}${ca})`;\n case \"isSizeBetween\":\n return `Schema.isSizeBetween(${filter.meta.minimum}, ${filter.meta.maximum}${ca})`;\n }\n }\n}\nconst VALID_ASCII_UPPER_JAVASCRIPT_IDENTIFIER_REGEXP = /^[A-Z_$][A-Za-z0-9_$]*$/;\n/**\n * Converts an arbitrary string into a valid (ASCII) JavaScript identifier\n * starting with an uppercase letter, `$`, or `_`.\n *\n * - Replaces invalid identifier characters with `_`\n * - Uppercases a leading ASCII letter\n * - If the first character is a digit, prefixes `_`\n * - Empty input becomes `_`\n *\n * @internal\n */\nexport function sanitizeJavaScriptIdentifier(s) {\n if (s.length === 0) return \"_\";\n if (VALID_ASCII_UPPER_JAVASCRIPT_IDENTIFIER_REGEXP.test(s)) return s;\n const out = [];\n let needsPrefix = false;\n let i = 0;\n for (const ch of s) {\n if (i === 0) {\n if (ch === \"_\" || ch === \"$\" || ch >= \"A\" && ch <= \"Z\") {\n out.push(ch);\n } else if (ch >= \"a\" && ch <= \"z\") {\n out.push(ch.toUpperCase());\n } else if (ch >= \"0\" && ch <= \"9\") {\n out.push(ch);\n needsPrefix = true;\n } else {\n out.push(\"_\");\n }\n } else {\n out.push(isAsciiIdPart(ch) ? ch : \"_\");\n }\n i++;\n }\n return needsPrefix ? \"_\" + out.join(\"\") : out.join(\"\");\n}\nfunction isAsciiIdStart(ch) {\n return ch === \"_\" || ch === \"$\" || ch >= \"A\" && ch <= \"Z\" || ch >= \"a\" && ch <= \"z\";\n}\nfunction isAsciiIdPart(ch) {\n return isAsciiIdStart(ch) || ch >= \"0\" && ch <= \"9\";\n}\nfunction replacePlaceholders(template, items) {\n let i = 0;\n return template.replace(/\\?/g, () => items[i++]);\n}\nfunction toTypeParts(parts) {\n if (parts.length === 0) {\n return [\"\"];\n }\n const [first, ...rest] = parts;\n const restPatterns = toTypeParts(rest);\n return toTypePart(first).flatMap(f => restPatterns.map(r => f + r));\n}\nfunction toTypePart(r) {\n switch (r._tag) {\n case \"Literal\":\n return [globalThis.String(r.literal)];\n case \"String\":\n return [\"${string}\"];\n case \"Number\":\n return [\"${number}\"];\n case \"BigInt\":\n return [\"${bigint}\"];\n case \"TemplateLiteral\":\n return toTypeParts(r.parts);\n case \"Union\":\n return r.types.flatMap(toTypePart);\n default:\n return [];\n }\n}\nconst toCodeAnnotationsBlacklist = /*#__PURE__*/new Set([...toJsonAnnotationsBlacklist, \"typeConstructor\", \"generation\", \"brands\"]);\nfunction toRuntimeAnnotations(annotations) {\n if (!annotations) return \"\";\n const entries = [];\n for (const [key, value] of Object.entries(annotations)) {\n if (toCodeAnnotationsBlacklist.has(key)) continue;\n entries.push(`${formatPropertyKey(key)}: ${format(value)}`);\n }\n if (entries.length === 0) return \"\";\n return `{ ${entries.join(\", \")} }`;\n}\nfunction toRuntimeBrand(annotations) {\n const brands = collectBrands(annotations);\n return brands.length > 0 ? `.pipe(${brands.map(b => `Schema.brand(${format(b)})`).join(\", \")})` : \"\";\n}\nfunction toRuntimeAnnotate(annotations) {\n const s = toRuntimeAnnotations(annotations);\n return s === \"\" ? \"\" : `.annotate(${s})`;\n}\nfunction toRuntimeAnnotateKey(annotations) {\n const s = toRuntimeAnnotations(annotations);\n return s === \"\" ? \"\" : `.annotateKey(${s})`;\n}\nfunction toRuntimeIsOptional(isOptional, runtime) {\n return isOptional ? `Schema.optionalKey(${runtime})` : runtime;\n}\nfunction toTypeIsOptional(isOptional, type) {\n return isOptional ? `${type}?` : type;\n}\nfunction toRuntimeIsMutable(isMutable, runtime) {\n return isMutable ? `Schema.mutableKey(${runtime})` : runtime;\n}\nfunction toTypeIsMutable(isMutable, type) {\n return isMutable ? type : `readonly ${type}`;\n}\nfunction toRuntimeValue(value) {\n if (value instanceof Date) {\n return `new Date(${value.getTime()})`;\n }\n return format(value);\n}\nfunction toRuntimeRegExp(regExp) {\n const args = [format(regExp.source)];\n const flags = regExp.flags.trim();\n if (flags !== \"\") {\n args.push(format(flags));\n }\n return `new RegExp(${args.join(\", \")})`;\n}\n/**\n * Parses a Draft 2020-12 JSON Schema document into a {@link Document}.\n *\n * **When to use**\n *\n * Use when you need to import a Draft 2020-12 JSON Schema document into the\n * Effect schema representation system.\n *\n * **Details**\n *\n * `options.onEnter` is an optional hook called on each JSON Schema node before\n * processing, allowing pre-transformation.\n *\n * **Gotchas**\n *\n * JSON Schema import is best-effort. Some JSON Schema constructs do not map\n * exactly to Effect schema representations, and importing a schema previously\n * emitted by `toJsonSchemaDocument` may produce an equivalent approximation\n * rather than the original representation shape.\n *\n * This throws if a `$ref` cannot be resolved within the document's definitions.\n * Circular `$ref`s are detected and cause an error.\n *\n * @see {@link Document}\n * @see {@link toJsonSchemaDocument}\n * @see {@link fromJsonSchemaMultiDocument}\n *\n * @category constructors\n * @since 4.0.0\n */\nexport function fromJsonSchemaDocument(document, options) {\n const {\n references,\n representations: schemas\n } = fromJsonSchemaMultiDocument({\n dialect: document.dialect,\n schemas: [document.schema],\n definitions: document.definitions\n }, options);\n return {\n representation: schemas[0],\n references\n };\n}\n/**\n * Parses a Draft 2020-12 JSON Schema multi-document into a\n * {@link MultiDocument}.\n *\n * **When to use**\n *\n * Use when you need to import a Draft 2020-12 JSON Schema multi-document whose\n * schemas share definitions.\n *\n * **Details**\n *\n * `options.onEnter` is an optional hook called on each JSON Schema node before\n * processing.\n *\n * **Gotchas**\n *\n * JSON Schema import is best-effort. Some JSON Schema constructs do not map\n * exactly to Effect schema representations, and importing schemas previously\n * emitted by `toJsonSchemaMultiDocument` may produce equivalent approximations\n * rather than the original representation shapes.\n *\n * This throws if a `$ref` cannot be resolved.\n *\n * @see {@link MultiDocument}\n * @see {@link toJsonSchemaMultiDocument}\n * @see {@link fromJsonSchemaDocument}\n *\n * @category constructors\n * @since 4.0.0\n */\nexport function fromJsonSchemaMultiDocument(document, options) {\n let visited;\n const references = {};\n const slots = new Map();\n function getSlot(identifier) {\n const existing = slots.get(identifier);\n if (existing) return existing;\n // Create the slot *before* resolving, so self-references can see it.\n const slot = {\n state: 0,\n value: undefined\n };\n slots.set(identifier, slot);\n return slot;\n }\n function resolveReference($ref) {\n const definition = document.definitions[$ref];\n if (definition === undefined) {\n throw new Error(`Reference ${$ref} not found`);\n }\n const slot = getSlot($ref);\n if (slot.state === 2) {\n // Already built: return the built schema directly\n return slot.value;\n }\n if (slot.state === 1) {\n // Circular: we're currently building this identifier.\n throw new Error(`Circular reference detected: ${$ref}`);\n }\n // First time: build it.\n slot.state = 1;\n const value = recur(definition);\n slot.value = value._tag === \"Reference\" ? resolveReference(value.$ref) : value;\n slot.state = 2;\n return slot.value;\n }\n Object.entries(document.definitions).forEach(([identifier, definition]) => {\n visited = new Set([identifier]);\n references[identifier] = unknownToJson(recur(definition));\n });\n visited = new Set();\n const representations = Arr.map(document.schemas, schema => unknownToJson(recur(schema)));\n return {\n representations,\n references\n };\n function recur(u) {\n if (u === false) return never;\n if (!Predicate.isObject(u)) return unknown;\n let js = options?.onEnter?.(u) ?? u;\n if (Array.isArray(js.type)) {\n if (js.type.every(isType)) {\n const {\n type,\n ...rest\n } = js;\n js = {\n anyOf: type.map(type => ({\n type\n })),\n ...rest\n };\n } else {\n js = {};\n }\n }\n let out = on(js);\n const annotations = collectAnnotations(js);\n if (annotations !== undefined) {\n out = combine(out, {\n _tag: \"Unknown\",\n annotations\n });\n }\n if (Array.isArray(js.allOf)) {\n out = js.allOf.reduce((acc, curr) => combine(acc, recur(curr)), out);\n }\n if (Array.isArray(js.anyOf)) {\n out = combine({\n _tag: \"Union\",\n types: js.anyOf.map(type => recur(type)),\n mode: \"anyOf\"\n }, out);\n }\n if (Array.isArray(js.oneOf)) {\n out = combine({\n _tag: \"Union\",\n types: js.oneOf.map(type => recur(type)),\n mode: \"oneOf\"\n }, out);\n }\n return out;\n }\n function on(js) {\n if (typeof js.$ref === \"string\") {\n const $ref = js.$ref.slice(2).split(\"/\").at(-1);\n if ($ref !== undefined) {\n const reference = {\n _tag: \"Reference\",\n $ref: unescapeToken($ref)\n };\n if (visited.has($ref)) {\n return {\n _tag: \"Suspend\",\n thunk: reference,\n checks: []\n };\n } else {\n return reference;\n }\n }\n } else if (\"const\" in js) {\n if (isLiteralValue(js.const)) {\n return {\n _tag: \"Literal\",\n literal: js.const\n };\n } else if (js.const === null) {\n return null_;\n }\n } else if (Array.isArray(js.enum)) {\n const types = [];\n for (const e of js.enum) {\n if (isLiteralValue(e)) {\n types.push({\n _tag: \"Literal\",\n literal: e\n });\n } else if (e === null) {\n types.push(null_);\n } else {\n types.push(recur(e));\n }\n }\n if (types.length === 1) {\n return types[0];\n } else {\n return {\n _tag: \"Union\",\n types,\n mode: \"anyOf\"\n };\n }\n }\n const type = isType(js.type) ? js.type : getType(js);\n if (type !== undefined) {\n switch (type) {\n case \"null\":\n return null_;\n case \"string\":\n {\n const checks = collectStringChecks(js);\n if (checks.length > 0) {\n return {\n ...string,\n checks\n };\n }\n return string;\n }\n case \"number\":\n return {\n _tag: \"Number\",\n checks: [{\n _tag: \"Filter\",\n meta: {\n _tag: \"isFinite\"\n }\n }, ...collectNumberChecks(js)]\n };\n case \"integer\":\n return {\n _tag: \"Number\",\n checks: [{\n _tag: \"Filter\",\n meta: {\n _tag: \"isInt\"\n }\n }, ...collectNumberChecks(js)]\n };\n case \"boolean\":\n return boolean;\n case \"array\":\n {\n const minItems = typeof js.minItems === \"number\" ? js.minItems : 0;\n const elements = (Array.isArray(js.prefixItems) ? js.prefixItems : []).map((e, i) => ({\n isOptional: i + 1 > minItems,\n type: recur(e)\n }));\n const rest = js.items !== undefined ? [recur(js.items)] : js.prefixItems !== undefined && typeof js.maxItems === \"number\" ? [] : [unknown];\n return {\n _tag: \"Arrays\",\n elements,\n rest,\n checks: collectArraysChecks(js)\n };\n }\n case \"object\":\n {\n return {\n _tag: \"Objects\",\n propertySignatures: collectProperties(js),\n indexSignatures: collectIndexSignatures(js),\n checks: collectObjectsChecks(js)\n };\n }\n }\n }\n return {\n _tag: \"Unknown\"\n };\n }\n function collectObjectsChecks(js) {\n const checks = [];\n if (typeof js.minProperties === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMinProperties\",\n minProperties: js.minProperties\n }\n });\n }\n if (typeof js.maxProperties === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMaxProperties\",\n maxProperties: js.maxProperties\n }\n });\n }\n if (js.propertyNames !== undefined) {\n const propertyNames = recur(js.propertyNames);\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isPropertyNames\",\n propertyNames\n }\n });\n }\n return checks;\n }\n function combine(a, b) {\n switch (a._tag) {\n default:\n return never;\n case \"Reference\":\n return combine(resolveReference(a.$ref), b);\n case \"Never\":\n return a;\n case \"Unknown\":\n switch (b._tag) {\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return {\n ...b,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n }\n case \"Null\":\n switch (b._tag) {\n case \"Unknown\":\n case \"Null\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"String\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"String\":\n {\n const checks = combineChecks(a.checks, b.checks, b.annotations);\n return {\n _tag: \"String\",\n checks: checks ?? a.checks,\n ...combineAnnotations(a.annotations, checks ? undefined : b.annotations)\n };\n }\n case \"Literal\":\n return typeof b.literal === \"string\" ? {\n ...b,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Number\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Number\":\n {\n const checks = combineNumberChecks(a.checks, b.checks, b.annotations);\n return {\n _tag: \"Number\",\n checks: checks ?? a.checks,\n ...combineAnnotations(a.annotations, checks ? undefined : b.annotations)\n };\n }\n case \"Literal\":\n return typeof b.literal === \"number\" ? {\n ...b,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Boolean\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Boolean\":\n return {\n _tag: \"Boolean\",\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Literal\":\n return typeof b.literal === \"boolean\" ? {\n ...b,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Literal\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Literal\":\n return a.literal === b.literal ? {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"String\":\n return typeof a.literal === \"string\" ? {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Number\":\n return typeof a.literal === \"number\" ? {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Boolean\":\n return typeof a.literal === \"boolean\" ? {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n } : never;\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Arrays\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Arrays\":\n {\n const checks = combineArraysChecks(a.checks, b.checks, b.annotations);\n return {\n _tag: \"Arrays\",\n elements: combineElements(a.elements, b.elements),\n rest: combineRest(a.rest, b.rest),\n checks: checks ?? a.checks,\n ...combineAnnotations(a.annotations, checks ? undefined : b.annotations)\n };\n }\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Objects\":\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n case \"Objects\":\n {\n const checks = combineChecks(a.checks, b.checks, b.annotations);\n return {\n _tag: \"Objects\",\n propertySignatures: combinePropertySignatures(a.propertySignatures, b.propertySignatures),\n indexSignatures: combineIndexSignatures(a.indexSignatures, b.indexSignatures),\n checks: checks ?? a.checks,\n ...combineAnnotations(a.annotations, checks ? undefined : b.annotations)\n };\n }\n case \"Union\":\n return combine(b, a);\n case \"Reference\":\n return combine(a, resolveReference(b.$ref));\n default:\n return never;\n }\n case \"Union\":\n {\n switch (b._tag) {\n case \"Unknown\":\n return {\n ...a,\n ...combineAnnotations(a.annotations, b.annotations)\n };\n default:\n {\n const types = a.types.map(s => combine(s, b)).filter(s => s !== never);\n if (types.length === 0) return never;\n return {\n _tag: \"Union\",\n types,\n mode: a.mode,\n ...makeAnnotations(a.annotations)\n };\n }\n }\n }\n }\n }\n function collectProperties(js) {\n const properties = Predicate.isObject(js.properties) ? js.properties : {};\n const required = Array.isArray(js.required) ? js.required : [];\n required.forEach(key => {\n if (!Object.hasOwn(properties, key)) {\n properties[key] = {};\n }\n });\n return Object.entries(properties).map(([key, v]) => ({\n name: key,\n type: recur(v),\n isOptional: !required.includes(key),\n isMutable: false\n }));\n }\n function collectIndexSignatures(js) {\n const out = [];\n if (Predicate.isObject(js.patternProperties)) {\n for (const [pattern, value] of Object.entries(js.patternProperties)) {\n out.push({\n parameter: recur({\n pattern\n }),\n type: recur(value)\n });\n }\n }\n if (js.additionalProperties === undefined || js.additionalProperties === true) {\n out.push({\n parameter: string,\n type: unknown\n });\n } else if (Predicate.isObject(js.additionalProperties)) {\n out.push({\n parameter: string,\n type: recur(js.additionalProperties)\n });\n }\n return out;\n }\n function combineElements(a, b) {\n const len = Math.max(a.length, b.length);\n let out = [];\n for (let i = 0; i < len; i++) {\n out.push({\n isOptional: a[i].isOptional && b[i].isOptional,\n type: combine(a[i].type, b[i].type)\n });\n }\n if (a.length > len) {\n out = [...out, ...a.slice(len)];\n } else if (b.length > len) {\n out = [...out, ...b.slice(len)];\n }\n return out;\n }\n function combineRest(a, b) {\n const len = Math.max(a.length, b.length);\n let out = [];\n for (let i = 0; i < len; i++) {\n out.push(combine(a[i], b[i]));\n }\n if (a.length > len) {\n out = [...out, ...a.slice(len)];\n } else if (b.length > len) {\n out = [...out, ...b.slice(len)];\n }\n return out;\n }\n function combinePropertySignatures(a, b) {\n const propertySignatures = [];\n const thatPropertiesMap = {};\n for (const p of b) {\n thatPropertiesMap[p.name] = p;\n }\n const keys = new Set();\n for (const p of a) {\n keys.add(p.name);\n const thatp = thatPropertiesMap[p.name];\n if (thatp) {\n propertySignatures.push({\n name: p.name,\n type: combine(p.type, thatp.type),\n isOptional: p.isOptional && thatp.isOptional,\n isMutable: p.isMutable\n });\n } else {\n propertySignatures.push(p);\n }\n }\n for (const p of b) {\n if (!keys.has(p.name)) propertySignatures.push(p);\n }\n return propertySignatures;\n }\n function combineIndexSignatures(a, b) {\n if (a.length === 0 || b.length === 0) return [];\n const out = [...a];\n for (const is of b) {\n if (is.parameter === string) {\n const i = a.findIndex(is => is.parameter === string);\n if (i !== -1) {\n out[i] = {\n parameter: string,\n type: combine(a[i].type, is.type)\n };\n } else {\n out.push(is);\n }\n } else {\n out.push(is);\n }\n }\n return out;\n }\n function unknownToJson(representation) {\n switch (representation._tag) {\n case \"Unknown\":\n return representation.annotations === undefined ? json : {\n ...json,\n annotations: {\n ...json.annotations,\n ...representation.annotations\n }\n };\n case \"Suspend\":\n {\n const thunk = unknownToJson(representation.thunk);\n return thunk === representation.thunk ? representation : {\n ...representation,\n thunk\n };\n }\n case \"String\":\n {\n if (representation.contentSchema === undefined) return representation;\n const contentSchema = unknownToJson(representation.contentSchema);\n return contentSchema === representation.contentSchema ? representation : {\n ...representation,\n contentSchema\n };\n }\n case \"Arrays\":\n {\n const elements = SchemaAST.mapOrSame(representation.elements, element => {\n const type = unknownToJson(element.type);\n return type === element.type ? element : {\n ...element,\n type\n };\n });\n const rest = SchemaAST.mapOrSame(representation.rest, unknownToJson);\n return elements === representation.elements && rest === representation.rest ? representation : {\n ...representation,\n elements,\n rest\n };\n }\n case \"Objects\":\n {\n const propertySignatures = SchemaAST.mapOrSame(representation.propertySignatures, propertySignature => {\n const type = unknownToJson(propertySignature.type);\n return type === propertySignature.type ? propertySignature : {\n ...propertySignature,\n type\n };\n });\n const indexSignatures = SchemaAST.mapOrSame(representation.indexSignatures, indexSignature => {\n const type = unknownToJson(indexSignature.type);\n return type === indexSignature.type ? indexSignature : {\n ...indexSignature,\n type\n };\n });\n return propertySignatures === representation.propertySignatures && indexSignatures === representation.indexSignatures ? representation : {\n ...representation,\n propertySignatures,\n indexSignatures\n };\n }\n case \"Union\":\n {\n const types = SchemaAST.mapOrSame(representation.types, unknownToJson);\n return types === representation.types ? representation : {\n ...representation,\n types\n };\n }\n default:\n return representation;\n }\n }\n}\nfunction asChecks(checks, annotations) {\n if (Arr.isReadonlyArrayNonEmpty(checks)) {\n if (annotations !== undefined) {\n if (checks.length === 1) {\n const check = checks[0];\n if (check.annotations === undefined) {\n return [{\n ...check,\n annotations\n }];\n } else {\n return [{\n _tag: \"FilterGroup\",\n checks,\n annotations\n }];\n }\n } else {\n return [{\n _tag: \"FilterGroup\",\n checks,\n annotations\n }];\n }\n }\n return checks;\n }\n}\nfunction combineChecks(a, b, annotations) {\n const checks = asChecks(b, annotations);\n if (checks) {\n return [...a, ...checks];\n }\n}\nfunction combineNumberChecks(a, b, annotations) {\n if (a.some(c => c._tag === \"Filter\" && c.meta._tag === \"isFinite\")) {\n b = b.filter(c => c._tag !== \"Filter\" || c.meta._tag !== \"isFinite\");\n }\n if (a.some(c => c._tag === \"Filter\" && c.meta._tag === \"isInt\")) {\n b = b.filter(c => c._tag !== \"Filter\" || c.meta._tag !== \"isInt\");\n }\n return combineChecks(a, b, annotations);\n}\nfunction combineArraysChecks(a, b, annotations) {\n if (a.some(c => c._tag === \"Filter\" && c.meta._tag === \"isUnique\")) {\n b = b.filter(c => c._tag !== \"Filter\" || c.meta._tag !== \"isUnique\");\n }\n return combineChecks(a, b, annotations);\n}\nfunction makeAnnotations(annotations) {\n return annotations ? {\n annotations\n } : undefined;\n}\nfunction combineAnnotations(a, b) {\n if (a === undefined) return makeAnnotations(b);\n if (b === undefined) return makeAnnotations(a);\n return {\n annotations: {\n ...a,\n ...b\n }\n }; // TODO: better merge\n}\nfunction collectStringChecks(js) {\n const checks = [];\n if (typeof js.minLength === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMinLength\",\n minLength: js.minLength\n }\n });\n }\n if (typeof js.maxLength === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMaxLength\",\n maxLength: js.maxLength\n }\n });\n }\n if (typeof js.pattern === \"string\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isPattern\",\n regExp: new RegExp(js.pattern)\n }\n });\n }\n return checks;\n}\nfunction collectNumberChecks(js) {\n const checks = [];\n if (typeof js.minimum === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isGreaterThanOrEqualTo\",\n minimum: js.minimum\n }\n });\n }\n if (typeof js.maximum === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isLessThanOrEqualTo\",\n maximum: js.maximum\n }\n });\n }\n if (typeof js.exclusiveMinimum === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isGreaterThan\",\n exclusiveMinimum: js.exclusiveMinimum\n }\n });\n }\n if (typeof js.exclusiveMaximum === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isLessThan\",\n exclusiveMaximum: js.exclusiveMaximum\n }\n });\n }\n if (typeof js.multipleOf === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMultipleOf\",\n divisor: js.multipleOf\n }\n });\n }\n return checks;\n}\nfunction collectArraysChecks(js) {\n const checks = [];\n if (js.prefixItems === undefined) {\n if (typeof js.minItems === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMinLength\",\n minLength: js.minItems\n }\n });\n }\n if (typeof js.maxItems === \"number\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isMaxLength\",\n maxLength: js.maxItems\n }\n });\n }\n }\n if (typeof js.uniqueItems === \"boolean\") {\n checks.push({\n _tag: \"Filter\",\n meta: {\n _tag: \"isUnique\"\n }\n });\n }\n return checks;\n}\nconst unknown = {\n _tag: \"Unknown\"\n};\nconst json = {\n _tag: \"Declaration\",\n annotations: {\n expected: \"JSON value\",\n generation: {\n Type: \"Schema.Json\",\n runtime: \"Schema.Json\"\n },\n typeConstructor: {\n _tag: \"effect/Json\"\n }\n },\n checks: [],\n encodedSchema: unknown,\n typeParameters: []\n};\nconst never = {\n _tag: \"Never\"\n};\nconst null_ = {\n _tag: \"Null\"\n};\nconst string = {\n _tag: \"String\",\n checks: []\n};\nconst boolean = {\n _tag: \"Boolean\"\n};\nfunction collectAnnotations(schema) {\n const as = {};\n if (typeof schema.title === \"string\") as.title = schema.title;\n if (typeof schema.description === \"string\") as.description = schema.description;\n if (schema.default !== undefined) as.default = schema.default;\n if (Array.isArray(schema.examples)) as.examples = schema.examples;\n if (typeof schema.readOnly === \"boolean\") as.readOnly = schema.readOnly;\n if (typeof schema.writeOnly === \"boolean\") as.writeOnly = schema.writeOnly;\n if (typeof schema.format === \"string\") as.format = schema.format;\n if (typeof schema.contentEncoding === \"string\") as.contentEncoding = schema.contentEncoding;\n if (typeof schema.contentMediaType === \"string\") as.contentMediaType = schema.contentMediaType;\n return Rec.isEmptyRecord(as) ? undefined : as;\n}\nfunction isLiteralValue(value) {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\nconst stringKeys = [\"minLength\", \"maxLength\", \"pattern\", \"format\", \"contentMediaType\", \"contentSchema\"];\nconst numberKeys = [\"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\", \"multipleOf\"];\nconst objectKeys = [\"properties\", \"required\", \"additionalProperties\", \"patternProperties\", \"propertyNames\", \"minProperties\", \"maxProperties\"];\nconst arrayKeys = [\"items\", \"prefixItems\", \"additionalItems\", \"minItems\", \"maxItems\", \"uniqueItems\"];\nfunction getType(js) {\n if (stringKeys.some(key => js[key] !== undefined)) {\n return \"string\";\n }\n if (numberKeys.some(key => js[key] !== undefined)) {\n return \"number\";\n }\n if (objectKeys.some(key => js[key] !== undefined)) {\n return \"object\";\n }\n if (arrayKeys.some(key => js[key] !== undefined)) {\n return \"array\";\n }\n}\nconst types = [\"null\", \"string\", \"number\", \"integer\", \"boolean\", \"object\", \"array\"];\nfunction isType(type) {\n return typeof type === \"string\" && types.includes(type);\n}\n/** @internal */\nexport function topologicalSort(references) {\n const identifiers = Object.keys(references);\n const identifierSet = new Set(identifiers);\n const collectRefs = root => {\n const refs = new Set();\n const visited = new WeakSet();\n const stack = [root];\n while (stack.length > 0) {\n const r = stack.pop();\n if (visited.has(r)) continue;\n visited.add(r);\n if (r._tag === \"Reference\") {\n if (identifierSet.has(r.$ref)) {\n refs.add(r.$ref);\n }\n }\n // Push nested Representation schemas onto the stack\n switch (r._tag) {\n case \"Declaration\":\n for (const typeParam of r.typeParameters) stack.push(typeParam);\n stack.push(r.encodedSchema);\n break;\n case \"Suspend\":\n stack.push(r.thunk);\n break;\n case \"String\":\n if (r.contentSchema !== undefined) stack.push(r.contentSchema);\n break;\n case \"TemplateLiteral\":\n for (const part of r.parts) stack.push(part);\n break;\n case \"Arrays\":\n for (const element of r.elements) stack.push(element.type);\n for (const rest of r.rest) stack.push(rest);\n break;\n case \"Objects\":\n for (const propertySignature of r.propertySignatures) stack.push(propertySignature.type);\n for (const indexSignature of r.indexSignatures) {\n stack.push(indexSignature.parameter);\n stack.push(indexSignature.type);\n }\n break;\n case \"Union\":\n for (const type of r.types) stack.push(type);\n break;\n }\n }\n return refs;\n };\n // identifier -> internal identifiers it depends on\n const dependencies = new Map(identifiers.map(id => [id, collectRefs(references[id])]));\n // Mark only nodes that are part of cycles\n const recursive = new Set();\n const state = new Map(); // 0 = new, 1 = visiting, 2 = done\n const stack = [];\n const indexInStack = new Map();\n const dfs = id => {\n const s = state.get(id) ?? 0;\n if (s === 1) {\n const start = indexInStack.get(id);\n if (start !== undefined) {\n for (let i = start; i < stack.length; i++) {\n recursive.add(stack[i]);\n }\n }\n return;\n }\n if (s === 2) return;\n state.set(id, 1);\n indexInStack.set(id, stack.length);\n stack.push(id);\n for (const dep of dependencies.get(id) ?? []) {\n dfs(dep);\n }\n stack.pop();\n indexInStack.delete(id);\n state.set(id, 2);\n };\n for (const id of identifiers) dfs(id);\n // Topologically sort the non-recursive nodes (ignoring edges to recursive nodes)\n const inDegree = new Map();\n const dependents = new Map(); // dep -> nodes that depend on it\n for (const id of identifiers) {\n if (!recursive.has(id)) {\n inDegree.set(id, 0);\n dependents.set(id, new Set());\n }\n }\n for (const [id, deps] of dependencies) {\n if (recursive.has(id)) continue;\n for (const dep of deps) {\n if (recursive.has(dep)) continue;\n inDegree.set(id, (inDegree.get(id) ?? 0) + 1);\n dependents.get(dep)?.add(id);\n }\n }\n const queue = [];\n for (const [id, deg] of inDegree) {\n if (deg === 0) queue.push(id);\n }\n const nonRecursives = [];\n for (let i = 0; i < queue.length; i++) {\n const $ref = queue[i];\n nonRecursives.push({\n $ref,\n representation: references[$ref]\n });\n for (const next of dependents.get($ref) ?? []) {\n const deg = (inDegree.get(next) ?? 0) - 1;\n inDegree.set(next, deg);\n if (deg === 0) queue.push(next);\n }\n }\n const recursives = {};\n for (const $ref of recursive) {\n recursives[$ref] = references[$ref];\n }\n return {\n nonRecursives,\n recursives\n };\n}\n//# sourceMappingURL=SchemaRepresentation.js.map","/**\n * Small helpers for schema patterns that are too specialized for the main\n * `Schema` module. The current helper builds a schema for an existing class:\n * the encoded input is checked with a struct schema, decoding calls the class\n * constructor with the decoded properties, and the final value remains an\n * instance of that class.\n *\n * @since 4.0.0\n */\nimport { identity } from \"./Function.js\";\nimport * as Schema from \"./Schema.js\";\nimport * as SchemaTransformation from \"./SchemaTransformation.js\";\n/**\n * Builds an experimental schema for instances of a native class using a struct\n * schema as the encoded representation.\n *\n * **When to use**\n *\n * Use when you need a schema for an existing native class while keeping a\n * `Struct` schema as its encoded representation.\n *\n * **Details**\n *\n * Decoding constructs `new constructor(props)` from the encoded fields.\n * Encoding uses the instance as the encoded shape, so the class should expose\n * properties compatible with the provided encoding schema.\n *\n * @see {@link Schema.instanceOf} for validating existing class instances without a struct encoding\n * @see {@link Schema.Class} for defining schema-backed classes directly\n * @see {@link Schema.ErrorClass} for defining schema-backed error classes\n *\n * @category schemas\n * @since 4.0.0\n */\nexport function getNativeClassSchema(constructor, options) {\n const transformation = SchemaTransformation.transform({\n decode: props => new constructor(props),\n encode: identity\n });\n return Schema.instanceOf(constructor, {\n toCodec: () => Schema.link()(options.encoding, transformation),\n ...options.annotations\n }).pipe(Schema.encodeTo(options.encoding, transformation));\n}\n//# sourceMappingURL=SchemaUtils.js.map","/**\n * Caches values that need scoped resource management.\n *\n * Each cached entry owns its own `Scope`, so resources opened while creating a\n * value stay alive while that entry is cached and are released when the entry is\n * removed. A `ScopedCache` also belongs to an outer scope, which closes all\n * remaining entries when the cache is closed. Lookups for the same missing key\n * share one in-progress effect, and entries can expire, be refreshed, be\n * invalidated, or be evicted by capacity limits.\n *\n * @since 4.0.0\n */\nimport * as Arr from \"./Array.js\";\nimport * as Context from \"./Context.js\";\nimport * as Deferred from \"./Deferred.js\";\nimport * as Duration from \"./Duration.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport { dual, identity } from \"./Function.js\";\nimport * as core from \"./internal/core.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as effect from \"./internal/effect.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport * as Option from \"./Option.js\";\nimport * as Predicate from \"./Predicate.js\";\nimport * as Scope from \"./Scope.js\";\nconst TypeId = \"~effect/ScopedCache\";\n/**\n * Creates a `ScopedCache` from a lookup function, maximum capacity, and a\n * time-to-live function computed from each lookup exit and key.\n *\n * **When to use**\n *\n * Use when you need a scoped cache whose entry lifetime depends on each lookup\n * result or key.\n *\n * **Details**\n *\n * The cache must be constructed in a `Scope`. Each lookup runs in its own entry\n * scope, and that scope is closed when the entry expires, is invalidated, is\n * evicted by capacity, or when the cache's owning scope closes.\n * `requireServicesAt` controls whether lookup services are captured at\n * construction time or required when lookup operations run.\n *\n * @see {@link make} for creating a scoped cache with one fixed time-to-live\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeWith = options => effect.contextWith(context => {\n const scope = Context.get(context, Scope.Scope);\n const self = Object.create(Proto);\n self.lookup = key => effect.updateContext(options.lookup(key), input => Context.merge(context, input));\n const map = MutableHashMap.empty();\n self.state = {\n _tag: \"Open\",\n map\n };\n self.capacity = options.capacity;\n self.timeToLive = options.timeToLive ? (exit, key) => Duration.fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;\n return effect.as(Scope.addFinalizer(scope, core.withFiber(fiber => {\n self.state = {\n _tag: \"Closed\"\n };\n return invalidateAllImpl(fiber, map);\n })), self);\n});\n/**\n * Creates a `ScopedCache` with a fixed time-to-live for every lookup result.\n *\n * **When to use**\n *\n * Use to create a scoped cache when every cached lookup result should share the\n * same lifetime.\n *\n * **Details**\n *\n * This is the constant-TTL variant of `makeWith`: values are acquired by the\n * lookup effect in per-entry scopes, capacity can evict older entries, and\n * entry scopes are closed when entries expire, are invalidated, are evicted, or\n * when the cache's owning scope closes.\n *\n * @see {@link makeWith} for computing time-to-live from each lookup result and key\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = options => makeWith({\n ...options,\n timeToLive: options.timeToLive ? () => options.timeToLive : defaultTimeToLive\n});\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n toJSON() {\n return {\n _id: \"ScopedCache\",\n capacity: this.capacity,\n state: this.state\n };\n }\n};\nconst defaultTimeToLive = (_, _key) => Duration.infinity;\n/**\n * Gets the value for a key, running the cache lookup when no unexpired entry is\n * present.\n *\n * **When to use**\n *\n * Use to retrieve a scoped cached value by key when a missing or expired entry\n * should run the cache lookup and share the in-flight lookup with concurrent\n * callers.\n *\n * **Details**\n *\n * Concurrent `get` calls for the same key share the same in-flight lookup.\n * Successful and failed lookup exits are cached according to the configured\n * TTL. If the cache is closed, the effect is interrupted.\n *\n * @see {@link getOption} for reading only when an unexpired entry is already cached\n * @see {@link getSuccess} for inspecting an already-completed successful entry\n * @see {@link refresh} for forcing a new lookup\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const get = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptibleMask(restore => core.withFiber(fiber => {\n const state = self.state;\n if (state._tag === \"Closed\") {\n return effect.interrupt;\n }\n const oentry = MutableHashMap.get(state.map, key);\n if (Option.isSome(oentry) && !hasExpired(oentry.value, fiber)) {\n // Move the entry to the end of the map to keep it fresh\n MutableHashMap.remove(state.map, key);\n MutableHashMap.set(state.map, key, oentry.value);\n return restore(Deferred.await(oentry.value.deferred));\n }\n const scope = Scope.makeUnsafe();\n const deferred = Deferred.makeUnsafe();\n const entry = {\n expiresAt: undefined,\n deferred,\n scope\n };\n MutableHashMap.set(state.map, key, entry);\n return checkCapacity(fiber, state.map, self.capacity).pipe(Option.isSome(oentry) ? effect.flatMap(() => Scope.close(oentry.value.scope, effect.exitVoid)) : identity, effect.flatMap(() => Scope.provide(restore(self.lookup(key)), scope)), effect.onExit(exit => {\n Deferred.doneUnsafe(deferred, exit);\n const ttl = self.timeToLive(exit, key);\n if (Duration.isFinite(ttl)) {\n entry.expiresAt = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl);\n }\n return effect.void;\n }));\n})));\nconst hasExpired = (entry, fiber) => {\n if (entry.expiresAt === undefined) {\n return false;\n }\n return fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() >= entry.expiresAt;\n};\nconst checkCapacity = (parent, map, capacity) => {\n if (!Number.isFinite(capacity)) return effect.void;\n let diff = MutableHashMap.size(map) - capacity;\n if (diff <= 0) return effect.void;\n // MutableHashMap has insertion order, so we can remove the oldest entries\n const fibers = Arr.empty();\n for (const [key, entry] of map) {\n MutableHashMap.remove(map, key);\n fibers.push(effect.forkUnsafe(parent, Scope.close(entry.scope, effect.exitVoid), true));\n diff--;\n if (diff === 0) break;\n }\n return effect.fiberAwaitAll(fibers);\n};\n/**\n * Reads an existing unexpired cache entry without running the lookup function.\n *\n * **When to use**\n *\n * Use to read a scoped value only when it is already cached, without starting\n * the lookup for missing or expired keys.\n *\n * **Details**\n *\n * Returns `Option.none` when the key is absent or expired. If an entry exists,\n * the effect waits for its cached result and returns `Option.some(value)` on\n * success, or fails with the cached lookup error.\n *\n * @see {@link get} for running the lookup on missing or expired keys\n * @see {@link getSuccess} for inspecting only already-completed successful entries\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getOption = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptibleMask(restore => core.withFiber(fiber => effect.flatMap(getImpl(self, key, fiber), entry => entry ? effect.asSome(restore(Deferred.await(entry.deferred))) : effect.succeedNone))));\nconst getImpl = (self, key, fiber, isRead = true) => {\n if (self.state._tag === \"Closed\") {\n return effect.interrupt;\n }\n const state = self.state;\n const oentry = MutableHashMap.get(state.map, key);\n if (Option.isNone(oentry)) {\n return effect.undefined;\n } else if (hasExpired(oentry.value, fiber)) {\n MutableHashMap.remove(state.map, key);\n return effect.as(Scope.close(oentry.value.scope, effect.exitVoid), undefined);\n } else if (isRead) {\n MutableHashMap.remove(state.map, key);\n MutableHashMap.set(state.map, key, oentry.value);\n }\n return effect.succeed(oentry.value);\n};\n/**\n * Retrieves the value associated with the specified key from the cache, only if\n * it contains a resolved successful value.\n *\n * **When to use**\n *\n * Use to inspect an already-completed successful scoped cache entry without\n * running or awaiting the lookup effect.\n *\n * **Details**\n *\n * Returns `Option.some` for a resolved successful entry. Returns `Option.none`\n * for missing, expired, failed, or still-pending entries.\n *\n * @see {@link get} for awaiting or starting the lookup effect\n * @see {@link getOption} for awaiting an already-cached entry without starting a lookup\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getSuccess = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptible(core.withFiber(fiber => effect.map(getImpl(self, key, fiber), entry => {\n const exit = entry?.deferred.effect;\n if (exit && effect.exitIsSuccess(exit)) {\n return Option.some(exit.value);\n }\n return Option.none();\n}))));\n/**\n * Sets a successful value for a key without running the lookup function.\n *\n * **When to use**\n *\n * Use to seed or overwrite a scoped cache entry with an already available\n * successful value.\n *\n * **Details**\n *\n * This replaces and closes any existing entry scope for the key, applies the\n * cache's TTL using a successful exit for the value, and may evict older\n * entries if the cache capacity is exceeded.\n *\n * @see {@link get} for reading or computing a cached value\n * @see {@link refresh} for replacing an entry by running the lookup function\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const set = /*#__PURE__*/dual(3, (self, key, value) => effect.uninterruptible(core.withFiber(fiber => {\n if (self.state._tag === \"Closed\") {\n return effect.interrupt;\n }\n const oentry = MutableHashMap.get(self.state.map, key);\n const state = self.state;\n const exit = core.exitSucceed(value);\n const deferred = Deferred.makeUnsafe();\n Deferred.doneUnsafe(deferred, exit);\n const ttl = self.timeToLive(exit, key);\n MutableHashMap.set(state.map, key, {\n scope: Scope.makeUnsafe(),\n deferred,\n expiresAt: Duration.isFinite(ttl) ? fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl) : undefined\n });\n const check = checkCapacity(fiber, state.map, self.capacity);\n return Option.isSome(oentry) ? effect.flatMap(Scope.close(oentry.value.scope, effect.exitVoid), () => check) : check;\n})));\n/**\n * Checks whether the cache contains an entry for the specified key.\n *\n * **When to use**\n *\n * Use to test whether an unexpired entry exists for a key without running the\n * cache lookup.\n *\n * **Details**\n *\n * This does not start lookups and does not refresh access order. Expired\n * entries are treated as absent and their scopes are closed while checking. If\n * the cache is closed, the effect is interrupted.\n *\n * @see {@link getOption} for reading an existing cached entry\n * @see {@link get} for running the lookup on missing or expired keys\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptible(core.withFiber(fiber => effect.map(getImpl(self, key, fiber, false), Predicate.isNotUndefined))));\n/**\n * Removes the entry associated with a key and closes its entry scope.\n *\n * **When to use**\n *\n * Use to remove a single key from a scoped cache and release any resources owned\n * by that entry before a later lookup computes it again.\n *\n * **Details**\n *\n * If the key is absent, this is a no-op.\n *\n * **Gotchas**\n *\n * If the cache is closed, the effect is interrupted.\n *\n * @see {@link refresh} for replacing a key by running a new lookup immediately\n * @see {@link invalidateWhen} for invalidating only when a cached value matches a predicate\n * @see {@link invalidateAll} for removing every cached entry\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidate = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptible(effect.suspend(() => {\n if (self.state._tag === \"Closed\") {\n return effect.interrupt;\n }\n const oentry = MutableHashMap.get(self.state.map, key);\n if (Option.isNone(oentry)) {\n return effect.void;\n }\n MutableHashMap.remove(self.state.map, key);\n return Scope.close(oentry.value.scope, effect.exitVoid);\n})));\n/**\n * Invalidates the entry associated with the specified key in the cache when the\n * predicate returns true for the cached value.\n *\n * **When to use**\n *\n * Use to remove an already-cached scoped value only when the successful cached\n * value satisfies a predicate.\n *\n * **Details**\n *\n * Returns `true` only when a successful cached value matches and is removed. It\n * returns `false` for absent, expired, failed, or non-matching entries.\n *\n * **Gotchas**\n *\n * A matching invalidation closes the entry scope and releases its resources.\n *\n * @see {@link invalidate} for unconditional removal by key\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidateWhen = /*#__PURE__*/dual(3, (self, key, f) => effect.uninterruptibleMask(restore => core.withFiber(fiber => effect.flatMap(getImpl(self, key, fiber, false), entry => {\n if (entry === undefined) {\n return effect.succeed(false);\n }\n return restore(Deferred.await(entry.deferred)).pipe(effect.flatMap(value => {\n if (self.state._tag === \"Closed\") {\n return effect.succeed(false);\n } else if (f(value)) {\n MutableHashMap.remove(self.state.map, key);\n return effect.as(Scope.close(entry.scope, effect.exitVoid), true);\n }\n return effect.succeed(false);\n }), effect.catch_(() => effect.succeed(false)));\n}))));\n/**\n * Forces a refresh of the value associated with the specified key in the cache.\n *\n * **When to use**\n *\n * Use to recompute a scoped cache entry immediately, even when an unexpired\n * value is already cached.\n *\n * **Details**\n *\n * It will always invoke the lookup function to construct a new value,\n * overwriting any existing value for that key.\n *\n * @see {@link get} for reusing an unexpired entry before running the lookup\n * @see {@link invalidate} for removing an entry without recomputing it\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const refresh = /*#__PURE__*/dual(2, (self, key) => effect.uninterruptibleMask(effect.fnUntraced(function* (restore) {\n if (self.state._tag === \"Closed\") return yield* effect.interrupt;\n const fiber = Fiber.getCurrent();\n const scope = Scope.makeUnsafe();\n const deferred = Deferred.makeUnsafe();\n const entry = {\n scope,\n expiresAt: undefined,\n deferred\n };\n const newEntry = !MutableHashMap.has(self.state.map, key);\n if (newEntry) {\n MutableHashMap.set(self.state.map, key, entry);\n yield* checkCapacity(fiber, self.state.map, self.capacity);\n }\n const exit = yield* effect.exit(restore(Scope.provide(self.lookup(key), scope)));\n Deferred.doneUnsafe(deferred, exit);\n // @ts-ignore async gap\n if (self.state._tag === \"Closed\") {\n if (!newEntry) {\n yield* Scope.close(scope, effect.exitVoid);\n }\n return yield* effect.interrupt;\n }\n const ttl = self.timeToLive(exit, key);\n entry.expiresAt = Duration.isFinite(ttl) ? fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl) : undefined;\n if (!newEntry) {\n const oentry = MutableHashMap.get(self.state.map, key);\n MutableHashMap.set(self.state.map, key, entry);\n if (Option.isSome(oentry)) {\n yield* Scope.close(oentry.value.scope, effect.exitVoid);\n }\n }\n return yield* exit;\n})));\n/**\n * Removes every entry from the cache and closes each entry scope.\n *\n * **When to use**\n *\n * Use to clear a scoped cache and release resources owned by all cached entries.\n *\n * **Details**\n *\n * If the cache is closed, the effect is interrupted.\n *\n * @see {@link invalidate} for removing one cached entry\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidateAll = self => core.withFiber(parent => {\n if (self.state._tag === \"Closed\") {\n return effect.interrupt;\n }\n return invalidateAllImpl(parent, self.state.map);\n});\nconst invalidateAllImpl = (parent, map) => {\n const fibers = Arr.empty();\n for (const [, entry] of map) {\n fibers.push(effect.forkUnsafe(parent, Scope.close(entry.scope, effect.exitVoid), true, true));\n }\n MutableHashMap.clear(map);\n return effect.fiberAwaitAll(fibers);\n};\n/**\n * Retrieves the approximate number of entries in the cache.\n *\n * **When to use**\n *\n * Use to inspect how many entries are currently stored in the scoped cache.\n *\n * **Gotchas**\n *\n * Note that expired entries are counted until they are accessed and removed.\n * The size reflects the current number of entries stored, not the number\n * of valid entries.\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const size = self => effect.sync(() => self.state._tag === \"Closed\" ? 0 : MutableHashMap.size(self.state.map));\n/**\n * Retrieves all active keys from the cache, automatically filtering out expired entries.\n *\n * **When to use**\n *\n * Use to inspect currently cached unexpired keys without running cache lookups.\n *\n * **Gotchas**\n *\n * Expired entries are removed and their scopes are closed while filtering.\n *\n * @see {@link entries} for retrieving successful cached key-value pairs\n * @see {@link values} for retrieving only successfully cached values\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const keys = self => core.withFiber(fiber => {\n if (self.state._tag === \"Closed\") return effect.succeed([]);\n const state = self.state;\n const now = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe();\n const fibers = Arr.empty();\n const keys = [];\n for (const [key, entry] of state.map) {\n if (entry.expiresAt === undefined || entry.expiresAt > now) {\n keys.push(key);\n } else {\n MutableHashMap.remove(state.map, key);\n fibers.push(effect.forkUnsafe(fiber, Scope.close(entry.scope, effect.exitVoid), true, true));\n }\n }\n return fibers.length === 0 ? effect.succeed(keys) : effect.as(effect.fiberAwaitAll(fibers), keys);\n});\n/**\n * Retrieves all successfully cached values from the cache, excluding failed\n * lookups and expired entries.\n *\n * **When to use**\n *\n * Use to inspect currently successful cached values without running cache\n * lookups.\n *\n * **Gotchas**\n *\n * Expired entries are removed and their scopes are closed while filtering.\n *\n * @see {@link entries} for retrieving successful cached key-value pairs\n * @see {@link keys} for retrieving only cached keys\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const values = self => effect.map(entries(self), Arr.map(([, value]) => value));\n/**\n * Retrieves all key-value pairs from the cache as an array. This function\n * only returns entries with successfully resolved values, filtering out any\n * failed lookups or expired entries.\n *\n * **When to use**\n *\n * Use to inspect the currently successful cached key-value pairs without\n * running cache lookups.\n *\n * **Gotchas**\n *\n * Expired entries are removed and their scopes are closed while filtering.\n *\n * @see {@link keys} for retrieving only cached keys\n * @see {@link values} for retrieving only cached values\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const entries = self => core.withFiber(fiber => {\n if (self.state._tag === \"Closed\") return effect.succeed([]);\n const state = self.state;\n const now = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe();\n const fibers = Arr.empty();\n const arr = [];\n for (const [key, entry] of state.map) {\n if (entry.expiresAt === undefined || entry.expiresAt > now) {\n const exit = entry.deferred.effect;\n if (core.isExit(exit) && !effect.exitIsFailure(exit)) {\n arr.push([key, exit.value]);\n }\n } else {\n MutableHashMap.remove(state.map, key);\n fibers.push(effect.forkUnsafe(fiber, Scope.close(entry.scope, effect.exitVoid), true, true));\n }\n }\n return fibers.length === 0 ? effect.succeed(arr) : effect.as(effect.fiberAwaitAll(fibers), arr);\n});\n//# sourceMappingURL=ScopedCache.js.map","/**\n * Service contract for command-line arguments and standard input, output, and\n * error output. It lets programs depend on standard I/O through the Effect\n * environment instead of reading from or writing to global process handles\n * directly.\n *\n * The service exposes arguments as an `Effect`, stdout and stderr as `Sink`s\n * that accept strings or bytes, and stdin as a byte `Stream`. This module also\n * provides a constructor for service values and a small test layer with\n * overridable defaults.\n *\n * @since 4.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as Sink from \"./Sink.js\";\nimport * as Stream from \"./Stream.js\";\n/**\n * Runtime identifier stored on `Stdio` service implementations.\n *\n * **Details**\n *\n * This marker is part of the runtime representation of `Stdio` service\n * implementations.\n *\n * @category type IDs\n * @since 4.0.0\n */\nexport const TypeId = \"~effect/Stdio\";\n/**\n * Service tag for process standard I/O.\n *\n * **When to use**\n *\n * Use when you need command-line arguments or standard I/O streams supplied by\n * an effect's environment.\n *\n * @see {@link make} for constructing a `Stdio` service directly\n * @see {@link layerTest} for a test layer with defaults and overrides\n *\n * @category services\n * @since 4.0.0\n */\nexport const Stdio = /*#__PURE__*/Context.Service(TypeId);\n/**\n * Creates a `Stdio` service implementation from the provided fields and\n * attaches the `Stdio` type identifier.\n *\n * **When to use**\n *\n * Use when you need to assemble a concrete `Stdio` service from command-line\n * arguments and standard I/O implementations.\n *\n * **Details**\n *\n * The returned service reuses the supplied fields unchanged and only adds the\n * `Stdio` type identifier; it does not create a `Layer` or provide defaults.\n *\n * @see {@link layerTest} for a test layer with default fields that can be overridden\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = options => ({\n [TypeId]: TypeId,\n ...options\n});\n/**\n * Creates a test layer for `Stdio`.\n *\n * **When to use**\n *\n * Use to provide deterministic standard I/O in tests while overriding only the\n * command-line arguments, input stream, or output sinks relevant to the case.\n *\n * **Details**\n *\n * Any provided fields override defaults. By default, arguments are empty,\n * standard output and error are draining sinks, and standard input is an empty\n * stream.\n *\n * @see {@link make} for constructing a `Stdio` service directly without a `Layer` or defaults\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layerTest = impl => Layer.succeed(Stdio, make({\n args: Effect.succeed([]),\n stdout: () => Sink.drain,\n stderr: () => Sink.drain,\n stdin: Stream.empty,\n ...impl\n}));\n//# sourceMappingURL=Stdio.js.map","/**\n * Stores mutable state and publishes changes as a stream.\n *\n * A `SubscriptionRef<A>` stores the latest value, publishes the initial value,\n * and publishes every committed update so subscribers can observe state over\n * time. Updates are serialized so only one change is applied at a time. This\n * module includes constructors, current-value reads, the `changes` stream,\n * writes, updates, partial updates, and effectful update helpers.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual, identity } from \"./Function.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as Option from \"./Option.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as PubSub from \"./PubSub.js\";\nimport * as Semaphore from \"./Semaphore.js\";\nimport * as Stream from \"./Stream.js\";\nconst TypeId = \"~effect/SubscriptionRef\";\n/**\n * Returns `true` if the provided value is a `SubscriptionRef`.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before calling `SubscriptionRef` operations\n * that require a subscription reference.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isSubscriptionRef = u => hasProperty(u, TypeId);\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: {\n _A: identity\n },\n toJSON() {\n return {\n _id: \"SubscriptionRef\",\n value: this.value\n };\n }\n};\n/**\n * Constructs a new `SubscriptionRef` from an initial value.\n *\n * **When to use**\n *\n * Use to create a `SubscriptionRef` when consumers need to read the latest\n * value and subscribe to every update.\n *\n * **Details**\n *\n * The initial value is published during construction, so `changes` starts new\n * subscribers with that value before future updates.\n *\n * @see {@link changes} for streaming the current value and subsequent updates\n * @see {@link set} for replacing the value and notifying subscribers\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = value => Effect.map(PubSub.unbounded({\n replay: 1\n}), pubsub => {\n const self = Object.create(Proto);\n self.semaphore = Semaphore.makeUnsafe(1);\n self.value = value;\n self.pubsub = pubsub;\n PubSub.publishUnsafe(self.pubsub, value);\n return self;\n});\n/**\n * Creates a stream that emits the current value and all subsequent changes to\n * the `SubscriptionRef`.\n *\n * **Details**\n *\n * The stream will first emit the current value, then emit all future changes\n * as they occur.\n *\n * **Example** (Streaming changes)\n *\n * ```ts\n * import { Deferred, Effect, Fiber, Stream, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(0)\n * const ready = yield* Deferred.make<void>()\n *\n * const fiber = yield* SubscriptionRef.changes(ref).pipe(\n * Stream.tap(() => Deferred.succeed(ready, void 0)),\n * Stream.take(3),\n * Stream.runCollect,\n * Effect.forkChild\n * )\n *\n * yield* Deferred.await(ready)\n * yield* SubscriptionRef.set(ref, 1)\n * yield* SubscriptionRef.set(ref, 2)\n *\n * const values = yield* Fiber.join(fiber)\n * console.log(values) // [ 0, 1, 2 ]\n * })\n *\n * Effect.runPromise(program)\n * ```\n *\n * @category changes\n * @since 4.0.0\n */\nexport const changes = self => Stream.fromPubSub(self.pubsub);\n/**\n * Retrieves the current value of the `SubscriptionRef` unsafely.\n *\n * **When to use**\n *\n * Use when you are in synchronous internals or test setup where concurrent\n * updates are controlled.\n *\n * **Gotchas**\n *\n * This function directly accesses the underlying reference without any\n * synchronization. It should only be used when you are certain there are no\n * concurrent modifications.\n *\n * **Example** (Reading the current value unsafely)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(42)\n *\n * const value = SubscriptionRef.getUnsafe(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category getters\n * @since 4.0.0\n */\nexport const getUnsafe = self => self.value;\n/**\n * Retrieves the current value of the `SubscriptionRef`.\n *\n * **Example** (Reading the current value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(42)\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const get = self => Effect.sync(() => self.value);\n/**\n * Retrieves the current value and sets a new value atomically, notifying\n * subscribers of the change.\n *\n * **Example** (Getting and setting a value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const oldValue = yield* SubscriptionRef.getAndSet(ref, 20)\n * console.log(\"Old value:\", oldValue)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const getAndSet = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Effect.sync(() => {\n const current = self.value;\n setUnsafe(self, value);\n return current;\n})));\nconst setUnsafe = (self, value) => {\n self.value = value;\n PubSub.publishUnsafe(self.pubsub, value);\n};\n/**\n * Retrieves the current value and updates it atomically with the result of\n * applying a function, notifying subscribers of the change.\n *\n * **Example** (Getting and updating a value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const oldValue = yield* SubscriptionRef.getAndUpdate(ref, (n) => n * 2)\n * console.log(\"Old value:\", oldValue)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const getAndUpdate = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const current = self.value;\n const newValue = update(current);\n setUnsafe(self, newValue);\n return current;\n})));\n/**\n * Retrieves the current value and updates it atomically with the result of\n * applying an effectful function, notifying subscribers of the change.\n *\n * **Example** (Getting and updating with an effect)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const oldValue = yield* SubscriptionRef.getAndUpdateEffect(\n * ref,\n * (n) => Effect.succeed(n + 5)\n * )\n * console.log(\"Old value:\", oldValue)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const getAndUpdateEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const current = self.value;\n return Effect.map(update(current), newValue => {\n setUnsafe(self, newValue);\n return current;\n });\n})));\n/**\n * Retrieves the current value and optionally updates the reference.\n *\n * **When to use**\n *\n * Use to read the old `SubscriptionRef` value while applying a synchronous\n * update only when a new value is available.\n *\n * **Details**\n *\n * If the function returns `Option.some`, the new value is set and published. If\n * it returns `Option.none`, the reference is left unchanged and no update is\n * published.\n *\n * **Example** (Getting and conditionally updating a value)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const oldValue = yield* SubscriptionRef.getAndUpdateSome(\n * ref,\n * (n) => n > 5 ? Option.some(n * 2) : Option.none()\n * )\n * console.log(\"Old value:\", oldValue)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const getAndUpdateSome = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const current = self.value;\n const option = update(current);\n if (Option.isNone(option)) {\n return Effect.succeed(current);\n }\n setUnsafe(self, option.value);\n return current;\n})));\n/**\n * Retrieves the current value and optionally updates the reference effectfully.\n *\n * **When to use**\n *\n * Use to read the old `SubscriptionRef` value while applying an effectful\n * update only when a new value is available.\n *\n * **Details**\n *\n * If the effect succeeds with `Option.some`, the new value is set and\n * published. If it succeeds with `Option.none`, the reference is left unchanged\n * and no update is published.\n *\n * **Example** (Getting and conditionally updating with an effect)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const oldValue = yield* SubscriptionRef.getAndUpdateSomeEffect(\n * ref,\n * (n) => Effect.succeed(n > 5 ? Option.some(n + 3) : Option.none())\n * )\n * console.log(\"Old value:\", oldValue)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const getAndUpdateSomeEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.suspend(() => {\n const current = self.value;\n return Effect.map(update(current), option => {\n if (Option.isNone(option)) return current;\n setUnsafe(self, option.value);\n return current;\n });\n})));\n/**\n * Modifies the `SubscriptionRef` atomically with a function that computes a\n * return value and a new value, notifying subscribers of the change.\n *\n * **Example** (Modifying a value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const result = yield* SubscriptionRef.modify(ref, (n) => [\n * `Old value was ${n}`,\n * n * 2\n * ])\n * console.log(result)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category modifications\n * @since 2.0.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, modify) => self.semaphore.withPermit(Effect.sync(() => {\n const [b, newValue] = modify(self.value);\n setUnsafe(self, newValue);\n return b;\n})));\n/**\n * Modifies the `SubscriptionRef` atomically with an effectful function that\n * computes a return value and a new value, notifying subscribers of the\n * change.\n *\n * **Example** (Modifying with an effect)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const result = yield* SubscriptionRef.modifyEffect(\n * ref,\n * (n) => Effect.succeed([`Doubled from ${n}`, n * 2] as const)\n * )\n * console.log(result)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category modifications\n * @since 2.0.0\n */\nexport const modifyEffect = /*#__PURE__*/dual(2, (self, modify) => self.semaphore.withPermit(Effect.suspend(() => Effect.map(modify(self.value), ([b, newValue]) => {\n setUnsafe(self, newValue);\n return b;\n}))));\n/**\n * Computes a return value and optionally updates the reference.\n *\n * **When to use**\n *\n * Use to return a separate result while synchronously deciding whether to\n * publish a new `SubscriptionRef` value.\n *\n * **Details**\n *\n * If the function returns `Option.some` for the new value, the value is set and\n * published. If it returns `Option.none`, the reference is left unchanged and\n * no update is published.\n *\n * **Example** (Conditionally modifying a value)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const result = yield* SubscriptionRef.modifySome(\n * ref,\n * (n) =>\n * n > 5 ? [\"Updated\", Option.some(n * 2)] : [\"Not updated\", Option.none()]\n * )\n * console.log(result)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category modifications\n * @since 2.0.0\n */\nexport const modifySome = /*#__PURE__*/dual(2, (self, modify) => self.semaphore.withPermit(Effect.sync(() => {\n const [b, option] = modify(self.value);\n if (Option.isNone(option)) return b;\n setUnsafe(self, option.value);\n return b;\n})));\n/**\n * Computes a return value and optionally updates the reference effectfully.\n *\n * **When to use**\n *\n * Use to return a separate result while effectfully deciding whether to publish\n * a new `SubscriptionRef` value.\n *\n * **Details**\n *\n * If the effect succeeds with `Option.some`, the new value is set and\n * published. If it succeeds with `Option.none`, the reference is left unchanged\n * and no update is published.\n *\n * **Example** (Conditionally modifying with an effect)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const result = yield* SubscriptionRef.modifySomeEffect(\n * ref,\n * (n) =>\n * Effect.succeed(\n * n > 5\n * ? ([\"Updated\", Option.some(n + 5)] as const)\n * : ([\"Not updated\", Option.none()] as const)\n * )\n * )\n * console.log(result)\n *\n * const newValue = yield* SubscriptionRef.get(ref)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category modifications\n * @since 2.0.0\n */\nexport const modifySomeEffect = /*#__PURE__*/dual(2, (self, modify) => self.semaphore.withPermit(Effect.suspend(() => Effect.map(modify(self.value), ([b, option]) => {\n if (Option.isNone(option)) return b;\n setUnsafe(self, option.value);\n return b;\n}))));\n/**\n * Sets the value of the `SubscriptionRef`, notifying all subscribers of the\n * change.\n *\n * **Example** (Setting a value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(0)\n *\n * yield* SubscriptionRef.set(ref, 42)\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category setters\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Effect.sync(() => setUnsafe(self, value))));\n/**\n * Sets the value of the `SubscriptionRef` and returns the new value,\n * notifying all subscribers of the change.\n *\n * **Example** (Setting and reading the new value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(0)\n *\n * const newValue = yield* SubscriptionRef.setAndGet(ref, 42)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category setters\n * @since 2.0.0\n */\nexport const setAndGet = /*#__PURE__*/dual(2, (self, value) => self.semaphore.withPermit(Effect.sync(() => {\n setUnsafe(self, value);\n return value;\n})));\n/**\n * Updates the value of the `SubscriptionRef` with the result of applying a\n * function, notifying subscribers of the change.\n *\n * **Example** (Updating a value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * yield* SubscriptionRef.update(ref, (n) => n * 2)\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => setUnsafe(self, update(self.value)))));\n/**\n * Updates the value of the `SubscriptionRef` with the result of applying an\n * effectful function, notifying subscribers of the change.\n *\n * **Example** (Updating with an effect)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * yield* SubscriptionRef.updateEffect(ref, (n) => Effect.succeed(n + 5))\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.suspend(() => Effect.map(update(self.value), newValue => setUnsafe(self, newValue)))));\n/**\n * Updates the value of the `SubscriptionRef` with the result of applying a\n * function and returns the new value, notifying subscribers of the change.\n *\n * **Example** (Updating and reading the new value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const newValue = yield* SubscriptionRef.updateAndGet(ref, (n) => n * 2)\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateAndGet = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const newValue = update(self.value);\n setUnsafe(self, newValue);\n return newValue;\n})));\n/**\n * Updates the value of the `SubscriptionRef` with the result of applying an\n * effectful function and returns the new value, notifying subscribers of the\n * change.\n *\n * **Example** (Updating with an effect and reading the new value)\n *\n * ```ts\n * import { Effect, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const newValue = yield* SubscriptionRef.updateAndGetEffect(\n * ref,\n * (n) => Effect.succeed(n + 5)\n * )\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateAndGetEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.suspend(() => Effect.map(update(self.value), newValue => {\n setUnsafe(self, newValue);\n return newValue;\n}))));\n/**\n * Applies an update function to the current value. If it returns\n * `Option.some`, sets and publishes that value; if it returns `Option.none`,\n * leaves the reference unchanged and does not publish.\n *\n * **Example** (Conditionally updating a value)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * yield* SubscriptionRef.updateSome(\n * ref,\n * (n) => n > 5 ? Option.some(n * 2) : Option.none()\n * )\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateSome = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const option = update(self.value);\n if (Option.isNone(option)) return;\n setUnsafe(self, option.value);\n})));\n/**\n * Applies an effectful update only when it produces a new value.\n *\n * **When to use**\n *\n * Use to conditionally update a `SubscriptionRef` with an effectful function\n * while discarding the resulting value.\n *\n * **Details**\n *\n * If the effect succeeds with `Option.some`, the new value is set and\n * published. If it succeeds with `Option.none`, the reference is left unchanged\n * and no update is published.\n *\n * **Example** (Conditionally updating with an effect)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * yield* SubscriptionRef.updateSomeEffect(\n * ref,\n * (n) => Effect.succeed(n > 5 ? Option.some(n + 3) : Option.none())\n * )\n *\n * const value = yield* SubscriptionRef.get(ref)\n * console.log(value)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateSomeEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.suspend(() => Effect.map(update(self.value), option => {\n if (Option.isNone(option)) return;\n setUnsafe(self, option.value);\n}))));\n/**\n * Applies an optional update and returns the current value afterward.\n *\n * **When to use**\n *\n * Use to conditionally update a `SubscriptionRef` and read the value that is\n * current after the update decision.\n *\n * **Details**\n *\n * If the function returns `Option.some`, the new value is set, published, and\n * returned. If it returns `Option.none`, the unchanged current value is\n * returned without publishing.\n *\n * **Example** (Conditionally updating and reading the new value)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const newValue = yield* SubscriptionRef.updateSomeAndGet(\n * ref,\n * (n) => n > 5 ? Option.some(n * 2) : Option.none()\n * )\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateSomeAndGet = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.sync(() => {\n const current = self.value;\n const option = update(current);\n if (Option.isNone(option)) return current;\n setUnsafe(self, option.value);\n return option.value;\n})));\n/**\n * Applies an effectful optional update and returns the current value afterward.\n *\n * **When to use**\n *\n * Use to conditionally update a `SubscriptionRef` effectfully and read the\n * value that is current after the update decision.\n *\n * **Details**\n *\n * If the effect succeeds with `Option.some`, the new value is set, published,\n * and returned. If it succeeds with `Option.none`, the unchanged current value\n * is returned without publishing.\n *\n * **Example** (Conditionally updating with an effect and reading the new value)\n *\n * ```ts\n * import { Effect, Option, SubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* SubscriptionRef.make(10)\n *\n * const newValue = yield* SubscriptionRef.updateSomeAndGetEffect(\n * ref,\n * (n) => Effect.succeed(n > 5 ? Option.some(n + 3) : Option.none())\n * )\n * console.log(\"New value:\", newValue)\n * })\n * ```\n *\n * @category updating\n * @since 2.0.0\n */\nexport const updateSomeAndGetEffect = /*#__PURE__*/dual(2, (self, update) => self.semaphore.withPermit(Effect.suspend(() => {\n const current = self.value;\n return Effect.map(update(current), option => {\n if (Option.isNone(option)) return current;\n setUnsafe(self, option.value);\n return option.value;\n });\n})));\n//# sourceMappingURL=SubscriptionRef.js.map","/**\n * The `Symbol` module contains the runtime predicate for JavaScript primitive\n * `symbol` values. It is most useful at boundaries where a value is `unknown`\n * and must be narrowed before it can be used as a symbol key, identifier, or\n * discriminant.\n *\n * @since 2.0.0\n */\nimport * as predicate from \"./Predicate.js\";\n/**\n * Checks whether a value is a `symbol`.\n *\n * **When to use**\n *\n * Use to validate unknown input before treating it as a JavaScript `symbol`.\n *\n * **Example** (Checking for symbols)\n *\n * ```ts\n * import { Symbol } from \"effect\"\n *\n * console.log(Symbol.isSymbol(globalThis.Symbol.for(\"a\"))) // true\n * console.log(Symbol.isSymbol(\"a\")) // false\n * ```\n *\n * @category guards\n * @since 2.0.0\n */\nexport const isSymbol = predicate.isSymbol;\n//# sourceMappingURL=Symbol.js.map","import * as Context from \"./Context.js\";\nimport * as Predicate from \"./Predicate.js\";\nimport * as Schema from \"./Schema.js\";\nconst TypeId = \"~effect/platform/Terminal\";\nconst QuitErrorTypeId = \"effect/platform/Terminal/QuitError\";\n/**\n * Represents an error that occurs when a user attempts to\n * quit out of a `Terminal` prompt for input (usually by entering `ctrl`+`c`).\n *\n * **When to use**\n *\n * Use when implementing terminal input or prompts that need to signal\n * user-requested cancellation through the typed error channel.\n *\n * @see {@link isQuitError} for checking unknown errors when handling terminal cancellation\n *\n * @category QuitError\n * @since 4.0.0\n */\nexport class QuitError extends /*#__PURE__*/Schema.ErrorClass(\"QuitError\")({\n _tag: /*#__PURE__*/Schema.tag(\"QuitError\")\n}) {\n /**\n * Marks this value as a terminal quit error for runtime guards.\n *\n * @since 4.0.0\n */\n [QuitErrorTypeId] = QuitErrorTypeId;\n}\n/**\n * Returns `true` if the provided value is a `Terminal.QuitError`.\n *\n * **When to use**\n *\n * Use to narrow unknown failures to `QuitError` when handling terminal input\n * cancellation.\n *\n * **Details**\n *\n * Returns `true` when the value carries the `QuitError` runtime marker and\n * narrows it to `QuitError`.\n *\n * @see {@link QuitError} for the error value produced when terminal input is quit\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isQuitError = u => Predicate.hasProperty(u, QuitErrorTypeId);\n/**\n * Service tag for command-line input and output services.\n *\n * **When to use**\n *\n * Use to access or provide platform terminal capabilities such as reading\n * input, writing output, and inspecting terminal dimensions.\n *\n * @category services\n * @since 4.0.0\n */\nexport const Terminal = /*#__PURE__*/Context.Service(\"effect/platform/Terminal\");\n/**\n * Creates a `Terminal` service implementation.\n *\n * **When to use**\n *\n * Use to construct a custom `Terminal` service implementation from concrete\n * terminal capabilities when writing a platform adapter, test implementation,\n * or custom runtime service.\n *\n * **Details**\n *\n * The implementation object supplies `columns`, `rows`, `readInput`,\n * `readLine`, and `display`; `make` attaches the `Terminal` service marker so\n * the result can be provided through the `Terminal` context service.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = impl => Terminal.of({\n ...impl,\n [TypeId]: TypeId\n});\n//# sourceMappingURL=Terminal.js.map","import * as Equal from \"../Equal.js\";\nimport { format } from \"../Formatter.js\";\nimport { dual, pipe } from \"../Function.js\";\nimport * as Hash from \"../Hash.js\";\nimport { NodeInspectSymbol, toJson } from \"../Inspectable.js\";\nimport * as Option from \"../Option.js\";\nimport { pipeArguments } from \"../Pipeable.js\";\nimport { hasProperty } from \"../Predicate.js\";\nimport * as Result from \"../Result.js\";\n/** @internal */\nexport const TrieTypeId = \"~effect/collections/Trie\";\nconst trieVariance = {\n /* c8 ignore next */\n _Value: _ => _\n};\nconst TrieProto = {\n [TrieTypeId]: trieVariance,\n [Symbol.iterator]() {\n return new TrieIterator(this, (k, v) => [k, v], () => true);\n },\n [Hash.symbol]() {\n let hash = Hash.hash(TrieTypeId);\n for (const item of this) {\n hash ^= pipe(Hash.hash(item[0]), Hash.combine(Hash.hash(item[1])));\n }\n return hash;\n },\n [Equal.symbol](that) {\n if (isTrie(that)) {\n const entries = Array.from(that);\n return Array.from(this).every((itemSelf, i) => {\n const itemThat = entries[i];\n return Equal.equals(itemSelf[0], itemThat[0]) && Equal.equals(itemSelf[1], itemThat[1]);\n });\n }\n return false;\n },\n toString() {\n return `Trie(${format(Array.from(this))})`;\n },\n toJSON() {\n return {\n _id: \"Trie\",\n values: toJson(Array.from(this))\n };\n },\n [NodeInspectSymbol]() {\n return this.toJSON();\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeImpl = root => {\n const trie = Object.create(TrieProto);\n trie._root = root;\n trie._count = root?.count ?? 0;\n return trie;\n};\nclass TrieIterator {\n stack = [];\n trie;\n f;\n filter;\n constructor(trie, f, filter) {\n this.trie = trie;\n this.f = f;\n this.filter = filter;\n const root = trie._root !== undefined ? trie._root : undefined;\n if (root !== undefined) {\n this.stack.push([root, \"\", false]);\n }\n }\n next() {\n while (this.stack.length > 0) {\n const [node, keyString, isAdded] = this.stack.pop();\n if (isAdded) {\n const value = node.value;\n if (value !== undefined) {\n const key = keyString + node.key;\n if (this.filter(key, value)) {\n return {\n done: false,\n value: this.f(key, value)\n };\n }\n }\n } else {\n this.addToStack(node, keyString);\n }\n }\n return {\n done: true,\n value: undefined\n };\n }\n addToStack(node, keyString) {\n if (node.right !== undefined) {\n this.stack.push([node.right, keyString, false]);\n }\n if (node.mid !== undefined) {\n this.stack.push([node.mid, keyString + node.key, false]);\n }\n this.stack.push([node, keyString, true]);\n if (node.left !== undefined) {\n this.stack.push([node.left, keyString, false]);\n }\n }\n [Symbol.iterator]() {\n return new TrieIterator(this.trie, this.f, this.filter);\n }\n}\n/** @internal */\nexport const isTrie = u => hasProperty(u, TrieTypeId);\n/** @internal */\nexport const empty = () => makeImpl(undefined);\n/** @internal */\nexport const fromIterable = entries => {\n let trie = empty();\n for (const [key, value] of entries) {\n trie = insert(trie, key, value);\n }\n return trie;\n};\n/** @internal */\nexport const make = (...entries) => {\n return fromIterable(entries);\n};\n/** @internal */\nexport const insert = /*#__PURE__*/dual(3, (self, key, value) => {\n if (key.length === 0) return self;\n // -1:left | 0:mid | 1:right\n const dStack = [];\n const nStack = [];\n let n = self._root ?? {\n key: key[0],\n count: 0\n };\n const count = n.count + 1;\n let cIndex = 0;\n while (cIndex < key.length) {\n const c = key[cIndex];\n nStack.push(n);\n if (c > n.key) {\n dStack.push(1);\n if (n.right === undefined) {\n n = {\n key: c,\n count\n };\n } else {\n n = n.right;\n }\n } else if (c < n.key) {\n dStack.push(-1);\n if (n.left === undefined) {\n n = {\n key: c,\n count\n };\n } else {\n n = n.left;\n }\n } else {\n if (cIndex === key.length - 1) {\n n.value = value;\n } else if (n.mid === undefined) {\n dStack.push(0);\n n = {\n key: key[cIndex + 1],\n count\n };\n } else {\n dStack.push(0);\n n = n.mid;\n }\n cIndex += 1;\n }\n }\n // Rebuild path to leaf node (Path-copying immutability)\n for (let s = nStack.length - 2; s >= 0; --s) {\n const n2 = nStack[s];\n const d = dStack[s];\n if (d === -1) {\n // left\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: nStack[s + 1],\n mid: n2.mid,\n right: n2.right\n };\n } else if (d === 1) {\n // right\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: n2.left,\n mid: n2.mid,\n right: nStack[s + 1]\n };\n } else {\n // mid\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: n2.left,\n mid: nStack[s + 1],\n right: n2.right\n };\n }\n }\n nStack[0].count = count;\n return makeImpl(nStack[0]);\n});\n/** @internal */\nexport const size = self => self._root?.count ?? 0;\n/** @internal */\nexport const isEmpty = self => size(self) === 0;\n/** @internal */\nexport const keys = self => new TrieIterator(self, key => key, () => true);\n/** @internal */\nexport const values = self => new TrieIterator(self, (_, value) => value, () => true);\n/** @internal */\nexport const entries = self => new TrieIterator(self, (key, value) => [key, value], () => true);\n/** @internal */\nexport const reduce = /*#__PURE__*/dual(3, (self, zero, f) => {\n let accumulator = zero;\n for (const entry of self) {\n accumulator = f(accumulator, entry[1], entry[0]);\n }\n return accumulator;\n});\n/** @internal */\nexport const map = /*#__PURE__*/dual(2, (self, f) => reduce(self, empty(), (trie, value, key) => insert(trie, key, f(value, key))));\n/** @internal */\nexport const filter = /*#__PURE__*/dual(2, (self, f) => reduce(self, empty(), (trie, value, key) => f(value, key) ? insert(trie, key, value) : trie));\n/** @internal */\nexport const filterMap = /*#__PURE__*/dual(2, (self, f) => reduce(self, empty(), (trie, value, key) => {\n const result = f(value, key);\n return Result.isSuccess(result) ? insert(trie, key, result.success) : trie;\n}));\n/** @internal */\nexport const compact = self => reduce(self, empty(), (trie, option, key) => Option.isSome(option) ? insert(trie, key, option.value) : trie);\n/** @internal */\nexport const forEach = /*#__PURE__*/dual(2, (self, f) => reduce(self, void 0, (_, value, key) => f(value, key)));\n/** @internal */\nexport const keysWithPrefix = /*#__PURE__*/dual(2, (self, prefix) => new TrieIterator(self, key => key, key => key.startsWith(prefix)));\n/** @internal */\nexport const valuesWithPrefix = /*#__PURE__*/dual(2, (self, prefix) => new TrieIterator(self, (_, value) => value, key => key.startsWith(prefix)));\n/** @internal */\nexport const entriesWithPrefix = /*#__PURE__*/dual(2, (self, prefix) => new TrieIterator(self, (key, value) => [key, value], key => key.startsWith(prefix)));\n/** @internal */\nexport const toEntriesWithPrefix = /*#__PURE__*/dual(2, (self, prefix) => Array.from(entriesWithPrefix(self, prefix)));\n/** @internal */\nexport const get = /*#__PURE__*/dual(2, (self, key) => {\n let n = self._root;\n if (n === undefined || key.length === 0) return Option.none();\n let cIndex = 0;\n while (cIndex < key.length) {\n const c = key[cIndex];\n if (c > n.key) {\n if (n.right === undefined) {\n return Option.none();\n } else {\n n = n.right;\n }\n } else if (c < n.key) {\n if (n.left === undefined) {\n return Option.none();\n } else {\n n = n.left;\n }\n } else {\n if (cIndex === key.length - 1) {\n return Option.fromUndefinedOr(n.value);\n } else {\n if (n.mid === undefined) {\n return Option.none();\n } else {\n n = n.mid;\n cIndex += 1;\n }\n }\n }\n }\n return Option.none();\n});\n/** @internal */\nexport const has = /*#__PURE__*/dual(2, (self, key) => Option.isSome(get(self, key)));\n/** @internal */\nexport const getUnsafe = /*#__PURE__*/dual(2, (self, key) => {\n const element = get(self, key);\n if (Option.isNone(element)) {\n throw new Error(\"Expected trie to contain key\");\n }\n return element.value;\n});\n/** @internal */\nexport const remove = /*#__PURE__*/dual(2, (self, key) => {\n let n = self._root;\n if (n === undefined || key.length === 0) return self;\n const count = n.count - 1;\n // -1:left | 0:mid | 1:right\n const dStack = [];\n const nStack = [];\n let cIndex = 0;\n while (cIndex < key.length) {\n const c = key[cIndex];\n if (c > n.key) {\n if (n.right === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(1);\n n = n.right;\n }\n } else if (c < n.key) {\n if (n.left === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(-1);\n n = n.left;\n }\n } else {\n if (cIndex === key.length - 1) {\n if (n.value !== undefined) {\n nStack.push(n);\n dStack.push(0);\n cIndex += 1;\n } else {\n return self;\n }\n } else {\n if (n.mid === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(0);\n n = n.mid;\n cIndex += 1;\n }\n }\n }\n }\n const removeNode = nStack[nStack.length - 1];\n nStack[nStack.length - 1] = {\n key: removeNode.key,\n count,\n left: removeNode.left,\n mid: removeNode.mid,\n right: removeNode.right\n };\n // Rebuild path to leaf node (Path-copying immutability)\n for (let s = nStack.length - 2; s >= 0; --s) {\n const n2 = nStack[s];\n const d = dStack[s];\n const child = nStack[s + 1];\n const nc = child.left === undefined && child.mid === undefined && child.right === undefined ? undefined : child;\n if (d === -1) {\n // left\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: nc,\n mid: n2.mid,\n right: n2.right\n };\n } else if (d === 1) {\n // right\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: n2.left,\n mid: n2.mid,\n right: nc\n };\n } else {\n // mid\n nStack[s] = {\n key: n2.key,\n count,\n value: n2.value,\n left: n2.left,\n mid: nc,\n right: n2.right\n };\n }\n }\n nStack[0].count = count;\n return makeImpl(nStack[0]);\n});\n/** @internal */\nexport const removeMany = /*#__PURE__*/dual(2, (self, keys) => {\n let trie = self;\n for (const key of keys) {\n trie = remove(key)(trie);\n }\n return trie;\n});\n/** @internal */\nexport const insertMany = /*#__PURE__*/dual(2, (self, iter) => {\n let trie = self;\n for (const [key, value] of iter) {\n trie = insert(key, value)(trie);\n }\n return trie;\n});\n/** @internal */\nexport const modify = /*#__PURE__*/dual(3, (self, key, f) => {\n let n = self._root;\n if (n === undefined || key.length === 0) return self;\n // -1:left | 0:mid | 1:right\n const dStack = [];\n const nStack = [];\n let cIndex = 0;\n while (cIndex < key.length) {\n const c = key[cIndex];\n if (c > n.key) {\n if (n.right === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(1);\n n = n.right;\n }\n } else if (c < n.key) {\n if (n.left === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(-1);\n n = n.left;\n }\n } else {\n if (cIndex === key.length - 1) {\n if (n.value !== undefined) {\n nStack.push(n);\n dStack.push(0);\n cIndex += 1;\n } else {\n return self;\n }\n } else {\n if (n.mid === undefined) {\n return self;\n } else {\n nStack.push(n);\n dStack.push(0);\n n = n.mid;\n cIndex += 1;\n }\n }\n }\n }\n const updateNode = nStack[nStack.length - 1];\n if (updateNode.value === undefined) {\n return self;\n }\n nStack[nStack.length - 1] = {\n key: updateNode.key,\n count: updateNode.count,\n value: f(updateNode.value),\n // Update\n left: updateNode.left,\n mid: updateNode.mid,\n right: updateNode.right\n };\n // Rebuild path to leaf node (Path-copying immutability)\n for (let s = nStack.length - 2; s >= 0; --s) {\n const n2 = nStack[s];\n const d = dStack[s];\n const child = nStack[s + 1];\n if (d === -1) {\n // left\n nStack[s] = {\n key: n2.key,\n count: n2.count,\n value: n2.value,\n left: child,\n mid: n2.mid,\n right: n2.right\n };\n } else if (d === 1) {\n // right\n nStack[s] = {\n key: n2.key,\n count: n2.count,\n value: n2.value,\n left: n2.left,\n mid: n2.mid,\n right: child\n };\n } else {\n // mid\n nStack[s] = {\n key: n2.key,\n count: n2.count,\n value: n2.value,\n left: n2.left,\n mid: child,\n right: n2.right\n };\n }\n }\n return makeImpl(nStack[0]);\n});\n/** @internal */\nexport const longestPrefixOf = /*#__PURE__*/dual(2, (self, key) => {\n let n = self._root;\n if (n === undefined || key.length === 0) return Option.none();\n let longestPrefixNode = Option.none();\n let cIndex = 0;\n while (cIndex < key.length) {\n const c = key[cIndex];\n if (n.value !== undefined) {\n longestPrefixNode = Option.some([key.slice(0, cIndex + 1), n.value]);\n }\n if (c > n.key) {\n if (n.right === undefined) {\n break;\n } else {\n n = n.right;\n }\n } else if (c < n.key) {\n if (n.left === undefined) {\n break;\n } else {\n n = n.left;\n }\n } else {\n if (n.mid === undefined) {\n break;\n } else {\n n = n.mid;\n cIndex += 1;\n }\n }\n }\n return longestPrefixNode;\n});\n//# sourceMappingURL=trie.js.map","import * as TR from \"./internal/trie.js\";\nconst TypeId = TR.TrieTypeId;\n/**\n * Creates an empty `Trie`.\n *\n * **Example** (Creating an empty trie)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<string>()\n *\n * assert.equal(Trie.size(trie), 0)\n * assert.deepStrictEqual(Array.from(trie), [])\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const empty = TR.empty;\n/**\n * Creates a new `Trie` from an iterable collection of key/value pairs (e.g. `Array<[string, V]>`).\n *\n * **Example** (Creating a trie from entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const iterable: Array<readonly [string, number]> = [[\"call\", 0], [\"me\", 1], [\n * \"mind\",\n * 2\n * ], [\"mid\", 3]]\n * const trie = Trie.fromIterable(iterable)\n *\n * // The entries in the `Trie` are extracted in alphabetical order, regardless of the insertion order\n * assert.deepStrictEqual(Array.from(trie), [[\"call\", 0], [\"me\", 1], [\"mid\", 3], [\n * \"mind\",\n * 2\n * ]])\n * assert.equal(\n * Equal.equals(\n * Trie.make([\"call\", 0], [\"me\", 1], [\"mind\", 2], [\"mid\", 3]),\n * trie\n * ),\n * true\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromIterable = TR.fromIterable;\n/**\n * Constructs a new `Trie` from the specified entries (`[string, V]`).\n *\n * **Example** (Constructing a trie from entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.make([\"ca\", 0], [\"me\", 1])\n *\n * assert.deepStrictEqual(Array.from(trie), [[\"ca\", 0], [\"me\", 1]])\n * assert.equal(\n * Equal.equals(Trie.fromIterable([[\"ca\", 0], [\"me\", 1]]), trie),\n * true\n * )\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = TR.make;\n/**\n * Inserts a new entry in the `Trie`.\n *\n * **Example** (Inserting entries)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie1 = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0)\n * )\n * const trie2 = trie1.pipe(Trie.insert(\"me\", 1))\n * const trie3 = trie2.pipe(Trie.insert(\"mind\", 2))\n * const trie4 = trie3.pipe(Trie.insert(\"mid\", 3))\n *\n * assert.deepStrictEqual(Array.from(trie1), [[\"call\", 0]])\n * assert.deepStrictEqual(Array.from(trie2), [[\"call\", 0], [\"me\", 1]])\n * assert.deepStrictEqual(Array.from(trie3), [[\"call\", 0], [\"me\", 1], [\"mind\", 2]])\n * assert.deepStrictEqual(Array.from(trie4), [[\"call\", 0], [\"me\", 1], [\"mid\", 3], [\n * \"mind\",\n * 2\n * ]])\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const insert = TR.insert;\n/**\n * Returns an `IterableIterator` of the keys within the `Trie`.\n *\n * **Details**\n *\n * The keys are returned in alphabetical order, regardless of insertion order.\n *\n * **Example** (Reading keys in alphabetical order)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"cab\", 0),\n * Trie.insert(\"abc\", 1),\n * Trie.insert(\"bca\", 2)\n * )\n *\n * const result = Array.from(Trie.keys(trie))\n * assert.deepStrictEqual(result, [\"abc\", \"bca\", \"cab\"])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const keys = TR.keys;\n/**\n * Returns an `IterableIterator` of the values within the `Trie`.\n *\n * **Details**\n *\n * Values are ordered based on their key in alphabetical order, regardless of insertion order.\n *\n * **Example** (Reading values by key order)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1),\n * Trie.insert(\"and\", 2)\n * )\n *\n * const result = Array.from(Trie.values(trie))\n * assert.deepStrictEqual(result, [2, 0, 1])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const values = TR.values;\n/**\n * Returns an `IterableIterator` of the entries within the `Trie`.\n *\n * **Details**\n *\n * The entries are returned by keys in alphabetical order, regardless of insertion order.\n *\n * **Example** (Reading entries in alphabetical order)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1)\n * )\n *\n * const result = Array.from(Trie.entries(trie))\n * assert.deepStrictEqual(result, [[\"call\", 0], [\"me\", 1]])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const entries = TR.entries;\n/**\n * Returns an `Array<[string, V]>` of the entries within the `Trie`.\n *\n * **Details**\n *\n * Equivalent to `Array.from(Trie.entries(trie))`.\n *\n * **Example** (Converting entries to an array)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1)\n * )\n * const result = Trie.toEntries(trie)\n *\n * assert.deepStrictEqual(result, [[\"call\", 0], [\"me\", 1]])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const toEntries = self => Array.from(entries(self));\n/**\n * Returns an `IterableIterator` of the keys within the `Trie`\n * that have `prefix` as prefix (`prefix` included if it exists).\n *\n * **Example** (Finding keys with a prefix)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"she\", 0),\n * Trie.insert(\"shells\", 1),\n * Trie.insert(\"sea\", 2),\n * Trie.insert(\"shore\", 3)\n * )\n *\n * const result = Array.from(Trie.keysWithPrefix(trie, \"she\"))\n * assert.deepStrictEqual(result, [\"she\", \"shells\"])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const keysWithPrefix = TR.keysWithPrefix;\n/**\n * Returns an `IterableIterator` of the values within the `Trie`\n * that have `prefix` as prefix (`prefix` included if it exists).\n *\n * **Example** (Finding values with a prefix)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"she\", 0),\n * Trie.insert(\"shells\", 1),\n * Trie.insert(\"sea\", 2),\n * Trie.insert(\"shore\", 3)\n * )\n *\n * const result = Array.from(Trie.valuesWithPrefix(trie, \"she\"))\n *\n * // 0: \"she\", 1: \"shells\"\n * assert.deepStrictEqual(result, [0, 1])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const valuesWithPrefix = TR.valuesWithPrefix;\n/**\n * Returns an `IterableIterator` of the entries within the `Trie`\n * that have `prefix` as prefix (`prefix` included if it exists).\n *\n * **Example** (Finding entries with a prefix)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"she\", 0),\n * Trie.insert(\"shells\", 1),\n * Trie.insert(\"sea\", 2),\n * Trie.insert(\"shore\", 3)\n * )\n *\n * const result = Array.from(Trie.entriesWithPrefix(trie, \"she\"))\n * assert.deepStrictEqual(result, [[\"she\", 0], [\"shells\", 1]])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const entriesWithPrefix = TR.entriesWithPrefix;\n/**\n * Returns an `Array<[string, V]>` of the entries within the `Trie` whose keys\n * start with `prefix`, including the entry for `prefix` itself when it exists.\n *\n * **Example** (Converting prefixed entries to an array)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"sea\", 2),\n * Trie.insert(\"she\", 3)\n * )\n *\n * const result = Trie.toEntriesWithPrefix(trie, \"she\")\n * assert.deepStrictEqual(result, [[\"she\", 3], [\"shells\", 0]])\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const toEntriesWithPrefix = TR.toEntriesWithPrefix;\n/**\n * Returns the longest key/value in the `Trie`\n * that is a prefix of that `key` if it exists, `None` otherwise.\n *\n * **Example** (Finding the longest prefix)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * const none = Trie.longestPrefixOf(trie, \"sell\")\n * const some = Trie.longestPrefixOf(trie, \"sells\")\n *\n * assert.equal(none._tag, \"None\")\n * assert.equal(some._tag, \"Some\")\n * if (some._tag === \"Some\") {\n * assert.deepStrictEqual(some.value, [\"sells\", 1])\n * }\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const longestPrefixOf = TR.longestPrefixOf;\n/**\n * Returns the size of the `Trie` (number of entries in the `Trie`).\n *\n * **Example** (Getting the size)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"a\", 0),\n * Trie.insert(\"b\", 1)\n * )\n *\n * assert.equal(Trie.size(trie), 2)\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const size = TR.size;\n/**\n * Looks up the value for the specified key in the `Trie` safely.\n *\n * **Example** (Looking up values safely)\n *\n * ```ts\n * import { Option, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1),\n * Trie.insert(\"mind\", 2),\n * Trie.insert(\"mid\", 3)\n * )\n *\n * assert.deepStrictEqual(Trie.get(trie, \"call\"), Option.some(0))\n * assert.deepStrictEqual(Trie.get(trie, \"me\"), Option.some(1))\n * assert.deepStrictEqual(Trie.get(trie, \"mind\"), Option.some(2))\n * assert.deepStrictEqual(Trie.get(trie, \"mid\"), Option.some(3))\n * assert.deepStrictEqual(Trie.get(trie, \"cale\"), Option.none())\n * assert.deepStrictEqual(Trie.get(trie, \"ma\"), Option.none())\n * assert.deepStrictEqual(Trie.get(trie, \"midn\"), Option.none())\n * assert.deepStrictEqual(Trie.get(trie, \"mea\"), Option.none())\n * ```\n *\n * @category elements\n * @since 2.0.0\n */\nexport const get = TR.get;\n/**\n * Checks whether the given key exists in the `Trie`.\n *\n * **Example** (Checking key membership)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1),\n * Trie.insert(\"mind\", 2),\n * Trie.insert(\"mid\", 3)\n * )\n *\n * assert.equal(Trie.has(trie, \"call\"), true)\n * assert.equal(Trie.has(trie, \"me\"), true)\n * assert.equal(Trie.has(trie, \"mind\"), true)\n * assert.equal(Trie.has(trie, \"mid\"), true)\n * assert.equal(Trie.has(trie, \"cale\"), false)\n * assert.equal(Trie.has(trie, \"ma\"), false)\n * assert.equal(Trie.has(trie, \"midn\"), false)\n * assert.equal(Trie.has(trie, \"mea\"), false)\n * ```\n *\n * @category elements\n * @since 2.0.0\n */\nexport const has = TR.has;\n/**\n * Returns `true` when the `Trie` contains no entries.\n *\n * **Example** (Checking whether a trie is empty)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>()\n * const trie1 = trie.pipe(Trie.insert(\"ma\", 0))\n *\n * assert.equal(Trie.isEmpty(trie), true)\n * assert.equal(Trie.isEmpty(trie1), false)\n * ```\n *\n * @category elements\n * @since 2.0.0\n */\nexport const isEmpty = TR.isEmpty;\n/**\n * Looks up the value for the specified key in the `Trie` unsafely.\n *\n * **When to use**\n *\n * Use when the trie key is known to exist and a missing key should be treated\n * as a programming error.\n *\n * **Gotchas**\n *\n * `getUnsafe` throws if the key is not found. Use `get` instead to safely get\n * a value from the `Trie`.\n *\n * **Example** (Looking up values unsafely)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1)\n * )\n *\n * assert.throws(() => Trie.getUnsafe(trie, \"mae\"))\n * ```\n *\n * @category unsafe\n * @since 4.0.0\n */\nexport const getUnsafe = TR.getUnsafe;\n/**\n * Removes the entry for the specified key in the `Trie`.\n *\n * **Example** (Removing entries)\n *\n * ```ts\n * import { Option, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"call\", 0),\n * Trie.insert(\"me\", 1),\n * Trie.insert(\"mind\", 2),\n * Trie.insert(\"mid\", 3)\n * )\n *\n * const trie1 = trie.pipe(Trie.remove(\"call\"))\n * const trie2 = trie1.pipe(Trie.remove(\"mea\"))\n *\n * assert.deepStrictEqual(Trie.get(trie, \"call\"), Option.some(0))\n * assert.deepStrictEqual(Trie.get(trie1, \"call\"), Option.none())\n * assert.deepStrictEqual(Trie.get(trie2, \"call\"), Option.none())\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const remove = TR.remove;\n/**\n * Reduces a state over the entries of the `Trie`.\n *\n * **Example** (Reducing entries)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * assert.equal(\n * trie.pipe(\n * Trie.reduce(0, (acc, n) => acc + n)\n * ),\n * 3\n * )\n * assert.equal(\n * trie.pipe(\n * Trie.reduce(10, (acc, n) => acc + n)\n * ),\n * 13\n * )\n * assert.equal(\n * trie.pipe(\n * Trie.reduce(\"\", (acc, _, key) => acc + key)\n * ),\n * \"sellssheshells\"\n * )\n * ```\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduce = TR.reduce;\n/**\n * Maps over the entries of the `Trie` using the specified function.\n *\n * **Example** (Mapping entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieMapV = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 1),\n * Trie.insert(\"sells\", 2),\n * Trie.insert(\"she\", 3)\n * )\n *\n * const trieMapK = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 6),\n * Trie.insert(\"sells\", 5),\n * Trie.insert(\"she\", 3)\n * )\n *\n * assert.equal(Equal.equals(Trie.map(trie, (v) => v + 1), trieMapV), true)\n * assert.equal(Equal.equals(Trie.map(trie, (_, k) => k.length), trieMapK), true)\n * ```\n *\n * @category folding\n * @since 2.0.0\n */\nexport const map = TR.map;\n/**\n * Filters entries out of a `Trie` using the specified predicate.\n *\n * **Example** (Filtering entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieMapV = Trie.empty<number>().pipe(\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieMapK = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1)\n * )\n *\n * assert.equal(Equal.equals(Trie.filter(trie, (v) => v > 1), trieMapV), true)\n * assert.equal(\n * Equal.equals(Trie.filter(trie, (_, k) => k.length > 3), trieMapK),\n * true\n * )\n * ```\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filter = TR.filter;\n/**\n * Maps over the entries of the `Trie` using the specified filter and keeps\n * only successful results.\n *\n * **Example** (Filtering and mapping entries)\n *\n * ```ts\n * import { Equal, Result, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieMapV = Trie.empty<number>().pipe(\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieMapK = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1)\n * )\n *\n * assert.equal(\n * Equal.equals(\n * Trie.filterMap(trie, (v) => v > 1 ? Result.succeed(v) : Result.failVoid),\n * trieMapV\n * ),\n * true\n * )\n * assert.equal(\n * Equal.equals(\n * Trie.filterMap(\n * trie,\n * (v, k) => k.length > 3 ? Result.succeed(v) : Result.failVoid\n * ),\n * trieMapK\n * ),\n * true\n * )\n * ```\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMap = TR.filterMap;\n/**\n * Filters out `None` values from a `Trie` of `Options`s.\n *\n * **Example** (Compacting optional values)\n *\n * ```ts\n * import { Equal, Option, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<Option.Option<number>>().pipe(\n * Trie.insert(\"shells\", Option.some(0)),\n * Trie.insert(\"sells\", Option.none()),\n * Trie.insert(\"she\", Option.some(2))\n * )\n *\n * const trieMapV = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"she\", 2)\n * )\n *\n * assert.equal(Equal.equals(Trie.compact(trie), trieMapV), true)\n * ```\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const compact = TR.compact;\n/**\n * Applies the specified function to the entries of the `Trie`.\n *\n * **Example** (Iterating over entries)\n *\n * ```ts\n * import { Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * let value = 0\n *\n * Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2),\n * Trie.forEach((n, key) => {\n * value += n + key.length\n * })\n * )\n *\n * assert.equal(value, 17)\n * ```\n *\n * @category traversing\n * @since 2.0.0\n */\nexport const forEach = TR.forEach;\n/**\n * Updates the value of the specified key within the `Trie` if it exists.\n *\n * **Example** (Modifying an existing value)\n *\n * ```ts\n * import { Equal, Option, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * assert.deepStrictEqual(\n * trie.pipe(Trie.modify(\"she\", (v) => v + 10), Trie.get(\"she\")),\n * Option.some(12)\n * )\n *\n * assert.equal(Equal.equals(trie.pipe(Trie.modify(\"me\", (v) => v)), trie), true)\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const modify = TR.modify;\n/**\n * Removes all entries in the `Trie` which have the specified keys.\n *\n * **Example** (Removing multiple entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * assert.equal(\n * Equal.equals(\n * trie.pipe(Trie.removeMany([\"she\", \"sells\"])),\n * Trie.empty<number>().pipe(Trie.insert(\"shells\", 0))\n * ),\n * true\n * )\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const removeMany = TR.removeMany;\n/**\n * Inserts multiple entries in the `Trie` at once.\n *\n * **Example** (Inserting multiple entries)\n *\n * ```ts\n * import { Equal, Trie } from \"effect\"\n * import * as assert from \"node:assert\"\n *\n * const trie = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insert(\"sells\", 1),\n * Trie.insert(\"she\", 2)\n * )\n *\n * const trieInsert = Trie.empty<number>().pipe(\n * Trie.insert(\"shells\", 0),\n * Trie.insertMany(\n * [[\"sells\", 1], [\"she\", 2]]\n * )\n * )\n *\n * assert.equal(\n * Equal.equals(trie, trieInsert),\n * true\n * )\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const insertMany = TR.insertMany;\n//# sourceMappingURL=Trie.js.map","/**\n * Transactional references for coordinating mutable state with Effect\n * transactions. A `TxRef` stores a current value, but reads and writes inside\n * `Effect.tx` are recorded in a transaction journal and committed together only\n * when the outermost transaction succeeds.\n *\n * This is the basic building block behind the other transactional collections\n * in Effect. The module provides effectful and unsafe constructors plus the\n * core operations for reading, setting, updating, and modifying a transactional\n * value while returning a separate result.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nconst TypeId = \"~effect/transactions/TxRef\";\n/**\n * Creates a new `TxRef` with the specified initial value.\n *\n * **When to use**\n *\n * Use to create a `TxRef` inside an `Effect` workflow.\n *\n * **Example** (Creating transactional references)\n *\n * ```ts\n * import { Effect, TxRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a transactional reference with initial value\n * const counter = yield* TxRef.make(0)\n * const name = yield* TxRef.make(\"Alice\")\n *\n * // Use in transactions\n * yield* Effect.tx(Effect.gen(function*() {\n * yield* TxRef.set(counter, 42)\n * yield* TxRef.set(name, \"Bob\")\n * }))\n *\n * console.log(yield* TxRef.get(counter)) // 42\n * console.log(yield* TxRef.get(name)) // \"Bob\"\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = initial => Effect.sync(() => makeUnsafe(initial));\n/**\n * Creates a new `TxRef` synchronously with the specified initial value.\n *\n * **When to use**\n *\n * Use to construct a `TxRef` synchronously when it must be created outside an\n * `Effect` workflow.\n *\n * **Example** (Creating transactional references unsafely)\n *\n * ```ts\n * import { TxRef } from \"effect\"\n *\n * // Create a TxRef synchronously (unsafe - use make instead in Effect contexts)\n * const counter = TxRef.makeUnsafe(0)\n * const config = TxRef.makeUnsafe({ timeout: 5000, retries: 3 })\n *\n * // These are now ready to use in transactions\n * console.log(counter.value) // 0\n * console.log(config.value) // { timeout: 5000, retries: 3 }\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeUnsafe = initial => ({\n [TypeId]: TypeId,\n pending: new Map(),\n pipe() {\n return pipeArguments(this, arguments);\n },\n version: 0,\n value: initial\n});\n/**\n * Modifies the value of the `TxRef` using the provided function.\n *\n * **When to use**\n *\n * Use to update a `TxRef` and return a computed result from the same\n * transaction step.\n *\n * **Example** (Modifying transactional references)\n *\n * ```ts\n * import { Effect, TxRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* TxRef.make(0)\n *\n * // Modify and return both old and new value\n * const result = yield* TxRef.modify(counter, (current) => [current * 2, current + 1])\n *\n * console.log(result) // 0 (the return value: current * 2)\n * console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, f) => Effect.Transaction.pipe(Effect.flatMap(state => Effect.sync(() => {\n if (!state.journal.has(self)) {\n state.journal.set(self, {\n version: self.version,\n value: self.value\n });\n }\n const current = state.journal.get(self);\n const [returnValue, next] = f(current.value);\n current.value = next;\n return returnValue;\n})), Effect.tx));\n/**\n * Updates the value of the `TxRef` using the provided function.\n *\n * **When to use**\n *\n * Use to transform a `TxRef` when no result value is needed.\n *\n * **Example** (Updating transactional references)\n *\n * ```ts\n * import { Effect, TxRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* TxRef.make(10)\n *\n * // Update the value using a function\n * yield* Effect.tx(\n * TxRef.update(counter, (current) => current * 2)\n * )\n *\n * console.log(yield* TxRef.get(counter)) // 20\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, f) => modify(self, current => [void 0, f(current)]));\n/**\n * Reads the current value of the `TxRef`.\n *\n * **When to use**\n *\n * Use to read the current value of a `TxRef`.\n *\n * **Example** (Reading transactional references)\n *\n * ```ts\n * import { Effect, TxRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* TxRef.make(42)\n *\n * // Read the value within a transaction\n * const value = yield* Effect.tx(\n * TxRef.get(counter)\n * )\n *\n * console.log(value) // 42\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const get = self => modify(self, current => [current, current]);\n/**\n * Sets the value of the `TxRef`.\n *\n * **When to use**\n *\n * Use to replace the value of a `TxRef`.\n *\n * **Example** (Setting transactional references)\n *\n * ```ts\n * import { Effect, TxRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counter = yield* TxRef.make(0)\n *\n * // Set a new value within a transaction\n * yield* Effect.tx(\n * TxRef.set(counter, 100)\n * )\n *\n * console.log(yield* TxRef.get(counter)) // 100\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, value) => update(self, () => value));\n//# sourceMappingURL=TxRef.js.map","/**\n * Stores a `Chunk` inside transactional state.\n *\n * A `TxChunk<A>` keeps its current `Chunk<A>` in a `TxRef`, so reads and\n * updates can be committed atomically with other transactional operations. This\n * module offers a transactional version of common chunk workflows, including\n * creating collections, reading or replacing the current chunk, adding or\n * removing values, checking size, slicing, mapping, filtering, and combining\n * chunks.\n *\n * @since 4.0.0\n */\nimport * as Chunk from \"./Chunk.js\";\nimport * as Effect from \"./Effect.js\";\nimport { format } from \"./Formatter.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxChunk\";\nconst TxChunkProto = {\n [NodeInspectSymbol]() {\n return this.toJSON();\n },\n toString() {\n return `TxChunk(${format(toJson(this.ref))})`;\n },\n toJSON() {\n return {\n _id: \"TxChunk\",\n ref: toJson(this.ref)\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n/**\n * Creates a new `TxChunk` with the specified initial chunk.\n *\n * **Details**\n *\n * This function returns a new TxChunk reference containing the provided initial chunk. No existing\n * TxChunk instances are modified.\n *\n * **Example** (Creating a TxChunk from a chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a TxChunk with initial values\n * const initialChunk = Chunk.fromIterable([1, 2, 3])\n * const txChunk = yield* TxChunk.make(initialChunk)\n *\n * // Read the value - automatically transactional\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3]\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = initial => Effect.map(TxRef.make(initial), ref => makeUnsafe(ref));\n/**\n * Creates a new empty `TxChunk`.\n *\n * **Details**\n *\n * This function returns a new TxChunk reference that is initially empty. No existing TxChunk\n * instances are modified.\n *\n * **Example** (Creating an empty TxChunk)\n *\n * ```ts\n * import { Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create an empty TxChunk\n * const txChunk = yield* TxChunk.empty<number>()\n *\n * // Check if it's empty - automatically transactional\n * const isEmpty = yield* TxChunk.isEmpty(txChunk)\n * console.log(isEmpty) // true\n *\n * // Add elements - automatically transactional\n * yield* TxChunk.append(txChunk, 42)\n *\n * const isStillEmpty = yield* TxChunk.isEmpty(txChunk)\n * console.log(isStillEmpty) // false\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const empty = () => Effect.map(TxRef.make(Chunk.empty()), ref => makeUnsafe(ref));\n/**\n * Creates a new `TxChunk` from an iterable.\n *\n * **Details**\n *\n * This function returns a new TxChunk reference containing elements from the provided iterable. No\n * existing TxChunk instances are modified.\n *\n * **Example** (Creating from an iterable)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create TxChunk from array\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5])\n *\n * // Read the contents - automatically transactional\n * const chunk = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(chunk)) // [1, 2, 3, 4, 5]\n *\n * // Multi-step atomic modification - use explicit transaction\n * yield* Effect.tx(\n * Effect.gen(function*() {\n * yield* TxChunk.append(txChunk, 6)\n * yield* TxChunk.prepend(txChunk, 0)\n * })\n * )\n *\n * const updated = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(updated)) // [0, 1, 2, 3, 4, 5, 6]\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const fromIterable = iterable => Effect.map(TxRef.make(Chunk.fromIterable(iterable)), ref => makeUnsafe(ref));\n/**\n * Creates a new `TxChunk` with the specified TxRef.\n *\n * **Details**\n *\n * This function returns a new TxChunk reference wrapping the provided TxRef. No existing TxChunk\n * instances are modified.\n *\n * **Example** (Wrapping an existing TxRef)\n *\n * ```ts\n * import { Chunk, TxChunk, TxRef } from \"effect\"\n *\n * // Create a TxChunk from an existing TxRef (advanced usage)\n * const ref = TxRef.makeUnsafe(Chunk.fromIterable([1, 2, 3]))\n * const txChunk = TxChunk.makeUnsafe(ref)\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeUnsafe = ref => {\n const txChunk = Object.create(TxChunkProto);\n txChunk[TypeId] = TypeId;\n txChunk.ref = ref;\n return txChunk;\n};\n/**\n * Modifies the value of the `TxChunk` using the provided function.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by updating its internal state. It does not return a\n * new TxChunk reference.\n *\n * **Example** (Modifying while returning a value)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Modify and return both old size and new chunk\n * const oldSize = yield* TxChunk.modify(txChunk, (chunk) => [\n * Chunk.size(chunk), // return value (old size)\n * Chunk.append(chunk, 4) // new value\n * ])\n *\n * console.log(oldSize) // 3\n *\n * const newChunk = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(newChunk)) // [1, 2, 3, 4]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, f) => TxRef.modify(self.ref, f));\n/**\n * Updates the value of the `TxChunk` using the provided function.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by updating its internal state. It does not return a\n * new TxChunk reference.\n *\n * **Example** (Updating the stored chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Update the chunk by reversing it atomically\n * yield* TxChunk.update(txChunk, (chunk) => Chunk.reverse(chunk))\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [3, 2, 1]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, f) => TxRef.update(self.ref, f));\n/**\n * Reads the current chunk from the `TxChunk`.\n *\n * **Example** (Reading the current chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Read the current value within a transaction\n * const chunk = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(chunk)) // [1, 2, 3]\n *\n * // The value is tracked for conflict detection\n * const size = Chunk.size(chunk)\n * console.log(size) // 3\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const get = self => TxRef.get(self.ref);\n/**\n * Sets the value of the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by replacing its internal state with the provided\n * chunk. It does not return a new TxChunk reference.\n *\n * **Example** (Replacing the stored chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Replace the entire chunk content\n * const newChunk = Chunk.fromIterable([10, 20, 30, 40])\n * yield* TxChunk.set(txChunk, newChunk)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [10, 20, 30, 40]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, chunk) => TxRef.set(self.ref, chunk));\n/**\n * Appends an element to the end of the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by adding the element to the end. It does not return a\n * new TxChunk reference.\n *\n * **Example** (Appending an element)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Add element to the end atomically\n * yield* TxChunk.append(txChunk, 4)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const append = /*#__PURE__*/dual(2, (self, element) => update(self, current => Chunk.append(current, element)));\n/**\n * Prepends an element to the beginning of the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by adding the element to the beginning. It does not\n * return a new TxChunk reference.\n *\n * **Example** (Prepending an element)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([2, 3, 4])\n *\n * // Add element to the beginning atomically\n * yield* TxChunk.prepend(txChunk, 1)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const prepend = /*#__PURE__*/dual(2, (self, element) => update(self, current => Chunk.prepend(current, element)));\n/**\n * Gets the size of the `TxChunk`.\n *\n * **Example** (Getting the size)\n *\n * ```ts\n * import { Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5])\n *\n * // Get the current size - automatically transactional\n * const currentSize = yield* TxChunk.size(txChunk)\n * console.log(currentSize) // 5\n *\n * // Size is tracked for conflict detection\n * yield* TxChunk.append(txChunk, 6)\n * const newSize = yield* TxChunk.size(txChunk)\n * console.log(newSize) // 6\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const size = self => modify(self, current => [Chunk.size(current), current]);\n/**\n * Checks whether the `TxChunk` is empty.\n *\n * **Example** (Checking for an empty chunk)\n *\n * ```ts\n * import { Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const emptyChunk = yield* TxChunk.empty<number>()\n * const nonEmptyChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Check if chunks are empty - automatically transactional\n * const isEmpty1 = yield* TxChunk.isEmpty(emptyChunk)\n * const isEmpty2 = yield* TxChunk.isEmpty(nonEmptyChunk)\n *\n * console.log(isEmpty1) // true\n * console.log(isEmpty2) // false\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isEmpty = self => modify(self, current => [Chunk.isEmpty(current), current]);\n/**\n * Checks whether the `TxChunk` is non-empty.\n *\n * **Example** (Checking for a non-empty chunk)\n *\n * ```ts\n * import { Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const emptyChunk = yield* TxChunk.empty<number>()\n * const nonEmptyChunk = yield* TxChunk.fromIterable([1, 2, 3])\n *\n * // Check if chunks are non-empty - automatically transactional\n * const isNonEmpty1 = yield* TxChunk.isNonEmpty(emptyChunk)\n * const isNonEmpty2 = yield* TxChunk.isNonEmpty(nonEmptyChunk)\n *\n * console.log(isNonEmpty1) // false\n * console.log(isNonEmpty2) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isNonEmpty = self => modify(self, current => [Chunk.isNonEmpty(current), current]);\n/**\n * Takes the first `n` elements from the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by keeping only the first n elements. It does not\n * return a new TxChunk reference.\n *\n * **Example** (Taking leading elements)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5])\n *\n * // Take only the first 3 elements - automatically transactional\n * yield* TxChunk.take(txChunk, 3)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const take = /*#__PURE__*/dual(2, (self, n) => update(self, current => Chunk.take(current, n)));\n/**\n * Drops the first `n` elements from the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by removing the first n elements. It does not return a\n * new TxChunk reference.\n *\n * **Example** (Dropping leading elements)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5])\n *\n * // Drop the first 2 elements - automatically transactional\n * yield* TxChunk.drop(txChunk, 2)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [3, 4, 5]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const drop = /*#__PURE__*/dual(2, (self, n) => update(self, current => Chunk.drop(current, n)));\n/**\n * Takes a slice of the `TxChunk` from `start` to `end` (exclusive).\n *\n * **Details**\n *\n * This function mutates the original TxChunk by keeping only the elements in the specified range. It\n * does not return a new TxChunk reference.\n *\n * **Example** (Taking a slice)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5, 6, 7])\n *\n * // Take elements from index 2 to 5 (exclusive) - automatically transactional\n * yield* TxChunk.slice(txChunk, 2, 5)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [3, 4, 5]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const slice = /*#__PURE__*/dual(3, (self, start, end) => update(self, current => Chunk.take(Chunk.drop(current, start), end - start)));\n/**\n * Maps each element of the `TxChunk` using a function that returns the same\n * element type.\n *\n * **Details**\n *\n * This function mutates the original `TxChunk` by transforming each element in place. It does not\n * return a new `TxChunk` reference.\n *\n * **Example** (Mapping elements)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4])\n *\n * // Transform each element atomically (must maintain same type)\n * yield* TxChunk.map(txChunk, (n) => n * 2)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [2, 4, 6, 8]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const map = /*#__PURE__*/dual(2, (self, f) => update(self, current => Chunk.map(current, f)));\n/**\n * Filters the `TxChunk` keeping only elements that satisfy the predicate.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by removing elements that don't match the predicate. It\n * does not return a new TxChunk reference.\n *\n * **Example** (Filtering elements)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5, 6])\n *\n * // Keep only even numbers atomically\n * yield* TxChunk.filter(txChunk, (n) => n % 2 === 0)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [2, 4, 6]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const filter = /*#__PURE__*/dual(2, (self, predicate) => update(self, current => Chunk.filter(current, predicate)));\n/**\n * Concatenates another chunk to the end of the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by appending all elements from the other chunk. It does\n * not return a new TxChunk reference.\n *\n * **Example** (Appending another chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([1, 2, 3])\n * const otherChunk = Chunk.fromIterable([4, 5, 6])\n *\n * // Append all elements from another chunk atomically\n * yield* TxChunk.appendAll(txChunk, otherChunk)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4, 5, 6]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const appendAll = /*#__PURE__*/dual(2, (self, other) => update(self, current => Chunk.appendAll(current, other)));\n/**\n * Concatenates another chunk to the beginning of the `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by prepending all elements from the other chunk. It\n * does not return a new TxChunk reference.\n *\n * **Example** (Prepending another chunk)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk = yield* TxChunk.fromIterable([4, 5, 6])\n * const otherChunk = Chunk.fromIterable([1, 2, 3])\n *\n * // Prepend all elements from another chunk atomically\n * yield* TxChunk.prependAll(txChunk, otherChunk)\n *\n * const result = yield* TxChunk.get(txChunk)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4, 5, 6]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const prependAll = /*#__PURE__*/dual(2, (self, other) => update(self, current => Chunk.prependAll(current, other)));\n/**\n * Concatenates another `TxChunk` to the end of this `TxChunk`.\n *\n * **Details**\n *\n * This function mutates the original TxChunk by appending all elements from the other TxChunk. It\n * does not return a new TxChunk reference.\n *\n * **Example** (Concatenating TxChunks)\n *\n * ```ts\n * import { Chunk, Effect, TxChunk } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txChunk1 = yield* TxChunk.fromIterable([1, 2, 3])\n * const txChunk2 = yield* TxChunk.fromIterable([4, 5, 6])\n *\n * // Concatenate atomically within a transaction\n * yield* TxChunk.concat(txChunk1, txChunk2)\n *\n * const result = yield* TxChunk.get(txChunk1)\n * console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4, 5, 6]\n *\n * // Original txChunk2 is unchanged\n * const original = yield* TxChunk.get(txChunk2)\n * console.log(Chunk.toReadonlyArray(original)) // [4, 5, 6]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const concat = /*#__PURE__*/dual(2, (self, other) => Effect.gen(function* () {\n const otherChunk = yield* get(other);\n yield* appendAll(self, otherChunk);\n}).pipe(Effect.tx));\n//# sourceMappingURL=TxChunk.js.map","/**\n * Transactional deferred values for coordinating Effect transactions.\n *\n * A `TxDeferred<A, E>` is a write-once cell whose completion is a\n * `Result<A, E>` stored in transactional state. Readers can wait for the value\n * from inside a transaction: while the cell is empty the transaction retries,\n * and when another transaction completes the deferred the waiting transaction\n * can resume with either the success value or the typed failure.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as O from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Res from \"./Result.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxDeferred\";\nconst TxDeferredProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxDeferred\"\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeTxDeferred = ref => {\n const self = Object.create(TxDeferredProto);\n self[TypeId] = TypeId;\n self.ref = ref;\n return self;\n};\n/**\n * Creates a new empty `TxDeferred`.\n *\n * **When to use**\n *\n * Use to create a transactional deferred that can be completed exactly once.\n *\n * **Example** (Creating a transactional deferred)\n *\n * ```ts\n * import { Effect, Option, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<string, Error>()\n * const state = yield* TxDeferred.poll(deferred)\n * console.log(Option.isNone(state)) // true\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = () => Effect.map(TxRef.make(O.none()), makeTxDeferred);\n/**\n * Reads the deferred value. Retries the transaction if the deferred has not\n * been completed yet.\n *\n * **Example** (Awaiting a deferred value)\n *\n * ```ts\n * import { Effect, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number>()\n * yield* TxDeferred.succeed(deferred, 42)\n * const value = yield* TxDeferred.await(deferred)\n * console.log(value) // 42\n * })\n * ```\n *\n * @category getters\n * @since 4.0.0\n */\nconst await_ = self => Effect.gen(function* () {\n const option = yield* TxRef.get(self.ref);\n if (O.isNone(option)) {\n return yield* Effect.txRetry;\n }\n return Res.isSuccess(option.value) ? option.value.success : yield* Effect.fail(option.value.failure);\n}).pipe(Effect.tx);\nexport {\n/**\n * Reads the deferred value. Retries the transaction if the deferred has not\n * been completed yet.\n *\n * **When to use**\n *\n * Use to read the success value of a `TxDeferred` while retrying until the\n * deferred is completed.\n *\n * @see {@link poll} for inspecting the current completion state without retrying the transaction\n *\n * @category getters\n * @since 4.0.0\n */\nawait_ as await };\n/**\n * Reads the current state of the deferred without retrying. Returns `None` if\n * not yet completed.\n *\n * **When to use**\n *\n * Use to inspect a `TxDeferred` without retrying when it is not completed yet.\n *\n * **Example** (Polling a deferred)\n *\n * ```ts\n * import { Effect, Option, Result, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number>()\n * const before = yield* TxDeferred.poll(deferred)\n * console.log(Option.isNone(before)) // true\n *\n * yield* TxDeferred.succeed(deferred, 42)\n * const after = yield* TxDeferred.poll(deferred)\n * console.log(after) // Some(Success(42))\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const poll = self => TxRef.get(self.ref);\n/**\n * Completes the deferred with a `Result`. Returns `true` if this was the first\n * completion, `false` if already completed.\n *\n * **When to use**\n *\n * Use to complete a `TxDeferred` with an already computed `Result`.\n *\n * **Example** (Completing with a result)\n *\n * ```ts\n * import { Effect, Result, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number, string>()\n * const first = yield* TxDeferred.done(deferred, Result.succeed(42))\n * console.log(first) // true\n * const second = yield* TxDeferred.done(deferred, Result.succeed(99))\n * console.log(second) // false\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const done = /*#__PURE__*/dual(2, (self, result) => TxRef.modify(self.ref, current => {\n if (O.isSome(current)) {\n return [false, current];\n }\n return [true, O.some(result)];\n}));\n/**\n * Completes the deferred with a success value. Returns `true` if this was the\n * first completion, `false` if already completed.\n *\n * **When to use**\n *\n * Use to complete a `TxDeferred` with a successful value.\n *\n * **Example** (Completing with a success value)\n *\n * ```ts\n * import { Effect, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number>()\n * const first = yield* TxDeferred.succeed(deferred, 42)\n * console.log(first) // true\n * const second = yield* TxDeferred.succeed(deferred, 99)\n * console.log(second) // false\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const succeed = /*#__PURE__*/dual(2, (self, value) => done(self, Res.succeed(value)));\n/**\n * Completes the deferred with a failure. Returns `true` if this was the first\n * completion, `false` if already completed.\n *\n * **When to use**\n *\n * Use to complete a `TxDeferred` with a typed failure value.\n *\n * **Example** (Completing with a failure)\n *\n * ```ts\n * import { Effect, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number, string>()\n * const first = yield* TxDeferred.fail(deferred, \"boom\")\n * console.log(first) // true\n * const second = yield* TxDeferred.fail(deferred, \"boom2\")\n * console.log(second) // false\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const fail = /*#__PURE__*/dual(2, (self, error) => done(self, Res.fail(error)));\n/**\n * Determines if the provided value is a `TxDeferred`.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a transactional deferred.\n *\n * **Example** (Checking transactional deferreds)\n *\n * ```ts\n * import { Effect, TxDeferred } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const deferred = yield* TxDeferred.make<number>()\n * console.log(TxDeferred.isTxDeferred(deferred)) // true\n * console.log(TxDeferred.isTxDeferred(\"not a deferred\")) // false\n * })\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxDeferred = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxDeferred.js.map","/**\n * Transactional hash maps for storing and updating key-value pairs inside\n * Effect transactions.\n *\n * A `TxHashMap` stores an immutable `HashMap` in a `TxRef`, so map reads and\n * writes can commit atomically with other transactional operations. Use it for\n * shared registries, counters, indexes, and other maps that need safe\n * read-modify-write sequences alongside related transactional state.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { format } from \"./Formatter.js\";\nimport { dual } from \"./Function.js\";\nimport * as HashMap from \"./HashMap.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as Option from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxHashMap\";\nconst TxHashMapProto = {\n [TypeId]: TypeId,\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toString() {\n return `TxHashMap(${format(toJson(this.ref))})`;\n },\n toJSON() {\n return {\n _id: \"TxHashMap\",\n ref: toJson(this.ref)\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n/**\n * Creates an empty TxHashMap.\n *\n * **Example** (Creating an empty map)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create an empty transactional hash map\n * const emptyMap = yield* TxHashMap.empty<string, number>()\n *\n * // Verify it's empty\n * const isEmpty = yield* TxHashMap.isEmpty(emptyMap)\n * console.log(isEmpty) // true\n *\n * const size = yield* TxHashMap.size(emptyMap)\n * console.log(size) // 0\n *\n * // Start adding elements\n * yield* TxHashMap.set(emptyMap, \"first\", 1)\n * const newSize = yield* TxHashMap.size(emptyMap)\n * console.log(newSize) // 1\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const empty = () => Effect.gen(function* () {\n const ref = yield* TxRef.make(HashMap.empty());\n return Object.assign(Object.create(TxHashMapProto), {\n ref\n });\n});\n/**\n * Creates a TxHashMap from the provided key-value pairs.\n *\n * **Example** (Creating a map from entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a user directory\n * const userMap = yield* TxHashMap.make(\n * [\"alice\", { name: \"Alice Smith\", role: \"admin\" }],\n * [\"bob\", { name: \"Bob Johnson\", role: \"user\" }],\n * [\"charlie\", { name: \"Charlie Brown\", role: \"user\" }]\n * )\n *\n * // Check the initial size\n * const size = yield* TxHashMap.size(userMap)\n * console.log(size) // 3\n *\n * // Access users\n * const alice = yield* TxHashMap.get(userMap, \"alice\")\n * console.log(alice) // Option.some({ name: \"Alice Smith\", role: \"admin\" })\n *\n * const nonExistent = yield* TxHashMap.get(userMap, \"david\")\n * console.log(nonExistent) // Option.none()\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = (...entries) => Effect.gen(function* () {\n const hashMap = HashMap.make(...entries);\n const ref = yield* TxRef.make(hashMap);\n return Object.assign(Object.create(TxHashMapProto), {\n ref\n });\n});\n/**\n * Creates a TxHashMap from an iterable of key-value pairs.\n *\n * **Example** (Creating a map from an iterable)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create from various iterable sources\n * const configEntries = [\n * [\"database.host\", \"localhost\"],\n * [\"database.port\", \"5432\"],\n * [\"cache.enabled\", \"true\"],\n * [\"logging.level\", \"info\"]\n * ] as const\n *\n * const configMap = yield* TxHashMap.fromIterable(configEntries)\n *\n * // Verify the configuration was loaded\n * const size = yield* TxHashMap.size(configMap)\n * console.log(size) // 4\n *\n * const dbHost = yield* TxHashMap.get(configMap, \"database.host\")\n * console.log(dbHost) // Option.some(\"localhost\")\n *\n * // Can also create from Map, Set of tuples, etc.\n * const jsMap = new Map([[\"key1\", \"value1\"], [\"key2\", \"value2\"]])\n * const txMapFromJs = yield* TxHashMap.fromIterable(jsMap)\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromIterable = entries => Effect.gen(function* () {\n const hashMap = HashMap.fromIterable(entries);\n const ref = yield* TxRef.make(hashMap);\n return Object.assign(Object.create(TxHashMapProto), {\n ref\n });\n});\n/**\n * Looks up the value for the specified key in the TxHashMap.\n *\n * **Example** (Looking up values safely)\n *\n * ```ts\n * import { Effect, Option, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const userMap = yield* TxHashMap.make(\n * [\"alice\", { name: \"Alice\", role: \"admin\" }],\n * [\"bob\", { name: \"Bob\", role: \"user\" }]\n * )\n *\n * // Safe lookup - returns Option\n * const alice = yield* TxHashMap.get(userMap, \"alice\")\n * console.log(alice) // Option.some({ name: \"Alice\", role: \"admin\" })\n *\n * const nonExistent = yield* TxHashMap.get(userMap, \"charlie\")\n * console.log(nonExistent) // Option.none()\n *\n * // Use with pipe syntax for type-safe access\n * const bobRole = yield* TxHashMap.get(userMap, \"bob\")\n * if (bobRole._tag === \"Some\") {\n * console.log(bobRole.value.role) // \"user\"\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const get = /*#__PURE__*/dual(2, (self, key) => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.get(map, key);\n}));\n/**\n * Sets the value for the specified key in the TxHashMap.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by updating its internal state.\n * It does not return a new TxHashMap reference.\n *\n * **Example** (Setting values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const inventory = yield* TxHashMap.make(\n * [\"laptop\", 5],\n * [\"mouse\", 20]\n * )\n *\n * // Update existing item\n * yield* TxHashMap.set(inventory, \"laptop\", 3)\n * const laptopStock = yield* TxHashMap.get(inventory, \"laptop\")\n * console.log(laptopStock) // Option.some(3)\n *\n * // Add new item\n * yield* TxHashMap.set(inventory, \"keyboard\", 15)\n * const keyboardStock = yield* TxHashMap.get(inventory, \"keyboard\")\n * console.log(keyboardStock) // Option.some(15)\n *\n * // Use with pipe syntax\n * yield* TxHashMap.set(\"tablet\", 8)(inventory)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const set = /*#__PURE__*/dual(3, (self, key, value) => TxRef.update(self.ref, map => HashMap.set(map, key, value)));\n/**\n * Checks whether the specified key exists in the TxHashMap.\n *\n * **Example** (Checking for keys)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const permissions = yield* TxHashMap.make(\n * [\"alice\", [\"read\", \"write\"]],\n * [\"bob\", [\"read\"]],\n * [\"charlie\", [\"admin\"]]\n * )\n *\n * // Check if users exist\n * const hasAlice = yield* TxHashMap.has(permissions, \"alice\")\n * console.log(hasAlice) // true\n *\n * const hasDavid = yield* TxHashMap.has(permissions, \"david\")\n * console.log(hasDavid) // false\n *\n * // Use direct method call for type-safe access\n * const hasBob = yield* TxHashMap.has(permissions, \"bob\")\n * console.log(hasBob) // true\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, key) => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.has(map, key);\n}));\n/**\n * Removes the specified key from the TxHashMap.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by removing the specified\n * key-value pair. It does not return a new TxHashMap reference.\n *\n * **Example** (Removing keys)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* TxHashMap.make(\n * [\"user:1\", { name: \"Alice\", lastSeen: \"2024-01-01\" }],\n * [\"user:2\", { name: \"Bob\", lastSeen: \"2024-01-02\" }],\n * [\"user:3\", { name: \"Charlie\", lastSeen: \"2023-12-30\" }]\n * )\n *\n * // Remove expired user\n * const removed = yield* TxHashMap.remove(cache, \"user:3\")\n * console.log(removed) // true (key existed and was removed)\n *\n * // Try to remove non-existent key\n * const notRemoved = yield* TxHashMap.remove(cache, \"user:999\")\n * console.log(notRemoved) // false (key didn't exist)\n *\n * // Verify removal\n * const hasUser3 = yield* TxHashMap.has(cache, \"user:3\")\n * console.log(hasUser3) // false\n *\n * const size = yield* TxHashMap.size(cache)\n * console.log(size) // 2\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const remove = /*#__PURE__*/dual(2, (self, key) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const existed = HashMap.has(currentMap, key);\n if (existed) {\n yield* TxRef.set(self.ref, HashMap.remove(currentMap, key));\n }\n return existed;\n}).pipe(Effect.tx));\n/**\n * Removes all entries from the TxHashMap.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by clearing all key-value pairs.\n * It does not return a new TxHashMap reference.\n *\n * **Example** (Clearing all entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const sessionMap = yield* TxHashMap.make(\n * [\"session1\", { userId: \"alice\", expires: \"2024-01-01T12:00:00Z\" }],\n * [\"session2\", { userId: \"bob\", expires: \"2024-01-01T13:00:00Z\" }],\n * [\"session3\", { userId: \"charlie\", expires: \"2024-01-01T14:00:00Z\" }]\n * )\n *\n * // Check initial state\n * const initialSize = yield* TxHashMap.size(sessionMap)\n * console.log(initialSize) // 3\n *\n * // Clear all sessions (e.g., during maintenance)\n * yield* TxHashMap.clear(sessionMap)\n *\n * // Verify cleared\n * const finalSize = yield* TxHashMap.size(sessionMap)\n * console.log(finalSize) // 0\n *\n * const isEmpty = yield* TxHashMap.isEmpty(sessionMap)\n * console.log(isEmpty) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const clear = self => TxRef.set(self.ref, HashMap.empty());\n/**\n * Returns the number of entries in the TxHashMap.\n *\n * **Example** (Counting entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const metrics = yield* TxHashMap.make(\n * [\"requests\", 1000],\n * [\"errors\", 5],\n * [\"users\", 50]\n * )\n *\n * const count = yield* TxHashMap.size(metrics)\n * console.log(count) // 3\n *\n * // Add more metrics\n * yield* TxHashMap.set(metrics, \"response_time\", 250)\n * const newCount = yield* TxHashMap.size(metrics)\n * console.log(newCount) // 4\n *\n * // Remove a metric\n * yield* TxHashMap.remove(metrics, \"errors\")\n * const finalCount = yield* TxHashMap.size(metrics)\n * console.log(finalCount) // 3\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const size = self => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.size(map);\n});\n/**\n * Checks whether the TxHashMap is empty.\n *\n * **Example** (Checking for an empty map)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Start with empty map\n * const cache = yield* TxHashMap.empty<string, any>()\n * const empty = yield* TxHashMap.isEmpty(cache)\n * console.log(empty) // true\n *\n * // Add an item\n * yield* TxHashMap.set(cache, \"key1\", \"value1\")\n * const stillEmpty = yield* TxHashMap.isEmpty(cache)\n * console.log(stillEmpty) // false\n *\n * // Clear and check again\n * yield* TxHashMap.clear(cache)\n * const emptyAgain = yield* TxHashMap.isEmpty(cache)\n * console.log(emptyAgain) // true\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const isEmpty = self => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.isEmpty(map);\n});\n/**\n * Checks whether the TxHashMap is non-empty.\n *\n * **Example** (Checking for a non-empty map)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const inventory = yield* TxHashMap.make([\"laptop\", 5])\n *\n * const hasItems = yield* TxHashMap.isNonEmpty(inventory)\n * console.log(hasItems) // true\n *\n * // Clear inventory\n * yield* TxHashMap.clear(inventory)\n * const stillHasItems = yield* TxHashMap.isNonEmpty(inventory)\n * console.log(stillHasItems) // false\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isNonEmpty = self => Effect.map(isEmpty(self), empty => !empty);\n/**\n * Updates the value for the specified key if it exists, returning the previous value in `Some`; returns `None` and leaves the map unchanged when the key is absent.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by updating the value at the\n * specified key. It does not return a new TxHashMap reference.\n *\n * **Example** (Updating existing values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const counters = yield* TxHashMap.make(\n * [\"downloads\", 100],\n * [\"views\", 250]\n * )\n *\n * // Increment existing counter\n * const oldDownloads = yield* TxHashMap.modify(\n * counters,\n * \"downloads\",\n * (count) => count + 1\n * )\n * console.log(oldDownloads) // Option.some(100)\n *\n * const newDownloads = yield* TxHashMap.get(counters, \"downloads\")\n * console.log(newDownloads) // Option.some(101)\n *\n * // Try to modify non-existent key\n * const nonExistent = yield* TxHashMap.modify(\n * counters,\n * \"clicks\",\n * (count) => count + 1\n * )\n * console.log(nonExistent) // Option.none()\n *\n * // Update views counter with direct method call\n * yield* TxHashMap.modify(counters, \"views\", (views) => views * 2)\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const modify = /*#__PURE__*/dual(3, (self, key, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const currentValue = HashMap.get(currentMap, key);\n if (Option.isSome(currentValue)) {\n const newValue = f(currentValue.value);\n yield* TxRef.set(self.ref, HashMap.set(currentMap, key, newValue));\n return currentValue;\n }\n return Option.none();\n}).pipe(Effect.tx));\n/**\n * Updates the value for the specified key using an Option-based update function.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by updating, adding, or removing\n * the key-value pair based on the function result. It does not return a new\n * TxHashMap reference.\n *\n * **Example** (Updating values with Option)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const storage = yield* TxHashMap.make<string, string | number>([\n * \"file1.txt\",\n * \"content1\"\n * ], [\"access_count\", 0])\n *\n * // Increment existing counter\n * yield* TxHashMap.modifyAt(storage, \"access_count\", (current) =>\n * current._tag === \"Some\" && typeof current.value === \"number\"\n * ? { ...current, value: current.value + 1 }\n * : current\n * )\n * const count1 = yield* TxHashMap.get(storage, \"access_count\")\n * console.log(count1) // Option.some(1)\n *\n * // Increment existing counter again\n * yield* TxHashMap.modifyAt(storage, \"access_count\", (current) =>\n * current._tag === \"Some\" && typeof current.value === \"number\"\n * ? { ...current, value: current.value + 1 }\n * : current\n * )\n * const count2 = yield* TxHashMap.get(storage, \"access_count\")\n * console.log(count2) // Option.some(2)\n *\n * // Update an existing string entry\n * yield* TxHashMap.modifyAt(storage, \"file1.txt\", (current) =>\n * current._tag === \"Some\" && typeof current.value === \"string\"\n * ? { ...current, value: `${current.value}.bak` }\n * : current\n * )\n * const backup = yield* TxHashMap.get(storage, \"file1.txt\")\n * console.log(backup) // Option.some(\"content1.bak\")\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const modifyAt = /*#__PURE__*/dual(3, (self, key, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const currentValue = HashMap.get(currentMap, key);\n const newValue = f(currentValue);\n if (Option.isSome(newValue)) {\n yield* TxRef.set(self.ref, HashMap.set(currentMap, key, newValue.value));\n } else if (Option.isSome(currentValue)) {\n yield* TxRef.set(self.ref, HashMap.remove(currentMap, key));\n }\n}).pipe(Effect.tx));\n/**\n * Returns an array of all keys in the TxHashMap.\n *\n * **Example** (Reading keys)\n *\n * ```ts\n * import { Effect, Option, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const userRoles = yield* TxHashMap.make(\n * [\"alice\", \"admin\"],\n * [\"bob\", \"user\"],\n * [\"charlie\", \"moderator\"]\n * )\n *\n * const usernames = yield* TxHashMap.keys(userRoles)\n * console.log(usernames.sort()) // [\"alice\", \"bob\", \"charlie\"]\n *\n * // Useful for iteration\n * for (const username of usernames) {\n * const role = yield* TxHashMap.get(userRoles, username)\n * if (role._tag === \"Some\") {\n * console.log(`${username}: ${role.value}`)\n * }\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const keys = self => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return Array.from(HashMap.keys(map));\n});\n/**\n * Returns an array of all values in the TxHashMap.\n *\n * **Example** (Reading values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const scores = yield* TxHashMap.make(\n * [\"alice\", 95],\n * [\"bob\", 87],\n * [\"charlie\", 92]\n * )\n *\n * const allScores = yield* TxHashMap.values(scores)\n * console.log(allScores.sort((a, b) => a - b)) // [87, 92, 95]\n *\n * // Calculate average\n * const average = allScores.reduce((sum, score) => sum + score, 0) /\n * allScores.length\n * console.log(average.toFixed(2)) // \"91.33\"\n *\n * // Find maximum\n * const maxScore = Math.max(...allScores)\n * console.log(maxScore) // 95\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const values = self => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.toValues(map);\n});\n/**\n * Returns an array of all key-value pairs in the TxHashMap.\n *\n * **Example** (Reading entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const config = yield* TxHashMap.make(\n * [\"host\", \"localhost\"],\n * [\"port\", \"3000\"],\n * [\"ssl\", \"false\"]\n * )\n *\n * const allEntries = yield* TxHashMap.entries(config)\n * const sortedEntries = allEntries.toSorted(([left], [right]) => left.localeCompare(right))\n * console.log(sortedEntries)\n * // [[\"host\", \"localhost\"], [\"port\", \"3000\"], [\"ssl\", \"false\"]]\n *\n * // Process configuration entries\n * for (const [key, value] of sortedEntries) {\n * console.log(`${key}=${value}`)\n * }\n * // host=localhost\n * // port=3000\n * // ssl=false\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const entries = self => Effect.gen(function* () {\n const map = yield* TxRef.get(self.ref);\n return HashMap.toEntries(map);\n});\n/**\n * Returns an immutable snapshot of the current TxHashMap state.\n *\n * **Example** (Taking immutable snapshots)\n *\n * ```ts\n * import { Effect, HashMap, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const liveData = yield* TxHashMap.make(\n * [\"temperature\", 22.5],\n * [\"humidity\", 45.2],\n * [\"pressure\", 1013.25]\n * )\n *\n * // Take snapshot for reporting\n * const snapshot = yield* TxHashMap.snapshot(liveData)\n *\n * // Continue modifying live data\n * yield* TxHashMap.set(liveData, \"temperature\", 23.1)\n * yield* TxHashMap.set(liveData, \"wind_speed\", 5.3)\n *\n * // Snapshot remains unchanged\n * console.log(HashMap.size(snapshot)) // 3\n * console.log(HashMap.get(snapshot, \"temperature\")) // Option.some(22.5)\n *\n * // Can use regular HashMap operations on snapshot\n * const tempReading = HashMap.get(snapshot, \"temperature\")\n * const humidityReading = HashMap.get(snapshot, \"humidity\")\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const snapshot = self => TxRef.get(self.ref);\n/**\n * Merges another HashMap into this TxHashMap. If both maps contain the same key,\n * the value from the other map will be used.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by merging the provided HashMap\n * into it. It does not return a new TxHashMap reference.\n *\n * **Example** (Merging HashMaps)\n *\n * ```ts\n * import { Effect, HashMap, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create initial user preferences\n * const userPrefs = yield* TxHashMap.make(\n * [\"theme\", \"light\"],\n * [\"language\", \"en\"],\n * [\"notifications\", \"enabled\"]\n * )\n *\n * // New preferences to merge in\n * const newSettings = HashMap.make(\n * [\"theme\", \"dark\"], // will override existing\n * [\"timezone\", \"UTC\"], // new setting\n * [\"sound\", \"enabled\"] // new setting\n * )\n *\n * // Merge the new settings\n * yield* TxHashMap.union(userPrefs, newSettings)\n *\n * // Check the merged result\n * const theme = yield* TxHashMap.get(userPrefs, \"theme\")\n * console.log(theme) // Option.some(\"dark\") - overridden\n *\n * const language = yield* TxHashMap.get(userPrefs, \"language\")\n * console.log(language) // Option.some(\"en\") - preserved\n *\n * const timezone = yield* TxHashMap.get(userPrefs, \"timezone\")\n * console.log(timezone) // Option.some(\"UTC\") - newly added\n *\n * const size = yield* TxHashMap.size(userPrefs)\n * console.log(size) // 5 total settings\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const union = /*#__PURE__*/dual(2, (self, other) => TxRef.update(self.ref, map => HashMap.union(map, other)));\n/**\n * Removes multiple keys from the TxHashMap.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by removing all specified keys.\n * It does not return a new TxHashMap reference.\n *\n * **Example** (Removing multiple keys)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a cache with temporary data\n * const cache = yield* TxHashMap.make(\n * [\"session_1\", { user: \"alice\", expires: \"2024-01-01\" }],\n * [\"session_2\", { user: \"bob\", expires: \"2024-01-01\" }],\n * [\"session_3\", { user: \"charlie\", expires: \"2024-12-31\" }],\n * [\"temp_data_1\", { value: \"temporary\" }],\n * [\"temp_data_2\", { value: \"also_temporary\" }]\n * )\n *\n * console.log(yield* TxHashMap.size(cache)) // 5\n *\n * // Remove expired sessions and temporary data\n * const keysToRemove = [\"session_1\", \"session_2\", \"temp_data_1\", \"temp_data_2\"]\n * yield* TxHashMap.removeMany(cache, keysToRemove)\n *\n * console.log(yield* TxHashMap.size(cache)) // 1\n *\n * // Verify only the valid session remains\n * const remainingSession = yield* TxHashMap.get(cache, \"session_3\")\n * console.log(remainingSession) // Option.some({ user: \"charlie\", expires: \"2024-12-31\" })\n *\n * // Can also remove from Set, Array, or any iterable\n * const moreKeysToRemove = new Set([\"session_3\"])\n * yield* TxHashMap.removeMany(cache, moreKeysToRemove)\n * console.log(yield* TxHashMap.isEmpty(cache)) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const removeMany = /*#__PURE__*/dual(2, (self, keys) => TxRef.update(self.ref, map => HashMap.removeMany(map, keys)));\n/**\n * Sets multiple key-value pairs in the TxHashMap.\n *\n * **Details**\n *\n * This function mutates the original TxHashMap by setting all provided key-value\n * pairs. It does not return a new TxHashMap reference.\n *\n * **Example** (Setting multiple entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create an empty product catalog\n * const catalog = yield* TxHashMap.empty<\n * string,\n * { price: number; stock: number }\n * >()\n *\n * // Bulk load initial products\n * const initialProducts: Array<\n * readonly [string, { price: number; stock: number }]\n * > = [\n * [\"laptop\", { price: 999, stock: 5 }],\n * [\"mouse\", { price: 29, stock: 50 }],\n * [\"keyboard\", { price: 79, stock: 20 }],\n * [\"monitor\", { price: 299, stock: 8 }]\n * ]\n *\n * yield* TxHashMap.setMany(catalog, initialProducts)\n *\n * console.log(yield* TxHashMap.size(catalog)) // 4\n *\n * // Update prices with a new batch\n * const priceUpdates: Array<\n * readonly [string, { price: number; stock: number }]\n * > = [\n * [\"laptop\", { price: 899, stock: 5 }], // sale price\n * [\"mouse\", { price: 25, stock: 50 }], // sale price\n * [\"webcam\", { price: 89, stock: 12 }] // new product\n * ]\n *\n * yield* TxHashMap.setMany(catalog, priceUpdates)\n *\n * console.log(yield* TxHashMap.size(catalog)) // 5 (4 original + 1 new)\n *\n * // Verify the updates\n * const laptop = yield* TxHashMap.get(catalog, \"laptop\")\n * console.log(laptop) // Option.some({ price: 899, stock: 5 })\n *\n * // Can also use Map, Set of tuples, or any iterable of entries\n * const jsMap = new Map([[\"tablet\", { price: 399, stock: 3 }]])\n * yield* TxHashMap.setMany(catalog, jsMap)\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const setMany = /*#__PURE__*/dual(2, (self, entries) => TxRef.update(self.ref, map => HashMap.setMany(map, entries)));\n/**\n * Returns `true` if the specified value is a `TxHashMap`, `false` otherwise.\n *\n * **Example** (Checking TxHashMap values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txMap = yield* TxHashMap.make([\"key\", \"value\"])\n *\n * console.log(TxHashMap.isTxHashMap(txMap)) // true\n * console.log(TxHashMap.isTxHashMap({})) // false\n * console.log(TxHashMap.isTxHashMap(null)) // false\n * console.log(TxHashMap.isTxHashMap(\"not a map\")) // false\n *\n * // Useful for type guards in runtime checks\n * const validateInput = (value: unknown) => {\n * if (TxHashMap.isTxHashMap(value)) {\n * // TypeScript now knows this is a TxHashMap\n * return Effect.succeed(\"Valid TxHashMap\")\n * }\n * return Effect.fail(\"Invalid input\")\n * }\n * })\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxHashMap = value => {\n return hasProperty(value, TypeId);\n};\n/**\n * Looks up the value for the specified key using a caller-supplied hash.\n *\n * **Gotchas**\n *\n * The supplied hash must be the hash for the same key, such as a precomputed\n * `Hash.hash(key)` value. If the hash does not match the key, an existing entry\n * may not be found.\n *\n * **Example** (Looking up values with precomputed hashes)\n *\n * ```ts\n * import { Effect, Hash, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a cache with user sessions\n * const cache = yield* TxHashMap.make(\n * [\"session_abc123\", { userId: \"user1\", lastActive: 1_700_000_000_000 }],\n * [\"session_def456\", { userId: \"user2\", lastActive: 1_700_000_060_000 }]\n * )\n *\n * // When you have precomputed hash (e.g., from another lookup)\n * const sessionId = \"session_abc123\"\n * const precomputedHash = Hash.string(sessionId)\n *\n * // Use hash-optimized lookup for performance in hot paths\n * const session = yield* TxHashMap.getHash(cache, sessionId, precomputedHash)\n * console.log(session) // Option.some({ userId: \"user1\", lastActive: ... })\n *\n * // This avoids recomputing the hash when you already have it\n * const invalidSession = yield* TxHashMap.getHash(\n * cache,\n * \"invalid\",\n * Hash.string(\"invalid\")\n * )\n * console.log(invalidSession) // Option.none()\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getHash = /*#__PURE__*/dual(3, (self, key, hash) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.getHash(map, key, hash))));\n/**\n * Checks whether the specified key has an entry using a caller-supplied hash.\n *\n * **Gotchas**\n *\n * The supplied hash must be the hash for the same key, such as a precomputed\n * `Hash.hash(key)` value. If the hash does not match the key, an existing entry\n * may not be found.\n *\n * **Example** (Checking keys with precomputed hashes)\n *\n * ```ts\n * import { Effect, Hash, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create an access control map\n * const permissions = yield* TxHashMap.make(\n * [\"admin\", { read: true, write: true, delete: true }],\n * [\"user\", { read: true, write: false, delete: false }]\n * )\n *\n * // When checking permissions frequently with same roles\n * const role = \"admin\"\n * const roleHash = Hash.string(role)\n *\n * // Use hash-optimized existence check\n * const hasAdminRole = yield* TxHashMap.hasHash(permissions, role, roleHash)\n * console.log(hasAdminRole) // true\n *\n * // Check non-existent role\n * const hasGuestRole = yield* TxHashMap.hasHash(\n * permissions,\n * \"guest\",\n * Hash.string(\"guest\")\n * )\n * console.log(hasGuestRole) // false\n *\n * // Useful in hot paths where hash is computed once and reused\n * const roles = [\"admin\", \"user\", \"moderator\"]\n * const roleHashes = roles.map((role) => [role, Hash.string(role)] as const)\n *\n * for (const [role, hash] of roleHashes) {\n * const exists = yield* TxHashMap.hasHash(permissions, role, hash)\n * console.log(`Role ${role}: ${exists}`)\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const hasHash = /*#__PURE__*/dual(3, (self, key, hash) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.hasHash(map, key, hash))));\n/**\n * Transforms all values in the TxHashMap using the provided function, preserving keys.\n *\n * **Details**\n *\n * This function returns a new TxHashMap reference with the transformed values.\n * The original TxHashMap is not modified.\n *\n * **Example** (Mapping values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a user profile map\n * const profiles = yield* TxHashMap.make(\n * [\"alice\", { name: \"Alice\", age: 30, active: true }],\n * [\"bob\", { name: \"Bob\", age: 25, active: false }],\n * [\"charlie\", { name: \"Charlie\", age: 35, active: true }]\n * )\n *\n * // Transform to extract just names with greeting\n * const greetings = yield* TxHashMap.map(\n * profiles,\n * (profile, userId) => `Hello, ${profile.name}! (User: ${userId})`\n * )\n *\n * // Check the transformed values\n * const aliceGreeting = yield* TxHashMap.get(greetings, \"alice\")\n * console.log(aliceGreeting) // Option.some(\"Hello, Alice! (User: alice)\")\n *\n * // Data-last usage with pipe\n * const ages = yield* profiles.pipe(\n * TxHashMap.map((profile) => profile.age)\n * )\n *\n * const aliceAge = yield* TxHashMap.get(ages, \"alice\")\n * console.log(aliceAge) // Option.some(30)\n *\n * // Original map is unchanged\n * const originalAlice = yield* TxHashMap.get(profiles, \"alice\")\n * console.log(originalAlice) // Option.some({ name: \"Alice\", age: 30, active: true })\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const map = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const mappedMap = HashMap.map(currentMap, f);\n return yield* fromHashMap(mappedMap);\n}).pipe(Effect.tx));\n/**\n * Filters the TxHashMap to keep only entries that satisfy the provided predicate.\n *\n * **Details**\n *\n * This function returns a new TxHashMap reference containing only the entries\n * that match the condition. The original TxHashMap is not modified.\n *\n * **Example** (Filtering entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a product inventory\n * const inventory = yield* TxHashMap.make(\n * [\"laptop\", { price: 999, stock: 5, category: \"electronics\" }],\n * [\"mouse\", { price: 29, stock: 50, category: \"electronics\" }],\n * [\"book\", { price: 15, stock: 100, category: \"books\" }],\n * [\"phone\", { price: 699, stock: 0, category: \"electronics\" }]\n * )\n *\n * // Filter to get only electronics in stock\n * const electronicsInStock = yield* TxHashMap.filter(\n * inventory,\n * (product) => product.category === \"electronics\" && product.stock > 0\n * )\n *\n * const size = yield* TxHashMap.size(electronicsInStock)\n * console.log(size) // 2 (laptop and mouse)\n *\n * // Data-last usage with pipe\n * const expensiveItems = yield* inventory.pipe(\n * TxHashMap.filter((product) => product.price > 500)\n * )\n *\n * const expensiveSize = yield* TxHashMap.size(expensiveItems)\n * console.log(expensiveSize) // 2 (laptop and phone)\n *\n * // Type guard usage\n * const highValueItems = yield* TxHashMap.filter(\n * inventory,\n * (product): product is typeof product & { price: number } =>\n * product.price > 50\n * )\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const filter = /*#__PURE__*/dual(2, (self, predicate) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const filteredMap = HashMap.filter(currentMap, predicate);\n return yield* fromHashMap(filteredMap);\n}).pipe(Effect.tx));\n/**\n * Reduces the TxHashMap entries to a single value by applying a reducer function.\n * Iterates over all key-value pairs and accumulates them into a final result.\n *\n * **Example** (Reducing entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a sales data map\n * const sales = yield* TxHashMap.make(\n * [\"Q1\", 15000],\n * [\"Q2\", 18000],\n * [\"Q3\", 22000],\n * [\"Q4\", 25000]\n * )\n *\n * // Calculate total sales\n * const totalSales = yield* TxHashMap.reduce(\n * sales,\n * 0,\n * (total, amount, quarter) => {\n * console.log(`Adding ${quarter}: ${amount}`)\n * return total + amount\n * }\n * )\n * console.log(`Total sales: ${totalSales}`) // 80000\n *\n * // Data-last usage with pipe\n * const quarterlyReport = yield* sales.pipe(\n * TxHashMap.reduce(\n * { quarters: 0, total: 0, max: 0 },\n * (report, amount, quarter) => ({\n * quarters: report.quarters + 1,\n * total: report.total + amount,\n * max: Math.max(report.max, amount)\n * })\n * )\n * )\n * console.log(quarterlyReport) // { quarters: 4, total: 80000, max: 25000 }\n *\n * // Build a summary string\n * const summary = yield* TxHashMap.reduce(\n * sales,\n * \"\",\n * (acc, amount, quarter) => acc + `${quarter}: $${amount.toLocaleString()}\\n`\n * )\n * console.log(summary)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const reduce = /*#__PURE__*/dual(3, (self, zero, f) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.reduce(map, zero, f))));\n/**\n * Combines filtering and mapping in a single operation. Applies a filter to each\n * entry, keeping only successful results and transforming them.\n *\n * **Details**\n *\n * This function returns a new TxHashMap reference containing only the transformed\n * entries that succeeded. The original TxHashMap is not modified.\n *\n * **Example** (Filtering and mapping entries)\n *\n * ```ts\n * import { Effect, Option, Result, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a mixed data map\n * const userData = yield* TxHashMap.make(\n * [\"alice\", { age: \"30\", role: \"admin\", active: true }],\n * [\"bob\", { age: \"invalid\", role: \"user\", active: true }],\n * [\"charlie\", { age: \"25\", role: \"admin\", active: false }],\n * [\"diana\", { age: \"28\", role: \"user\", active: true }]\n * )\n *\n * // Extract valid ages for active admin users only\n * const activeAdminAges = yield* TxHashMap.filterMap(\n * userData,\n * (user, username) => {\n * if (!user.active || user.role !== \"admin\") return Result.failVoid\n * const age = parseInt(user.age)\n * if (isNaN(age)) return Result.failVoid\n * return Result.succeed({\n * username,\n * age,\n * seniority: age > 27 ? \"senior\" : \"junior\"\n * })\n * }\n * )\n *\n * const aliceData = yield* TxHashMap.get(activeAdminAges, \"alice\")\n * console.log(aliceData) // Option.some({ username: \"alice\", age: 30, seniority: \"senior\" })\n *\n * const charlieData = yield* TxHashMap.get(activeAdminAges, \"charlie\")\n * console.log(charlieData) // Option.none() (not active)\n *\n * // Data-last usage with pipe\n * const validAges = yield* userData.pipe(\n * TxHashMap.filterMap((user) => {\n * const age = parseInt(user.age)\n * return isNaN(age) ? Result.failVoid : Result.succeed(age)\n * })\n * )\n *\n * const size = yield* TxHashMap.size(validAges)\n * console.log(size) // 3 (alice, charlie, diana have valid ages)\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const filterMap = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const filteredMap = HashMap.filterMap(currentMap, f);\n return yield* fromHashMap(filteredMap);\n}).pipe(Effect.tx));\n/**\n * Checks whether any entry in the TxHashMap matches the given predicate.\n *\n * **Example** (Checking entries with a predicate)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a user status map\n * const currentTime = 1_700_000_000_000\n * const userStatuses = yield* TxHashMap.make(\n * [\"alice\", { status: \"online\", lastSeen: currentTime }],\n * [\"bob\", { status: \"offline\", lastSeen: currentTime - 3_600_000 }],\n * [\"charlie\", { status: \"online\", lastSeen: currentTime }]\n * )\n *\n * // Check if any users are online\n * const hasOnlineUsers = yield* TxHashMap.hasBy(\n * userStatuses,\n * (user) => user.status === \"online\"\n * )\n * console.log(hasOnlineUsers) // true\n *\n * // Check if any users have specific username pattern\n * const hasAdminUser = yield* TxHashMap.hasBy(\n * userStatuses,\n * (user, username) => username.startsWith(\"admin\")\n * )\n * console.log(hasAdminUser) // false\n *\n * // Data-last usage with pipe\n * const hasRecentActivity = yield* userStatuses.pipe(\n * TxHashMap.hasBy((user) => currentTime - user.lastSeen < 1_800_000) // 30 minutes\n * )\n * console.log(hasRecentActivity) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const hasBy = /*#__PURE__*/dual(2, (self, predicate) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.hasBy(map, predicate))));\n/**\n * Finds the first entry in the TxHashMap that matches the given predicate.\n * Returns the key-value pair as a tuple wrapped in an Option.\n *\n * **Example** (Finding the first matching entry)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a task priority map\n * const tasks = yield* TxHashMap.make(\n * [\"task1\", { priority: 1, assignee: \"alice\", completed: false }],\n * [\"task2\", { priority: 3, assignee: \"bob\", completed: true }],\n * [\"task3\", { priority: 2, assignee: \"alice\", completed: false }]\n * )\n *\n * // Find first high-priority incomplete task\n * const highPriorityTask = yield* TxHashMap.findFirst(\n * tasks,\n * (task) => task.priority >= 2 && !task.completed\n * )\n *\n * if (highPriorityTask._tag === \"Some\") {\n * const [taskId, task] = highPriorityTask.value\n * console.log(`Found task: ${taskId}, priority: ${task.priority}`)\n * // \"Found task: task3, priority: 2\"\n * }\n *\n * // Find first task assigned to specific user\n * const aliceTask = yield* tasks.pipe(\n * TxHashMap.findFirst((task) => task.assignee === \"alice\")\n * )\n *\n * if (aliceTask._tag === \"Some\") {\n * console.log(`Alice's task: ${aliceTask.value[0]}`)\n * }\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const findFirst = /*#__PURE__*/dual(2, (self, predicate) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.findFirst(map, predicate))));\n/**\n * Checks whether at least one entry in the TxHashMap satisfies the given predicate.\n *\n * **Example** (Checking whether some entries match)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a product inventory\n * const inventory = yield* TxHashMap.make(\n * [\"laptop\", { price: 999, stock: 5 }],\n * [\"mouse\", { price: 29, stock: 50 }],\n * [\"keyboard\", { price: 79, stock: 0 }]\n * )\n *\n * // Check if any products are expensive\n * const hasExpensiveProducts = yield* TxHashMap.some(\n * inventory,\n * (product) => product.price > 500\n * )\n * console.log(hasExpensiveProducts) // true\n *\n * // Check if any products are out of stock\n * const hasOutOfStock = yield* TxHashMap.some(\n * inventory,\n * (product) => product.stock === 0\n * )\n * console.log(hasOutOfStock) // true\n *\n * // Data-last usage with pipe\n * const hasAffordableItems = yield* inventory.pipe(\n * TxHashMap.some((product) => product.price < 50)\n * )\n * console.log(hasAffordableItems) // true (mouse is $29)\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const some = /*#__PURE__*/dual(2, (self, predicate) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.some(map, predicate))));\n/**\n * Checks whether all entries in the TxHashMap satisfy the given predicate.\n *\n * **Example** (Checking whether every entry matches)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a user permissions map\n * const permissions = yield* TxHashMap.make(\n * [\"alice\", { canRead: true, canWrite: true, canDelete: false }],\n * [\"bob\", { canRead: true, canWrite: false, canDelete: false }],\n * [\"charlie\", { canRead: true, canWrite: true, canDelete: true }]\n * )\n *\n * // Check if all users can read\n * const allCanRead = yield* TxHashMap.every(\n * permissions,\n * (perms) => perms.canRead\n * )\n * console.log(allCanRead) // true\n *\n * // Check if all users can write\n * const allCanWrite = yield* TxHashMap.every(\n * permissions,\n * (perms) => perms.canWrite\n * )\n * console.log(allCanWrite) // false\n *\n * // Data-last usage with pipe\n * const allHaveBasicAccess = yield* permissions.pipe(\n * TxHashMap.every((perms, username) => perms.canRead && username.length > 2)\n * )\n * console.log(allHaveBasicAccess) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const every = /*#__PURE__*/dual(2, (self, predicate) => TxRef.get(self.ref).pipe(Effect.map(map => HashMap.every(map, predicate))));\n/**\n * Executes a side-effect function for each entry in the TxHashMap.\n * The function receives the value and key as parameters and can perform effects.\n *\n * **Example** (Running effects for each entry)\n *\n * ```ts\n * import { Console, Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a log processing map\n * const logs = yield* TxHashMap.make(\n * [\"error.log\", { size: 1024, level: \"error\" }],\n * [\"access.log\", { size: 2048, level: \"info\" }],\n * [\"debug.log\", { size: 512, level: \"debug\" }]\n * )\n *\n * // Process each log file with side effects\n * yield* TxHashMap.forEach(logs, (logInfo, filename) =>\n * Effect.gen(function*() {\n * yield* Console.log(\n * `Processing ${filename}: ${logInfo.size} bytes, level: ${logInfo.level}`\n * )\n * if (logInfo.level === \"error\") {\n * yield* Console.log(`⚠️ Error log detected: ${filename}`)\n * }\n * }))\n *\n * // Data-last usage with pipe\n * yield* logs.pipe(\n * TxHashMap.forEach((logInfo) =>\n * logInfo.size > 1000\n * ? Console.log(`Large log file: ${logInfo.size} bytes`)\n * : Effect.void\n * )\n * )\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const forEach = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const entries = HashMap.toEntries(currentMap);\n yield* Effect.forEach(entries, ([key, value]) => f(value, key));\n}));\n/**\n * Maps each entry effectfully to a `TxHashMap` and flattens the produced maps.\n *\n * **Details**\n *\n * This function returns a new TxHashMap reference with the flattened results.\n * The original TxHashMap is not modified.\n *\n * **Example** (Flat mapping entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a department-employee map\n * const departments = yield* TxHashMap.make(\n * [\"engineering\", [\"alice\", \"bob\"]],\n * [\"marketing\", [\"charlie\", \"diana\"]]\n * )\n *\n * // Expand each department into individual employee entries with metadata\n * const employeeDetails = yield* TxHashMap.flatMap(\n * departments,\n * (employees, department) =>\n * Effect.gen(function*() {\n * const employeeMap = yield* TxHashMap.empty<\n * string,\n * { department: string; role: string }\n * >()\n * for (let i = 0; i < employees.length; i++) {\n * const employee = employees[i]\n * const role = i === 0 ? \"lead\" : \"member\"\n * yield* TxHashMap.set(employeeMap, employee, { department, role })\n * }\n * return employeeMap\n * })\n * )\n *\n * // Check the flattened result\n * const alice = yield* TxHashMap.get(employeeDetails, \"alice\")\n * console.log(alice) // Option.some({ department: \"engineering\", role: \"lead\" })\n *\n * const charlie = yield* TxHashMap.get(employeeDetails, \"charlie\")\n * console.log(charlie) // Option.some({ department: \"marketing\", role: \"lead\" })\n *\n * const size = yield* TxHashMap.size(employeeDetails)\n * console.log(size) // 4 (all employees)\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const flatMap = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const result = yield* empty();\n const mapEntries = HashMap.toEntries(currentMap);\n for (const [key, value] of mapEntries) {\n const newMap = yield* f(value, key);\n const newEntries = yield* entries(newMap);\n yield* setMany(result, newEntries);\n }\n return result;\n}).pipe(Effect.tx));\n/**\n * Removes all None values from a TxHashMap containing Option values.\n *\n * **Details**\n *\n * This function returns a new TxHashMap reference with only the Some values\n * unwrapped. The original TxHashMap is not modified.\n *\n * **Example** (Compacting optional values)\n *\n * ```ts\n * import { Effect, Option, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a map with optional user data\n * const userData = yield* TxHashMap.make<\n * string,\n * Option.Option<{ age: number; email?: string }>\n * >(\n * [\"alice\", Option.some({ age: 30, email: \"alice@example.com\" })],\n * [\"bob\", Option.none()], // incomplete data\n * [\"charlie\", Option.some({ age: 25 })],\n * [\"diana\", Option.none()], // missing data\n * [\"eve\", Option.some({ age: 28, email: \"eve@example.com\" })]\n * )\n *\n * // Remove all None values and unwrap Some values\n * const validUsers = yield* TxHashMap.compact(userData)\n *\n * const size = yield* TxHashMap.size(validUsers)\n * console.log(size) // 3 (alice, charlie, eve)\n *\n * const alice = yield* TxHashMap.get(validUsers, \"alice\")\n * console.log(alice) // Option.some({ age: 30, email: \"alice@example.com\" })\n *\n * const bob = yield* TxHashMap.get(validUsers, \"bob\")\n * console.log(bob) // Option.none() (removed from map)\n *\n * // Useful for cleaning up optional data processing results\n * const userAges = yield* TxHashMap.map(validUsers, (user) => user.age)\n * const ageEntries = yield* TxHashMap.entries(userAges)\n * const sortedAgeEntries = ageEntries.toSorted(([left], [right]) => left.localeCompare(right))\n * console.log(sortedAgeEntries) // [[\"alice\", 30], [\"charlie\", 25], [\"eve\", 28]]\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const compact = self => Effect.gen(function* () {\n const currentMap = yield* TxRef.get(self.ref);\n const compactedMap = HashMap.compact(currentMap);\n return yield* fromHashMap(compactedMap);\n}).pipe(Effect.tx);\n/**\n * Returns an array of all key-value pairs in the TxHashMap.\n * This is an alias for the `entries` function, providing API consistency with HashMap.\n *\n * **Example** (Converting to entries)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const settings = yield* TxHashMap.make(\n * [\"theme\", \"dark\"],\n * [\"language\", \"en-US\"],\n * [\"timezone\", \"UTC\"]\n * )\n *\n * // Get all entries as an array\n * const allEntries = yield* TxHashMap.toEntries(settings)\n * const sortedEntries = allEntries.toSorted(([left], [right]) => left.localeCompare(right))\n * console.log(sortedEntries)\n * // [[\"language\", \"en-US\"], [\"theme\", \"dark\"], [\"timezone\", \"UTC\"]]\n *\n * // Process entries\n * for (const [setting, value] of sortedEntries) {\n * console.log(`${setting}: ${value}`)\n * }\n *\n * // Convert to object for JSON serialization\n * const settingsObj = Object.fromEntries(sortedEntries)\n * console.log(JSON.stringify(settingsObj))\n * // {\"language\":\"en-US\",\"theme\":\"dark\",\"timezone\":\"UTC\"}\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const toEntries = self => entries(self);\n/**\n * Returns an array of all values in the TxHashMap.\n * This is an alias for the `values` function, providing API consistency with HashMap.\n *\n * **Example** (Converting to values)\n *\n * ```ts\n * import { Effect, TxHashMap } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const inventory = yield* TxHashMap.make(\n * [\"laptop\", { price: 999, stock: 5 }],\n * [\"mouse\", { price: 29, stock: 50 }],\n * [\"keyboard\", { price: 79, stock: 20 }]\n * )\n *\n * // Get all product information\n * const products = yield* TxHashMap.toValues(inventory)\n * console.log(products.length) // 3\n *\n * // Calculate total inventory value\n * const totalValue = products.reduce(\n * (sum, product) => sum + (product.price * product.stock),\n * 0\n * )\n * console.log(`Total inventory value: $${totalValue}`) // Total inventory value: $8025\n *\n * // Find products with low stock\n * const lowStockProducts = products.filter((product) => product.stock < 10)\n * console.log(`${lowStockProducts.length} product with low stock`) // 1 product with low stock\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const toValues = self => values(self);\n/**\n * Helper function to create a TxHashMap from an existing HashMap\n */\nconst fromHashMap = hashMap => Effect.gen(function* () {\n const ref = yield* TxRef.make(hashMap);\n return Object.assign(Object.create(TxHashMapProto), {\n ref\n });\n});\n//# sourceMappingURL=TxHashMap.js.map","/**\n * Transactional hash sets for storing unique values inside Effect\n * transactions.\n *\n * A `TxHashSet` keeps an immutable `HashSet` inside a `TxRef`, so membership\n * checks and updates can commit atomically with other transactional operations.\n * Use it when several pieces of shared transactional state must change\n * together, such as adding a value only after checking related state. The\n * module includes the usual set operations, including adding, removing,\n * membership checks, set algebra, mapping, filtering, reducing, and conversion\n * back to `HashSet`.\n *\n * @since 2.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { format } from \"./Formatter.js\";\nimport { dual } from \"./Function.js\";\nimport * as HashSet from \"./HashSet.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxHashSet\";\nconst TxHashSetProto = {\n [TypeId]: TypeId,\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toString() {\n return `TxHashSet(${format(toJson(this.ref))})`;\n },\n toJSON() {\n return {\n _id: \"TxHashSet\",\n ref: toJson(this.ref)\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeTxHashSet = ref => {\n const self = Object.create(TxHashSetProto);\n self.ref = ref;\n return self;\n};\n/**\n * Creates an empty TxHashSet.\n *\n * **Example** (Creating an empty transactional hash set)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.empty<string>()\n *\n * console.log(yield* TxHashSet.size(txSet)) // 0\n * console.log(yield* TxHashSet.isEmpty(txSet)) // true\n *\n * // Add some values\n * yield* TxHashSet.add(txSet, \"hello\")\n * yield* TxHashSet.add(txSet, \"world\")\n * console.log(yield* TxHashSet.size(txSet)) // 2\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const empty = () => Effect.gen(function* () {\n const ref = yield* TxRef.make(HashSet.empty());\n return makeTxHashSet(ref);\n});\n/**\n * Creates a TxHashSet from a variable number of values.\n *\n * **Example** (Creating transactional hash sets from values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const fruits = yield* TxHashSet.make(\"apple\", \"banana\", \"cherry\")\n * console.log(yield* TxHashSet.size(fruits)) // 3\n *\n * const numbers = yield* TxHashSet.make(1, 2, 3, 2, 1) // Duplicates ignored\n * console.log(yield* TxHashSet.size(numbers)) // 3\n *\n * const mixed = yield* TxHashSet.make(\"hello\", 42, true)\n * console.log(yield* TxHashSet.size(mixed)) // 3\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = (...values) => Effect.gen(function* () {\n const hashSet = HashSet.make(...values);\n const ref = yield* TxRef.make(hashSet);\n return makeTxHashSet(ref);\n});\n/**\n * Creates a TxHashSet from an iterable collection of values.\n *\n * **Example** (Creating a transactional hash set from an iterable)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const fromArray = yield* TxHashSet.fromIterable([\"a\", \"b\", \"c\", \"b\", \"a\"])\n * console.log(yield* TxHashSet.size(fromArray)) // 3\n *\n * const fromSet = yield* TxHashSet.fromIterable(new Set([1, 2, 3]))\n * console.log(yield* TxHashSet.size(fromSet)) // 3\n *\n * const fromString = yield* TxHashSet.fromIterable(\"hello\")\n * const values = yield* TxHashSet.toHashSet(fromString)\n * console.log(Array.from(values).sort()) // [\"e\", \"h\", \"l\", \"o\"]\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromIterable = values => Effect.gen(function* () {\n const hashSet = HashSet.fromIterable(values);\n const ref = yield* TxRef.make(hashSet);\n return makeTxHashSet(ref);\n});\n/**\n * Creates a TxHashSet from an existing HashSet.\n *\n * **Example** (Creating a transactional hash set from a HashSet)\n *\n * ```ts\n * import { Effect, HashSet, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hashSet = HashSet.make(\"x\", \"y\", \"z\")\n * const txSet = yield* TxHashSet.fromHashSet(hashSet)\n *\n * console.log(yield* TxHashSet.size(txSet)) // 3\n * console.log(yield* TxHashSet.has(txSet, \"y\")) // true\n *\n * // Original hashSet is unchanged when txSet is modified\n * yield* TxHashSet.add(txSet, \"w\")\n * console.log(HashSet.size(hashSet)) // 3 (original unchanged)\n * console.log(yield* TxHashSet.size(txSet)) // 4\n * })\n * ```\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const fromHashSet = hashSet => Effect.gen(function* () {\n const ref = yield* TxRef.make(hashSet);\n return makeTxHashSet(ref);\n});\n/**\n * Checks whether a value is a TxHashSet.\n *\n * **Example** (Checking for a TxHashSet)\n *\n * ```ts\n * import { Effect, HashSet, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(1, 2, 3)\n * const hashSet = HashSet.make(1, 2, 3)\n * const array = [1, 2, 3]\n *\n * console.log(TxHashSet.isTxHashSet(txSet)) // true\n * console.log(TxHashSet.isTxHashSet(hashSet)) // false\n * console.log(TxHashSet.isTxHashSet(array)) // false\n * console.log(TxHashSet.isTxHashSet(null)) // false\n * })\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxHashSet = u => hasProperty(u, TypeId);\n/**\n * Adds a value to the TxHashSet. If the value already exists, the operation has no effect.\n *\n * **Details**\n *\n * This function mutates the original TxHashSet by adding the specified value. It does not return a new TxHashSet reference.\n *\n * **Example** (Adding values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(\"a\", \"b\")\n *\n * yield* TxHashSet.add(txSet, \"c\")\n * console.log(yield* TxHashSet.size(txSet)) // 3\n * console.log(yield* TxHashSet.has(txSet, \"c\")) // true\n *\n * // Adding existing value has no effect\n * yield* TxHashSet.add(txSet, \"a\")\n * console.log(yield* TxHashSet.size(txSet)) // 3 (unchanged)\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const add = /*#__PURE__*/dual(2, (self, value) => TxRef.update(self.ref, set => HashSet.add(set, value)));\n/**\n * Removes a value from the TxHashSet.\n *\n * **Details**\n *\n * This function mutates the original TxHashSet by removing the specified value. It does not return a new TxHashSet reference.\n *\n * **Example** (Removing values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(\"a\", \"b\", \"c\")\n *\n * const removed = yield* TxHashSet.remove(txSet, \"b\")\n * console.log(removed) // true (value existed and was removed)\n * console.log(yield* TxHashSet.size(txSet)) // 2\n * console.log(yield* TxHashSet.has(txSet, \"b\")) // false\n *\n * // Removing non-existent value returns false\n * const notRemoved = yield* TxHashSet.remove(txSet, \"d\")\n * console.log(notRemoved) // false\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const remove = /*#__PURE__*/dual(2, (self, value) => Effect.gen(function* () {\n const currentSet = yield* TxRef.get(self.ref);\n const existed = HashSet.has(currentSet, value);\n if (existed) {\n yield* TxRef.set(self.ref, HashSet.remove(currentSet, value));\n }\n return existed;\n}).pipe(Effect.tx));\n/**\n * Checks whether the TxHashSet contains the specified value.\n *\n * **Example** (Checking membership)\n *\n * ```ts\n * import { Effect, Equal, Hash, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(\"apple\", \"banana\", \"cherry\")\n *\n * console.log(yield* TxHashSet.has(txSet, \"apple\")) // true\n * console.log(yield* TxHashSet.has(txSet, \"grape\")) // false\n *\n * // Works with any type that implements Equal\n * class Person implements Equal.Equal {\n * constructor(readonly name: string) {}\n *\n * [Equal.symbol](other: unknown) {\n * return other instanceof Person && this.name === other.name\n * }\n *\n * [Hash.symbol](): number {\n * return Hash.string(this.name)\n * }\n * }\n *\n * const people = yield* TxHashSet.make(new Person(\"Alice\"), new Person(\"Bob\"))\n * console.log(yield* TxHashSet.has(people, new Person(\"Alice\"))) // true\n * })\n * ```\n *\n * @category elements\n * @since 2.0.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, value) => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.has(set, value);\n}));\n/**\n * Returns the number of values in the TxHashSet.\n *\n * **Example** (Getting the set size)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const empty = yield* TxHashSet.empty<string>()\n * console.log(yield* TxHashSet.size(empty)) // 0\n *\n * const small = yield* TxHashSet.make(\"a\", \"b\")\n * console.log(yield* TxHashSet.size(small)) // 2\n *\n * const fromIterable = yield* TxHashSet.fromIterable([\"x\", \"y\", \"z\", \"x\", \"y\"])\n * console.log(yield* TxHashSet.size(fromIterable)) // 3 (duplicates ignored)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const size = self => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.size(set);\n});\n/**\n * Checks whether the TxHashSet is empty.\n *\n * **Example** (Checking whether a set is empty)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const empty = yield* TxHashSet.empty<string>()\n * console.log(yield* TxHashSet.isEmpty(empty)) // true\n *\n * const nonEmpty = yield* TxHashSet.make(\"a\")\n * console.log(yield* TxHashSet.isEmpty(nonEmpty)) // false\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isEmpty = self => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.isEmpty(set);\n});\n/**\n * Removes all values from the TxHashSet.\n *\n * **Details**\n *\n * This function mutates the original TxHashSet by clearing all values. It does not return a new TxHashSet reference.\n *\n * **Example** (Clearing all values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(\"a\", \"b\", \"c\")\n * console.log(yield* TxHashSet.size(txSet)) // 3\n *\n * yield* TxHashSet.clear(txSet)\n * console.log(yield* TxHashSet.size(txSet)) // 0\n * console.log(yield* TxHashSet.isEmpty(txSet)) // true\n * })\n * ```\n *\n * @category mutations\n * @since 4.0.0\n */\nexport const clear = self => TxRef.set(self.ref, HashSet.empty());\n/**\n * Creates the union of two TxHashSets, returning a new TxHashSet.\n *\n * **Example** (Combining sets with union)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set1 = yield* TxHashSet.make(\"a\", \"b\")\n * const set2 = yield* TxHashSet.make(\"b\", \"c\")\n * const combined = yield* TxHashSet.union(set1, set2)\n *\n * const values = yield* TxHashSet.toHashSet(combined)\n * console.log(Array.from(values).sort()) // [\"a\", \"b\", \"c\"]\n * console.log(yield* TxHashSet.size(combined)) // 3\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const union = /*#__PURE__*/dual(2, (self, that) => Effect.gen(function* () {\n const set1 = yield* TxRef.get(self.ref);\n const set2 = yield* TxRef.get(that.ref);\n const combined = HashSet.union(set1, set2);\n return yield* fromHashSet(combined);\n}).pipe(Effect.tx));\n/**\n * Creates the intersection of two TxHashSets, returning a new TxHashSet.\n *\n * **Example** (Finding common values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set1 = yield* TxHashSet.make(\"a\", \"b\", \"c\")\n * const set2 = yield* TxHashSet.make(\"b\", \"c\", \"d\")\n * const common = yield* TxHashSet.intersection(set1, set2)\n *\n * const values = yield* TxHashSet.toHashSet(common)\n * console.log(Array.from(values).sort()) // [\"b\", \"c\"]\n * console.log(yield* TxHashSet.size(common)) // 2\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const intersection = /*#__PURE__*/dual(2, (self, that) => Effect.gen(function* () {\n const set1 = yield* TxRef.get(self.ref);\n const set2 = yield* TxRef.get(that.ref);\n const common = HashSet.intersection(set1, set2);\n return yield* fromHashSet(common);\n}).pipe(Effect.tx));\n/**\n * Creates the difference of two TxHashSets (elements in the first set that are not in the second), returning a new TxHashSet.\n *\n * **Example** (Finding values absent from another set)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const set1 = yield* TxHashSet.make(\"a\", \"b\", \"c\")\n * const set2 = yield* TxHashSet.make(\"b\", \"d\")\n * const diff = yield* TxHashSet.difference(set1, set2)\n *\n * const values = yield* TxHashSet.toHashSet(diff)\n * console.log(Array.from(values).sort()) // [\"a\", \"c\"]\n * console.log(yield* TxHashSet.size(diff)) // 2\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const difference = /*#__PURE__*/dual(2, (self, that) => Effect.gen(function* () {\n const set1 = yield* TxRef.get(self.ref);\n const set2 = yield* TxRef.get(that.ref);\n const diff = HashSet.difference(set1, set2);\n return yield* fromHashSet(diff);\n}).pipe(Effect.tx));\n/**\n * Checks whether a TxHashSet is a subset of another TxHashSet.\n *\n * **Example** (Checking subset relationships)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const small = yield* TxHashSet.make(\"a\", \"b\")\n * const large = yield* TxHashSet.make(\"a\", \"b\", \"c\", \"d\")\n * const other = yield* TxHashSet.make(\"x\", \"y\")\n *\n * console.log(yield* TxHashSet.isSubset(small, large)) // true\n * console.log(yield* TxHashSet.isSubset(large, small)) // false\n * console.log(yield* TxHashSet.isSubset(small, other)) // false\n * console.log(yield* TxHashSet.isSubset(small, small)) // true\n * })\n * ```\n *\n * @category elements\n * @since 4.0.0\n */\nexport const isSubset = /*#__PURE__*/dual(2, (self, that) => Effect.gen(function* () {\n const set1 = yield* TxRef.get(self.ref);\n const set2 = yield* TxRef.get(that.ref);\n return HashSet.isSubset(set1, set2);\n}).pipe(Effect.tx));\n/**\n * Checks whether at least one value in the TxHashSet satisfies the predicate.\n *\n * **Example** (Testing whether some values match)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5)\n *\n * console.log(yield* TxHashSet.some(numbers, (n) => n > 3)) // true\n * console.log(yield* TxHashSet.some(numbers, (n) => n > 10)) // false\n *\n * const empty = yield* TxHashSet.empty<number>()\n * console.log(yield* TxHashSet.some(empty, (n) => n > 0)) // false\n * })\n * ```\n *\n * @category elements\n * @since 4.0.0\n */\nexport const some = /*#__PURE__*/dual(2, (self, predicate) => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.some(set, predicate);\n}));\n/**\n * Checks whether all values in the TxHashSet satisfy the predicate.\n *\n * **Example** (Testing whether every value matches)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const numbers = yield* TxHashSet.make(2, 4, 6, 8)\n *\n * console.log(yield* TxHashSet.every(numbers, (n) => n % 2 === 0)) // true\n * console.log(yield* TxHashSet.every(numbers, (n) => n > 5)) // false\n *\n * const empty = yield* TxHashSet.empty<number>()\n * console.log(yield* TxHashSet.every(empty, (n) => n > 0)) // true (vacuously true)\n * })\n * ```\n *\n * @category elements\n * @since 4.0.0\n */\nexport const every = /*#__PURE__*/dual(2, (self, predicate) => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.every(set, predicate);\n}));\n/**\n * Maps each value in the TxHashSet using the provided function, returning a new TxHashSet.\n *\n * **Example** (Mapping values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const numbers = yield* TxHashSet.make(1, 2, 3)\n * const doubled = yield* TxHashSet.map(numbers, (n) => n * 2)\n *\n * const values = yield* TxHashSet.toHashSet(doubled)\n * console.log(Array.from(values).sort()) // [2, 4, 6]\n * console.log(yield* TxHashSet.size(doubled)) // 3\n *\n * // Mapping can reduce size if function produces duplicates\n * const strings = yield* TxHashSet.make(\"apple\", \"banana\", \"cherry\")\n * const lengths = yield* TxHashSet.map(strings, (s) => s.length)\n * const lengthValues = yield* TxHashSet.toHashSet(lengths)\n * console.log(Array.from(lengthValues).sort()) // [5, 6] (apple=5, banana=6, cherry=6)\n * })\n * ```\n *\n * @category mapping\n * @since 4.0.0\n */\nexport const map = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const currentSet = yield* TxRef.get(self.ref);\n const mappedSet = HashSet.map(currentSet, f);\n return yield* fromHashSet(mappedSet);\n}).pipe(Effect.tx));\n/**\n * Filters the TxHashSet keeping only values that satisfy the predicate, returning a new TxHashSet.\n *\n * **Example** (Filtering values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5, 6)\n * const evens = yield* TxHashSet.filter(numbers, (n) => n % 2 === 0)\n *\n * const values = yield* TxHashSet.toHashSet(evens)\n * console.log(Array.from(values).sort()) // [2, 4, 6]\n * console.log(yield* TxHashSet.size(evens)) // 3\n * })\n * ```\n *\n * @category filtering\n * @since 4.0.0\n */\nexport const filter = /*#__PURE__*/dual(2, (self, predicate) => Effect.gen(function* () {\n const currentSet = yield* TxRef.get(self.ref);\n const filteredSet = HashSet.filter(currentSet, predicate);\n return yield* fromHashSet(filteredSet);\n}).pipe(Effect.tx));\n/**\n * Reduces the TxHashSet to a single value by iterating through the values and applying an accumulator function.\n *\n * **Example** (Reducing values)\n *\n * ```ts\n * import { Effect, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5)\n * const sum = yield* TxHashSet.reduce(numbers, 0, (acc, n) => acc + n)\n *\n * console.log(sum) // 15\n *\n * const strings = yield* TxHashSet.make(\"a\", \"b\", \"c\")\n * const concatenated = yield* TxHashSet.reduce(strings, \"\", (acc, s) => acc + s)\n * console.log(concatenated) // Order may vary: \"abc\", \"bac\", etc.\n * })\n * ```\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduce = /*#__PURE__*/dual(3, (self, zero, f) => Effect.gen(function* () {\n const set = yield* TxRef.get(self.ref);\n return HashSet.reduce(set, zero, f);\n}));\n/**\n * Converts the TxHashSet to an immutable HashSet snapshot.\n *\n * **Example** (Taking a HashSet snapshot)\n *\n * ```ts\n * import { Effect, HashSet, TxHashSet } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const txSet = yield* TxHashSet.make(\"x\", \"y\", \"z\")\n * const hashSet = yield* TxHashSet.toHashSet(txSet)\n *\n * console.log(HashSet.size(hashSet)) // 3\n * console.log(HashSet.has(hashSet, \"y\")) // true\n *\n * // hashSet is a snapshot - modifications to txSet don't affect it\n * yield* TxHashSet.add(txSet, \"w\")\n * console.log(HashSet.size(hashSet)) // 3 (unchanged)\n * console.log(yield* TxHashSet.size(txSet)) // 4\n * })\n * ```\n *\n * @category converting\n * @since 2.0.0\n */\nexport const toHashSet = self => TxRef.get(self.ref);\n//# sourceMappingURL=TxHashSet.js.map","/**\n * Transactional priority queues whose state is stored in a `TxRef`. Elements\n * are kept in the order defined by the `Order` supplied at construction time,\n * and dequeue operations return the first element according to that ordering.\n *\n * Use `TxPriorityQueue` when multiple fibers coordinate through a shared queue\n * and queue operations need to compose with other transactional state changes.\n * The retrying `peek` and `take` operations wait transactionally when the queue\n * is empty, so they can be combined with other transactional reads and writes in\n * one atomic workflow.\n *\n * @since 4.0.0\n */\nimport * as C from \"./Chunk.js\";\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as O from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxPriorityQueue\";\nconst TxPriorityQueueProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxPriorityQueue\"\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeTxPriorityQueue = (ref, ord) => {\n const self = Object.create(TxPriorityQueueProto);\n self[TypeId] = TypeId;\n self.ref = ref;\n self.ord = ord;\n return self;\n};\nconst insertSorted = (chunk, value, ord) => {\n const arr = C.toArray(chunk);\n let lo = 0;\n let hi = arr.length;\n while (lo < hi) {\n const mid = lo + hi >>> 1;\n if (ord(arr[mid], value) <= 0) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n const out = Array(arr.length + 1);\n for (let i = 0; i < lo; i++) out[i] = arr[i];\n out[lo] = value;\n for (let i = lo; i < arr.length; i++) out[i + 1] = arr[i];\n return C.fromIterable(out);\n};\n/**\n * Creates an empty `TxPriorityQueue` with the given ordering.\n *\n * **Example** (Creating an empty priority queue)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * const empty = yield* TxPriorityQueue.isEmpty(pq)\n * console.log(empty) // true\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const empty = order => Effect.map(TxRef.make(C.empty()), ref => makeTxPriorityQueue(ref, order));\n/**\n * Creates a `TxPriorityQueue` from an iterable of elements.\n *\n * **Example** (Creating a priority queue from an iterable)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])\n * const first = yield* TxPriorityQueue.take(pq)\n * console.log(first) // 1\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const fromIterable = /*#__PURE__*/dual(2, (order, iterable) => {\n const arr = Array.from(iterable).sort((a, b) => order(a, b));\n return Effect.map(TxRef.make(C.fromIterable(arr)), ref => makeTxPriorityQueue(ref, order));\n});\n/**\n * Creates a `TxPriorityQueue` from variadic elements.\n *\n * **Example** (Creating a priority queue from variadic values)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.make(Order.Number)(3, 1, 2)\n * const first = yield* TxPriorityQueue.take(pq)\n * console.log(first) // 1\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = order => (...elements) => fromIterable(order, elements);\n/**\n * Returns the number of elements in the queue.\n *\n * **Example** (Getting the queue size)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3])\n * const s = yield* TxPriorityQueue.size(pq)\n * console.log(s) // 3\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const size = self => Effect.map(TxRef.get(self.ref), C.size);\n/**\n * Returns `true` if the queue is empty.\n *\n * **Example** (Checking whether a queue is empty)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * const empty = yield* TxPriorityQueue.isEmpty(pq)\n * console.log(empty) // true\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isEmpty = self => Effect.map(size(self), n => n === 0);\n/**\n * Returns `true` if the queue has at least one element.\n *\n * **Example** (Checking whether a queue has elements)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1])\n * const nonEmpty = yield* TxPriorityQueue.isNonEmpty(pq)\n * console.log(nonEmpty) // true\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isNonEmpty = self => Effect.map(size(self), n => n > 0);\n/**\n * Observes the smallest element without removing it.\n *\n * **When to use**\n *\n * Use to inspect the next prioritized value and retry transactionally while\n * the queue is empty.\n *\n * **Example** (Peeking at the next value)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])\n * const top = yield* TxPriorityQueue.peek(pq)\n * console.log(top) // 1\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const peek = self => Effect.gen(function* () {\n const chunk = yield* TxRef.get(self.ref);\n const head = C.head(chunk);\n if (O.isNone(head)) {\n return yield* Effect.txRetry;\n }\n return head.value;\n}).pipe(Effect.tx);\n/**\n * Observes the smallest element without removing it, returning `None` when the\n * queue is empty.\n *\n * **When to use**\n *\n * Use to inspect the next prioritized value without retrying on an empty queue.\n *\n * **Example** (Peeking without retrying)\n *\n * ```ts\n * import { Effect, Option, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * const result = yield* TxPriorityQueue.peekOption(pq)\n * console.log(Option.isNone(result)) // true\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const peekOption = self => Effect.map(TxRef.get(self.ref), C.head);\n/**\n * Inserts an element into the queue in sorted position.\n *\n * **Example** (Offering a value)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * yield* TxPriorityQueue.offer(pq, 2)\n * yield* TxPriorityQueue.offer(pq, 1)\n * const first = yield* TxPriorityQueue.take(pq)\n * console.log(first) // 1\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const offer = /*#__PURE__*/dual(2, (self, value) => TxRef.update(self.ref, chunk => insertSorted(chunk, value, self.ord)));\n/**\n * Inserts all elements from an iterable into the queue.\n *\n * **Example** (Offering multiple values)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * yield* TxPriorityQueue.offerAll(pq, [3, 1, 2])\n * const first = yield* TxPriorityQueue.take(pq)\n * console.log(first) // 1\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const offerAll = /*#__PURE__*/dual(2, (self, values) => TxRef.update(self.ref, chunk => {\n const arr = [...C.toArray(chunk), ...values].sort((a, b) => self.ord(a, b));\n return C.fromIterable(arr);\n}));\n/**\n * Takes the smallest element from the queue. Retries if the queue is empty.\n *\n * **Example** (Taking the next value)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])\n * const first = yield* TxPriorityQueue.take(pq)\n * console.log(first) // 1\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const take = self => Effect.gen(function* () {\n const chunk = yield* TxRef.get(self.ref);\n const head = C.head(chunk);\n if (O.isNone(head)) {\n return yield* Effect.txRetry;\n }\n yield* TxRef.set(self.ref, C.drop(chunk, 1));\n return head.value;\n}).pipe(Effect.tx);\n/**\n * Takes all elements from the queue, returning them in priority order.\n *\n * **Example** (Taking all values in priority order)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])\n * const all = yield* TxPriorityQueue.takeAll(pq)\n * console.log(all) // [1, 2, 3]\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const takeAll = self => Effect.map(TxRef.modify(self.ref, chunk => [chunk, C.empty()]), C.toArray);\n/**\n * Tries to take the smallest element. Returns `None` if the queue is empty.\n *\n * **Example** (Taking without retrying)\n *\n * ```ts\n * import { Effect, Option, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * const result = yield* TxPriorityQueue.takeOption(pq)\n * console.log(Option.isNone(result)) // true\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const takeOption = self => TxRef.modify(self.ref, chunk => {\n const head = C.head(chunk);\n if (O.isNone(head)) {\n return [O.none(), chunk];\n }\n return [O.some(head.value), C.drop(chunk, 1)];\n});\n/**\n * Takes up to `n` elements from the queue in priority order.\n *\n * **Example** (Taking up to a limit)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [5, 3, 1, 4, 2])\n * const top2 = yield* TxPriorityQueue.takeUpTo(pq, 2)\n * console.log(top2) // [1, 2]\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const takeUpTo = /*#__PURE__*/dual(2, (self, n) => Effect.map(TxRef.modify(self.ref, chunk => {\n const taken = C.take(chunk, n);\n const rest = C.drop(chunk, n);\n return [taken, rest];\n}), C.toArray));\n/**\n * Removes elements matching the predicate.\n *\n * **Example** (Removing matching values)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])\n * yield* TxPriorityQueue.removeIf(pq, (n) => n % 2 === 0)\n * const all = yield* TxPriorityQueue.takeAll(pq)\n * console.log(all) // [1, 3, 5]\n * })\n * ```\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const removeIf = /*#__PURE__*/dual(2, (self, predicate) => TxRef.update(self.ref, chunk => C.filter(chunk, a => !predicate(a))));\n/**\n * Keeps only elements matching the predicate.\n *\n * **Example** (Retaining matching values)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])\n * yield* TxPriorityQueue.retainIf(pq, (n) => n % 2 === 0)\n * const all = yield* TxPriorityQueue.takeAll(pq)\n * console.log(all) // [2, 4]\n * })\n * ```\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const retainIf = /*#__PURE__*/dual(2, (self, predicate) => TxRef.update(self.ref, chunk => C.filter(chunk, predicate)));\n/**\n * Returns all elements in priority order without removing them.\n *\n * **Example** (Reading values in priority order)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])\n * const all = yield* TxPriorityQueue.toArray(pq)\n * console.log(all) // [1, 2, 3]\n * })\n * ```\n *\n * @category converting\n * @since 2.0.0\n */\nexport const toArray = self => Effect.map(TxRef.get(self.ref), C.toArray);\n/**\n * Determines if the provided value is a `TxPriorityQueue`.\n *\n * **Example** (Checking for a TxPriorityQueue)\n *\n * ```ts\n * import { Effect, Order, TxPriorityQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)\n * console.log(TxPriorityQueue.isTxPriorityQueue(pq)) // true\n * console.log(TxPriorityQueue.isTxPriorityQueue(\"nope\")) // false\n * })\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxPriorityQueue = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxPriorityQueue.js.map","import * as Cause from \"./Cause.js\";\nimport * as Chunk from \"./Chunk.js\";\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as Option from \"./Option.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport { isDoneCause } from \"./Pull.js\";\nimport * as TxChunk from \"./TxChunk.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst EnqueueTypeId = \"~effect/transactions/TxQueue/Enqueue\";\nconst DequeueTypeId = \"~effect/transactions/TxQueue/Dequeue\";\nconst TypeId = \"~effect/transactions/TxQueue\";\n/**\n * Checks whether the given value is a TxEnqueue.\n *\n * **Example** (Checking enqueue handles)\n *\n * ```ts\n * import { TxQueue } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxQueue.isTxEnqueue(someValue)) {\n * // someValue is now typed as TxEnqueue<unknown, unknown>\n * console.log(\"This is a TxEnqueue\")\n * }\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxEnqueue = u => hasProperty(u, EnqueueTypeId);\n/**\n * Checks whether the given value is a TxDequeue.\n *\n * **Example** (Checking dequeue handles)\n *\n * ```ts\n * import { TxQueue } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxQueue.isTxDequeue(someValue)) {\n * // someValue is now typed as TxDequeue<unknown, unknown>\n * console.log(\"This is a TxDequeue\")\n * }\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxDequeue = u => hasProperty(u, DequeueTypeId);\n/**\n * Checks whether the given value is a TxQueue.\n *\n * **Example** (Checking queue handles)\n *\n * ```ts\n * import { TxQueue } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxQueue.isTxQueue(someValue)) {\n * // someValue is now typed as TxQueue<unknown, unknown>\n * console.log(\"This is a TxQueue\")\n * }\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxQueue = u => hasProperty(u, TypeId);\n// =============================================================================\n// Proto\n// =============================================================================\nconst TxQueueProto = {\n [EnqueueTypeId]: {\n _A: _ => _,\n _E: _ => _\n },\n [DequeueTypeId]: {\n _A: _ => _,\n _E: _ => _\n },\n [TypeId]: {\n _A: _ => _,\n _E: _ => _\n },\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toString() {\n return `TxQueue(${this.strategy}, ${this.capacity})`;\n },\n toJSON() {\n return {\n _id: \"TxQueue\",\n strategy: this.strategy,\n capacity: this.capacity\n };\n }\n};\n// =============================================================================\n// Constructors\n// =============================================================================\n/**\n * Creates a new bounded `TxQueue` with the specified capacity.\n *\n * **Details**\n *\n * This function returns a new TxQueue reference with the specified capacity. No existing TxQueue instances are modified.\n *\n * **Example** (Creating bounded queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a bounded queue (E defaults to never)\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * // Create a bounded queue with error channel\n * const faultTolerantQueue = yield* TxQueue.bounded<number, string>(10)\n *\n * // Offer items - will succeed until capacity is reached\n * yield* TxQueue.offer(queue, 1)\n * yield* TxQueue.offer(queue, 2)\n *\n * const item = yield* TxQueue.take(queue)\n * console.log(item) // 1\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const bounded = capacity => Effect.gen(function* () {\n const items = yield* TxChunk.empty();\n const stateRef = yield* TxRef.make({\n _tag: \"Open\"\n });\n const txQueue = Object.create(TxQueueProto);\n txQueue.strategy = \"bounded\";\n txQueue.capacity = capacity;\n txQueue.items = items;\n txQueue.stateRef = stateRef;\n return txQueue;\n}).pipe(Effect.tx);\n/**\n * Creates a new unbounded `TxQueue` with unlimited capacity.\n *\n * **Details**\n *\n * This function returns a new TxQueue reference with unlimited capacity. No existing TxQueue instances are modified.\n *\n * **Example** (Creating unbounded queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create an unbounded queue (E defaults to never)\n * const queue = yield* TxQueue.unbounded<string>()\n *\n * // Create an unbounded queue with error channel\n * const faultTolerantQueue = yield* TxQueue.unbounded<string, Error>()\n *\n * // Can offer unlimited items\n * yield* TxQueue.offer(queue, \"hello\")\n * yield* TxQueue.offer(queue, \"world\")\n *\n * const size = yield* TxQueue.size(queue)\n * console.log(size) // 2\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const unbounded = () => Effect.gen(function* () {\n const items = yield* TxChunk.empty();\n const stateRef = yield* TxRef.make({\n _tag: \"Open\"\n });\n const txQueue = Object.create(TxQueueProto);\n txQueue.strategy = \"unbounded\";\n txQueue.capacity = Number.POSITIVE_INFINITY;\n txQueue.items = items;\n txQueue.stateRef = stateRef;\n return txQueue;\n}).pipe(Effect.tx);\n/**\n * Creates a new dropping `TxQueue` with the specified capacity that drops new items when full.\n *\n * **Details**\n *\n * This function returns a new TxQueue reference with dropping strategy. No existing TxQueue instances are modified.\n *\n * **Example** (Creating dropping queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a dropping queue with capacity 2\n * const queue = yield* TxQueue.dropping<number>(2)\n *\n * // Fill to capacity\n * yield* TxQueue.offer(queue, 1)\n * yield* TxQueue.offer(queue, 2)\n *\n * // This will be dropped (returns false)\n * const accepted = yield* TxQueue.offer(queue, 3)\n * console.log(accepted) // false\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const dropping = capacity => Effect.gen(function* () {\n const items = yield* TxChunk.empty();\n const stateRef = yield* TxRef.make({\n _tag: \"Open\"\n });\n const txQueue = Object.create(TxQueueProto);\n txQueue.strategy = \"dropping\";\n txQueue.capacity = capacity;\n txQueue.items = items;\n txQueue.stateRef = stateRef;\n return txQueue;\n}).pipe(Effect.tx);\n/**\n * Creates a new sliding `TxQueue` with the specified capacity that evicts old items when full.\n *\n * **Details**\n *\n * This function returns a new TxQueue reference with sliding strategy. No existing TxQueue instances are modified.\n *\n * **Example** (Creating sliding queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * // Create a sliding queue with capacity 2\n * const queue = yield* TxQueue.sliding<number>(2)\n *\n * // Fill to capacity\n * yield* TxQueue.offer(queue, 1)\n * yield* TxQueue.offer(queue, 2)\n *\n * // This will evict item 1 and add 3\n * yield* TxQueue.offer(queue, 3)\n *\n * const item = yield* TxQueue.take(queue)\n * console.log(item) // 2 (item 1 was evicted)\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const sliding = capacity => Effect.gen(function* () {\n const items = yield* TxChunk.empty();\n const stateRef = yield* TxRef.make({\n _tag: \"Open\"\n });\n const txQueue = Object.create(TxQueueProto);\n txQueue.strategy = \"sliding\";\n txQueue.capacity = capacity;\n txQueue.items = items;\n txQueue.stateRef = stateRef;\n return txQueue;\n}).pipe(Effect.tx);\n// =============================================================================\n// Core Queue Operations\n// =============================================================================\n/**\n * Offers an item to the queue and returns whether it was accepted.\n *\n * **Details**\n *\n * Open unbounded queues always accept; open bounded queues retry while full; dropping queues return `false` when full; sliding queues evict the oldest item when full. Closing or done queues return `false`. This function mutates the original TxQueue by adding the item according to the queue's strategy. It does not return a new TxQueue reference.\n *\n * **Example** (Offering a value)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * // Offer an item - returns true if accepted\n * const accepted = yield* TxQueue.offer(queue, 42)\n * console.log(accepted) // true\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const offer = /*#__PURE__*/dual(2, (self, value) => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag === \"Done\" || state._tag === \"Closing\") {\n return false;\n }\n const currentSize = yield* size(self);\n // Unbounded - always accept\n if (self.strategy === \"unbounded\") {\n yield* TxChunk.append(self.items, value);\n return true;\n }\n // For bounded queues, check capacity\n if (currentSize < self.capacity) {\n yield* TxChunk.append(self.items, value);\n return true;\n }\n // Queue is at capacity, strategy-specific behavior\n if (self.strategy === \"dropping\") {\n return false; // Drop the new item\n }\n if (self.strategy === \"sliding\") {\n yield* TxChunk.drop(self.items, 1); // Remove oldest item\n yield* TxChunk.append(self.items, value); // Add new item\n return true;\n }\n // bounded strategy - block until space is available\n return yield* Effect.txRetry;\n}).pipe(Effect.tx));\n/**\n * Offers multiple items to the queue, returning the items that were not\n * accepted.\n *\n * **Details**\n *\n * Each item follows `offer` semantics: bounded queues retry while full, dropping queues reject new items when full, sliding queues evict old items to accept new items, and closing or done queues reject all items. This function mutates the original TxQueue by adding items according to the queue's strategy. It does not return a new TxQueue reference.\n *\n * **Example** (Offering multiple values)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * // Offer multiple items - returns rejected items as array\n * const rejected = yield* TxQueue.offerAll(queue, [1, 2, 3, 4, 5])\n * console.log(rejected) // [] if all accepted\n * console.log(rejected.length) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const offerAll = /*#__PURE__*/dual(2, (self, values) => Effect.gen(function* () {\n const rejected = [];\n for (const value of values) {\n const accepted = yield* offer(self, value);\n if (!accepted) {\n rejected.push(value);\n }\n }\n return rejected;\n}).pipe(Effect.tx));\n/**\n * Takes the next item from the queue, retrying the transaction while the queue\n * is empty.\n *\n * **Details**\n *\n * If the queue is done, the effect fails with the queue's completion cause. This function mutates the original TxQueue by removing the first item. It does not return a new TxQueue reference.\n *\n * **Example** (Taking a value)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(10)\n * yield* TxQueue.offer(queue, 42)\n *\n * // Take an item - blocks if empty\n * const item = yield* TxQueue.take(queue)\n * console.log(item) // 42\n *\n * // When queue fails, take fails with the same error\n * yield* TxQueue.fail(queue, \"queue error\")\n * const result = yield* Effect.flip(TxQueue.take(queue))\n * console.log(result) // \"queue error\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const take = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n // Check if queue is done - forward the cause directly\n if (state._tag === \"Done\") {\n return yield* Effect.failCause(state.cause);\n }\n // If no items available, retry transaction\n if (yield* isEmpty(self)) {\n return yield* Effect.txRetry;\n }\n // Take item from queue\n const chunk = yield* TxChunk.get(self.items);\n const head = Chunk.head(chunk);\n if (Option.isNone(head)) {\n return yield* Effect.txRetry;\n }\n yield* TxChunk.drop(self.items, 1);\n // Check if we need to transition Closing → Done\n if (state._tag === \"Closing\" && (yield* isEmpty(self))) {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n }\n return head.value;\n}).pipe(Effect.tx);\n/**\n * Tries to take an item from the queue without blocking.\n *\n * **Example** (Polling without blocking)\n *\n * ```ts\n * import { Effect, Option, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * // Poll returns Option.none if empty\n * const maybe = yield* TxQueue.poll(queue)\n * console.log(Option.isNone(maybe)) // true\n *\n * yield* TxQueue.offer(queue, 42)\n * const item = yield* TxQueue.poll(queue)\n * console.log(Option.getOrNull(item)) // 42\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const poll = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag === \"Done\") {\n return Option.none();\n }\n const chunk = yield* TxChunk.get(self.items);\n const head = Chunk.head(chunk);\n if (Option.isNone(head)) {\n return Option.none();\n }\n yield* TxChunk.drop(self.items, 1);\n return Option.some(head.value);\n}).pipe(Effect.tx);\n/**\n * Takes all items from the queue. Blocks if the queue is empty.\n *\n * **Details**\n *\n * If the queue is already in a failed state, the error is propagated through the E-channel. This follows the same patterns as `take` and waits when there are no elements. It returns a non-empty array because it blocks until at least one item is available. This function mutates the original TxQueue by removing all items. It does not return a new TxQueue reference.\n *\n * **Example** (Taking all queued values)\n *\n * ```ts\n * import { Array, Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(10)\n * yield* TxQueue.offerAll(queue, [1, 2, 3, 4, 5])\n *\n * // Take all items atomically - returns NonEmptyArray\n * const items = yield* TxQueue.takeAll(queue)\n * console.log(items) // [1, 2, 3, 4, 5]\n * console.log(Array.isArrayNonEmpty(items)) // true\n * })\n *\n * // Error propagation example\n * const errorExample = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(5)\n * yield* TxQueue.offerAll(queue, [1, 2])\n * yield* TxQueue.fail(queue, \"processing error\")\n *\n * // takeAll() propagates the queue error through E-channel\n * const result = yield* Effect.flip(TxQueue.takeAll(queue))\n * console.log(result) // \"processing error\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const takeAll = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n // Handle done queue\n if (state._tag === \"Done\") {\n return yield* Effect.failCause(state.cause);\n }\n // Wait if empty - same pattern as take()\n if (yield* isEmpty(self)) {\n return yield* Effect.txRetry;\n }\n const chunk = yield* TxChunk.get(self.items);\n // Take all items (guaranteed non-empty due to isEmpty check above)\n const items = Chunk.toArray(chunk);\n yield* TxChunk.set(self.items, Chunk.empty());\n // Check if we need to transition Closing → Done\n if (state._tag === \"Closing\") {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n }\n return items;\n}).pipe(Effect.tx);\n/**\n * Takes up to `n` items from the queue in a single transaction.\n *\n * **Details**\n *\n * For an open queue, waits until `min(n, capacity)` items are available, then removes that many items. If `n` is less than or equal to zero, returns an empty array without modifying the queue. If the queue is closing, drains the currently available items and transitions to `Done`. If the queue is already done, the effect fails with the queue's completion cause. This function mutates the original TxQueue by removing the taken items. It does not return a new TxQueue reference.\n *\n * **Example** (Taking a fixed number of values)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(5)\n * yield* TxQueue.offerAll(queue, [1, 2, 3, 4])\n *\n * const items = yield* TxQueue.takeN(queue, 4)\n * console.log(items) // [1, 2, 3, 4]\n *\n * // This requests more than capacity (5), so takes all available (up to 5)\n * yield* TxQueue.offerAll(queue, [5, 6, 7, 8, 9])\n * const all = yield* TxQueue.takeN(queue, 10)\n * console.log(all) // [5, 6, 7, 8, 9]\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const takeN = /*#__PURE__*/dual(2, (self, n) => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n // Check if queue is done - forward the cause directly\n if (state._tag === \"Done\") {\n return yield* Effect.failCause(state.cause);\n }\n const currentSize = yield* size(self);\n // Determine how many items we can/should take\n const requestedCount = n;\n const maxPossible = Math.min(requestedCount, self.capacity);\n // If we can't get the requested amount due to capacity constraints,\n // take what the capacity allows. Otherwise, wait for the full amount.\n const shouldWaitForFull = requestedCount <= self.capacity;\n const minimumRequired = shouldWaitForFull ? requestedCount : maxPossible;\n // If we don't have enough items available\n if (currentSize < minimumRequired) {\n // If queue is closing, transition to done and return what we have\n if (state._tag === \"Closing\") {\n if (yield* isEmpty(self)) {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n return [];\n }\n // Take all remaining items when closing\n const chunk = yield* TxChunk.get(self.items);\n const taken = Chunk.toArray(chunk);\n yield* TxChunk.set(self.items, Chunk.empty());\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n return taken;\n }\n // Queue is still open but not enough items - retry transaction\n return yield* Effect.txRetry;\n }\n // Take the determined number of items\n const toTake = minimumRequired;\n const chunk = yield* TxChunk.get(self.items);\n const taken = Chunk.take(chunk, toTake);\n yield* TxChunk.drop(self.items, toTake);\n // Check if we need to transition Closing → Done\n if (state._tag === \"Closing\" && (yield* isEmpty(self))) {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n }\n return Chunk.toArray(taken);\n}).pipe(Effect.tx));\n/**\n * Takes between `min` and `max` currently available items, waiting for `min` on\n * an open queue.\n *\n * **Details**\n *\n * If the queue is closing, drains the currently available items even when fewer than `min` are available and transitions to `Done`. Invalid ranges (`min <= 0`, `max <= 0`, or `min > max`) return an empty array. If the queue is already done, the effect fails with the queue's completion cause.\n *\n * **Example** (Taking batches within bounds)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offerAll(queue, [1, 2, 3, 4, 5, 6, 7, 8])\n *\n * // Take between 2 and 5 items\n * const batch1 = yield* TxQueue.takeBetween(queue, 2, 5)\n * console.log(batch1) // [1, 2, 3, 4, 5] - took 5 (up to max)\n *\n * // Take between 1 and 10 items (but only 3 remain)\n * const batch2 = yield* TxQueue.takeBetween(queue, 1, 10)\n * console.log(batch2) // [6, 7, 8] - took 3 (all remaining)\n *\n * // Would wait for at least 1 item to be available\n * // const batch3 = yield* TxQueue.takeBetween(queue, 1, 3)\n * })\n * ```\n *\n * @category taking\n * @since 2.0.0\n */\nexport const takeBetween = /*#__PURE__*/dual(3, (self, min, max) => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n // Check if queue is done - forward the cause directly\n if (state._tag === \"Done\") {\n return yield* Effect.failCause(state.cause);\n }\n // Validate parameters\n if (min <= 0 || max <= 0 || min > max) {\n return [];\n }\n const currentSize = yield* size(self);\n // If we have less than minimum required items\n if (currentSize < min) {\n // If queue is closing, transition to done and return what we have\n if (state._tag === \"Closing\") {\n if (yield* isEmpty(self)) {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n return [];\n }\n // Take all remaining items when closing (if >= min or all available)\n const chunk = yield* TxChunk.get(self.items);\n const taken = Chunk.toArray(chunk);\n yield* TxChunk.set(self.items, Chunk.empty());\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n return taken;\n }\n // Queue is still open but not enough items - retry transaction\n return yield* Effect.txRetry;\n }\n // We have at least the minimum, take up to the maximum\n const toTake = Math.min(currentSize, max);\n const chunk = yield* TxChunk.get(self.items);\n const taken = Chunk.take(chunk, toTake);\n yield* TxChunk.drop(self.items, toTake);\n // Check if we need to transition Closing → Done\n if (state._tag === \"Closing\" && (yield* isEmpty(self))) {\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: state.cause\n });\n }\n return Chunk.toArray(taken);\n}).pipe(Effect.tx));\n/**\n * Waits transactionally for the next item and returns it without removing it.\n *\n * **Details**\n *\n * If the queue is open but empty, the transaction retries until an item is available or the queue completes. If the queue is done, the queue's completion cause is propagated through the error channel.\n *\n * **Example** (Peeking without removing values)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(10)\n * yield* TxQueue.offer(queue, 42)\n *\n * // Peek at the next item without removing it\n * const item = yield* TxQueue.peek(queue)\n * console.log(item) // 42\n *\n * // Item is still in the queue\n * const size = yield* TxQueue.size(queue)\n * console.log(size) // 1\n * })\n *\n * // Error handling example\n * const errorExample = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(5)\n * yield* TxQueue.fail(queue, \"queue failed\")\n *\n * // peek() propagates the queue error through E-channel\n * const result = yield* Effect.flip(TxQueue.peek(queue))\n * console.log(result) // \"queue failed\"\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const peek = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag === \"Done\") {\n return yield* Effect.failCause(state.cause);\n }\n const chunk = yield* TxChunk.get(self.items);\n const head = Chunk.head(chunk);\n if (Option.isNone(head)) {\n return yield* Effect.txRetry;\n }\n return head.value;\n}).pipe(Effect.tx);\n/**\n * Gets the current size of the queue.\n *\n * **Example** (Reading queue size)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offerAll(queue, [1, 2, 3])\n *\n * const size = yield* TxQueue.size(queue)\n * console.log(size) // 3\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const size = self => TxChunk.size(self.items);\n/**\n * Checks whether the queue is empty.\n *\n * **Example** (Checking whether a queue is empty)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * const empty = yield* TxQueue.isEmpty(queue)\n * console.log(empty) // true\n *\n * yield* TxQueue.offer(queue, 42)\n * const stillEmpty = yield* TxQueue.isEmpty(queue)\n * console.log(stillEmpty) // false\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const isEmpty = self => TxChunk.isEmpty(self.items);\n/**\n * Checks whether the queue is at capacity.\n *\n * **Example** (Checking whether a queue is full)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(2)\n *\n * const full = yield* TxQueue.isFull(queue)\n * console.log(full) // false\n *\n * yield* TxQueue.offerAll(queue, [1, 2])\n * const nowFull = yield* TxQueue.isFull(queue)\n * console.log(nowFull) // true\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const isFull = self => self.capacity === Number.POSITIVE_INFINITY ? Effect.succeed(false) : Effect.map(size(self), currentSize => currentSize >= self.capacity);\n/**\n * Interrupts the queue gracefully with the current fiber's interruption cause.\n *\n * **Details**\n *\n * If the queue still contains items, it enters the closing state so buffered items can be drained before consumers observe the interruption. If it is empty, it transitions directly to done. Returns `false` if the queue was already closing or done.\n *\n * **Example** (Interrupting queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offer(queue, 42)\n *\n * // Interrupt gracefully - allows remaining items to be consumed\n * const result = yield* TxQueue.interrupt(queue)\n * console.log(result) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const interrupt = self => Effect.withFiber(fiber => failCause(self, Cause.interrupt(fiber.id)));\n/**\n * Fails the queue with the specified error, discarding any buffered items.\n *\n * **Details**\n *\n * The queue transitions directly to done with `Cause.fail(error)`. Returns `false` if the queue was already closing or done.\n *\n * **Example** (Failing queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(10)\n *\n * // Fail the queue with an error\n * const result = yield* TxQueue.fail(queue, \"connection lost\")\n * console.log(result) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const fail = /*#__PURE__*/dual(2, (self, error) => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag !== \"Open\") {\n return false; // Already closing/done\n }\n // Fail transitions directly to Done, clearing items\n yield* TxChunk.set(self.items, Chunk.empty());\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause: Cause.fail(error)\n });\n return true;\n}).pipe(Effect.tx));\n/**\n * Completes the queue with the specified cause.\n *\n * **Details**\n *\n * If the queue is empty, it transitions directly to done. If it still contains items, it enters the closing state so buffered items can be drained before the cause is observed. Returns `false` if the queue was already closing or done.\n *\n * **Example** (Failing queues with causes)\n *\n * ```ts\n * import { Cause, Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * // Complete with specific cause\n * const cause = Cause.interrupt()\n * const result = yield* TxQueue.failCause(queue, cause)\n * console.log(result) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const failCause = /*#__PURE__*/dual(2, (self, cause) => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag !== \"Open\") {\n return false; // Already closing/done\n }\n if (yield* isEmpty(self)) {\n // Can transition directly to Done\n yield* TxRef.set(self.stateRef, {\n _tag: \"Done\",\n cause\n });\n } else {\n // Need to go through Closing state\n yield* TxRef.set(self.stateRef, {\n _tag: \"Closing\",\n cause\n });\n }\n return true;\n}).pipe(Effect.tx));\n/**\n * Ends a queue by signaling completion with a `Cause.Done` error.\n *\n * **Details**\n *\n * This is a convenience wrapper around `failCause` for queues whose error channel can contain `Cause.Done`. If buffered items remain, the queue enters the closing state and those items may still be consumed before later `take` or `peek` operations fail with `Cause.Done`.\n *\n * **Example** (Ending queues)\n *\n * ```ts\n * import { Cause, Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, Cause.Done>(10)\n *\n * // Signal the end of the queue\n * const result = yield* TxQueue.end(queue)\n * console.log(result) // true\n *\n * // All operations will now fail with Done\n * const takeResult = yield* Effect.flip(TxQueue.take(queue))\n * console.log(Cause.isDone(takeResult)) // true\n *\n * const peekResult = yield* Effect.flip(TxQueue.peek(queue))\n * console.log(Cause.isDone(peekResult)) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const end = self => failCause(self, Cause.fail(Cause.Done()));\n/**\n * Removes and returns all currently buffered elements without changing the\n * queue state.\n *\n * **Details**\n *\n * If the queue is already done with a `Cause.Done` error, returns an empty array. If the queue is done for any other cause, including interruption or failure, that cause is propagated.\n *\n * **Example** (Clearing queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offerAll(queue, [1, 2, 3, 4, 5])\n *\n * const sizeBefore = yield* TxQueue.size(queue)\n * console.log(sizeBefore) // 5\n *\n * const cleared = yield* TxQueue.clear(queue)\n * console.log(cleared) // [1, 2, 3, 4, 5]\n *\n * const sizeAfter = yield* TxQueue.size(queue)\n * console.log(sizeAfter) // 0\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const clear = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag === \"Done\") {\n // Return empty array only for halt causes (like Cause.Done)\n if (isDoneCause(state.cause)) {\n return [];\n }\n return yield* Effect.failCause(state.cause);\n }\n const chunk = yield* TxChunk.get(self.items);\n yield* TxChunk.set(self.items, Chunk.empty());\n return Chunk.toArray(chunk);\n}).pipe(Effect.tx);\n/**\n * Shuts down the queue immediately by clearing all items and interrupting it (legacy compatibility).\n *\n * **Details**\n *\n * This operation clears all items from the queue using `clear`, then interrupts the queue using `interrupt`. This function mutates the original TxQueue by clearing its contents and marking it as shutdown. It does not return a new TxQueue reference.\n *\n * **Example** (Shutting down queues)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offerAll(queue, [1, 2, 3, 4, 5])\n *\n * const sizeBefore = yield* TxQueue.size(queue)\n * console.log(sizeBefore) // 5\n *\n * yield* TxQueue.shutdown(queue)\n *\n * const sizeAfter = yield* TxQueue.size(queue)\n * console.log(sizeAfter) // 0 (cleared)\n *\n * const isShutdown = yield* TxQueue.isShutdown(queue)\n * console.log(isShutdown) // true (interrupted)\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const shutdown = self => Effect.gen(function* () {\n yield* Effect.ignore(clear(self));\n return yield* interrupt(self);\n}).pipe(Effect.tx);\n/**\n * Checks whether the queue is in the open state.\n *\n * **Example** (Checking open state)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * const open = yield* TxQueue.isOpen(queue)\n * console.log(open) // true\n *\n * yield* TxQueue.interrupt(queue)\n * const stillOpen = yield* TxQueue.isOpen(queue)\n * console.log(stillOpen) // false\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isOpen = self => Effect.map(TxRef.get(self.stateRef), state => state._tag === \"Open\");\n/**\n * Checks whether the queue is in the closing state.\n *\n * **Example** (Checking closing state)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n * yield* TxQueue.offer(queue, 42)\n *\n * const closing = yield* TxQueue.isClosing(queue)\n * console.log(closing) // false\n *\n * yield* TxQueue.interrupt(queue)\n * const nowClosing = yield* TxQueue.isClosing(queue)\n * console.log(nowClosing) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isClosing = self => Effect.map(TxRef.get(self.stateRef), state => state._tag === \"Closing\");\n/**\n * Checks whether the queue is done (completed or failed).\n *\n * **Example** (Checking done state)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * const done = yield* TxQueue.isDone(queue)\n * console.log(done) // false\n *\n * yield* TxQueue.interrupt(queue)\n * const nowDone = yield* TxQueue.isDone(queue)\n * console.log(nowDone) // true\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const isDone = self => Effect.map(TxRef.get(self.stateRef), state => state._tag === \"Done\");\n/**\n * Checks whether the queue is shutdown (legacy compatibility).\n *\n * **Example** (Checking shutdown state)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number>(10)\n *\n * const isShutdown = yield* TxQueue.isShutdown(queue)\n * console.log(isShutdown) // false\n *\n * yield* TxQueue.shutdown(queue)\n * const nowShutdown = yield* TxQueue.isShutdown(queue)\n * console.log(nowShutdown) // true\n * })\n * ```\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const isShutdown = self => isDone(self);\n/**\n * Waits for the queue to complete (either successfully or with failure).\n *\n * **Example** (Awaiting queue completion)\n *\n * ```ts\n * import { Effect, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const queue = yield* TxQueue.bounded<number, string>(10)\n *\n * // In another fiber, end the queue\n * yield* Effect.forkChild(Effect.delay(TxQueue.interrupt(queue), \"100 millis\"))\n *\n * // Wait for completion - succeeds when queue ends\n * yield* TxQueue.awaitCompletion(queue)\n * console.log(\"Queue completed successfully\")\n * })\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const awaitCompletion = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n if (state._tag === \"Done\") {\n return void 0;\n }\n // Not done yet, retry transaction\n return yield* Effect.txRetry;\n}).pipe(Effect.tx);\n//# sourceMappingURL=TxQueue.js.map","/**\n * Broadcasts values to subscribers inside Effect transactions.\n *\n * A `TxPubSub<A>` is a transactional publish/subscribe hub. Each subscriber\n * owns a `TxQueue`, and each published value is offered to the subscriber\n * queues that are registered at the time of publication. This module includes\n * bounded, dropping, sliding, and unbounded hubs, publishing helpers, scoped\n * subscriptions, shutdown operations, and a guard.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxQueue from \"./TxQueue.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxPubSub\";\nconst TxPubSubProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxPubSub\",\n strategy: this.strategy,\n capacity: this.capacity\n };\n },\n toString() {\n return `TxPubSub(${this.strategy}, ${this.capacity})`;\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeTxPubSub = (subscribersRef, shutdownRef, strategy, cap) => {\n const self = Object.create(TxPubSubProto);\n self[TypeId] = TypeId;\n self.subscribersRef = subscribersRef;\n self.shutdownRef = shutdownRef;\n self.strategy = strategy;\n self.capacity = cap;\n return self;\n};\n// =============================================================================\n// Constructors\n// =============================================================================\n/**\n * Creates a bounded TxPubSub with the specified capacity. When a subscriber's\n * queue is full, the publisher will retry the transaction until space is available.\n *\n * **Example** (Creating a bounded pub/sub)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.bounded<number>(16)\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, 42)\n * const value = yield* TxQueue.take(sub)\n * console.log(value) // 42\n * })\n * )\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const bounded = capacity => Effect.gen(function* () {\n const subscribersRef = yield* TxRef.make([]);\n const shutdownRef = yield* TxRef.make(false);\n return makeTxPubSub(subscribersRef, shutdownRef, \"bounded\", capacity);\n}).pipe(Effect.tx);\n/**\n * Creates a dropping TxPubSub with the specified capacity. When a subscriber's\n * queue is full, the message is dropped for that subscriber.\n *\n * **Example** (Creating a dropping pub/sub)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.dropping<number>(2)\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, 1)\n * yield* TxPubSub.publish(hub, 2)\n * yield* TxPubSub.publish(hub, 3) // dropped\n * const v1 = yield* TxQueue.take(sub)\n * const v2 = yield* TxQueue.take(sub)\n * console.log(v1, v2) // 1 2\n * })\n * )\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const dropping = capacity => Effect.gen(function* () {\n const subscribersRef = yield* TxRef.make([]);\n const shutdownRef = yield* TxRef.make(false);\n return makeTxPubSub(subscribersRef, shutdownRef, \"dropping\", capacity);\n}).pipe(Effect.tx);\n/**\n * Creates a sliding TxPubSub with the specified capacity. When a subscriber's\n * queue is full, the oldest message in that subscriber's queue is dropped.\n *\n * **Example** (Creating a sliding pub/sub)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.sliding<number>(2)\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, 1)\n * yield* TxPubSub.publish(hub, 2)\n * yield* TxPubSub.publish(hub, 3) // evicts 1\n * const v1 = yield* TxQueue.take(sub)\n * console.log(v1) // 2\n * })\n * )\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const sliding = capacity => Effect.gen(function* () {\n const subscribersRef = yield* TxRef.make([]);\n const shutdownRef = yield* TxRef.make(false);\n return makeTxPubSub(subscribersRef, shutdownRef, \"sliding\", capacity);\n}).pipe(Effect.tx);\n/**\n * Creates an unbounded TxPubSub with unlimited capacity. Messages are always accepted.\n *\n * **Example** (Creating an unbounded pub/sub)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<string>()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, \"msg\")\n * const msg = yield* TxQueue.take(sub)\n * console.log(msg) // \"msg\"\n * })\n * )\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const unbounded = () => Effect.gen(function* () {\n const subscribersRef = yield* TxRef.make([]);\n const shutdownRef = yield* TxRef.make(false);\n return makeTxPubSub(subscribersRef, shutdownRef, \"unbounded\", Number.POSITIVE_INFINITY);\n}).pipe(Effect.tx);\n// =============================================================================\n// Getters\n// =============================================================================\n/**\n * Returns the capacity of the TxPubSub.\n *\n * **Example** (Reading pub/sub capacity)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.bounded<number>(16)\n * console.log(TxPubSub.capacity(hub)) // 16\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const capacity = self => self.capacity;\n/**\n * Returns the current number of messages across all subscriber queues (the max).\n *\n * **Example** (Reading subscriber queue size)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, 1)\n * yield* TxPubSub.publish(hub, 2)\n * const s = yield* TxPubSub.size(hub)\n * console.log(s) // 2\n * })\n * )\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const size = self => Effect.gen(function* () {\n const subscribers = yield* TxRef.get(self.subscribersRef);\n let maxSize = 0;\n for (const queue of subscribers) {\n const s = yield* TxQueue.size(queue);\n if (s > maxSize) maxSize = s;\n }\n return maxSize;\n}).pipe(Effect.tx);\n/**\n * Checks whether the TxPubSub has no pending messages (all subscriber queues are empty).\n *\n * **Example** (Checking whether a pub/sub is empty)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n * const empty = yield* TxPubSub.isEmpty(hub)\n * console.log(empty) // true\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isEmpty = self => Effect.map(size(self), s => s === 0);\n/**\n * Checks whether any subscriber queue is at capacity.\n *\n * **Example** (Checking whether a pub/sub is full)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.bounded<number>(2)\n * const full = yield* TxPubSub.isFull(hub)\n * console.log(full) // false\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isFull = self => Effect.gen(function* () {\n if (self.capacity === Number.POSITIVE_INFINITY) return false;\n const subscribers = yield* TxRef.get(self.subscribersRef);\n for (const queue of subscribers) {\n if (yield* TxQueue.isFull(queue)) return true;\n }\n return false;\n}).pipe(Effect.tx);\n/**\n * Checks whether the TxPubSub has been shut down.\n *\n * **Example** (Checking whether a pub/sub is shut down)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n * console.log(yield* TxPubSub.isShutdown(hub)) // false\n * yield* TxPubSub.shutdown(hub)\n * console.log(yield* TxPubSub.isShutdown(hub)) // true\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const isShutdown = self => TxRef.get(self.shutdownRef);\n// =============================================================================\n// Mutations\n// =============================================================================\n/**\n * Publishes a message to all current subscribers.\n *\n * **Details**\n *\n * Returns `true` if the message was delivered to all subscribers, or `false` if the hub is shut down or the message was dropped for any subscriber. For the bounded strategy, the transaction retries if any subscriber queue is full. For the sliding strategy, full subscriber queues drop their oldest messages. For the dropping strategy, full subscriber queues drop the new message and the operation returns `false`.\n *\n * **Example** (Publishing a message to subscribers)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<string>()\n *\n * // No subscribers - publish is a no-op\n * const r1 = yield* TxPubSub.publish(hub, \"no one listening\")\n * console.log(r1) // true\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publish(hub, \"hello\")\n * const msg = yield* TxQueue.take(sub)\n * console.log(msg) // \"hello\"\n * })\n * )\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const publish = /*#__PURE__*/dual(2, (self, value) => Effect.gen(function* () {\n if (yield* TxRef.get(self.shutdownRef)) return false;\n const subscribers = yield* TxRef.get(self.subscribersRef);\n let allAccepted = true;\n for (const queue of subscribers) {\n const accepted = yield* TxQueue.offer(queue, value);\n if (!accepted) allAccepted = false;\n }\n return allAccepted;\n}).pipe(Effect.tx));\n/**\n * Publishes all messages from an iterable to all current subscribers.\n *\n * **Details**\n *\n * Returns `true` if all messages were delivered to all subscribers.\n *\n * **Example** (Publishing multiple messages to subscribers)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxPubSub.subscribe(hub)\n * yield* TxPubSub.publishAll(hub, [1, 2, 3])\n * const v1 = yield* TxQueue.take(sub)\n * const v2 = yield* TxQueue.take(sub)\n * const v3 = yield* TxQueue.take(sub)\n * console.log(v1, v2, v3) // 1 2 3\n * })\n * )\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const publishAll = /*#__PURE__*/dual(2, (self, values) => Effect.gen(function* () {\n if (yield* TxRef.get(self.shutdownRef)) return false;\n let allAccepted = true;\n for (const value of values) {\n const accepted = yield* publish(self, value);\n if (!accepted) allAccepted = false;\n }\n return allAccepted;\n}).pipe(Effect.tx));\n/**\n * Subscribes to the TxPubSub, returning a scoped `TxQueue` for messages published after subscription.\n *\n * **Details**\n *\n * The returned queue uses the hub's capacity strategy: bounded subscriptions backpressure publishers when full, dropping subscriptions may miss new messages when full, and sliding subscriptions may evict older queued messages. The subscription is automatically removed when the scope is closed.\n *\n * **Example** (Subscribing multiple queues)\n *\n * ```ts\n * import { Effect, TxPubSub, TxQueue } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<string>()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub1 = yield* TxPubSub.subscribe(hub)\n * const sub2 = yield* TxPubSub.subscribe(hub)\n *\n * yield* TxPubSub.publish(hub, \"broadcast\")\n *\n * const msg1 = yield* TxQueue.take(sub1)\n * const msg2 = yield* TxQueue.take(sub2)\n * console.log(msg1, msg2) // \"broadcast\" \"broadcast\"\n * })\n * )\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const subscribe = self => Effect.acquireRelease(Effect.tx(acquireSubscriber(self)), queue => Effect.tx(releaseSubscriber(self, queue)));\n/**\n * Creates a subscriber queue and registers it with the pub/sub.\n *\n * **When to use**\n *\n * Use to create and register a subscriber queue inside a larger transaction\n * when registration must be atomic with other Tx operations.\n *\n * **Details**\n *\n * This is the transactional acquire step of `subscribe`, exposed so that callers can compose it with other Tx operations in a single transaction, such as `TxSubscriptionRef.changes`.\n *\n * @see {@link subscribe} for the scoped acquire and release wrapper when no custom transaction composition is needed\n * @see {@link releaseSubscriber} to remove and shut down a queue returned by `acquireSubscriber`\n *\n * @category mutations\n * @since 4.0.0\n */\nexport const acquireSubscriber = self => Effect.gen(function* () {\n const queue = yield* makeSubscriberQueue(self.strategy, self.capacity);\n yield* TxRef.update(self.subscribersRef, subs => [...subs, queue]);\n return queue;\n});\n/**\n * Removes a subscriber queue from the pub/sub and shuts it down.\n *\n * **When to use**\n *\n * Use to release a manually acquired subscriber queue inside a larger\n * transaction, removing it from the pub/sub and shutting it down together with\n * related transactional cleanup.\n *\n * **Details**\n *\n * This is the transactional release step of `subscribe`, exposed so that callers can compose it with other Tx operations in a single transaction.\n *\n * **Gotchas**\n *\n * The supplied queue is shut down after being removed, so callers should pass a\n * queue acquired for this pub/sub.\n *\n * @see {@link acquireSubscriber} for the matching transactional acquire step\n * @see {@link subscribe} for the scoped acquire and release wrapper\n *\n * @category mutations\n * @since 4.0.0\n */\nexport const releaseSubscriber = /*#__PURE__*/dual(2, (self, queue) => Effect.gen(function* () {\n yield* TxRef.update(self.subscribersRef, subs => subs.filter(q => q !== queue));\n yield* TxQueue.shutdown(queue);\n}));\nconst makeSubscriberQueue = (strategy, cap) => {\n switch (strategy) {\n case \"bounded\":\n return TxQueue.bounded(cap);\n case \"dropping\":\n return TxQueue.dropping(cap);\n case \"sliding\":\n return TxQueue.sliding(cap);\n case \"unbounded\":\n return TxQueue.unbounded();\n }\n};\n/**\n * Shuts down the TxPubSub and all subscriber queues registered at the time of shutdown.\n *\n * **Details**\n *\n * After shutdown, `publish` and `publishAll` return `false`, and `awaitShutdown` completes. The operation is idempotent.\n *\n * **Gotchas**\n *\n * Subscribers acquired after shutdown are not automatically shut down by this call.\n *\n * **Example** (Shutting down a pub/sub)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n * yield* TxPubSub.shutdown(hub)\n *\n * const shut = yield* TxPubSub.isShutdown(hub)\n * console.log(shut) // true\n *\n * const accepted = yield* TxPubSub.publish(hub, 1)\n * console.log(accepted) // false\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const shutdown = self => Effect.gen(function* () {\n const alreadyShutdown = yield* TxRef.get(self.shutdownRef);\n if (alreadyShutdown) return;\n yield* TxRef.set(self.shutdownRef, true);\n const subscribers = yield* TxRef.get(self.subscribersRef);\n for (const queue of subscribers) {\n yield* TxQueue.shutdown(queue);\n }\n}).pipe(Effect.tx);\n/**\n * Waits for the TxPubSub to be shut down.\n *\n * **Example** (Waiting for shutdown)\n *\n * ```ts\n * import { Effect, TxPubSub } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const hub = yield* TxPubSub.unbounded<number>()\n *\n * const fiber = yield* Effect.forkChild(TxPubSub.awaitShutdown(hub))\n * yield* TxPubSub.shutdown(hub)\n * yield* fiber.await\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const awaitShutdown = self => Effect.gen(function* () {\n const shut = yield* TxRef.get(self.shutdownRef);\n if (shut) return;\n return yield* Effect.txRetry;\n}).pipe(Effect.tx);\n// =============================================================================\n// Guards\n// =============================================================================\n/**\n * Checks whether the given value is a TxPubSub.\n *\n * **Example** (Checking for a TxPubSub)\n *\n * ```ts\n * import { TxPubSub } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxPubSub.isTxPubSub(someValue)) {\n * console.log(\"This is a TxPubSub\")\n * }\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxPubSub = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxPubSub.js.map","/**\n * Coordinates shared access inside transactions with read and write locks.\n *\n * A `TxReentrantLock` lets many fibers hold read locks at the same time, or one\n * fiber hold a write lock for exclusive access. Lock ownership is tracked by\n * fiber, so a fiber that already holds the lock can acquire it again and later\n * release each acquisition. Attempts that cannot proceed retry transactionally\n * until the lock becomes available. This module includes manual, scoped, and\n * wrapper-style operations for read and write locking.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport * as HashMap from \"./HashMap.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport * as Option from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxReentrantLock\";\nconst emptyState = {\n readers: /*#__PURE__*/HashMap.empty(),\n writer: /*#__PURE__*/Option.none()\n};\nconst TxReentrantLockProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxReentrantLock\"\n };\n },\n toString() {\n return \"TxReentrantLock\";\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n// =============================================================================\n// Constructors\n// =============================================================================\n/**\n * Creates a new TxReentrantLock.\n *\n * **Example** (Creating a reentrant lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const isLocked = yield* TxReentrantLock.locked(lock)\n * console.log(isLocked) // false\n * })\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = () => Effect.gen(function* () {\n const stateRef = yield* TxRef.make(emptyState);\n const self = Object.create(TxReentrantLockProto);\n self[TypeId] = TypeId;\n self.stateRef = stateRef;\n return self;\n}).pipe(Effect.tx);\n// =============================================================================\n// Mutations\n// =============================================================================\n/**\n * Acquires a read lock. Blocks if another fiber holds the write lock.\n * If the current fiber already holds the write lock, the read lock is granted (reentrancy).\n * Returns the current number of read locks held by this fiber.\n *\n * **Example** (Acquiring a read lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const count = yield* TxReentrantLock.acquireRead(lock)\n * console.log(count) // 1\n * yield* TxReentrantLock.releaseRead(lock)\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const acquireRead = self => Effect.withFiber(fiber => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n const fiberId = fiber.id;\n // If another fiber holds the write lock, retry\n if (Option.isSome(state.writer) && state.writer.value[0] !== fiberId) {\n return yield* Effect.txRetry;\n }\n // Grant read lock\n const currentCount = Option.getOrElse(HashMap.get(state.readers, fiberId), () => 0);\n const newCount = currentCount + 1;\n yield* TxRef.set(self.stateRef, {\n ...state,\n readers: HashMap.set(state.readers, fiberId, newCount)\n });\n return newCount;\n}).pipe(Effect.tx));\n/**\n * Acquires the write lock for the current fiber.\n *\n * **When to use**\n *\n * Use to enter an exclusive section manually when `withWriteLock` is not the\n * right shape.\n *\n * **Details**\n *\n * Blocks if any other fiber holds a read or write lock. If the current fiber\n * already holds the write lock, the count is incremented. If the current fiber\n * holds a read lock, the write lock is granted as an upgrade.\n *\n * Returns the current number of write locks held by this fiber.\n *\n * **Example** (Acquiring a write lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const count = yield* TxReentrantLock.acquireWrite(lock)\n * console.log(count) // 1\n * yield* TxReentrantLock.releaseWrite(lock)\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const acquireWrite = self => Effect.withFiber(fiber => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n const fiberId = fiber.id;\n // If another fiber holds the write lock, retry\n if (Option.isSome(state.writer) && state.writer.value[0] !== fiberId) {\n return yield* Effect.txRetry;\n }\n // If other fibers hold read locks, retry\n for (const [readerId] of state.readers) {\n if (readerId !== fiberId && Option.getOrElse(HashMap.get(state.readers, readerId), () => 0) > 0) {\n return yield* Effect.txRetry;\n }\n }\n // Grant write lock\n if (Option.isSome(state.writer)) {\n // Reentrant: increment write count\n const newCount = state.writer.value[1] + 1;\n yield* TxRef.set(self.stateRef, {\n ...state,\n writer: Option.some([fiberId, newCount])\n });\n return newCount;\n }\n // First write lock acquisition\n yield* TxRef.set(self.stateRef, {\n ...state,\n writer: Option.some([fiberId, 1])\n });\n return 1;\n}).pipe(Effect.tx));\n/**\n * Releases one read lock held by the current fiber.\n *\n * **When to use**\n *\n * Use to leave a manually acquired read lock.\n *\n * **Details**\n *\n * Returns the remaining number of read locks held by this fiber.\n *\n * **Example** (Releasing a read lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * yield* TxReentrantLock.acquireRead(lock)\n * const remaining = yield* TxReentrantLock.releaseRead(lock)\n * console.log(remaining) // 0\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const releaseRead = self => Effect.withFiber(fiber => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n const fiberId = fiber.id;\n const currentCount = Option.getOrElse(HashMap.get(state.readers, fiberId), () => 0);\n if (currentCount <= 0) return 0;\n const newCount = currentCount - 1;\n const newReaders = newCount === 0 ? HashMap.remove(state.readers, fiberId) : HashMap.set(state.readers, fiberId, newCount);\n yield* TxRef.set(self.stateRef, {\n ...state,\n readers: newReaders\n });\n return newCount;\n}).pipe(Effect.tx));\n/**\n * Releases one write lock held by the current fiber.\n *\n * **When to use**\n *\n * Use to leave a manually acquired write lock.\n *\n * **Details**\n *\n * Returns the remaining number of write locks held by this fiber.\n *\n * **Example** (Releasing a write lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * yield* TxReentrantLock.acquireWrite(lock)\n * const remaining = yield* TxReentrantLock.releaseWrite(lock)\n * console.log(remaining) // 0\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const releaseWrite = self => Effect.withFiber(fiber => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n const fiberId = fiber.id;\n if (Option.isNone(state.writer) || state.writer.value[0] !== fiberId) return 0;\n const newCount = state.writer.value[1] - 1;\n const newWriter = newCount <= 0 ? Option.none() : Option.some([fiberId, newCount]);\n yield* TxRef.set(self.stateRef, {\n ...state,\n writer: newWriter\n });\n return newCount;\n}).pipe(Effect.tx));\n/**\n * Acquires a read lock for the duration of the scope.\n * The lock is automatically released when the scope closes.\n *\n * **Example** (Holding a scoped read lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * yield* TxReentrantLock.readLock(lock)\n * // read lock is held for the duration of the scope\n * })\n * )\n * // read lock is released\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const readLock = self => Effect.acquireRelease(acquireRead(self), () => releaseRead(self));\n/**\n * Acquires a write lock for the duration of the scope.\n * The lock is automatically released when the scope closes.\n *\n * **Example** (Holding a scoped write lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * yield* TxReentrantLock.writeLock(lock)\n * // write lock is held for the duration of the scope\n * })\n * )\n * // write lock is released\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const writeLock = self => Effect.acquireRelease(acquireWrite(self), () => releaseWrite(self));\n/**\n * Runs the provided effect while holding a read lock. The lock is automatically\n * released after the effect completes, fails, or is interrupted.\n *\n * **Example** (Running an effect with a read lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const result = yield* TxReentrantLock.withReadLock(\n * lock,\n * Effect.succeed(\"read data\")\n * )\n * console.log(result) // \"read data\"\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const withReadLock = (...args) => {\n if (args.length === 1) {\n const [effect] = args;\n return self => Effect.acquireUseRelease(acquireRead(self), () => effect, () => releaseRead(self));\n }\n const [self, effect] = args;\n return Effect.acquireUseRelease(acquireRead(self), () => effect, () => releaseRead(self));\n};\n/**\n * Runs the provided effect while holding a write lock. The lock is automatically\n * released after the effect completes, fails, or is interrupted.\n *\n * **Example** (Running an effect with a write lock)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const result = yield* TxReentrantLock.withWriteLock(\n * lock,\n * Effect.succeed(\"wrote data\")\n * )\n * console.log(result) // \"wrote data\"\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const withWriteLock = (...args) => {\n if (args.length === 1) {\n const [effect] = args;\n return self => Effect.acquireUseRelease(acquireWrite(self), () => effect, () => releaseWrite(self));\n }\n const [self, effect] = args;\n return Effect.acquireUseRelease(acquireWrite(self), () => effect, () => releaseWrite(self));\n};\n/**\n * Runs an effect while holding a write lock.\n *\n * **When to use**\n *\n * Use when you need to run an effect with exclusive write access through a\n * `TxReentrantLock` and prefer the concise lock helper.\n *\n * **Example** (Running an effect with exclusive access)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const result = yield* TxReentrantLock.withLock(\n * lock,\n * Effect.succeed(\"exclusive operation\")\n * )\n * console.log(result) // \"exclusive operation\"\n * })\n * ```\n *\n * @category mutations\n * @since 2.0.0\n */\nexport const withLock = withWriteLock;\n// =============================================================================\n// Getters\n// =============================================================================\n/**\n * Returns the total number of read locks held across all fibers.\n *\n * **Example** (Counting read locks)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * yield* TxReentrantLock.acquireRead(lock)\n * const count = yield* TxReentrantLock.readLocks(lock)\n * console.log(count) // 1\n * yield* TxReentrantLock.releaseRead(lock)\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const readLocks = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n let total = 0;\n for (const [, count] of state.readers) {\n total += count;\n }\n return total;\n});\n/**\n * Returns the number of write locks held (0 or the reentrant count).\n *\n * **Example** (Counting write locks)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const count = yield* TxReentrantLock.writeLocks(lock)\n * console.log(count) // 0\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const writeLocks = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n return Option.isSome(state.writer) ? state.writer.value[1] : 0;\n});\n/**\n * Checks whether the lock is held by any fiber (read or write).\n *\n * **Example** (Checking whether a lock is held)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const isLocked = yield* TxReentrantLock.locked(lock)\n * console.log(isLocked) // false\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const locked = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n return HashMap.size(state.readers) > 0 || Option.isSome(state.writer);\n});\n/**\n * Checks whether any fiber holds a read lock.\n *\n * **Example** (Checking whether a read lock is held)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const isReadLocked = yield* TxReentrantLock.readLocked(lock)\n * console.log(isReadLocked) // false\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const readLocked = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n return HashMap.size(state.readers) > 0;\n});\n/**\n * Checks whether any fiber holds a write lock.\n *\n * **Example** (Checking whether a write lock is held)\n *\n * ```ts\n * import { Effect, TxReentrantLock } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const lock = yield* TxReentrantLock.make()\n * const isWriteLocked = yield* TxReentrantLock.writeLocked(lock)\n * console.log(isWriteLocked) // false\n * })\n * ```\n *\n * @category getters\n * @since 2.0.0\n */\nexport const writeLocked = self => Effect.gen(function* () {\n const state = yield* TxRef.get(self.stateRef);\n return Option.isSome(state.writer);\n});\n// =============================================================================\n// Guards\n// =============================================================================\n/**\n * Checks whether the given value is a TxReentrantLock.\n *\n * **Example** (Checking for TxReentrantLock values)\n *\n * ```ts\n * import { TxReentrantLock } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxReentrantLock.isTxReentrantLock(someValue)) {\n * console.log(\"This is a TxReentrantLock\")\n * }\n * ```\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxReentrantLock = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxReentrantLock.js.map","/**\n * Coordinates access to limited resources inside transactions.\n *\n * A `TxSemaphore` has a fixed capacity and stores its available permit count in\n * a `TxRef`. Acquiring or releasing permits can therefore commit atomically\n * with other transactional state changes. This module includes operations for\n * creating semaphores, checking capacity and availability, acquiring or\n * releasing permits, and running effects while permits are held.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxSemaphore\";\nconst TxSemaphoreProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxSemaphore\",\n capacity: this.capacity\n };\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\nconst makeTxSemaphore = (permitsRef, capacity) => {\n const self = Object.create(TxSemaphoreProto);\n self[TypeId] = TypeId;\n self.permitsRef = permitsRef;\n self.capacity = capacity;\n return self;\n};\n/**\n * Creates a new TxSemaphore with the specified number of permits.\n *\n * **When to use**\n *\n * Use to create a transactional semaphore with a fixed permit capacity.\n *\n * **Example** (Creating a semaphore)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * // Create a semaphore for managing concurrent access to a resource pool\n * const program = Effect.gen(function*() {\n * // Create a semaphore with 3 permits for a connection pool\n * const connectionSemaphore = yield* TxSemaphore.make(3)\n *\n * // Check initial state\n * const available = yield* TxSemaphore.available(connectionSemaphore)\n * const capacity = yield* TxSemaphore.capacity(connectionSemaphore)\n *\n * yield* Console.log(\n * `Created semaphore with ${capacity} permits, ${available} available`\n * )\n * // Output: \"Created semaphore with 3 permits, 3 available\"\n * })\n * ```\n *\n * @see {@link available} for reading the current available permit count\n * @see {@link capacity} for reading the fixed total permit count\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = permits => Effect.gen(function* () {\n if (permits < 0) {\n return yield* Effect.die(new Error(\"Permits must be non-negative\"));\n }\n const permitsRef = yield* TxRef.make(permits);\n return makeTxSemaphore(permitsRef, permits);\n}).pipe(Effect.tx);\n/**\n * Gets the current number of available permits in the semaphore.\n *\n * **When to use**\n *\n * Use to inspect how many permits are currently available.\n *\n * **Example** (Checking available permits)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(5)\n *\n * // Check available permits before acquiring\n * const before = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`Available permits: ${before}`) // 5\n *\n * // Acquire some permits\n * yield* TxSemaphore.acquire(semaphore)\n * yield* TxSemaphore.acquire(semaphore)\n *\n * // Check available permits after acquiring\n * const after = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`Available permits: ${after}`) // 3\n * })\n * ```\n *\n * @see {@link capacity} for reading the fixed total permit count\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const available = self => TxRef.get(self.permitsRef);\n/**\n * Gets the maximum capacity (total permits) of the semaphore.\n *\n * **When to use**\n *\n * Use to inspect the fixed total number of permits managed by the semaphore.\n *\n * **Example** (Checking semaphore capacity)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(10)\n *\n * const capacity = yield* TxSemaphore.capacity(semaphore)\n * yield* Console.log(`Semaphore capacity: ${capacity}`) // 10\n *\n * // Capacity remains constant regardless of current permits\n * yield* TxSemaphore.acquire(semaphore)\n * const stillSame = yield* TxSemaphore.capacity(semaphore)\n * yield* Console.log(`Capacity after acquire: ${stillSame}`) // 10\n * })\n * ```\n *\n * @see {@link available} for reading the current available permit count\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const capacity = self => Effect.succeed(self.capacity);\n/**\n * Acquires a single permit from the semaphore. If no permits are available,\n * the effect will block until one becomes available.\n *\n * **When to use**\n *\n * Use to manually acquire one permit transactionally, waiting until one is\n * available.\n *\n * **Example** (Acquiring a permit)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(2)\n *\n * yield* Console.log(\"Acquiring first permit...\")\n * yield* TxSemaphore.acquire(semaphore)\n * yield* Console.log(\"First permit acquired\")\n *\n * yield* Console.log(\"Acquiring second permit...\")\n * yield* TxSemaphore.acquire(semaphore)\n * yield* Console.log(\"Second permit acquired\")\n *\n * const available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`Available permits: ${available}`) // 0\n * })\n * ```\n *\n * @see {@link tryAcquire} for a non-blocking single-permit attempt\n * @see {@link release} for returning one permit\n * @see {@link withPermit} for automatic acquire and release around an effect\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const acquire = self => Effect.gen(function* () {\n const permits = yield* TxRef.get(self.permitsRef);\n if (permits <= 0) {\n return yield* Effect.txRetry;\n }\n yield* TxRef.set(self.permitsRef, permits - 1);\n}).pipe(Effect.tx);\n/**\n * Acquires the specified number of permits from the semaphore.\n *\n * **When to use**\n *\n * Use to manually acquire multiple permits transactionally, waiting until all\n * requested permits are available.\n *\n * **Details**\n *\n * If fewer than `n` permits are available, the transaction retries until enough\n * permits are released.\n *\n * **Gotchas**\n *\n * Passing a non-positive `n` dies with a defect. Passing a value greater than\n * the semaphore capacity can wait forever because the capacity is fixed.\n *\n * **Example** (Acquiring multiple permits)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(5)\n *\n * yield* Console.log(\"Acquiring 3 permits...\")\n * yield* TxSemaphore.acquireN(semaphore, 3)\n * yield* Console.log(\"3 permits acquired\")\n *\n * const available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`Available permits: ${available}`) // 2\n * })\n * ```\n *\n * @see {@link tryAcquireN} for a non-blocking multi-permit attempt\n * @see {@link releaseN} for returning multiple permits\n * @see {@link withPermits} for automatic acquire and release around an effect\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const acquireN = (self, n) => {\n if (n <= 0) {\n return Effect.die(new Error(\"Number of permits must be positive\"));\n }\n return Effect.gen(function* () {\n const permits = yield* TxRef.get(self.permitsRef);\n if (permits < n) {\n return yield* Effect.txRetry;\n }\n yield* TxRef.set(self.permitsRef, permits - n);\n }).pipe(Effect.tx);\n};\n/**\n * Tries to acquire a single permit from the semaphore without blocking,\n * returning `true` if successful or `false` if no permits are available.\n *\n * **When to use**\n *\n * Use to attempt a single-permit acquisition without retrying when no permit is\n * available.\n *\n * **Example** (Trying to acquire a permit)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(1)\n *\n * // First try should succeed\n * const first = yield* TxSemaphore.tryAcquire(semaphore)\n * yield* Console.log(`First try: ${first}`) // true\n *\n * // Second try should fail (no permits left)\n * const second = yield* TxSemaphore.tryAcquire(semaphore)\n * yield* Console.log(`Second try: ${second}`) // false\n * })\n * ```\n *\n * @see {@link acquire} for waiting until one permit is available\n * @see {@link tryAcquireN} for attempting to acquire multiple permits without blocking\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const tryAcquire = self => TxRef.modify(self.permitsRef, permits => {\n if (permits > 0) {\n return [true, permits - 1];\n }\n return [false, permits];\n});\n/**\n * Tries to acquire the specified number of permits from the semaphore without\n * blocking, returning `true` if successful or `false` if not enough permits are\n * available.\n *\n * **When to use**\n *\n * Use to attempt a multi-permit acquisition without retrying when not enough\n * permits are available.\n *\n * **Example** (Trying to acquire multiple permits)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(3)\n *\n * // Try to acquire 2 permits (should succeed)\n * const first = yield* TxSemaphore.tryAcquireN(semaphore, 2)\n * yield* Console.log(`First try (2 permits): ${first}`) // true\n *\n * // Try to acquire 2 more permits (should fail, only 1 left)\n * const second = yield* TxSemaphore.tryAcquireN(semaphore, 2)\n * yield* Console.log(`Second try (2 permits): ${second}`) // false\n * })\n * ```\n *\n * @see {@link acquireN} for waiting until all requested permits are available\n * @see {@link tryAcquire} for attempting to acquire one permit without blocking\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const tryAcquireN = (self, n) => {\n if (n <= 0) {\n return Effect.die(new Error(\"Number of permits must be positive\"));\n }\n return TxRef.modify(self.permitsRef, permits => {\n if (permits >= n) {\n return [true, permits - n];\n }\n return [false, permits];\n });\n};\n/**\n * Releases one permit back to the semaphore, making it available for\n * acquisition.\n *\n * **When to use**\n *\n * Use to manually return one permit after a transactional acquire.\n *\n * **Details**\n *\n * If the semaphore is already at capacity, this operation leaves the permit\n * count unchanged.\n *\n * **Example** (Releasing a permit)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(2)\n *\n * // Acquire a permit\n * yield* TxSemaphore.acquire(semaphore)\n * let available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`After acquire: ${available}`) // 1\n *\n * // Release the permit\n * yield* TxSemaphore.release(semaphore)\n * available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`After release: ${available}`) // 2\n * })\n * ```\n *\n * @see {@link acquire} for manually acquiring one permit\n * @see {@link releaseN} for returning multiple permits\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const release = self => TxRef.update(self.permitsRef, permits => permits >= self.capacity ? permits : permits + 1);\n/**\n * Releases the specified number of permits back to the semaphore.\n *\n * **When to use**\n *\n * Use to manually return multiple permits after a transactional acquire.\n *\n * **Details**\n *\n * The available permit count is capped at the semaphore capacity.\n *\n * **Gotchas**\n *\n * Passing a non-positive `n` dies with a defect.\n *\n * **Example** (Releasing multiple permits)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(5)\n *\n * // Acquire 3 permits\n * yield* TxSemaphore.acquireN(semaphore, 3)\n * let available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`After acquire: ${available}`) // 2\n *\n * // Release 2 permits\n * yield* TxSemaphore.releaseN(semaphore, 2)\n * available = yield* TxSemaphore.available(semaphore)\n * yield* Console.log(`After release: ${available}`) // 4\n * })\n * ```\n *\n * @see {@link acquireN} for manually acquiring multiple permits\n * @see {@link release} for returning one permit\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const releaseN = (self, n) => {\n if (n <= 0) {\n return Effect.die(new Error(\"Number of permits must be positive\"));\n }\n return TxRef.update(self.permitsRef, permits => {\n const newPermits = permits + n;\n return newPermits > self.capacity ? self.capacity : newPermits;\n });\n};\n/**\n * Executes an effect with a single permit from the semaphore. The permit is\n * automatically acquired before execution and released afterwards, even if the\n * effect fails or is interrupted.\n *\n * **When to use**\n *\n * Use to run an effect while automatically acquiring and releasing one\n * transactional permit.\n *\n * **Details**\n *\n * The permit acquisition and release operations use atomic semantics to ensure\n * proper resource management with Effect's scoped operations.\n *\n * **Example** (Running an effect with a permit)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(2)\n *\n * // Execute database operation with automatic permit management\n * const result = yield* TxSemaphore.withPermit(\n * semaphore,\n * Effect.gen(function*() {\n * yield* Console.log(\"Permit acquired, accessing database...\")\n * yield* Effect.sleep(\"100 millis\") // Simulate database work\n * yield* Console.log(\"Database operation complete\")\n * return \"query result\"\n * })\n * )\n *\n * yield* Console.log(`Result: ${result}`)\n * // Permit is automatically released here\n * })\n * ```\n *\n * @see {@link withPermits} for automatically acquiring and releasing multiple permits\n * @see {@link withPermitScoped} for acquiring one permit for the current scope\n * @see {@link acquire} for manual single-permit acquisition\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const withPermit = (...args) => {\n if (args.length === 1) {\n const [self] = args;\n return effect => Effect.acquireUseRelease(acquire(self), () => effect, () => release(self));\n }\n const [self, effect] = args;\n return Effect.acquireUseRelease(acquire(self), () => effect, () => release(self));\n};\n/**\n * Runs an effect while holding the specified number of permits from the\n * semaphore.\n *\n * **When to use**\n *\n * Use to run an effect while automatically acquiring and releasing multiple\n * transactional permits.\n *\n * **Details**\n *\n * The permits are acquired before the effect starts and released after it\n * completes, fails, or is interrupted.\n *\n * **Gotchas**\n *\n * Passing a non-positive `n` dies with a defect. Passing a value greater than\n * the semaphore capacity can wait forever.\n *\n * **Example** (Running an effect with multiple permits)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(5)\n *\n * // Execute batch operation with 3 permits\n * const results = yield* TxSemaphore.withPermits(\n * semaphore,\n * 3,\n * Effect.gen(function*() {\n * yield* Console.log(\"3 permits acquired, processing batch...\")\n * yield* Effect.sleep(\"200 millis\") // Simulate batch processing\n * return [\"result1\", \"result2\", \"result3\"]\n * })\n * )\n *\n * yield* Console.log(`Batch results: ${results.join(\", \")}`)\n * // All 3 permits are automatically released here\n * })\n * ```\n *\n * @see {@link withPermit} for automatically acquiring and releasing one permit\n * @see {@link acquireN} for manual multi-permit acquisition\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const withPermits = (...args) => {\n if (args.length === 2) {\n const [self, n] = args;\n return effect => Effect.acquireUseRelease(acquireN(self, n), () => effect, () => releaseN(self, n));\n }\n const [self, n, effect] = args;\n return Effect.acquireUseRelease(acquireN(self, n), () => effect, () => releaseN(self, n));\n};\n/**\n * Acquires a single permit from the semaphore in a scoped manner. The permit\n * will be automatically released when the scope is closed, even if effects\n * within the scope fail or are interrupted.\n *\n * **When to use**\n *\n * Use to acquire one transactional permit for the lifetime of the current\n * scope.\n *\n * **Details**\n *\n * The permit acquisition and release operations use atomic semantics to ensure\n * proper resource management with Effect's scoped operations.\n *\n * **Example** (Acquiring a scoped permit)\n *\n * ```ts\n * import { Console, Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(3)\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * // Acquire permit for the duration of this scope\n * yield* TxSemaphore.withPermitScoped(semaphore)\n * yield* Console.log(\"Permit acquired for scope\")\n *\n * // Do work within the scope\n * yield* Effect.sleep(\"500 millis\")\n * yield* Console.log(\"Work completed\")\n *\n * // Permit will be automatically released when scope closes\n * })\n * )\n *\n * yield* Console.log(\"Scope closed, permit released\")\n * })\n * ```\n *\n * @see {@link withPermit} for acquiring one permit around a single effect\n * @see {@link acquire} for manual single-permit acquisition\n *\n * @category combinators\n * @since 2.0.0\n */\nexport const withPermitScoped = self => Effect.acquireRelease(acquire(self), () => release(self));\n/**\n * Determines if the provided value is a TxSemaphore.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a `TxSemaphore`.\n *\n * **Example** (Checking semaphore values)\n *\n * ```ts\n * import { Effect, TxSemaphore } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const semaphore = yield* TxSemaphore.make(5)\n * const notSemaphore = { some: \"object\" }\n *\n * console.log(TxSemaphore.isTxSemaphore(semaphore)) // true\n * console.log(TxSemaphore.isTxSemaphore(notSemaphore)) // false\n *\n * // Useful for runtime type checking in generic functions\n * if (TxSemaphore.isTxSemaphore(semaphore)) {\n * const available = yield* TxSemaphore.available(semaphore)\n * console.log(`Available permits: ${available}`)\n * }\n * })\n * ```\n *\n * @see {@link make} for creating a `TxSemaphore`\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxSemaphore = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxSemaphore.js.map","/**\n * Stores transactional state and publishes committed changes.\n *\n * A `TxSubscriptionRef<A>` combines a `TxRef<A>` for the current value with a\n * transactional pub/sub channel for updates. Subscribers first receive the\n * current value and then every later value that is published by committed\n * updates. This module includes constructors, reads, writes, update and modify\n * helpers, transactional-queue subscriptions, stream subscriptions, and a guard.\n *\n * @since 4.0.0\n */\nimport * as Effect from \"./Effect.js\";\nimport { dual } from \"./Function.js\";\nimport { NodeInspectSymbol, toJson } from \"./Inspectable.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Stream from \"./Stream.js\";\nimport * as TxPubSub from \"./TxPubSub.js\";\nimport * as TxQueue from \"./TxQueue.js\";\nimport * as TxRef from \"./TxRef.js\";\nconst TypeId = \"~effect/transactions/TxSubscriptionRef\";\nconst TxSubscriptionRefProto = {\n [NodeInspectSymbol]() {\n return toJson(this);\n },\n toJSON() {\n return {\n _id: \"TxSubscriptionRef\"\n };\n },\n toString() {\n return \"TxSubscriptionRef\";\n },\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n// =============================================================================\n// Constructors\n// =============================================================================\n/**\n * Creates a new TxSubscriptionRef with the specified initial value.\n *\n * **When to use**\n *\n * Use to create a `TxSubscriptionRef` that publishes every committed update to\n * subscribers.\n *\n * **Example** (Creating a transactional subscription reference)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(42)\n * const value = yield* TxSubscriptionRef.get(ref)\n * console.log(value) // 42\n * })\n * ```\n *\n * @see {@link changes} for subscribing to the created reference\n *\n * @category constructors\n * @since 3.10.0\n */\nexport const make = value => Effect.gen(function* () {\n const ref = yield* TxRef.make(value);\n const pubsub = yield* TxPubSub.unbounded();\n const self = Object.create(TxSubscriptionRefProto);\n self[TypeId] = TypeId;\n self.ref = ref;\n self.pubsub = pubsub;\n return self;\n}).pipe(Effect.tx);\n// =============================================================================\n// Getters\n// =============================================================================\n/**\n * Reads the current value of the TxSubscriptionRef.\n *\n * **When to use**\n *\n * Use to read the current `TxSubscriptionRef` value without subscribing to\n * future changes.\n *\n * **Example** (Reading the current value)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(\"hello\")\n * const value = yield* TxSubscriptionRef.get(ref)\n * console.log(value) // \"hello\"\n * })\n * ```\n *\n * @see {@link changes} for reading the current value and subsequent updates\n *\n * @category getters\n * @since 3.10.0\n */\nexport const get = self => TxRef.get(self.ref);\n// =============================================================================\n// Mutations\n// =============================================================================\n/**\n * Modifies the value of the TxSubscriptionRef using a function that returns both a\n * result and the new value. The new value is published to all subscribers atomically.\n *\n * **When to use**\n *\n * Use to compute a separate return value and next `TxSubscriptionRef` state in\n * one transactional update.\n *\n * **Example** (Modifying and returning a value)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(10)\n * const result = yield* TxSubscriptionRef.modify(ref, (n) => [`was ${n}`, n + 1])\n * console.log(result) // \"was 10\"\n * console.log(yield* TxSubscriptionRef.get(ref)) // 11\n * })\n * ```\n *\n * @see {@link update} for deriving the next value without a separate return value\n * @see {@link set} for replacing the value directly\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const modify = /*#__PURE__*/dual(2, (self, f) => Effect.gen(function* () {\n const current = yield* TxRef.get(self.ref);\n const [returnValue, newValue] = f(current);\n yield* TxRef.set(self.ref, newValue);\n yield* TxPubSub.publish(self.pubsub, newValue);\n return returnValue;\n}).pipe(Effect.tx));\n/**\n * Sets the value of the TxSubscriptionRef and publishes the new value to all subscribers.\n *\n * **When to use**\n *\n * Use to replace the current `TxSubscriptionRef` value with a known value and\n * publish it.\n *\n * **Example** (Setting a new value)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(0)\n * yield* TxSubscriptionRef.set(ref, 42)\n * console.log(yield* TxSubscriptionRef.get(ref)) // 42\n * })\n * ```\n *\n * @see {@link update} for deriving the new value from the current value\n * @see {@link getAndSet} for setting while returning the previous value\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const set = /*#__PURE__*/dual(2, (self, value) => modify(self, () => [void 0, value]));\n/**\n * Updates the value of the TxSubscriptionRef using a function and publishes the new\n * value to all subscribers.\n *\n * **When to use**\n *\n * Use to derive the next `TxSubscriptionRef` value from the current value and\n * publish it.\n *\n * **Example** (Updating a value)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(5)\n * yield* TxSubscriptionRef.update(ref, (n) => n * 2)\n * console.log(yield* TxSubscriptionRef.get(ref)) // 10\n * })\n * ```\n *\n * @see {@link set} for replacing the value directly\n * @see {@link updateAndGet} for returning the new value after the update\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const update = /*#__PURE__*/dual(2, (self, f) => modify(self, current => [void 0, f(current)]));\n/**\n * Gets the current value and sets a new value atomically. Publishes the new value\n * to all subscribers.\n *\n * **When to use**\n *\n * Use to replace a `TxSubscriptionRef` value while returning the previous value\n * and publishing the update to subscribers.\n *\n * **Example** (Getting and setting atomically)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(\"a\")\n * const old = yield* TxSubscriptionRef.getAndSet(ref, \"b\")\n * console.log(old) // \"a\"\n * console.log(yield* TxSubscriptionRef.get(ref)) // \"b\"\n * })\n * ```\n *\n * @see {@link set} for setting without returning the previous value\n * @see {@link getAndUpdate} for deriving the new value from the previous value\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const getAndSet = /*#__PURE__*/dual(2, (self, value) => modify(self, current => [current, value]));\n/**\n * Gets the current value and updates it using a function atomically. Publishes\n * the new value to all subscribers.\n *\n * **When to use**\n *\n * Use to derive and publish a new `TxSubscriptionRef` value while returning the\n * previous value.\n *\n * **Example** (Getting and updating atomically)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(1)\n * const old = yield* TxSubscriptionRef.getAndUpdate(ref, (n) => n + 10)\n * console.log(old) // 1\n * console.log(yield* TxSubscriptionRef.get(ref)) // 11\n * })\n * ```\n *\n * @see {@link update} for updating without returning the previous value\n * @see {@link updateAndGet} for returning the new value instead\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const getAndUpdate = /*#__PURE__*/dual(2, (self, f) => modify(self, current => [current, f(current)]));\n/**\n * Updates the value using a function and returns the new value. Publishes the\n * new value to all subscribers.\n *\n * **When to use**\n *\n * Use to derive and publish a new `TxSubscriptionRef` value while returning\n * that new value.\n *\n * **Example** (Updating and reading atomically)\n *\n * ```ts\n * import { Effect, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(3)\n * const result = yield* TxSubscriptionRef.updateAndGet(ref, (n) => n * 3)\n * console.log(result) // 9\n * })\n * ```\n *\n * @see {@link update} for updating without returning the new value\n * @see {@link getAndUpdate} for returning the previous value instead\n *\n * @category mutations\n * @since 3.10.0\n */\nexport const updateAndGet = /*#__PURE__*/dual(2, (self, f) => modify(self, current => {\n const newValue = f(current);\n return [newValue, newValue];\n}));\n// =============================================================================\n// Subscriptions\n// =============================================================================\n/**\n * Subscribes to all changes of the TxSubscriptionRef. Returns a scoped TxDequeue\n * that first yields the current value, then every subsequent update.\n *\n * **When to use**\n *\n * Use to subscribe to `TxSubscriptionRef` committed changes through a scoped\n * transactional queue.\n *\n * **Example** (Subscribing to changes)\n *\n * ```ts\n * import { Effect, TxQueue, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(0)\n *\n * yield* Effect.scoped(\n * Effect.gen(function*() {\n * const sub = yield* TxSubscriptionRef.changes(ref)\n * const initial = yield* TxQueue.take(sub)\n * console.log(initial) // 0\n *\n * yield* TxSubscriptionRef.set(ref, 1)\n * const next = yield* TxQueue.take(sub)\n * console.log(next) // 1\n * })\n * )\n * })\n * ```\n *\n * @see {@link changesStream} for subscribing through a `Stream`\n *\n * @category subscriptions\n * @since 3.10.0\n */\nexport const changes = self => Effect.acquireRelease(Effect.tx(Effect.gen(function* () {\n const sub = yield* TxPubSub.acquireSubscriber(self.pubsub);\n const current = yield* TxRef.get(self.ref);\n yield* TxQueue.offer(sub, current);\n return sub;\n})), queue => Effect.tx(TxPubSub.releaseSubscriber(self.pubsub, queue)));\n/**\n * Returns a Stream of all changes to the TxSubscriptionRef, starting with the\n * current value followed by every subsequent update.\n *\n * **When to use**\n *\n * Use to consume `TxSubscriptionRef` committed changes as a `Stream`.\n *\n * **Example** (Streaming changes)\n *\n * ```ts\n * import { Effect, Stream, TxSubscriptionRef } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* TxSubscriptionRef.make(0)\n * yield* TxSubscriptionRef.set(ref, 1)\n * yield* TxSubscriptionRef.set(ref, 2)\n *\n * const values = yield* Stream.runCollect(\n * TxSubscriptionRef.changesStream(ref).pipe(Stream.take(1))\n * )\n * console.log(values) // [2]\n * })\n * ```\n *\n * @see {@link changes} for subscribing through a transactional queue\n *\n * @category subscriptions\n * @since 3.10.0\n */\nexport const changesStream = self => Stream.unwrap(Effect.map(changes(self), sub => Stream.fromEffectRepeat(Effect.tx(TxQueue.take(sub)))));\n// =============================================================================\n// Guards\n// =============================================================================\n/**\n * Checks whether the given value is a TxSubscriptionRef.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a `TxSubscriptionRef`.\n *\n * **Example** (Checking transactional subscription references)\n *\n * ```ts\n * import { TxSubscriptionRef } from \"effect\"\n *\n * declare const someValue: unknown\n *\n * if (TxSubscriptionRef.isTxSubscriptionRef(someValue)) {\n * console.log(\"This is a TxSubscriptionRef\")\n * }\n * ```\n *\n * @see {@link make} for creating a `TxSubscriptionRef`\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isTxSubscriptionRef = u => hasProperty(u, TypeId);\n//# sourceMappingURL=TxSubscriptionRef.js.map","/**\n * Provides compile-time utility types for TypeScript.\n *\n * Everything in this module is type-level only; it does not define runtime\n * values. The types are used throughout Effect to work with tuple lengths,\n * object shapes, tagged unions, reason-tagged errors, mutability, exactness,\n * required keys, concurrency settings, and variance markers.\n *\n * @since 4.0.0\n */\nexport {};\n//# sourceMappingURL=Types.js.map","/**\n * Defines Effect's type-level unification protocol.\n *\n * Unification collapses unions of protocol-enabled values into their public data\n * types. It is mostly for maintainers of Effect data types and advanced library\n * authors; application code usually benefits from it through APIs such as\n * `Effect`, `Option`, `Result`, `Stream`, `Layer`, and `Match`. This module\n * exports the protocol symbols, the `Unify` type that performs normalization,\n * and `unify`, an identity function that changes only the inferred type.\n *\n * @since 2.0.0\n */\nimport { identity } from \"./Function.js\";\n/**\n * Applies `Unify` to a value or function return type at compile time.\n *\n * **When to use**\n *\n * Use to keep a value or function unchanged at runtime while normalizing its\n * inferred type with Effect's unification protocol.\n *\n * **Details**\n *\n * This is an identity function at runtime. For functions, the returned function\n * has the same runtime behavior while its return type is normalized with the\n * Effect unification protocol.\n *\n * **Example** (Unifying values and function results)\n *\n * ```ts\n * import { Unify } from \"effect\"\n *\n * // Unify a simple value\n * const unifiedValue = Unify.unify(\"hello\")\n * // Type: string\n *\n * // Unify a function result\n * const createUnifiableValue = () => ({\n * value: \"test\",\n * [Unify.typeSymbol]: \"string\" as const,\n * [Unify.unifySymbol]: { String: () => \"test\" as const }\n * })\n *\n * const unifiedFunction = Unify.unify(createUnifiableValue)\n * // The result will be properly unified\n *\n * // Unify with curried functions\n * const curriedFunction = (a: string) => (b: number) => ({ result: a + b })\n * const unifiedCurried = Unify.unify(curriedFunction)\n * // Type: (a: string) => (b: number) => Unify<{ result: string }>\n * ```\n *\n * @see {@link Unify} for the type-level normalization applied by this helper\n *\n * @category utility types\n * @since 2.0.0\n */\nexport const unify = identity;\n//# sourceMappingURL=Unify.js.map","/**\n * @since 2.0.0\n */\nexport {\n/**\n * @since 2.0.0\n */\nabsurd,\n/**\n * @since 2.0.0\n */\ncast,\n/**\n * @since 2.0.0\n */\nflow,\n/**\n * @since 2.0.0\n */\nhole,\n/**\n * @since 2.0.0\n */\nidentity,\n/**\n * @since 2.0.0\n */\npipe } from \"./Function.js\";\n// @barrel: Auto-generated exports. Do not edit manually.\n/**\n * @since 2.0.0\n */\nexport * as Array from \"./Array.js\";\n/**\n * @since 2.0.0\n */\nexport * as BigDecimal from \"./BigDecimal.js\";\n/**\n * @since 2.0.0\n */\nexport * as BigInt from \"./BigInt.js\";\n/**\n * @since 2.0.0\n */\nexport * as Boolean from \"./Boolean.js\";\n/**\n * @since 2.0.0\n */\nexport * as Brand from \"./Brand.js\";\n/**\n * @since 4.0.0\n */\nexport * as Cache from \"./Cache.js\";\n/**\n * @since 2.0.0\n */\nexport * as Cause from \"./Cause.js\";\n/**\n * @since 2.0.0\n */\nexport * as Channel from \"./Channel.js\";\n/**\n * @since 4.0.0\n */\nexport * as ChannelSchema from \"./ChannelSchema.js\";\n/**\n * @since 2.0.0\n */\nexport * as Chunk from \"./Chunk.js\";\n/**\n * @since 2.0.0\n */\nexport * as Clock from \"./Clock.js\";\n/**\n * @since 4.0.0\n */\nexport * as Combiner from \"./Combiner.js\";\n/**\n * @since 4.0.0\n */\nexport * as Config from \"./Config.js\";\n/**\n * @since 4.0.0\n */\nexport * as ConfigProvider from \"./ConfigProvider.js\";\n/**\n * @since 2.0.0\n */\nexport * as Console from \"./Console.js\";\n/**\n * @since 4.0.0\n */\nexport * as Context from \"./Context.js\";\n/**\n * @since 2.0.0\n */\nexport * as Cron from \"./Cron.js\";\n/**\n * @since 4.0.0\n */\nexport * as Crypto from \"./Crypto.js\";\n/**\n * @since 2.0.0\n */\nexport * as Data from \"./Data.js\";\n/**\n * @since 3.6.0\n */\nexport * as DateTime from \"./DateTime.js\";\n/**\n * @since 2.0.0\n */\nexport * as Deferred from \"./Deferred.js\";\n/**\n * @since 4.0.0\n */\nexport * as Differ from \"./Differ.js\";\n/**\n * @since 2.0.0\n */\nexport * as Duration from \"./Duration.js\";\n/**\n * @since 2.0.0\n */\nexport * as Effect from \"./Effect.js\";\n/**\n * @since 4.0.0\n */\nexport * as Effectable from \"./Effectable.js\";\n/**\n * @since 4.0.0\n */\nexport * as Encoding from \"./Encoding.js\";\n/**\n * @since 2.0.0\n */\nexport * as Equal from \"./Equal.js\";\n/**\n * @since 2.0.0\n */\nexport * as Equivalence from \"./Equivalence.js\";\n/**\n * @since 4.0.0\n */\nexport * as ErrorReporter from \"./ErrorReporter.js\";\n/**\n * @since 3.16.0\n */\nexport * as ExecutionPlan from \"./ExecutionPlan.js\";\n/**\n * @since 2.0.0\n */\nexport * as Exit from \"./Exit.js\";\n/**\n * @since 2.0.0\n */\nexport * as Fiber from \"./Fiber.js\";\n/**\n * @since 2.0.0\n */\nexport * as FiberHandle from \"./FiberHandle.js\";\n/**\n * @since 2.0.0\n */\nexport * as FiberMap from \"./FiberMap.js\";\n/**\n * @since 2.0.0\n */\nexport * as FiberSet from \"./FiberSet.js\";\n/**\n * @since 4.0.0\n */\nexport * as FileSystem from \"./FileSystem.js\";\n/**\n * @since 4.0.0\n */\nexport * as Filter from \"./Filter.js\";\n/**\n * @since 4.0.0\n */\nexport * as Formatter from \"./Formatter.js\";\n/**\n * @since 2.0.0\n */\nexport * as Function from \"./Function.js\";\n/**\n * @since 4.0.0\n */\nexport * as Graph from \"./Graph.js\";\n/**\n * @since 2.0.0\n */\nexport * as Hash from \"./Hash.js\";\n/**\n * @since 2.0.0\n */\nexport * as HashMap from \"./HashMap.js\";\n/**\n * @since 4.0.0\n */\nexport * as HashRing from \"./HashRing.js\";\n/**\n * @since 2.0.0\n */\nexport * as HashSet from \"./HashSet.js\";\n/**\n * @since 2.0.0\n */\nexport * as HKT from \"./HKT.js\";\n/**\n * @since 2.0.0\n */\nexport * as Inspectable from \"./Inspectable.js\";\n/**\n * @since 2.0.0\n */\nexport * as Iterable from \"./Iterable.js\";\n/**\n * @since 4.0.0\n */\nexport * as JsonPatch from \"./JsonPatch.js\";\n/**\n * @since 4.0.0\n */\nexport * as JsonPointer from \"./JsonPointer.js\";\n/**\n * @since 4.0.0\n */\nexport * as JsonSchema from \"./JsonSchema.js\";\n/**\n * @since 4.0.0\n */\nexport * as Latch from \"./Latch.js\";\n/**\n * @since 2.0.0\n */\nexport * as Layer from \"./Layer.js\";\n/**\n * @since 3.14.0\n */\nexport * as LayerMap from \"./LayerMap.js\";\n/**\n * @since 2.0.0\n */\nexport * as Logger from \"./Logger.js\";\n/**\n * @since 2.0.0\n */\nexport * as LogLevel from \"./LogLevel.js\";\n/**\n * @since 2.0.0\n */\nexport * as ManagedRuntime from \"./ManagedRuntime.js\";\n/**\n * @since 4.0.0\n */\nexport * as Match from \"./Match.js\";\n/**\n * @since 2.0.0\n */\nexport * as Metric from \"./Metric.js\";\n/**\n * @since 2.0.0\n */\nexport * as MutableHashMap from \"./MutableHashMap.js\";\n/**\n * @since 2.0.0\n */\nexport * as MutableHashSet from \"./MutableHashSet.js\";\n/**\n * @since 4.0.0\n */\nexport * as MutableList from \"./MutableList.js\";\n/**\n * @since 2.0.0\n */\nexport * as MutableRef from \"./MutableRef.js\";\n/**\n * @since 4.0.0\n */\nexport * as Newtype from \"./Newtype.js\";\n/**\n * @since 2.0.0\n */\nexport * as NonEmptyIterable from \"./NonEmptyIterable.js\";\n/**\n * @since 2.0.0\n */\nexport * as Number from \"./Number.js\";\n/**\n * @since 4.0.0\n */\nexport * as Optic from \"./Optic.js\";\n/**\n * @since 2.0.0\n */\nexport * as Option from \"./Option.js\";\n/**\n * @since 2.0.0\n */\nexport * as Order from \"./Order.js\";\n/**\n * @since 2.0.0\n */\nexport * as Ordering from \"./Ordering.js\";\n/**\n * @since 4.0.0\n */\nexport * as PartitionedSemaphore from \"./PartitionedSemaphore.js\";\n/**\n * @since 4.0.0\n */\nexport * as Path from \"./Path.js\";\n/**\n * @since 2.0.0\n */\nexport * as Pipeable from \"./Pipeable.js\";\n/**\n * @since 4.0.0\n */\nexport * as PlatformError from \"./PlatformError.js\";\n/**\n * @since 2.0.0\n */\nexport * as Pool from \"./Pool.js\";\n/**\n * @since 2.0.0\n */\nexport * as Predicate from \"./Predicate.js\";\n/**\n * @since 2.0.0\n */\nexport * as PrimaryKey from \"./PrimaryKey.js\";\n/**\n * @since 2.0.0\n */\nexport * as PubSub from \"./PubSub.js\";\n/**\n * @since 4.0.0\n */\nexport * as Pull from \"./Pull.js\";\n/**\n * @since 3.8.0\n */\nexport * as Queue from \"./Queue.js\";\n/**\n * @since 4.0.0\n */\nexport * as Random from \"./Random.js\";\n/**\n * @since 3.5.0\n */\nexport * as RcMap from \"./RcMap.js\";\n/**\n * @since 3.5.0\n */\nexport * as RcRef from \"./RcRef.js\";\n/**\n * @since 2.0.0\n */\nexport * as Record from \"./Record.js\";\n/**\n * @since 4.0.0\n */\nexport * as Redactable from \"./Redactable.js\";\n/**\n * @since 3.3.0\n */\nexport * as Redacted from \"./Redacted.js\";\n/**\n * @since 4.0.0\n */\nexport * as Reducer from \"./Reducer.js\";\n/**\n * @since 2.0.0\n */\nexport * as Ref from \"./Ref.js\";\n/**\n * @since 4.0.0\n */\nexport * as References from \"./References.js\";\n/**\n * @since 2.0.0\n */\nexport * as RegExp from \"./RegExp.js\";\n/**\n * @since 2.0.0\n */\nexport * as Request from \"./Request.js\";\n/**\n * @since 2.0.0\n */\nexport * as RequestResolver from \"./RequestResolver.js\";\n/**\n * @since 2.0.0\n */\nexport * as Resource from \"./Resource.js\";\n/**\n * @since 4.0.0\n */\nexport * as Result from \"./Result.js\";\n/**\n * @since 4.0.0\n */\nexport * as Runtime from \"./Runtime.js\";\n/**\n * @since 2.0.0\n */\nexport * as Schedule from \"./Schedule.js\";\n/**\n * @since 2.0.0\n */\nexport * as Scheduler from \"./Scheduler.js\";\n/**\n * @since 4.0.0\n */\nexport * as Schema from \"./Schema.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaAST from \"./SchemaAST.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaGetter from \"./SchemaGetter.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaIssue from \"./SchemaIssue.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaParser from \"./SchemaParser.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaRepresentation from \"./SchemaRepresentation.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaTransformation from \"./SchemaTransformation.js\";\n/**\n * @since 4.0.0\n */\nexport * as SchemaUtils from \"./SchemaUtils.js\";\n/**\n * @since 2.0.0\n */\nexport * as Scope from \"./Scope.js\";\n/**\n * @since 4.0.0\n */\nexport * as ScopedCache from \"./ScopedCache.js\";\n/**\n * @since 2.0.0\n */\nexport * as ScopedRef from \"./ScopedRef.js\";\n/**\n * @since 4.0.0\n */\nexport * as Semaphore from \"./Semaphore.js\";\n/**\n * @since 2.0.0\n */\nexport * as Sink from \"./Sink.js\";\n/**\n * @since 4.0.0\n */\nexport * as Stdio from \"./Stdio.js\";\n/**\n * @since 2.0.0\n */\nexport * as Stream from \"./Stream.js\";\n/**\n * @since 2.0.0\n */\nexport * as String from \"./String.js\";\n/**\n * @since 2.0.0\n */\nexport * as Struct from \"./Struct.js\";\n/**\n * @since 2.0.0\n */\nexport * as SubscriptionRef from \"./SubscriptionRef.js\";\n/**\n * @since 2.0.0\n */\nexport * as Symbol from \"./Symbol.js\";\n/**\n * @since 2.0.0\n */\nexport * as SynchronizedRef from \"./SynchronizedRef.js\";\n/**\n * @since 2.0.0\n */\nexport * as Take from \"./Take.js\";\n/**\n * @since 4.0.0\n */\nexport * as Terminal from \"./Terminal.js\";\n/**\n * @since 2.0.0\n */\nexport * as Tracer from \"./Tracer.js\";\n/**\n * @since 2.0.0\n */\nexport * as Trie from \"./Trie.js\";\n/**\n * @since 2.0.0\n */\nexport * as Tuple from \"./Tuple.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxChunk from \"./TxChunk.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxDeferred from \"./TxDeferred.js\";\n/**\n * @since 2.0.0\n */\nexport * as TxHashMap from \"./TxHashMap.js\";\n/**\n * @since 2.0.0\n */\nexport * as TxHashSet from \"./TxHashSet.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxPriorityQueue from \"./TxPriorityQueue.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxPubSub from \"./TxPubSub.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxQueue from \"./TxQueue.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxReentrantLock from \"./TxReentrantLock.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxRef from \"./TxRef.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxSemaphore from \"./TxSemaphore.js\";\n/**\n * @since 4.0.0\n */\nexport * as TxSubscriptionRef from \"./TxSubscriptionRef.js\";\n/**\n * @since 4.0.0\n */\nexport * as Types from \"./Types.js\";\n/**\n * @since 4.0.0\n */\nexport * as UndefinedOr from \"./UndefinedOr.js\";\n/**\n * @since 2.0.0\n */\nexport * as Unify from \"./Unify.js\";\n/**\n * @since 2.0.0\n */\nexport * as Utils from \"./Utils.js\";\n//# sourceMappingURL=index.js.map"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,IAAa,SAAS,WAAW;AACjC,IAAM,UAAuB,qBAAO,CAAC;AACrC,IAAM,UAAuB,qBAAO,CAAC;AACrC,IAAM,UAAuB,qBAAO,CAAC;;;;;;;;;;;;;;;;;;;;;AAqBrC,IAAa,WAAWA;;;;;;;;;;;;;;;;;;;;;;;AAuBxB,IAAa,MAAmB,mBAAK,IAAI,MAAM,SAAS,OAA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