"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.DumpResponseT = exports.DumpResponse = 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 dump_1 = require("../../fbs/transport/dump");
const tuple_1 = require("../../fbs/transport/tuple");
const dtls_parameters_1 = require("../../fbs/web-rtc-transport/dtls-parameters");
const dtls_state_1 = require("../../fbs/web-rtc-transport/dtls-state");
const ice_candidate_1 = require("../../fbs/web-rtc-transport/ice-candidate");
const ice_parameters_1 = require("../../fbs/web-rtc-transport/ice-parameters");
const ice_role_1 = require("../../fbs/web-rtc-transport/ice-role");
const ice_state_1 = require("../../fbs/web-rtc-transport/ice-state");
class DumpResponse {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsDumpResponse(bb, obj) {
        return (obj || new DumpResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsDumpResponse(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new DumpResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    base(obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new dump_1.Dump()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    iceRole() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : ice_role_1.IceRole.CONTROLLED;
    }
    iceParameters(obj) {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? (obj || new ice_parameters_1.IceParameters()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    iceCandidates(index, obj) {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? (obj || new ice_candidate_1.IceCandidate()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
    }
    iceCandidatesLength() {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    iceState() {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : ice_state_1.IceState.NEW;
    }
    iceSelectedTuple(obj) {
        const offset = this.bb.__offset(this.bb_pos, 14);
        return offset ? (obj || new tuple_1.Tuple()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    dtlsParameters(obj) {
        const offset = this.bb.__offset(this.bb_pos, 16);
        return offset ? (obj || new dtls_parameters_1.DtlsParameters()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    dtlsState() {
        const offset = this.bb.__offset(this.bb_pos, 18);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : dtls_state_1.DtlsState.NEW;
    }
    static startDumpResponse(builder) {
        builder.startObject(8);
    }
    static addBase(builder, baseOffset) {
        builder.addFieldOffset(0, baseOffset, 0);
    }
    static addIceRole(builder, iceRole) {
        builder.addFieldInt8(1, iceRole, ice_role_1.IceRole.CONTROLLED);
    }
    static addIceParameters(builder, iceParametersOffset) {
        builder.addFieldOffset(2, iceParametersOffset, 0);
    }
    static addIceCandidates(builder, iceCandidatesOffset) {
        builder.addFieldOffset(3, iceCandidatesOffset, 0);
    }
    static createIceCandidatesVector(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 startIceCandidatesVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static addIceState(builder, iceState) {
        builder.addFieldInt8(4, iceState, ice_state_1.IceState.NEW);
    }
    static addIceSelectedTuple(builder, iceSelectedTupleOffset) {
        builder.addFieldOffset(5, iceSelectedTupleOffset, 0);
    }
    static addDtlsParameters(builder, dtlsParametersOffset) {
        builder.addFieldOffset(6, dtlsParametersOffset, 0);
    }
    static addDtlsState(builder, dtlsState) {
        builder.addFieldInt8(7, dtlsState, dtls_state_1.DtlsState.NEW);
    }
    static endDumpResponse(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // base
        builder.requiredField(offset, 8); // ice_parameters
        builder.requiredField(offset, 10); // ice_candidates
        builder.requiredField(offset, 16); // dtls_parameters
        return offset;
    }
    unpack() {
        return new DumpResponseT((this.base() !== null ? this.base().unpack() : null), this.iceRole(), (this.iceParameters() !== null ? this.iceParameters().unpack() : null), this.bb.createObjList(this.iceCandidates.bind(this), this.iceCandidatesLength()), this.iceState(), (this.iceSelectedTuple() !== null ? this.iceSelectedTuple().unpack() : null), (this.dtlsParameters() !== null ? this.dtlsParameters().unpack() : null), this.dtlsState());
    }
    unpackTo(_o) {
        _o.base = (this.base() !== null ? this.base().unpack() : null);
        _o.iceRole = this.iceRole();
        _o.iceParameters = (this.iceParameters() !== null ? this.iceParameters().unpack() : null);
        _o.iceCandidates = this.bb.createObjList(this.iceCandidates.bind(this), this.iceCandidatesLength());
        _o.iceState = this.iceState();
        _o.iceSelectedTuple = (this.iceSelectedTuple() !== null ? this.iceSelectedTuple().unpack() : null);
        _o.dtlsParameters = (this.dtlsParameters() !== null ? this.dtlsParameters().unpack() : null);
        _o.dtlsState = this.dtlsState();
    }
}
exports.DumpResponse = DumpResponse;
class DumpResponseT {
    base;
    iceRole;
    iceParameters;
    iceCandidates;
    iceState;
    iceSelectedTuple;
    dtlsParameters;
    dtlsState;
    constructor(base = null, iceRole = ice_role_1.IceRole.CONTROLLED, iceParameters = null, iceCandidates = [], iceState = ice_state_1.IceState.NEW, iceSelectedTuple = null, dtlsParameters = null, dtlsState = dtls_state_1.DtlsState.NEW) {
        this.base = base;
        this.iceRole = iceRole;
        this.iceParameters = iceParameters;
        this.iceCandidates = iceCandidates;
        this.iceState = iceState;
        this.iceSelectedTuple = iceSelectedTuple;
        this.dtlsParameters = dtlsParameters;
        this.dtlsState = dtlsState;
    }
    pack(builder) {
        const base = (this.base !== null ? this.base.pack(builder) : 0);
        const iceParameters = (this.iceParameters !== null ? this.iceParameters.pack(builder) : 0);
        const iceCandidates = DumpResponse.createIceCandidatesVector(builder, builder.createObjectOffsetList(this.iceCandidates));
        const iceSelectedTuple = (this.iceSelectedTuple !== null ? this.iceSelectedTuple.pack(builder) : 0);
        const dtlsParameters = (this.dtlsParameters !== null ? this.dtlsParameters.pack(builder) : 0);
        DumpResponse.startDumpResponse(builder);
        DumpResponse.addBase(builder, base);
        DumpResponse.addIceRole(builder, this.iceRole);
        DumpResponse.addIceParameters(builder, iceParameters);
        DumpResponse.addIceCandidates(builder, iceCandidates);
        DumpResponse.addIceState(builder, this.iceState);
        DumpResponse.addIceSelectedTuple(builder, iceSelectedTuple);
        DumpResponse.addDtlsParameters(builder, dtlsParameters);
        DumpResponse.addDtlsState(builder, this.dtlsState);
        return DumpResponse.endDumpResponse(builder);
    }
}
exports.DumpResponseT = DumpResponseT;
