"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatasetFileDownloadUrl = exports.DatasetUploadSchema = exports.ValidationError = exports.DatasetInfo_LabelsEntry = exports.DatasetInfo = exports.datasetInfo_StatusToJSON = exports.datasetInfo_StatusFromJSON = exports.DatasetInfo_Status = 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");
exports.protobufPackage = 'yandex.cloud.ai.dataset.v1';
/** Status of the dataset. */
var DatasetInfo_Status;
(function (DatasetInfo_Status) {
    DatasetInfo_Status[DatasetInfo_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    DatasetInfo_Status[DatasetInfo_Status["DRAFT"] = 1] = "DRAFT";
    DatasetInfo_Status[DatasetInfo_Status["VALIDATING"] = 2] = "VALIDATING";
    DatasetInfo_Status[DatasetInfo_Status["READY"] = 3] = "READY";
    DatasetInfo_Status[DatasetInfo_Status["INVALID"] = 4] = "INVALID";
    DatasetInfo_Status[DatasetInfo_Status["DELETING"] = 5] = "DELETING";
    DatasetInfo_Status[DatasetInfo_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(DatasetInfo_Status = exports.DatasetInfo_Status || (exports.DatasetInfo_Status = {}));
function datasetInfo_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return DatasetInfo_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'DRAFT':
            return DatasetInfo_Status.DRAFT;
        case 2:
        case 'VALIDATING':
            return DatasetInfo_Status.VALIDATING;
        case 3:
        case 'READY':
            return DatasetInfo_Status.READY;
        case 4:
        case 'INVALID':
            return DatasetInfo_Status.INVALID;
        case 5:
        case 'DELETING':
            return DatasetInfo_Status.DELETING;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return DatasetInfo_Status.UNRECOGNIZED;
    }
}
exports.datasetInfo_StatusFromJSON = datasetInfo_StatusFromJSON;
function datasetInfo_StatusToJSON(object) {
    switch (object) {
        case DatasetInfo_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case DatasetInfo_Status.DRAFT:
            return 'DRAFT';
        case DatasetInfo_Status.VALIDATING:
            return 'VALIDATING';
        case DatasetInfo_Status.READY:
            return 'READY';
        case DatasetInfo_Status.INVALID:
            return 'INVALID';
        case DatasetInfo_Status.DELETING:
            return 'DELETING';
        default:
            return 'UNKNOWN';
    }
}
exports.datasetInfo_StatusToJSON = datasetInfo_StatusToJSON;
const baseDatasetInfo = {
    datasetId: '',
    folderId: '',
    name: '',
    description: '',
    metadata: '',
    status: 0,
    taskType: '',
    rows: 0,
    sizeBytes: 0,
    createdById: '',
    createdBy: '',
    updatedBy: '',
    allowDataLog: false,
};
exports.DatasetInfo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.datasetId !== '') {
            writer.uint32(10).string(message.datasetId);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.name !== '') {
            writer.uint32(26).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.metadata !== '') {
            writer.uint32(42).string(message.metadata);
        }
        if (message.status !== 0) {
            writer.uint32(48).int32(message.status);
        }
        if (message.taskType !== '') {
            writer.uint32(58).string(message.taskType);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(66).fork()).ldelim();
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(74).fork()).ldelim();
        }
        if (message.rows !== 0) {
            writer.uint32(80).int64(message.rows);
        }
        if (message.sizeBytes !== 0) {
            writer.uint32(88).int64(message.sizeBytes);
        }
        if (message.createdById !== '') {
            writer.uint32(98).string(message.createdById);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.DatasetInfo_LabelsEntry.encode({ key: key, value }, writer.uint32(106).fork()).ldelim();
        });
        if (message.createdBy !== '') {
            writer.uint32(114).string(message.createdBy);
        }
        if (message.updatedBy !== '') {
            writer.uint32(122).string(message.updatedBy);
        }
        for (const v of message.validationError) {
            exports.ValidationError.encode(v, writer.uint32(170).fork()).ldelim();
        }
        if (message.allowDataLog === true) {
            writer.uint32(176).bool(message.allowDataLog);
        }
        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({}, baseDatasetInfo);
        message.labels = {};
        message.validationError = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.datasetId = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.name = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 5:
                    message.metadata = reader.string();
                    break;
                case 6:
                    message.status = reader.int32();
                    break;
                case 7:
                    message.taskType = reader.string();
                    break;
                case 8:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 9:
                    message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 10:
                    message.rows = longToNumber(reader.int64());
                    break;
                case 11:
                    message.sizeBytes = longToNumber(reader.int64());
                    break;
                case 12:
                    message.createdById = reader.string();
                    break;
                case 13:
                    const entry13 = exports.DatasetInfo_LabelsEntry.decode(reader, reader.uint32());
                    if (entry13.value !== undefined) {
                        message.labels[entry13.key] = entry13.value;
                    }
                    break;
                case 14:
                    message.createdBy = reader.string();
                    break;
                case 15:
                    message.updatedBy = reader.string();
                    break;
                case 21:
                    message.validationError.push(exports.ValidationError.decode(reader, reader.uint32()));
                    break;
                case 22:
                    message.allowDataLog = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b;
        const message = Object.assign({}, baseDatasetInfo);
        message.datasetId =
            object.datasetId !== undefined && object.datasetId !== null
                ? String(object.datasetId)
                : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.metadata =
            object.metadata !== undefined && object.metadata !== null
                ? String(object.metadata)
                : '';
        message.status =
            object.status !== undefined && object.status !== null
                ? datasetInfo_StatusFromJSON(object.status)
                : 0;
        message.taskType =
            object.taskType !== undefined && object.taskType !== null
                ? String(object.taskType)
                : '';
        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.rows = object.rows !== undefined && object.rows !== null ? Number(object.rows) : 0;
        message.sizeBytes =
            object.sizeBytes !== undefined && object.sizeBytes !== null
                ? Number(object.sizeBytes)
                : 0;
        message.createdById =
            object.createdById !== undefined && object.createdById !== null
                ? String(object.createdById)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.createdBy =
            object.createdBy !== undefined && object.createdBy !== null
                ? String(object.createdBy)
                : '';
        message.updatedBy =
            object.updatedBy !== undefined && object.updatedBy !== null
                ? String(object.updatedBy)
                : '';
        message.validationError = ((_b = object.validationError) !== null && _b !== void 0 ? _b : []).map((e) => exports.ValidationError.fromJSON(e));
        message.allowDataLog =
            object.allowDataLog !== undefined && object.allowDataLog !== null
                ? Boolean(object.allowDataLog)
                : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.datasetId !== undefined && (obj.datasetId = message.datasetId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.metadata !== undefined && (obj.metadata = message.metadata);
        message.status !== undefined && (obj.status = datasetInfo_StatusToJSON(message.status));
        message.taskType !== undefined && (obj.taskType = message.taskType);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString());
        message.rows !== undefined && (obj.rows = Math.round(message.rows));
        message.sizeBytes !== undefined && (obj.sizeBytes = Math.round(message.sizeBytes));
        message.createdById !== undefined && (obj.createdById = message.createdById);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.createdBy !== undefined && (obj.createdBy = message.createdBy);
        message.updatedBy !== undefined && (obj.updatedBy = message.updatedBy);
        if (message.validationError) {
            obj.validationError = message.validationError.map((e) => e ? exports.ValidationError.toJSON(e) : undefined);
        }
        else {
            obj.validationError = [];
        }
        message.allowDataLog !== undefined && (obj.allowDataLog = message.allowDataLog);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
        const message = Object.assign({}, baseDatasetInfo);
        message.datasetId = (_a = object.datasetId) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.name = (_c = object.name) !== null && _c !== void 0 ? _c : '';
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        message.metadata = (_e = object.metadata) !== null && _e !== void 0 ? _e : '';
        message.status = (_f = object.status) !== null && _f !== void 0 ? _f : 0;
        message.taskType = (_g = object.taskType) !== null && _g !== void 0 ? _g : '';
        message.createdAt = (_h = object.createdAt) !== null && _h !== void 0 ? _h : undefined;
        message.updatedAt = (_j = object.updatedAt) !== null && _j !== void 0 ? _j : undefined;
        message.rows = (_k = object.rows) !== null && _k !== void 0 ? _k : 0;
        message.sizeBytes = (_l = object.sizeBytes) !== null && _l !== void 0 ? _l : 0;
        message.createdById = (_m = object.createdById) !== null && _m !== void 0 ? _m : '';
        message.labels = Object.entries((_o = object.labels) !== null && _o !== void 0 ? _o : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.createdBy = (_p = object.createdBy) !== null && _p !== void 0 ? _p : '';
        message.updatedBy = (_q = object.updatedBy) !== null && _q !== void 0 ? _q : '';
        message.validationError =
            ((_r = object.validationError) === null || _r === void 0 ? void 0 : _r.map((e) => exports.ValidationError.fromPartial(e))) || [];
        message.allowDataLog = (_s = object.allowDataLog) !== null && _s !== void 0 ? _s : false;
        return message;
    },
};
const baseDatasetInfo_LabelsEntry = { key: '', value: '' };
exports.DatasetInfo_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({}, baseDatasetInfo_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({}, baseDatasetInfo_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({}, baseDatasetInfo_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseValidationError = { error: '', errorDescription: '', rowNumbers: 0 };
exports.ValidationError = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.error !== '') {
            writer.uint32(10).string(message.error);
        }
        if (message.errorDescription !== '') {
            writer.uint32(18).string(message.errorDescription);
        }
        writer.uint32(26).fork();
        for (const v of message.rowNumbers) {
            writer.int64(v);
        }
        writer.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({}, baseValidationError);
        message.rowNumbers = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.error = reader.string();
                    break;
                case 2:
                    message.errorDescription = reader.string();
                    break;
                case 3:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.rowNumbers.push(longToNumber(reader.int64()));
                        }
                    }
                    else {
                        message.rowNumbers.push(longToNumber(reader.int64()));
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseValidationError);
        message.error =
            object.error !== undefined && object.error !== null ? String(object.error) : '';
        message.errorDescription =
            object.errorDescription !== undefined && object.errorDescription !== null
                ? String(object.errorDescription)
                : '';
        message.rowNumbers = ((_a = object.rowNumbers) !== null && _a !== void 0 ? _a : []).map((e) => Number(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.error !== undefined && (obj.error = message.error);
        message.errorDescription !== undefined && (obj.errorDescription = message.errorDescription);
        if (message.rowNumbers) {
            obj.rowNumbers = message.rowNumbers.map((e) => Math.round(e));
        }
        else {
            obj.rowNumbers = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseValidationError);
        message.error = (_a = object.error) !== null && _a !== void 0 ? _a : '';
        message.errorDescription = (_b = object.errorDescription) !== null && _b !== void 0 ? _b : '';
        message.rowNumbers = ((_c = object.rowNumbers) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
        return message;
    },
};
const baseDatasetUploadSchema = { taskType: '', uploadFormat: '', schema: '' };
exports.DatasetUploadSchema = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.taskType !== '') {
            writer.uint32(10).string(message.taskType);
        }
        if (message.uploadFormat !== '') {
            writer.uint32(18).string(message.uploadFormat);
        }
        if (message.schema !== '') {
            writer.uint32(26).string(message.schema);
        }
        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({}, baseDatasetUploadSchema);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.taskType = reader.string();
                    break;
                case 2:
                    message.uploadFormat = reader.string();
                    break;
                case 3:
                    message.schema = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDatasetUploadSchema);
        message.taskType =
            object.taskType !== undefined && object.taskType !== null
                ? String(object.taskType)
                : '';
        message.uploadFormat =
            object.uploadFormat !== undefined && object.uploadFormat !== null
                ? String(object.uploadFormat)
                : '';
        message.schema =
            object.schema !== undefined && object.schema !== null ? String(object.schema) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.taskType !== undefined && (obj.taskType = message.taskType);
        message.uploadFormat !== undefined && (obj.uploadFormat = message.uploadFormat);
        message.schema !== undefined && (obj.schema = message.schema);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseDatasetUploadSchema);
        message.taskType = (_a = object.taskType) !== null && _a !== void 0 ? _a : '';
        message.uploadFormat = (_b = object.uploadFormat) !== null && _b !== void 0 ? _b : '';
        message.schema = (_c = object.schema) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseDatasetFileDownloadUrl = { key: '', url: '' };
exports.DatasetFileDownloadUrl = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.url !== '') {
            writer.uint32(18).string(message.url);
        }
        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({}, baseDatasetFileDownloadUrl);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.url = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDatasetFileDownloadUrl);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.url = object.url !== undefined && object.url !== null ? String(object.url) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.url !== undefined && (obj.url = message.url);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseDatasetFileDownloadUrl);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.url = (_b = object.url) !== 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();
}
