import {
  require_lib
} from "./chunk-WTIA47ZU.js";
import {
  require_lib as require_lib2
} from "./chunk-WDCEFGHP.js";
import {
  attachTooltipToHighlight,
  createHighlight,
  getElementsPositionInDocument,
  positionHighlight
} from "./chunk-LEAOZWS7.js";
import {
  escape
} from "./chunk-PXGSXSC7.js";
import {
  closeOnOutsideClick
} from "./chunk-WM2KMMIK.js";
import {
  settings
} from "./chunk-LEX3GG7N.js";
import {
  __toESM
} from "./chunk-5WRI5ZAA.js";

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/annotations.js
var ELEMENT_ANNOTATIONS = /* @__PURE__ */ new WeakMap();
function getAnnotationsForElement(element) {
  return ELEMENT_ANNOTATIONS.get(element);
}
var ANNOTATION_MAP = {
  "data-astro-source-file": "file",
  "data-astro-source-loc": "location"
};
function extractAnnotations(element) {
  const annotations = {};
  for (const [attr, key] of Object.entries(ANNOTATION_MAP)) {
    annotations[key] = element.getAttribute(attr);
  }
  for (const attr of Object.keys(ANNOTATION_MAP)) {
    element.removeAttribute(attr);
  }
  return annotations;
}
function processAnnotations() {
  for (const element of document.querySelectorAll(`[data-astro-source-file]`)) {
    ELEMENT_ANNOTATIONS.set(element, extractAnnotations(element));
  }
}

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js
var import_aria_query = __toESM(require_lib2(), 1);
var import_axobject_query = __toESM(require_lib(), 1);
var WHITESPACE_REGEX = /\s+/;
var a11y_required_attributes = {
  a: ["href"],
  area: ["alt", "aria-label", "aria-labelledby"],
  // html-has-lang
  html: ["lang"],
  // iframe-has-title
  iframe: ["title"],
  img: ["alt"],
  object: ["title", "aria-label", "aria-labelledby"]
};
var MAYBE_INTERACTIVE = /* @__PURE__ */ new Map([
  ["a", "href"],
  ["input", "type"],
  ["audio", "controls"],
  ["img", "usemap"],
  ["object", "usemap"],
  ["video", "controls"]
]);
var interactiveElements = [
  "button",
  "details",
  "embed",
  "iframe",
  "label",
  "select",
  "textarea",
  ...MAYBE_INTERACTIVE.keys()
];
var labelableElements = ["button", "input", "meter", "output", "progress", "select", "textarea"];
var aria_non_interactive_roles = [
  "alert",
  "alertdialog",
  "application",
  "article",
  "banner",
  "cell",
  "columnheader",
  "complementary",
  "contentinfo",
  "definition",
  "dialog",
  "directory",
  "document",
  "feed",
  "figure",
  "form",
  "group",
  "heading",
  "image",
  "img",
  "list",
  "listitem",
  "log",
  "main",
  "marquee",
  "math",
  "navigation",
  "none",
  "note",
  "presentation",
  "region",
  "row",
  "rowgroup",
  "rowheader",
  "search",
  "status",
  "tabpanel",
  "term",
  "timer",
  "toolbar",
  "tooltip"
];
var roleless_elements = ["div", "span"];
var a11y_required_content = [
  // anchor-has-content
  "a",
  // heading-has-content
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6"
];
var a11y_distracting_elements = ["blink", "marquee"];
var a11y_implicit_semantics = /* @__PURE__ */ new Map([
  ["a", "link"],
  ["area", "link"],
  ["article", "article"],
  ["aside", "complementary"],
  ["body", "document"],
  ["button", "button"],
  ["datalist", "listbox"],
  ["dd", "definition"],
  ["dfn", "term"],
  ["dialog", "dialog"],
  ["details", "group"],
  ["dt", "term"],
  ["fieldset", "group"],
  ["figure", "figure"],
  ["form", "form"],
  ["h1", "heading"],
  ["h2", "heading"],
  ["h3", "heading"],
  ["h4", "heading"],
  ["h5", "heading"],
  ["h6", "heading"],
  ["hr", "separator"],
  ["img", "image"],
  ["li", "listitem"],
  ["link", "link"],
  ["main", "main"],
  ["menu", "list"],
  ["meter", "progressbar"],
  ["nav", "navigation"],
  ["ol", "list"],
  ["option", "option"],
  ["optgroup", "group"],
  ["output", "status"],
  ["progress", "progressbar"],
  ["section", "region"],
  ["summary", "button"],
  ["table", "table"],
  ["tbody", "rowgroup"],
  ["textarea", "textbox"],
  ["tfoot", "rowgroup"],
  ["thead", "rowgroup"],
  ["tr", "row"],
  ["ul", "list"]
]);
var menuitem_type_to_implicit_role = /* @__PURE__ */ new Map([
  ["command", "menuitem"],
  ["checkbox", "menuitemcheckbox"],
  ["radio", "menuitemradio"]
]);
var input_type_to_implicit_role = /* @__PURE__ */ new Map([
  ["button", "button"],
  ["image", "button"],
  ["reset", "button"],
  ["submit", "button"],
  ["checkbox", "checkbox"],
  ["radio", "radio"],
  ["range", "slider"],
  ["number", "spinbutton"],
  ["email", "textbox"],
  ["search", "searchbox"],
  ["tel", "textbox"],
  ["text", "textbox"],
  ["url", "textbox"]
]);
var ariaAttributes = new Set(
  "activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext".split(
    " "
  )
);
var ariaRoles = new Set(
  "alert alertdialog application article banner blockquote button caption cell checkbox code columnheader combobox command complementary composite contentinfo definition deletion dialog directory document emphasis feed figure form generic grid gridcell group heading image img input insertion landmark link list listbox listitem log main marquee math meter menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option paragraph presentation progressbar radio radiogroup range region roletype row rowgroup rowheader scrollbar search searchbox section sectionhead select separator slider spinbutton status strong structure subscript superscript switch tab table tablist tabpanel term textbox time timer toolbar tooltip tree treegrid treeitem widget window".split(
    " "
  )
);
function isInteractive(element) {
  const attribute = MAYBE_INTERACTIVE.get(element.localName);
  if (attribute) {
    return element.hasAttribute(attribute);
  }
  return true;
}
var a11y = [
  {
    code: "a11y-accesskey",
    title: "Avoid using `accesskey`",
    message: "The `accesskey` attribute can cause accessibility issues. The shortcuts can conflict with the browser's or operating system's shortcuts, and they are difficult for users to discover and use.",
    selector: "[accesskey]"
  },
  {
    code: "a11y-aria-activedescendant-has-tabindex",
    title: "Elements with attribute `aria-activedescendant` must be tabbable",
    message: "Element with the `aria-activedescendant` attribute must either have an inherent `tabindex` or declare `tabindex` as an attribute.",
    selector: "[aria-activedescendant]",
    match(element) {
      if (!element.tabIndex && !element.hasAttribute("tabindex")) return true;
    }
  },
  {
    code: "a11y-aria-attributes",
    title: "Element does not support ARIA roles.",
    message: "Elements like `meta`, `html`, `script`, `style` do not support having ARIA roles.",
    selector: ":is(meta, html, script, style)[role]",
    match(element) {
      for (const attribute of element.attributes) {
        if (attribute.name.startsWith("aria-")) return true;
      }
    }
  },
  {
    code: "a11y-autofocus",
    title: "Avoid using `autofocus`",
    message: "The `autofocus` attribute can cause accessibility issues, as it can cause the focus to move around unexpectedly for screen reader users.",
    selector: "[autofocus]"
  },
  {
    code: "a11y-distracting-elements",
    title: "Distracting elements should not be used",
    message: "Elements that can be visually distracting like `<marquee>` or `<blink>` can cause accessibility issues for visually impaired users and should be avoided.",
    selector: `:is(${a11y_distracting_elements.join(",")})`
  },
  {
    code: "a11y-hidden",
    title: "Certain DOM elements are useful for screen reader navigation and should not be hidden",
    message: (element) => `${element.localName} element should not be hidden.`,
    selector: "[aria-hidden]:is(h1,h2,h3,h4,h5,h6)"
  },
  {
    code: "a11y-img-redundant-alt",
    title: "Redundant text in alt attribute",
    message: 'Screen readers already announce `img` elements as an image. There is no need to use words such as "image", "photo", and/or "picture".',
    selector: "img[alt]:not([aria-hidden])",
    match: (img) => /\b(?:image|picture|photo)\b/i.test(img.alt)
  },
  {
    code: "a11y-incorrect-aria-attribute-type",
    title: "Incorrect value for ARIA attribute.",
    message: "`aria-hidden` should only receive a boolean.",
    selector: "[aria-hidden]",
    match(element) {
      const value = element.getAttribute("aria-hidden");
      if (!value) return true;
      if (!["true", "false"].includes(value)) return true;
    }
  },
  {
    code: "a11y-invalid-href",
    title: "Invalid `href` attribute",
    message: "`href` should not be empty, `'#'`, or `javascript:`.",
    selector: 'a[href]:is([href=""], [href="#"], [href^="javascript:" i])'
  },
  {
    code: "a11y-invalid-label",
    title: "`label` element should have an associated control and a text content.",
    message: "The `label` element must be associated with a control either by using the `for` attribute or by containing a nested form element. Additionally, the `label` element must have text content.",
    selector: "label",
    match(element) {
      const hasFor = element.hasAttribute("for");
      const nestedLabelableElement = element.querySelector(`${labelableElements.join(", ")}`);
      if (!hasFor && !nestedLabelableElement) return true;
      const innerText = element.innerText.trim();
      if (innerText === "") return true;
    }
  },
  {
    code: "a11y-media-has-caption",
    title: "Unmuted video elements should have captions",
    message: "Videos without captions can be difficult for deaf and hard-of-hearing users to follow along with. If the video does not need captions, add the `muted` attribute.",
    selector: "video:not([muted])",
    match(element) {
      const tracks = element.querySelectorAll("track");
      if (!tracks.length) return true;
      const hasCaptionTrack = Array.from(tracks).some(
        (track) => track.getAttribute("kind") === "captions"
      );
      return !hasCaptionTrack;
    }
  },
  {
    code: "a11y-misplaced-scope",
    title: "The `scope` attribute should only be used on `<th>` elements",
    message: "The `scope` attribute tells the browser and screen readers how to navigate tables. In HTML5, it should only be used on `<th>` elements.",
    selector: ":not(th)[scope]"
  },
  {
    code: "a11y-missing-attribute",
    title: "Required attributes missing.",
    description: "Some HTML elements require additional attributes for accessibility. For example, an `img` element requires an `alt` attribute, this attribute is used to describe the content of the image for screen readers.",
    message: (element) => {
      const requiredAttributes = a11y_required_attributes[element.localName];
      const missingAttributes = requiredAttributes.filter(
        (attribute) => !element.hasAttribute(attribute)
      );
      return `${element.localName} element is missing required attributes for accessibility: ${missingAttributes.join(", ")} `;
    },
    selector: Object.keys(a11y_required_attributes).join(","),
    match(element) {
      const requiredAttributes = a11y_required_attributes[element.localName];
      if (!requiredAttributes) return true;
      for (const attribute of requiredAttributes) {
        if (!element.hasAttribute(attribute)) return true;
      }
      return false;
    }
  },
  {
    code: "a11y-missing-content",
    title: "Missing content",
    message: "Headings and anchors must have an accessible name, which can come from: inner text, aria-label, aria-labelledby, an img with alt property, or an svg with a tag <title></title>.",
    selector: a11y_required_content.join(","),
    match(element) {
      const innerText = element.innerText?.trim();
      if (innerText && innerText !== "") return false;
      const ariaLabel = element.getAttribute("aria-label")?.trim();
      if (ariaLabel && ariaLabel !== "") return false;
      const ariaLabelledby = element.getAttribute("aria-labelledby")?.trim();
      if (ariaLabelledby) {
        const ids = ariaLabelledby.split(" ");
        for (const id of ids) {
          const referencedElement = document.getElementById(id);
          if (referencedElement && referencedElement.innerText.trim() !== "") return false;
        }
      }
      const imgElements = element.querySelectorAll("img");
      for (const img of imgElements) {
        const altAttribute = img.getAttribute("alt");
        if (altAttribute && altAttribute.trim() !== "") return false;
      }
      const svgElements = element.querySelectorAll("svg");
      for (const svg of svgElements) {
        const titleText = svg.querySelector("title");
        if (titleText && titleText.textContent && titleText.textContent.trim() !== "") return false;
      }
      const inputElements = element.querySelectorAll("input");
      for (const input of inputElements) {
        if (input.type === "image") {
          const altAttribute = input.getAttribute("alt");
          if (altAttribute && altAttribute.trim() !== "") return false;
        }
        const inputAriaLabel = input.getAttribute("aria-label")?.trim();
        if (inputAriaLabel && inputAriaLabel !== "") return false;
        const inputAriaLabelledby = input.getAttribute("aria-labelledby")?.trim();
        if (inputAriaLabelledby) {
          const ids = inputAriaLabelledby.split(" ");
          for (const id of ids) {
            const referencedElement = document.getElementById(id);
            if (referencedElement && referencedElement.innerText.trim() !== "") return false;
          }
        }
        const title = input.getAttribute("title")?.trim();
        if (title && title !== "") return false;
      }
      return true;
    }
  },
  {
    code: "a11y-no-redundant-roles",
    title: "HTML element has redundant ARIA roles",
    message: "Giving these elements an ARIA role that is already set by the browser has no effect and is redundant.",
    selector: [...a11y_implicit_semantics.keys()].join(","),
    match(element) {
      const role = element.getAttribute("role");
      if (element.localName === "input") {
        const type = element.getAttribute("type");
        if (!type) return true;
        const implicitRoleForType = input_type_to_implicit_role.get(type);
        if (!implicitRoleForType) return true;
        if (role === implicitRoleForType) return false;
      }
      const implicitRole = a11y_implicit_semantics.get(element.localName);
      if (!implicitRole) return true;
      if (role === implicitRole) return false;
    }
  },
  {
    code: "a11y-no-interactive-element-to-noninteractive-role",
    title: "Non-interactive ARIA role used on interactive HTML element.",
    message: "Interactive HTML elements like `<a>` and `<button>` cannot use non-interactive roles like `heading`, `list`, `menu`, and `toolbar`.",
    selector: `[role]:is(${interactiveElements.join(",")})`,
    match(element) {
      if (!isInteractive(element)) return false;
      const role = element.getAttribute("role");
      if (!role) return false;
      if (!ariaRoles.has(role)) return false;
      if (roleless_elements.includes(element.localName)) return false;
      if (aria_non_interactive_roles.includes(role)) return true;
    }
  },
  {
    code: "a11y-no-noninteractive-element-to-interactive-role",
    title: "Interactive ARIA role used on non-interactive HTML element.",
    message: "Interactive roles should not be used to convert a non-interactive element to an interactive element",
    selector: `[role]:not(${interactiveElements.join(",")})`,
    match(element) {
      if (!isInteractive(element)) return false;
      const role = element.getAttribute("role");
      if (!role) return false;
      if (!ariaRoles.has(role)) return false;
      const exceptions = a11y_non_interactive_element_to_interactive_role_exceptions[element.localName];
      if (exceptions?.includes(role)) return false;
      if (roleless_elements.includes(element.localName)) return false;
      if (!aria_non_interactive_roles.includes(role)) return true;
    }
  },
  {
    code: "a11y-no-noninteractive-tabindex",
    title: "Invalid `tabindex` on non-interactive element",
    description: 'The `tabindex` attribute should only be used on interactive elements, as it can be confusing for keyboard-only users to navigate through non-interactive elements. If your element is only conditionally interactive, consider using `tabindex="-1"` to make it focusable only when it is actually interactive.',
    message: (element) => `${element.localName} elements should not have \`tabindex\` attribute`,
    selector: '[tabindex]:not([role="tabpanel"])',
    match(element) {
      const isScrollable = element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
      if (isScrollable) return false;
      if (element.localName === "pre") return false;
      if (!isInteractive(element)) return false;
      if (!interactiveElements.includes(element.localName) && !roleless_elements.includes(element.localName))
        return true;
    }
  },
  {
    code: "a11y-positive-tabindex",
    title: "Avoid positive `tabindex` property values",
    message: "This will move elements out of the expected tab order, creating a confusing experience for keyboard users.",
    selector: '[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'
  },
  {
    code: "a11y-role-has-required-aria-props",
    title: "Missing attributes required for ARIA role",
    message: (element) => {
      const { __astro_role: role, __astro_missing_attributes: required } = element;
      return `${element.localName} element is missing required attributes for its role (${role}): ${required.join(", ")}`;
    },
    selector: "*",
    match(element) {
      const role = getRole(element);
      if (!role) return false;
      if (is_semantic_role_element(role, element.localName, getAttributeObject(element))) {
        return;
      }
      const elementRoles = role.split(WHITESPACE_REGEX);
      for (const elementRole of elementRoles) {
        const roleData = import_aria_query.roles.get(normalizeAriaRole(elementRole));
        if (!roleData) continue;
        const { requiredProps } = roleData;
        const required_role_props = Object.keys(requiredProps);
        const missingProps = required_role_props.filter((prop) => !element.hasAttribute(prop));
        if (missingProps.length > 0) {
          element.__astro_role = elementRole;
          element.__astro_missing_attributes = missingProps;
          return true;
        }
      }
    }
  },
  {
    code: "a11y-role-supports-aria-props",
    title: "Unsupported ARIA attribute",
    message: (element) => {
      const { __astro_role: role, __astro_unsupported_attributes: unsupported } = element;
      return `${element.localName} element has ARIA attributes that are not supported by its role (${role}): ${unsupported.join(
        ", "
      )}`;
    },
    selector: "*",
    match(element) {
      const role = getRole(element);
      if (!role) return false;
      const elementRoles = role.split(WHITESPACE_REGEX);
      for (const elementRole of elementRoles) {
        const roleData = import_aria_query.roles.get(normalizeAriaRole(elementRole));
        if (!roleData) continue;
        const { props } = roleData;
        const attributes = getAttributeObject(element);
        const unsupportedAttributes = import_aria_query.aria.keys().filter((attribute) => !(attribute in props));
        const invalidAttributes = Object.keys(attributes).filter(
          (key) => key.startsWith("aria-") && unsupportedAttributes.includes(key)
        );
        if (invalidAttributes.length > 0) {
          element.__astro_role = elementRole;
          element.__astro_unsupported_attributes = invalidAttributes;
          return true;
        }
      }
    }
  },
  {
    code: "a11y-structure",
    title: "Invalid DOM structure",
    message: "The DOM structure must be valid for accessibility of the page, for example `figcaption` must be a direct child of `figure`.",
    selector: "figcaption:not(figure > figcaption)"
  },
  {
    code: "a11y-unknown-aria-attribute",
    title: "Unknown ARIA attribute",
    message: "ARIA attributes prefixed with `aria-` must be valid, non-abstract ARIA attributes.",
    selector: "*",
    match(element) {
      for (const attribute of element.attributes) {
        if (attribute.name.startsWith("aria-")) {
          if (!ariaAttributes.has(attribute.name.slice("aria-".length))) return true;
        }
      }
    }
  },
  {
    code: "a11y-unknown-role",
    title: "Unknown ARIA role",
    message: "ARIA roles must be valid, non-abstract ARIA roles.",
    selector: "[role]",
    match(element) {
      const role = element.getAttribute("role");
      if (!role) return true;
      if (!ariaRoles.has(role)) return true;
    }
  }
];
var a11y_non_interactive_element_to_interactive_role_exceptions = {
  ul: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
  ol: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
  li: ["menuitem", "option", "row", "tab", "treeitem"],
  table: ["grid"],
  td: ["gridcell"],
  fieldset: ["radiogroup", "presentation"]
};
var combobox_if_list = ["email", "search", "tel", "text", "url"];
function input_implicit_role(attributes) {
  if (!("type" in attributes)) return;
  const { type, list } = attributes;
  if (!type) return;
  if (list && combobox_if_list.includes(type)) {
    return "combobox";
  }
  return input_type_to_implicit_role.get(type);
}
function menuitem_implicit_role(attributes) {
  if (!("type" in attributes)) return;
  const { type } = attributes;
  if (!type) return;
  return menuitem_type_to_implicit_role.get(type);
}
var ariaQueryRoleAliases = {
  image: "img"
};
function normalizeAriaRole(role) {
  return ariaQueryRoleAliases[role] ?? role;
}
function getRole(element) {
  if (element.hasAttribute("role")) {
    return element.getAttribute("role");
  }
  return getImplicitRole(element);
}
function getImplicitRole(element) {
  const name = element.localName;
  const attrs = getAttributeObject(element);
  if (name === "menuitem") {
    return menuitem_implicit_role(attrs);
  } else if (name === "input") {
    return input_implicit_role(attrs);
  } else {
    return a11y_implicit_semantics.get(name);
  }
}
function getAttributeObject(element) {
  let obj = {};
  for (let i = 0; i < element.attributes.length; i++) {
    const attribute = element.attributes.item(i);
    obj[attribute.name] = attribute.value;
  }
  return obj;
}
function is_semantic_role_element(role, tag_name, attributes) {
  for (const [schema, ax_object] of import_axobject_query.elementAXObjects.entries()) {
    if (schema.name === tag_name && (!schema.attributes || schema.attributes.every((attr) => attributes[attr.name] === attr.value))) {
      for (const name of ax_object) {
        const axRoles = import_axobject_query.AXObjectRoles.get(name);
        if (axRoles) {
          for (const { name: _name } of axRoles) {
            if (_name === role) {
              return true;
            }
          }
        }
      }
    }
  }
  return false;
}

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js
var EXTERNAL_URL_REGEX = /^(?:[a-z+]+:)?\/\//i;
var perf = [
  {
    code: "perf-use-image-component",
    title: "Use the Image component",
    message: "This image could be replaced with the Image component to improve performance.",
    selector: "img:not([data-image-component])",
    async match(element) {
      if (element.closest("astro-island")) return false;
      const src = element.getAttribute("src");
      if (!src) return false;
      if (src.startsWith("data:")) return false;
      if (!EXTERNAL_URL_REGEX.test(src)) {
        const imageData = await fetch(src).then((response) => response.blob());
        if (imageData.size < 20480) return false;
      }
      return true;
    }
  },
  {
    code: "perf-use-loading-lazy",
    title: "Unoptimized loading attribute",
    message: (element) => `This ${element.nodeName} tag is below the fold and could be lazy-loaded to improve performance.`,
    selector: 'img:not([loading]), img[loading="eager"], iframe:not([loading]), iframe[loading="eager"]',
    match(element) {
      const htmlElement = element;
      let currentElement = element;
      let elementYPosition = 0;
      while (currentElement) {
        elementYPosition += currentElement.offsetTop;
        currentElement = currentElement.offsetParent;
      }
      if (elementYPosition < window.innerHeight) return false;
      if (htmlElement.src.startsWith("data:")) return false;
      return true;
    }
  },
  {
    code: "perf-use-loading-eager",
    title: "Unoptimized loading attribute",
    message: (element) => `This ${element.nodeName} tag is above the fold and could be eagerly-loaded to improve performance.`,
    selector: 'img[loading="lazy"], iframe[loading="lazy"]',
    match(element) {
      const htmlElement = element;
      let currentElement = element;
      let elementYPosition = 0;
      while (currentElement) {
        elementYPosition += currentElement.offsetTop;
        currentElement = currentElement.offsetParent;
      }
      if (elementYPosition > window.innerHeight) return false;
      if (htmlElement.src.startsWith("data:")) return false;
      return true;
    }
  },
  {
    code: "perf-use-videos",
    title: "Use videos instead of GIFs for large animations",
    message: "This GIF could be replaced with a video to reduce its file size and improve performance.",
    selector: 'img[src$=".gif"]',
    async match(element) {
      const src = element.getAttribute("src");
      if (!src) return false;
      if (EXTERNAL_URL_REGEX.test(src)) return false;
      if (!EXTERNAL_URL_REGEX.test(src)) {
        const imageData = await fetch(src).then((response) => response.blob());
        if (imageData.size < 102400) return false;
      }
      return true;
    }
  },
  {
    code: "perf-slow-component-server-render",
    title: "Server-rendered component took a long time to render",
    message: (element) => `This component took an unusually long time to render on the server (${getCleanRenderingTime(
      element.getAttribute("server-render-time")
    )}). This might be a sign that it's doing too much work on the server, or something is blocking rendering.`,
    selector: "astro-island[server-render-time]",
    match(element) {
      const serverRenderTime = element.getAttribute("server-render-time");
      if (!serverRenderTime) return false;
      const renderingTime = Number.parseFloat(serverRenderTime);
      if (Number.isNaN(renderingTime)) return false;
      return renderingTime > 500;
    }
  },
  {
    code: "perf-slow-component-client-hydration",
    title: "Client-rendered component took a long time to hydrate",
    message: (element) => `This component took an unusually long time to render on the server (${getCleanRenderingTime(
      element.getAttribute("client-render-time")
    )}). This could be a sign that something is blocking the main thread and preventing the component from hydrating quickly.`,
    selector: "astro-island[client-render-time]",
    match(element) {
      const clientRenderTime = element.getAttribute("client-render-time");
      if (!clientRenderTime) return false;
      const renderingTime = Number.parseFloat(clientRenderTime);
      if (Number.isNaN(renderingTime)) return false;
      return renderingTime > 500;
    }
  }
];
function getCleanRenderingTime(time) {
  if (!time) return "unknown";
  const renderingTime = Number.parseFloat(time);
  if (Number.isNaN(renderingTime)) return "unknown";
  return renderingTime.toFixed(2) + "s";
}

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/rules/index.js
var rulesCategories = [
  { code: "a11y", name: "Accessibility", icon: "person-arms-spread", rules: a11y },
  { code: "perf", name: "Performance", icon: "gauge", rules: perf }
];
var dynamicAuditRuleKeys = ["title", "message", "description"];
function resolveAuditRule(rule, element) {
  let resolved = { ...rule };
  for (const key of dynamicAuditRuleKeys) {
    const value = rule[key];
    if (typeof value === "string") continue;
    try {
      if (!value) {
        resolved[key] = "";
        continue;
      }
      resolved[key] = value(element);
    } catch (err) {
      settings.logger.error(`Error resolving dynamic audit rule ${rule.code}'s ${key}: ${err}`);
      resolved[key] = "Error resolving dynamic rule";
    }
  }
  return resolved;
}
function getAuditCategory(rule) {
  return rule.code.split("-")[0];
}

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-item.js
var DevToolbarAuditListItem = class extends HTMLElement {
  clickAction;
  shadowRoot;
  isManualFocus;
  constructor() {
    super();
    this.shadowRoot = this.attachShadow({ mode: "open" });
    this.isManualFocus = false;
    this.shadowRoot.innerHTML = `
			<style>
				:host>button, :host>div {
					box-sizing: border-box;
					padding: 16px;
					background: transparent;
					border: none;
					border-bottom: 1px solid #1F2433;
					text-decoration: none;
					width: 100%;
	    		height: 100%;
				}

				h1, h2, h3, h4, h5, h6 {
					color: #fff;
					font-weight: 600;
				}

				:host>button:hover, :host([hovered])>button {
					background: #FFFFFF20;
				}

				svg {
					display: block;
					margin: 0 auto;
				}

			:host>button#astro-overlay-card {
			  text-align: left;
				box-shadow: none;
				display: flex;
				align-items: center;
				overflow: hidden;
				gap: 8px;
			}

			:host(:not([active]))>button:hover {
			  cursor: pointer;
			}

			.extended-info {
				display: none;
				color: white;
				font-size: 14px;
			}

			.extended-info hr {
				border: 1px solid rgba(27, 30, 36, 1);
			}

			:host([active]) .extended-info {
				display: block;
				position: absolute;
				height: 100%;
				top: 98px;
				height: calc(100% - 98px);
				background: #0d0e12;
				user-select: text;
				overflow: auto;
				border: none;
				z-index: 1000000000;
				flex-direction: column;
				line-height: 1.25rem;
			}

			:host([active])>button#astro-overlay-card {
				display: none;
			}

			.audit-title {
				margin: 0;
				margin-bottom: 4px;
			}

			.extended-info .audit-selector {
				font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
				display: flex;
				align-items: center;
				border-bottom: 1px solid transparent;
				user-select: none;
				color: rgba(191, 193, 201, 1);
			}

			.extended-info .audit-selector:hover {
				border-bottom: 1px solid rgba(255, 255, 255);
				cursor: pointer;
				color: #fff;
			}

			.audit-selector svg {
				width: 16px;
				height: 16px;
    		display: inline;
			}

			.extended-info .audit-description {
				color: rgba(191, 193, 201, 1);
			}

			.extended-info code {
				padding: 1px 3px;
				border-radius: 3px;
				background: #1F2433;
			}

			.reset-button {
				text-align: left;
				border: none;
				margin: 0;
				width: auto;
				overflow: visible;
				background: transparent;
				font: inherit;
				line-height: normal;
				-webkit-font-smoothing: inherit;
				-moz-osx-font-smoothing: inherit;
				-webkit-appearance: none;
				padding: 0;
				color: white;
			}
			</style>

			<button id="astro-overlay-card">
				<slot />
			</button>
		`;
  }
  connectedCallback() {
    if (this.clickAction) {
      this.shadowRoot.getElementById("astro-overlay-card")?.addEventListener("click", this.clickAction);
    }
  }
};

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-window.js
function createRoundedBadge(icon2) {
  const badge = document.createElement("astro-dev-toolbar-badge");
  badge.shadowRoot.innerHTML += `
		<style>
			:host>div {
				padding: 12px 8px;
				font-size: 14px;
				display: flex;
				gap: 4px;
			}
		</style>
	`;
  badge.innerHTML = `<astro-dev-toolbar-icon icon="${icon2}"></astro-dev-toolbar-icon>0`;
  return {
    badge,
    updateCount: (count) => {
      if (count === 0) {
        badge.badgeStyle = "green";
      } else {
        badge.badgeStyle = "purple";
      }
      badge.innerHTML = `<astro-dev-toolbar-icon icon="${icon2}"></astro-dev-toolbar-icon>${count}`;
    }
  };
}
var DevToolbarAuditListWindow = class extends HTMLElement {
  _audits = [];
  shadowRoot;
  badges = {};
  get audits() {
    return this._audits;
  }
  set audits(value) {
    this._audits = value;
    this.render();
  }
  constructor() {
    super();
    this.shadowRoot = this.attachShadow({ mode: "open" });
    this.shadowRoot.innerHTML = `<style>
			:host {
				box-sizing: border-box;
				display: flex;
				flex-direction: column;
				background: linear-gradient(0deg, #13151a, #13151a), linear-gradient(0deg, #343841, #343841);
				border: 1px solid rgba(52, 56, 65, 1);
				width: min(640px, 100%);
				max-height: 480px;
				border-radius: 12px;
				padding: 24px;
				font-family:
					ui-sans-serif,
					system-ui,
					-apple-system,
					BlinkMacSystemFont,
					"Segoe UI",
					Roboto,
					"Helvetica Neue",
					Arial,
					"Noto Sans",
					sans-serif,
					"Apple Color Emoji",
					"Segoe UI Emoji",
					"Segoe UI Symbol",
					"Noto Color Emoji";
				color: rgba(191, 193, 201, 1);
				position: fixed;
				z-index: 2000000009;
				bottom: 72px;
				left: 50%;
				transform: translateX(-50%);
				box-shadow:
					0px 0px 0px 0px rgba(19, 21, 26, 0.3),
					0px 1px 2px 0px rgba(19, 21, 26, 0.29),
					0px 4px 4px 0px rgba(19, 21, 26, 0.26),
					0px 10px 6px 0px rgba(19, 21, 26, 0.15),
					0px 17px 7px 0px rgba(19, 21, 26, 0.04),
					0px 26px 7px 0px rgba(19, 21, 26, 0.01);
			}

			@media (forced-colors: active) {
				:host {
					background: white;
				}
			}

			@media (max-width: 640px) {
				:host {
					border-radius: 0;
				}
			}

			hr,
			::slotted(hr) {
				border: 1px solid rgba(27, 30, 36, 1);
				margin: 1em 0;
			}

			.reset-button {
				text-align: left;
				border: none;
				margin: 0;
				width: auto;
				overflow: visible;
				background: transparent;
				font: inherit;
				line-height: normal;
				-webkit-font-smoothing: inherit;
				-moz-osx-font-smoothing: inherit;
				-webkit-appearance: none;
				padding: 0;
			}

			:host {
				left: initial;
				top: 8px;
				right: 8px;
				transform: none;
				width: 350px;
				min-height: 350px;
				max-height: 420px;
				padding: 0;
				overflow: hidden;
			}

			hr {
				margin: 0;
			}

			header {
				display: flex;
				align-items: center;
				gap: 4px;
			}

			header > section {
				display: flex;
				align-items: center;
				gap: 1em;
				padding: 18px;
			}

			header.category-header {
				background: rgba(27, 30, 36, 1);
				padding: 10px 16px;
				position: sticky;
				top: 0;
			}

			header.category-header astro-dev-toolbar-icon {
				opacity: 0.6;
			}

			#audit-counts {
				display: flex;
				gap: 0.5em;
			}

			#audit-counts > div {
				display: flex;
				gap: 8px;
				align-items: center;
			}

			ul,
			li {
				margin: 0;
				padding: 0;
				list-style: none;
			}

			h1 {
				font-size: 24px;
				font-weight: 600;
				color: #fff;
				margin: 0;
			}

			h2 {
				font-weight: 600;
				margin: 0;
				color: white;
				font-size: 14px;
			}

			h3 {
				font-weight: normal;
				margin: 0;
				color: white;
				font-size: 14px;
			}

			.audit-header {
				display: flex;
				gap: 8px;
				align-items: center;
			}

			.audit-selector {
				color: white;
				font-size: 12px;
				font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
					"Liberation Mono", "Courier New", monospace;
				border: 1px solid rgba(255, 255, 255, 0.1);
				border-radius: 4px;
				padding: 4px 6px;
			}

			[active] .audit-selector:hover {
				text-decoration: underline;
				cursor: pointer;
			}

			.selector-title-container {
				display: flex;
				align-items: center;
				gap: 8px;
			}

			astro-dev-toolbar-icon {
				color: white;
				fill: white;
				display: inline-block;
				height: 16px;
				width: 16px;
			}

			#audit-list {
				display: flex;
				flex-direction: column;
				overflow: auto;
				overscroll-behavior: contain;
				height: 100%;
			}

			#back-to-list {
				display: none;
				align-items: center;
				justify-content: center;
				background: rgba(27, 30, 36, 1);
				gap: 8px;
				padding: 8px;
				color: white;
				font-size: 14px;
				padding-right: 24px;
			}

			#back-to-list:hover {
				cursor: pointer;
				background: #313236;
			}

			#back-to-list:has(+ #audit-list astro-dev-toolbar-audit-list-item[active]) {
				display: flex;
			}

			.no-audit-container {
				display: flex;
				flex-direction: column;
				padding: 24px;
			}

			.no-audit-container h1 {
				font-size: 20px;
			}

			.no-audit-container astro-dev-toolbar-icon {
				width: auto;
				height: auto;
				margin: 0 auto;
			}
</style>

<template id="category-template">
	<div>
		<header class="category-header">
		</header>
		<div class="category-content"></div>
	</div>
</template>

<header>
	<section id="header-left">
		<h1>Audit</h1>
		<section id="audit-counts"></section>
	</section>
</header>
<hr />
<button id="back-to-list" class="reset-button">
	<astro-dev-toolbar-icon icon="arrow-left"></astro-dev-toolbar-icon>
	Back to list
</button>
<div id="audit-list"></div>
		`;
    const auditCounts = this.shadowRoot.getElementById("audit-counts");
    if (auditCounts) {
      rulesCategories.forEach((category) => {
        const headerEntryContainer = document.createElement("div");
        const auditCount = this.audits.filter(
          (audit) => getAuditCategory(audit.rule) === category.code
        ).length;
        const categoryBadge = createRoundedBadge(category.icon);
        categoryBadge.updateCount(auditCount);
        headerEntryContainer.append(categoryBadge.badge);
        auditCounts.append(headerEntryContainer);
        this.badges[category.code] = categoryBadge;
      });
    }
    const backToListButton = this.shadowRoot.getElementById("back-to-list");
    if (backToListButton) {
      backToListButton.addEventListener("click", () => {
        const activeAudit = this.shadowRoot.querySelector(
          "astro-dev-toolbar-audit-list-item[active]"
        );
        if (activeAudit) {
          activeAudit.toggleAttribute("active", false);
        }
      });
    }
  }
  connectedCallback() {
    this.render();
  }
  updateAuditList() {
    const auditListContainer = this.shadowRoot.getElementById("audit-list");
    if (auditListContainer) {
      auditListContainer.innerHTML = "";
      if (this.audits.length > 0) {
        for (const category of rulesCategories) {
          const template = this.shadowRoot.getElementById(
            "category-template"
          );
          if (!template) return;
          const clone = document.importNode(template.content, true);
          const categoryContainer = clone.querySelector("div");
          const categoryHeader = clone.querySelector(".category-header");
          categoryHeader.innerHTML = `<astro-dev-toolbar-icon icon="${category.icon}"></astro-dev-toolbar-icon><h2>${category.name}</h2>`;
          categoryContainer.append(categoryHeader);
          const categoryContent = clone.querySelector(".category-content");
          const categoryAudits = this.audits.filter(
            (audit) => getAuditCategory(audit.rule) === category.code
          );
          for (const audit of categoryAudits) {
            if (audit.card) categoryContent.append(audit.card);
          }
          categoryContainer.append(categoryContent);
          auditListContainer.append(categoryContainer);
        }
      } else {
        const noAuditContainer = document.createElement("div");
        noAuditContainer.classList.add("no-audit-container");
        noAuditContainer.innerHTML = `
					<header>
						<h1></astro-dev-toolbar-icon>No accessibility or performance issues detected.</h1>
					</header>
					<p>
						Nice work! This app scans the page and highlights common accessibility and performance issues for you, like a missing "alt" attribute on an image, or an image not using performant attributes.
					</p>
					<astro-dev-toolbar-icon icon="houston-detective"></astro-dev-toolbar-icon>
					`;
        auditListContainer.append(noAuditContainer);
      }
    }
  }
  updateBadgeCounts() {
    for (const category of rulesCategories) {
      const auditCount = this.audits.filter(
        (audit) => getAuditCategory(audit.rule) === category.code
      ).length;
      this.badges[category.code].updateCount(auditCount);
    }
  }
  render() {
    this.updateAuditList();
    this.updateBadgeCounts();
  }
};

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js
function truncate(val, maxLength) {
  return val.length > maxLength ? val.slice(0, maxLength - 1) + "&hellip;" : val;
}
function createAuditUI(audit, audits) {
  const rect = audit.auditedElement.getBoundingClientRect();
  const highlight = createHighlight(rect, "warning", { "data-audit-code": audit.rule.code });
  const resolvedAuditRule = resolveAuditRule(audit.rule, audit.auditedElement);
  const tooltip = buildAuditTooltip(resolvedAuditRule, audit.auditedElement);
  const card = buildAuditCard(resolvedAuditRule, highlight, audit.auditedElement, audits);
  ["focus", "mouseover"].forEach((event) => {
    const attribute = event === "focus" ? "active" : "hovered";
    highlight.addEventListener(event, () => {
      if (event === "focus") {
        audits.forEach((adt) => {
          if (adt.card) adt.card.toggleAttribute("active", false);
        });
        if (!card.isManualFocus) card.scrollIntoView();
        card.toggleAttribute("active", true);
      } else {
        card.toggleAttribute(attribute, true);
      }
    });
  });
  highlight.addEventListener("mouseout", () => {
    card.toggleAttribute("hovered", false);
  });
  const { isFixed } = getElementsPositionInDocument(audit.auditedElement);
  if (isFixed) {
    tooltip.style.position = highlight.style.position = "fixed";
  }
  attachTooltipToHighlight(highlight, tooltip, audit.auditedElement);
  return { highlight, card };
}
function buildAuditTooltip(rule, element) {
  const tooltip = document.createElement("astro-dev-toolbar-tooltip");
  const { title, message } = rule;
  tooltip.sections = [
    {
      icon: "warning",
      title: escape(title)
    },
    {
      content: escape(message)
    }
  ];
  const { file: elementFile, location: elementPosition } = getAnnotationsForElement(element) ?? {};
  if (elementFile) {
    const elementFileWithPosition = elementFile + (elementPosition ? ":" + elementPosition : "");
    tooltip.sections.push({
      content: elementFileWithPosition.slice(
        window.__astro_dev_toolbar__.root.length - 1
        // We want to keep the final slash, so minus one.
      ),
      clickDescription: "Click to go to file",
      async clickAction() {
        await fetch("/__open-in-editor?file=" + encodeURIComponent(elementFileWithPosition));
      }
    });
  }
  return tooltip;
}
function buildAuditCard(rule, highlightElement, auditedElement, audits) {
  const card = document.createElement(
    "astro-dev-toolbar-audit-list-item"
  );
  card.clickAction = () => {
    if (card.hasAttribute("active")) return;
    audits.forEach((audit) => {
      audit.card?.toggleAttribute("active", false);
    });
    highlightElement.scrollIntoView();
    card.isManualFocus = true;
    highlightElement.focus();
    card.isManualFocus = false;
  };
  const selectorTitleContainer = document.createElement("section");
  selectorTitleContainer.classList.add("selector-title-container");
  const selector = document.createElement("span");
  const selectorName = truncate(auditedElement.tagName.toLowerCase(), 8);
  selector.classList.add("audit-selector");
  selector.innerHTML = escape(selectorName);
  const title = document.createElement("h3");
  title.classList.add("audit-title");
  title.innerText = rule.title;
  selectorTitleContainer.append(selector, title);
  card.append(selectorTitleContainer);
  const extendedInfo = document.createElement("div");
  extendedInfo.classList.add("extended-info");
  const selectorButton = document.createElement("button");
  selectorButton.className = "audit-selector reset-button";
  selectorButton.innerHTML = `${selectorName} <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256"><path d="M128,136v64a8,8,0,0,1-16,0V155.32L45.66,221.66a8,8,0,0,1-11.32-11.32L100.68,144H56a8,8,0,0,1,0-16h64A8,8,0,0,1,128,136ZM208,32H80A16,16,0,0,0,64,48V96a8,8,0,0,0,16,0V48H208V176H160a8,8,0,0,0,0,16h48a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Z"></path></svg>`;
  selectorButton.addEventListener("click", () => {
    highlightElement.scrollIntoView();
    highlightElement.focus();
  });
  extendedInfo.append(title.cloneNode(true));
  extendedInfo.append(selectorButton);
  extendedInfo.append(document.createElement("hr"));
  const message = document.createElement("p");
  message.classList.add("audit-message");
  message.innerHTML = simpleRenderMarkdown(rule.message);
  extendedInfo.appendChild(message);
  const description = rule.description;
  if (description) {
    const descriptionElement = document.createElement("p");
    descriptionElement.classList.add("audit-description");
    descriptionElement.innerHTML = simpleRenderMarkdown(description);
    extendedInfo.appendChild(descriptionElement);
  }
  card.shadowRoot.appendChild(extendedInfo);
  return card;
}
var linkRegex = /\[([^[]+)\]\((.*)\)/g;
var boldRegex = /\*\*(.+)\*\*/g;
var codeRegex = /`([^`]+)`/g;
function simpleRenderMarkdown(markdown) {
  return escape(markdown).replace(linkRegex, `<a href="$2" target="_blank">$1</a>`).replace(boldRegex, "<b>$1</b>").replace(codeRegex, "<code>$1</code>");
}

// node_modules/astro/dist/runtime/client/dev-toolbar/apps/audit/index.js
var icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 1 20 16" aria-hidden="true"><path fill="#fff" d="M.6 2A1.1 1.1 0 0 1 1.7.9h16.6a1.1 1.1 0 1 1 0 2.2H1.6A1.1 1.1 0 0 1 .8 2Zm1.1 7.1h6a1.1 1.1 0 0 0 0-2.2h-6a1.1 1.1 0 0 0 0 2.2ZM9.3 13H1.8a1.1 1.1 0 1 0 0 2.2h7.5a1.1 1.1 0 1 0 0-2.2Zm11.3 1.9a1.1 1.1 0 0 1-1.5 0l-1.7-1.7a4.1 4.1 0 1 1 1.6-1.6l1.6 1.7a1.1 1.1 0 0 1 0 1.6Zm-5.3-3.4a1.9 1.9 0 1 0 0-3.8 1.9 1.9 0 0 0 0 3.8Z"/></svg>';
try {
  customElements.define("astro-dev-toolbar-audit-window", DevToolbarAuditListWindow);
  customElements.define("astro-dev-toolbar-audit-list-item", DevToolbarAuditListItem);
} catch {
}
var showState = false;
var audit_default = {
  id: "astro:audit",
  name: "Audit",
  icon,
  async init(canvas, eventTarget) {
    let audits = [];
    let auditWindow = document.createElement(
      "astro-dev-toolbar-audit-window"
    );
    let hasCreatedUI = false;
    auditWindow.popover = "";
    canvas.appendChild(auditWindow);
    await run();
    let mutationDebounce;
    const observer = new MutationObserver(() => {
      if (mutationDebounce) {
        clearTimeout(mutationDebounce);
      }
      mutationDebounce = setTimeout(() => {
        settings.logger.verboseLog("Rerunning audit lints because the DOM has been updated.");
        if ("requestIdleCallback" in window) {
          window.requestIdleCallback(
            async () => {
              run().then(() => {
                if (showState) createAuditsUI();
              });
            },
            { timeout: 300 }
          );
        } else {
          setTimeout(async () => {
            run().then(() => {
              if (showState) createAuditsUI();
            });
          }, 150);
        }
      }, 250);
    });
    setupObserver();
    document.addEventListener("astro:before-preparation", () => {
      observer.disconnect();
    });
    document.addEventListener("astro:after-swap", async () => {
      run();
    });
    document.addEventListener("astro:page-load", async () => {
      refreshLintPositions();
      setTimeout(() => {
        setupObserver();
      }, 100);
    });
    eventTarget.addEventListener("app-toggled", (event) => {
      if (event.detail.state === true) {
        showState = true;
        createAuditsUI();
      } else {
        showState = false;
      }
    });
    closeOnOutsideClick(eventTarget, () => {
      const activeAudits = audits.filter((audit) => audit.card?.hasAttribute("active"));
      if (activeAudits.length > 0) {
        activeAudits.forEach((audit) => {
          audit.card?.toggleAttribute("active", false);
        });
        return true;
      }
      return false;
    });
    async function createAuditsUI() {
      if (hasCreatedUI) return;
      const fragment = document.createDocumentFragment();
      for (const audit of audits) {
        const { card, highlight } = createAuditUI(audit, audits);
        audit.card = card;
        audit.highlight = highlight;
        fragment.appendChild(highlight);
      }
      auditWindow.audits = audits;
      canvas.appendChild(fragment);
      hasCreatedUI = true;
    }
    async function run() {
      processAnnotations();
      await lint();
    }
    async function lint() {
      if (audits.length > 0) {
        audits.forEach((audit) => {
          audit.highlight?.remove();
          audit.card?.remove();
        });
        audits = [];
        hasCreatedUI = false;
      }
      const selectorCache = /* @__PURE__ */ new Map();
      for (const ruleCategory of rulesCategories) {
        for (const rule of ruleCategory.rules) {
          const elements = selectorCache.get(rule.selector) ?? document.querySelectorAll(rule.selector);
          let matches = [];
          if (typeof rule.match === "undefined") {
            matches = Array.from(elements);
          } else {
            for (const element of elements) {
              try {
                if (await rule.match(element)) {
                  matches.push(element);
                }
              } catch (e) {
                settings.logger.error(`Error while running audit's match function: ${e}`);
              }
            }
          }
          for (const element of matches) {
            if (audits.some((audit) => audit.auditedElement === element)) continue;
            await createAuditProblem(rule, element);
          }
        }
      }
      eventTarget.dispatchEvent(
        new CustomEvent("toggle-notification", {
          detail: {
            state: audits.length > 0
          }
        })
      );
    }
    async function createAuditProblem(rule, originalElement) {
      const computedStyle = window.getComputedStyle(originalElement);
      const targetedElement = originalElement.children[0] || originalElement;
      if (targetedElement.offsetParent === null || computedStyle.display === "none") {
        return;
      }
      if (originalElement.nodeName === "IMG" && !originalElement.complete) {
        await new Promise((resolve) => {
          originalElement.addEventListener("load", () => resolve(), { once: true });
          originalElement.addEventListener("error", () => resolve(), { once: true });
        });
      }
      audits.push({
        auditedElement: originalElement,
        rule,
        card: null,
        highlight: null
      });
    }
    function refreshLintPositions() {
      audits.forEach(({ highlight, auditedElement }) => {
        const rect = auditedElement.getBoundingClientRect();
        if (highlight) positionHighlight(highlight, rect);
      });
    }
    ["scroll", "resize"].forEach((event) => {
      window.addEventListener(event, refreshLintPositions);
    });
    function setupObserver() {
      observer.observe(document.body, {
        childList: true,
        subtree: true
      });
    }
  }
};
export {
  audit_default as default
};
//# sourceMappingURL=audit-XFDIA4TR.js.map
