"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    ServerPublicController: function() {
        return ServerPublicController;
    },
    default: function() {
        return _default;
    }
});
const _awilixexpress = require("awilix-express");
const _serverconstants = require("../server.constants");
const _envutils = require("../utils/env.utils");
const _authenticate = require("../middleware/authenticate");
const _authorizationconstants = require("../constants/authorization.constants");
const _isdocker = require("../utils/is-docker");
class ServerPublicController {
    serverVersion;
    settingsStore;
    printerSocketStore;
    serverReleaseService;
    monsterPiService;
    userService;
    roleService;
    isTypeormMode;
    constructor({ settingsStore, printerSocketStore, serverVersion, serverReleaseService, monsterPiService, userService, roleService, isTypeormMode }){
        this.settingsStore = settingsStore;
        this.serverVersion = serverVersion;
        this.printerSocketStore = printerSocketStore;
        this.serverReleaseService = serverReleaseService;
        this.monsterPiService = monsterPiService;
        this.userService = userService;
        this.roleService = roleService;
        this.isTypeormMode = isTypeormMode;
    }
    welcome(req, res) {
        const serverSettings = this.settingsStore.getSettings();
        if (!this.settingsStore.getLoginRequired()) {
            return res.send({
                message: "Login disabled. Please load the Vue app."
            });
        }
        return res.send({
            message: "Login required. Please load the Vue app."
        });
    }
    getFeatures(req, res) {
        const serverSettings = this.settingsStore.getServerSettings();
        const moonrakerEnabled = serverSettings.experimentalMoonrakerSupport;
        res.send({
            batchReprintCalls: {
                available: true,
                version: 2
            },
            batchConnectSocketCalls: {
                available: true,
                version: 1
            },
            batchConnectUsbCalls: {
                available: true,
                version: 1
            },
            newSockets: {
                available: true,
                version: 1
            },
            anonymousDiagnosticsToggle: {
                available: true,
                version: 1
            },
            pauseResumePrinterCommand: {
                available: true,
                version: 1
            },
            logDumpZip: {
                available: true,
                version: 1
            },
            clearLogFiles: {
                available: true,
                version: 1
            },
            batchTogglePrinterEnabled: {
                available: true,
                version: 1
            },
            cameraStream: {
                available: true,
                version: 1,
                subFeatures: {}
            },
            printerGroupsApi: {
                available: this.isTypeormMode,
                version: 1,
                subFeatures: {}
            },
            printerControlApi: {
                available: true,
                version: 1
            },
            githubRateLimitApi: {
                available: true,
                version: 1
            },
            multiplePrinterServices: {
                available: true,
                version: 1,
                subFeatures: {
                    types: moonrakerEnabled ? [
                        "octoprint",
                        "klipper"
                    ] : [
                        "octoprint"
                    ]
                }
            }
        });
    }
    async getVersion(req, res) {
        let updateState = this.serverReleaseService.getState();
        const monsterPiVersion = this.monsterPiService.getMonsterPiVersionSafe();
        res.json({
            version: this.serverVersion,
            isDockerContainer: (0, _isdocker.isDocker)(),
            isNodemon: (0, _envutils.isNodemon)(),
            isNode: (0, _envutils.isNode)(),
            isPm2: (0, _envutils.isPm2)(),
            os: process.env.OS,
            monsterPi: monsterPiVersion,
            update: {
                synced: updateState.synced,
                updateAvailable: updateState.updateAvailable,
                airGapped: updateState.airGapped
            }
        });
    }
    async test(req, res) {
        res.send({
            message: "Test successful. Please load the Vue app."
        });
    }
}
const _default = (0, _awilixexpress.createController)(ServerPublicController).prefix(_serverconstants.AppConstants.apiRoute + "/").get("", "welcome", {
    before: [
        (0, _authenticate.authenticate)(),
        (0, _authenticate.authorizePermission)(_authorizationconstants.PERMS.ServerInfo.Get)
    ]
}).get("test", "test").get("features", "getFeatures", {
    before: [
        (0, _authenticate.authenticate)()
    ]
}).get("version", "getVersion", {
    before: [
        (0, _authenticate.authenticate)(),
        (0, _authenticate.authorizePermission)(_authorizationconstants.PERMS.ServerInfo.Get)
    ]
});

//# sourceMappingURL=server-public.controller.js.map