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 { Coin } from "../../../cosmos/base/v1beta1/coin_pb.js";
import { RedemptionSchedule } from "./insurance_pb.js";
import { InsuranceFund } from "./insurance_pb.js";
class EventInsuranceFundUpdate$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventInsuranceFundUpdate", [
      { no: 1, name: "fund", kind: "message", T: () => InsuranceFund }
    ]);
  }
  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 /* injective.insurance.v1beta1.InsuranceFund fund */
        1:
          message.fund = InsuranceFund.internalBinaryRead(reader, reader.uint32(), options, message.fund);
          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.fund)
      InsuranceFund.internalBinaryWrite(message.fund, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const EventInsuranceFundUpdate = new EventInsuranceFundUpdate$Type();
class EventRequestRedemption$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventRequestRedemption", [
      { no: 1, name: "schedule", kind: "message", T: () => RedemptionSchedule }
    ]);
  }
  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 /* injective.insurance.v1beta1.RedemptionSchedule schedule */
        1:
          message.schedule = RedemptionSchedule.internalBinaryRead(reader, reader.uint32(), options, message.schedule);
          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.schedule)
      RedemptionSchedule.internalBinaryWrite(message.schedule, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const EventRequestRedemption = new EventRequestRedemption$Type();
class EventWithdrawRedemption$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventWithdrawRedemption", [
      { no: 1, name: "schedule", kind: "message", T: () => RedemptionSchedule },
      { no: 2, name: "redeem_coin", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false } }
    ]);
  }
  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 /* injective.insurance.v1beta1.RedemptionSchedule schedule */
        1:
          message.schedule = RedemptionSchedule.internalBinaryRead(reader, reader.uint32(), options, message.schedule);
          break;
        case /* cosmos.base.v1beta1.Coin redeem_coin */
        2:
          message.redeemCoin = Coin.internalBinaryRead(reader, reader.uint32(), options, message.redeemCoin);
          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.schedule)
      RedemptionSchedule.internalBinaryWrite(message.schedule, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    if (message.redeemCoin)
      Coin.internalBinaryWrite(message.redeemCoin, 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 EventWithdrawRedemption = new EventWithdrawRedemption$Type();
class EventWithdrawRedemptionFailed$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventWithdrawRedemptionFailed", [
      { no: 1, name: "schedule", kind: "message", T: () => RedemptionSchedule },
      {
        no: 2,
        name: "withdraw_err",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.withdrawErr = "";
    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 /* injective.insurance.v1beta1.RedemptionSchedule schedule */
        1:
          message.schedule = RedemptionSchedule.internalBinaryRead(reader, reader.uint32(), options, message.schedule);
          break;
        case /* string withdraw_err */
        2:
          message.withdrawErr = 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.schedule)
      RedemptionSchedule.internalBinaryWrite(message.schedule, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
    if (message.withdrawErr !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.withdrawErr);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
    return writer;
  }
}
const EventWithdrawRedemptionFailed = new EventWithdrawRedemptionFailed$Type();
class EventUnderwrite$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventUnderwrite", [
      {
        no: 1,
        name: "underwriter",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "marketId",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 3, name: "deposit", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false } },
      { no: 4, name: "shares", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.underwriter = "";
    message.marketId = "";
    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 underwriter */
        1:
          message.underwriter = reader.string();
          break;
        case /* string marketId */
        2:
          message.marketId = reader.string();
          break;
        case /* cosmos.base.v1beta1.Coin deposit */
        3:
          message.deposit = Coin.internalBinaryRead(reader, reader.uint32(), options, message.deposit);
          break;
        case /* cosmos.base.v1beta1.Coin shares */
        4:
          message.shares = Coin.internalBinaryRead(reader, reader.uint32(), options, message.shares);
          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.underwriter !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.underwriter);
    if (message.marketId !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.marketId);
    if (message.deposit)
      Coin.internalBinaryWrite(message.deposit, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
    if (message.shares)
      Coin.internalBinaryWrite(message.shares, 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 EventUnderwrite = new EventUnderwrite$Type();
class EventInsuranceWithdraw$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventInsuranceWithdraw", [
      {
        no: 1,
        name: "market_id",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "market_ticker",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 3, name: "withdrawal", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.marketId = "";
    message.marketTicker = "";
    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 market_id */
        1:
          message.marketId = reader.string();
          break;
        case /* string market_ticker */
        2:
          message.marketTicker = reader.string();
          break;
        case /* cosmos.base.v1beta1.Coin withdrawal */
        3:
          message.withdrawal = Coin.internalBinaryRead(reader, reader.uint32(), options, message.withdrawal);
          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.marketId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.marketId);
    if (message.marketTicker !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.marketTicker);
    if (message.withdrawal)
      Coin.internalBinaryWrite(message.withdrawal, 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 EventInsuranceWithdraw = new EventInsuranceWithdraw$Type();
class EventSetVoucher$Type extends MessageType {
  constructor() {
    super("injective.insurance.v1beta1.EventSetVoucher", [
      {
        no: 1,
        name: "addr",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      { no: 2, name: "voucher", kind: "message", T: () => Coin, options: { "gogoproto.nullable": false, "gogoproto.customtype": "github.com/cosmos/cosmos-sdk/types.Coin" } }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.addr = "";
    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 addr */
        1:
          message.addr = reader.string();
          break;
        case /* cosmos.base.v1beta1.Coin voucher */
        2:
          message.voucher = Coin.internalBinaryRead(reader, reader.uint32(), options, message.voucher);
          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.addr !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.addr);
    if (message.voucher)
      Coin.internalBinaryWrite(message.voucher, 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 EventSetVoucher = new EventSetVoucher$Type();
export {
  EventInsuranceFundUpdate,
  EventInsuranceWithdraw,
  EventRequestRedemption,
  EventSetVoucher,
  EventUnderwrite,
  EventWithdrawRedemption,
  EventWithdrawRedemptionFailed
};
