2 lines
31 KiB
JavaScript
2 lines
31 KiB
JavaScript
import{A as e,D as t}from"./package-Bop5TfAT.js";var n=t(((t,n)=>{(function(e){if(typeof t==`object`&&n!==void 0)n.exports=e();else if(typeof define==`function`&&define.amd)define([],e);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.pica=e()}})(function(){return(function(){function t(n,r,i){function a(s,c){if(!r[s]){if(!n[s]){var l=typeof e==`function`&&e;if(!c&&l)return l(s,!0);if(o)return o(s,!0);var u=Error(`Cannot find module '`+s+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=r[s]={exports:{}};n[s][0].call(d.exports,function(e){var t=n[s][1][e];return a(t||e)},d,d.exports,t,n,r,i)}return r[s].exports}for(var o=typeof e==`function`&&e,s=0;s<i.length;s++)a(i[s]);return a}return t})()({1:[function(e,t,n){var r=e(`inherits`),i=e(`multimath`),a=e(`./mm_unsharp_mask`),o=e(`./mm_resize`);function s(e){var t=e||[],n={js:t.indexOf(`js`)>=0,wasm:t.indexOf(`wasm`)>=0};i.call(this,n),this.features={js:n.js,wasm:n.wasm&&this.has_wasm()},this.use(a),this.use(o)}r(s,i),s.prototype.resizeAndUnsharp=function(e,t){var n=this.resize(e,t);return e.unsharpAmount&&this.unsharp_mask(n,e.toWidth,e.toHeight,e.unsharpAmount,e.unsharpRadius,e.unsharpThreshold),n},t.exports=s},{"./mm_resize":4,"./mm_unsharp_mask":9,inherits:19,multimath:20}],2:[function(e,t,n){function r(e){return e<0?0:e>255?255:e}function i(e,t,n,i,a,o){var s,c,l,u,d,f,p,m,h,g,_,v=0,y=0;for(h=0;h<i;h++){for(d=0,g=0;g<a;g++){for(f=o[d++],p=o[d++],m=v+f*4|0,s=c=l=u=0;p>0;p--)_=o[d++],u=u+_*e[m+3]|0,l=l+_*e[m+2]|0,c=c+_*e[m+1]|0,s=s+_*e[m]|0,m=m+4|0;t[y+3]=r(u+8192>>14),t[y+2]=r(l+8192>>14),t[y+1]=r(c+8192>>14),t[y]=r(s+8192>>14),y=y+i*4|0}y=(h+1)*4|0,v=(h+1)*n*4|0}}function a(e,t,n,i,a,o){var s,c,l,u,d,f,p,m,h,g,_,v=0,y=0;for(h=0;h<i;h++){for(d=0,g=0;g<a;g++){for(f=o[d++],p=o[d++],m=v+f*4|0,s=c=l=u=0;p>0;p--)_=o[d++],u=u+_*e[m+3]|0,l=l+_*e[m+2]|0,c=c+_*e[m+1]|0,s=s+_*e[m]|0,m=m+4|0;t[y+3]=r(u+8192>>14),t[y+2]=r(l+8192>>14),t[y+1]=r(c+8192>>14),t[y]=r(s+8192>>14),y=y+i*4|0}y=(h+1)*4|0,v=(h+1)*n*4|0}}t.exports={convolveHorizontally:i,convolveVertically:a}},{}],3:[function(e,t,n){t.exports=`AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEXA2AAAGAGf39/f39/AGAHf39/f39/fwACDwEDZW52Bm1lbW9yeQIAAAMEAwABAgYGAX8AQQALB1cFEV9fd2FzbV9jYWxsX2N0b3JzAAAIY29udm9sdmUAAQpjb252b2x2ZUhWAAIMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAK7AMDAwABC8YDAQ9/AkAgA0UNACAERQ0AA0AgDCENQQAhE0EAIQcDQCAHQQJqIQYCfyAHQQF0IAVqIgcuAQIiFEUEQEGAwAAhCEGAwAAhCUGAwAAhCkGAwAAhCyAGDAELIBIgBy4BAGohCEEAIQsgFCEHQQAhDiAGIQlBACEPQQAhEANAIAUgCUEBdGouAQAiESAAIAhBAnRqKAIAIgpBGHZsIBBqIRAgCkH/AXEgEWwgC2ohCyAKQRB2Qf8BcSARbCAPaiEPIApBCHZB/wFxIBFsIA5qIQ4gCEEBaiEIIAlBAWohCSAHQQFrIgcNAAsgC0GAQGshCCAOQYBAayEJIA9BgEBrIQogEEGAQGshCyAGIBRqCyEHIAEgDUECdGogCUEOdSIGQf8BIAZB/wFIGyIGQQAgBkEAShtBCHRBgP4DcSAKQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EQdEGAgPwHcSALQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EYdHJyIAhBDnUiBkH/ASAGQf8BSBsiBkEAIAZBAEobcjYCACADIA1qIQ0gE0EBaiITIARHDQALIAxBAWoiDCACbCESIAMgDEcNAAsLCx4AQQAgAiADIAQgBSAAEAEgAkEAIAQgBSAGIAEQAQs=`},{}],4:[function(e,t,n){t.exports={name:`resize`,fn:e(`./resize`),wasm_fn:e(`./resize_wasm`),wasm_src:e(`./convolve_wasm_base64`)}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(e,t,n){var r=e(`./resize_filter_gen`),i=e(`./convolve`).convolveHorizontally,a=e(`./convolve`).convolveVertically;function o(e,t,n){for(var r=3,i=t*n*4|0;r<i;)e[r]=255,r=r+4|0}t.exports=function(e){var t=e.src,n=e.width,s=e.height,c=e.toWidth,l=e.toHeight,u=e.scaleX||e.toWidth/e.width,d=e.scaleY||e.toHeight/e.height,f=e.offsetX||0,p=e.offsetY||0,m=e.dest||new Uint8Array(c*l*4),h=e.quality===void 0?3:e.quality,g=e.alpha||!1,_=r(h,n,c,u,f),v=r(h,s,l,d,p),y=new Uint8Array(c*s*4);return i(t,y,n,s,c,_),a(y,m,s,c,l,v),g||o(m,c,l),m}},{"./convolve":2,"./resize_filter_gen":6}],6:[function(e,t,n){var r=e(`./resize_filter_info`),i=14;function a(e){return Math.round(e*((1<<i)-1))}t.exports=function(e,t,n,i,o){var s=r[e].filter,c=1/i,l=Math.min(1,i),u=r[e].win/l,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=Math.floor((u+1)*2),k=new Int16Array((O+2)*n),A=0,j=!k.subarray||!k.set;for(d=0;d<n;d++){for(f=(d+.5)*c+o,p=Math.max(0,Math.floor(f-u)),m=Math.min(t-1,Math.ceil(f+u)),h=m-p+1,g=new Float32Array(h),_=new Int16Array(h),v=0,y=p,b=0;y<=m;y++,b++)x=s((y+.5-f)*l),v+=x,g[b]=x;for(S=0,b=0;b<g.length;b++)C=g[b]/v,S+=C,_[b]=a(C);for(_[n>>1]+=a(1-S),w=0;w<_.length&&_[w]===0;)w++;if(w<_.length){for(T=_.length-1;T>0&&_[T]===0;)T--;if(E=p+w,D=T-w+1,k[A++]=E,k[A++]=D,!j)k.set(_.subarray(w,T+1),A),A+=D;else for(b=w;b<=T;b++)k[A++]=_[b]}else k[A++]=0,k[A++]=0}return k}},{"./resize_filter_info":7}],7:[function(e,t,n){t.exports=[{win:.5,filter:function(e){return+(e>=-.5&&e<.5)}},{win:1,filter:function(e){if(e<=-1||e>=1)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},{win:2,filter:function(e){if(e<=-2||e>=2)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},{win:3,filter:function(e){if(e<=-3||e>=3)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}}]},{}],8:[function(e,t,n){var r=e(`./resize_filter_gen`);function i(e,t,n){for(var r=3,i=t*n*4|0;r<i;)e[r]=255,r=r+4|0}function a(e){return new Uint8Array(e.buffer,0,e.byteLength)}var o=!0;try{o=new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]===1}catch{}function s(e,t,n){if(o){t.set(a(e),n);return}for(var r=n,i=0;i<e.length;i++){var s=e[i];t[r++]=s&255,t[r++]=s>>8&255}}t.exports=function(e){var t=e.src,n=e.width,a=e.height,o=e.toWidth,c=e.toHeight,l=e.scaleX||e.toWidth/e.width,u=e.scaleY||e.toHeight/e.height,d=e.offsetX||0,f=e.offsetY||0,p=e.dest||new Uint8Array(o*c*4),m=e.quality===void 0?3:e.quality,h=e.alpha||!1,g=r(m,n,o,l,d),_=r(m,a,c,u,f),v=this.__align(0+Math.max(t.byteLength,p.byteLength)),y=this.__align(v+a*o*4),b=this.__align(y+g.byteLength),x=b+_.byteLength,S=this.__instance(`resize`,x),C=new Uint8Array(this.__memory.buffer),w=new Uint32Array(this.__memory.buffer),T=new Uint32Array(t.buffer);return w.set(T),s(g,C,y),s(_,C,b),(S.exports.convolveHV||S.exports._convolveHV)(y,b,v,n,a,o,c),new Uint32Array(p.buffer).set(new Uint32Array(this.__memory.buffer,0,c*o)),h||i(p,o,c),p}},{"./resize_filter_gen":6}],9:[function(e,t,n){t.exports={name:`unsharp_mask`,fn:e(`./unsharp_mask`),wasm_fn:e(`./unsharp_mask_wasm`),wasm_src:e(`./unsharp_mask_wasm_base64`)}},{"./unsharp_mask":10,"./unsharp_mask_wasm":11,"./unsharp_mask_wasm_base64":12}],10:[function(e,t,n){var r=e(`glur/mono16`);function i(e,t,n){for(var r=t*n,i=new Uint16Array(r),a,o,s,c,l=0;l<r;l++)a=e[4*l],o=e[4*l+1],s=e[4*l+2],c=a>=o&&a>=s?a:o>=s&&o>=a?o:s,i[l]=c<<8;return i}t.exports=function(e,t,n,a,o,s){var c,l,u,d,f;if(!(a===0||o<.5)){o>2&&(o=2);var p=i(e,t,n),m=new Uint16Array(p);r(m,t,n,o);for(var h=a/100*4096+.5|0,g=s<<8,_=t*n,v=0;v<_;v++)c=p[v],d=c-m[v],Math.abs(d)>=g&&(l=c+(h*d+2048>>12),l=l>65280?65280:l,l=l<0?0:l,c=c===0?1:c,u=(l<<12)/c|0,f=v*4,e[f]=e[f]*u+2048>>12,e[f+1]=e[f+1]*u+2048>>12,e[f+2]=e[f+2]*u+2048>>12)}}},{"glur/mono16":18}],11:[function(e,t,n){t.exports=function(e,t,n,r,i,a){if(!(r===0||i<.5)){i>2&&(i=2);var o=t*n,s=o*4,c=o*2,l=o*2,u=Math.max(t,n)*4,d=32,f=0,p=s,m=p+c,h=m+l,g=h+l,_=g+u,v=this.__instance(`unsharp_mask`,s+c+l*2+u+d,{exp:Math.exp}),y=new Uint32Array(e.buffer);new Uint32Array(this.__memory.buffer).set(y);var b=v.exports.hsv_v16||v.exports._hsv_v16;b(f,p,t,n),b=v.exports.blurMono16||v.exports._blurMono16,b(p,m,h,g,_,t,n,i),b=v.exports.unsharp||v.exports._unsharp,b(f,f,p,m,t,n,r,a),y.set(new Uint32Array(this.__memory.buffer,0,o))}}},{}],12:[function(e,t,n){t.exports=`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`},{}],13:[function(e,t,n){var r=100;function i(e,t){this.create=e,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=t||2e3}i.prototype.acquire=function(){var e=this,t;return this.available.length===0?(t=this.create(),t.id=this.lastId++,t.release=function(){return e.release(t)}):t=this.available.pop(),this.acquired[t.id]=t,t},i.prototype.release=function(e){var t=this;delete this.acquired[e.id],e.lastUsed=Date.now(),this.available.push(e),this.timeoutId===0&&(this.timeoutId=setTimeout(function(){return t.gc()},r))},i.prototype.gc=function(){var e=this,t=Date.now();this.available=this.available.filter(function(n){return t-n.lastUsed>e.idle?(n.destroy(),!1):!0}),this.available.length===0?this.timeoutId=0:this.timeoutId=setTimeout(function(){return e.gc()},r)},t.exports=i},{}],14:[function(e,t,n){var r=2;t.exports=function(e,t,n,i,a,o){var s=n/e,c=i/t,l=(2*o+r+1)/a;if(l>.5)return[[n,i]];var u=Math.ceil(Math.log(Math.min(s,c))/Math.log(l));if(u<=1)return[[n,i]];for(var d=[],f=0;f<u;f++){var p=Math.round((e**(u-f-1)*n**+(f+1))**(1/u)),m=Math.round((t**(u-f-1)*i**+(f+1))**(1/u));d.push([p,m])}return d}},{}],15:[function(e,t,n){var r=1e-5;function i(e){var t=Math.round(e);return Math.abs(e-t)<r?t:Math.floor(e)}function a(e){var t=Math.round(e);return Math.abs(e-t)<r?t:Math.ceil(e)}t.exports=function(e){var t=e.toWidth/e.width,n=e.toHeight/e.height,r=i(e.srcTileSize*t)-2*e.destTileBorder,o=i(e.srcTileSize*n)-2*e.destTileBorder;if(r<1||o<1)throw Error(`Internal error in pica: target tile width/height is too small.`);var s,c,l,u,d,f,p=[],m;for(u=0;u<e.toHeight;u+=o)for(l=0;l<e.toWidth;l+=r)s=l-e.destTileBorder,s<0&&(s=0),d=l+r+e.destTileBorder-s,s+d>=e.toWidth&&(d=e.toWidth-s),c=u-e.destTileBorder,c<0&&(c=0),f=u+o+e.destTileBorder-c,c+f>=e.toHeight&&(f=e.toHeight-c),m={toX:s,toY:c,toWidth:d,toHeight:f,toInnerX:l,toInnerY:u,toInnerWidth:r,toInnerHeight:o,offsetX:s/t-i(s/t),offsetY:c/n-i(c/n),scaleX:t,scaleY:n,x:i(s/t),y:i(c/n),width:a(d/t),height:a(f/n)},p.push(m);return p}},{}],16:[function(e,t,n){function r(e){return Object.prototype.toString.call(e)}t.exports.isCanvas=function(e){var t=r(e);return t===`[object HTMLCanvasElement]`||t===`[object OffscreenCanvas]`||t===`[object Canvas]`},t.exports.isImage=function(e){return r(e)===`[object HTMLImageElement]`},t.exports.isImageBitmap=function(e){return r(e)===`[object ImageBitmap]`},t.exports.limiter=function(e){var t=0,n=[];function r(){t<e&&n.length&&(t++,n.shift()())}return function(e){return new Promise(function(i,a){n.push(function(){e().then(function(e){i(e),t--,r()},function(e){a(e),t--,r()})}),r()})}},t.exports.cib_quality_name=function(e){switch(e){case 0:return`pixelated`;case 1:return`low`;case 2:return`medium`}return`high`},t.exports.cib_support=function(e){return Promise.resolve().then(function(){if(typeof createImageBitmap>`u`)return!1;var t=e(100,100);return createImageBitmap(t,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:`high`}).then(function(e){var n=e.width===10;return e.close(),t=null,n})}).catch(function(){return!1})},t.exports.worker_offscreen_canvas_support=function(){return new Promise(function(e,t){if(typeof OffscreenCanvas>`u`){e(!1);return}function n(e){if(typeof createImageBitmap>`u`){e.postMessage(!1);return}Promise.resolve().then(function(){var e=new OffscreenCanvas(10,10);return e.getContext(`2d`).rect(0,0,1,1),createImageBitmap(e,0,0,1,1)}).then(function(){return e.postMessage(!0)},function(){return e.postMessage(!1)})}var r=btoa(`(${n.toString()})(self);`),i=new Worker(`data:text/javascript;base64,${r}`);i.onmessage=function(t){return e(t.data)},i.onerror=t}).then(function(e){return e},function(){return!1})},t.exports.can_use_canvas=function(e){var t=!1;try{var n=e(2,1).getContext(`2d`),r=n.createImageData(2,1);r.data[0]=12,r.data[1]=23,r.data[2]=34,r.data[3]=255,r.data[4]=45,r.data[5]=56,r.data[6]=67,r.data[7]=255,n.putImageData(r,0,0),r=null,r=n.getImageData(0,0,2,1),r.data[0]===12&&r.data[1]===23&&r.data[2]===34&&r.data[3]===255&&r.data[4]===45&&r.data[5]===56&&r.data[6]===67&&r.data[7]===255&&(t=!0)}catch{}return t},t.exports.cib_can_use_region=function(){return new Promise(function(e){if(typeof createImageBitmap>`u`){e(!1);return}var t=new Image;t.src=`data:image/jpeg;base64,/9j/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAYAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAAB/9sAQwAEAwMEAwMEBAMEBQQEBQYKBwYGBgYNCQoICg8NEBAPDQ8OERMYFBESFxIODxUcFRcZGRsbGxAUHR8dGh8YGhsa/9sAQwEEBQUGBQYMBwcMGhEPERoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoa/8IAEQgAAQACAwERAAIRAQMRAf/EABQAAQAAAAAAAAAAAAAAAAAAAAf/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAF/P//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAQUCf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEABj8Cf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8hf//aAAwDAQACAAMAAAAQH//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Qf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Qf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8Qf//Z`,t.onload=function(){createImageBitmap(t,0,0,t.width,t.height).then(function(n){n.width===t.width&&n.height===t.height?e(!0):e(!1)},function(){return e(!1)})},t.onerror=function(){return e(!1)}})}},{}],17:[function(e,t,n){t.exports=function(){var t=e(`./mathlib`),n;onmessage=function(e){var r=e.data.opts,i=!1;if(!r.src&&r.srcBitmap){var a=new OffscreenCanvas(r.width,r.height),o=a.getContext(`2d`,{alpha:!!r.alpha});o.drawImage(r.srcBitmap,0,0),r.src=o.getImageData(0,0,r.width,r.height).data,a.width=a.height=0,a=null,r.srcBitmap.close(),r.srcBitmap=null}n||=new t(e.data.features);var s=n.resizeAndUnsharp(r);if(i){var c=new ImageData(new Uint8ClampedArray(s),r.toWidth,r.toHeight),l=new OffscreenCanvas(r.toWidth,r.toHeight);l.getContext(`2d`,{alpha:!!r.alpha}).putImageData(c,0,0),createImageBitmap(l).then(function(e){postMessage({bitmap:e},[e])})}else postMessage({data:s},[s.buffer])}}},{"./mathlib":1}],18:[function(e,t,n){var r,i,a,o,s,c,l,u;function d(e){e<.5&&(e=.5);var t=Math.exp(.726*.726)/e,n=Math.exp(-t),d=Math.exp(-2*t),f=(1-n)*(1-n)/(1+2*t*n-d);return r=f,i=f*(t-1)*n,a=f*(t+1)*n,o=-f*d,s=2*n,c=-d,l=(r+i)/(1-s-c),u=(a+o)/(1-s-c),new Float32Array([r,i,a,o,s,c,l,u])}function f(e,t,n,r,i,a){var o,s,c,l,u,d,f,p,m,h,g,_,v,y;for(m=0;m<a;m++){for(d=m*i,f=m,p=0,o=e[d],u=o*r[6],l=u,g=r[0],_=r[1],v=r[4],y=r[5],h=0;h<i;h++)s=e[d],c=s*g+o*_+l*v+u*y,u=l,l=c,o=s,n[p]=l,p++,d++;for(d--,p--,f+=a*(i-1),o=e[d],u=o*r[7],l=u,s=o,g=r[2],_=r[3],h=i-1;h>=0;h--)c=s*g+o*_+l*v+u*y,u=l,l=c,o=s,s=e[d],t[f]=n[p]+l,d--,p--,f-=a}}function p(e,t,n,r){if(r){var i=new Uint16Array(e.length),a=new Float32Array(Math.max(t,n)),o=d(r);f(e,i,a,o,t,n,r),f(i,e,a,o,n,t,r)}}t.exports=p},{}],19:[function(e,t,n){typeof Object.create==`function`?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],20:[function(e,t,n){var r=e(`object-assign`),i=e(`./lib/base64decode`),a=e(`./lib/wa_detect`),o={js:!0,wasm:!0};function s(e){if(!(this instanceof s))return new s(e);var t=r({},o,e||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]===1,!this.options.js&&!this.options.wasm)throw Error(`mathlib: at least "js" or "wasm" should be enabled`)}s.prototype.has_wasm=a,s.prototype.use=function(e){return this.__modules[e.name]=e,this.options.wasm&&this.has_wasm()&&e.wasm_fn?this[e.name]=e.wasm_fn:this[e.name]=e.fn,this},s.prototype.init=function(){if(this.__init_promise)return this.__init_promise;if(!this.options.js&&this.options.wasm&&!this.has_wasm())return Promise.reject(Error(`mathlib: only "wasm" was enabled, but it's not supported`));var e=this;return this.__init_promise=Promise.all(Object.keys(e.__modules).map(function(t){var n=e.__modules[t];return!e.options.wasm||!e.has_wasm()||!n.wasm_fn||e.__wasm[t]?null:WebAssembly.compile(e.__base64decode(n.wasm_src)).then(function(n){e.__wasm[t]=n})})).then(function(){return e}),this.__init_promise},s.prototype.__base64decode=i,s.prototype.__reallocate=function(e){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(e/(64*1024))}),this.__memory;var t=this.__memory.buffer.byteLength;return t<e&&this.__memory.grow(Math.ceil((e-t)/(64*1024))),this.__memory},s.prototype.__instance=function(e,t,n){if(t&&this.__reallocate(t),!this.__wasm[e]){var i=this.__modules[e];this.__wasm[e]=new WebAssembly.Module(this.__base64decode(i.wasm_src))}if(!this.__cache[e]){var a={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:`anyfunc`})};this.__cache[e]=new WebAssembly.Instance(this.__wasm[e],{env:r(a,n||{})})}return this.__cache[e]},s.prototype.__align=function(e,t){t||=8;var n=e%t;return e+(n?t-n:0)},t.exports=s},{"./lib/base64decode":21,"./lib/wa_detect":22,"object-assign":23}],21:[function(e,t,n){var r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;t.exports=function(e){for(var t=e.replace(/[\r\n=]/g,``),n=t.length,i=new Uint8Array(n*3>>2),a=0,o=0,s=0;s<n;s++)s%4==0&&s&&(i[o++]=a>>16&255,i[o++]=a>>8&255,i[o++]=a&255),a=a<<6|r.indexOf(t.charAt(s));var c=n%4*6;return c===0?(i[o++]=a>>16&255,i[o++]=a>>8&255,i[o++]=a&255):c===18?(i[o++]=a>>10&255,i[o++]=a>>2&255):c===12&&(i[o++]=a>>4&255),i}},{}],22:[function(e,t,n){var r;t.exports=function(){if(r!==void 0||(r=!1,typeof WebAssembly>`u`))return r;try{var e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return new WebAssembly.Instance(t,{}).exports.test(4)!==0&&(r=!0),r}catch{}return r}},{}],23:[function(e,t,n){var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(e){if(e==null)throw TypeError(`Object.assign cannot be called with null or undefined`);return Object(e)}function s(){try{if(!Object.assign)return!1;var e=new String(`abc`);if(e[5]=`de`,Object.getOwnPropertyNames(e)[0]===`5`)return!1;for(var t={},n=0;n<10;n++)t[`_`+String.fromCharCode(n)]=n;if(Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(``)!==`0123456789`)return!1;var r={};return`abcdefghijklmnopqrst`.split(``).forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join(``)===`abcdefghijklmnopqrst`}catch{return!1}}t.exports=s()?Object.assign:function(e,t){for(var n,s=o(e),c,l=1;l<arguments.length;l++){for(var u in n=Object(arguments[l]),n)i.call(n,u)&&(s[u]=n[u]);if(r){c=r(n);for(var d=0;d<c.length;d++)a.call(n,c[d])&&(s[c[d]]=n[c[d]])}}return s}},{}],24:[function(e,t,n){var r=arguments[3],i=arguments[4],a=arguments[5],o=JSON.stringify;t.exports=function(e,t){for(var n,s=Object.keys(a),c=0,l=s.length;c<l;c++){var u=s[c],d=a[u].exports;if(d===e||d&&d.default===e){n=u;break}}if(!n){n=Math.floor(16**8*Math.random()).toString(16);for(var f={},c=0,l=s.length;c<l;c++){var u=s[c];f[u]=u}i[n]=[`function(require,module,exports){`+e+`(self); }`,f]}var p=Math.floor(16**8*Math.random()).toString(16),m={};m[n]=n,i[p]=[`function(require,module,exports){var f = require(`+o(n)+`);(f.default ? f.default : f)(self);}`,m];var h={};g(p);function g(e){for(var t in h[e]=!0,i[e][1]){var n=i[e][1][t];h[n]||g(n)}}var _=`(`+r+`)({`+Object.keys(h).map(function(e){return o(e)+`:[`+i[e][0]+`,`+o(i[e][1])+`]`}).join(`,`)+`},{},[`+o(p)+`])`,v=window.URL||window.webkitURL||window.mozURL||window.msURL,y=new Blob([_],{type:`text/javascript`});if(t&&t.bare)return y;var b=v.createObjectURL(y),x=new Worker(b);return x.objectURL=b,x}},{}],"/index.js":[function(e,t,n){function r(e,t){return c(e)||s(e,t)||a(e,t)||i()}function i(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a(e,t){if(e){if(typeof e==`string`)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}}function o(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function c(e){if(Array.isArray(e))return e}var l=e(`object-assign`),u=e(`webworkify`),d=e(`./lib/mathlib`),f=e(`./lib/pool`),p=e(`./lib/utils`),m=e(`./lib/worker`),h=e(`./lib/stepper`),g=e(`./lib/tiler`),_={},v=!1;try{typeof navigator<`u`&&navigator.userAgent&&(v=navigator.userAgent.indexOf(`Safari`)>=0)}catch{}var y=1;typeof navigator<`u`&&(y=Math.min(navigator.hardwareConcurrency||1,4));var b={tile:1024,concurrency:y,features:[`js`,`wasm`,`ww`],idle:2e3,createCanvas:function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,n}},x={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},S=!1,C=!1,w=!1,T=!1,E=!1;function D(){return{value:u(m),destroy:function(){if(this.value.terminate(),typeof window<`u`){var e=window.URL||window.webkitURL||window.mozURL||window.msURL;e&&e.revokeObjectURL&&this.value.objectURL&&e.revokeObjectURL(this.value.objectURL)}}}}function O(e){if(!(this instanceof O))return new O(e);this.options=l({},b,e||{});var t=`lk_${this.options.concurrency}`;this.__limit=_[t]||p.limiter(this.options.concurrency),_[t]||(_[t]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}O.prototype.init=function(){var t=this;if(this.__initPromise)return this.__initPromise;if(typeof ImageData<`u`&&typeof Uint8ClampedArray<`u`)try{new ImageData(new Uint8ClampedArray(400),10,10),S=!0}catch{}typeof ImageBitmap<`u`&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?C=!0:this.debug(`ImageBitmap does not support .close(), disabled`));var n=this.options.features.slice();if(n.indexOf(`all`)>=0&&(n=[`cib`,`wasm`,`js`,`ww`]),this.__requested_features=n,this.__mathlib=new d(n),n.indexOf(`ww`)>=0&&typeof window<`u`&&`Worker`in window)try{e(`webworkify`)(function(){}).terminate(),this.features.ww=!0;var r=`wp_${JSON.stringify(this.options)}`;_[r]?this.__workersPool=_[r]:(this.__workersPool=new f(D,this.options.idle),_[r]=this.__workersPool)}catch{}var i=this.__mathlib.init().then(function(e){l(t.features,e.features)}),a=C?p.cib_support(this.options.createCanvas).then(function(e){if(t.features.cib&&n.indexOf(`cib`)<0){t.debug(`createImageBitmap() resize supported, but disabled by config`);return}n.indexOf(`cib`)>=0&&(t.features.cib=e)}):Promise.resolve(!1);w=p.can_use_canvas(this.options.createCanvas);var o=C&&S&&n.indexOf(`ww`)!==-1?p.worker_offscreen_canvas_support():Promise.resolve(!1);o=o.then(function(e){T=e});var s=p.cib_can_use_region().then(function(e){E=e});return this.__initPromise=Promise.all([i,a,o,s]).then(function(){return t}),this.__initPromise},O.prototype.__invokeResize=function(e,t){var n=this;return t.__mathCache=t.__mathCache||{},Promise.resolve().then(function(){return n.features.ww?new Promise(function(r,i){var a=n.__workersPool.acquire();t.cancelToken&&t.cancelToken.catch(function(e){return i(e)}),a.value.onmessage=function(e){a.release(),e.data.err?i(e.data.err):r(e.data)};var o=[];e.src&&o.push(e.src.buffer),e.srcBitmap&&o.push(e.srcBitmap),a.value.postMessage({opts:e,features:n.__requested_features,preload:{wasm_nodule:n.__mathlib.__}},o)}):{data:n.__mathlib.resizeAndUnsharp(e,t.__mathCache)}})},O.prototype.__extractTileData=function(e,t,n,r,i){if(this.features.ww&&T&&(p.isCanvas(t)||E))return this.debug(`Create tile for OffscreenCanvas`),createImageBitmap(r.srcImageBitmap||t,e.x,e.y,e.width,e.height).then(function(e){return i.srcBitmap=e,i});if(p.isCanvas(t))return r.srcCtx||=t.getContext(`2d`,{alpha:!!n.alpha}),this.debug(`Get tile pixel data`),i.src=r.srcCtx.getImageData(e.x,e.y,e.width,e.height).data,i;this.debug(`Draw tile imageBitmap/image to temporary canvas`);var a=this.options.createCanvas(e.width,e.height),o=a.getContext(`2d`,{alpha:!!n.alpha});return o.globalCompositeOperation=`copy`,o.drawImage(r.srcImageBitmap||t,e.x,e.y,e.width,e.height,0,0,e.width,e.height),this.debug(`Get tile pixel data`),i.src=o.getImageData(0,0,e.width,e.height).data,a.width=a.height=0,i},O.prototype.__landTileData=function(e,t,n){var r;if(this.debug(`Convert raw rgba tile result to ImageData`),t.bitmap)return n.toCtx.drawImage(t.bitmap,e.toX,e.toY),null;if(S)r=new ImageData(new Uint8ClampedArray(t.data),e.toWidth,e.toHeight);else if(r=n.toCtx.createImageData(e.toWidth,e.toHeight),r.data.set)r.data.set(t.data);else for(var i=r.data.length-1;i>=0;i--)r.data[i]=t.data[i];return this.debug(`Draw tile`),v?n.toCtx.putImageData(r,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth+1e-5,e.toInnerHeight+1e-5):n.toCtx.putImageData(r,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth,e.toInnerHeight),null},O.prototype.__tileAndResize=function(e,t,n){var r=this,i={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null},a=function(t){return r.__limit(function(){if(n.canceled)return n.cancelToken;var a={width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,quality:n.quality,alpha:n.alpha,unsharpAmount:n.unsharpAmount,unsharpRadius:n.unsharpRadius,unsharpThreshold:n.unsharpThreshold};return r.debug(`Invoke resize math`),Promise.resolve(a).then(function(a){return r.__extractTileData(t,e,n,i,a)}).then(function(e){return r.debug(`Invoke resize math`),r.__invokeResize(e,n)}).then(function(e){return n.canceled?n.cancelToken:(i.srcImageData=null,r.__landTileData(t,e,i))})})};return Promise.resolve().then(function(){if(i.toCtx=t.getContext(`2d`,{alpha:!!n.alpha}),p.isCanvas(e))return null;if(p.isImageBitmap(e))return i.srcImageBitmap=e,i.isImageBitmapReused=!0,null;if(p.isImage(e))return C?(r.debug(`Decode image via createImageBitmap`),createImageBitmap(e).then(function(e){i.srcImageBitmap=e}).catch(function(e){return null})):null;throw Error(`Pica: ".from" should be Image, Canvas or ImageBitmap`)}).then(function(){if(n.canceled)return n.cancelToken;r.debug(`Calculate tiles`);var e=g({width:n.width,height:n.height,srcTileSize:r.options.tile,toWidth:n.toWidth,toHeight:n.toHeight,destTileBorder:n.__destTileBorder}).map(function(e){return a(e)});function o(e){e.srcImageBitmap&&=(e.isImageBitmapReused||e.srcImageBitmap.close(),null)}return r.debug(`Process tiles`),Promise.all(e).then(function(){return r.debug(`Finished!`),o(i),t},function(e){throw o(i),e})})},O.prototype.__processStages=function(e,t,n,i){var a=this;if(i.canceled)return i.cancelToken;var o=r(e.shift(),2),s=o[0],c=o[1],u=e.length===0;i=l({},i,{toWidth:s,toHeight:c,quality:u?i.quality:Math.min(1,i.quality)});var d;return u||(d=this.options.createCanvas(s,c)),this.__tileAndResize(t,u?n:d,i).then(function(){return u?n:(i.width=s,i.height=c,a.__processStages(e,d,n,i))}).then(function(e){return d&&(d.width=d.height=0),e})},O.prototype.__resizeViaCreateImageBitmap=function(e,t,n){var r=this,i=t.getContext(`2d`,{alpha:!!n.alpha});return this.debug(`Resize via createImageBitmap()`),createImageBitmap(e,{resizeWidth:n.toWidth,resizeHeight:n.toHeight,resizeQuality:p.cib_quality_name(n.quality)}).then(function(e){if(n.canceled)return n.cancelToken;if(!n.unsharpAmount)return i.drawImage(e,0,0),e.close(),i=null,r.debug(`Finished!`),t;r.debug(`Unsharp result`);var a=r.options.createCanvas(n.toWidth,n.toHeight),o=a.getContext(`2d`,{alpha:!!n.alpha});o.drawImage(e,0,0),e.close();var s=o.getImageData(0,0,n.toWidth,n.toHeight);return r.__mathlib.unsharp_mask(s.data,n.toWidth,n.toHeight,n.unsharpAmount,n.unsharpRadius,n.unsharpThreshold),i.putImageData(s,0,0),a.width=a.height=0,s=o=a=i=null,r.debug(`Finished!`),t})},O.prototype.resize=function(e,t,n){var r=this;this.debug(`Start resize...`);var i=l({},x);return isNaN(n)?n&&(i=l(i,n)):i=l(i,{quality:n}),i.toWidth=t.width,i.toHeight=t.height,i.width=e.naturalWidth||e.width,i.height=e.naturalHeight||e.height,t.width===0||t.height===0?Promise.reject(Error(`Invalid output size: ${t.width}x${t.height}`)):(i.unsharpRadius>2&&(i.unsharpRadius=2),i.canceled=!1,i.cancelToken&&=i.cancelToken.then(function(e){throw i.canceled=!0,e},function(e){throw i.canceled=!0,e}),i.__destTileBorder=Math.ceil(Math.max(3,2.5*i.unsharpRadius|0)),this.init().then(function(){if(i.canceled)return i.cancelToken;if(r.features.cib)return r.__resizeViaCreateImageBitmap(e,t,i);if(!w){var n=Error(`Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled`);throw n.code=`ERR_GET_IMAGE_DATA`,n}var a=h(i.width,i.height,i.toWidth,i.toHeight,r.options.tile,i.__destTileBorder);return r.__processStages(a,e,t,i)}))},O.prototype.resizeBuffer=function(e){var t=this,n=l({},x,e);return this.init().then(function(){return t.__mathlib.resizeAndUnsharp(n)})},O.prototype.toBlob=function(e,t,n){return t||=`image/png`,new Promise(function(r){if(e.toBlob){e.toBlob(function(e){return r(e)},t,n);return}if(e.convertToBlob){r(e.convertToBlob({type:t,quality:n}));return}for(var i=atob(e.toDataURL(t,n).split(`,`)[1]),a=i.length,o=new Uint8Array(a),s=0;s<a;s++)o[s]=i.charCodeAt(s);r(new Blob([o],{type:t}))})},O.prototype.debug=function(){},t.exports=O},{"./lib/mathlib":1,"./lib/pool":13,"./lib/stepper":14,"./lib/tiler":15,"./lib/utils":16,"./lib/worker":17,"object-assign":23,webworkify:24}]},{},[])(`/index.js`)})}));export default n(); |