"use strict";
/**
 *  ProgramFactory
 *
 *  Copyright (C) 2010-2020 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
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
     */
    function ProgramFactory(programMaker, bucketMaker) {
        this.programMaker = programMaker;
        this.bucketMaker = bucketMaker;
    }
    /**
     * Create a new program
     *
  
     * @param bucket_data - base bucket data
     *
     * @return a program and bucket
     */
    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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHJvZ3JhbUZhY3RvcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJQcm9ncmFtRmFjdG9yeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FtQkc7OztBQUtILDJEQUFxRTtBQUVyRTs7R0FFRztBQUNIO0lBQ0U7Ozs7O09BS0c7SUFDSCx3QkFDbUIsWUFBMkIsRUFDM0IsV0FBa0M7UUFEbEMsaUJBQVksR0FBWixZQUFZLENBQWU7UUFDM0IsZ0JBQVcsR0FBWCxXQUFXLENBQXVCO0lBQ2xELENBQUM7SUFFSjs7Ozs7OztPQU9HO0lBQ0ksc0NBQWEsR0FBcEIsVUFDRSxXQUE4QjtRQUE5Qiw0QkFBQSxFQUFBLGdCQUE4QjtRQUU5QixJQUFNLE9BQU8sR0FBRyxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUM7UUFDcEMsSUFBTSxNQUFNLEdBQUcsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDLFNBQVMsQ0FDekMsNEJBQW1CLENBQUMsT0FBTyxDQUFDLENBQUMsV0FBVyxDQUFDLEVBQUUsQ0FDNUMsQ0FBQztRQUVGLE9BQU8sQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBRWpDLE9BQU8sRUFBQyxNQUFNLFFBQUEsRUFBRSxPQUFPLFNBQUEsRUFBQyxDQUFDO0lBQzNCLENBQUM7SUFDSCxxQkFBQztBQUFELENBQUMsQUFoQ0QsSUFnQ0M7QUFoQ1ksd0NBQWMifQ==