"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Reaction = exports.EmojiSDKType = exports.EmojiAmino = exports.Emoji = void 0;
exports.emojiFromJSON = emojiFromJSON;
exports.emojiToJSON = emojiToJSON;
var _binary = require("../binary");
var _helpers = require("../helpers");
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var Emoji = exports.Emoji = /*#__PURE__*/function (Emoji) {
  Emoji[Emoji["EMOJI_THUMBS_UP"] = 0] = "EMOJI_THUMBS_UP";
  Emoji[Emoji["EMOJI_THUMBS_DOWN"] = 1] = "EMOJI_THUMBS_DOWN";
  Emoji[Emoji["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return Emoji;
}({});
var EmojiSDKType = exports.EmojiSDKType = Emoji;
var EmojiAmino = exports.EmojiAmino = Emoji;
function emojiFromJSON(object) {
  switch (object) {
    case 0:
    case "EMOJI_THUMBS_UP":
      return Emoji.EMOJI_THUMBS_UP;
    case 1:
    case "EMOJI_THUMBS_DOWN":
      return Emoji.EMOJI_THUMBS_DOWN;
    case -1:
    case "UNRECOGNIZED":
    default:
      return Emoji.UNRECOGNIZED;
  }
}
function emojiToJSON(object) {
  switch (object) {
    case Emoji.EMOJI_THUMBS_UP:
      return "EMOJI_THUMBS_UP";
    case Emoji.EMOJI_THUMBS_DOWN:
      return "EMOJI_THUMBS_DOWN";
    case Emoji.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseReaction() {
  return {
    address: "",
    emojis: []
  };
}
var Reaction = exports.Reaction = {
  typeUrl: "/gitopia.gitopia.gitopia.Reaction",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.address !== "") {
      writer.uint32(10).string(message.address);
    }
    writer.uint32(18).fork();
    var _iterator = _createForOfIteratorHelper(message.emojis),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        writer.int32(v);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    writer.ldelim();
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      address: (0, _helpers.isSet)(object.address) ? String(object.address) : "",
      emojis: Array.isArray(object === null || object === void 0 ? void 0 : object.emojis) ? object.emojis.map(function (e) {
        return emojiFromJSON(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$address, _object$emojis;
    var message = createBaseReaction();
    message.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    message.emojis = ((_object$emojis = object.emojis) === null || _object$emojis === void 0 ? void 0 : _object$emojis.map(function (e) {
      return e;
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$emojis2;
    var message = createBaseReaction();
    if (object.address !== undefined && object.address !== null) {
      message.address = object.address;
    }
    message.emojis = ((_object$emojis2 = object.emojis) === null || _object$emojis2 === void 0 ? void 0 : _object$emojis2.map(function (e) {
      return e;
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.address = message.address === "" ? undefined : message.address;
    if (message.emojis) {
      obj.emojis = message.emojis.map(function (e) {
        return e;
      });
    } else {
      obj.emojis = message.emojis;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Reaction.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Reaction.decode(message.value);
  },
  toProto: function toProto(message) {
    return Reaction.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Reaction",
      value: Reaction.encode(message).finish()
    };
  }
};