import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
class SigCountMessage$Type extends MessageType {
  constructor() {
    super("tendermint.blocksync.SigCountMessage", [
      { no: 3, name: "block_response", kind: "message", T: () => SigCountBlockResponse }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* tendermint.blocksync.SigCountBlockResponse block_response */
        3:
          message.blockResponse = SigCountBlockResponse.internalBinaryRead(reader, reader.uint32(), options, message.blockResponse);
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.blockResponse)
      SigCountBlockResponse.internalBinaryWrite(message.blockResponse, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const SigCountMessage = new SigCountMessage$Type();
class SigCountBlockResponse$Type extends MessageType {
  constructor() {
    super("tendermint.blocksync.SigCountBlockResponse", [
      { no: 1, name: "block", kind: "message", T: () => SigCountBlock },
      { no: 2, name: "ext_commit", kind: "message", T: () => SigCountExtendedCommit }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* tendermint.blocksync.SigCountBlock block */
        1:
          message.block = SigCountBlock.internalBinaryRead(reader, reader.uint32(), options, message.block);
          break;
        case /* tendermint.blocksync.SigCountExtendedCommit ext_commit */
        2:
          message.extCommit = SigCountExtendedCommit.internalBinaryRead(reader, reader.uint32(), options, message.extCommit);
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.block)
      SigCountBlock.internalBinaryWrite(message.block, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    if (message.extCommit)
      SigCountExtendedCommit.internalBinaryWrite(message.extCommit, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const SigCountBlockResponse = new SigCountBlockResponse$Type();
class SigCountBlock$Type extends MessageType {
  constructor() {
    super("tendermint.blocksync.SigCountBlock", [
      { no: 4, name: "last_commit", kind: "message", T: () => SigCountCommit }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* tendermint.blocksync.SigCountCommit last_commit */
        4:
          message.lastCommit = SigCountCommit.internalBinaryRead(reader, reader.uint32(), options, message.lastCommit);
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.lastCommit)
      SigCountCommit.internalBinaryWrite(message.lastCommit, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const SigCountBlock = new SigCountBlock$Type();
class SigCountCommit$Type extends MessageType {
  constructor() {
    super("tendermint.blocksync.SigCountCommit", [
      { no: 4, name: "signatures", kind: "scalar", repeat: 2, T: 12, options: { "gogoproto.nullable": false, "gogoproto.customtype": "NoSig" } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.signatures = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* repeated bytes signatures */
        4:
          message.signatures.push(reader.bytes());
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.signatures.length; i++)
      writer.tag(4, WireType.LengthDelimited).bytes(message.signatures[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const SigCountCommit = new SigCountCommit$Type();
class SigCountExtendedCommit$Type extends MessageType {
  constructor() {
    super("tendermint.blocksync.SigCountExtendedCommit", [
      { no: 4, name: "extended_signatures", kind: "scalar", repeat: 2, T: 12, options: { "gogoproto.nullable": false, "gogoproto.customtype": "NoSig" } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.extendedSignatures = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* repeated bytes extended_signatures */
        4:
          message.extendedSignatures.push(reader.bytes());
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.extendedSignatures.length; i++)
      writer.tag(4, WireType.LengthDelimited).bytes(message.extendedSignatures[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const SigCountExtendedCommit = new SigCountExtendedCommit$Type();
export {
  SigCountBlock,
  SigCountBlockResponse,
  SigCountCommit,
  SigCountExtendedCommit,
  SigCountMessage
};
