"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionsT = exports.Options = 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 num_sctp_streams_1 = require("../../fbs/sctp-parameters/num-sctp-streams");
class Options {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsOptions(bb, obj) {
        return (obj || new Options()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsOptions(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new Options()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    direct() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
    }
    /**
     * Only needed for DirectTransport. This value is handled by base Transport.
     */
    maxMessageSize() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : null;
    }
    initialAvailableOutgoingBitrate() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : null;
    }
    enableSctp() {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
    }
    numSctpStreams(obj) {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? (obj || new num_sctp_streams_1.NumSctpStreams()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    maxSctpMessageSize() {
        const offset = this.bb.__offset(this.bb_pos, 14);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
    }
    sctpSendBufferSize() {
        const offset = this.bb.__offset(this.bb_pos, 16);
        return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
    }
    isDataChannel() {
        const offset = this.bb.__offset(this.bb_pos, 18);
        return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
    }
    static startOptions(builder) {
        builder.startObject(8);
    }
    static addDirect(builder, direct) {
        builder.addFieldInt8(0, +direct, +false);
    }
    static addMaxMessageSize(builder, maxMessageSize) {
        builder.addFieldInt32(1, maxMessageSize, null);
    }
    static addInitialAvailableOutgoingBitrate(builder, initialAvailableOutgoingBitrate) {
        builder.addFieldInt32(2, initialAvailableOutgoingBitrate, null);
    }
    static addEnableSctp(builder, enableSctp) {
        builder.addFieldInt8(3, +enableSctp, +false);
    }
    static addNumSctpStreams(builder, numSctpStreamsOffset) {
        builder.addFieldOffset(4, numSctpStreamsOffset, 0);
    }
    static addMaxSctpMessageSize(builder, maxSctpMessageSize) {
        builder.addFieldInt32(5, maxSctpMessageSize, 0);
    }
    static addSctpSendBufferSize(builder, sctpSendBufferSize) {
        builder.addFieldInt32(6, sctpSendBufferSize, 0);
    }
    static addIsDataChannel(builder, isDataChannel) {
        builder.addFieldInt8(7, +isDataChannel, +false);
    }
    static endOptions(builder) {
        const offset = builder.endObject();
        return offset;
    }
    unpack() {
        return new OptionsT(this.direct(), this.maxMessageSize(), this.initialAvailableOutgoingBitrate(), this.enableSctp(), (this.numSctpStreams() !== null ? this.numSctpStreams().unpack() : null), this.maxSctpMessageSize(), this.sctpSendBufferSize(), this.isDataChannel());
    }
    unpackTo(_o) {
        _o.direct = this.direct();
        _o.maxMessageSize = this.maxMessageSize();
        _o.initialAvailableOutgoingBitrate = this.initialAvailableOutgoingBitrate();
        _o.enableSctp = this.enableSctp();
        _o.numSctpStreams = (this.numSctpStreams() !== null ? this.numSctpStreams().unpack() : null);
        _o.maxSctpMessageSize = this.maxSctpMessageSize();
        _o.sctpSendBufferSize = this.sctpSendBufferSize();
        _o.isDataChannel = this.isDataChannel();
    }
}
exports.Options = Options;
class OptionsT {
    direct;
    maxMessageSize;
    initialAvailableOutgoingBitrate;
    enableSctp;
    numSctpStreams;
    maxSctpMessageSize;
    sctpSendBufferSize;
    isDataChannel;
    constructor(direct = false, maxMessageSize = null, initialAvailableOutgoingBitrate = null, enableSctp = false, numSctpStreams = null, maxSctpMessageSize = 0, sctpSendBufferSize = 0, isDataChannel = false) {
        this.direct = direct;
        this.maxMessageSize = maxMessageSize;
        this.initialAvailableOutgoingBitrate = initialAvailableOutgoingBitrate;
        this.enableSctp = enableSctp;
        this.numSctpStreams = numSctpStreams;
        this.maxSctpMessageSize = maxSctpMessageSize;
        this.sctpSendBufferSize = sctpSendBufferSize;
        this.isDataChannel = isDataChannel;
    }
    pack(builder) {
        const numSctpStreams = (this.numSctpStreams !== null ? this.numSctpStreams.pack(builder) : 0);
        Options.startOptions(builder);
        Options.addDirect(builder, this.direct);
        if (this.maxMessageSize !== null)
            Options.addMaxMessageSize(builder, this.maxMessageSize);
        if (this.initialAvailableOutgoingBitrate !== null)
            Options.addInitialAvailableOutgoingBitrate(builder, this.initialAvailableOutgoingBitrate);
        Options.addEnableSctp(builder, this.enableSctp);
        Options.addNumSctpStreams(builder, numSctpStreams);
        Options.addMaxSctpMessageSize(builder, this.maxSctpMessageSize);
        Options.addSctpSendBufferSize(builder, this.sctpSendBufferSize);
        Options.addIsDataChannel(builder, this.isDataChannel);
        return Options.endOptions(builder);
    }
}
exports.OptionsT = OptionsT;
