import * as Protocol from "../../generated/protocol.js";
import { Issue, IssueCategory, IssueKind } from "./Issue.js";
export var IssueCode = /* @__PURE__ */ ((IssueCode2) => {
  IssueCode2["PermissionPolicyDisabled"] = "AttributionReportingIssue::PermissionPolicyDisabled";
  IssueCode2["InvalidAttributionSourceEventId"] = "AttributionReportingIssue::InvalidAttributionSourceEventId";
  IssueCode2["InvalidAttributionData"] = "AttributionReportingIssue::InvalidAttributionData";
  IssueCode2["MissingAttributionData"] = "AttributionReportingIssue::MissingAttributionData";
  IssueCode2["AttributionSourceUntrustworthyFrameOrigin"] = "AttributionReportingIssue::AttributionSourceUntrustworthyFrameOrigin";
  IssueCode2["AttributionSourceUntrustworthyOrigin"] = "AttributionReportingIssue::AttributionSourceUntrustworthyOrigin";
  IssueCode2["AttributionUntrustworthyFrameOrigin"] = "AttributionReportingIssue::AttributionUntrustworthyFrameOrigin";
  IssueCode2["AttributionUntrustworthyOrigin"] = "AttributionReportingIssue::AttributionUntrustworthyOrigin";
  IssueCode2["AttributionTriggerDataTooLarge"] = "AttributionReportingIssue::AttributionTriggerDataTooLarge";
  IssueCode2["AttributionEventSourceTriggerDataTooLarge"] = "AttributionReportingIssue::AttributionEventSourceTriggerDataTooLarge";
  IssueCode2["InvalidAttributionSourceExpiry"] = "AttributionReportingIssue::InvalidAttributionSourceExpiry";
  IssueCode2["InvalidAttributionSourcePriority"] = "AttributionReportingIssue::InvalidAttributionSourcePriority";
  IssueCode2["InvalidEventSourceTriggerData"] = "AttributionReportingIssue::InvalidEventSourceTriggerData";
  IssueCode2["InvalidTriggerPriority"] = "AttributionReportingIssue::InvalidTriggerPriority";
  IssueCode2["InvalidTriggerDedupKey"] = "AttributionReportingIssue::InvalidTriggerDedupKey";
  return IssueCode2;
})(IssueCode || {});
function getIssueCode(details) {
  switch (details.violationType) {
    case Protocol.Audits.AttributionReportingIssueType.PermissionPolicyDisabled:
      return "AttributionReportingIssue::PermissionPolicyDisabled" /* PermissionPolicyDisabled */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidAttributionSourceEventId:
      return "AttributionReportingIssue::InvalidAttributionSourceEventId" /* InvalidAttributionSourceEventId */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidAttributionData:
      return details.invalidParameter !== void 0 ? "AttributionReportingIssue::InvalidAttributionData" /* InvalidAttributionData */ : "AttributionReportingIssue::MissingAttributionData" /* MissingAttributionData */;
    case Protocol.Audits.AttributionReportingIssueType.AttributionSourceUntrustworthyOrigin:
      return details.frame !== void 0 ? "AttributionReportingIssue::AttributionSourceUntrustworthyFrameOrigin" /* AttributionSourceUntrustworthyFrameOrigin */ : "AttributionReportingIssue::AttributionSourceUntrustworthyOrigin" /* AttributionSourceUntrustworthyOrigin */;
    case Protocol.Audits.AttributionReportingIssueType.AttributionUntrustworthyOrigin:
      return details.frame !== void 0 ? "AttributionReportingIssue::AttributionUntrustworthyFrameOrigin" /* AttributionUntrustworthyFrameOrigin */ : "AttributionReportingIssue::AttributionUntrustworthyOrigin" /* AttributionUntrustworthyOrigin */;
    case Protocol.Audits.AttributionReportingIssueType.AttributionTriggerDataTooLarge:
      return "AttributionReportingIssue::AttributionTriggerDataTooLarge" /* AttributionTriggerDataTooLarge */;
    case Protocol.Audits.AttributionReportingIssueType.AttributionEventSourceTriggerDataTooLarge:
      return "AttributionReportingIssue::AttributionEventSourceTriggerDataTooLarge" /* AttributionEventSourceTriggerDataTooLarge */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidAttributionSourceExpiry:
      return "AttributionReportingIssue::InvalidAttributionSourceExpiry" /* InvalidAttributionSourceExpiry */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidAttributionSourcePriority:
      return "AttributionReportingIssue::InvalidAttributionSourcePriority" /* InvalidAttributionSourcePriority */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidEventSourceTriggerData:
      return "AttributionReportingIssue::InvalidEventSourceTriggerData" /* InvalidEventSourceTriggerData */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidTriggerPriority:
      return "AttributionReportingIssue::InvalidTriggerPriority" /* InvalidTriggerPriority */;
    case Protocol.Audits.AttributionReportingIssueType.InvalidTriggerDedupKey:
      return "AttributionReportingIssue::InvalidTriggerDedupKey" /* InvalidTriggerDedupKey */;
  }
}
export class AttributionReportingIssue extends Issue {
  issueDetails;
  constructor(issueDetails, issuesModel) {
    super(getIssueCode(issueDetails), issuesModel);
    this.issueDetails = issueDetails;
  }
  getCategory() {
    return IssueCategory.AttributionReporting;
  }
  getDescription() {
    switch (this.code()) {
      case "AttributionReportingIssue::PermissionPolicyDisabled" /* PermissionPolicyDisabled */:
        return {
          file: "arPermissionPolicyDisabled.md",
          links: []
        };
      case "AttributionReportingIssue::InvalidAttributionSourceEventId" /* InvalidAttributionSourceEventId */:
        return {
          file: "arInvalidAttributionSourceEventId.md",
          links: [{
            link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#html-attribute-attributionsourceeventid-required",
            linkTitle: "attributionsourceeventid attribute"
          }]
        };
      case "AttributionReportingIssue::InvalidAttributionData" /* InvalidAttributionData */:
        return {
          file: "arInvalidAttributionData.md",
          links: []
        };
      case "AttributionReportingIssue::MissingAttributionData" /* MissingAttributionData */:
        return {
          file: "arMissingAttributionData.md",
          links: []
        };
      case "AttributionReportingIssue::AttributionSourceUntrustworthyFrameOrigin" /* AttributionSourceUntrustworthyFrameOrigin */:
        return {
          file: "arAttributionSourceUntrustworthyFrameOrigin.md",
          links: []
        };
      case "AttributionReportingIssue::AttributionSourceUntrustworthyOrigin" /* AttributionSourceUntrustworthyOrigin */:
        return {
          file: "arAttributionSourceUntrustworthyOrigin.md",
          links: [
            {
              link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#html-attribute-attributiondestination-required",
              linkTitle: "attributiondestination attribute"
            },
            {
              link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#html-attribute-attributionreportto",
              linkTitle: "attributionreportto attribute"
            }
          ]
        };
      case "AttributionReportingIssue::AttributionUntrustworthyFrameOrigin" /* AttributionUntrustworthyFrameOrigin */:
        return {
          file: "arAttributionUntrustworthyFrameOrigin.md",
          links: []
        };
      case "AttributionReportingIssue::AttributionUntrustworthyOrigin" /* AttributionUntrustworthyOrigin */:
        return {
          file: "arAttributionUntrustworthyOrigin.md",
          links: []
        };
      case "AttributionReportingIssue::AttributionTriggerDataTooLarge" /* AttributionTriggerDataTooLarge */:
        return {
          file: "arAttributionTriggerDataTooLarge.md",
          links: []
        };
      case "AttributionReportingIssue::AttributionEventSourceTriggerDataTooLarge" /* AttributionEventSourceTriggerDataTooLarge */:
        return {
          file: "arAttributionEventSourceTriggerDataTooLarge.md",
          links: []
        };
      case "AttributionReportingIssue::InvalidAttributionSourceExpiry" /* InvalidAttributionSourceExpiry */:
        return {
          file: "arInvalidAttributionSourceExpiry.md",
          links: [{
            link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#html-attribute-attributionexpiry",
            linkTitle: "attributionexpiry attribute"
          }]
        };
      case "AttributionReportingIssue::InvalidAttributionSourcePriority" /* InvalidAttributionSourcePriority */:
        return {
          file: "arInvalidAttributionSourcePriority.md",
          links: [{
            link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#html-attribute-attributionsourcepriority",
            linkTitle: "attributionsourcepriority attribute"
          }]
        };
      case "AttributionReportingIssue::InvalidEventSourceTriggerData" /* InvalidEventSourceTriggerData */:
        return {
          file: "arInvalidEventSourceTriggerData.md",
          links: []
        };
      case "AttributionReportingIssue::InvalidTriggerPriority" /* InvalidTriggerPriority */:
        return {
          file: "arInvalidTriggerPriority.md",
          links: [{
            link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#prioritize-specific-conversions",
            linkTitle: "Prioritizing specific conversions"
          }]
        };
      case "AttributionReportingIssue::InvalidTriggerDedupKey" /* InvalidTriggerDedupKey */:
        return {
          file: "arInvalidTriggerDedupKey.md",
          links: [{
            link: "https://developer.chrome.com/docs/privacy-sandbox/attribution-reporting-event-guide/#deduplicate-reports",
            linkTitle: "Deduplicating reports"
          }]
        };
    }
  }
  primaryKey() {
    return JSON.stringify(this.issueDetails);
  }
  getKind() {
    return IssueKind.PageError;
  }
  static fromInspectorIssue(issuesModel, inspectorIssue) {
    const { attributionReportingIssueDetails } = inspectorIssue.details;
    if (!attributionReportingIssueDetails) {
      console.warn("Attribution Reporting issue without details received.");
      return [];
    }
    return [new AttributionReportingIssue(attributionReportingIssueDetails, issuesModel)];
  }
}
//# sourceMappingURL=AttributionReportingIssue.js.map
