"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Params = void 0;
var _pool = require("./pool");
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; }
/** Params defines the parameters for the module. */

/** Params defines the parameters for the module. */

/** Params defines the parameters for the module. */

function createBaseParams() {
  return {
    evaluatorAddress: "",
    rewardSeries: []
  };
}
var Params = exports.Params = {
  typeUrl: "/gitopia.gitopia.rewards.Params",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.evaluatorAddress !== "") {
      writer.uint32(10).string(message.evaluatorAddress);
    }
    var _iterator = _createForOfIteratorHelper(message.rewardSeries),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _pool.RewardPool.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      evaluatorAddress: (0, _helpers.isSet)(object.evaluatorAddress) ? String(object.evaluatorAddress) : "",
      rewardSeries: Array.isArray(object === null || object === void 0 ? void 0 : object.rewardSeries) ? object.rewardSeries.map(function (e) {
        return _pool.RewardPool.fromJSON(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$evaluatorAddr, _object$rewardSeries;
    var message = createBaseParams();
    message.evaluatorAddress = (_object$evaluatorAddr = object.evaluatorAddress) !== null && _object$evaluatorAddr !== void 0 ? _object$evaluatorAddr : "";
    message.rewardSeries = ((_object$rewardSeries = object.rewardSeries) === null || _object$rewardSeries === void 0 ? void 0 : _object$rewardSeries.map(function (e) {
      return _pool.RewardPool.fromPartial(e);
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$reward_series;
    var message = createBaseParams();
    if (object.evaluator_address !== undefined && object.evaluator_address !== null) {
      message.evaluatorAddress = object.evaluator_address;
    }
    message.rewardSeries = ((_object$reward_series = object.reward_series) === null || _object$reward_series === void 0 ? void 0 : _object$reward_series.map(function (e) {
      return _pool.RewardPool.fromAmino(e);
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.evaluator_address = message.evaluatorAddress === "" ? undefined : message.evaluatorAddress;
    if (message.rewardSeries) {
      obj.reward_series = message.rewardSeries.map(function (e) {
        return e ? _pool.RewardPool.toAmino(e) : undefined;
      });
    } else {
      obj.reward_series = message.rewardSeries;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Params.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Params.decode(message.value);
  },
  toProto: function toProto(message) {
    return Params.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.rewards.Params",
      value: Params.encode(message).finish()
    };
  }
};