text: !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pica=t()}}(function(){return function t(e,i,r){function n(o,s){if(!i[o]){if(!e[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var f=i[o]={exports:{}};e[o][0].call(f.exports,function(t){var i=e[o][1][t];return n(i||t)},f,f.exports,t,e,i,r)}return i[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)n(r[o]);return n}({1:[function(t,e,i){"use strict";function r(t,e){this.__requested_features=t||[],this.__initialized=!1,this.__initCallbacks=[],this.__wasm_module=e&&e.wasm_module?e:null,this.features={js:!1,wasm:!1}}function n(t,e,i){for(var r=3,n=e*i*4|0;r<n;)t[r]=255,r=r+4|0}function a(t){return new Uint8Array(t.buffer,0,t.byteLength)}function o(t,e,i){if(f)e.set(a(t),i);else for(var r=i,n=0;n<t.length;n++){var o=t[n];e[r++]=255&o,e[r++]=o>>8&255}}var s=t("./utils").base64decode,u=t("./mathlib/wasm/math_wasm_base64");r.prototype.__init__=function(t){var e=this;if(this.__initCallbacks.length>0)this.__initCallbacks.push(t);else{this.__initCallbacks=[t];var i=function(){var t=e.__initCallbacks;e.__initCallbacks=[],e.__initialized=!0,t.forEach(function(t){return t()})};if(this.unsharp=this.unsharp_js,this.__requested_features.indexOf("js")>=0&&(this.features.js=!0,this.resize=this.resize_js),"undefined"!=typeof WebAssembly&&this.__requested_features.indexOf("wasm")>=0)return this.__wasm_module?(this.features.wasm=!0,this.resize=this.resize_wasm,void i()):void WebAssembly.compile(s(u)).then(function(t){e.__wasm_module=t,e.features.wasm=!0,e.resize=e.resize_wasm,i()}).catch(function(){i()});i()}},r.prototype.init=function(t){var e=this;if("function"!=typeof t)return this.__initialized?Promise.resolve(this):new Promise(function(t,i){e.__init__(function(r){r?i(r):e.features.wasm||e.features.js?t(e):i(new Error("Pica mathlib: no supported methods found"))})});this.__initialized?t(null,this):this.__init__(function(i){i?t(i):e.features.wasm||e.features.js?t(null,e):t(new Error("Pica mathlib: no supported methods found"))})},r.prototype.resizeAndUnsharp=function(t,e){var i=this.resize(t,e);return t.unsharpAmount&&this.unsharp(i,t.toWidth,t.toHeight,t.unsharpAmount,t.unsharpRadius,t.unsharpThreshold),i},r.prototype.unsharp_js=t("./mathlib/unsharp_js"),r.prototype.resize_js=t("./mathlib/resize_js");var h=t("./mathlib/resize_filter_gen"),f=!0;try{f=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(t){}r.prototype.resize_wasm=function(t,e){var i=t.src,r=t.width,a=t.height,s=t.toWidth,u=t.toHeight,f=t.scaleX||t.toWidth/t.width,l=t.scaleY||t.toHeight/t.height,c=t.offsetX||0,d=t.offsetY||0,g=t.dest||new Uint8Array(s*u*4),p=void 0===t.quality?3:t.quality,m=t.alpha||!1;e||(e={});var A="filter_"+p+"|"+a+"|"+u+"|"+l+"|"+d,w=e["filter_"+p+"|"+r+"|"+s+"|"+f+"|"+c]||h(p,r,s,f,c),v=e[A]||h(p,a,u,l,d),b=Math.max(i.byteLength,g.byteLength)+w.byteLength+v.byteLength+a*s*4,_=Math.ceil(b/65536),y=e.wasm_imports||{env:{memory:new WebAssembly.Memory({initial:_})}},I=y.env.memory,B=I.buffer.byteLength/65536;_>B&&I.grow(_-B+16);var C=e.wasm_instance||new WebAssembly.Instance(this.__wasm_module,y);e.wasm_imports||(e.wasm_imports=y),e.wasm_instance||(e.wasm_instance=C);var E=new Uint8Array(y.env.memory.buffer),x=new Uint32Array(y.env.memory.buffer),j=new Uint32Array(i.buffer);x.set(j);var M=Math.max(i.byteLength,g.byteLength),U=M+a*s*4,z=U+w.byteLength;o(w,E,U),o(v,E,z),C.exports.convolveHV(U,z,M,r,a,s,u);var Q=new Uint32Array(g.buffer);return Q.set(x.subarray(0,Q.length)),m||n(g,s,u),g},e.exports=r},{"./mathlib/resize_filter_gen":4,"./mathlib/resize_js":6,"./mathlib/unsharp_js":7,"./mathlib/wasm/math_wasm_base64":8,"./utils":11}],2:[function(t,e,i){"use strict";e.exports=function(t,e,i){for(var r,n,a,o,s,u=e*i,h=new Uint16Array(u),f=0;f<u;f++)r=t[4*f],n=t[4*f+1],a=t[4*f+2],s=r>=n&&r>=a?r:n>=a&&n>=r?n:a,o=r<=n&&r<=a?r:n<=a&&n<=r?n:a,h[f]=257*(s+o)>>1;return h}},{}],3:[function(t,e,i){"use strict";function r(t){return t<0?0:t>255?255:t}e.exports={convolveHorizontally:function(t,e,i,n,a,o){var s,u,h,f,l,c,d,g,p,m,A,w=0,v=0;for(p=0;p<n;p++){for(l=0,m=0;m<a;m++){for(c=o[l++],d=o[l++],g=w+4*c|0,s=u=h=f=0;d>0;d--)f=f+(A=o[l++])*t[g+3]|0,h=h+A*t[g+2]|0,u=u+A*t[g+1]|0,s=s+A*t[g]|0,g=g+4|0;e[v+3]=r(f+8192>>14),e[v+2]=r(h+8192>>14),e[v+1]=r(u+8192>>14),e[v]=r(s+8192>>14),v=v+4*n|0}v=4*(p+1)|0,w=(p+1)*i*4|0}},convolveVertically:function(t,e,i,n,a,o){var s,u,h,f,l,c,d,g,p,m,A,w=0,v=0;for(p=0;p<n;p++){for(l=0,m=0;m<a;m++){for(c=o[l++],d=o[l++],g=w+4*c|0,s=u=h=f=0;d>0;d--)f=f+(A=o[l++])*t[g+3]|0,h=h+A*t[g+2]|0,u=u+A*t[g+1]|0,s=s+A*t[g]|0,g=g+4|0;e[v+3]=r(f+8192>>14),e[v+2]=r(h+8192>>14),e[v+1]=r(u+8192>>14),e[v]=r(s+8192>>14),v=v+4*n|0}v=4*(p+1)|0,w=(p+1)*i*4|0}}}},{}],4:[function(t,e,i){"use strict";function r(t){return Math.round(t*((1<<a)-1))}var n=t("./resize_filter_info"),a=14;e.exports=function(t,e,i,a,o){var s,u,h,f,l,c,d,g,p,m,A,w,v,b,_,y,I,B=n[t].filter,C=1/a,E=Math.min(1,a),x=n[t].win/E,j=Math.floor(2*(x+1)),M=new Int16Array((j+2)*i),U=0,z=!M.subarray||!M.set;for(s=0;s<i;s++){for(u=(s+.5)*C+o,h=Math.max(0,Math.floor(u-x)),l=(f=Math.min(e-1,Math.ceil(u+x)))-h+1,c=new Float32Array(l),d=new Int16Array(l),g=0,p=h,m=0;p<=f;p++,m++)g+=A=B((p+.5-u)*E),c[m]=A;for(w=0,m=0;m<c.length;m++)w+=v=c[m]/g,d[m]=r(v);for(d[i>>1]+=r(1-w),b=0;b<d.length&&0===d[b];)b++;if(b<d.length){for(_=d.length-1;_>0&&0===d[_];)_--;if(y=h+b,I=_-b+1,M[U++]=y,M[U++]=I,z)for(m=b;m<=_;m++)M[U++]=d[m];else M.set(d.subarray(b,_+1),U),U+=I}else M[U++]=0,M[U++]=0}return M}},{"./resize_filter_info":5}],5:[function(t,e,i){"use strict";e.exports=[{win:.5,filter:function(t){return t>=-.5&&t<.5?1:0}},{win:1,filter:function(t){if(t<=-1||t>=1)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*(.54+.46*Math.cos(e/1))}},{win:2,filter:function(t){if(t<=-2||t>=2)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/2)/(e/2)}},{win:3,filter:function(t){if(t<=-3||t>=3)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/3)/(e/3)}}]},{}],6:[function(t,e,i){"use strict";function r(t,e,i){for(var r=3,n=e*i*4|0;r<n;)t[r]=255,r=r+4|0}var n=t("./resize_filter_gen"),a=t("./resize_convolve_js").convolveHorizontally,o=t("./resize_convolve_js").convolveVertically;e.exports=function(t,e){var i=t.src,s=t.width,u=t.height,h=t.toWidth,f=t.toHeight,l=t.scaleX||t.toWidth/t.width,c=t.scaleY||t.toHeight/t.height,d=t.offsetX||0,g=t.offsetY||0,p=t.dest||new Uint8Array(h*f*4),m=void 0===t.quality?3:t.quality,A=t.alpha||!1;if(s<1||u<1||h<1||f<1)return[];e||(e={});var w="filter_"+m+"|"+u+"|"+f+"|"+c+"|"+g,v=e["filter_"+m+"|"+s+"|"+h+"|"+l+"|"+d]||n(m,s,h,l,d),b=e[w]||n(m,u,f,c,g),_=new Uint8Array(h*u*4);return a(i,_,s,u,h,v),o(_,p,u,h,f,b),A||r(p,h,f),p}},{"./resize_convolve_js":3,"./resize_filter_gen":4}],7:[function(t,e,i){"use strict";var r=t("glur/mono16"),n=t("./lightness16_js");e.exports=function(t,e,i,a,o,s){var u,h,f,l,c,d,g,p,m,A,w,v,b;if(!(0===a||o<.5)){o>2&&(o=2);var _=n(t,e,i),y=new Uint16Array(_);r(y,e,i,o);for(var I=a/100*4096+.5|0,B=257*s|0,C=e*i,E=0;E<C;E++)v=2*(_[E]-y[E]),Math.abs(v)>=B&&(u=t[b=4*E],h=t[b+1],f=t[b+2],d=257*((p=u>=h&&u>=f?u:h>=u&&h>=f?h:f)+(g=u<=h&&u<=f?u:h<=u&&h<=f?h:f))>>1,g===p?l=c=0:(c=d<=32767?4095*(p-g)/(p+g)|0:4095*(p-g)/(510-p-g)|0,l=u===p?65535*(h-f)/(6*(p-g))|0:h===p?21845+(65535*(f-u)/(6*(p-g))|0):43690+(65535*(u-h)/(6*(p-g))|0)),(d+=I*v+2048>>12)>65535?d=65535:d<0&&(d=0),0===c?u=h=f=d>>8:(m=2*d-(A=d<=32767?d*(4096+c)+2048>>12:d+((65535-d)*c+2048>>12))>>8,A>>=8,u=(w=l+21845&65535)>=43690?m:w>=32767?m+(6*(A-m)*(43690-w)+32768>>16):w>=10922?A:m+(6*(A-m)*w+32768>>16),h=(w=65535&l)>=43690?m:w>=32767?m+(6*(A-m)*(43690-w)+32768>>16):w>=10922?A:m+(6*(A-m)*w+32768>>16),f=(w=l-21845&65535)>=43690?m:w>=32767?m+(6*(A-m)*(43690-w)+32768>>16):w>=10922?A:m+(6*(A-m)*w+32768>>16)),t[b]=u,t[b+1]=h,t[b+2]=f)}}},{"./lightness16_js":2,"glur/mono16":13}],8:[function(t,e,i){"use strict";e.exports="AGFzbQEAAAABlICAgAACYAZ/f39/f38AYAd/f39/f39/AAKPgICAAAEDZW52Bm1lbW9yeQIAAQODgICAAAIAAQSEgICAAAFwAAAHmYCAgAACCGNvbnZvbHZlAAAKY29udm9sdmVIVgABCYGAgIAAAArtg4CAAALBg4CAAAEQfwJAIANFDQAgBEUNACAFQQRqIRVBACEMQQAhDQNAIA0hDkEAIRFBACEHA0AgB0ECaiESAn8gBSAHQQF0IgdqIgZBAmouAQAiEwRAQQAhCEEAIBNrIRQgFSAHaiEPIAAgDCAGLgEAakECdGohEEEAIQlBACEKQQAhCwNAIBAoAgAiB0EYdiAPLgEAIgZsIAtqIQsgB0H/AXEgBmwgCGohCCAHQRB2Qf8BcSAGbCAKaiEKIAdBCHZB/wFxIAZsIAlqIQkgD0ECaiEPIBBBBGohECAUQQFqIhQNAAsgEiATagwBC0EAIQtBACEKQQAhCUEAIQggEgshByABIA5BAnRqIApBgMAAakEOdSIGQf8BIAZB/wFIG0EQdEGAgPwHcUEAIAZBAEobIAtBgMAAakEOdSIGQf8BIAZB/wFIG0EYdEEAIAZBAEobciAJQYDAAGpBDnUiBkH/ASAGQf8BSBtBCHRBgP4DcUEAIAZBAEobciAIQYDAAGpBDnUiBkH/ASAGQf8BSBtB/wFxQQAgBkEAShtyNgIAIA4gA2ohDiARQQFqIhEgBEcNAAsgDCACaiEMIA1BAWoiDSADRw0ACwsLoYCAgAAAAkBBACACIAMgBCAFIAAQACACQQAgBCAFIAYgARAACws="},{}],9:[function(t,e,i){"use strict";function r(t,e){this.create=t,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=e||2e3}r.prototype.acquire=function(){var t=this,e=void 0;return 0!==this.available.length?e=this.available.pop():((e=this.create()).id=this.lastId++,e.release=function(){return t.release(e)}),this.acquired[e.id]=e,e},r.prototype.release=function(t){var e=this;delete this.acquired[t.id],t.lastUsed=Date.now(),this.available.push(t),0===this.timeoutId&&(this.timeoutId=setTimeout(function(){return e.gc()},100))},r.prototype.gc=function(){var t=this,e=Date.now();this.available=this.available.filter(function(i){return!(e-i.lastUsed>t.idle)||(i.destroy(),!1)}),0!==this.available.length?this.timeoutId=setTimeout(function(){return t.gc()},100):this.timeoutId=0},e.exports=r},{}],10:[function(t,e,i){"use strict";function r(t){var e=Math.round(t);return Math.abs(t-e)<a?e:Math.floor(t)}function n(t){var e=Math.round(t);return Math.abs(t-e)<a?e:Math.ceil(t)}var a=1e-5;e.exports=function(t){var e,i,a,o,s,u,h,f=t.toWidth/t.width,l=t.toHeight/t.height,c=r(t.srcTileSize*f)-2*t.destTileBorder,d=r(t.srcTileSize*l)-2*t.destTileBorder,g=[];for(o=0;o<t.toHeight;o+=d)for(a=0;a<t.toWidth;a+=c)(e=a-t.destTileBorder)<0&&(e=0),e+(s=a+c+t.destTileBorder-e)>=t.toWidth&&(s=t.toWidth-e),(i=o-t.destTileBorder)<0&&(i=0),i+(u=o+d+t.destTileBorder-i)>=t.toHeight&&(u=t.toHeight-i),h={toX:e,toY:i,toWidth:s,toHeight:u,toInnerX:a,toInnerY:o,toInnerWidth:c,toInnerHeight:d,offsetX:e/f-r(e/f),offsetY:i/l-r(i/l),scaleX:f,scaleY:l,x:r(e/f),y:r(i/l),width:n(s/f),height:n(u/l)},g.push(h);return g}},{}],11:[function(t,e,i){"use strict";function r(t){return Object.prototype.toString.call(t)}e.exports.isCanvas=function(t){var e=r(t);return"[object HTMLCanvasElement]"===e||"[object Canvas]"===e},e.exports.isImage=function(t){return"[object HTMLImageElement]"===r(t)},e.exports.limiter=function(t){function e(){i<t&&r.length&&(i++,r.shift()())}var i=0,r=[];return function(t){return new Promise(function(n,a){r.push(function(){t().then(function(t){n(t),i--,e()},function(t){a(t),i--,e()})}),e()})}},e.exports.cib_quality_name=function(t){switch(t){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"},e.exports.cib_support=function(){return Promise.resolve().then(function(){if("undefined"==typeof createImageBitmap||"undefined"==typeof document)return!1;var t=document.createElement("canvas");return t.width=100,t.height=100,createImageBitmap(t,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:"high"}).then(function(e){var i=10===e.width;return e.close(),t=null,i})}).catch(function(){return!1})};e.exports.base64decode=function(t){for(var e=t.replace(/[\r\n=]/g,""),i=e.length,r=[],n=0,a=0;a<i;a++)a%4==0&&a&&(r.push(n>>16&255),r.push(n>>8&255),r.push(255&n)),n=n<<6|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r".indexOf(e.charAt(a));var o=i%4*6;return 0===o?(r.push(n>>16&255),r.push(n>>8&255),r.push(255&n)):18===o?(r.push(n>>10&255),r.push(n>>2&255)):12===o&&r.push(n>>4&255),new Uint8Array(r)}},{}],12:[function(t,e,i){"use strict";e.exports=function(){var e=t("./mathlib"),i=void 0,r={};onmessage=function(t){var n=t.data.opts;i||(i=new e(t.data.features,t.data.preload)),i.init(function(t){if(t)postMessage({err:t});else{var e=i.resizeAndUnsharp(n,r);postMessage({result:e},[e.buffer])}})}}},{"./mathlib":1}],13:[function(t,e,i){function r(t){t<.5&&(t=.5);var e=Math.exp(.527076)/t,i=Math.exp(-e),r=Math.exp(-2*e),n=(1-i)*(1-i)/(1+2*e*i-r);return a=n,o=n*(e-1)*i,s=n*(e+1)*i,u=-n*r,h=2*i,f=-r,l=(a+o)/(1-h-f),c=(s+u)/(1-h-f),new Float32Array([a,o,s,u,h,f,l,c])}function n(t,e,i,r,n,a){var o,s,u,h,f,l,c,d,g,p,m,A,w,v;for(g=0;g<a;g++){for(c=g,d=0,h=f=(o=t[l=g*n])*r[6],m=r[0],A=r[1],w=r[4],v=r[5],p=0;p<n;p++)u=(s=t[l])*m+o*A+h*w+f*v,f=h,h=u,o=s,i[d]=h,d++,l++;for(d--,c+=a*(n-1),h=f=(o=t[--l])*r[7],s=o,m=r[2],A=r[3],p=n-1;p>=0;p--)u=s*m+o*A+h*w+f*v,f=h,h=u,o=s,s=t[l],e[c]=i[d]+h,l--,d--,c-=a}}var a,o,s,u,h,f,l,c;e.exports=function(t,e,i,a){if(a){var o=new Uint16Array(t.length),s=new Float32Array(Math.max(e,i)),u=r(a);n(t,o,s,u,e,i,a),n(o,t,s,u,i,e,a)}}},{}],14:[function(t,e,i){"use strict";function r(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}var n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},i=0;i<10;i++)e["_"+String.fromCharCode(i)]=i;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var i,s,u=r(t),h=1;h<arguments.length;h++){i=Object(arguments[h]);for(var f in i)a.call(i,f)&&(u[f]=i[f]);if(n){s=n(i);for(var l=0;l<s.length;l++)o.call(i,s[l])&&(u[s[l]]=i[s[l]])}}return u}},{}],15:[function(t,e,i){var r=arguments[3],n=arguments[4],a=arguments[5],o=JSON.stringify;e.exports=function(t,e){function i(t){m[t]=!0;for(var e in n[t][1]){var r=n[t][1][e];m[r]||i(r)}}for(var s,u=Object.keys(a),h=0,f=u.length;h<f;h++){var l=u[h],c=a[l].exports;if(c===t||c&&c.default===t){s=l;break}}if(!s){s=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var d={},h=0,f=u.length;h<f;h++)d[l=u[h]]=l;n[s]=[Function(["require","module","exports"],"("+t+")(self)"),d]}var g=Math.floor(Math.pow(16,8)*Math.random()).toString(16),p={};p[s]=s,n[g]=[Function(["require"],"var f = require("+o(s)+");(f.default ? f.default : f)(self);"),p];var m={};i(g);var A="("+r+")({"+Object.keys(m).map(function(t){return o(t)+":["+n[t][0]+","+o(n[t][1])+"]"}).join(",")+"},{},["+o(g)+"])",w=window.URL||window.webkitURL||window.mozURL||window.msURL,v=new Blob([A],{type:"text/javascript"});if(e&&e.bare)return v;var b=w.createObjectURL(v),_=new Worker(b);return _.objectURL=b,_}},{}],"/":[function(t,e,i){"use strict";function r(){return{value:o(f),destroy:function(){if(this.value.terminate(),"undefined"!=typeof window){var t=window.URL||window.webkitURL||window.mozURL||window.msURL;t&&t.revokeObjectURL&&this.value.objectURL&&t.revokeObjectURL(this.value.objectURL)}}}}function n(t){if(!(this instanceof n))return new n(t);this.options=a(p,t||{});var e="lk_"+this.options.concurrency;this.__limit=c[e]||h.limiter(this.options.concurrency),c[e]||(c[e]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}var a=t("object-assign"),o=t("webworkify"),s=t("./lib/mathlib"),u=t("./lib/pool"),h=t("./lib/utils"),f=t("./lib/worker"),l=t("./lib/tiler"),c={},d=!1;try{"undefined"!=typeof navigator&&navigator.userAgent&&(d=navigator.userAgent.indexOf("Safari")>=0)}catch(t){}var g=1;"undefined"!=typeof navigator&&(g=Math.min(navigator.hardwareConcurrency||1,4));var p={tile:1024,concurrency:g,features:["js","wasm","ww"],idle:2e3},m={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},A=void 0;n.prototype.init=function(){var e=this;if(this.__initPromise)return this.__initPromise;if(!1!==A&&!0!==A&&(A=!1,"undefined"!=typeof ImageData&&"undefined"!=typeof Uint8ClampedArray))try{new ImageData(new Uint8ClampedArray(400),10,10),A=!0}catch(t){}var i=this.options.features.slice();if(i.indexOf("all")>=0&&(i=["cib","wasm","js","ww"]),this.__requested_features=i,this.__mathlib=new s(i),i.indexOf("ww")>=0&&"undefined"!=typeof window&&"Worker"in window)try{t("webworkify")(function(){}).terminate(),this.features.ww=!0;var n="wp_"+JSON.stringify(this.options);c[n]?this.__workersPool=c[n]:(this.__workersPool=new u(r,this.options.idle),c[n]=this.__workersPool)}catch(t){}var o=this.__mathlib.init().then(function(t){a(e.features,t.features)}),f=h.cib_support().then(function(t){e.features.cib&&i.indexOf("cib")<0?e.debug("createImageBitmap() resize supported, but disabled by config"):i.indexOf("cib")>=0&&(e.features.cib=t)});return this.__initPromise=Promise.all([o,f]).then(function(){return e}),this.__initPromise},n.prototype.resize=function(t,e,i){var r=this;this.debug("Start resize...");var n=m;isNaN(i)?i&&(n=a(n,i)):n=a(n,{quality:i}),n.toWidth=e.width,n.toHeigth=e.height,n.width=t.naturalWidth||t.width,n.height=t.naturalHeight||t.height;var o=!1,s=null;n.cancelToken&&(s=n.cancelToken.then(function(t){throw o=!0,t},function(t){throw o=!0,t}));var u=e.getContext("2d",{alpha:Boolean(n.alpha)});return this.init().then(function(){if(o)return s;if(r.features.cib)return r.debug("Resize via createImageBitmap()"),createImageBitmap(t,{resizeWidth:n.toWidth,resizeHeight:n.toHeigth,resizeQuality:h.cib_quality_name(n.quality)}).then(function(t){if(o)return s;if(!n.unsharpAmount)return u.drawImage(t,0,0),t.close(),u=null,r.debug("Finished!"),e;r.debug("Unsharp result");var i=document.createElement("canvas");i.width=n.toWidth,i.height=n.toHeigth;var a=i.getContext("2d",{alpha:Boolean(n.alpha)});a.drawImage(t,0,0),t.close();var h=a.getImageData(0,0,n.toWidth,n.toHeigth);return r.__mathlib.unsharp(h.data,n.toWidth,n.toHeigth,n.unsharpAmount,n.unsharpRadius,n.unsharpThreshold),u.putImageData(h,0,0),h=a=i=u=null,r.debug("Finished!"),e});var i=void 0,a=void 0,f={},c=function(t){return Promise.resolve().then(function(){return r.features.ww?new Promise(function(e,i){var n=r.__workersPool.acquire();s&&s.catch(function(t){return i(t)}),n.value.onmessage=function(t){n.release(),t.data.err?i(t.data.err):e(t.data.result)},n.value.postMessage({opts:t,features:r.__requested_features,preload:{wasm_nodule:r.__mathlib.__}},[t.src.buffer])}):r.__mathlib.resizeAndUnsharp(t,f)})},g=function(e){return r.__limit(function(){if(o)return s;var f=void 0;if(h.isCanvas(t))r.debug("Get tile pixel data"),f=i.getImageData(e.x,e.y,e.width,e.height);else{r.debug("Draw tile imageBitmap/image to temporary canvas");var l=document.createElement("canvas");l.width=e.width,l.height=e.height;var g=l.getContext("2d",{alpha:Boolean(n.alpha)});g.globalCompositeOperation="copy",g.drawImage(a||t,e.x,e.y,e.width,e.height,0,0,e.width,e.height),r.debug("Get tile pixel data"),f=g.getImageData(0,0,e.width,e.height),g=l=null}var p={src:f.data,width:e.width,height:e.height,toWidth:e.toWidth,toHeight:e.toHeight,scaleX:e.scaleX,scaleY:e.scaleY,offsetX:e.offsetX,offsetY:e.offsetY,quality:n.quality,alpha:n.alpha,unsharpAmount:n.unsharpAmount,unsharpRadius:n.unsharpRadius,unsharpThreshold:n.unsharpThreshold};return r.debug("Invoke resize math"),Promise.resolve().then(function(){return c(p)}).then(function(t){if(o)return s;f=null;var i=void 0;if(r.debug("Convert raw rgba tile result to ImageData"),A)i=new ImageData(new Uint8ClampedArray(t),e.toWidth,e.toHeight);else if((i=u.createImageData(e.toWidth,e.toHeight)).data.set)i.data.set(t);else for(var n=i.data.length-1;n>=0;n--)i.data[n]=t[n];return r.debug("Draw tile"),d?u.putImageData(i,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth+1e-5,e.toInnerHeight+1e-5):u.putImageData(i,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth,e.toInnerHeight),null})})};return Promise.resolve().then(function(){if(h.isCanvas(t))return i=t.getContext("2d",{alpha:Boolean(n.alpha)}),null;if(h.isImage(t))return"undefined"==typeof createImageBitmap?null:(r.debug("Decode image via createImageBitmap"),createImageBitmap(t).then(function(t){a=t}));throw new Error('".from" should be image or canvas')}).then(function(){function t(){a&&(a.close(),a=null)}if(o)return s;r.debug("Calculate tiles");var i=l({width:n.width,height:n.height,srcTileSize:r.options.tile,toWidth:n.toWidth,toHeight:n.toHeigth,destTileBorder:Math.ceil(Math.max(3,2.5*n.unsharpRadius|0))}).map(function(t){return g(t)});return r.debug("Process tiles"),Promise.all(i).then(function(){return r.debug("Finished!"),t(),e},function(e){throw t(),e})})})},n.prototype.resizeBuffer=function(t){var e=this,i=a(m,t);return this.init().then(function(){return e.__mathlib.resizeAndUnsharp(i)})},n.prototype.toBlob=function(t,e,i){return e=e||"image/png",new Promise(function(r){if(t.toBlob)t.toBlob(function(t){return r(t)},e,i);else{for(var n=atob(t.toDataURL(e,i).split(",")[1]),a=n.length,o=new Uint8Array(a),s=0;s<a;s++)o[s]=n.charCodeAt(s);r(new Blob([o],{type:e}))}})},n.prototype.debug=function(){},e.exports=n},{"./lib/mathlib":1,"./lib/pool":9,"./lib/tiler":10,"./lib/utils":11,"./lib/worker":12,"object-assign":14,webworkify:15}]},{},[])("/")});
  