"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.VolumesNotificationT = exports.VolumesNotification = 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 volume_1 = require("../../fbs/audio-level-observer/volume");
class VolumesNotification {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsVolumesNotification(bb, obj) {
        return (obj || new VolumesNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsVolumesNotification(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new VolumesNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    volumes(index, obj) {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? (obj || new volume_1.Volume()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
    }
    volumesLength() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
    }
    static startVolumesNotification(builder) {
        builder.startObject(1);
    }
    static addVolumes(builder, volumesOffset) {
        builder.addFieldOffset(0, volumesOffset, 0);
    }
    static createVolumesVector(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 startVolumesVector(builder, numElems) {
        builder.startVector(4, numElems, 4);
    }
    static endVolumesNotification(builder) {
        const offset = builder.endObject();
        builder.requiredField(offset, 4); // volumes
        return offset;
    }
    static createVolumesNotification(builder, volumesOffset) {
        VolumesNotification.startVolumesNotification(builder);
        VolumesNotification.addVolumes(builder, volumesOffset);
        return VolumesNotification.endVolumesNotification(builder);
    }
    unpack() {
        return new VolumesNotificationT(this.bb.createObjList(this.volumes.bind(this), this.volumesLength()));
    }
    unpackTo(_o) {
        _o.volumes = this.bb.createObjList(this.volumes.bind(this), this.volumesLength());
    }
}
exports.VolumesNotification = VolumesNotification;
class VolumesNotificationT {
    volumes;
    constructor(volumes = []) {
        this.volumes = volumes;
    }
    pack(builder) {
        const volumes = VolumesNotification.createVolumesVector(builder, builder.createObjectOffsetList(this.volumes));
        return VolumesNotification.createVolumesNotification(builder, volumes);
    }
}
exports.VolumesNotificationT = VolumesNotificationT;
