// 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';
import { MailMessage, MailMessageT } from '../diplomail/mail-message.js';


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

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

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

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

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

static startAdminResponse(builder:flatbuffers.Builder) {
  builder.startObject(2);
}

static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, messageOffset, 0);
}

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

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


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


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

export class AdminResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public message: MailMessageT|null = null,
  public receipt: MailBroadcastReceiptT|null = null
){}


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

  AdminResponse.startAdminResponse(builder);
  AdminResponse.addMessage(builder, message);
  AdminResponse.addReceipt(builder, receipt);

  return AdminResponse.endAdminResponse(builder);
}
}
