"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebSearchServiceClient = exports.WebSearchServiceService = exports.WebSearchAsyncServiceClient = exports.WebSearchAsyncServiceService = exports.WebSearchResponse = exports.WebSearchRequest = exports.GroupSpec = exports.SortSpec = exports.webSearchRequest_FormatToJSON = exports.webSearchRequest_FormatFromJSON = exports.WebSearchRequest_Format = exports.webSearchRequest_LocalizationToJSON = exports.webSearchRequest_LocalizationFromJSON = exports.WebSearchRequest_Localization = exports.groupSpec_GroupModeToJSON = exports.groupSpec_GroupModeFromJSON = exports.GroupSpec_GroupMode = exports.sortSpec_SortModeToJSON = exports.sortSpec_SortModeFromJSON = exports.SortSpec_SortMode = exports.sortSpec_SortOrderToJSON = exports.sortSpec_SortOrderFromJSON = exports.SortSpec_SortOrder = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const search_query_1 = require("../../../../yandex/cloud/searchapi/v2/search_query");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.searchapi.v2';
var SortSpec_SortOrder;
(function (SortSpec_SortOrder) {
    SortSpec_SortOrder[SortSpec_SortOrder["SORT_ORDER_UNSPECIFIED"] = 0] = "SORT_ORDER_UNSPECIFIED";
    /** SORT_ORDER_ASC - Reverse order from oldest to most recent. */
    SortSpec_SortOrder[SortSpec_SortOrder["SORT_ORDER_ASC"] = 1] = "SORT_ORDER_ASC";
    /** SORT_ORDER_DESC - Direct order from most recent to oldest (default). */
    SortSpec_SortOrder[SortSpec_SortOrder["SORT_ORDER_DESC"] = 2] = "SORT_ORDER_DESC";
    SortSpec_SortOrder[SortSpec_SortOrder["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SortSpec_SortOrder = exports.SortSpec_SortOrder || (exports.SortSpec_SortOrder = {}));
function sortSpec_SortOrderFromJSON(object) {
    switch (object) {
        case 0:
        case 'SORT_ORDER_UNSPECIFIED':
            return SortSpec_SortOrder.SORT_ORDER_UNSPECIFIED;
        case 1:
        case 'SORT_ORDER_ASC':
            return SortSpec_SortOrder.SORT_ORDER_ASC;
        case 2:
        case 'SORT_ORDER_DESC':
            return SortSpec_SortOrder.SORT_ORDER_DESC;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SortSpec_SortOrder.UNRECOGNIZED;
    }
}
exports.sortSpec_SortOrderFromJSON = sortSpec_SortOrderFromJSON;
function sortSpec_SortOrderToJSON(object) {
    switch (object) {
        case SortSpec_SortOrder.SORT_ORDER_UNSPECIFIED:
            return 'SORT_ORDER_UNSPECIFIED';
        case SortSpec_SortOrder.SORT_ORDER_ASC:
            return 'SORT_ORDER_ASC';
        case SortSpec_SortOrder.SORT_ORDER_DESC:
            return 'SORT_ORDER_DESC';
        default:
            return 'UNKNOWN';
    }
}
exports.sortSpec_SortOrderToJSON = sortSpec_SortOrderToJSON;
var SortSpec_SortMode;
(function (SortSpec_SortMode) {
    SortSpec_SortMode[SortSpec_SortMode["SORT_MODE_UNSPECIFIED"] = 0] = "SORT_MODE_UNSPECIFIED";
    /** SORT_MODE_BY_RELEVANCE - Sort documents by relevance (default value). */
    SortSpec_SortMode[SortSpec_SortMode["SORT_MODE_BY_RELEVANCE"] = 1] = "SORT_MODE_BY_RELEVANCE";
    /** SORT_MODE_BY_TIME - Sort documents by update time. */
    SortSpec_SortMode[SortSpec_SortMode["SORT_MODE_BY_TIME"] = 2] = "SORT_MODE_BY_TIME";
    SortSpec_SortMode[SortSpec_SortMode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SortSpec_SortMode = exports.SortSpec_SortMode || (exports.SortSpec_SortMode = {}));
function sortSpec_SortModeFromJSON(object) {
    switch (object) {
        case 0:
        case 'SORT_MODE_UNSPECIFIED':
            return SortSpec_SortMode.SORT_MODE_UNSPECIFIED;
        case 1:
        case 'SORT_MODE_BY_RELEVANCE':
            return SortSpec_SortMode.SORT_MODE_BY_RELEVANCE;
        case 2:
        case 'SORT_MODE_BY_TIME':
            return SortSpec_SortMode.SORT_MODE_BY_TIME;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SortSpec_SortMode.UNRECOGNIZED;
    }
}
exports.sortSpec_SortModeFromJSON = sortSpec_SortModeFromJSON;
function sortSpec_SortModeToJSON(object) {
    switch (object) {
        case SortSpec_SortMode.SORT_MODE_UNSPECIFIED:
            return 'SORT_MODE_UNSPECIFIED';
        case SortSpec_SortMode.SORT_MODE_BY_RELEVANCE:
            return 'SORT_MODE_BY_RELEVANCE';
        case SortSpec_SortMode.SORT_MODE_BY_TIME:
            return 'SORT_MODE_BY_TIME';
        default:
            return 'UNKNOWN';
    }
}
exports.sortSpec_SortModeToJSON = sortSpec_SortModeToJSON;
var GroupSpec_GroupMode;
(function (GroupSpec_GroupMode) {
    GroupSpec_GroupMode[GroupSpec_GroupMode["GROUP_MODE_UNSPECIFIED"] = 0] = "GROUP_MODE_UNSPECIFIED";
    /** GROUP_MODE_FLAT - Flat grouping. Each group contains a single document. */
    GroupSpec_GroupMode[GroupSpec_GroupMode["GROUP_MODE_FLAT"] = 1] = "GROUP_MODE_FLAT";
    /** GROUP_MODE_DEEP - Grouping by domain. Each group contains documents from one domain. */
    GroupSpec_GroupMode[GroupSpec_GroupMode["GROUP_MODE_DEEP"] = 2] = "GROUP_MODE_DEEP";
    GroupSpec_GroupMode[GroupSpec_GroupMode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GroupSpec_GroupMode = exports.GroupSpec_GroupMode || (exports.GroupSpec_GroupMode = {}));
function groupSpec_GroupModeFromJSON(object) {
    switch (object) {
        case 0:
        case 'GROUP_MODE_UNSPECIFIED':
            return GroupSpec_GroupMode.GROUP_MODE_UNSPECIFIED;
        case 1:
        case 'GROUP_MODE_FLAT':
            return GroupSpec_GroupMode.GROUP_MODE_FLAT;
        case 2:
        case 'GROUP_MODE_DEEP':
            return GroupSpec_GroupMode.GROUP_MODE_DEEP;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return GroupSpec_GroupMode.UNRECOGNIZED;
    }
}
exports.groupSpec_GroupModeFromJSON = groupSpec_GroupModeFromJSON;
function groupSpec_GroupModeToJSON(object) {
    switch (object) {
        case GroupSpec_GroupMode.GROUP_MODE_UNSPECIFIED:
            return 'GROUP_MODE_UNSPECIFIED';
        case GroupSpec_GroupMode.GROUP_MODE_FLAT:
            return 'GROUP_MODE_FLAT';
        case GroupSpec_GroupMode.GROUP_MODE_DEEP:
            return 'GROUP_MODE_DEEP';
        default:
            return 'UNKNOWN';
    }
}
exports.groupSpec_GroupModeToJSON = groupSpec_GroupModeToJSON;
var WebSearchRequest_Localization;
(function (WebSearchRequest_Localization) {
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_UNSPECIFIED"] = 0] = "LOCALIZATION_UNSPECIFIED";
    /** LOCALIZATION_RU - Russian (default value) */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_RU"] = 1] = "LOCALIZATION_RU";
    /** LOCALIZATION_UK - Ukrainian */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_UK"] = 2] = "LOCALIZATION_UK";
    /** LOCALIZATION_BE - Belarusian */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_BE"] = 3] = "LOCALIZATION_BE";
    /** LOCALIZATION_KK - Kazakh */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_KK"] = 4] = "LOCALIZATION_KK";
    /** LOCALIZATION_TR - Turkish */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_TR"] = 5] = "LOCALIZATION_TR";
    /** LOCALIZATION_EN - English */
    WebSearchRequest_Localization[WebSearchRequest_Localization["LOCALIZATION_EN"] = 6] = "LOCALIZATION_EN";
    WebSearchRequest_Localization[WebSearchRequest_Localization["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(WebSearchRequest_Localization = exports.WebSearchRequest_Localization || (exports.WebSearchRequest_Localization = {}));
function webSearchRequest_LocalizationFromJSON(object) {
    switch (object) {
        case 0:
        case 'LOCALIZATION_UNSPECIFIED':
            return WebSearchRequest_Localization.LOCALIZATION_UNSPECIFIED;
        case 1:
        case 'LOCALIZATION_RU':
            return WebSearchRequest_Localization.LOCALIZATION_RU;
        case 2:
        case 'LOCALIZATION_UK':
            return WebSearchRequest_Localization.LOCALIZATION_UK;
        case 3:
        case 'LOCALIZATION_BE':
            return WebSearchRequest_Localization.LOCALIZATION_BE;
        case 4:
        case 'LOCALIZATION_KK':
            return WebSearchRequest_Localization.LOCALIZATION_KK;
        case 5:
        case 'LOCALIZATION_TR':
            return WebSearchRequest_Localization.LOCALIZATION_TR;
        case 6:
        case 'LOCALIZATION_EN':
            return WebSearchRequest_Localization.LOCALIZATION_EN;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return WebSearchRequest_Localization.UNRECOGNIZED;
    }
}
exports.webSearchRequest_LocalizationFromJSON = webSearchRequest_LocalizationFromJSON;
function webSearchRequest_LocalizationToJSON(object) {
    switch (object) {
        case WebSearchRequest_Localization.LOCALIZATION_UNSPECIFIED:
            return 'LOCALIZATION_UNSPECIFIED';
        case WebSearchRequest_Localization.LOCALIZATION_RU:
            return 'LOCALIZATION_RU';
        case WebSearchRequest_Localization.LOCALIZATION_UK:
            return 'LOCALIZATION_UK';
        case WebSearchRequest_Localization.LOCALIZATION_BE:
            return 'LOCALIZATION_BE';
        case WebSearchRequest_Localization.LOCALIZATION_KK:
            return 'LOCALIZATION_KK';
        case WebSearchRequest_Localization.LOCALIZATION_TR:
            return 'LOCALIZATION_TR';
        case WebSearchRequest_Localization.LOCALIZATION_EN:
            return 'LOCALIZATION_EN';
        default:
            return 'UNKNOWN';
    }
}
exports.webSearchRequest_LocalizationToJSON = webSearchRequest_LocalizationToJSON;
var WebSearchRequest_Format;
(function (WebSearchRequest_Format) {
    WebSearchRequest_Format[WebSearchRequest_Format["FORMAT_UNSPECIFIED"] = 0] = "FORMAT_UNSPECIFIED";
    /** FORMAT_XML - XML format (default value) */
    WebSearchRequest_Format[WebSearchRequest_Format["FORMAT_XML"] = 1] = "FORMAT_XML";
    /** FORMAT_HTML - HTML format */
    WebSearchRequest_Format[WebSearchRequest_Format["FORMAT_HTML"] = 2] = "FORMAT_HTML";
    WebSearchRequest_Format[WebSearchRequest_Format["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(WebSearchRequest_Format = exports.WebSearchRequest_Format || (exports.WebSearchRequest_Format = {}));
function webSearchRequest_FormatFromJSON(object) {
    switch (object) {
        case 0:
        case 'FORMAT_UNSPECIFIED':
            return WebSearchRequest_Format.FORMAT_UNSPECIFIED;
        case 1:
        case 'FORMAT_XML':
            return WebSearchRequest_Format.FORMAT_XML;
        case 2:
        case 'FORMAT_HTML':
            return WebSearchRequest_Format.FORMAT_HTML;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return WebSearchRequest_Format.UNRECOGNIZED;
    }
}
exports.webSearchRequest_FormatFromJSON = webSearchRequest_FormatFromJSON;
function webSearchRequest_FormatToJSON(object) {
    switch (object) {
        case WebSearchRequest_Format.FORMAT_UNSPECIFIED:
            return 'FORMAT_UNSPECIFIED';
        case WebSearchRequest_Format.FORMAT_XML:
            return 'FORMAT_XML';
        case WebSearchRequest_Format.FORMAT_HTML:
            return 'FORMAT_HTML';
        default:
            return 'UNKNOWN';
    }
}
exports.webSearchRequest_FormatToJSON = webSearchRequest_FormatToJSON;
const baseSortSpec = { sortMode: 0, sortOrder: 0 };
exports.SortSpec = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.sortMode !== 0) {
            writer.uint32(8).int32(message.sortMode);
        }
        if (message.sortOrder !== 0) {
            writer.uint32(16).int32(message.sortOrder);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSortSpec);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sortMode = reader.int32();
                    break;
                case 2:
                    message.sortOrder = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSortSpec);
        message.sortMode =
            object.sortMode !== undefined && object.sortMode !== null
                ? sortSpec_SortModeFromJSON(object.sortMode)
                : 0;
        message.sortOrder =
            object.sortOrder !== undefined && object.sortOrder !== null
                ? sortSpec_SortOrderFromJSON(object.sortOrder)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.sortMode !== undefined &&
            (obj.sortMode = sortSpec_SortModeToJSON(message.sortMode));
        message.sortOrder !== undefined &&
            (obj.sortOrder = sortSpec_SortOrderToJSON(message.sortOrder));
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseSortSpec);
        message.sortMode = (_a = object.sortMode) !== null && _a !== void 0 ? _a : 0;
        message.sortOrder = (_b = object.sortOrder) !== null && _b !== void 0 ? _b : 0;
        return message;
    },
};
const baseGroupSpec = { groupMode: 0, groupsOnPage: 0, docsInGroup: 0 };
exports.GroupSpec = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.groupMode !== 0) {
            writer.uint32(8).int32(message.groupMode);
        }
        if (message.groupsOnPage !== 0) {
            writer.uint32(16).int64(message.groupsOnPage);
        }
        if (message.docsInGroup !== 0) {
            writer.uint32(24).int64(message.docsInGroup);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGroupSpec);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.groupMode = reader.int32();
                    break;
                case 2:
                    message.groupsOnPage = longToNumber(reader.int64());
                    break;
                case 3:
                    message.docsInGroup = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGroupSpec);
        message.groupMode =
            object.groupMode !== undefined && object.groupMode !== null
                ? groupSpec_GroupModeFromJSON(object.groupMode)
                : 0;
        message.groupsOnPage =
            object.groupsOnPage !== undefined && object.groupsOnPage !== null
                ? Number(object.groupsOnPage)
                : 0;
        message.docsInGroup =
            object.docsInGroup !== undefined && object.docsInGroup !== null
                ? Number(object.docsInGroup)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.groupMode !== undefined &&
            (obj.groupMode = groupSpec_GroupModeToJSON(message.groupMode));
        message.groupsOnPage !== undefined && (obj.groupsOnPage = Math.round(message.groupsOnPage));
        message.docsInGroup !== undefined && (obj.docsInGroup = Math.round(message.docsInGroup));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseGroupSpec);
        message.groupMode = (_a = object.groupMode) !== null && _a !== void 0 ? _a : 0;
        message.groupsOnPage = (_b = object.groupsOnPage) !== null && _b !== void 0 ? _b : 0;
        message.docsInGroup = (_c = object.docsInGroup) !== null && _c !== void 0 ? _c : 0;
        return message;
    },
};
const baseWebSearchRequest = {
    maxPassages: 0,
    region: '',
    l10n: 0,
    folderId: '',
    responseFormat: 0,
    userAgent: '',
};
exports.WebSearchRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.query !== undefined) {
            search_query_1.SearchQuery.encode(message.query, writer.uint32(10).fork()).ldelim();
        }
        if (message.sortSpec !== undefined) {
            exports.SortSpec.encode(message.sortSpec, writer.uint32(18).fork()).ldelim();
        }
        if (message.groupSpec !== undefined) {
            exports.GroupSpec.encode(message.groupSpec, writer.uint32(26).fork()).ldelim();
        }
        if (message.maxPassages !== 0) {
            writer.uint32(32).int64(message.maxPassages);
        }
        if (message.region !== '') {
            writer.uint32(42).string(message.region);
        }
        if (message.l10n !== 0) {
            writer.uint32(48).int32(message.l10n);
        }
        if (message.folderId !== '') {
            writer.uint32(58).string(message.folderId);
        }
        if (message.responseFormat !== 0) {
            writer.uint32(64).int32(message.responseFormat);
        }
        if (message.userAgent !== '') {
            writer.uint32(74).string(message.userAgent);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseWebSearchRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.query = search_query_1.SearchQuery.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.sortSpec = exports.SortSpec.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.groupSpec = exports.GroupSpec.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.maxPassages = longToNumber(reader.int64());
                    break;
                case 5:
                    message.region = reader.string();
                    break;
                case 6:
                    message.l10n = reader.int32();
                    break;
                case 7:
                    message.folderId = reader.string();
                    break;
                case 8:
                    message.responseFormat = reader.int32();
                    break;
                case 9:
                    message.userAgent = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWebSearchRequest);
        message.query =
            object.query !== undefined && object.query !== null
                ? search_query_1.SearchQuery.fromJSON(object.query)
                : undefined;
        message.sortSpec =
            object.sortSpec !== undefined && object.sortSpec !== null
                ? exports.SortSpec.fromJSON(object.sortSpec)
                : undefined;
        message.groupSpec =
            object.groupSpec !== undefined && object.groupSpec !== null
                ? exports.GroupSpec.fromJSON(object.groupSpec)
                : undefined;
        message.maxPassages =
            object.maxPassages !== undefined && object.maxPassages !== null
                ? Number(object.maxPassages)
                : 0;
        message.region =
            object.region !== undefined && object.region !== null ? String(object.region) : '';
        message.l10n =
            object.l10n !== undefined && object.l10n !== null
                ? webSearchRequest_LocalizationFromJSON(object.l10n)
                : 0;
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.responseFormat =
            object.responseFormat !== undefined && object.responseFormat !== null
                ? webSearchRequest_FormatFromJSON(object.responseFormat)
                : 0;
        message.userAgent =
            object.userAgent !== undefined && object.userAgent !== null
                ? String(object.userAgent)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.query !== undefined &&
            (obj.query = message.query ? search_query_1.SearchQuery.toJSON(message.query) : undefined);
        message.sortSpec !== undefined &&
            (obj.sortSpec = message.sortSpec ? exports.SortSpec.toJSON(message.sortSpec) : undefined);
        message.groupSpec !== undefined &&
            (obj.groupSpec = message.groupSpec ? exports.GroupSpec.toJSON(message.groupSpec) : undefined);
        message.maxPassages !== undefined && (obj.maxPassages = Math.round(message.maxPassages));
        message.region !== undefined && (obj.region = message.region);
        message.l10n !== undefined &&
            (obj.l10n = webSearchRequest_LocalizationToJSON(message.l10n));
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.responseFormat !== undefined &&
            (obj.responseFormat = webSearchRequest_FormatToJSON(message.responseFormat));
        message.userAgent !== undefined && (obj.userAgent = message.userAgent);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f;
        const message = Object.assign({}, baseWebSearchRequest);
        message.query =
            object.query !== undefined && object.query !== null
                ? search_query_1.SearchQuery.fromPartial(object.query)
                : undefined;
        message.sortSpec =
            object.sortSpec !== undefined && object.sortSpec !== null
                ? exports.SortSpec.fromPartial(object.sortSpec)
                : undefined;
        message.groupSpec =
            object.groupSpec !== undefined && object.groupSpec !== null
                ? exports.GroupSpec.fromPartial(object.groupSpec)
                : undefined;
        message.maxPassages = (_a = object.maxPassages) !== null && _a !== void 0 ? _a : 0;
        message.region = (_b = object.region) !== null && _b !== void 0 ? _b : '';
        message.l10n = (_c = object.l10n) !== null && _c !== void 0 ? _c : 0;
        message.folderId = (_d = object.folderId) !== null && _d !== void 0 ? _d : '';
        message.responseFormat = (_e = object.responseFormat) !== null && _e !== void 0 ? _e : 0;
        message.userAgent = (_f = object.userAgent) !== null && _f !== void 0 ? _f : '';
        return message;
    },
};
const baseWebSearchResponse = {};
exports.WebSearchResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.rawData.length !== 0) {
            writer.uint32(10).bytes(message.rawData);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseWebSearchResponse);
        message.rawData = Buffer.alloc(0);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.rawData = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseWebSearchResponse);
        message.rawData =
            object.rawData !== undefined && object.rawData !== null
                ? Buffer.from(bytesFromBase64(object.rawData))
                : Buffer.alloc(0);
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.rawData !== undefined &&
            (obj.rawData = base64FromBytes(message.rawData !== undefined ? message.rawData : Buffer.alloc(0)));
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseWebSearchResponse);
        message.rawData = (_a = object.rawData) !== null && _a !== void 0 ? _a : Buffer.alloc(0);
        return message;
    },
};
/** A set of methods for async search the Yandex search database. */
exports.WebSearchAsyncServiceService = {
    search: {
        path: '/yandex.cloud.searchapi.v2.WebSearchAsyncService/Search',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.WebSearchRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.WebSearchRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.WebSearchAsyncServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.WebSearchAsyncServiceService, 'yandex.cloud.searchapi.v2.WebSearchAsyncService');
/** A set of methods for searching the Yandex search database. */
exports.WebSearchServiceService = {
    search: {
        path: '/yandex.cloud.searchapi.v2.WebSearchService/Search',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.WebSearchRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.WebSearchRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.WebSearchResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.WebSearchResponse.decode(value),
    },
};
exports.WebSearchServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.WebSearchServiceService, 'yandex.cloud.searchapi.v2.WebSearchService');
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
const atob = globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
function bytesFromBase64(b64) {
    const bin = atob(b64);
    const arr = new Uint8Array(bin.length);
    for (let i = 0; i < bin.length; ++i) {
        arr[i] = bin.charCodeAt(i);
    }
    return arr;
}
const btoa = globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr) {
    const bin = [];
    for (const byte of arr) {
        bin.push(String.fromCharCode(byte));
    }
    return btoa(bin.join(''));
}
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
