var _a;

import * as tsplus_module_1 from "@effect/core/io/Cause/definition";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/timeoutFailCause";
import * as tsplus_module_4 from "@effect/core/stream/Stream/operations/catchSomeCause";
export const StreamTimeoutErrorSym = /*#__PURE__*/Symbol.for("@effect/core/stream/Stream/StreamTimeoutError");
export class StreamTimeoutError {
  constructor(message) {
    this.message = message;
    this[_a] = "StreamTimeoutError";
  }

}
_a = StreamTimeoutErrorSym;
export function isStreamTimeoutError(u) {
  return u instanceof StreamTimeoutError && u[StreamTimeoutErrorSym] === "StreamTimeoutError";
}
/**
 * Switches the stream if it does not produce a value after the spcified
 * duration.
 *
 * @tsplus fluent ets/Stream timeoutTo
 */

export function timeoutTo_(self, duration, that, __tsplusTrace) {
  return tsplus_module_4.catchSomeCause_(tsplus_module_3.timeoutFailCause_(self, () => tsplus_module_1.die(new StreamTimeoutError()), duration, __tsplusTrace), cause => tsplus_module_1.isDieType(cause) && isStreamTimeoutError(cause.value) ? tsplus_module_2.some(that()) : tsplus_module_2.none, __tsplusTrace);
}
/**
 * Switches the stream if it does not produce a value after the spcified
 * duration.
 *
 * @tsplus static ets/Stream/Aspects timeoutTo
 */

export const timeoutTo = (duration, that, __tsplusTrace) => self => timeoutTo_(self, duration, that, __tsplusTrace);
//# sourceMappingURL=timeoutTo.mjs.map