"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RefererVerificationSettings = exports.AdvertisementSettings_YandexDirect = exports.AdvertisementSettings = exports.ChannelSettings = exports.Channel_LabelsEntry = exports.Channel = 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.video.v1';
const baseChannel = { id: '', organizationId: '', title: '', description: '' };
exports.Channel = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.organizationId !== '') {
            writer.uint32(18).string(message.organizationId);
        }
        if (message.title !== '') {
            writer.uint32(26).string(message.title);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(802).fork()).ldelim();
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(810).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.Channel_LabelsEntry.encode({ key: key, value }, writer.uint32(1602).fork()).ldelim();
        });
        if (message.settings !== undefined) {
            exports.ChannelSettings.encode(message.settings, writer.uint32(1610).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({}, baseChannel);
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.organizationId = reader.string();
                    break;
                case 3:
                    message.title = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 100:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 101:
                    message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 200:
                    const entry200 = exports.Channel_LabelsEntry.decode(reader, reader.uint32());
                    if (entry200.value !== undefined) {
                        message.labels[entry200.key] = entry200.value;
                    }
                    break;
                case 201:
                    message.settings = exports.ChannelSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseChannel);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.organizationId =
            object.organizationId !== undefined && object.organizationId !== null
                ? String(object.organizationId)
                : '';
        message.title =
            object.title !== undefined && object.title !== null ? String(object.title) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.updatedAt =
            object.updatedAt !== undefined && object.updatedAt !== null
                ? fromJsonTimestamp(object.updatedAt)
                : undefined;
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.settings =
            object.settings !== undefined && object.settings !== null
                ? exports.ChannelSettings.fromJSON(object.settings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.organizationId !== undefined && (obj.organizationId = message.organizationId);
        message.title !== undefined && (obj.title = message.title);
        message.description !== undefined && (obj.description = message.description);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString());
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.settings !== undefined &&
            (obj.settings = message.settings
                ? exports.ChannelSettings.toJSON(message.settings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g;
        const message = Object.assign({}, baseChannel);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.organizationId = (_b = object.organizationId) !== null && _b !== void 0 ? _b : '';
        message.title = (_c = object.title) !== null && _c !== void 0 ? _c : '';
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        message.createdAt = (_e = object.createdAt) !== null && _e !== void 0 ? _e : undefined;
        message.updatedAt = (_f = object.updatedAt) !== null && _f !== void 0 ? _f : undefined;
        message.labels = Object.entries((_g = object.labels) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.settings =
            object.settings !== undefined && object.settings !== null
                ? exports.ChannelSettings.fromPartial(object.settings)
                : undefined;
        return message;
    },
};
const baseChannel_LabelsEntry = { key: '', value: '' };
exports.Channel_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({}, baseChannel_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({}, baseChannel_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({}, baseChannel_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseChannelSettings = {};
exports.ChannelSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.advertisement !== undefined) {
            exports.AdvertisementSettings.encode(message.advertisement, writer.uint32(10).fork()).ldelim();
        }
        if (message.refererVerification !== undefined) {
            exports.RefererVerificationSettings.encode(message.refererVerification, 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({}, baseChannelSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.advertisement = exports.AdvertisementSettings.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.refererVerification = exports.RefererVerificationSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseChannelSettings);
        message.advertisement =
            object.advertisement !== undefined && object.advertisement !== null
                ? exports.AdvertisementSettings.fromJSON(object.advertisement)
                : undefined;
        message.refererVerification =
            object.refererVerification !== undefined && object.refererVerification !== null
                ? exports.RefererVerificationSettings.fromJSON(object.refererVerification)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.advertisement !== undefined &&
            (obj.advertisement = message.advertisement
                ? exports.AdvertisementSettings.toJSON(message.advertisement)
                : undefined);
        message.refererVerification !== undefined &&
            (obj.refererVerification = message.refererVerification
                ? exports.RefererVerificationSettings.toJSON(message.refererVerification)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseChannelSettings);
        message.advertisement =
            object.advertisement !== undefined && object.advertisement !== null
                ? exports.AdvertisementSettings.fromPartial(object.advertisement)
                : undefined;
        message.refererVerification =
            object.refererVerification !== undefined && object.refererVerification !== null
                ? exports.RefererVerificationSettings.fromPartial(object.refererVerification)
                : undefined;
        return message;
    },
};
const baseAdvertisementSettings = {};
exports.AdvertisementSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.yandexDirect !== undefined) {
            exports.AdvertisementSettings_YandexDirect.encode(message.yandexDirect, writer.uint32(802).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({}, baseAdvertisementSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 100:
                    message.yandexDirect = exports.AdvertisementSettings_YandexDirect.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseAdvertisementSettings);
        message.yandexDirect =
            object.yandexDirect !== undefined && object.yandexDirect !== null
                ? exports.AdvertisementSettings_YandexDirect.fromJSON(object.yandexDirect)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.yandexDirect !== undefined &&
            (obj.yandexDirect = message.yandexDirect
                ? exports.AdvertisementSettings_YandexDirect.toJSON(message.yandexDirect)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseAdvertisementSettings);
        message.yandexDirect =
            object.yandexDirect !== undefined && object.yandexDirect !== null
                ? exports.AdvertisementSettings_YandexDirect.fromPartial(object.yandexDirect)
                : undefined;
        return message;
    },
};
const baseAdvertisementSettings_YandexDirect = { enable: false, pageId: 0, category: 0 };
exports.AdvertisementSettings_YandexDirect = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.enable === true) {
            writer.uint32(8).bool(message.enable);
        }
        if (message.pageId !== 0) {
            writer.uint32(16).int64(message.pageId);
        }
        if (message.category !== 0) {
            writer.uint32(24).int64(message.category);
        }
        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({}, baseAdvertisementSettings_YandexDirect);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.enable = reader.bool();
                    break;
                case 2:
                    message.pageId = longToNumber(reader.int64());
                    break;
                case 3:
                    message.category = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseAdvertisementSettings_YandexDirect);
        message.enable =
            object.enable !== undefined && object.enable !== null ? Boolean(object.enable) : false;
        message.pageId =
            object.pageId !== undefined && object.pageId !== null ? Number(object.pageId) : 0;
        message.category =
            object.category !== undefined && object.category !== null ? Number(object.category) : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.enable !== undefined && (obj.enable = message.enable);
        message.pageId !== undefined && (obj.pageId = Math.round(message.pageId));
        message.category !== undefined && (obj.category = Math.round(message.category));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseAdvertisementSettings_YandexDirect);
        message.enable = (_a = object.enable) !== null && _a !== void 0 ? _a : false;
        message.pageId = (_b = object.pageId) !== null && _b !== void 0 ? _b : 0;
        message.category = (_c = object.category) !== null && _c !== void 0 ? _c : 0;
        return message;
    },
};
const baseRefererVerificationSettings = { enable: false, allowedDomains: '' };
exports.RefererVerificationSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.enable === true) {
            writer.uint32(8).bool(message.enable);
        }
        for (const v of message.allowedDomains) {
            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({}, baseRefererVerificationSettings);
        message.allowedDomains = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.enable = reader.bool();
                    break;
                case 2:
                    message.allowedDomains.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRefererVerificationSettings);
        message.enable =
            object.enable !== undefined && object.enable !== null ? Boolean(object.enable) : false;
        message.allowedDomains = ((_a = object.allowedDomains) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.enable !== undefined && (obj.enable = message.enable);
        if (message.allowedDomains) {
            obj.allowedDomains = message.allowedDomains.map((e) => e);
        }
        else {
            obj.allowedDomains = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRefererVerificationSettings);
        message.enable = (_a = object.enable) !== null && _a !== void 0 ? _a : false;
        message.allowedDomains = ((_b = object.allowedDomains) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        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();
}
