/**
 * #postv2.ts
 *
 * @packageDocumentation
 */
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { messageTypeRegistry } from "../../../typeRegistry.js";
import { LinkFlairV2, UserFlairV2 } from "./flair.js";
export var CrowdControlLevel;
(function (CrowdControlLevel) {
    CrowdControlLevel[CrowdControlLevel["OFF"] = 0] = "OFF";
    CrowdControlLevel[CrowdControlLevel["LENIENT"] = 1] = "LENIENT";
    CrowdControlLevel[CrowdControlLevel["MEDIUM"] = 2] = "MEDIUM";
    CrowdControlLevel[CrowdControlLevel["STRICT"] = 3] = "STRICT";
    CrowdControlLevel[CrowdControlLevel["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CrowdControlLevel || (CrowdControlLevel = {}));
export function crowdControlLevelFromJSON(object) {
    switch (object) {
        case 0:
        case "OFF":
            return CrowdControlLevel.OFF;
        case 1:
        case "LENIENT":
            return CrowdControlLevel.LENIENT;
        case 2:
        case "MEDIUM":
            return CrowdControlLevel.MEDIUM;
        case 3:
        case "STRICT":
            return CrowdControlLevel.STRICT;
        case -1:
        case "UNRECOGNIZED":
        default:
            return CrowdControlLevel.UNRECOGNIZED;
    }
}
export function crowdControlLevelToJSON(object) {
    switch (object) {
        case CrowdControlLevel.OFF:
            return 0;
        case CrowdControlLevel.LENIENT:
            return 1;
        case CrowdControlLevel.MEDIUM:
            return 2;
        case CrowdControlLevel.STRICT:
            return 3;
        case CrowdControlLevel.UNRECOGNIZED:
        default:
            return -1;
    }
}
export var DistinguishType;
(function (DistinguishType) {
    DistinguishType[DistinguishType["NULL_VALUE"] = 0] = "NULL_VALUE";
    DistinguishType[DistinguishType["ADMIN"] = 1] = "ADMIN";
    DistinguishType[DistinguishType["GOLD"] = 2] = "GOLD";
    DistinguishType[DistinguishType["GOLD_AUTO"] = 3] = "GOLD_AUTO";
    DistinguishType[DistinguishType["YES"] = 4] = "YES";
    DistinguishType[DistinguishType["SPECIAL"] = 5] = "SPECIAL";
    DistinguishType[DistinguishType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(DistinguishType || (DistinguishType = {}));
export function distinguishTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "NULL_VALUE":
            return DistinguishType.NULL_VALUE;
        case 1:
        case "ADMIN":
            return DistinguishType.ADMIN;
        case 2:
        case "GOLD":
            return DistinguishType.GOLD;
        case 3:
        case "GOLD_AUTO":
            return DistinguishType.GOLD_AUTO;
        case 4:
        case "YES":
            return DistinguishType.YES;
        case 5:
        case "SPECIAL":
            return DistinguishType.SPECIAL;
        case -1:
        case "UNRECOGNIZED":
        default:
            return DistinguishType.UNRECOGNIZED;
    }
}
export function distinguishTypeToJSON(object) {
    switch (object) {
        case DistinguishType.NULL_VALUE:
            return 0;
        case DistinguishType.ADMIN:
            return 1;
        case DistinguishType.GOLD:
            return 2;
        case DistinguishType.GOLD_AUTO:
            return 3;
        case DistinguishType.YES:
            return 4;
        case DistinguishType.SPECIAL:
            return 5;
        case DistinguishType.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBasePostV2() {
    return {
        id: "",
        title: "",
        selftext: "",
        nsfw: false,
        authorId: "",
        crowdControlLevel: 0,
        numReports: 0,
        isGallery: false,
        isMeta: false,
        createdAt: 0,
        isApproved: false,
        isArchived: false,
        distinguished: 0,
        ignoreReports: false,
        isSelf: false,
        isVideo: false,
        isLocked: false,
        isSpoiler: false,
        subredditId: "",
        upvotes: 0,
        downvotes: 0,
        url: "",
        isSticky: false,
        linkFlair: undefined,
        authorFlair: undefined,
        spam: false,
        deleted: false,
        languageCode: "",
        updatedAt: 0,
        gildings: 0,
        score: 0,
        numComments: 0,
        thumbnail: "",
        media: undefined,
        crosspostParentId: "",
        permalink: "",
        isPoll: false,
        isPromoted: false,
        isMultiMedia: false,
        type: "",
        unlisted: false,
        galleryImages: [],
        isImage: false,
        mediaUrls: [],
        isClubContent: false,
    };
}
export const PostV2 = {
    $type: "devvit.reddit.v2alpha.PostV2",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.title !== "") {
            writer.uint32(18).string(message.title);
        }
        if (message.selftext !== "") {
            writer.uint32(26).string(message.selftext);
        }
        if (message.nsfw !== false) {
            writer.uint32(32).bool(message.nsfw);
        }
        if (message.authorId !== "") {
            writer.uint32(42).string(message.authorId);
        }
        if (message.crowdControlLevel !== 0) {
            writer.uint32(48).int32(message.crowdControlLevel);
        }
        if (message.numReports !== 0) {
            writer.uint32(56).int32(message.numReports);
        }
        if (message.isGallery !== false) {
            writer.uint32(64).bool(message.isGallery);
        }
        if (message.isMeta !== false) {
            writer.uint32(72).bool(message.isMeta);
        }
        if (message.createdAt !== 0) {
            writer.uint32(80).int64(message.createdAt);
        }
        if (message.isApproved !== false) {
            writer.uint32(88).bool(message.isApproved);
        }
        if (message.isArchived !== false) {
            writer.uint32(96).bool(message.isArchived);
        }
        if (message.distinguished !== 0) {
            writer.uint32(104).int32(message.distinguished);
        }
        if (message.ignoreReports !== false) {
            writer.uint32(112).bool(message.ignoreReports);
        }
        if (message.isSelf !== false) {
            writer.uint32(120).bool(message.isSelf);
        }
        if (message.isVideo !== false) {
            writer.uint32(128).bool(message.isVideo);
        }
        if (message.isLocked !== false) {
            writer.uint32(136).bool(message.isLocked);
        }
        if (message.isSpoiler !== false) {
            writer.uint32(144).bool(message.isSpoiler);
        }
        if (message.subredditId !== "") {
            writer.uint32(154).string(message.subredditId);
        }
        if (message.upvotes !== 0) {
            writer.uint32(160).int32(message.upvotes);
        }
        if (message.downvotes !== 0) {
            writer.uint32(168).int32(message.downvotes);
        }
        if (message.url !== "") {
            writer.uint32(178).string(message.url);
        }
        if (message.isSticky !== false) {
            writer.uint32(184).bool(message.isSticky);
        }
        if (message.linkFlair !== undefined) {
            LinkFlairV2.encode(message.linkFlair, writer.uint32(194).fork()).ldelim();
        }
        if (message.authorFlair !== undefined) {
            UserFlairV2.encode(message.authorFlair, writer.uint32(202).fork()).ldelim();
        }
        if (message.spam !== false) {
            writer.uint32(208).bool(message.spam);
        }
        if (message.deleted !== false) {
            writer.uint32(216).bool(message.deleted);
        }
        if (message.languageCode !== "") {
            writer.uint32(226).string(message.languageCode);
        }
        if (message.updatedAt !== 0) {
            writer.uint32(232).int64(message.updatedAt);
        }
        if (message.gildings !== 0) {
            writer.uint32(240).int32(message.gildings);
        }
        if (message.score !== 0) {
            writer.uint32(248).int32(message.score);
        }
        if (message.numComments !== 0) {
            writer.uint32(256).int32(message.numComments);
        }
        if (message.thumbnail !== "") {
            writer.uint32(266).string(message.thumbnail);
        }
        if (message.media !== undefined) {
            MediaObject.encode(message.media, writer.uint32(274).fork()).ldelim();
        }
        if (message.crosspostParentId !== "") {
            writer.uint32(282).string(message.crosspostParentId);
        }
        if (message.permalink !== "") {
            writer.uint32(290).string(message.permalink);
        }
        if (message.isPoll !== false) {
            writer.uint32(296).bool(message.isPoll);
        }
        if (message.isPromoted !== false) {
            writer.uint32(304).bool(message.isPromoted);
        }
        if (message.isMultiMedia !== false) {
            writer.uint32(312).bool(message.isMultiMedia);
        }
        if (message.type !== "") {
            writer.uint32(322).string(message.type);
        }
        if (message.unlisted !== false) {
            writer.uint32(328).bool(message.unlisted);
        }
        for (const v of message.galleryImages) {
            writer.uint32(338).string(v);
        }
        if (message.isImage !== false) {
            writer.uint32(344).bool(message.isImage);
        }
        for (const v of message.mediaUrls) {
            writer.uint32(354).string(v);
        }
        if (message.isClubContent !== false) {
            writer.uint32(360).bool(message.isClubContent);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBasePostV2();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.title = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.selftext = reader.string();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.nsfw = reader.bool();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.authorId = reader.string();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.crowdControlLevel = reader.int32();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.numReports = reader.int32();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.isGallery = reader.bool();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.isMeta = reader.bool();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.createdAt = longToNumber(reader.int64());
                    continue;
                case 11:
                    if (tag !== 88) {
                        break;
                    }
                    message.isApproved = reader.bool();
                    continue;
                case 12:
                    if (tag !== 96) {
                        break;
                    }
                    message.isArchived = reader.bool();
                    continue;
                case 13:
                    if (tag !== 104) {
                        break;
                    }
                    message.distinguished = reader.int32();
                    continue;
                case 14:
                    if (tag !== 112) {
                        break;
                    }
                    message.ignoreReports = reader.bool();
                    continue;
                case 15:
                    if (tag !== 120) {
                        break;
                    }
                    message.isSelf = reader.bool();
                    continue;
                case 16:
                    if (tag !== 128) {
                        break;
                    }
                    message.isVideo = reader.bool();
                    continue;
                case 17:
                    if (tag !== 136) {
                        break;
                    }
                    message.isLocked = reader.bool();
                    continue;
                case 18:
                    if (tag !== 144) {
                        break;
                    }
                    message.isSpoiler = reader.bool();
                    continue;
                case 19:
                    if (tag !== 154) {
                        break;
                    }
                    message.subredditId = reader.string();
                    continue;
                case 20:
                    if (tag !== 160) {
                        break;
                    }
                    message.upvotes = reader.int32();
                    continue;
                case 21:
                    if (tag !== 168) {
                        break;
                    }
                    message.downvotes = reader.int32();
                    continue;
                case 22:
                    if (tag !== 178) {
                        break;
                    }
                    message.url = reader.string();
                    continue;
                case 23:
                    if (tag !== 184) {
                        break;
                    }
                    message.isSticky = reader.bool();
                    continue;
                case 24:
                    if (tag !== 194) {
                        break;
                    }
                    message.linkFlair = LinkFlairV2.decode(reader, reader.uint32());
                    continue;
                case 25:
                    if (tag !== 202) {
                        break;
                    }
                    message.authorFlair = UserFlairV2.decode(reader, reader.uint32());
                    continue;
                case 26:
                    if (tag !== 208) {
                        break;
                    }
                    message.spam = reader.bool();
                    continue;
                case 27:
                    if (tag !== 216) {
                        break;
                    }
                    message.deleted = reader.bool();
                    continue;
                case 28:
                    if (tag !== 226) {
                        break;
                    }
                    message.languageCode = reader.string();
                    continue;
                case 29:
                    if (tag !== 232) {
                        break;
                    }
                    message.updatedAt = longToNumber(reader.int64());
                    continue;
                case 30:
                    if (tag !== 240) {
                        break;
                    }
                    message.gildings = reader.int32();
                    continue;
                case 31:
                    if (tag !== 248) {
                        break;
                    }
                    message.score = reader.int32();
                    continue;
                case 32:
                    if (tag !== 256) {
                        break;
                    }
                    message.numComments = reader.int32();
                    continue;
                case 33:
                    if (tag !== 266) {
                        break;
                    }
                    message.thumbnail = reader.string();
                    continue;
                case 34:
                    if (tag !== 274) {
                        break;
                    }
                    message.media = MediaObject.decode(reader, reader.uint32());
                    continue;
                case 35:
                    if (tag !== 282) {
                        break;
                    }
                    message.crosspostParentId = reader.string();
                    continue;
                case 36:
                    if (tag !== 290) {
                        break;
                    }
                    message.permalink = reader.string();
                    continue;
                case 37:
                    if (tag !== 296) {
                        break;
                    }
                    message.isPoll = reader.bool();
                    continue;
                case 38:
                    if (tag !== 304) {
                        break;
                    }
                    message.isPromoted = reader.bool();
                    continue;
                case 39:
                    if (tag !== 312) {
                        break;
                    }
                    message.isMultiMedia = reader.bool();
                    continue;
                case 40:
                    if (tag !== 322) {
                        break;
                    }
                    message.type = reader.string();
                    continue;
                case 41:
                    if (tag !== 328) {
                        break;
                    }
                    message.unlisted = reader.bool();
                    continue;
                case 42:
                    if (tag !== 338) {
                        break;
                    }
                    message.galleryImages.push(reader.string());
                    continue;
                case 43:
                    if (tag !== 344) {
                        break;
                    }
                    message.isImage = reader.bool();
                    continue;
                case 44:
                    if (tag !== 354) {
                        break;
                    }
                    message.mediaUrls.push(reader.string());
                    continue;
                case 45:
                    if (tag !== 360) {
                        break;
                    }
                    message.isClubContent = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            title: isSet(object.title) ? globalThis.String(object.title) : "",
            selftext: isSet(object.selftext) ? globalThis.String(object.selftext) : "",
            nsfw: isSet(object.nsfw) ? globalThis.Boolean(object.nsfw) : false,
            authorId: isSet(object.authorId) ? globalThis.String(object.authorId) : "",
            crowdControlLevel: isSet(object.crowdControlLevel) ? crowdControlLevelFromJSON(object.crowdControlLevel) : 0,
            numReports: isSet(object.numReports) ? globalThis.Number(object.numReports) : 0,
            isGallery: isSet(object.isGallery) ? globalThis.Boolean(object.isGallery) : false,
            isMeta: isSet(object.isMeta) ? globalThis.Boolean(object.isMeta) : false,
            createdAt: isSet(object.createdAt) ? globalThis.Number(object.createdAt) : 0,
            isApproved: isSet(object.isApproved) ? globalThis.Boolean(object.isApproved) : false,
            isArchived: isSet(object.isArchived) ? globalThis.Boolean(object.isArchived) : false,
            distinguished: isSet(object.distinguished) ? distinguishTypeFromJSON(object.distinguished) : 0,
            ignoreReports: isSet(object.ignoreReports) ? globalThis.Boolean(object.ignoreReports) : false,
            isSelf: isSet(object.isSelf) ? globalThis.Boolean(object.isSelf) : false,
            isVideo: isSet(object.isVideo) ? globalThis.Boolean(object.isVideo) : false,
            isLocked: isSet(object.isLocked) ? globalThis.Boolean(object.isLocked) : false,
            isSpoiler: isSet(object.isSpoiler) ? globalThis.Boolean(object.isSpoiler) : false,
            subredditId: isSet(object.subredditId) ? globalThis.String(object.subredditId) : "",
            upvotes: isSet(object.upvotes) ? globalThis.Number(object.upvotes) : 0,
            downvotes: isSet(object.downvotes) ? globalThis.Number(object.downvotes) : 0,
            url: isSet(object.url) ? globalThis.String(object.url) : "",
            isSticky: isSet(object.isSticky) ? globalThis.Boolean(object.isSticky) : false,
            linkFlair: isSet(object.linkFlair) ? LinkFlairV2.fromJSON(object.linkFlair) : undefined,
            authorFlair: isSet(object.authorFlair) ? UserFlairV2.fromJSON(object.authorFlair) : undefined,
            spam: isSet(object.spam) ? globalThis.Boolean(object.spam) : false,
            deleted: isSet(object.deleted) ? globalThis.Boolean(object.deleted) : false,
            languageCode: isSet(object.languageCode) ? globalThis.String(object.languageCode) : "",
            updatedAt: isSet(object.updatedAt) ? globalThis.Number(object.updatedAt) : 0,
            gildings: isSet(object.gildings) ? globalThis.Number(object.gildings) : 0,
            score: isSet(object.score) ? globalThis.Number(object.score) : 0,
            numComments: isSet(object.numComments) ? globalThis.Number(object.numComments) : 0,
            thumbnail: isSet(object.thumbnail) ? globalThis.String(object.thumbnail) : "",
            media: isSet(object.media) ? MediaObject.fromJSON(object.media) : undefined,
            crosspostParentId: isSet(object.crosspostParentId) ? globalThis.String(object.crosspostParentId) : "",
            permalink: isSet(object.permalink) ? globalThis.String(object.permalink) : "",
            isPoll: isSet(object.isPoll) ? globalThis.Boolean(object.isPoll) : false,
            isPromoted: isSet(object.isPromoted) ? globalThis.Boolean(object.isPromoted) : false,
            isMultiMedia: isSet(object.isMultiMedia) ? globalThis.Boolean(object.isMultiMedia) : false,
            type: isSet(object.type) ? globalThis.String(object.type) : "",
            unlisted: isSet(object.unlisted) ? globalThis.Boolean(object.unlisted) : false,
            galleryImages: globalThis.Array.isArray(object?.galleryImages)
                ? object.galleryImages.map((e) => globalThis.String(e))
                : [],
            isImage: isSet(object.isImage) ? globalThis.Boolean(object.isImage) : false,
            mediaUrls: globalThis.Array.isArray(object?.mediaUrls)
                ? object.mediaUrls.map((e) => globalThis.String(e))
                : [],
            isClubContent: isSet(object.isClubContent) ? globalThis.Boolean(object.isClubContent) : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.title !== "") {
            obj.title = message.title;
        }
        if (message.selftext !== "") {
            obj.selftext = message.selftext;
        }
        if (message.nsfw !== false) {
            obj.nsfw = message.nsfw;
        }
        if (message.authorId !== "") {
            obj.authorId = message.authorId;
        }
        if (message.crowdControlLevel !== 0) {
            obj.crowdControlLevel = crowdControlLevelToJSON(message.crowdControlLevel);
        }
        if (message.numReports !== 0) {
            obj.numReports = Math.round(message.numReports);
        }
        if (message.isGallery !== false) {
            obj.isGallery = message.isGallery;
        }
        if (message.isMeta !== false) {
            obj.isMeta = message.isMeta;
        }
        if (message.createdAt !== 0) {
            obj.createdAt = Math.round(message.createdAt);
        }
        if (message.isApproved !== false) {
            obj.isApproved = message.isApproved;
        }
        if (message.isArchived !== false) {
            obj.isArchived = message.isArchived;
        }
        if (message.distinguished !== 0) {
            obj.distinguished = distinguishTypeToJSON(message.distinguished);
        }
        if (message.ignoreReports !== false) {
            obj.ignoreReports = message.ignoreReports;
        }
        if (message.isSelf !== false) {
            obj.isSelf = message.isSelf;
        }
        if (message.isVideo !== false) {
            obj.isVideo = message.isVideo;
        }
        if (message.isLocked !== false) {
            obj.isLocked = message.isLocked;
        }
        if (message.isSpoiler !== false) {
            obj.isSpoiler = message.isSpoiler;
        }
        if (message.subredditId !== "") {
            obj.subredditId = message.subredditId;
        }
        if (message.upvotes !== 0) {
            obj.upvotes = Math.round(message.upvotes);
        }
        if (message.downvotes !== 0) {
            obj.downvotes = Math.round(message.downvotes);
        }
        if (message.url !== "") {
            obj.url = message.url;
        }
        if (message.isSticky !== false) {
            obj.isSticky = message.isSticky;
        }
        if (message.linkFlair !== undefined) {
            obj.linkFlair = LinkFlairV2.toJSON(message.linkFlair);
        }
        if (message.authorFlair !== undefined) {
            obj.authorFlair = UserFlairV2.toJSON(message.authorFlair);
        }
        if (message.spam !== false) {
            obj.spam = message.spam;
        }
        if (message.deleted !== false) {
            obj.deleted = message.deleted;
        }
        if (message.languageCode !== "") {
            obj.languageCode = message.languageCode;
        }
        if (message.updatedAt !== 0) {
            obj.updatedAt = Math.round(message.updatedAt);
        }
        if (message.gildings !== 0) {
            obj.gildings = Math.round(message.gildings);
        }
        if (message.score !== 0) {
            obj.score = Math.round(message.score);
        }
        if (message.numComments !== 0) {
            obj.numComments = Math.round(message.numComments);
        }
        if (message.thumbnail !== "") {
            obj.thumbnail = message.thumbnail;
        }
        if (message.media !== undefined) {
            obj.media = MediaObject.toJSON(message.media);
        }
        if (message.crosspostParentId !== "") {
            obj.crosspostParentId = message.crosspostParentId;
        }
        if (message.permalink !== "") {
            obj.permalink = message.permalink;
        }
        if (message.isPoll !== false) {
            obj.isPoll = message.isPoll;
        }
        if (message.isPromoted !== false) {
            obj.isPromoted = message.isPromoted;
        }
        if (message.isMultiMedia !== false) {
            obj.isMultiMedia = message.isMultiMedia;
        }
        if (message.type !== "") {
            obj.type = message.type;
        }
        if (message.unlisted !== false) {
            obj.unlisted = message.unlisted;
        }
        if (message.galleryImages?.length) {
            obj.galleryImages = message.galleryImages;
        }
        if (message.isImage !== false) {
            obj.isImage = message.isImage;
        }
        if (message.mediaUrls?.length) {
            obj.mediaUrls = message.mediaUrls;
        }
        if (message.isClubContent !== false) {
            obj.isClubContent = message.isClubContent;
        }
        return obj;
    },
    create(base) {
        return PostV2.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePostV2();
        message.id = object.id ?? "";
        message.title = object.title ?? "";
        message.selftext = object.selftext ?? "";
        message.nsfw = object.nsfw ?? false;
        message.authorId = object.authorId ?? "";
        message.crowdControlLevel = object.crowdControlLevel ?? 0;
        message.numReports = object.numReports ?? 0;
        message.isGallery = object.isGallery ?? false;
        message.isMeta = object.isMeta ?? false;
        message.createdAt = object.createdAt ?? 0;
        message.isApproved = object.isApproved ?? false;
        message.isArchived = object.isArchived ?? false;
        message.distinguished = object.distinguished ?? 0;
        message.ignoreReports = object.ignoreReports ?? false;
        message.isSelf = object.isSelf ?? false;
        message.isVideo = object.isVideo ?? false;
        message.isLocked = object.isLocked ?? false;
        message.isSpoiler = object.isSpoiler ?? false;
        message.subredditId = object.subredditId ?? "";
        message.upvotes = object.upvotes ?? 0;
        message.downvotes = object.downvotes ?? 0;
        message.url = object.url ?? "";
        message.isSticky = object.isSticky ?? false;
        message.linkFlair = (object.linkFlair !== undefined && object.linkFlair !== null)
            ? LinkFlairV2.fromPartial(object.linkFlair)
            : undefined;
        message.authorFlair = (object.authorFlair !== undefined && object.authorFlair !== null)
            ? UserFlairV2.fromPartial(object.authorFlair)
            : undefined;
        message.spam = object.spam ?? false;
        message.deleted = object.deleted ?? false;
        message.languageCode = object.languageCode ?? "";
        message.updatedAt = object.updatedAt ?? 0;
        message.gildings = object.gildings ?? 0;
        message.score = object.score ?? 0;
        message.numComments = object.numComments ?? 0;
        message.thumbnail = object.thumbnail ?? "";
        message.media = (object.media !== undefined && object.media !== null)
            ? MediaObject.fromPartial(object.media)
            : undefined;
        message.crosspostParentId = object.crosspostParentId ?? "";
        message.permalink = object.permalink ?? "";
        message.isPoll = object.isPoll ?? false;
        message.isPromoted = object.isPromoted ?? false;
        message.isMultiMedia = object.isMultiMedia ?? false;
        message.type = object.type ?? "";
        message.unlisted = object.unlisted ?? false;
        message.galleryImages = object.galleryImages?.map((e) => e) || [];
        message.isImage = object.isImage ?? false;
        message.mediaUrls = object.mediaUrls?.map((e) => e) || [];
        message.isClubContent = object.isClubContent ?? false;
        return message;
    },
};
messageTypeRegistry.set(PostV2.$type, PostV2);
function createBaseOembed() {
    return {
        type: "",
        version: "",
        title: "",
        description: "",
        authorName: "",
        authorUrl: "",
        providerName: "",
        providerUrl: "",
        thumbnailUrl: "",
        thumbnailWidth: 0,
        thumbnailHeight: 0,
        html: "",
        width: 0,
        height: 0,
    };
}
export const Oembed = {
    $type: "devvit.reddit.v2alpha.Oembed",
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== "") {
            writer.uint32(10).string(message.type);
        }
        if (message.version !== "") {
            writer.uint32(18).string(message.version);
        }
        if (message.title !== "") {
            writer.uint32(26).string(message.title);
        }
        if (message.description !== "") {
            writer.uint32(34).string(message.description);
        }
        if (message.authorName !== "") {
            writer.uint32(42).string(message.authorName);
        }
        if (message.authorUrl !== "") {
            writer.uint32(50).string(message.authorUrl);
        }
        if (message.providerName !== "") {
            writer.uint32(58).string(message.providerName);
        }
        if (message.providerUrl !== "") {
            writer.uint32(66).string(message.providerUrl);
        }
        if (message.thumbnailUrl !== "") {
            writer.uint32(74).string(message.thumbnailUrl);
        }
        if (message.thumbnailWidth !== 0) {
            writer.uint32(80).int32(message.thumbnailWidth);
        }
        if (message.thumbnailHeight !== 0) {
            writer.uint32(88).int32(message.thumbnailHeight);
        }
        if (message.html !== "") {
            writer.uint32(98).string(message.html);
        }
        if (message.width !== 0) {
            writer.uint32(104).int32(message.width);
        }
        if (message.height !== 0) {
            writer.uint32(112).int32(message.height);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOembed();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.type = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.version = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.title = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.description = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.authorName = reader.string();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.authorUrl = reader.string();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.providerName = reader.string();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.providerUrl = reader.string();
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.thumbnailUrl = reader.string();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.thumbnailWidth = reader.int32();
                    continue;
                case 11:
                    if (tag !== 88) {
                        break;
                    }
                    message.thumbnailHeight = reader.int32();
                    continue;
                case 12:
                    if (tag !== 98) {
                        break;
                    }
                    message.html = reader.string();
                    continue;
                case 13:
                    if (tag !== 104) {
                        break;
                    }
                    message.width = reader.int32();
                    continue;
                case 14:
                    if (tag !== 112) {
                        break;
                    }
                    message.height = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? globalThis.String(object.type) : "",
            version: isSet(object.version) ? globalThis.String(object.version) : "",
            title: isSet(object.title) ? globalThis.String(object.title) : "",
            description: isSet(object.description) ? globalThis.String(object.description) : "",
            authorName: isSet(object.authorName) ? globalThis.String(object.authorName) : "",
            authorUrl: isSet(object.authorUrl) ? globalThis.String(object.authorUrl) : "",
            providerName: isSet(object.providerName) ? globalThis.String(object.providerName) : "",
            providerUrl: isSet(object.providerUrl) ? globalThis.String(object.providerUrl) : "",
            thumbnailUrl: isSet(object.thumbnailUrl) ? globalThis.String(object.thumbnailUrl) : "",
            thumbnailWidth: isSet(object.thumbnailWidth) ? globalThis.Number(object.thumbnailWidth) : 0,
            thumbnailHeight: isSet(object.thumbnailHeight) ? globalThis.Number(object.thumbnailHeight) : 0,
            html: isSet(object.html) ? globalThis.String(object.html) : "",
            width: isSet(object.width) ? globalThis.Number(object.width) : 0,
            height: isSet(object.height) ? globalThis.Number(object.height) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== "") {
            obj.type = message.type;
        }
        if (message.version !== "") {
            obj.version = message.version;
        }
        if (message.title !== "") {
            obj.title = message.title;
        }
        if (message.description !== "") {
            obj.description = message.description;
        }
        if (message.authorName !== "") {
            obj.authorName = message.authorName;
        }
        if (message.authorUrl !== "") {
            obj.authorUrl = message.authorUrl;
        }
        if (message.providerName !== "") {
            obj.providerName = message.providerName;
        }
        if (message.providerUrl !== "") {
            obj.providerUrl = message.providerUrl;
        }
        if (message.thumbnailUrl !== "") {
            obj.thumbnailUrl = message.thumbnailUrl;
        }
        if (message.thumbnailWidth !== 0) {
            obj.thumbnailWidth = Math.round(message.thumbnailWidth);
        }
        if (message.thumbnailHeight !== 0) {
            obj.thumbnailHeight = Math.round(message.thumbnailHeight);
        }
        if (message.html !== "") {
            obj.html = message.html;
        }
        if (message.width !== 0) {
            obj.width = Math.round(message.width);
        }
        if (message.height !== 0) {
            obj.height = Math.round(message.height);
        }
        return obj;
    },
    create(base) {
        return Oembed.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseOembed();
        message.type = object.type ?? "";
        message.version = object.version ?? "";
        message.title = object.title ?? "";
        message.description = object.description ?? "";
        message.authorName = object.authorName ?? "";
        message.authorUrl = object.authorUrl ?? "";
        message.providerName = object.providerName ?? "";
        message.providerUrl = object.providerUrl ?? "";
        message.thumbnailUrl = object.thumbnailUrl ?? "";
        message.thumbnailWidth = object.thumbnailWidth ?? 0;
        message.thumbnailHeight = object.thumbnailHeight ?? 0;
        message.html = object.html ?? "";
        message.width = object.width ?? 0;
        message.height = object.height ?? 0;
        return message;
    },
};
messageTypeRegistry.set(Oembed.$type, Oembed);
function createBaseRedditVideo() {
    return {
        bitrateKbps: 0,
        fallbackUrl: "",
        height: 0,
        width: 0,
        scrubberMediaUrl: "",
        dashUrl: "",
        duration: 0,
        hlsUrl: "",
        isGif: false,
        transcodingStatus: "",
    };
}
export const RedditVideo = {
    $type: "devvit.reddit.v2alpha.RedditVideo",
    encode(message, writer = _m0.Writer.create()) {
        if (message.bitrateKbps !== 0) {
            writer.uint32(8).int32(message.bitrateKbps);
        }
        if (message.fallbackUrl !== "") {
            writer.uint32(18).string(message.fallbackUrl);
        }
        if (message.height !== 0) {
            writer.uint32(24).int32(message.height);
        }
        if (message.width !== 0) {
            writer.uint32(32).int32(message.width);
        }
        if (message.scrubberMediaUrl !== "") {
            writer.uint32(42).string(message.scrubberMediaUrl);
        }
        if (message.dashUrl !== "") {
            writer.uint32(50).string(message.dashUrl);
        }
        if (message.duration !== 0) {
            writer.uint32(56).int64(message.duration);
        }
        if (message.hlsUrl !== "") {
            writer.uint32(66).string(message.hlsUrl);
        }
        if (message.isGif !== false) {
            writer.uint32(72).bool(message.isGif);
        }
        if (message.transcodingStatus !== "") {
            writer.uint32(82).string(message.transcodingStatus);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRedditVideo();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.bitrateKbps = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.fallbackUrl = reader.string();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.height = reader.int32();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.width = reader.int32();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.scrubberMediaUrl = reader.string();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.dashUrl = reader.string();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.duration = longToNumber(reader.int64());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.hlsUrl = reader.string();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.isGif = reader.bool();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.transcodingStatus = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            bitrateKbps: isSet(object.bitrateKbps) ? globalThis.Number(object.bitrateKbps) : 0,
            fallbackUrl: isSet(object.fallbackUrl) ? globalThis.String(object.fallbackUrl) : "",
            height: isSet(object.height) ? globalThis.Number(object.height) : 0,
            width: isSet(object.width) ? globalThis.Number(object.width) : 0,
            scrubberMediaUrl: isSet(object.scrubberMediaUrl) ? globalThis.String(object.scrubberMediaUrl) : "",
            dashUrl: isSet(object.dashUrl) ? globalThis.String(object.dashUrl) : "",
            duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0,
            hlsUrl: isSet(object.hlsUrl) ? globalThis.String(object.hlsUrl) : "",
            isGif: isSet(object.isGif) ? globalThis.Boolean(object.isGif) : false,
            transcodingStatus: isSet(object.transcodingStatus) ? globalThis.String(object.transcodingStatus) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.bitrateKbps !== 0) {
            obj.bitrateKbps = Math.round(message.bitrateKbps);
        }
        if (message.fallbackUrl !== "") {
            obj.fallbackUrl = message.fallbackUrl;
        }
        if (message.height !== 0) {
            obj.height = Math.round(message.height);
        }
        if (message.width !== 0) {
            obj.width = Math.round(message.width);
        }
        if (message.scrubberMediaUrl !== "") {
            obj.scrubberMediaUrl = message.scrubberMediaUrl;
        }
        if (message.dashUrl !== "") {
            obj.dashUrl = message.dashUrl;
        }
        if (message.duration !== 0) {
            obj.duration = Math.round(message.duration);
        }
        if (message.hlsUrl !== "") {
            obj.hlsUrl = message.hlsUrl;
        }
        if (message.isGif !== false) {
            obj.isGif = message.isGif;
        }
        if (message.transcodingStatus !== "") {
            obj.transcodingStatus = message.transcodingStatus;
        }
        return obj;
    },
    create(base) {
        return RedditVideo.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRedditVideo();
        message.bitrateKbps = object.bitrateKbps ?? 0;
        message.fallbackUrl = object.fallbackUrl ?? "";
        message.height = object.height ?? 0;
        message.width = object.width ?? 0;
        message.scrubberMediaUrl = object.scrubberMediaUrl ?? "";
        message.dashUrl = object.dashUrl ?? "";
        message.duration = object.duration ?? 0;
        message.hlsUrl = object.hlsUrl ?? "";
        message.isGif = object.isGif ?? false;
        message.transcodingStatus = object.transcodingStatus ?? "";
        return message;
    },
};
messageTypeRegistry.set(RedditVideo.$type, RedditVideo);
function createBaseMediaObject() {
    return { type: "", oembed: undefined, redditVideo: undefined };
}
export const MediaObject = {
    $type: "devvit.reddit.v2alpha.MediaObject",
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== "") {
            writer.uint32(10).string(message.type);
        }
        if (message.oembed !== undefined) {
            Oembed.encode(message.oembed, writer.uint32(18).fork()).ldelim();
        }
        if (message.redditVideo !== undefined) {
            RedditVideo.encode(message.redditVideo, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMediaObject();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.type = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.oembed = Oembed.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.redditVideo = RedditVideo.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? globalThis.String(object.type) : "",
            oembed: isSet(object.oembed) ? Oembed.fromJSON(object.oembed) : undefined,
            redditVideo: isSet(object.redditVideo) ? RedditVideo.fromJSON(object.redditVideo) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== "") {
            obj.type = message.type;
        }
        if (message.oembed !== undefined) {
            obj.oembed = Oembed.toJSON(message.oembed);
        }
        if (message.redditVideo !== undefined) {
            obj.redditVideo = RedditVideo.toJSON(message.redditVideo);
        }
        return obj;
    },
    create(base) {
        return MediaObject.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseMediaObject();
        message.type = object.type ?? "";
        message.oembed = (object.oembed !== undefined && object.oembed !== null)
            ? Oembed.fromPartial(object.oembed)
            : undefined;
        message.redditVideo = (object.redditVideo !== undefined && object.redditVideo !== null)
            ? RedditVideo.fromPartial(object.redditVideo)
            : undefined;
        return message;
    },
};
messageTypeRegistry.set(MediaObject.$type, MediaObject);
function longToNumber(long) {
    if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    return long.toNumber();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
function isSet(value) {
    return value !== null && value !== undefined;
}
