import*as i18n from"../i18n/i18n.js";import*as Platform from"../platform/platform.js";import{AffectedElementsView}from"./AffectedElementsView.js";export class AffectedElementsWithLowContrastView extends AffectedElementsView{constructor(t,e){super(t,e),this.runningUpdatePromise=Promise.resolve(),this.aggregateIssue=e}update(){this.runningUpdatePromise=this.runningUpdatePromise.then(this.doUpdate.bind(this))}async doUpdate(){this.clear(),await this.appendLowContrastElements(this.aggregateIssue.getLowContrastIssues())}async appendLowContrastElement(t){const e=document.createElement("tr");e.classList.add("affected-resource-low-contrast");const i=t.details();e.appendChild(await this.renderElementCell({nodeName:i.violatingNodeSelector,backendNodeId:i.violatingNodeId})),this.appendIssueDetailCell(e,String(Platform.NumberUtilities.floor(i.contrastRatio,2))),this.appendIssueDetailCell(e,String(i.thresholdAA)),this.appendIssueDetailCell(e,String(i.thresholdAAA)),this.appendIssueDetailCell(e,i.fontSize),this.appendIssueDetailCell(e,i.fontWeight),this.affectedResources.appendChild(e)}async appendLowContrastElements(t){const e=document.createElement("tr");this.appendColumnTitle(e,i18nString(UIStrings.element)),this.appendColumnTitle(e,i18nString(UIStrings.contrastRatio)),this.appendColumnTitle(e,i18nString(UIStrings.minimumAA)),this.appendColumnTitle(e,i18nString(UIStrings.minimumAAA)),this.appendColumnTitle(e,i18nString(UIStrings.textSize)),this.appendColumnTitle(e,i18nString(UIStrings.textWeight)),this.affectedResources.appendChild(e);let i=0;for(const n of t)i++,await this.appendLowContrastElement(n);this.updateAffectedResourceCount(i)}}const UIStrings={element:"Element",contrastRatio:"Contrast ratio",minimumAA:"Minimum AA ratio",minimumAAA:"Minimum AAA ratio",textSize:"Text size",textWeight:"Text weight"},str_=i18n.i18n.registerUIStrings("issues/AffectedElementsWithLowContrastView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);