"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "PrinterApiFactory", {
    enumerable: true,
    get: function() {
        return PrinterApiFactory;
    }
});
const _printerapiinterface = require("./printer-api.interface");
const _containertokens = require("../container.tokens");
class PrinterApiFactory {
    cradleService;
    constructor(cradleService){
        this.cradleService = cradleService;
    }
    getById(id) {
        const printerCache = this.cradleService.resolve(_containertokens.DITokens.printerCache);
        const login = printerCache.getLoginDto(id);
        const printerApi = this.getScopedPrinter(login);
        if (login.printerType === _printerapiinterface.BambuType && "setPrinterId" in printerApi) {
            printerApi.setPrinterId(id);
        }
        return printerApi;
    }
    getScopedPrinter(login) {
        let printerApi;
        if (login.printerType === _printerapiinterface.OctoprintType) {
            printerApi = this.cradleService.resolve(_containertokens.DITokens.octoprintApi);
        } else if (login.printerType === _printerapiinterface.MoonrakerType) {
            printerApi = this.cradleService.resolve(_containertokens.DITokens.moonrakerApi);
        } else if (login.printerType === _printerapiinterface.PrusaLinkType) {
            printerApi = this.cradleService.resolve(_containertokens.DITokens.prusaLinkApi);
        } else if (login.printerType === _printerapiinterface.BambuType) {
            printerApi = this.cradleService.resolve(_containertokens.DITokens.bambuApi);
        } else {
            throw new Error("PrinterType is unknown, cant pick the right socket adapter");
        }
        printerApi.login = login;
        return printerApi;
    }
}

//# sourceMappingURL=printer-api.factory.js.map