"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: io/restorecommerce/search.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.SearchServiceDefinition = exports.SearchResponse = exports.SearchRequest = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const any_1 = require("../../google/protobuf/any");
const auth_1 = require("./auth");
const options_1 = require("./options");
exports.protobufPackage = "io.restorecommerce.search";
function createBaseSearchRequest() {
    return {};
}
exports.SearchRequest = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.collection !== undefined) {
            writer.uint32(10).string(message.collection);
        }
        if (message.text !== undefined) {
            writer.uint32(18).string(message.text);
        }
        if (message.acls !== undefined && message.acls.length !== 0) {
            for (const v of message.acls) {
                writer.uint32(26).string(v);
            }
        }
        if (message.subject !== undefined) {
            auth_1.Subject.encode(message.subject, writer.uint32(34).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const 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 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.text = reader.string();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    if (message.acls === undefined) {
                        message.acls = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.acls.push(el);
                    }
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.subject = auth_1.Subject.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            collection: isSet(object.collection) ? globalThis.String(object.collection) : undefined,
            text: isSet(object.text) ? globalThis.String(object.text) : undefined,
            acls: globalThis.Array.isArray(object?.acls) ? object.acls.map((e) => globalThis.String(e)) : undefined,
            subject: isSet(object.subject) ? auth_1.Subject.fromJSON(object.subject) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.collection !== undefined) {
            obj.collection = message.collection;
        }
        if (message.text !== undefined) {
            obj.text = message.text;
        }
        if (message.acls?.length) {
            obj.acls = message.acls;
        }
        if (message.subject !== undefined) {
            obj.subject = auth_1.Subject.toJSON(message.subject);
        }
        return obj;
    },
    create(base) {
        return exports.SearchRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSearchRequest();
        message.collection = object.collection ?? undefined;
        message.text = object.text ?? undefined;
        message.acls = object.acls?.map((e) => e) || undefined;
        message.subject = (object.subject !== undefined && object.subject !== null)
            ? auth_1.Subject.fromPartial(object.subject)
            : undefined;
        return message;
    },
};
function createBaseSearchResponse() {
    return {};
}
exports.SearchResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.data !== undefined && message.data.length !== 0) {
            for (const v of message.data) {
                any_1.Any.encode(v, writer.uint32(10).fork()).join();
            }
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSearchResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.data === undefined) {
                        message.data = [];
                    }
                    const el = any_1.Any.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.data.push(el);
                    }
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { data: globalThis.Array.isArray(object?.data) ? object.data.map((e) => any_1.Any.fromJSON(e)) : undefined };
    },
    toJSON(message) {
        const obj = {};
        if (message.data?.length) {
            obj.data = message.data.map((e) => any_1.Any.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return exports.SearchResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSearchResponse();
        message.data = object.data?.map((e) => any_1.Any.fromPartial(e)) || undefined;
        return message;
    },
};
exports.SearchServiceDefinition = {
    name: "SearchService",
    fullName: "io.restorecommerce.search.SearchService",
    methods: {
        search: {
            name: "Search",
            requestType: exports.SearchRequest,
            requestStream: false,
            responseType: exports.SearchResponse,
            responseStream: false,
            options: {},
        },
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/search.proto",
        "package": "io.restorecommerce.search",
        "dependency": ["google/protobuf/any.proto", "io/restorecommerce/auth.proto", "io/restorecommerce/options.proto"],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "SearchRequest",
                "field": [{
                        "name": "collection",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "collection",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "text",
                        "number": 2,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "text",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "acls",
                        "number": 3,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "acls",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "subject",
                        "number": 4,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.Subject",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "subject",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_collection", "options": undefined }, { "name": "_text", "options": undefined }, {
                        "name": "_subject",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "SearchResponse",
                "field": [{
                        "name": "data",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".google.protobuf.Any",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "data",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [{
                "name": "SearchService",
                "method": [{
                        "name": "Search",
                        "inputType": ".io.restorecommerce.search.SearchRequest",
                        "outputType": ".io.restorecommerce.search.SearchResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }],
                "options": undefined,
            }],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [6, 0],
                    "span": [8, 0, 10, 1],
                    "leadingComments": " Service provides the CRUD operations\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.search.SearchRequest": exports.SearchRequest,
        ".io.restorecommerce.search.SearchResponse": exports.SearchResponse,
    },
    dependencies: [any_1.protoMetadata, auth_1.protoMetadata, options_1.protoMetadata],
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=search.js.map