// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v1.176.0
//   protoc               v3.19.1
// source: v1/search_get.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { consistencyLevelFromJSON, consistencyLevelToJSON, Filters, Vectors } from "./base.js";
import { BM25, Hybrid, NearAudioSearch, NearDepthSearch, NearImageSearch, NearIMUSearch, NearObject, NearTextSearch, NearThermalSearch, NearVector, NearVideoSearch, } from "./base_search.js";
import { GenerativeReply, GenerativeResult, GenerativeSearch } from "./generative.js";
import { Properties } from "./properties.js";
export const protobufPackage = "weaviate.v1";
function createBaseSearchRequest() {
    return {
        collection: "",
        tenant: "",
        consistencyLevel: undefined,
        properties: undefined,
        metadata: undefined,
        groupBy: undefined,
        limit: 0,
        offset: 0,
        autocut: 0,
        after: "",
        sortBy: [],
        filters: undefined,
        hybridSearch: undefined,
        bm25Search: undefined,
        nearVector: undefined,
        nearObject: undefined,
        nearText: undefined,
        nearImage: undefined,
        nearAudio: undefined,
        nearVideo: undefined,
        nearDepth: undefined,
        nearThermal: undefined,
        nearImu: undefined,
        generative: undefined,
        rerank: undefined,
        uses123Api: false,
        uses125Api: false,
        uses127Api: false,
    };
}
export const SearchRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.collection !== "") {
            writer.uint32(10).string(message.collection);
        }
        if (message.tenant !== "") {
            writer.uint32(82).string(message.tenant);
        }
        if (message.consistencyLevel !== undefined) {
            writer.uint32(88).int32(message.consistencyLevel);
        }
        if (message.properties !== undefined) {
            PropertiesRequest.encode(message.properties, writer.uint32(162).fork()).ldelim();
        }
        if (message.metadata !== undefined) {
            MetadataRequest.encode(message.metadata, writer.uint32(170).fork()).ldelim();
        }
        if (message.groupBy !== undefined) {
            GroupBy.encode(message.groupBy, writer.uint32(178).fork()).ldelim();
        }
        if (message.limit !== 0) {
            writer.uint32(240).uint32(message.limit);
        }
        if (message.offset !== 0) {
            writer.uint32(248).uint32(message.offset);
        }
        if (message.autocut !== 0) {
            writer.uint32(256).uint32(message.autocut);
        }
        if (message.after !== "") {
            writer.uint32(266).string(message.after);
        }
        for (const v of message.sortBy) {
            SortBy.encode(v, writer.uint32(274).fork()).ldelim();
        }
        if (message.filters !== undefined) {
            Filters.encode(message.filters, writer.uint32(322).fork()).ldelim();
        }
        if (message.hybridSearch !== undefined) {
            Hybrid.encode(message.hybridSearch, writer.uint32(330).fork()).ldelim();
        }
        if (message.bm25Search !== undefined) {
            BM25.encode(message.bm25Search, writer.uint32(338).fork()).ldelim();
        }
        if (message.nearVector !== undefined) {
            NearVector.encode(message.nearVector, writer.uint32(346).fork()).ldelim();
        }
        if (message.nearObject !== undefined) {
            NearObject.encode(message.nearObject, writer.uint32(354).fork()).ldelim();
        }
        if (message.nearText !== undefined) {
            NearTextSearch.encode(message.nearText, writer.uint32(362).fork()).ldelim();
        }
        if (message.nearImage !== undefined) {
            NearImageSearch.encode(message.nearImage, writer.uint32(370).fork()).ldelim();
        }
        if (message.nearAudio !== undefined) {
            NearAudioSearch.encode(message.nearAudio, writer.uint32(378).fork()).ldelim();
        }
        if (message.nearVideo !== undefined) {
            NearVideoSearch.encode(message.nearVideo, writer.uint32(386).fork()).ldelim();
        }
        if (message.nearDepth !== undefined) {
            NearDepthSearch.encode(message.nearDepth, writer.uint32(394).fork()).ldelim();
        }
        if (message.nearThermal !== undefined) {
            NearThermalSearch.encode(message.nearThermal, writer.uint32(402).fork()).ldelim();
        }
        if (message.nearImu !== undefined) {
            NearIMUSearch.encode(message.nearImu, writer.uint32(410).fork()).ldelim();
        }
        if (message.generative !== undefined) {
            GenerativeSearch.encode(message.generative, writer.uint32(482).fork()).ldelim();
        }
        if (message.rerank !== undefined) {
            Rerank.encode(message.rerank, writer.uint32(490).fork()).ldelim();
        }
        if (message.uses123Api !== false) {
            writer.uint32(800).bool(message.uses123Api);
        }
        if (message.uses125Api !== false) {
            writer.uint32(808).bool(message.uses125Api);
        }
        if (message.uses127Api !== false) {
            writer.uint32(816).bool(message.uses127Api);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSearchRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.collection = reader.string();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.tenant = reader.string();
                    continue;
                case 11:
                    if (tag !== 88) {
                        break;
                    }
                    message.consistencyLevel = reader.int32();
                    continue;
                case 20:
                    if (tag !== 162) {
                        break;
                    }
                    message.properties = PropertiesRequest.decode(reader, reader.uint32());
                    continue;
                case 21:
                    if (tag !== 170) {
                        break;
                    }
                    message.metadata = MetadataRequest.decode(reader, reader.uint32());
                    continue;
                case 22:
                    if (tag !== 178) {
                        break;
                    }
                    message.groupBy = GroupBy.decode(reader, reader.uint32());
                    continue;
                case 30:
                    if (tag !== 240) {
                        break;
                    }
                    message.limit = reader.uint32();
                    continue;
                case 31:
                    if (tag !== 248) {
                        break;
                    }
                    message.offset = reader.uint32();
                    continue;
                case 32:
                    if (tag !== 256) {
                        break;
                    }
                    message.autocut = reader.uint32();
                    continue;
                case 33:
                    if (tag !== 266) {
                        break;
                    }
                    message.after = reader.string();
                    continue;
                case 34:
                    if (tag !== 274) {
                        break;
                    }
                    message.sortBy.push(SortBy.decode(reader, reader.uint32()));
                    continue;
                case 40:
                    if (tag !== 322) {
                        break;
                    }
                    message.filters = Filters.decode(reader, reader.uint32());
                    continue;
                case 41:
                    if (tag !== 330) {
                        break;
                    }
                    message.hybridSearch = Hybrid.decode(reader, reader.uint32());
                    continue;
                case 42:
                    if (tag !== 338) {
                        break;
                    }
                    message.bm25Search = BM25.decode(reader, reader.uint32());
                    continue;
                case 43:
                    if (tag !== 346) {
                        break;
                    }
                    message.nearVector = NearVector.decode(reader, reader.uint32());
                    continue;
                case 44:
                    if (tag !== 354) {
                        break;
                    }
                    message.nearObject = NearObject.decode(reader, reader.uint32());
                    continue;
                case 45:
                    if (tag !== 362) {
                        break;
                    }
                    message.nearText = NearTextSearch.decode(reader, reader.uint32());
                    continue;
                case 46:
                    if (tag !== 370) {
                        break;
                    }
                    message.nearImage = NearImageSearch.decode(reader, reader.uint32());
                    continue;
                case 47:
                    if (tag !== 378) {
                        break;
                    }
                    message.nearAudio = NearAudioSearch.decode(reader, reader.uint32());
                    continue;
                case 48:
                    if (tag !== 386) {
                        break;
                    }
                    message.nearVideo = NearVideoSearch.decode(reader, reader.uint32());
                    continue;
                case 49:
                    if (tag !== 394) {
                        break;
                    }
                    message.nearDepth = NearDepthSearch.decode(reader, reader.uint32());
                    continue;
                case 50:
                    if (tag !== 402) {
                        break;
                    }
                    message.nearThermal = NearThermalSearch.decode(reader, reader.uint32());
                    continue;
                case 51:
                    if (tag !== 410) {
                        break;
                    }
                    message.nearImu = NearIMUSearch.decode(reader, reader.uint32());
                    continue;
                case 60:
                    if (tag !== 482) {
                        break;
                    }
                    message.generative = GenerativeSearch.decode(reader, reader.uint32());
                    continue;
                case 61:
                    if (tag !== 490) {
                        break;
                    }
                    message.rerank = Rerank.decode(reader, reader.uint32());
                    continue;
                case 100:
                    if (tag !== 800) {
                        break;
                    }
                    message.uses123Api = reader.bool();
                    continue;
                case 101:
                    if (tag !== 808) {
                        break;
                    }
                    message.uses125Api = reader.bool();
                    continue;
                case 102:
                    if (tag !== 816) {
                        break;
                    }
                    message.uses127Api = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            collection: isSet(object.collection) ? globalThis.String(object.collection) : "",
            tenant: isSet(object.tenant) ? globalThis.String(object.tenant) : "",
            consistencyLevel: isSet(object.consistencyLevel) ? consistencyLevelFromJSON(object.consistencyLevel) : undefined,
            properties: isSet(object.properties) ? PropertiesRequest.fromJSON(object.properties) : undefined,
            metadata: isSet(object.metadata) ? MetadataRequest.fromJSON(object.metadata) : undefined,
            groupBy: isSet(object.groupBy) ? GroupBy.fromJSON(object.groupBy) : undefined,
            limit: isSet(object.limit) ? globalThis.Number(object.limit) : 0,
            offset: isSet(object.offset) ? globalThis.Number(object.offset) : 0,
            autocut: isSet(object.autocut) ? globalThis.Number(object.autocut) : 0,
            after: isSet(object.after) ? globalThis.String(object.after) : "",
            sortBy: globalThis.Array.isArray(object?.sortBy) ? object.sortBy.map((e) => SortBy.fromJSON(e)) : [],
            filters: isSet(object.filters) ? Filters.fromJSON(object.filters) : undefined,
            hybridSearch: isSet(object.hybridSearch) ? Hybrid.fromJSON(object.hybridSearch) : undefined,
            bm25Search: isSet(object.bm25Search) ? BM25.fromJSON(object.bm25Search) : undefined,
            nearVector: isSet(object.nearVector) ? NearVector.fromJSON(object.nearVector) : undefined,
            nearObject: isSet(object.nearObject) ? NearObject.fromJSON(object.nearObject) : undefined,
            nearText: isSet(object.nearText) ? NearTextSearch.fromJSON(object.nearText) : undefined,
            nearImage: isSet(object.nearImage) ? NearImageSearch.fromJSON(object.nearImage) : undefined,
            nearAudio: isSet(object.nearAudio) ? NearAudioSearch.fromJSON(object.nearAudio) : undefined,
            nearVideo: isSet(object.nearVideo) ? NearVideoSearch.fromJSON(object.nearVideo) : undefined,
            nearDepth: isSet(object.nearDepth) ? NearDepthSearch.fromJSON(object.nearDepth) : undefined,
            nearThermal: isSet(object.nearThermal) ? NearThermalSearch.fromJSON(object.nearThermal) : undefined,
            nearImu: isSet(object.nearImu) ? NearIMUSearch.fromJSON(object.nearImu) : undefined,
            generative: isSet(object.generative) ? GenerativeSearch.fromJSON(object.generative) : undefined,
            rerank: isSet(object.rerank) ? Rerank.fromJSON(object.rerank) : undefined,
            uses123Api: isSet(object.uses123Api) ? globalThis.Boolean(object.uses123Api) : false,
            uses125Api: isSet(object.uses125Api) ? globalThis.Boolean(object.uses125Api) : false,
            uses127Api: isSet(object.uses127Api) ? globalThis.Boolean(object.uses127Api) : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.collection !== "") {
            obj.collection = message.collection;
        }
        if (message.tenant !== "") {
            obj.tenant = message.tenant;
        }
        if (message.consistencyLevel !== undefined) {
            obj.consistencyLevel = consistencyLevelToJSON(message.consistencyLevel);
        }
        if (message.properties !== undefined) {
            obj.properties = PropertiesRequest.toJSON(message.properties);
        }
        if (message.metadata !== undefined) {
            obj.metadata = MetadataRequest.toJSON(message.metadata);
        }
        if (message.groupBy !== undefined) {
            obj.groupBy = GroupBy.toJSON(message.groupBy);
        }
        if (message.limit !== 0) {
            obj.limit = Math.round(message.limit);
        }
        if (message.offset !== 0) {
            obj.offset = Math.round(message.offset);
        }
        if (message.autocut !== 0) {
            obj.autocut = Math.round(message.autocut);
        }
        if (message.after !== "") {
            obj.after = message.after;
        }
        if (message.sortBy?.length) {
            obj.sortBy = message.sortBy.map((e) => SortBy.toJSON(e));
        }
        if (message.filters !== undefined) {
            obj.filters = Filters.toJSON(message.filters);
        }
        if (message.hybridSearch !== undefined) {
            obj.hybridSearch = Hybrid.toJSON(message.hybridSearch);
        }
        if (message.bm25Search !== undefined) {
            obj.bm25Search = BM25.toJSON(message.bm25Search);
        }
        if (message.nearVector !== undefined) {
            obj.nearVector = NearVector.toJSON(message.nearVector);
        }
        if (message.nearObject !== undefined) {
            obj.nearObject = NearObject.toJSON(message.nearObject);
        }
        if (message.nearText !== undefined) {
            obj.nearText = NearTextSearch.toJSON(message.nearText);
        }
        if (message.nearImage !== undefined) {
            obj.nearImage = NearImageSearch.toJSON(message.nearImage);
        }
        if (message.nearAudio !== undefined) {
            obj.nearAudio = NearAudioSearch.toJSON(message.nearAudio);
        }
        if (message.nearVideo !== undefined) {
            obj.nearVideo = NearVideoSearch.toJSON(message.nearVideo);
        }
        if (message.nearDepth !== undefined) {
            obj.nearDepth = NearDepthSearch.toJSON(message.nearDepth);
        }
        if (message.nearThermal !== undefined) {
            obj.nearThermal = NearThermalSearch.toJSON(message.nearThermal);
        }
        if (message.nearImu !== undefined) {
            obj.nearImu = NearIMUSearch.toJSON(message.nearImu);
        }
        if (message.generative !== undefined) {
            obj.generative = GenerativeSearch.toJSON(message.generative);
        }
        if (message.rerank !== undefined) {
            obj.rerank = Rerank.toJSON(message.rerank);
        }
        if (message.uses123Api !== false) {
            obj.uses123Api = message.uses123Api;
        }
        if (message.uses125Api !== false) {
            obj.uses125Api = message.uses125Api;
        }
        if (message.uses127Api !== false) {
            obj.uses127Api = message.uses127Api;
        }
        return obj;
    },
    create(base) {
        return SearchRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSearchRequest();
        message.collection = object.collection ?? "";
        message.tenant = object.tenant ?? "";
        message.consistencyLevel = object.consistencyLevel ?? undefined;
        message.properties = (object.properties !== undefined && object.properties !== null)
            ? PropertiesRequest.fromPartial(object.properties)
            : undefined;
        message.metadata = (object.metadata !== undefined && object.metadata !== null)
            ? MetadataRequest.fromPartial(object.metadata)
            : undefined;
        message.groupBy = (object.groupBy !== undefined && object.groupBy !== null)
            ? GroupBy.fromPartial(object.groupBy)
            : undefined;
        message.limit = object.limit ?? 0;
        message.offset = object.offset ?? 0;
        message.autocut = object.autocut ?? 0;
        message.after = object.after ?? "";
        message.sortBy = object.sortBy?.map((e) => SortBy.fromPartial(e)) || [];
        message.filters = (object.filters !== undefined && object.filters !== null)
            ? Filters.fromPartial(object.filters)
            : undefined;
        message.hybridSearch = (object.hybridSearch !== undefined && object.hybridSearch !== null)
            ? Hybrid.fromPartial(object.hybridSearch)
            : undefined;
        message.bm25Search = (object.bm25Search !== undefined && object.bm25Search !== null)
            ? BM25.fromPartial(object.bm25Search)
            : undefined;
        message.nearVector = (object.nearVector !== undefined && object.nearVector !== null)
            ? NearVector.fromPartial(object.nearVector)
            : undefined;
        message.nearObject = (object.nearObject !== undefined && object.nearObject !== null)
            ? NearObject.fromPartial(object.nearObject)
            : undefined;
        message.nearText = (object.nearText !== undefined && object.nearText !== null)
            ? NearTextSearch.fromPartial(object.nearText)
            : undefined;
        message.nearImage = (object.nearImage !== undefined && object.nearImage !== null)
            ? NearImageSearch.fromPartial(object.nearImage)
            : undefined;
        message.nearAudio = (object.nearAudio !== undefined && object.nearAudio !== null)
            ? NearAudioSearch.fromPartial(object.nearAudio)
            : undefined;
        message.nearVideo = (object.nearVideo !== undefined && object.nearVideo !== null)
            ? NearVideoSearch.fromPartial(object.nearVideo)
            : undefined;
        message.nearDepth = (object.nearDepth !== undefined && object.nearDepth !== null)
            ? NearDepthSearch.fromPartial(object.nearDepth)
            : undefined;
        message.nearThermal = (object.nearThermal !== undefined && object.nearThermal !== null)
            ? NearThermalSearch.fromPartial(object.nearThermal)
            : undefined;
        message.nearImu = (object.nearImu !== undefined && object.nearImu !== null)
            ? NearIMUSearch.fromPartial(object.nearImu)
            : undefined;
        message.generative = (object.generative !== undefined && object.generative !== null)
            ? GenerativeSearch.fromPartial(object.generative)
            : undefined;
        message.rerank = (object.rerank !== undefined && object.rerank !== null)
            ? Rerank.fromPartial(object.rerank)
            : undefined;
        message.uses123Api = object.uses123Api ?? false;
        message.uses125Api = object.uses125Api ?? false;
        message.uses127Api = object.uses127Api ?? false;
        return message;
    },
};
function createBaseGroupBy() {
    return { path: [], numberOfGroups: 0, objectsPerGroup: 0 };
}
export const GroupBy = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.path) {
            writer.uint32(10).string(v);
        }
        if (message.numberOfGroups !== 0) {
            writer.uint32(16).int32(message.numberOfGroups);
        }
        if (message.objectsPerGroup !== 0) {
            writer.uint32(24).int32(message.objectsPerGroup);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGroupBy();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.path.push(reader.string());
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.numberOfGroups = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.objectsPerGroup = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            path: globalThis.Array.isArray(object?.path) ? object.path.map((e) => globalThis.String(e)) : [],
            numberOfGroups: isSet(object.numberOfGroups) ? globalThis.Number(object.numberOfGroups) : 0,
            objectsPerGroup: isSet(object.objectsPerGroup) ? globalThis.Number(object.objectsPerGroup) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.path?.length) {
            obj.path = message.path;
        }
        if (message.numberOfGroups !== 0) {
            obj.numberOfGroups = Math.round(message.numberOfGroups);
        }
        if (message.objectsPerGroup !== 0) {
            obj.objectsPerGroup = Math.round(message.objectsPerGroup);
        }
        return obj;
    },
    create(base) {
        return GroupBy.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGroupBy();
        message.path = object.path?.map((e) => e) || [];
        message.numberOfGroups = object.numberOfGroups ?? 0;
        message.objectsPerGroup = object.objectsPerGroup ?? 0;
        return message;
    },
};
function createBaseSortBy() {
    return { ascending: false, path: [] };
}
export const SortBy = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.ascending !== false) {
            writer.uint32(8).bool(message.ascending);
        }
        for (const v of message.path) {
            writer.uint32(18).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSortBy();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.ascending = reader.bool();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.path.push(reader.string());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            ascending: isSet(object.ascending) ? globalThis.Boolean(object.ascending) : false,
            path: globalThis.Array.isArray(object?.path) ? object.path.map((e) => globalThis.String(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.ascending !== false) {
            obj.ascending = message.ascending;
        }
        if (message.path?.length) {
            obj.path = message.path;
        }
        return obj;
    },
    create(base) {
        return SortBy.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSortBy();
        message.ascending = object.ascending ?? false;
        message.path = object.path?.map((e) => e) || [];
        return message;
    },
};
function createBaseMetadataRequest() {
    return {
        uuid: false,
        vector: false,
        creationTimeUnix: false,
        lastUpdateTimeUnix: false,
        distance: false,
        certainty: false,
        score: false,
        explainScore: false,
        isConsistent: false,
        vectors: [],
    };
}
export const MetadataRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.uuid !== false) {
            writer.uint32(8).bool(message.uuid);
        }
        if (message.vector !== false) {
            writer.uint32(16).bool(message.vector);
        }
        if (message.creationTimeUnix !== false) {
            writer.uint32(24).bool(message.creationTimeUnix);
        }
        if (message.lastUpdateTimeUnix !== false) {
            writer.uint32(32).bool(message.lastUpdateTimeUnix);
        }
        if (message.distance !== false) {
            writer.uint32(40).bool(message.distance);
        }
        if (message.certainty !== false) {
            writer.uint32(48).bool(message.certainty);
        }
        if (message.score !== false) {
            writer.uint32(56).bool(message.score);
        }
        if (message.explainScore !== false) {
            writer.uint32(64).bool(message.explainScore);
        }
        if (message.isConsistent !== false) {
            writer.uint32(72).bool(message.isConsistent);
        }
        for (const v of message.vectors) {
            writer.uint32(82).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMetadataRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.uuid = reader.bool();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.vector = reader.bool();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.creationTimeUnix = reader.bool();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.lastUpdateTimeUnix = reader.bool();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.distance = reader.bool();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.certainty = reader.bool();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.score = reader.bool();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.explainScore = reader.bool();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.isConsistent = reader.bool();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.vectors.push(reader.string());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            uuid: isSet(object.uuid) ? globalThis.Boolean(object.uuid) : false,
            vector: isSet(object.vector) ? globalThis.Boolean(object.vector) : false,
            creationTimeUnix: isSet(object.creationTimeUnix) ? globalThis.Boolean(object.creationTimeUnix) : false,
            lastUpdateTimeUnix: isSet(object.lastUpdateTimeUnix) ? globalThis.Boolean(object.lastUpdateTimeUnix) : false,
            distance: isSet(object.distance) ? globalThis.Boolean(object.distance) : false,
            certainty: isSet(object.certainty) ? globalThis.Boolean(object.certainty) : false,
            score: isSet(object.score) ? globalThis.Boolean(object.score) : false,
            explainScore: isSet(object.explainScore) ? globalThis.Boolean(object.explainScore) : false,
            isConsistent: isSet(object.isConsistent) ? globalThis.Boolean(object.isConsistent) : false,
            vectors: globalThis.Array.isArray(object?.vectors) ? object.vectors.map((e) => globalThis.String(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.uuid !== false) {
            obj.uuid = message.uuid;
        }
        if (message.vector !== false) {
            obj.vector = message.vector;
        }
        if (message.creationTimeUnix !== false) {
            obj.creationTimeUnix = message.creationTimeUnix;
        }
        if (message.lastUpdateTimeUnix !== false) {
            obj.lastUpdateTimeUnix = message.lastUpdateTimeUnix;
        }
        if (message.distance !== false) {
            obj.distance = message.distance;
        }
        if (message.certainty !== false) {
            obj.certainty = message.certainty;
        }
        if (message.score !== false) {
            obj.score = message.score;
        }
        if (message.explainScore !== false) {
            obj.explainScore = message.explainScore;
        }
        if (message.isConsistent !== false) {
            obj.isConsistent = message.isConsistent;
        }
        if (message.vectors?.length) {
            obj.vectors = message.vectors;
        }
        return obj;
    },
    create(base) {
        return MetadataRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseMetadataRequest();
        message.uuid = object.uuid ?? false;
        message.vector = object.vector ?? false;
        message.creationTimeUnix = object.creationTimeUnix ?? false;
        message.lastUpdateTimeUnix = object.lastUpdateTimeUnix ?? false;
        message.distance = object.distance ?? false;
        message.certainty = object.certainty ?? false;
        message.score = object.score ?? false;
        message.explainScore = object.explainScore ?? false;
        message.isConsistent = object.isConsistent ?? false;
        message.vectors = object.vectors?.map((e) => e) || [];
        return message;
    },
};
function createBasePropertiesRequest() {
    return { nonRefProperties: [], refProperties: [], objectProperties: [], returnAllNonrefProperties: false };
}
export const PropertiesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.nonRefProperties) {
            writer.uint32(10).string(v);
        }
        for (const v of message.refProperties) {
            RefPropertiesRequest.encode(v, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.objectProperties) {
            ObjectPropertiesRequest.encode(v, writer.uint32(26).fork()).ldelim();
        }
        if (message.returnAllNonrefProperties !== false) {
            writer.uint32(88).bool(message.returnAllNonrefProperties);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBasePropertiesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.nonRefProperties.push(reader.string());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.refProperties.push(RefPropertiesRequest.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.objectProperties.push(ObjectPropertiesRequest.decode(reader, reader.uint32()));
                    continue;
                case 11:
                    if (tag !== 88) {
                        break;
                    }
                    message.returnAllNonrefProperties = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            nonRefProperties: globalThis.Array.isArray(object?.nonRefProperties)
                ? object.nonRefProperties.map((e) => globalThis.String(e))
                : [],
            refProperties: globalThis.Array.isArray(object?.refProperties)
                ? object.refProperties.map((e) => RefPropertiesRequest.fromJSON(e))
                : [],
            objectProperties: globalThis.Array.isArray(object?.objectProperties)
                ? object.objectProperties.map((e) => ObjectPropertiesRequest.fromJSON(e))
                : [],
            returnAllNonrefProperties: isSet(object.returnAllNonrefProperties)
                ? globalThis.Boolean(object.returnAllNonrefProperties)
                : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.nonRefProperties?.length) {
            obj.nonRefProperties = message.nonRefProperties;
        }
        if (message.refProperties?.length) {
            obj.refProperties = message.refProperties.map((e) => RefPropertiesRequest.toJSON(e));
        }
        if (message.objectProperties?.length) {
            obj.objectProperties = message.objectProperties.map((e) => ObjectPropertiesRequest.toJSON(e));
        }
        if (message.returnAllNonrefProperties !== false) {
            obj.returnAllNonrefProperties = message.returnAllNonrefProperties;
        }
        return obj;
    },
    create(base) {
        return PropertiesRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePropertiesRequest();
        message.nonRefProperties = object.nonRefProperties?.map((e) => e) || [];
        message.refProperties = object.refProperties?.map((e) => RefPropertiesRequest.fromPartial(e)) || [];
        message.objectProperties = object.objectProperties?.map((e) => ObjectPropertiesRequest.fromPartial(e)) || [];
        message.returnAllNonrefProperties = object.returnAllNonrefProperties ?? false;
        return message;
    },
};
function createBaseObjectPropertiesRequest() {
    return { propName: "", primitiveProperties: [], objectProperties: [] };
}
export const ObjectPropertiesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.propName !== "") {
            writer.uint32(10).string(message.propName);
        }
        for (const v of message.primitiveProperties) {
            writer.uint32(18).string(v);
        }
        for (const v of message.objectProperties) {
            ObjectPropertiesRequest.encode(v, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseObjectPropertiesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.propName = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.primitiveProperties.push(reader.string());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.objectProperties.push(ObjectPropertiesRequest.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            propName: isSet(object.propName) ? globalThis.String(object.propName) : "",
            primitiveProperties: globalThis.Array.isArray(object?.primitiveProperties)
                ? object.primitiveProperties.map((e) => globalThis.String(e))
                : [],
            objectProperties: globalThis.Array.isArray(object?.objectProperties)
                ? object.objectProperties.map((e) => ObjectPropertiesRequest.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.propName !== "") {
            obj.propName = message.propName;
        }
        if (message.primitiveProperties?.length) {
            obj.primitiveProperties = message.primitiveProperties;
        }
        if (message.objectProperties?.length) {
            obj.objectProperties = message.objectProperties.map((e) => ObjectPropertiesRequest.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return ObjectPropertiesRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseObjectPropertiesRequest();
        message.propName = object.propName ?? "";
        message.primitiveProperties = object.primitiveProperties?.map((e) => e) || [];
        message.objectProperties = object.objectProperties?.map((e) => ObjectPropertiesRequest.fromPartial(e)) || [];
        return message;
    },
};
function createBaseRefPropertiesRequest() {
    return { referenceProperty: "", properties: undefined, metadata: undefined, targetCollection: "" };
}
export const RefPropertiesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.referenceProperty !== "") {
            writer.uint32(10).string(message.referenceProperty);
        }
        if (message.properties !== undefined) {
            PropertiesRequest.encode(message.properties, writer.uint32(18).fork()).ldelim();
        }
        if (message.metadata !== undefined) {
            MetadataRequest.encode(message.metadata, writer.uint32(26).fork()).ldelim();
        }
        if (message.targetCollection !== "") {
            writer.uint32(34).string(message.targetCollection);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRefPropertiesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.referenceProperty = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.properties = PropertiesRequest.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.metadata = MetadataRequest.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.targetCollection = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            referenceProperty: isSet(object.referenceProperty) ? globalThis.String(object.referenceProperty) : "",
            properties: isSet(object.properties) ? PropertiesRequest.fromJSON(object.properties) : undefined,
            metadata: isSet(object.metadata) ? MetadataRequest.fromJSON(object.metadata) : undefined,
            targetCollection: isSet(object.targetCollection) ? globalThis.String(object.targetCollection) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.referenceProperty !== "") {
            obj.referenceProperty = message.referenceProperty;
        }
        if (message.properties !== undefined) {
            obj.properties = PropertiesRequest.toJSON(message.properties);
        }
        if (message.metadata !== undefined) {
            obj.metadata = MetadataRequest.toJSON(message.metadata);
        }
        if (message.targetCollection !== "") {
            obj.targetCollection = message.targetCollection;
        }
        return obj;
    },
    create(base) {
        return RefPropertiesRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRefPropertiesRequest();
        message.referenceProperty = object.referenceProperty ?? "";
        message.properties = (object.properties !== undefined && object.properties !== null)
            ? PropertiesRequest.fromPartial(object.properties)
            : undefined;
        message.metadata = (object.metadata !== undefined && object.metadata !== null)
            ? MetadataRequest.fromPartial(object.metadata)
            : undefined;
        message.targetCollection = object.targetCollection ?? "";
        return message;
    },
};
function createBaseRerank() {
    return { property: "", query: undefined };
}
export const Rerank = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.property !== "") {
            writer.uint32(10).string(message.property);
        }
        if (message.query !== undefined) {
            writer.uint32(18).string(message.query);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRerank();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.property = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.query = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            property: isSet(object.property) ? globalThis.String(object.property) : "",
            query: isSet(object.query) ? globalThis.String(object.query) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.property !== "") {
            obj.property = message.property;
        }
        if (message.query !== undefined) {
            obj.query = message.query;
        }
        return obj;
    },
    create(base) {
        return Rerank.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRerank();
        message.property = object.property ?? "";
        message.query = object.query ?? undefined;
        return message;
    },
};
function createBaseSearchReply() {
    return {
        took: 0,
        results: [],
        generativeGroupedResult: undefined,
        groupByResults: [],
        generativeGroupedResults: undefined,
    };
}
export const SearchReply = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.took !== 0) {
            writer.uint32(13).float(message.took);
        }
        for (const v of message.results) {
            SearchResult.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.generativeGroupedResult !== undefined) {
            writer.uint32(26).string(message.generativeGroupedResult);
        }
        for (const v of message.groupByResults) {
            GroupByResult.encode(v, writer.uint32(34).fork()).ldelim();
        }
        if (message.generativeGroupedResults !== undefined) {
            GenerativeResult.encode(message.generativeGroupedResults, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSearchReply();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 13) {
                        break;
                    }
                    message.took = reader.float();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.results.push(SearchResult.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.generativeGroupedResult = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.groupByResults.push(GroupByResult.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.generativeGroupedResults = GenerativeResult.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            took: isSet(object.took) ? globalThis.Number(object.took) : 0,
            results: globalThis.Array.isArray(object?.results)
                ? object.results.map((e) => SearchResult.fromJSON(e))
                : [],
            generativeGroupedResult: isSet(object.generativeGroupedResult)
                ? globalThis.String(object.generativeGroupedResult)
                : undefined,
            groupByResults: globalThis.Array.isArray(object?.groupByResults)
                ? object.groupByResults.map((e) => GroupByResult.fromJSON(e))
                : [],
            generativeGroupedResults: isSet(object.generativeGroupedResults)
                ? GenerativeResult.fromJSON(object.generativeGroupedResults)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.took !== 0) {
            obj.took = message.took;
        }
        if (message.results?.length) {
            obj.results = message.results.map((e) => SearchResult.toJSON(e));
        }
        if (message.generativeGroupedResult !== undefined) {
            obj.generativeGroupedResult = message.generativeGroupedResult;
        }
        if (message.groupByResults?.length) {
            obj.groupByResults = message.groupByResults.map((e) => GroupByResult.toJSON(e));
        }
        if (message.generativeGroupedResults !== undefined) {
            obj.generativeGroupedResults = GenerativeResult.toJSON(message.generativeGroupedResults);
        }
        return obj;
    },
    create(base) {
        return SearchReply.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSearchReply();
        message.took = object.took ?? 0;
        message.results = object.results?.map((e) => SearchResult.fromPartial(e)) || [];
        message.generativeGroupedResult = object.generativeGroupedResult ?? undefined;
        message.groupByResults = object.groupByResults?.map((e) => GroupByResult.fromPartial(e)) || [];
        message.generativeGroupedResults =
            (object.generativeGroupedResults !== undefined && object.generativeGroupedResults !== null)
                ? GenerativeResult.fromPartial(object.generativeGroupedResults)
                : undefined;
        return message;
    },
};
function createBaseRerankReply() {
    return { score: 0 };
}
export const RerankReply = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.score !== 0) {
            writer.uint32(9).double(message.score);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRerankReply();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 9) {
                        break;
                    }
                    message.score = reader.double();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { score: isSet(object.score) ? globalThis.Number(object.score) : 0 };
    },
    toJSON(message) {
        const obj = {};
        if (message.score !== 0) {
            obj.score = message.score;
        }
        return obj;
    },
    create(base) {
        return RerankReply.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRerankReply();
        message.score = object.score ?? 0;
        return message;
    },
};
function createBaseGroupByResult() {
    return {
        name: "",
        minDistance: 0,
        maxDistance: 0,
        numberOfObjects: 0,
        objects: [],
        rerank: undefined,
        generative: undefined,
        generativeResult: undefined,
    };
}
export const GroupByResult = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.name !== "") {
            writer.uint32(10).string(message.name);
        }
        if (message.minDistance !== 0) {
            writer.uint32(21).float(message.minDistance);
        }
        if (message.maxDistance !== 0) {
            writer.uint32(29).float(message.maxDistance);
        }
        if (message.numberOfObjects !== 0) {
            writer.uint32(32).int64(message.numberOfObjects);
        }
        for (const v of message.objects) {
            SearchResult.encode(v, writer.uint32(42).fork()).ldelim();
        }
        if (message.rerank !== undefined) {
            RerankReply.encode(message.rerank, writer.uint32(50).fork()).ldelim();
        }
        if (message.generative !== undefined) {
            GenerativeReply.encode(message.generative, writer.uint32(58).fork()).ldelim();
        }
        if (message.generativeResult !== undefined) {
            GenerativeResult.encode(message.generativeResult, writer.uint32(66).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGroupByResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                case 2:
                    if (tag !== 21) {
                        break;
                    }
                    message.minDistance = reader.float();
                    continue;
                case 3:
                    if (tag !== 29) {
                        break;
                    }
                    message.maxDistance = reader.float();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.numberOfObjects = longToNumber(reader.int64());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.objects.push(SearchResult.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.rerank = RerankReply.decode(reader, reader.uint32());
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.generative = GenerativeReply.decode(reader, reader.uint32());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.generativeResult = GenerativeResult.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            minDistance: isSet(object.minDistance) ? globalThis.Number(object.minDistance) : 0,
            maxDistance: isSet(object.maxDistance) ? globalThis.Number(object.maxDistance) : 0,
            numberOfObjects: isSet(object.numberOfObjects) ? globalThis.Number(object.numberOfObjects) : 0,
            objects: globalThis.Array.isArray(object?.objects)
                ? object.objects.map((e) => SearchResult.fromJSON(e))
                : [],
            rerank: isSet(object.rerank) ? RerankReply.fromJSON(object.rerank) : undefined,
            generative: isSet(object.generative) ? GenerativeReply.fromJSON(object.generative) : undefined,
            generativeResult: isSet(object.generativeResult) ? GenerativeResult.fromJSON(object.generativeResult) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.minDistance !== 0) {
            obj.minDistance = message.minDistance;
        }
        if (message.maxDistance !== 0) {
            obj.maxDistance = message.maxDistance;
        }
        if (message.numberOfObjects !== 0) {
            obj.numberOfObjects = Math.round(message.numberOfObjects);
        }
        if (message.objects?.length) {
            obj.objects = message.objects.map((e) => SearchResult.toJSON(e));
        }
        if (message.rerank !== undefined) {
            obj.rerank = RerankReply.toJSON(message.rerank);
        }
        if (message.generative !== undefined) {
            obj.generative = GenerativeReply.toJSON(message.generative);
        }
        if (message.generativeResult !== undefined) {
            obj.generativeResult = GenerativeResult.toJSON(message.generativeResult);
        }
        return obj;
    },
    create(base) {
        return GroupByResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGroupByResult();
        message.name = object.name ?? "";
        message.minDistance = object.minDistance ?? 0;
        message.maxDistance = object.maxDistance ?? 0;
        message.numberOfObjects = object.numberOfObjects ?? 0;
        message.objects = object.objects?.map((e) => SearchResult.fromPartial(e)) || [];
        message.rerank = (object.rerank !== undefined && object.rerank !== null)
            ? RerankReply.fromPartial(object.rerank)
            : undefined;
        message.generative = (object.generative !== undefined && object.generative !== null)
            ? GenerativeReply.fromPartial(object.generative)
            : undefined;
        message.generativeResult = (object.generativeResult !== undefined && object.generativeResult !== null)
            ? GenerativeResult.fromPartial(object.generativeResult)
            : undefined;
        return message;
    },
};
function createBaseSearchResult() {
    return { properties: undefined, metadata: undefined, generative: undefined };
}
export const SearchResult = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.properties !== undefined) {
            PropertiesResult.encode(message.properties, writer.uint32(10).fork()).ldelim();
        }
        if (message.metadata !== undefined) {
            MetadataResult.encode(message.metadata, writer.uint32(18).fork()).ldelim();
        }
        if (message.generative !== undefined) {
            GenerativeResult.encode(message.generative, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSearchResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.properties = PropertiesResult.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.metadata = MetadataResult.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.generative = GenerativeResult.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            properties: isSet(object.properties) ? PropertiesResult.fromJSON(object.properties) : undefined,
            metadata: isSet(object.metadata) ? MetadataResult.fromJSON(object.metadata) : undefined,
            generative: isSet(object.generative) ? GenerativeResult.fromJSON(object.generative) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.properties !== undefined) {
            obj.properties = PropertiesResult.toJSON(message.properties);
        }
        if (message.metadata !== undefined) {
            obj.metadata = MetadataResult.toJSON(message.metadata);
        }
        if (message.generative !== undefined) {
            obj.generative = GenerativeResult.toJSON(message.generative);
        }
        return obj;
    },
    create(base) {
        return SearchResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSearchResult();
        message.properties = (object.properties !== undefined && object.properties !== null)
            ? PropertiesResult.fromPartial(object.properties)
            : undefined;
        message.metadata = (object.metadata !== undefined && object.metadata !== null)
            ? MetadataResult.fromPartial(object.metadata)
            : undefined;
        message.generative = (object.generative !== undefined && object.generative !== null)
            ? GenerativeResult.fromPartial(object.generative)
            : undefined;
        return message;
    },
};
function createBaseMetadataResult() {
    return {
        id: "",
        vector: [],
        creationTimeUnix: 0,
        creationTimeUnixPresent: false,
        lastUpdateTimeUnix: 0,
        lastUpdateTimeUnixPresent: false,
        distance: 0,
        distancePresent: false,
        certainty: 0,
        certaintyPresent: false,
        score: 0,
        scorePresent: false,
        explainScore: "",
        explainScorePresent: false,
        isConsistent: undefined,
        generative: "",
        generativePresent: false,
        isConsistentPresent: false,
        vectorBytes: new Uint8Array(0),
        idAsBytes: new Uint8Array(0),
        rerankScore: 0,
        rerankScorePresent: false,
        vectors: [],
    };
}
export const MetadataResult = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        writer.uint32(18).fork();
        for (const v of message.vector) {
            writer.float(v);
        }
        writer.ldelim();
        if (message.creationTimeUnix !== 0) {
            writer.uint32(24).int64(message.creationTimeUnix);
        }
        if (message.creationTimeUnixPresent !== false) {
            writer.uint32(32).bool(message.creationTimeUnixPresent);
        }
        if (message.lastUpdateTimeUnix !== 0) {
            writer.uint32(40).int64(message.lastUpdateTimeUnix);
        }
        if (message.lastUpdateTimeUnixPresent !== false) {
            writer.uint32(48).bool(message.lastUpdateTimeUnixPresent);
        }
        if (message.distance !== 0) {
            writer.uint32(61).float(message.distance);
        }
        if (message.distancePresent !== false) {
            writer.uint32(64).bool(message.distancePresent);
        }
        if (message.certainty !== 0) {
            writer.uint32(77).float(message.certainty);
        }
        if (message.certaintyPresent !== false) {
            writer.uint32(80).bool(message.certaintyPresent);
        }
        if (message.score !== 0) {
            writer.uint32(93).float(message.score);
        }
        if (message.scorePresent !== false) {
            writer.uint32(96).bool(message.scorePresent);
        }
        if (message.explainScore !== "") {
            writer.uint32(106).string(message.explainScore);
        }
        if (message.explainScorePresent !== false) {
            writer.uint32(112).bool(message.explainScorePresent);
        }
        if (message.isConsistent !== undefined) {
            writer.uint32(120).bool(message.isConsistent);
        }
        if (message.generative !== "") {
            writer.uint32(130).string(message.generative);
        }
        if (message.generativePresent !== false) {
            writer.uint32(136).bool(message.generativePresent);
        }
        if (message.isConsistentPresent !== false) {
            writer.uint32(144).bool(message.isConsistentPresent);
        }
        if (message.vectorBytes.length !== 0) {
            writer.uint32(154).bytes(message.vectorBytes);
        }
        if (message.idAsBytes.length !== 0) {
            writer.uint32(162).bytes(message.idAsBytes);
        }
        if (message.rerankScore !== 0) {
            writer.uint32(169).double(message.rerankScore);
        }
        if (message.rerankScorePresent !== false) {
            writer.uint32(176).bool(message.rerankScorePresent);
        }
        for (const v of message.vectors) {
            Vectors.encode(v, writer.uint32(186).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMetadataResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag === 21) {
                        message.vector.push(reader.float());
                        continue;
                    }
                    if (tag === 18) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.vector.push(reader.float());
                        }
                        continue;
                    }
                    break;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.creationTimeUnix = longToNumber(reader.int64());
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.creationTimeUnixPresent = reader.bool();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.lastUpdateTimeUnix = longToNumber(reader.int64());
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.lastUpdateTimeUnixPresent = reader.bool();
                    continue;
                case 7:
                    if (tag !== 61) {
                        break;
                    }
                    message.distance = reader.float();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.distancePresent = reader.bool();
                    continue;
                case 9:
                    if (tag !== 77) {
                        break;
                    }
                    message.certainty = reader.float();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.certaintyPresent = reader.bool();
                    continue;
                case 11:
                    if (tag !== 93) {
                        break;
                    }
                    message.score = reader.float();
                    continue;
                case 12:
                    if (tag !== 96) {
                        break;
                    }
                    message.scorePresent = reader.bool();
                    continue;
                case 13:
                    if (tag !== 106) {
                        break;
                    }
                    message.explainScore = reader.string();
                    continue;
                case 14:
                    if (tag !== 112) {
                        break;
                    }
                    message.explainScorePresent = reader.bool();
                    continue;
                case 15:
                    if (tag !== 120) {
                        break;
                    }
                    message.isConsistent = reader.bool();
                    continue;
                case 16:
                    if (tag !== 130) {
                        break;
                    }
                    message.generative = reader.string();
                    continue;
                case 17:
                    if (tag !== 136) {
                        break;
                    }
                    message.generativePresent = reader.bool();
                    continue;
                case 18:
                    if (tag !== 144) {
                        break;
                    }
                    message.isConsistentPresent = reader.bool();
                    continue;
                case 19:
                    if (tag !== 154) {
                        break;
                    }
                    message.vectorBytes = reader.bytes();
                    continue;
                case 20:
                    if (tag !== 162) {
                        break;
                    }
                    message.idAsBytes = reader.bytes();
                    continue;
                case 21:
                    if (tag !== 169) {
                        break;
                    }
                    message.rerankScore = reader.double();
                    continue;
                case 22:
                    if (tag !== 176) {
                        break;
                    }
                    message.rerankScorePresent = reader.bool();
                    continue;
                case 23:
                    if (tag !== 186) {
                        break;
                    }
                    message.vectors.push(Vectors.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            vector: globalThis.Array.isArray(object?.vector) ? object.vector.map((e) => globalThis.Number(e)) : [],
            creationTimeUnix: isSet(object.creationTimeUnix) ? globalThis.Number(object.creationTimeUnix) : 0,
            creationTimeUnixPresent: isSet(object.creationTimeUnixPresent)
                ? globalThis.Boolean(object.creationTimeUnixPresent)
                : false,
            lastUpdateTimeUnix: isSet(object.lastUpdateTimeUnix) ? globalThis.Number(object.lastUpdateTimeUnix) : 0,
            lastUpdateTimeUnixPresent: isSet(object.lastUpdateTimeUnixPresent)
                ? globalThis.Boolean(object.lastUpdateTimeUnixPresent)
                : false,
            distance: isSet(object.distance) ? globalThis.Number(object.distance) : 0,
            distancePresent: isSet(object.distancePresent) ? globalThis.Boolean(object.distancePresent) : false,
            certainty: isSet(object.certainty) ? globalThis.Number(object.certainty) : 0,
            certaintyPresent: isSet(object.certaintyPresent) ? globalThis.Boolean(object.certaintyPresent) : false,
            score: isSet(object.score) ? globalThis.Number(object.score) : 0,
            scorePresent: isSet(object.scorePresent) ? globalThis.Boolean(object.scorePresent) : false,
            explainScore: isSet(object.explainScore) ? globalThis.String(object.explainScore) : "",
            explainScorePresent: isSet(object.explainScorePresent) ? globalThis.Boolean(object.explainScorePresent) : false,
            isConsistent: isSet(object.isConsistent) ? globalThis.Boolean(object.isConsistent) : undefined,
            generative: isSet(object.generative) ? globalThis.String(object.generative) : "",
            generativePresent: isSet(object.generativePresent) ? globalThis.Boolean(object.generativePresent) : false,
            isConsistentPresent: isSet(object.isConsistentPresent) ? globalThis.Boolean(object.isConsistentPresent) : false,
            vectorBytes: isSet(object.vectorBytes) ? bytesFromBase64(object.vectorBytes) : new Uint8Array(0),
            idAsBytes: isSet(object.idAsBytes) ? bytesFromBase64(object.idAsBytes) : new Uint8Array(0),
            rerankScore: isSet(object.rerankScore) ? globalThis.Number(object.rerankScore) : 0,
            rerankScorePresent: isSet(object.rerankScorePresent) ? globalThis.Boolean(object.rerankScorePresent) : false,
            vectors: globalThis.Array.isArray(object?.vectors) ? object.vectors.map((e) => Vectors.fromJSON(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.vector?.length) {
            obj.vector = message.vector;
        }
        if (message.creationTimeUnix !== 0) {
            obj.creationTimeUnix = Math.round(message.creationTimeUnix);
        }
        if (message.creationTimeUnixPresent !== false) {
            obj.creationTimeUnixPresent = message.creationTimeUnixPresent;
        }
        if (message.lastUpdateTimeUnix !== 0) {
            obj.lastUpdateTimeUnix = Math.round(message.lastUpdateTimeUnix);
        }
        if (message.lastUpdateTimeUnixPresent !== false) {
            obj.lastUpdateTimeUnixPresent = message.lastUpdateTimeUnixPresent;
        }
        if (message.distance !== 0) {
            obj.distance = message.distance;
        }
        if (message.distancePresent !== false) {
            obj.distancePresent = message.distancePresent;
        }
        if (message.certainty !== 0) {
            obj.certainty = message.certainty;
        }
        if (message.certaintyPresent !== false) {
            obj.certaintyPresent = message.certaintyPresent;
        }
        if (message.score !== 0) {
            obj.score = message.score;
        }
        if (message.scorePresent !== false) {
            obj.scorePresent = message.scorePresent;
        }
        if (message.explainScore !== "") {
            obj.explainScore = message.explainScore;
        }
        if (message.explainScorePresent !== false) {
            obj.explainScorePresent = message.explainScorePresent;
        }
        if (message.isConsistent !== undefined) {
            obj.isConsistent = message.isConsistent;
        }
        if (message.generative !== "") {
            obj.generative = message.generative;
        }
        if (message.generativePresent !== false) {
            obj.generativePresent = message.generativePresent;
        }
        if (message.isConsistentPresent !== false) {
            obj.isConsistentPresent = message.isConsistentPresent;
        }
        if (message.vectorBytes.length !== 0) {
            obj.vectorBytes = base64FromBytes(message.vectorBytes);
        }
        if (message.idAsBytes.length !== 0) {
            obj.idAsBytes = base64FromBytes(message.idAsBytes);
        }
        if (message.rerankScore !== 0) {
            obj.rerankScore = message.rerankScore;
        }
        if (message.rerankScorePresent !== false) {
            obj.rerankScorePresent = message.rerankScorePresent;
        }
        if (message.vectors?.length) {
            obj.vectors = message.vectors.map((e) => Vectors.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return MetadataResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseMetadataResult();
        message.id = object.id ?? "";
        message.vector = object.vector?.map((e) => e) || [];
        message.creationTimeUnix = object.creationTimeUnix ?? 0;
        message.creationTimeUnixPresent = object.creationTimeUnixPresent ?? false;
        message.lastUpdateTimeUnix = object.lastUpdateTimeUnix ?? 0;
        message.lastUpdateTimeUnixPresent = object.lastUpdateTimeUnixPresent ?? false;
        message.distance = object.distance ?? 0;
        message.distancePresent = object.distancePresent ?? false;
        message.certainty = object.certainty ?? 0;
        message.certaintyPresent = object.certaintyPresent ?? false;
        message.score = object.score ?? 0;
        message.scorePresent = object.scorePresent ?? false;
        message.explainScore = object.explainScore ?? "";
        message.explainScorePresent = object.explainScorePresent ?? false;
        message.isConsistent = object.isConsistent ?? undefined;
        message.generative = object.generative ?? "";
        message.generativePresent = object.generativePresent ?? false;
        message.isConsistentPresent = object.isConsistentPresent ?? false;
        message.vectorBytes = object.vectorBytes ?? new Uint8Array(0);
        message.idAsBytes = object.idAsBytes ?? new Uint8Array(0);
        message.rerankScore = object.rerankScore ?? 0;
        message.rerankScorePresent = object.rerankScorePresent ?? false;
        message.vectors = object.vectors?.map((e) => Vectors.fromPartial(e)) || [];
        return message;
    },
};
function createBasePropertiesResult() {
    return { refProps: [], targetCollection: "", metadata: undefined, nonRefProps: undefined, refPropsRequested: false };
}
export const PropertiesResult = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.refProps) {
            RefPropertiesResult.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.targetCollection !== "") {
            writer.uint32(26).string(message.targetCollection);
        }
        if (message.metadata !== undefined) {
            MetadataResult.encode(message.metadata, writer.uint32(34).fork()).ldelim();
        }
        if (message.nonRefProps !== undefined) {
            Properties.encode(message.nonRefProps, writer.uint32(90).fork()).ldelim();
        }
        if (message.refPropsRequested !== false) {
            writer.uint32(96).bool(message.refPropsRequested);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBasePropertiesResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.refProps.push(RefPropertiesResult.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.targetCollection = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.metadata = MetadataResult.decode(reader, reader.uint32());
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.nonRefProps = Properties.decode(reader, reader.uint32());
                    continue;
                case 12:
                    if (tag !== 96) {
                        break;
                    }
                    message.refPropsRequested = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            refProps: globalThis.Array.isArray(object?.refProps)
                ? object.refProps.map((e) => RefPropertiesResult.fromJSON(e))
                : [],
            targetCollection: isSet(object.targetCollection) ? globalThis.String(object.targetCollection) : "",
            metadata: isSet(object.metadata) ? MetadataResult.fromJSON(object.metadata) : undefined,
            nonRefProps: isSet(object.nonRefProps) ? Properties.fromJSON(object.nonRefProps) : undefined,
            refPropsRequested: isSet(object.refPropsRequested) ? globalThis.Boolean(object.refPropsRequested) : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.refProps?.length) {
            obj.refProps = message.refProps.map((e) => RefPropertiesResult.toJSON(e));
        }
        if (message.targetCollection !== "") {
            obj.targetCollection = message.targetCollection;
        }
        if (message.metadata !== undefined) {
            obj.metadata = MetadataResult.toJSON(message.metadata);
        }
        if (message.nonRefProps !== undefined) {
            obj.nonRefProps = Properties.toJSON(message.nonRefProps);
        }
        if (message.refPropsRequested !== false) {
            obj.refPropsRequested = message.refPropsRequested;
        }
        return obj;
    },
    create(base) {
        return PropertiesResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBasePropertiesResult();
        message.refProps = object.refProps?.map((e) => RefPropertiesResult.fromPartial(e)) || [];
        message.targetCollection = object.targetCollection ?? "";
        message.metadata = (object.metadata !== undefined && object.metadata !== null)
            ? MetadataResult.fromPartial(object.metadata)
            : undefined;
        message.nonRefProps = (object.nonRefProps !== undefined && object.nonRefProps !== null)
            ? Properties.fromPartial(object.nonRefProps)
            : undefined;
        message.refPropsRequested = object.refPropsRequested ?? false;
        return message;
    },
};
function createBaseRefPropertiesResult() {
    return { properties: [], propName: "" };
}
export const RefPropertiesResult = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.properties) {
            PropertiesResult.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.propName !== "") {
            writer.uint32(18).string(message.propName);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRefPropertiesResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.properties.push(PropertiesResult.decode(reader, reader.uint32()));
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.propName = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            properties: globalThis.Array.isArray(object?.properties)
                ? object.properties.map((e) => PropertiesResult.fromJSON(e))
                : [],
            propName: isSet(object.propName) ? globalThis.String(object.propName) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.properties?.length) {
            obj.properties = message.properties.map((e) => PropertiesResult.toJSON(e));
        }
        if (message.propName !== "") {
            obj.propName = message.propName;
        }
        return obj;
    },
    create(base) {
        return RefPropertiesResult.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRefPropertiesResult();
        message.properties = object.properties?.map((e) => PropertiesResult.fromPartial(e)) || [];
        message.propName = object.propName ?? "";
        return message;
    },
};
function bytesFromBase64(b64) {
    if (globalThis.Buffer) {
        return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
    }
    else {
        const bin = globalThis.atob(b64);
        const arr = new Uint8Array(bin.length);
        for (let i = 0; i < bin.length; ++i) {
            arr[i] = bin.charCodeAt(i);
        }
        return arr;
    }
}
function base64FromBytes(arr) {
    if (globalThis.Buffer) {
        return globalThis.Buffer.from(arr).toString("base64");
    }
    else {
        const bin = [];
        arr.forEach((byte) => {
            bin.push(globalThis.String.fromCharCode(byte));
        });
        return globalThis.btoa(bin.join(""));
    }
}
function longToNumber(long) {
    if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    return long.toNumber();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
function isSet(value) {
    return value !== null && value !== undefined;
}
