import*as Host from"../host/host.js";import*as i18n from"../i18n/i18n.js";import*as UI from"../ui/ui.js";import{latestReleaseNote,releaseNoteViewId}from"./HelpImpl.js";const UIStrings={s:"{PH1}",learnMore:"Learn more",close:"Close"},str_=i18n.i18n.registerUIStrings("help/ReleaseNoteView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);let releaseNoteViewInstance;export class ReleaseNoteView extends UI.Widget.VBox{constructor(){super(!0),this.registerRequiredCSS("help/releaseNote.css",{enableLegacyPatching:!0}),this._releaseNoteElement=this._createReleaseNoteElement(latestReleaseNote());this.contentElement.createChild("div","release-note-top-section").textContent=i18nString(UIStrings.s,{PH1:latestReleaseNote().header}),this.contentElement.appendChild(this._releaseNoteElement)}static instance(e={forceNew:null}){const{forceNew:t}=e;return releaseNoteViewInstance&&!t||(releaseNoteViewInstance=new ReleaseNoteView),releaseNoteViewInstance}elementsToRestoreScrollPositionsFor(){return[this._releaseNoteElement]}_createReleaseNoteElement(e){const t=document.createElement("div");t.classList.add("hbox");const s=t.createChild("div","release-note-container"),n=s.createChild("ul");UI.ARIAUtils.setAccessibleName(n,i18nString(UIStrings.s,{PH1:latestReleaseNote().header}));let i=1;for(const c of e.highlights){const t=n.createChild("li"),s=UI.XLink.XLink.create(c.link,"","release-note-link");s.textContent="",UI.ARIAUtils.markAsLink(s),UI.ARIAUtils.setAccessibleName(s,`${c.title}: ${c.subtitle} ${i} of ${e.highlights.length}`);s.createChild("div","release-note-title").textContent=c.title;s.createChild("div","release-note-subtitle").textContent=c.subtitle,t.appendChild(s),i++}const o=s.createChild("div","release-note-action-container"),l=UI.UIUtils.createTextButton(i18nString(UIStrings.learnMore),(t=>{t.consume(!0),Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(e.link)}));UI.ARIAUtils.markAsLink(l),o.appendChild(l),o.appendChild(UI.UIUtils.createTextButton(i18nString(UIStrings.close),(e=>{e.consume(!0),UI.InspectorView.InspectorView.instance().closeDrawerTab(releaseNoteViewId,!0)}),"close-release-note"));const r=UI.XLink.XLink.create(e.link," ");r.classList.add("release-note-image"),UI.Tooltip.Tooltip.install(r,i18nString(UIStrings.s,{PH1:latestReleaseNote().header})),t.appendChild(r);const a=r.createChild("img");return a.src="Images/whatsnew.avif",UI.Tooltip.Tooltip.install(a,UI.Tooltip.Tooltip.getContent(r)),a.alt=UI.Tooltip.Tooltip.getContent(a),t}}