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

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

export const protobufPackage = "protobuf";

export interface ScannerDataElement {
  rank?: number | undefined;
  contract?: Contract | undefined;
  marketName?: string | undefined;
  distance?: string | undefined;
  benchmark?: string | undefined;
  projection?: string | undefined;
  comboKey?: string | undefined;
}

function createBaseScannerDataElement(): ScannerDataElement {
  return {
    rank: undefined,
    contract: undefined,
    marketName: undefined,
    distance: undefined,
    benchmark: undefined,
    projection: undefined,
    comboKey: undefined,
  };
}

export const ScannerDataElement: MessageFns<ScannerDataElement> = {
  encode(message: ScannerDataElement, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.rank !== undefined) {
      writer.uint32(8).int32(message.rank);
    }
    if (message.contract !== undefined) {
      Contract.encode(message.contract, writer.uint32(18).fork()).join();
    }
    if (message.marketName !== undefined) {
      writer.uint32(26).string(message.marketName);
    }
    if (message.distance !== undefined) {
      writer.uint32(34).string(message.distance);
    }
    if (message.benchmark !== undefined) {
      writer.uint32(42).string(message.benchmark);
    }
    if (message.projection !== undefined) {
      writer.uint32(50).string(message.projection);
    }
    if (message.comboKey !== undefined) {
      writer.uint32(58).string(message.comboKey);
    }
    return writer;
  },

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

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

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

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

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

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

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

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

  fromJSON(object: any): ScannerDataElement {
    return {
      rank: isSet(object.rank) ? globalThis.Number(object.rank) : undefined,
      contract: isSet(object.contract) ? Contract.fromJSON(object.contract) : undefined,
      marketName: isSet(object.marketName) ? globalThis.String(object.marketName) : undefined,
      distance: isSet(object.distance) ? globalThis.String(object.distance) : undefined,
      benchmark: isSet(object.benchmark) ? globalThis.String(object.benchmark) : undefined,
      projection: isSet(object.projection) ? globalThis.String(object.projection) : undefined,
      comboKey: isSet(object.comboKey) ? globalThis.String(object.comboKey) : undefined,
    };
  },

  toJSON(message: ScannerDataElement): unknown {
    const obj: any = {};
    if (message.rank !== undefined) {
      obj.rank = Math.round(message.rank);
    }
    if (message.contract !== undefined) {
      obj.contract = Contract.toJSON(message.contract);
    }
    if (message.marketName !== undefined) {
      obj.marketName = message.marketName;
    }
    if (message.distance !== undefined) {
      obj.distance = message.distance;
    }
    if (message.benchmark !== undefined) {
      obj.benchmark = message.benchmark;
    }
    if (message.projection !== undefined) {
      obj.projection = message.projection;
    }
    if (message.comboKey !== undefined) {
      obj.comboKey = message.comboKey;
    }
    return obj;
  },

  create(base?: DeepPartial<ScannerDataElement>): ScannerDataElement {
    return ScannerDataElement.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ScannerDataElement>): ScannerDataElement {
    const message = createBaseScannerDataElement();
    message.rank = object.rank ?? undefined;
    message.contract = (object.contract !== undefined && object.contract !== null)
      ? Contract.fromPartial(object.contract)
      : undefined;
    message.marketName = object.marketName ?? undefined;
    message.distance = object.distance ?? undefined;
    message.benchmark = object.benchmark ?? undefined;
    message.projection = object.projection ?? undefined;
    message.comboKey = object.comboKey ?? 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;
}
