export function getApproximateDataUriSizeInBytes(dataUri: string): number {
  const commaIndex = dataUri.indexOf(",")
  if (commaIndex === -1) return 0
  const base64 = dataUri.slice(commaIndex + 1)
  const padding = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0
  return Math.floor((base64.length * 3) / 4) - padding
}
