/*! cornerstone-wado-image-loader - 0.15.1 - 2017-10-26 | (c) 2016 Chris Hafey | https://github.com/chafey/cornerstoneWADOImageLoader */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cornerstoneWADOImageLoaderWebWorker",[],t):"object"==typeof exports?exports.cornerstoneWADOImageLoaderWebWorker=t():e.cornerstoneWADOImageLoaderWebWorker=t()}(this,function(){return function(e){function t(a){if(r[a])return r[a].exports;var n=r[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=55)}({2:function(e,t,r){"use strict";function a(e){for(var t=e[0],r=e[0],a=void 0,n=e.length,i=1;i<n;i++)a=e[i],t=Math.min(t,a),r=Math.max(r,a);return{min:t,max:r}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a},37:function(e,t,r){"use strict";function a(e,t){var r=new JpxImage;r.parse(t);var a=r.tiles.length;if(1!==a)throw"JPEG2000 decoder returned a tileCount of "+a+", when 1 is expected";return e.columns=r.width,e.rows=r.height,e.pixelData=r.tiles[0].items,e}function n(e,t,r){var a=s._malloc(e.length);s.writeArrayToMemory(e,a);var n=s._malloc(4),i=s._malloc(4),o=s._malloc(4),l=s._malloc(4),f=s._malloc(4),u=Date.now();if(0!==s.ccall("jp2_decode","number",["number","number","number","number","number","number","number"],[a,e.length,n,i,o,l,f]))return console.log("[opj_decode] decoding failed!"),s._free(a),s._free(s.getValue(n,"*")),s._free(o),s._free(l),s._free(i),void s._free(f);var d=s.getValue(n,"*"),c={length:s.getValue(i,"i32"),sx:s.getValue(o,"i32"),sy:s.getValue(l,"i32"),nbChannels:s.getValue(f,"i32"),perf_timetodecode:void 0,pixelData:void 0},p=c.sx*c.sy*c.nbChannels,m=new Int32Array(s.HEAP32.buffer,d,p);if(1===t)if(Uint8Array.from)c.pixelData=Uint8Array.from(m);else{c.pixelData=new Uint8Array(p);for(var g=0;g<p;g++)c.pixelData[g]=m[g]}else if(r)if(Int16Array.from)c.pixelData=Int16Array.from(m);else{c.pixelData=new Int16Array(p);for(var y=0;y<p;y++)c.pixelData[y]=m[y]}else if(Uint16Array.from)c.pixelData=Uint16Array.from(m);else{c.pixelData=new Uint16Array(p);for(var b=0;b<p;b++)c.pixelData[b]=m[b]}var x=Date.now();return c.perf_timetodecode=x-u,s._free(a),s._free(n),s._free(d),s._free(i),s._free(o),s._free(l),s._free(f),c}function i(e,t){var r=e.bitsAllocated<=8?1:2,a=1===e.pixelRepresentation,i=n(t,r,a);return e.columns=i.sx,e.rows=i.sy,e.pixelData=i.pixelData,i.nbChannels>1&&(e.photometricInterpretation="RGB"),e}function o(e){if(!e.usePDFJS&&"undefined"==typeof OpenJPEG)throw"OpenJPEG decoder not loaded";if(!(s||(s=OpenJPEG())&&s._jp2_decode))throw"OpenJPEG failed to initialize"}function l(e,t,r,n){return n=n||{},o(r),n.usePDFJS||r.usePDFJS?a(e,t):i(e,t)}Object.defineProperty(t,"__esModule",{value:!0});var s=void 0;t.default=l,t.initializeJPEG2000=o},38:function(e,t,r){"use strict";function a(e,t){var r=o._malloc(e.length);o.writeArrayToMemory(e,r);var a=o._malloc(4),n=o._malloc(4),i=o._malloc(4),l=o._malloc(4),s=o._malloc(4),f=o._malloc(4),u=o._malloc(4),d=o._malloc(4),c=o._malloc(4),p=o.ccall("jpegls_decode","number",["number","number","number","number","number","number","number","number","number","number","number"],[r,e.length,a,n,i,l,s,f,d,u,c]),m={result:p,width:o.getValue(i,"i32"),height:o.getValue(l,"i32"),bitsPerSample:o.getValue(s,"i32"),stride:o.getValue(f,"i32"),components:o.getValue(d,"i32"),allowedLossyError:o.getValue(u,"i32"),interleaveMode:o.getValue(c,"i32"),pixelData:void 0},g=o.getValue(a,"*");return m.bitsPerSample<=8?(m.pixelData=new Uint8Array(m.width*m.height*m.components),m.pixelData.set(new Uint8Array(o.HEAP8.buffer,g,m.pixelData.length))):t?(m.pixelData=new Int16Array(m.width*m.height*m.components),m.pixelData.set(new Int16Array(o.HEAP16.buffer,g,m.pixelData.length))):(m.pixelData=new Uint16Array(m.width*m.height*m.components),m.pixelData.set(new Uint16Array(o.HEAP16.buffer,g,m.pixelData.length))),o._free(r),o._free(g),o._free(a),o._free(n),o._free(i),o._free(l),o._free(s),o._free(f),o._free(d),o._free(c),m}function n(){if("undefined"==typeof CharLS)throw"No JPEG-LS decoder loaded";if(!(o||(o=CharLS())&&o._jpegls_decode))throw"JPEG-LS failed to initialize"}function i(e,t){n();var r=a(t,1===e.pixelRepresentation);if(0!==r.result&&6!==r.result)throw"JPEG-LS decoder failed to decode frame (error code "+r.result+")";return e.columns=r.width,e.rows=r.height,e.pixelData=r.pixelData,e}Object.defineProperty(t,"__esModule",{value:!0});var o=void 0;t.default=i,t.initializeJPEGLS=n},55:function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.registerTaskHandler=void 0;var n=r(9);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return a(n).default}});var i=r(56),o=r(57),l=a(o);(0,i.registerTaskHandler)(l.default),t.registerTaskHandler=i.registerTaskHandler},56:function(e,t,r){"use strict";function a(e){if(!l){if(s=e.config,e.config.webWorkerTaskPaths)for(var t=0;t<e.config.webWorkerTaskPaths.length;t++)self.importScripts(e.config.webWorkerTaskPaths[t]);Object.keys(o).forEach(function(e){o[e].initialize(s.taskConfiguration)}),self.postMessage({taskType:"initialize",status:"success",result:{},workerIndex:e.workerIndex}),l=!0}}function n(e){if(o[e.taskType])return console.log('attempt to register duplicate task handler "',e.taskType,'"'),!1;o[e.taskType]=e,l&&e.initialize(s.taskConfiguration)}function i(e){s=e.config,self.importScripts(e.sourcePath)}Object.defineProperty(t,"__esModule",{value:!0}),t.registerTaskHandler=n;var o={},l=!1,s=void 0;self.onmessage=function(e){return"initialize"===e.data.taskType?void a(e.data):"loadWebWorkerTask"===e.data.taskType?void i(e.data):o[e.data.taskType]?void o[e.data.taskType].handler(e.data,function(t,r){self.postMessage({taskType:e.data.taskType,status:"success",result:t,workerIndex:e.data.workerIndex},r)}):(console.log("no task handler for ",e.data.taskType),console.log(o),void self.postMessage({taskType:e.data.taskType,status:"failed - no task handler registered",workerIndex:e.data.workerIndex}))}},57:function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function n(e){m||(self.importScripts(e.decodeTask.codecsPath),m=!0,e.decodeTask.initializeCodecsOnStartup&&((0,s.initializeJPEG2000)(e.decodeTask),(0,f.initializeJPEGLS)(e.decodeTask)))}function i(e){g=e,e.decodeTask.loadCodecsOnStartup&&n(e)}function o(e){var t=(0,d.default)(e.pixelData);!0===g.decodeTask.strict?(e.smallestPixelValue!==t.min&&console.warn("Image smallestPixelValue tag is incorrect. Rendering performance will suffer considerably."),e.largestPixelValue!==t.max&&console.warn("Image largestPixelValue tag is incorrect. Rendering performance will suffer considerably.")):(e.smallestPixelValue=t.min,e.largestPixelValue=t.max)}function l(e,t){n(g);var r=e.data.imageFrame,a=new Uint8Array(e.data.pixelData);(0,p.default)(r,e.data.transferSyntax,a,g.decodeTask,e.data.options),o(r),r.pixelData=r.pixelData.buffer,t(r,[r.pixelData])}Object.defineProperty(t,"__esModule",{value:!0});var s=r(37),f=r(38),u=r(2),d=a(u),c=r(58),p=a(c),m=!1,g=void 0;t.default={taskType:"decodeTask",handler:l,initialize:i}},58:function(e,t,r){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function n(e,t,r,a,n){var i=(new Date).getTime();if("1.2.840.10008.1.2"===t)e=(0,o.default)(e,r);else if("1.2.840.10008.1.2.1"===t)e=(0,o.default)(e,r);else if("1.2.840.10008.1.2.2"===t)e=(0,s.default)(e,r);else if("1.2.840.10008.1.2.1.99"===t)e=(0,o.default)(e,r);else if("1.2.840.10008.1.2.5"===t)e=(0,u.default)(e,r);else if("1.2.840.10008.1.2.4.50"===t)e=(0,c.default)(e,r);else if("1.2.840.10008.1.2.4.51"===t)e=(0,c.default)(e,r);else if("1.2.840.10008.1.2.4.57"===t)e=(0,m.default)(e,r);else if("1.2.840.10008.1.2.4.70"===t)e=(0,m.default)(e,r);else if("1.2.840.10008.1.2.4.80"===t)e=(0,y.default)(e,r);else if("1.2.840.10008.1.2.4.81"===t)e=(0,y.default)(e,r);else if("1.2.840.10008.1.2.4.90"===t)e=(0,x.default)(e,r,a,n);else{if("1.2.840.10008.1.2.4.91"!==t)throw console&&console.log&&console.log("Image cannot be decoded due to Unsupported transfer syntax "+t),"no decoder for transfer syntax "+t;e=(0,x.default)(e,r,a,n)}var l=(new Date).getTime();return e.decodeTimeInMS=l-i,e}Object.defineProperty(t,"__esModule",{value:!0});var i=r(59),o=a(i),l=r(60),s=a(l),f=r(61),u=a(f),d=r(62),c=a(d),p=r(63),m=a(p),g=r(38),y=a(g),b=r(37),x=a(b);t.default=n},59:function(e,t,r){"use strict";function a(e,t){if(16===e.bitsAllocated){var r=t.buffer,a=t.byteOffset,n=t.length;a%2&&(r=r.slice(a),a=0),0===e.pixelRepresentation?e.pixelData=new Uint16Array(r,a,n/2):e.pixelData=new Int16Array(r,a,n/2)}else 8===e.bitsAllocated&&(e.pixelData=t);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a},60:function(e,t,r){"use strict";function a(e){return(255&e)<<8|e>>8&255}function n(e,t){if(16===e.bitsAllocated){var r=t.buffer,n=t.byteOffset,i=t.length;n%2&&(r=r.slice(n),n=0),0===e.pixelRepresentation?e.pixelData=new Uint16Array(r,n,i/2):e.pixelData=new Int16Array(r,n,i/2);for(var o=0;o<e.pixelData.length;o++)e.pixelData[o]=a(e.pixelData[o])}else 8===e.bitsAllocated&&(e.pixelData=t);return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},61:function(e,t,r){"use strict";function a(e,t){if(8===e.bitsAllocated)return e.planarConfiguration?i(e,t):n(e,t);if(16===e.bitsAllocated)return o(e,t);throw"unsupported pixel format for RLE"}function n(e,t){for(var r=t,a=e.rows*e.columns,n=new ArrayBuffer(a*e.samplesPerPixel),i=new DataView(r.buffer,r.byteOffset),o=new Int8Array(r.buffer,r.byteOffset),l=new Int8Array(n),s=0,f=i.getInt32(0,!0),u=0;u<f;++u){s=u;var d=i.getInt32(4*(u+1),!0),c=i.getInt32(4*(u+2),!0);0===c&&(c=r.length);for(var p=a*f;d<c;){var m=o[d++];if(m>=0&&m<=127)for(var g=0;g<m+1&&s<p;++g)l[s]=o[d++],s+=e.samplesPerPixel;else if(m<=-1&&m>=-127)for(var y=o[d++],b=0;b<1-m&&s<p;++b)l[s]=y,s+=e.samplesPerPixel}}return e.pixelData=new Uint8Array(n),e}function i(e,t){for(var r=t,a=e.rows*e.columns,n=new ArrayBuffer(a*e.samplesPerPixel),i=new DataView(r.buffer,r.byteOffset),o=new Int8Array(r.buffer,r.byteOffset),l=new Int8Array(n),s=0,f=i.getInt32(0,!0),u=0;u<f;++u){s=u*a;var d=i.getInt32(4*(u+1),!0),c=i.getInt32(4*(u+2),!0);0===c&&(c=r.length);for(var p=a*f;d<c;){var m=o[d++];if(m>=0&&m<=127)for(var g=0;g<m+1&&s<p;++g)l[s]=o[d++],s++;else if(m<=-1&&m>=-127)for(var y=o[d++],b=0;b<1-m&&s<p;++b)l[s]=y,s++}}return e.pixelData=new Uint8Array(n),e}function o(e,t){for(var r=t,a=e.rows*e.columns,n=new ArrayBuffer(a*e.samplesPerPixel*2),i=new DataView(r.buffer,r.byteOffset),o=new Int8Array(r.buffer,r.byteOffset),l=new Int8Array(n),s=i.getInt32(0,!0),f=0;f<s;++f){var u=0,d=0===f?1:0,c=i.getInt32(4*(f+1),!0),p=i.getInt32(4*(f+2),!0);for(0===p&&(p=r.length);c<p;){var m=o[c++];if(m>=0&&m<=127)for(var g=0;g<m+1&&u<a;++g)l[2*u+d]=o[c++],u++;else if(m<=-1&&m>=-127)for(var y=o[c++],b=0;b<1-m&&u<a;++b)l[2*u+d]=y,u++}}return 0===e.pixelRepresentation?e.pixelData=new Uint16Array(n):e.pixelData=new Int16Array(n),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a},62:function(e,t,r){"use strict";function a(e,t){if("undefined"==typeof JpegImage)throw"No JPEG Baseline decoder loaded";var r=new JpegImage;return r.parse(t),r.colorTransform=!1,8===e.bitsAllocated?(e.pixelData=r.getData(e.columns,e.rows),e):16===e.bitsAllocated?(e.pixelData=r.getData16(e.columns,e.rows),e):void 0}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a},63:function(e,t,r){"use strict";function a(e,t){if("undefined"==typeof jpeg||void 0===jpeg.lossless||void 0===jpeg.lossless.Decoder)throw"No JPEG Lossless decoder loaded";var r=e.bitsAllocated<=8?1:2,a=t.buffer,n=new jpeg.lossless.Decoder,i=n.decode(a,t.byteOffset,t.length,r);return 0===e.pixelRepresentation?16===e.bitsAllocated?(e.pixelData=new Uint16Array(i.buffer),e):(e.pixelData=new Uint8Array(i.buffer),e):(e.pixelData=new Int16Array(i.buffer),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a},9:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default="0.15.1"}})});
//# sourceMappingURL=cornerstoneWADOImageLoaderWebWorker.min.js.map