function base64ToBlob(base64, type = "application/octet-stream") {
  const binStr = window.atob(base64);
  const len = binStr.length;
  const arr = new Uint8Array(len);
  for (let i = 0; i < len; i++) {
    arr[i] = binStr.charCodeAt(i);
  }
  return new Blob([arr], { type: type });
}

export const createUrlFromBase64 = (b64: string, type?: string) => {
  if (b64) {
    const blob = base64ToBlob(b64, type || "application/pdf");
    return URL.createObjectURL(blob);
  }
};
