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

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

export const protobufPackage = "protobuf";

export interface ExecutionFilter {
  clientId?: number | undefined;
  acctCode?: string | undefined;
  time?: string | undefined;
  symbol?: string | undefined;
  secType?: string | undefined;
  exchange?: string | undefined;
  side?: string | undefined;
  lastNDays?: number | undefined;
  specificDates: number[];
}

function createBaseExecutionFilter(): ExecutionFilter {
  return {
    clientId: undefined,
    acctCode: undefined,
    time: undefined,
    symbol: undefined,
    secType: undefined,
    exchange: undefined,
    side: undefined,
    lastNDays: undefined,
    specificDates: [],
  };
}

export const ExecutionFilter: MessageFns<ExecutionFilter> = {
  encode(message: ExecutionFilter, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.clientId !== undefined) {
      writer.uint32(8).int32(message.clientId);
    }
    if (message.acctCode !== undefined) {
      writer.uint32(18).string(message.acctCode);
    }
    if (message.time !== undefined) {
      writer.uint32(26).string(message.time);
    }
    if (message.symbol !== undefined) {
      writer.uint32(34).string(message.symbol);
    }
    if (message.secType !== undefined) {
      writer.uint32(42).string(message.secType);
    }
    if (message.exchange !== undefined) {
      writer.uint32(50).string(message.exchange);
    }
    if (message.side !== undefined) {
      writer.uint32(58).string(message.side);
    }
    if (message.lastNDays !== undefined) {
      writer.uint32(64).int32(message.lastNDays);
    }
    writer.uint32(74).fork();
    for (const v of message.specificDates) {
      writer.int32(v);
    }
    writer.join();
    return writer;
  },

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

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

          message.acctCode = reader.string();
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

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

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

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

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

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

          message.lastNDays = reader.int32();
          continue;
        }
        case 9: {
          if (tag === 72) {
            message.specificDates.push(reader.int32());

            continue;
          }

          if (tag === 74) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.specificDates.push(reader.int32());
            }

            continue;
          }

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

  fromJSON(object: any): ExecutionFilter {
    return {
      clientId: isSet(object.clientId) ? globalThis.Number(object.clientId) : undefined,
      acctCode: isSet(object.acctCode) ? globalThis.String(object.acctCode) : undefined,
      time: isSet(object.time) ? globalThis.String(object.time) : undefined,
      symbol: isSet(object.symbol) ? globalThis.String(object.symbol) : undefined,
      secType: isSet(object.secType) ? globalThis.String(object.secType) : undefined,
      exchange: isSet(object.exchange) ? globalThis.String(object.exchange) : undefined,
      side: isSet(object.side) ? globalThis.String(object.side) : undefined,
      lastNDays: isSet(object.lastNDays) ? globalThis.Number(object.lastNDays) : undefined,
      specificDates: globalThis.Array.isArray(object?.specificDates)
        ? object.specificDates.map((e: any) => globalThis.Number(e))
        : [],
    };
  },

  toJSON(message: ExecutionFilter): unknown {
    const obj: any = {};
    if (message.clientId !== undefined) {
      obj.clientId = Math.round(message.clientId);
    }
    if (message.acctCode !== undefined) {
      obj.acctCode = message.acctCode;
    }
    if (message.time !== undefined) {
      obj.time = message.time;
    }
    if (message.symbol !== undefined) {
      obj.symbol = message.symbol;
    }
    if (message.secType !== undefined) {
      obj.secType = message.secType;
    }
    if (message.exchange !== undefined) {
      obj.exchange = message.exchange;
    }
    if (message.side !== undefined) {
      obj.side = message.side;
    }
    if (message.lastNDays !== undefined) {
      obj.lastNDays = Math.round(message.lastNDays);
    }
    if (message.specificDates?.length) {
      obj.specificDates = message.specificDates.map((e) => Math.round(e));
    }
    return obj;
  },

  create(base?: DeepPartial<ExecutionFilter>): ExecutionFilter {
    return ExecutionFilter.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ExecutionFilter>): ExecutionFilter {
    const message = createBaseExecutionFilter();
    message.clientId = object.clientId ?? undefined;
    message.acctCode = object.acctCode ?? undefined;
    message.time = object.time ?? undefined;
    message.symbol = object.symbol ?? undefined;
    message.secType = object.secType ?? undefined;
    message.exchange = object.exchange ?? undefined;
    message.side = object.side ?? undefined;
    message.lastNDays = object.lastNDays ?? undefined;
    message.specificDates = object.specificDates?.map((e) => e) || [];
    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;
}
