"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ensure_rehearsal_1 = require("./ensure-rehearsal");
const chain_stubbing_1 = require("./chain-stubbing");
const add_implied_callback_arg_if_necessary_1 = require("./add-implied-callback-arg-if-necessary");
const call_log_1 = require("../value/call-log");
const stubbing_register_1 = require("../value/stubbing-register");
const stubbing_1 = require("../value/stubbing");
exports.default = (__rehearseInvocationHere__, options) => {
    const rehearsal = call_log_1.default.instance.pop();
    ensure_rehearsal_1.default(rehearsal);
    return chain_stubbing_1.default(rehearsal.double, (type, outcomes) => {
        stubbing_register_1.default.instance.add(rehearsal.double, new stubbing_1.default(type, add_implied_callback_arg_if_necessary_1.default(type, rehearsal.call.args), outcomes, options));
    });
};
