"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var all_models_1 = require("../all-models");
var enum_converter_1 = require("../converter/enum-converter");
var TargetProtocolListConverter = /** @class */ (function () {
    function TargetProtocolListConverter(converter) {
        if (converter === void 0) { converter = new enum_converter_1.EnumListConverter(1, TargetProtocolListConverter._mapping); }
        this.converter = converter;
    }
    TargetProtocolListConverter.prototype.decode = function (data) {
        return this.converter.decode(data).map(function (protocol) { return Math.log2(protocol); });
    };
    TargetProtocolListConverter.prototype.encode = function (data) {
        return this.converter.encode(data.map(function (protocol) { return 1 << protocol; }));
    };
    TargetProtocolListConverter.setupMapping = function () {
        var mapping = {};
        Object.keys(all_models_1.TargetProtocol)
            .filter(function (key) { return !isNaN(parseInt(all_models_1.TargetProtocol[key])); })
            .forEach(function (key) {
            mapping[key] = 1 << all_models_1.TargetProtocol[key];
        });
        return mapping;
    };
    TargetProtocolListConverter._mapping = TargetProtocolListConverter.setupMapping();
    return TargetProtocolListConverter;
}());
exports.TargetProtocolListConverter = TargetProtocolListConverter;
