convertImagesToBase64 = async svgElement => {
  const imageElements = svgElement.querySelectorAll('image')
  const promises = Array.from(imageElements).map(async img => {
    const href = img.getAttribute('xlink:href') || img.getAttribute('href')
    if (href && !href.startsWith('data:')) {
      try {
        const response = await fetch(href)
        const blob = await response.blob()
        const reader = new FileReader()
        return new Promise(resolve => {
          reader.onload = () => {
            setHref(img, reader.result)
            resolve()
          }
          reader.readAsDataURL(blob)
        })
      } catch (error) {
        console.error('Failed to fetch image:', error)
      }
    }
  })
  await Promise.all(promises)
}
Utility function to convert all external image links in an SVG element to Base64 data URLs.
@param {SVGElement} svgElement - The SVG element to process.
@returns {Promise<void>}