import{d as f}from"./chunk-4CLCTAJ7.js";function w(c){return f(this,null,function*(){let a=yield _(c),r=a.naturalWidth,n=a.naturalHeight;if(!r||!n)return null;let i=document.createElement("canvas");i.width=r,i.height=n;let o=i.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.drawImage(a,0,0);let s;try{s=o.getImageData(0,0,r,n)}catch{return null}let e=s.data,u=0,g=0,h=0,M=0;for(let t=0;t<e.length;t+=4){if(e[t+3]===0)continue;u++;let l=e[t],m=e[t+1],I=e[t+2];if(Math.max(l,m,I)-Math.min(l,m,I)>32)continue;g++;let d=l*.299+m*.587+I*.114;d<128&&h++,d>=72&&d<=184&&M++}if(!u||!g||h/u<.02||M/g>.35)return null;for(let t=0;t<e.length;t+=4){if(e[t+3]===0)continue;Math.max(e[t],e[t+1],e[t+2])-Math.min(e[t],e[t+1],e[t+2])<=32&&(e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2])}return o.putImageData(s,0,0),i.toDataURL("image/png")})}function _(c){return new Promise((a,r)=>{let n=new Image;n.onload=()=>a(n),n.onerror=()=>r(new Error("could not read artwork")),n.src=c})}export{w as whiteInkPlate};
