debug-server-next
Version:
Dev server for hippy-core.
145 lines • 74.3 kB
JavaScript
!function(){"use strict";
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const e="…",t="data:image/jpeg;base64,",n={label:"pass",minScore:.9},i={label:"average",minScore:.5},r={label:"fail"},s={label:"error"},o=["com","co","gov","edu","ac","org","go","gob","or","net","in","ne","nic","gouv","web","spb","blog","jus","kiev","mil","wi","qc","ca","bel","on"];class a{static get PASS_THRESHOLD(){return.9}static get MS_DISPLAY_VALUE(){return"%10d ms"}static prepareReportResult(e){const n=JSON.parse(JSON.stringify(e));n.configSettings.locale||(n.configSettings.locale="en"),n.configSettings.formFactor||(n.configSettings.formFactor=n.configSettings.emulatedFormFactor);for(const e of Object.values(n.audits))if("not_applicable"!==e.scoreDisplayMode&&"not-applicable"!==e.scoreDisplayMode||(e.scoreDisplayMode="notApplicable"),e.details&&(void 0!==e.details.type&&"diagnostic"!==e.details.type||(e.details.type="debugdata"),"filmstrip"===e.details.type))for(const n of e.details.items)n.data.startsWith(t)||(n.data=t+n.data);if("object"!=typeof n.categories)throw new Error("No categories provided.");const i=new Map;for(const e of Object.values(n.categories))e.auditRefs.forEach((e=>{e.relevantAudits&&e.relevantAudits.forEach((t=>{const n=i.get(t)||[];n.push(e),i.set(t,n)}))})),e.auditRefs.forEach((e=>{const t=n.audits[e.id];e.result=t,i.has(e.id)&&(e.relevantMetrics=i.get(e.id)),n.stackPacks&&n.stackPacks.forEach((t=>{t.descriptions[e.id]&&(e.stackPacks=e.stackPacks||[],e.stackPacks.push({title:t.title,iconDataURL:t.iconDataURL,description:t.descriptions[e.id]}))}))}));return n}static showAsPassed(e){switch(e.scoreDisplayMode){case"manual":case"notApplicable":return!0;case"error":case"informative":return!1;case"numeric":case"binary":default:return Number(e.score)>=n.minScore}}static calculateRating(e,t){if("manual"===t||"notApplicable"===t)return n.label;if("error"===t)return s.label;if(null===e)return r.label;let o=r.label;return e>=n.minScore?o=n.label:e>=i.minScore&&(o=i.label),o}static splitMarkdownCodeSpans(e){const t=[],n=e.split(/`(.*?)`/g);for(let e=0;e<n.length;e++){const i=n[e];if(!i)continue;const r=e%2!=0;t.push({isCode:r,text:i})}return t}static splitMarkdownLink(e){const t=[],n=e.split(/\[([^\]]+?)\]\((https?:\/\/.*?)\)/g);for(;n.length;){const[e,i,r]=n.splice(0,3);e&&t.push({isLink:!1,text:e}),i&&r&&t.push({isLink:!0,text:i,linkHref:r})}return t}static getURLDisplayName(t,n){const i=void 0!==(n=n||{numPathParts:void 0,preserveQuery:void 0,preserveHost:void 0}).numPathParts?n.numPathParts:2,r=void 0===n.preserveQuery||n.preserveQuery,s=n.preserveHost||!1;let o;if("about:"===t.protocol||"data:"===t.protocol)o=t.href;else{o=t.pathname;const n=o.split("/").filter((e=>e.length));i&&n.length>i&&(o=e+n.slice(-1*i).join("/")),s&&(o=`${t.host}/${o.replace(/^\//,"")}`),r&&(o=`${o}${t.search}`)}if(o=o.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g,"$1…"),o=o.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,"$1…"),o=o.replace(/(\d{3})\d{6,}/g,"$1…"),o=o.replace(/\u2026+/g,e),o.length>64&&o.includes("?")&&(o=o.replace(/\?([^=]*)(=)?.*/,"?$1$2…"),o.length>64&&(o=o.replace(/\?.*/,"?…"))),o.length>64){const t=o.lastIndexOf(".");o=t>=0?o.slice(0,63-(o.length-t))+`…${o.slice(t)}`:o.slice(0,63)+e}return o}static parseURL(e){const t=new URL(e);return{file:a.getURLDisplayName(t),hostname:t.hostname,origin:t.origin}}static createOrReturnURL(e){return e instanceof URL?e:new URL(e)}static getTld(e){const t=e.split(".").slice(-2);return o.includes(t[0])?`.${t.join(".")}`:`.${t[t.length-1]}`}static getRootDomain(e){const t=a.createOrReturnURL(e).hostname,n=a.getTld(t).split(".");return t.split(".").slice(-n.length).join(".")}static getEnvironmentDisplayValues(e){const t=a.getEmulationDescriptions(e);return[{name:a.i18n.strings.runtimeSettingsDevice,description:t.deviceEmulation},{name:a.i18n.strings.runtimeSettingsNetworkThrottling,description:t.networkThrottling},{name:a.i18n.strings.runtimeSettingsCPUThrottling,description:t.cpuThrottling}]}static getEmulationDescriptions(e){let t,n;const i=e.throttling;switch(e.throttlingMethod){case"provided":t=a.i18n.strings.throttlingProvided,n=a.i18n.strings.throttlingProvided;break;case"devtools":{const{cpuSlowdownMultiplier:e,requestLatencyMs:r}=i;t=`${a.i18n.formatNumber(e)}x slowdown (DevTools)`,n=`${a.i18n.formatNumber(r)} ms HTTP RTT, ${a.i18n.formatNumber(i.downloadThroughputKbps)} Kbps down, ${a.i18n.formatNumber(i.uploadThroughputKbps)} Kbps up (DevTools)`;break}case"simulate":{const{cpuSlowdownMultiplier:e,rttMs:r,throughputKbps:s}=i;t=`${a.i18n.formatNumber(e)}x slowdown (Simulated)`,n=`${a.i18n.formatNumber(r)} ms TCP RTT, ${a.i18n.formatNumber(s)} Kbps throughput (Simulated)`;break}default:t=a.i18n.strings.runtimeUnknown,n=a.i18n.strings.runtimeUnknown}return{deviceEmulation:{mobile:a.i18n.strings.runtimeMobileEmulation,desktop:a.i18n.strings.runtimeDesktopEmulation}[e.formFactor]||a.i18n.strings.runtimeNoEmulation,cpuThrottling:t,networkThrottling:n}}static filterRelevantLines(e,t,n){if(0===t.length)return e.slice(0,2*n+1);const i=new Set;return(t=t.sort(((e,t)=>(e.lineNumber||0)-(t.lineNumber||0)))).forEach((({lineNumber:e})=>{let t=e-n,r=e+n;for(;t<1;)t++,r++;i.has(t-3-1)&&(t-=3);for(let e=t;e<=r;e++){const t=e;i.add(t)}})),e.filter((e=>i.has(e.lineNumber)))}static isPluginCategory(e){return e.startsWith("lighthouse-plugin-")}}a.reportJson=null,a.getUniqueSuffix=(()=>{let e=0;return function(){return e++}})(),a.i18n=null,a.UIStrings={varianceDisclaimer:"Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics.",calculatorLink:"See calculator.",showRelevantAudits:"Show audits relevant to:",opportunityResourceColumnLabel:"Opportunity",opportunitySavingsColumnLabel:"Estimated Savings",errorMissingAuditInfo:"Report error: no audit information",errorLabel:"Error!",warningHeader:"Warnings: ",warningAuditsGroupTitle:"Passed audits but with warnings",passedAuditsGroupTitle:"Passed audits",notApplicableAuditsGroupTitle:"Not applicable",manualAuditsGroupTitle:"Additional items to manually check",toplevelWarningsMessage:"There were issues affecting this run of Lighthouse:",crcInitialNavigation:"Initial Navigation",crcLongestDurationLabel:"Maximum critical path latency:",snippetExpandButtonLabel:"Expand snippet",snippetCollapseButtonLabel:"Collapse snippet",lsPerformanceCategoryDescription:"[Lighthouse](https://developers.google.com/web/tools/lighthouse/) analysis of the current page on an emulated mobile network. Values are estimated and may vary.",labDataTitle:"Lab Data",thirdPartyResourcesLabel:"Show 3rd-party resources",viewTreemapLabel:"View Treemap",dropdownPrintSummary:"Print Summary",dropdownPrintExpanded:"Print Expanded",dropdownCopyJSON:"Copy JSON",dropdownSaveHTML:"Save as HTML",dropdownSaveJSON:"Save as JSON",dropdownViewer:"Open in Viewer",dropdownSaveGist:"Save as Gist",dropdownDarkTheme:"Toggle Dark Theme",runtimeSettingsTitle:"Runtime Settings",runtimeSettingsUrl:"URL",runtimeSettingsFetchTime:"Fetch Time",runtimeSettingsDevice:"Device",runtimeSettingsNetworkThrottling:"Network throttling",runtimeSettingsCPUThrottling:"CPU throttling",runtimeSettingsChannel:"Channel",runtimeSettingsUA:"User agent (host)",runtimeSettingsUANetwork:"User agent (network)",runtimeSettingsBenchmark:"CPU/Memory Power",runtimeSettingsAxeVersion:"Axe version",footerIssue:"File an issue",runtimeNoEmulation:"No emulation",runtimeMobileEmulation:"Emulated Moto G4",runtimeDesktopEmulation:"Emulated Desktop",runtimeUnknown:"Unknown",throttlingProvided:"Provided by environment"},a.UIStrings;
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class l{constructor(e){this._document=e,this._lighthouseChannel="unknown"}createElement(e,t,n={}){const i=this._document.createElement(e);return t&&(i.className=t),Object.keys(n).forEach((e=>{const t=n[e];void 0!==t&&i.setAttribute(e,t)})),i}createElementNS(e,t,n,i={}){const r=this._document.createElementNS(e,t);return n&&(r.className=n),Object.keys(i).forEach((e=>{const t=i[e];void 0!==t&&r.setAttribute(e,t)})),r}createFragment(){return this._document.createDocumentFragment()}createChildOf(e,t,n,i){const r=this.createElement(t,n,i);return e.appendChild(r),r}cloneTemplate(e,t){const n=t.querySelector(e);if(!n)throw new Error(`Template not found: template${e}`);const i=this._document.importNode(n.content,!0);return n.hasAttribute("data-stamped")&&this.findAll("style",i).forEach((e=>e.remove())),n.setAttribute("data-stamped","true"),i}resetTemplates(){this.findAll("template[data-stamped]",this._document).forEach((e=>{e.removeAttribute("data-stamped")}))}convertMarkdownLinkSnippets(e){const t=this.createElement("span");for(const n of a.splitMarkdownLink(e)){if(!n.isLink){t.appendChild(this._document.createTextNode(n.text));continue}const e=new URL(n.linkHref);["https://developers.google.com","https://web.dev"].includes(e.origin)&&(e.searchParams.set("utm_source","lighthouse"),e.searchParams.set("utm_medium",this._lighthouseChannel));const i=this.createElement("a");i.rel="noopener",i.target="_blank",i.textContent=n.text,i.href=e.href,t.appendChild(i)}return t}convertMarkdownCodeSnippets(e){const t=this.createElement("span");for(const n of a.splitMarkdownCodeSpans(e))if(n.isCode){const e=this.createElement("code");e.textContent=n.text,t.appendChild(e)}else t.appendChild(this._document.createTextNode(n.text));return t}setLighthouseChannel(e){this._lighthouseChannel=e}document(){return this._document}isDevTools(){return!!this._document.querySelector(".lh-devtools")}find(e,t){const n=t.querySelector(e);if(null===n)throw new Error(`query ${e} not found`);return n}findAll(e,t){return Array.from(t.querySelectorAll(e))}}
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class d{constructor(e){this.el=e,this._id=void 0}log(e,t=!0){this._id&&clearTimeout(this._id),this.el.textContent=e,this.el.classList.add("show"),t&&(this._id=setTimeout((e=>{this.el.classList.remove("show")}),7e3))}warn(e){this.log("Warning: "+e)}error(e){this.log(e),setTimeout((t=>{throw new Error(e)}),0)}hide(){this._id&&clearTimeout(this._id),this.el.classList.remove("show")}}
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class c{constructor(e,t){this.dom=e,this.detailsRenderer=t,this.templateContext=this.dom.document(),this.detailsRenderer.setTemplateContext(this.templateContext)}get _clumpTitles(){return{warning:a.i18n.strings.warningAuditsGroupTitle,manual:a.i18n.strings.manualAuditsGroupTitle,passed:a.i18n.strings.passedAuditsGroupTitle,notApplicable:a.i18n.strings.notApplicableAuditsGroupTitle}}renderAudit(e){const t=this.dom.cloneTemplate("#tmpl-lh-audit",this.templateContext);return this.populateAuditValues(e,t)}populateAuditValues(e,t){const n=a.i18n.strings,i=this.dom.find(".lh-audit",t);i.id=e.result.id;const r=e.result.scoreDisplayMode;e.result.displayValue&&(this.dom.find(".lh-audit__display-text",i).textContent=e.result.displayValue);const s=this.dom.find(".lh-audit__title",i);s.appendChild(this.dom.convertMarkdownCodeSnippets(e.result.title));const o=this.dom.find(".lh-audit__description",i);o.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description));for(const t of e.relevantMetrics||[]){this.dom.createChildOf(o,"span","lh-audit__adorn",{title:`Relevant to ${t.result.title}`}).textContent=t.acronym||t.id}e.stackPacks&&e.stackPacks.forEach((e=>{const t=this.dom.createElement("div");t.classList.add("lh-audit__stackpack");const n=this.dom.createElement("img");n.classList.add("lh-audit__stackpack__img"),n.src=e.iconDataURL,n.alt=e.title,t.appendChild(n),t.appendChild(this.dom.convertMarkdownLinkSnippets(e.description)),this.dom.find(".lh-audit__stackpacks",i).appendChild(t)}));const l=this.dom.find("details",i);if(e.result.details){const t=this.detailsRenderer.render(e.result.details);t&&(t.classList.add("lh-details"),l.appendChild(t))}if(this.dom.find(".lh-chevron-container",i).appendChild(this._createChevron()),this._setRatingClass(i,e.result.score,r),"error"===e.result.scoreDisplayMode){i.classList.add("lh-audit--error");const t=this.dom.find(".lh-audit__display-text",i);t.textContent=n.errorLabel,t.classList.add("tooltip-boundary");this.dom.createChildOf(t,"div","tooltip tooltip--error").textContent=e.result.errorMessage||n.errorMissingAuditInfo}else if(e.result.explanation){this.dom.createChildOf(s,"div","lh-audit-explanation").textContent=e.result.explanation}const d=e.result.warnings;if(!d||0===d.length)return i;const c=this.dom.find("summary",l),h=this.dom.createChildOf(c,"div","lh-warnings");if(this.dom.createChildOf(h,"span").textContent=n.warningHeader,1===d.length)h.appendChild(this.dom.document().createTextNode(d.join("")));else{const e=this.dom.createChildOf(h,"ul");for(const t of d){this.dom.createChildOf(e,"li").textContent=t}}return i}_createChevron(){const e=this.dom.cloneTemplate("#tmpl-lh-chevron",this.templateContext);return this.dom.find("svg.lh-chevron",e)}_setRatingClass(e,t,n){const i=a.calculateRating(t,n);return e.classList.add(`lh-audit--${n.toLowerCase()}`),"informative"!==n&&e.classList.add(`lh-audit--${i}`),e}renderCategoryHeader(e,t){const n=this.dom.cloneTemplate("#tmpl-lh-category-header",this.templateContext),i=this.dom.find(".lh-score__gauge",n),r=this.renderScoreGauge(e,t);if(i.appendChild(r),e.description){const t=this.dom.convertMarkdownLinkSnippets(e.description);this.dom.find(".lh-category-header__description",n).appendChild(t)}return n}renderAuditGroup(e){const t=this.dom.createElement("div","lh-audit-group"),n=this.dom.createElement("div","lh-audit-group__header");if(this.dom.createChildOf(n,"span","lh-audit-group__title").textContent=e.title,e.description){const t=this.dom.convertMarkdownLinkSnippets(e.description);t.classList.add("lh-audit-group__description"),n.appendChild(t)}return t.appendChild(n),t}_renderGroupedAudits(e,t){const n=new Map,i="NotAGroup";n.set(i,[]);for(const t of e){const e=t.group||i,r=n.get(e)||[];r.push(t),n.set(e,r)}const r=[];for(const[e,s]of n){if(e===i){for(const e of s)r.push(this.renderAudit(e));continue}const n=t[e],o=this.renderAuditGroup(n);for(const e of s)o.appendChild(this.renderAudit(e));o.classList.add(`lh-audit-group--${e}`),r.push(o)}return r}renderUnexpandableClump(e,t){const n=this.dom.createElement("div");return this._renderGroupedAudits(e,t).forEach((e=>n.appendChild(e))),n}renderClump(e,{auditRefs:t,description:n}){const i=this.dom.cloneTemplate("#tmpl-lh-clump",this.templateContext),r=this.dom.find(".lh-clump",i);"warning"===e&&r.setAttribute("open","");this.dom.find("div.lh-audit-group__summary",r).appendChild(this._createChevron());const s=this.dom.find(".lh-audit-group__header",r),o=this._clumpTitles[e];if(this.dom.find(".lh-audit-group__title",s).textContent=o,n){const e=this.dom.convertMarkdownLinkSnippets(n);e.classList.add("lh-audit-group__description"),s.appendChild(e)}this.dom.find(".lh-audit-group__itemcount",r).textContent=`(${t.length})`;const a=t.map(this.renderAudit.bind(this));return r.append(...a),r.classList.add(`lh-clump--${e.toLowerCase()}`),r}setTemplateContext(e){this.templateContext=e,this.detailsRenderer.setTemplateContext(e)}renderScoreGauge(e,t){const n=this.dom.cloneTemplate("#tmpl-lh-gauge",this.templateContext),i=this.dom.find("a.lh-gauge__wrapper",n);i.href=`#${e.id}`,a.isPluginCategory(e.id)&&i.classList.add("lh-gauge__wrapper--plugin");const r=Number(e.score),s=this.dom.find(".lh-gauge",n),o=this.dom.find("circle.lh-gauge-arc",s);o&&this._setGaugeArc(o,r);const l=Math.round(100*r),d=this.dom.find("div.lh-gauge__percentage",n);return d.textContent=l.toString(),null===e.score&&(d.textContent="?",d.title=a.i18n.strings.errorLabel),0===e.auditRefs.length||this.hasApplicableAudits(e)?i.classList.add(`lh-gauge__wrapper--${a.calculateRating(e.score)}`):(i.classList.add("lh-gauge__wrapper--not-applicable"),d.textContent="-",d.title=a.i18n.strings.notApplicableAuditsGroupTitle),this.dom.find(".lh-gauge__label",n).textContent=e.title,n}hasApplicableAudits(e){return e.auditRefs.some((e=>"notApplicable"!==e.result.scoreDisplayMode))}_setGaugeArc(e,t){const n=2*Math.PI*Number(e.getAttribute("r")),i=Number(e.getAttribute("stroke-width")),r=.25*i/n;e.style.transform=`rotate(${360*r-90}deg)`;let s=t*n-i/2;0===t&&(e.style.opacity="0"),1===t&&(s=n),e.style.strokeDasharray=`${Math.max(s,0)} ${n}`}_auditHasWarning(e){return Boolean(e.result.warnings&&e.result.warnings.length)}_getClumpIdForAuditRef(e){const t=e.result.scoreDisplayMode;return"manual"===t||"notApplicable"===t?t:a.showAsPassed(e.result)?this._auditHasWarning(e)?"warning":"passed":"failed"}render(e,t={}){const n=this.dom.createElement("div","lh-category");this.createPermalinkSpan(n,e.id),n.appendChild(this.renderCategoryHeader(e,t));const i=new Map;i.set("failed",[]),i.set("warning",[]),i.set("manual",[]),i.set("passed",[]),i.set("notApplicable",[]);for(const t of e.auditRefs){const e=this._getClumpIdForAuditRef(t),n=i.get(e);n.push(t),i.set(e,n)}for(const[r,s]of i){if(0===s.length)continue;if("failed"===r){const e=this.renderUnexpandableClump(s,t);e.classList.add("lh-clump--failed"),n.appendChild(e);continue}const i="manual"===r?e.manualDescription:void 0,o=this.renderClump(r,{auditRefs:s,description:i});n.appendChild(o)}return n}createPermalinkSpan(e,t){this.dom.createChildOf(e,"span","lh-permalink").id=t}}
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class h{static initTree(e){let t=0;const n=Object.keys(e);if(n.length>0){t=e[n[0]].request.startTime}return{tree:e,startTime:t,transferSize:0}}static createSegment(e,t,n,i,r,s){const o=e[t],a=Object.keys(e),l=a.indexOf(t)===a.length-1,d=!!o.children&&Object.keys(o.children).length>0,c=Array.isArray(r)?r.slice(0):[];return void 0!==s&&c.push(!s),{node:o,isLastChild:l,hasChildren:d,startTime:n,transferSize:i+o.request.transferSize,treeMarkers:c}}static createChainNode(e,t,n,i){const r=e.cloneTemplate("#tmpl-lh-crc__chains",t);e.find(".crc-node",r).setAttribute("title",n.node.request.url);const s=e.find(".crc-node__tree-marker",r);n.treeMarkers.forEach((t=>{t?(s.appendChild(e.createElement("span","tree-marker vert")),s.appendChild(e.createElement("span","tree-marker"))):(s.appendChild(e.createElement("span","tree-marker")),s.appendChild(e.createElement("span","tree-marker")))})),n.isLastChild?(s.appendChild(e.createElement("span","tree-marker up-right")),s.appendChild(e.createElement("span","tree-marker right"))):(s.appendChild(e.createElement("span","tree-marker vert-right")),s.appendChild(e.createElement("span","tree-marker right"))),n.hasChildren?s.appendChild(e.createElement("span","tree-marker horiz-down")):s.appendChild(e.createElement("span","tree-marker right"));const o=n.node.request.url,l=i.renderTextURL(o),d=e.find(".crc-node__tree-value",r);if(d.appendChild(l),!n.hasChildren){const{startTime:t,endTime:i,transferSize:r}=n.node.request,s=e.createElement("span","crc-node__chain-duration");s.textContent=" - "+a.i18n.formatMilliseconds(1e3*(i-t))+", ";const o=e.createElement("span","crc-node__chain-duration");o.textContent=a.i18n.formatBytesToKiB(r,.01),d.appendChild(s),d.appendChild(o)}return r}static buildTree(e,t,n,i,r,s){if(i.appendChild(u.createChainNode(e,t,n,s)),n.node.children)for(const o of Object.keys(n.node.children)){const a=u.createSegment(n.node.children,o,n.startTime,n.transferSize,n.treeMarkers,n.isLastChild);u.buildTree(e,t,a,i,r,s)}}static render(e,t,n,i){const r=e.cloneTemplate("#tmpl-lh-crc",t),s=e.find(".lh-crc",r);e.find(".crc-initial-nav",r).textContent=a.i18n.strings.crcInitialNavigation,e.find(".lh-crc__longest_duration_label",r).textContent=a.i18n.strings.crcLongestDurationLabel,e.find(".lh-crc__longest_duration",r).textContent=a.i18n.formatMilliseconds(n.longestChain.duration);const o=u.initTree(n.chains);for(const t of Object.keys(o.tree)){const a=u.createSegment(o.tree,t,o.startTime,o.transferSize);u.buildTree(e,r,a,s,n,i)}return e.find(".lh-crc-container",r)}}const u=h,p=0,m=1,g=2,f=0,_=1,y=2,b=3,C={[f]:["lh-snippet__line--content"],[_]:["lh-snippet__line--content","lh-snippet__line--content-highlighted"],[y]:["lh-snippet__line--placeholder"],[b]:["lh-snippet__line--message"]};
/**
* @license Copyright 2019 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/function v(e,t){return{line:e.find((e=>e.lineNumber===t)),previousLine:e.find((e=>e.lineNumber===t-1))}}function w(e,t){return e.filter((e=>e.lineNumber===t))}function S(e){return a.filterRelevantLines(e.lines,e.lineMessages,2)}class k{static renderHeader(e,t,n,i,r){const s=S(n).length<n.lines.length,o=e.cloneTemplate("#tmpl-lh-snippet__header",t);e.find(".lh-snippet__title",o).textContent=n.title;const{snippetCollapseButtonLabel:l,snippetExpandButtonLabel:d}=a.i18n.strings;e.find(".lh-snippet__btn-label-collapse",o).textContent=l,e.find(".lh-snippet__btn-label-expand",o).textContent=d;const c=e.find(".lh-snippet__toggle-expand",o);if(s?c.addEventListener("click",(()=>r())):c.remove(),n.node&&e.isDevTools()){e.find(".lh-snippet__node",o).appendChild(i.renderNode(n.node))}return o}static renderSnippetLine(e,t,{content:n,lineNumber:i,truncated:r,contentType:s,visibility:o}){const a=e.cloneTemplate("#tmpl-lh-snippet__line",t),l=e.find(".lh-snippet__line",a),{classList:d}=l;C[s].forEach((e=>d.add(e))),o===m?d.add("lh-snippet__show-if-collapsed"):o===g&&d.add("lh-snippet__show-if-expanded");const c=n+(r?"…":""),h=e.find(".lh-snippet__line code",l);return s===b?h.appendChild(e.convertMarkdownLinkSnippets(c)):h.textContent=c,e.find(".lh-snippet__line-number",l).textContent=i.toString(),l}static renderMessage(e,t,n){return k.renderSnippetLine(e,t,{lineNumber:" ",content:n.message,contentType:b})}static renderOmittedLinesPlaceholder(e,t,n){return k.renderSnippetLine(e,t,{lineNumber:"…",content:"",visibility:n,contentType:y})}static renderSnippetContent(e,t,n){const i=e.cloneTemplate("#tmpl-lh-snippet__content",t),r=e.find(".lh-snippet__snippet-inner",i);return n.generalMessages.forEach((n=>r.append(k.renderMessage(e,t,n)))),r.append(k.renderSnippetLines(e,t,n)),i}static renderSnippetLines(e,t,n){const{lineMessages:i,generalMessages:r,lineCount:s,lines:o}=n,a=S(n),l=r.length>0&&0===i.length,d=e.createFragment();let c=!1;for(let n=1;n<=s;n++){const{line:r,previousLine:s}=v(o,n),{line:h,previousLine:u}=v(a,n),y=!!h;!!u&&!y&&(c=!0),y&&c&&(d.append(k.renderOmittedLinesPlaceholder(e,t,m)),c=!1);const b=!r&&1===n;if(!r&&!!s||b){const i=!a.some((e=>e.lineNumber>n))||1===n;d.append(k.renderOmittedLinesPlaceholder(e,t,i?g:p)),c=!1}if(!r)continue;const C=w(i,n),S=C.length>0||l,x=Object.assign({},r,{contentType:S?_:f,visibility:h?p:g});d.append(k.renderSnippetLine(e,t,x)),C.forEach((n=>{d.append(k.renderMessage(e,t,n))}))}return d}static render(e,t,n,i){const r=e.cloneTemplate("#tmpl-lh-snippet",t),s=e.find(".lh-snippet",r),o=k.renderHeader(e,r,n,i,(()=>s.classList.toggle("lh-snippet--expanded"))),a=k.renderSnippetContent(e,r,n);return s.append(o,a),s}}
/**
* @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/function x(e,t,n){return e<t?t:e>n?n:e}class T{static getScreenshotPositions(e,t,n){const i={x:(r=e).left+r.width/2,y:r.top+r.height/2};var r;const s=x(i.x-t.width/2,0,n.width-t.width),o=x(i.y-t.height/2,0,n.height-t.height);return{screenshot:{left:s,top:o},clip:{left:e.left-s,top:e.top-o}}}static renderClipPathInScreenshot(e,t,n,i,r){const s=e.find("clipPath",t),o=`clip-${a.getUniqueSuffix()}`;s.id=o,t.style.clipPath=`url(#${o})`;const l=n.top/r.height,d=l+i.height/r.height,c=n.left/r.width,h=c+i.width/r.width,u=[`0,0 1,0 1,${l} 0,${l}`,`0,${d} 1,${d} 1,1 0,1`,`0,${l} ${c},${l} ${c},${d} 0,${d}`,`${h},${l} 1,${l} 1,${d} ${h},${d}`];for(const t of u)s.append(e.createElementNS("http://www.w3.org/2000/svg","polygon",void 0,{points:t}))}static installFullPageScreenshot(e,t){e.style.setProperty("--element-screenshot-url",`url(${t.data})`)}static installOverlayFeature(e){const{dom:t,reportEl:n,overlayContainerEl:i,templateContext:r,fullPageScreenshot:s}=e,o="lh-screenshot-overlay--enabled";n.classList.contains(o)||(n.classList.add(o),n.addEventListener("click",(e=>{const n=e.target;if(!n)return;const o=n.closest(".lh-node > .lh-element-screenshot");if(!o)return;const a=t.createElement("div","lh-element-screenshot__overlay");i.append(a);const l={width:.95*a.clientWidth,height:.8*a.clientHeight},d={width:Number(o.dataset.rectWidth),height:Number(o.dataset.rectHeight),left:Number(o.dataset.rectLeft),right:Number(o.dataset.rectLeft)+Number(o.dataset.rectWidth),top:Number(o.dataset.rectTop),bottom:Number(o.dataset.rectTop)+Number(o.dataset.rectHeight)},c=T.render(t,r,s.screenshot,d,l);c?(a.appendChild(c),a.addEventListener("click",(()=>a.remove()))):a.remove()})))}static _computeZoomFactor(e,t){const n={x:t.width/e.width,y:t.height/e.height},i=.75*Math.min(n.x,n.y);return Math.min(1,i)}static render(e,t,n,i,r){if(!function(e,t){return t.left<=e.width&&0<=t.right&&t.top<=e.height&&0<=t.bottom}(n,i))return null;const s=e.cloneTemplate("#tmpl-lh-element-screenshot",t),o=e.find("div.lh-element-screenshot",s);o.dataset.rectWidth=i.width.toString(),o.dataset.rectHeight=i.height.toString(),o.dataset.rectLeft=i.left.toString(),o.dataset.rectTop=i.top.toString();const a=this._computeZoomFactor(i,r),l={width:r.width/a,height:r.height/a};l.width=Math.min(n.width,l.width);const d=l.width*a,c=l.height*a,h=T.getScreenshotPositions(i,l,{width:n.width,height:n.height});e.find("div.lh-element-screenshot__content",o).style.top=`-${c}px`;const u=e.find("div.lh-element-screenshot__image",o);u.style.width=d+"px",u.style.height=c+"px",u.style.backgroundPositionY=-h.screenshot.top*a+"px",u.style.backgroundPositionX=-h.screenshot.left*a+"px",u.style.backgroundSize=`${n.width*a}px ${n.height*a}px`;const p=e.find("div.lh-element-screenshot__element-marker",o);p.style.width=i.width*a+"px",p.style.height=i.height*a+"px",p.style.left=h.clip.left*a+"px",p.style.top=h.clip.top*a+"px";const m=e.find("div.lh-element-screenshot__mask",o);return m.style.width=d+"px",m.style.height=c+"px",T.renderClipPathInScreenshot(e,m,h.clip,i,l),o}}
/**
* @license
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const L=["http://","https://","data:"];class E{constructor(e,t={}){this._dom=e,this._fullPageScreenshot=t.fullPageScreenshot,this._templateContext}setTemplateContext(e){this._templateContext=e}render(e){switch(e.type){case"filmstrip":return this._renderFilmstrip(e);case"list":return this._renderList(e);case"table":return this._renderTable(e);case"criticalrequestchain":return h.render(this._dom,this._templateContext,e,this);case"opportunity":return this._renderTable(e);case"screenshot":case"debugdata":case"full-page-screenshot":case"treemap-data":return null;default:return this._renderUnknown(e.type,e)}}_renderBytes(e){const t=a.i18n.formatBytesToKiB(e.value,e.granularity),n=this._renderText(t);return n.title=a.i18n.formatBytes(e.value),n}_renderMilliseconds(e){let t=a.i18n.formatMilliseconds(e.value,e.granularity);return"duration"===e.displayUnit&&(t=a.i18n.formatDuration(e.value)),this._renderText(t)}renderTextURL(e){const t=e;let n,i,r;try{const e=a.parseURL(t);n="/"===e.file?e.origin:e.file,i="/"===e.file||""===e.hostname?"":`(${e.hostname})`,r=t}catch(e){n=t}const s=this._dom.createElement("div","lh-text__url");if(s.appendChild(this._renderLink({text:n,url:t})),i){const e=this._renderText(i);e.classList.add("lh-text__url-host"),s.appendChild(e)}return r&&(s.title=t,s.dataset.url=t),s}_renderLink(e){let t;try{t=new URL(e.url)}catch(e){}if(!t||!["https:","http:"].includes(t.protocol)){const t=this._renderText(e.text);return t.classList.add("lh-link"),t}const n=this._dom.createElement("a");return n.rel="noopener",n.target="_blank",n.textContent=e.text,n.href=t.href,n.classList.add("lh-link"),n}_renderText(e){const t=this._dom.createElement("div","lh-text");return t.textContent=e,t}_renderNumeric(e){const t=a.i18n.formatNumber(e.value,e.granularity),n=this._dom.createElement("div","lh-numeric");return n.textContent=t,n}_renderThumbnail(e){const t=this._dom.createElement("img","lh-thumbnail"),n=e;return t.src=n,t.title=n,t.alt="",t}_renderUnknown(e,t){console.error(`Unknown details type: ${e}`,t);const n=this._dom.createElement("details","lh-unknown");return this._dom.createChildOf(n,"summary").textContent=`We don't know how to render audit details of type \`${e}\`. The Lighthouse version that collected this data is likely newer than the Lighthouse version of the report renderer. Expand for the raw JSON.`,this._dom.createChildOf(n,"pre").textContent=JSON.stringify(t,null,2),n}_renderTableValue(e,t){if(null==e)return null;if("object"==typeof e)switch(e.type){case"code":return this._renderCode(e.value);case"link":return this._renderLink(e);case"node":return this.renderNode(e);case"numeric":return this._renderNumeric(e);case"source-location":return this.renderSourceLocation(e);case"url":return this.renderTextURL(e.value);default:return this._renderUnknown(e.type,e)}switch(t.valueType){case"bytes":{const n=Number(e);return this._renderBytes({value:n,granularity:t.granularity})}case"code":{const t=String(e);return this._renderCode(t)}case"ms":{const n={value:Number(e),granularity:t.granularity,displayUnit:t.displayUnit};return this._renderMilliseconds(n)}case"numeric":{const n=Number(e);return this._renderNumeric({value:n,granularity:t.granularity})}case"text":{const t=String(e);return this._renderText(t)}case"thumbnail":{const t=String(e);return this._renderThumbnail(t)}case"timespanMs":{const t=Number(e);return this._renderMilliseconds({value:t})}case"url":{const t=String(e);return L.some((e=>t.startsWith(e)))?this.renderTextURL(t):this._renderCode(t)}default:return this._renderUnknown(t.valueType,e)}}_getCanonicalizedHeadingsFromTable(e){return"opportunity"===e.type?e.headings:e.headings.map((e=>this._getCanonicalizedHeading(e)))}_getCanonicalizedHeading(e){let t;return e.subItemsHeading&&(t=this._getCanonicalizedsubItemsHeading(e.subItemsHeading,e)),{key:e.key,valueType:e.itemType,subItemsHeading:t,label:e.text,displayUnit:e.displayUnit,granularity:e.granularity}}_getCanonicalizedsubItemsHeading(e,t){return e.key||console.warn("key should not be null"),{key:e.key||"",valueType:e.itemType||t.itemType,granularity:e.granularity||t.granularity,displayUnit:e.displayUnit||t.displayUnit}}_getDerivedsubItemsHeading(e){return e.subItemsHeading?{key:e.subItemsHeading.key||"",valueType:e.subItemsHeading.valueType||e.valueType,granularity:e.subItemsHeading.granularity||e.granularity,displayUnit:e.subItemsHeading.displayUnit||e.displayUnit,label:""}:null}_renderTableRow(e,t){const n=this._dom.createElement("tr");for(const i of t){if(!i||!i.key){this._dom.createChildOf(n,"td","lh-table-column--empty");continue}const t=e[i.key];let r;if(null!=t&&(r=this._renderTableValue(t,i)),r){const e=`lh-table-column--${i.valueType}`;this._dom.createChildOf(n,"td",e).appendChild(r)}else this._dom.createChildOf(n,"td","lh-table-column--empty")}return n}_renderTableRowsFromItem(e,t){const n=this._dom.createFragment();if(n.append(this._renderTableRow(e,t)),!e.subItems)return n;const i=t.map(this._getDerivedsubItemsHeading);if(!i.some(Boolean))return n;for(const t of e.subItems.items){const e=this._renderTableRow(t,i);e.classList.add("lh-sub-item-row"),n.append(e)}return n}_renderTable(e){if(!e.items.length)return this._dom.createElement("span");const t=this._dom.createElement("table","lh-table"),n=this._dom.createChildOf(t,"thead"),i=this._dom.createChildOf(n,"tr"),r=this._getCanonicalizedHeadingsFromTable(e);for(const e of r){const t=`lh-table-column--${e.valueType||"text"}`,n=this._dom.createElement("div","lh-text");n.textContent=e.label,this._dom.createChildOf(i,"th",t).appendChild(n)}const s=this._dom.createChildOf(t,"tbody");let o=!0;for(const t of e.items){const e=this._renderTableRowsFromItem(t,r);for(const t of this._dom.findAll("tr",e))t.classList.add(o?"lh-row--even":"lh-row--odd");o=!o,s.append(e)}return t}_renderList(e){const t=this._dom.createElement("div","lh-list");return e.items.forEach((e=>{const n=k.render(this._dom,this._templateContext,e,this);t.appendChild(n)})),t}renderNode(e){const t=this._dom.createElement("span","lh-node");if(e.nodeLabel){const n=this._dom.createElement("div");n.textContent=e.nodeLabel,t.appendChild(n)}if(e.snippet){const n=this._dom.createElement("div");n.classList.add("lh-node__snippet"),n.textContent=e.snippet,t.appendChild(n)}if(e.selector&&(t.title=e.selector),e.path&&t.setAttribute("data-path",e.path),e.selector&&t.setAttribute("data-selector",e.selector),e.snippet&&t.setAttribute("data-snippet",e.snippet),!this._fullPageScreenshot)return t;const n=e.lhId&&this._fullPageScreenshot.nodes[e.lhId];if(!n||0===n.width||0===n.height)return t;const i=T.render(this._dom,this._templateContext,this._fullPageScreenshot.screenshot,n,{width:147,height:100});return i&&t.prepend(i),t}renderSourceLocation(e){if(!e.url)return null;const t=`${e.url}:${e.line+1}:${e.column}`;let n,i;if(e.original){n=`${e.original.file||"<unmapped>"}:${e.original.line+1}:${e.original.column}`}if("network"===e.urlProvider&&n)i=this._renderLink({url:e.url,text:n}),i.title=`maps to generated location ${t}`;else if("network"!==e.urlProvider||n)if("comment"===e.urlProvider&&n)i=this._renderText(`${n} (from source map)`),i.title=`${t} (from sourceURL)`;else{if("comment"!==e.urlProvider||n)return null;i=this._renderText(`${t} (from sourceURL)`)}else i=this.renderTextURL(e.url),this._dom.find(".lh-link",i).textContent+=`:${e.line+1}:${e.column}`;return i.classList.add("lh-source-location"),i.setAttribute("data-source-url",e.url),i.setAttribute("data-source-line",String(e.line)),i.setAttribute("data-source-column",String(e.column)),i}_renderFilmstrip(e){const t=this._dom.createElement("div","lh-filmstrip");for(const n of e.items){const e=this._dom.createChildOf(t,"div","lh-filmstrip__frame");this._dom.createChildOf(e,"img","lh-filmstrip__thumbnail",{src:n.data,alt:"Screenshot"})}return t}_renderCode(e){const t=this._dom.createElement("pre","lh-code");return t.textContent=e,t}}
/**
* @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/const A=1024;class M{constructor(e,t){"en-XA"===e&&(e="de"),this._numberDateLocale=e,this._numberFormatter=new Intl.NumberFormat(e),this._percentFormatter=new Intl.NumberFormat(e,{style:"percent"}),this._strings=t}get strings(){return this._strings}formatNumber(e,t=.1){const n=Math.round(e/t)*t;return this._numberFormatter.format(n)}formatPercent(e){return this._percentFormatter.format(e)}formatBytesToKiB(e,t=.1){return`${this._byteFormatterForGranularity(t).format(Math.round(e/1024/t)*t)} KiB`}formatBytesToMiB(e,t=.1){return`${this._byteFormatterForGranularity(t).format(Math.round(e/1048576/t)*t)} MiB`}formatBytes(e,t=1){return`${this._byteFormatterForGranularity(t).format(Math.round(e/t)*t)} bytes`}formatBytesWithBestUnit(e,t=.1){return e>=1048576?this.formatBytesToMiB(e,t):e>=A?this.formatBytesToKiB(e,t):this.formatNumber(e,t)+" B"}_byteFormatterForGranularity(e){let t=0;return e<1&&(t=-Math.floor(Math.log10(e))),new Intl.NumberFormat(this._numberDateLocale,{...this._numberFormatter.resolvedOptions(),maximumFractionDigits:t,minimumFractionDigits:t})}formatMilliseconds(e,t=10){const n=Math.round(e/t)*t;return 0===n?`${this._numberFormatter.format(0)} ms`:`${this._numberFormatter.format(n)} ms`}formatSeconds(e,t=.1){const n=Math.round(e/1e3/t)*t;return`${this._numberFormatter.format(n)} s`}formatDateTime(e){const t={month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",timeZoneName:"short"};let n;try{n=new Intl.DateTimeFormat(this._numberDateLocale,t)}catch(e){t.timeZone="UTC",n=new Intl.DateTimeFormat(this._numberDateLocale,t)}return n.format(new Date(e))}formatDuration(e){let t=e/1e3;if(0===Math.round(t))return"None";const n=[],i={d:86400,h:3600,m:60,s:1};return Object.keys(i).forEach((e=>{const r=i[e],s=Math.floor(t/r);s>0&&(t-=s*r,n.push(`${s} ${e}`))})),n.join(" ")}}
/**
* @license
* Copyright 2018 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class D extends c{_renderMetric(e){const t=this.dom.cloneTemplate("#tmpl-lh-metric",this.templateContext),n=this.dom.find(".lh-metric",t);n.id=e.result.id;const i=a.calculateRating(e.result.score,e.result.scoreDisplayMode);n.classList.add(`lh-metric--${i}`);this.dom.find(".lh-metric__title",t).textContent=e.result.title;const r=this.dom.find(".lh-metric__value",t);r.textContent=e.result.displayValue||"";const s=this.dom.find(".lh-metric__description",t);if(s.appendChild(this.dom.convertMarkdownLinkSnippets(e.result.description)),"error"===e.result.scoreDisplayMode){s.textContent="",r.textContent="Error!";this.dom.createChildOf(s,"span").textContent=e.result.errorMessage||"Report error: no metric information"}return n}_renderOpportunity(e,t){const n=this.dom.cloneTemplate("#tmpl-lh-opportunity",this.templateContext),i=this.populateAuditValues(e,n);if(i.id=e.result.id,!e.result.details||"error"===e.result.scoreDisplayMode)return i;const r=e.result.details;if("opportunity"!==r.type)return i;const s=this.dom.find("span.lh-audit__display-text, div.lh-audit__display-text",i),o=r.overallSavingsMs/t*100+"%";if(this.dom.find("div.lh-sparkline__bar",i).style.width=o,s.textContent=a.i18n.formatSeconds(r.overallSavingsMs,.01),e.result.displayValue){const t=e.result.displayValue;this.dom.find("div.lh-load-opportunity__sparkline",i).title=t,s.title=t}return i}_getWastedMs(e){if(e.result.details&&"opportunity"===e.result.details.type){const t=e.result.details;if("number"!=typeof t.overallSavingsMs)throw new Error("non-opportunity details passed to _getWastedMs");return t.overallSavingsMs}return Number.MIN_VALUE}_getScoringCalculatorHref(e){const t=e.filter((e=>"metrics"===e.group)),n=e.find((e=>"first-cpu-idle"===e.id)),i=e.find((e=>"first-meaningful-paint"===e.id));n&&t.push(n),i&&t.push(i);const r=[...t.map((e=>{let t;var n;return"number"==typeof e.result.numericValue?(t="cumulative-layout-shift"===e.id?(n=e.result.numericValue,Math.round(100*n)/100):Math.round(e.result.numericValue),t=t.toString()):t="null",[e.acronym||e.id,t]}))];a.reportJson&&(r.push(["device",a.reportJson.configSettings.formFactor]),r.push(["version",a.reportJson.lighthouseVersion]));const s=new URLSearchParams(r),o=new URL("https://googlechrome.github.io/lighthouse/scorecalc/");return o.hash=s.toString(),o.href}render(e,t,n){const i=a.i18n.strings,r=this.dom.createElement("div","lh-category");if("PSI"===n){const n=this.dom.createElement("div","lh-score__gauge");n.appendChild(this.renderScoreGauge(e,t)),r.appendChild(n)}else this.createPermalinkSpan(r,e.id),r.appendChild(this.renderCategoryHeader(e,t));const s=this.renderAuditGroup(t.metrics),o=this.dom.cloneTemplate("#tmpl-lh-metrics-toggle",this.templateContext),l=this.dom.find(".lh-metrics-toggle",o);s.append(...l.childNodes);const d=e.auditRefs.filter((e=>"metrics"===e.group)),c=this.dom.createChildOf(s,"div","lh-metrics-container");d.forEach((e=>{c.appendChild(this._renderMetric(e))}));const h=this.dom.createChildOf(s,"div","lh-metrics__disclaimer"),u=this.dom.convertMarkdownLinkSnippets(i.varianceDisclaimer);h.appendChild(u);const p=this.dom.createChildOf(h,"a","lh-calclink");p.target="_blank",p.textContent=i.calculatorLink,p.href=this._getScoringCalculatorHref(e.auditRefs),s.classList.add("lh-audit-group--metrics"),r.appendChild(s);const m=this.dom.createChildOf(r,"div","lh-filmstrip-container"),g=e.auditRefs.find((e=>"screenshot-thumbnails"===e.id)),f=g&&g.result;if(f&&f.details){m.id=f.id;const e=this.detailsRenderer.render(f.details);e&&m.appendChild(e)}const _=e.auditRefs.filter((e=>"load-opportunities"===e.group&&!a.showAsPassed(e.result))).sort(((e,t)=>this._getWastedMs(t)-this._getWastedMs(e))),y=d.filter((e=>!!e.relevantAudits));if(y.length&&this.renderMetricAuditFilter(y,r),_.length){const e=2e3,n=_.map((e=>this._getWastedMs(e))),s=Math.max(...n),o=Math.max(1e3*Math.ceil(s/1e3),e),a=this.renderAuditGroup(t["load-opportunities"]),l=this.dom.cloneTemplate("#tmpl-lh-opportunity-header",this.templateContext);this.dom.find(".lh-load-opportunity__col--one",l).textContent=i.opportunityResourceColumnLabel,this.dom.find(".lh-load-opportunity__col--two",l).textContent=i.opportunitySavingsColumnLabel;const d=this.dom.find(".lh-load-opportunity__header",l);a.appendChild(d),_.forEach((e=>a.appendChild(this._renderOpportunity(e,o)))),a.classList.add("lh-audit-group--load-opportunities"),r.appendChild(a)}const b=e.auditRefs.filter((e=>"diagnostics"===e.group&&!a.showAsPassed(e.result))).sort(((e,t)=>("informative"===e.result.scoreDisplayMode?100:Number(e.result.score))-("informative"===t.result.scoreDisplayMode?100:Number(t.result.score))));if(b.length){const e=this.renderAuditGroup(t.diagnostics);b.forEach((t=>e.appendChild(this.renderAudit(t)))),e.classList.add("lh-audit-group--diagnostics"),r.appendChild(e)}const C=e.auditRefs.filter((e=>("load-opportunities"===e.group||"diagnostics"===e.group)&&a.showAsPassed(e.result)));if(!C.length)return r;const v={auditRefs:C,groupDefinitions:t},w=this.renderClump("passed",v);r.appendChild(w);const S=[];if(["performance-budget","timing-budget"].forEach((t=>{const n=e.auditRefs.find((e=>e.id===t));if(n&&n.result.details){const e=this.detailsRenderer.render(n.result.details);e&&(e.id=t,e.classList.add("lh-audit"),S.push(e))}})),S.length>0){const e=this.renderAuditGroup(t.budgets);S.forEach((t=>e.appendChild(t))),e.classList.add("lh-audit-group--budgets"),r.appendChild(e)}return r}renderMetricAuditFilter(e,t){const n=this.dom.createElement("div","lh-metricfilter");this.dom.createChildOf(n,"span","lh-metricfilter__text").textContent=a.i18n.strings.showRelevantAudits;const i=[{acronym:"All"},...e];for(const e of i){const i=`metric-${e.acronym}`,r=this.dom.createChildOf(n,"input","lh-metricfilter__radio",{type:"radio",name:"metricsfilter",id:i}),s=this.dom.createChildOf(n,"label","lh-metricfilter__label",{for:i,title:e.result&&e.result.title});s.textContent=e.acronym||e.id,"All"===e.acronym&&(r.checked=!0,s.classList.add("lh-metricfilter__label--active")),t.append(n),r.addEventListener("input",(n=>{for(const e of t.querySelectorAll("label.lh-metricfilter__label"))e.classList.toggle("lh-metricfilter__label--active",e.htmlFor===i);t.classList.toggle("lh-category--filtered","All"!==e.acronym);for(const n of t.querySelectorAll("div.lh-audit"))"All"!==e.acronym?(n.hidden=!0,e.relevantAudits&&e.relevantAudits.includes(n.id)&&(n.hidden=!1)):n.hidden=!1;const r=t.querySelectorAll("div.lh-audit-group, details.lh-audit-group");for(const e of r){e.hidden=!1;const t=Array.from(e.querySelectorAll("div.lh-audit")),n=!!t.length&&t.every((e=>e.hidden));e.hidden=n}}))}}}
/**
* @license
* Copyright 2018 The Lighthouse Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class R extends c{render(e,t={}){const n=this.dom.createElement("div","lh-category");this.createPermalinkSpan(n,e.id),n.appendChild(this.renderCategoryHeader(e,t));const i=e.auditRefs,r=i.filter((e=>"manual"!==e.result.scoreDisplayMode)),s=this._renderAudits(r,t);n.appendChild(s);const o=i.filter((e=>"manual"===e.result.scoreDisplayMode)),a=this.renderClump("manual",{auditRefs:o,description:e.manualDescription});return n.appendChild(a),n}renderScoreGauge(e,t){if(null===e.score)return super.renderScoreGauge(e,t);const n=this.dom.cloneTemplate("#tmpl-lh-gauge--pwa",this.templateContext),i=this.dom.find("a.lh-gauge--pwa__wrapper",n);i.href=`#${e.id}`;const r=n.querySelector("svg");if(!r)throw new Error("no SVG element found in PWA score gauge t