import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/timeoutFail";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/toPull";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_5 from "@effect/core/stream/Stream/operations/fromPull";
import * as tsplus_module_6 from "@effect/core/stream/Stream/operations/succeed";
import * as tsplus_module_7 from "@effect/core/stream/Stream/operations/flatMap";
/**
 * Ends the stream if it does not produce a value after the specified duration.
 *
 * @tsplus fluent ets/Stream timeout
 */

export function timeout_(self, duration, __tsplusTrace) {
  return tsplus_module_7.flatMap_(tsplus_module_6.succeed(duration, __tsplusTrace), duration => tsplus_module_5.fromPull(() => tsplus_module_4.map_(tsplus_module_3.toPull(self, __tsplusTrace), pull => tsplus_module_2.timeoutFail_(pull, () => tsplus_module_1.none, () => duration, __tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * Ends the stream if it does not produce a value after the specified duration.
 *
 * @tsplus static ets/Stream/Aspects timeout
 */

export const timeout = (duration, __tsplusTrace) => self => timeout_(self, duration, __tsplusTrace);
//# sourceMappingURL=timeout.mjs.map