/**
 * #request_context.ts
 *
 * Code generated by ts-proto. DO NOT EDIT.
 * @packageDocumentation
 */
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { messageTypeRegistry } from "../../../typeRegistry.js";
export var AppStatus;
(function (AppStatus) {
    /** APP_STATUS_UNSPECIFIED - Default value. Should not be used for requests. */
    AppStatus[AppStatus["APP_STATUS_UNSPECIFIED"] = 0] = "APP_STATUS_UNSPECIFIED";
    /** PRERELEASE - App is in prerelease state */
    AppStatus[AppStatus["PRERELEASE"] = 1] = "PRERELEASE";
    /** PUBLISHED - App is published and available */
    AppStatus[AppStatus["PUBLISHED"] = 2] = "PUBLISHED";
    AppStatus[AppStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(AppStatus || (AppStatus = {}));
export function appStatusFromJSON(object) {
    switch (object) {
        case 0:
        case "APP_STATUS_UNSPECIFIED":
            return AppStatus.APP_STATUS_UNSPECIFIED;
        case 1:
        case "PRERELEASE":
            return AppStatus.PRERELEASE;
        case 2:
        case "PUBLISHED":
            return AppStatus.PUBLISHED;
        case -1:
        case "UNRECOGNIZED":
        default:
            return AppStatus.UNRECOGNIZED;
    }
}
export function appStatusToJSON(object) {
    switch (object) {
        case AppStatus.APP_STATUS_UNSPECIFIED:
            return 0;
        case AppStatus.PRERELEASE:
            return 1;
        case AppStatus.PUBLISHED:
            return 2;
        case AppStatus.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseRequestContext() {
    return { installation: undefined, app: undefined, post: undefined, subreddit: undefined, user: undefined };
}
export const RequestContext = {
    $type: "devvit.platform.v1.RequestContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.installation !== undefined) {
            InstallationContext.encode(message.installation, writer.uint32(10).fork()).ldelim();
        }
        if (message.app !== undefined) {
            AppContext.encode(message.app, writer.uint32(18).fork()).ldelim();
        }
        if (message.post !== undefined) {
            PostContext.encode(message.post, writer.uint32(26).fork()).ldelim();
        }
        if (message.subreddit !== undefined) {
            SubredditContext.encode(message.subreddit, writer.uint32(34).fork()).ldelim();
        }
        if (message.user !== undefined) {
            UserContext.encode(message.user, writer.uint32(42).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 = createBaseRequestContext();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installation = InstallationContext.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.app = AppContext.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.post = PostContext.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.subreddit = SubredditContext.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.user = UserContext.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            installation: isSet(object.installation) ? InstallationContext.fromJSON(object.installation) : undefined,
            app: isSet(object.app) ? AppContext.fromJSON(object.app) : undefined,
            post: isSet(object.post) ? PostContext.fromJSON(object.post) : undefined,
            subreddit: isSet(object.subreddit) ? SubredditContext.fromJSON(object.subreddit) : undefined,
            user: isSet(object.user) ? UserContext.fromJSON(object.user) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.installation !== undefined) {
            obj.installation = InstallationContext.toJSON(message.installation);
        }
        if (message.app !== undefined) {
            obj.app = AppContext.toJSON(message.app);
        }
        if (message.post !== undefined) {
            obj.post = PostContext.toJSON(message.post);
        }
        if (message.subreddit !== undefined) {
            obj.subreddit = SubredditContext.toJSON(message.subreddit);
        }
        if (message.user !== undefined) {
            obj.user = UserContext.toJSON(message.user);
        }
        return obj;
    },
    create(base) {
        return RequestContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRequestContext();
        message.installation = (object.installation !== undefined && object.installation !== null)
            ? InstallationContext.fromPartial(object.installation)
            : undefined;
        message.app = (object.app !== undefined && object.app !== null) ? AppContext.fromPartial(object.app) : undefined;
        message.post = (object.post !== undefined && object.post !== null)
            ? PostContext.fromPartial(object.post)
            : undefined;
        message.subreddit = (object.subreddit !== undefined && object.subreddit !== null)
            ? SubredditContext.fromPartial(object.subreddit)
            : undefined;
        message.user = (object.user !== undefined && object.user !== null)
            ? UserContext.fromPartial(object.user)
            : undefined;
        return message;
    },
};
messageTypeRegistry.set(RequestContext.$type, RequestContext);
function createBaseInstallationContext() {
    return { id: "" };
}
export const InstallationContext = {
    $type: "devvit.platform.v1.InstallationContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        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 = createBaseInstallationContext();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    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) : "" };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        return obj;
    },
    create(base) {
        return InstallationContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationContext();
        message.id = object.id ?? "";
        return message;
    },
};
messageTypeRegistry.set(InstallationContext.$type, InstallationContext);
function createBaseAppContext() {
    return { id: "", name: "", version: "", status: 0, slug: "", account: undefined };
}
export const AppContext = {
    $type: "devvit.platform.v1.AppContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.name !== "") {
            writer.uint32(18).string(message.name);
        }
        if (message.version !== "") {
            writer.uint32(26).string(message.version);
        }
        if (message.status !== 0) {
            writer.uint32(32).int32(message.status);
        }
        if (message.slug !== "") {
            writer.uint32(42).string(message.slug);
        }
        if (message.account !== undefined) {
            AppAccount.encode(message.account, writer.uint32(50).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 = createBaseAppContext();
        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.name = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.version = reader.string();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.status = reader.int32();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.slug = reader.string();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.account = AppAccount.decode(reader, reader.uint32());
                    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) : "",
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            version: isSet(object.version) ? globalThis.String(object.version) : "",
            status: isSet(object.status) ? appStatusFromJSON(object.status) : 0,
            slug: isSet(object.slug) ? globalThis.String(object.slug) : "",
            account: isSet(object.account) ? AppAccount.fromJSON(object.account) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.version !== "") {
            obj.version = message.version;
        }
        if (message.status !== 0) {
            obj.status = appStatusToJSON(message.status);
        }
        if (message.slug !== "") {
            obj.slug = message.slug;
        }
        if (message.account !== undefined) {
            obj.account = AppAccount.toJSON(message.account);
        }
        return obj;
    },
    create(base) {
        return AppContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAppContext();
        message.id = object.id ?? "";
        message.name = object.name ?? "";
        message.version = object.version ?? "";
        message.status = object.status ?? 0;
        message.slug = object.slug ?? "";
        message.account = (object.account !== undefined && object.account !== null)
            ? AppAccount.fromPartial(object.account)
            : undefined;
        return message;
    },
};
messageTypeRegistry.set(AppContext.$type, AppContext);
function createBaseAppAccount() {
    return { id: "" };
}
export const AppAccount = {
    $type: "devvit.platform.v1.AppAccount",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        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 = createBaseAppAccount();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    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) : "" };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        return obj;
    },
    create(base) {
        return AppAccount.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAppAccount();
        message.id = object.id ?? "";
        return message;
    },
};
messageTypeRegistry.set(AppAccount.$type, AppAccount);
function createBasePostContext() {
    return { id: "", author: "" };
}
export const PostContext = {
    $type: "devvit.platform.v1.PostContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.author !== "") {
            writer.uint32(18).string(message.author);
        }
        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 = createBasePostContext();
        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.author = reader.string();
                    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) : "",
            author: isSet(object.author) ? globalThis.String(object.author) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.author !== "") {
            obj.author = message.author;
        }
        return obj;
    },
    create(base) {
        return PostContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePostContext();
        message.id = object.id ?? "";
        message.author = object.author ?? "";
        return message;
    },
};
messageTypeRegistry.set(PostContext.$type, PostContext);
function createBaseSubredditContext() {
    return { name: "", id: "" };
}
export const SubredditContext = {
    $type: "devvit.platform.v1.SubredditContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.name !== "") {
            writer.uint32(10).string(message.name);
        }
        if (message.id !== "") {
            writer.uint32(18).string(message.id);
        }
        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 = createBaseSubredditContext();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            id: isSet(object.id) ? globalThis.String(object.id) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.id !== "") {
            obj.id = message.id;
        }
        return obj;
    },
    create(base) {
        return SubredditContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSubredditContext();
        message.name = object.name ?? "";
        message.id = object.id ?? "";
        return message;
    },
};
messageTypeRegistry.set(SubredditContext.$type, SubredditContext);
function createBaseUserContext() {
    return { name: "", id: "", snoovatar: "", sessionId: "" };
}
export const UserContext = {
    $type: "devvit.platform.v1.UserContext",
    encode(message, writer = _m0.Writer.create()) {
        if (message.name !== "") {
            writer.uint32(10).string(message.name);
        }
        if (message.id !== "") {
            writer.uint32(18).string(message.id);
        }
        if (message.snoovatar !== "") {
            writer.uint32(26).string(message.snoovatar);
        }
        if (message.sessionId !== "") {
            writer.uint32(34).string(message.sessionId);
        }
        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 = createBaseUserContext();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.snoovatar = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.sessionId = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            snoovatar: isSet(object.snoovatar) ? globalThis.String(object.snoovatar) : "",
            sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.snoovatar !== "") {
            obj.snoovatar = message.snoovatar;
        }
        if (message.sessionId !== "") {
            obj.sessionId = message.sessionId;
        }
        return obj;
    },
    create(base) {
        return UserContext.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseUserContext();
        message.name = object.name ?? "";
        message.id = object.id ?? "";
        message.snoovatar = object.snoovatar ?? "";
        message.sessionId = object.sessionId ?? "";
        return message;
    },
};
messageTypeRegistry.set(UserContext.$type, UserContext);
function isSet(value) {
    return value !== null && value !== undefined;
}
