UNPKG

@alireza-beta-script/dicom-image-loader-new

Version:

Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file

1 lines 1.28 MB
!function(A,I){"object"==typeof exports&&"object"==typeof module?module.exports=I():"function"==typeof define&&define.amd?define("cornerstoneDICOMImageLoader",[],I):"object"==typeof exports?exports.cornerstoneDICOMImageLoader=I():A.cornerstoneDICOMImageLoader=I()}(this,(()=>(()=>{"use strict";var A={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:w,Z_STREAM_END:t,Z_NEED_DICT:h,Z_STREAM_ERROR:G,Z_DATA_ERROR:F,Z_MEM_ERROR:e}=g(684);function c(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!==w)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!==w)))throw new Error(E[g])}function y(A,I){const g=new c(I);if(g.push(A),g.err)throw g.msg||E[g.err];return g.result}c.prototype.push=function(A,I){const g=this.strm,Q=this.options.chunkSize,E=this.options.dictionary;let i,o,c;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===h&&E&&(i=B.inflateSetDictionary(g,E),i===w?i=B.inflate(g,o):i===F&&(i=h));g.avail_in>0&&i===t&&g.state.wrap>0&&0!==A[g.next_in];)B.inflateReset(g),i=B.inflate(g,o);switch(i){case G:case F:case h:case e:return this.onEnd(i),this.ended=!0,!1}if(c=g.avail_out,g.next_out&&(0===g.avail_out||i===t))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!==w||0!==c){if(i===t)return i=B.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===g.avail_in)break}}return!0},c.prototype.onData=function(A){this.chunks.push(A)},c.prototype.onEnd=function(A){A===w&&("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,w,t,h,G,F,e,c,y,r,R,N,n,S,U,k;const J=A.state;B=A.next_in,U=A.input,Q=B+(A.avail_in-5),C=A.next_out,k=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,w=J.window,t=J.hold,h=J.bits,G=J.lencode,F=J.distcode,e=(1<<J.lenbits)-1,c=(1<<J.distbits)-1;A:do{h<15&&(t+=U[B++]<<h,h+=8,t+=U[B++]<<h,h+=8),y=G[t&e];I:for(;;){if(r=y>>>24,t>>>=r,h-=r,r=y>>>16&255,0===r)k[C++]=65535&y;else{if(!(16&r)){if(0==(64&r)){y=G[(65535&y)+(t&(1<<r)-1)];continue I}if(32&r){J.mode=16191;break A}A.msg="invalid literal/length code",J.mode=I;break A}R=65535&y,r&=15,r&&(h<r&&(t+=U[B++]<<h,h+=8),R+=t&(1<<r)-1,t>>>=r,h-=r),h<15&&(t+=U[B++]<<h,h+=8,t+=U[B++]<<h,h+=8),y=F[t&c];g:for(;;){if(r=y>>>24,t>>>=r,h-=r,r=y>>>16&255,!(16&r)){if(0==(64&r)){y=F[(65535&y)+(t&(1<<r)-1)];continue g}A.msg="invalid distance code",J.mode=I;break A}if(N=65535&y,r&=15,h<r&&(t+=U[B++]<<h,h+=8,h<r&&(t+=U[B++]<<h,h+=8)),N+=t&(1<<r)-1,N>o){A.msg="invalid distance too far back",J.mode=I;break A}if(t>>>=r,h-=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(n=0,S=w,0===s){if(n+=D-r,r<R){R-=r;do{k[C++]=w[n++]}while(--r);n=C-N,S=k}}else if(s<r){if(n+=D+s-r,r-=s,r<R){R-=r;do{k[C++]=w[n++]}while(--r);if(n=0,s<R){r=s,R-=r;do{k[C++]=w[n++]}while(--r);n=C-N,S=k}}}else if(n+=s-r,r<R){R-=r;do{k[C++]=w[n++]}while(--r);n=C-N,S=k}for(;R>2;)k[C++]=S[n++],k[C++]=S[n++],k[C++]=S[n++],R-=3;R&&(k[C++]=S[n++],R>1&&(k[C++]=S[n++]))}else{n=C-N;do{k[C++]=k[n++],k[C++]=k[n++],k[C++]=k[n++],R-=3}while(R>2);R&&(k[C++]=k[n++],R>1&&(k[C++]=k[n++]))}break}}break}}while(B<Q&&C<i);R=h>>3,B-=R,h-=R<<3,t&=(1<<h)-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=t,J.bits=h}},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:w,Z_STREAM_ERROR:t,Z_DATA_ERROR:h,Z_MEM_ERROR:G,Z_BUF_ERROR:F,Z_DEFLATED:e}=g(684),c=16180,y=16190,r=16191,R=16192,N=16194,n=16199,S=16200,U=16206,k=16209,J=16210,H=A=>(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24);function M(){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 L=A=>{if(!A)return 1;const I=A.state;return!I||I.strm!==A||I.mode<c||I.mode>16211?1:0},Y=A=>{if(L(A))return t;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=c,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(L(A))return t;const I=A.state;return I.wsize=0,I.whave=0,I.wnext=0,Y(A)},d=(A,I)=>{let g;if(L(A))return t;const B=A.state;return I<0?(g=0,I=-I):(g=5+(I>>4),I<48&&(I&=15)),I&&(I<8||I>15)?t:(null!==B.window&&B.wbits!==I&&(B.window=null),B.wrap=g,B.wbits=I,K(A))},l=(A,I)=>{if(!A)return t;const g=new M;A.state=g,g.strm=A,g.window=null,g.mode=c;const B=d(A,I);return B!==a&&(A.state=null),B};let f,u,q=!0;const p=A=>{if(q){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}),q=!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=Y,A.exports.inflateInit=A=>l(A,15),A.exports.inflateInit2=l,A.exports.inflate=(A,I)=>{let g,M,Y,K,d,l,f,u,q,m,W,Z,x,T,v,P,X,V,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(L(A)||!A.output||!A.input&&0!==A.avail_in)return t;g=A.state,g.mode===r&&(g.mode=R),d=A.next_out,Y=A.output,f=A.avail_out,K=A.next_in,M=A.input,l=A.avail_in,u=g.hold,q=g.bits,m=l,W=f,_=a;A:for(;;)switch(g.mode){case c:if(0===g.wrap){g.mode=R;break}for(;q<16;){if(0===l)break A;l--,u+=M[K++]<<q,q+=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,q=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=k;break}if((15&u)!==e){A.msg="unknown compression method",g.mode=k;break}if(u>>>=4,q-=4,z=8+(15&u),0===g.wbits&&(g.wbits=z),z>15||z>g.wbits){A.msg="invalid window size",g.mode=k;break}g.dmax=1<<g.wbits,g.flags=0,A.adler=g.check=1,g.mode=512&u?16189:r,u=0,q=0;break;case 16181:for(;q<16;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(g.flags=u,(255&g.flags)!==e){A.msg="unknown compression method",g.mode=k;break}if(57344&g.flags){A.msg="unknown header flags set",g.mode=k;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,q=0,g.mode=16182;case 16182:for(;q<32;){if(0===l)break A;l--,u+=M[K++]<<q,q+=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,q=0,g.mode=16183;case 16183:for(;q<16;){if(0===l)break A;l--,u+=M[K++]<<q,q+=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,q=0,g.mode=16184;case 16184:if(1024&g.flags){for(;q<16;){if(0===l)break A;l--,u+=M[K++]<<q,q+=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,q=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(M.subarray(K,K+Z),z)),512&g.flags&&4&g.wrap&&(g.check=Q(g.check,M,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=M[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,M,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=M[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,M,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(;q<16;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(4&g.wrap&&u!==(65535&g.check)){A.msg="header crc mismatch",g.mode=k;break}u=0,q=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(;q<32;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}A.adler=g.check=H(u),u=0,q=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=q,w;A.adler=g.check=1,g.mode=r;case r:if(I===o||I===D)break A;case R:if(g.last){u>>>=7&q,q-=7&q,g.mode=U;break}for(;q<3;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}switch(g.last=1&u,u>>>=1,q-=1,3&u){case 0:g.mode=16193;break;case 1:if(p(g),g.mode=n,I===D){u>>>=2,q-=2;break A}break;case 2:g.mode=16196;break;case 3:A.msg="invalid block type",g.mode=k}u>>>=2,q-=2;break;case 16193:for(u>>>=7&q,q-=7&q;q<32;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if((65535&u)!=(u>>>16^65535)){A.msg="invalid stored block lengths",g.mode=k;break}if(g.length=65535&u,u=0,q=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;Y.set(M.subarray(K,K+Z),d),l-=Z,K+=Z,f-=Z,d+=Z,g.length-=Z;break}g.mode=r;break;case 16196:for(;q<14;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(g.nlen=257+(31&u),u>>>=5,q-=5,g.ndist=1+(31&u),u>>>=5,q-=5,g.ncode=4+(15&u),u>>>=4,q-=4,g.nlen>286||g.ndist>30){A.msg="too many length or distance symbols",g.mode=k;break}g.have=0,g.mode=16197;case 16197:for(;g.have<g.ncode;){for(;q<3;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}g.lens[BA[g.have++]]=7&u,u>>>=3,q-=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=k;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,P=$>>>16&255,X=65535&$,!(v<=q);){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(X<16)u>>>=v,q-=v,g.lens[g.have++]=X;else{if(16===X){for(gA=v+2;q<gA;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(u>>>=v,q-=v,0===g.have){A.msg="invalid bit length repeat",g.mode=k;break}z=g.lens[g.have-1],Z=3+(3&u),u>>>=2,q-=2}else if(17===X){for(gA=v+3;q<gA;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}u>>>=v,q-=v,z=0,Z=3+(7&u),u>>>=3,q-=3}else{for(gA=v+7;q<gA;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}u>>>=v,q-=v,z=0,Z=11+(127&u),u>>>=7,q-=7}if(g.have+Z>g.nlen+g.ndist){A.msg="invalid bit length repeat",g.mode=k;break}for(;Z--;)g.lens[g.have++]=z}}if(g.mode===k)break;if(0===g.lens[256]){A.msg="invalid code -- missing end-of-block",g.mode=k;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=k;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=k;break}if(g.mode=n,I===D)break A;case n:g.mode=S;case S: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=q,C(A,W),d=A.next_out,Y=A.output,f=A.avail_out,K=A.next_in,M=A.input,l=A.avail_in,u=g.hold,q=g.bits,g.mode===r&&(g.back=-1);break}for(g.back=0;$=g.lencode[u&(1<<g.lenbits)-1],v=$>>>24,P=$>>>16&255,X=65535&$,!(v<=q);){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(P&&0==(240&P)){for(V=v,O=P,j=X;$=g.lencode[j+((u&(1<<V+O)-1)>>V)],v=$>>>24,P=$>>>16&255,X=65535&$,!(V+v<=q);){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}u>>>=V,q-=V,g.back+=V}if(u>>>=v,q-=v,g.back+=v,g.length=X,0===P){g.mode=16205;break}if(32&P){g.back=-1,g.mode=r;break}if(64&P){A.msg="invalid literal/length code",g.mode=k;break}g.extra=15&P,g.mode=16201;case 16201:if(g.extra){for(gA=g.extra;q<gA;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}g.length+=u&(1<<g.extra)-1,u>>>=g.extra,q-=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,P=$>>>16&255,X=65535&$,!(v<=q);){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(0==(240&P)){for(V=v,O=P,j=X;$=g.distcode[j+((u&(1<<V+O)-1)>>V)],v=$>>>24,P=$>>>16&255,X=65535&$,!(V+v<=q);){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}u>>>=V,q-=V,g.back+=V}if(u>>>=v,q-=v,g.back+=v,64&P){A.msg="invalid distance code",g.mode=k;break}g.offset=X,g.extra=15&P,g.mode=16203;case 16203:if(g.extra){for(gA=g.extra;q<gA;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}g.offset+=u&(1<<g.extra)-1,u>>>=g.extra,q-=g.extra,g.back+=g.extra}if(g.offset>g.dmax){A.msg="invalid distance too far back",g.mode=k;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=k;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=Y,x=d-g.offset,Z=g.length;Z>f&&(Z=f),f-=Z,g.length-=Z;do{Y[d++]=T[x++]}while(--Z);0===g.length&&(g.mode=S);break;case 16205:if(0===f)break A;Y[d++]=g.length,f--,g.mode=S;break;case U:if(g.wrap){for(;q<32;){if(0===l)break A;l--,u|=M[K++]<<q,q+=8}if(W-=f,A.total_out+=W,g.total+=W,4&g.wrap&&W&&(A.adler=g.check=g.flags?Q(g.check,Y,W,d-W):B(g.check,Y,W,d-W)),W=f,4&g.wrap&&(g.flags?u:H(u))!==g.check){A.msg="incorrect data check",g.mode=k;break}u=0,q=0}g.mode=16207;case 16207:if(g.wrap&&g.flags){for(;q<32;){if(0===l)break A;l--,u+=M[K++]<<q,q+=8}if(4&g.wrap&&u!==(4294967295&g.total)){A.msg="incorrect length check",g.mode=k;break}u=0,q=0}g.mode=16208;case 16208:_=s;break A;case k:_=h;break A;case J:return G;default:return t}return A.next_out=d,A.avail_out=f,A.next_in=K,A.avail_in=l,g.hold=u,g.bits=q,(g.wsize||W!==A.avail_out&&g.mode<k&&(g.mode<U||I!==i))&&b(A,A.output,A.next_out,W-A.avail_out)?(g.mode=J,G):(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,Y,W,A.next_out-W):B(g.check,Y,W,A.next_out-W)),A.data_type=g.bits+(g.last?64:0)+(g.mode===r?128:0)+(g.mode===n||g.mode===N?256:0),(0===m&&0===W||I===i)&&_===a&&(_=F),_)},A.exports.inflateEnd=A=>{if(L(A))return t;let I=A.state;return I.window&&(I.window=null),A.state=null,a},A.exports.inflateGetHeader=(A,I)=>{if(L(A))return t;const g=A.state;return 0==(2&g.wrap)?t:(g.head=I,I.done=!1,a)},A.exports.inflateSetDictionary=(A,I)=>{const g=I.length;let Q,C,E;return L(A)?t:(Q=A.state,0!==Q.wrap&&Q.mode!==y?t:Q.mode===y&&(C=1,C=B(C,I,g,0),C!==Q.check)?h:(E=b(A,I,g,g),E?(Q.mode=J,G):(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,w)=>{const t=w.bits;let h,G,F,e,c,y,r=0,R=0,N=0,n=0,S=0,U=0,k=0,J=0,H=0,M=0,L=null;const Y=new Uint16Array(16),K=new Uint16Array(16);let d,l,f,u=null;for(r=0;r<=I;r++)Y[r]=0;for(R=0;R<o;R++)Y[E[i+R]]++;for(S=t,n=I;n>=1&&0===Y[n];n--);if(S>n&&(S=n),0===n)return D[a++]=20971520,D[a++]=20971520,w.bits=1,0;for(N=1;N<n&&0===Y[N];N++);for(S<N&&(S=N),J=1,r=1;r<=I;r++)if(J<<=1,J-=Y[r],J<0)return-1;if(J>0&&(0===A||1!==n))return-1;for(K[1]=0,r=1;r<I;r++)K[r+1]=K[r]+Y[r];for(R=0;R<o;R++)0!==E[i+R]&&(s[K[E[i+R]]++]=R);if(0===A?(L=u=s,y=20):1===A?(L=g,u=B,y=257):(L=Q,u=C,y=0),M=0,R=0,r=N,c=a,U=S,k=0,F=-1,H=1<<S,e=H-1,1===A&&H>852||2===A&&H>592)return 1;for(;;){d=r-k,s[R]+1<y?(l=0,f=s[R]):s[R]>=y?(l=u[s[R]-y],f=L[s[R]-y]):(l=96,f=0),h=1<<r-k,G=1<<U,N=G;do{G-=h,D[c+(M>>k)+G]=d<<24|l<<16|f|0}while(0!==G);for(h=1<<r-1;M&h;)h>>=1;if(0!==h?(M&=h-1,M+=h):M=0,R++,0==--Y[r]){if(r===n)break;r=E[i+s[R]]}if(r>S&&(M&e)!==F){for(0===k&&(k=S),c+=N,U=r-k,J=1<<U;U+k<n&&(J-=Y[U+k],!(J<=0));)U++,J<<=1;if(H+=1<<U,1===A&&H>852||2===A&&H>592)return 1;F=M&e,D[F]=S<<24|U<<16|c-a|0}}return 0!==M&&(D[c+M]=r-k<<24|64<<16|0),w.bits=S,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)}}}},I={};function g(B){var Q=I[B];if(void 0!==Q)return Q.exports;var C=I[B]={exports:{}};return A[B](C,C.exports,g),C.exports}g.n=A=>{var I=A&&A.__esModule?()=>A.default:()=>A;return g.d(I,{a:I}),I},g.d=(A,I)=>{for(var B in I)g.o(I,B)&&!g.o(A,B)&&Object.defineProperty(A,B,{enumerable:!0,get:I[B]})},g.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(A){if("object"==typeof window)return window}}(),g.o=(A,I)=>Object.prototype.hasOwnProperty.call(A,I),g.r=A=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})},(()=>{var A;g.g.importScripts&&(A=g.g.location+"");var I=g.g.document;if(!A&&I&&(I.currentScript&&(A=I.currentScript.src),!A)){var B=I.getElementsByTagName("script");if(B.length)for(var Q=B.length-1;Q>-1&&!A;)A=B[Q--].src}if(!A)throw new Error("Automatic publicPath is not supported in this browser");A=A.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),g.p=A})();var B={};return(()=>{function A(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 I(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 I.set(A)}function Q(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 C(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)}}function E(A,I){const g=A.length,B=new Uint8ClampedArray(g);for(let Q=0;Q<g;++Q)B[Q]=A[Q]>>I;return B}function i(A,I,g){const B=A.columns*A.rows,Q=A.pixelData,C=A.redPaletteColorLookupTableData,i=A.greenPaletteColorLookupTableData,o=A.bluePaletteColorLookupTableData,D=A.redPaletteColorLookupTableData.length;let a=0,s=0;const w=A.redPaletteColorLookupTableDescriptor[1],t=8===A.redPaletteColorLookupTableDescriptor[2]?0:8,h=E(C,t),G=E(i,t),F=E(o,t);if(g)for(let A=0;A<B;++A){let A=Q[a++];A<w?A=0:A>w+D-1?A=D-1:A-=w,I[s++]=h[A],I[s++]=G[A],I[s++]=F[A],I[s++]=255}else for(let A=0;A<B;++A){let A=Q[a++];A<w?A=0:A>w+D-1?A=D-1:A-=w,I[s++]=h[A],I[s++]=G[A],I[s++]=F[A]}}function o(A,I){if(A.elements[I]&&6===A.elements[I].length)return[A.uint16(I,0),A.uint16(I,1),A.uint16(I,2)]}function D(A,I,g){const B=[],Q=A.elements[I];for(let C=0;C<g[0];C++)16===g[2]?B[C]=A.uint16(I,C):B[C]=A.byteArray[C+Q.dataOffset];return B}g.r(B),g.d(B,{configure:()=>BI,convertColorSpace:()=>v,convertPALETTECOLOR:()=>i,convertRGBColorByPixel:()=>A,convertRGBColorByPlane:()=>I,convertYBRFullByPixel:()=>Q,convertYBRFullByPlane:()=>C,createImage:()=>cA,decodeImageFrame:()=>sA,decodeJPEGBaseline8BitColor:()=>X,default:()=>QI,external:()=>UA,getImageFrame:()=>wA,getMinMax:()=>x,getPixelData:()=>Z,internal:()=>m,isColorImage:()=>tA,isJPEGBaseline8BitColor:()=>hA,wadors:()=>rA,wadouri:()=>gI,webWorkerManager:()=>oA});const a=function(A){const I={samplesPerPixel:A.uint16("x00280002"),photometricInterpretation:A.string("x00280004"),rows:A.uint16("x00280010"),columns:A.uint16("x00280011"),bitsAllocated:A.uint16("x00280100"),bitsStored:A.uint16("x00280101"),highBit:A.uint16("x00280102"),pixelRepresentation:A.uint16("x00280103"),planarConfiguration:A.uint16("x00280006"),pixelAspectRatio:A.string("x00280034")};return function(A,I){0===A.uint16("x00280103")?(I.smallestPixelValue=A.uint16("x00280106"),I.largestPixelValue=A.uint16("x00280107")):(I.smallestPixelValue=A.int16("x00280106"),I.largestPixelValue=A.int16("x00280107"))}(A,I),"PALETTE COLOR"===I.photometricInterpretation&&A.elements.x00281101&&function(A,I){I.redPaletteColorLookupTableDescriptor=o(A,"x00281101"),I.greenPaletteColorLookupTableDescriptor=o(A,"x00281102"),I.bluePaletteColorLookupTableDescriptor=o(A,"x00281103"),0===I.redPaletteColorLookupTableDescriptor[0]&&(I.redPaletteColorLookupTableDescriptor[0]=65536,I.greenPaletteColorLookupTableDescriptor[0]=65536,I.bluePaletteColorLookupTableDescriptor[0]=65536);const g=I.redPaletteColorLookupTableDescriptor[0],B=A.elements.x00281201.length===g?8:16;I.redPaletteColorLookupTableDescriptor[2]!==B&&(I.redPaletteColorLookupTableDescriptor[2]=B,I.greenPaletteColorLookupTableDescriptor[2]=B,I.bluePaletteColorLookupTableDescriptor[2]=B),I.redPaletteColorLookupTableData=D(A,"x00281201",I.redPaletteColorLookupTableDescriptor),I.greenPaletteColorLookupTableData=D(A,"x00281202",I.greenPaletteColorLookupTableDescriptor),I.bluePaletteColorLookupTableData=D(A,"x00281203",I.bluePaletteColorLookupTableDescriptor)}(A,I),I};function s(A,I){let g=I.uint16("x00283002",0);0===g&&(g=65535);let B=0;B=0===A?I.uint16("x00283002",1):I.int16("x00283002",1);const Q={id:"1",firstValueMapped:B,numBitsPerEntry:I.uint16("x00283002",2),lut:[]};for(let B=0;B<g;B++)Q.lut[B]=0===A?I.uint16("x00283006",B):I.int16("x00283006",B);return Q}const w=function(A,I){if(!I||!I.items||!I.items.length)return;const g=[];for(let B=0;B<I.items.length;B++){const Q=s(A,I.items[B].dataSet);Q&&g.push(Q)}return g};const t=function(A){const I=A.string("x00080016");if("1.2.840.10008.5.1.4.1.1.2"===I||"1.2.840.10008.5.1.4.1.1.2.1"===I)return 1;const g=A.floatString("x00281052"),B=A.floatString("x00281053");if(void 0!==g&&void 0!==B){const I=function(A){const I=A.uint16("x00280103"),g=A.uint16("x00280101");return 0===I?0:-1<<g-1}(A);return I*B+g<0?1:0}return A.elements.x00283000&&A.elements.x00283000.length>0?0:A.uint16("x00280103")};const h=function(A,I,g){const B=[],Q=A.string(I);if(!Q)return;const C=Q.split("\\");if(!(g&&C.length<g)){for(let A=0;A<C.length;A++)B.push(parseFloat(C[A]));return B}};const G=function(A,I,g){return I=I||0,A&&A.Value?A.Value.length<=I?g:A.Value[I]:g};const F=function(A,I,g){const B=G(A,I,g);if(void 0!==B)return parseFloat(B)};const e=function(A,I){const g=G(A,I);if(void 0!==g)return parseFloat(g)};const c=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 y(A){const I=A.indexOf(":");return A.substring(I+1)}function r(A){let I=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return A&&A.Value?A.Value[0]&&I?A.Value[0]:A.Value:A}function R(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 N(A){let{52009230:I,52009229:g,"00280008":B,...Q}=A;return I=r(I,!1),g=r(g,!1),B=r(B),{PerFrameFunctionalGroupsSequence:I,SharedFunctionalGroupsSequence:g,NumberOfFrames:B,rest:Q}}function n(A){const I=A.indexOf("/frames/")+8,g=A.slice(0,I),B=parseInt(A.slice(I),10);return{metadata:U[`${g}1`],frame:B}}const S={_retrieveMultiframeMetadata:n,retrieveMultiframeMetadata:function(A){return n(y(A))},isMultiframe:function(A){const I=G(A["00280008"]);return I&&I>1}};let U=[],k={};const J={add:function(A,I){const g=y(A);I.isMultiframe=S.isMultiframe(I),U[g]=I},get:function(A){const I=y(A),g=U[I];if(g&&!g?.isMultiframe)return g;const B=k[I];if(B)return B;const Q=S._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}=N(I);if(g||Q>1){const{shared:E,perFrame:i}=R(g,B,A),o=Object.assign(I,{frameNumber:A});return[...E,...i].forEach((A=>{Object.entries(A).forEach((A=>{let[I,g]=A;o[I]=g}))})),Object.assign(C,{"00280008":Q},o)}return I}(E,C);return k[I]=A,A}},remove:function(A){const I=y(A);U[I]=void 0,k[I]=void 0},purge:function(){U=[],k={}}};function H(A){return"RECON TOMO"===A||"RECON GATED TOMO"===A}function M(A){return G(A["00080060"]).includes("NM")}function L(A,I){const g=r(A["00080008"],!1);if(g)return g[I]}function Y(A){let I=c(A["00200037"],6);return!I&&M(A)&&(I=function(A){let I;const g=L(A,2);if(g&&H(g)){const g=r(A["00540022"]);g&&(I=c(g["00200037"],6))}return I}(A)),I}function K(A){let I=c(A["00200032"],3);return!I&&M(A)&&(I=function(A){let I;const g=L(A,2);if(g&&H(g)){const g=r(A["00540022"]);g&&(I=c(g["00200032"],3))}return I}(A)),I}const d=function(A,I){if("multiframeModule"===A){const{metadata:A,frame:g}=S.retrieveMultiframeMetadata(I);if(!A)return;const{PerFrameFunctionalGroupsSequence:B,SharedFunctionalGroupsSequence:Q,NumberOfFrames:C}=N(A);if(B||C>1){const{shared:A,perFrame:I}=R(B,Q,g);return{NumberOfFrames:C,PerFrameFunctionalInformation:I,SharedFunctionalInformation:A}}return{NumberOfFrames:C}}const{dicomParser:g}=UA,B=J.get(I);if(B){if("generalSeriesModule"===A)return{modality:G(B["00080060"]),seriesInstanceUID:G(B["0020000E"]),seriesNumber:e(B["00200011"]),studyInstanceUID:G(B["0020000D"]),seriesDate:g.parseDA(G(B["00080021"])),seriesTime:g.parseTM(G(B["00080031"],0,"")),acquisitionDate:g.parseDA(G(B["00080022"]),""),acquisitionTime:g.parseTM(G(B["00080032"],0,""))};if("patientStudyModule"===A)return{patientAge:e(B["00101010"]),patientSize:e(B["00101020"]),patientSex:G(B["00100040"]),patientWeight:e(B["00101030"])};if("nmMultiframeGeometryModule"===A){const A=G(B["00080060"]),I=L(B,2);return{modality:A,imageType:G(B["00080008"]),imageSubType:I,imageOrientationPatient:Y(B),imagePositionPatient:K(B),sliceThickness:e(B["00180050"]),pixelSpacing:c(B["00280030"],2),numberOfFrames:e(B["00280008"]),isNMReconstructable:H(I)&&A.includes("NM")}}if("imagePlaneModule"===A){const A=Y(B),I=K(B),g=c(B["00280030"],2);let Q=null,C=null;g&&(C=g[0],Q=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:G(B["00200052"]),rows:e(B["00280010"]),columns:e(B["00280011"]),imageOrientationPatient:A,rowCosines:E,columnCosines:i,imagePositionPatient:I,sliceThickness:e(B["00180050"]),sliceLocation:e(B["00201041"]),pixelSpacing:g,rowPixelSpacing:C,columnPixelSpacing:Q}}if("imagePixelModule"===A)return{samplesPerPixel:e(B["00280002"]),photometricInterpretation:G(B["00280004"]),rows:e(B["00280010"]),columns:e(B["00280011"]),bitsAllocated:e(B["00280100"]),bitsStored:e(B["00280101"]),highBit:G(B["00280102"]),pixelRepresentation:e(B["00280103"]),planarConfiguration:e(B["00280006"]),pixelAspectRatio:G(B["00280034"]),smallestPixelValue:e(B["00280106"]),largestPixelValue:e(B["00280107"]),redPaletteColorLookupTableDescriptor:c(B["00281101"]),greenPaletteColorLookupTableDescriptor:c(B["00281102"]),bluePaletteColorLookupTableDescriptor:c(B["00281103"]),redPaletteColorLookupTableData:c(B["00281201"]),greenPaletteColorLookupTableData:c(B["00281202"]),bluePaletteColorLookupTableData:c(B["00281203"])};if("voiLutModule"===A)return{windowCenter:c(B["00281050"],1),windowWidth:c(B["00281051"],1)};if("modalityLutModule"===A)return{rescaleIntercept:e(B["00281052"]),rescaleSlope:e(B["00281053"]),rescaleType:G(B["00281054"])};if("sopCommonModule"===A)return{sopClassUID:G(B["00080016"]),sopInstanceUID:G(B["00080018"])};if("petIsotopeModule"===A){const A=G(B["00540016"]);if(void 0===A)return;return{radiopharmaceuticalInfo:{radiopharmaceuticalStartTime:g.parseTM(G(A["00181072"],0,"")),radiopharmaceuticalStartDateTime:G(A["00181078"],0,""),radionuclideTotalDose:e(A["00181074"]),radionuclideHalfLife:e(A["00181075"])}}}return"overlayPlaneModule"===A?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=G(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:e(A[`${B}0010`]),columns:e(A[`${B}0011`]),type:G(A[`${B}0040`]),x:e(A[`${B}0050`],1)-1,y:e(A[`${B}0050`],0)-1,pixelData:C,description:G(A[`${B}0022`]),label:G(A[`${B}1500`]),roiArea:G(A[`${B}1301`]),roiMean:G(A[`${B}1302`]),roiStandardDeviation:G(A[`${B}1303`])})}return{overlays:I}}(B):"transferSyntax"===A?{transferSyntaxUID:G(B["00020010"])}:"petSeriesModule"===A?{correctedImage:G(B["00280051"]),units:G(B["00541001"]),decayCorrection:G(B["00541102"])}:"petImageModule"===A?{frameReferenceTime:e(B["00541300"]),actualFrameDuration:e(B["00181242"])}: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 q(A){u=Object.assign(u,A)}function p(){return u}const b=function(A,I){let g=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},B=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const{cornerstone:Q}=UA,C=p(),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?C.beforeProcessing(i).then(o).catch((()=>{E(i),D(i)})):(E(i),D(i)))},i.onprogress=function(g){const E=g.loaded;let i,o;g.lengthComputable&&(i=g.total,o=Math.round(E/i*100)),C.onprogress&&C.onprogress(g,B);const D={url:A,imageId:I,loaded:E,total:i,percentComplete:o};Q.triggerEvent(Q.events,Q.EVENTS.IMAGE_LOAD_PROGRESS,D)},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:q,getOptions:p};function W(A){for(let I=0;I<A.length;I++)if("Content-Type:"===A[I].substr(0,13))return A[I].substr(13).trim()}const Z=function(A,I){const g={Accept:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/octet-stream"};return new Promise(((B,Q)=>{const C=b(A,I,g),{xhr:E}=C;C.then((function(A){const I=new Uint8Array(A),g=E.getResponseHeader("Content-Type")||"application/octet-stream";if(-1===g.indexOf("multipart"))return void B({contentType:g,imageFrame:{pixelData:I}});const C=f(I,"\r\n\r\n");-1===C&&Q(new Error("invalid response - no multipart mime header"));const i=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}(I,0,C),o=i.split("\r\n"),D=function(A){for(let I=0;I<A.length;I++)if("--"===A[I].substr(0,2))return A[I]}(o);D||Q(new Error("invalid response - no boundary marker"));const a=C+4,s=f(I,D,a);-1===s&&Q(new Error("invalid response - terminating boundary not found"));const w=s-a-2;B({contentType:W(o),imageFrame:{pixelData:new Uint8Array(A,a,w)}})}),Q)}))};const x=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 T(g,B,Q){0===g.planarConfiguration?A(g.pixelData,B,Q):I(g.pixelData,B,Q)}function v(A,I,g){if("RGB"===A.photometricInterpretation)T(A,I,g);else if("YBR_RCT"===A.photometricInterpretation)T(A,I,g);else if("YBR_ICT"===A.photometricInterpretation)T(A,I,g);else if("PALETTE COLOR"===A.photometricInterpretation)i(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 3");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?Q(A.pixelData,I,g):C(A.pixelData,I,g)}(A,I,g)}}function P(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 X=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=x(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(P(E.result))}`:Q.src=`data:image/jpeg;base64,${window.btoa(E.result)}`},E.onerror=A=>{C(A)}}))};var V=g(465),O=g.n(V);function j(){return O()('(()=>{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 t,c=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&&(t=C.wasmBinary);var N;C.noExitRuntime;"object"!=typeof WebAssembly&&Z("no native wasm support detected");var R,U,S,r,k,J,e,n,H,M=!1,Y="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&&Y)return Y.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}(S,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,S,I,g)}function d(A){R=A,C.HEAP8=U=new Int8Array(A),C.HEAP16=r=new Int16Array(A),C.HEAP32=J=new Int32Array(A),C.HEAPU8=S=new Uint8Array(A),C.HEAPU16=k=new Uint16Array(A),C.HEAPU32=e=new Uint32Array(A),C.HEAPF32=n=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),c(A="Aborted("+A+")"),M=!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&&t)return new Uint8Array(t);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){e[this.ptr+4>>2]=A},this.get_type=function(){return e[this.ptr+4>>2]},this.set_destructor=function(A){e[this.ptr+8>>2]=A},this.get_destructor=function(){return e[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.ptr>>2];J[this.ptr>>2]=A+1},this.release_ref=function(){var A=J[this.ptr>>2];return J[this.ptr>>2]=A-1,1===A},this.set_adjusted_ptr=function(A){e[this.ptr+16>>2]=A},this.get_adjusted_ptr=function(){return e[this.ptr+16>>2]},this.get_exception_ptr=function(){if(qI(this.get_type()))return e[this.excPtr>>2];var A=this.get_adjusted_ptr();return 0!==A?A:this.excPtr}}X(m="charlswasm_decode.wasm")||(x=m,m=C.locateFile?C.locateFile(x,F):F+x);var z={};function $(A){for(;A.length;){var I=A.pop();A.pop()(I)}}function _(A){return this.fromWireType(J[A>>2])}var AA={},IA={},gA={},BA=48,QA=57;function CA(A){if(void 0===A)return"_unknown";var I=(A=A.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return I>=BA&&I<=QA?"_"+A:A}function EA(A,I){return A=CA(A),new Function("body","return function "+A+\'() {\\n "use strict"; return body.apply(this, arguments);\\n};\\n\')(I)}function iA(A,I){var g=EA(I,(function(A){this.name=I,this.message=A;var g=new Error(A).stack;void 0!==g&&(this.stack=this.toString()+"\\n"+g.replace(/^Error(:[^\\n]*)?\\n/,""))}));return g.prototype=Object.create(A.prototype),g.prototype.constructor=g,g.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},g}var oA=void 0;function DA(A){throw new oA(A)}function wA(A,I,g){function B(I){var B=g(I);B.length!==A.length&&DA("Mismatched type converter count");for(var Q=0;Q<A.length;++Q)yA(A[Q],B[Q])}A.forEach((function(A){gA[A]=I}));var Q=new Array(I.length),C=[],E=0;I.forEach(((A,I)=>{IA.hasOwnProperty(A)?Q[I]=IA[A]:(C.push(A),AA.hasOwnProperty(A)||(AA[A]=[]),AA[A].push((()=>{Q[I]=IA[A],++E===C.length&&B(Q)})))})),0===C.length&&B(Q)}function sA(A){switch(A){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+A)}}var aA=void 0;function GA(A){for(var I="",g=A;S[g];)I+=aA[S[g++]];return I}var FA=void 0;function hA(A){throw new FA(A)}function yA(A,I,g={}){if(!("argPackAdvance"in I))throw new TypeError("registerType registeredInstance requires argPackAdvance");var B=I.name;if(A||hA(\'type "\'+B+\'" must have a positive integer typeid pointer\'),IA.hasOwnProperty(A)){if(g.ignoreDuplicateRegistrations)return;hA("Cannot register type \'"+B+"\' twice")}if(IA[A]=I,delete gA[A],AA.hasOwnProperty(A)){var Q=AA[A];delete AA[A],Q.forEach((A=>A()))}}function tA(A){if(!(this instanceof uA))return!1;if(!(A instanceof uA))return!1;for(var I=this.$$.ptrType.registeredClass,g=this.$$.ptr,B=A.$$.ptrType.registeredClass,Q=A.$$.ptr;I.baseClass;)g=I.upcast(g),I=I.baseClass;for(;B.baseClass;)Q=B.upcast(Q),B=B.baseClass;return I===B&&g===Q}function cA(A){hA(A.$$.ptrType.registeredClass.name+" instance already deleted")}var NA=!1;function RA(A){}function UA(A){A.count.value-=1,0===A.count.value&&function(A){A.smartPtr?A.smartPtrType.rawDestructor(A.smartPtr):A.ptrType.registeredClass.rawDestructor(A.ptr)}(A)}function SA(A,I,g){if(I===g)return A;if(void 0===g.baseClass)return null;var B=SA(A,I,g.baseClass);return null===B?null:g.downcast(B)}var rA={};function kA(){return Object.keys(YA).length}function JA(){var A=[];for(var I in YA)YA.hasOwnProperty(I)&&A.push(YA[I]);return A}var eA=[];function nA(){for(;eA.length;){var A=eA.pop();A.$$.deleteScheduled=!1,A.delete()}}var HA=void 0;function MA(A){HA=A,eA.length&&HA&&HA(nA)}var YA={};function LA(A,I){return I=function(A,I){for(void 0===I&&hA("ptr should not be undefined");A.baseClass;)I=A.upcast(I),A=A.baseClass;return I}(A,I),YA[I]}function KA(A,I){return I.ptrType&&I.ptr||DA("makeClassHandle requires ptr and ptrType"),!!I.smartPtrType!=!!I.smartPtr&&DA("Both smartPtrType and smartPtr must be specified"),I.count={value:1},lA(Object.create(A,{$$:{value:I}}))}function dA(A){var I=this.getPointee(A);if(!I)return this.destructor(A),null;var g=LA(this.registeredClass,I);if(void 0!==g){if(0===g.$$.count.value)return g.$$.ptr=I,g.$$.smartPtr=A,g.clone();var B=g.clone();return this.destructor(A),B}function Q(){return this.isSmartPointer?KA(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:I,smartPtrType:t