import*as Host from"../host/host.js";import*as i18n from"../i18n/i18n.js";import*as Network from"../network/network.js";import*as UI from"../ui/ui.js";import{AffectedResourcesView}from"./AffectedResourcesView.js";const UIStrings={cookie:"cookie",cookies:"cookies",name:"Name",domain:"Domain",path:"Path"},str_=i18n.i18n.registerUIStrings("issues/AffectedCookiesView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class AffectedCookiesView extends AffectedResourcesView{constructor(e,t){super(e,{singular:i18nString(UIStrings.cookie),plural:i18nString(UIStrings.cookies)}),this.issue=t}appendAffectedCookies(e){const t=document.createElement("tr");this.appendColumnTitle(t,i18nString(UIStrings.name)),this.appendColumnTitle(t,i18nString(UIStrings.domain)+" & "+i18nString(UIStrings.path),"affected-resource-cookie-info-header"),this.affectedResources.appendChild(t);let i=0;for(const o of e)i++,this.appendAffectedCookie(o.cookie,o.hasRequest);this.updateAffectedResourceCount(i)}appendAffectedCookie(e,t){const i=document.createElement("tr");i.classList.add("affected-resource-cookie");const o=document.createElement("td");t?o.appendChild(UI.UIUtils.createTextButton(e.name,(()=>{Host.userMetrics.issuesPanelResourceOpened(this.issue.getCategory(),"Cookie"),Network.NetworkPanel.NetworkPanel.revealAndFilter([{filterType:"cookie-domain",filterValue:e.domain},{filterType:"cookie-name",filterValue:e.name},{filterType:"cookie-path",filterValue:e.path}])}),"link-style devtools-link")):o.textContent=e.name,i.appendChild(o),this.appendIssueDetailCell(i,`${e.domain}${e.path}`,"affected-resource-cookie-info"),this.affectedResources.appendChild(i)}update(){this.clear(),this.appendAffectedCookies(this.issue.cookiesWithRequestIndicator())}}