import * as tsplus_module_1 from "@effect/core/io/Cause/operations/isInterrupted";
import * as tsplus_module_2 from "@effect/core/stream/Pull/operations/end";
import * as tsplus_module_3 from "@effect/core/stream/Pull/operations/failCause";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/flatMap";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/catchAllCause";
import * as tsplus_module_6 from "@effect/core/stream/Stream/operations/repeatEffectChunkMaybe";
/**
 * Creates a stream from a queue of values.
 *
 * @tsplus static ets/Stream/Ops fromChunkQueue
 */

export function fromChunkQueue(queue, __tsplusTrace) {
  return tsplus_module_6.repeatEffectChunkMaybe(() => {
    const queue0 = queue();
    return tsplus_module_5.catchAllCause_(queue0.take, cause => tsplus_module_4.flatMap_(queue0.isShutdown, isShutdown => isShutdown && tsplus_module_1.isInterrupted(cause) ? tsplus_module_2.end : tsplus_module_3.failCause(cause), __tsplusTrace), __tsplusTrace);
  }, __tsplusTrace);
}
//# sourceMappingURL=fromChunkQueue.mjs.map