/**
 * #realtime_subscription.ts
 *
 * @packageDocumentation
 */
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { messageTypeRegistry } from "../../../../typeRegistry.js";
import { RealtimeEvent } from "../../../events/v1alpha/realtime.js";
export var RealtimeSubscriptionStatus;
(function (RealtimeSubscriptionStatus) {
    RealtimeSubscriptionStatus[RealtimeSubscriptionStatus["REALTIME_SUBSCRIBED"] = 0] = "REALTIME_SUBSCRIBED";
    RealtimeSubscriptionStatus[RealtimeSubscriptionStatus["REALTIME_UNSUBSCRIBED"] = 1] = "REALTIME_UNSUBSCRIBED";
    RealtimeSubscriptionStatus[RealtimeSubscriptionStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RealtimeSubscriptionStatus || (RealtimeSubscriptionStatus = {}));
export function realtimeSubscriptionStatusFromJSON(object) {
    switch (object) {
        case 0:
        case "REALTIME_SUBSCRIBED":
            return RealtimeSubscriptionStatus.REALTIME_SUBSCRIBED;
        case 1:
        case "REALTIME_UNSUBSCRIBED":
            return RealtimeSubscriptionStatus.REALTIME_UNSUBSCRIBED;
        case -1:
        case "UNRECOGNIZED":
        default:
            return RealtimeSubscriptionStatus.UNRECOGNIZED;
    }
}
export function realtimeSubscriptionStatusToJSON(object) {
    switch (object) {
        case RealtimeSubscriptionStatus.REALTIME_SUBSCRIBED:
            return 0;
        case RealtimeSubscriptionStatus.REALTIME_UNSUBSCRIBED:
            return 1;
        case RealtimeSubscriptionStatus.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseRealtimeSubscriptionsEffect() {
    return { subscriptionIds: [] };
}
export const RealtimeSubscriptionsEffect = {
    $type: "devvit.ui.effect_types.v1alpha.RealtimeSubscriptionsEffect",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.subscriptionIds) {
            writer.uint32(10).string(v);
        }
        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 = createBaseRealtimeSubscriptionsEffect();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.subscriptionIds.push(reader.string());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionIds: globalThis.Array.isArray(object?.subscriptionIds)
                ? object.subscriptionIds.map((e) => globalThis.String(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionIds?.length) {
            obj.subscriptionIds = message.subscriptionIds;
        }
        return obj;
    },
    create(base) {
        return RealtimeSubscriptionsEffect.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRealtimeSubscriptionsEffect();
        message.subscriptionIds = object.subscriptionIds?.map((e) => e) || [];
        return message;
    },
};
messageTypeRegistry.set(RealtimeSubscriptionsEffect.$type, RealtimeSubscriptionsEffect);
function createBaseRealtimeSubscriptionEvent() {
    return { event: undefined, status: undefined };
}
export const RealtimeSubscriptionEvent = {
    $type: "devvit.ui.effect_types.v1alpha.RealtimeSubscriptionEvent",
    encode(message, writer = _m0.Writer.create()) {
        if (message.event !== undefined) {
            RealtimeEvent.encode(message.event, writer.uint32(10).fork()).ldelim();
        }
        if (message.status !== undefined) {
            writer.uint32(16).int32(message.status);
        }
        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 = createBaseRealtimeSubscriptionEvent();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.event = RealtimeEvent.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.status = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            event: isSet(object.event) ? RealtimeEvent.fromJSON(object.event) : undefined,
            status: isSet(object.status) ? realtimeSubscriptionStatusFromJSON(object.status) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.event !== undefined) {
            obj.event = RealtimeEvent.toJSON(message.event);
        }
        if (message.status !== undefined) {
            obj.status = realtimeSubscriptionStatusToJSON(message.status);
        }
        return obj;
    },
    create(base) {
        return RealtimeSubscriptionEvent.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRealtimeSubscriptionEvent();
        message.event = (object.event !== undefined && object.event !== null)
            ? RealtimeEvent.fromPartial(object.event)
            : undefined;
        message.status = object.status ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(RealtimeSubscriptionEvent.$type, RealtimeSubscriptionEvent);
function isSet(value) {
    return value !== null && value !== undefined;
}
