import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { Duration } from "../../google/protobuf/duration_pb.js";
class ConsensusParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.ConsensusParams", [
      { no: 1, name: "block", kind: "message", T: () => BlockParams },
      { no: 2, name: "evidence", kind: "message", T: () => EvidenceParams },
      { no: 3, name: "validator", kind: "message", T: () => ValidatorParams },
      { no: 4, name: "version", kind: "message", T: () => VersionParams },
      { no: 5, name: "abci", kind: "message", T: () => ABCIParams },
      { no: 6, name: "authority", kind: "message", T: () => AuthorityParams }
    ]);
  }
  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.types.BlockParams block */
        1:
          message.block = BlockParams.internalBinaryRead(reader, reader.uint32(), options, message.block);
          break;
        case /* tendermint.types.EvidenceParams evidence */
        2:
          message.evidence = EvidenceParams.internalBinaryRead(reader, reader.uint32(), options, message.evidence);
          break;
        case /* tendermint.types.ValidatorParams validator */
        3:
          message.validator = ValidatorParams.internalBinaryRead(reader, reader.uint32(), options, message.validator);
          break;
        case /* tendermint.types.VersionParams version */
        4:
          message.version = VersionParams.internalBinaryRead(reader, reader.uint32(), options, message.version);
          break;
        case /* tendermint.types.ABCIParams abci */
        5:
          message.abci = ABCIParams.internalBinaryRead(reader, reader.uint32(), options, message.abci);
          break;
        case /* tendermint.types.AuthorityParams authority */
        6:
          message.authority = AuthorityParams.internalBinaryRead(reader, reader.uint32(), options, message.authority);
          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)
      BlockParams.internalBinaryWrite(message.block, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    if (message.evidence)
      EvidenceParams.internalBinaryWrite(message.evidence, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    if (message.validator)
      ValidatorParams.internalBinaryWrite(message.validator, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    if (message.version)
      VersionParams.internalBinaryWrite(message.version, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
    if (message.abci)
      ABCIParams.internalBinaryWrite(message.abci, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
    if (message.authority)
      AuthorityParams.internalBinaryWrite(message.authority, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const ConsensusParams = new ConsensusParams$Type();
class BlockParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.BlockParams", [
      {
        no: 1,
        name: "max_bytes",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 2,
        name: "max_gas",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.maxBytes = 0n;
    message.maxGas = 0n;
    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 /* int64 max_bytes */
        1:
          message.maxBytes = reader.int64().toBigInt();
          break;
        case /* int64 max_gas */
        2:
          message.maxGas = reader.int64().toBigInt();
          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.maxBytes !== 0n)
      writer.tag(1, WireType.Varint).int64(message.maxBytes);
    if (message.maxGas !== 0n)
      writer.tag(2, WireType.Varint).int64(message.maxGas);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const BlockParams = new BlockParams$Type();
class EvidenceParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.EvidenceParams", [
      {
        no: 1,
        name: "max_age_num_blocks",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 2, name: "max_age_duration", kind: "message", T: () => Duration, options: { "gogoproto.nullable": false, "gogoproto.stdduration": true } },
      {
        no: 3,
        name: "max_bytes",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.maxAgeNumBlocks = 0n;
    message.maxBytes = 0n;
    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 /* int64 max_age_num_blocks */
        1:
          message.maxAgeNumBlocks = reader.int64().toBigInt();
          break;
        case /* google.protobuf.Duration max_age_duration */
        2:
          message.maxAgeDuration = Duration.internalBinaryRead(reader, reader.uint32(), options, message.maxAgeDuration);
          break;
        case /* int64 max_bytes */
        3:
          message.maxBytes = reader.int64().toBigInt();
          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.maxAgeNumBlocks !== 0n)
      writer.tag(1, WireType.Varint).int64(message.maxAgeNumBlocks);
    if (message.maxAgeDuration)
      Duration.internalBinaryWrite(message.maxAgeDuration, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    if (message.maxBytes !== 0n)
      writer.tag(3, WireType.Varint).int64(message.maxBytes);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const EvidenceParams = new EvidenceParams$Type();
class ValidatorParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.ValidatorParams", [
      {
        no: 1,
        name: "pub_key_types",
        kind: "scalar",
        repeat: 2,
        T: 9
        /*ScalarType.STRING*/
      }
    ], { "gogoproto.populate": true, "gogoproto.equal": true });
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.pubKeyTypes = [];
    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 string pub_key_types */
        1:
          message.pubKeyTypes.push(reader.string());
          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.pubKeyTypes.length; i++)
      writer.tag(1, WireType.LengthDelimited).string(message.pubKeyTypes[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const ValidatorParams = new ValidatorParams$Type();
class VersionParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.VersionParams", [
      {
        no: 1,
        name: "app",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      }
    ], { "gogoproto.populate": true, "gogoproto.equal": true });
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.app = 0n;
    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 /* uint64 app */
        1:
          message.app = reader.uint64().toBigInt();
          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.app !== 0n)
      writer.tag(1, WireType.Varint).uint64(message.app);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const VersionParams = new VersionParams$Type();
class HashedParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.HashedParams", [
      {
        no: 1,
        name: "block_max_bytes",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 2,
        name: "block_max_gas",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.blockMaxBytes = 0n;
    message.blockMaxGas = 0n;
    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 /* int64 block_max_bytes */
        1:
          message.blockMaxBytes = reader.int64().toBigInt();
          break;
        case /* int64 block_max_gas */
        2:
          message.blockMaxGas = reader.int64().toBigInt();
          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.blockMaxBytes !== 0n)
      writer.tag(1, WireType.Varint).int64(message.blockMaxBytes);
    if (message.blockMaxGas !== 0n)
      writer.tag(2, WireType.Varint).int64(message.blockMaxGas);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const HashedParams = new HashedParams$Type();
class ABCIParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.ABCIParams", [
      {
        no: 1,
        name: "vote_extensions_enable_height",
        kind: "scalar",
        T: 3,
        L: 0
        /*LongType.BIGINT*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.voteExtensionsEnableHeight = 0n;
    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 /* int64 vote_extensions_enable_height */
        1:
          message.voteExtensionsEnableHeight = reader.int64().toBigInt();
          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.voteExtensionsEnableHeight !== 0n)
      writer.tag(1, WireType.Varint).int64(message.voteExtensionsEnableHeight);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const ABCIParams = new ABCIParams$Type();
class AuthorityParams$Type extends MessageType {
  constructor() {
    super("tendermint.types.AuthorityParams", [
      {
        no: 1,
        name: "authority",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.authority = "";
    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 /* string authority */
        1:
          message.authority = reader.string();
          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.authority !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.authority);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const AuthorityParams = new AuthorityParams$Type();
export {
  ABCIParams,
  AuthorityParams,
  BlockParams,
  ConsensusParams,
  EvidenceParams,
  HashedParams,
  ValidatorParams,
  VersionParams
};
