"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleManagementRequests = handleManagementRequests;
const managementCommands_1 = require("./managementCommands");
function handleManagementRequests(onCommand, dispatch, frontApplet) {
    onCommand(async (commandEvent) => {
        switch (commandEvent.command.type) {
            case managementCommands_1.ManagementSupportsRequest:
                await dispatch({
                    type: managementCommands_1.ManagementSupportsResult,
                    supports: await frontApplet.management.supports(commandEvent.command.capability),
                });
                break;
            case managementCommands_1.ManagementGetModelRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetModelResult,
                    model: await frontApplet.management.getModel(),
                });
                break;
            case managementCommands_1.ManagementGetSerialNumberRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetSerialNumberResult,
                    serialNumber: await frontApplet.management.getSerialNumber(),
                });
                break;
            case managementCommands_1.ManagementGetTemperatureRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetTemperatureResult,
                    temperature: await frontApplet.management.getTemperature(),
                });
                break;
            case managementCommands_1.ManagementGetBrandRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetBrandResult,
                    brand: await frontApplet.management.getBrand(),
                });
                break;
            case managementCommands_1.ManagementGetBatteryStatusRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetBatteryStatusResult,
                    status: await frontApplet.management.getBatteryStatus(),
                });
                break;
            case managementCommands_1.ManagementResetSettingsRequest:
                await frontApplet.management.resetSettings();
                await dispatch({
                    type: managementCommands_1.ManagementResetSettingsResult,
                    result: {},
                });
                break;
            case managementCommands_1.ManagementFactoryResetRequest:
                await frontApplet.management.factoryReset();
                await dispatch({
                    type: managementCommands_1.ManagementFactoryResetResult,
                    result: {},
                });
                break;
            case managementCommands_1.ManagementGetExtendedManagementUrlRequest:
                await dispatch({
                    type: managementCommands_1.ManagementGetExtendedManagementUrlResult,
                    result: await frontApplet.management.getExtendedManagementUrl(),
                });
                break;
            case managementCommands_1.ManagementSetExtendedManagementUrlRequest:
                await frontApplet.management.setExtendedManagementUrl(commandEvent.command.url);
                await dispatch({
                    type: managementCommands_1.ManagementSetExtendedManagementUrlResult,
                    result: {},
                });
                break;
            default:
        }
    });
}
//# sourceMappingURL=handleManagementRequests.js.map