"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConversationStatistics = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const statistics_common_1 = require("../../../../../yandex/cloud/speechsense/v1/analysis/statistics_common");
const speaker_statistics_1 = require("../../../../../yandex/cloud/speechsense/v1/analysis/speaker_statistics");
exports.protobufPackage = 'yandex.cloud.speechsense.v1.analysis';
const baseConversationStatistics = {};
exports.ConversationStatistics = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.conversationBoundaries !== undefined) {
            statistics_common_1.AudioSegmentBoundaries.encode(message.conversationBoundaries, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.speakerStatistics) {
            speaker_statistics_1.SpeakerStatistics.encode(v, 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({}, baseConversationStatistics);
        message.speakerStatistics = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.conversationBoundaries = statistics_common_1.AudioSegmentBoundaries.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.speakerStatistics.push(speaker_statistics_1.SpeakerStatistics.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseConversationStatistics);
        message.conversationBoundaries =
            object.conversationBoundaries !== undefined && object.conversationBoundaries !== null
                ? statistics_common_1.AudioSegmentBoundaries.fromJSON(object.conversationBoundaries)
                : undefined;
        message.speakerStatistics = ((_a = object.speakerStatistics) !== null && _a !== void 0 ? _a : []).map((e) => speaker_statistics_1.SpeakerStatistics.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.conversationBoundaries !== undefined &&
            (obj.conversationBoundaries = message.conversationBoundaries
                ? statistics_common_1.AudioSegmentBoundaries.toJSON(message.conversationBoundaries)
                : undefined);
        if (message.speakerStatistics) {
            obj.speakerStatistics = message.speakerStatistics.map((e) => e ? speaker_statistics_1.SpeakerStatistics.toJSON(e) : undefined);
        }
        else {
            obj.speakerStatistics = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseConversationStatistics);
        message.conversationBoundaries =
            object.conversationBoundaries !== undefined && object.conversationBoundaries !== null
                ? statistics_common_1.AudioSegmentBoundaries.fromPartial(object.conversationBoundaries)
                : undefined;
        message.speakerStatistics =
            ((_a = object.speakerStatistics) === null || _a === void 0 ? void 0 : _a.map((e) => speaker_statistics_1.SpeakerStatistics.fromPartial(e))) || [];
        return message;
    },
};
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
