//@ts-nocheck
import { Long, isSet, bytesFromBase64, base64FromBytes } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
/**
 * AccountAuthenticator represents a foundational model for all authenticators.
 * It provides extensibility by allowing concrete types to interpret and
 * validate transactions based on the encapsulated data.
 */

/**
 * AccountAuthenticator represents a foundational model for all authenticators.
 * It provides extensibility by allowing concrete types to interpret and
 * validate transactions based on the encapsulated data.
 */

function createBaseAccountAuthenticator() {
  return {
    id: Long.UZERO,
    type: "",
    config: new Uint8Array()
  };
}
export const AccountAuthenticator = {
  encode(message, writer = _m0.Writer.create()) {
    if (!message.id.isZero()) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.type !== "") {
      writer.uint32(18).string(message.type);
    }
    if (message.config.length !== 0) {
      writer.uint32(26).bytes(message.config);
    }
    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 = createBaseAccountAuthenticator();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.id = reader.uint64();
          break;
        case 2:
          message.type = reader.string();
          break;
        case 3:
          message.config = reader.bytes();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? Long.fromValue(object.id) : Long.UZERO,
      type: isSet(object.type) ? String(object.type) : "",
      config: isSet(object.config) ? bytesFromBase64(object.config) : new Uint8Array()
    };
  },
  toJSON(message) {
    const obj = {};
    message.id !== undefined && (obj.id = (message.id || Long.UZERO).toString());
    message.type !== undefined && (obj.type = message.type);
    message.config !== undefined && (obj.config = base64FromBytes(message.config !== undefined ? message.config : new Uint8Array()));
    return obj;
  },
  fromPartial(object) {
    var _object$type, _object$config;
    const message = createBaseAccountAuthenticator();
    message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO;
    message.type = (_object$type = object.type) !== null && _object$type !== void 0 ? _object$type : "";
    message.config = (_object$config = object.config) !== null && _object$config !== void 0 ? _object$config : new Uint8Array();
    return message;
  }
};