export async function downloadFile(
  url: string,
  filename: string,
  isBlobUrl: boolean = false,
) {
  try {
    let blobUrl = url;

    if (!isBlobUrl) {
      const response = await fetch(url);
      const blob = await response.blob();
      blobUrl = URL.createObjectURL(blob);
    }

    const link = document.createElement("a");
    link.href = blobUrl;
    link.download = filename;
    link.click();
    URL.revokeObjectURL(blobUrl);
  } catch (error) {
    console.error("Error downloading file:", error);
  }
}
