"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Timeline = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
exports.protobufPackage = 'yandex.cloud.monitoring.v3';
const baseTimeline = { period: '', refreshInterval: 0 };
exports.Timeline = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.period !== '') {
            writer.uint32(10).string(message.period);
        }
        if (message.refreshInterval !== 0) {
            writer.uint32(16).int64(message.refreshInterval);
        }
        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({}, baseTimeline);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.period = reader.string();
                    break;
                case 2:
                    message.refreshInterval = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTimeline);
        message.period =
            object.period !== undefined && object.period !== null ? String(object.period) : '';
        message.refreshInterval =
            object.refreshInterval !== undefined && object.refreshInterval !== null
                ? Number(object.refreshInterval)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.period !== undefined && (obj.period = message.period);
        message.refreshInterval !== undefined &&
            (obj.refreshInterval = Math.round(message.refreshInterval));
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTimeline);
        message.period = (_a = object.period) !== null && _a !== void 0 ? _a : '';
        message.refreshInterval = (_b = object.refreshInterval) !== null && _b !== void 0 ? _b : 0;
        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 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();
}
