{"version":3,"sources":["QueryDuration.min__4e9032d9a7117b17aab0.js","./src/ui/QueryDuration/QueryDuration.ts"],"names":["webpackJsonpCoveo__temporary","268","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","QueryDuration","ID","ComponentOptions","initComponentOptions","bind","onRootElement","QueryEvents","querySuccess","data","handleQuerySuccess","queryError","$$","hide","style","display","textContainer","el","appendChild","_this","disabled","results","length","Assert","exists","tooltip","l","formatQueryDuration","duration","searchAPIDuration","indexDuration","join","textContent","setAttribute","durationInMillis","undefined","seconds","Math","max","String","Globalize","format","doExport","exportGlobally","Component","Initialization","registerAutoCreateComponent","641"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,EAASC,GAEjC,YAEA,IAAIC,GAAaC,MAAQA,KAAKD,WAAc,WACxC,GAAIE,GAAgBC,OAAOC,iBACpBC,uBAA2BC,QAAS,SAAUC,EAAGC,GAAKD,EAAEF,UAAYG,IACvE,SAAUD,EAAGC,GAAK,IAAK,GAAIC,KAAKD,GAAOA,EAAEE,eAAeD,KAAIF,EAAEE,GAAKD,EAAEC,IACzE,OAAO,UAAUF,EAAGC,GAEhB,QAASG,KAAOV,KAAKW,YAAcL,EADnCL,EAAcK,EAAGC,GAEjBD,EAAEM,UAAkB,OAANL,EAAaL,OAAOW,OAAON,IAAMG,EAAGE,UAAYL,EAAEK,UAAW,GAAIF,OAGvFR,QAAOY,eAAejB,EAAS,cAAgBkB,OAAO,GCjBtD,YAEA,OACA,QACA,OACA,OACA,OACA,OACA,QACA,MAEA,OAYA,mBAqBE,WAAmBC,EAA6BC,EAAiCC,GAAjF,MACE,YAAMF,EAASG,EAAcC,GAAIF,IAAS,IDWtC,OCZa,GAAAF,UAA6B,EAAAC,UAG9C,EAAKA,QAAU,EAAAI,iBAAiBC,qBAAqBN,EAASG,EAAeF,GAE7E,EAAKM,KAAKC,cAAc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C8C,IACA,SAAUrE,EAAQC","file":"QueryDuration.min__4e9032d9a7117b17aab0.js","sourcesContent":["webpackJsonpCoveo__temporary([67],{\n\n/***/ 268:\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 Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar QueryEvents_1 = __webpack_require__(11);\nvar Assert_1 = __webpack_require__(5);\nvar Dom_1 = __webpack_require__(1);\nvar Strings_1 = __webpack_require__(6);\nvar Initialization_1 = __webpack_require__(2);\nvar Globalize = __webpack_require__(23);\nvar GlobalExports_1 = __webpack_require__(3);\n__webpack_require__(641);\n/**\n * The QueryDuration component displays the duration of the last query execution.\n *\n * When a {@link QueryEvents.querySuccess} event is triggered, the QueryDuration component becomes visible. It also\n * displays the global duration, the index duration, and the client duration in a single tooltip.\n *\n * If a {@link QueryEvents.queryError} event is triggered, the QueryDuration component becomes hidden.\n */\nvar QueryDuration = /** @class */ (function (_super) {\n    __extends(QueryDuration, _super);\n    /**\n     * Creates a new QueryDuration component.\n     * Binds handlers on the {@link QueryEvents.querySuccess} and {@link QueryEvents.queryError} events.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the QueryDuration 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 QueryDuration(element, options, bindings) {\n        var _this = _super.call(this, element, QueryDuration.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, QueryDuration, options);\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (data) { return _this.handleQuerySuccess(data); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function () { return Dom_1.$$(_this.element).hide(); });\n        _this.element.style.display = 'none';\n        _this.textContainer = Dom_1.$$('span').el;\n        _this.element.appendChild(_this.textContainer);\n        return _this;\n    }\n    QueryDuration.prototype.handleQuerySuccess = function (data) {\n        if (!this.disabled && data.results.results.length > 0) {\n            Assert_1.Assert.exists(data);\n            var tooltip = [\n                Strings_1.l('Duration', this.formatQueryDuration(data.results.duration)),\n                Strings_1.l('SearchAPIDuration', this.formatQueryDuration(data.results.searchAPIDuration)),\n                Strings_1.l('IndexDuration', this.formatQueryDuration(data.results.indexDuration))\n            ].join('\\n');\n            this.textContainer.textContent = this.formatQueryDuration(data.results.duration);\n            this.element.setAttribute('title', tooltip);\n            this.element.style.display = 'inline';\n        }\n        else {\n            this.element.style.display = 'none';\n        }\n    };\n    QueryDuration.prototype.formatQueryDuration = function (durationInMillis) {\n        if (durationInMillis == undefined) {\n            return Strings_1.l('Unavailable');\n        }\n        else {\n            var seconds = Math.max(durationInMillis / 1000, 0.01);\n            if (String['locale'] === 'en') {\n                return Strings_1.l('Seconds', Globalize.format(seconds, 'n2'), seconds, true);\n            }\n            else {\n                return Strings_1.l('Seconds', Globalize.format(seconds, 'n2'), seconds);\n            }\n        }\n    };\n    QueryDuration.ID = 'QueryDuration';\n    QueryDuration.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            QueryDuration: QueryDuration\n        });\n    };\n    QueryDuration.options = {};\n    return QueryDuration;\n}(Component_1.Component));\nexports.QueryDuration = QueryDuration;\nInitialization_1.Initialization.registerAutoCreateComponent(QueryDuration);\n\n\n/***/ }),\n\n/***/ 641:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// QueryDuration.min__4e9032d9a7117b17aab0.js","import { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { QueryEvents, IQuerySuccessEventArgs } from '../../events/QueryEvents';\nimport { Assert } from '../../misc/Assert';\nimport { $$ } from '../../utils/Dom';\nimport { l } from '../../strings/Strings';\nimport { Initialization } from '../Base/Initialization';\nimport * as Globalize from 'globalize';\nimport { exportGlobally } from '../../GlobalExports';\n\nimport 'styling/_QueryDuration';\n\nexport interface IQueryDurationOptions {}\n\n/**\n * The QueryDuration component displays the duration of the last query execution.\n *\n * When a {@link QueryEvents.querySuccess} event is triggered, the QueryDuration component becomes visible. It also\n * displays the global duration, the index duration, and the client duration in a single tooltip.\n *\n * If a {@link QueryEvents.queryError} event is triggered, the QueryDuration component becomes hidden.\n */\nexport class QueryDuration extends Component {\n  static ID = 'QueryDuration';\n\n  static doExport = () => {\n    exportGlobally({\n      QueryDuration: QueryDuration\n    });\n  };\n\n  static options: IQueryDurationOptions = {};\n\n  private textContainer: HTMLElement;\n\n  /**\n   * Creates a new QueryDuration component.\n   * Binds handlers on the {@link QueryEvents.querySuccess} and {@link QueryEvents.queryError} events.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the QueryDuration 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?: IQueryDurationOptions, bindings?: IComponentBindings) {\n    super(element, QueryDuration.ID, bindings);\n\n    this.options = ComponentOptions.initComponentOptions(element, QueryDuration, options);\n\n    this.bind.onRootElement(QueryEvents.querySuccess, (data: IQuerySuccessEventArgs) => this.handleQuerySuccess(data));\n    this.bind.onRootElement(QueryEvents.queryError, () => $$(this.element).hide());\n    this.element.style.display = 'none';\n    this.textContainer = $$('span').el;\n    this.element.appendChild(this.textContainer);\n  }\n\n  private handleQuerySuccess(data: IQuerySuccessEventArgs) {\n    if (!this.disabled && data.results.results.length > 0) {\n      Assert.exists(data);\n\n      let tooltip = [\n        l('Duration', this.formatQueryDuration(data.results.duration)),\n        l('SearchAPIDuration', this.formatQueryDuration(data.results.searchAPIDuration)),\n        l('IndexDuration', this.formatQueryDuration(data.results.indexDuration))\n      ].join('\\n');\n\n      this.textContainer.textContent = this.formatQueryDuration(data.results.duration);\n      this.element.setAttribute('title', tooltip);\n      this.element.style.display = 'inline';\n    } else {\n      this.element.style.display = 'none';\n    }\n  }\n\n  private formatQueryDuration(durationInMillis: number): string {\n    if (durationInMillis == undefined) {\n      return l('Unavailable');\n    } else {\n      var seconds = Math.max(durationInMillis / 1000, 0.01);\n      if (String['locale'] === 'en') {\n        return l('Seconds', Globalize.format(seconds, 'n2'), seconds, true);\n      } else {\n        return l('Seconds', Globalize.format(seconds, 'n2'), seconds);\n      }\n    }\n  }\n}\nInitialization.registerAutoCreateComponent(QueryDuration);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/QueryDuration/QueryDuration.ts"],"sourceRoot":""}