"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dashboard_Content = exports.Dashboard = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../../../google/protobuf/timestamp");
const widget_1 = require("../../../../../../yandex/cloud/loadtesting/api/v1/regression/widget");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1.regression';
const baseDashboard = {
    id: '',
    name: '',
    description: '',
    createdBy: '',
    updatedBy: '',
    etag: '',
};
exports.Dashboard = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.name !== '') {
            writer.uint32(18).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(34).fork()).ldelim();
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(42).fork()).ldelim();
        }
        if (message.createdBy !== '') {
            writer.uint32(50).string(message.createdBy);
        }
        if (message.updatedBy !== '') {
            writer.uint32(58).string(message.updatedBy);
        }
        if (message.etag !== '') {
            writer.uint32(66).string(message.etag);
        }
        if (message.content !== undefined) {
            exports.Dashboard_Content.encode(message.content, writer.uint32(74).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({}, baseDashboard);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.name = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 4:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 5:
                    message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 6:
                    message.createdBy = reader.string();
                    break;
                case 7:
                    message.updatedBy = reader.string();
                    break;
                case 8:
                    message.etag = reader.string();
                    break;
                case 9:
                    message.content = exports.Dashboard_Content.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDashboard);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.updatedAt =
            object.updatedAt !== undefined && object.updatedAt !== null
                ? fromJsonTimestamp(object.updatedAt)
                : undefined;
        message.createdBy =
            object.createdBy !== undefined && object.createdBy !== null
                ? String(object.createdBy)
                : '';
        message.updatedBy =
            object.updatedBy !== undefined && object.updatedBy !== null
                ? String(object.updatedBy)
                : '';
        message.etag = object.etag !== undefined && object.etag !== null ? String(object.etag) : '';
        message.content =
            object.content !== undefined && object.content !== null
                ? exports.Dashboard_Content.fromJSON(object.content)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString());
        message.createdBy !== undefined && (obj.createdBy = message.createdBy);
        message.updatedBy !== undefined && (obj.updatedBy = message.updatedBy);
        message.etag !== undefined && (obj.etag = message.etag);
        message.content !== undefined &&
            (obj.content = message.content ? exports.Dashboard_Content.toJSON(message.content) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, baseDashboard);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.createdAt = (_d = object.createdAt) !== null && _d !== void 0 ? _d : undefined;
        message.updatedAt = (_e = object.updatedAt) !== null && _e !== void 0 ? _e : undefined;
        message.createdBy = (_f = object.createdBy) !== null && _f !== void 0 ? _f : '';
        message.updatedBy = (_g = object.updatedBy) !== null && _g !== void 0 ? _g : '';
        message.etag = (_h = object.etag) !== null && _h !== void 0 ? _h : '';
        message.content =
            object.content !== undefined && object.content !== null
                ? exports.Dashboard_Content.fromPartial(object.content)
                : undefined;
        return message;
    },
};
const baseDashboard_Content = {};
exports.Dashboard_Content = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.widgets) {
            widget_1.Widget.encode(v, writer.uint32(10).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({}, baseDashboard_Content);
        message.widgets = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.widgets.push(widget_1.Widget.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseDashboard_Content);
        message.widgets = ((_a = object.widgets) !== null && _a !== void 0 ? _a : []).map((e) => widget_1.Widget.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.widgets) {
            obj.widgets = message.widgets.map((e) => (e ? widget_1.Widget.toJSON(e) : undefined));
        }
        else {
            obj.widgets = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDashboard_Content);
        message.widgets = ((_a = object.widgets) === null || _a === void 0 ? void 0 : _a.map((e) => widget_1.Widget.fromPartial(e))) || [];
        return message;
    },
};
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));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
