@segmed/cornerstonejs-dicom-image-loader
Version:
Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file
1 lines • 1.3 MB
JavaScript
!function(A,I){"object"==typeof exports&&"object"==typeof module?module.exports=I(require("dicom-parser")):"function"==typeof define&&define.amd?define("cornerstoneDICOMImageLoader",["dicom-parser"],I):"object"==typeof exports?exports.cornerstoneDICOMImageLoader=I(require("dicom-parser")):A.cornerstoneDICOMImageLoader=I(A.dicomParser)}(this,(A=>(()=>{"use strict";var I={578:(A,I,g)=>{const B=g(823),Q=g(187),C=g(592),E=g(604),i=g(249),o=g(968),D=Object.prototype.toString,{Z_NO_FLUSH:a,Z_FINISH:s,Z_OK:t,Z_STREAM_END:w,Z_NEED_DICT:e,Z_STREAM_ERROR:h,Z_DATA_ERROR:G,Z_MEM_ERROR:c}=g(684);function F(A){this.options=Q.assign({chunkSize:65536,windowBits:15,to:""},A||{});const I=this.options;I.raw&&I.windowBits>=0&&I.windowBits<16&&(I.windowBits=-I.windowBits,0===I.windowBits&&(I.windowBits=-15)),!(I.windowBits>=0&&I.windowBits<16)||A&&A.windowBits||(I.windowBits+=32),I.windowBits>15&&I.windowBits<48&&0==(15&I.windowBits)&&(I.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;let g=B.inflateInit2(this.strm,I.windowBits);if(g!==t)throw new Error(E[g]);if(this.header=new o,B.inflateGetHeader(this.strm,this.header),I.dictionary&&("string"==typeof I.dictionary?I.dictionary=C.string2buf(I.dictionary):"[object ArrayBuffer]"===D.call(I.dictionary)&&(I.dictionary=new Uint8Array(I.dictionary)),I.raw&&(g=B.inflateSetDictionary(this.strm,I.dictionary),g!==t)))throw new Error(E[g])}function y(A,I){const g=new F(I);if(g.push(A),g.err)throw g.msg||E[g.err];return g.result}F.prototype.push=function(A,I){const g=this.strm,Q=this.options.chunkSize,E=this.options.dictionary;let i,o,F;if(this.ended)return!1;for(o=I===~~I?I:!0===I?s:a,"[object ArrayBuffer]"===D.call(A)?g.input=new Uint8Array(A):g.input=A,g.next_in=0,g.avail_in=g.input.length;;){for(0===g.avail_out&&(g.output=new Uint8Array(Q),g.next_out=0,g.avail_out=Q),i=B.inflate(g,o),i===e&&E&&(i=B.inflateSetDictionary(g,E),i===t?i=B.inflate(g,o):i===G&&(i=e));g.avail_in>0&&i===w&&g.state.wrap>0&&0!==A[g.next_in];)B.inflateReset(g),i=B.inflate(g,o);switch(i){case h:case G:case e:case c:return this.onEnd(i),this.ended=!0,!1}if(F=g.avail_out,g.next_out&&(0===g.avail_out||i===w))if("string"===this.options.to){let A=C.utf8border(g.output,g.next_out),I=g.next_out-A,B=C.buf2string(g.output,A);g.next_out=I,g.avail_out=Q-I,I&&g.output.set(g.output.subarray(A,A+I),0),this.onData(B)}else this.onData(g.output.length===g.next_out?g.output:g.output.subarray(0,g.next_out));if(i!==t||0!==F){if(i===w)return i=B.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===g.avail_in)break}}return!0},F.prototype.onData=function(A){this.chunks.push(A)},F.prototype.onEnd=function(A){A===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Q.flattenChunks(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg},A.exports.Hq=function(A,I){return(I=I||{}).raw=!0,y(A,I)},g(684)},187:A=>{const I=(A,I)=>Object.prototype.hasOwnProperty.call(A,I);A.exports.assign=function(A){const g=Array.prototype.slice.call(arguments,1);for(;g.length;){const B=g.shift();if(B){if("object"!=typeof B)throw new TypeError(B+"must be non-object");for(const g in B)I(B,g)&&(A[g]=B[g])}}return A},A.exports.flattenChunks=A=>{let I=0;for(let g=0,B=A.length;g<B;g++)I+=A[g].length;const g=new Uint8Array(I);for(let I=0,B=0,Q=A.length;I<Q;I++){let Q=A[I];g.set(Q,B),B+=Q.length}return g}},592:A=>{let I=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){I=!1}const g=new Uint8Array(256);for(let A=0;A<256;A++)g[A]=A>=252?6:A>=248?5:A>=240?4:A>=224?3:A>=192?2:1;g[254]=g[254]=1,A.exports.string2buf=A=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(A);let I,g,B,Q,C,E=A.length,i=0;for(Q=0;Q<E;Q++)g=A.charCodeAt(Q),55296==(64512&g)&&Q+1<E&&(B=A.charCodeAt(Q+1),56320==(64512&B)&&(g=65536+(g-55296<<10)+(B-56320),Q++)),i+=g<128?1:g<2048?2:g<65536?3:4;for(I=new Uint8Array(i),C=0,Q=0;C<i;Q++)g=A.charCodeAt(Q),55296==(64512&g)&&Q+1<E&&(B=A.charCodeAt(Q+1),56320==(64512&B)&&(g=65536+(g-55296<<10)+(B-56320),Q++)),g<128?I[C++]=g:g<2048?(I[C++]=192|g>>>6,I[C++]=128|63&g):g<65536?(I[C++]=224|g>>>12,I[C++]=128|g>>>6&63,I[C++]=128|63&g):(I[C++]=240|g>>>18,I[C++]=128|g>>>12&63,I[C++]=128|g>>>6&63,I[C++]=128|63&g);return I};A.exports.buf2string=(A,B)=>{const Q=B||A.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(A.subarray(0,B));let C,E;const i=new Array(2*Q);for(E=0,C=0;C<Q;){let I=A[C++];if(I<128){i[E++]=I;continue}let B=g[I];if(B>4)i[E++]=65533,C+=B-1;else{for(I&=2===B?31:3===B?15:7;B>1&&C<Q;)I=I<<6|63&A[C++],B--;B>1?i[E++]=65533:I<65536?i[E++]=I:(I-=65536,i[E++]=55296|I>>10&1023,i[E++]=56320|1023&I)}}return((A,g)=>{if(g<65534&&A.subarray&&I)return String.fromCharCode.apply(null,A.length===g?A:A.subarray(0,g));let B="";for(let I=0;I<g;I++)B+=String.fromCharCode(A[I]);return B})(i,E)},A.exports.utf8border=(A,I)=>{(I=I||A.length)>A.length&&(I=A.length);let B=I-1;for(;B>=0&&128==(192&A[B]);)B--;return B<0||0===B?I:B+g[A[B]]>I?B:I}},693:A=>{A.exports=(A,I,g,B)=>{let Q=65535&A|0,C=A>>>16&65535|0,E=0;for(;0!==g;){E=g>2e3?2e3:g,g-=E;do{Q=Q+I[B++]|0,C=C+Q|0}while(--E);Q%=65521,C%=65521}return Q|C<<16|0}},684:A=>{A.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},464:A=>{const I=new Uint32Array((()=>{let A,I=[];for(var g=0;g<256;g++){A=g;for(var B=0;B<8;B++)A=1&A?3988292384^A>>>1:A>>>1;I[g]=A}return I})());A.exports=(A,g,B,Q)=>{const C=I,E=Q+B;A^=-1;for(let I=Q;I<E;I++)A=A>>>8^C[255&(A^g[I])];return-1^A}},968:A=>{A.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},365:A=>{const I=16209;A.exports=function(A,g){let B,Q,C,E,i,o,D,a,s,t,w,e,h,G,c,F,y,r,n,N,R,k,S,U;const J=A.state;B=A.next_in,S=A.input,Q=B+(A.avail_in-5),C=A.next_out,U=A.output,E=C-(g-A.avail_out),i=C+(A.avail_out-257),o=J.dmax,D=J.wsize,a=J.whave,s=J.wnext,t=J.window,w=J.hold,e=J.bits,h=J.lencode,G=J.distcode,c=(1<<J.lenbits)-1,F=(1<<J.distbits)-1;A:do{e<15&&(w+=S[B++]<<e,e+=8,w+=S[B++]<<e,e+=8),y=h[w&c];I:for(;;){if(r=y>>>24,w>>>=r,e-=r,r=y>>>16&255,0===r)U[C++]=65535&y;else{if(!(16&r)){if(0==(64&r)){y=h[(65535&y)+(w&(1<<r)-1)];continue I}if(32&r){J.mode=16191;break A}A.msg="invalid literal/length code",J.mode=I;break A}n=65535&y,r&=15,r&&(e<r&&(w+=S[B++]<<e,e+=8),n+=w&(1<<r)-1,w>>>=r,e-=r),e<15&&(w+=S[B++]<<e,e+=8,w+=S[B++]<<e,e+=8),y=G[w&F];g:for(;;){if(r=y>>>24,w>>>=r,e-=r,r=y>>>16&255,!(16&r)){if(0==(64&r)){y=G[(65535&y)+(w&(1<<r)-1)];continue g}A.msg="invalid distance code",J.mode=I;break A}if(N=65535&y,r&=15,e<r&&(w+=S[B++]<<e,e+=8,e<r&&(w+=S[B++]<<e,e+=8)),N+=w&(1<<r)-1,N>o){A.msg="invalid distance too far back",J.mode=I;break A}if(w>>>=r,e-=r,r=C-E,N>r){if(r=N-r,r>a&&J.sane){A.msg="invalid distance too far back",J.mode=I;break A}if(R=0,k=t,0===s){if(R+=D-r,r<n){n-=r;do{U[C++]=t[R++]}while(--r);R=C-N,k=U}}else if(s<r){if(R+=D+s-r,r-=s,r<n){n-=r;do{U[C++]=t[R++]}while(--r);if(R=0,s<n){r=s,n-=r;do{U[C++]=t[R++]}while(--r);R=C-N,k=U}}}else if(R+=s-r,r<n){n-=r;do{U[C++]=t[R++]}while(--r);R=C-N,k=U}for(;n>2;)U[C++]=k[R++],U[C++]=k[R++],U[C++]=k[R++],n-=3;n&&(U[C++]=k[R++],n>1&&(U[C++]=k[R++]))}else{R=C-N;do{U[C++]=U[R++],U[C++]=U[R++],U[C++]=U[R++],n-=3}while(n>2);n&&(U[C++]=U[R++],n>1&&(U[C++]=U[R++]))}break}}break}}while(B<Q&&C<i);n=e>>3,B-=n,e-=n<<3,w&=(1<<e)-1,A.next_in=B,A.next_out=C,A.avail_in=B<Q?Q-B+5:5-(B-Q),A.avail_out=C<i?i-C+257:257-(C-i),J.hold=w,J.bits=e}},823:(A,I,g)=>{const B=g(693),Q=g(464),C=g(365),E=g(446),{Z_FINISH:i,Z_BLOCK:o,Z_TREES:D,Z_OK:a,Z_STREAM_END:s,Z_NEED_DICT:t,Z_STREAM_ERROR:w,Z_DATA_ERROR:e,Z_MEM_ERROR:h,Z_BUF_ERROR:G,Z_DEFLATED:c}=g(684),F=16180,y=16190,r=16191,n=16192,N=16194,R=16199,k=16200,S=16206,U=16209,J=16210,H=A=>(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24);function Y(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const M=A=>{if(!A)return 1;const I=A.state;return!I||I.strm!==A||I.mode<F||I.mode>16211?1:0},L=A=>{if(M(A))return w;const I=A.state;return A.total_in=A.total_out=I.total=0,A.msg="",I.wrap&&(A.adler=1&I.wrap),I.mode=F,I.last=0,I.havedict=0,I.flags=-1,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new Int32Array(852),I.distcode=I.distdyn=new Int32Array(592),I.sane=1,I.back=-1,a},K=A=>{if(M(A))return w;const I=A.state;return I.wsize=0,I.whave=0,I.wnext=0,L(A)},d=(A,I)=>{let g;if(M(A))return w;const B=A.state;return I<0?(g=0,I=-I):(g=5+(I>>4),I<48&&(I&=15)),I&&(I<8||I>15)?w:(null!==B.window&&B.wbits!==I&&(B.window=null),B.wrap=g,B.wbits=I,K(A))},l=(A,I)=>{if(!A)return w;const g=new Y;A.state=g,g.strm=A,g.window=null,g.mode=F;const B=d(A,I);return B!==a&&(A.state=null),B};let f,u,p=!0;const q=A=>{if(p){f=new Int32Array(512),u=new Int32Array(32);let I=0;for(;I<144;)A.lens[I++]=8;for(;I<256;)A.lens[I++]=9;for(;I<280;)A.lens[I++]=7;for(;I<288;)A.lens[I++]=8;for(E(1,A.lens,0,288,f,0,A.work,{bits:9}),I=0;I<32;)A.lens[I++]=5;E(2,A.lens,0,32,u,0,A.work,{bits:5}),p=!1}A.lencode=f,A.lenbits=9,A.distcode=u,A.distbits=5},b=(A,I,g,B)=>{let Q;const C=A.state;return null===C.window&&(C.wsize=1<<C.wbits,C.wnext=0,C.whave=0,C.window=new Uint8Array(C.wsize)),B>=C.wsize?(C.window.set(I.subarray(g-C.wsize,g),0),C.wnext=0,C.whave=C.wsize):(Q=C.wsize-C.wnext,Q>B&&(Q=B),C.window.set(I.subarray(g-B,g-B+Q),C.wnext),(B-=Q)?(C.window.set(I.subarray(g-B,g),0),C.wnext=B,C.whave=C.wsize):(C.wnext+=Q,C.wnext===C.wsize&&(C.wnext=0),C.whave<C.wsize&&(C.whave+=Q))),0};A.exports.inflateReset=K,A.exports.inflateReset2=d,A.exports.inflateResetKeep=L,A.exports.inflateInit=A=>l(A,15),A.exports.inflateInit2=l,A.exports.inflate=(A,I)=>{let g,Y,L,K,d,l,f,u,p,m,W,Z,x,T,v,X,V,P,O,j,z,_,$=0;const AA=new Uint8Array(4);let IA,gA;const BA=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(M(A)||!A.output||!A.input&&0!==A.avail_in)return w;g=A.state,g.mode===r&&(g.mode=n),d=A.next_out,L=A.output,f=A.avail_out,K=A.next_in,Y=A.input,l=A.avail_in,u=g.hold,p=g.bits,m=l,W=f,_=a;A:for(;;)switch(g.mode){case F:if(0===g.wrap){g.mode=n;break}for(;p<16;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(2&g.wrap&&35615===u){0===g.wbits&&(g.wbits=15),g.check=0,AA[0]=255&u,AA[1]=u>>>8&255,g.check=Q(g.check,AA,2,0),u=0,p=0,g.mode=16181;break}if(g.head&&(g.head.done=!1),!(1&g.wrap)||(((255&u)<<8)+(u>>8))%31){A.msg="incorrect header check",g.mode=U;break}if((15&u)!==c){A.msg="unknown compression method",g.mode=U;break}if(u>>>=4,p-=4,z=8+(15&u),0===g.wbits&&(g.wbits=z),z>15||z>g.wbits){A.msg="invalid window size",g.mode=U;break}g.dmax=1<<g.wbits,g.flags=0,A.adler=g.check=1,g.mode=512&u?16189:r,u=0,p=0;break;case 16181:for(;p<16;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(g.flags=u,(255&g.flags)!==c){A.msg="unknown compression method",g.mode=U;break}if(57344&g.flags){A.msg="unknown header flags set",g.mode=U;break}g.head&&(g.head.text=u>>8&1),512&g.flags&&4&g.wrap&&(AA[0]=255&u,AA[1]=u>>>8&255,g.check=Q(g.check,AA,2,0)),u=0,p=0,g.mode=16182;case 16182:for(;p<32;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.head&&(g.head.time=u),512&g.flags&&4&g.wrap&&(AA[0]=255&u,AA[1]=u>>>8&255,AA[2]=u>>>16&255,AA[3]=u>>>24&255,g.check=Q(g.check,AA,4,0)),u=0,p=0,g.mode=16183;case 16183:for(;p<16;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.head&&(g.head.xflags=255&u,g.head.os=u>>8),512&g.flags&&4&g.wrap&&(AA[0]=255&u,AA[1]=u>>>8&255,g.check=Q(g.check,AA,2,0)),u=0,p=0,g.mode=16184;case 16184:if(1024&g.flags){for(;p<16;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.length=u,g.head&&(g.head.extra_len=u),512&g.flags&&4&g.wrap&&(AA[0]=255&u,AA[1]=u>>>8&255,g.check=Q(g.check,AA,2,0)),u=0,p=0}else g.head&&(g.head.extra=null);g.mode=16185;case 16185:if(1024&g.flags&&(Z=g.length,Z>l&&(Z=l),Z&&(g.head&&(z=g.head.extra_len-g.length,g.head.extra||(g.head.extra=new Uint8Array(g.head.extra_len)),g.head.extra.set(Y.subarray(K,K+Z),z)),512&g.flags&&4&g.wrap&&(g.check=Q(g.check,Y,Z,K)),l-=Z,K+=Z,g.length-=Z),g.length))break A;g.length=0,g.mode=16186;case 16186:if(2048&g.flags){if(0===l)break A;Z=0;do{z=Y[K+Z++],g.head&&z&&g.length<65536&&(g.head.name+=String.fromCharCode(z))}while(z&&Z<l);if(512&g.flags&&4&g.wrap&&(g.check=Q(g.check,Y,Z,K)),l-=Z,K+=Z,z)break A}else g.head&&(g.head.name=null);g.length=0,g.mode=16187;case 16187:if(4096&g.flags){if(0===l)break A;Z=0;do{z=Y[K+Z++],g.head&&z&&g.length<65536&&(g.head.comment+=String.fromCharCode(z))}while(z&&Z<l);if(512&g.flags&&4&g.wrap&&(g.check=Q(g.check,Y,Z,K)),l-=Z,K+=Z,z)break A}else g.head&&(g.head.comment=null);g.mode=16188;case 16188:if(512&g.flags){for(;p<16;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(4&g.wrap&&u!==(65535&g.check)){A.msg="header crc mismatch",g.mode=U;break}u=0,p=0}g.head&&(g.head.hcrc=g.flags>>9&1,g.head.done=!0),A.adler=g.check=0,g.mode=r;break;case 16189:for(;p<32;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}A.adler=g.check=H(u),u=0,p=0,g.mode=y;case y:if(0===g.havedict)return A.next_out=d,A.avail_out=f,A.next_in=K,A.avail_in=l,g.hold=u,g.bits=p,t;A.adler=g.check=1,g.mode=r;case r:if(I===o||I===D)break A;case n:if(g.last){u>>>=7&p,p-=7&p,g.mode=S;break}for(;p<3;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}switch(g.last=1&u,u>>>=1,p-=1,3&u){case 0:g.mode=16193;break;case 1:if(q(g),g.mode=R,I===D){u>>>=2,p-=2;break A}break;case 2:g.mode=16196;break;case 3:A.msg="invalid block type",g.mode=U}u>>>=2,p-=2;break;case 16193:for(u>>>=7&p,p-=7&p;p<32;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if((65535&u)!=(u>>>16^65535)){A.msg="invalid stored block lengths",g.mode=U;break}if(g.length=65535&u,u=0,p=0,g.mode=N,I===D)break A;case N:g.mode=16195;case 16195:if(Z=g.length,Z){if(Z>l&&(Z=l),Z>f&&(Z=f),0===Z)break A;L.set(Y.subarray(K,K+Z),d),l-=Z,K+=Z,f-=Z,d+=Z,g.length-=Z;break}g.mode=r;break;case 16196:for(;p<14;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(g.nlen=257+(31&u),u>>>=5,p-=5,g.ndist=1+(31&u),u>>>=5,p-=5,g.ncode=4+(15&u),u>>>=4,p-=4,g.nlen>286||g.ndist>30){A.msg="too many length or distance symbols",g.mode=U;break}g.have=0,g.mode=16197;case 16197:for(;g.have<g.ncode;){for(;p<3;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.lens[BA[g.have++]]=7&u,u>>>=3,p-=3}for(;g.have<19;)g.lens[BA[g.have++]]=0;if(g.lencode=g.lendyn,g.lenbits=7,IA={bits:g.lenbits},_=E(0,g.lens,0,19,g.lencode,0,g.work,IA),g.lenbits=IA.bits,_){A.msg="invalid code lengths set",g.mode=U;break}g.have=0,g.mode=16198;case 16198:for(;g.have<g.nlen+g.ndist;){for(;$=g.lencode[u&(1<<g.lenbits)-1],v=$>>>24,X=$>>>16&255,V=65535&$,!(v<=p);){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(V<16)u>>>=v,p-=v,g.lens[g.have++]=V;else{if(16===V){for(gA=v+2;p<gA;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(u>>>=v,p-=v,0===g.have){A.msg="invalid bit length repeat",g.mode=U;break}z=g.lens[g.have-1],Z=3+(3&u),u>>>=2,p-=2}else if(17===V){for(gA=v+3;p<gA;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}u>>>=v,p-=v,z=0,Z=3+(7&u),u>>>=3,p-=3}else{for(gA=v+7;p<gA;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}u>>>=v,p-=v,z=0,Z=11+(127&u),u>>>=7,p-=7}if(g.have+Z>g.nlen+g.ndist){A.msg="invalid bit length repeat",g.mode=U;break}for(;Z--;)g.lens[g.have++]=z}}if(g.mode===U)break;if(0===g.lens[256]){A.msg="invalid code -- missing end-of-block",g.mode=U;break}if(g.lenbits=9,IA={bits:g.lenbits},_=E(1,g.lens,0,g.nlen,g.lencode,0,g.work,IA),g.lenbits=IA.bits,_){A.msg="invalid literal/lengths set",g.mode=U;break}if(g.distbits=6,g.distcode=g.distdyn,IA={bits:g.distbits},_=E(2,g.lens,g.nlen,g.ndist,g.distcode,0,g.work,IA),g.distbits=IA.bits,_){A.msg="invalid distances set",g.mode=U;break}if(g.mode=R,I===D)break A;case R:g.mode=k;case k:if(l>=6&&f>=258){A.next_out=d,A.avail_out=f,A.next_in=K,A.avail_in=l,g.hold=u,g.bits=p,C(A,W),d=A.next_out,L=A.output,f=A.avail_out,K=A.next_in,Y=A.input,l=A.avail_in,u=g.hold,p=g.bits,g.mode===r&&(g.back=-1);break}for(g.back=0;$=g.lencode[u&(1<<g.lenbits)-1],v=$>>>24,X=$>>>16&255,V=65535&$,!(v<=p);){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(X&&0==(240&X)){for(P=v,O=X,j=V;$=g.lencode[j+((u&(1<<P+O)-1)>>P)],v=$>>>24,X=$>>>16&255,V=65535&$,!(P+v<=p);){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}u>>>=P,p-=P,g.back+=P}if(u>>>=v,p-=v,g.back+=v,g.length=V,0===X){g.mode=16205;break}if(32&X){g.back=-1,g.mode=r;break}if(64&X){A.msg="invalid literal/length code",g.mode=U;break}g.extra=15&X,g.mode=16201;case 16201:if(g.extra){for(gA=g.extra;p<gA;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.length+=u&(1<<g.extra)-1,u>>>=g.extra,p-=g.extra,g.back+=g.extra}g.was=g.length,g.mode=16202;case 16202:for(;$=g.distcode[u&(1<<g.distbits)-1],v=$>>>24,X=$>>>16&255,V=65535&$,!(v<=p);){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(0==(240&X)){for(P=v,O=X,j=V;$=g.distcode[j+((u&(1<<P+O)-1)>>P)],v=$>>>24,X=$>>>16&255,V=65535&$,!(P+v<=p);){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}u>>>=P,p-=P,g.back+=P}if(u>>>=v,p-=v,g.back+=v,64&X){A.msg="invalid distance code",g.mode=U;break}g.offset=V,g.extra=15&X,g.mode=16203;case 16203:if(g.extra){for(gA=g.extra;p<gA;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}g.offset+=u&(1<<g.extra)-1,u>>>=g.extra,p-=g.extra,g.back+=g.extra}if(g.offset>g.dmax){A.msg="invalid distance too far back",g.mode=U;break}g.mode=16204;case 16204:if(0===f)break A;if(Z=W-f,g.offset>Z){if(Z=g.offset-Z,Z>g.whave&&g.sane){A.msg="invalid distance too far back",g.mode=U;break}Z>g.wnext?(Z-=g.wnext,x=g.wsize-Z):x=g.wnext-Z,Z>g.length&&(Z=g.length),T=g.window}else T=L,x=d-g.offset,Z=g.length;Z>f&&(Z=f),f-=Z,g.length-=Z;do{L[d++]=T[x++]}while(--Z);0===g.length&&(g.mode=k);break;case 16205:if(0===f)break A;L[d++]=g.length,f--,g.mode=k;break;case S:if(g.wrap){for(;p<32;){if(0===l)break A;l--,u|=Y[K++]<<p,p+=8}if(W-=f,A.total_out+=W,g.total+=W,4&g.wrap&&W&&(A.adler=g.check=g.flags?Q(g.check,L,W,d-W):B(g.check,L,W,d-W)),W=f,4&g.wrap&&(g.flags?u:H(u))!==g.check){A.msg="incorrect data check",g.mode=U;break}u=0,p=0}g.mode=16207;case 16207:if(g.wrap&&g.flags){for(;p<32;){if(0===l)break A;l--,u+=Y[K++]<<p,p+=8}if(4&g.wrap&&u!==(4294967295&g.total)){A.msg="incorrect length check",g.mode=U;break}u=0,p=0}g.mode=16208;case 16208:_=s;break A;case U:_=e;break A;case J:return h;default:return w}return A.next_out=d,A.avail_out=f,A.next_in=K,A.avail_in=l,g.hold=u,g.bits=p,(g.wsize||W!==A.avail_out&&g.mode<U&&(g.mode<S||I!==i))&&b(A,A.output,A.next_out,W-A.avail_out)?(g.mode=J,h):(m-=A.avail_in,W-=A.avail_out,A.total_in+=m,A.total_out+=W,g.total+=W,4&g.wrap&&W&&(A.adler=g.check=g.flags?Q(g.check,L,W,A.next_out-W):B(g.check,L,W,A.next_out-W)),A.data_type=g.bits+(g.last?64:0)+(g.mode===r?128:0)+(g.mode===R||g.mode===N?256:0),(0===m&&0===W||I===i)&&_===a&&(_=G),_)},A.exports.inflateEnd=A=>{if(M(A))return w;let I=A.state;return I.window&&(I.window=null),A.state=null,a},A.exports.inflateGetHeader=(A,I)=>{if(M(A))return w;const g=A.state;return 0==(2&g.wrap)?w:(g.head=I,I.done=!1,a)},A.exports.inflateSetDictionary=(A,I)=>{const g=I.length;let Q,C,E;return M(A)?w:(Q=A.state,0!==Q.wrap&&Q.mode!==y?w:Q.mode===y&&(C=1,C=B(C,I,g,0),C!==Q.check)?e:(E=b(A,I,g,g),E?(Q.mode=J,h):(Q.havedict=1,a)))},A.exports.inflateInfo="pako inflate (from Nodeca project)"},446:A=>{const I=15,g=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),B=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Q=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),C=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);A.exports=(A,E,i,o,D,a,s,t)=>{const w=t.bits;let e,h,G,c,F,y,r=0,n=0,N=0,R=0,k=0,S=0,U=0,J=0,H=0,Y=0,M=null;const L=new Uint16Array(16),K=new Uint16Array(16);let d,l,f,u=null;for(r=0;r<=I;r++)L[r]=0;for(n=0;n<o;n++)L[E[i+n]]++;for(k=w,R=I;R>=1&&0===L[R];R--);if(k>R&&(k=R),0===R)return D[a++]=20971520,D[a++]=20971520,t.bits=1,0;for(N=1;N<R&&0===L[N];N++);for(k<N&&(k=N),J=1,r=1;r<=I;r++)if(J<<=1,J-=L[r],J<0)return-1;if(J>0&&(0===A||1!==R))return-1;for(K[1]=0,r=1;r<I;r++)K[r+1]=K[r]+L[r];for(n=0;n<o;n++)0!==E[i+n]&&(s[K[E[i+n]]++]=n);if(0===A?(M=u=s,y=20):1===A?(M=g,u=B,y=257):(M=Q,u=C,y=0),Y=0,n=0,r=N,F=a,S=k,U=0,G=-1,H=1<<k,c=H-1,1===A&&H>852||2===A&&H>592)return 1;for(;;){d=r-U,s[n]+1<y?(l=0,f=s[n]):s[n]>=y?(l=u[s[n]-y],f=M[s[n]-y]):(l=96,f=0),e=1<<r-U,h=1<<S,N=h;do{h-=e,D[F+(Y>>U)+h]=d<<24|l<<16|f|0}while(0!==h);for(e=1<<r-1;Y&e;)e>>=1;if(0!==e?(Y&=e-1,Y+=e):Y=0,n++,0==--L[r]){if(r===R)break;r=E[i+s[n]]}if(r>k&&(Y&c)!==G){for(0===U&&(U=k),F+=N,S=r-U,J=1<<S;S+U<R&&(J-=L[S+U],!(J<=0));)S++,J<<=1;if(H+=1<<S,1===A&&H>852||2===A&&H>592)return 1;G=Y&c,D[G]=k<<24|S<<16|F-a|0}}return 0!==Y&&(D[F+Y]=r-U<<24|64<<16|0),t.bits=k,0}},604:A=>{A.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},249:A=>{A.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},465:A=>{A.exports=function(A,I,g,B){var Q=self||window;try{try{var C;try{C=new Q.Blob([A])}catch(I){(C=new(Q.BlobBuilder||Q.WebKitBlobBuilder||Q.MozBlobBuilder||Q.MSBlobBuilder)).append(A),C=C.getBlob()}var E=Q.URL||Q.webkitURL,i=E.createObjectURL(C),o=new Q[I](i,g);return E.revokeObjectURL(i),o}catch(B){return new Q[I]("data:application/javascript,".concat(encodeURIComponent(A)),g)}}catch(A){if(!B)throw Error("Inline worker is not supported");return new Q[I](B,g)}}},713:I=>{I.exports=A}},g={};function B(A){var Q=g[A];if(void 0!==Q)return Q.exports;var C=g[A]={exports:{}};return I[A](C,C.exports,B),C.exports}B.n=A=>{var I=A&&A.__esModule?()=>A.default:()=>A;return B.d(I,{a:I}),I},B.d=(A,I)=>{for(var g in I)B.o(I,g)&&!B.o(A,g)&&Object.defineProperty(A,g,{enumerable:!0,get:I[g]})},B.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(A){if("object"==typeof window)return window}}(),B.o=(A,I)=>Object.prototype.hasOwnProperty.call(A,I),B.r=A=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})},(()=>{var A;B.g.importScripts&&(A=B.g.location+"");var I=B.g.document;if(!A&&I&&(I.currentScript&&(A=I.currentScript.src),!A)){var g=I.getElementsByTagName("script");if(g.length)for(var Q=g.length-1;Q>-1&&!A;)A=g[Q--].src}if(!A)throw new Error("Automatic publicPath is not supported in this browser");A=A.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),B.p=A})();var Q={};return(()=>{B.r(Q),B.d(Q,{configure:()=>JI,convertColorSpace:()=>IA,convertPALETTECOLOR:()=>UI,convertRGBColorByPixel:()=>g,convertRGBColorByPlane:()=>C,convertYBRFullByPixel:()=>E,convertYBRFullByPlane:()=>i,createImage:()=>JA,decodeImageFrame:()=>nA,decodeJPEGBaseline8BitColor:()=>BA,default:()=>YI,external:()=>kI,getImageFrame:()=>NA,getMinMax:()=>$,getPixelData:()=>_,internal:()=>m,isColorImage:()=>RA,isJPEGBaseline8BitColor:()=>HI,wadors:()=>lA,wadouri:()=>yI,webWorkerManager:()=>FA});var A={};B.r(A),B.d(A,{ProgressiveIterator:()=>W});var I={};function g(A,I,g){if(void 0===A)throw new Error("decodeRGB: rgbBuffer must not be undefined");if(A.length%3!=0)throw new Error("decodeRGB: rgbBuffer length must be divisible by 3");const B=A.length/3;let Q=0,C=0;if(g)for(let g=0;g<B;g++)I[C++]=A[Q++],I[C++]=A[Q++],I[C++]=A[Q++],I[C++]=255;else I.set(A)}function C(A,I,g){if(void 0===A)throw new Error("decodeRGB: rgbBuffer must not be undefined");if(A.length%3!=0)throw new Error("decodeRGB: rgbBuffer length must be divisible by 3");const B=A.length/3;let Q=0,C=0,E=B,i=2*B;if(g)for(let g=0;g<B;g++)I[Q++]=A[C++],I[Q++]=A[E++],I[Q++]=A[i++],I[Q++]=255;else for(let g=0;g<B;g++)I[Q++]=A[C++],I[Q++]=A[E++],I[Q++]=A[i++]}function E(A,I,g){if(void 0===A)throw new Error("decodeRGB: ybrBuffer must not be undefined");if(A.length%3!=0)throw new Error("decodeRGB: ybrBuffer length must be divisble by 3");const B=A.length/3;let Q=0,C=0;if(g)for(let g=0;g<B;g++){const g=A[Q++],B=A[Q++],E=A[Q++];I[C++]=g+1.402*(E-128),I[C++]=g-.34414*(B-128)-.71414*(E-128),I[C++]=g+1.772*(B-128),I[C++]=255}else for(let g=0;g<B;g++){const g=A[Q++],B=A[Q++],E=A[Q++];I[C++]=g+1.402*(E-128),I[C++]=g-.34414*(B-128)-.71414*(E-128),I[C++]=g+1.772*(B-128)}}function i(A,I,g){if(void 0===A)throw new Error("decodeRGB: ybrBuffer must not be undefined");if(A.length%3!=0)throw new Error("decodeRGB: ybrBuffer length must be divisble by 3");const B=A.length/3;let Q=0,C=0,E=B,i=2*B;if(g)for(let g=0;g<B;g++){const g=A[C++],B=A[E++],o=A[i++];I[Q++]=g+1.402*(o-128),I[Q++]=g-.34414*(B-128)-.71414*(o-128),I[Q++]=g+1.772*(B-128),I[Q++]=255}else for(let g=0;g<B;g++){const g=A[C++],B=A[E++],o=A[i++];I[Q++]=g+1.402*(o-128),I[Q++]=g-.34414*(B-128)-.71414*(o-128),I[Q++]=g+1.772*(B-128)}}B.r(I),B.d(I,{ImageQualityStatus:()=>x});const o=function(A,I,g){return I=I||0,A&&A.Value?A.Value.length<=I?g:A.Value[I]:g};const D=function(A,I,g){const B=o(A,I,g);if(void 0!==B)return parseFloat(B)};const a=function(A,I){const g=o(A,I);if(void 0!==g)return parseFloat(g)};const s=function(A,I){if(!A)return;if(!A.Value)return;if(!Array.isArray(A.Value))return;if(I&&A.Value.length<I)return;const g=[];for(let I=0;I<A.Value.length;I++)g.push(parseFloat(A.Value[I]));return g};function t(A){const I=A.indexOf(":");return A.substring(I+1)}function w(A,I=!0){return A&&A.Value?A.Value[0]&&I?A.Value[0]:A.Value:A}function e(A,I,g){return{shared:(I?Object.values(I[0]):[]).map((A=>A[0])).filter((A=>void 0!==A&&"object"==typeof A)),perFrame:(A?Object.values(A[g-1]):[]).map((A=>A.Value[0])).filter((A=>void 0!==A&&"object"==typeof A))}}function h(A){let{52009230:I,52009229:g,"00280008":B,...Q}=A;return I=w(I,!1),g=w(g,!1),B=w(B),{PerFrameFunctionalGroupsSequence:I,SharedFunctionalGroupsSequence:g,NumberOfFrames:B,rest:Q}}function G(A){const I=A.indexOf("/frames/")+8,g=A.slice(0,I),B=parseInt(A.slice(I),10);return{metadata:F[`${g}1`],frame:B}}const c={_retrieveMultiframeMetadata:G,retrieveMultiframeMetadata:function(A){return G(t(A))},isMultiframe:function(A){const I=o(A["00280008"]);return I&&I>1}};let F=[],y={};const r={add:function(A,I){const g=t(A);I.isMultiframe=c.isMultiframe(I),F[g]=I},get:function(A){const I=t(A),g=F[I];if(g&&!g?.isMultiframe)return g;const B=y[I];if(B)return B;const Q=c._retrieveMultiframeMetadata(I);if(!Q||!Q.metadata)return;const{metadata:C,frame:E}=Q;if(C){const A=function(A,I){const{PerFrameFunctionalGroupsSequence:g,SharedFunctionalGroupsSequence:B,NumberOfFrames:Q,rest:C}=h(I);if(g||Q>1){const{shared:E,perFrame:i}=e(g,B,A),o=Object.assign(I,{frameNumber:A});return[...E,...i].forEach((A=>{Object.entries(A).forEach((([A,I])=>{o[A]=I}))})),Object.assign(C,{"00280008":Q},o)}return I}(E,C);return y[I]=A,A}},remove:function(A){const I=t(A);F[I]=void 0,y[I]=void 0},purge:function(){F=[],y={}}};function n(A){return"RECON TOMO"===A||"RECON GATED TOMO"===A}function N(A){return o(A["00080060"]).includes("NM")}function R(A,I){const g=w(A["00080008"],!1);if(g)return g[I]}function k(A){let I=s(A["00200037"],6);return!I&&N(A)&&(I=function(A){let I;const g=R(A,2);if(g&&n(g)){const g=w(A["00540022"]);g&&(I=s(g["00200037"],6))}return I}(A)),I}function S(A){let I=s(A["00200032"],3);return!I&&N(A)&&(I=function(A){let I;const g=R(A,2);if(g&&n(g)){const g=w(A["00540022"]);g&&(I=s(g["00200032"],3))}return I}(A)),I}function U(A,I,g){const B={};for(const Q of g)try{const g=I(Q,A);if(g){const A={};for(const I in g)if(I in g){A[J(I)]=g[I]}Object.assign(B,A)}}catch(A){console.error(`Error retrieving ${Q} data:`,A)}return B}const J=A=>A.charAt(0).toUpperCase()+A.slice(1),H=["multiframeModule","generalSeriesModule","patientStudyModule","imagePlaneModule","nmMultiframeGeometryModule","imagePixelModule","modalityLutModule","voiLutModule","sopCommonModule","petIsotopeModule","overlayPlaneModule","transferSyntax","petSeriesModule","petImageModule"];function Y(A,I){const g=s(A[I]);return g?g[0]:null}const M=function(A){return A?.Value?.length?Array.isArray(A.Value)?A.Value:"object"==typeof A.Value?(console.warn("Warning: Value should be an array, but an object was found. Encapsulating the object in an array."),[A.Value]):[]:[]};function L(A){const I=M(A["00186011"]);if(!I||!I.length)return null;return I.map((A=>{const I=Y(A,"0018602C"),g=Y(A,"0018602E"),B=Y(A,"00186024"),Q=Y(A,"00186026");return{regionLocationMinY0:Y(A,"0018601A"),regionLocationMaxY1:Y(A,"0018601E"),regionLocationMinX0:Y(A,"00186018"),regionLocationMaxX1:Y(A,"0018601C"),referencePixelX0:Y(A,"00186020"),referencePixelY0:Y(A,"00186022"),physicalDeltaX:I,physicalDeltaY:g,physicalUnitXDirection:B,physicalUnitYDirection:Q,referencePhysicalPixelValueY:Y(A,"0018602A"),referencePhysicalPixelValueX:Y(A,"00186028"),regionSpatialFormat:Y(A,"00186012"),regionDataType:Y(A,"00186014"),regionFlags:Y(A,"00186016"),transducerFrequency:Y(A,"00186030")}}))}function K(A,I){return{transferSyntaxUID:o(I["00020010"])||o(I["00083002"])}}const d=function A(I,g){const{MetadataModules:B}=kI.cornerstone.Enums;if(I===B.MULTIFRAME){const{metadata:A,frame:I}=c.retrieveMultiframeMetadata(g);if(!A)return;const{PerFrameFunctionalGroupsSequence:B,SharedFunctionalGroupsSequence:Q,NumberOfFrames:C}=h(A);if(B||C>1){const{shared:A,perFrame:g}=e(B,Q,I);return{NumberOfFrames:C,PerFrameFunctionalInformation:g,SharedFunctionalInformation:A}}return{NumberOfFrames:C}}const{dicomParser:Q}=kI,C=r.get(g);if(C){if(I===B.GENERAL_SERIES)return{modality:o(C["00080060"]),seriesInstanceUID:o(C["0020000E"]),seriesNumber:a(C["00200011"]),studyInstanceUID:o(C["0020000D"]),seriesDate:Q.parseDA(o(C["00080021"])),seriesTime:Q.parseTM(o(C["00080031"],0,"")),acquisitionDate:Q.parseDA(o(C["00080022"]),""),acquisitionTime:Q.parseTM(o(C["00080032"],0,""))};if(I===B.PATIENT_STUDY)return{patientAge:a(C["00101010"]),patientSize:a(C["00101020"]),patientSex:o(C["00100040"]),patientWeight:a(C["00101030"])};if(I===B.NM_MULTIFRAME_GEOMETRY){const A=o(C["00080060"]),I=R(C,2);return{modality:A,imageType:o(C["00080008"]),imageSubType:I,imageOrientationPatient:k(C),imagePositionPatient:S(C),sliceThickness:a(C["00180050"]),pixelSpacing:s(C["00280030"],2),numberOfFrames:a(C["00280008"]),isNMReconstructable:n(I)&&A.includes("NM")}}if(I===B.IMAGE_PLANE){const A=k(C),I=S(C),g=s(C["00280030"],2);let B=null,Q=null;g&&(Q=g[0],B=g[1]);let E=null,i=null;return A&&(E=[parseFloat(A[0]),parseFloat(A[1]),parseFloat(A[2])],i=[parseFloat(A[3]),parseFloat(A[4]),parseFloat(A[5])]),{frameOfReferenceUID:o(C["00200052"]),rows:a(C["00280010"]),columns:a(C["00280011"]),imageOrientationPatient:A,rowCosines:E,columnCosines:i,imagePositionPatient:I,sliceThickness:a(C["00180050"]),sliceLocation:a(C["00201041"]),pixelSpacing:g,rowPixelSpacing:Q,columnPixelSpacing:B}}if(I===B.ULTRASOUND_ENHANCED_REGION)return L(C);if(I===B.CALIBRATION){if("US"===o(C["00080060"])){return{sequenceOfUltrasoundRegions:L(C)}}}if(I===B.IMAGE_URL)return function(A,I){const{transferSyntaxUID:g}=K(A,I),B=kI.cornerstone.utilities.isVideoTransferSyntax(g),Q=A.substring(7),C=Q.replace("/frames/","/thumbnail/");let E=Q.replace("/frames/","/rendered/");B&&(E=E.replace("/rendered/1","/rendered"));return{isVideo:B,rendered:E,thumbnail:C}}(g,C);if(I===B.CINE)return function(A,I){const g=o(I["00180040"]);return{cineRate:g,numberOfFrames:a(I["00280008"])}}(0,C);if("imagePixelModule"===I)return{samplesPerPixel:a(C["00280002"]),photometricInterpretation:o(C["00280004"]),rows:a(C["00280010"]),columns:a(C["00280011"]),bitsAllocated:a(C["00280100"]),bitsStored:a(C["00280101"]),highBit:o(C["00280102"]),pixelRepresentation:a(C["00280103"]),planarConfiguration:a(C["00280006"]),pixelAspectRatio:o(C["00280034"]),smallestPixelValue:a(C["00280106"]),largestPixelValue:a(C["00280107"]),redPaletteColorLookupTableDescriptor:s(C["00281101"]),greenPaletteColorLookupTableDescriptor:s(C["00281102"]),bluePaletteColorLookupTableDescriptor:s(C["00281103"]),redPaletteColorLookupTableData:s(C["00281201"]),greenPaletteColorLookupTableData:s(C["00281202"]),bluePaletteColorLookupTableData:s(C["00281203"])};if("voiLutModule"===I)return{windowCenter:s(C["00281050"],1),windowWidth:s(C["00281051"],1)};if("modalityLutModule"===I)return{rescaleIntercept:a(C["00281052"]),rescaleSlope:a(C["00281053"]),rescaleType:o(C["00281054"])};if("sopCommonModule"===I)return{sopClassUID:o(C["00080016"]),sopInstanceUID:o(C["00080018"])};if("petIsotopeModule"===I){const A=o(C["00540016"]);if(void 0===A)return;return{radiopharmaceuticalInfo:{radiopharmaceuticalStartTime:Q.parseTM(o(A["00181072"],0,"")),radiopharmaceuticalStartDateTime:o(A["00181078"],0,""),radionuclideTotalDose:a(A["00181074"]),radionuclideHalfLife:a(A["00181075"])}}}return"overlayPlaneModule"===I?function(A){const I=[];for(let g=0;g<=30;g+=2){let B=`x60${g.toString(16)}`;4===B.length&&(B=`x600${g.toString(16)}`);const Q=o(A[`${B}3000`]);if(!Q)continue;const C=[];for(let I=0;I<Q.length;I++)for(let g=0;g<8;g++){const B=A.Value[Q.dataOffset+I];C[8*I+g]=B>>g&1}I.push({rows:a(A[`${B}0010`]),columns:a(A[`${B}0011`]),type:o(A[`${B}0040`]),x:a(A[`${B}0050`],1)-1,y:a(A[`${B}0050`],0)-1,pixelData:C,description:o(A[`${B}0022`]),label:o(A[`${B}1500`]),roiArea:o(A[`${B}1301`]),roiMean:o(A[`${B}1302`]),roiStandardDeviation:o(A[`${B}1303`])})}return{overlays:I}}(C):"transferSyntax"===I?K(g,C):"petSeriesModule"===I?{correctedImage:o(C["00280051"]),units:o(C["00541001"]),decayCorrection:o(C["00541102"])}:"petImageModule"===I?{frameReferenceTime:a(C["00541300"]),actualFrameDuration:a(C["00181242"])}:"instance"===I?U(g,A,H):void 0}};function l(A,I,g){if(g+A.length>I.length)return!1;let B=g;for(let g=0;g<A.length;g++)if(A[g]!==I[B++])return!1;return!0}const f=function(A,I,g){g=g||0;const B=function(A){const I=new Uint8Array(A.length);for(let g=0,B=A.length;g<B;g++)I[g]=A.charCodeAt(g);return I}(I);for(let I=g;I<A.length;I++)if(B[0]===A[I]&&l(B,A,I))return I;return-1};let u={open(A,I){A.open("get",I,!0)},beforeSend(){},beforeProcessing:A=>Promise.resolve(A.response),imageCreated(){},strict:!1,decodeConfig:{convertFloatPixelDataToInt:!0,use16BitDataType:!1}};function p(A){u=Object.assign(u,A)}function q(){return u}const b=function(A,I,g={},B={}){const{cornerstone:Q}=kI,C=q(),E=A=>{if("function"==typeof C.errorInterceptor){const I=new Error("request failed");I.request=A,I.response=A.response,I.status=A.status,C.errorInterceptor(I)}},i=new XMLHttpRequest,o=new Promise(((o,D)=>{C.open(i,A,g,B);const a=C.beforeSend(i,I,g,B);i.responseType="arraybuffer";const s=Object.assign({},g,a);Object.keys(s).forEach((function(I){null!==s[I]&&("Accept"===I&&-1!==A.indexOf("accept=")||i.setRequestHeader(I,s[I]))})),B.deferred={resolve:o,reject:D},B.url=A,B.imageId=I,i.onloadstart=function(g){C.onloadstart&&C.onloadstart(g,B);const E={url:A,imageId:I};Q.triggerEvent(Q.events,"cornerstoneimageloadstart",E)},i.onloadend=function(g){C.onloadend&&C.onloadend(g,B);const E={url:A,imageId:I};Q.triggerEvent(Q.events,"cornerstoneimageloadend",E)},i.onreadystatechange=function(A){C.onreadystatechange?C.onreadystatechange(A,B):4===i.readyState&&(200===i.status||206===i.status?C.beforeProcessing(i).then(o).catch((()=>{E(i),D(i)})):(E(i),D(i)))},i.onprogress=function(A){const I=A.loaded;let g,Q;A.lengthComputable&&(g=A.total,Q=Math.round(I/g*100)),C.onprogress&&C.onprogress(A,B)},i.onerror=function(){E(i),D(i)},i.onabort=function(){E(i),D(i)},i.send()}));return o.xhr=i,o},m={xhrRequest:b,setOptions:p,getOptions:q};class W{constructor(A){this.name=A||"unknown"}static as(A){if(A.iterator)return A.iterator;const I=new W("as iterator");return A.then((A=>{try{I.add(A,!0)}catch(A){I.reject(A)}}),(A=>I.reject(A))),I}add(A,I=!1){this.nextValue=A,this.done||=I,this.waiting&&(this.waiting.resolve(A),this.waiting=void 0)}resolve(){this.done=!0,this.waiting&&(this.waiting.resolve(this.nextValue),this.waiting=void 0)}reject(A){this.rejectReason=A,this.waiting?.reject(A)}getRecent(){if(this.rejectReason)throw this.rejectReason;return this.nextValue}async*[Symbol.asyncIterator](){for(;!this.done;){if(this.rejectReason)throw this.rejectReason;if(void 0!==this.nextValue&&(yield this.nextValue,this.done))break;this.waiting||(this.waiting={},this.waiting.promise=new Promise(((A,I)=>{this.waiting.resolve=A,this.waiting.reject=I}))),await this.waiting.promise}yield this.nextValue}async forEach(A,I){let g=0;try{for await(const B of this){const{done:Q}=this;try{await A(B,Q,g),g++}catch(A){if(!Q){console.warn("Caught exception in intermediate value",A);continue}if(!I)throw A;I(A,Q)}}}catch(A){if(!I)throw A;I(A,!0)}}generate(A,I){return A(this,this.reject.bind(this)).then((()=>{this.done||this.resolve()}),(A=>{this.reject(A),I?I(A):console.warn("Couldn't process because",A)}))}async nextPromise(){for await(const A of this)if(A)return A;return this.nextValue}async donePromise(){for await(const A of this);return this.nextValue}getNextPromise(){const A=this.nextPromise();return A.iterator=this,A}getDonePromise(){const A=this.donePromise();return A.iterator=this,A}}var Z;!function(A){A[A.FAR_REPLICATE=1]="FAR_REPLICATE",A[A.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",A[A.SUBRESOLUTION=6]="SUBRESOLUTION",A[A.LOSSY=7]="LOSSY",A[A.FULL_RESOLUTION=8]="FULL_RESOLUTION"}(Z||(Z={}));const x=Z,{ImageQualityStatus:T}=I;function v(A,I,g){g||={};const B=new Uint8Array(I),Q=!!g?.isPartial;if(-1===A.indexOf("multipart"))return{contentType:A,imageQualityStatus:Q?T.SUBRESOLUTION:T.FULL_RESOLUTION,pixelData:B};let{tokenIndex:C,responseHeaders:E,boundary:i,multipartContentType:o}=g;if(C||=f(B,"\r\n\r\n"),-1===C)throw new Error("invalid response - no multipart mime header");if(!i){const A=function(A,I,g){I=I||0,g=g||A.length-I;let B="";for(let Q=I;Q<I+g;Q++)B+=String.fromCharCode(A[Q]);return B}(B,0,C);if(E=A.split("\r\n"),i=function(A){for(let I=0;I<A.length;I++)if("--"===A[I].substr(0,2))return A[I]}(E),!i)throw new Error("invalid response - no boundary marker")}const D=C+4,a=f(B,i,D);if(-1===a&&!Q)throw new Error("invalid response - terminating boundary not found");return o||=function(A){for(let I=0;I<A.length;I++)if("Content-Type:"===A[I].substr(0,13))return A[I].substr(13).trim()}(E),g.tokenIndex=C,g.boundary=i,g.responseHeaders=E,g.multipartContentType=o,g.isPartial=-1===a,{contentType:o,extractDone:!Q||-1!==a,tokenIndex:C,responseHeaders:E,boundary:i,multipartContentType:o,pixelData:I.slice(D,a-2)}}const{ImageQualityStatus:X}=I;function V(A,I=!0){return I?A.imageQualityStatus??X.FULL_RESOLUTION:X.SUBRESOLUTION}const{ProgressiveIterator:P}=A;function O(A,I,g={},B={}){const Q=q(),{retrieveOptions:C={},streamingData:E={}}=B,i=C.minChunkSize||131072,o=new P("streamRequest");return o.generate((async(B,o)=>{const D=Object.assign({},g);Object.keys(D).forEach((function(I){null===D[I]&&(D[I]=void 0),"Accept"===I&&-1!==A.indexOf("accept=")&&(D[I]=void 0)}));try{const Q=await fetch(A,{headers:g,signal:void 0});if(200!==Q.status)throw new Error(`Couldn't retrieve ${A} got status ${Q.status}`);const o=Q.body.getReader(),D=Q.headers,a=D.get("content-type"),s=Number(D.get("Content-Length"));let t=!1,w=E.encodedData,e=E.lastSize||0;for(E.isPartial=!0;!t;){const{done:g,value:Q}=await o.read();if(w=j(w,Q),!w){if(t)throw new Error(`Done but no image frame available ${I}`);continue}if(t=g||w.byteLength===s,!t&&w.length<e+i)continue;e=w.length,E.isPartial=!g;const D=v(a,w,E),h=V(C,t),G={url:A,imageId:I,...D,percentComplete:g?100:100*D.pixelData?.length/s,imageQualityStatus:h,done:t};B.add(G,t)}}catch(A){(A=>{if("function"==typeof Q.errorInterceptor){const A=new Error("request failed");Q.errorInterceptor(A)}})(),console.error(A),o(A)}})),o.getNextPromise()}function j(A,I){if(!A)return I;if(!I)return A;const g=new Uint8Array(A.length+I.length);return g.set(A,0),g.set(I,A.length),g}function z(A,I,g={},B={}){const Q=q(),{retrieveOptions:C={},streamingData:E}=B,i=E.chunkSize||function(A,I,g){const B=I[g];if("function"!=typeof B)return B;const Q=r.get(A);return B(Q,A)}(I,C,"chunkSize")||65536,o=new Promise((async(I,B)=>{const o=Object.assign({},g);Object.keys(o).forEach((function(A){null!==o[A]&&void 0!==o[A]||delete o[A]}));try{E.encodedData||(E.chunkSize=i,E.rangesFetched=0);const g=function(A,I){const{totalBytes:g,encodedData:B,chunkSize:Q=65536}=A,{rangeIndex:C=0}=I;if(!(-1!==C||g&&B))return[0,""];if(-1===C||B?.byteLength>g-Q)return[B?.byteLength||0,""];return[B?.byteLength||0,Q*(C+1)-1]}(E,C),{encodedData:B,responseHeaders:Q}=await async function(A,I,g,B){g&&(I=Object.assign(I,{Range:`bytes=${g[0]}-${g[1]}`}));let{encodedData:Q}=B;if(g[1]&&Q?.byteLength>g[1])return B;const C=await fetch(A,{headers:I,signal:void 0}),E=await C.arrayBuffer(),i=new Uint8Array(E),{status:o}=C;let D;Q?(D=new Uint8Array(Q.length+i.length),D.set(Q,0),D.set(i,Q.length),B.rangesFetched=1):(D=new Uint8Array(i.length),D.set(i,0),B.rangesFetched++);B.encodedData=Q=D,B.responseHeaders=C.headers;const a=C.headers.get("Content-Range");a?B.totalBytes=Number(a.split("/")[1]):206===o&&g?""===g[1]||Q?.length<g[1]?B.totalBytes=Q.byteLength:B.totalBytes=Number.MAX_SAFE_INTEGER:B.totalBytes=Q?.byteLength;return B}(A,o,g,E),D=Q.get("content-type"),{totalBytes:a}=E,s=a===B.byteLength,t=v(D,B,{isPartial:!0}),w=V(C,s||t.extractDone);I({...t,imageQualityStatus:w,percentComplete:t.extractDone?100:100*i/a})}catch(A){(A=>{if("function"==typeof Q.errorInterceptor){const A=new Error("request failed");Q.errorInterceptor(A)}else console.warn("rangeRequest:Caught",A)})(A),console.error(A),B(A)}}));return o}const _=function(A,I,g="application/octet-stream",B){const{streamingData:Q,retrieveOptions:C={}}=B||{},E={Accept:g};let i=C.urlArguments?`${A}${-1===A.indexOf("?")?"?":"&"}${C.urlArguments}`:A;if(C.framesPath&&(i=i.replace("/frames/",C.framesPath)),Q?.url!==i&&(B.streamingData={url:i}),void 0!==C.rangeIndex)return z(i,I,E,B);if(C.streaming)return O(i,I,E,B);const o=b(i,I,E),{xhr:D}=o;return o.then((function(A){const I=v(D.getResponseHeader("Content-Type")||"application/octet-stream",new Uint8Array(A));return I.imageQualityStatus=V(C,!0),I}))};const $=function(A){let I,g=A[0],B=A[0];const Q=A.length;for(let C=1;C<Q;C++)I=A[C],g=Math.min(g,I),B=Math.max(B,I);return{min:g,max:B}};function AA(A,I,B){0===A.planarConfiguration?g(A.pixelData,I,B):C(A.pixelData,I,B)}function IA(A,I,g){if("RGB"===A.photometricInterpretation)AA(A,I,g);else if("YBR_RCT"===A.photometricInterpretation)AA(A,I,g);else if("YBR_ICT"===A.photometricInterpretation)AA(A,I,g);else if("PALETTE COLOR"===A.photometricInterpretation)UI(A,I,g);else if("YBR_FULL_422"===A.photometricInterpretation)!function(A,I,g){if(void 0===A)throw new Error("decodeRGB: ybrBuffer must not be undefined");if(A.length%2!=0)throw new Error("decodeRGB: ybrBuffer length must be divisble by 2");const B=A.length/2;let Q=0,C=0;if(g)for(let g=0;g<B;g+=2){const g=A[Q++],B=A[Q++],E=A[Q++],i=A[Q++];I[C++]=g+1.402*(i-128),I[C++]=g-.34414*(E-128)-.71414*(i-128),I[C++]=g+1.772*(E-128),I[C++]=255,I[C++]=B+1.402*(i-128),I[C++]=B-.34414*(E-128)-.71414*(i-128),I[C++]=B+1.772*(E-128),I[C++]=255}else for(let g=0;g<B;g+=2){const g=A[Q++],B=A[Q++],E=A[Q++],i=A[Q++];I[C++]=g+1.402*(i-128),I[C++]=g-.34414*(E-128)-.71414*(i-128),I[C++]=g+1.772*(E-128),I[C++]=B+1.402*(i-128),I[C++]=B-.34414*(E-128)-.71414*(i-128),I[C++]=B+1.772*(E-128)}}(A.pixelData,I,g);else{if("YBR_FULL"!==A.photometricInterpretation)throw new Error(`No color space conversion for photometric interpretation ${A.photometricInterpretation}`);!function(A,I,g){0===A.planarConfiguration?E(A.pixelData,I,g):i(A.pixelData,I,g)}(A,I,g)}}function gA(A){return function(A){let I;try{return decodeURIComponent(escape(A))}catch(g){if(I=g,I instanceof URIError)return A;throw I}}(String.fromCharCode.apply(null,Array.prototype.slice.apply(new Uint8Array(A))))}const BA=function(A,I,g){const B=(new Date).getTime(),Q=new Blob([I],{type:"image/jpeg"});return new Promise(((I,C)=>{const E=new FileReader;void 0===E.readAsBinaryString?E.readAsArrayBuffer(Q):E.readAsBinaryString(Q),E.onload=function(){const Q=new Image;Q.onload=function(){g.height=Q.height,g.width=Q.width,A.rows=Q.height,A.columns=Q.width;const C=g.getContext("2d");C.drawImage(this,0,0);const E=C.getImageData(0,0,Q.width,Q.height),i=(new Date).getTime();A.pixelData=new Uint8Array(E.data.buffer),A.imageData=E,A.decodeTimeInMS=i-B;const o=$(A.pixelData);A.smallestPixelValue=o.min,A.largestPixelValue=o.max,A.pixelDataLength=A.pixelData.length,I(A)},Q.onerror=function(A){C(A)},void 0===E.readAsBinaryString?Q.src=`data:image/jpeg;base64,${window.btoa(gA(E.result))}`:Q.src=`data:image/jpeg;base64,${window.btoa(E.result)}`},E.onerror=A=>{C(A)}}))};var QA=B(465),CA=B.n(QA);function EA(){return CA()('(()=>{var A,I,g={37:(A,I,g)=>{var B,Q=(B=(B="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(A){var I,Q,C=void 0!==(A=A||{})?A:{};C.ready=new Promise((function(A,g){I=A,Q=g}));var E,i,o,D=Object.assign({},C),w=[],s="object"==typeof window,a="function"==typeof importScripts,G="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,F="";if(G){var h=g(716),y=g(401);F=a?y.dirname(F)+"/":"//",E=(A,I)=>(A=V(A)?new URL(A):y.normalize(A),h.readFileSync(A,I?void 0:"utf8")),o=A=>{var I=E(A,!0);return I.buffer||(I=new Uint8Array(I)),I},i=(A,I,g)=>{A=V(A)?new URL(A):y.normalize(A),h.readFile(A,(function(A,B){A?g(A):I(B.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\\\/g,"/"),w=process.argv.slice(2),process.on("uncaughtException",(function(A){if(!(A instanceof P))throw A})),process.on("unhandledRejection",(function(A){throw A})),C.inspect=function(){return"[Emscripten Module object]"}}else(s||a)&&(a?F=self.location.href:"undefined"!=typeof document&&document.currentScript&&(F=document.currentScript.src),B&&(F=B),F=0!==F.indexOf("blob:")?F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1):"",E=A=>{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.send(null),I.responseText},a&&(o=A=>{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}),i=(A,I,g)=>{var B=new XMLHttpRequest;B.open("GET",A,!0),B.responseType="arraybuffer",B.onload=()=>{200==B.status||0==B.status&&B.response?I(B.response):g()},B.onerror=g,B.send(null)});C.print||console.log.bind(console);var c,t=C.printErr||console.warn.bind(console);Object.assign(C,D),D=null,C.arguments&&(w=C.arguments),C.thisProgram&&C.thisProgram,C.quit&&C.quit,C.wasmBinary&&(c=C.wasmBinary);var N;C.noExitRuntime;"object"!=typeof WebAssembly&&Z("no native wasm support detected");var R,U,k,S,r,J,n,e,H,Y=!1,M="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function L(A,I){return A?function(A,I,g){for(var B=I+g,Q=I;A[Q]&&!(Q>=B);)++Q;if(Q-I>16&&A.buffer&&M)return M.decode(A.subarray(I,Q));for(var C="";I<Q;){var E=A[I++];if(128&E){var i=63&A[I++];if(192!=(224&E)){var o=63&A[I++];if((E=224==(240&E)?(15&E)<<12|i<<6|o:(7&E)<<18|i<<12|o<<6|63&A[I++])<65536)C+=String.fromCharCode(E);else{var D=E-65536;C+=String.fromCharCode(55296|D>>10,56320|1023&D)}}else C+=String.fromCharCode((31&E)<<6|i)}else C+=String.fromCharCode(E)}return C}(k,A,I):""}function K(A,I,g){return function(A,I,g,B){if(!(B>0))return 0;for(var Q=g,C=g+B-1,E=0;E<A.length;++E){var i=A.charCodeAt(E);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++E)),i<=127){if(g>=C)break;I[g++]=i}else if(i<=2047){if(g+1>=C)break;I[g++]=192|i>>6,I[g++]=128|63&i}else if(i<=65535){if(g+2>=C)break;I[g++]=224|i>>12,I[g++]=128|i>>6&63,I[g++]=128|63&i}else{if(g+3>=C)break;I[g++]=240|i>>18,I[g++]=128|i>>12&63,I[g++]=128|i>>6&63,I[g++]=128|63&i}}return I[g]=0,g-Q}(A,k,I,g)}function d(A){R=A,C.HEAP8=U=new Int8Array(A),C.HEAP16=S=new Int16Array(A),C.HEAP32=J=new Int32Array(A),C.HEAPU8=k=new Uint8Array(A),C.HEAPU16=r=new Uint16Array(A),C.HEAPU32=n=new Uint32Array(A),C.HEAPF32=e=new Float32Array(A),C.HEAPF64=H=new Float64Array(A)}C.INITIAL_MEMORY;var l,f=[],q=[],p=[],b=0,u=null,W=null;function Z(A){C.onAbort&&C.onAbort(A),t(A="Aborted("+A+")"),Y=!0,A+=". Build with -sASSERTIONS for more info.";var I=new WebAssembly.RuntimeError(A);throw Q(I),I}var m,x,T="data:application/octet-stream;base64,";function X(A){return A.startsWith(T)}function V(A){return A.startsWith("file://")}function v(A){try{if(A==m&&c)return new Uint8Array(c);if(o)return o(A);throw"both async and sync fetching of the wasm failed"}catch(A){Z(A)}}function P(A){this.name="ExitStatus",this.message="Program terminated with exit("+A+")",this.status=A}function O(A){for(;A.length>0;)A.shift()(C)}function j(A){this.excPtr=A,this.ptr=A-24,this.set_type=function(A){n[this.ptr+4>>2]=A},this.get_type=function(){return n[this.ptr+4>>2]},this.set_destructor=function(A){n[this.ptr+8>>2]=A},this.get_destructor=function(){return n[this.ptr+8>>2]},this.set_refcount=function(A){J[this.ptr>>2]=A},this.set_caught=function(A){A=A?1:0,U[this.ptr+12>>0]=A},this.get_caught=function(){return 0!=U[this.ptr+12>>0]},this.set_rethrown=function(A){A=A?1:0,U[this.ptr+13>>0]=A},this.get_rethrown=function(){return 0!=U[this.ptr+13>>0]},this.init=function(A,I){this.set_adjusted_ptr(0),this.set_type(A),this.set_destructor(I),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var A=J[this