"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsumerScoreT = exports.ConsumerScore = void 0;
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
const flatbuffers = require("flatbuffers");
class ConsumerScore {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsConsumerScore(bb, obj) {
        return (obj || new ConsumerScore()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsConsumerScore(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new ConsumerScore()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    score() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
    }
    producerScore() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : 0;
    }
    producerScores(index) {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
    }
    producerScoresLength() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    producerScoresArray() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
    }
    static startConsumerScore(builder) {
        builder.startObject(3);
    }
    static addScore(builder, score) {
        builder.addFieldInt8(0, score, 0);
    }
    static addProducerScore(builder, producerScore) {
        builder.addFieldInt8(1, producerScore, 0);
    }
    static addProducerScores(builder, producerScoresOffset) {
        builder.addFieldOffset(2, producerScoresOffset, 0);
    }
    static createProducerScoresVector(builder, data) {
        builder.startVector(1, data.length, 1);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addInt8(data[i]);
        }
        return builder.endVector();
    }
    static startProducerScoresVector(builder, numElems) {
        builder.startVector(1, numElems, 1);
    }
    static endConsumerScore(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 8); // producer_scores
        return offset;
    }
    static createConsumerScore(builder, score, producerScore, producerScoresOffset) {
        ConsumerScore.startConsumerScore(builder);
        ConsumerScore.addScore(builder, score);
        ConsumerScore.addProducerScore(builder, producerScore);
        ConsumerScore.addProducerScores(builder, producerScoresOffset);
        return ConsumerScore.endConsumerScore(builder);
    }
    unpack() {
        return new ConsumerScoreT(this.score(), this.producerScore(), this.bb.createScalarList(this.producerScores.bind(this), this.producerScoresLength()));
    }
    unpackTo(_o) {
        _o.score = this.score();
        _o.producerScore = this.producerScore();
        _o.producerScores = this.bb.createScalarList(this.producerScores.bind(this), this.producerScoresLength());
    }
}
exports.ConsumerScore = ConsumerScore;
class ConsumerScoreT {
    score;
    producerScore;
    producerScores;
    constructor(score = 0, producerScore = 0, producerScores = []) {
        this.score = score;
        this.producerScore = producerScore;
        this.producerScores = producerScores;
    }
    pack(builder) {
        const producerScores = ConsumerScore.createProducerScoresVector(builder, this.producerScores);
        return ConsumerScore.createConsumerScore(builder, this.score, this.producerScore, producerScores);
    }
}
exports.ConsumerScoreT = ConsumerScoreT;
