import * as tsplus_module_1 from "@effect/core/stream/Stream/operations/succeed";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/succeed";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_4 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/foldEffect";
import * as tsplus_module_7 from "@effect/core/stream/Stream/operations/unfoldEffect";
import * as tsplus_module_8 from "@effect/core/stream/Stream/operations/concat";
import * as tsplus_module_9 from "@effect/core/io/Schedule/operations/driver";
import * as tsplus_module_10 from "@effect/core/io/Effect/operations/zip";
import * as tsplus_module_11 from "@effect/core/stream/Stream/operations/fromEffect";
import * as tsplus_module_12 from "@effect/core/stream/Stream/operations/flatMap";
/**
 * Creates a stream from an effect producing a value of type `A`, which is
 * repeated using the specified schedule.
 *
 * @tsplus static ets/Stream/Ops repeatEffectWithSchedule
 */

export function repeatEffectWithSchedule(effect, schedule, __tsplusTrace) {
  return tsplus_module_12.flatMap_(tsplus_module_1.succeed(() => tsplus_module_3.make(effect(), schedule()), __tsplusTrace), ({
    tuple: [effect, schedule]
  }) => tsplus_module_12.flatMap_(tsplus_module_11.fromEffect(() => tsplus_module_10.zip_(effect, () => tsplus_module_9.driver(schedule), __tsplusTrace), __tsplusTrace), ({
    tuple: [a, driver]
  }) => tsplus_module_8.concat_(tsplus_module_1.succeed(() => a, __tsplusTrace), () => tsplus_module_7.unfoldEffect(() => a, a => tsplus_module_6.foldEffect_(driver.next(a), e => tsplus_module_2.succeed(() => e, __tsplusTrace), () => tsplus_module_5.map_(effect, nextA => tsplus_module_4.some(tsplus_module_3.make(nextA, nextA)), __tsplusTrace), __tsplusTrace)), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=repeatEffectWithSchedule.mjs.map