"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runQuirrel = void 0;
const scheduler_1 = require("./scheduler");
const logger_1 = require("./shared/logger");
const worker_1 = require("./worker");
const package_json_1 = __importDefault(require("../../package.json"));
const telemetrist_1 = require("./shared/telemetrist");
async function runQuirrel(config) {
    var _a, _b;
    const logger = (0, logger_1.getLogger)(config.logger);
    const server = await (0, scheduler_1.createServer)({ ...config, logger });
    const worker = await (0, worker_1.createWorker)({
        ...config,
        enableUsageMetering: !!((_a = config.passphrases) === null || _a === void 0 ? void 0 : _a.length),
        logger,
    });
    if (!config.disableTelemetry) {
        new telemetrist_1.Telemetrist((_b = config.runningInDocker) !== null && _b !== void 0 ? _b : false).record(`/version/${package_json_1.default.version}`);
    }
    return {
        server,
        worker,
        httpServer: server.server,
        async close() {
            await Promise.all([server.close(), worker.close()]);
        },
    };
}
exports.runQuirrel = runQuirrel;
//# sourceMappingURL=index.js.map