import*as i18n from"../i18n/i18n.js";import{Issue,IssueCategory,resolveLazyDescription}from"./Issue.js";const UIStrings={contentSecurityPolicySource:"Content Security Policy - Source Allowlists",contentSecurityPolicyInlineCode:"Content Security Policy - Inline Code",contentSecurityPolicyEval:"Content Security Policy - Eval",trustedTypesFixViolations:"Trusted Types - Fix violations",trustedTypesPolicyViolation:"Trusted Types - Policy violation"},str_=i18n.i18n.registerUIStrings("sdk/ContentSecurityPolicyIssue.js",UIStrings),i18nLazyString=i18n.i18n.getLazilyComputedLocalizedString.bind(void 0,str_);export class ContentSecurityPolicyIssue extends Issue{constructor(i,o){super([Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,i.contentSecurityPolicyViolationType].join("::"),o),this._issueDetails=i}getCategory(){return IssueCategory.ContentSecurityPolicy}primaryKey(){return JSON.stringify(this._issueDetails,["blockedURL","contentSecurityPolicyViolationType","violatedDirective","isReportOnly","sourceCodeLocation","url","lineNumber","columnNumber","violatingNodeId"])}getDescription(){return resolveLazyDescription(issueDescriptions.get(this._issueDetails.contentSecurityPolicyViolationType))}details(){return this._issueDetails}}const cspURLViolation={file:"issues/descriptions/cspURLViolation.md",substitutions:void 0,links:[{link:"https://developers.google.com/web/fundamentals/security/csp#source_allowlists",linkTitle:i18nLazyString(UIStrings.contentSecurityPolicySource)}]},cspInlineViolation={file:"issues/descriptions/cspInlineViolation.md",substitutions:void 0,links:[{link:"https://developers.google.com/web/fundamentals/security/csp#inline_code_is_considered_harmful",linkTitle:i18nLazyString(UIStrings.contentSecurityPolicyInlineCode)}]},cspEvalViolation={file:"issues/descriptions/cspEvalViolation.md",substitutions:void 0,links:[{link:"https://developers.google.com/web/fundamentals/security/csp#eval_too",linkTitle:i18nLazyString(UIStrings.contentSecurityPolicyEval)}]},cspTrustedTypesSinkViolation={file:"issues/descriptions/cspTrustedTypesSinkViolation.md",substitutions:void 0,links:[{link:"https://web.dev/trusted-types/#fix-the-violations",linkTitle:i18nLazyString(UIStrings.trustedTypesFixViolations)}]},cspTrustedTypesPolicyViolation={file:"issues/descriptions/cspTrustedTypesPolicyViolation.md",substitutions:void 0,links:[{link:"https://web.dev/trusted-types/",linkTitle:i18nLazyString(UIStrings.trustedTypesPolicyViolation)}]};export const urlViolationCode=[Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,Protocol.Audits.ContentSecurityPolicyViolationType.KURLViolation].join("::");export const inlineViolationCode=[Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,Protocol.Audits.ContentSecurityPolicyViolationType.KInlineViolation].join("::");export const evalViolationCode=[Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,Protocol.Audits.ContentSecurityPolicyViolationType.KEvalViolation].join("::");export const trustedTypesSinkViolationCode=[Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,Protocol.Audits.ContentSecurityPolicyViolationType.KTrustedTypesSinkViolation].join("::");export const trustedTypesPolicyViolationCode=[Protocol.Audits.InspectorIssueCode.ContentSecurityPolicyIssue,Protocol.Audits.ContentSecurityPolicyViolationType.KTrustedTypesPolicyViolation].join("::");const issueDescriptions=new Map([[Protocol.Audits.ContentSecurityPolicyViolationType.KURLViolation,cspURLViolation],[Protocol.Audits.ContentSecurityPolicyViolationType.KInlineViolation,cspInlineViolation],[Protocol.Audits.ContentSecurityPolicyViolationType.KEvalViolation,cspEvalViolation],[Protocol.Audits.ContentSecurityPolicyViolationType.KTrustedTypesSinkViolation,cspTrustedTypesSinkViolation],[Protocol.Audits.ContentSecurityPolicyViolationType.KTrustedTypesPolicyViolation,cspTrustedTypesPolicyViolation]]);