| 1 |
- import{C as d}from"./index.js";function c(e){const o=e.split(","),i=o[0].match(/:(.*?);/)[1],t=window.atob(o[1]);let n=t.length;const a=new Uint8Array(n);for(;n--;)a[n]=t.charCodeAt(n);return o.length==1?new Blob([a],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}):new Blob([a],{type:i})}function m(e){return new Promise((o,r)=>{e||r();const i=new FileReader;i.readAsDataURL(e),i.onload=function(t){const n=t.target.result;o(n)}})}function l(e,o){return new Promise((r,i)=>{let t=document.createElement("CANVAS");const n=t.getContext("2d"),a=new Image;a.crossOrigin="",a.onload=function(){if(!t||!n)return i();t.height=a.height,t.width=a.width,n.drawImage(a,0,0);const s=t.toDataURL(o||"image/png");t=null,r(s)},a.src=e})}function p(e,o,r,i){l(e).then(t=>{u(t,o,r,i)})}function u(e,o,r,i){const t=c(e);f(t,o,r,i)}function f(e,o,r,i){const t=typeof i!="undefined"?[i,e]:[e],n=new Blob(t,{type:r||"application/octet-stream"}),a=window.URL.createObjectURL(n),s=document.createElement("a");s.style.display="none",s.href=a,s.setAttribute("download",o),typeof s.download=="undefined"&&s.setAttribute("target","_blank"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(a)}function b({url:e,target:o="_blank",fileName:r}){const i=window.navigator.userAgent.toLowerCase().indexOf("chrome")>-1,t=window.navigator.userAgent.toLowerCase().indexOf("safari")>-1;if(/(iP)/g.test(window.navigator.userAgent))return!1;if(i||t){const n=document.createElement("a");if(n.href=e,n.target=o,n.download!==void 0&&(n.download=r||e.substring(e.lastIndexOf("/")+1,e.length)),document.createEvent){const a=document.createEvent("MouseEvents");return a.initEvent("click",!0,!0),n.dispatchEvent(a),!0}}return e.indexOf("?")===-1&&(e+="?download"),d(e,{target:o}),!0}export{c as a,u as b,p as c,b as d,f as e,m as f};
|