"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function GaugeComponentAdapter(input) {
    const type = input.accessor.value('GUI_renderType', 'string');
    const { accessor, variable } = input;
    if (accessor.has("ValueMapping")) {
        let valueMappingComponent = {
            type: 'ListLayout',
            elements: []
        };
        let caseMap = {};
        let mappings = accessor.list("ValueMapping", []);
        for (let mapping of mappings) {
            let data = mapping.data.$ || {};
            let bitRange = data['GUI_bitRange'];
            let switchComponent;
            if (data['GUI_bitRange'] === undefined || data['GUI_bitRange'] === "") {
                continue;
            }
            if (!(bitRange in caseMap)) {
                switchComponent = {
                    type: "VariableValueSwitch",
                    variable: `${variable.name}`,
                    bitRange: `${data['GUI_bitRange']}`,
                    cases: []
                };
                caseMap[bitRange] = switchComponent;
                valueMappingComponent.elements.push(switchComponent);
            }
            else {
                switchComponent = caseMap[bitRange];
            }
            switchComponent.cases.push({
                condition: `${data['GUI_value']}`,
                content: {
                    variable: `${variable.name}`,
                    type: 'TapVariableContext',
                    content: data['GUI_content']
                }
            });
        }
        return valueMappingComponent;
    }
    return undefined;
}
exports.default = GaugeComponentAdapter;
//# sourceMappingURL=ValueMappingAdapter.js.map