"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleSet = exports.WafProfileExclusionRule_ExcludeRules = exports.WafProfileExclusionRule = exports.WafProfileRule = exports.WafProfile_AnalyzeRequestBody = exports.WafProfile_CoreRuleSet = exports.WafProfile_LabelsEntry = exports.WafProfile = exports.wafProfile_AnalyzeRequestBody_ActionToJSON = exports.wafProfile_AnalyzeRequestBody_ActionFromJSON = exports.WafProfile_AnalyzeRequestBody_Action = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const security_profile_1 = require("../../../../../yandex/cloud/smartwebsecurity/v1/security_profile");
const timestamp_1 = require("../../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.smartwebsecurity.v1.waf';
/** Action to perform if maximum size of body exceeded. */
var WafProfile_AnalyzeRequestBody_Action;
(function (WafProfile_AnalyzeRequestBody_Action) {
    WafProfile_AnalyzeRequestBody_Action[WafProfile_AnalyzeRequestBody_Action["ACTION_UNSPECIFIED"] = 0] = "ACTION_UNSPECIFIED";
    /** IGNORE - Ignore request. */
    WafProfile_AnalyzeRequestBody_Action[WafProfile_AnalyzeRequestBody_Action["IGNORE"] = 1] = "IGNORE";
    /** DENY - Deny request. */
    WafProfile_AnalyzeRequestBody_Action[WafProfile_AnalyzeRequestBody_Action["DENY"] = 2] = "DENY";
    WafProfile_AnalyzeRequestBody_Action[WafProfile_AnalyzeRequestBody_Action["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(WafProfile_AnalyzeRequestBody_Action = exports.WafProfile_AnalyzeRequestBody_Action || (exports.WafProfile_AnalyzeRequestBody_Action = {}));
function wafProfile_AnalyzeRequestBody_ActionFromJSON(object) {
    switch (object) {
        case 0:
        case 'ACTION_UNSPECIFIED':
            return WafProfile_AnalyzeRequestBody_Action.ACTION_UNSPECIFIED;
        case 1:
        case 'IGNORE':
            return WafProfile_AnalyzeRequestBody_Action.IGNORE;
        case 2:
        case 'DENY':
            return WafProfile_AnalyzeRequestBody_Action.DENY;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return WafProfile_AnalyzeRequestBody_Action.UNRECOGNIZED;
    }
}
exports.wafProfile_AnalyzeRequestBody_ActionFromJSON = wafProfile_AnalyzeRequestBody_ActionFromJSON;
function wafProfile_AnalyzeRequestBody_ActionToJSON(object) {
    switch (object) {
        case WafProfile_AnalyzeRequestBody_Action.ACTION_UNSPECIFIED:
            return 'ACTION_UNSPECIFIED';
        case WafProfile_AnalyzeRequestBody_Action.IGNORE:
            return 'IGNORE';
        case WafProfile_AnalyzeRequestBody_Action.DENY:
            return 'DENY';
        default:
            return 'UNKNOWN';
    }
}
exports.wafProfile_AnalyzeRequestBody_ActionToJSON = wafProfile_AnalyzeRequestBody_ActionToJSON;
const baseWafProfile = { id: '', folderId: '', cloudId: '', name: '', description: '' };
exports.WafProfile = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.cloudId !== '') {
            writer.uint32(26).string(message.cloudId);
        }
        if (message.name !== '') {
            writer.uint32(34).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(42).string(message.description);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.WafProfile_LabelsEntry.encode({ key: key, value }, writer.uint32(50).fork()).ldelim();
        });
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).ldelim();
        }
        for (const v of message.rules) {
            exports.WafProfileRule.encode(v, writer.uint32(74).fork()).ldelim();
        }
        for (const v of message.exclusionRules) {
            exports.WafProfileExclusionRule.encode(v, writer.uint32(82).fork()).ldelim();
        }
        if (message.coreRuleSet !== undefined) {
            exports.WafProfile_CoreRuleSet.encode(message.coreRuleSet, writer.uint32(90).fork()).ldelim();
        }
        if (message.analyzeRequestBody !== undefined) {
            exports.WafProfile_AnalyzeRequestBody.encode(message.analyzeRequestBody, writer.uint32(98).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({}, baseWafProfile);
        message.labels = {};
        message.rules = [];
        message.exclusionRules = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.cloudId = reader.string();
                    break;
                case 4:
                    message.name = reader.string();
                    break;
                case 5:
                    message.description = reader.string();
                    break;
                case 6:
                    const entry6 = exports.WafProfile_LabelsEntry.decode(reader, reader.uint32());
                    if (entry6.value !== undefined) {
                        message.labels[entry6.key] = entry6.value;
                    }
                    break;
                case 7:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 9:
                    message.rules.push(exports.WafProfileRule.decode(reader, reader.uint32()));
                    break;
                case 10:
                    message.exclusionRules.push(exports.WafProfileExclusionRule.decode(reader, reader.uint32()));
                    break;
                case 11:
                    message.coreRuleSet = exports.WafProfile_CoreRuleSet.decode(reader, reader.uint32());
                    break;
                case 12:
                    message.analyzeRequestBody = exports.WafProfile_AnalyzeRequestBody.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseWafProfile);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        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.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.rules = ((_b = object.rules) !== null && _b !== void 0 ? _b : []).map((e) => exports.WafProfileRule.fromJSON(e));
        message.exclusionRules = ((_c = object.exclusionRules) !== null && _c !== void 0 ? _c : []).map((e) => exports.WafProfileExclusionRule.fromJSON(e));
        message.coreRuleSet =
            object.coreRuleSet !== undefined && object.coreRuleSet !== null
                ? exports.WafProfile_CoreRuleSet.fromJSON(object.coreRuleSet)
                : undefined;
        message.analyzeRequestBody =
            object.analyzeRequestBody !== undefined && object.analyzeRequestBody !== null
                ? exports.WafProfile_AnalyzeRequestBody.fromJSON(object.analyzeRequestBody)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        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.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        if (message.rules) {
            obj.rules = message.rules.map((e) => (e ? exports.WafProfileRule.toJSON(e) : undefined));
        }
        else {
            obj.rules = [];
        }
        if (message.exclusionRules) {
            obj.exclusionRules = message.exclusionRules.map((e) => e ? exports.WafProfileExclusionRule.toJSON(e) : undefined);
        }
        else {
            obj.exclusionRules = [];
        }
        message.coreRuleSet !== undefined &&
            (obj.coreRuleSet = message.coreRuleSet
                ? exports.WafProfile_CoreRuleSet.toJSON(message.coreRuleSet)
                : undefined);
        message.analyzeRequestBody !== undefined &&
            (obj.analyzeRequestBody = message.analyzeRequestBody
                ? exports.WafProfile_AnalyzeRequestBody.toJSON(message.analyzeRequestBody)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        const message = Object.assign({}, baseWafProfile);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.cloudId = (_c = object.cloudId) !== null && _c !== void 0 ? _c : '';
        message.name = (_d = object.name) !== null && _d !== void 0 ? _d : '';
        message.description = (_e = object.description) !== null && _e !== void 0 ? _e : '';
        message.labels = Object.entries((_f = object.labels) !== null && _f !== void 0 ? _f : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.createdAt = (_g = object.createdAt) !== null && _g !== void 0 ? _g : undefined;
        message.rules = ((_h = object.rules) === null || _h === void 0 ? void 0 : _h.map((e) => exports.WafProfileRule.fromPartial(e))) || [];
        message.exclusionRules =
            ((_j = object.exclusionRules) === null || _j === void 0 ? void 0 : _j.map((e) => exports.WafProfileExclusionRule.fromPartial(e))) || [];
        message.coreRuleSet =
            object.coreRuleSet !== undefined && object.coreRuleSet !== null
                ? exports.WafProfile_CoreRuleSet.fromPartial(object.coreRuleSet)
                : undefined;
        message.analyzeRequestBody =
            object.analyzeRequestBody !== undefined && object.analyzeRequestBody !== null
                ? exports.WafProfile_AnalyzeRequestBody.fromPartial(object.analyzeRequestBody)
                : undefined;
        return message;
    },
};
const baseWafProfile_LabelsEntry = { key: '', value: '' };
exports.WafProfile_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({}, baseWafProfile_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({}, baseWafProfile_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({}, baseWafProfile_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseWafProfile_CoreRuleSet = { inboundAnomalyScore: 0, paranoiaLevel: 0 };
exports.WafProfile_CoreRuleSet = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.inboundAnomalyScore !== 0) {
            writer.uint32(8).int64(message.inboundAnomalyScore);
        }
        if (message.paranoiaLevel !== 0) {
            writer.uint32(16).int64(message.paranoiaLevel);
        }
        if (message.ruleSet !== undefined) {
            exports.RuleSet.encode(message.ruleSet, 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({}, baseWafProfile_CoreRuleSet);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.inboundAnomalyScore = longToNumber(reader.int64());
                    break;
                case 2:
                    message.paranoiaLevel = longToNumber(reader.int64());
                    break;
                case 3:
                    message.ruleSet = exports.RuleSet.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWafProfile_CoreRuleSet);
        message.inboundAnomalyScore =
            object.inboundAnomalyScore !== undefined && object.inboundAnomalyScore !== null
                ? Number(object.inboundAnomalyScore)
                : 0;
        message.paranoiaLevel =
            object.paranoiaLevel !== undefined && object.paranoiaLevel !== null
                ? Number(object.paranoiaLevel)
                : 0;
        message.ruleSet =
            object.ruleSet !== undefined && object.ruleSet !== null
                ? exports.RuleSet.fromJSON(object.ruleSet)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.inboundAnomalyScore !== undefined &&
            (obj.inboundAnomalyScore = Math.round(message.inboundAnomalyScore));
        message.paranoiaLevel !== undefined &&
            (obj.paranoiaLevel = Math.round(message.paranoiaLevel));
        message.ruleSet !== undefined &&
            (obj.ruleSet = message.ruleSet ? exports.RuleSet.toJSON(message.ruleSet) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseWafProfile_CoreRuleSet);
        message.inboundAnomalyScore = (_a = object.inboundAnomalyScore) !== null && _a !== void 0 ? _a : 0;
        message.paranoiaLevel = (_b = object.paranoiaLevel) !== null && _b !== void 0 ? _b : 0;
        message.ruleSet =
            object.ruleSet !== undefined && object.ruleSet !== null
                ? exports.RuleSet.fromPartial(object.ruleSet)
                : undefined;
        return message;
    },
};
const baseWafProfile_AnalyzeRequestBody = {
    isEnabled: false,
    sizeLimit: 0,
    sizeLimitAction: 0,
};
exports.WafProfile_AnalyzeRequestBody = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.isEnabled === true) {
            writer.uint32(8).bool(message.isEnabled);
        }
        if (message.sizeLimit !== 0) {
            writer.uint32(16).int64(message.sizeLimit);
        }
        if (message.sizeLimitAction !== 0) {
            writer.uint32(24).int32(message.sizeLimitAction);
        }
        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({}, baseWafProfile_AnalyzeRequestBody);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.isEnabled = reader.bool();
                    break;
                case 2:
                    message.sizeLimit = longToNumber(reader.int64());
                    break;
                case 3:
                    message.sizeLimitAction = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWafProfile_AnalyzeRequestBody);
        message.isEnabled =
            object.isEnabled !== undefined && object.isEnabled !== null
                ? Boolean(object.isEnabled)
                : false;
        message.sizeLimit =
            object.sizeLimit !== undefined && object.sizeLimit !== null
                ? Number(object.sizeLimit)
                : 0;
        message.sizeLimitAction =
            object.sizeLimitAction !== undefined && object.sizeLimitAction !== null
                ? wafProfile_AnalyzeRequestBody_ActionFromJSON(object.sizeLimitAction)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.isEnabled !== undefined && (obj.isEnabled = message.isEnabled);
        message.sizeLimit !== undefined && (obj.sizeLimit = Math.round(message.sizeLimit));
        message.sizeLimitAction !== undefined &&
            (obj.sizeLimitAction = wafProfile_AnalyzeRequestBody_ActionToJSON(message.sizeLimitAction));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseWafProfile_AnalyzeRequestBody);
        message.isEnabled = (_a = object.isEnabled) !== null && _a !== void 0 ? _a : false;
        message.sizeLimit = (_b = object.sizeLimit) !== null && _b !== void 0 ? _b : 0;
        message.sizeLimitAction = (_c = object.sizeLimitAction) !== null && _c !== void 0 ? _c : 0;
        return message;
    },
};
const baseWafProfileRule = { ruleId: '', isEnabled: false, isBlocking: false };
exports.WafProfileRule = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.ruleId !== '') {
            writer.uint32(10).string(message.ruleId);
        }
        if (message.isEnabled === true) {
            writer.uint32(16).bool(message.isEnabled);
        }
        if (message.isBlocking === true) {
            writer.uint32(24).bool(message.isBlocking);
        }
        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({}, baseWafProfileRule);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.ruleId = reader.string();
                    break;
                case 2:
                    message.isEnabled = reader.bool();
                    break;
                case 3:
                    message.isBlocking = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWafProfileRule);
        message.ruleId =
            object.ruleId !== undefined && object.ruleId !== null ? String(object.ruleId) : '';
        message.isEnabled =
            object.isEnabled !== undefined && object.isEnabled !== null
                ? Boolean(object.isEnabled)
                : false;
        message.isBlocking =
            object.isBlocking !== undefined && object.isBlocking !== null
                ? Boolean(object.isBlocking)
                : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.ruleId !== undefined && (obj.ruleId = message.ruleId);
        message.isEnabled !== undefined && (obj.isEnabled = message.isEnabled);
        message.isBlocking !== undefined && (obj.isBlocking = message.isBlocking);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseWafProfileRule);
        message.ruleId = (_a = object.ruleId) !== null && _a !== void 0 ? _a : '';
        message.isEnabled = (_b = object.isEnabled) !== null && _b !== void 0 ? _b : false;
        message.isBlocking = (_c = object.isBlocking) !== null && _c !== void 0 ? _c : false;
        return message;
    },
};
const baseWafProfileExclusionRule = { name: '', description: '', logExcluded: false };
exports.WafProfileExclusionRule = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(18).string(message.description);
        }
        if (message.condition !== undefined) {
            security_profile_1.Condition.encode(message.condition, writer.uint32(26).fork()).ldelim();
        }
        if (message.excludeRules !== undefined) {
            exports.WafProfileExclusionRule_ExcludeRules.encode(message.excludeRules, writer.uint32(34).fork()).ldelim();
        }
        if (message.logExcluded === true) {
            writer.uint32(40).bool(message.logExcluded);
        }
        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({}, baseWafProfileExclusionRule);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.description = reader.string();
                    break;
                case 3:
                    message.condition = security_profile_1.Condition.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.excludeRules = exports.WafProfileExclusionRule_ExcludeRules.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.logExcluded = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWafProfileExclusionRule);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? security_profile_1.Condition.fromJSON(object.condition)
                : undefined;
        message.excludeRules =
            object.excludeRules !== undefined && object.excludeRules !== null
                ? exports.WafProfileExclusionRule_ExcludeRules.fromJSON(object.excludeRules)
                : undefined;
        message.logExcluded =
            object.logExcluded !== undefined && object.logExcluded !== null
                ? Boolean(object.logExcluded)
                : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.condition !== undefined &&
            (obj.condition = message.condition ? security_profile_1.Condition.toJSON(message.condition) : undefined);
        message.excludeRules !== undefined &&
            (obj.excludeRules = message.excludeRules
                ? exports.WafProfileExclusionRule_ExcludeRules.toJSON(message.excludeRules)
                : undefined);
        message.logExcluded !== undefined && (obj.logExcluded = message.logExcluded);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseWafProfileExclusionRule);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? security_profile_1.Condition.fromPartial(object.condition)
                : undefined;
        message.excludeRules =
            object.excludeRules !== undefined && object.excludeRules !== null
                ? exports.WafProfileExclusionRule_ExcludeRules.fromPartial(object.excludeRules)
                : undefined;
        message.logExcluded = (_c = object.logExcluded) !== null && _c !== void 0 ? _c : false;
        return message;
    },
};
const baseWafProfileExclusionRule_ExcludeRules = { excludeAll: false, ruleIds: '' };
exports.WafProfileExclusionRule_ExcludeRules = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.excludeAll === true) {
            writer.uint32(8).bool(message.excludeAll);
        }
        for (const v of message.ruleIds) {
            writer.uint32(18).string(v);
        }
        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({}, baseWafProfileExclusionRule_ExcludeRules);
        message.ruleIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.excludeAll = reader.bool();
                    break;
                case 2:
                    message.ruleIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseWafProfileExclusionRule_ExcludeRules);
        message.excludeAll =
            object.excludeAll !== undefined && object.excludeAll !== null
                ? Boolean(object.excludeAll)
                : false;
        message.ruleIds = ((_a = object.ruleIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.excludeAll !== undefined && (obj.excludeAll = message.excludeAll);
        if (message.ruleIds) {
            obj.ruleIds = message.ruleIds.map((e) => e);
        }
        else {
            obj.ruleIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseWafProfileExclusionRule_ExcludeRules);
        message.excludeAll = (_a = object.excludeAll) !== null && _a !== void 0 ? _a : false;
        message.ruleIds = ((_b = object.ruleIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
const baseRuleSet = { name: '', version: '' };
exports.RuleSet = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.version !== '') {
            writer.uint32(18).string(message.version);
        }
        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({}, baseRuleSet);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.version = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRuleSet);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.version =
            object.version !== undefined && object.version !== null ? String(object.version) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.version !== undefined && (obj.version = message.version);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRuleSet);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.version = (_b = object.version) !== null && _b !== void 0 ? _b : '';
        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();
}
