
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * https://fantastic-admin.hurui.me
 */
  
import{t as e}from"./preload-helper-HclGiUj8.js";import{t}from"./dom-to-png-BbPRUKX6-CWMLafQI.js";async function n({domElement:n,fileName:r,scale:i=2,orientation:a=`auto`,overflowTolerance:o=.2,aspectRatio:s=null}){if(!n)return Promise.reject(`No domElement provided`);let c=typeof navigator<`u`&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent),l;try{l=(await e(async()=>{let{default:e}=await import(`./__vite-optional-peer-dep_jspdf_vue-data-ui-t5dhqR-O.js`);return{default:e}},[],import.meta.url)).default}catch{return Promise.reject(`jspdf is not installed. Run npm install jspdf`)}let u={width:595.28,height:841.89},d={width:841.89,height:595.28},f=1e3;function p(e){if(e==null)return null;if(typeof e==`number`&&e>0)return{w:1,h:e};if(typeof e==`string`){let t=e.split(`/`).map(e=>e.trim());if(t.length===2){let e=Number(t[0]),n=Number(t[1]);if(e>0&&n>0)return{w:e,h:n}}else if(t.length===1){let e=Number(t[0]);if(e>0)return{w:1,h:e}}}return null}let m=p(s),h=m?{width:f,height:f*(m.h/m.w)}:null,g=m?{width:h.height,height:h.width}:null;if(c)try{await t({container:n,scale:i}),await t({container:n,scale:i}),await t({container:n,scale:i}),await t({container:n,scale:i})}catch{}let _=await t({container:n,scale:i});return await new Promise((e,t)=>{let n=new window.Image;n.onload=function(){let t=.5,i=n.naturalWidth,s=n.naturalHeight,c=a===`auto`?s>=i?`p`:`l`:a,f=c===`l`?m?g:d:m?h:u,p=f.width/i,v=f.height/s,y=s*p,b=`single`,x;y<=f.height+t?x=p:y<=f.height*(1+o)?x=Math.min(p,v):(b=`multi`,x=p);let S=i*x,C=s*x,w=(f.width-S)/2,T=new l({orientation:c,unit:`pt`,format:m?[f.width,f.height]:`a4`});if(b===`single`){let e=(f.height-C)/2;T.addImage(_,`PNG`,w,e,S,C,``,`FAST`)}else{let e=f.height/x,n=s,r=0;for(;n>t;)T.addImage(_,`PNG`,w,r,S,C,``,`FAST`),n-=e,r-=f.height,n>t&&T.addPage()}T.save(`${r}.pdf`),e()},n.onerror=e=>t(`Failed to load image for PDF: `+e),n.src=_})}export{n as default};