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CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;aAC/D;SACF;IACH,CAAC;IA7DM,gBAAE,GAAG,eAAe,CAAC;IAErB,sBAAQ,GAAG;QAChB,8BAAc,CAAC;YACb,aAAa,EAAE,aAAa;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;IAEK,qBAAO,GAA0B,EAAE,CAAC;IAsD7C,oBAAC;CAAA,CA/DkC,qBAAS,GA+D3C;AA/DY,sCAAa;AAgE1B,+BAAc,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC;;;;;;;;ACvF1D,yC","file":"QueryDuration__d2b01b0f173a0c131e66.js","sourcesContent":["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","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./sass/_QueryDuration.scss\n// module id = 637\n// module chunks = 67 88"],"sourceRoot":""}