"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraceNotificationT = exports.TraceNotification = 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 trace_direction_1 = require("../../fbs/common/trace-direction");
const trace_event_type_1 = require("../../fbs/producer/trace-event-type");
const trace_info_1 = require("../../fbs/producer/trace-info");
class TraceNotification {
    bb = null;
    bb_pos = 0;
    __init(i, bb) {
        this.bb_pos = i;
        this.bb = bb;
        return this;
    }
    static getRootAsTraceNotification(bb, obj) {
        return (obj || new TraceNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    static getSizePrefixedRootAsTraceNotification(bb, obj) {
        bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
        return (obj || new TraceNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    }
    type() {
        const offset = this.bb.__offset(this.bb_pos, 4);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : trace_event_type_1.TraceEventType.KEYFRAME;
    }
    timestamp() {
        const offset = this.bb.__offset(this.bb_pos, 6);
        return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
    }
    direction() {
        const offset = this.bb.__offset(this.bb_pos, 8);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : trace_direction_1.TraceDirection.DIRECTION_IN;
    }
    infoType() {
        const offset = this.bb.__offset(this.bb_pos, 10);
        return offset ? this.bb.readUint8(this.bb_pos + offset) : trace_info_1.TraceInfo.NONE;
    }
    info(obj) {
        const offset = this.bb.__offset(this.bb_pos, 12);
        return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
    }
    static startTraceNotification(builder) {
        builder.startObject(5);
    }
    static addType(builder, type) {
        builder.addFieldInt8(0, type, trace_event_type_1.TraceEventType.KEYFRAME);
    }
    static addTimestamp(builder, timestamp) {
        builder.addFieldInt64(1, timestamp, BigInt('0'));
    }
    static addDirection(builder, direction) {
        builder.addFieldInt8(2, direction, trace_direction_1.TraceDirection.DIRECTION_IN);
    }
    static addInfoType(builder, infoType) {
        builder.addFieldInt8(3, infoType, trace_info_1.TraceInfo.NONE);
    }
    static addInfo(builder, infoOffset) {
        builder.addFieldOffset(4, infoOffset, 0);
    }
    static endTraceNotification(builder) {
        const offset = builder.endObject();
        return offset;
    }
    static createTraceNotification(builder, type, timestamp, direction, infoType, infoOffset) {
        TraceNotification.startTraceNotification(builder);
        TraceNotification.addType(builder, type);
        TraceNotification.addTimestamp(builder, timestamp);
        TraceNotification.addDirection(builder, direction);
        TraceNotification.addInfoType(builder, infoType);
        TraceNotification.addInfo(builder, infoOffset);
        return TraceNotification.endTraceNotification(builder);
    }
    unpack() {
        return new TraceNotificationT(this.type(), this.timestamp(), this.direction(), this.infoType(), (() => {
            const temp = (0, trace_info_1.unionToTraceInfo)(this.infoType(), this.info.bind(this));
            if (temp === null) {
                return null;
            }
            return temp.unpack();
        })());
    }
    unpackTo(_o) {
        _o.type = this.type();
        _o.timestamp = this.timestamp();
        _o.direction = this.direction();
        _o.infoType = this.infoType();
        _o.info = (() => {
            const temp = (0, trace_info_1.unionToTraceInfo)(this.infoType(), this.info.bind(this));
            if (temp === null) {
                return null;
            }
            return temp.unpack();
        })();
    }
}
exports.TraceNotification = TraceNotification;
class TraceNotificationT {
    type;
    timestamp;
    direction;
    infoType;
    info;
    constructor(type = trace_event_type_1.TraceEventType.KEYFRAME, timestamp = BigInt('0'), direction = trace_direction_1.TraceDirection.DIRECTION_IN, infoType = trace_info_1.TraceInfo.NONE, info = null) {
        this.type = type;
        this.timestamp = timestamp;
        this.direction = direction;
        this.infoType = infoType;
        this.info = info;
    }
    pack(builder) {
        const info = builder.createObjectOffset(this.info);
        return TraceNotification.createTraceNotification(builder, this.type, this.timestamp, this.direction, this.infoType, info);
    }
}
exports.TraceNotificationT = TraceNotificationT;
