// 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 { AccountView, AccountViewT } from '../user/account-view.js';


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

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

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

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

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

static addAccount(builder:flatbuffers.Builder, accountOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, accountOffset, 0);
}

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

static finishAccountResponseBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
  builder.finish(offset);
}

static finishSizePrefixedAccountResponseBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
  builder.finish(offset, undefined, true);
}

static createAccountResponse(builder:flatbuffers.Builder, accountOffset:flatbuffers.Offset):flatbuffers.Offset {
  AccountResponse.startAccountResponse(builder);
  AccountResponse.addAccount(builder, accountOffset);
  return AccountResponse.endAccountResponse(builder);
}

unpack(): AccountResponseT {
  return new AccountResponseT(
    (this.account() !== null ? this.account()!.unpack() : null)
  );
}


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

export class AccountResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public account: AccountViewT|null = null
){}


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

  return AccountResponse.createAccountResponse(builder,
    account
  );
}
}
