"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2604],{85993:(t,e,r)=>{function i(t,e){var r={};return e.forEach(function(e){Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}),r}r.r(e),r.d(e,{default:()=>g});var n={assign:function(t){for(var e,r=1;r=0,wasm:e.indexOf("wasm")>=0};n.call(this,r),this.features={js:r.js,wasm:r.wasm&&this.has_wasm()},this.use(a),this.use(o)}i(s,n),s.prototype.resizeAndUnsharp=function(t,e){var r=this.resize(t,e);return t.unsharpAmount&&this.unsharp_mask(r,t.toWidth,t.toHeight,t.unsharpAmount,t.unsharpRadius,t.unsharpThreshold),r},e.exports=s},{"./mm_resize":4,"./mm_unsharp_mask":9,inherits:19,multimath:20}],2:[function(t,e,r){function i(t){return t<0?0:t>255?255:t}e.exports={convolveHorizontally:function(t,e,r,n,a,o){var s,A,u,h,f,c,l,g,p,d,_,m=0,I=0;for(p=0;p0;l--)h=h+(_=o[f++])*t[g+3]|0,u=u+_*t[g+2]|0,A=A+_*t[g+1]|0,s=s+_*t[g]|0,g=g+4|0;e[I+3]=i(h+8192>>14),e[I+2]=i(u+8192>>14),e[I+1]=i(A+8192>>14),e[I]=i(s+8192>>14),I=I+4*n|0}I=(p+1)*4|0,m=(p+1)*r*4|0}},convolveVertically:function(t,e,r,n,a,o){var s,A,u,h,f,c,l,g,p,d,_,m=0,I=0;for(p=0;p0;l--)h=h+(_=o[f++])*t[g+3]|0,u=u+_*t[g+2]|0,A=A+_*t[g+1]|0,s=s+_*t[g]|0,g=g+4|0;e[I+3]=i(h+8192>>14),e[I+2]=i(u+8192>>14),e[I+1]=i(A+8192>>14),e[I]=i(s+8192>>14),I=I+4*n|0}I=(p+1)*4|0,m=(p+1)*r*4|0}}}},{}],3:[function(t,e,r){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEXA2AAAGAGf39/f39/AGAHf39/f39/fwACDwEDZW52Bm1lbW9yeQIAAAMEAwABAgYGAX8AQQALB1cFEV9fd2FzbV9jYWxsX2N0b3JzAAAIY29udm9sdmUAAQpjb252b2x2ZUhWAAIMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAK7AMDAwABC8YDAQ9/AkAgA0UNACAERQ0AA0AgDCENQQAhE0EAIQcDQCAHQQJqIQYCfyAHQQF0IAVqIgcuAQIiFEUEQEGAwAAhCEGAwAAhCUGAwAAhCkGAwAAhCyAGDAELIBIgBy4BAGohCEEAIQsgFCEHQQAhDiAGIQlBACEPQQAhEANAIAUgCUEBdGouAQAiESAAIAhBAnRqKAIAIgpBGHZsIBBqIRAgCkH/AXEgEWwgC2ohCyAKQRB2Qf8BcSARbCAPaiEPIApBCHZB/wFxIBFsIA5qIQ4gCEEBaiEIIAlBAWohCSAHQQFrIgcNAAsgC0GAQGshCCAOQYBAayEJIA9BgEBrIQogEEGAQGshCyAGIBRqCyEHIAEgDUECdGogCUEOdSIGQf8BIAZB/wFIGyIGQQAgBkEAShtBCHRBgP4DcSAKQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EQdEGAgPwHcSALQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EYdHJyIAhBDnUiBkH/ASAGQf8BSBsiBkEAIAZBAEobcjYCACADIA1qIQ0gE0EBaiITIARHDQALIAxBAWoiDCACbCESIAMgDEcNAAsLCx4AQQAgAiADIAQgBSAAEAEgAkEAIAQgBSAGIAEQAQs="},{}],4:[function(t,e,r){e.exports={name:"resize",fn:t("./resize"),wasm_fn:t("./resize_wasm"),wasm_src:t("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(t,e,r){var i=t("./resize_filter_gen"),n=t("./convolve").convolveHorizontally,a=t("./convolve").convolveVertically;e.exports=function(t){var e=t.src,r=t.width,o=t.height,s=t.toWidth,A=t.toHeight,u=t.scaleX||t.toWidth/t.width,h=t.scaleY||t.toHeight/t.height,f=t.offsetX||0,c=t.offsetY||0,l=t.dest||new Uint8Array(s*A*4),g=void 0===t.quality?3:t.quality,p=t.alpha||!1,d=i(g,r,s,u,f),_=i(g,o,A,h,c),m=new Uint8Array(s*o*4);return n(e,m,r,o,s,d),a(m,l,o,s,A,_),p||function(t,e,r){for(var i=3,n=e*r*4|0;i>1]+=n(1-m),w=0;w0&&0===l[b];)b--;if(v=u+w,y=b-w+1,x[M++]=v,x[M++]=y,D)for(d=w;d<=b;d++)x[M++]=l[d];else x.set(l.subarray(w,b+1),M),M+=y}else x[M++]=0,x[M++]=0}return x}},{"./resize_filter_info":7}],7:[function(t,e,r){e.exports=[{win:.5,filter:function(t){return+(t>=-.5&&t<.5)}},{win:1,filter:function(t){if(t<=-1||t>=1)return 0;if(t>-11920929e-14&&t<11920929e-14)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>-11920929e-14&&t<11920929e-14)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>-11920929e-14&&t<11920929e-14)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/3)/(e/3)}}]},{}],8:[function(t,e,r){var i=t("./resize_filter_gen"),n=!0;try{n=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(t){}function a(t,e,r){if(n)return void e.set(new Uint8Array(t.buffer,0,t.byteLength),r);for(var i=r,a=0;a>8&255}}e.exports=function(t){var e=t.src,r=t.width,n=t.height,o=t.toWidth,s=t.toHeight,A=t.scaleX||t.toWidth/t.width,u=t.scaleY||t.toHeight/t.height,h=t.offsetX||0,f=t.offsetY||0,c=t.dest||new Uint8Array(o*s*4),l=void 0===t.quality?3:t.quality,g=t.alpha||!1,p=i(l,r,o,A,h),d=i(l,n,s,u,f),_=this.__align(0+Math.max(e.byteLength,c.byteLength)),m=this.__align(_+n*o*4),I=this.__align(m+p.byteLength),w=I+d.byteLength,b=this.__instance("resize",w),v=new Uint8Array(this.__memory.buffer),y=new Uint32Array(this.__memory.buffer),B=new Uint32Array(e.buffer);return y.set(B),a(p,v,m),a(d,v,I),(b.exports.convolveHV||b.exports._convolveHV)(m,I,_,r,n,o,s),new Uint32Array(c.buffer).set(new Uint32Array(this.__memory.buffer,0,s*o)),g||function(t,e,r){for(var i=3,n=e*r*4|0;i2&&(a=2);var s,A,u,h,f,c=function(t,e,r){for(var i,n,a,o,s=e*r,A=new Uint16Array(s),u=0;u=n&&i>=a?i:n>=a&&n>=i?n:a,A[u]=o<<8;return A}(t,e,r),l=new Uint16Array(c);i(l,e,r,a);for(var g=n/100*4096+.5|0,p=o<<8,d=e*r,_=0;_=p&&(u=((A=(A=(A=s+(g*h+2048>>12))>65280?65280:A)<0?0:A)<<12)/(s=0!==s?s:1)|0,t[f=4*_]=t[f]*u+2048>>12,t[f+1]=t[f+1]*u+2048>>12,t[f+2]=t[f+2]*u+2048>>12)}}},{"glur/mono16":18}],11:[function(t,e,r){e.exports=function(t,e,r,i,n,a){if(0!==i&&!(n<.5)){n>2&&(n=2);var o=e*r,s=4*o,A=2*o,u=2*o,h=4*Math.max(e,r),f=s+A,c=f+u,l=c+u,g=this.__instance("unsharp_mask",s+A+2*u+h+32,{exp:Math.exp}),p=new Uint32Array(t.buffer);new Uint32Array(this.__memory.buffer).set(p);var d=g.exports.hsv_v16||g.exports._hsv_v16;d(0,s,e,r),(d=g.exports.blurMono16||g.exports._blurMono16)(s,f,c,l,l+h,e,r,n),(d=g.exports.unsharp||g.exports._unsharp)(0,0,s,f,e,r,i,a),p.set(new Uint32Array(this.__memory.buffer,0,o))}}},{}],12:[function(t,e,r){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGA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dsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},{}],13:[function(t,e,r){function i(t,e){this.create=t,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=e||2e3}i.prototype.acquire=function(){var t,e=this;return 0!==this.available.length?t=this.available.pop():((t=this.create()).id=this.lastId++,t.release=function(){return e.release(t)}),this.acquired[t.id]=t,t},i.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))},i.prototype.gc=function(){var t=this,e=Date.now();this.available=this.available.filter(function(r){return!(e-r.lastUsed>t.idle)||(r.destroy(),!1)}),0!==this.available.length?this.timeoutId=setTimeout(function(){return t.gc()},100):this.timeoutId=0},e.exports=i},{}],14:[function(t,e,r){e.exports=function(t,e,r,i,n,a){var o=r/t,s=i/e,A=(2*a+2+1)/n;if(A>.5)return[[r,i]];var u=Math.ceil(Math.log(Math.min(o,s))/Math.log(A));if(u<=1)return[[r,i]];for(var h=[],f=0;fMath.abs(t-e)?e:Math.floor(t)}function n(t){var e=Math.round(t);return 1e-5>Math.abs(t-e)?e:Math.ceil(t)}e.exports=function(t){var e,r,a,o,s,A,u=t.toWidth/t.width,h=t.toHeight/t.height,f=i(t.srcTileSize*u)-2*t.destTileBorder,c=i(t.srcTileSize*h)-2*t.destTileBorder;if(f<1||c<1)throw Error("Internal error in pica: target tile width/height is too small.");var l=[];for(o=0;o=t.toWidth&&(s=t.toWidth-e),(r=o-t.destTileBorder)<0&&(r=0),A=o+c+t.destTileBorder-r,r+A>=t.toHeight&&(A=t.toHeight-r),l.push({toX:e,toY:r,toWidth:s,toHeight:A,toInnerX:a,toInnerY:o,toInnerWidth:f,toInnerHeight:c,offsetX:e/u-i(e/u),offsetY:r/h-i(r/h),scaleX:u,scaleY:h,x:i(e/u),y:i(r/h),width:n(s/u),height:n(A/h)});return l}},{}],16:[function(t,e,r){function i(t){return Object.prototype.toString.call(t)}e.exports.isCanvas=function(t){var e=i(t);return"[object HTMLCanvasElement]"===e||"[object OffscreenCanvas]"===e||"[object Canvas]"===e},e.exports.isImage=function(t){return"[object HTMLImageElement]"===i(t)},e.exports.isImageBitmap=function(t){return"[object ImageBitmap]"===i(t)},e.exports.limiter=function(t){var e=0,r=[];function i(){e=0;p--)A=s*d+o*_+u*m+h*I,h=u,u=A,o=s,s=t[f],e[c]=r[l]+u,f--,l--,c-=a}}e.exports=function(t,e,r,c){if(c){var l,g,p,d,_,m=new Uint16Array(t.length),I=new Float32Array(Math.max(e,r)),w=((l=c)<.5&&(l=.5),p=Math.exp(-(g=Math.exp(.527076)/l)),d=Math.exp(-2*g),i=_=(1-p)*(1-p)/(1+2*g*p-d),n=_*(g-1)*p,a=_*(g+1)*p,o=-_*d,u=(i+n)/(1-(s=2*p)-(A=-d)),h=(a+o)/(1-s-A),new Float32Array([i,n,a,o,s,A,u,h]));f(t,m,I,w,e,r),f(m,t,I,w,r,e)}}},{}],19:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],20:[function(t,e,r){var i=t("object-assign"),n=t("./lib/base64decode"),a=t("./lib/wa_detect"),o={js:!0,wasm:!0};function s(t){if(!(this instanceof s))return new s(t);var e=i({},o,t||{});if(this.options=e,this.__cache={},this.__init_promise=null,this.__modules=e.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!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(t){return this.__modules[t.name]=t,this.options.wasm&&this.has_wasm()&&t.wasm_fn?this[t.name]=t.wasm_fn:this[t.name]=t.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 t=this;return this.__init_promise=Promise.all(Object.keys(t.__modules).map(function(e){var r=t.__modules[e];return t.options.wasm&&t.has_wasm()&&r.wasm_fn&&!t.__wasm[e]?WebAssembly.compile(t.__base64decode(r.wasm_src)).then(function(r){t.__wasm[e]=r}):null})).then(function(){return t}),this.__init_promise},s.prototype.__base64decode=n,s.prototype.__reallocate=function(t){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(t/65536)}),this.__memory;var e=this.__memory.buffer.byteLength;return e>2),n=0,a=0,o=0;o>16&255,i[a++]=n>>8&255,i[a++]=255&n),n=n<<6|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e.charAt(o));var s=r%4*6;return 0===s?(i[a++]=n>>16&255,i[a++]=n>>8&255,i[a++]=255&n):18===s?(i[a++]=n>>10&255,i[a++]=n>>2&255):12===s&&(i[a++]=n>>4&255),i}},{}],22:[function(t,e,r){var i;e.exports=function(){if(void 0!==i||(i=!1,"u"t.length)&&(e=t.length);for(var r=0,i=Array(e);rtypeof navigator&&navigator.userAgent&&(l=navigator.userAgent.indexOf("Safari")>=0)}catch(t){}var g=1;"u">typeof navigator&&(g=Math.min(navigator.hardwareConcurrency||1,4));var p={tile:1024,concurrency:g,features:["js","wasm","ww"],idle:2e3,createCanvas:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r}},d={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},_=!1,m=!1,I=!1,w=!1,b=!1;function v(){return{value:a(u),destroy:function(){if(this.value.terminate(),"u">typeof window){var t=window.URL||window.webkitURL||window.mozURL||window.msURL;t&&t.revokeObjectURL&&this.value.objectURL&&t.revokeObjectURL(this.value.objectURL)}}}}function y(t){if(!(this instanceof y))return new y(t);this.options=n({},p,t||{});var e="lk_".concat(this.options.concurrency);this.__limit=c[e]||A.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}y.prototype.init=function(){var e,r,i=this;if(this.__initPromise)return this.__initPromise;if("u">typeof ImageData&&"u">typeof Uint8ClampedArray)try{new ImageData(new Uint8ClampedArray(400),10,10),_=!0}catch(t){}"u">typeof ImageBitmap&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?m=!0:this.debug("ImageBitmap does not support .close(), disabled"));var a=this.options.features.slice();if(a.indexOf("all")>=0&&(a=["cib","wasm","js","ww"]),this.__requested_features=a,this.__mathlib=new o(a),a.indexOf("ww")>=0&&"u">typeof window&&"Worker"in window)try{t("webworkify")(function(){}).terminate(),this.features.ww=!0;var u="wp_".concat(JSON.stringify(this.options));c[u]?this.__workersPool=c[u]:(this.__workersPool=new s(v,this.options.idle),c[u]=this.__workersPool)}catch(t){}var h=this.__mathlib.init().then(function(t){n(i.features,t.features)});e=m?A.cib_support(this.options.createCanvas).then(function(t){i.features.cib&&0>a.indexOf("cib")?i.debug("createImageBitmap() resize supported, but disabled by config"):a.indexOf("cib")>=0&&(i.features.cib=t)}):Promise.resolve(!1),I=A.can_use_canvas(this.options.createCanvas),r=(r=m&&_&&-1!==a.indexOf("ww")?A.worker_offscreen_canvas_support():Promise.resolve(!1)).then(function(t){w=t});var f=A.cib_can_use_region().then(function(t){b=t});return this.__initPromise=Promise.all([h,e,r,f]).then(function(){return i}),this.__initPromise},y.prototype.__invokeResize=function(t,e){var r=this;return e.__mathCache=e.__mathCache||{},Promise.resolve().then(function(){return r.features.ww?new Promise(function(i,n){var a=r.__workersPool.acquire();e.cancelToken&&e.cancelToken.catch(function(t){return n(t)}),a.value.onmessage=function(t){a.release(),t.data.err?n(t.data.err):i(t.data)};var o=[];t.src&&o.push(t.src.buffer),t.srcBitmap&&o.push(t.srcBitmap),a.value.postMessage({opts:t,features:r.__requested_features,preload:{wasm_nodule:r.__mathlib.__}},o)}):{data:r.__mathlib.resizeAndUnsharp(t,e.__mathCache)}})},y.prototype.__extractTileData=function(t,e,r,i,n){if(this.features.ww&&w&&(A.isCanvas(e)||b))return this.debug("Create tile for OffscreenCanvas"),createImageBitmap(i.srcImageBitmap||e,t.x,t.y,t.width,t.height).then(function(t){return n.srcBitmap=t,n});if(A.isCanvas(e))return i.srcCtx||(i.srcCtx=e.getContext("2d",{alpha:!!r.alpha})),this.debug("Get tile pixel data"),n.src=i.srcCtx.getImageData(t.x,t.y,t.width,t.height).data,n;this.debug("Draw tile imageBitmap/image to temporary canvas");var a=this.options.createCanvas(t.width,t.height),o=a.getContext("2d",{alpha:!!r.alpha});return o.globalCompositeOperation="copy",o.drawImage(i.srcImageBitmap||e,t.x,t.y,t.width,t.height,0,0,t.width,t.height),this.debug("Get tile pixel data"),n.src=o.getImageData(0,0,t.width,t.height).data,a.width=a.height=0,n},y.prototype.__landTileData=function(t,e,r){var i;if(this.debug("Convert raw rgba tile result to ImageData"),e.bitmap)return r.toCtx.drawImage(e.bitmap,t.toX,t.toY),null;if(_)i=new ImageData(new Uint8ClampedArray(e.data),t.toWidth,t.toHeight);else if((i=r.toCtx.createImageData(t.toWidth,t.toHeight)).data.set)i.data.set(e.data);else for(var n=i.data.length-1;n>=0;n--)i.data[n]=e.data[n];return this.debug("Draw tile"),l?r.toCtx.putImageData(i,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth+1e-5,t.toInnerHeight+1e-5):r.toCtx.putImageData(i,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth,t.toInnerHeight),null},y.prototype.__tileAndResize=function(t,e,r){var i=this,n={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null};return Promise.resolve().then(function(){if(n.toCtx=e.getContext("2d",{alpha:!!r.alpha}),A.isCanvas(t))return null;if(A.isImageBitmap(t))return n.srcImageBitmap=t,n.isImageBitmapReused=!0,null;if(A.isImage(t))return m?(i.debug("Decode image via createImageBitmap"),createImageBitmap(t).then(function(t){n.srcImageBitmap=t}).catch(function(t){return null})):null;throw Error('Pica: ".from" should be Image, Canvas or ImageBitmap')}).then(function(){if(r.canceled)return r.cancelToken;i.debug("Calculate tiles");var a=f({width:r.width,height:r.height,srcTileSize:i.options.tile,toWidth:r.toWidth,toHeight:r.toHeight,destTileBorder:r.__destTileBorder}).map(function(e){return i.__limit(function(){if(r.canceled)return r.cancelToken;var a={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:r.quality,alpha:r.alpha,unsharpAmount:r.unsharpAmount,unsharpRadius:r.unsharpRadius,unsharpThreshold:r.unsharpThreshold};return i.debug("Invoke resize math"),Promise.resolve(a).then(function(a){return i.__extractTileData(e,t,r,n,a)}).then(function(t){return i.debug("Invoke resize math"),i.__invokeResize(t,r)}).then(function(t){return r.canceled?r.cancelToken:(n.srcImageData=null,i.__landTileData(e,t,n))})})});function o(t){t.srcImageBitmap&&(t.isImageBitmapReused||t.srcImageBitmap.close(),t.srcImageBitmap=null)}return i.debug("Process tiles"),Promise.all(a).then(function(){return i.debug("Finished!"),o(n),e},function(t){throw o(n),t})})},y.prototype.__processStages=function(t,e,r,a){var o,s,A=this;if(a.canceled)return a.cancelToken;var u=function(t){if(Array.isArray(t))return t}(o=t.shift())||function(t){var e,r,i=null==t?null:"u">typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n=[],a=!0,o=!1;try{for(i=i.call(t);!(a=(e=i.next()).done)&&(n.push(e.value),2!==n.length);a=!0);}catch(t){o=!0,r=t}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return n}}(o)||function(t){if(t){if("string"==typeof t)return i(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);if("Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(t,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=u[0],f=u[1],c=0===t.length;return a=n({},a,{toWidth:h,toHeight:f,quality:c?a.quality:Math.min(1,a.quality)}),c||(s=this.options.createCanvas(h,f)),this.__tileAndResize(e,c?r:s,a).then(function(){return c?r:(a.width=h,a.height=f,A.__processStages(t,s,r,a))}).then(function(t){return s&&(s.width=s.height=0),t})},y.prototype.__resizeViaCreateImageBitmap=function(t,e,r){var i=this,n=e.getContext("2d",{alpha:!!r.alpha});return this.debug("Resize via createImageBitmap()"),createImageBitmap(t,{resizeWidth:r.toWidth,resizeHeight:r.toHeight,resizeQuality:A.cib_quality_name(r.quality)}).then(function(t){if(r.canceled)return r.cancelToken;if(!r.unsharpAmount)return n.drawImage(t,0,0),t.close(),n=null,i.debug("Finished!"),e;i.debug("Unsharp result");var a=i.options.createCanvas(r.toWidth,r.toHeight),o=a.getContext("2d",{alpha:!!r.alpha});o.drawImage(t,0,0),t.close();var s=o.getImageData(0,0,r.toWidth,r.toHeight);return i.__mathlib.unsharp_mask(s.data,r.toWidth,r.toHeight,r.unsharpAmount,r.unsharpRadius,r.unsharpThreshold),n.putImageData(s,0,0),a.width=a.height=0,s=o=a=n=null,i.debug("Finished!"),e})},y.prototype.resize=function(t,e,r){var i=this;this.debug("Start resize...");var a=n({},d);return(isNaN(r)?r&&(a=n(a,r)):a=n(a,{quality:r}),a.toWidth=e.width,a.toHeight=e.height,a.width=t.naturalWidth||t.width,a.height=t.naturalHeight||t.height,0===e.width||0===e.height)?Promise.reject(Error("Invalid output size: ".concat(e.width,"x").concat(e.height))):(a.unsharpRadius>2&&(a.unsharpRadius=2),a.canceled=!1,a.cancelToken&&(a.cancelToken=a.cancelToken.then(function(t){throw a.canceled=!0,t},function(t){throw a.canceled=!0,t})),a.__destTileBorder=Math.ceil(Math.max(3,2.5*a.unsharpRadius|0)),this.init().then(function(){if(a.canceled)return a.cancelToken;if(i.features.cib)return i.__resizeViaCreateImageBitmap(t,e,a);if(!I){var r=Error("Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled");throw r.code="ERR_GET_IMAGE_DATA",r}var n=h(a.width,a.height,a.toWidth,a.toHeight,i.options.tile,a.__destTileBorder);return i.__processStages(n,t,e,a)}))},y.prototype.resizeBuffer=function(t){var e=this,r=n({},d,t);return this.init().then(function(){return e.__mathlib.resizeAndUnsharp(r)})},y.prototype.toBlob=function(t,e,r){return e=e||"image/png",new Promise(function(i){if(t.toBlob)return void t.toBlob(function(t){return i(t)},e,r);if(t.convertToBlob)return void i(t.convertToBlob({type:e,quality:r}));for(var n=atob(t.toDataURL(e,r).split(",")[1]),a=n.length,o=new Uint8Array(a),s=0;s0;r--)e="0"+e;return"0x"+e}function i(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function n(t,r,i){this.input=t.subarray(r,i),this.start=r;var n=String.fromCharCode.apply(null,this.input.subarray(0,4));if("II*\0"!==n&&"MM\0*"!==n)throw e("invalid TIFF signature","EBADDATA");this.big_endian="M"===n[0]}n.prototype.each=function(t){this.aborted=!1;var e=this.read_uint32(4);for(this.ifds_to_read=[{id:0,offset:e}];this.ifds_to_read.length>0&&!this.aborted;){var r=this.ifds_to_read.shift();r.offset&&this.scan_ifd(r.id,r.offset,t)}},n.prototype.filter=function(t){var r={};r.ifd0={id:0,entries:[]},this.each(function(e){!1===t(e)&&!e.is_subifd_link||e.is_subifd_link&&1!==e.count&&4!==e.format||(r["ifd"+e.ifd]||(r["ifd"+e.ifd]={id:e.ifd,entries:[]}),r["ifd"+e.ifd].entries.push(e))}),delete r.ifd1;var i=8;Object.keys(r).forEach(function(t){i+=2,r[t].entries.forEach(function(t){i+=12+(t.data_length>4?2*Math.ceil(t.data_length/2):0)}),i+=4}),this.output=new Uint8Array(i),this.output[0]=this.output[1]=(this.big_endian?"M":"I").charCodeAt(0),this.write_uint16(2,42);var n=8,a=this;if(this.write_uint32(4,n),Object.keys(r).forEach(function(t){r[t].written_offset=n;var e=n,i=e+2+12*r[t].entries.length+4;n=i,a.write_uint16(e,r[t].entries.length),r[t].entries.sort(function(t,e){return t.tag-e.tag}).forEach(function(t,i){var o=e+2+12*i;a.write_uint16(o,t.tag),a.write_uint16(o+2,t.format),a.write_uint32(o+4,t.count),t.is_subifd_link?r["ifd"+t.tag]&&(r["ifd"+t.tag].link_offset=o+8):t.data_length<=4?a.output.set(a.input.subarray(t.data_offset-a.start,t.data_offset-a.start+4),o+8):(a.write_uint32(o+8,n),a.output.set(a.input.subarray(t.data_offset-a.start,t.data_offset-a.start+t.data_length),n),n+=2*Math.ceil(t.data_length/2))});var o=r["ifd"+(r[t].id+1)];o&&(o.link_offset=i-4)}),Object.keys(r).forEach(function(t){r[t].written_offset&&r[t].link_offset&&a.write_uint32(r[t].link_offset,r[t].written_offset)}),this.output.length!==n)throw e("internal error: incorrect buffer size allocated");return this.output},n.prototype.read_uint16=function(t){var r=this.input;if(t+2>r.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?256*r[t]+r[t+1]:r[t]+256*r[t+1]},n.prototype.read_uint32=function(t){var r=this.input;if(t+4>r.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?0x1000000*r[t]+65536*r[t+1]+256*r[t+2]+r[t+3]:r[t]+256*r[t+1]+65536*r[t+2]+0x1000000*r[t+3]},n.prototype.write_uint16=function(t,e){var r=this.output;this.big_endian?(r[t]=e>>>8&255,r[t+1]=255&e):(r[t]=255&e,r[t+1]=e>>>8&255)},n.prototype.write_uint32=function(t,e){var r=this.output;this.big_endian?(r[t]=e>>>24&255,r[t+1]=e>>>16&255,r[t+2]=e>>>8&255,r[t+3]=255&e):(r[t]=255&e,r[t+1]=e>>>8&255,r[t+2]=e>>>16&255,r[t+3]=e>>>24&255)},n.prototype.is_subifd_link=function(t,e){return 0===t&&34665===e||0===t&&34853===e||34665===t&&40965===e},n.prototype.exif_format_length=function(t){switch(t){case 1:case 2:case 6:case 7:return 1;case 3:case 8:return 2;case 4:case 9:case 11:return 4;case 5:case 10:case 12:return 8;default:return 0}},n.prototype.exif_format_read=function(t,e){var r;switch(t){case 1:case 2:return this.input[e];case 6:return(r=this.input[e])|(128&r)*0x1fffffe;case 3:return this.read_uint16(e);case 8:return(r=this.read_uint16(e))|(32768&r)*131070;case 4:return this.read_uint32(e);case 9:return 0|(r=this.read_uint32(e));default:return null}},n.prototype.scan_ifd=function(t,r,i){var n=this.read_uint16(r);r+=2;for(var a=0;athis.input.length)throw e("unexpected EOF","EBADDATA");for(var l=[],g=f,p=0;p0&&(this.ifds_to_read.push({id:o,offset:l[0]}),c=!0),!1===i({is_big_endian:this.big_endian,ifd:t,tag:o,format:s,count:A,entry_offset:r+this.start,data_length:h,data_offset:f+this.start,value:l,is_subifd_link:c})){this.aborted=!0;return}r+=12}0===t&&this.ifds_to_read.push({id:1,offset:this.read_uint32(r)})},t.exports.is_jpeg=function(t){return t.length>=4&&255===t[0]&&216===t[1]&&255===t[2]},t.exports.jpeg_segments_each=function(n,a){if(!i(n))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof a)throw e("Invalid argument (on_segment), Function expected","EINVAL");if(!t.exports.is_jpeg(n))throw e("Unknown file format","ENOTJPEG");for(var o=0,s=n.length,A=!1;;){if(o+1>=s)throw e("Unexpected EOF","EBADDATA");var u,h,f=n[o],c=n[o+1];if(255===f&&255===c)u=255,h=1;else if(255===f&&0!==c){if(h=2,208<=(u=c)&&u<=217||1===u);else{if(o+3>=s)throw e("Unexpected EOF","EBADDATA");if((h+=256*n[o+2]+n[o+3])<2)throw e("Invalid segment length","EBADDATA");if(o+h-1>=s)throw e("Unexpected EOF","EBADDATA")}A&&(u>=208&&u<=215||(A=!1)),218===u&&(A=!0)}else if(A)for(var l=o+1;;l++){if(l>=s)throw e("Unexpected EOF","EBADDATA");if(255===n[l]){if(l+1>=s)throw e("Unexpected EOF","EBADDATA");if(0!==n[l+1]){u=0,h=l-o;break}}}else throw e("Unexpected byte at segment start: "+r(f)+" (offset "+r(o)+")","EBADDATA");if(!1===a({code:u,offset:o,length:h})||217===u)break;o+=h}},t.exports.jpeg_segments_filter=function(r,n){if(!i(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof n)throw e("Invalid argument (on_segment), Function expected","EINVAL");var a=[],o=0;t.exports.jpeg_segments_each(r,function(t){var e=n(t);if(i(e))a.push({data:e}),o+=e.length;else if(Array.isArray(e))e.filter(i).forEach(function(t){a.push({data:t}),o+=t.length});else if(!1!==e){var r={start:t.offset,end:t.offset+t.length};a.length>0&&a[a.length-1].end===r.start?a[a.length-1].end=r.end:a.push(r),o+=t.length}});var s=new Uint8Array(o),A=0;return a.forEach(function(t){var e=t.data||r.subarray(t.start,t.end);s.set(e,A),A+=e.length}),s},t.exports.jpeg_exif_tags_each=function(r,a){if(!i(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof a)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");t.exports.jpeg_segments_each(r,function(t){return 218!==t.code&&(225===t.code&&t.length>=10&&69===r[t.offset+4]&&120===r[t.offset+5]&&105===r[t.offset+6]&&102===r[t.offset+7]&&0===r[t.offset+8]&&0===r[t.offset+9]?(new n(r,t.offset+10,t.offset+t.length).each(a),!1):void 0)})},t.exports.jpeg_exif_tags_filter=function(r,a){if(!i(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof a)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");var o=!1;return t.exports.jpeg_segments_filter(r,function(t){if(!o&&(218===t.code&&(o=!0),225===t.code&&t.length>=10&&69===r[t.offset+4]&&120===r[t.offset+5]&&105===r[t.offset+6]&&102===r[t.offset+7]&&0===r[t.offset+8]&&0===r[t.offset+9])){var e=new n(r,t.offset+10,t.offset+t.length).filter(a);if(!e)return!1;var i=new Uint8Array(10);return i.set(r.slice(t.offset,t.offset+10)),i[2]=e.length+8>>>8&255,i[3]=e.length+8&255,o=!0,[i,e]}})},t.exports.jpeg_add_comment=function(e,r){var i=!1,n=0;return t.exports.jpeg_segments_filter(e,function(t){if((1!=++n||216!==t.code)&&(2!==n||224!==t.code)&&!i){var a=new Uint8Array(5+(r=function(t){try{return unescape(encodeURIComponent(t))}catch(e){return t}}(r)).length),o=0;return a[o++]=255,a[o++]=254,a[o++]=r.length+3>>>8&255,a[o++]=r.length+3&255,r.split("").forEach(function(t){a[o++]=255&t.charCodeAt(0)}),a[o++]=0,i=!0,[a,e.subarray(t.offset,t.offset+t.length)]}})}});function u(t){return this._getUint8Array(t.blob).then(function(e){if(t.is_jpeg=A.is_jpeg(e),!t.is_jpeg)return Promise.resolve(t);t.orig_blob=t.blob;try{var r,i;if(A.jpeg_exif_tags_each(e,function(e){if(0===e.ifd&&274===e.tag&&Array.isArray(e.value))return t.orientation=e.value[0]||1,r=e.is_big_endian,i=e.data_offset,!1}),i){var n=new Uint8Array(r?[0,1]:[1,0]);t.blob=new Blob([e.slice(0,i),n,e.slice(i+2)],{type:"image/jpeg"})}}catch(t){}return t})}function h(t){if(!t.is_jpeg)return Promise.resolve(t);var e,r=t.orientation-1;if(!r)return Promise.resolve(t);var i=(e=4&r?this.pica.options.createCanvas(t.out_canvas.height,t.out_canvas.width):this.pica.options.createCanvas(t.out_canvas.width,t.out_canvas.height)).getContext("2d");return i.save(),1&r&&i.transform(-1,0,0,1,e.width,0),2&r&&i.transform(-1,0,0,-1,e.width,e.height),4&r&&i.transform(0,1,1,0,0,0),i.drawImage(t.out_canvas,0,0),i.restore(),t.out_canvas.width=t.out_canvas.height=0,t.out_canvas=e,Promise.resolve(t)}function f(t){return t.is_jpeg?Promise.all([this._getUint8Array(t.blob),this._getUint8Array(t.out_blob)]).then(function(e){var r=e[0],i=e[1];if(!A.is_jpeg(r))return Promise.resolve(t);var n=[];return A.jpeg_segments_each(r,function(t){if(218===t.code)return!1;n.push(t)}),n=n.filter(function(t){return 226!==t.code&&(!!(t.code>=224)&&!!(t.code<240)||254===t.code)}).map(function(t){return r.slice(t.offset,t.offset+t.length)}),t.out_blob=new Blob([i.slice(0,2)].concat(n).concat([i.slice(20)]),{type:"image/jpeg"}),t}):Promise.resolve(t)}var c=function(t){t.before("_blob_to_image",u),t.after("_transform",h),t.after("_create_blob",f)};function l(t){if(!(this instanceof l))return new l(t);t=t||{},this.pica=t.pica||s({}),this.initialized=!1,this.utils=n}l.prototype.use=function(t){var e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},l.prototype.init=function(){this.use(c)},l.prototype.toBlob=function(t,e){var r=n.assign({max:1/0},e);return this.initialized||(this.init(),this.initialized=!0),Promise.resolve({blob:t,opts:r}).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then(this._create_blob).then(function(t){return t.out_canvas.width=t.out_canvas.height=0,t.out_blob})},l.prototype.toCanvas=function(t,e){var r=n.assign({max:1/0},e);return this.initialized||(this.init(),this.initialized=!0),Promise.resolve({blob:t,opts:r}).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then(function(t){return t.out_canvas})},l.prototype.before=function(t,e){if(!this[t])throw Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw Error('Invalid argument "fn", function expected');var r=this[t],i=this;return this[t]=function(t){return e.call(i,t).then(function(t){return r.call(i,t)})},this},l.prototype.after=function(t,e){if(!this[t])throw Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw Error('Invalid argument "fn", function expected');var r=this[t],i=this;return this[t]=function(t){return r.call(i,t).then(function(t){return e.call(i,t)})},this},l.prototype._blob_to_image=function(t){var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return t.image=document.createElement("img"),t.image_url=e.createObjectURL(t.blob),t.image.src=t.image_url,new Promise(function(e,r){t.image.onerror=function(){r(Error("ImageBlobReduce: failed to create Image() from blob"))},t.image.onload=function(){e(t)}})},l.prototype._calculate_size=function(t){var e=t.opts.max/Math.max(t.image.width,t.image.height);return e>1&&(e=1),t.transform_width=Math.max(Math.round(t.image.width*e),1),t.transform_height=Math.max(Math.round(t.image.height*e),1),t.scale_factor=e,Promise.resolve(t)},l.prototype._transform=function(t){t.out_canvas=this.pica.options.createCanvas(t.transform_width,t.transform_height),t.transform_width=null,t.transform_height=null;var e={alpha:"image/png"===t.blob.type};return this.utils.assign(e,this.utils.pick_pica_resize_options(t.opts)),this.pica.resize(t.image,t.out_canvas,e).then(function(){return t})},l.prototype._cleanup=function(t){t.image.src="",t.image=null;var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return e.revokeObjectURL&&e.revokeObjectURL(t.image_url),t.image_url=null,Promise.resolve(t)},l.prototype._create_blob=function(t){return this.pica.toBlob(t.out_canvas,t.blob.type).then(function(e){return t.out_blob=e,t})},l.prototype._getUint8Array=function(t){return t.arrayBuffer?t.arrayBuffer().then(function(t){return new Uint8Array(t)}):new Promise(function(e,r){var i=new FileReader;i.readAsArrayBuffer(t),i.onload=function(){e(new Uint8Array(i.result))},i.onerror=function(){r(Error("ImageBlobReduce: failed to load data from input blob")),i.abort()},i.onabort=function(){r(Error("ImageBlobReduce: failed to load data from input blob (aborted)"))}})},l.pica=s;let g=l}}]);