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 { OracleType } from "../../oracle/v1beta1/oracle_pb.js";
class RateLimit$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.RateLimit", [
      {
        no: 1,
        name: "token_address",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "token_decimals",
        kind: "scalar",
        T: 13
        /*ScalarType.UINT32*/
      },
      {
        no: 3,
        name: "token_price_id",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 4,
        name: "rate_limit_window",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 5, name: "rate_limit_usd", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.LegacyDec" } },
      { no: 6, name: "absolute_mint_limit", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } },
      { no: 7, name: "transfers", kind: "message", repeat: 2, T: () => BridgeTransfer },
      { no: 8, name: "token_oracle_type", kind: "enum", T: () => ["injective.oracle.v1beta1.OracleType", OracleType] }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.tokenAddress = "";
    message.tokenDecimals = 0;
    message.tokenPriceId = "";
    message.rateLimitWindow = 0n;
    message.rateLimitUsd = "";
    message.absoluteMintLimit = "";
    message.transfers = [];
    message.tokenOracleType = 0;
    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 token_address */
        1:
          message.tokenAddress = reader.string();
          break;
        case /* uint32 token_decimals */
        2:
          message.tokenDecimals = reader.uint32();
          break;
        case /* string token_price_id */
        3:
          message.tokenPriceId = reader.string();
          break;
        case /* uint64 rate_limit_window */
        4:
          message.rateLimitWindow = reader.uint64().toBigInt();
          break;
        case /* string rate_limit_usd */
        5:
          message.rateLimitUsd = reader.string();
          break;
        case /* string absolute_mint_limit = 6 [deprecated = true] */
        6:
          message.absoluteMintLimit = reader.string();
          break;
        case /* repeated injective.peggy.v1.BridgeTransfer transfers = 7 [deprecated = true] */
        7:
          message.transfers.push(BridgeTransfer.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* injective.oracle.v1beta1.OracleType token_oracle_type */
        8:
          message.tokenOracleType = reader.int32();
          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.tokenAddress !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.tokenAddress);
    if (message.tokenDecimals !== 0)
      writer.tag(2, WireType.Varint).uint32(message.tokenDecimals);
    if (message.tokenPriceId !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.tokenPriceId);
    if (message.rateLimitWindow !== 0n)
      writer.tag(4, WireType.Varint).uint64(message.rateLimitWindow);
    if (message.rateLimitUsd !== "")
      writer.tag(5, WireType.LengthDelimited).string(message.rateLimitUsd);
    if (message.absoluteMintLimit !== "")
      writer.tag(6, WireType.LengthDelimited).string(message.absoluteMintLimit);
    for (let i = 0; i < message.transfers.length; i++)
      BridgeTransfer.internalBinaryWrite(message.transfers[i], writer.tag(7, WireType.LengthDelimited).fork(), options).join();
    if (message.tokenOracleType !== 0)
      writer.tag(8, WireType.Varint).int32(message.tokenOracleType);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const RateLimit = new RateLimit$Type();
class BridgeTransfer$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.BridgeTransfer", [
      { no: 1, name: "amount", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } },
      {
        no: 2,
        name: "block_number",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      {
        no: 3,
        name: "is_deposit",
        kind: "scalar",
        T: 8
        /*ScalarType.BOOL*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.amount = "";
    message.blockNumber = 0n;
    message.isDeposit = false;
    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 amount */
        1:
          message.amount = reader.string();
          break;
        case /* uint64 block_number */
        2:
          message.blockNumber = reader.uint64().toBigInt();
          break;
        case /* bool is_deposit */
        3:
          message.isDeposit = reader.bool();
          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.amount !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.amount);
    if (message.blockNumber !== 0n)
      writer.tag(2, WireType.Varint).uint64(message.blockNumber);
    if (message.isDeposit !== false)
      writer.tag(3, WireType.Varint).bool(message.isDeposit);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const BridgeTransfer = new BridgeTransfer$Type();
class RateLimitTransfers$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.RateLimitTransfers", [
      {
        no: 1,
        name: "token",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 2, name: "inflows", kind: "message", repeat: 2, T: () => BlockTransferRecord },
      { no: 3, name: "outflows", kind: "message", repeat: 2, T: () => BlockTransferRecord }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.token = "";
    message.inflows = [];
    message.outflows = [];
    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 token */
        1:
          message.token = reader.string();
          break;
        case /* repeated injective.peggy.v1.BlockTransferRecord inflows */
        2:
          message.inflows.push(BlockTransferRecord.internalBinaryRead(reader, reader.uint32(), options));
          break;
        case /* repeated injective.peggy.v1.BlockTransferRecord outflows */
        3:
          message.outflows.push(BlockTransferRecord.internalBinaryRead(reader, reader.uint32(), options));
          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.token !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.token);
    for (let i = 0; i < message.inflows.length; i++)
      BlockTransferRecord.internalBinaryWrite(message.inflows[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
    for (let i = 0; i < message.outflows.length; i++)
      BlockTransferRecord.internalBinaryWrite(message.outflows[i], 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 RateLimitTransfers = new RateLimitTransfers$Type();
class BlockTransferRecord$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.BlockTransferRecord", [
      {
        no: 1,
        name: "block_number",
        kind: "scalar",
        T: 4,
        L: 0
        /*LongType.BIGINT*/
      },
      { no: 2, name: "amount", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.blockNumber = 0n;
    message.amount = "";
    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 block_number */
        1:
          message.blockNumber = reader.uint64().toBigInt();
          break;
        case /* string amount */
        2:
          message.amount = 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.blockNumber !== 0n)
      writer.tag(1, WireType.Varint).uint64(message.blockNumber);
    if (message.amount !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.amount);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const BlockTransferRecord = new BlockTransferRecord$Type();
class MintAmount$Type extends MessageType {
  constructor() {
    super("injective.peggy.v1.MintAmount", [
      {
        no: 1,
        name: "token",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 2, name: "amount", kind: "scalar", T: 9, options: { "gogoproto.nullable": false, "gogoproto.customtype": "cosmossdk.io/math.Int" } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.token = "";
    message.amount = "";
    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 token */
        1:
          message.token = reader.string();
          break;
        case /* string amount */
        2:
          message.amount = 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.token !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.token);
    if (message.amount !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.amount);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const MintAmount = new MintAmount$Type();
export {
  BlockTransferRecord,
  BridgeTransfer,
  MintAmount,
  RateLimit,
  RateLimitTransfers
};
