"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleManagementScreenRequests = handleManagementScreenRequests;
const screenCommands_1 = require("./screenCommands");
function handleManagementScreenRequests(onCommand, dispatch, frontApplet) {
    onCommand(async (commandEvent) => {
        switch (commandEvent.command.type) {
            case screenCommands_1.ManagementScreenResizeRequest:
                await frontApplet.management.screen.resize(commandEvent.command.baseUrl, commandEvent.command.orientation, commandEvent.command.resolution, commandEvent.command.currentVersion, commandEvent.command.videoOrientation);
                await dispatch({
                    type: screenCommands_1.ManagementScreenResizeResult,
                    result: {},
                });
                break;
            case screenCommands_1.ManagementScreenGetOrientationRequest:
                await dispatch({
                    type: screenCommands_1.ManagementScreenGetOrientationResult,
                    result: await frontApplet.management.screen.getOrientation(),
                });
                break;
            case screenCommands_1.ManagementScreenSetBrightnessRequest:
                await frontApplet.management.screen.setBrightness(commandEvent.command.timeFrom1, commandEvent.command.brightness1, commandEvent.command.timeFrom2, commandEvent.command.brightness2);
                await dispatch({
                    type: screenCommands_1.ManagementScreenSetBrightnessResult,
                    result: {},
                });
                break;
            case screenCommands_1.ManagementScreenGetBrightnessRequest:
                await dispatch({
                    type: screenCommands_1.ManagementScreenGetBrightnessResult,
                    result: await frontApplet.management.screen.getBrightness(),
                });
                break;
            case screenCommands_1.ManagementScreenTakeScreenshotRequest: {
                const data = await frontApplet.management.screen.takeAndUploadScreenshot(commandEvent.command.uploadBaseUrl, commandEvent.command.computeHash);
                await dispatch({
                    type: screenCommands_1.ManagementScreenTakeScreenshotResult,
                    screenshotUrl: data.screenshotUrl,
                    aHash: data.aHash,
                });
                break;
            }
            case screenCommands_1.ManagementScreenPowerOnRequest:
                await frontApplet.management.screen.powerOn();
                await dispatch({
                    type: screenCommands_1.ManagementScreenPowerOnResult,
                    result: {},
                });
                break;
            case screenCommands_1.ManagementScreenPowerOffRequest:
                await frontApplet.management.screen.powerOff();
                await dispatch({
                    type: screenCommands_1.ManagementScreenPowerOffResult,
                    result: {},
                });
                break;
            case screenCommands_1.ManagementScreenIsPoweredOnRequest:
                await dispatch({
                    type: screenCommands_1.ManagementScreenIsPoweredOnResult,
                    result: await frontApplet.management.screen.isPoweredOn(),
                });
                break;
            default:
        }
    });
}
//# sourceMappingURL=handleScreenRequests.js.map