"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlaylistServiceClient = exports.PlaylistServiceService = exports.GetPlaylistPlayerURLResponse = exports.PlaylistPlayerParams = exports.GetPlaylistPlayerURLRequest = exports.BatchDeletePlaylistsMetadata = exports.BatchDeletePlaylistsRequest = exports.DeletePlaylistMetadata = exports.DeletePlaylistRequest = exports.UpdatePlaylistMetadata = exports.UpdatePlaylistRequest = exports.CreatePlaylistMetadata = exports.CreatePlaylistRequest = exports.ListPlaylistsResponse = exports.ListPlaylistsRequest = exports.GetPlaylistRequest = 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 field_mask_1 = require("../../../../google/protobuf/field_mask");
const playlist_1 = require("../../../../yandex/cloud/video/v1/playlist");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.video.v1';
const baseGetPlaylistRequest = { playlistId: '' };
exports.GetPlaylistRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        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({}, baseGetPlaylistRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetPlaylistRequest);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetPlaylistRequest);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListPlaylistsRequest = {
    channelId: '',
    pageSize: 0,
    pageToken: '',
    orderBy: '',
    filter: '',
};
exports.ListPlaylistsRequest = {
    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);
        }
        if (message.orderBy !== '') {
            writer.uint32(818).string(message.orderBy);
        }
        if (message.filter !== '') {
            writer.uint32(826).string(message.filter);
        }
        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({}, baseListPlaylistsRequest);
        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;
                case 102:
                    message.orderBy = reader.string();
                    break;
                case 103:
                    message.filter = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListPlaylistsRequest);
        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)
                : '';
        message.orderBy =
            object.orderBy !== undefined && object.orderBy !== null ? String(object.orderBy) : '';
        message.filter =
            object.filter !== undefined && object.filter !== null ? String(object.filter) : '';
        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);
        message.orderBy !== undefined && (obj.orderBy = message.orderBy);
        message.filter !== undefined && (obj.filter = message.filter);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseListPlaylistsRequest);
        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 : '';
        message.orderBy = (_d = object.orderBy) !== null && _d !== void 0 ? _d : '';
        message.filter = (_e = object.filter) !== null && _e !== void 0 ? _e : '';
        return message;
    },
};
const baseListPlaylistsResponse = { nextPageToken: '' };
exports.ListPlaylistsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.playlists) {
            playlist_1.Playlist.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({}, baseListPlaylistsResponse);
        message.playlists = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlists.push(playlist_1.Playlist.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({}, baseListPlaylistsResponse);
        message.playlists = ((_a = object.playlists) !== null && _a !== void 0 ? _a : []).map((e) => playlist_1.Playlist.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.playlists) {
            obj.playlists = message.playlists.map((e) => (e ? playlist_1.Playlist.toJSON(e) : undefined));
        }
        else {
            obj.playlists = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListPlaylistsResponse);
        message.playlists = ((_a = object.playlists) === null || _a === void 0 ? void 0 : _a.map((e) => playlist_1.Playlist.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCreatePlaylistRequest = { channelId: '', title: '', description: '' };
exports.CreatePlaylistRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        if (message.title !== '') {
            writer.uint32(18).string(message.title);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        for (const v of message.items) {
            playlist_1.PlaylistItem.encode(v, writer.uint32(34).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({}, baseCreatePlaylistRequest);
        message.items = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.title = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 4:
                    message.items.push(playlist_1.PlaylistItem.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCreatePlaylistRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        message.title =
            object.title !== undefined && object.title !== null ? String(object.title) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.items = ((_a = object.items) !== null && _a !== void 0 ? _a : []).map((e) => playlist_1.PlaylistItem.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        message.title !== undefined && (obj.title = message.title);
        message.description !== undefined && (obj.description = message.description);
        if (message.items) {
            obj.items = message.items.map((e) => (e ? playlist_1.PlaylistItem.toJSON(e) : undefined));
        }
        else {
            obj.items = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseCreatePlaylistRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        message.title = (_b = object.title) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.items = ((_d = object.items) === null || _d === void 0 ? void 0 : _d.map((e) => playlist_1.PlaylistItem.fromPartial(e))) || [];
        return message;
    },
};
const baseCreatePlaylistMetadata = { playlistId: '' };
exports.CreatePlaylistMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        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({}, baseCreatePlaylistMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreatePlaylistMetadata);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreatePlaylistMetadata);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseUpdatePlaylistRequest = { playlistId: '', title: '', description: '' };
exports.UpdatePlaylistRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        if (message.fieldMask !== undefined) {
            field_mask_1.FieldMask.encode(message.fieldMask, writer.uint32(18).fork()).ldelim();
        }
        if (message.title !== '') {
            writer.uint32(26).string(message.title);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        for (const v of message.items) {
            playlist_1.PlaylistItem.encode(v, writer.uint32(42).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({}, baseUpdatePlaylistRequest);
        message.items = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                case 2:
                    message.fieldMask = field_mask_1.FieldMask.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.title = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 5:
                    message.items.push(playlist_1.PlaylistItem.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseUpdatePlaylistRequest);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        message.fieldMask =
            object.fieldMask !== undefined && object.fieldMask !== null
                ? field_mask_1.FieldMask.fromJSON(object.fieldMask)
                : undefined;
        message.title =
            object.title !== undefined && object.title !== null ? String(object.title) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.items = ((_a = object.items) !== null && _a !== void 0 ? _a : []).map((e) => playlist_1.PlaylistItem.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        message.fieldMask !== undefined &&
            (obj.fieldMask = message.fieldMask ? field_mask_1.FieldMask.toJSON(message.fieldMask) : undefined);
        message.title !== undefined && (obj.title = message.title);
        message.description !== undefined && (obj.description = message.description);
        if (message.items) {
            obj.items = message.items.map((e) => (e ? playlist_1.PlaylistItem.toJSON(e) : undefined));
        }
        else {
            obj.items = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseUpdatePlaylistRequest);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        message.fieldMask =
            object.fieldMask !== undefined && object.fieldMask !== null
                ? field_mask_1.FieldMask.fromPartial(object.fieldMask)
                : undefined;
        message.title = (_b = object.title) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.items = ((_d = object.items) === null || _d === void 0 ? void 0 : _d.map((e) => playlist_1.PlaylistItem.fromPartial(e))) || [];
        return message;
    },
};
const baseUpdatePlaylistMetadata = { playlistId: '' };
exports.UpdatePlaylistMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        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({}, baseUpdatePlaylistMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdatePlaylistMetadata);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseUpdatePlaylistMetadata);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeletePlaylistRequest = { playlistId: '' };
exports.DeletePlaylistRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        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({}, baseDeletePlaylistRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeletePlaylistRequest);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeletePlaylistRequest);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeletePlaylistMetadata = { playlistId: '' };
exports.DeletePlaylistMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        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({}, baseDeletePlaylistMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeletePlaylistMetadata);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeletePlaylistMetadata);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseBatchDeletePlaylistsRequest = { channelId: '', playlistIds: '' };
exports.BatchDeletePlaylistsRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.channelId !== '') {
            writer.uint32(10).string(message.channelId);
        }
        for (const v of message.playlistIds) {
            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({}, baseBatchDeletePlaylistsRequest);
        message.playlistIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.channelId = reader.string();
                    break;
                case 2:
                    message.playlistIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeletePlaylistsRequest);
        message.channelId =
            object.channelId !== undefined && object.channelId !== null
                ? String(object.channelId)
                : '';
        message.playlistIds = ((_a = object.playlistIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.channelId !== undefined && (obj.channelId = message.channelId);
        if (message.playlistIds) {
            obj.playlistIds = message.playlistIds.map((e) => e);
        }
        else {
            obj.playlistIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseBatchDeletePlaylistsRequest);
        message.channelId = (_a = object.channelId) !== null && _a !== void 0 ? _a : '';
        message.playlistIds = ((_b = object.playlistIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
const baseBatchDeletePlaylistsMetadata = { playlistIds: '' };
exports.BatchDeletePlaylistsMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.playlistIds) {
            writer.uint32(10).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({}, baseBatchDeletePlaylistsMetadata);
        message.playlistIds = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistIds.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeletePlaylistsMetadata);
        message.playlistIds = ((_a = object.playlistIds) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.playlistIds) {
            obj.playlistIds = message.playlistIds.map((e) => e);
        }
        else {
            obj.playlistIds = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseBatchDeletePlaylistsMetadata);
        message.playlistIds = ((_a = object.playlistIds) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        return message;
    },
};
const baseGetPlaylistPlayerURLRequest = { playlistId: '' };
exports.GetPlaylistPlayerURLRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playlistId !== '') {
            writer.uint32(10).string(message.playlistId);
        }
        if (message.params !== undefined) {
            exports.PlaylistPlayerParams.encode(message.params, writer.uint32(18).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({}, baseGetPlaylistPlayerURLRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playlistId = reader.string();
                    break;
                case 2:
                    message.params = exports.PlaylistPlayerParams.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetPlaylistPlayerURLRequest);
        message.playlistId =
            object.playlistId !== undefined && object.playlistId !== null
                ? String(object.playlistId)
                : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.PlaylistPlayerParams.fromJSON(object.params)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playlistId !== undefined && (obj.playlistId = message.playlistId);
        message.params !== undefined &&
            (obj.params = message.params ? exports.PlaylistPlayerParams.toJSON(message.params) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetPlaylistPlayerURLRequest);
        message.playlistId = (_a = object.playlistId) !== null && _a !== void 0 ? _a : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.PlaylistPlayerParams.fromPartial(object.params)
                : undefined;
        return message;
    },
};
const basePlaylistPlayerParams = { mute: false, autoplay: false, hidden: false };
exports.PlaylistPlayerParams = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.mute === true) {
            writer.uint32(8).bool(message.mute);
        }
        if (message.autoplay === true) {
            writer.uint32(16).bool(message.autoplay);
        }
        if (message.hidden === true) {
            writer.uint32(24).bool(message.hidden);
        }
        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({}, basePlaylistPlayerParams);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.mute = reader.bool();
                    break;
                case 2:
                    message.autoplay = reader.bool();
                    break;
                case 3:
                    message.hidden = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePlaylistPlayerParams);
        message.mute =
            object.mute !== undefined && object.mute !== null ? Boolean(object.mute) : false;
        message.autoplay =
            object.autoplay !== undefined && object.autoplay !== null
                ? Boolean(object.autoplay)
                : false;
        message.hidden =
            object.hidden !== undefined && object.hidden !== null ? Boolean(object.hidden) : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.mute !== undefined && (obj.mute = message.mute);
        message.autoplay !== undefined && (obj.autoplay = message.autoplay);
        message.hidden !== undefined && (obj.hidden = message.hidden);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, basePlaylistPlayerParams);
        message.mute = (_a = object.mute) !== null && _a !== void 0 ? _a : false;
        message.autoplay = (_b = object.autoplay) !== null && _b !== void 0 ? _b : false;
        message.hidden = (_c = object.hidden) !== null && _c !== void 0 ? _c : false;
        return message;
    },
};
const baseGetPlaylistPlayerURLResponse = { playerUrl: '', html: '' };
exports.GetPlaylistPlayerURLResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.playerUrl !== '') {
            writer.uint32(10).string(message.playerUrl);
        }
        if (message.html !== '') {
            writer.uint32(18).string(message.html);
        }
        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({}, baseGetPlaylistPlayerURLResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.playerUrl = reader.string();
                    break;
                case 2:
                    message.html = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetPlaylistPlayerURLResponse);
        message.playerUrl =
            object.playerUrl !== undefined && object.playerUrl !== null
                ? String(object.playerUrl)
                : '';
        message.html = object.html !== undefined && object.html !== null ? String(object.html) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.playerUrl !== undefined && (obj.playerUrl = message.playerUrl);
        message.html !== undefined && (obj.html = message.html);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseGetPlaylistPlayerURLResponse);
        message.playerUrl = (_a = object.playerUrl) !== null && _a !== void 0 ? _a : '';
        message.html = (_b = object.html) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
/** Playlist management service. */
exports.PlaylistServiceService = {
    /** Get the specific playlist. */
    get: {
        path: '/yandex.cloud.video.v1.PlaylistService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetPlaylistRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetPlaylistRequest.decode(value),
        responseSerialize: (value) => Buffer.from(playlist_1.Playlist.encode(value).finish()),
        responseDeserialize: (value) => playlist_1.Playlist.decode(value),
    },
    /** List playlists for a channel. */
    list: {
        path: '/yandex.cloud.video.v1.PlaylistService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListPlaylistsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListPlaylistsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListPlaylistsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListPlaylistsResponse.decode(value),
    },
    /** Create playlist. */
    create: {
        path: '/yandex.cloud.video.v1.PlaylistService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreatePlaylistRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreatePlaylistRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Update playlist. */
    update: {
        path: '/yandex.cloud.video.v1.PlaylistService/Update',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpdatePlaylistRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpdatePlaylistRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Delete playlist. */
    delete: {
        path: '/yandex.cloud.video.v1.PlaylistService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeletePlaylistRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeletePlaylistRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Batch delete playlists. */
    batchDelete: {
        path: '/yandex.cloud.video.v1.PlaylistService/BatchDelete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.BatchDeletePlaylistsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.BatchDeletePlaylistsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Get player url. */
    getPlayerURL: {
        path: '/yandex.cloud.video.v1.PlaylistService/GetPlayerURL',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetPlaylistPlayerURLRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetPlaylistPlayerURLRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.GetPlaylistPlayerURLResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.GetPlaylistPlayerURLResponse.decode(value),
    },
};
exports.PlaylistServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.PlaylistServiceService, 'yandex.cloud.video.v1.PlaylistService');
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();
}
