{"version":3,"sources":["DidYouMean.min__4e9032d9a7117b17aab0.js","./src/ui/DidYouMean/DidYouMean.ts"],"names":["webpackJsonpCoveo__temporary","250","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","DidYouMean","ID","ComponentOptions","initComponentOptions","Assert","exists","hideNext","ignoreNextNoResults","correctedTerm","bind","onRootElement","QueryEvents","buildingQuery","handlePrepareQueryBuilder","querySuccess","handleProcessNewQueryResults","noResults","handleNoResults","newQuery","handleNewQuery","$$","hide","_this","doQueryWithCorrectedTerm","queryStateModel","set","QueryStateModel","attributesEnum","q","queryController","deferExecuteQuery","beforeExecuteQuery","usageAnalytics","logSearchEvent","analyticsActionCauseList","didyoumeanClick","empty","data","queryBuilder","enableDidYouMean","logger","warn","Utils","isNonEmptyArray","results","queryCorrections","searchAsYouType","enableAutoCorrection","originalQuery","get","correctedQuery","correctedSentence","buildCorrectedSentence","searchInterface","historyManager","replaceState","getAttributes","retryTheQuery","noResultsFor","className","el","innerHTML","l","StringUtils","htmlEncode","appendChild","automaticCorrect","show","didyoumeanAutomatic","trace","correctedWordEl","type","didYouMean","outerHTML","appendedCorrectedWordEl","find","tagName","on","correction","toReturn","currentOffset","_","each","wordCorrections","wordCorrection","push","slice","offset","length","join","doExport","exportGlobally","buildBooleanOption","defaultValue","Component","Initialization","registerAutoCreateComponent","608"],"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,KAA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aA8Jb,EAAA+F,eAAeC,4BAA4BhG,IDPrCiG,IACA,SAAUxH,EAAQC","file":"DidYouMean.min__4e9032d9a7117b17aab0.js","sourcesContent":["webpackJsonpCoveo__temporary([74],{\n\n/***/ 250:\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 });\n__webpack_require__(608);\nvar _ = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\nvar QueryEvents_1 = __webpack_require__(11);\nvar Assert_1 = __webpack_require__(5);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Strings_1 = __webpack_require__(6);\nvar Dom_1 = __webpack_require__(1);\nvar StringUtils_1 = __webpack_require__(22);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\n/**\n * The DidYouMean component is responsible for displaying query corrections. If this component is in the page and the\n * query returns no result but finds a possible query correction, the component either suggests the correction or\n * automatically triggers a new query with the suggested term.\n */\nvar DidYouMean = /** @class */ (function (_super) {\n    __extends(DidYouMean, _super);\n    /**\n     * Creates a new DidYouMean component.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the DidYouMean 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 DidYouMean(element, options, bindings) {\n        var _this = _super.call(this, element, DidYouMean.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.bindings = bindings;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, DidYouMean, options);\n        Assert_1.Assert.exists(element);\n        Assert_1.Assert.exists(_this.options);\n        _this.hideNext = true;\n        _this.ignoreNextNoResults = false;\n        _this.correctedTerm = null;\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, _this.handlePrepareQueryBuilder);\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, _this.handleProcessNewQueryResults);\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.noResults, _this.handleNoResults);\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.newQuery, _this.handleNewQuery);\n        Dom_1.$$(_this.element).hide();\n        return _this;\n    }\n    /**\n     * Executes a query with the corrected term.\n     * Throws an exception if the corrected term has not been initialized.\n     * If successful, logs a `didyoumeanClick` event in the usage analytics.\n     */\n    DidYouMean.prototype.doQueryWithCorrectedTerm = function () {\n        var _this = this;\n        Assert_1.Assert.exists(this.correctedTerm);\n        this.queryStateModel.set(QueryStateModel_1.QueryStateModel.attributesEnum.q, this.correctedTerm);\n        this.queryController.deferExecuteQuery({\n            beforeExecuteQuery: function () { return _this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.didyoumeanClick, {}); }\n        });\n    };\n    DidYouMean.prototype.handleNewQuery = function () {\n        if (this.hideNext) {\n            Dom_1.$$(this.element).empty();\n            Dom_1.$$(this.element).hide();\n            this.correctedTerm = null;\n        }\n        else {\n            this.hideNext = true;\n        }\n    };\n    DidYouMean.prototype.handlePrepareQueryBuilder = function (data) {\n        Assert_1.Assert.exists(data);\n        data.queryBuilder.enableDidYouMean = true;\n    };\n    DidYouMean.prototype.handleNoResults = function (data) {\n        if (this.ignoreNextNoResults) {\n            this.logger.warn('Query is being automatically corrected twice while returning no results.');\n            return;\n        }\n        // We do not auto-correct on search-as-you-type queries\n        if (Utils_1.Utils.isNonEmptyArray(data.results.queryCorrections) && !data.searchAsYouType && this.options.enableAutoCorrection) {\n            this.ignoreNextNoResults = true;\n            var originalQuery = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.q);\n            this.correctedTerm = data.results.queryCorrections[0].correctedQuery;\n            var correctedSentence = this.buildCorrectedSentence(data.results.queryCorrections[0]);\n            this.queryStateModel.set(QueryStateModel_1.QueryStateModel.attributesEnum.q, data.results.queryCorrections[0].correctedQuery);\n            this.searchInterface.historyManager.replaceState(this.queryStateModel.getAttributes());\n            data.retryTheQuery = true;\n            this.hideNext = false;\n            var noResultsFor = Dom_1.$$('div', { className: 'coveo-did-you-mean-no-results-for' }).el;\n            noResultsFor.innerHTML = Strings_1.l('noResultFor', '<span class=\"coveo-highlight coveo-did-you-mean-highlight\">' + StringUtils_1.StringUtils.htmlEncode(originalQuery) + '</span>');\n            this.element.appendChild(noResultsFor);\n            var automaticCorrect = Dom_1.$$('div', { className: 'coveo-did-you-mean-automatic-correct' }).el;\n            automaticCorrect.innerHTML = Strings_1.l('autoCorrectedQueryTo', '<span class=\"coveo-highlight\">' + correctedSentence + '</span>');\n            this.element.appendChild(automaticCorrect);\n            Dom_1.$$(this.element).show();\n            this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.didyoumeanAutomatic, {});\n        }\n    };\n    DidYouMean.prototype.handleProcessNewQueryResults = function (data) {\n        var _this = this;\n        Assert_1.Assert.exists(data);\n        Assert_1.Assert.exists(data.results);\n        this.ignoreNextNoResults = false;\n        var results = data.results;\n        this.logger.trace('Received query results from new query', results);\n        if (Utils_1.Utils.isNonEmptyArray(results.queryCorrections)) {\n            var correctedSentence = this.buildCorrectedSentence(results.queryCorrections[0]);\n            this.correctedTerm = results.queryCorrections[0].correctedQuery;\n            var correctedWordEl = Dom_1.$$('button', { type: 'button' }, correctedSentence).el;\n            var didYouMean = Dom_1.$$('div', { className: 'coveo-did-you-mean-suggestion' }, Strings_1.l('didYouMean', correctedWordEl.outerHTML));\n            this.element.appendChild(didYouMean.el);\n            var appendedCorrectedWordEl = didYouMean.find(correctedWordEl.tagName);\n            Dom_1.$$(appendedCorrectedWordEl).on('click', function () { return _this.doQueryWithCorrectedTerm(); });\n            Dom_1.$$(this.element).show();\n        }\n    };\n    DidYouMean.prototype.buildCorrectedSentence = function (correction) {\n        var toReturn = [];\n        var tagStart = \"<span class='coveo-did-you-mean-word-correction'>\";\n        var tagEnd = '</span>';\n        var currentOffset = 0;\n        _.each(correction.wordCorrections, function (wordCorrection) {\n            toReturn.push(StringUtils_1.StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset, wordCorrection.offset)));\n            currentOffset = wordCorrection.offset;\n            toReturn.push(tagStart);\n            toReturn.push(StringUtils_1.StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset, wordCorrection.length + currentOffset)));\n            toReturn.push(tagEnd);\n            currentOffset = wordCorrection.offset + wordCorrection.length;\n        });\n        toReturn.push(StringUtils_1.StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset)));\n        return toReturn.join('');\n    };\n    DidYouMean.ID = 'DidYouMean';\n    DidYouMean.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            DidYouMean: DidYouMean\n        });\n    };\n    /**\n     * The options for the component\n     * @componentOptions\n     */\n    DidYouMean.options = {\n        /**\n         * Specifies whether the DidYouMean component automatically triggers a new query when a query returns no result and\n         * a possible correction is available.\n         *\n         * Default value is `true`.\n         */\n        enableAutoCorrection: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true })\n    };\n    return DidYouMean;\n}(Component_1.Component));\nexports.DidYouMean = DidYouMean;\nInitialization_1.Initialization.registerAutoCreateComponent(DidYouMean);\n\n\n/***/ }),\n\n/***/ 608:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// DidYouMean.min__4e9032d9a7117b17aab0.js","import 'styling/_DidYouMean';\nimport * as _ from 'underscore';\nimport { exportGlobally } from '../../GlobalExports';\nimport { IBuildingQueryEventArgs, INoResultsEventArgs, IQuerySuccessEventArgs, QueryEvents } from '../../events/QueryEvents';\nimport { Assert } from '../../misc/Assert';\nimport { QueryStateModel } from '../../models/QueryStateModel';\nimport { IQueryCorrection } from '../../rest/QueryCorrection';\nimport { l } from '../../strings/Strings';\nimport { $$ } from '../../utils/Dom';\nimport { StringUtils } from '../../utils/StringUtils';\nimport { Utils } from '../../utils/Utils';\nimport { IAnalyticsNoMeta, analyticsActionCauseList } from '../Analytics/AnalyticsActionListMeta';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { Initialization } from '../Base/Initialization';\n\nexport interface IDidYouMeanOptions {\n  enableAutoCorrection?: boolean;\n}\n\n/**\n * The DidYouMean component is responsible for displaying query corrections. If this component is in the page and the\n * query returns no result but finds a possible query correction, the component either suggests the correction or\n * automatically triggers a new query with the suggested term.\n */\nexport class DidYouMean extends Component {\n  static ID = 'DidYouMean';\n\n  static doExport = () => {\n    exportGlobally({\n      DidYouMean: DidYouMean\n    });\n  };\n\n  /**\n   * The options for the component\n   * @componentOptions\n   */\n  static options: IDidYouMeanOptions = {\n    /**\n     * Specifies whether the DidYouMean component automatically triggers a new query when a query returns no result and\n     * a possible correction is available.\n     *\n     * Default value is `true`.\n     */\n    enableAutoCorrection: ComponentOptions.buildBooleanOption({ defaultValue: true })\n  };\n\n  public correctedTerm: string;\n\n  private hideNext: boolean;\n\n  private ignoreNextNoResults: boolean;\n\n  /**\n   * Creates a new DidYouMean component.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the DidYouMean 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(public element: HTMLElement, public options?: IDidYouMeanOptions, public bindings?: IComponentBindings) {\n    super(element, DidYouMean.ID, bindings);\n\n    this.options = ComponentOptions.initComponentOptions(element, DidYouMean, options);\n    Assert.exists(element);\n    Assert.exists(this.options);\n\n    this.hideNext = true;\n\n    this.ignoreNextNoResults = false;\n\n    this.correctedTerm = null;\n\n    this.bind.onRootElement(QueryEvents.buildingQuery, this.handlePrepareQueryBuilder);\n    this.bind.onRootElement(QueryEvents.querySuccess, this.handleProcessNewQueryResults);\n    this.bind.onRootElement(QueryEvents.noResults, this.handleNoResults);\n    this.bind.onRootElement(QueryEvents.newQuery, this.handleNewQuery);\n    $$(this.element).hide();\n  }\n\n  /**\n   * Executes a query with the corrected term.\n   * Throws an exception if the corrected term has not been initialized.\n   * If successful, logs a `didyoumeanClick` event in the usage analytics.\n   */\n  public doQueryWithCorrectedTerm() {\n    Assert.exists(this.correctedTerm);\n    this.queryStateModel.set(QueryStateModel.attributesEnum.q, this.correctedTerm);\n    this.queryController.deferExecuteQuery({\n      beforeExecuteQuery: () => this.usageAnalytics.logSearchEvent<IAnalyticsNoMeta>(analyticsActionCauseList.didyoumeanClick, {})\n    });\n  }\n\n  private handleNewQuery() {\n    if (this.hideNext) {\n      $$(this.element).empty();\n      $$(this.element).hide();\n      this.correctedTerm = null;\n    } else {\n      this.hideNext = true;\n    }\n  }\n\n  private handlePrepareQueryBuilder(data: IBuildingQueryEventArgs) {\n    Assert.exists(data);\n    data.queryBuilder.enableDidYouMean = true;\n  }\n\n  private handleNoResults(data: INoResultsEventArgs) {\n    if (this.ignoreNextNoResults) {\n      this.logger.warn('Query is being automatically corrected twice while returning no results.');\n      return;\n    }\n\n    // We do not auto-correct on search-as-you-type queries\n    if (Utils.isNonEmptyArray(data.results.queryCorrections) && !data.searchAsYouType && this.options.enableAutoCorrection) {\n      this.ignoreNextNoResults = true;\n      let originalQuery = this.queryStateModel.get(QueryStateModel.attributesEnum.q);\n      this.correctedTerm = data.results.queryCorrections[0].correctedQuery;\n      let correctedSentence = this.buildCorrectedSentence(data.results.queryCorrections[0]);\n      this.queryStateModel.set(QueryStateModel.attributesEnum.q, data.results.queryCorrections[0].correctedQuery);\n      this.searchInterface.historyManager.replaceState(this.queryStateModel.getAttributes());\n      data.retryTheQuery = true;\n      this.hideNext = false;\n\n      let noResultsFor = $$('div', { className: 'coveo-did-you-mean-no-results-for' }).el;\n      noResultsFor.innerHTML = l(\n        'noResultFor',\n        '<span class=\"coveo-highlight coveo-did-you-mean-highlight\">' + StringUtils.htmlEncode(originalQuery) + '</span>'\n      );\n      this.element.appendChild(noResultsFor);\n\n      let automaticCorrect = $$('div', { className: 'coveo-did-you-mean-automatic-correct' }).el;\n      automaticCorrect.innerHTML = l('autoCorrectedQueryTo', '<span class=\"coveo-highlight\">' + correctedSentence + '</span>');\n      this.element.appendChild(automaticCorrect);\n\n      $$(this.element).show();\n      this.usageAnalytics.logSearchEvent<IAnalyticsNoMeta>(analyticsActionCauseList.didyoumeanAutomatic, {});\n    }\n  }\n\n  private handleProcessNewQueryResults(data: IQuerySuccessEventArgs) {\n    Assert.exists(data);\n    Assert.exists(data.results);\n    this.ignoreNextNoResults = false;\n\n    let results = data.results;\n    this.logger.trace('Received query results from new query', results);\n\n    if (Utils.isNonEmptyArray(results.queryCorrections)) {\n      const correctedSentence = this.buildCorrectedSentence(results.queryCorrections[0]);\n      this.correctedTerm = results.queryCorrections[0].correctedQuery;\n\n      const correctedWordEl = $$('button', { type: 'button' }, correctedSentence).el;\n      const didYouMean = $$('div', { className: 'coveo-did-you-mean-suggestion' }, l('didYouMean', correctedWordEl.outerHTML));\n      this.element.appendChild(didYouMean.el);\n\n      const appendedCorrectedWordEl = didYouMean.find(correctedWordEl.tagName);\n      $$(appendedCorrectedWordEl).on('click', () => this.doQueryWithCorrectedTerm());\n\n      $$(this.element).show();\n    }\n  }\n\n  private buildCorrectedSentence(correction: IQueryCorrection) {\n    let toReturn = [];\n    let tagStart = \"<span class='coveo-did-you-mean-word-correction'>\";\n    let tagEnd = '</span>';\n    let currentOffset = 0;\n    _.each(correction.wordCorrections, wordCorrection => {\n      toReturn.push(StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset, wordCorrection.offset)));\n      currentOffset = wordCorrection.offset;\n      toReturn.push(tagStart);\n      toReturn.push(StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset, wordCorrection.length + currentOffset)));\n      toReturn.push(tagEnd);\n      currentOffset = wordCorrection.offset + wordCorrection.length;\n    });\n    toReturn.push(StringUtils.htmlEncode(correction.correctedQuery.slice(currentOffset)));\n    return toReturn.join('');\n  }\n}\n\nInitialization.registerAutoCreateComponent(DidYouMean);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/DidYouMean/DidYouMean.ts"],"sourceRoot":""}