import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/pipeTo";
import * as tsplus_module_2 from "@effect/core/stream/Channel/operations/write";
import * as tsplus_module_3 from "@effect/core/stream/Channel/operations/zipRight";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/fail";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_6 from "@effect/core/stream/Channel/operations/readWith";
/**
 * @tsplus fluent ets/Channel contramapEffect
 */

export function contramapEffect_(self, f) {
  return tsplus_module_1.pipeTo_(contramapMReader(f), () => self);
}
/**
 * @tsplus static ets/Channel/Aspects contramapEffect
 */

export const contramapEffect = f => self => contramapEffect_(self, f);

function contramapMReader(f) {
  return tsplus_module_6.readWith(inElem => tsplus_module_3.zipRight_(tsplus_module_2.write(() => inElem), () => contramapMReader(f)), inErr => tsplus_module_4.fail(() => inErr), inDone => tsplus_module_5.fromEffect(() => f(inDone)));
}
//# sourceMappingURL=contramapEffect.mjs.map