{"version":3,"sources":["FacetValueSuggestions.min__87a2f876e355bf8ecbd9.js","./src/ui/FacetValueSuggestions/FacetValueSuggestions.ts","./src/ui/FacetValueSuggestions/FacetValueSuggestionsProvider.ts"],"names":["webpackJsonpCoveo__temporary","251","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__generator","body","verb","v","op","f","TypeError","_","y","label","ops","pop","trys","push","g","sent","throw","return","Symbol","iterator","defineProperty","element","options","bindings","FacetValueSuggestions","ID","ComponentOptions","initComponentOptions","facetValueSuggestionsProvider","FacetValueSuggestionsProvider","queryController","field","expression","queryStateFieldFacetId","templateHelper","defaultTemplate","$$","root","on","OmniboxEvents","populateOmniboxSuggestions","args","suggestions","getSuggestions","omnibox","_this","row","keyword","html","facetValue","DomUtils","highlight","details","displayEstimateNumberOfResults","l","numberOfResults","toString","getQuerySuggestionKeywordFromText","text","_a","numberOfSuggestions","getText","getFacetValueSuggestions","getQuerySuggestionsKeywords","useQuerySuggestions","suggestionAddon","getSuggestion","map","wordsToQuery","suggestionsKeywords","allKeywordsToQuery","useValueFromSearchbox","unique","concat","filter","getSuggestionsForWords","keywordToQuery","currentSelectedValues_1","filteredSuggestions","error_1","logger","debug","queryStateModel","get","suggestion","isSuggestionRowAlreadyCheckedInFacet","rankSuggestionRows","mapFacetValueSuggestion","error","currentlySelectedValues","some","rankedResults","sort","a","score","distanceFromTotalForField","firstSlice","Math","ceil","lastSlice","floor","firstResultsToReturn","splice","lastResultsToReturn","slice","resultToShow","buildDisplayNameForRow","fieldValues","isCategoryField","split","categoryFieldDelimitingCharacter","advancedQuery","join","onSelect","onSuggestionSelected","ex","setText","fvState","QueryStateModel","attributesEnum","fv","existingValues","set","magicBox","blur","usageAnalytics","logSearchEvent","analyticsActionCauseList","omniboxField","executeQuery","doExport","exportGlobally","buildFieldOption","required","buildNumberOption","defaultValue","min","buildBooleanOption","postProcessing","buildCustomOption","buildStringOption","depend","buildQueryExpressionOption","Component","Initialization","registerAutoCreateComponent","516","614","valuesToSearch","fieldsToQuery","getFieldValuesToQuery","getAllSuggestionsRows","responses","reference","fieldResponses","fieldTotalReference","reduce","allValues","fieldResponse","suggestionRows","values","indexFieldValue","computeScoreForSuggestionRow","referenceValuesRequest","queryParts","suggestionValuesRequests","requests","buildReferenceFieldValueRequest","getQueryToExecuteParts","queryToExecute","buildListFieldValueRequest","getEndpoint","listFieldValuesBatch","batch","computeReferenceFromBatch","fieldValue","totalNumberForFieldValue","fieldsTotal","smallestTotal","forEach","ignoreAccents","maximumNumberOfValues","queryOverride","lastQuery","getLastQuery","aq","removeFieldExpressionFromExpression","cq","part","replace","RegExp"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,EAASC,GAEjC,YAEA,IAAIC,GAAaC,MAAQA,KAAKD,WAAc,WACxC,GAAIE,GAAgBC,OAAOC,iBACpBC,uBAA2BC,QAAS,SAAUC,EAAGC,GAAKD,EAAEF,UAAYG,IACvE,SAAUD,EAAGC,GAAK,IAAK,GAAIC,KAAKD,GAAOA,EAAEE,eAAeD,KAAIF,EAAEE,GAAKD,EAAEC,IACzE,OAAO,UAAUF,EAAGC,GAEhB,QAASG,KAAOV,KAAKW,YAAcL,EADnCL,EAAcK,EAAGC,GAEjBD,EAAEM,UAAkB,OAANL,EAAaL,OAAOW,OAAON,IAAMG,EAAGE,UAAYL,EAAEK,UAAW,GAAIF,QAGnFI,EAAYd,MAAQA,KAAKc,UAAaZ,OAAOa,QAAU,SAASC,GAChE,IAAK,GAAIC,GAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAAK,CACjDD,EAAIG,UAAUF,EACd,KAAK,GAAIV,KAAKS,GAAOf,OAAOU,UAAUH,eAAea,KAAKL,EAAGT,KACzD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oCAAR,SAA4C3J,EAAeC,GAGzD,MAAOA,GACJ6J,QAAQ,GAAIC,QAAU/J,EAAK,YAAkC,MAAO,IACpE8J,QAAQ,GAAIC,QAAU/J,EAAK,UAAgC,MAAO,KAEzE,IA1Ga,GAAAF","file":"FacetValueSuggestions.min__87a2f876e355bf8ecbd9.js","sourcesContent":["webpackJsonpCoveo__temporary([45],{\n\n/***/ 251:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(516);\nvar _ = __webpack_require__(0);\nvar OmniboxEvents_1 = __webpack_require__(33);\nvar GlobalExports_1 = __webpack_require__(3);\nvar MiscModules_1 = __webpack_require__(72);\nvar ModelsModules_1 = __webpack_require__(200);\nvar Dom_1 = __webpack_require__(1);\nvar UtilsModules_1 = __webpack_require__(122);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\nvar FacetValueSuggestionsProvider_1 = __webpack_require__(614);\n/**\n * This component provides [`Omnibox`]{@link Omnibox} query suggestions scoped to distinct categories based on the values of a\n * specific [`field`]{@link FacetValueSuggestions.options.field} whose [Facet](https://docs.coveo.com/en/1982/#facet) option is enabled.\n *\n * @externaldocs [Providing Facet Value Suggestions](https://docs.coveo.com/en/340/#providing-facet-value-suggestions)\n *\n * @availablesince [May 2018 Release (v2.4094.8)](https://docs.coveo.com/410/#may-2018-release-v240948)\n */\nvar FacetValueSuggestions = /** @class */ (function (_super) {\n __extends(FacetValueSuggestions, _super);\n /**\n * Creates a new `FacetValueSuggestions` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `FacetValueSuggestions` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n */\n function FacetValueSuggestions(element, options, bindings) {\n var _this = _super.call(this, element, FacetValueSuggestions.ID, bindings) || this;\n _this.options = options;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, FacetValueSuggestions, options);\n _this.facetValueSuggestionsProvider = new FacetValueSuggestionsProvider_1.FacetValueSuggestionsProvider(_this.queryController, {\n field: _this.options.field,\n expression: _this.options.expression\n });\n _this.queryStateFieldFacetId = \"f:\" + _this.options.field;\n if (!_this.options.templateHelper) {\n _this.options.templateHelper = FacetValueSuggestions.defaultTemplate;\n }\n Dom_1.$$(_this.root).on(OmniboxEvents_1.OmniboxEvents.populateOmniboxSuggestions, function (e, args) {\n args.suggestions.push(_this.getSuggestions(args.omnibox));\n });\n return _this;\n }\n FacetValueSuggestions.defaultTemplate = function (row, omnibox) {\n var keyword = row.keyword.html;\n var facetValue = UtilsModules_1.DomUtils.highlight(row.value, 'coveo-omnibox-hightlight');\n var details = this.options.displayEstimateNumberOfResults\n ? UtilsModules_1.DomUtils.highlight(\" (\" + MiscModules_1.l('ResultCount', row.numberOfResults.toString(), row.numberOfResults) + \")\", 'coveo-omnibox-suggestion-results-count', true)\n : '';\n return \"\" + MiscModules_1.l('KeywordInCategory', keyword, facetValue) + details;\n };\n FacetValueSuggestions.getQuerySuggestionKeywordFromText = function (text) {\n return {\n text: text,\n html: UtilsModules_1.DomUtils.highlight(text, 'coveo-omnibox-hightlight')\n };\n };\n FacetValueSuggestions.prototype.getSuggestions = function (omnibox) {\n return __awaiter(this, void 0, void 0, function () {\n var text, suggestions;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this.options.numberOfSuggestions == 0) {\n return [2 /*return*/, []];\n }\n text = omnibox.getText();\n return [4 /*yield*/, this.getFacetValueSuggestions(text, omnibox)];\n case 1:\n suggestions = _a.sent();\n return [2 /*return*/, suggestions || []];\n }\n });\n });\n };\n FacetValueSuggestions.prototype.getQuerySuggestionsKeywords = function (omnibox) {\n return __awaiter(this, void 0, void 0, function () {\n var suggestions;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this.options.useQuerySuggestions && omnibox.suggestionAddon)) return [3 /*break*/, 2];\n return [4 /*yield*/, omnibox.suggestionAddon.getSuggestion()];\n case 1:\n suggestions = _a.sent();\n return [2 /*return*/, suggestions.map(function (_a) {\n var text = _a.text, html = _a.html;\n return ({ text: text || '', html: html });\n })];\n case 2: return [2 /*return*/, []];\n }\n });\n });\n };\n FacetValueSuggestions.prototype.getFacetValueSuggestions = function (text, omnibox) {\n return __awaiter(this, void 0, void 0, function () {\n var wordsToQuery, suggestionsKeywords, allKeywordsToQuery;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n wordsToQuery = this.options.useValueFromSearchbox ? [FacetValueSuggestions.getQuerySuggestionKeywordFromText(text)] : [];\n return [4 /*yield*/, this.getQuerySuggestionsKeywords(omnibox)];\n case 1:\n suggestionsKeywords = _a.sent();\n allKeywordsToQuery = _.unique(wordsToQuery.concat(suggestionsKeywords).filter(function (keyword) { return keyword.text != ''; }), function (keyword) { return keyword.text; });\n if (allKeywordsToQuery.length === 0) {\n return [2 /*return*/, []];\n }\n return [2 /*return*/, this.getSuggestionsForWords(allKeywordsToQuery, omnibox)];\n }\n });\n });\n };\n FacetValueSuggestions.prototype.getSuggestionsForWords = function (keywordToQuery, omnibox) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var suggestions, currentSelectedValues_1, filteredSuggestions, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, this.facetValueSuggestionsProvider.getSuggestions(keywordToQuery)];\n case 1:\n suggestions = _a.sent();\n this.logger.debug('FacetValue Suggestions Results', suggestions);\n currentSelectedValues_1 = this.queryStateModel.get(this.queryStateFieldFacetId) || [];\n filteredSuggestions = suggestions.filter(function (suggestion) {\n return _this.isSuggestionRowAlreadyCheckedInFacet(suggestion, currentSelectedValues_1);\n });\n return [2 /*return*/, this.rankSuggestionRows(filteredSuggestions).map(function (result) { return _this.mapFacetValueSuggestion(result, omnibox); })];\n case 2:\n error_1 = _a.sent();\n this.logger.error(error_1);\n return [2 /*return*/, []];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n FacetValueSuggestions.prototype.isSuggestionRowAlreadyCheckedInFacet = function (suggestion, currentlySelectedValues) {\n return !currentlySelectedValues.some(function (value) { return value == suggestion.value; });\n };\n FacetValueSuggestions.prototype.rankSuggestionRows = function (suggestions) {\n var rankedResults = suggestions.sort(function (a, b) { return b.score.distanceFromTotalForField - a.score.distanceFromTotalForField; }).slice();\n var firstSlice = Math.ceil(this.options.numberOfSuggestions / 2);\n var lastSlice = -Math.floor(this.options.numberOfSuggestions / 2);\n var firstResultsToReturn = rankedResults.splice(0, firstSlice);\n if (lastSlice != 0) {\n var lastResultsToReturn = rankedResults.slice(lastSlice);\n return firstResultsToReturn.concat(lastResultsToReturn);\n }\n return firstResultsToReturn;\n };\n FacetValueSuggestions.prototype.mapFacetValueSuggestion = function (resultToShow, omnibox) {\n var _this = this;\n var suggestion = {\n html: this.buildDisplayNameForRow(resultToShow, omnibox),\n text: resultToShow.keyword.text\n };\n var fieldValues = this.options.isCategoryField\n ? resultToShow.value.split(this.options.categoryFieldDelimitingCharacter)\n : [resultToShow.value];\n suggestion.advancedQuery = fieldValues.map(function (value) { return _this.options.field + \"==\\\"\" + value + \"\\\"\"; }).join(' AND ');\n suggestion.onSelect = function () { return _this.onSuggestionSelected(suggestion, fieldValues, omnibox); };\n return suggestion;\n };\n FacetValueSuggestions.prototype.buildDisplayNameForRow = function (row, omnibox) {\n try {\n return this.options.templateHelper.call(this, row, omnibox);\n }\n catch (ex) {\n this.logger.error('Could not apply template from options for the given row. Will use default template.', ex, row, omnibox);\n return FacetValueSuggestions.defaultTemplate.call(this, row, omnibox);\n }\n };\n FacetValueSuggestions.prototype.onSuggestionSelected = function (suggestion, fieldValues, omnibox) {\n omnibox.setText(suggestion.text);\n // Copy the state here, else it will directly modify queryStateModel.defaultAttributes.fv.\n var fvState = __assign({}, this.queryStateModel.get(ModelsModules_1.QueryStateModel.attributesEnum.fv));\n var existingValues = fvState[this.options.field.toString()] || [];\n fvState[this.options.field.toString()] = existingValues.concat(fieldValues);\n this.queryStateModel.set(ModelsModules_1.QueryStateModel.attributesEnum.fv, fvState);\n omnibox.magicBox.blur();\n this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxField, {});\n this.queryController.executeQuery();\n };\n FacetValueSuggestions.ID = 'FacetValueSuggestions';\n FacetValueSuggestions.doExport = function () {\n GlobalExports_1.exportGlobally({\n FacetValueSuggestions: FacetValueSuggestions\n });\n };\n /**\n * @componentOptions\n */\n FacetValueSuggestions.options = {\n /**\n * The field on whose values the scoped query suggestions should be based.\n *\n * @examples @productcategory\n */\n field: ComponentOptions_1.ComponentOptions.buildFieldOption({ required: true }),\n /**\n * The maximum number of suggestions to render in the [`Omnibox`]{@link Omnibox}.\n */\n numberOfSuggestions: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 5, min: 1 }),\n /**\n * Whether to get scoped query suggestions from the current Coveo ML query suggestions.\n *\n * **Notes:**\n * - If this option is set to `true`, the [`enableQuerySuggestAddon`]{@link Omnibox.options.enableQuerySuggestAddon} option of the [`Omnibox`]{@link Omnibox} component must be set to `true` as well.\n * - If this option is set to `true`, an additional `POST` HTTP request is sent to `https://platform.cloud.coveo.com/rest/search/v2/querySuggest`.\n */\n useQuerySuggestions: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }),\n /**\n * Whether to get scoped query suggestions from the current user query entered in the search box.\n *\n * **Default:** `true` if [`useQuerySuggestions`]{@link FacetValueSuggestions.options.useQuerySuggestions} is `false`; `false` otherwise\n */\n useValueFromSearchbox: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n postProcessing: function (value, options) {\n return value || !options.useQuerySuggestions;\n }\n }),\n /**\n * Whether to display an estimate of the number of results for each scoped query suggestions.\n *\n * **Notes:**\n * - Setting this option to `true` has no effect when the [`templateHelper`]{@link FacetValueSuggestions.options.templateHelper} options is set.\n * - When displaying scoped query suggestions for a standalone search box whose queries are redirected to a search interface enforcing other filters, the number of results will be inaccurate.\n */\n displayEstimateNumberOfResults: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * The template helper function to execute when rendering each scoped query suggestion.\n *\n * If specified, the function must have the following signature: (row: [IFacetValueSuggestionRow]{@link IFacetValueSuggestionRow}, omnibox: Omnibox) => string\n *\n * If not specified, a default function will be used.\n *\n * **Note:** You cannot set this option directly in the component markup as an HTML attribute. You must either set it:\n * - In the [`init`]{@link init} call of your search interface (see [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)\n * - Before the `init` call, using the [`options`](@link options) top-level function (see [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n *\n * ```javascript\n * Coveo.init(document.getElementById('search'), {\n * FacetValueSuggestions: {\n * templateHelper: (row, omnibox) => { return `Searching for ${row.keyword} in category ${row.value}`; }\n * }\n * })\n * ```\n */\n templateHelper: ComponentOptions_1.ComponentOptions.buildCustomOption(function () {\n return null;\n }),\n /**\n * Whether the [`field`]{@link FacetValueSuggestions.options.field} option references a multi-value field.\n *\n * Setting this option to `true` if appropriate will allow the corresponding [`CategoryFacet`]{@link CategoryFacet} or [`DynamicHierarchicalFacet`]{@link DynamicHierarchicalFacet} component (if present) to properly handle the filter format.\n *\n * See also the [`categoryFieldDelimitingCharacter`]{@link FacetValueSuggestions.options.categoryFieldDelimitingCharacter} option.\n */\n isCategoryField: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * The delimiting character used for the multi-value field referenced by the [`field`]{@link FacetValueSuggestions.options.field} option.\n *\n * @examples ;, #\n */\n categoryFieldDelimitingCharacter: ComponentOptions_1.ComponentOptions.buildStringOption({ defaultValue: '|', depend: 'isCategoryField' }),\n /**\n * An advanced query expression to add when requesting facet value suggestions.\n *\n * Set this option to ensure that the suggestions are properly scoped when using the component with a standalone search box. For instance, if a certain [tab]{@link Tab} is automatically selected in the search interface the standalone search box is redirecting its queries to, you should set this option to that tab's [`expression`]{@link Tab.options.expression}.\n *\n * @examples @objecttype==Message\n */\n expression: ComponentOptions_1.ComponentOptions.buildQueryExpressionOption()\n };\n return FacetValueSuggestions;\n}(Component_1.Component));\nexports.FacetValueSuggestions = FacetValueSuggestions;\nInitialization_1.Initialization.registerAutoCreateComponent(FacetValueSuggestions);\n\n\n/***/ }),\n\n/***/ 516:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 614:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar FacetValueSuggestionsProvider = /** @class */ (function () {\n function FacetValueSuggestionsProvider(queryController, options) {\n this.queryController = queryController;\n this.options = options;\n }\n FacetValueSuggestionsProvider.prototype.getSuggestions = function (valuesToSearch) {\n return __awaiter(this, void 0, void 0, function () {\n var fieldsToQuery;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.getFieldValuesToQuery(valuesToSearch)];\n case 1:\n fieldsToQuery = _a.sent();\n return [2 /*return*/, this.getAllSuggestionsRows(fieldsToQuery.responses, fieldsToQuery.reference)];\n }\n });\n });\n };\n FacetValueSuggestionsProvider.prototype.getAllSuggestionsRows = function (fieldResponses, fieldTotalReference) {\n var _this = this;\n return fieldResponses.reduce(function (allValues, fieldResponse) {\n var suggestionRows = fieldResponse.values.map(function (indexFieldValue) {\n return {\n numberOfResults: indexFieldValue.numberOfResults,\n keyword: fieldResponse.keyword,\n value: indexFieldValue.value,\n score: _this.computeScoreForSuggestionRow(indexFieldValue, fieldTotalReference),\n field: _this.options.field\n };\n });\n return allValues.concat(suggestionRows);\n }, []);\n };\n FacetValueSuggestionsProvider.prototype.getFieldValuesToQuery = function (valuesToSearch) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var referenceValuesRequest, queryParts, suggestionValuesRequests, requests, values, reference, responses;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n referenceValuesRequest = this.buildReferenceFieldValueRequest();\n queryParts = this.getQueryToExecuteParts();\n if (this.options.expression) {\n queryParts.push(this.options.expression);\n }\n suggestionValuesRequests = valuesToSearch.map(function (keyword) {\n var queryToExecute = queryParts.concat([keyword.text]).join(' ');\n return _this.buildListFieldValueRequest(queryToExecute);\n });\n requests = suggestionValuesRequests.concat([referenceValuesRequest]);\n return [4 /*yield*/, this.queryController.getEndpoint().listFieldValuesBatch({\n batch: requests\n })];\n case 1:\n values = _a.sent();\n reference = this.computeReferenceFromBatch(values.pop());\n responses = values.map(function (value, i) {\n return {\n keyword: valuesToSearch[i],\n values: value\n };\n });\n return [2 /*return*/, {\n responses: responses,\n reference: reference\n }];\n }\n });\n });\n };\n FacetValueSuggestionsProvider.prototype.computeScoreForSuggestionRow = function (fieldValue, reference) {\n var totalNumberForFieldValue = reference.fieldsTotal[fieldValue.value] || reference.smallestTotal;\n var distanceFromTotalForField = (totalNumberForFieldValue - fieldValue.numberOfResults) / totalNumberForFieldValue * 100;\n return {\n distanceFromTotalForField: distanceFromTotalForField\n };\n };\n FacetValueSuggestionsProvider.prototype.computeReferenceFromBatch = function (batch) {\n var fieldsTotal = {};\n batch.forEach(function (value) { return (fieldsTotal[value.value] = value.numberOfResults); });\n return {\n fieldsTotal: fieldsTotal,\n smallestTotal: batch[batch.length - 1].numberOfResults\n };\n };\n FacetValueSuggestionsProvider.prototype.buildListFieldValueRequest = function (queryToExecute) {\n return {\n field: this.options.field,\n ignoreAccents: true,\n maximumNumberOfValues: 3,\n queryOverride: queryToExecute\n };\n };\n FacetValueSuggestionsProvider.prototype.buildReferenceFieldValueRequest = function () {\n return {\n field: this.options.field\n };\n };\n FacetValueSuggestionsProvider.prototype.getQueryToExecuteParts = function () {\n var lastQuery = this.queryController.getLastQuery();\n var aqWithoutCurrentField = lastQuery && lastQuery.aq ? this.removeFieldExpressionFromExpression(this.options.field.toString(), lastQuery.aq) : '';\n return [aqWithoutCurrentField, lastQuery.cq].filter(function (part) { return !!part; });\n };\n FacetValueSuggestionsProvider.prototype.removeFieldExpressionFromExpression = function (field, expression) {\n var expressionWithParenthesis = '([^)]*)';\n var expressionAsSingleValue = '[^ ]*';\n return expression\n .replace(new RegExp(field + \"==\" + expressionWithParenthesis, 'gi'), '')\n .replace(new RegExp(field + \"==\" + expressionAsSingleValue, 'gi'), '');\n };\n return FacetValueSuggestionsProvider;\n}());\nexports.FacetValueSuggestionsProvider = FacetValueSuggestionsProvider;\n\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// FacetValueSuggestions.min__87a2f876e355bf8ecbd9.js","import 'styling/_FieldSuggestions';\nimport * as _ from 'underscore';\nimport { IPopulateOmniboxSuggestionsEventArgs, OmniboxEvents } from '../../events/OmniboxEvents';\nimport { exportGlobally } from '../../GlobalExports';\nimport { l } from '../../MiscModules';\nimport { QueryStateModel } from '../../ModelsModules';\nimport { $$ } from '../../utils/Dom';\nimport { DomUtils } from '../../UtilsModules';\nimport { analyticsActionCauseList, IAnalyticsNoMeta } from '../Analytics/AnalyticsActionListMeta';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { IFieldOption } from '../Base/IComponentOptions';\nimport { Initialization } from '../Base/Initialization';\nimport { IOmniboxSuggestion, Omnibox } from '../Omnibox/Omnibox';\nimport { FacetValueSuggestionsProvider, IFacetValueSuggestionRow, IFacetValueSuggestionsProvider } from './FacetValueSuggestionsProvider';\nimport { Suggestion } from '../../magicbox/SuggestionsManager';\n\nexport interface IFacetValueSuggestionsOptions {\n numberOfSuggestions: number;\n field?: IFieldOption;\n isCategoryField?: boolean;\n categoryFieldDelimitingCharacter?: string;\n useQuerySuggestions?: boolean;\n useValueFromSearchbox?: boolean;\n displayEstimateNumberOfResults?: boolean;\n expression?: string;\n templateHelper?: (row: IFacetValueSuggestionRow, omnibox: Omnibox) => string;\n}\n\nexport interface IQuerySuggestionKeyword {\n text: string;\n html: string;\n}\n\n/**\n * This component provides [`Omnibox`]{@link Omnibox} query suggestions scoped to distinct categories based on the values of a\n * specific [`field`]{@link FacetValueSuggestions.options.field} whose [Facet](https://docs.coveo.com/en/1982/#facet) option is enabled.\n *\n * @externaldocs [Providing Facet Value Suggestions](https://docs.coveo.com/en/340/#providing-facet-value-suggestions)\n *\n * @availablesince [May 2018 Release (v2.4094.8)](https://docs.coveo.com/410/#may-2018-release-v240948)\n */\nexport class FacetValueSuggestions extends Component {\n static ID = 'FacetValueSuggestions';\n\n static doExport = () => {\n exportGlobally({\n FacetValueSuggestions: FacetValueSuggestions\n });\n };\n\n /**\n * @componentOptions\n */\n static options: IFacetValueSuggestionsOptions = {\n /**\n * The field on whose values the scoped query suggestions should be based.\n *\n * @examples @productcategory\n */\n field: ComponentOptions.buildFieldOption({ required: true }),\n\n /**\n * The maximum number of suggestions to render in the [`Omnibox`]{@link Omnibox}.\n */\n numberOfSuggestions: ComponentOptions.buildNumberOption({ defaultValue: 5, min: 1 }),\n\n /**\n * Whether to get scoped query suggestions from the current Coveo ML query suggestions.\n *\n * **Notes:**\n * - If this option is set to `true`, the [`enableQuerySuggestAddon`]{@link Omnibox.options.enableQuerySuggestAddon} option of the [`Omnibox`]{@link Omnibox} component must be set to `true` as well.\n * - If this option is set to `true`, an additional `POST` HTTP request is sent to `https://platform.cloud.coveo.com/rest/search/v2/querySuggest`.\n */\n useQuerySuggestions: ComponentOptions.buildBooleanOption({ defaultValue: true }),\n\n /**\n * Whether to get scoped query suggestions from the current user query entered in the search box.\n *\n * **Default:** `true` if [`useQuerySuggestions`]{@link FacetValueSuggestions.options.useQuerySuggestions} is `false`; `false` otherwise\n */\n useValueFromSearchbox: ComponentOptions.buildBooleanOption({\n postProcessing: (value, options: IFacetValueSuggestionsOptions) => {\n return value || !options.useQuerySuggestions;\n }\n }),\n\n /**\n * Whether to display an estimate of the number of results for each scoped query suggestions.\n *\n * **Notes:**\n * - Setting this option to `true` has no effect when the [`templateHelper`]{@link FacetValueSuggestions.options.templateHelper} options is set.\n * - When displaying scoped query suggestions for a standalone search box whose queries are redirected to a search interface enforcing other filters, the number of results will be inaccurate.\n */\n displayEstimateNumberOfResults: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * The template helper function to execute when rendering each scoped query suggestion.\n *\n * If specified, the function must have the following signature: (row: [IFacetValueSuggestionRow]{@link IFacetValueSuggestionRow}, omnibox: Omnibox) => string\n *\n * If not specified, a default function will be used.\n *\n * **Note:** You cannot set this option directly in the component markup as an HTML attribute. You must either set it:\n * - In the [`init`]{@link init} call of your search interface (see [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)\n * - Before the `init` call, using the [`options`](@link options) top-level function (see [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n *\n * ```javascript\n * Coveo.init(document.getElementById('search'), {\n * FacetValueSuggestions: {\n * templateHelper: (row, omnibox) => { return `Searching for ${row.keyword} in category ${row.value}`; }\n * }\n * })\n * ```\n */\n templateHelper: ComponentOptions.buildCustomOption<(row: IFacetValueSuggestionRow, omnibox: Omnibox) => string>(() => {\n return null;\n }),\n\n /**\n * Whether the [`field`]{@link FacetValueSuggestions.options.field} option references a multi-value field.\n *\n * Setting this option to `true` if appropriate will allow the corresponding [`CategoryFacet`]{@link CategoryFacet} or [`DynamicHierarchicalFacet`]{@link DynamicHierarchicalFacet} component (if present) to properly handle the filter format.\n *\n * See also the [`categoryFieldDelimitingCharacter`]{@link FacetValueSuggestions.options.categoryFieldDelimitingCharacter} option.\n */\n isCategoryField: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * The delimiting character used for the multi-value field referenced by the [`field`]{@link FacetValueSuggestions.options.field} option.\n *\n * @examples ;, #\n */\n categoryFieldDelimitingCharacter: ComponentOptions.buildStringOption({ defaultValue: '|', depend: 'isCategoryField' }),\n\n /**\n * An advanced query expression to add when requesting facet value suggestions.\n *\n * Set this option to ensure that the suggestions are properly scoped when using the component with a standalone search box. For instance, if a certain [tab]{@link Tab} is automatically selected in the search interface the standalone search box is redirecting its queries to, you should set this option to that tab's [`expression`]{@link Tab.options.expression}.\n *\n * @examples @objecttype==Message\n */\n expression: ComponentOptions.buildQueryExpressionOption()\n };\n\n public facetValueSuggestionsProvider: IFacetValueSuggestionsProvider;\n\n private queryStateFieldFacetId;\n\n static defaultTemplate(this: FacetValueSuggestions, row: IFacetValueSuggestionRow, omnibox: Omnibox): string {\n const keyword = row.keyword.html;\n const facetValue = DomUtils.highlight(row.value, 'coveo-omnibox-hightlight');\n const details = this.options.displayEstimateNumberOfResults\n ? DomUtils.highlight(\n ` (${l('ResultCount', row.numberOfResults.toString(), row.numberOfResults)})`,\n 'coveo-omnibox-suggestion-results-count',\n true\n )\n : '';\n return `${l('KeywordInCategory', keyword, facetValue)}${details}`;\n }\n\n private static getQuerySuggestionKeywordFromText(text: string): IQuerySuggestionKeyword {\n return {\n text,\n html: DomUtils.highlight(text, 'coveo-omnibox-hightlight')\n };\n }\n\n /**\n * Creates a new `FacetValueSuggestions` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `FacetValueSuggestions` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n */\n constructor(element: HTMLElement, public options: IFacetValueSuggestionsOptions, bindings?: IComponentBindings) {\n super(element, FacetValueSuggestions.ID, bindings);\n\n this.options = ComponentOptions.initComponentOptions(element, FacetValueSuggestions, options);\n\n this.facetValueSuggestionsProvider = new FacetValueSuggestionsProvider(this.queryController, {\n field: this.options.field,\n expression: this.options.expression\n });\n this.queryStateFieldFacetId = `f:${this.options.field}`;\n\n if (!this.options.templateHelper) {\n this.options.templateHelper = FacetValueSuggestions.defaultTemplate;\n }\n\n $$(this.root).on(OmniboxEvents.populateOmniboxSuggestions, (e: Event, args: IPopulateOmniboxSuggestionsEventArgs) => {\n args.suggestions.push(this.getSuggestions(args.omnibox));\n });\n }\n\n public async getSuggestions(omnibox: Omnibox): Promise {\n if (this.options.numberOfSuggestions == 0) {\n return [];\n }\n\n const text = omnibox.getText();\n\n const suggestions: IOmniboxSuggestion[] = await this.getFacetValueSuggestions(text, omnibox);\n\n return suggestions || [];\n }\n\n private async getQuerySuggestionsKeywords(omnibox: Omnibox): Promise {\n if (this.options.useQuerySuggestions && omnibox.suggestionAddon) {\n const suggestions = await omnibox.suggestionAddon.getSuggestion();\n return suggestions.map(({ text, html }) => { text: text || '', html });\n } else {\n return [];\n }\n }\n\n private async getFacetValueSuggestions(text: string, omnibox: Omnibox): Promise {\n const wordsToQuery = this.options.useValueFromSearchbox ? [FacetValueSuggestions.getQuerySuggestionKeywordFromText(text)] : [];\n\n const suggestionsKeywords: IQuerySuggestionKeyword[] = await this.getQuerySuggestionsKeywords(omnibox);\n const allKeywordsToQuery = _.unique(\n wordsToQuery.concat(suggestionsKeywords).filter(keyword => keyword.text != ''),\n keyword => keyword.text\n );\n\n if (allKeywordsToQuery.length === 0) {\n return [];\n }\n\n return this.getSuggestionsForWords(allKeywordsToQuery, omnibox);\n }\n\n private async getSuggestionsForWords(keywordToQuery: IQuerySuggestionKeyword[], omnibox: Omnibox): Promise {\n try {\n const suggestions = await this.facetValueSuggestionsProvider.getSuggestions(keywordToQuery);\n\n this.logger.debug('FacetValue Suggestions Results', suggestions);\n\n const currentSelectedValues: string[] = this.queryStateModel.get(this.queryStateFieldFacetId) || [];\n const filteredSuggestions = suggestions.filter(suggestion =>\n this.isSuggestionRowAlreadyCheckedInFacet(suggestion, currentSelectedValues)\n );\n return this.rankSuggestionRows(filteredSuggestions).map(result => this.mapFacetValueSuggestion(result, omnibox));\n } catch (error) {\n this.logger.error(error);\n return [];\n }\n }\n\n private isSuggestionRowAlreadyCheckedInFacet(suggestion: IFacetValueSuggestionRow, currentlySelectedValues: string[]): boolean {\n return !currentlySelectedValues.some(value => value == suggestion.value);\n }\n\n private rankSuggestionRows(suggestions: IFacetValueSuggestionRow[]): IFacetValueSuggestionRow[] {\n const rankedResults = [...suggestions.sort((a, b) => b.score.distanceFromTotalForField - a.score.distanceFromTotalForField)];\n const firstSlice = Math.ceil(this.options.numberOfSuggestions / 2);\n const lastSlice = -Math.floor(this.options.numberOfSuggestions / 2);\n\n const firstResultsToReturn = rankedResults.splice(0, firstSlice);\n\n if (lastSlice != 0) {\n const lastResultsToReturn = rankedResults.slice(lastSlice);\n return [...firstResultsToReturn, ...lastResultsToReturn];\n }\n\n return firstResultsToReturn;\n }\n\n private mapFacetValueSuggestion(resultToShow: IFacetValueSuggestionRow, omnibox: Omnibox) {\n const suggestion: IOmniboxSuggestion = {\n html: this.buildDisplayNameForRow(resultToShow, omnibox),\n text: resultToShow.keyword.text\n };\n\n const fieldValues = this.options.isCategoryField\n ? resultToShow.value.split(this.options.categoryFieldDelimitingCharacter)\n : [resultToShow.value];\n\n suggestion.advancedQuery = fieldValues.map(value => `${this.options.field}==\"${value}\"`).join(' AND ');\n\n suggestion.onSelect = () => this.onSuggestionSelected(suggestion, fieldValues, omnibox);\n\n return suggestion;\n }\n\n private buildDisplayNameForRow(row: IFacetValueSuggestionRow, omnibox: Omnibox): string {\n try {\n return this.options.templateHelper.call(this, row, omnibox);\n } catch (ex) {\n this.logger.error('Could not apply template from options for the given row. Will use default template.', ex, row, omnibox);\n return FacetValueSuggestions.defaultTemplate.call(this, row, omnibox);\n }\n }\n\n private onSuggestionSelected(suggestion: Suggestion, fieldValues: string[], omnibox: Omnibox): void {\n omnibox.setText(suggestion.text);\n // Copy the state here, else it will directly modify queryStateModel.defaultAttributes.fv.\n const fvState: { [key: string]: string[] } = { ...this.queryStateModel.get(QueryStateModel.attributesEnum.fv) };\n const existingValues: string[] = fvState[this.options.field.toString()] || [];\n\n fvState[this.options.field.toString()] = existingValues.concat(fieldValues);\n\n this.queryStateModel.set(QueryStateModel.attributesEnum.fv, fvState);\n omnibox.magicBox.blur();\n this.usageAnalytics.logSearchEvent(analyticsActionCauseList.omniboxField, {});\n this.queryController.executeQuery();\n }\n}\n\nInitialization.registerAutoCreateComponent(FacetValueSuggestions);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/FacetValueSuggestions/FacetValueSuggestions.ts","import { QueryController } from '../../Core';\nimport { IIndexFieldValue } from '../../rest/FieldValue';\nimport { IListFieldValuesRequest } from '../../rest/ListFieldValuesRequest';\nimport { IFieldOption } from '../Base/IComponentOptions';\nimport { IQuerySuggestionKeyword } from './FacetValueSuggestions';\n\n/**\n * Used to define a row returned by an [`IFacetValueSuggestionsProvider`]{@link IFacetValueSuggestionsProvider}.\n */\nexport interface IFacetValueSuggestionRow {\n /**\n * The score computed by the suggestions provider.\n *\n * A higher score means the results is more relevant.\n */\n score: IFacetValueSuggestionScore;\n\n /**\n * The field value returned by the suggestion that should be used to filter the results.\n */\n value: string;\n /**\n * The number of results matching the value for the given keyword.\n */\n numberOfResults: number;\n /**\n * The keyword that was used in the query to retrieve results.\n */\n keyword: IQuerySuggestionKeyword;\n /**\n * The field that was used for the suggestions.\n */\n field: IFieldOption;\n}\n\nexport interface IFacetValueSuggestionScore {\n distanceFromTotalForField: number;\n}\n\ninterface IFacetValueSuggestionsResponse {\n responses: IFacetValueBatchResponse[];\n reference: IFacetValueReference;\n}\n\ninterface IFacetValueBatchResponse {\n values: IIndexFieldValue[];\n keyword: IQuerySuggestionKeyword;\n}\n\ntype IFacetValueReference = {\n fieldsTotal: { [value: string]: number };\n smallestTotal: number;\n};\n\n/**\n * Defines options for the [`FacetValueSuggestions`]{@link FacetValueSuggestions} component.\n */\nexport interface IFacetValueSuggestionsProviderOptions {\n field: string;\n expression?: string;\n}\n\n/**\n * Provides suggestions for the [`FacetValueSuggestions`]{@link FacetValueSuggestions} component.\n */\nexport interface IFacetValueSuggestionsProvider {\n getSuggestions(valuesToSearch: IQuerySuggestionKeyword[]): Promise;\n}\n\nexport class FacetValueSuggestionsProvider implements IFacetValueSuggestionsProvider {\n constructor(private queryController: QueryController, private options: IFacetValueSuggestionsProviderOptions) {}\n\n public async getSuggestions(valuesToSearch: IQuerySuggestionKeyword[]): Promise {\n const fieldsToQuery = await this.getFieldValuesToQuery(valuesToSearch);\n return this.getAllSuggestionsRows(fieldsToQuery.responses, fieldsToQuery.reference);\n }\n\n private getAllSuggestionsRows(\n fieldResponses: IFacetValueBatchResponse[],\n fieldTotalReference: IFacetValueReference\n ): IFacetValueSuggestionRow[] {\n return fieldResponses.reduce((allValues, fieldResponse) => {\n const suggestionRows = fieldResponse.values.map(indexFieldValue => {\n return {\n numberOfResults: indexFieldValue.numberOfResults,\n keyword: fieldResponse.keyword,\n value: indexFieldValue.value,\n score: this.computeScoreForSuggestionRow(indexFieldValue, fieldTotalReference),\n field: this.options.field\n };\n });\n return allValues.concat(suggestionRows);\n }, []);\n }\n\n private async getFieldValuesToQuery(valuesToSearch: IQuerySuggestionKeyword[]): Promise {\n // The reference request will be used to get the maximum number of values for a given facet value.\n const referenceValuesRequest = this.buildReferenceFieldValueRequest();\n const queryParts = this.getQueryToExecuteParts();\n\n if (this.options.expression) {\n queryParts.push(this.options.expression);\n }\n\n const suggestionValuesRequests = valuesToSearch.map(keyword => {\n const queryToExecute = [...queryParts, keyword.text].join(' ');\n return this.buildListFieldValueRequest(queryToExecute);\n });\n\n const requests = [...suggestionValuesRequests, referenceValuesRequest];\n const values = await this.queryController.getEndpoint().listFieldValuesBatch({\n batch: requests\n });\n\n const reference = this.computeReferenceFromBatch(values.pop());\n const responses: IFacetValueBatchResponse[] = values.map((value, i) => {\n return {\n keyword: valuesToSearch[i],\n values: value\n };\n });\n\n return {\n responses,\n reference\n };\n }\n\n private computeScoreForSuggestionRow(fieldValue: IIndexFieldValue, reference: IFacetValueReference): IFacetValueSuggestionScore {\n const totalNumberForFieldValue = reference.fieldsTotal[fieldValue.value] || reference.smallestTotal;\n const distanceFromTotalForField: number = (totalNumberForFieldValue - fieldValue.numberOfResults) / totalNumberForFieldValue * 100;\n return {\n distanceFromTotalForField\n };\n }\n\n private computeReferenceFromBatch(batch: IIndexFieldValue[]): IFacetValueReference {\n const fieldsTotal = {};\n batch.forEach(value => (fieldsTotal[value.value] = value.numberOfResults));\n return {\n fieldsTotal: fieldsTotal,\n smallestTotal: batch[batch.length - 1].numberOfResults\n };\n }\n\n private buildListFieldValueRequest(queryToExecute: string): IListFieldValuesRequest {\n return {\n field: this.options.field,\n ignoreAccents: true,\n maximumNumberOfValues: 3,\n queryOverride: queryToExecute\n };\n }\n\n private buildReferenceFieldValueRequest(): IListFieldValuesRequest {\n return {\n field: this.options.field\n };\n }\n\n private getQueryToExecuteParts(): string[] {\n const lastQuery = this.queryController.getLastQuery();\n const aqWithoutCurrentField =\n lastQuery && lastQuery.aq ? this.removeFieldExpressionFromExpression(this.options.field.toString(), lastQuery.aq) : '';\n\n return [aqWithoutCurrentField, lastQuery.cq].filter(part => !!part);\n }\n\n private removeFieldExpressionFromExpression(field: string, expression: string): string {\n const expressionWithParenthesis = '([^)]*)';\n const expressionAsSingleValue = '[^ ]*';\n return expression\n .replace(new RegExp(`${field}==${expressionWithParenthesis}`, 'gi'), '')\n .replace(new RegExp(`${field}==${expressionAsSingleValue}`, 'gi'), '');\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/FacetValueSuggestions/FacetValueSuggestionsProvider.ts"],"sourceRoot":""}