//@ts-nocheck
import { Long, isSet, bytesFromBase64, base64FromBytes } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
/** MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. */

/** MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. */

/** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */

/** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */

/**
 * MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request
 * type.
 */

/**
 * MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request
 * type.
 */

/**
 * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response
 * type.
 */

/**
 * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response
 * type.
 */

/**
 * TxExtension allows for additional authenticator-specific data in
 * transactions.
 */

/**
 * TxExtension allows for additional authenticator-specific data in
 * transactions.
 */

function createBaseMsgAddAuthenticator() {
  return {
    sender: "",
    authenticatorType: "",
    data: new Uint8Array()
  };
}
export const MsgAddAuthenticator = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.authenticatorType !== "") {
      writer.uint32(18).string(message.authenticatorType);
    }
    if (message.data.length !== 0) {
      writer.uint32(26).bytes(message.data);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgAddAuthenticator();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.authenticatorType = reader.string();
          break;
        case 3:
          message.data = reader.bytes();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      sender: isSet(object.sender) ? String(object.sender) : "",
      authenticatorType: isSet(object.authenticatorType) ? String(object.authenticatorType) : "",
      data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array()
    };
  },
  toJSON(message) {
    const obj = {};
    message.sender !== undefined && (obj.sender = message.sender);
    message.authenticatorType !== undefined && (obj.authenticatorType = message.authenticatorType);
    message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
    return obj;
  },
  fromPartial(object) {
    var _object$sender, _object$authenticator, _object$data;
    const message = createBaseMsgAddAuthenticator();
    message.sender = (_object$sender = object.sender) !== null && _object$sender !== void 0 ? _object$sender : "";
    message.authenticatorType = (_object$authenticator = object.authenticatorType) !== null && _object$authenticator !== void 0 ? _object$authenticator : "";
    message.data = (_object$data = object.data) !== null && _object$data !== void 0 ? _object$data : new Uint8Array();
    return message;
  }
};
function createBaseMsgAddAuthenticatorResponse() {
  return {
    success: false
  };
}
export const MsgAddAuthenticatorResponse = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.success === true) {
      writer.uint32(8).bool(message.success);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgAddAuthenticatorResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.success = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      success: isSet(object.success) ? Boolean(object.success) : false
    };
  },
  toJSON(message) {
    const obj = {};
    message.success !== undefined && (obj.success = message.success);
    return obj;
  },
  fromPartial(object) {
    var _object$success;
    const message = createBaseMsgAddAuthenticatorResponse();
    message.success = (_object$success = object.success) !== null && _object$success !== void 0 ? _object$success : false;
    return message;
  }
};
function createBaseMsgRemoveAuthenticator() {
  return {
    sender: "",
    id: Long.UZERO
  };
}
export const MsgRemoveAuthenticator = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (!message.id.isZero()) {
      writer.uint32(16).uint64(message.id);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgRemoveAuthenticator();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.id = reader.uint64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      sender: isSet(object.sender) ? String(object.sender) : "",
      id: isSet(object.id) ? Long.fromValue(object.id) : Long.UZERO
    };
  },
  toJSON(message) {
    const obj = {};
    message.sender !== undefined && (obj.sender = message.sender);
    message.id !== undefined && (obj.id = (message.id || Long.UZERO).toString());
    return obj;
  },
  fromPartial(object) {
    var _object$sender2;
    const message = createBaseMsgRemoveAuthenticator();
    message.sender = (_object$sender2 = object.sender) !== null && _object$sender2 !== void 0 ? _object$sender2 : "";
    message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO;
    return message;
  }
};
function createBaseMsgRemoveAuthenticatorResponse() {
  return {
    success: false
  };
}
export const MsgRemoveAuthenticatorResponse = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.success === true) {
      writer.uint32(8).bool(message.success);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgRemoveAuthenticatorResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.success = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      success: isSet(object.success) ? Boolean(object.success) : false
    };
  },
  toJSON(message) {
    const obj = {};
    message.success !== undefined && (obj.success = message.success);
    return obj;
  },
  fromPartial(object) {
    var _object$success2;
    const message = createBaseMsgRemoveAuthenticatorResponse();
    message.success = (_object$success2 = object.success) !== null && _object$success2 !== void 0 ? _object$success2 : false;
    return message;
  }
};
function createBaseMsgSetActiveState() {
  return {
    sender: "",
    active: false
  };
}
export const MsgSetActiveState = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.sender !== "") {
      writer.uint32(10).string(message.sender);
    }
    if (message.active === true) {
      writer.uint32(16).bool(message.active);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgSetActiveState();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.sender = reader.string();
          break;
        case 2:
          message.active = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      sender: isSet(object.sender) ? String(object.sender) : "",
      active: isSet(object.active) ? Boolean(object.active) : false
    };
  },
  toJSON(message) {
    const obj = {};
    message.sender !== undefined && (obj.sender = message.sender);
    message.active !== undefined && (obj.active = message.active);
    return obj;
  },
  fromPartial(object) {
    var _object$sender3, _object$active;
    const message = createBaseMsgSetActiveState();
    message.sender = (_object$sender3 = object.sender) !== null && _object$sender3 !== void 0 ? _object$sender3 : "";
    message.active = (_object$active = object.active) !== null && _object$active !== void 0 ? _object$active : false;
    return message;
  }
};
function createBaseMsgSetActiveStateResponse() {
  return {};
}
export const MsgSetActiveStateResponse = {
  encode(_, writer = _m0.Writer.create()) {
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseMsgSetActiveStateResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(_) {
    return {};
  },
  toJSON(_) {
    const obj = {};
    return obj;
  },
  fromPartial(_) {
    const message = createBaseMsgSetActiveStateResponse();
    return message;
  }
};
function createBaseTxExtension() {
  return {
    selectedAuthenticators: []
  };
}
export const TxExtension = {
  encode(message, writer = _m0.Writer.create()) {
    writer.uint32(10).fork();
    for (const v of message.selectedAuthenticators) {
      writer.uint64(v);
    }
    writer.ldelim();
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseTxExtension();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if ((tag & 7) === 2) {
            const end2 = reader.uint32() + reader.pos;
            while (reader.pos < end2) {
              message.selectedAuthenticators.push(reader.uint64());
            }
          } else {
            message.selectedAuthenticators.push(reader.uint64());
          }
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      selectedAuthenticators: Array.isArray(object === null || object === void 0 ? void 0 : object.selectedAuthenticators) ? object.selectedAuthenticators.map(e => Long.fromValue(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    if (message.selectedAuthenticators) {
      obj.selectedAuthenticators = message.selectedAuthenticators.map(e => (e || Long.UZERO).toString());
    } else {
      obj.selectedAuthenticators = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$selectedAuthe;
    const message = createBaseTxExtension();
    message.selectedAuthenticators = ((_object$selectedAuthe = object.selectedAuthenticators) === null || _object$selectedAuthe === void 0 ? void 0 : _object$selectedAuthe.map(e => Long.fromValue(e))) || [];
    return message;
  }
};