var u=(a,e,t)=>new Promise((s,r)=>{var n=o=>{try{c(t.next(o))}catch(g){r(g)}},i=o=>{try{c(t.throw(o))}catch(g){r(g)}},c=o=>o.done?s(o.value):Promise.resolve(o.value).then(n,i);c((t=t.apply(a,e)).next())});function b(a,e){return u(this,null,function*(){const t=yield h(a),s=yield l(t),r=yield m(s,e,a),n=f(r);return F(n.src,a.name)})}function h(a){return u(this,null,function*(){return new Promise(e=>{const t=new FileReader;t.readAsDataURL(a),t.onload=function(s){e(s.target.result)}})})}function l(a){return u(this,null,function*(){const e=document.createElement("img");e.setAttribute("src",a),yield new Promise(s=>e.onload=s);const t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),t})}function m(a,e,t){return u(this,null,function*(){const s=yield d(t),r=a.getContext("2d"),n=Math.floor(s.width/25);r.font=n,r.fillStyle="#FFFFFF",r.strokeStyle="rgba(255, 255, 255, 1)",r.shadowColor="rgba(255, 255, 255, 1)",r.shadowOffsetX=0,r.shadowOffsetY=0;const i=(s.width-n)/n,c=[];return e.forEach((o,g)=>{o.length<=i?c.push({mark:o,start:n/2}):(c.push({mark:o.substring(i),start:n/2+n*3}),c.push({mark:o.substring(0,i),start:n/2}))}),c.forEach((o,g)=>{r.fillText(o.mark,o.start,w(s.height,g,n))}),a})}function w(a,e,t){return e===0?a-t:a-e*t-t-e*(t/3)}function d(a){return new Promise((e,t)=>{var s=new FileReader;s.onload=function(r){var n=new Image;n.onload=function(){e({width:n.width,height:n.height})},n.src=r.target.result},s.onerror=function(r){t(r)},s.readAsDataURL(a)})}function f(a){const e=new Image;return e.src=a.toDataURL("image/png"),e}function F(a,e){const t=a.split(","),s=t[0].match(/:(.*?);/)[1],r=atob(t[1]);let n=r.length;const i=new Uint8Array(n);for(;n--;)i[n]=r.charCodeAt(n);return new File([i],e,{type:s})}export{b as f};
