dcmjs-imaging
Version:
DICOM image and overlay rendering for Node.js and browser using dcmjs
2 lines • 105 kB
JavaScript
/*! dcmjs-imaging - 0.2.2 - 2025-08-06 | (c) 2021-2025 Pantelis Georgiadis | https://github.com/PantelisGeorgiadis/dcmjs-imaging */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("dcmjs")):"function"==typeof define&&define.amd?define("dcmjs-imaging",["dcmjs"],t):"object"==typeof exports?exports["dcmjs-imaging"]=t(require("dcmjs")):e.dcmjsImaging=t(e.dcmjs)}(this,(__WEBPACK_EXTERNAL_MODULE__111__=>(()=>{var __webpack_modules__={68:(e,t,r)=>{const{PhotometricInterpretation:i,StandardColorPalette:s}=r(492),n=r(91),a=r(311);class o{isValid(){throw new Error("isValid should be implemented")}getMinimumOutputValue(){throw new Error("getMinimumOutputValue should be implemented")}getMaximumOutputValue(){throw new Error("getMaximumOutputValue should be implemented")}recalculate(){throw new Error("recalculate should be implemented")}getValue(e){throw new Error("getValue should be implemented")}}class l extends o{constructor(e,t,r,i){super(),this.slope=r,this.intercept=i,this.minValue=this.getValue(e),this.maxValue=this.getValue(t)}getRescaleSlope(){return this.slope}getRescaleIntercept(){return this.intercept}isValid(){return!0}getMinimumOutputValue(){return this.minValue}getMaximumOutputValue(){return this.maxValue}recalculate(){}getValue(e){return Math.trunc(e*this.getRescaleSlope()+this.getRescaleIntercept())}}class c extends o{constructor(e,t){super(),this.setWindowLevel(e),this.setFunction(t||"LINEAR"),this.valid=!1}getWindowLevel(){return this.windowLevel}setWindowLevel(e){this.windowLevel=e,this.valid=!1}getFunction(){return this.function}setFunction(e){this.function=e,this.valid=!1}isValid(){return this.valid}getMinimumOutputValue(){return 0}getMaximumOutputValue(){return 255}recalculate(){if(this.isValid())return;const e=this.getWindowLevel();this.windowCenter=e.getLevel(),this.windowWidth=e.getWindow(),this.windowCenterMin05=this.windowCenter-.5,this.windowWidthMin1=this.windowWidth-1,this.windowWidthDiv2=this.windowWidthMin1/2,this.windowStart=Math.trunc(this.windowCenterMin05-this.windowWidthDiv2),this.windowEnd=Math.trunc(this.windowCenterMin05+this.windowWidthDiv2),this.valid=!0}getValue(e){return 1===this.windowWidth?e<this.windowCenterMin05?this.getMinimumOutputValue():this.getMaximumOutputValue():"SIGMOID"===this.function.toUpperCase()?Math.min(this.getMaximumOutputValue(),Math.max(this.getMinimumOutputValue(),Math.trunc(this.getMaximumOutputValue()/(1+Math.exp((e-this.windowCenter)/this.windowWidth*-4))))):"LINEAR_EXACT"===this.function.toUpperCase()?Math.min(this.getMaximumOutputValue(),Math.max(this.getMinimumOutputValue(),Math.trunc((e-this.windowCenter)/this.windowWidth*this.getMaximumOutputValue()+this.getMinimumOutputValue()))):Math.min(this.getMaximumOutputValue(),Math.max(this.getMinimumOutputValue(),Math.trunc(((e-this.windowCenterMin05)/this.windowWidthMin1+.5)*this.getMaximumOutputValue()+this.getMinimumOutputValue())))}}class h extends o{constructor(e,t){super(),this.minValue=e,this.maxValue=t}isValid(){return!0}getMinimumOutputValue(){return this.minValue}getMaximumOutputValue(){return this.maxValue}recalculate(){}getValue(e){return Math.trunc(this.getMaximumOutputValue()-e)}}class d extends o{constructor(e,t){super(),this.minValue=e,this.setColorPalette(t)}getColorPalette(){return this.colorPalette}setColorPalette(e){this.colorPalette=e}isValid(){return void 0!==this.colorPalette}getMinimumOutputValue(){return Number.MIN_SAFE_INTEGER}getMaximumOutputValue(){return Number.MAX_SAFE_INTEGER}recalculate(){}getValue(e){return Math.trunc(this.colorPalette[e-this.minValue>0?e-this.minValue:0])}}class u extends o{constructor(e){super(),this.table=void 0,this.setColorPalette(e)}getColorPalette(){return this.colorPalette}setColorPalette(e){if(void 0===e||!Array.isArray(e)||256!==e.length)throw new Error("Expected 256-entry color palette");this.colorPalette=e,this.table=void 0}isValid(){return void 0!==this.table}getMinimumOutputValue(){return Number.MIN_SAFE_INTEGER}getMaximumOutputValue(){return Number.MAX_SAFE_INTEGER}recalculate(){if(!this.isValid()){this.table=new Array(256);for(let e=0;e<256;e++)this.table[e]=this.colorPalette[e]}}getValue(e){return Math.trunc(this.table[e])}}class g extends o{constructor(){super(),this.luts=[]}addLut(e){if(!(e instanceof o))throw new Error(`${e.toString()} is not a LUT`);this.luts.push(e)}isValid(){for(let e=0;e<this.luts.length;e++){if(!this.luts[e].isValid())return!1}return!0}getMinimumOutputValue(){let e;return this.luts.length>0&&(e=this.luts[this.luts.length-1]),void 0!==e?e.getMinimumOutputValue():0}getMaximumOutputValue(){let e;return this.luts.length>0&&(e=this.luts[this.luts.length-1]),void 0!==e?e.getMaximumOutputValue():255}recalculate(){for(let e=0;e<this.luts.length;e++){this.luts[e].recalculate()}}getValue(e){for(let t=0;t<this.luts.length;t++){e=this.luts[t].getValue(e)}return Math.trunc(e)}}class p extends o{constructor(e,t,r){super(),this.minValue=t,this.maxValue=r,this.offset=-this.minValue,this.table=new Array(this.maxValue-this.minValue+1),this.lut=e}isValid(){return this.lut.isValid()}getMinimumOutputValue(){return this.lut.getMinimumOutputValue()}getMaximumOutputValue(){return this.lut.getMaximumOutputValue()}recalculate(){this.isValid()||this.lut.recalculate();for(let e=this.minValue;e<=this.maxValue;e++)this.table[e+this.offset]=this.lut.getValue(e)}getValue(e){const t=e+this.offset;return t<0?this.table[0]:t>=this.table.length?this.table[this.table.length-1]:Math.trunc(this.table[t])}}class m extends o{constructor(e,t,r){super(),this.minValue=t,this.maxValue=r,this.offset=-this.minValue,this.lutCache={},this.lutCacheLength=this.maxValue-this.minValue+1,this.lut=e}isValid(){return this.lut.isValid()}getMinimumOutputValue(){return this.lut.getMinimumOutputValue()}getMaximumOutputValue(){return this.lut.getMaximumOutputValue()}recalculate(){this.isValid()||this.lut.recalculate()}getValue(e){const t=e+this.offset;return t<0?this._getOrCalculate(0):t>=this.lutCacheLength?this._getOrCalculate(this.lutCacheLength-1):this._getOrCalculate(t)}_getOrCalculate(e){if(void 0!==this.lutCache[e])return this.lutCache[e];const t=this.lut.getValue(e-this.offset);return this.lutCache[e]=Math.trunc(t),t}}class f{getLut(){throw new Error("getLut should be implemented")}static create(e,t,r,a){const o=e.getPhotometricInterpretation();if(o===i.Monochrome1||o===i.Monochrome2){const l=new w(e.getRescaleSlope(),e.getRescaleIntercept(),e.getBitsStored(),e.isSigned());return l.setColorPalette(void 0!==a&&a!==s.Grayscale?n.getColorPaletteStandard(a):o===i.Monochrome1?n.getColorPaletteMonochrome1():n.getColorPaletteMonochrome2()),l.setWindowLevel(t||this._calculateWindowLevel(e,r)),l.setVoiLutFunction(e.getVoiLutFunction()),l}if(o===i.Rgb||o===i.YbrFull||o===i.YbrFull422||o===i.YbrPartial422||o===i.YbrIct||o===i.YbrRct||o===i.Argb||o===i.Cmyk||o===i.Hsv)return new P;if(o===i.PaletteColor)return new x(e);throw new Error(`Unsupported LUT pipeline photometric interpretation: ${o}`)}static _calculateWindowLevel(e,t){if(void 0!==e.getSmallestImagePixelValue()&&void 0!==e.getLargestImagePixelValue()){let t=e.getSmallestImagePixelValue(),r=e.getLargestImagePixelValue();if(t<r)return t=Math.trunc(t*e.getRescaleSlope()+e.getRescaleIntercept()),r=Math.trunc(r*e.getRescaleSlope()+e.getRescaleIntercept()),new a(Math.abs(r-t),(r+t)/2,"Smallest-largest value window")}let r;if(1===e.getBitsStored())return new a(2,1,"Single-bit window");if(e.getBitsStored()<=8)r=e.getFrameDataU8(t);else if(e.getBitsStored()<=16)r=e.isSigned()?e.getFrameDataS16(t):e.getFrameDataU16(t);else{if(!(e.getBitsStored()<=32))throw new Error(`Unsupported pixel data value for bits stored: ${e.getBitsStored()}`);r=e.hasFloatPixelData()?e.getFrameDataF32(t):e.isSigned()?e.getFrameDataS32(t):e.getFrameDataU32(t)}let i=r[0],s=r[0];const n=e.getPixelPaddingValue();for(let e=0;e<r.length;e++){const t=r[e];void 0!==n&&n===t||(t>s&&(s=t),t<i&&(i=t))}return i=i<e.getMinimumPixelValue()?e.getMinimumPixelValue():i,s=s>e.getMaximumPixelValue()?e.getMaximumPixelValue():s,i=Math.trunc(i*e.getRescaleSlope()+e.getRescaleIntercept()),s=Math.trunc(s*e.getRescaleSlope()+e.getRescaleIntercept()),new a(Math.max(1,Math.abs(s-i)),(s+i)/2,"Min-max value window")}}class w extends f{constructor(e,t,r,i){super(),this.bitsStored=r,this.minValue=i?-Math.pow(2,r-1):0,this.maxValue=i?Math.pow(2,r-1)-1:Math.pow(2,r)-1,this.rescaleLut=new l(this.minValue,this.maxValue,e,t),this.voiLut=new c(new a(this.maxValue-this.minValue,(this.minValue+this.maxValue)/2),"LINEAR"),this.outputLut=new u(n.getColorPaletteMonochrome2()),this.invert=!1,this.lut=void 0,this.precalculatedOrCachedLut=void 0}getWindowLevel(){return this.voiLut.getWindowLevel()}setWindowLevel(e){this.voiLut.setWindowLevel(e)}getVoiLutFunction(){return this.voiLut.getFunction()}setVoiLutFunction(e){this.voiLut.setFunction(e)}getColorPalette(){return this.outputLut.getColorPalette()}setColorPalette(e){this.outputLut.setColorPalette(e)}getInvert(){return this.invert}setInvert(e){this.invert=e,this.lut=void 0}getLut(){if(!this.lut){const e=new g;void 0!==this.rescaleLut&&e.addLut(this.rescaleLut),e.addLut(this.voiLut),e.addLut(this.outputLut),this.invert&&e.addLut(new h(this.outputLut.getMinimumOutputValue(),this.outputLut.getMaximumOutputValue())),this.lut=e}return this.precalculatedOrCachedLut||(this.precalculatedOrCachedLut=32===this.bitsStored?new m(this.lut,this.minValue,this.maxValue):new p(this.lut,this.minValue,this.maxValue)),this.precalculatedOrCachedLut}}class P extends f{constructor(){super()}getLut(){}}class x extends f{constructor(e){super();const t=n.getColorPalettePaletteColor(e);let r=0;const i=e.getRedPaletteColorLookupTableDescriptor();void 0!==i&&Array.isArray(i)&&i.length>0&&(r=i[1]),this.lut=new d(r,t)}getLut(){return this.lut}}e.exports={CachedLut:m,CompositeLut:g,GrayscaleLutPipeline:w,InvertLut:h,Lut:o,LutPipeline:f,OutputLut:u,PaletteColorLut:d,PaletteColorLutPipeline:x,PreCalculatedLut:p,RescaleLut:l,RgbColorLutPipeline:P,VoiLut:c}},91:(e,t,r)=>{const{StandardColorPalette:i}=r(492),s=[{palette:i.HotIron,r:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],g:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],b:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255]},{palette:i.Pet,r:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],g:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,63,61,59,57,55,53,51,49,47,45,43,41,39,37,35,33,31,29,27,25,23,21,19,17,15,13,11,9,7,5,3,1,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],b:[0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,252,248,244,240,236,232,228,224,220,216,212,208,204,200,196,192,188,184,180,176,172,168,164,160,156,152,148,144,140,136,132,128,124,120,116,112,108,104,100,96,92,88,84,80,76,72,68,64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,170,174,178,182,186,190,194,198,202,206,210,214,218,222,226,230,234,238,242,246,250,255]},{palette:i.HotMetalBlue,r:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,52,55,57,59,62,64,66,69,71,74,76,78,81,83,85,88,90,93,96,99,102,105,108,111,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,166,169,172,175,178,181,184,187,190,194,198,201,205,209,213,217,221,224,228,232,236,240,244,247,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],g:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,9,11,13,15,17,19,21,23,24,26,28,30,32,34,36,38,40,41,43,45,47,49,51,53,55,56,58,60,62,64,66,68,70,72,73,75,77,79,81,83,85,87,88,90,92,94,96,98,100,102,104,105,107,109,111,113,115,117,119,120,122,124,126,128,130,132,134,136,137,139,141,143,145,147,149,151,152,154,156,158,160,162,164,166,168,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,201,203,205,207,209,211,213,215,216,218,220,222,224,226,228,229,231,233,235,237,239,240,242,244,246,248,250,251,253,255],b:[0,2,4,6,8,10,12,14,16,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,197,194,191,188,185,182,179,176,174,171,168,165,162,159,156,153,150,144,138,132,126,121,115,109,103,97,91,85,79,74,68,62,56,50,47,44,41,38,35,32,29,26,24,21,18,15,12,9,6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,176,179,182,185,188,191,194,197,200,203,206,210,213,216,219,223,226,229,232,236,239,242,245,249,252,255]},{palette:i.Pet20Step,r:[0,0,0,0,0,0,0,0,0,0,0,0,0,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192,192,192,192,192,176,176,176,176,176,176,176,176,176,176,176,176,176,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],g:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,96,96,96,96,96,96,96,96,96,96,96,96,96,144,144,144,144,144,144,144,144,144,144,144,144,144,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,176,176,176,176,176,176,176,176,176,176,176,176,176,144,144,144,144,144,144,144,144,144,144,144,144,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255],b:[0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,128,176,176,176,176,176,176,176,176,176,176,176,176,176,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,64,64,64,64,64,64,64,64,64,64,64,64,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255]}];Object.freeze(s);e.exports=class{static getColorPaletteMonochrome1(){return this._getGrayscaleColorPalette(!0)}static getColorPaletteMonochrome2(){return this._getGrayscaleColorPalette(!1)}static getColorPalettePaletteColor(e){let t=0,r=0;const i=e.getRedPaletteColorLookupTableDescriptor();void 0!==i&&Array.isArray(i)&&i.length>1&&(t=i[0],r=i[2]),t=0===t?65536:t,r=0===r?16:r;const s=e.getRedPaletteColorLookupTableData(),n=e.getGreenPaletteColorLookupTableData(),a=e.getBluePaletteColorLookupTableData();if(void 0===s||void 0===n||void 0===a)throw new Error("Palette color LUT data is missing");const o=new Uint8Array(Array.isArray(s)?s.find((e=>e)):s),l=new Uint8Array(Array.isArray(n)?n.find((e=>e)):n),c=new Uint8Array(Array.isArray(a)?a.find((e=>e)):a),h=new Array(t);if(o.length===t)for(let e=0;e<t;e++)h[e]=255<<24|o[e]<<16|l[e]<<8|c[e];else{let e=16===r?1:0;for(let r=0;r<t;r++,e+=2)h[r]=255<<24|o[e]<<16|l[e]<<8|c[e]}return h}static getColorPaletteStandard(e){const t=s.find((t=>t.palette===e));if(!t)throw new Error(`Standard color palette not found [${e}]`);const r=new Array(256);for(let e=0;e<256;e++)r[e]=255<<24|t.r[e]<<16|t.g[e]<<8|t.b[e];return r}static _getGrayscaleColorPalette(e){const t=new Array(256);for(let r=0,i=e?255:0;r<256;r++,e?i--:i++)t[r]=255<<24|i<<16|i<<8|i;return t}}},111:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__111__},153:(e,t,r)=>{const{SingleBitPixelPipeline:i}=r(605),s=r(736),n=r(547),a=r(111),{Tag:o}=a.data;class l{render(e,t,r,i){throw new Error("render should be implemented")}static fromDicomImageElements(e){const t=[],r=Object.keys(e);for(let i=0;i<r.length;i++){const s=r[i],n=o.fromString(s);16===n.element()&&n.group()>=24576&&n.group()<=24831&&n.group()%2==0&&t.push(new c(e,n.group()))}const i=e.GraphicAnnotationSequence;return void 0!==i&&Array.isArray(i)&&i.length>0&&i.forEach((e=>{const r=e.GraphicObjectSequence;void 0!==r&&Array.isArray(r)&&r.length>0&&r.forEach((e=>{t.push(new h(e))}))})),t}}class c extends l{constructor(e,t){super(),this.group=t,this.height=this._getElement(e,o.fromNumbers(t,16).toCleanString())||0,this.width=this._getElement(e,o.fromNumbers(t,17).toCleanString())||0,this.type=this._getElement(e,o.fromNumbers(t,64).toCleanString())||"Unknown",this.originX=0,this.originY=0;const r=this._getElement(e,o.fromNumbers(t,80).toCleanString());void 0!==r&&Array.isArray(r)&&2===r.length&&(this.originX=r[0],this.originY=r[1]),this.bitsAllocated=this._getElement(e,o.fromNumbers(t,256).toCleanString())||1,this.bitPosition=this._getElement(e,o.fromNumbers(t,258).toCleanString())||0,this.description=this._getElement(e,o.fromNumbers(t,34).toCleanString())||"",this.subtype=this._getElement(e,o.fromNumbers(t,69).toCleanString())||"",this.label=this._getElement(e,o.fromNumbers(t,5376).toCleanString())||"",this.frames=this._getElement(e,o.fromNumbers(t,21).toCleanString())||1,this.frameOrigin=this._getElement(e,o.fromNumbers(t,81).toCleanString())||1,this.data=this._getElement(e,o.fromNumbers(t,12288).toCleanString())}getGroup(){return this.group}getWidth(){return this.width}getHeight(){return this.height}getType(){return this.type}getOriginX(){return this.originX}getOriginY(){return this.originY}getBitsAllocated(){return this.bitsAllocated}getBitPosition(){return this.bitPosition}getDescription(){return this.description}getSubtype(){return this.subtype}getLabel(){return this.label}getNumberOfFrames(){return this.frames}getFrameOrigin(){return this.frameOrigin}getData(){return this.data}render(e,t,r,s){if(!this.getData())return void n.warn("G60xx overlay: No data. Skipping...");if(!this.getWidth()||!this.getHeight())return void n.warn("G60xx overlay: No width or height. Skipping...");if(!this.getBitsAllocated())return void n.warn("G60xx overlay: No bits allocated. Skipping...");const a=this.getData();let o=new Uint8Array(Array.isArray(a)?a.find((e=>e)):a);const l=new i(this.getWidth(),this.getHeight(),o).render(),c=this.getOriginX()-1,h=this.getOriginY()-1,d=this.getHeight(),u=this.getWidth();for(let i=0;i<d;++i){if(h+i>=r)return;for(let r=u*i,n=r+u,a=(h+i)*t+c,o=0;r<n;r++,a++,o++)if(l[r]>0){if(c+o>=t)break;e[a]|=s}}}_getElement(e,t){return e[t]}}class h extends l{constructor(e){super(),this.graphicAnnotationUnits=e.GraphicAnnotationUnits,this.graphicDimensions=e.GraphicDimensions,this.numberOfGraphicPoints=e.NumberOfGraphicPoints,this.graphicData=e.GraphicData,this.graphicType=e.GraphicType,this.graphicFilled=e.GraphicFilled}getGraphicAnnotationUnits(){return this.graphicAnnotationUnits}getGraphicDimensions(){return this.graphicDimensions}getNumberOfGraphicPoints(){return this.numberOfGraphicPoints}getGraphicData(){return this.graphicData}getGraphicType(){return this.graphicType}getGraphicFilled(){return this.graphicFilled}render(e,t,r,i){const a=this.getGraphicData();if(!a||!Array.isArray(a))return void n.warn("GSPS graphic overlay: No graphic data. Skipping...");if(!this.getGraphicType())return void n.warn("GSPS graphic overlay: No graphic type. Skipping...");if("PIXEL"!==this.getGraphicAnnotationUnits()&&"DISPLAY"!==this.getGraphicAnnotationUnits())return void n.warn(`GSPS graphic overlay: ${this.getGraphicAnnotationUnits()} graphic annotation units is not supported. Skipping...`);const o=this.getGraphicFilled();o&&"Y"===o&&n.warn("GSPS graphic overlay: Filled graphics are not supported. Will render just the basic shape...");const l="DISPLAY"===this.getGraphicAnnotationUnits();switch(this.getGraphicType()){case"POINT":{if(2!==a.length)return void n.warn(`GSPS graphic overlay: POINT graphic type should contain 2 graphic data values [Got: ${a.length}]. Skipping...`);const o=[l?a[0]*t:a[0],l?a[1]*r:a[1],l?a[0]*t:a[0],l?a[1]*r:a[1]];s.drawPolyline(e,t,r,o,i)}break;case"POLYLINE":{const n=[];for(let e=0;e<a.length/2;e++)n.push(l?a[2*e]*t:a[2*e],l?a[2*e+1]*r:a[2*e+1]);s.drawPolyline(e,t,r,n,i)}break;default:n.warn(`GSPS graphic overlay: ${this.getGraphicType()} graphic type is not supported yet. Skipping...`)}}}e.exports={G60xxOverlay:c,GspsGraphicOverlay:h,Overlay:l}},213:function(e,t,r){var i,s;!function(){"use strict";i=function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},n=null;function a(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(i){return"debug"===i&&(i="log"),typeof console!==t&&("trace"===i&&r?o:void 0!==console[i]?a(console,i):void 0!==console.log?a(console,"log"):e)}function c(){for(var r=this.getLevel(),s=0;s<i.length;s++){var n=i[s];this[n]=s<r?e:this.methodFactory(n,r,this.name)}if(this.log=this.debug,typeof console===t&&r<this.levels.SILENT)return"No console available for logging"}function h(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function d(e,t,r){return l(e)||h.apply(this,arguments)}function u(e,r){var a,o,l,h=this,u="loglevel";function g(e){var r=(i[e]||"silent").toUpperCase();if(typeof window!==t&&u){try{return void(window.localStorage[u]=r)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+r+";"}catch(e){}}}function p(){var e;if(typeof window!==t&&u){try{e=window.localStorage[u]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,i=encodeURIComponent(u),s=r.indexOf(i+"=");-1!==s&&(e=/^([^;]+)/.exec(r.slice(s+i.length+1))[1])}catch(e){}return void 0===h.levels[e]&&(e=void 0),e}}function m(){if(typeof window!==t&&u){try{window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}function f(e){var t=e;if("string"==typeof t&&void 0!==h.levels[t.toUpperCase()]&&(t=h.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=h.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?u+=":"+e:"symbol"==typeof e&&(u=void 0),h.name=e,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=r||d,h.getLevel=function(){return null!=l?l:null!=o?o:a},h.setLevel=function(e,t){return l=f(e),!1!==t&&g(l),c.call(h)},h.setDefaultLevel=function(e){o=f(e),p()||h.setLevel(e,!1)},h.resetLevel=function(){l=null,m(),c.call(h)},h.enableAll=function(e){h.setLevel(h.levels.TRACE,e)},h.disableAll=function(e){h.setLevel(h.levels.SILENT,e)},h.rebuild=function(){if(n!==h&&(a=f(n.getLevel())),c.call(h),n===h)for(var e in s)s[e].rebuild()},a=f(n?n.getLevel():"WARN");var w=p();null!=w&&(l=f(w)),c.call(h)}(n=new u).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=s[e];return t||(t=s[e]=new u(e,n.methodFactory)),t};var g=typeof window!==t?window.log:void 0;return n.noConflict=function(){return typeof window!==t&&window.log===n&&(window.log=g),n},n.getLoggers=function(){return s},n.default=n,n},void 0===(s="function"==typeof i?i.call(t,r,t,e):i)||(e.exports=s)}()},236:function(module,__unused_webpack_exports,__webpack_require__){var t;t=__WEBPACK_EXTERNAL_MODULE__111__=>(()=>{var __webpack_modules__={25:(module,__unused_webpack_exports,__nested_webpack_require_500__)=>{const{ErrNo,Jpeg2000ProgressionOrder,JpegSampleFactor,PhotometricInterpretation}=__nested_webpack_require_500__(492),Context=__nested_webpack_require_500__(234),log=__nested_webpack_require_500__(547),wasmFilename="dcmjs-native-codecs.wasm";Object.freeze(wasmFilename);class NativeCodecs{static async initializeAsync(e={}){this.logCodecsInfo=e.logCodecsInfo||!1,this.logCodecsTrace=e.logCodecsTrace||!1,this.webAssemblyModulePathOrUrl=e.webAssemblyModulePathOrUrl;const{instance:t,module:r}=await this._createWebAssemblyInstance(),i=WebAssembly.Module.exports(r).filter((e=>"function"===e.kind)),s={wasmInstance:t,wasmModule:r,wasmMemory:t.exports.memory,wasmEnv:{}};i.forEach((e=>{const r=`wasm${e.name}`;s[r]=t.exports[e.name]})),this.wasmApi=s}static isInitialized(){return void 0!==this.wasmApi}static release(){this.wasmApi=void 0}static decodeRle(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createDecoderContext(e),i=this._createDecoderParameters(t);return this.wasmApi.wasmDecodeRle(r,i),this._releaseDecoderParameters(i),this._releaseDecoderContext(r)}static encodeRle(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createEncoderContext(e),i=this._createEncoderParameters(t);return this.wasmApi.wasmEncodeRle(r,i),this._releaseEncoderParameters(i),this._releaseEncoderContext(r)}static decodeJpeg(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createDecoderContext(e),i=this._createDecoderParameters(t);return this.wasmApi.wasmDecodeJpeg(r,i),this._releaseDecoderParameters(i),this._releaseDecoderContext(r)}static encodeJpeg(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createEncoderContext(e),i=this._createEncoderParameters(t);return this.wasmApi.wasmEncodeJpeg(r,i),this._releaseEncoderParameters(i),this._releaseEncoderContext(r)}static decodeJpegLs(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createDecoderContext(e),i=this._createDecoderParameters(t);return this.wasmApi.wasmDecodeJpegLs(r,i),this._releaseDecoderParameters(i),this._releaseDecoderContext(r)}static encodeJpegLs(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createEncoderContext(e),i=this._createEncoderParameters(t);return this.wasmApi.wasmEncodeJpegLs(r,i),this._releaseEncoderParameters(i),this._releaseEncoderContext(r)}static decodeJpeg2000(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createDecoderContext(e),i=this._createDecoderParameters(t);return this.wasmApi.wasmDecodeJpeg2000(r,i),this._releaseDecoderParameters(i),this._releaseDecoderContext(r)}static encodeJpeg2000(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createEncoderContext(e),i=this._createEncoderParameters(t);return this.wasmApi.wasmEncodeJpeg2000(r,i),this._releaseEncoderParameters(i),this._releaseEncoderContext(r)}static decodeHtJpeg2000(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createDecoderContext(e),i=this._createDecoderParameters(t);return this.wasmApi.wasmDecodeHtJpeg2000(r,i),this._releaseDecoderParameters(i),this._releaseDecoderContext(r)}static encodeHtJpeg2000(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=this._createEncoderContext(e),i=this._createEncoderParameters(t);return this.wasmApi.wasmEncodeHtJpeg2000(r,i),this._releaseEncoderParameters(i),this._releaseEncoderContext(r)}static _createDecoderContext(e){this._throwIfCodecsModuleIsNotInitialized(),e.validate();const t=this.wasmApi.wasmCreateCodecsContext();this.wasmApi.wasmSetColumns(t,e.getWidth()),this.wasmApi.wasmSetRows(t,e.getHeight()),this.wasmApi.wasmSetBitsAllocated(t,e.getBitsAllocated()),this.wasmApi.wasmSetBitsStored(t,e.getBitsStored()),this.wasmApi.wasmSetSamplesPerPixel(t,e.getSamplesPerPixel()),this.wasmApi.wasmSetPixelRepresentation(t,e.getPixelRepresentation()),this.wasmApi.wasmSetPlanarConfiguration(t,e.getPlanarConfiguration()),this.wasmApi.wasmSetPhotometricInterpretation(t,Object.values(PhotometricInterpretation).indexOf(e.getPhotometricInterpretation()));const r=e.getEncodedBuffer();this.wasmApi.wasmSetEncodedBufferSize(t,r.length);const i=this.wasmApi.wasmGetEncodedBuffer(t);return new Uint8Array(this.wasmApi.wasmMemory.buffer).set(r,i),t}static _createEncoderContext(e){this._throwIfCodecsModuleIsNotInitialized(),e.validate();const t=this.wasmApi.wasmCreateCodecsContext();this.wasmApi.wasmSetColumns(t,e.getWidth()),this.wasmApi.wasmSetRows(t,e.getHeight()),this.wasmApi.wasmSetBitsAllocated(t,e.getBitsAllocated()),this.wasmApi.wasmSetBitsStored(t,e.getBitsStored()),this.wasmApi.wasmSetSamplesPerPixel(t,e.getSamplesPerPixel()),this.wasmApi.wasmSetPixelRepresentation(t,e.getPixelRepresentation()),this.wasmApi.wasmSetPlanarConfiguration(t,e.getPlanarConfiguration()),this.wasmApi.wasmSetPhotometricInterpretation(t,Object.values(PhotometricInterpretation).indexOf(e.getPhotometricInterpretation()));const r=e.getDecodedBuffer();this.wasmApi.wasmSetDecodedBufferSize(t,r.length);const i=this.wasmApi.wasmGetDecodedBuffer(t);return new Uint8Array(this.wasmApi.wasmMemory.buffer).set(r,i),t}static _releaseDecoderContext(e){this._throwIfCodecsModuleIsNotInitialized();const t=this.wasmApi.wasmGetDecodedBuffer(e),r=this.wasmApi.wasmGetDecodedBufferSize(e),i=new Uint8Array(this.wasmApi.wasmMemory.buffer),s=new Uint8Array(i.buffer,t,r).slice(0),n=new Context({width:this.wasmApi.wasmGetColumns(e),height:this.wasmApi.wasmGetRows(e),bitsAllocated:this.wasmApi.wasmGetBitsAllocated(e),bitsStored:this.wasmApi.wasmGetBitsStored(e),samplesPerPixel:this.wasmApi.wasmGetSamplesPerPixel(e),pixelRepresentation:this.wasmApi.wasmGetPixelRepresentation(e),planarConfiguration:this.wasmApi.wasmGetPlanarConfiguration(e),photometricInterpretation:Object.values(PhotometricInterpretation)[this.wasmApi.wasmGetPhotometricInterpretation(e)],decodedBuffer:s});return this.wasmApi.wasmReleaseCodecsContext(e),n}static _releaseEncoderContext(e){this._throwIfCodecsModuleIsNotInitialized();const t=this.wasmApi.wasmGetEncodedBuffer(e),r=this.wasmApi.wasmGetEncodedBufferSize(e),i=new Uint8Array(this.wasmApi.wasmMemory.buffer),s=new Uint8Array(i.buffer,t,r).slice(0),n=new Context({width:this.wasmApi.wasmGetColumns(e),height:this.wasmApi.wasmGetRows(e),bitsAllocated:this.wasmApi.wasmGetBitsAllocated(e),bitsStored:this.wasmApi.wasmGetBitsStored(e),samplesPerPixel:this.wasmApi.wasmGetSamplesPerPixel(e),pixelRepresentation:this.wasmApi.wasmGetPixelRepresentation(e),planarConfiguration:this.wasmApi.wasmGetPlanarConfiguration(e),photometricInterpretation:Object.values(PhotometricInterpretation)[this.wasmApi.wasmGetPhotometricInterpretation(e)],encodedBuffer:s});return this.wasmApi.wasmReleaseCodecsContext(e),n}static _createDecoderParameters(e={}){this._throwIfCodecsModuleIsNotInitialized();const t=this.wasmApi.wasmCreateDecoderParameters();return this.wasmApi.wasmSetConvertColorspaceToRgb(t,e.convertColorspaceToRgb||!1),t}static _createEncoderParameters(e={}){this._throwIfCodecsModuleIsNotInitialized();const t=this.wasmApi.wasmCreateEncoderParameters();return this.wasmApi.wasmSetLossy(t,e.lossy||!1),this.wasmApi.wasmSetQuality(t,e.quality??90),this.wasmApi.wasmSetSmoothingFactor(t,e.smoothingFactor??0),this.wasmApi.wasmSetSampleFactor(t,Object.values(JpegSampleFactor).indexOf(e.sampleFactor??JpegSampleFactor.Sf444)),this.wasmApi.wasmSetPredictor(t,e.predictor??1),this.wasmApi.wasmSetPointTransform(t,e.pointTransform??0),this.wasmApi.wasmSetAllowedLossyError(t,e.allowedLossyError??10),this.wasmApi.wasmSetProgressionOrder(t,Object.values(Jpeg2000ProgressionOrder).indexOf(e.progressionOrder??Jpeg2000ProgressionOrder.Lrcp)),this.wasmApi.wasmSetRate(t,e.rate??20),this.wasmApi.wasmSetAllowMct(t,e.allowMct??1),t}static _releaseDecoderParameters(e){this._throwIfCodecsModuleIsNotInitialized(),this.wasmApi.wasmReleaseDecoderParameters(e)}static _releaseEncoderParameters(e){this._throwIfCodecsModuleIsNotInitialized(),this.wasmApi.wasmReleaseEncoderParameters(e)}static async _createWebAssemblyInstance(){const e={wasi_snapshot_preview1:{environ_get:(e,t)=>{this._throwIfCodecsModuleIsNotInitialized();const r=new Uint8Array(this.wasmApi.wasmMemory.buffer),i=new DataView(this.wasmApi.wasmMemory.buffer),s=this.wasmApi.wasmEnv;return Object.keys(s).forEach((n=>{i.setUint32(e,t,!0),e+=4;const a=this._stringToBytes(`${n}=${s[n]}\0`);r.set(a,t),t+=a.length})),ErrNo.Success},environ_sizes_get:(e,t)=>{this._throwIfCodecsModuleIsNotInitialized();const r=new DataView(this.wasmApi.wasmMemory.buffer),i=this.wasmApi.wasmEnv;return r.setUint32(e,Object.keys(i).length,!0),r.setUint32(t,Object.keys(i).reduce(((e,t)=>e+this._stringToBytes(`${t}=${i[t]}\0`).length),0),!0),ErrNo.Success},proc_exit:e=>{throw new Error(`WebAssembly module exited with return value ${e}`)},fd_write:(e,t,r,i)=>{if(this._throwIfCodecsModuleIsNotInitialized(),1!==e&&2!==e)return ErrNo.BadFileDescriptor;const s=new DataView(this.wasmApi.wasmMemory.buffer);let n=0;for(let e=0;e<r;e++){const e=s.getUint32(t,!0);t+=4;const r=s.getUint32(t,!0);t+=4;const i=this._wasmToJsString(e,r);log.error(`NativeCodecs::fd_write::${i}`),n+=r}return s.setUint32(i,n,!0),ErrNo.Success},fd_seek:(e,t,r,i)=>ErrNo.Success,fd_close:e=>ErrNo.Success},env:{emscripten_notify_memory_growth:e=>{},onCodecsInfo:(e,t)=>{if(!this.logCodecsInfo)return;const r=this._wasmToJsString(e,t);log.info(`NativeCodecs::onCodecsInfo::${r}`)},onCodecsTrace:(e,t)=>{if(!this.logCodecsTrace)return;const r=this._wasmToJsString(e,t);log.info(`NativeCodecs::onCodecsTrace::${r}`)},onCodecsException:(e,t)=>{const r=this._wasmToJsString(e,t);throw new Error(r)}}},t=await this._getWebAssemblyBytes(),{instance:r,module:i}=await WebAssembly.instantiate(t,e);return{instance:r,module:i}}static async _getWebAssemblyBytes(){const isNodeJs=!("undefined"==typeof process||!process.versions||!process.versions.node);if(!isNodeJs){const response=await eval("fetch(this.webAssemblyModulePathOrUrl || wasmFilename)"),responseArrayBuffer=await response.arrayBuffer();return responseArrayBuffer}const fs=eval("require('fs')"),path=eval("require('path')"),buffer=await fs.promises.readFile(this.webAssemblyModulePathOrUrl||path.resolve(__dirname,wasmFilename));return buffer.buffer.slice(buffer.byteOffset,buffer.byteOffset+buffer.byteLength)}static _wasmToJsString(e,t){this._throwIfCodecsModuleIsNotInitialized();const r=new Uint8Array(this.wasmApi.wasmMemory.buffer),i=new Uint8Array(r.buffer,e,t);let s="";for(let e=0;e<t;e++)s+=String.fromCharCode(i[e]);return s}static _stringToBytes(e){return e.split("").map((e=>e.charCodeAt(0)))}static _throwIfCodecsModuleIsNotInitialized(){if(!this.wasmApi)throw new Error("Native codecs module is not initialized")}}module.exports=NativeCodecs},111:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__111__},190:(e,t,r)=>{const{Implementation:i,StorageClass:s,TranscodeMap:n,TransferSyntax:a}=r(492),{Codec:o}=r(258),l=r(111),{DicomDict:c,DicomMessage:h,DicomMetaDictionary:d,ReadBufferStream:u,WriteBufferStream:g}=l.data,p=l.log;e.exports=class{constructor(e,t,r={}){r={ignoreErrors:!0,...r},p.level="error",this.transferSyntaxUid=t||a.ImplicitVRLittleEndian,e instanceof ArrayBuffer?t?this._fromElementsBuffer(e,t,r):this._fromP10Buffer(e):this.elements=e||{}}transcode(e,t={}){if(!e)throw new Error("New transfer syntax UID is required");let r=this.getTransferSyntaxUid();if(r===e)return;const i=n.find((e=>e.syntax===r)),s=n.find((t=>t.syntax===e));if(!i||!s)throw new Error(`A transfer syntax transcoding from ${r} to ${e} is currently not supported`);if(i.encapsulated&&s.encapsulated&&(this.transcode(a.ExplicitVRLittleEndian,t),r=a.ExplicitVRLittleEndian),this._getElement("PixelData")){const n=this._getElement("BitsAllocated");if(8!==n&&16!==n)throw new Error(`Transcoding is supported for 8 and 16 bits allocated [bits: ${n}]`);let a=this.getElements();(i.encapsulated||i.bigEndian)&&(a=o.getCodec(r).decode(a,r,t)),(s.encapsulated||s.bigEndian)&&(a=o.getCodec(e).encode(a,r,t)),this.elements=a}this.transferSyntaxUid=e}getTransferSyntaxUid(){return this.transferSyntaxUid}getElements(){return this.elements}getDicomDataset(e,t){e={fragmentMultiframe:!1,...e};const r=t?d.denaturalizeDataset(this.getElements(),{...d.nameMap,...t}):d.denaturalizeDataset(this.getElements()),i=new g;return h.write(r,i,this.transferSyntaxUid,e),i.getBuffer()}getDicomPart10(e,t){e={fragmentMultiframe:!1,...e};const r={_meta:{FileMetaInformationVersion:new Uint8Array([0,1]).buffer,MediaStorageSOPClassUID:this._getElement("SOPClassUID")||s.SecondaryCaptureImageStorage,MediaStorageSOPInstanceUID:this._getElement("SOPInstanceUID")||d.uid(),TransferSyntaxUID:this.getTransferSyntaxUid(),ImplementationClassUID:i.ImplementationClassUid,ImplementationVersionName:i.ImplementationVersion},...this.getElements()},n=d.denaturalizeDataset(r._meta),a=new c(n);return a.dict=t?d.denaturalizeDataset(r,{...d.nameMap,...t}):d.denaturalizeDataset(r),a.write(e)}_getElement(e){return this.elements[e]}_fromP10Buffer(e,t){const r=h.readFile(e,t),i=d.naturalizeDataset(r.meta).TransferSyntaxUID,s=d.naturalizeDataset(r.dict);this.elements=s,this.transferSyntaxUid=i}_fromElementsBuffer(e,t,r){const i=new u(e),s=t===a.ImplicitVRLittleEndian?a.ImplicitVRLittleEndian:t===a.ExplicitVRBigEndian?a.ExplicitVRBigEndian:a.ExplicitVRLittleEndian,n=h._read(i,s,r);this.elements=d.naturalizeDataset(n),this.transferSyntaxUid=t}}},213:function(e,t,r){var i,s;!function(){"use strict";i=function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],s={},n=null;function a(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(i){return"debug"===i&&(i="log"),typeof console!==t&&("trace"===i&&r?o:void 0!==console[i]?a(console,i):void 0!==console.log?a(console,"log"):e)}function c(){for(var r=this.getLevel(),s=0;s<i.length;s++){var n=i[s];this[n]=s<r?e:this.methodFactory(n,r,this.name)}if(this.log=this.debug,typeof console===t&&r<this.levels.SILENT)return"No console available for logging"}function h(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function d(e,t,r){return l(e)||h.apply(this,arguments)}function u(e,r){var a,o,l,h=this,u="loglevel";function g(e){var r=(i[e]||"silent").toUpperCase();if(typeof window!==t&&u){try{return void(window.localStorage[u]=r)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+r+";"}catch(e){}}}function p(){var e;if(typeof window!==t&&u){try{e=window.localStorage[u]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,i=encodeURIComponent(u),s=r.indexOf(i+"=");-1!==s&&(e=/^([^;]+)/.exec(r.slice(s+i.length+1))[1])}catch(e){}return void 0===h.levels[e]&&(e=void 0),e}}function m(e){var t=e;if("string"==typeof t&&void 0!==h.levels[t.toUpperCase()]&&(t=h.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=h.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?u+=":"+e:"symbol"==typeof e&&(u=void 0),h.name=e,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=r||d,h.getLevel=function(){return null!=l?l:null!=o?o:a},h.setLevel=function(e,t){return l=m(e),!1!==t&&g(l),c.call(h)},h.setDefaultLevel=function(e){o=m(e),p()||h.setLevel(e,!1)},h.resetLevel=function(){l=null,function(){if(typeof window!==t&&u){try{window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(h)},h.enableAll=function(e){h.setLevel(h.levels.TRACE,e)},h.disableAll=function(e){h.setLevel(h.levels.SILENT,e)},h.rebuild=function(){if(n!==h&&(a=m(n.getLevel())),c.call(h),n===h)for(var e in s)s[e].rebuild()},a=m(n?n.getLevel():"WARN");var f=p();null!=f&&(l=m(f)),c.call(h)}(n=new u).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=s[e];return t||(t=s[e]=new u(e,n.methodFactory)),t};var g=typeof window!==t?window.log:void 0;return n.noConflict=function(){return typeof window!==t&&window.log===n&&(window.log=g),n},n.getLoggers=function(){return s},n.default=n,n},void 0===(s=i.call(t,r,t,e))||(e.exports=s)}()},234:(e,t,r)=>{const{PhotometricInterpretation:i}=r(492);class s{constructor(e={}){const{width:t,height:r,bitsAllocated:i,bitsStored:s,samplesPerPixel:n,pixelRepresentation:a,planarConfiguration:o,photometricInterpretation:l,encodedBuffer:c,decodedBuffer:h}=e;this.width=t,this.height=r,this.bitsAllocated=i,this.bitsStored=s,this.samplesPerPixel=n,this.pixelRepresentation=a,this.planarConfiguration=o,this.photometricInterpretation=l,this.encodedBuffer=c,this.decodedBuffer=h}getWidth(){return this.width}setWidth(e){this.width=e}getHeight(){return this.height}setHeight(e){this.height=e}getBitsStored(){return this.bitsStored}setBitsStored(e){this.bitsStored=e}getBitsAllocated(){return this.bitsAllocated}setBitsAllocated(e){this.bitsAllocated=e}getSamplesPerPixel(){return this.samplesPerPixel}setSamplesPerPixel(e){this.samplesPerPixel=e}getPixelRepresentation(){return this.pixelRepresentation}setPixelRepresentation(e){this.pixelRepresentation=e}getPlanarConfiguration(){return this.planarConfiguration}setPlanarConfiguration(e){this.planarConfiguration=e}getPhotometricInterpretation(){return this.photometricInterpretation}setPhotometricInterpretation(e){this.photometricInterpretation=e}getEncodedBuffer(){return this.encodedBuffer}setEncodedBuffer(e){this.encodedBuffer=e}getDecodedBuffer(){return this.decodedBuffer}setDecodedBuffer(e){this.decodedBuffer=e}validate(){if(!this.getWidth())throw new Error(`Width has an invalid value [${this.getWidth()}]`);if(!this.getHeight())throw new Error(`Height has an invalid value [${this.getHeight()}]`);if(!this.getBitsStored())throw new Error(`Bits stored has an invalid value [${this.getBitsStored()}]`);if(!this.getBitsAllocated())throw new Error(`Bits allocated has an invalid value [${this.getBitsAllocated()}]`);if(!this.getSamplesPerPixel())throw new Error(`Sample per pixel has an invalid value [${this.getSamplesPerPixel()}]`);if(void 0===this.getPixelRepresentation())throw new Error(`Pixel representation has an invalid value [${this.getSamplesPerPixel()}]`);if(!Object.values(i).includes(this.getPhotometricInterpretation()))throw new Error(`Photometric interpretation has an invalid value [${this.getPhotometricInterpretation()}]`)}static fromDicomElements(e){const t=new s({width:e.Columns,height:e.Rows,bitsAllocated:e.BitsAllocated,bitsStored:e.BitsStored,samplesPerPixel:e.SamplesPerPixel,pixelRepresentation:e.PixelRepresentation,planarConfiguration:e.PlanarConfiguration,photometricInterpretation:e.PhotometricInterpretation});return void 0!==e.PlanarConfiguration&&t.setPlanarConfiguration(e.PlanarConfiguration),t}toDicomElements(){const e={Columns:this.getWidth(),Rows:this.getHeight(),BitsAllocated:this.getBitsAllocated(),BitsStored:this.getBitsStored(),SamplesPerPixel:this.getSamplesPerPixel(),PixelRepresentation:this.getPixelRepresentation(),PhotometricInterpretation:this.getPhotometricInterpretation()};return void 0!==this.getPlanarConfiguration()&&(e.PlanarConfiguration=this.getPlanarConfiguration()),e}toString(){return`Width: ${this.getWidth()}, Height: ${this.getHeight()}, Bits Stored: ${this.getBitsStored()}, Bits Allocated: ${this.getBitsAllocated()}, Samples per Pixel: ${this.getSamplesPerPixel()}, Pixel Representation: ${this.getPixelRepresentation()}, Planar Configuration: ${this.getPlanarConfiguration()}, Photometric Interpretation: ${this.getPhotometricInterpretation()}`}}e.exports=s},237:(e,t,r)=>{const{Codec:i,ExplicitVRBigEndianCodec:s,ExplicitVRLittleEndianCodec:n,HtJpeg2000LosslessCodec:a,HtJpeg2000LosslessRpclCodec:o,HtJpeg2000LossyCodec:l,ImplicitVRLittleEndianCodec:c,Jpeg2000LosslessCodec:h,Jpeg2000LossyCodec:d,JpegBaselineProcess1Codec:u,JpegLosslessProcess14V1Codec:g,JpegLsLosslessCodec:p,JpegLsLossyCodec:m,RleLosslessCodec:f}=r(258),{Jpeg2000ProgressionOrder:w,JpegSampleFactor:P,PhotometricInterpretation:x,PixelRepresentation:y,PlanarConfiguration:b,TransferSyntax:C}=r(492),_=r(234),S=r(25),E=r(190),A={codecs:{Codec:i,ExplicitVRBigEndianCodec:s,ExplicitVRLittleEndianCodec:n,HtJpeg