<commit_before>// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/* eslint-disable rulesdir/no_underscored_properties */

import * as Common from '../common/common.js';  // eslint-disable-line no-unused-vars
import * as i18n from '../i18n/i18n.js';
import * as UI from '../ui/ui.js';

import {Events, LighthouseController, RuntimeSettings} from './LighthouseController.js';  // eslint-disable-line no-unused-vars

export const UIStrings = {
  /**
  *@description Text to cancel something
  */
  cancel: 'Cancel',
  /**
  *@description Text when something is loading
  */
  loading: 'Loading…',
  /**
  *@description Text in Lighthouse Status View
  *@example {github.com} PH1
  */
  auditingS: 'Auditing {PH1}',
  /**
  *@description Text in Lighthouse Status View
  */
  auditingYourWebPage: 'Auditing your web page',
  /**
  *@description Text in Lighthouse Status View
  */
  cancelling: 'Cancelling…',
  /**
  *@description Text in Lighthouse Status View
  */
  lighthouseIsWarmingUp: '`Lighthouse` is warming up…',
  /**
  *@description Text in Lighthouse Status View
  */
  lighthouseIsLoadingYourPage: '`Lighthouse` is loading your page',
  /**
  *@description Text in Lighthouse Status View
  *@example {75% of global mobile users in 2016 were on 2G or 3G [Source: GSMA Mobile]} PH1
  */
  fastFactMessageWithPlaceholder: '💡 {PH1}',
  /**
  *@description Text of a DOM element in Lighthouse Status View
  */
  ahSorryWeRanIntoAnError: 'Ah, sorry! We ran into an error.',
  /**
  *@description Text in Lighthouse Status View
  */
  tryToNavigateToTheUrlInAFresh:
      'Try to navigate to the URL in a fresh `Chrome` profile without any other tabs or extensions open and try again.',
  /**
  *@description Text of a DOM element in Lighthouse Status View
  */
  ifThisIssueIsReproduciblePlease: 'If this issue is reproducible, please report it at the `Lighthouse` `GitHub` repo.',
  /**
  *@description Text in Lighthouse Status View
  */
  lighthouseIsLoadingThePage: 'Lighthouse is loading the page.',
  /**
  *@description Text in the pop-up dialog when lighthouse is gathering information in the Lighthouse panel
  */
  lighthouseIsGatheringInformation: '`Lighthouse` is gathering information about the page to compute your score.',
  /**
  *@description Text in the pop-up dialog when lighthouse is auditing in the Lighthouse panel
  */
  almostThereLighthouseIsNow: 'Almost there! `Lighthouse` is now generating your report.',
  /**
  *@description Text when lighthouse is loading the page in the Lighthouse panel
  */
  lighthouseIsLoadingYourPageWith:
      '`Lighthouse` is loading your page with throttling to measure performance on a mobile device on 3G.',
  /**
  *@description Text when lighthouse is loading the page in the Lighthouse panel
  */
  lighthouseIsLoadingYourPageWithThrottling:
      '`Lighthouse` is loading your page with throttling to measure performance on a slow desktop on 3G.',
  /**
  *@description Text when lighthouse is loading the page in the Lighthouse panel
  */
  lighthouseIsLoadingYourPageWithMobile: '`Lighthouse` is loading your page with mobile emulation.',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  mbTakesAMinimumOfSecondsTo:
      '1MB takes a minimum of 5 seconds to download on a typical 3G connection [Source: `WebPageTest` and `DevTools` 3G definition].',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  rebuildingPinterestPagesFor:
      'Rebuilding Pinterest pages for performance increased conversion rates by 15% [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  byReducingTheResponseSizeOfJson:
      'By reducing the response size of JSON needed for displaying comments, Instagram saw increased impressions [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  walmartSawAIncreaseInRevenueFor:
      'Walmart saw a 1% increase in revenue for every 100ms improvement in page load [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  ifASiteTakesSecondToBecome:
      'If a site takes >1 second to become interactive, users lose attention, and their perception of completing the page task is broken [Source: `Google Developers Blog`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  OfGlobalMobileUsersInWereOnGOrG: '75% of global mobile users in 2016 were on 2G or 3G [Source: `GSMA Mobile`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  theAverageUserDeviceCostsLess:
      'The average user device costs less than 200 USD. [Source: `International Data Corporation`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  SecondsIsTheAverageTimeAMobile:
      '19 seconds is the average time a mobile web page takes to load on a 3G connection [Source: `Google DoubleClick blog`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  OfMobilePagesTakeNearlySeconds:
      '70% of mobile pages take nearly 7 seconds for the visual content above the fold to display on the screen. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  asPageLoadTimeIncreasesFromOne:
      'As page load time increases from one second to seven seconds, the probability of a mobile site visitor bouncing increases 113%. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  asTheNumberOfElementsOnAPage:
      'As the number of elements on a page increases from 400 to 6,000, the probability of conversion drops 95%. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the pop-up dialog when lighthouse is running in the Lighthouse panel
  */
  lighthouseOnlySimulatesMobile:
      '`Lighthouse` only simulates mobile performance; to measure performance on a real device, try WebPageTest.org [Source: `Lighthouse` team]',
};
const str_ = i18n.i18n.registerUIStrings('lighthouse/LighthouseStatusView.ts', UIStrings);
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
export class StatusView {
  _controller: LighthouseController;
  _statusView: Element|null;
  _statusHeader: Element|null;
  _progressWrapper: Element|null;
  _progressBar: Element|null;
  _statusText: Element|null;
  _cancelButton: HTMLButtonElement|null;
  _inspectedURL: string;
  _textChangedAt: number;
  _fastFactsQueued: Common.UIString.LocalizedString[];
  _currentPhase: {id: string, message: string, progressBarClass: string, statusMessagePrefix: string}|null;
  _scheduledTextChangeTimeout: number|null;
  _scheduledFastFactTimeout: number|null;
  _dialog: UI.Dialog.Dialog;

  constructor(controller: LighthouseController) {
    this._controller = controller;

    this._statusView = null;
    this._statusHeader = null;
    this._progressWrapper = null;
    this._progressBar = null;
    this._statusText = null;
    this._cancelButton = null;<commit_msg>More precise descriptions for Lighthouse splash screen<commit_after>// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/* eslint-disable rulesdir/no_underscored_properties */

import * as Common from '../common/common.js';  // eslint-disable-line no-unused-vars
import * as i18n from '../i18n/i18n.js';
import * as UI from '../ui/ui.js';

import {Events, LighthouseController, RuntimeSettings} from './LighthouseController.js';  // eslint-disable-line no-unused-vars

export const UIStrings = {
  /**
  *@description Text to cancel something
  */
  cancel: 'Cancel',
  /**
  *@description Text when something is loading
  */
  loading: 'Loading…',
  /**
  *@description Status text in Lighthouse splash screen while an audit is being performed
  *@example {github.com} PH1
  */
  auditingS: 'Auditing {PH1}',
  /**
  *@description Status text in Lighthouse splash screen while an audit is being performed
  */
  auditingYourWebPage: 'Auditing your web page',
  /**
  *@description Status text in Lighthouse splash screen while an audit is being performed, and cancellation to take effect
  */
  cancelling: 'Cancelling…',
  /**
  *@description Status text in Lighthouse splash screen while preparing for an audit
  */
  lighthouseIsWarmingUp: '`Lighthouse` is warming up…',
  /**
  *@description Status text in Lighthouse splash screen while an audit is being performed
  */
  lighthouseIsLoadingYourPage: '`Lighthouse` is loading your page',
  /**
  *@description Text in Lighthouse Status View
  *@example {75% of global mobile users in 2016 were on 2G or 3G [Source: GSMA Mobile]} PH1
  */
  fastFactMessageWithPlaceholder: '💡 {PH1}',
  /**
  *@description Text of a DOM element in Lighthouse Status View
  */
  ahSorryWeRanIntoAnError: 'Ah, sorry! We ran into an error.',
  /**
  *@description Text in Lighthouse Status View
  */
  tryToNavigateToTheUrlInAFresh:
      'Try to navigate to the URL in a fresh `Chrome` profile without any other tabs or extensions open and try again.',
  /**
  *@description Text of a DOM element in Lighthouse Status View
  */
  ifThisIssueIsReproduciblePlease: 'If this issue is reproducible, please report it at the `Lighthouse` `GitHub` repo.',
  /**
  *@description Text in Lighthouse splash screen when loading the page for auditing
  */
  lighthouseIsLoadingThePage: 'Lighthouse is loading the page.',
  /**
  *@description Text in Lighthouse splash screen when Lighthouse is gathering information for display
  */
  lighthouseIsGatheringInformation: '`Lighthouse` is gathering information about the page to compute your score.',
  /**
  *@description Text in Lighthouse splash screen when Lighthouse is generating a report.
  */
  almostThereLighthouseIsNow: 'Almost there! `Lighthouse` is now generating your report.',
  /**
  *@description Text in Lighthouse splash screen when loading the page for auditing
  */
  lighthouseIsLoadingYourPageWith:
      '`Lighthouse` is loading your page with throttling to measure performance on a mobile device on 3G.',
  /**
  *@description Text in Lighthouse splash screen when loading the page for auditing
  */
  lighthouseIsLoadingYourPageWithThrottling:
      '`Lighthouse` is loading your page with throttling to measure performance on a slow desktop on 3G.',
  /**
  *@description Text in Lighthouse splash screen when loading the page for auditing
  */
  lighthouseIsLoadingYourPageWithMobile: '`Lighthouse` is loading your page with mobile emulation.',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  mbTakesAMinimumOfSecondsTo:
      '1MB takes a minimum of 5 seconds to download on a typical 3G connection [Source: `WebPageTest` and `DevTools` 3G definition].',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  rebuildingPinterestPagesFor:
      'Rebuilding Pinterest pages for performance increased conversion rates by 15% [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  byReducingTheResponseSizeOfJson:
      'By reducing the response size of JSON needed for displaying comments, Instagram saw increased impressions [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  walmartSawAIncreaseInRevenueFor:
      'Walmart saw a 1% increase in revenue for every 100ms improvement in page load [Source: `WPO Stats`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  ifASiteTakesSecondToBecome:
      'If a site takes >1 second to become interactive, users lose attention, and their perception of completing the page task is broken [Source: `Google Developers Blog`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  OfGlobalMobileUsersInWereOnGOrG: '75% of global mobile users in 2016 were on 2G or 3G [Source: `GSMA Mobile`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  theAverageUserDeviceCostsLess:
      'The average user device costs less than 200 USD. [Source: `International Data Corporation`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  SecondsIsTheAverageTimeAMobile:
      '19 seconds is the average time a mobile web page takes to load on a 3G connection [Source: `Google DoubleClick blog`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  OfMobilePagesTakeNearlySeconds:
      '70% of mobile pages take nearly 7 seconds for the visual content above the fold to display on the screen. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  asPageLoadTimeIncreasesFromOne:
      'As page load time increases from one second to seven seconds, the probability of a mobile site visitor bouncing increases 113%. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  asTheNumberOfElementsOnAPage:
      'As the number of elements on a page increases from 400 to 6,000, the probability of conversion drops 95%. [Source: `Think with Google`]',
  /**
  *@description Fast fact in the splash screen while Lighthouse is performing an audit
  */
  lighthouseOnlySimulatesMobile:
      '`Lighthouse` only simulates mobile performance; to measure performance on a real device, try WebPageTest.org [Source: `Lighthouse` team]',
};
const str_ = i18n.i18n.registerUIStrings('lighthouse/LighthouseStatusView.ts', UIStrings);
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
export class StatusView {
  _controller: LighthouseController;
  _statusView: Element|null;
  _statusHeader: Element|null;
  _progressWrapper: Element|null;
  _progressBar: Element|null;
  _statusText: Element|null;
  _cancelButton: HTMLButtonElement|null;
  _inspectedURL: string;
  _textChangedAt: number;
  _fastFactsQueued: Common.UIString.LocalizedString[];
  _currentPhase: {id: string, message: string, progressBarClass: string, statusMessagePrefix: string}|null;
  _scheduledTextChangeTimeout: number|null;
  _scheduledFastFactTimeout: number|null;
  _dialog: UI.Dialog.Dialog;

  constructor(controller: LighthouseController) {
    this._controller = controller;

    this._statusView = null;
    this._statusHeader = null;
    this._progressWrapper = null;
    this._progressBar = null;
    this._statusText = null;
    this._cancelButton = null;
{'fraction_non_alphanumeric': 0.08321320927794522, 'fraction_numerical': 0.009697287380421964, 'mean_word_length': 4.18620455317703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6878497', 'n_tokens_mistral': 4525, 'n_tokens_neox': 4179, 'n_words': 1722}