"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetStatsResponseT = exports.GetStatsResponse = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
const flatbuffers = require("flatbuffers");
const stats_1 = require("../../fbs/rtp-stream/stats");
class GetStatsResponse {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsGetStatsResponse(bb, obj) {
        return (obj || new GetStatsResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsGetStatsResponse(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new GetStatsResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    stats(index, obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new stats_1.Stats()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
    }
    statsLength() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    static startGetStatsResponse(builder) {
        builder.startObject(1);
    }
    static addStats(builder, statsOffset) {
        builder.addFieldOffset(0, statsOffset, 0);
    }
    static createStatsVector(builder, data) {
        builder.startVector(4, data.length, 4);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addOffset(data[i]);
        }
        return builder.endVector();
    }
    static startStatsVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static endGetStatsResponse(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // stats
        return offset;
    }
    static createGetStatsResponse(builder, statsOffset) {
        GetStatsResponse.startGetStatsResponse(builder);
        GetStatsResponse.addStats(builder, statsOffset);
        return GetStatsResponse.endGetStatsResponse(builder);
    }
    unpack() {
        return new GetStatsResponseT(this.bb.createObjList(this.stats.bind(this), this.statsLength()));
    }
    unpackTo(_o) {
        _o.stats = this.bb.createObjList(this.stats.bind(this), this.statsLength());
    }
}
exports.GetStatsResponse = GetStatsResponse;
class GetStatsResponseT {
    stats;
    constructor(stats = []) {
        this.stats = stats;
    }
    pack(builder) {
        const stats = GetStatsResponse.createStatsVector(builder, builder.createObjectOffsetList(this.stats));
        return GetStatsResponse.createGetStatsResponse(builder, stats);
    }
}
exports.GetStatsResponseT = GetStatsResponseT;
