"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BatchSettings = exports.PutQueueMessage = exports.RetrySettings = exports.WorkflowTarget = exports.LoggingTarget = exports.GatewayWebsocketBroadcastTarget = exports.ContainerTarget = exports.FunctionTarget = exports.YmqTarget = exports.YdsTarget = exports.Target = exports.Transformer = exports.Filter = exports.Rule_LabelsEntry = exports.Rule = exports.target_StatusToJSON = exports.target_StatusFromJSON = exports.Target_Status = exports.rule_StatusToJSON = exports.rule_StatusFromJSON = exports.Rule_Status = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const duration_1 = require("../../../../../google/protobuf/duration");
const timestamp_1 = require("../../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.serverless.eventrouter.v1';
var Rule_Status;
(function (Rule_Status) {
    Rule_Status[Rule_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** CREATING - Rule creation in progress, rule is not enabled yet */
    Rule_Status[Rule_Status["CREATING"] = 1] = "CREATING";
    /** ENABLED - Rule is operating */
    Rule_Status[Rule_Status["ENABLED"] = 2] = "ENABLED";
    /** UPDATING - Rule update in progress, rule is disabled during update */
    Rule_Status[Rule_Status["UPDATING"] = 3] = "UPDATING";
    /** DISABLED - Rule is explicitly disabled by the user */
    Rule_Status[Rule_Status["DISABLED"] = 4] = "DISABLED";
    /** DELETING - Rule deletion in progress */
    Rule_Status[Rule_Status["DELETING"] = 5] = "DELETING";
    Rule_Status[Rule_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Rule_Status = exports.Rule_Status || (exports.Rule_Status = {}));
function rule_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return Rule_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'CREATING':
            return Rule_Status.CREATING;
        case 2:
        case 'ENABLED':
            return Rule_Status.ENABLED;
        case 3:
        case 'UPDATING':
            return Rule_Status.UPDATING;
        case 4:
        case 'DISABLED':
            return Rule_Status.DISABLED;
        case 5:
        case 'DELETING':
            return Rule_Status.DELETING;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Rule_Status.UNRECOGNIZED;
    }
}
exports.rule_StatusFromJSON = rule_StatusFromJSON;
function rule_StatusToJSON(object) {
    switch (object) {
        case Rule_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case Rule_Status.CREATING:
            return 'CREATING';
        case Rule_Status.ENABLED:
            return 'ENABLED';
        case Rule_Status.UPDATING:
            return 'UPDATING';
        case Rule_Status.DISABLED:
            return 'DISABLED';
        case Rule_Status.DELETING:
            return 'DELETING';
        default:
            return 'UNKNOWN';
    }
}
exports.rule_StatusToJSON = rule_StatusToJSON;
/** Status of the target. */
var Target_Status;
(function (Target_Status) {
    Target_Status[Target_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** ENABLED - Target is enabled. */
    Target_Status[Target_Status["ENABLED"] = 1] = "ENABLED";
    /** DISABLED - Target is disabled. */
    Target_Status[Target_Status["DISABLED"] = 2] = "DISABLED";
    /** RESOURCE_NOT_FOUND - Target does not exist. */
    Target_Status[Target_Status["RESOURCE_NOT_FOUND"] = 3] = "RESOURCE_NOT_FOUND";
    /** PERMISSION_DENIED - Service account does not have read permission on source. */
    Target_Status[Target_Status["PERMISSION_DENIED"] = 4] = "PERMISSION_DENIED";
    /** SUBJECT_NOT_FOUND - Service account not found. */
    Target_Status[Target_Status["SUBJECT_NOT_FOUND"] = 5] = "SUBJECT_NOT_FOUND";
    Target_Status[Target_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Target_Status = exports.Target_Status || (exports.Target_Status = {}));
function target_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return Target_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'ENABLED':
            return Target_Status.ENABLED;
        case 2:
        case 'DISABLED':
            return Target_Status.DISABLED;
        case 3:
        case 'RESOURCE_NOT_FOUND':
            return Target_Status.RESOURCE_NOT_FOUND;
        case 4:
        case 'PERMISSION_DENIED':
            return Target_Status.PERMISSION_DENIED;
        case 5:
        case 'SUBJECT_NOT_FOUND':
            return Target_Status.SUBJECT_NOT_FOUND;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Target_Status.UNRECOGNIZED;
    }
}
exports.target_StatusFromJSON = target_StatusFromJSON;
function target_StatusToJSON(object) {
    switch (object) {
        case Target_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case Target_Status.ENABLED:
            return 'ENABLED';
        case Target_Status.DISABLED:
            return 'DISABLED';
        case Target_Status.RESOURCE_NOT_FOUND:
            return 'RESOURCE_NOT_FOUND';
        case Target_Status.PERMISSION_DENIED:
            return 'PERMISSION_DENIED';
        case Target_Status.SUBJECT_NOT_FOUND:
            return 'SUBJECT_NOT_FOUND';
        default:
            return 'UNKNOWN';
    }
}
exports.target_StatusToJSON = target_StatusToJSON;
const baseRule = {
    id: '',
    busId: '',
    folderId: '',
    cloudId: '',
    name: '',
    description: '',
    deletionProtection: false,
    status: 0,
};
exports.Rule = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.busId !== '') {
            writer.uint32(18).string(message.busId);
        }
        if (message.folderId !== '') {
            writer.uint32(26).string(message.folderId);
        }
        if (message.cloudId !== '') {
            writer.uint32(34).string(message.cloudId);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(42).fork()).ldelim();
        }
        if (message.name !== '') {
            writer.uint32(50).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(58).string(message.description);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.Rule_LabelsEntry.encode({ key: key, value }, writer.uint32(66).fork()).ldelim();
        });
        if (message.filter !== undefined) {
            exports.Filter.encode(message.filter, writer.uint32(90).fork()).ldelim();
        }
        for (const v of message.targets) {
            exports.Target.encode(v, writer.uint32(98).fork()).ldelim();
        }
        if (message.deletionProtection === true) {
            writer.uint32(104).bool(message.deletionProtection);
        }
        if (message.status !== 0) {
            writer.uint32(112).int32(message.status);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRule);
        message.labels = {};
        message.targets = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.busId = reader.string();
                    break;
                case 3:
                    message.folderId = reader.string();
                    break;
                case 4:
                    message.cloudId = reader.string();
                    break;
                case 5:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 6:
                    message.name = reader.string();
                    break;
                case 7:
                    message.description = reader.string();
                    break;
                case 8:
                    const entry8 = exports.Rule_LabelsEntry.decode(reader, reader.uint32());
                    if (entry8.value !== undefined) {
                        message.labels[entry8.key] = entry8.value;
                    }
                    break;
                case 11:
                    message.filter = exports.Filter.decode(reader, reader.uint32());
                    break;
                case 12:
                    message.targets.push(exports.Target.decode(reader, reader.uint32()));
                    break;
                case 13:
                    message.deletionProtection = reader.bool();
                    break;
                case 14:
                    message.status = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b;
        const message = Object.assign({}, baseRule);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.busId =
            object.busId !== undefined && object.busId !== null ? String(object.busId) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.filter =
            object.filter !== undefined && object.filter !== null
                ? exports.Filter.fromJSON(object.filter)
                : undefined;
        message.targets = ((_b = object.targets) !== null && _b !== void 0 ? _b : []).map((e) => exports.Target.fromJSON(e));
        message.deletionProtection =
            object.deletionProtection !== undefined && object.deletionProtection !== null
                ? Boolean(object.deletionProtection)
                : false;
        message.status =
            object.status !== undefined && object.status !== null
                ? rule_StatusFromJSON(object.status)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.busId !== undefined && (obj.busId = message.busId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.filter !== undefined &&
            (obj.filter = message.filter ? exports.Filter.toJSON(message.filter) : undefined);
        if (message.targets) {
            obj.targets = message.targets.map((e) => (e ? exports.Target.toJSON(e) : undefined));
        }
        else {
            obj.targets = [];
        }
        message.deletionProtection !== undefined &&
            (obj.deletionProtection = message.deletionProtection);
        message.status !== undefined && (obj.status = rule_StatusToJSON(message.status));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
        const message = Object.assign({}, baseRule);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.busId = (_b = object.busId) !== null && _b !== void 0 ? _b : '';
        message.folderId = (_c = object.folderId) !== null && _c !== void 0 ? _c : '';
        message.cloudId = (_d = object.cloudId) !== null && _d !== void 0 ? _d : '';
        message.createdAt = (_e = object.createdAt) !== null && _e !== void 0 ? _e : undefined;
        message.name = (_f = object.name) !== null && _f !== void 0 ? _f : '';
        message.description = (_g = object.description) !== null && _g !== void 0 ? _g : '';
        message.labels = Object.entries((_h = object.labels) !== null && _h !== void 0 ? _h : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.filter =
            object.filter !== undefined && object.filter !== null
                ? exports.Filter.fromPartial(object.filter)
                : undefined;
        message.targets = ((_j = object.targets) === null || _j === void 0 ? void 0 : _j.map((e) => exports.Target.fromPartial(e))) || [];
        message.deletionProtection = (_k = object.deletionProtection) !== null && _k !== void 0 ? _k : false;
        message.status = (_l = object.status) !== null && _l !== void 0 ? _l : 0;
        return message;
    },
};
const baseRule_LabelsEntry = { key: '', value: '' };
exports.Rule_LabelsEntry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== '') {
            writer.uint32(18).string(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRule_LabelsEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRule_LabelsEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null ? String(object.value) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined && (obj.value = message.value);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRule_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseFilter = {};
exports.Filter = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.jqFilter !== undefined) {
            writer.uint32(10).string(message.jqFilter);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFilter);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.jqFilter = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFilter);
        message.jqFilter =
            object.jqFilter !== undefined && object.jqFilter !== null
                ? String(object.jqFilter)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.jqFilter !== undefined && (obj.jqFilter = message.jqFilter);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseFilter);
        message.jqFilter = (_a = object.jqFilter) !== null && _a !== void 0 ? _a : undefined;
        return message;
    },
};
const baseTransformer = {};
exports.Transformer = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.jqTransformer !== undefined) {
            writer.uint32(10).string(message.jqTransformer);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTransformer);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.jqTransformer = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTransformer);
        message.jqTransformer =
            object.jqTransformer !== undefined && object.jqTransformer !== null
                ? String(object.jqTransformer)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.jqTransformer !== undefined && (obj.jqTransformer = message.jqTransformer);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTransformer);
        message.jqTransformer = (_a = object.jqTransformer) !== null && _a !== void 0 ? _a : undefined;
        return message;
    },
};
const baseTarget = { status: 0 };
exports.Target = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.yds !== undefined) {
            exports.YdsTarget.encode(message.yds, writer.uint32(10).fork()).ldelim();
        }
        if (message.ymq !== undefined) {
            exports.YmqTarget.encode(message.ymq, writer.uint32(18).fork()).ldelim();
        }
        if (message.function !== undefined) {
            exports.FunctionTarget.encode(message.function, writer.uint32(26).fork()).ldelim();
        }
        if (message.container !== undefined) {
            exports.ContainerTarget.encode(message.container, writer.uint32(34).fork()).ldelim();
        }
        if (message.gatewayWsBroadcast !== undefined) {
            exports.GatewayWebsocketBroadcastTarget.encode(message.gatewayWsBroadcast, writer.uint32(42).fork()).ldelim();
        }
        if (message.logging !== undefined) {
            exports.LoggingTarget.encode(message.logging, writer.uint32(50).fork()).ldelim();
        }
        if (message.workflow !== undefined) {
            exports.WorkflowTarget.encode(message.workflow, writer.uint32(58).fork()).ldelim();
        }
        if (message.transformer !== undefined) {
            exports.Transformer.encode(message.transformer, writer.uint32(402).fork()).ldelim();
        }
        if (message.retrySettings !== undefined) {
            exports.RetrySettings.encode(message.retrySettings, writer.uint32(410).fork()).ldelim();
        }
        if (message.deadLetterQueue !== undefined) {
            exports.PutQueueMessage.encode(message.deadLetterQueue, writer.uint32(418).fork()).ldelim();
        }
        if (message.status !== 0) {
            writer.uint32(432).int32(message.status);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.yds = exports.YdsTarget.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.ymq = exports.YmqTarget.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.function = exports.FunctionTarget.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.container = exports.ContainerTarget.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.gatewayWsBroadcast = exports.GatewayWebsocketBroadcastTarget.decode(reader, reader.uint32());
                    break;
                case 6:
                    message.logging = exports.LoggingTarget.decode(reader, reader.uint32());
                    break;
                case 7:
                    message.workflow = exports.WorkflowTarget.decode(reader, reader.uint32());
                    break;
                case 50:
                    message.transformer = exports.Transformer.decode(reader, reader.uint32());
                    break;
                case 51:
                    message.retrySettings = exports.RetrySettings.decode(reader, reader.uint32());
                    break;
                case 52:
                    message.deadLetterQueue = exports.PutQueueMessage.decode(reader, reader.uint32());
                    break;
                case 54:
                    message.status = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTarget);
        message.yds =
            object.yds !== undefined && object.yds !== null
                ? exports.YdsTarget.fromJSON(object.yds)
                : undefined;
        message.ymq =
            object.ymq !== undefined && object.ymq !== null
                ? exports.YmqTarget.fromJSON(object.ymq)
                : undefined;
        message.function =
            object.function !== undefined && object.function !== null
                ? exports.FunctionTarget.fromJSON(object.function)
                : undefined;
        message.container =
            object.container !== undefined && object.container !== null
                ? exports.ContainerTarget.fromJSON(object.container)
                : undefined;
        message.gatewayWsBroadcast =
            object.gatewayWsBroadcast !== undefined && object.gatewayWsBroadcast !== null
                ? exports.GatewayWebsocketBroadcastTarget.fromJSON(object.gatewayWsBroadcast)
                : undefined;
        message.logging =
            object.logging !== undefined && object.logging !== null
                ? exports.LoggingTarget.fromJSON(object.logging)
                : undefined;
        message.workflow =
            object.workflow !== undefined && object.workflow !== null
                ? exports.WorkflowTarget.fromJSON(object.workflow)
                : undefined;
        message.transformer =
            object.transformer !== undefined && object.transformer !== null
                ? exports.Transformer.fromJSON(object.transformer)
                : undefined;
        message.retrySettings =
            object.retrySettings !== undefined && object.retrySettings !== null
                ? exports.RetrySettings.fromJSON(object.retrySettings)
                : undefined;
        message.deadLetterQueue =
            object.deadLetterQueue !== undefined && object.deadLetterQueue !== null
                ? exports.PutQueueMessage.fromJSON(object.deadLetterQueue)
                : undefined;
        message.status =
            object.status !== undefined && object.status !== null
                ? target_StatusFromJSON(object.status)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.yds !== undefined &&
            (obj.yds = message.yds ? exports.YdsTarget.toJSON(message.yds) : undefined);
        message.ymq !== undefined &&
            (obj.ymq = message.ymq ? exports.YmqTarget.toJSON(message.ymq) : undefined);
        message.function !== undefined &&
            (obj.function = message.function ? exports.FunctionTarget.toJSON(message.function) : undefined);
        message.container !== undefined &&
            (obj.container = message.container
                ? exports.ContainerTarget.toJSON(message.container)
                : undefined);
        message.gatewayWsBroadcast !== undefined &&
            (obj.gatewayWsBroadcast = message.gatewayWsBroadcast
                ? exports.GatewayWebsocketBroadcastTarget.toJSON(message.gatewayWsBroadcast)
                : undefined);
        message.logging !== undefined &&
            (obj.logging = message.logging ? exports.LoggingTarget.toJSON(message.logging) : undefined);
        message.workflow !== undefined &&
            (obj.workflow = message.workflow ? exports.WorkflowTarget.toJSON(message.workflow) : undefined);
        message.transformer !== undefined &&
            (obj.transformer = message.transformer
                ? exports.Transformer.toJSON(message.transformer)
                : undefined);
        message.retrySettings !== undefined &&
            (obj.retrySettings = message.retrySettings
                ? exports.RetrySettings.toJSON(message.retrySettings)
                : undefined);
        message.deadLetterQueue !== undefined &&
            (obj.deadLetterQueue = message.deadLetterQueue
                ? exports.PutQueueMessage.toJSON(message.deadLetterQueue)
                : undefined);
        message.status !== undefined && (obj.status = target_StatusToJSON(message.status));
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTarget);
        message.yds =
            object.yds !== undefined && object.yds !== null
                ? exports.YdsTarget.fromPartial(object.yds)
                : undefined;
        message.ymq =
            object.ymq !== undefined && object.ymq !== null
                ? exports.YmqTarget.fromPartial(object.ymq)
                : undefined;
        message.function =
            object.function !== undefined && object.function !== null
                ? exports.FunctionTarget.fromPartial(object.function)
                : undefined;
        message.container =
            object.container !== undefined && object.container !== null
                ? exports.ContainerTarget.fromPartial(object.container)
                : undefined;
        message.gatewayWsBroadcast =
            object.gatewayWsBroadcast !== undefined && object.gatewayWsBroadcast !== null
                ? exports.GatewayWebsocketBroadcastTarget.fromPartial(object.gatewayWsBroadcast)
                : undefined;
        message.logging =
            object.logging !== undefined && object.logging !== null
                ? exports.LoggingTarget.fromPartial(object.logging)
                : undefined;
        message.workflow =
            object.workflow !== undefined && object.workflow !== null
                ? exports.WorkflowTarget.fromPartial(object.workflow)
                : undefined;
        message.transformer =
            object.transformer !== undefined && object.transformer !== null
                ? exports.Transformer.fromPartial(object.transformer)
                : undefined;
        message.retrySettings =
            object.retrySettings !== undefined && object.retrySettings !== null
                ? exports.RetrySettings.fromPartial(object.retrySettings)
                : undefined;
        message.deadLetterQueue =
            object.deadLetterQueue !== undefined && object.deadLetterQueue !== null
                ? exports.PutQueueMessage.fromPartial(object.deadLetterQueue)
                : undefined;
        message.status = (_a = object.status) !== null && _a !== void 0 ? _a : 0;
        return message;
    },
};
const baseYdsTarget = { database: '', streamName: '', serviceAccountId: '' };
exports.YdsTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.database !== '') {
            writer.uint32(10).string(message.database);
        }
        if (message.streamName !== '') {
            writer.uint32(18).string(message.streamName);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(26).string(message.serviceAccountId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseYdsTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.database = reader.string();
                    break;
                case 2:
                    message.streamName = reader.string();
                    break;
                case 3:
                    message.serviceAccountId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseYdsTarget);
        message.database =
            object.database !== undefined && object.database !== null
                ? String(object.database)
                : '';
        message.streamName =
            object.streamName !== undefined && object.streamName !== null
                ? String(object.streamName)
                : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.database !== undefined && (obj.database = message.database);
        message.streamName !== undefined && (obj.streamName = message.streamName);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseYdsTarget);
        message.database = (_a = object.database) !== null && _a !== void 0 ? _a : '';
        message.streamName = (_b = object.streamName) !== null && _b !== void 0 ? _b : '';
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseYmqTarget = { queueArn: '', serviceAccountId: '' };
exports.YmqTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.queueArn !== '') {
            writer.uint32(10).string(message.queueArn);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(18).string(message.serviceAccountId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseYmqTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.queueArn = reader.string();
                    break;
                case 2:
                    message.serviceAccountId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseYmqTarget);
        message.queueArn =
            object.queueArn !== undefined && object.queueArn !== null
                ? String(object.queueArn)
                : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.queueArn !== undefined && (obj.queueArn = message.queueArn);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseYmqTarget);
        message.queueArn = (_a = object.queueArn) !== null && _a !== void 0 ? _a : '';
        message.serviceAccountId = (_b = object.serviceAccountId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseFunctionTarget = { functionId: '', functionTag: '', serviceAccountId: '' };
exports.FunctionTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.functionId !== '') {
            writer.uint32(10).string(message.functionId);
        }
        if (message.functionTag !== '') {
            writer.uint32(18).string(message.functionTag);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(26).string(message.serviceAccountId);
        }
        if (message.batchSettings !== undefined) {
            exports.BatchSettings.encode(message.batchSettings, writer.uint32(34).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFunctionTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.functionId = reader.string();
                    break;
                case 2:
                    message.functionTag = reader.string();
                    break;
                case 3:
                    message.serviceAccountId = reader.string();
                    break;
                case 4:
                    message.batchSettings = exports.BatchSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFunctionTarget);
        message.functionId =
            object.functionId !== undefined && object.functionId !== null
                ? String(object.functionId)
                : '';
        message.functionTag =
            object.functionTag !== undefined && object.functionTag !== null
                ? String(object.functionTag)
                : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromJSON(object.batchSettings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.functionId !== undefined && (obj.functionId = message.functionId);
        message.functionTag !== undefined && (obj.functionTag = message.functionTag);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.batchSettings !== undefined &&
            (obj.batchSettings = message.batchSettings
                ? exports.BatchSettings.toJSON(message.batchSettings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseFunctionTarget);
        message.functionId = (_a = object.functionId) !== null && _a !== void 0 ? _a : '';
        message.functionTag = (_b = object.functionTag) !== null && _b !== void 0 ? _b : '';
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromPartial(object.batchSettings)
                : undefined;
        return message;
    },
};
const baseContainerTarget = {
    containerId: '',
    containerRevisionId: '',
    path: '',
    serviceAccountId: '',
};
exports.ContainerTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.containerId !== '') {
            writer.uint32(10).string(message.containerId);
        }
        if (message.containerRevisionId !== '') {
            writer.uint32(18).string(message.containerRevisionId);
        }
        if (message.path !== '') {
            writer.uint32(26).string(message.path);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(34).string(message.serviceAccountId);
        }
        if (message.batchSettings !== undefined) {
            exports.BatchSettings.encode(message.batchSettings, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseContainerTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.containerId = reader.string();
                    break;
                case 2:
                    message.containerRevisionId = reader.string();
                    break;
                case 3:
                    message.path = reader.string();
                    break;
                case 4:
                    message.serviceAccountId = reader.string();
                    break;
                case 5:
                    message.batchSettings = exports.BatchSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseContainerTarget);
        message.containerId =
            object.containerId !== undefined && object.containerId !== null
                ? String(object.containerId)
                : '';
        message.containerRevisionId =
            object.containerRevisionId !== undefined && object.containerRevisionId !== null
                ? String(object.containerRevisionId)
                : '';
        message.path = object.path !== undefined && object.path !== null ? String(object.path) : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromJSON(object.batchSettings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.containerId !== undefined && (obj.containerId = message.containerId);
        message.containerRevisionId !== undefined &&
            (obj.containerRevisionId = message.containerRevisionId);
        message.path !== undefined && (obj.path = message.path);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.batchSettings !== undefined &&
            (obj.batchSettings = message.batchSettings
                ? exports.BatchSettings.toJSON(message.batchSettings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseContainerTarget);
        message.containerId = (_a = object.containerId) !== null && _a !== void 0 ? _a : '';
        message.containerRevisionId = (_b = object.containerRevisionId) !== null && _b !== void 0 ? _b : '';
        message.path = (_c = object.path) !== null && _c !== void 0 ? _c : '';
        message.serviceAccountId = (_d = object.serviceAccountId) !== null && _d !== void 0 ? _d : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromPartial(object.batchSettings)
                : undefined;
        return message;
    },
};
const baseGatewayWebsocketBroadcastTarget = {
    gatewayId: '',
    path: '',
    serviceAccountId: '',
};
exports.GatewayWebsocketBroadcastTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.gatewayId !== '') {
            writer.uint32(10).string(message.gatewayId);
        }
        if (message.path !== '') {
            writer.uint32(18).string(message.path);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(26).string(message.serviceAccountId);
        }
        if (message.batchSettings !== undefined) {
            exports.BatchSettings.encode(message.batchSettings, writer.uint32(34).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGatewayWebsocketBroadcastTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.gatewayId = reader.string();
                    break;
                case 2:
                    message.path = reader.string();
                    break;
                case 3:
                    message.serviceAccountId = reader.string();
                    break;
                case 4:
                    message.batchSettings = exports.BatchSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGatewayWebsocketBroadcastTarget);
        message.gatewayId =
            object.gatewayId !== undefined && object.gatewayId !== null
                ? String(object.gatewayId)
                : '';
        message.path = object.path !== undefined && object.path !== null ? String(object.path) : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromJSON(object.batchSettings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.gatewayId !== undefined && (obj.gatewayId = message.gatewayId);
        message.path !== undefined && (obj.path = message.path);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.batchSettings !== undefined &&
            (obj.batchSettings = message.batchSettings
                ? exports.BatchSettings.toJSON(message.batchSettings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseGatewayWebsocketBroadcastTarget);
        message.gatewayId = (_a = object.gatewayId) !== null && _a !== void 0 ? _a : '';
        message.path = (_b = object.path) !== null && _b !== void 0 ? _b : '';
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromPartial(object.batchSettings)
                : undefined;
        return message;
    },
};
const baseLoggingTarget = { serviceAccountId: '' };
exports.LoggingTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.logGroupId !== undefined) {
            writer.uint32(10).string(message.logGroupId);
        }
        if (message.folderId !== undefined) {
            writer.uint32(18).string(message.folderId);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(26).string(message.serviceAccountId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseLoggingTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.logGroupId = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.serviceAccountId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseLoggingTarget);
        message.logGroupId =
            object.logGroupId !== undefined && object.logGroupId !== null
                ? String(object.logGroupId)
                : undefined;
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : undefined;
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.logGroupId !== undefined && (obj.logGroupId = message.logGroupId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseLoggingTarget);
        message.logGroupId = (_a = object.logGroupId) !== null && _a !== void 0 ? _a : undefined;
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : undefined;
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseWorkflowTarget = { workflowId: '', serviceAccountId: '' };
exports.WorkflowTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.workflowId !== '') {
            writer.uint32(10).string(message.workflowId);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(34).string(message.serviceAccountId);
        }
        if (message.batchSettings !== undefined) {
            exports.BatchSettings.encode(message.batchSettings, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseWorkflowTarget);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.workflowId = reader.string();
                    break;
                case 4:
                    message.serviceAccountId = reader.string();
                    break;
                case 5:
                    message.batchSettings = exports.BatchSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWorkflowTarget);
        message.workflowId =
            object.workflowId !== undefined && object.workflowId !== null
                ? String(object.workflowId)
                : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromJSON(object.batchSettings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.workflowId !== undefined && (obj.workflowId = message.workflowId);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.batchSettings !== undefined &&
            (obj.batchSettings = message.batchSettings
                ? exports.BatchSettings.toJSON(message.batchSettings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseWorkflowTarget);
        message.workflowId = (_a = object.workflowId) !== null && _a !== void 0 ? _a : '';
        message.serviceAccountId = (_b = object.serviceAccountId) !== null && _b !== void 0 ? _b : '';
        message.batchSettings =
            object.batchSettings !== undefined && object.batchSettings !== null
                ? exports.BatchSettings.fromPartial(object.batchSettings)
                : undefined;
        return message;
    },
};
const baseRetrySettings = { retryAttempts: 0 };
exports.RetrySettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.retryAttempts !== 0) {
            writer.uint32(8).int64(message.retryAttempts);
        }
        if (message.maximumAge !== undefined) {
            duration_1.Duration.encode(message.maximumAge, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRetrySettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.retryAttempts = longToNumber(reader.int64());
                    break;
                case 2:
                    message.maximumAge = duration_1.Duration.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRetrySettings);
        message.retryAttempts =
            object.retryAttempts !== undefined && object.retryAttempts !== null
                ? Number(object.retryAttempts)
                : 0;
        message.maximumAge =
            object.maximumAge !== undefined && object.maximumAge !== null
                ? duration_1.Duration.fromJSON(object.maximumAge)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.retryAttempts !== undefined &&
            (obj.retryAttempts = Math.round(message.retryAttempts));
        message.maximumAge !== undefined &&
            (obj.maximumAge = message.maximumAge ? duration_1.Duration.toJSON(message.maximumAge) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseRetrySettings);
        message.retryAttempts = (_a = object.retryAttempts) !== null && _a !== void 0 ? _a : 0;
        message.maximumAge =
            object.maximumAge !== undefined && object.maximumAge !== null
                ? duration_1.Duration.fromPartial(object.maximumAge)
                : undefined;
        return message;
    },
};
const basePutQueueMessage = { queueArn: '', serviceAccountId: '' };
exports.PutQueueMessage = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.queueArn !== '') {
            writer.uint32(10).string(message.queueArn);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(18).string(message.serviceAccountId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, basePutQueueMessage);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.queueArn = reader.string();
                    break;
                case 2:
                    message.serviceAccountId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePutQueueMessage);
        message.queueArn =
            object.queueArn !== undefined && object.queueArn !== null
                ? String(object.queueArn)
                : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.queueArn !== undefined && (obj.queueArn = message.queueArn);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, basePutQueueMessage);
        message.queueArn = (_a = object.queueArn) !== null && _a !== void 0 ? _a : '';
        message.serviceAccountId = (_b = object.serviceAccountId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseBatchSettings = { maxCount: 0, maxBytes: 0 };
exports.BatchSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.maxCount !== 0) {
            writer.uint32(8).int64(message.maxCount);
        }
        if (message.maxBytes !== 0) {
            writer.uint32(16).int64(message.maxBytes);
        }
        if (message.cutoff !== undefined) {
            duration_1.Duration.encode(message.cutoff, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseBatchSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.maxCount = longToNumber(reader.int64());
                    break;
                case 2:
                    message.maxBytes = longToNumber(reader.int64());
                    break;
                case 3:
                    message.cutoff = duration_1.Duration.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseBatchSettings);
        message.maxCount =
            object.maxCount !== undefined && object.maxCount !== null ? Number(object.maxCount) : 0;
        message.maxBytes =
            object.maxBytes !== undefined && object.maxBytes !== null ? Number(object.maxBytes) : 0;
        message.cutoff =
            object.cutoff !== undefined && object.cutoff !== null
                ? duration_1.Duration.fromJSON(object.cutoff)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.maxCount !== undefined && (obj.maxCount = Math.round(message.maxCount));
        message.maxBytes !== undefined && (obj.maxBytes = Math.round(message.maxBytes));
        message.cutoff !== undefined &&
            (obj.cutoff = message.cutoff ? duration_1.Duration.toJSON(message.cutoff) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseBatchSettings);
        message.maxCount = (_a = object.maxCount) !== null && _a !== void 0 ? _a : 0;
        message.maxBytes = (_b = object.maxBytes) !== null && _b !== void 0 ? _b : 0;
        message.cutoff =
            object.cutoff !== undefined && object.cutoff !== null
                ? duration_1.Duration.fromPartial(object.cutoff)
                : undefined;
        return message;
    },
};
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
