import { innerFrom } from "../observable/innerFrom.mjs";
import { mergeMap } from "./mergeMap.mjs";
import { concat } from "../observable/concat.mjs";
import { take } from "./take.mjs";
import { ignoreElements } from "./ignoreElements.mjs";
import { mapTo } from "./mapTo.mjs";

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/delayWhen.js
function delayWhen(delayDurationSelector, subscriptionDelay) {
	if (subscriptionDelay) return function(source) {
		return concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
	};
	return mergeMap(function(value, index) {
		return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value));
	});
}

//#endregion
export { delayWhen };
//# sourceMappingURL=delayWhen.mjs.map