import*as Common from"../common/common.js";import*as SDK from"../sdk/sdk.js";import{IssuesManager}from"./IssuesManager.js";function issuesAssociatedWithNetworkRequest(s,e){return s.filter((s=>{for(const t of s.requests())if(t.requestId===e.requestId())return!0;return!1}))}function issuesAssociatedWithCookie(s,e,t,r){return s.filter((s=>{for(const o of s.cookies())if(o.domain===e&&o.name===t&&o.path===r)return!0;return!1}))}export function issuesAssociatedWith(s,e){if(e instanceof SDK.NetworkRequest.NetworkRequest)return issuesAssociatedWithNetworkRequest(s,e);if(e instanceof SDK.Cookie.Cookie)return issuesAssociatedWithCookie(s,e.domain(),e.name(),e.path());throw new Error(`issues can not be associated with ${JSON.stringify(e)}`)}export function hasIssues(s){return issuesAssociatedWith(Array.from(IssuesManager.instance().issues()),s).length>0}export function hasIssueOfCategory(s,e){return issuesAssociatedWith(Array.from(IssuesManager.instance().issues()),s).some((s=>s.getCategory()===e))}export async function reveal(s,e){const t=issuesAssociatedWith(Array.from(IssuesManager.instance().issues()),s).filter((s=>!e||s.getCategory()===e));if(t.length>0)return Common.Revealer.reveal(t[0])}