"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeGetAccountDataWithQueueHintsResp = serializeGetAccountDataWithQueueHintsResp;
exports.deserializeGetAccountDataWithQueueHintsResp = deserializeGetAccountDataWithQueueHintsResp;
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
const WrappedDataFromQueue_1 = require("./WrappedDataFromQueue");
const cGetAccountDataWithQueueHintsRespVersion = 1;
function serializeGetAccountDataWithQueueHintsResp(stream, obj, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cGetAccountDataWithQueueHintsResp);
    }
    stream.writeUInt8(cGetAccountDataWithQueueHintsRespVersion);
    if (obj.accountData !== null) {
        stream.writeUInt8(1);
        stream.writeUInt16(obj.accountData.length);
        for (const item of obj.accountData) {
            (0, WrappedDataFromQueue_1.serializeWrappedDataFromQueue)(stream, item);
        }
    }
    else {
        stream.writeUInt8(0);
    }
}
function deserializeGetAccountDataWithQueueHintsResp(stream) {
    const version = stream.readUInt8();
    if (version > cGetAccountDataWithQueueHintsRespVersion) {
        throw new Error('GetAccountDataWithQueueHintsResp version mismatch');
    }
    const accountDataPresent = stream.readUInt8();
    let accountData = null;
    if (accountDataPresent === 1) {
        const length = stream.readUInt16();
        accountData = [];
        for (let i = 0; i < length; i++) {
            accountData.push((0, WrappedDataFromQueue_1.deserializeWrappedDataFromQueue)(stream)); // Deserialize each WrappedDataFromQueueBinary
        }
    }
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.GetAccountDataWithQueueHintsResp, { accountData });
    if (errors && errors.length > 0) {
        throw new Error('Data validation error');
    }
    return {
        accountData,
    };
}
//# sourceMappingURL=GetAccountDataWithQueueHintsResp.js.map