// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.5
//   protoc               v7.34.1
// source: ConfigResponse.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { ApiConfig } from "./ApiConfig.js";
import { LockAndExitConfig } from "./LockAndExitConfig.js";
import { MessageConfig } from "./MessageConfig.js";
import { OrdersConfig } from "./OrdersConfig.js";

export const protobufPackage = "protobuf";

export interface ConfigResponse {
  reqId?: number | undefined;
  lockAndExit?: LockAndExitConfig | undefined;
  messages: MessageConfig[];
  api?: ApiConfig | undefined;
  orders?: OrdersConfig | undefined;
}

function createBaseConfigResponse(): ConfigResponse {
  return { reqId: undefined, lockAndExit: undefined, messages: [], api: undefined, orders: undefined };
}

export const ConfigResponse: MessageFns<ConfigResponse> = {
  encode(message: ConfigResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.reqId !== undefined) {
      writer.uint32(8).int32(message.reqId);
    }
    if (message.lockAndExit !== undefined) {
      LockAndExitConfig.encode(message.lockAndExit, writer.uint32(18).fork()).join();
    }
    for (const v of message.messages) {
      MessageConfig.encode(v!, writer.uint32(26).fork()).join();
    }
    if (message.api !== undefined) {
      ApiConfig.encode(message.api, writer.uint32(34).fork()).join();
    }
    if (message.orders !== undefined) {
      OrdersConfig.encode(message.orders, writer.uint32(42).fork()).join();
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): ConfigResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseConfigResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 8) {
            break;
          }

          message.reqId = reader.int32();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.lockAndExit = LockAndExitConfig.decode(reader, reader.uint32());
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

          message.messages.push(MessageConfig.decode(reader, reader.uint32()));
          continue;
        }
        case 4: {
          if (tag !== 34) {
            break;
          }

          message.api = ApiConfig.decode(reader, reader.uint32());
          continue;
        }
        case 5: {
          if (tag !== 42) {
            break;
          }

          message.orders = OrdersConfig.decode(reader, reader.uint32());
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): ConfigResponse {
    return {
      reqId: isSet(object.reqId) ? globalThis.Number(object.reqId) : undefined,
      lockAndExit: isSet(object.lockAndExit) ? LockAndExitConfig.fromJSON(object.lockAndExit) : undefined,
      messages: globalThis.Array.isArray(object?.messages)
        ? object.messages.map((e: any) => MessageConfig.fromJSON(e))
        : [],
      api: isSet(object.api) ? ApiConfig.fromJSON(object.api) : undefined,
      orders: isSet(object.orders) ? OrdersConfig.fromJSON(object.orders) : undefined,
    };
  },

  toJSON(message: ConfigResponse): unknown {
    const obj: any = {};
    if (message.reqId !== undefined) {
      obj.reqId = Math.round(message.reqId);
    }
    if (message.lockAndExit !== undefined) {
      obj.lockAndExit = LockAndExitConfig.toJSON(message.lockAndExit);
    }
    if (message.messages?.length) {
      obj.messages = message.messages.map((e) => MessageConfig.toJSON(e));
    }
    if (message.api !== undefined) {
      obj.api = ApiConfig.toJSON(message.api);
    }
    if (message.orders !== undefined) {
      obj.orders = OrdersConfig.toJSON(message.orders);
    }
    return obj;
  },

  create(base?: DeepPartial<ConfigResponse>): ConfigResponse {
    return ConfigResponse.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ConfigResponse>): ConfigResponse {
    const message = createBaseConfigResponse();
    message.reqId = object.reqId ?? undefined;
    message.lockAndExit = (object.lockAndExit !== undefined && object.lockAndExit !== null)
      ? LockAndExitConfig.fromPartial(object.lockAndExit)
      : undefined;
    message.messages = object.messages?.map((e) => MessageConfig.fromPartial(e)) || [];
    message.api = (object.api !== undefined && object.api !== null) ? ApiConfig.fromPartial(object.api) : undefined;
    message.orders = (object.orders !== undefined && object.orders !== null)
      ? OrdersConfig.fromPartial(object.orders)
      : undefined;
    return message;
  },
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

export interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
