import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/suspendSucceed";
import { IGetForkScope, IOverrideForkScope } from "@effect/core/io/Effect/definition/primitives";
/**
 * Transplants specified effects so that when those effects fork other
 * effects, the forked effects will be governed by the scope of the fiber that
 * executes this effect.
 *
 * This can be used to "graft" deep grandchildren onto a higher-level scope,
 * effectively extending their lifespans into the parent scope.
 *
 * @tsplus static ets/Effect/Ops transplant
 */

export function transplant(f, __tsplusTrace) {
  return tsplus_module_2.suspendSucceed(() => new IGetForkScope(scope => f((effect, __tsplusTrace) => tsplus_module_2.suspendSucceed(() => new IOverrideForkScope(effect(), tsplus_module_1.some(scope), __tsplusTrace), __tsplusTrace))), __tsplusTrace);
}
//# sourceMappingURL=transplant.mjs.map