|<\\/sn>/g, '').trim();\n }\n return value;\n },\n formatPlSn: function (value, count) {\n var isPlural = _.isBoolean(count) ? count : count !== 1 && count !== -1;\n if (isPlural) {\n value = value.replace(pluralRegex, '$1').replace(singularRegex, '');\n }\n else {\n value = value.replace(pluralRegex, '').replace(singularRegex, '$1');\n }\n return value;\n }\n};\n\n\n/***/ }),\n/* 153 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\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 });\nvar underscore_1 = __webpack_require__(0);\nvar Assert_1 = __webpack_require__(5);\nvar Logger_1 = __webpack_require__(9);\nvar AnalyticsEndpointCaller_1 = __webpack_require__(330);\nvar UrlUtils_1 = __webpack_require__(43);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsInformation_1 = __webpack_require__(50);\nvar AnalyticsEndpoint = /** @class */ (function () {\n function AnalyticsEndpoint(options) {\n this.options = options;\n this.logger = new Logger_1.Logger(this);\n var endpointCallerOptions = {\n accessToken: this.options.accessToken.token\n };\n this.endpointCaller = new AnalyticsEndpointCaller_1.AnalyticsEndpointCaller(endpointCallerOptions);\n this.organization = options.organization;\n }\n AnalyticsEndpoint.getURLFromSearchEndpoint = function (endpoint) {\n if (!endpoint || !endpoint.options || !endpoint.options.restUri) {\n return this.DEFAULT_ANALYTICS_URI;\n }\n var basePlatform = endpoint.options.restUri.replace(/^(https?:\\/\\/)platform/, '$1analytics').split('/rest')[0];\n return basePlatform + '/rest/ua';\n };\n AnalyticsEndpoint.prototype.getCurrentVisitId = function () {\n return this.visitId;\n };\n AnalyticsEndpoint.prototype.getCurrentVisitIdPromise = function () {\n var _this = this;\n return new Promise(function (resolve, reject) {\n if (_this.getCurrentVisitId()) {\n resolve(_this.getCurrentVisitId());\n }\n else {\n var url = _this.buildAnalyticsUrl('/analytics/visit');\n _this.getFromService(url, {})\n .then(function (response) {\n _this.visitId = response.id;\n resolve(_this.visitId);\n })\n .catch(function (response) {\n reject(response);\n });\n }\n });\n };\n AnalyticsEndpoint.prototype.sendSearchEvents = function (searchEvents) {\n if (searchEvents.length > 0) {\n this.logger.info('Logging analytics search events', searchEvents);\n return this.sendToService(searchEvents, 'searches', 'searchEvents');\n }\n };\n AnalyticsEndpoint.prototype.sendDocumentViewEvent = function (documentViewEvent) {\n Assert_1.Assert.exists(documentViewEvent);\n this.logger.info('Logging analytics document view', documentViewEvent);\n return this.sendToService(documentViewEvent, 'click', 'clickEvent');\n };\n AnalyticsEndpoint.prototype.sendCustomEvent = function (customEvent) {\n Assert_1.Assert.exists(customEvent);\n this.logger.info('Logging analytics custom event', customEvent);\n return this.sendToService(customEvent, 'custom', 'customEvent');\n };\n AnalyticsEndpoint.prototype.getTopQueries = function (params) {\n var url = this.buildAnalyticsUrl('/stats/topQueries');\n return this.getFromService(url, params);\n };\n AnalyticsEndpoint.prototype.clearCookies = function () {\n new AnalyticsInformation_1.AnalyticsInformation().clear();\n };\n AnalyticsEndpoint.prototype.sendToService = function (data, path, paramName) {\n return __awaiter(this, void 0, void 0, function () {\n var url, request, results, error_1, successfullyRenewed;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(AnalyticsEndpoint.pendingRequest != null)) return [3 /*break*/, 2];\n return [4 /*yield*/, AnalyticsEndpoint.pendingRequest];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2:\n url = this.getURL(path);\n request = this.executeRequest(url, data);\n _a.label = 3;\n case 3:\n _a.trys.push([3, 5, , 8]);\n return [4 /*yield*/, request];\n case 4:\n results = _a.sent();\n AnalyticsEndpoint.pendingRequest = null;\n this.handleAnalyticsEventResponse(results.data);\n return [2 /*return*/, results.data];\n case 5:\n error_1 = _a.sent();\n AnalyticsEndpoint.pendingRequest = null;\n if (!this.isAnalyticsTokenExpired(error_1)) return [3 /*break*/, 7];\n return [4 /*yield*/, this.options.accessToken.doRenew()];\n case 6:\n successfullyRenewed = _a.sent();\n if (successfullyRenewed) {\n return [2 /*return*/, this.sendToService(data, path, paramName)];\n }\n _a.label = 7;\n case 7: throw error_1;\n case 8: return [2 /*return*/];\n }\n });\n });\n };\n AnalyticsEndpoint.prototype.isAnalyticsTokenExpired = function (error) {\n return error != null && error.statusCode === 400 && error.data && error.data.type === 'InvalidToken';\n };\n AnalyticsEndpoint.prototype.executeRequest = function (urlNormalized, data) {\n var request = this.endpointCaller.call({\n errorsAsSuccess: false,\n method: 'POST',\n queryString: urlNormalized.queryNormalized,\n requestData: data,\n url: urlNormalized.path,\n responseType: 'text',\n requestDataType: 'application/json'\n });\n if (request) {\n AnalyticsEndpoint.pendingRequest = request;\n return request;\n }\n // In some case, (eg: using navigator.sendBeacon), there won't be any response to read from the service\n // In those case, send back an empty object upstream.\n return Promise.resolve({\n data: {\n visitId: '',\n visitorId: ''\n },\n duration: 0\n });\n };\n AnalyticsEndpoint.prototype.getURL = function (path) {\n var versionToCall = AnalyticsEndpoint.CUSTOM_ANALYTICS_VERSION || AnalyticsEndpoint.DEFAULT_ANALYTICS_VERSION;\n var urlNormalized = UrlUtils_1.UrlUtils.normalizeAsParts({\n paths: [this.options.serviceUrl, versionToCall, '/analytics/', path],\n query: {\n org: this.organization\n }\n });\n return urlNormalized;\n };\n AnalyticsEndpoint.prototype.getFromService = function (url, params) {\n var paramsToSend = __assign({}, params, { access_token: this.options.accessToken.token });\n return this.endpointCaller\n .call({\n errorsAsSuccess: false,\n method: 'GET',\n queryString: this.options.organization ? ['org=' + Utils_1.Utils.safeEncodeURIComponent(this.options.organization)] : [],\n requestData: paramsToSend,\n responseType: 'json',\n url: url\n })\n .then(function (res) {\n return res.data;\n });\n };\n AnalyticsEndpoint.prototype.handleAnalyticsEventResponse = function (response) {\n var visitId;\n if (response['visitId']) {\n visitId = response['visitId'];\n }\n else if (response['searchEventResponses']) {\n visitId = underscore_1.first(response['searchEventResponses']).visitId;\n }\n if (visitId) {\n this.visitId = visitId;\n }\n return response;\n };\n AnalyticsEndpoint.prototype.buildAnalyticsUrl = function (path) {\n return UrlUtils_1.UrlUtils.normalizeAsString({\n paths: [this.options.serviceUrl, AnalyticsEndpoint.CUSTOM_ANALYTICS_VERSION || AnalyticsEndpoint.DEFAULT_ANALYTICS_VERSION, path]\n });\n };\n AnalyticsEndpoint.DEFAULT_ANALYTICS_URI = 'https://analytics.cloud.coveo.com/rest/ua';\n AnalyticsEndpoint.DEFAULT_ANALYTICS_VERSION = 'v15';\n AnalyticsEndpoint.CUSTOM_ANALYTICS_VERSION = undefined;\n return AnalyticsEndpoint;\n}());\nexports.AnalyticsEndpoint = AnalyticsEndpoint;\n\n\n/***/ }),\n/* 154 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar QueryController_1 = __webpack_require__(44);\nexports.QueryController = QueryController_1.QueryController;\nvar HistoryController_1 = __webpack_require__(155);\nexports.HistoryController = HistoryController_1.HistoryController;\nvar LocalStorageHistoryController_1 = __webpack_require__(156);\nexports.LocalStorageHistoryController = LocalStorageHistoryController_1.LocalStorageHistoryController;\n\n\n/***/ }),\n/* 155 */\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})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Assert_1 = __webpack_require__(5);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar Dom_1 = __webpack_require__(1);\nvar HashUtils_1 = __webpack_require__(42);\nvar Defer_1 = __webpack_require__(31);\nvar RootComponent_1 = __webpack_require__(45);\nvar Utils_1 = __webpack_require__(4);\nvar _ = __webpack_require__(0);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar SharedAnalyticsCalls_1 = __webpack_require__(125);\nvar Model_1 = __webpack_require__(18);\n/**\n * This component is instantiated automatically by the framework on the root if the {@link SearchInterface}.
\n * When the {@link SearchInterface.options.enableHistory} option is set to true, this component is instantiated.
\n * It's only job is to apply changes in the {@link QueryStateModel} to the hash in the URL, and vice versa.
\n * This component does *not* hold the state of the interface, it only represent it in the URL.\n */\nvar HistoryController = /** @class */ (function (_super) {\n __extends(HistoryController, _super);\n /**\n * Create a new HistoryController\n * @param element\n * @param window\n * @param queryStateModel\n * @param queryController\n * @param usageAnalytics **Deprecated.** Since the [October 2019 Release (v2.7219)](https://docs.coveo.com/en/3084/), the class retrieves and uses the {@link AnalyticsClient} from the `queryController` constructor parameter.\n */\n function HistoryController(element, window, queryStateModel, queryController, usageAnalytics) {\n var _this = _super.call(this, element, HistoryController.ID) || this;\n _this.window = window;\n _this.queryStateModel = queryStateModel;\n _this.queryController = queryController;\n _this.willUpdateHash = false;\n Assert_1.Assert.exists(_this.queryStateModel);\n Assert_1.Assert.exists(_this.queryController);\n Dom_1.$$(_this.element).on(InitializationEvents_1.InitializationEvents.restoreHistoryState, function () {\n _this.logger.trace('Restore history state. Update model');\n _this.updateModelFromHash();\n _this.lastState = _this.queryStateModel.getAttributes();\n });\n Dom_1.$$(_this.element).on(_this.queryStateModel.getEventName(Model_1.Model.eventTypes.all), function () {\n _this.logger.trace('Query model changed. Update hash');\n _this.updateHashFromModel();\n });\n _this.hashchange = function () {\n _this.handleHashChange();\n _this.lastState = _this.queryStateModel.getAttributes();\n };\n _this.window.addEventListener('hashchange', _this.hashchange);\n Dom_1.$$(_this.element).on(InitializationEvents_1.InitializationEvents.nuke, function () { return _this.handleNuke(); });\n return _this;\n }\n Object.defineProperty(HistoryController.prototype, \"usageAnalytics\", {\n get: function () {\n return this.queryController.usageAnalytics;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(HistoryController.prototype, \"hashUtils\", {\n get: function () {\n return this.hashUtilsModule ? this.hashUtilsModule : HashUtils_1.HashUtils;\n },\n set: function (hashUtils) {\n this.hashUtilsModule = hashUtils;\n },\n enumerable: true,\n configurable: true\n });\n HistoryController.prototype.setState = function (state) {\n this.setHashValues(state);\n };\n HistoryController.prototype.replaceState = function (state) {\n var hash = '#' + this.hashUtils.encodeValues(state);\n this.window.location.replace(hash);\n };\n HistoryController.prototype.replaceUrl = function (url) {\n this.window.location.replace(url);\n };\n /**\n * Set the given map of key value in the hash of the URL\n * @param values\n */\n HistoryController.prototype.setHashValues = function (values) {\n this.logger.trace('Update history hash');\n var encoded = this.hashUtils.encodeValues(values);\n var hash = encoded ? \"#\" + encoded : '';\n var hashHasChanged = this.window.location.hash != hash;\n this.logger.trace('from', this.window.location.hash, 'to', hash);\n var location = this.window.location;\n var url = \"\" + location.pathname + location.search + hash;\n if (this.queryController.firstQuery) {\n if (hashHasChanged) {\n // Using replace avoids adding an entry in the History of the browser.\n // This means that this new URL will become the new initial URL.\n this.replaceUrl(url);\n this.logger.trace('History hash modified', hash);\n }\n }\n else if (hashHasChanged) {\n this.window.history.pushState('', '', url);\n this.logger.trace('History hash created', hash);\n }\n };\n HistoryController.prototype.debugInfo = function () {\n return {\n state: this.queryStateModel.getAttributes()\n };\n };\n HistoryController.prototype.handleHashChange = function () {\n this.logger.trace('History hash changed');\n var attributesThatGotApplied = this.updateModelFromHash();\n if (_.difference(attributesThatGotApplied, HistoryController.attributesThatDoNotTriggerQuery).length > 0) {\n if (this.lastState) {\n var differenceWithLastState = Utils_1.Utils.differenceBetweenObjects(this.queryStateModel.getAttributes(), this.lastState);\n this.mapStateDifferenceToUsageAnalyticsCall(differenceWithLastState);\n }\n this.queryController.executeQuery();\n }\n };\n HistoryController.prototype.handleNuke = function () {\n this.window.removeEventListener('hashchange', this.hashchange);\n };\n HistoryController.prototype.updateHashFromModel = function () {\n var _this = this;\n this.logger.trace('Model -> history hash');\n if (!this.willUpdateHash) {\n Defer_1.Defer.defer(function () {\n var attributes = _this.queryStateModel.getAttributes();\n _this.setHashValues(attributes);\n _this.logger.debug('Saving state to hash', attributes);\n _this.willUpdateHash = false;\n });\n this.willUpdateHash = true;\n }\n };\n HistoryController.prototype.updateModelFromHash = function () {\n var _this = this;\n this.logger.trace('History hash -> model');\n var toSet = {};\n var diff = [];\n _.each(this.queryStateModel.attributes, function (value, key, obj) {\n var valToSet = _this.getHashValue(key);\n toSet[key] = valToSet;\n if (\"\" + _this.queryStateModel.get(key) !== \"\" + valToSet) {\n diff.push(key);\n }\n });\n this.queryStateModel.setMultiple(toSet);\n return diff;\n };\n HistoryController.prototype.getHashValue = function (key) {\n Assert_1.Assert.isNonEmptyString(key);\n var value;\n try {\n var hash = this.hashUtils.getHash(this.window);\n value = this.hashUtils.getValue(key, hash);\n }\n catch (error) {\n this.logger.error(\"Could not parse parameter \" + key + \" from URI\");\n }\n if (Utils_1.Utils.isUndefined(value)) {\n value = this.queryStateModel.defaultAttributes[key];\n }\n return value;\n };\n HistoryController.prototype.mapStateDifferenceToUsageAnalyticsCall = function (stateDifference) {\n // In this method, we want to only match a single analytics event for the current state change.\n // Even though it's technically possible that many property changed at the same time since the last state,\n // the backend UA service does not support multiple search cause for a single search event.\n // So we find the first event that match (if any), by order of importance (query expression > sort > facet)\n var _this = this;\n if (!this.usageAnalytics) {\n this.logger.warn(\"The query state has been modified directly in the URL and we couldn't log the proper analytics call.\");\n this.logger.warn('This is caused by a history controller that has been initialized without the usage analytics parameter.');\n return;\n }\n if (QueryStateModel_1.QUERY_STATE_ATTRIBUTES.Q in stateDifference) {\n SharedAnalyticsCalls_1.logSearchBoxSubmitEvent(this.usageAnalytics);\n return;\n }\n else if (QueryStateModel_1.QUERY_STATE_ATTRIBUTES.SORT in stateDifference) {\n SharedAnalyticsCalls_1.logSortEvent(this.usageAnalytics, stateDifference[QueryStateModel_1.QUERY_STATE_ATTRIBUTES.SORT]);\n return;\n }\n else {\n // Facet id are not known at compilation time, so we iterate on all keys,\n // and try to determine if at least one is linked to a facet selection or exclusion.\n _.keys(stateDifference).forEach(function (key) {\n var facetInfo = _this.extractFacetInfoFromStateDifference(key);\n if (facetInfo) {\n _this.usageAnalytics.logSearchEvent(facetInfo.actionCause, {\n facetId: facetInfo.fieldName,\n facetField: facetInfo.fieldName,\n facetTitle: facetInfo.fieldName,\n facetValue: facetInfo.valueModified\n });\n }\n });\n }\n };\n HistoryController.prototype.extractFacetInfoFromStateDifference = function (key) {\n var regexForFacetInclusion = /^f:(?!.*:not)(.*)/;\n var matchForInclusion = regexForFacetInclusion.exec(key);\n var regexForFacetExclusion = /^f:(.*):not/;\n var matchForExclusion = regexForFacetExclusion.exec(key);\n var currentValue = this.queryStateModel.get(key) || [];\n var lastValue = this.lastState[key] || [];\n var valueRemoved = currentValue.length < lastValue.length;\n var valueModified;\n if (valueRemoved) {\n valueModified = _.first(_.difference(lastValue, currentValue));\n }\n else {\n valueModified = _.first(_.difference(currentValue, lastValue));\n }\n if (matchForInclusion) {\n var fieldName = matchForInclusion[1];\n var actionCause = void 0;\n if (valueRemoved) {\n actionCause = AnalyticsActionListMeta_1.analyticsActionCauseList.facetDeselect;\n }\n else {\n actionCause = AnalyticsActionListMeta_1.analyticsActionCauseList.facetSelect;\n }\n return {\n fieldName: fieldName,\n actionCause: actionCause,\n valueModified: valueModified\n };\n }\n if (matchForExclusion) {\n var fieldName = matchForExclusion[1];\n var actionCause = void 0;\n if (valueRemoved) {\n actionCause = AnalyticsActionListMeta_1.analyticsActionCauseList.facetUnexclude;\n }\n else {\n actionCause = AnalyticsActionListMeta_1.analyticsActionCauseList.facetExclude;\n }\n return {\n fieldName: fieldName,\n actionCause: actionCause,\n valueModified: valueModified\n };\n }\n return null;\n };\n HistoryController.ID = 'HistoryController';\n HistoryController.attributesThatDoNotTriggerQuery = ['quickview'];\n return HistoryController;\n}(RootComponent_1.RootComponent));\nexports.HistoryController = HistoryController;\n\n\n/***/ }),\n/* 156 */\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})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar LocalStorageUtils_1 = __webpack_require__(41);\nvar Model_1 = __webpack_require__(18);\nvar Logger_1 = __webpack_require__(9);\nvar Assert_1 = __webpack_require__(5);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar RootComponent_1 = __webpack_require__(45);\nvar Dom_1 = __webpack_require__(1);\nvar underscore_1 = __webpack_require__(0);\n/**\n * This component acts like the {@link HistoryController} excepts that is saves the {@link QueryStateModel} in the local storage.
\n * This will not allow 'back' and 'forward' navigation in the history, like the standard {@link HistoryController} allows. Instead, it load the query state only on page load.
\n * To enable this component, you should set the {@link SearchInterface.options.useLocalStorageForHistory} as well as the {@link SearchInterface.options.enableHistory} options to true.\n */\nvar LocalStorageHistoryController = /** @class */ (function (_super) {\n __extends(LocalStorageHistoryController, _super);\n /**\n * Create a new LocalStorageHistoryController instance\n * @param element\n * @param windoh For mock purpose\n * @param model\n * @param queryController\n */\n function LocalStorageHistoryController(element, windoh, model, queryController) {\n var _this = _super.call(this, element, LocalStorageHistoryController.ID) || this;\n _this.windoh = windoh;\n _this.model = model;\n _this.queryController = queryController;\n _this.omit = [];\n if (!LocalStorageUtils_1.localStorageExists) {\n new Logger_1.Logger(element).info('No local storage available in current browser. LocalStorageHistoryController cannot initialize itself', _this);\n }\n else {\n _this.storage = new LocalStorageUtils_1.LocalStorageUtils(LocalStorageHistoryController.ID);\n Assert_1.Assert.exists(_this.model);\n Assert_1.Assert.exists(_this.queryController);\n Dom_1.$$(_this.element).on(InitializationEvents_1.InitializationEvents.restoreHistoryState, function () { return _this.initModelFromLocalStorage(); });\n Dom_1.$$(_this.element).on(_this.model.getEventName(Model_1.Model.eventTypes.all), function () { return _this.updateLocalStorageFromModel(); });\n }\n return _this;\n }\n LocalStorageHistoryController.prototype.replaceState = function (state) {\n this.storage.save(state);\n };\n /**\n * Specifies an array of attributes from the query state model that should not be persisted in the local storage\n * @param attributes\n */\n LocalStorageHistoryController.prototype.withoutThoseAttribute = function (attributes) {\n this.omit = attributes;\n };\n LocalStorageHistoryController.prototype.setState = function (values) {\n this.storage.save(values);\n };\n LocalStorageHistoryController.prototype.updateLocalStorageFromModel = function () {\n var attributes = underscore_1.omit(this.model.getAttributes(), this.omit);\n this.setState(attributes);\n this.logger.debug('Saving state to localstorage', attributes);\n };\n LocalStorageHistoryController.prototype.initModelFromLocalStorage = function () {\n var model = this.localStorageModel;\n this.model.setMultiple(model);\n };\n Object.defineProperty(LocalStorageHistoryController.prototype, \"localStorageModel\", {\n get: function () {\n var _this = this;\n var model = {};\n var storedValues = this.storage.load() || {};\n underscore_1.each(this.model.attributes, function (value, key) {\n var storedValue = storedValues[key];\n var defaultValue = _this.model.defaultAttributes[key];\n var valueToSet = storedValue == undefined ? defaultValue : storedValue;\n model[key] = valueToSet;\n });\n return model;\n },\n enumerable: true,\n configurable: true\n });\n LocalStorageHistoryController.ID = 'LocalStorageHistoryController';\n return LocalStorageHistoryController;\n}(RootComponent_1.RootComponent));\nexports.LocalStorageHistoryController = LocalStorageHistoryController;\n\n\n/***/ }),\n/* 157 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar StringUtils_1 = __webpack_require__(22);\nvar ResponsiveComponents_1 = __webpack_require__(54);\nvar _ = __webpack_require__(0);\nvar TemplateConditionEvaluator = /** @class */ (function () {\n function TemplateConditionEvaluator() {\n }\n TemplateConditionEvaluator.getFieldFromString = function (text) {\n var acceptableCharacterInFieldName = '[a-z0-9_]';\n var fieldWithAtSymbolPrefix = \"@(\" + acceptableCharacterInFieldName + \"+)\\\\b\";\n var rawFieldAccessedUsingDotOperator = \"\\\\braw\\\\.(\" + acceptableCharacterInFieldName + \"+)\\\\b\";\n var fieldBetweenDoubleQuotes = \"\\\"[^\\\"]*?(\" + acceptableCharacterInFieldName + \"+)[^\\\"]*?\\\"\";\n var fieldBetweenSingleQuotes = \"'[^']*?(\" + acceptableCharacterInFieldName + \"+)[^']*?'\";\n var rawFieldAccessedUsingString = \"\\\\braw\\\\[(?:\" + fieldBetweenDoubleQuotes + \"|\" + fieldBetweenSingleQuotes + \")\\\\]\";\n var fieldUsedInCondition = \"data-condition-field-(?:not-)?(\" + acceptableCharacterInFieldName + \"+)=\";\n var fieldMatcher = new RegExp(fieldWithAtSymbolPrefix + \"|\" + rawFieldAccessedUsingDotOperator + \"|\" + rawFieldAccessedUsingString + \"|\" + fieldUsedInCondition, 'gi');\n var matchedFields = StringUtils_1.StringUtils.match(text, fieldMatcher);\n return _.map(matchedFields, function (match) { return _.find(match.splice(1), function (field) { return field; }); });\n };\n TemplateConditionEvaluator.evaluateCondition = function (condition, result, responsiveComponents) {\n if (responsiveComponents === void 0) { responsiveComponents = new ResponsiveComponents_1.ResponsiveComponents(); }\n var templateShouldBeLoaded = true;\n var fieldsInCondition = TemplateConditionEvaluator.getFieldFromString(condition);\n _.each(fieldsInCondition, function (fieldInCondition) {\n var matchingFieldValues = TemplateConditionEvaluator.evaluateMatchingFieldValues(fieldInCondition, condition);\n var fieldShouldNotBeNull = matchingFieldValues.length != 0 || TemplateConditionEvaluator.evaluateFieldShouldNotBeNull(fieldInCondition, condition);\n if (fieldShouldNotBeNull) {\n templateShouldBeLoaded = templateShouldBeLoaded && result.raw[fieldInCondition] != null;\n }\n if (templateShouldBeLoaded) {\n _.each(matchingFieldValues, function (fieldValue) {\n templateShouldBeLoaded = templateShouldBeLoaded && result.raw[fieldInCondition].toLowerCase() == fieldValue.toLowerCase();\n });\n }\n });\n if (templateShouldBeLoaded) {\n if (TemplateConditionEvaluator.evaluateShouldUseSmallScreen(condition)) {\n templateShouldBeLoaded = templateShouldBeLoaded && responsiveComponents.isSmallScreenWidth();\n }\n }\n return templateShouldBeLoaded;\n };\n TemplateConditionEvaluator.evaluateMatchingFieldValues = function (field, condition) {\n var foundForCurrentField = [];\n // try to get the field value in the format raw.filetype == \"YouTubeVideo\"\n var firstRegexToGetValue = new RegExp(\"raw\\\\.\" + field + \"\\\\s*=+\\\\s*[\\\"|']([a-zA-Z]+)[\\\"|']\", 'gi');\n // try to get the field value in the format raw['filetype'] == \"YouTubeVideo\"\n var secondRegexToGetValue = new RegExp(\"raw\\\\[[\\\"|']\" + field + \"[\\\"|']\\\\]\\\\s*=+\\\\s*[\\\"|']([a-zA-Z]+)[\\\"|']\", 'gi');\n var matches = StringUtils_1.StringUtils.match(condition, firstRegexToGetValue).concat(StringUtils_1.StringUtils.match(condition, secondRegexToGetValue));\n matches.forEach(function (match) {\n foundForCurrentField = foundForCurrentField.concat(match[1]);\n });\n return _.unique(foundForCurrentField);\n };\n TemplateConditionEvaluator.evaluateFieldShouldNotBeNull = function (field, condition) {\n var firstRegexToMatchNonNull = new RegExp(\"raw\\\\.\" + field + \"\\\\s*!=\\\\s*(?=null|undefined)\", 'gi');\n var secondRegexToMatchNonNull = new RegExp(\"raw\\\\[[\\\"|']\" + field + \"[\\\"|']\\\\]\\\\s*!=\\\\s*(?=null|undefined)\", 'gi');\n return condition.match(firstRegexToMatchNonNull) != null || condition.match(secondRegexToMatchNonNull) != null;\n };\n TemplateConditionEvaluator.evaluateShouldUseSmallScreen = function (condition) {\n return condition.match(/Coveo\\.DeviceUtils\\.isSmallScreenWidth/gi);\n };\n return TemplateConditionEvaluator;\n}());\nexports.TemplateConditionEvaluator = TemplateConditionEvaluator;\n\n\n/***/ }),\n/* 158 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Utils_1 = __webpack_require__(4);\nvar TemplateConditionEvaluator_1 = __webpack_require__(157);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Dom_1 = __webpack_require__(1);\nvar Initialization_1 = __webpack_require__(2);\nvar underscore_1 = __webpack_require__(0);\nvar TemplateFromAScriptTag = /** @class */ (function () {\n function TemplateFromAScriptTag(template, scriptTag) {\n this.template = template;\n this.scriptTag = scriptTag;\n var condition = scriptTag.getAttribute('data-condition');\n if (condition != null) {\n // Allows to add quotes in data-condition on the templates\n condition = condition.toString().replace(/"/g, '\"');\n template.setConditionWithFallback(condition);\n }\n else {\n var parsedFieldsAttributes = this.parseFieldsAttributes();\n if (parsedFieldsAttributes && Utils_1.Utils.isNonEmptyArray(parsedFieldsAttributes)) {\n this.template.fieldsToMatch = parsedFieldsAttributes;\n }\n }\n this.template.layout = this.parseLayout();\n this.template.mobile = this.parseScreenSize('data-mobile');\n this.template.tablet = this.parseScreenSize('data-tablet');\n this.template.desktop = this.parseScreenSize('data-desktop');\n this.template.fields = TemplateConditionEvaluator_1.TemplateConditionEvaluator.getFieldFromString(scriptTag.innerHTML + \" \" + (condition ? condition : ''));\n this.template.role = scriptTag.getAttribute('data-role');\n this.template.addFields(TemplateConditionEvaluator_1.TemplateConditionEvaluator.getFieldFromString(scriptTag.innerHTML + ' ' + condition) || []);\n // Additional fields that might be specified directly on the script element\n var additionalFields = ComponentOptions_1.ComponentOptions.loadFieldsOption(scriptTag, 'fields', {\n includeInResults: true\n });\n if (additionalFields != null) {\n // remove the @\n this.template.addFields(underscore_1.map(additionalFields, function (field) { return field.substr(1); }));\n }\n // Additional fields that might be used to conditionally load the template when it's going to be rendered.\n this.template.addFields(underscore_1.map(this.template.fieldsToMatch, function (toMatch) {\n return toMatch.field;\n }));\n // Scan components in this template\n // return the fields needed for the content of this template\n var neededFieldsForComponents = underscore_1.chain(this.template.getComponentsInside(scriptTag.innerHTML))\n .map(function (component) {\n return Initialization_1.Initialization.getRegisteredFieldsComponentForQuery(component);\n })\n .flatten()\n .value();\n this.template.addFields(neededFieldsForComponents);\n }\n TemplateFromAScriptTag.prototype.toHtmlElement = function (container) {\n if (!container) {\n container = Dom_1.$$('code');\n }\n var condition = Dom_1.$$(this.scriptTag).getAttribute('data-condition');\n if (condition) {\n container.setAttribute('data-condition', condition);\n }\n container.setHtml(this.scriptTag.innerHTML);\n return container.el;\n };\n TemplateFromAScriptTag.prototype.parseFieldsAttributes = function () {\n var dataSet = this.scriptTag.dataset;\n return underscore_1.chain(dataSet)\n .map(function (value, key) {\n var match = key.match(/field([a-zA-Z0-9_\\.]*)/i);\n if (match) {\n var values = void 0;\n if (value != null && value != 'null' && value != '') {\n values = underscore_1.map(value.split(','), function (val) { return val.trim(); });\n }\n return {\n field: match[1].toLowerCase(),\n values: values\n };\n }\n else {\n return undefined;\n }\n })\n .compact()\n .value();\n };\n TemplateFromAScriptTag.prototype.parseScreenSize = function (attribute) {\n return Utils_1.Utils.parseBooleanIfNotUndefined(this.scriptTag.getAttribute(attribute));\n };\n TemplateFromAScriptTag.prototype.parseLayout = function () {\n var layout = this.scriptTag.getAttribute('data-layout');\n return layout;\n };\n TemplateFromAScriptTag.fromString = function (template, properties, container) {\n if (properties === void 0) { properties = {}; }\n if (container === void 0) { container = document.createElement('code'); }\n container.innerHTML = template;\n if (properties.condition != null) {\n container.setAttribute('data-condition', properties.condition);\n }\n if (properties.layout != null) {\n container.setAttribute('data-layout', properties.layout);\n }\n else {\n container.setAttribute('data-layout', 'list');\n }\n if (properties.mobile != null) {\n container.setAttribute('data-mobile', properties.mobile.toString());\n }\n if (properties.tablet != null) {\n container.setAttribute('data-tablet', properties.tablet.toString());\n }\n if (properties.desktop != null) {\n container.setAttribute('data-desktop', properties.desktop.toString());\n }\n if (properties.fieldsToMatch != null) {\n underscore_1.each(properties.fieldsToMatch, function (fieldToMatch) {\n if (fieldToMatch.values) {\n container.setAttribute(\"data-field-\" + fieldToMatch.field.toLowerCase(), fieldToMatch.values.join(','));\n }\n else {\n container.setAttribute(\"data-field-\" + fieldToMatch.field.toLowerCase(), null);\n }\n });\n }\n if (properties.role != null) {\n container.setAttribute('data-role', properties.role);\n }\n return container;\n };\n return TemplateFromAScriptTag;\n}());\nexports.TemplateFromAScriptTag = TemplateFromAScriptTag;\n\n\n/***/ }),\n/* 159 */\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};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ComponentOptions_1 = __webpack_require__(8);\nvar LocalStorageUtils_1 = __webpack_require__(41);\nvar ResultListEvents_1 = __webpack_require__(29);\nvar DebugEvents_1 = __webpack_require__(105);\nvar Dom_1 = __webpack_require__(1);\nvar StringUtils_1 = __webpack_require__(22);\nvar SearchEndpoint_1 = __webpack_require__(53);\nvar RootComponent_1 = __webpack_require__(45);\nvar BaseComponent_1 = __webpack_require__(36);\nvar ExternalModulesShim_1 = __webpack_require__(26);\nvar Globalize = __webpack_require__(23);\nvar _ = __webpack_require__(0);\n__webpack_require__(389);\nvar Strings_1 = __webpack_require__(6);\nvar DebugHeader_1 = __webpack_require__(390);\nvar QueryEvents_1 = __webpack_require__(11);\nvar DebugForResult_1 = __webpack_require__(392);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Template_1 = __webpack_require__(27);\nvar Debug = /** @class */ (function (_super) {\n __extends(Debug, _super);\n function Debug(element, bindings, options, ModalBox) {\n if (ModalBox === void 0) { ModalBox = ExternalModulesShim_1.ModalBox; }\n var _this = _super.call(this, element, Debug.ID) || this;\n _this.element = element;\n _this.bindings = bindings;\n _this.options = options;\n _this.ModalBox = ModalBox;\n _this.opened = false;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, Debug, options);\n // This gets debounced so the following logic works correctly :\n // When you alt dbl click on a component, it's possible to add/merge multiple debug info source together\n // They will be merged together in this.addInfoToDebugPanel\n // Then, openModalBox, even if it's called from multiple different caller will be opened only once all the info has been merged together correctly\n _this.showDebugPanel = _.debounce(function () { return _this.openModalBox(); }, 100);\n Dom_1.$$(_this.element).on(ResultListEvents_1.ResultListEvents.newResultDisplayed, function (e, args) {\n return _this.handleNewResultDisplayed(args);\n });\n Dom_1.$$(_this.element).on(DebugEvents_1.DebugEvents.showDebugPanel, function (e, args) { return _this.handleShowDebugPanel(args); });\n Dom_1.$$(_this.element).on(QueryEvents_1.QueryEvents.querySuccess, function (e, args) { return _this.handleQuerySuccess(args); });\n Dom_1.$$(_this.element).on(QueryEvents_1.QueryEvents.newQuery, function () { return _this.handleNewQuery(); });\n _this.localStorageDebug = new LocalStorageUtils_1.LocalStorageUtils('DebugPanel');\n _this.collapsedSections = _this.localStorageDebug.load() || [];\n return _this;\n }\n Debug.prototype.debugInfo = function () {\n return null;\n };\n Debug.prototype.addInfoToDebugPanel = function (info) {\n if (this.stackDebug == null) {\n this.stackDebug = {};\n }\n this.stackDebug = __assign({}, this.stackDebug, info);\n };\n Debug.prototype.handleNewResultDisplayed = function (args) {\n var _this = this;\n Dom_1.$$(args.item).on('dblclick', function (e) {\n _this.handleResultDoubleClick(e, args);\n });\n };\n Debug.prototype.handleResultDoubleClick = function (e, args) {\n if (e.altKey) {\n var index_1 = args.result.index;\n var template = args.item['template'];\n var findResult = function (results) {\n return results != null ? _.find(results.results, function (result) { return result.index == index_1; }) : args.result;\n };\n var debugInfo = __assign({}, new DebugForResult_1.DebugForResult(this.bindings).generateDebugInfoForResult(args.result), { findResult: findResult, template: this.templateToJson(template) });\n this.addInfoToDebugPanel(debugInfo);\n this.showDebugPanel();\n }\n };\n Debug.prototype.handleQuerySuccess = function (args) {\n if (this.opened) {\n if (this.stackDebug && this.stackDebug.findResult) {\n this.addInfoToDebugPanel(new DebugForResult_1.DebugForResult(this.bindings).generateDebugInfoForResult(this.stackDebug.findResult(args.results)));\n }\n this.redrawDebugPanel();\n this.hideAnimationDuringQuery();\n }\n };\n Debug.prototype.handleNewQuery = function () {\n if (this.opened) {\n this.showAnimationDuringQuery();\n }\n };\n Debug.prototype.handleShowDebugPanel = function (args) {\n this.addInfoToDebugPanel(args);\n this.showDebugPanel();\n };\n Debug.prototype.buildStackPanel = function () {\n var _this = this;\n var body = Dom_1.$$('div', {\n className: 'coveo-debug'\n });\n var keys = _.chain(this.stackDebug)\n .omit('findResult') // findResult is a duplicate of the simpler \"result\" key used to retrieve the results only\n .keys()\n .value();\n // TODO Can't chain this properly due to a bug in underscore js definition file.\n // Yep, A PR is opened to DefinitelyTyped.\n var keysPaired = _.pairs(keys);\n keysPaired = keysPaired.sort(function (a, b) {\n var indexA = _.indexOf(Debug.customOrder, a[1]);\n var indexB = _.indexOf(Debug.customOrder, b[1]);\n if (indexA != -1 && indexB != -1) {\n return indexA - indexB;\n }\n if (indexA != -1) {\n return -1;\n }\n if (indexB != -1) {\n return 1;\n }\n return a[0] - b[0];\n });\n var json = {};\n _.forEach(keysPaired, function (key) {\n var section = _this.buildSection(key[1]);\n var build = _this.buildStackPanelSection(_this.stackDebug[key[1]], _this.stackDebug['result']);\n section.container.append(build.section);\n if (build.json != null) {\n json[key[1]] = build.json;\n }\n body.append(section.dom.el);\n });\n return {\n body: body.el,\n json: json\n };\n };\n Debug.prototype.getModalBody = function () {\n if (this.modalBox && this.modalBox.content) {\n return Dom_1.$$(this.modalBox.content).find('.coveo-modal-body');\n }\n return null;\n };\n Debug.prototype.redrawDebugPanel = function () {\n var build = this.buildStackPanel();\n var body = this.getModalBody();\n if (body) {\n Dom_1.$$(body).empty();\n Dom_1.$$(body).append(build.body);\n }\n this.updateSearchFunctionnality(build);\n };\n Debug.prototype.openModalBox = function () {\n var _this = this;\n var build = this.buildStackPanel();\n this.opened = true;\n this.modalBox = this.ModalBox.open(build.body, {\n title: Strings_1.l('Debug'),\n className: 'coveo-debug',\n titleClose: true,\n overlayClose: true,\n validation: function () {\n _this.onCloseModalBox();\n return true;\n },\n sizeMod: 'big',\n body: this.bindings.root\n });\n var title = Dom_1.$$(this.modalBox.wrapper).find('.coveo-modal-header');\n if (title) {\n if (!this.debugHeader) {\n this.debugHeader = new DebugHeader_1.DebugHeader(this, title, function (value) { return _this.search(value, build.body); }, this.stackDebug);\n }\n else {\n this.debugHeader.moveTo(title);\n this.updateSearchFunctionnality(build);\n }\n }\n else {\n this.logger.warn('No title found in modal box.');\n }\n };\n Debug.prototype.updateSearchFunctionnality = function (build) {\n var _this = this;\n if (this.debugHeader) {\n this.debugHeader.setNewInfoToDebug(this.stackDebug);\n this.debugHeader.setSearch(function (value) { return _this.search(value, build.body); });\n }\n };\n Debug.prototype.onCloseModalBox = function () {\n this.stackDebug = null;\n this.opened = false;\n };\n Debug.prototype.buildStackPanelSection = function (value, results) {\n if (value instanceof HTMLElement) {\n return { section: value };\n }\n else if (_.isFunction(value)) {\n return this.buildStackPanelSection(value(results), results);\n }\n var json = this.toJson(value);\n return { section: this.buildProperty(json), json: json };\n };\n Debug.prototype.findInProperty = function (element, value) {\n var _this = this;\n var wrappedElement = Dom_1.$$(element);\n var match = element['label'].indexOf(value) != -1;\n if (match) {\n this.highlightSearch(element['labelDom'], value);\n }\n else {\n this.removeHighlightSearch(element['labelDom']);\n }\n if (wrappedElement.hasClass('coveo-property-object')) {\n wrappedElement.toggleClass('coveo-search-match', match);\n var children = element['buildKeys']();\n var submatch_1 = false;\n _.each(children, function (child) {\n submatch_1 = _this.findInProperty(child, value) || submatch_1;\n });\n wrappedElement.toggleClass('coveo-search-submatch', submatch_1);\n return match || submatch_1;\n }\n else {\n if (element['values'].indexOf(value) != -1) {\n this.highlightSearch(element['valueDom'], value);\n match = true;\n }\n else {\n this.removeHighlightSearch(element['valueDom']);\n }\n wrappedElement.toggleClass('coveo-search-match', match);\n }\n return match;\n };\n Debug.prototype.buildSection = function (id) {\n var _this = this;\n var dom = Dom_1.$$('div', {\n className: \"coveo-section coveo-\" + id + \"-section\"\n });\n var header = Dom_1.$$('div', {\n className: 'coveo-section-header'\n });\n Dom_1.$$(header).text(id);\n dom.append(header.el);\n var container = Dom_1.$$('div', {\n className: 'coveo-section-container'\n });\n dom.append(container.el);\n if (_.contains(this.collapsedSections, id)) {\n Dom_1.$$(dom).addClass('coveo-debug-collapsed');\n }\n header.on('click', function () {\n Dom_1.$$(dom).toggleClass('coveo-debug-collapsed');\n if (_.contains(_this.collapsedSections, id)) {\n _this.collapsedSections = _.without(_this.collapsedSections, id);\n }\n else {\n _this.collapsedSections.push(id);\n }\n _this.localStorageDebug.save(_this.collapsedSections);\n });\n return {\n dom: dom,\n header: header,\n container: container\n };\n };\n Debug.prototype.buildProperty = function (value, label) {\n if (value instanceof Promise) {\n return this.buildPromise(value, label);\n }\n else if ((_.isArray(value) || _.isObject(value)) && !_.isString(value)) {\n return this.buildObjectProperty(value, label);\n }\n else {\n return this.buildBasicProperty(value, label);\n }\n };\n Debug.prototype.buildPromise = function (promise, label) {\n var _this = this;\n var dom = Dom_1.$$('div', {\n className: 'coveo-property coveo-property-promise'\n });\n promise.then(function (value) {\n var resolvedDom = _this.buildProperty(value, label);\n dom.replaceWith(resolvedDom);\n });\n return dom.el;\n };\n Debug.prototype.buildObjectProperty = function (object, label) {\n var _this = this;\n var dom = Dom_1.$$('div', {\n className: 'coveo-property coveo-property-object'\n });\n var valueContainer = Dom_1.$$('div', {\n className: 'coveo-property-value'\n });\n var keys = _.keys(object);\n if (!_.isArray(object)) {\n keys.sort();\n }\n var children;\n var buildKeys = function () {\n if (children == null) {\n children = [];\n _.each(keys, function (key) {\n var property = _this.buildProperty(object[key], key);\n if (property != null) {\n children.push(property);\n valueContainer.append(property);\n }\n });\n }\n return children;\n };\n dom.el['buildKeys'] = buildKeys;\n if (label != null) {\n var labelDom = Dom_1.$$('div', {\n className: 'coveo-property-label'\n });\n labelDom.text(label);\n dom.el['labelDom'] = labelDom.el;\n dom.append(labelDom.el);\n if (keys.length != 0) {\n dom.addClass('coveo-collapsible');\n labelDom.on('click', function () {\n buildKeys();\n var className = dom.el.className.split(/\\s+/);\n if (_.contains(className, 'coveo-expanded')) {\n className = _.without(className, 'coveo-expanded');\n }\n else {\n className.push('coveo-expanded');\n }\n dom.el.className = className.join(' ');\n });\n }\n }\n else {\n buildKeys();\n }\n if (keys.length == 0) {\n var className = _.without(dom.el.className.split(/\\s+/), 'coveo-property-object');\n className.push('coveo-property-basic');\n dom.el.className = className.join(' ');\n if (_.isArray(object)) {\n valueContainer.setHtml('[]');\n }\n else {\n valueContainer.setHtml('{}');\n }\n dom.el['values'] = '';\n }\n dom.el['label'] = label != null ? label.toLowerCase() : '';\n dom.append(valueContainer.el);\n return dom.el;\n };\n Debug.prototype.buildBasicProperty = function (value, label) {\n var _this = this;\n var dom = Dom_1.$$('div', {\n className: 'coveo-property coveo-property-basic'\n });\n if (label != null) {\n var labelDom = Dom_1.$$('div', {\n className: 'coveo-property-label'\n });\n labelDom.text(label);\n dom.append(labelDom.el);\n dom.el['labelDom'] = labelDom.el;\n }\n var stringValue = value != null ? value.toString() : String(value);\n if (value != null && value['ref'] != null) {\n value = value['ref'];\n }\n var valueDom = Dom_1.$$('div');\n valueDom.text(stringValue);\n valueDom.on('dblclick', function () {\n _this.selectElementText(valueDom.el);\n });\n dom.append(valueDom.el);\n dom.el['valueDom'] = valueDom;\n var className = ['coveo-property-value'];\n if (_.isString(value)) {\n className.push('coveo-property-value-string');\n }\n if (_.isNull(value) || _.isUndefined(value)) {\n className.push('coveo-property-value-null');\n }\n if (_.isNumber(value)) {\n className.push('coveo-property-value-number');\n }\n if (_.isBoolean(value)) {\n className.push('coveo-property-value-boolean');\n }\n if (_.isDate(value)) {\n className.push('coveo-property-value-date');\n }\n if (_.isObject(value)) {\n className.push('coveo-property-value-object');\n }\n if (_.isArray(value)) {\n className.push('coveo-property-value-array');\n }\n valueDom.el.className = className.join(' ');\n dom.el['label'] = label != null ? label.toLowerCase() : '';\n dom.el['values'] = stringValue.toLowerCase();\n return dom.el;\n };\n Debug.prototype.toJson = function (value, depth, done) {\n var _this = this;\n if (depth === void 0) { depth = 0; }\n if (done === void 0) { done = []; }\n if (value instanceof BaseComponent_1.BaseComponent || value instanceof SearchEndpoint_1.SearchEndpoint) {\n return this.componentToJson(value, depth);\n }\n if (value instanceof HTMLElement) {\n return this.htmlToJson(value);\n }\n if (value instanceof Template_1.Template) {\n return this.templateToJson(value);\n }\n if (value instanceof Promise) {\n return value.then(function (value) {\n return _this.toJson(value, depth, done);\n });\n }\n if (value == window) {\n return this.toJsonRef(value);\n }\n if (_.isArray(value) || _.isObject(value)) {\n if (_.contains(done, value)) {\n return this.toJsonRef(value, '< RECURSIVE >');\n }\n else if (depth >= Debug.maxDepth) {\n return this.toJsonRef(value);\n }\n else if (_.isArray(value)) {\n return _.map(value, function (subValue, key) { return _this.toJson(subValue, depth + 1, done.concat([value])); });\n }\n else if (_.isDate(value)) {\n return this.toJsonRef(value, Globalize.format(value, 'F'));\n }\n else {\n var result_1 = {};\n _.each(value, function (subValue, key) {\n result_1[key] = _this.toJson(subValue, depth + 1, done.concat([value]));\n });\n result_1['ref'];\n return result_1;\n }\n }\n return value;\n };\n Debug.prototype.toJsonRef = function (value, stringValue) {\n stringValue = new String(stringValue || value);\n stringValue['ref'] = value;\n return stringValue;\n };\n Debug.prototype.componentToJson = function (value, depth) {\n if (depth === void 0) { depth = 0; }\n var options = _.keys(value['options']);\n if (options.length > 0) {\n return this.toJson(value['options'], depth);\n }\n else {\n return this.toJsonRef(value['options'], new String('No options'));\n }\n };\n Debug.prototype.htmlToJson = function (value) {\n if (value == null) {\n return undefined;\n }\n return {\n tagName: value.tagName,\n id: value.id,\n classList: value.className.split(/\\s+/)\n };\n };\n Debug.prototype.templateToJson = function (template) {\n if (template == null) {\n return null;\n }\n var element = template['element'];\n var templateObject = {\n type: template.getType()\n };\n if (element != null) {\n templateObject.id = element.id;\n templateObject.condition = element.attributes['data-condition'];\n templateObject.content = element.innerText;\n }\n return templateObject;\n };\n Debug.prototype.selectElementText = function (el) {\n if (window.getSelection && document.createRange) {\n var selection = window.getSelection();\n var range = document.createRange();\n range.selectNodeContents(el);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n else if ('createTextRange' in document.body) {\n var textRange = document.body['createTextRange']();\n textRange.moveToElementText(el);\n textRange.select();\n }\n };\n Debug.prototype.search = function (value, body) {\n var _this = this;\n if (_.isEmpty(value)) {\n Dom_1.$$(body)\n .findAll('.coveo-search-match, .coveo-search-submatch')\n .forEach(function (el) {\n Dom_1.$$(el).removeClass('coveo-search-match, coveo-search-submatch');\n });\n Dom_1.$$(body).removeClass('coveo-searching');\n }\n else {\n Dom_1.$$(body).addClass('coveo-searching-loading');\n setTimeout(function () {\n var rootProperties = Dom_1.$$(body).findAll('.coveo-section .coveo-section-container > .coveo-property');\n _.each(rootProperties, function (element) {\n _this.findInProperty(element, value);\n });\n Dom_1.$$(body).addClass('coveo-searching');\n Dom_1.$$(body).removeClass('coveo-searching-loading');\n });\n }\n };\n Debug.prototype.highlightSearch = function (elementToSearch, search) {\n var asHTMLElement;\n if (elementToSearch instanceof HTMLElement) {\n asHTMLElement = elementToSearch;\n }\n else if (elementToSearch instanceof Dom_1.Dom) {\n asHTMLElement = elementToSearch.el;\n }\n if (asHTMLElement != null && asHTMLElement.innerText != null) {\n var match = asHTMLElement.innerText.split(new RegExp('(?=' + StringUtils_1.StringUtils.regexEncode(search) + ')', 'gi'));\n asHTMLElement.innerHTML = '';\n match.forEach(function (value) {\n var regex = new RegExp('(' + StringUtils_1.StringUtils.regexEncode(search) + ')', 'i');\n var group = value.match(regex);\n var span;\n if (group != null) {\n span = Dom_1.$$('span', {\n className: 'coveo-debug-highlight'\n });\n span.text(group[1]);\n asHTMLElement.appendChild(span.el);\n span = Dom_1.$$('span');\n span.text(value.substr(group[1].length));\n asHTMLElement.appendChild(span.el);\n }\n else {\n span = Dom_1.$$('span');\n span.text(value);\n asHTMLElement.appendChild(span.el);\n }\n });\n }\n };\n Debug.prototype.removeHighlightSearch = function (element) {\n if (element != null) {\n element.innerHTML = element.innerText;\n }\n };\n Debug.prototype.showAnimationDuringQuery = function () {\n Dom_1.$$(this.modalBox.content).addClass('coveo-debug-loading');\n };\n Debug.prototype.hideAnimationDuringQuery = function () {\n Dom_1.$$(this.modalBox.content).removeClass('coveo-debug-loading');\n };\n Debug.ID = 'Debug';\n Debug.doExport = function () {\n GlobalExports_1.exportGlobally({\n Debug: Debug\n });\n };\n Debug.options = {\n enableDebug: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false })\n };\n Debug.customOrder = ['error', 'queryDuration', 'result', 'fields', 'rankingInfo', 'template', 'query', 'results', 'state'];\n Debug.durationKeys = ['indexDuration', 'proxyDuration', 'clientDuration', 'duration'];\n Debug.maxDepth = 10;\n return Debug;\n}(RootComponent_1.RootComponent));\nexports.Debug = Debug;\n\n\n/***/ }),\n/* 160 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isObject = __webpack_require__(109);\nvar document = __webpack_require__(38).document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n\n\n/***/ }),\n/* 161 */\n/***/ (function(module, exports) {\n\nmodule.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n\n\n/***/ }),\n/* 162 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\nvar anObject = __webpack_require__(79);\nvar dPs = __webpack_require__(402);\nvar enumBugKeys = __webpack_require__(166);\nvar IE_PROTO = __webpack_require__(114)('IE_PROTO');\nvar Empty = function () { /* empty */ };\nvar PROTOTYPE = 'prototype';\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar createDict = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = __webpack_require__(160)('iframe');\n var i = enumBugKeys.length;\n var lt = '<';\n var gt = '>';\n var iframeDocument;\n iframe.style.display = 'none';\n __webpack_require__(409).appendChild(iframe);\n iframe.src = 'javascript:'; // eslint-disable-line no-script-url\n // createDict = iframe.contentWindow.Object;\n // html.removeChild(iframe);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);\n iframeDocument.close();\n createDict = iframeDocument.F;\n while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];\n return createDict();\n};\n\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n Empty[PROTOTYPE] = anObject(O);\n result = new Empty();\n Empty[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = createDict();\n return Properties === undefined ? result : dPs(result, Properties);\n};\n\n\n/***/ }),\n/* 163 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar core = __webpack_require__(39);\nvar global = __webpack_require__(38);\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || (global[SHARED] = {});\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: core.version,\n mode: __webpack_require__(164) ? 'pure' : 'global',\n copyright: '© 2019 Denis Pushkarev (zloirock.ru)'\n});\n\n\n/***/ }),\n/* 164 */\n/***/ (function(module, exports) {\n\nmodule.exports = true;\n\n\n/***/ }),\n/* 165 */\n/***/ (function(module, exports) {\n\nvar id = 0;\nvar px = Math.random();\nmodule.exports = function (key) {\n return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n\n\n/***/ }),\n/* 166 */\n/***/ (function(module, exports) {\n\n// IE 8- don't enum bug keys\nmodule.exports = (\n 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'\n).split(',');\n\n\n/***/ }),\n/* 167 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar LIBRARY = __webpack_require__(164);\nvar $export = __webpack_require__(59);\nvar redefine = __webpack_require__(422);\nvar hide = __webpack_require__(60);\nvar Iterators = __webpack_require__(83);\nvar $iterCreate = __webpack_require__(423);\nvar setToStringTag = __webpack_require__(168);\nvar getPrototypeOf = __webpack_require__(424);\nvar ITERATOR = __webpack_require__(46)('iterator');\nvar BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`\nvar FF_ITERATOR = '@@iterator';\nvar KEYS = 'keys';\nvar VALUES = 'values';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {\n $iterCreate(Constructor, NAME, next);\n var getMethod = function (kind) {\n if (!BUGGY && kind in proto) return proto[kind];\n switch (kind) {\n case KEYS: return function keys() { return new Constructor(this, kind); };\n case VALUES: return function values() { return new Constructor(this, kind); };\n } return function entries() { return new Constructor(this, kind); };\n };\n var TAG = NAME + ' Iterator';\n var DEF_VALUES = DEFAULT == VALUES;\n var VALUES_BUG = false;\n var proto = Base.prototype;\n var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];\n var $default = $native || getMethod(DEFAULT);\n var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;\n var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;\n var methods, key, IteratorPrototype;\n // Fix native\n if ($anyNative) {\n IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));\n if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {\n // Set @@toStringTag to native iterators\n setToStringTag(IteratorPrototype, TAG, true);\n // fix for some old engines\n if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);\n }\n }\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEF_VALUES && $native && $native.name !== VALUES) {\n VALUES_BUG = true;\n $default = function values() { return $native.call(this); };\n }\n // Define iterator\n if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {\n hide(proto, ITERATOR, $default);\n }\n // Plug for library\n Iterators[NAME] = $default;\n Iterators[TAG] = returnThis;\n if (DEFAULT) {\n methods = {\n values: DEF_VALUES ? $default : getMethod(VALUES),\n keys: IS_SET ? $default : getMethod(KEYS),\n entries: $entries\n };\n if (FORCED) for (key in methods) {\n if (!(key in proto)) redefine(proto, key, methods[key]);\n } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);\n }\n return methods;\n};\n\n\n/***/ }),\n/* 168 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar def = __webpack_require__(108).f;\nvar has = __webpack_require__(81);\nvar TAG = __webpack_require__(46)('toStringTag');\n\nmodule.exports = function (it, tag, stat) {\n if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });\n};\n\n\n/***/ }),\n/* 169 */\n/***/ (function(module, exports) {\n\nmodule.exports = '\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003' +\n '\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n\n\n/***/ }),\n/* 170 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar DeviceUtils_1 = __webpack_require__(24);\nvar PendingSearchEvent_1 = __webpack_require__(116);\nvar PendingSearchAsYouTypeSearchEvent_1 = __webpack_require__(127);\nvar Assert_1 = __webpack_require__(5);\nvar Logger_1 = __webpack_require__(9);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Defer_1 = __webpack_require__(31);\nvar Dom_1 = __webpack_require__(1);\nvar AnalyticsEvents_1 = __webpack_require__(57);\nvar APIAnalyticsBuilder_1 = __webpack_require__(171);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Component_1 = __webpack_require__(7);\nvar Version_1 = __webpack_require__(103);\nvar QueryUtils_1 = __webpack_require__(21);\nvar _ = __webpack_require__(0);\nvar AnalyticsInformation_1 = __webpack_require__(50);\nvar ControllersModules_1 = __webpack_require__(154);\nvar LiveAnalyticsClient = /** @class */ (function () {\n function LiveAnalyticsClient(endpoint, rootElement, userId, userDisplayName, anonymous, splitTestRunName, splitTestRunVersion, originLevel1, sendToCloud, bindings) {\n this.endpoint = endpoint;\n this.rootElement = rootElement;\n this.userId = userId;\n this.userDisplayName = userDisplayName;\n this.anonymous = anonymous;\n this.splitTestRunName = splitTestRunName;\n this.splitTestRunVersion = splitTestRunVersion;\n this.originLevel1 = originLevel1;\n this.sendToCloud = sendToCloud;\n this.bindings = bindings;\n this.isContextual = false;\n this.originContext = 'Search';\n this.language = String['locale'];\n this.device = DeviceUtils_1.DeviceUtils.getDeviceName();\n this.mobile = DeviceUtils_1.DeviceUtils.isMobileDevice();\n Assert_1.Assert.exists(endpoint);\n Assert_1.Assert.exists(rootElement);\n Assert_1.Assert.isNonEmptyString(this.language);\n Assert_1.Assert.isNonEmptyString(this.device);\n Assert_1.Assert.isNonEmptyString(this.originLevel1);\n this.logger = new Logger_1.Logger(this);\n }\n LiveAnalyticsClient.prototype.isActivated = function () {\n return true;\n };\n LiveAnalyticsClient.prototype.getCurrentVisitId = function () {\n return this.endpoint.getCurrentVisitId();\n };\n LiveAnalyticsClient.prototype.getCurrentVisitIdPromise = function () {\n return this.endpoint.getCurrentVisitIdPromise();\n };\n LiveAnalyticsClient.prototype.getCurrentEventCause = function () {\n if (this.pendingSearchEvent != null) {\n return this.pendingSearchEvent.getEventCause();\n }\n if (this.pendingSearchAsYouTypeSearchEvent != null) {\n return this.pendingSearchAsYouTypeSearchEvent.getEventCause();\n }\n return null;\n };\n LiveAnalyticsClient.prototype.getCurrentEventMeta = function () {\n if (this.pendingSearchEvent != null) {\n return this.pendingSearchEvent.getEventMeta();\n }\n if (this.pendingSearchAsYouTypeSearchEvent != null) {\n return this.pendingSearchAsYouTypeSearchEvent.getEventMeta();\n }\n return null;\n };\n LiveAnalyticsClient.prototype.logSearchEvent = function (actionCause, meta) {\n var metaObject = this.buildMetaObject(meta);\n this.pushSearchEvent(actionCause, metaObject);\n };\n LiveAnalyticsClient.prototype.logSearchAsYouType = function (actionCause, meta) {\n var metaObject = this.buildMetaObject(meta);\n this.pushSearchAsYouTypeEvent(actionCause, metaObject);\n };\n LiveAnalyticsClient.prototype.logClickEvent = function (actionCause, meta, result, element) {\n var metaObject = this.buildMetaObject(meta, result);\n return this.pushClickEvent(actionCause, metaObject, result, element);\n };\n LiveAnalyticsClient.prototype.logCustomEvent = function (actionCause, meta, element, result) {\n var metaObject = this.buildMetaObject(meta, result);\n return this.pushCustomEvent(actionCause, metaObject, element);\n };\n LiveAnalyticsClient.prototype.getTopQueries = function (params) {\n return this.endpoint.getTopQueries(params);\n };\n LiveAnalyticsClient.prototype.sendAllPendingEvents = function () {\n if (this.pendingSearchAsYouTypeSearchEvent) {\n this.pendingSearchAsYouTypeSearchEvent.sendRightNow();\n }\n };\n LiveAnalyticsClient.prototype.cancelAllPendingEvents = function () {\n if (this.pendingSearchAsYouTypeSearchEvent) {\n this.pendingSearchAsYouTypeSearchEvent.cancel();\n this.pendingSearchAsYouTypeSearchEvent = null;\n }\n if (this.pendingSearchEvent) {\n this.pendingSearchEvent.cancel();\n this.pendingSearchEvent = null;\n }\n };\n LiveAnalyticsClient.prototype.getPendingSearchEvent = function () {\n if (this.pendingSearchEvent) {\n return this.pendingSearchEvent;\n }\n else if (this.pendingSearchAsYouTypeSearchEvent) {\n return this.pendingSearchAsYouTypeSearchEvent;\n }\n return null;\n };\n LiveAnalyticsClient.prototype.warnAboutSearchEvent = function () {\n if (_.isUndefined(this.pendingSearchEvent) && _.isUndefined(this.pendingSearchAsYouTypeSearchEvent)) {\n this.logger.warn('A search was triggered, but no analytics event was logged. If you wish to have consistent analytics data, consider logging a search event using the methods provided by the framework', 'https://docs.coveo.com/en/2726/#logging-your-own-search-events');\n if (window['console'] && console.trace) {\n console.trace();\n }\n }\n };\n LiveAnalyticsClient.prototype.setOriginContext = function (originContext) {\n this.originContext = originContext;\n };\n LiveAnalyticsClient.prototype.getOriginContext = function () {\n return this.originContext;\n };\n LiveAnalyticsClient.prototype.getUserDisplayName = function () {\n return this.userDisplayName;\n };\n LiveAnalyticsClient.prototype.pushCustomEvent = function (actionCause, metaObject, element) {\n var customEvent = this.buildCustomEvent(actionCause, metaObject, element);\n this.triggerChangeAnalyticsCustomData('CustomEvent', metaObject, customEvent);\n this.checkToSendAnyPendingSearchAsYouType(actionCause);\n Dom_1.$$(this.rootElement).trigger(AnalyticsEvents_1.AnalyticsEvents.customEvent, {\n customEvent: APIAnalyticsBuilder_1.APIAnalyticsBuilder.convertCustomEventToAPI(customEvent)\n });\n Dom_1.$$(this.rootElement).trigger(AnalyticsEvents_1.AnalyticsEvents.analyticsEventReady, {\n event: 'CoveoCustomEvent',\n coveoAnalyticsEventData: customEvent\n });\n return this.sendToCloud ? this.endpoint.sendCustomEvent(customEvent) : Promise.resolve(null);\n };\n LiveAnalyticsClient.prototype.pushSearchEvent = function (actionCause, metaObject) {\n var _this = this;\n Assert_1.Assert.exists(actionCause);\n if (this.pendingSearchEvent && this.pendingSearchEvent.getEventCause() !== actionCause.name) {\n this.pendingSearchEvent.stopRecording();\n this.pendingSearchEvent = null;\n }\n this.checkToSendAnyPendingSearchAsYouType(actionCause);\n if (!this.pendingSearchEvent) {\n var searchEvent = this.buildSearchEvent(actionCause, metaObject);\n this.triggerChangeAnalyticsCustomData('SearchEvent', metaObject, searchEvent);\n var pendingSearchEvent = (this.pendingSearchEvent = new PendingSearchEvent_1.PendingSearchEvent(this.rootElement, this.endpoint, searchEvent, this.sendToCloud));\n Defer_1.Defer.defer(function () {\n // At this point all `duringQuery` events should have been fired, so we can forget\n // about the pending search event. It will finish processing automatically when\n // all the deferred that were caught terminate.\n _this.pendingSearchEvent = undefined;\n pendingSearchEvent.stopRecording();\n });\n }\n };\n LiveAnalyticsClient.prototype.checkToSendAnyPendingSearchAsYouType = function (actionCause) {\n if (this.eventIsNotRelatedToSearchbox(actionCause.name)) {\n this.sendAllPendingEvents();\n }\n else {\n this.cancelAnyPendingSearchAsYouTypeEvent();\n }\n };\n LiveAnalyticsClient.prototype.pushSearchAsYouTypeEvent = function (actionCause, metaObject) {\n this.cancelAnyPendingSearchAsYouTypeEvent();\n var searchEvent = this.buildSearchEvent(actionCause, metaObject);\n this.triggerChangeAnalyticsCustomData('SearchEvent', metaObject, searchEvent);\n this.pendingSearchAsYouTypeSearchEvent = new PendingSearchAsYouTypeSearchEvent_1.PendingSearchAsYouTypeSearchEvent(this.rootElement, this.endpoint, searchEvent, this.sendToCloud);\n };\n LiveAnalyticsClient.prototype.pushClickEvent = function (actionCause, metaObject, result, element) {\n var event = this.buildClickEvent(actionCause, metaObject, result, element);\n this.checkToSendAnyPendingSearchAsYouType(actionCause);\n this.triggerChangeAnalyticsCustomData('ClickEvent', metaObject, event, { resultData: result });\n Assert_1.Assert.isNonEmptyString(event.searchQueryUid);\n Assert_1.Assert.isNonEmptyString(event.collectionName);\n Assert_1.Assert.isNonEmptyString(event.sourceName);\n Assert_1.Assert.isNumber(event.documentPosition);\n Dom_1.$$(this.rootElement).trigger(AnalyticsEvents_1.AnalyticsEvents.documentViewEvent, {\n documentViewEvent: APIAnalyticsBuilder_1.APIAnalyticsBuilder.convertDocumentViewToAPI(event)\n });\n Dom_1.$$(this.rootElement).trigger(AnalyticsEvents_1.AnalyticsEvents.analyticsEventReady, {\n event: 'CoveoClickEvent',\n coveoAnalyticsEventData: event\n });\n return this.sendToCloud ? this.endpoint.sendDocumentViewEvent(event) : Promise.resolve(null);\n };\n LiveAnalyticsClient.prototype.buildAnalyticsEvent = function (actionCause, metaObject) {\n return {\n searchQueryUid: undefined,\n actionCause: actionCause.name,\n actionType: actionCause.type,\n username: this.userId,\n userDisplayName: this.userDisplayName,\n anonymous: this.anonymous,\n device: this.device,\n mobile: this.mobile,\n language: this.language,\n responseTime: undefined,\n originLevel1: this.originLevel1,\n originLevel2: this.getOriginLevel2(this.rootElement),\n originLevel3: document.referrer,\n originContext: this.originContext,\n customData: _.keys(metaObject).length > 0 ? metaObject : undefined,\n userAgent: navigator.userAgent,\n clientId: new AnalyticsInformation_1.AnalyticsInformation().clientId\n };\n };\n LiveAnalyticsClient.prototype.buildSearchEvent = function (actionCause, metaObject) {\n return this.merge(this.buildAnalyticsEvent(actionCause, metaObject), {\n searchQueryUid: undefined,\n pipeline: undefined,\n splitTestRunName: this.splitTestRunName,\n splitTestRunVersion: this.splitTestRunVersion,\n queryText: undefined,\n advancedQuery: undefined,\n results: undefined,\n resultsPerPage: undefined,\n pageNumber: undefined,\n didYouMean: undefined,\n facets: undefined,\n contextual: this.isContextual\n });\n };\n LiveAnalyticsClient.prototype.buildClickEvent = function (actionCause, metaObject, result, element) {\n return this.merge(this.buildAnalyticsEvent(actionCause, metaObject), {\n searchQueryUid: result.queryUid,\n queryPipeline: result.pipeline,\n splitTestRunName: this.splitTestRunName || result.splitTestRun,\n splitTestRunVersion: this.splitTestRunVersion || (result.splitTestRun != undefined ? result.pipeline : undefined),\n documentUri: result.uri,\n documentUriHash: QueryUtils_1.QueryUtils.getUriHash(result),\n documentUrl: result.clickUri,\n documentTitle: result.title,\n documentCategory: QueryUtils_1.QueryUtils.getObjectType(result),\n originLevel2: this.getOriginLevel2(element),\n collectionName: QueryUtils_1.QueryUtils.getCollection(result),\n sourceName: QueryUtils_1.QueryUtils.getSource(result),\n documentPosition: result.index + 1,\n responseTime: 0,\n viewMethod: actionCause.name,\n rankingModifier: result.rankingModifier\n });\n };\n LiveAnalyticsClient.prototype.buildCustomEvent = function (actionCause, metaObject, element) {\n return this.merge(this.buildAnalyticsEvent(actionCause, metaObject), {\n lastSearchQueryUid: this.getLastSearchQueryUid(),\n eventType: actionCause.type,\n eventValue: actionCause.name,\n originLevel2: this.getOriginLevel2(element),\n responseTime: 0\n });\n };\n LiveAnalyticsClient.prototype.getOriginLevel2 = function (element) {\n return this.resolveActiveTabFromElement(element) || 'default';\n };\n LiveAnalyticsClient.prototype.getLastSearchQueryUid = function () {\n var queryController = Component_1.Component.resolveBinding(Component_1.Component.resolveRoot(this.rootElement), ControllersModules_1.QueryController);\n if (!queryController) {\n return;\n }\n var lastResults = queryController.getLastResults();\n if (!lastResults) {\n return;\n }\n return lastResults.searchUid;\n };\n LiveAnalyticsClient.prototype.buildMetaObject = function (meta, result) {\n var modifiedMeta = _.extend({}, meta);\n modifiedMeta['JSUIVersion'] = Version_1.version.lib + ';' + Version_1.version.product;\n var contentIDsAreAlreadySet = modifiedMeta['contentIDKey'] && modifiedMeta['contentIDValue'];\n if (!contentIDsAreAlreadySet && result) {\n var uniqueId = QueryUtils_1.QueryUtils.getPermanentId(result);\n modifiedMeta['contentIDKey'] = uniqueId.fieldUsed;\n modifiedMeta['contentIDValue'] = uniqueId.fieldValue;\n }\n return modifiedMeta;\n };\n LiveAnalyticsClient.prototype.cancelAnyPendingSearchAsYouTypeEvent = function () {\n if (this.pendingSearchAsYouTypeSearchEvent) {\n this.pendingSearchAsYouTypeSearchEvent.cancel();\n this.pendingSearchAsYouTypeSearchEvent = undefined;\n }\n };\n LiveAnalyticsClient.prototype.resolveActiveTabFromElement = function (element) {\n Assert_1.Assert.exists(element);\n var queryStateModel = this.resolveQueryStateModel(element);\n return queryStateModel && queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.t);\n };\n LiveAnalyticsClient.prototype.resolveQueryStateModel = function (rootElement) {\n return Component_1.Component.resolveBinding(rootElement, QueryStateModel_1.QueryStateModel);\n };\n LiveAnalyticsClient.prototype.eventIsNotRelatedToSearchbox = function (event) {\n return event !== AnalyticsActionListMeta_1.analyticsActionCauseList.searchboxSubmit.name && event !== AnalyticsActionListMeta_1.analyticsActionCauseList.searchboxClear.name;\n };\n LiveAnalyticsClient.prototype.triggerChangeAnalyticsCustomData = function (type, metaObject, event, data) {\n // This is for backward compatibility. Before the analytics were using either numbered\n // metas in `metaDataAsNumber` of later on named metas in `metaDataAsString`. Thus we still\n // provide those properties in a deprecated way. Below we are moving any data that put\n // in them to the root.\n metaObject['metaDataAsString'] = {};\n metaObject['metaDataAsNumber'] = {};\n var changeableAnalyticsDataObject = {\n language: event.language,\n originLevel1: event.originLevel1,\n originLevel2: event.originLevel2,\n originLevel3: event.originLevel3,\n metaObject: metaObject\n };\n var args = _.extend({}, {\n type: type,\n actionType: event.actionType,\n actionCause: event.actionCause\n }, changeableAnalyticsDataObject, data);\n Dom_1.$$(this.rootElement).trigger(AnalyticsEvents_1.AnalyticsEvents.changeAnalyticsCustomData, args);\n event.language = args.language;\n event.originLevel1 = args.originLevel1;\n event.originLevel2 = args.originLevel2;\n event.originLevel3 = args.originLevel3;\n event.customData = metaObject;\n // This is for backward compatibility. Before the analytics were using either numbered\n // metas in `metaDataAsNumber` of later on named metas in `metaDataAsString`. We are now putting\n // them all at the root, and if I encounter the older properties I move them to the top\n // level after issuing a warning.\n var metaDataAsString = event.customData['metaDataAsString'];\n if (_.keys(metaDataAsString).length > 0) {\n this.logger.warn(\"Using deprecated 'metaDataAsString' key to log custom analytics data. Custom meta should now be put at the root of the object.\");\n _.extend(event.customData, metaDataAsString);\n }\n delete event.customData['metaDataAsString'];\n var metaDataAsNumber = event.customData['metaDataAsNumber'];\n if (_.keys(metaDataAsNumber).length > 0) {\n this.logger.warn(\"Using deprecated 'metaDataAsNumber' key to log custom analytics data. Custom meta should now be put at the root of the object.\");\n _.extend(event.customData, metaDataAsNumber);\n }\n delete event.customData['metaDataAsNumber'];\n };\n LiveAnalyticsClient.prototype.merge = function (first, second) {\n return _.extend({}, first, second);\n };\n return LiveAnalyticsClient;\n}());\nexports.LiveAnalyticsClient = LiveAnalyticsClient;\n\n\n/***/ }),\n/* 171 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar APIAnalyticsBuilder = /** @class */ (function () {\n function APIAnalyticsBuilder() {\n }\n APIAnalyticsBuilder.convertSearchEventToAPI = function (searchEvent) {\n var apiSearchEvent = {\n advancedQuery: searchEvent.advancedQuery,\n customMetadatas: searchEvent.customData,\n device: searchEvent.device,\n didYouMean: searchEvent.didYouMean,\n language: searchEvent.language,\n pageNumber: searchEvent.pageNumber,\n queryText: searchEvent.queryText,\n responseTime: searchEvent.responseTime,\n numberOfResults: searchEvent.numberOfResults,\n resultsPerPage: searchEvent.resultsPerPage,\n searchHub: searchEvent.originLevel1,\n searchInterface: searchEvent.originLevel2,\n searchQueryUid: searchEvent.searchQueryUid,\n type: searchEvent.actionType,\n actionCause: searchEvent.actionCause,\n queryPipeline: searchEvent.queryPipeline,\n splitTestRunName: searchEvent.splitTestRunName,\n splitTestRunVersion: searchEvent.splitTestRunVersion\n };\n return apiSearchEvent;\n };\n APIAnalyticsBuilder.convertDocumentViewToAPI = function (documentView) {\n var apiDocumentView = {\n collectionName: documentView.collectionName,\n device: documentView.device,\n documentPosition: documentView.documentPosition,\n title: documentView.documentTitle,\n documentUrl: documentView.documentUrl,\n documentUri: documentView.documentUri,\n documentUriHash: documentView.documentUriHash,\n language: documentView.language,\n responseTime: documentView.responseTime,\n searchHub: documentView.originLevel1,\n searchInterface: documentView.originLevel2,\n searchQueryUid: documentView.searchQueryUid,\n sourceName: documentView.sourceName,\n viewMethod: documentView.viewMethod,\n customMetadatas: documentView.customData,\n actionCause: documentView.actionCause,\n queryPipeline: documentView.queryPipeline,\n splitTestRunName: documentView.splitTestRunName,\n splitTestRunVersion: documentView.splitTestRunVersion\n };\n return apiDocumentView;\n };\n APIAnalyticsBuilder.convertCustomEventToAPI = function (customEvent) {\n var apiCustomEvent = {\n actionCause: customEvent.actionCause,\n actionType: customEvent.actionType,\n device: customEvent.device,\n language: customEvent.language,\n responseTime: customEvent.responseTime,\n searchHub: customEvent.originLevel1,\n searchInterface: customEvent.originLevel2,\n customMetadatas: customEvent.customData\n };\n return apiCustomEvent;\n };\n return APIAnalyticsBuilder;\n}());\nexports.APIAnalyticsBuilder = APIAnalyticsBuilder;\n\n\n/***/ }),\n/* 172 */,\n/* 173 */,\n/* 174 */,\n/* 175 */,\n/* 176 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar Utils_1 = __webpack_require__(4);\nvar _ = __webpack_require__(0);\n__webpack_require__(388);\nvar QueryEvents_1 = __webpack_require__(11);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar ResultListEvents_1 = __webpack_require__(29);\nvar HashUtils_1 = __webpack_require__(42);\nvar ComponentsTypes_1 = __webpack_require__(47);\nvar InitializationPlaceholder = /** @class */ (function () {\n function InitializationPlaceholder(root) {\n this.root = root;\n this.facetPlaceholder = \"\\n \\n \\n \\n \\n \";\n this.resultListPlaceholder = \"\";\n this.cardResultListPlaceholder = \"\\n\";\n this.recommendationResultListPlaceholder = \"