import*as i18n from"../../core/i18n/i18n.js";import*as UI from"../../ui/legacy/legacy.js";import lighthouseDialogStyles from"./lighthouseDialog.css.js";const UIStrings={timespanStarting:"Timespan starting…",timespanStarted:"Timespan started, interact with the page",endTimespan:"End timespan",cancel:"Cancel"},str_=i18n.i18n.registerUIStrings("panels/lighthouse/LighthouseTimespanView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class TimespanView extends UI.Dialog.Dialog{panel;statusHeader;endButton;constructor(t){super(),this.panel=t,this.statusHeader=null,this.endButton=null,this.setDimmed(!0),this.setCloseOnEscape(!1),this.setOutsideClickCallback((t=>t.consume(!0))),this.render()}show(t){this.reset(),super.show(t)}reset(){this.statusHeader&&this.endButton&&(this.statusHeader.textContent=i18nString(UIStrings.timespanStarting),this.endButton.disabled=!0)}ready(){this.statusHeader&&this.endButton&&(this.statusHeader.textContent=i18nString(UIStrings.timespanStarted),this.endButton.disabled=!1,this.endButton.focus())}render(){const t=UI.Utils.createShadowRootWithCoreStyles(this.contentElement,{cssFile:[lighthouseDialogStyles],delegatesFocus:void 0});this.endButton=UI.UIUtils.createTextButton(i18nString(UIStrings.endTimespan),this.endTimespan.bind(this),void 0,!0);const e=UI.UIUtils.createTextButton(i18nString(UIStrings.cancel),this.cancel.bind(this)),s=UI.Fragment.Fragment.build`
  <div class="lighthouse-view vbox">
  <h2 $="status-header"></h2>
  <div class="lighthouse-action-buttons hbox">
  ${e}
  ${this.endButton}
  </div>
  </div>
  `;this.statusHeader=s.$("status-header"),t.appendChild(s.element()),this.setSizeBehavior("SetExactWidthMaxHeight"),this.setMaxContentSize(new UI.Geometry.Size(500,400)),this.reset()}async endTimespan(){await this.panel.handleTimespanEnd()}async cancel(){await this.panel.handleRunCancel()}}