"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgramFactory = void 0;
var loader_1 = require("../../../src/server/quote/loader");
/**
 * Generates a new program on demand
 */
var ProgramFactory = /** @class */ (function () {
    /**
     * Create a new ProgramFactory
     *
     * @param programMaker     - creates a program
     * @param bucketMaker      - creates a bucket
     * @param programInitMaker - inits a program
  
     */
    function ProgramFactory(programMaker, bucketMaker) {
        this.programMaker = programMaker;
        this.bucketMaker = bucketMaker;
    }
    /**
     * Create a new program
     *
     * @return a new program
     */
    ProgramFactory.prototype.createProgram = function (bucket_data) {
        if (bucket_data === void 0) { bucket_data = {}; }
        var program = this.programMaker();
        var bucket = (this.bucketMaker().setValues(loader_1.applyBucketDefaults(program)(bucket_data)()));
        program.initQuote(bucket, false);
        return { bucket: bucket, program: program };
    };
    return ProgramFactory;
}());
exports.ProgramFactory = ProgramFactory;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHJvZ3JhbUZhY3RvcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJQcm9ncmFtRmFjdG9yeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFHQSwyREFBcUU7QUFZckU7O0dBRUc7QUFDSDtJQUNFOzs7Ozs7O09BT0c7SUFDSCx3QkFDbUIsWUFBMkIsRUFDM0IsV0FBa0M7UUFEbEMsaUJBQVksR0FBWixZQUFZLENBQWU7UUFDM0IsZ0JBQVcsR0FBWCxXQUFXLENBQXVCO0lBQ2xELENBQUM7SUFFSjs7OztPQUlHO0lBQ0ksc0NBQWEsR0FBcEIsVUFDRSxXQUE4QjtRQUE5Qiw0QkFBQSxFQUFBLGdCQUE4QjtRQUU5QixJQUFNLE9BQU8sR0FBRyxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUM7UUFDcEMsSUFBTSxNQUFNLEdBQWtCLENBQzVCLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQyxTQUFTLENBQUMsNEJBQW1CLENBQUMsT0FBTyxDQUFDLENBQUMsV0FBVyxDQUFDLEVBQUUsQ0FBQyxDQUMxRSxDQUFDO1FBRUYsT0FBTyxDQUFDLFNBQVMsQ0FBQyxNQUFNLEVBQUUsS0FBSyxDQUFDLENBQUM7UUFFakMsT0FBTyxFQUFDLE1BQU0sUUFBQSxFQUFFLE9BQU8sU0FBQSxFQUFDLENBQUM7SUFDM0IsQ0FBQztJQUNILHFCQUFDO0FBQUQsQ0FBQyxBQS9CRCxJQStCQztBQS9CWSx3Q0FBYyJ9