"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.DtlsParametersT = exports.DtlsParameters = 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 dtls_role_1 = require("../../fbs/web-rtc-transport/dtls-role");
const fingerprint_1 = require("../../fbs/web-rtc-transport/fingerprint");
class DtlsParameters {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsDtlsParameters(bb, obj) {
        return (obj || new DtlsParameters()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsDtlsParameters(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new DtlsParameters()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    fingerprints(index, obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new fingerprint_1.Fingerprint()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
    }
    fingerprintsLength() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    role() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : dtls_role_1.DtlsRole.AUTO;
    }
    static startDtlsParameters(builder) {
        builder.startObject(2);
    }
    static addFingerprints(builder, fingerprintsOffset) {
        builder.addFieldOffset(0, fingerprintsOffset, 0);
    }
    static createFingerprintsVector(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 startFingerprintsVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static addRole(builder, role) {
        builder.addFieldInt8(1, role, dtls_role_1.DtlsRole.AUTO);
    }
    static endDtlsParameters(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // fingerprints
        return offset;
    }
    static createDtlsParameters(builder, fingerprintsOffset, role) {
        DtlsParameters.startDtlsParameters(builder);
        DtlsParameters.addFingerprints(builder, fingerprintsOffset);
        DtlsParameters.addRole(builder, role);
        return DtlsParameters.endDtlsParameters(builder);
    }
    unpack() {
        return new DtlsParametersT(this.bb.createObjList(this.fingerprints.bind(this), this.fingerprintsLength()), this.role());
    }
    unpackTo(_o) {
        _o.fingerprints = this.bb.createObjList(this.fingerprints.bind(this), this.fingerprintsLength());
        _o.role = this.role();
    }
}
exports.DtlsParameters = DtlsParameters;
class DtlsParametersT {
    fingerprints;
    role;
    constructor(fingerprints = [], role = dtls_role_1.DtlsRole.AUTO) {
        this.fingerprints = fingerprints;
        this.role = role;
    }
    pack(builder) {
        const fingerprints = DtlsParameters.createFingerprintsVector(builder, builder.createObjectOffsetList(this.fingerprints));
        return DtlsParameters.createDtlsParameters(builder, fingerprints, this.role);
    }
}
exports.DtlsParametersT = DtlsParametersT;
