"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListResponse = exports.ListRequest_Range = exports.ListRequest_Prefix = exports.ListRequest = exports.IndexValue = exports.GetResponse = exports.GetRequest = void 0;
var _pagination = require("../../../base/query/v1beta1/pagination");
var _any = require("../../../../google/protobuf/any");
var _timestamp = require("../../../../google/protobuf/timestamp");
var _duration = require("../../../../google/protobuf/duration");
var _helpers = require("../../../../helpers");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
/** GetRequest is the Query/Get request type. */

/** GetRequest is the Query/Get request type. */

/** GetResponse is the Query/Get response type. */

/** GetResponse is the Query/Get response type. */

/** ListRequest is the Query/List request type. */

/** ListRequest is the Query/List request type. */

/** Prefix specifies the arguments to a prefix query. */

/** Prefix specifies the arguments to a prefix query. */

/** Range specifies the arguments to a range query. */

/** Range specifies the arguments to a range query. */

/** ListResponse is the Query/List response type. */

/** ListResponse is the Query/List response type. */

/** IndexValue represents the value of a field in an ORM index expression. */

/** IndexValue represents the value of a field in an ORM index expression. */

function createBaseGetRequest() {
  return {
    messageName: "",
    index: "",
    values: []
  };
}
var GetRequest = exports.GetRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.messageName !== "") {
      writer.uint32(10).string(message.messageName);
    }
    if (message.index !== "") {
      writer.uint32(18).string(message.index);
    }
    var _iterator = _createForOfIteratorHelper(message.values),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        IndexValue.encode(v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseGetRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.messageName = reader.string();
          break;
        case 2:
          message.index = reader.string();
          break;
        case 3:
          message.values.push(IndexValue.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      messageName: (0, _helpers.isSet)(object.messageName) ? String(object.messageName) : "",
      index: (0, _helpers.isSet)(object.index) ? String(object.index) : "",
      values: Array.isArray(object === null || object === void 0 ? void 0 : object.values) ? object.values.map(function (e) {
        return IndexValue.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.messageName !== undefined && (obj.messageName = message.messageName);
    message.index !== undefined && (obj.index = message.index);
    if (message.values) {
      obj.values = message.values.map(function (e) {
        return e ? IndexValue.toJSON(e) : undefined;
      });
    } else {
      obj.values = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$messageName, _object$index, _object$values;
    var message = createBaseGetRequest();
    message.messageName = (_object$messageName = object.messageName) !== null && _object$messageName !== void 0 ? _object$messageName : "";
    message.index = (_object$index = object.index) !== null && _object$index !== void 0 ? _object$index : "";
    message.values = ((_object$values = object.values) === null || _object$values === void 0 ? void 0 : _object$values.map(function (e) {
      return IndexValue.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseGetResponse() {
  return {
    result: undefined
  };
}
var GetResponse = exports.GetResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.result !== undefined) {
      _any.Any.encode(message.result, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseGetResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.result = _any.Any.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      result: (0, _helpers.isSet)(object.result) ? _any.Any.fromJSON(object.result) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.result !== undefined && (obj.result = message.result ? _any.Any.toJSON(message.result) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseGetResponse();
    message.result = object.result !== undefined && object.result !== null ? _any.Any.fromPartial(object.result) : undefined;
    return message;
  }
};
function createBaseListRequest() {
  return {
    messageName: "",
    index: "",
    prefix: undefined,
    range: undefined,
    pagination: undefined
  };
}
var ListRequest = exports.ListRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.messageName !== "") {
      writer.uint32(10).string(message.messageName);
    }
    if (message.index !== "") {
      writer.uint32(18).string(message.index);
    }
    if (message.prefix !== undefined) {
      ListRequest_Prefix.encode(message.prefix, writer.uint32(26).fork()).ldelim();
    }
    if (message.range !== undefined) {
      ListRequest_Range.encode(message.range, writer.uint32(34).fork()).ldelim();
    }
    if (message.pagination !== undefined) {
      _pagination.PageRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.messageName = reader.string();
          break;
        case 2:
          message.index = reader.string();
          break;
        case 3:
          message.prefix = ListRequest_Prefix.decode(reader, reader.uint32());
          break;
        case 4:
          message.range = ListRequest_Range.decode(reader, reader.uint32());
          break;
        case 5:
          message.pagination = _pagination.PageRequest.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      messageName: (0, _helpers.isSet)(object.messageName) ? String(object.messageName) : "",
      index: (0, _helpers.isSet)(object.index) ? String(object.index) : "",
      prefix: (0, _helpers.isSet)(object.prefix) ? ListRequest_Prefix.fromJSON(object.prefix) : undefined,
      range: (0, _helpers.isSet)(object.range) ? ListRequest_Range.fromJSON(object.range) : undefined,
      pagination: (0, _helpers.isSet)(object.pagination) ? _pagination.PageRequest.fromJSON(object.pagination) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.messageName !== undefined && (obj.messageName = message.messageName);
    message.index !== undefined && (obj.index = message.index);
    message.prefix !== undefined && (obj.prefix = message.prefix ? ListRequest_Prefix.toJSON(message.prefix) : undefined);
    message.range !== undefined && (obj.range = message.range ? ListRequest_Range.toJSON(message.range) : undefined);
    message.pagination !== undefined && (obj.pagination = message.pagination ? _pagination.PageRequest.toJSON(message.pagination) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$messageName2, _object$index2;
    var message = createBaseListRequest();
    message.messageName = (_object$messageName2 = object.messageName) !== null && _object$messageName2 !== void 0 ? _object$messageName2 : "";
    message.index = (_object$index2 = object.index) !== null && _object$index2 !== void 0 ? _object$index2 : "";
    message.prefix = object.prefix !== undefined && object.prefix !== null ? ListRequest_Prefix.fromPartial(object.prefix) : undefined;
    message.range = object.range !== undefined && object.range !== null ? ListRequest_Range.fromPartial(object.range) : undefined;
    message.pagination = object.pagination !== undefined && object.pagination !== null ? _pagination.PageRequest.fromPartial(object.pagination) : undefined;
    return message;
  }
};
function createBaseListRequest_Prefix() {
  return {
    values: []
  };
}
var ListRequest_Prefix = exports.ListRequest_Prefix = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator2 = _createForOfIteratorHelper(message.values),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var v = _step2.value;
        IndexValue.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListRequest_Prefix();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.values.push(IndexValue.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      values: Array.isArray(object === null || object === void 0 ? void 0 : object.values) ? object.values.map(function (e) {
        return IndexValue.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    if (message.values) {
      obj.values = message.values.map(function (e) {
        return e ? IndexValue.toJSON(e) : undefined;
      });
    } else {
      obj.values = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$values2;
    var message = createBaseListRequest_Prefix();
    message.values = ((_object$values2 = object.values) === null || _object$values2 === void 0 ? void 0 : _object$values2.map(function (e) {
      return IndexValue.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseListRequest_Range() {
  return {
    start: [],
    end: []
  };
}
var ListRequest_Range = exports.ListRequest_Range = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator3 = _createForOfIteratorHelper(message.start),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var v = _step3.value;
        IndexValue.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    var _iterator4 = _createForOfIteratorHelper(message.end),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var _v = _step4.value;
        IndexValue.encode(_v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListRequest_Range();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.start.push(IndexValue.decode(reader, reader.uint32()));
          break;
        case 2:
          message.end.push(IndexValue.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      start: Array.isArray(object === null || object === void 0 ? void 0 : object.start) ? object.start.map(function (e) {
        return IndexValue.fromJSON(e);
      }) : [],
      end: Array.isArray(object === null || object === void 0 ? void 0 : object.end) ? object.end.map(function (e) {
        return IndexValue.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    if (message.start) {
      obj.start = message.start.map(function (e) {
        return e ? IndexValue.toJSON(e) : undefined;
      });
    } else {
      obj.start = [];
    }
    if (message.end) {
      obj.end = message.end.map(function (e) {
        return e ? IndexValue.toJSON(e) : undefined;
      });
    } else {
      obj.end = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$start, _object$end;
    var message = createBaseListRequest_Range();
    message.start = ((_object$start = object.start) === null || _object$start === void 0 ? void 0 : _object$start.map(function (e) {
      return IndexValue.fromPartial(e);
    })) || [];
    message.end = ((_object$end = object.end) === null || _object$end === void 0 ? void 0 : _object$end.map(function (e) {
      return IndexValue.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseListResponse() {
  return {
    results: [],
    pagination: undefined
  };
}
var ListResponse = exports.ListResponse = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    var _iterator5 = _createForOfIteratorHelper(message.results),
      _step5;
    try {
      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
        var v = _step5.value;
        _any.Any.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator5.e(err);
    } finally {
      _iterator5.f();
    }
    if (message.pagination !== undefined) {
      _pagination.PageResponse.encode(message.pagination, writer.uint32(42).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.results.push(_any.Any.decode(reader, reader.uint32()));
          break;
        case 5:
          message.pagination = _pagination.PageResponse.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      results: Array.isArray(object === null || object === void 0 ? void 0 : object.results) ? object.results.map(function (e) {
        return _any.Any.fromJSON(e);
      }) : [],
      pagination: (0, _helpers.isSet)(object.pagination) ? _pagination.PageResponse.fromJSON(object.pagination) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    if (message.results) {
      obj.results = message.results.map(function (e) {
        return e ? _any.Any.toJSON(e) : undefined;
      });
    } else {
      obj.results = [];
    }
    message.pagination !== undefined && (obj.pagination = message.pagination ? _pagination.PageResponse.toJSON(message.pagination) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$results;
    var message = createBaseListResponse();
    message.results = ((_object$results = object.results) === null || _object$results === void 0 ? void 0 : _object$results.map(function (e) {
      return _any.Any.fromPartial(e);
    })) || [];
    message.pagination = object.pagination !== undefined && object.pagination !== null ? _pagination.PageResponse.fromPartial(object.pagination) : undefined;
    return message;
  }
};
function createBaseIndexValue() {
  return {
    uint: undefined,
    "int": undefined,
    str: undefined,
    bytes: undefined,
    "enum": undefined,
    bool: undefined,
    timestamp: undefined,
    duration: undefined
  };
}
var IndexValue = exports.IndexValue = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.uint !== undefined) {
      writer.uint32(8).uint64(message.uint);
    }
    if (message["int"] !== undefined) {
      writer.uint32(16).int64(message["int"]);
    }
    if (message.str !== undefined) {
      writer.uint32(26).string(message.str);
    }
    if (message.bytes !== undefined) {
      writer.uint32(34).bytes(message.bytes);
    }
    if (message["enum"] !== undefined) {
      writer.uint32(42).string(message["enum"]);
    }
    if (message.bool !== undefined) {
      writer.uint32(48).bool(message.bool);
    }
    if (message.timestamp !== undefined) {
      _timestamp.Timestamp.encode(message.timestamp, writer.uint32(58).fork()).ldelim();
    }
    if (message.duration !== undefined) {
      _duration.Duration.encode(message.duration, writer.uint32(66).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseIndexValue();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.uint = reader.uint64();
          break;
        case 2:
          message["int"] = reader.int64();
          break;
        case 3:
          message.str = reader.string();
          break;
        case 4:
          message.bytes = reader.bytes();
          break;
        case 5:
          message["enum"] = reader.string();
          break;
        case 6:
          message.bool = reader.bool();
          break;
        case 7:
          message.timestamp = _timestamp.Timestamp.decode(reader, reader.uint32());
          break;
        case 8:
          message.duration = _duration.Duration.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      uint: (0, _helpers.isSet)(object.uint) ? _helpers.Long.fromValue(object.uint) : undefined,
      "int": (0, _helpers.isSet)(object["int"]) ? _helpers.Long.fromValue(object["int"]) : undefined,
      str: (0, _helpers.isSet)(object.str) ? String(object.str) : undefined,
      bytes: (0, _helpers.isSet)(object.bytes) ? (0, _helpers.bytesFromBase64)(object.bytes) : undefined,
      "enum": (0, _helpers.isSet)(object["enum"]) ? String(object["enum"]) : undefined,
      bool: (0, _helpers.isSet)(object.bool) ? Boolean(object.bool) : undefined,
      timestamp: (0, _helpers.isSet)(object.timestamp) ? (0, _helpers.fromJsonTimestamp)(object.timestamp) : undefined,
      duration: (0, _helpers.isSet)(object.duration) ? _duration.Duration.fromJSON(object.duration) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.uint !== undefined && (obj.uint = (message.uint || undefined).toString());
    message["int"] !== undefined && (obj["int"] = (message["int"] || undefined).toString());
    message.str !== undefined && (obj.str = message.str);
    message.bytes !== undefined && (obj.bytes = message.bytes !== undefined ? (0, _helpers.base64FromBytes)(message.bytes) : undefined);
    message["enum"] !== undefined && (obj["enum"] = message["enum"]);
    message.bool !== undefined && (obj.bool = message.bool);
    message.timestamp !== undefined && (obj.timestamp = (0, _helpers.fromTimestamp)(message.timestamp).toISOString());
    message.duration !== undefined && (obj.duration = message.duration ? _duration.Duration.toJSON(message.duration) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$str, _object$bytes, _object$enum, _object$bool;
    var message = createBaseIndexValue();
    message.uint = object.uint !== undefined && object.uint !== null ? _helpers.Long.fromValue(object.uint) : undefined;
    message["int"] = object["int"] !== undefined && object["int"] !== null ? _helpers.Long.fromValue(object["int"]) : undefined;
    message.str = (_object$str = object.str) !== null && _object$str !== void 0 ? _object$str : undefined;
    message.bytes = (_object$bytes = object.bytes) !== null && _object$bytes !== void 0 ? _object$bytes : undefined;
    message["enum"] = (_object$enum = object["enum"]) !== null && _object$enum !== void 0 ? _object$enum : undefined;
    message.bool = (_object$bool = object.bool) !== null && _object$bool !== void 0 ? _object$bool : undefined;
    message.timestamp = object.timestamp !== undefined && object.timestamp !== null ? _timestamp.Timestamp.fromPartial(object.timestamp) : undefined;
    message.duration = object.duration !== undefined && object.duration !== null ? _duration.Duration.fromPartial(object.duration) : undefined;
    return message;
  }
};