var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
/**
 *
 * @experimental
 */
export function extractTypedDataFromRecord(data, mapping, allowUndefinedKeys) {
    var e_1, _a;
    // console.log('decodeDataLogPacket', meta)
    var result = {};
    try {
        // const bundleMeta: BundleConfig | undefined = meta.find(
        for (var _b = __values(Object.keys(mapping).map(function (key) { return parseInt(key, 10); })), _c = _b.next(); !_c.done; _c = _b.next()) {
            var key = _c.value;
            if (key in data) {
                var value = data[key];
                var _d = mapping[key], name_1 = _d.name, converter = _d.converter;
                result[name_1] = converter.decode(value);
            }
            else {
                if (!allowUndefinedKeys) {
                    throw new Error("Missing variable identifier \"" + key + "\" in data");
                }
            }
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
        }
        finally { if (e_1) throw e_1.error; }
    }
    return result;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0eS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bpb3RpemUvdGFwL2RhdGEtbG9nLyIsInNvdXJjZXMiOlsibGliL3V0aWxpdHkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7QUFRQTs7O0dBR0c7QUFDSCxNQUFNLFVBQVUsMEJBQTBCLENBQ3RDLElBQTRCLEVBQzVCLE9BQTJELEVBQzNELGtCQUE2Qjs7SUFFN0IsMkNBQTJDO0lBQzNDLElBQU0sTUFBTSxHQUFnQixFQUFFLENBQUM7O1FBQy9CLDBEQUEwRDtRQUUxRCxLQUFrQixJQUFBLEtBQUEsU0FBQSxNQUFNLENBQUMs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