"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThumbnailServiceClient = exports.ThumbnailServiceService = exports.DeleteThumbnailMetadata = exports.DeleteThumbnailRequest = exports.GenerateThumbnailUploadURLResponse = exports.GenerateThumbnailUploadURLRequest = exports.ThumbnailDownloadURL_ScaledURL = exports.ThumbnailDownloadURL = exports.BatchGenerateDownloadURLsResponse = exports.BatchGenerateDownloadURLsRequest = exports.CreateThumbnailMetadata = exports.CreateThumbnailRequest = exports.ListThumbnailResponse = exports.ListThumbnailRequest = exports.GetThumbnailRequest = exports.thumbnailDownloadURL_ImageFormatToJSON = exports.thumbnailDownloadURL_ImageFormatFromJSON = exports.ThumbnailDownloadURL_ImageFormat = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const thumbnail_1 = require("../../../../yandex/cloud/video/v1/thumbnail");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.video.v1';
var ThumbnailDownloadURL_ImageFormat;
(function (ThumbnailDownloadURL_ImageFormat) {
    /** IMAGE_FORMAT_UNSPECIFIED - Image format unspecified. */
    ThumbnailDownloadURL_ImageFormat[ThumbnailDownloadURL_ImageFormat["IMAGE_FORMAT_UNSPECIFIED"] = 0] = "IMAGE_FORMAT_UNSPECIFIED";
    /** JPEG - JPEG image format. */
    ThumbnailDownloadURL_ImageFormat[ThumbnailDownloadURL_ImageFormat["JPEG"] = 1] = "JPEG";
    /** WEBP - WebP image format. */
    ThumbnailDownloadURL_ImageFormat[ThumbnailDownloadURL_ImageFormat["WEBP"] = 2] = "WEBP";
    ThumbnailDownloadURL_ImageFormat[ThumbnailDownloadURL_ImageFormat["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ThumbnailDownloadURL_ImageFormat = exports.ThumbnailDownloadURL_ImageFormat || (exports.ThumbnailDownloadURL_ImageFormat = {}));
function thumbnailDownloadURL_ImageFormatFromJSON(object) {
    switch (object) {
        case 0:
        case 'IMAGE_FORMAT_UNSPECIFIED':
            return ThumbnailDownloadURL_ImageFormat.IMAGE_FORMAT_UNSPECIFIED;
        case 1:
        case 'JPEG':
            return ThumbnailDownloadURL_ImageFormat.JPEG;
        case 2:
        case 'WEBP':
            return ThumbnailDownloadURL_ImageFormat.WEBP;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return ThumbnailDownloadURL_ImageFormat.UNRECOGNIZED;
    }
}
exports.thumbnailDownloadURL_ImageFormatFromJSON = thumbnailDownloadURL_ImageFormatFromJSON;
function thumbnailDownloadURL_ImageFormatToJSON(object) {
    switch (object) {
        case ThumbnailDownloadURL_ImageFormat.IMAGE_FORMAT_UNSPECIFIED:
            return 'IMAGE_FORMAT_UNSPECIFIED';
        case ThumbnailDownloadURL_ImageFormat.JPEG:
            return 'JPEG';
        case ThumbnailDownloadURL_ImageFormat.WEBP:
            return 'WEBP';
        default:
            return 'UNKNOWN';
    }
}
exports.thumbnailDownloadURL_ImageFormatToJSON = thumbnailDownloadURL_ImageFormatToJSON;
const baseGetThumbnailRequest = { thumbnailId: '' };
exports.GetThumbnailRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        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({}, baseGetThumbnailRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetThumbnailRequest);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetThumbnailRequest);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListThumbnailRequest = { channelId: '', pageSize: 0, pageToken: '' };
exports.ListThumbnailRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        if (message.pageSize !== 0) {
            writer.uint32(800).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(810).string(message.pageToken);
        }
        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({}, baseListThumbnailRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 100:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 101:
                    message.pageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListThumbnailRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseListThumbnailRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        message.pageSize = (_b = object.pageSize) !== null && _b !== void 0 ? _b : 0;
        message.pageToken = (_c = object.pageToken) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseListThumbnailResponse = { nextPageToken: '' };
exports.ListThumbnailResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.thumbnails) {
            thumbnail_1.Thumbnail.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(802).string(message.nextPageToken);
        }
        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({}, baseListThumbnailResponse);
        message.thumbnails = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnails.push(thumbnail_1.Thumbnail.decode(reader, reader.uint32()));
                    break;
                case 100:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListThumbnailResponse);
        message.thumbnails = ((_a = object.thumbnails) !== null && _a !== void 0 ? _a : []).map((e) => thumbnail_1.Thumbnail.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.thumbnails) {
            obj.thumbnails = message.thumbnails.map((e) => (e ? thumbnail_1.Thumbnail.toJSON(e) : undefined));
        }
        else {
            obj.thumbnails = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListThumbnailResponse);
        message.thumbnails = ((_a = object.thumbnails) === null || _a === void 0 ? void 0 : _a.map((e) => thumbnail_1.Thumbnail.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCreateThumbnailRequest = { channelId: '' };
exports.CreateThumbnailRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        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({}, baseCreateThumbnailRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateThumbnailRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateThumbnailRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseCreateThumbnailMetadata = { thumbnailId: '' };
exports.CreateThumbnailMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        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({}, baseCreateThumbnailMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateThumbnailMetadata);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateThumbnailMetadata);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseBatchGenerateDownloadURLsRequest = { channelId: '', thumbnailIds: '' };
exports.BatchGenerateDownloadURLsRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        for (const v of message.thumbnailIds) {
            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({}, baseBatchGenerateDownloadURLsRequest);
        message.thumbnailIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.thumbnailIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchGenerateDownloadURLsRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        message.thumbnailIds = ((_a = object.thumbnailIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        if (message.thumbnailIds) {
            obj.thumbnailIds = message.thumbnailIds.map((e) => e);
        }
        else {
            obj.thumbnailIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseBatchGenerateDownloadURLsRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        message.thumbnailIds = ((_b = object.thumbnailIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
const baseBatchGenerateDownloadURLsResponse = {};
exports.BatchGenerateDownloadURLsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.downloadUrls) {
            exports.ThumbnailDownloadURL.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({}, baseBatchGenerateDownloadURLsResponse);
        message.downloadUrls = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.downloadUrls.push(exports.ThumbnailDownloadURL.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchGenerateDownloadURLsResponse);
        message.downloadUrls = ((_a = object.downloadUrls) !== null && _a !== void 0 ? _a : []).map((e) => exports.ThumbnailDownloadURL.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.downloadUrls) {
            obj.downloadUrls = message.downloadUrls.map((e) => e ? exports.ThumbnailDownloadURL.toJSON(e) : undefined);
        }
        else {
            obj.downloadUrls = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseBatchGenerateDownloadURLsResponse);
        message.downloadUrls =
            ((_a = object.downloadUrls) === null || _a === void 0 ? void 0 : _a.map((e) => exports.ThumbnailDownloadURL.fromPartial(e))) || [];
        return message;
    },
};
const baseThumbnailDownloadURL = { thumbnailId: '', originalUrl: '' };
exports.ThumbnailDownloadURL = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        if (message.originalUrl !== '') {
            writer.uint32(18).string(message.originalUrl);
        }
        for (const v of message.scaledUrls) {
            exports.ThumbnailDownloadURL_ScaledURL.encode(v, 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({}, baseThumbnailDownloadURL);
        message.scaledUrls = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                case 2:
                    message.originalUrl = reader.string();
                    break;
                case 3:
                    message.scaledUrls.push(exports.ThumbnailDownloadURL_ScaledURL.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseThumbnailDownloadURL);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        message.originalUrl =
            object.originalUrl !== undefined && object.originalUrl !== null
                ? String(object.originalUrl)
                : '';
        message.scaledUrls = ((_a = object.scaledUrls) !== null && _a !== void 0 ? _a : []).map((e) => exports.ThumbnailDownloadURL_ScaledURL.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        message.originalUrl !== undefined && (obj.originalUrl = message.originalUrl);
        if (message.scaledUrls) {
            obj.scaledUrls = message.scaledUrls.map((e) => e ? exports.ThumbnailDownloadURL_ScaledURL.toJSON(e) : undefined);
        }
        else {
            obj.scaledUrls = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseThumbnailDownloadURL);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        message.originalUrl = (_b = object.originalUrl) !== null && _b !== void 0 ? _b : '';
        message.scaledUrls =
            ((_c = object.scaledUrls) === null || _c === void 0 ? void 0 : _c.map((e) => exports.ThumbnailDownloadURL_ScaledURL.fromPartial(e))) || [];
        return message;
    },
};
const baseThumbnailDownloadURL_ScaledURL = {
    url: '',
    maxWidth: 0,
    maxHeight: 0,
    imageFormat: 0,
};
exports.ThumbnailDownloadURL_ScaledURL = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.url !== '') {
            writer.uint32(10).string(message.url);
        }
        if (message.maxWidth !== 0) {
            writer.uint32(16).int64(message.maxWidth);
        }
        if (message.maxHeight !== 0) {
            writer.uint32(24).int64(message.maxHeight);
        }
        if (message.imageFormat !== 0) {
            writer.uint32(32).int32(message.imageFormat);
        }
        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({}, baseThumbnailDownloadURL_ScaledURL);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.url = reader.string();
                    break;
                case 2:
                    message.maxWidth = longToNumber(reader.int64());
                    break;
                case 3:
                    message.maxHeight = longToNumber(reader.int64());
                    break;
                case 4:
                    message.imageFormat = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseThumbnailDownloadURL_ScaledURL);
        message.url = object.url !== undefined && object.url !== null ? String(object.url) : '';
        message.maxWidth =
            object.maxWidth !== undefined && object.maxWidth !== null ? Number(object.maxWidth) : 0;
        message.maxHeight =
            object.maxHeight !== undefined && object.maxHeight !== null
                ? Number(object.maxHeight)
                : 0;
        message.imageFormat =
            object.imageFormat !== undefined && object.imageFormat !== null
                ? thumbnailDownloadURL_ImageFormatFromJSON(object.imageFormat)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.url !== undefined && (obj.url = message.url);
        message.maxWidth !== undefined && (obj.maxWidth = Math.round(message.maxWidth));
        message.maxHeight !== undefined && (obj.maxHeight = Math.round(message.maxHeight));
        message.imageFormat !== undefined &&
            (obj.imageFormat = thumbnailDownloadURL_ImageFormatToJSON(message.imageFormat));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseThumbnailDownloadURL_ScaledURL);
        message.url = (_a = object.url) !== null && _a !== void 0 ? _a : '';
        message.maxWidth = (_b = object.maxWidth) !== null && _b !== void 0 ? _b : 0;
        message.maxHeight = (_c = object.maxHeight) !== null && _c !== void 0 ? _c : 0;
        message.imageFormat = (_d = object.imageFormat) !== null && _d !== void 0 ? _d : 0;
        return message;
    },
};
const baseGenerateThumbnailUploadURLRequest = { thumbnailId: '' };
exports.GenerateThumbnailUploadURLRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        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({}, baseGenerateThumbnailUploadURLRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGenerateThumbnailUploadURLRequest);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGenerateThumbnailUploadURLRequest);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGenerateThumbnailUploadURLResponse = { uploadUrl: '' };
exports.GenerateThumbnailUploadURLResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.uploadUrl !== '') {
            writer.uint32(10).string(message.uploadUrl);
        }
        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({}, baseGenerateThumbnailUploadURLResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.uploadUrl = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGenerateThumbnailUploadURLResponse);
        message.uploadUrl =
            object.uploadUrl !== undefined && object.uploadUrl !== null
                ? String(object.uploadUrl)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.uploadUrl !== undefined && (obj.uploadUrl = message.uploadUrl);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGenerateThumbnailUploadURLResponse);
        message.uploadUrl = (_a = object.uploadUrl) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteThumbnailRequest = { thumbnailId: '' };
exports.DeleteThumbnailRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        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({}, baseDeleteThumbnailRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteThumbnailRequest);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteThumbnailRequest);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteThumbnailMetadata = { thumbnailId: '' };
exports.DeleteThumbnailMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.thumbnailId !== '') {
            writer.uint32(10).string(message.thumbnailId);
        }
        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({}, baseDeleteThumbnailMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.thumbnailId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteThumbnailMetadata);
        message.thumbnailId =
            object.thumbnailId !== undefined && object.thumbnailId !== null
                ? String(object.thumbnailId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.thumbnailId !== undefined && (obj.thumbnailId = message.thumbnailId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteThumbnailMetadata);
        message.thumbnailId = (_a = object.thumbnailId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
/** Thumbnail management service. */
exports.ThumbnailServiceService = {
    /** Get the specific thumbnail. */
    get: {
        path: '/yandex.cloud.video.v1.ThumbnailService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetThumbnailRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetThumbnailRequest.decode(value),
        responseSerialize: (value) => Buffer.from(thumbnail_1.Thumbnail.encode(value).finish()),
        responseDeserialize: (value) => thumbnail_1.Thumbnail.decode(value),
    },
    /** List thumbnails for channel. */
    list: {
        path: '/yandex.cloud.video.v1.ThumbnailService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListThumbnailRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListThumbnailRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListThumbnailResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListThumbnailResponse.decode(value),
    },
    /** Create thumbnail. */
    create: {
        path: '/yandex.cloud.video.v1.ThumbnailService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateThumbnailRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateThumbnailRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Generate urls for downloading images. */
    batchGenerateDownloadURLs: {
        path: '/yandex.cloud.video.v1.ThumbnailService/BatchGenerateDownloadURLs',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.BatchGenerateDownloadURLsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.BatchGenerateDownloadURLsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.BatchGenerateDownloadURLsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.BatchGenerateDownloadURLsResponse.decode(value),
    },
    /** Generate url for uploading an image. */
    generateUploadURL: {
        path: '/yandex.cloud.video.v1.ThumbnailService/GenerateUploadURL',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GenerateThumbnailUploadURLRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GenerateThumbnailUploadURLRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.GenerateThumbnailUploadURLResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.GenerateThumbnailUploadURLResponse.decode(value),
    },
    /** Delete thumbnail. */
    delete: {
        path: '/yandex.cloud.video.v1.ThumbnailService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteThumbnailRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteThumbnailRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.ThumbnailServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.ThumbnailServiceService, 'yandex.cloud.video.v1.ThumbnailService');
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();
}
