"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MemberRoleSDKType = exports.MemberRoleAmino = exports.MemberRole = exports.Member = void 0;
exports.memberRoleFromJSON = memberRoleFromJSON;
exports.memberRoleToJSON = memberRoleToJSON;
var _binary = require("../binary");
var _helpers = require("../helpers");
var MemberRole = exports.MemberRole = /*#__PURE__*/function (MemberRole) {
  MemberRole[MemberRole["MEMBER"] = 0] = "MEMBER";
  MemberRole[MemberRole["OWNER"] = 1] = "OWNER";
  MemberRole[MemberRole["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return MemberRole;
}({});
var MemberRoleSDKType = exports.MemberRoleSDKType = MemberRole;
var MemberRoleAmino = exports.MemberRoleAmino = MemberRole;
function memberRoleFromJSON(object) {
  switch (object) {
    case 0:
    case "MEMBER":
      return MemberRole.MEMBER;
    case 1:
    case "OWNER":
      return MemberRole.OWNER;
    case -1:
    case "UNRECOGNIZED":
    default:
      return MemberRole.UNRECOGNIZED;
  }
}
function memberRoleToJSON(object) {
  switch (object) {
    case MemberRole.MEMBER:
      return "MEMBER";
    case MemberRole.OWNER:
      return "OWNER";
    case MemberRole.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseMember() {
  return {
    id: BigInt(0),
    address: "",
    daoAddress: "",
    role: 0
  };
}
var Member = exports.Member = {
  typeUrl: "/gitopia.gitopia.gitopia.Member",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.address !== "") {
      writer.uint32(18).string(message.address);
    }
    if (message.daoAddress !== "") {
      writer.uint32(26).string(message.daoAddress);
    }
    if (message.role !== 0) {
      writer.uint32(32).int32(message.role);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      id: (0, _helpers.isSet)(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      address: (0, _helpers.isSet)(object.address) ? String(object.address) : "",
      daoAddress: (0, _helpers.isSet)(object.daoAddress) ? String(object.daoAddress) : "",
      role: (0, _helpers.isSet)(object.role) ? memberRoleFromJSON(object.role) : -1
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$address, _object$daoAddress, _object$role;
    var message = createBaseMember();
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    message.daoAddress = (_object$daoAddress = object.daoAddress) !== null && _object$daoAddress !== void 0 ? _object$daoAddress : "";
    message.role = (_object$role = object.role) !== null && _object$role !== void 0 ? _object$role : 0;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMember();
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.address !== undefined && object.address !== null) {
      message.address = object.address;
    }
    if (object.daoAddress !== undefined && object.daoAddress !== null) {
      message.daoAddress = object.daoAddress;
    }
    if (object.role !== undefined && object.role !== null) {
      message.role = object.role;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.address = message.address === "" ? undefined : message.address;
    obj.daoAddress = message.daoAddress === "" ? undefined : message.daoAddress;
    obj.role = message.role === 0 ? undefined : message.role;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Member.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Member.decode(message.value);
  },
  toProto: function toProto(message) {
    return Member.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Member",
      value: Member.encode(message).finish()
    };
  }
};