"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/transport/stats");
const tuple_1 = require("../../fbs/transport/tuple");
const dtls_state_1 = require("../../fbs/web-rtc-transport/dtls-state");
const ice_role_1 = require("../../fbs/web-rtc-transport/ice-role");
const ice_state_1 = require("../../fbs/web-rtc-transport/ice-state");
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);
    }
    base(obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new stats_1.Stats()).__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;
    }
    iceState() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : ice_state_1.IceState.NEW;
    }
    iceSelectedTuple(obj) {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? (obj || new tuple_1.Tuple()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
    }
    dtlsState() {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : dtls_state_1.DtlsState.NEW;
    }
    static startGetStatsResponse(builder) {
        builder.startObject(5);
    }
    static addBase(builder, baseOffset) {
        builder.addFieldOffset(0, baseOffset, 0);
    }
    static addIceRole(builder, iceRole) {
        builder.addFieldInt8(1, iceRole, ice_role_1.IceRole.CONTROLLED);
    }
    static addIceState(builder, iceState) {
        builder.addFieldInt8(2, iceState, ice_state_1.IceState.NEW);
    }
    static addIceSelectedTuple(builder, iceSelectedTupleOffset) {
        builder.addFieldOffset(3, iceSelectedTupleOffset, 0);
    }
    static addDtlsState(builder, dtlsState) {
        builder.addFieldInt8(4, dtlsState, dtls_state_1.DtlsState.NEW);
    }
    static endGetStatsResponse(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // base
        return offset;
    }
    unpack() {
        return new GetStatsResponseT((this.base() !== null ? this.base().unpack() : null), this.iceRole(), this.iceState(), (this.iceSelectedTuple() !== null ? this.iceSelectedTuple().unpack() : null), this.dtlsState());
    }
    unpackTo(_o) {
        _o.base = (this.base() !== null ? this.base().unpack() : null);
        _o.iceRole = this.iceRole();
        _o.iceState = this.iceState();
        _o.iceSelectedTuple = (this.iceSelectedTuple() !== null ? this.iceSelectedTuple().unpack() : null);
        _o.dtlsState = this.dtlsState();
    }
}
exports.GetStatsResponse = GetStatsResponse;
class GetStatsResponseT {
    base;
    iceRole;
    iceState;
    iceSelectedTuple;
    dtlsState;
    constructor(base = null, iceRole = ice_role_1.IceRole.CONTROLLED, iceState = ice_state_1.IceState.NEW, iceSelectedTuple = null, dtlsState = dtls_state_1.DtlsState.NEW) {
        this.base = base;
        this.iceRole = iceRole;
        this.iceState = iceState;
        this.iceSelectedTuple = iceSelectedTuple;
        this.dtlsState = dtlsState;
    }
    pack(builder) {
        const base = (this.base !== null ? this.base.pack(builder) : 0);
        const iceSelectedTuple = (this.iceSelectedTuple !== null ? this.iceSelectedTuple.pack(builder) : 0);
        GetStatsResponse.startGetStatsResponse(builder);
        GetStatsResponse.addBase(builder, base);
        GetStatsResponse.addIceRole(builder, this.iceRole);
        GetStatsResponse.addIceState(builder, this.iceState);
        GetStatsResponse.addIceSelectedTuple(builder, iceSelectedTuple);
        GetStatsResponse.addDtlsState(builder, this.dtlsState);
        return GetStatsResponse.endGetStatsResponse(builder);
    }
}
exports.GetStatsResponseT = GetStatsResponseT;
