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

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";

export const protobufPackage = "protobuf";

export interface OrderCondition {
  type?: number | undefined;
  isConjunctionConnection?: boolean | undefined;
  isMore?: boolean | undefined;
  conId?: number | undefined;
  exchange?: string | undefined;
  symbol?: string | undefined;
  secType?: string | undefined;
  percent?: number | undefined;
  changePercent?: number | undefined;
  price?: number | undefined;
  triggerMethod?: number | undefined;
  time?: string | undefined;
  volume?: number | undefined;
}

function createBaseOrderCondition(): OrderCondition {
  return {
    type: undefined,
    isConjunctionConnection: undefined,
    isMore: undefined,
    conId: undefined,
    exchange: undefined,
    symbol: undefined,
    secType: undefined,
    percent: undefined,
    changePercent: undefined,
    price: undefined,
    triggerMethod: undefined,
    time: undefined,
    volume: undefined,
  };
}

export const OrderCondition: MessageFns<OrderCondition> = {
  encode(message: OrderCondition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.type !== undefined) {
      writer.uint32(8).int32(message.type);
    }
    if (message.isConjunctionConnection !== undefined) {
      writer.uint32(16).bool(message.isConjunctionConnection);
    }
    if (message.isMore !== undefined) {
      writer.uint32(24).bool(message.isMore);
    }
    if (message.conId !== undefined) {
      writer.uint32(32).int32(message.conId);
    }
    if (message.exchange !== undefined) {
      writer.uint32(42).string(message.exchange);
    }
    if (message.symbol !== undefined) {
      writer.uint32(50).string(message.symbol);
    }
    if (message.secType !== undefined) {
      writer.uint32(58).string(message.secType);
    }
    if (message.percent !== undefined) {
      writer.uint32(64).int32(message.percent);
    }
    if (message.changePercent !== undefined) {
      writer.uint32(73).double(message.changePercent);
    }
    if (message.price !== undefined) {
      writer.uint32(81).double(message.price);
    }
    if (message.triggerMethod !== undefined) {
      writer.uint32(88).int32(message.triggerMethod);
    }
    if (message.time !== undefined) {
      writer.uint32(98).string(message.time);
    }
    if (message.volume !== undefined) {
      writer.uint32(104).int32(message.volume);
    }
    return writer;
  },

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

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

          message.isConjunctionConnection = reader.bool();
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

          message.isMore = reader.bool();
          continue;
        }
        case 4: {
          if (tag !== 32) {
            break;
          }

          message.conId = reader.int32();
          continue;
        }
        case 5: {
          if (tag !== 42) {
            break;
          }

          message.exchange = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 50) {
            break;
          }

          message.symbol = reader.string();
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

          message.secType = reader.string();
          continue;
        }
        case 8: {
          if (tag !== 64) {
            break;
          }

          message.percent = reader.int32();
          continue;
        }
        case 9: {
          if (tag !== 73) {
            break;
          }

          message.changePercent = reader.double();
          continue;
        }
        case 10: {
          if (tag !== 81) {
            break;
          }

          message.price = reader.double();
          continue;
        }
        case 11: {
          if (tag !== 88) {
            break;
          }

          message.triggerMethod = reader.int32();
          continue;
        }
        case 12: {
          if (tag !== 98) {
            break;
          }

          message.time = reader.string();
          continue;
        }
        case 13: {
          if (tag !== 104) {
            break;
          }

          message.volume = reader.int32();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): OrderCondition {
    return {
      type: isSet(object.type) ? globalThis.Number(object.type) : undefined,
      isConjunctionConnection: isSet(object.isConjunctionConnection)
        ? globalThis.Boolean(object.isConjunctionConnection)
        : undefined,
      isMore: isSet(object.isMore) ? globalThis.Boolean(object.isMore) : undefined,
      conId: isSet(object.conId) ? globalThis.Number(object.conId) : undefined,
      exchange: isSet(object.exchange) ? globalThis.String(object.exchange) : undefined,
      symbol: isSet(object.symbol) ? globalThis.String(object.symbol) : undefined,
      secType: isSet(object.secType) ? globalThis.String(object.secType) : undefined,
      percent: isSet(object.percent) ? globalThis.Number(object.percent) : undefined,
      changePercent: isSet(object.changePercent) ? globalThis.Number(object.changePercent) : undefined,
      price: isSet(object.price) ? globalThis.Number(object.price) : undefined,
      triggerMethod: isSet(object.triggerMethod) ? globalThis.Number(object.triggerMethod) : undefined,
      time: isSet(object.time) ? globalThis.String(object.time) : undefined,
      volume: isSet(object.volume) ? globalThis.Number(object.volume) : undefined,
    };
  },

  toJSON(message: OrderCondition): unknown {
    const obj: any = {};
    if (message.type !== undefined) {
      obj.type = Math.round(message.type);
    }
    if (message.isConjunctionConnection !== undefined) {
      obj.isConjunctionConnection = message.isConjunctionConnection;
    }
    if (message.isMore !== undefined) {
      obj.isMore = message.isMore;
    }
    if (message.conId !== undefined) {
      obj.conId = Math.round(message.conId);
    }
    if (message.exchange !== undefined) {
      obj.exchange = message.exchange;
    }
    if (message.symbol !== undefined) {
      obj.symbol = message.symbol;
    }
    if (message.secType !== undefined) {
      obj.secType = message.secType;
    }
    if (message.percent !== undefined) {
      obj.percent = Math.round(message.percent);
    }
    if (message.changePercent !== undefined) {
      obj.changePercent = message.changePercent;
    }
    if (message.price !== undefined) {
      obj.price = message.price;
    }
    if (message.triggerMethod !== undefined) {
      obj.triggerMethod = Math.round(message.triggerMethod);
    }
    if (message.time !== undefined) {
      obj.time = message.time;
    }
    if (message.volume !== undefined) {
      obj.volume = Math.round(message.volume);
    }
    return obj;
  },

  create(base?: DeepPartial<OrderCondition>): OrderCondition {
    return OrderCondition.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<OrderCondition>): OrderCondition {
    const message = createBaseOrderCondition();
    message.type = object.type ?? undefined;
    message.isConjunctionConnection = object.isConjunctionConnection ?? undefined;
    message.isMore = object.isMore ?? undefined;
    message.conId = object.conId ?? undefined;
    message.exchange = object.exchange ?? undefined;
    message.symbol = object.symbol ?? undefined;
    message.secType = object.secType ?? undefined;
    message.percent = object.percent ?? undefined;
    message.changePercent = object.changePercent ?? undefined;
    message.price = object.price ?? undefined;
    message.triggerMethod = object.triggerMethod ?? undefined;
    message.time = object.time ?? undefined;
    message.volume = object.volume ?? 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;
}
