"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StorageTypeSDKType = exports.StorageTypeAmino = exports.StorageType = exports.ModuleSchemaDescriptor_FileEntry = exports.ModuleSchemaDescriptor = void 0;
exports.storageTypeFromJSON = storageTypeFromJSON;
exports.storageTypeToJSON = storageTypeToJSON;
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; }
/** StorageType */
var StorageType = exports.StorageType = /*#__PURE__*/function (StorageType) {
  StorageType[StorageType["STORAGE_TYPE_DEFAULT_UNSPECIFIED"] = 0] = "STORAGE_TYPE_DEFAULT_UNSPECIFIED";
  StorageType[StorageType["STORAGE_TYPE_MEMORY"] = 1] = "STORAGE_TYPE_MEMORY";
  StorageType[StorageType["STORAGE_TYPE_TRANSIENT"] = 2] = "STORAGE_TYPE_TRANSIENT";
  StorageType[StorageType["STORAGE_TYPE_INDEX"] = 3] = "STORAGE_TYPE_INDEX";
  StorageType[StorageType["STORAGE_TYPE_COMMITMENT"] = 4] = "STORAGE_TYPE_COMMITMENT";
  StorageType[StorageType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return StorageType;
}({});
var StorageTypeSDKType = exports.StorageTypeSDKType = StorageType;
var StorageTypeAmino = exports.StorageTypeAmino = StorageType;
function storageTypeFromJSON(object) {
  switch (object) {
    case 0:
    case "STORAGE_TYPE_DEFAULT_UNSPECIFIED":
      return StorageType.STORAGE_TYPE_DEFAULT_UNSPECIFIED;
    case 1:
    case "STORAGE_TYPE_MEMORY":
      return StorageType.STORAGE_TYPE_MEMORY;
    case 2:
    case "STORAGE_TYPE_TRANSIENT":
      return StorageType.STORAGE_TYPE_TRANSIENT;
    case 3:
    case "STORAGE_TYPE_INDEX":
      return StorageType.STORAGE_TYPE_INDEX;
    case 4:
    case "STORAGE_TYPE_COMMITMENT":
      return StorageType.STORAGE_TYPE_COMMITMENT;
    case -1:
    case "UNRECOGNIZED":
    default:
      return StorageType.UNRECOGNIZED;
  }
}
function storageTypeToJSON(object) {
  switch (object) {
    case StorageType.STORAGE_TYPE_DEFAULT_UNSPECIFIED:
      return "STORAGE_TYPE_DEFAULT_UNSPECIFIED";
    case StorageType.STORAGE_TYPE_MEMORY:
      return "STORAGE_TYPE_MEMORY";
    case StorageType.STORAGE_TYPE_TRANSIENT:
      return "STORAGE_TYPE_TRANSIENT";
    case StorageType.STORAGE_TYPE_INDEX:
      return "STORAGE_TYPE_INDEX";
    case StorageType.STORAGE_TYPE_COMMITMENT:
      return "STORAGE_TYPE_COMMITMENT";
    case StorageType.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
/** ModuleSchemaDescriptor describe's a module's ORM schema. */

/** ModuleSchemaDescriptor describe's a module's ORM schema. */

/** ModuleSchemaDescriptor describe's a module's ORM schema. */

/** FileEntry describes an ORM file used in a module. */

/** FileEntry describes an ORM file used in a module. */

/** FileEntry describes an ORM file used in a module. */

function createBaseModuleSchemaDescriptor() {
  return {
    schemaFile: [],
    prefix: new Uint8Array()
  };
}
var ModuleSchemaDescriptor = exports.ModuleSchemaDescriptor = {
  typeUrl: "/cosmos.orm.v1alpha1.ModuleSchemaDescriptor",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    var _iterator = _createForOfIteratorHelper(message.schemaFile),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        ModuleSchemaDescriptor_FileEntry.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    if (message.prefix.length !== 0) {
      writer.uint32(18).bytes(message.prefix);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      schemaFile: Array.isArray(object === null || object === void 0 ? void 0 : object.schemaFile) ? object.schemaFile.map(function (e) {
        return ModuleSchemaDescriptor_FileEntry.fromJSON(e);
      }) : [],
      prefix: (0, _helpers.isSet)(object.prefix) ? (0, _helpers.bytesFromBase64)(object.prefix) : new Uint8Array()
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$schemaFile, _object$prefix;
    var message = createBaseModuleSchemaDescriptor();
    message.schemaFile = ((_object$schemaFile = object.schemaFile) === null || _object$schemaFile === void 0 ? void 0 : _object$schemaFile.map(function (e) {
      return ModuleSchemaDescriptor_FileEntry.fromPartial(e);
    })) || [];
    message.prefix = (_object$prefix = object.prefix) !== null && _object$prefix !== void 0 ? _object$prefix : new Uint8Array();
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$schema_file;
    var message = createBaseModuleSchemaDescriptor();
    message.schemaFile = ((_object$schema_file = object.schema_file) === null || _object$schema_file === void 0 ? void 0 : _object$schema_file.map(function (e) {
      return ModuleSchemaDescriptor_FileEntry.fromAmino(e);
    })) || [];
    if (object.prefix !== undefined && object.prefix !== null) {
      message.prefix = (0, _helpers.bytesFromBase64)(object.prefix);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    if (message.schemaFile) {
      obj.schema_file = message.schemaFile.map(function (e) {
        return e ? ModuleSchemaDescriptor_FileEntry.toAmino(e) : undefined;
      });
    } else {
      obj.schema_file = message.schemaFile;
    }
    obj.prefix = message.prefix ? (0, _helpers.base64FromBytes)(message.prefix) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return ModuleSchemaDescriptor.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/ModuleSchemaDescriptor",
      value: ModuleSchemaDescriptor.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return ModuleSchemaDescriptor.decode(message.value);
  },
  toProto: function toProto(message) {
    return ModuleSchemaDescriptor.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.orm.v1alpha1.ModuleSchemaDescriptor",
      value: ModuleSchemaDescriptor.encode(message).finish()
    };
  }
};
function createBaseModuleSchemaDescriptor_FileEntry() {
  return {
    id: 0,
    protoFileName: "",
    storageType: 0
  };
}
var ModuleSchemaDescriptor_FileEntry = exports.ModuleSchemaDescriptor_FileEntry = {
  typeUrl: "/cosmos.orm.v1alpha1.FileEntry",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.id !== 0) {
      writer.uint32(8).uint32(message.id);
    }
    if (message.protoFileName !== "") {
      writer.uint32(18).string(message.protoFileName);
    }
    if (message.storageType !== 0) {
      writer.uint32(24).int32(message.storageType);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      id: (0, _helpers.isSet)(object.id) ? Number(object.id) : 0,
      protoFileName: (0, _helpers.isSet)(object.protoFileName) ? String(object.protoFileName) : "",
      storageType: (0, _helpers.isSet)(object.storageType) ? storageTypeFromJSON(object.storageType) : -1
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$id, _object$protoFileName, _object$storageType;
    var message = createBaseModuleSchemaDescriptor_FileEntry();
    message.id = (_object$id = object.id) !== null && _object$id !== void 0 ? _object$id : 0;
    message.protoFileName = (_object$protoFileName = object.protoFileName) !== null && _object$protoFileName !== void 0 ? _object$protoFileName : "";
    message.storageType = (_object$storageType = object.storageType) !== null && _object$storageType !== void 0 ? _object$storageType : 0;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseModuleSchemaDescriptor_FileEntry();
    if (object.id !== undefined && object.id !== null) {
      message.id = object.id;
    }
    if (object.proto_file_name !== undefined && object.proto_file_name !== null) {
      message.protoFileName = object.proto_file_name;
    }
    if (object.storage_type !== undefined && object.storage_type !== null) {
      message.storageType = object.storage_type;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.id = message.id === 0 ? undefined : message.id;
    obj.proto_file_name = message.protoFileName === "" ? undefined : message.protoFileName;
    obj.storage_type = message.storageType === 0 ? undefined : message.storageType;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return ModuleSchemaDescriptor_FileEntry.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/FileEntry",
      value: ModuleSchemaDescriptor_FileEntry.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return ModuleSchemaDescriptor_FileEntry.decode(message.value);
  },
  toProto: function toProto(message) {
    return ModuleSchemaDescriptor_FileEntry.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.orm.v1alpha1.FileEntry",
      value: ModuleSchemaDescriptor_FileEntry.encode(message).finish()
    };
  }
};