"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeWrappedDataFromQueue = exports.serializeWrappedDataFromQueue = exports.cWrappedDataFromQueueVersion = exports.cWrappedDataFromQueueBinaryVersion = void 0;
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
const WrappedData_1 = require("./WrappedData");
exports.cWrappedDataFromQueueBinaryVersion = 1;
exports.cWrappedDataFromQueueVersion = 1;
function serializeWrappedDataFromQueue(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cWrappedDataFromQueue);
    }
    stream.writeUInt8(exports.cWrappedDataFromQueueVersion);
    (0, WrappedData_1.serializeWrappedData)(stream, obj);
    stream.writeUInt8(obj.seenInQueue ? 1 : 0);
}
exports.serializeWrappedDataFromQueue = serializeWrappedDataFromQueue;
function deserializeWrappedDataFromQueue(stream) {
    const version = stream.readUInt8();
    if (version > exports.cWrappedDataFromQueueBinaryVersion) {
        throw new Error('WrappedDataFromQueue version mismatch');
    }
    const wrappedData = (0, WrappedData_1.deserializeWrappedData)(stream);
    return {
        ...wrappedData,
        seenInQueue: stream.readUInt8() === 1,
    };
}
exports.deserializeWrappedDataFromQueue = deserializeWrappedDataFromQueue;
//# sourceMappingURL=WrappedDataFromQueue.js.map