// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { MailBroadcastReceipt, MailBroadcastReceiptT } from '../diplomail/mail-broadcast-receipt.js';


export class BroadcastResponse implements flatbuffers.IUnpackableObject<BroadcastResponseT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):BroadcastResponse {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsBroadcastResponse(bb:flatbuffers.ByteBuffer, obj?:BroadcastResponse):BroadcastResponse {
  return (obj || new BroadcastResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsBroadcastResponse(bb:flatbuffers.ByteBuffer, obj?:BroadcastResponse):BroadcastResponse {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new BroadcastResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

receipt(obj?:MailBroadcastReceipt):MailBroadcastReceipt|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new MailBroadcastReceipt()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

static startBroadcastResponse(builder:flatbuffers.Builder) {
  builder.startObject(1);
}

static addReceipt(builder:flatbuffers.Builder, receiptOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, receiptOffset, 0);
}

static endBroadcastResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createBroadcastResponse(builder:flatbuffers.Builder, receiptOffset:flatbuffers.Offset):flatbuffers.Offset {
  BroadcastResponse.startBroadcastResponse(builder);
  BroadcastResponse.addReceipt(builder, receiptOffset);
  return BroadcastResponse.endBroadcastResponse(builder);
}

unpack(): BroadcastResponseT {
  return new BroadcastResponseT(
    (this.receipt() !== null ? this.receipt()!.unpack() : null)
  );
}


unpackTo(_o: BroadcastResponseT): void {
  _o.receipt = (this.receipt() !== null ? this.receipt()!.unpack() : null);
}
}

export class BroadcastResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public receipt: MailBroadcastReceiptT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const receipt = (this.receipt !== null ? this.receipt!.pack(builder) : 0);

  return BroadcastResponse.createBroadcastResponse(builder,
    receipt
  );
}
}
