"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddSubchannelResponseT = exports.AddSubchannelResponse = 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 AddSubchannelResponse {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsAddSubchannelResponse(bb, obj) {
        return (obj || new AddSubchannelResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsAddSubchannelResponse(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new AddSubchannelResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    subchannels(index) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readUint16(this.bb.__vector(this.bb_pos + offset) + index * 2) : 0;
    }
    subchannelsLength() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    subchannelsArray() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? new Uint16Array(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 startAddSubchannelResponse(builder) {
        builder.startObject(1);
    }
    static addSubchannels(builder, subchannelsOffset) {
        builder.addFieldOffset(0, subchannelsOffset, 0);
    }
    static createSubchannelsVector(builder, data) {
        builder.startVector(2, data.length, 2);
        for (let i = data.length - 1; i >= 0; i--) {
            builder.addInt16(data[i]);
        }
        return builder.endVector();
    }
    static startSubchannelsVector(builder, numElems) {
        builder.startVector(2, numElems, 2);
    }
    static endAddSubchannelResponse(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // subchannels
        return offset;
    }
    static createAddSubchannelResponse(builder, subchannelsOffset) {
        AddSubchannelResponse.startAddSubchannelResponse(builder);
        AddSubchannelResponse.addSubchannels(builder, subchannelsOffset);
        return AddSubchannelResponse.endAddSubchannelResponse(builder);
    }
    unpack() {
        return new AddSubchannelResponseT(this.bb.createScalarList(this.subchannels.bind(this), this.subchannelsLength()));
    }
    unpackTo(_o) {
        _o.subchannels = this.bb.createScalarList(this.subchannels.bind(this), this.subchannelsLength());
    }
}
exports.AddSubchannelResponse = AddSubchannelResponse;
class AddSubchannelResponseT {
    subchannels;
    constructor(subchannels = []) {
        this.subchannels = subchannels;
    }
    pack(builder) {
        const subchannels = AddSubchannelResponse.createSubchannelsVector(builder, this.subchannels);
        return AddSubchannelResponse.createAddSubchannelResponse(builder, subchannels);
    }
}
exports.AddSubchannelResponseT = AddSubchannelResponseT;
