import { ownerTypeFromJSON } from "./whois";
import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
export let RepositoryCollaborator_Permission = /*#__PURE__*/function (RepositoryCollaborator_Permission) {
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["READ"] = 0] = "READ";
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["TRIAGE"] = 1] = "TRIAGE";
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["WRITE"] = 2] = "WRITE";
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["MAINTAIN"] = 3] = "MAINTAIN";
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["ADMIN"] = 4] = "ADMIN";
  RepositoryCollaborator_Permission[RepositoryCollaborator_Permission["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return RepositoryCollaborator_Permission;
}({});
export const RepositoryCollaborator_PermissionSDKType = RepositoryCollaborator_Permission;
export const RepositoryCollaborator_PermissionAmino = RepositoryCollaborator_Permission;
export function repositoryCollaborator_PermissionFromJSON(object) {
  switch (object) {
    case 0:
    case "READ":
      return RepositoryCollaborator_Permission.READ;
    case 1:
    case "TRIAGE":
      return RepositoryCollaborator_Permission.TRIAGE;
    case 2:
    case "WRITE":
      return RepositoryCollaborator_Permission.WRITE;
    case 3:
    case "MAINTAIN":
      return RepositoryCollaborator_Permission.MAINTAIN;
    case 4:
    case "ADMIN":
      return RepositoryCollaborator_Permission.ADMIN;
    case -1:
    case "UNRECOGNIZED":
    default:
      return RepositoryCollaborator_Permission.UNRECOGNIZED;
  }
}
export function repositoryCollaborator_PermissionToJSON(object) {
  switch (object) {
    case RepositoryCollaborator_Permission.READ:
      return "READ";
    case RepositoryCollaborator_Permission.TRIAGE:
      return "TRIAGE";
    case RepositoryCollaborator_Permission.WRITE:
      return "WRITE";
    case RepositoryCollaborator_Permission.MAINTAIN:
      return "MAINTAIN";
    case RepositoryCollaborator_Permission.ADMIN:
      return "ADMIN";
    case RepositoryCollaborator_Permission.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
export let RepositoryBackup_Store = /*#__PURE__*/function (RepositoryBackup_Store) {
  RepositoryBackup_Store[RepositoryBackup_Store["IPFS"] = 0] = "IPFS";
  RepositoryBackup_Store[RepositoryBackup_Store["ARWEAVE"] = 1] = "ARWEAVE";
  RepositoryBackup_Store[RepositoryBackup_Store["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return RepositoryBackup_Store;
}({});
export const RepositoryBackup_StoreSDKType = RepositoryBackup_Store;
export const RepositoryBackup_StoreAmino = RepositoryBackup_Store;
export function repositoryBackup_StoreFromJSON(object) {
  switch (object) {
    case 0:
    case "IPFS":
      return RepositoryBackup_Store.IPFS;
    case 1:
    case "ARWEAVE":
      return RepositoryBackup_Store.ARWEAVE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return RepositoryBackup_Store.UNRECOGNIZED;
  }
}
export function repositoryBackup_StoreToJSON(object) {
  switch (object) {
    case RepositoryBackup_Store.IPFS:
      return "IPFS";
    case RepositoryBackup_Store.ARWEAVE:
      return "ARWEAVE";
    case RepositoryBackup_Store.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseRepository() {
  return {
    creator: "",
    id: BigInt(0),
    name: "",
    owner: undefined,
    description: "",
    forks: [],
    subscribers: "",
    commits: "",
    issuesCount: BigInt(0),
    pullsCount: BigInt(0),
    labels: [],
    labelsCount: BigInt(0),
    releases: [],
    createdAt: BigInt(0),
    updatedAt: BigInt(0),
    pushedAt: BigInt(0),
    stargazers: [],
    archived: false,
    license: "",
    defaultBranch: "",
    parent: BigInt(0),
    fork: false,
    collaborators: [],
    allowForking: false,
    backups: [],
    enableArweaveBackup: false
  };
}
export const Repository = {
  typeUrl: "/gitopia.gitopia.gitopia.Repository",
  encode(message, writer = BinaryWriter.create()) {
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.id !== BigInt(0)) {
      writer.uint32(16).uint64(message.id);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    if (message.owner !== undefined) {
      RepositoryOwner.encode(message.owner, writer.uint32(34).fork()).ldelim();
    }
    if (message.description !== "") {
      writer.uint32(42).string(message.description);
    }
    writer.uint32(50).fork();
    for (const v of message.forks) {
      writer.uint64(v);
    }
    writer.ldelim();
    if (message.subscribers !== "") {
      writer.uint32(58).string(message.subscribers);
    }
    if (message.commits !== "") {
      writer.uint32(66).string(message.commits);
    }
    if (message.issuesCount !== BigInt(0)) {
      writer.uint32(72).uint64(message.issuesCount);
    }
    if (message.pullsCount !== BigInt(0)) {
      writer.uint32(80).uint64(message.pullsCount);
    }
    for (const v of message.labels) {
      RepositoryLabel.encode(v, writer.uint32(90).fork()).ldelim();
    }
    if (message.labelsCount !== BigInt(0)) {
      writer.uint32(96).uint64(message.labelsCount);
    }
    for (const v of message.releases) {
      RepositoryRelease.encode(v, writer.uint32(106).fork()).ldelim();
    }
    if (message.createdAt !== BigInt(0)) {
      writer.uint32(112).int64(message.createdAt);
    }
    if (message.updatedAt !== BigInt(0)) {
      writer.uint32(120).int64(message.updatedAt);
    }
    if (message.pushedAt !== BigInt(0)) {
      writer.uint32(128).int64(message.pushedAt);
    }
    writer.uint32(138).fork();
    for (const v of message.stargazers) {
      writer.uint64(v);
    }
    writer.ldelim();
    if (message.archived === true) {
      writer.uint32(144).bool(message.archived);
    }
    if (message.license !== "") {
      writer.uint32(154).string(message.license);
    }
    if (message.defaultBranch !== "") {
      writer.uint32(162).string(message.defaultBranch);
    }
    if (message.parent !== BigInt(0)) {
      writer.uint32(168).uint64(message.parent);
    }
    if (message.fork === true) {
      writer.uint32(176).bool(message.fork);
    }
    for (const v of message.collaborators) {
      RepositoryCollaborator.encode(v, writer.uint32(186).fork()).ldelim();
    }
    if (message.allowForking === true) {
      writer.uint32(192).bool(message.allowForking);
    }
    for (const v of message.backups) {
      RepositoryBackup.encode(v, writer.uint32(202).fork()).ldelim();
    }
    if (message.enableArweaveBackup === true) {
      writer.uint32(208).bool(message.enableArweaveBackup);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      creator: isSet(object.creator) ? String(object.creator) : "",
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      name: isSet(object.name) ? String(object.name) : "",
      owner: isSet(object.owner) ? RepositoryOwner.fromJSON(object.owner) : undefined,
      description: isSet(object.description) ? String(object.description) : "",
      forks: Array.isArray(object === null || object === void 0 ? void 0 : object.forks) ? object.forks.map(e => BigInt(e.toString())) : [],
      subscribers: isSet(object.subscribers) ? String(object.subscribers) : "",
      commits: isSet(object.commits) ? String(object.commits) : "",
      issuesCount: isSet(object.issuesCount) ? BigInt(object.issuesCount.toString()) : BigInt(0),
      pullsCount: isSet(object.pullsCount) ? BigInt(object.pullsCount.toString()) : BigInt(0),
      labels: Array.isArray(object === null || object === void 0 ? void 0 : object.labels) ? object.labels.map(e => RepositoryLabel.fromJSON(e)) : [],
      labelsCount: isSet(object.labelsCount) ? BigInt(object.labelsCount.toString()) : BigInt(0),
      releases: Array.isArray(object === null || object === void 0 ? void 0 : object.releases) ? object.releases.map(e => RepositoryRelease.fromJSON(e)) : [],
      createdAt: isSet(object.createdAt) ? BigInt(object.createdAt.toString()) : BigInt(0),
      updatedAt: isSet(object.updatedAt) ? BigInt(object.updatedAt.toString()) : BigInt(0),
      pushedAt: isSet(object.pushedAt) ? BigInt(object.pushedAt.toString()) : BigInt(0),
      stargazers: Array.isArray(object === null || object === void 0 ? void 0 : object.stargazers) ? object.stargazers.map(e => BigInt(e.toString())) : [],
      archived: isSet(object.archived) ? Boolean(object.archived) : false,
      license: isSet(object.license) ? String(object.license) : "",
      defaultBranch: isSet(object.defaultBranch) ? String(object.defaultBranch) : "",
      parent: isSet(object.parent) ? BigInt(object.parent.toString()) : BigInt(0),
      fork: isSet(object.fork) ? Boolean(object.fork) : false,
      collaborators: Array.isArray(object === null || object === void 0 ? void 0 : object.collaborators) ? object.collaborators.map(e => RepositoryCollaborator.fromJSON(e)) : [],
      allowForking: isSet(object.allowForking) ? Boolean(object.allowForking) : false,
      backups: Array.isArray(object === null || object === void 0 ? void 0 : object.backups) ? object.backups.map(e => RepositoryBackup.fromJSON(e)) : [],
      enableArweaveBackup: isSet(object.enableArweaveBackup) ? Boolean(object.enableArweaveBackup) : false
    };
  },
  fromPartial(object) {
    var _object$creator, _object$name, _object$description, _object$forks, _object$subscribers, _object$commits, _object$labels, _object$releases, _object$stargazers, _object$archived, _object$license, _object$defaultBranch, _object$fork, _object$collaborators, _object$allowForking, _object$backups, _object$enableArweave;
    const message = createBaseRepository();
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.owner = object.owner !== undefined && object.owner !== null ? RepositoryOwner.fromPartial(object.owner) : undefined;
    message.description = (_object$description = object.description) !== null && _object$description !== void 0 ? _object$description : "";
    message.forks = ((_object$forks = object.forks) === null || _object$forks === void 0 ? void 0 : _object$forks.map(e => BigInt(e.toString()))) || [];
    message.subscribers = (_object$subscribers = object.subscribers) !== null && _object$subscribers !== void 0 ? _object$subscribers : "";
    message.commits = (_object$commits = object.commits) !== null && _object$commits !== void 0 ? _object$commits : "";
    message.issuesCount = object.issuesCount !== undefined && object.issuesCount !== null ? BigInt(object.issuesCount.toString()) : BigInt(0);
    message.pullsCount = object.pullsCount !== undefined && object.pullsCount !== null ? BigInt(object.pullsCount.toString()) : BigInt(0);
    message.labels = ((_object$labels = object.labels) === null || _object$labels === void 0 ? void 0 : _object$labels.map(e => RepositoryLabel.fromPartial(e))) || [];
    message.labelsCount = object.labelsCount !== undefined && object.labelsCount !== null ? BigInt(object.labelsCount.toString()) : BigInt(0);
    message.releases = ((_object$releases = object.releases) === null || _object$releases === void 0 ? void 0 : _object$releases.map(e => RepositoryRelease.fromPartial(e))) || [];
    message.createdAt = object.createdAt !== undefined && object.createdAt !== null ? BigInt(object.createdAt.toString()) : BigInt(0);
    message.updatedAt = object.updatedAt !== undefined && object.updatedAt !== null ? BigInt(object.updatedAt.toString()) : BigInt(0);
    message.pushedAt = object.pushedAt !== undefined && object.pushedAt !== null ? BigInt(object.pushedAt.toString()) : BigInt(0);
    message.stargazers = ((_object$stargazers = object.stargazers) === null || _object$stargazers === void 0 ? void 0 : _object$stargazers.map(e => BigInt(e.toString()))) || [];
    message.archived = (_object$archived = object.archived) !== null && _object$archived !== void 0 ? _object$archived : false;
    message.license = (_object$license = object.license) !== null && _object$license !== void 0 ? _object$license : "";
    message.defaultBranch = (_object$defaultBranch = object.defaultBranch) !== null && _object$defaultBranch !== void 0 ? _object$defaultBranch : "";
    message.parent = object.parent !== undefined && object.parent !== null ? BigInt(object.parent.toString()) : BigInt(0);
    message.fork = (_object$fork = object.fork) !== null && _object$fork !== void 0 ? _object$fork : false;
    message.collaborators = ((_object$collaborators = object.collaborators) === null || _object$collaborators === void 0 ? void 0 : _object$collaborators.map(e => RepositoryCollaborator.fromPartial(e))) || [];
    message.allowForking = (_object$allowForking = object.allowForking) !== null && _object$allowForking !== void 0 ? _object$allowForking : false;
    message.backups = ((_object$backups = object.backups) === null || _object$backups === void 0 ? void 0 : _object$backups.map(e => RepositoryBackup.fromPartial(e))) || [];
    message.enableArweaveBackup = (_object$enableArweave = object.enableArweaveBackup) !== null && _object$enableArweave !== void 0 ? _object$enableArweave : false;
    return message;
  },
  fromAmino(object) {
    var _object$forks2, _object$labels2, _object$releases2, _object$stargazers2, _object$collaborators2, _object$backups2;
    const message = createBaseRepository();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    if (object.owner !== undefined && object.owner !== null) {
      message.owner = RepositoryOwner.fromAmino(object.owner);
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = object.description;
    }
    message.forks = ((_object$forks2 = object.forks) === null || _object$forks2 === void 0 ? void 0 : _object$forks2.map(e => BigInt(e))) || [];
    if (object.subscribers !== undefined && object.subscribers !== null) {
      message.subscribers = object.subscribers;
    }
    if (object.commits !== undefined && object.commits !== null) {
      message.commits = object.commits;
    }
    if (object.issuesCount !== undefined && object.issuesCount !== null) {
      message.issuesCount = BigInt(object.issuesCount);
    }
    if (object.pullsCount !== undefined && object.pullsCount !== null) {
      message.pullsCount = BigInt(object.pullsCount);
    }
    message.labels = ((_object$labels2 = object.labels) === null || _object$labels2 === void 0 ? void 0 : _object$labels2.map(e => RepositoryLabel.fromAmino(e))) || [];
    if (object.labelsCount !== undefined && object.labelsCount !== null) {
      message.labelsCount = BigInt(object.labelsCount);
    }
    message.releases = ((_object$releases2 = object.releases) === null || _object$releases2 === void 0 ? void 0 : _object$releases2.map(e => RepositoryRelease.fromAmino(e))) || [];
    if (object.createdAt !== undefined && object.createdAt !== null) {
      message.createdAt = BigInt(object.createdAt);
    }
    if (object.updatedAt !== undefined && object.updatedAt !== null) {
      message.updatedAt = BigInt(object.updatedAt);
    }
    if (object.pushedAt !== undefined && object.pushedAt !== null) {
      message.pushedAt = BigInt(object.pushedAt);
    }
    message.stargazers = ((_object$stargazers2 = object.stargazers) === null || _object$stargazers2 === void 0 ? void 0 : _object$stargazers2.map(e => BigInt(e))) || [];
    if (object.archived !== undefined && object.archived !== null) {
      message.archived = object.archived;
    }
    if (object.license !== undefined && object.license !== null) {
      message.license = object.license;
    }
    if (object.defaultBranch !== undefined && object.defaultBranch !== null) {
      message.defaultBranch = object.defaultBranch;
    }
    if (object.parent !== undefined && object.parent !== null) {
      message.parent = BigInt(object.parent);
    }
    if (object.fork !== undefined && object.fork !== null) {
      message.fork = object.fork;
    }
    message.collaborators = ((_object$collaborators2 = object.collaborators) === null || _object$collaborators2 === void 0 ? void 0 : _object$collaborators2.map(e => RepositoryCollaborator.fromAmino(e))) || [];
    if (object.allowForking !== undefined && object.allowForking !== null) {
      message.allowForking = object.allowForking;
    }
    message.backups = ((_object$backups2 = object.backups) === null || _object$backups2 === void 0 ? void 0 : _object$backups2.map(e => RepositoryBackup.fromAmino(e))) || [];
    if (object.enableArweaveBackup !== undefined && object.enableArweaveBackup !== null) {
      message.enableArweaveBackup = object.enableArweaveBackup;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.name = message.name === "" ? undefined : message.name;
    obj.owner = message.owner ? RepositoryOwner.toAmino(message.owner) : undefined;
    obj.description = message.description === "" ? undefined : message.description;
    if (message.forks) {
      obj.forks = message.forks.map(e => e.toString());
    } else {
      obj.forks = message.forks;
    }
    obj.subscribers = message.subscribers === "" ? undefined : message.subscribers;
    obj.commits = message.commits === "" ? undefined : message.commits;
    obj.issuesCount = message.issuesCount !== BigInt(0) ? message.issuesCount.toString() : undefined;
    obj.pullsCount = message.pullsCount !== BigInt(0) ? message.pullsCount.toString() : undefined;
    if (message.labels) {
      obj.labels = message.labels.map(e => e ? RepositoryLabel.toAmino(e) : undefined);
    } else {
      obj.labels = message.labels;
    }
    obj.labelsCount = message.labelsCount !== BigInt(0) ? message.labelsCount.toString() : undefined;
    if (message.releases) {
      obj.releases = message.releases.map(e => e ? RepositoryRelease.toAmino(e) : undefined);
    } else {
      obj.releases = message.releases;
    }
    obj.createdAt = message.createdAt !== BigInt(0) ? message.createdAt.toString() : undefined;
    obj.updatedAt = message.updatedAt !== BigInt(0) ? message.updatedAt.toString() : undefined;
    obj.pushedAt = message.pushedAt !== BigInt(0) ? message.pushedAt.toString() : undefined;
    if (message.stargazers) {
      obj.stargazers = message.stargazers.map(e => e.toString());
    } else {
      obj.stargazers = message.stargazers;
    }
    obj.archived = message.archived === false ? undefined : message.archived;
    obj.license = message.license === "" ? undefined : message.license;
    obj.defaultBranch = message.defaultBranch === "" ? undefined : message.defaultBranch;
    obj.parent = message.parent !== BigInt(0) ? message.parent.toString() : undefined;
    obj.fork = message.fork === false ? undefined : message.fork;
    if (message.collaborators) {
      obj.collaborators = message.collaborators.map(e => e ? RepositoryCollaborator.toAmino(e) : undefined);
    } else {
      obj.collaborators = message.collaborators;
    }
    obj.allowForking = message.allowForking === false ? undefined : message.allowForking;
    if (message.backups) {
      obj.backups = message.backups.map(e => e ? RepositoryBackup.toAmino(e) : undefined);
    } else {
      obj.backups = message.backups;
    }
    obj.enableArweaveBackup = message.enableArweaveBackup === false ? undefined : message.enableArweaveBackup;
    return obj;
  },
  fromAminoMsg(object) {
    return Repository.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Repository.decode(message.value);
  },
  toProto(message) {
    return Repository.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Repository",
      value: Repository.encode(message).finish()
    };
  }
};
function createBaseRepositoryId() {
  return {
    id: "",
    name: ""
  };
}
export const RepositoryId = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryId",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    if (message.name !== "") {
      writer.uint32(18).string(message.name);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? String(object.id) : "",
      name: isSet(object.name) ? String(object.name) : ""
    };
  },
  fromPartial(object) {
    var _object$id, _object$name2;
    const message = createBaseRepositoryId();
    message.id = (_object$id = object.id) !== null && _object$id !== void 0 ? _object$id : "";
    message.name = (_object$name2 = object.name) !== null && _object$name2 !== void 0 ? _object$name2 : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseRepositoryId();
    if (object.id !== undefined && object.id !== null) {
      message.id = object.id;
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id === "" ? undefined : message.id;
    obj.name = message.name === "" ? undefined : message.name;
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryId.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryId.decode(message.value);
  },
  toProto(message) {
    return RepositoryId.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryId",
      value: RepositoryId.encode(message).finish()
    };
  }
};
function createBaseBaseRepositoryKey() {
  return {
    id: BigInt(0),
    address: "",
    name: ""
  };
}
export const BaseRepositoryKey = {
  typeUrl: "/gitopia.gitopia.gitopia.BaseRepositoryKey",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.address !== "") {
      writer.uint32(18).string(message.address);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      address: isSet(object.address) ? String(object.address) : "",
      name: isSet(object.name) ? String(object.name) : ""
    };
  },
  fromPartial(object) {
    var _object$address, _object$name3;
    const message = createBaseBaseRepositoryKey();
    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.name = (_object$name3 = object.name) !== null && _object$name3 !== void 0 ? _object$name3 : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseBaseRepositoryKey();
    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.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.address = message.address === "" ? undefined : message.address;
    obj.name = message.name === "" ? undefined : message.name;
    return obj;
  },
  fromAminoMsg(object) {
    return BaseRepositoryKey.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return BaseRepositoryKey.decode(message.value);
  },
  toProto(message) {
    return BaseRepositoryKey.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.BaseRepositoryKey",
      value: BaseRepositoryKey.encode(message).finish()
    };
  }
};
function createBaseRepositoryOwner() {
  return {
    id: "",
    type: 0
  };
}
export const RepositoryOwner = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryOwner",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    if (message.type !== 0) {
      writer.uint32(16).int32(message.type);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? String(object.id) : "",
      type: isSet(object.type) ? ownerTypeFromJSON(object.type) : -1
    };
  },
  fromPartial(object) {
    var _object$id2, _object$type;
    const message = createBaseRepositoryOwner();
    message.id = (_object$id2 = object.id) !== null && _object$id2 !== void 0 ? _object$id2 : "";
    message.type = (_object$type = object.type) !== null && _object$type !== void 0 ? _object$type : 0;
    return message;
  },
  fromAmino(object) {
    const message = createBaseRepositoryOwner();
    if (object.id !== undefined && object.id !== null) {
      message.id = object.id;
    }
    if (object.type !== undefined && object.type !== null) {
      message.type = object.type;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id === "" ? undefined : message.id;
    obj.type = message.type === 0 ? undefined : message.type;
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryOwner.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryOwner.decode(message.value);
  },
  toProto(message) {
    return RepositoryOwner.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryOwner",
      value: RepositoryOwner.encode(message).finish()
    };
  }
};
function createBaseIssueIid() {
  return {
    iid: BigInt(0),
    id: BigInt(0)
  };
}
export const IssueIid = {
  typeUrl: "/gitopia.gitopia.gitopia.IssueIid",
  encode(message, writer = BinaryWriter.create()) {
    if (message.iid !== BigInt(0)) {
      writer.uint32(8).uint64(message.iid);
    }
    if (message.id !== BigInt(0)) {
      writer.uint32(16).uint64(message.id);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      iid: isSet(object.iid) ? BigInt(object.iid.toString()) : BigInt(0),
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0)
    };
  },
  fromPartial(object) {
    const message = createBaseIssueIid();
    message.iid = object.iid !== undefined && object.iid !== null ? BigInt(object.iid.toString()) : BigInt(0);
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    return message;
  },
  fromAmino(object) {
    const message = createBaseIssueIid();
    if (object.iid !== undefined && object.iid !== null) {
      message.iid = BigInt(object.iid);
    }
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.iid = message.iid !== BigInt(0) ? message.iid.toString() : undefined;
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return IssueIid.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return IssueIid.decode(message.value);
  },
  toProto(message) {
    return IssueIid.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.IssueIid",
      value: IssueIid.encode(message).finish()
    };
  }
};
function createBasePullRequestIid() {
  return {
    iid: BigInt(0),
    id: BigInt(0)
  };
}
export const PullRequestIid = {
  typeUrl: "/gitopia.gitopia.gitopia.PullRequestIid",
  encode(message, writer = BinaryWriter.create()) {
    if (message.iid !== BigInt(0)) {
      writer.uint32(8).uint64(message.iid);
    }
    if (message.id !== BigInt(0)) {
      writer.uint32(16).uint64(message.id);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      iid: isSet(object.iid) ? BigInt(object.iid.toString()) : BigInt(0),
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0)
    };
  },
  fromPartial(object) {
    const message = createBasePullRequestIid();
    message.iid = object.iid !== undefined && object.iid !== null ? BigInt(object.iid.toString()) : BigInt(0);
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    return message;
  },
  fromAmino(object) {
    const message = createBasePullRequestIid();
    if (object.iid !== undefined && object.iid !== null) {
      message.iid = BigInt(object.iid);
    }
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.iid = message.iid !== BigInt(0) ? message.iid.toString() : undefined;
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    return obj;
  },
  fromAminoMsg(object) {
    return PullRequestIid.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return PullRequestIid.decode(message.value);
  },
  toProto(message) {
    return PullRequestIid.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.PullRequestIid",
      value: PullRequestIid.encode(message).finish()
    };
  }
};
function createBaseRepositoryCollaborator() {
  return {
    id: "",
    permission: 0
  };
}
export const RepositoryCollaborator = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryCollaborator",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    if (message.permission !== 0) {
      writer.uint32(16).int32(message.permission);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? String(object.id) : "",
      permission: isSet(object.permission) ? repositoryCollaborator_PermissionFromJSON(object.permission) : -1
    };
  },
  fromPartial(object) {
    var _object$id3, _object$permission;
    const message = createBaseRepositoryCollaborator();
    message.id = (_object$id3 = object.id) !== null && _object$id3 !== void 0 ? _object$id3 : "";
    message.permission = (_object$permission = object.permission) !== null && _object$permission !== void 0 ? _object$permission : 0;
    return message;
  },
  fromAmino(object) {
    const message = createBaseRepositoryCollaborator();
    if (object.id !== undefined && object.id !== null) {
      message.id = object.id;
    }
    if (object.permission !== undefined && object.permission !== null) {
      message.permission = object.permission;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id === "" ? undefined : message.id;
    obj.permission = message.permission === 0 ? undefined : message.permission;
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryCollaborator.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryCollaborator.decode(message.value);
  },
  toProto(message) {
    return RepositoryCollaborator.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryCollaborator",
      value: RepositoryCollaborator.encode(message).finish()
    };
  }
};
function createBaseRepositoryLabel() {
  return {
    id: BigInt(0),
    name: "",
    color: "",
    description: ""
  };
}
export const RepositoryLabel = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryLabel",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.name !== "") {
      writer.uint32(18).string(message.name);
    }
    if (message.color !== "") {
      writer.uint32(26).string(message.color);
    }
    if (message.description !== "") {
      writer.uint32(34).string(message.description);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      name: isSet(object.name) ? String(object.name) : "",
      color: isSet(object.color) ? String(object.color) : "",
      description: isSet(object.description) ? String(object.description) : ""
    };
  },
  fromPartial(object) {
    var _object$name4, _object$color, _object$description2;
    const message = createBaseRepositoryLabel();
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.name = (_object$name4 = object.name) !== null && _object$name4 !== void 0 ? _object$name4 : "";
    message.color = (_object$color = object.color) !== null && _object$color !== void 0 ? _object$color : "";
    message.description = (_object$description2 = object.description) !== null && _object$description2 !== void 0 ? _object$description2 : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseRepositoryLabel();
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    if (object.color !== undefined && object.color !== null) {
      message.color = object.color;
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = object.description;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.name = message.name === "" ? undefined : message.name;
    obj.color = message.color === "" ? undefined : message.color;
    obj.description = message.description === "" ? undefined : message.description;
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryLabel.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryLabel.decode(message.value);
  },
  toProto(message) {
    return RepositoryLabel.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryLabel",
      value: RepositoryLabel.encode(message).finish()
    };
  }
};
function createBaseRepositoryRelease() {
  return {
    id: BigInt(0),
    tagName: ""
  };
}
export const RepositoryRelease = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryRelease",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.tagName !== "") {
      writer.uint32(18).string(message.tagName);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      tagName: isSet(object.tagName) ? String(object.tagName) : ""
    };
  },
  fromPartial(object) {
    var _object$tagName;
    const message = createBaseRepositoryRelease();
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.tagName = (_object$tagName = object.tagName) !== null && _object$tagName !== void 0 ? _object$tagName : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseRepositoryRelease();
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.tagName !== undefined && object.tagName !== null) {
      message.tagName = object.tagName;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.tagName = message.tagName === "" ? undefined : message.tagName;
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryRelease.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryRelease.decode(message.value);
  },
  toProto(message) {
    return RepositoryRelease.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryRelease",
      value: RepositoryRelease.encode(message).finish()
    };
  }
};
function createBaseRepositoryBackup() {
  return {
    store: 0,
    refs: []
  };
}
export const RepositoryBackup = {
  typeUrl: "/gitopia.gitopia.gitopia.RepositoryBackup",
  encode(message, writer = BinaryWriter.create()) {
    if (message.store !== 0) {
      writer.uint32(8).int32(message.store);
    }
    for (const v of message.refs) {
      writer.uint32(18).string(v);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      store: isSet(object.store) ? repositoryBackup_StoreFromJSON(object.store) : -1,
      refs: Array.isArray(object === null || object === void 0 ? void 0 : object.refs) ? object.refs.map(e => String(e)) : []
    };
  },
  fromPartial(object) {
    var _object$store, _object$refs;
    const message = createBaseRepositoryBackup();
    message.store = (_object$store = object.store) !== null && _object$store !== void 0 ? _object$store : 0;
    message.refs = ((_object$refs = object.refs) === null || _object$refs === void 0 ? void 0 : _object$refs.map(e => e)) || [];
    return message;
  },
  fromAmino(object) {
    var _object$refs2;
    const message = createBaseRepositoryBackup();
    if (object.store !== undefined && object.store !== null) {
      message.store = object.store;
    }
    message.refs = ((_object$refs2 = object.refs) === null || _object$refs2 === void 0 ? void 0 : _object$refs2.map(e => e)) || [];
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.store = message.store === 0 ? undefined : message.store;
    if (message.refs) {
      obj.refs = message.refs.map(e => e);
    } else {
      obj.refs = message.refs;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return RepositoryBackup.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return RepositoryBackup.decode(message.value);
  },
  toProto(message) {
    return RepositoryBackup.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.RepositoryBackup",
      value: RepositoryBackup.encode(message).finish()
    };
  }
};