@cornerstonejs/nifti-volume-loader 2.1.10 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -4
- package/dist/umd/index.js +0 -2
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/nifti-volume-loader",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "Nifti Image Loader for Cornerstone3D",
|
|
5
|
-
"main": "./dist/umd/index.js",
|
|
6
5
|
"module": "./dist/esm/index.js",
|
|
7
6
|
"types": "./dist/esm/index.d.ts",
|
|
8
7
|
"repository": "https://github.com/cornerstonejs/cornerstone3D",
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
"nifti-reader-js": "^0.6.8"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"@cornerstonejs/core": "^2.1.
|
|
65
|
+
"@cornerstonejs/core": "^2.1.11"
|
|
67
66
|
},
|
|
68
67
|
"contributors": [
|
|
69
68
|
{
|
|
@@ -76,5 +75,5 @@
|
|
|
76
75
|
"type": "individual",
|
|
77
76
|
"url": "https://ohif.org/donate"
|
|
78
77
|
},
|
|
79
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "ee9c95b4cb88c5c1517c0a39ad76480a25726789"
|
|
80
79
|
}
|
package/dist/umd/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@cornerstonejs/core"),require("gl-matrix")):"function"==typeof define&&define.amd?define(["@cornerstonejs/core","gl-matrix"],e):"object"==typeof exports?exports.cornerstoneNiftiVolumeLoader=e(require("@cornerstonejs/core"),require("gl-matrix")):t.cornerstoneNiftiVolumeLoader=e(t.cornerstone3D,t.window)}(self,((t,e)=>(()=>{"use strict";var i={237:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NIFTIEXTENSION=void 0,e.NIFTIEXTENSION=class{esize;ecode;edata;littleEndian;constructor(t,e,i,n){if(t%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=t,this.ecode=e,this.edata=i,this.littleEndian=n}toArrayBuffer(){let t=new Uint8Array(this.esize),e=new Uint8Array(this.edata);t.set(e,8);let i=new DataView(t.buffer);return i.setInt32(0,this.esize,this.littleEndian),i.setInt32(4,this.ecode,this.littleEndian),t.buffer}}},130:function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(e,i);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,s)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),s=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&n(e,t,i);return s(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.readExtensionData=e.readExtension=e.readImage=e.hasExtension=e.readHeader=e.decompress=e.isCompressed=e.isNIFTI=e.isNIFTI2=e.isNIFTI1=e.NIFTIEXTENSION=e.Utils=e.NIFTI2=e.NIFTI1=void 0;const a=r(i(876)),o=i(232),l=i(103),h=i(517);var f=i(232);Object.defineProperty(e,"NIFTI1",{enumerable:!0,get:function(){return f.NIFTI1}});var c=i(103);Object.defineProperty(e,"NIFTI2",{enumerable:!0,get:function(){return c.NIFTI2}});var u=i(517);Object.defineProperty(e,"Utils",{enumerable:!0,get:function(){return u.Utils}});var d=i(237);function p(t,e=!1){var i,n,s,r;return!(t.byteLength<o.NIFTI1.STANDARD_HEADER_SIZE||((i=new DataView(t))&&(n=i.getUint8(o.NIFTI1.MAGIC_NUMBER_LOCATION)),s=i.getUint8(o.NIFTI1.MAGIC_NUMBER_LOCATION+1),r=i.getUint8(o.NIFTI1.MAGIC_NUMBER_LOCATION+2),!(e&&n===o.NIFTI1.MAGIC_NUMBER2[0]&&s===o.NIFTI1.MAGIC_NUMBER2[1]&&r===o.NIFTI1.MAGIC_NUMBER2[2]||n===o.NIFTI1.MAGIC_NUMBER[0]&&s===o.NIFTI1.MAGIC_NUMBER[1]&&r===o.NIFTI1.MAGIC_NUMBER[2])))}function g(t,e=!1){var i,n,s,r;return!(t.byteLength<o.NIFTI1.STANDARD_HEADER_SIZE||(n=(i=new DataView(t)).getUint8(l.NIFTI2.MAGIC_NUMBER_LOCATION),s=i.getUint8(l.NIFTI2.MAGIC_NUMBER_LOCATION+1),r=i.getUint8(l.NIFTI2.MAGIC_NUMBER_LOCATION+2),!(e&&n===l.NIFTI2.MAGIC_NUMBER2[0]&&s===l.NIFTI2.MAGIC_NUMBER2[1]&&r===l.NIFTI2.MAGIC_NUMBER2[2]||n===l.NIFTI2.MAGIC_NUMBER[0]&&s===l.NIFTI2.MAGIC_NUMBER[1]&&r===l.NIFTI2.MAGIC_NUMBER[2])))}function m(t){var e,i,n;if(t){if(i=(e=new DataView(t)).getUint8(0),n=e.getUint8(1),i===h.Utils.GUNZIP_MAGIC_COOKIE1)return!0;if(n===h.Utils.GUNZIP_MAGIC_COOKIE2)return!0}return!1}function _(t){return a.decompressSync(new Uint8Array(t)).buffer}Object.defineProperty(e,"NIFTIEXTENSION",{enumerable:!0,get:function(){return d.NIFTIEXTENSION}}),e.isNIFTI1=p,e.isNIFTI2=g,e.isNIFTI=function(t,e=!1){return p(t,e)||g(t,e)},e.isCompressed=m,e.decompress=_,e.readHeader=function(t,e=!1){var i=null;return m(t)&&(t=_(t)),p(t,e)?i=new o.NIFTI1:g(t,e)&&(i=new l.NIFTI2),i?i.readHeader(t):console.error("That file does not appear to be NIFTI!"),i},e.hasExtension=function(t){return 0!=t.extensionFlag[0]},e.readImage=function(t,e){var i=t.vox_offset,n=1,s=1;t.dims[4]&&(n=t.dims[4]),t.dims[5]&&(s=t.dims[5]);var r=t.dims[1]*t.dims[2]*t.dims[3]*n*s*(t.numBitsPerVoxel/8);return e.slice(i,i+r)},e.readExtension=function(t,e){var i=t.getExtensionLocation(),n=t.extensionSize;return e.slice(i,i+n)},e.readExtensionData=function(t,e){var i=t.getExtensionLocation(),n=t.extensionSize;return e.slice(i+8,i+n)}},232:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NIFTI1=void 0;const n=i(517);class s{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic="0";isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var e,i,r,a,o=new DataView(t),l=n.Utils.getIntAt(o,0,this.littleEndian);if(l!==s.MAGIC_COOKIE&&(this.littleEndian=!0,l=n.Utils.getIntAt(o,0,this.littleEndian)),l!==s.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=n.Utils.getByteAt(o,39),e=0;e<8;e+=1)a=40+2*e,this.dims[e]=n.Utils.getShortAt(o,a,this.littleEndian);for(this.intent_p1=n.Utils.getFloatAt(o,56,this.littleEndian),this.intent_p2=n.Utils.getFloatAt(o,60,this.littleEndian),this.intent_p3=n.Utils.getFloatAt(o,64,this.littleEndian),this.intent_code=n.Utils.getShortAt(o,68,this.littleEndian),this.datatypeCode=n.Utils.getShortAt(o,70,this.littleEndian),this.numBitsPerVoxel=n.Utils.getShortAt(o,72,this.littleEndian),this.slice_start=n.Utils.getShortAt(o,74,this.littleEndian),e=0;e<8;e+=1)a=76+4*e,this.pixDims[e]=n.Utils.getFloatAt(o,a,this.littleEndian);if(this.vox_offset=n.Utils.getFloatAt(o,108,this.littleEndian),this.scl_slope=n.Utils.getFloatAt(o,112,this.littleEndian),this.scl_inter=n.Utils.getFloatAt(o,116,this.littleEndian),this.slice_end=n.Utils.getShortAt(o,120,this.littleEndian),this.slice_code=n.Utils.getByteAt(o,122),this.xyzt_units=n.Utils.getByteAt(o,123),this.cal_max=n.Utils.getFloatAt(o,124,this.littleEndian),this.cal_min=n.Utils.getFloatAt(o,128,this.littleEndian),this.slice_duration=n.Utils.getFloatAt(o,132,this.littleEndian),this.toffset=n.Utils.getFloatAt(o,136,this.littleEndian),this.description=n.Utils.getStringAt(o,148,228),this.aux_file=n.Utils.getStringAt(o,228,252),this.qform_code=n.Utils.getShortAt(o,252,this.littleEndian),this.sform_code=n.Utils.getShortAt(o,254,this.littleEndian),this.quatern_b=n.Utils.getFloatAt(o,256,this.littleEndian),this.quatern_c=n.Utils.getFloatAt(o,260,this.littleEndian),this.quatern_d=n.Utils.getFloatAt(o,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(Math.pow(this.quatern_b,2)+Math.pow(this.quatern_c,2)+Math.pow(this.quatern_d,2))),this.qoffset_x=n.Utils.getFloatAt(o,268,this.littleEndian),this.qoffset_y=n.Utils.getFloatAt(o,272,this.littleEndian),this.qoffset_z=n.Utils.getFloatAt(o,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){const t=this.quatern_a,e=this.quatern_b,n=this.quatern_c,s=this.quatern_d;for(this.qfac=0===this.pixDims[0]?1:this.pixDims[0],this.quatern_R=[[t*t+e*e-n*n-s*s,2*e*n-2*t*s,2*e*s+2*t*n],[2*e*n+2*t*s,t*t+n*n-e*e-s*s,2*n*s-2*t*e],[2*e*s-2*t*n,2*n*s+2*t*e,t*t+s*s-n*n-e*e]],i=0;i<3;i+=1)for(r=0;r<3;r+=1)this.affine[i][r]=this.quatern_R[i][r]*this.pixDims[r+1],2===r&&(this.affine[i][r]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(i=0;i<3;i+=1)for(r=0;r<4;r+=1)a=280+4*(4*i+r),this.affine[i][r]=n.Utils.getFloatAt(o,a,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=n.Utils.getStringAt(o,328,344),this.magic=n.Utils.getStringAt(o,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,s.MAGIC_NUMBER2),o.byteLength>s.MAGIC_COOKIE){this.extensionFlag[0]=n.Utils.getByteAt(o,348),this.extensionFlag[1]=n.Utils.getByteAt(o,349),this.extensionFlag[2]=n.Utils.getByteAt(o,350),this.extensionFlag[3]=n.Utils.getByteAt(o,351);let t=!0;!this.isHDR&&this.vox_offset<=352&&(t=!1),o.byteLength<=368&&(t=!1),t&&this.extensionFlag[0]&&(this.extensions=n.Utils.getExtensionsAt(o,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=n.Utils.formatNumber,e="";return e+="Dim Info = "+this.dim_info+"\n",e+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+"\n",e+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+"\n",e+="Intent Code = "+this.intent_code+"\n",e+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+")\n",e+="Bits Per Voxel = "+this.numBitsPerVoxel+"\n",e+="Slice Start = "+this.slice_start+"\n",e+="Voxel Dimensions (1-8): "+t(this.pixDims[0])+", "+t(this.pixDims[1])+", "+t(this.pixDims[2])+", "+t(this.pixDims[3])+", "+t(this.pixDims[4])+", "+t(this.pixDims[5])+", "+t(this.pixDims[6])+", "+t(this.pixDims[7])+"\n",e+="Image Offset = "+this.vox_offset+"\n",e+="Data Scale: Slope = "+t(this.scl_slope)+" Intercept = "+t(this.scl_inter)+"\n",e+="Slice End = "+this.slice_end+"\n",e+="Slice Code = "+this.slice_code+"\n",e+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(s.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(s.TEMPORAL_UNITS_MASK&this.xyzt_units)+")\n",e+="Display Range: Max = "+t(this.cal_max)+" Min = "+t(this.cal_min)+"\n",e+="Slice Duration = "+this.slice_duration+"\n",e+="Time Axis Shift = "+this.toffset+"\n",e+='Description: "'+this.description+'"\n',e+='Auxiliary File: "'+this.aux_file+'"\n',e+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+")\n",e+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+")\n",e+="Quaternion Parameters: b = "+t(this.quatern_b)+" c = "+t(this.quatern_c)+" d = "+t(this.quatern_d)+"\n",e+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+"\n",e+="S-Form Parameters X: "+t(this.affine[0][0])+", "+t(this.affine[0][1])+", "+t(this.affine[0][2])+", "+t(this.affine[0][3])+"\n",e+="S-Form Parameters Y: "+t(this.affine[1][0])+", "+t(this.affine[1][1])+", "+t(this.affine[1][2])+", "+t(this.affine[1][3])+"\n",e+="S-Form Parameters Z: "+t(this.affine[2][0])+", "+t(this.affine[2][1])+", "+t(this.affine[2][2])+", "+t(this.affine[2][3])+"\n",e+='Intent Name: "'+this.intent_name+'"\n',this.extensionFlag[0]&&(e+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+"\n"),e}getDatatypeCodeString=function(t){return t===s.TYPE_UINT8?"1-Byte Unsigned Integer":t===s.TYPE_INT16?"2-Byte Signed Integer":t===s.TYPE_INT32?"4-Byte Signed Integer":t===s.TYPE_FLOAT32?"4-Byte Float":t===s.TYPE_FLOAT64?"8-Byte Float":t===s.TYPE_RGB24?"RGB":t===s.TYPE_INT8?"1-Byte Signed Integer":t===s.TYPE_UINT16?"2-Byte Unsigned Integer":t===s.TYPE_UINT32?"4-Byte Unsigned Integer":t===s.TYPE_INT64?"8-Byte Signed Integer":t===s.TYPE_UINT64?"8-Byte Unsigned Integer":"Unknown"};getTransformCodeString=function(t){return t===s.XFORM_SCANNER_ANAT?"Scanner":t===s.XFORM_ALIGNED_ANAT?"Aligned":t===s.XFORM_TALAIRACH?"Talairach":t===s.XFORM_MNI_152?"MNI":"Unknown"};getUnitsCodeString=function(t){return t===s.UNITS_METER?"Meters":t===s.UNITS_MM?"Millimeters":t===s.UNITS_MICRON?"Microns":t===s.UNITS_SEC?"Seconds":t===s.UNITS_MSEC?"Milliseconds":t===s.UNITS_USEC?"Microseconds":t===s.UNITS_HZ?"Hz":t===s.UNITS_PPM?"PPM":t===s.UNITS_RADS?"Rads":"Unknown"};getQformMat(){return this.convertNiftiQFormToNiftiSForm(this.quatern_b,this.quatern_c,this.quatern_d,this.qoffset_x,this.qoffset_y,this.qoffset_z,this.pixDims[1],this.pixDims[2],this.pixDims[3],this.pixDims[0])}convertNiftiQFormToNiftiSForm(t,e,i,n,s,r,a,o,l,h){var f,c,u,d,p=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],g=t,m=e,_=i;return p[3][0]=p[3][1]=p[3][2]=0,p[3][3]=1,(f=1-(g*g+m*m+_*_))<1e-7?(g*=f=1/Math.sqrt(g*g+m*m+_*_),m*=f,_*=f,f=0):f=Math.sqrt(f),c=a>0?a:1,u=o>0?o:1,d=l>0?l:1,h<0&&(d=-d),p[0][0]=(f*f+g*g-m*m-_*_)*c,p[0][1]=2*(g*m-f*_)*u,p[0][2]=2*(g*_+f*m)*d,p[1][0]=2*(g*m+f*_)*c,p[1][1]=(f*f+m*m-g*g-_*_)*u,p[1][2]=2*(m*_-f*g)*d,p[2][0]=2*(g*_-f*m)*c,p[2][1]=2*(m*_+f*g)*u,p[2][2]=(f*f+_*_-m*m-g*g)*d,p[0][3]=n,p[1][3]=s,p[2][3]=r,p}convertNiftiSFormToNEMA(t){var e,i,n,s,r,a,o,l,h,f,c,u,d,p,g,m,_,v,I,E,y,A,T,x,N,U,b,F,w,S,M,C,D;if(p=0,U=[[0,0,0],[0,0,0],[0,0,0]],b=[[0,0,0],[0,0,0],[0,0,0]],e=t[0][0],i=t[0][1],n=t[0][2],s=t[1][0],r=t[1][1],a=t[1][2],o=t[2][0],l=t[2][1],h=t[2][2],0===(f=Math.sqrt(e*e+s*s+o*o)))return null;if(e/=f,s/=f,o/=f,0===(f=Math.sqrt(i*i+r*r+l*l)))return null;if(f=e*(i/=f)+s*(r/=f)+o*(l/=f),Math.abs(f)>1e-4){if(i-=f*e,r-=f*s,l-=f*o,0===(f=Math.sqrt(i*i+r*r+l*l)))return null;i/=f,r/=f,l/=f}if(0===(f=Math.sqrt(n*n+a*a+h*h))?(n=s*l-o*r,a=o*i-l*e,h=e*r-s*i):(n/=f,a/=f,h/=f),f=e*n+s*a+o*h,Math.abs(f)>1e-4){if(n-=f*e,a-=f*s,h-=f*o,0===(f=Math.sqrt(n*n+a*a+h*h)))return null;n/=f,a/=f,h/=f}if(f=i*n+r*a+l*h,Math.abs(f)>1e-4){if(n-=f*i,a-=f*r,h-=f*l,0===(f=Math.sqrt(n*n+a*a+h*h)))return null;n/=f,a/=f,h/=f}if(U[0][0]=e,U[0][1]=i,U[0][2]=n,U[1][0]=s,U[1][1]=r,U[1][2]=a,U[2][0]=o,U[2][1]=l,U[2][2]=h,0===(c=this.nifti_mat33_determ(U)))return null;for(N=-666,v=y=A=T=1,I=2,E=3,u=1;u<=3;u+=1)for(d=1;d<=3;d+=1)if(u!==d)for(p=1;p<=3;p+=1)if(u!==p&&d!==p)for(b[0][0]=b[0][1]=b[0][2]=b[1][0]=b[1][1]=b[1][2]=b[2][0]=b[2][1]=b[2][2]=0,g=-1;g<=1;g+=2)for(m=-1;m<=1;m+=2)for(_=-1;_<=1;_+=2)b[0][u-1]=g,b[1][d-1]=m,b[2][p-1]=_,this.nifti_mat33_determ(b)*c>0&&(f=(x=this.nifti_mat33_mul(b,U))[0][0]+x[1][1]+x[2][2])>N&&(N=f,v=u,I=d,E=p,y=g,A=m,T=_);switch(F=w=S=M=C=D="",v*y){case 1:F="X",M="+";break;case-1:F="X",M="-";break;case 2:F="Y",M="+";break;case-2:F="Y",M="-";break;case 3:F="Z",M="+";break;case-3:F="Z",M="-"}switch(I*A){case 1:w="X",C="+";break;case-1:w="X",C="-";break;case 2:w="Y",C="+";break;case-2:w="Y",C="-";break;case 3:w="Z",C="+";break;case-3:w="Z",C="-"}switch(E*T){case 1:S="X",D="+";break;case-1:S="X",D="-";break;case 2:S="Y",D="+";break;case-2:S="Y",D="-";break;case 3:S="Z",D="+";break;case-3:S="Z",D="-"}return F+w+S+M+C+D}nifti_mat33_mul=function(t,e){var i,n,s=[[0,0,0],[0,0,0],[0,0,0]];for(i=0;i<3;i+=1)for(n=0;n<3;n+=1)s[i][n]=t[i][0]*e[0][n]+t[i][1]*e[1][n]+t[i][2]*e[2][n];return s};nifti_mat33_determ=function(t){var e,i,n,s,r,a,o,l,h;return e=t[0][0],i=t[0][1],n=t[0][2],s=t[1][0],r=t[1][1],a=t[1][2],o=t[2][0],l=t[2][1],e*r*(h=t[2][2])-e*l*a-s*i*h+s*l*n+o*i*a-o*r*n};getExtensionLocation(){return s.MAGIC_COOKIE+4}getExtensionSize(t){return n.Utils.getIntAt(t,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(t){return n.Utils.getIntAt(t,this.getExtensionLocation()+4,this.littleEndian)}addExtension(t,e=-1){-1==e?this.extensions.push(t):this.extensions.splice(e,0,t),this.vox_offset+=t.esize}removeExtension(t){let e=this.extensions[t];e&&(this.vox_offset-=e.esize),this.extensions.splice(t,1)}toArrayBuffer(t=!1){let e=352;if(t)for(let t of this.extensions)e+=t.esize;let i=new Uint8Array(e),n=new DataView(i.buffer);n.setInt32(0,348,this.littleEndian),n.setUint8(39,this.dim_info);for(let t=0;t<8;t++)n.setUint16(40+2*t,this.dims[t],this.littleEndian);n.setFloat32(56,this.intent_p1,this.littleEndian),n.setFloat32(60,this.intent_p2,this.littleEndian),n.setFloat32(64,this.intent_p3,this.littleEndian),n.setInt16(68,this.intent_code,this.littleEndian),n.setInt16(70,this.datatypeCode,this.littleEndian),n.setInt16(72,this.numBitsPerVoxel,this.littleEndian),n.setInt16(74,this.slice_start,this.littleEndian);for(let t=0;t<8;t++)n.setFloat32(76+4*t,this.pixDims[t],this.littleEndian);n.setFloat32(108,this.vox_offset,this.littleEndian),n.setFloat32(112,this.scl_slope,this.littleEndian),n.setFloat32(116,this.scl_inter,this.littleEndian),n.setInt16(120,this.slice_end,this.littleEndian),n.setUint8(122,this.slice_code),n.setUint8(123,this.xyzt_units),n.setFloat32(124,this.cal_max,this.littleEndian),n.setFloat32(128,this.cal_min,this.littleEndian),n.setFloat32(132,this.slice_duration,this.littleEndian),n.setFloat32(136,this.toffset,this.littleEndian),i.set(Buffer.from(this.description),148),i.set(Buffer.from(this.aux_file),228),n.setInt16(252,this.qform_code,this.littleEndian),n.setInt16(254,this.sform_code,this.littleEndian),n.setFloat32(256,this.quatern_b,this.littleEndian),n.setFloat32(260,this.quatern_c,this.littleEndian),n.setFloat32(264,this.quatern_d,this.littleEndian),n.setFloat32(268,this.qoffset_x,this.littleEndian),n.setFloat32(272,this.qoffset_y,this.littleEndian),n.setFloat32(276,this.qoffset_z,this.littleEndian);const s=this.affine.flat();for(let t=0;t<12;t++)n.setFloat32(280+4*t,s[t],this.littleEndian);if(i.set(Buffer.from(this.intent_name),328),i.set(Buffer.from(this.magic),344),t){i.set(Uint8Array.from([1,0,0,0]),348);let t=this.getExtensionLocation();for(const e of this.extensions)n.setInt32(t,e.esize,e.littleEndian),n.setInt32(t+4,e.ecode,e.littleEndian),i.set(new Uint8Array(e.edata),t+8),t+=e.esize}else i.set(new Uint8Array(4).fill(0),348);return i.buffer}}e.NIFTI1=s},103:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NIFTI2=void 0;const n=i(232),s=i(517);class r{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];magic="0";extensionFlag=[0,0,0,0];extensions=[];extensionSize=0;extensionCode=0;static MAGIC_COOKIE=540;static MAGIC_NUMBER_LOCATION=4;static MAGIC_NUMBER=[110,43,50,0,13,10,26,10];static MAGIC_NUMBER2=[110,105,50,0,13,10,26,10];readHeader(t){var e,i,n,a,o=new DataView(t),l=s.Utils.getIntAt(o,0,this.littleEndian);if(l!==r.MAGIC_COOKIE&&(this.littleEndian=!0,l=s.Utils.getIntAt(o,0,this.littleEndian)),l!==r.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.magic=s.Utils.getStringAt(o,4,12),this.datatypeCode=s.Utils.getShortAt(o,12,this.littleEndian),this.numBitsPerVoxel=s.Utils.getShortAt(o,14,this.littleEndian),e=0;e<8;e+=1)a=16+8*e,this.dims[e]=s.Utils.getLongAt(o,a,this.littleEndian);for(this.intent_p1=s.Utils.getDoubleAt(o,80,this.littleEndian),this.intent_p2=s.Utils.getDoubleAt(o,88,this.littleEndian),this.intent_p3=s.Utils.getDoubleAt(o,96,this.littleEndian),e=0;e<8;e+=1)a=104+8*e,this.pixDims[e]=s.Utils.getDoubleAt(o,a,this.littleEndian);for(this.vox_offset=s.Utils.getLongAt(o,168,this.littleEndian),this.scl_slope=s.Utils.getDoubleAt(o,176,this.littleEndian),this.scl_inter=s.Utils.getDoubleAt(o,184,this.littleEndian),this.cal_max=s.Utils.getDoubleAt(o,192,this.littleEndian),this.cal_min=s.Utils.getDoubleAt(o,200,this.littleEndian),this.slice_duration=s.Utils.getDoubleAt(o,208,this.littleEndian),this.toffset=s.Utils.getDoubleAt(o,216,this.littleEndian),this.slice_start=s.Utils.getLongAt(o,224,this.littleEndian),this.slice_end=s.Utils.getLongAt(o,232,this.littleEndian),this.description=s.Utils.getStringAt(o,240,320),this.aux_file=s.Utils.getStringAt(o,320,344),this.qform_code=s.Utils.getIntAt(o,344,this.littleEndian),this.sform_code=s.Utils.getIntAt(o,348,this.littleEndian),this.quatern_b=s.Utils.getDoubleAt(o,352,this.littleEndian),this.quatern_c=s.Utils.getDoubleAt(o,360,this.littleEndian),this.quatern_d=s.Utils.getDoubleAt(o,368,this.littleEndian),this.qoffset_x=s.Utils.getDoubleAt(o,376,this.littleEndian),this.qoffset_y=s.Utils.getDoubleAt(o,384,this.littleEndian),this.qoffset_z=s.Utils.getDoubleAt(o,392,this.littleEndian),i=0;i<3;i+=1)for(n=0;n<4;n+=1)a=400+8*(4*i+n),this.affine[i][n]=s.Utils.getDoubleAt(o,a,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.slice_code=s.Utils.getIntAt(o,496,this.littleEndian),this.xyzt_units=s.Utils.getIntAt(o,500,this.littleEndian),this.intent_code=s.Utils.getIntAt(o,504,this.littleEndian),this.intent_name=s.Utils.getStringAt(o,508,524),this.dim_info=s.Utils.getByteAt(o,524),o.byteLength>r.MAGIC_COOKIE&&(this.extensionFlag[0]=s.Utils.getByteAt(o,540),this.extensionFlag[1]=s.Utils.getByteAt(o,541),this.extensionFlag[2]=s.Utils.getByteAt(o,542),this.extensionFlag[3]=s.Utils.getByteAt(o,543),this.extensionFlag[0]&&(this.extensions=s.Utils.getExtensionsAt(o,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var t=s.Utils.formatNumber,e="";return e+="Datatype = "+ +this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+")\n",e+="Bits Per Voxel = = "+this.numBitsPerVoxel+"\n",e+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+"\n",e+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+"\n",e+="Voxel Dimensions (1-8): "+t(this.pixDims[0])+", "+t(this.pixDims[1])+", "+t(this.pixDims[2])+", "+t(this.pixDims[3])+", "+t(this.pixDims[4])+", "+t(this.pixDims[5])+", "+t(this.pixDims[6])+", "+t(this.pixDims[7])+"\n",e+="Image Offset = "+this.vox_offset+"\n",e+="Data Scale: Slope = "+t(this.scl_slope)+" Intercept = "+t(this.scl_inter)+"\n",e+="Display Range: Max = "+t(this.cal_max)+" Min = "+t(this.cal_min)+"\n",e+="Slice Duration = "+this.slice_duration+"\n",e+="Time Axis Shift = "+this.toffset+"\n",e+="Slice Start = "+this.slice_start+"\n",e+="Slice End = "+this.slice_end+"\n",e+='Description: "'+this.description+'"\n',e+='Auxiliary File: "'+this.aux_file+'"\n',e+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+")\n",e+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+")\n",e+="Quaternion Parameters: b = "+t(this.quatern_b)+" c = "+t(this.quatern_c)+" d = "+t(this.quatern_d)+"\n",e+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+"\n",e+="S-Form Parameters X: "+t(this.affine[0][0])+", "+t(this.affine[0][1])+", "+t(this.affine[0][2])+", "+t(this.affine[0][3])+"\n",e+="S-Form Parameters Y: "+t(this.affine[1][0])+", "+t(this.affine[1][1])+", "+t(this.affine[1][2])+", "+t(this.affine[1][3])+"\n",e+="S-Form Parameters Z: "+t(this.affine[2][0])+", "+t(this.affine[2][1])+", "+t(this.affine[2][2])+", "+t(this.affine[2][3])+"\n",e+="Slice Code = "+this.slice_code+"\n",e+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(n.NIFTI1.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(n.NIFTI1.TEMPORAL_UNITS_MASK&this.xyzt_units)+")\n",e+="Intent Code = "+this.intent_code+"\n",(e+='Intent Name: "'+this.intent_name+'"\n')+"Dim Info = "+this.dim_info+"\n"}getExtensionLocation=function(){return r.MAGIC_COOKIE+4};getExtensionSize=n.NIFTI1.prototype.getExtensionSize;getExtensionCode=n.NIFTI1.prototype.getExtensionCode;addExtension=n.NIFTI1.prototype.addExtension;removeExtension=n.NIFTI1.prototype.removeExtension;getDatatypeCodeString=n.NIFTI1.prototype.getDatatypeCodeString;getTransformCodeString=n.NIFTI1.prototype.getTransformCodeString;getUnitsCodeString=n.NIFTI1.prototype.getUnitsCodeString;getQformMat=n.NIFTI1.prototype.getQformMat;convertNiftiQFormToNiftiSForm=n.NIFTI1.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=n.NIFTI1.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=n.NIFTI1.prototype.nifti_mat33_mul;nifti_mat33_determ=n.NIFTI1.prototype.nifti_mat33_determ;toArrayBuffer(t=!1){let e=544;if(t)for(let t of this.extensions)e+=t.esize;let i=new Uint8Array(e),n=new DataView(i.buffer);n.setInt32(0,540,this.littleEndian),i.set(Buffer.from(this.magic),4),n.setInt16(12,this.datatypeCode,this.littleEndian),n.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let t=0;t<8;t++)n.setBigInt64(16+8*t,BigInt(this.dims[t]),this.littleEndian);n.setFloat64(80,this.intent_p1,this.littleEndian),n.setFloat64(88,this.intent_p2,this.littleEndian),n.setFloat64(96,this.intent_p3,this.littleEndian);for(let t=0;t<8;t++)n.setFloat64(104+8*t,this.pixDims[t],this.littleEndian);n.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),n.setFloat64(176,this.scl_slope,this.littleEndian),n.setFloat64(184,this.scl_inter,this.littleEndian),n.setFloat64(192,this.cal_max,this.littleEndian),n.setFloat64(200,this.cal_min,this.littleEndian),n.setFloat64(208,this.slice_duration,this.littleEndian),n.setFloat64(216,this.toffset,this.littleEndian),n.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),n.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),i.set(Buffer.from(this.description),240),i.set(Buffer.from(this.aux_file),320),n.setInt32(344,this.qform_code,this.littleEndian),n.setInt32(348,this.sform_code,this.littleEndian),n.setFloat64(352,this.quatern_b,this.littleEndian),n.setFloat64(360,this.quatern_c,this.littleEndian),n.setFloat64(368,this.quatern_d,this.littleEndian),n.setFloat64(376,this.qoffset_x,this.littleEndian),n.setFloat64(384,this.qoffset_y,this.littleEndian),n.setFloat64(392,this.qoffset_z,this.littleEndian);const s=this.affine.flat();for(let t=0;t<12;t++)n.setFloat64(400+8*t,s[t],this.littleEndian);if(n.setInt32(496,this.slice_code,this.littleEndian),n.setInt32(500,this.xyzt_units,this.littleEndian),n.setInt32(504,this.intent_code,this.littleEndian),i.set(Buffer.from(this.intent_name),508),n.setUint8(524,this.dim_info),t){i.set(Uint8Array.from([1,0,0,0]),540);let t=this.getExtensionLocation();for(const e of this.extensions)n.setInt32(t,e.esize,e.littleEndian),n.setInt32(t+4,e.ecode,e.littleEndian),i.set(new Uint8Array(e.edata),t+8),t+=e.esize}else i.set(new Uint8Array(4).fill(0),540);return i.buffer}}e.NIFTI2=r},517:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Utils=void 0;const n=i(237);class s{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(t,e,i){var n,s,r="";for(n=e;n<i;n+=1)0!==(s=t.getUint8(n))&&(r+=String.fromCharCode(s));return r}static getByteAt=function(t,e){return t.getInt8(e)};static getShortAt=function(t,e,i){return t.getInt16(e,i)};static getIntAt(t,e,i){return t.getInt32(e,i)}static getFloatAt(t,e,i){return t.getFloat32(e,i)}static getDoubleAt(t,e,i){return t.getFloat64(e,i)}static getLongAt(t,e,i){var n,r=[],a=0;for(n=0;n<8;n+=1)r[n]=s.getByteAt(t,e+n);for(n=r.length-1;n>=0;n--)a=256*a+r[n];return a}static getExtensionsAt(t,e,i,r){let a=[],o=e;for(;o<r;){let e=i,l=s.getIntAt(t,o,i);if(!l)break;if(l+o>r&&(e=!e,l=s.getIntAt(t,o,e),l+o>r))throw new Error("This does not appear to be a valid NIFTI extension");if(l%16!=0)throw new Error("This does not appear to be a NIFTI extension");let h=s.getIntAt(t,o+4,e),f=t.buffer.slice(o+8,o+l);console.log("extensionByteIndex: "+(o+8)+" esize: "+l),console.log(f);let c=new n.NIFTIEXTENSION(l,h,f,e);a.push(c),o+=l}return a}static toArrayBuffer(t){var e,i,n;for(e=new ArrayBuffer(t.length),i=new Uint8Array(e),n=0;n<t.length;n+=1)i[n]=t[n];return e}static isString(t){return"string"==typeof t||t instanceof String}static formatNumber(t,e=void 0){let i;return i=s.isString(t)?Number(t):t,i=e?i.toPrecision(5):i.toPrecision(7),parseFloat(i)}static makeCRCTable(){let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}static crc32(t){s.crcTable||(s.crcTable=s.makeCRCTable());const e=s.crcTable;let i=-1;for(var n=0;n<t.byteLength;n++)i=i>>>8^e[255&(i^t.getUint8(n))];return~i>>>0}}e.Utils=s},953:e=>{e.exports=t},976:t=>{t.exports=e},876:(t,e,i)=>{var n=i(735),s=Uint8Array,r=Uint16Array,a=Uint32Array,o=new s([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),l=new s([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),h=new s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=function(t,e){for(var i=new r(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];var s=new a(i[30]);for(n=1;n<30;++n)for(var o=i[n];o<i[n+1];++o)s[o]=o-i[n]<<5|n;return[i,s]},c=f(o,2),u=c[0],d=c[1];u[28]=258,d[258]=28;for(var p=f(l,0),g=p[0],m=p[1],_=new r(32768),v=0;v<32768;++v){var I=(43690&v)>>>1|(21845&v)<<1;I=(61680&(I=(52428&I)>>>2|(13107&I)<<2))>>>4|(3855&I)<<4,_[v]=((65280&I)>>>8|(255&I)<<8)>>>1}var E=function(t,e,i){for(var n=t.length,s=0,a=new r(e);s<n;++s)t[s]&&++a[t[s]-1];var o,l=new r(e);for(s=0;s<e;++s)l[s]=l[s-1]+a[s-1]<<1;if(i){o=new r(1<<e);var h=15-e;for(s=0;s<n;++s)if(t[s])for(var f=s<<4|t[s],c=e-t[s],u=l[t[s]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)o[_[u]>>>h]=f}else for(o=new r(n),s=0;s<n;++s)t[s]&&(o[s]=_[l[t[s]-1]++]>>>15-t[s]);return o},y=new s(288);for(v=0;v<144;++v)y[v]=8;for(v=144;v<256;++v)y[v]=9;for(v=256;v<280;++v)y[v]=7;for(v=280;v<288;++v)y[v]=8;var A=new s(32);for(v=0;v<32;++v)A[v]=5;var T=E(y,9,0),x=E(y,9,1),N=E(A,5,0),U=E(A,5,1),b=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},F=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(7&e)&i},w=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},S=function(t){return(t+7)/8|0},M=function(t,e,i){(null==e||e<0)&&(e=0),(null==i||i>t.length)&&(i=t.length);var n=new(2==t.BYTES_PER_ELEMENT?r:4==t.BYTES_PER_ELEMENT?a:s)(i-e);return n.set(t.subarray(e,i)),n};e.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var C=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],D=function(t,e,i){var n=new Error(e||C[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,D),!i)throw n;return n},O=function(t,e,i){var n=t.length;if(!n||i&&i.f&&!i.l)return e||new s(0);var r=!e||i,a=!i||i.i;i||(i={}),e||(e=new s(3*n));var f=function(t){var i=e.length;if(t>i){var n=new s(Math.max(2*i,t));n.set(e),e=n}},c=i.f||0,d=i.p||0,p=i.b||0,m=i.l,_=i.d,v=i.m,I=i.n,y=8*n;do{if(!m){c=F(t,d,1);var A=F(t,d+1,3);if(d+=3,!A){var T=t[(G=S(d)+4)-4]|t[G-3]<<8,N=G+T;if(N>n){a&&D(0);break}r&&f(p+T),e.set(t.subarray(G,N),p),i.b=p+=T,i.p=d=8*N,i.f=c;continue}if(1==A)m=x,_=U,v=9,I=5;else if(2==A){var C=F(t,d,31)+257,O=F(t,d+10,15)+4,P=C+F(t,d+5,31)+1;d+=14;for(var R=new s(P),q=new s(19),B=0;B<O;++B)q[h[B]]=F(t,d+3*B,7);d+=3*O;var z=b(q),L=(1<<z)-1,k=E(q,z,1);for(B=0;B<P;){var G,V=k[F(t,d,L)];if(d+=15&V,(G=V>>>4)<16)R[B++]=G;else{var Y=0,H=0;for(16==G?(H=3+F(t,d,3),d+=2,Y=R[B-1]):17==G?(H=3+F(t,d,7),d+=3):18==G&&(H=11+F(t,d,127),d+=7);H--;)R[B++]=Y}}var X=R.subarray(0,C),Z=R.subarray(C);v=b(X),I=b(Z),m=E(X,v,1),_=E(Z,I,1)}else D(1);if(d>y){a&&D(0);break}}r&&f(p+131072);for(var j=(1<<v)-1,K=(1<<I)-1,Q=d;;Q=d){var $=(Y=m[w(t,d)&j])>>>4;if((d+=15&Y)>y){a&&D(0);break}if(Y||D(2),$<256)e[p++]=$;else{if(256==$){Q=d,m=null;break}var W=$-254;if($>264){var J=o[B=$-257];W=F(t,d,(1<<J)-1)+u[B],d+=J}var tt=_[w(t,d)&K],et=tt>>>4;if(tt||D(3),d+=15&tt,Z=g[et],et>3&&(J=l[et],Z+=w(t,d)&(1<<J)-1,d+=J),d>y){a&&D(0);break}r&&f(p+131072);for(var it=p+W;p<it;p+=4)e[p]=e[p-Z],e[p+1]=e[p+1-Z],e[p+2]=e[p+2-Z],e[p+3]=e[p+3-Z];p=it}}i.l=m,i.p=Q,i.b=p,i.f=c,m&&(c=1,i.m=v,i.d=_,i.n=I)}while(!c);return p==e.length?e:M(e,0,p)},P=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>>8},R=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>>8,t[n+2]|=i>>>16},q=function(t,e){for(var i=[],n=0;n<t.length;++n)t[n]&&i.push({s:n,f:t[n]});var a=i.length,o=i.slice();if(!a)return[Y,0];if(1==a){var l=new s(i[0].s+1);return l[i[0].s]=1,[l,1]}i.sort((function(t,e){return t.f-e.f})),i.push({s:-1,f:25001});var h=i[0],f=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:h.f+f.f,l:h,r:f};u!=a-1;)h=i[i[c].f<i[d].f?c++:d++],f=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:h.f+f.f,l:h,r:f};var p=o[0].s;for(n=1;n<a;++n)o[n].s>p&&(p=o[n].s);var g=new r(p+1),m=B(i[u-1],g,0);if(m>e){n=0;var _=0,v=m-e,I=1<<v;for(o.sort((function(t,e){return g[e.s]-g[t.s]||t.f-e.f}));n<a;++n){var E=o[n].s;if(!(g[E]>e))break;_+=I-(1<<m-g[E]),g[E]=e}for(_>>>=v;_>0;){var y=o[n].s;g[y]<e?_-=1<<e-g[y]++-1:++n}for(;n>=0&&_;--n){var A=o[n].s;g[A]==e&&(--g[A],++_)}m=e}return[new s(g),m]},B=function(t,e,i){return-1==t.s?Math.max(B(t.l,e,i+1),B(t.r,e,i+1)):e[t.s]=i},z=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new r(++e),n=0,s=t[0],a=1,o=function(t){i[n++]=t},l=1;l<=e;++l)if(t[l]==s&&l!=e)++a;else{if(!s&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(s),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(s);a=1,s=t[l]}return[i.subarray(0,n),e]},L=function(t,e){for(var i=0,n=0;n<e.length;++n)i+=t[n]*e[n];return i},k=function(t,e,i){var n=i.length,s=S(e+2);t[s]=255&n,t[s+1]=n>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var r=0;r<n;++r)t[s+r+4]=i[r];return 8*(s+4+n)},G=function(t,e,i,n,s,a,f,c,u,d,p){P(e,p++,i),++s[256];for(var g=q(s,15),m=g[0],_=g[1],v=q(a,15),I=v[0],x=v[1],U=z(m),b=U[0],F=U[1],w=z(I),S=w[0],M=w[1],C=new r(19),D=0;D<b.length;++D)C[31&b[D]]++;for(D=0;D<S.length;++D)C[31&S[D]]++;for(var O=q(C,7),B=O[0],G=O[1],V=19;V>4&&!B[h[V-1]];--V);var Y,H,X,Z,j=d+5<<3,K=L(s,y)+L(a,A)+f,Q=L(s,m)+L(a,I)+f+14+3*V+L(C,B)+(2*C[16]+3*C[17]+7*C[18]);if(j<=K&&j<=Q)return k(e,p,t.subarray(u,u+d));if(P(e,p,1+(Q<K)),p+=2,Q<K){Y=E(m,_,0),H=m,X=E(I,x,0),Z=I;var $=E(B,G,0);for(P(e,p,F-257),P(e,p+5,M-1),P(e,p+10,V-4),p+=14,D=0;D<V;++D)P(e,p+3*D,B[h[D]]);p+=3*V;for(var W=[b,S],J=0;J<2;++J){var tt=W[J];for(D=0;D<tt.length;++D){var et=31&tt[D];P(e,p,$[et]),p+=B[et],et>15&&(P(e,p,tt[D]>>>5&127),p+=tt[D]>>>12)}}}else Y=T,H=y,X=N,Z=A;for(D=0;D<c;++D)if(n[D]>255){et=n[D]>>>18&31,R(e,p,Y[et+257]),p+=H[et+257],et>7&&(P(e,p,n[D]>>>23&31),p+=o[et]);var it=31&n[D];R(e,p,X[it]),p+=Z[it],it>3&&(R(e,p,n[D]>>>5&8191),p+=l[it])}else R(e,p,Y[n[D]]),p+=H[n[D]];return R(e,p,Y[256]),p+H[256]},V=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Y=new s(0),H=function(t,e,i,n,h,f){var c=t.length,u=new s(n+c+5*(1+Math.ceil(c/7e3))+h),p=u.subarray(n,u.length-h),g=0;if(!e||c<8)for(var _=0;_<=c;_+=65535){var v=_+65535;v>=c&&(p[g>>3]=f),g=k(p,g+1,t.subarray(_,v))}else{for(var I=V[e-1],E=I>>>13,y=8191&I,A=(1<<i)-1,T=new r(32768),x=new r(A+1),N=Math.ceil(i/3),U=2*N,b=function(e){return(t[e]^t[e+1]<<N^t[e+2]<<U)&A},F=new a(25e3),w=new r(288),C=new r(32),D=0,O=0,P=(_=0,0),R=0,q=0;_<c;++_){var B=b(_),z=32767&_,L=x[B];if(T[z]=L,x[B]=z,R<=_){var H=c-_;if((D>7e3||P>24576)&&H>423){g=G(t,p,0,F,w,C,O,P,q,_-q,g),P=D=O=0,q=_;for(var X=0;X<286;++X)w[X]=0;for(X=0;X<30;++X)C[X]=0}var Z=2,j=0,K=y,Q=z-L&32767;if(H>2&&B==b(_-Q))for(var $=Math.min(E,H)-1,W=Math.min(32767,_),J=Math.min(258,H);Q<=W&&--K&&z!=L;){if(t[_+Z]==t[_+Z-Q]){for(var tt=0;tt<J&&t[_+tt]==t[_+tt-Q];++tt);if(tt>Z){if(Z=tt,j=Q,tt>$)break;var et=Math.min(Q,tt-2),it=0;for(X=0;X<et;++X){var nt=_-Q+X+32768&32767,st=nt-T[nt]+32768&32767;st>it&&(it=st,L=nt)}}}Q+=(z=L)-(L=T[z])+32768&32767}if(j){F[P++]=268435456|d[Z]<<18|m[j];var rt=31&d[Z],at=31&m[j];O+=o[rt]+l[at],++w[257+rt],++C[at],R=_+Z,++D}else F[P++]=t[_],++w[t[_]]}}g=G(t,p,f,F,w,C,O,P,q,_-q,g),!f&&7&g&&(g=k(p,g+1,Y))}return M(u,0,n+S(g)+h)},X=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),Z=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n<e.length;++n)i=X[255&i^e[n]]^i>>>8;t=i},d:function(){return~t}}},j=function(){var t=1,e=0;return{p:function(i){for(var n=t,s=e,r=0|i.length,a=0;a!=r;){for(var o=Math.min(a+2655,r);a<o;++a)s+=n+=i[a];n=(65535&n)+15*(n>>16),s=(65535&s)+15*(s>>16)}t=n,e=s},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(e%=65521))<<8|e>>>8}}},K=function(t,e,i,n,s){return H(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,i,n,!s)},Q=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},$=function(t,e,i){for(var n=t(),s=t.toString(),r=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<n.length;++a){var o=n[a],l=r[a];if("function"==typeof o){e+=";"+l+"=";var h=o.toString();if(o.prototype)if(-1!=h.indexOf("[native code]")){var f=h.indexOf(" ",8)+1;e+=h.slice(f,h.indexOf("(",f))}else for(var c in e+=h,o.prototype)e+=";"+l+".prototype."+c+"="+o.prototype[c].toString();else e+=h}else i[l]=o}return[e,i]},W=[],J=function(t,e,i,s){var r;if(!W[i]){for(var a="",o={},l=t.length-1,h=0;h<l;++h)a=(r=$(t[h],a,o))[0],o=r[1];W[i]=$(t[l],a,o)}var f=Q({},W[i][1]);return n.default(W[i][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",i,f,function(t){var e=[];for(var i in t)t[i].buffer&&e.push((t[i]=new t[i].constructor(t[i])).buffer);return e}(f),s)},tt=function(){return[s,r,a,o,l,h,u,g,x,U,_,C,E,b,F,w,S,M,D,O,wt,at,ot]},et=function(){return[s,r,a,o,l,h,d,m,T,y,N,A,_,V,Y,E,P,R,q,B,z,L,k,G,S,M,H,K,Nt,at]},it=function(){return[gt,vt,pt,Z,X]},nt=function(){return[mt,_t]},st=function(){return[It,pt,j]},rt=function(){return[Et]},at=function(t){return postMessage(t,[t.buffer])},ot=function(t){return t&&t.size&&new s(t.size)},lt=function(t,e,i,n,s,r){var a=J(i,n,s,(function(t,e){a.terminate(),r(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},ht=function(t){return t.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(e){return t.push(e.data[0],e.data[1])}},ft=function(t,e,i,n,s){var r,a=J(t,n,s,(function(t,i){t?(a.terminate(),e.ondata.call(e,t)):(i[1]&&a.terminate(),e.ondata.call(e,t,i[0],i[1]))}));a.postMessage(i),e.push=function(t,i){e.ondata||D(5),r&&e.ondata(D(4,0,1),null,!!i),a.postMessage([t,r=i],[t.buffer])},e.terminate=function(){a.terminate()}},ct=function(t,e){return t[e]|t[e+1]<<8},ut=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},dt=function(t,e){return ut(t,e)+4294967296*ut(t,e+4)},pt=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8},gt=function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&pt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var n=0;n<=i.length;++n)t[n+10]=i.charCodeAt(n)}},mt=function(t){31==t[0]&&139==t[1]&&8==t[2]||D(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=t[10]|2+(t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)},_t=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},vt=function(t){return 10+(t.filename&&t.filename.length+1||0)},It=function(t,e){var i=e.level,n=0==i?0:i<6?1:9==i?3:2;t[0]=120,t[1]=n<<6|(n?32-2*n:1)},Et=function(t){(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&D(6,"invalid zlib data"),32&t[1]&&D(6,"invalid zlib data: preset dictionaries not supported")};function yt(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var At=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(K(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){this.ondata||D(5),this.d&&D(4),this.d=e,this.p(t,e||!1)},t}();e.Deflate=At;var Tt=function(){return function(t,e){ft([et,function(){return[ht,At]}],this,yt.call(this,t,e),(function(t){var e=new At(t.data);onmessage=ht(e)}),6)}}();function xt(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[et],(function(t){return at(Nt(t.data[0],t.data[1]))}),0,i)}function Nt(t,e){return K(t,e||{},0,0)}e.AsyncDeflate=Tt,e.deflate=xt,e.deflateSync=Nt;var Ut=function(){function t(t){this.s={},this.p=new s(0),this.ondata=t}return t.prototype.e=function(t){this.ondata||D(5),this.d&&D(4);var e=this.p.length,i=new s(e+t.length);i.set(this.p),i.set(t,e),this.p=i},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,i=O(this.p,this.o,this.s);this.ondata(M(i,e,this.s.b),this.d),this.o=M(i,this.s.b-32768),this.s.b=this.o.length,this.p=M(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}();e.Inflate=Ut;var bt=function(){return function(t){this.ondata=t,ft([tt,function(){return[ht,Ut]}],this,0,(function(){var t=new Ut;onmessage=ht(t)}),7)}}();function Ft(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[tt],(function(t){return at(wt(t.data[0],ot(t.data[1])))}),1,i)}function wt(t,e){return O(t,e)}e.AsyncInflate=bt,e.inflate=Ft,e.inflateSync=wt;var St=function(){function t(t,e){this.c=Z(),this.l=0,this.v=1,At.call(this,t,e)}return t.prototype.push=function(t,e){At.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var i=K(t,this.o,this.v&&vt(this.o),e&&8,!e);this.v&&(gt(i,this.o),this.v=0),e&&(pt(i,i.length-8,this.c.d()),pt(i,i.length-4,this.l)),this.ondata(i,e)},t}();e.Gzip=St,e.Compress=St;var Mt=function(){return function(t,e){ft([et,it,function(){return[ht,At,St]}],this,yt.call(this,t,e),(function(t){var e=new St(t.data);onmessage=ht(e)}),8)}}();function Ct(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[et,it,function(){return[Dt]}],(function(t){return at(Dt(t.data[0],t.data[1]))}),2,i)}function Dt(t,e){e||(e={});var i=Z(),n=t.length;i.p(t);var s=K(t,e,vt(e),8),r=s.length;return gt(s,e),pt(s,r-8,i.d()),pt(s,r-4,n),s}e.AsyncGzip=Mt,e.AsyncCompress=Mt,e.gzip=Ct,e.compress=Ct,e.gzipSync=Dt,e.compressSync=Dt;var Ot=function(){function t(t){this.v=1,Ut.call(this,t)}return t.prototype.push=function(t,e){if(Ut.prototype.e.call(this,t),this.v){var i=this.p.length>3?mt(this.p):4;if(i>=this.p.length&&!e)return;this.p=this.p.subarray(i),this.v=0}e&&(this.p.length<8&&D(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),Ut.prototype.c.call(this,e)},t}();e.Gunzip=Ot;var Pt=function(){return function(t){this.ondata=t,ft([tt,nt,function(){return[ht,Ut,Ot]}],this,0,(function(){var t=new Ot;onmessage=ht(t)}),9)}}();function Rt(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[tt,nt,function(){return[qt]}],(function(t){return at(qt(t.data[0]))}),3,i)}function qt(t,e){return O(t.subarray(mt(t),-8),e||new s(_t(t)))}e.AsyncGunzip=Pt,e.gunzip=Rt,e.gunzipSync=qt;var Bt=function(){function t(t,e){this.c=j(),this.v=1,At.call(this,t,e)}return t.prototype.push=function(t,e){At.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var i=K(t,this.o,this.v&&2,e&&4,!e);this.v&&(It(i,this.o),this.v=0),e&&pt(i,i.length-4,this.c.d()),this.ondata(i,e)},t}();e.Zlib=Bt;var zt=function(){return function(t,e){ft([et,st,function(){return[ht,At,Bt]}],this,yt.call(this,t,e),(function(t){var e=new Bt(t.data);onmessage=ht(e)}),10)}}();function Lt(t,e){e||(e={});var i=j();i.p(t);var n=K(t,e,2,4);return It(n,e),pt(n,n.length-4,i.d()),n}e.AsyncZlib=zt,e.zlib=function(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[et,st,function(){return[Lt]}],(function(t){return at(Lt(t.data[0],t.data[1]))}),4,i)},e.zlibSync=Lt;var kt=function(){function t(t){this.v=1,Ut.call(this,t)}return t.prototype.push=function(t,e){if(Ut.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}e&&(this.p.length<4&&D(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Ut.prototype.c.call(this,e)},t}();e.Unzlib=kt;var Gt=function(){return function(t){this.ondata=t,ft([tt,rt,function(){return[ht,Ut,kt]}],this,0,(function(){var t=new kt;onmessage=ht(t)}),11)}}();function Vt(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),lt(t,e,[tt,rt,function(){return[Yt]}],(function(t){return at(Yt(t.data[0],ot(t.data[1])))}),5,i)}function Yt(t,e){return O((Et(t),t.subarray(2,-4)),e)}e.AsyncUnzlib=Gt,e.unzlib=Vt,e.unzlibSync=Yt;var Ht=function(){function t(t){this.G=Ot,this.I=Ut,this.Z=kt,this.ondata=t}return t.prototype.push=function(t,e){if(this.ondata||D(5),this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var i=new s(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var n=this,r=function(){n.ondata.apply(n,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(r):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(r):new this.Z(r),this.s.push(this.p,e),this.p=null}}},t}();e.Decompress=Ht;var Xt=function(){function t(t){this.G=Pt,this.I=bt,this.Z=Gt,this.ondata=t}return t.prototype.push=function(t,e){Ht.prototype.push.call(this,t,e)},t}();e.AsyncDecompress=Xt,e.decompress=function(t,e,i){return i||(i=e,e={}),"function"!=typeof i&&D(7),31==t[0]&&139==t[1]&&8==t[2]?Rt(t,e,i):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Ft(t,e,i):Vt(t,e,i)},e.decompressSync=function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?qt(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?wt(t,e):Yt(t,e)};var Zt=function(t,e,i,n){for(var r in t){var a=t[r],o=e+r,l=n;Array.isArray(a)&&(l=Q(n,a[1]),a=a[0]),a instanceof s?i[o]=[a,l]:(i[o+="/"]=[new s(0),l],Zt(a,o,i,n))}},jt="undefined"!=typeof TextEncoder&&new TextEncoder,Kt="undefined"!=typeof TextDecoder&&new TextDecoder,Qt=0;try{Kt.decode(Y,{stream:!0}),Qt=1}catch(t){}var $t=function(t){for(var e="",i=0;;){var n=t[i++],s=(n>127)+(n>223)+(n>239);if(i+s>t.length)return[e,M(t,i-1)];s?3==s?(n=((15&n)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=1&s?String.fromCharCode((31&n)<<6|63&t[i++]):String.fromCharCode((15&n)<<12|(63&t[i++])<<6|63&t[i++]):e+=String.fromCharCode(n)}},Wt=function(){function t(t){this.ondata=t,Qt?this.t=new TextDecoder:this.p=Y}return t.prototype.push=function(t,e){if(this.ondata||D(5),e=!!e,this.t)return this.ondata(this.t.decode(t,{stream:!0}),e),void(e&&(this.t.decode().length&&D(8),this.t=null));this.p||D(4);var i=new s(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length);var n=$t(i),r=n[0],a=n[1];e?(a.length&&D(8),this.p=null):this.p=a,this.ondata(r,e)},t}();e.DecodeUTF8=Wt;var Jt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){this.ondata||D(5),this.d&&D(4),this.ondata(te(t),this.d=e||!1)},t}();function te(t,e){if(e){for(var i=new s(t.length),n=0;n<t.length;++n)i[n]=t.charCodeAt(n);return i}if(jt)return jt.encode(t);var r=t.length,a=new s(t.length+(t.length>>1)),o=0,l=function(t){a[o++]=t};for(n=0;n<r;++n){if(o+5>a.length){var h=new s(o+8+(r-n<<1));h.set(a),a=h}var f=t.charCodeAt(n);f<128||e?l(f):f<2048?(l(192|f>>6),l(128|63&f)):f>55295&&f<57344?(l(240|(f=65536+(1047552&f)|1023&t.charCodeAt(++n))>>18),l(128|f>>12&63),l(128|f>>6&63),l(128|63&f)):(l(224|f>>12),l(128|f>>6&63),l(128|63&f))}return M(a,0,o)}function ee(t,e){if(e){for(var i="",n=0;n<t.length;n+=16384)i+=String.fromCharCode.apply(null,t.subarray(n,n+16384));return i}if(Kt)return Kt.decode(t);var s=$t(t),r=s[0];return s[1].length&&D(8),r}e.EncodeUTF8=Jt,e.strToU8=te,e.strFromU8=ee;var ie=function(t){return 1==t?3:t<6?2:9==t?1:0},ne=function(t,e){return e+30+ct(t,e+26)+ct(t,e+28)},se=function(t,e,i){var n=ct(t,e+28),s=ee(t.subarray(e+46,e+46+n),!(2048&ct(t,e+8))),r=e+46+n,a=ut(t,e+20),o=i&&4294967295==a?re(t,r):[a,ut(t,e+24),ut(t,e+42)],l=o[0],h=o[1],f=o[2];return[ct(t,e+10),l,h,s,r+ct(t,e+30)+ct(t,e+32),f]},re=function(t,e){for(;1!=ct(t,e);e+=4+ct(t,e+2));return[dt(t,e+12),dt(t,e+4),dt(t,e+20)]},ae=function(t){var e=0;if(t)for(var i in t){var n=t[i].length;n>65535&&D(9),e+=n+4}return e},oe=function(t,e,i,n,s,r,a,o){var l=n.length,h=i.extra,f=o&&o.length,c=ae(h);pt(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(null==r&&8),t[e++]=s&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var u=new Date(null==i.mtime?Date.now():i.mtime),d=u.getFullYear()-1980;if((d<0||d>119)&&D(10),pt(t,e,d<<25|u.getMonth()+1<<21|u.getDate()<<16|u.getHours()<<11|u.getMinutes()<<5|u.getSeconds()>>>1),e+=4,null!=r&&(pt(t,e,i.crc),pt(t,e+4,r),pt(t,e+8,i.size)),pt(t,e+12,l),pt(t,e+14,c),e+=16,null!=a&&(pt(t,e,f),pt(t,e+6,i.attrs),pt(t,e+10,a),e+=14),t.set(n,e),e+=l,c)for(var p in h){var g=h[p],m=g.length;pt(t,e,+p),pt(t,e+2,m),t.set(g,e+4),e+=4+m}return f&&(t.set(o,e),e+=f),e},le=function(t,e,i,n,s){pt(t,e,101010256),pt(t,e+8,i),pt(t,e+10,i),pt(t,e+12,n),pt(t,e+16,s)},he=function(){function t(t){this.filename=t,this.c=Z(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){this.ondata||D(5),this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}();e.ZipPassThrough=he;var fe=function(){function t(t,e){var i=this;e||(e={}),he.call(this,t),this.d=new At(e,(function(t,e){i.ondata(null,t,e)})),this.compression=8,this.flag=ie(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){he.prototype.push.call(this,t,e)},t}();e.ZipDeflate=fe;var ce=function(){function t(t,e){var i=this;e||(e={}),he.call(this,t),this.d=new Tt(e,(function(t,e,n){i.ondata(t,e,n)})),this.compression=8,this.flag=ie(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){he.prototype.push.call(this,t,e)},t}();e.AsyncZipDeflate=ce;var ue=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(this.ondata||D(5),2&this.d)this.ondata(D(4+8*(1&this.d),0,1),null,!1);else{var i=te(t.filename),n=i.length,r=t.comment,a=r&&te(r),o=n!=t.filename.length||a&&r.length!=a.length,l=n+ae(t.extra)+30;n>65535&&this.ondata(D(11,0,1),null,!1);var h=new s(l);oe(h,0,t,i,o);var f=[h],c=function(){for(var t=0,i=f;t<i.length;t++){var n=i[t];e.ondata(null,n,!1)}f=[]},u=this.d;this.d=0;var d=this.u.length,p=Q(t,{f:i,u:o,o:a,t:function(){t.terminate&&t.terminate()},r:function(){if(c(),u){var t=e.u[d+1];t?t.r():e.d=1}u=1}}),g=0;t.ondata=function(i,n,r){if(i)e.ondata(i,n,r),e.terminate();else if(g+=n.length,f.push(n),r){var a=new s(16);pt(a,0,134695760),pt(a,4,t.crc),pt(a,8,g),pt(a,12,t.size),f.push(a),p.c=g,p.b=l+g+16,p.crc=t.crc,p.size=t.size,u&&p.r(),u=1}else u&&c()},this.u.push(p)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(D(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,e=0,i=0,n=0,r=this.u;n<r.length;n++)i+=46+(h=r[n]).f.length+ae(h.extra)+(h.o?h.o.length:0);for(var a=new s(i+22),o=0,l=this.u;o<l.length;o++){var h=l[o];oe(a,t,h,h.f,h.u,h.c,e,h.o),t+=46+h.f.length+ae(h.extra)+(h.o?h.o.length:0),e+=h.b}le(a,t,this.u.length,i,e),this.ondata(null,a,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++)e[t].t();this.d=2},t}();e.Zip=ue,e.zip=function(t,e,i){i||(i=e,e={}),"function"!=typeof i&&D(7);var n={};Zt(t,"",n,e);var r=Object.keys(n),a=r.length,o=0,l=0,h=a,f=new Array(a),c=[],u=function(){for(var t=0;t<c.length;++t)c[t]()},d=function(t,e){_e((function(){i(t,e)}))};_e((function(){d=i}));var p=function(){var t=new s(l+22),e=o,i=l-o;l=0;for(var n=0;n<h;++n){var r=f[n];try{var a=r.c.length;oe(t,l,r,r.f,r.u,a);var c=30+r.f.length+ae(r.extra),u=l+c;t.set(r.c,u),oe(t,o,r,r.f,r.u,a,l,r.m),o+=16+c+(r.m?r.m.length:0),l=u+a}catch(t){return d(t,null)}}le(t,o,f.length,i,e),d(null,t)};a||p();for(var g=function(t){var e=r[t],i=n[e],s=i[0],h=i[1],g=Z(),m=s.length;g.p(s);var _=te(e),v=_.length,I=h.comment,E=I&&te(I),y=E&&E.length,A=ae(h.extra),T=0==h.level?0:8,x=function(i,n){if(i)u(),d(i,null);else{var s=n.length;f[t]=Q(h,{size:m,crc:g.d(),c:n,f:_,m:E,u:v!=e.length||E&&I.length!=y,compression:T}),o+=30+v+A+s,l+=76+2*(v+A)+(y||0)+s,--a||p()}};if(v>65535&&x(D(11,0,1),null),T)if(m<16e4)try{x(null,Nt(s,h))}catch(t){x(t,null)}else c.push(xt(s,h,x));else x(null,s)},m=0;m<h;++m)g(m);return u},e.zipSync=function(t,e){e||(e={});var i={},n=[];Zt(t,"",i,e);var r=0,a=0;for(var o in i){var l=i[o],h=l[0],f=l[1],c=0==f.level?0:8,u=(x=te(o)).length,d=f.comment,p=d&&te(d),g=p&&p.length,m=ae(f.extra);u>65535&&D(11);var _=c?Nt(h,f):h,v=_.length,I=Z();I.p(h),n.push(Q(f,{size:h.length,crc:I.d(),c:_,f:x,m:p,u:u!=o.length||p&&d.length!=g,o:r,compression:c})),r+=30+u+m+v,a+=76+2*(u+m)+(g||0)+v}for(var E=new s(a+22),y=r,A=a-r,T=0;T<n.length;++T){var x=n[T];oe(E,x.o,x,x.f,x.u,x.c.length);var N=30+x.f.length+ae(x.extra);E.set(x.c,x.o+N),oe(E,r,x,x.f,x.u,x.c.length,x.o,x.m),r+=16+N+(x.m?x.m.length:0)}return le(E,r,n.length,A,y),E};var de=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}();e.UnzipPassThrough=de;var pe=function(){function t(){var t=this;this.i=new Ut((function(e,i){t.ondata(null,e,i)}))}return t.prototype.push=function(t,e){try{this.i.push(t,e)}catch(t){this.ondata(t,null,e)}},t.compression=8,t}();e.UnzipInflate=pe;var ge=function(){function t(t,e){var i=this;e<32e4?this.i=new Ut((function(t,e){i.ondata(null,t,e)})):(this.i=new bt((function(t,e,n){i.ondata(t,e,n)})),this.terminate=this.i.terminate)}return t.prototype.push=function(t,e){this.i.terminate&&(t=M(t,0)),this.i.push(t,e)},t.compression=8,t}();e.AsyncUnzipInflate=ge;var me=function(){function t(t){this.onfile=t,this.k=[],this.o={0:de},this.p=Y}return t.prototype.push=function(t,e){var i=this;if(this.onfile||D(5),this.p||D(4),this.c>0){var n=Math.min(this.c,t.length),r=t.subarray(0,n);if(this.c-=n,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(n)).length)return this.push(t,e)}else{var a=0,o=0,l=void 0,h=void 0;this.p.length?t.length?((h=new s(this.p.length+t.length)).set(this.p),h.set(t,this.p.length)):h=this.p:h=t;for(var f=h.length,c=this.c,u=c&&this.d,d=function(){var t,e=ut(h,o);if(67324752==e){a=1,l=o,p.d=null,p.c=0;var n=ct(h,o+6),s=ct(h,o+8),r=2048&n,u=8&n,d=ct(h,o+26),g=ct(h,o+28);if(f>o+30+d+g){var m=[];p.k.unshift(m),a=2;var _,v=ut(h,o+18),I=ut(h,o+22),E=ee(h.subarray(o+30,o+=30+d),!r);4294967295==v?(t=u?[-2]:re(h,o),v=t[0],I=t[1]):u&&(v=-1),o+=g,p.c=v;var y={name:E,compression:s,start:function(){if(y.ondata||D(5),v){var t=i.o[s];t||y.ondata(D(14,"unknown compression type "+s,1),null,!1),(_=v<0?new t(E):new t(E,v,I)).ondata=function(t,e,i){y.ondata(t,e,i)};for(var e=0,n=m;e<n.length;e++){var r=n[e];_.push(r,!1)}i.k[0]==m&&i.c?i.d=_:_.push(Y,!0)}else y.ondata(null,Y,!0)},terminate:function(){_&&_.terminate&&_.terminate()}};v>=0&&(y.size=v,y.originalSize=I),p.onfile(y)}return"break"}if(c){if(134695760==e)return l=o+=12+(-2==c&&8),a=3,p.c=0,"break";if(33639248==e)return l=o-=4,a=3,p.c=0,"break"}},p=this;o<f-4&&"break"!==d();++o);if(this.p=Y,c<0){var g=a?h.subarray(0,l-12-(-2==c&&8)-(134695760==ut(h,l-16)&&4)):h.subarray(0,o);u?u.push(g,!!a):this.k[+(2==a)].push(g)}if(2&a)return this.push(h.subarray(o),e);this.p=h.subarray(o)}e&&(this.c&&D(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}();e.Unzip=me;var _e="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};e.unzip=function(t,e,i){i||(i=e,e={}),"function"!=typeof i&&D(7);var n=[],r=function(){for(var t=0;t<n.length;++t)n[t]()},a={},o=function(t,e){_e((function(){i(t,e)}))};_e((function(){o=i}));for(var l=t.length-22;101010256!=ut(t,l);--l)if(!l||t.length-l>65558)return o(D(13,0,1),null),r;var h=ct(t,l+8);if(h){var f=h,c=ut(t,l+16),u=4294967295==c;if(u){if(l=ut(t,l-12),101075792!=ut(t,l))return o(D(13,0,1),null),r;f=h=ut(t,l+32),c=ut(t,l+48)}for(var d=e&&e.filter,p=function(e){var i=se(t,c,u),l=i[0],f=i[1],p=i[2],g=i[3],m=i[4],_=i[5],v=ne(t,_);c=m;var I=function(t,e){t?(r(),o(t,null)):(e&&(a[g]=e),--h||o(null,a))};if(!d||d({name:g,size:f,originalSize:p,compression:l}))if(l)if(8==l){var E=t.subarray(v,v+f);if(f<32e4)try{I(null,wt(E,new s(p)))}catch(t){I(t,null)}else n.push(Ft(E,{size:p},I))}else I(D(14,"unknown compression type "+l,1),null);else I(null,M(t,v,v+f));else I(null,null)},g=0;g<f;++g)p()}else o(null,{});return r},e.unzipSync=function(t,e){for(var i={},n=t.length-22;101010256!=ut(t,n);--n)(!n||t.length-n>65558)&&D(13);var r=ct(t,n+8);if(!r)return{};var a=ut(t,n+16),o=4294967295==a;o&&(n=ut(t,n-12),101075792!=ut(t,n)&&D(13),r=ut(t,n+32),a=ut(t,n+48));for(var l=e&&e.filter,h=0;h<r;++h){var f=se(t,a,o),c=f[0],u=f[1],d=f[2],p=f[3],g=f[4],m=f[5],_=ne(t,m);a=g,l&&!l({name:p,size:u,originalSize:d,compression:c})||(c?8==c?i[p]=wt(t.subarray(_,_+u),new s(d)):D(14,"unknown compression type "+c):i[p]=M(t,_,_+u))}return i}},735:(t,e)=>{var i={};e.default=function(t,e,n,s,r){var a=new Worker(i[e]||(i[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return a.onmessage=function(t){var e=t.data,i=e.$e$;if(i){var n=new Error(i[0]);n.code=i[1],n.stack=i[2],r(n,null)}else r(null,e)},a.postMessage(n,s),a}}},n={};function s(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={exports:{}};return i[t].call(r.exports,r,r.exports,s),r.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{s.r(r),s.d(r,{Enums:()=>e,cornerstoneNiftiImageLoader:()=>y,createNiftiImageIdsAndCacheMetadata:()=>M,helpers:()=>t});var t={};s.r(t),s.d(t,{makeVolumeMetadata:()=>N,modalityScaleNifti:()=>g});var e={};s.r(e),s.d(e,{Events:()=>o});var i=s(953),n=s(130),a=function(t){return t.NIFTI_VOLUME_LOADED="CORNERSTONE_NIFTI_VOLUME_LOADED",t.NIFTI_VOLUME_PROGRESS="CORNERSTONE_NIFTI_VOLUME_PROGRESS",t}(a||{});const o=a,l=2,h=4,f=8,c=16,u=256,d=512,p=768;function g(t,e){const{datatypeCode:i,scl_slope:n,scl_inter:s}=t;let r=n,a=s;n&&0!==n&&!Number.isNaN(n)||(r=1),s&&!Number.isNaN(s)||(a=0);const o=a<0||r<0,g=a%1!=0||r%1!=0;let _,I,E=1;switch(i){case l:_=new Uint8Array(e),g?I=v("Float32Array",_):o?I=v("Int16Array",_):(E=0,I=v("Uint8Array",_));break;case h:_=new Int16Array(e),I=v(g?"Float32Array":"Int16Array",_);break;case f:_=new Int32Array(e),I=v("Float32Array",_);break;case c:_=new Float32Array(e),I=v("Float32Array",_);break;case u:_=new Int8Array(e),I=v(g?"Float32Array":"Int8Array",_);break;case d:_=new Uint16Array(e),g||o?I=v("Float32Array",_):(E=0,I=v("Uint16Array",_));break;case p:_=new Uint32Array(e),I=v("Float32Array",_);break;default:throw new Error(`NIFTI datatypeCode ${i} is not yet supported`)}const y=I.length;if(1!==r&&0!==a)for(let t=0;t<y;t++)I[t]=m(I[t],r,a);return t.numBitsPerVoxel=I.byteLength/I.length*8,{scalarData:I,pixelRepresentation:E}}function m(t,e,i){return t*e+i}function _(t,e){const n=t/8*e;if(!i.cache.isCacheable(n))throw new Error(i.Enums.Events.CACHE_SIZE_EXCEEDED);return i.cache.decacheIfNecessaryUntilBytesAvailable(n),n}function v(t,e){let i,n;const s=e.length;switch(t){case"Float32Array":i=32,_(i,s),n=new Float32Array(s);break;case"Int16Array":i=16,_(i,s),n=new Int16Array(s);break;case"Int8Array":i=8,_(i,s),n=new Int16Array(s);break;case"Uint16Array":i=16,_(i,s),n=new Uint16Array(s);break;case"Uint8Array":i=8,_(i,s),n=new Uint8Array(s);break;default:throw new Error(`TypedArray ${t} is not yet supported`)}return n.set(e),n}const I=new Map;let E=null;function y(t){const[e,s]=t.substring(6).split("?frame="),r=parseInt(s,10),a=i.metaData.get(i.Enums.MetadataModules.IMAGE_PIXEL,t),l=i.metaData.get(i.Enums.MetadataModules.IMAGE_PLANE,t),h=new Promise(((s,h)=>{I.get(e)?function(t,e,i,n){return new Promise((s=>{const r=setInterval((()=>{E&&(clearInterval(r),s(A(t,e,i,n)))}),10)}))}(t,r,a,l).then(s).catch(h):(I.set(e,!0),async function(t,e,s,r,a){let l=await function(t){let{url:e,signal:n,onload:s}=t;return new Promise(((t,r)=>{const a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType="arraybuffer";const l=function(e){s&&"function"==typeof s&&s(),n&&n.removeEventListener("abort",h),t(a.response)},h=()=>{a.abort(),a.removeEventListener("load",l),r(new Error("Request aborted"))};a.addEventListener("load",l),a.onprogress=function(t){((t,n)=>{const s={url:e,loaded:t,total:n};(0,i.triggerEvent)(i.eventTarget,o.NIFTI_VOLUME_PROGRESS,{data:s})})(t.loaded,t.total)},n&&n.aborted?(a.abort(),r(new Error("Request aborted"))):n&&n.addEventListener("abort",h),a.send()}))}({url:e}),h=null,f=null;if(n.isCompressed(l)&&(l=n.decompress(l)),!n.isNIFTI(l)){const t="The provided buffer is not a valid NIFTI file.";throw console.warn(t),new Error(t)}h=n.readHeader(l),f=n.readImage(h,l);const{scalarData:c}=g(h,f);return E=c,A(t,s,r,a)}(t,e,r,a,l).then(s).catch(h))}));return{promise:h,cancelFn:void 0}}function A(t,e,n,s){const{rows:r,columns:a}=s,o=r*a,l=o*e,h=new E.constructor(o);h.set(E.subarray(l,l+o));const f=i.utilities.VoxelManager.createImageVoxelManager({width:a,height:r,numberOfComponents:1,scalarData:h});return{imageId:t,dataType:E.constructor.name,columnPixelSpacing:s.columnPixelSpacing,columns:s.columns,height:s.rows,invert:"MONOCHROME1"===n.photometricInterpretation,rowPixelSpacing:s.rowPixelSpacing,rows:s.rows,sizeInBytes:r*a*E.BYTES_PER_ELEMENT,width:s.columns,getPixelData:()=>f.getScalarData(),getCanvas:void 0,numberOfComponents:void 0,voxelManager:f}}var T=s(976);const{windowLevel:x}=i.utilities;function N(t,e,i){const{numBitsPerVoxel:n,littleEndian:s,pixDims:r,dims:a}=t,{windowWidth:o,windowCenter:l}=(a[1],a[2],Math.floor(a[3]/2),{windowWidth:400,windowCenter:40}),h=T.vec3.create(),f=T.vec3.create(),c=T.vec3.create();return T.vec3.set(h,e[0],e[1],e[2]),T.vec3.set(f,e[3],e[4],e[5]),T.vec3.set(c,e[6],e[7],e[8]),{volumeMetadata:{BitsAllocated:n,BitsStored:n,SamplesPerPixel:1,HighBit:s?n-1:1,PhotometricInterpretation:"MONOCHROME2",PixelRepresentation:i,ImageOrientationPatient:[h[0],h[1],h[2],f[0],f[1],f[2]],PixelSpacing:[r[1],r[2]],Columns:a[1],Rows:a[2],voiLut:[{windowCenter:l,windowWidth:o}],FrameOfReferenceUID:"1.2.3",Modality:"MR",VOILUTFunction:"LINEAR"},dimensions:[a[1],a[2],a[3]],direction:new Float32Array([h[0],h[1],h[2],f[0],f[1],f[2],c[0],c[1],c[2]])}}const U="nifti",b=new Map,F=540,w=Math.max(348,F);async function S(t){let{url:e,onProgress:i,controller:s,onLoad:r,onHeader:a,loadFullVolume:o=!1}=t;const g=e.endsWith(".gz");let m,_=new Uint8Array(0),v=null;const I=s.signal;try{const t=await fetch(e,{signal:I});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);m=t.headers.get("Content-Length");const i=t.body.getReader(),n=g?new DecompressionStream("gzip"):null;if(async function(t,e,i,n,s,r){for(;;){const{done:n,value:a}=await t.read();if(n){i&&e.close();break}if(a.length,i?await e.write(a):s(a),r.signal.aborted)break}}(i,n?n.writable.getWriter():null,g,0,E,s).catch(console.error),g){const t=n.readable.getReader();for(;;){const{done:e,value:i}=await t.read();if(e)break;if(E(i),v&&!o){s.abort();break}}}return r&&"function"==typeof r&&r(),{data:_,headerInfo:v,sliceInfo:null}}catch(t){throw"AbortError"===t.name?console.log("Fetch aborted"):console.error("Fetch error:",t),t}function E(t){!function(t){const e=new Uint8Array(_.length+t.length);e.set(_),e.set(t,_.length),_=e,!o&&!v&&_.length>=w&&(v=function(t){if(t.length<w)return{isValid:!1,message:"Not enough data to check header"};try{const e=t.slice(0,w).buffer,i=n.readHeader(e),s=i.sizeof_hdr===F?2:1,{orientation:r,origin:a,spacing:o}=function(t){const{affine:e}=t,{orientation:i,origin:n,spacing:s}=function(t){const e=[t[0][3],t[1][3],t[2][3]],i=[Math.sqrt(t[0][0]**2+t[1][0]**2+t[2][0]**2),Math.sqrt(t[0][1]**2+t[1][1]**2+t[2][1]**2),Math.sqrt(t[0][2]**2+t[1][2]**2+t[2][2]**2)];return{origin:e,orientation:[t[0][0]/i[0],t[0][1]/i[1],t[0][2]/i[2],t[1][0]/i[0],t[1][1]/i[1],t[1][2]/i[2],t[2][0]/i[0],t[2][1]/i[1],t[2][2]/i[2]],spacing:i}}(e);return{origin:[-n[0],-n[1],n[2]],orientation:[-i[0],-i[3],i[6],-i[1],-i[4],i[7],-i[2],-i[5],i[8]],spacing:s}}(i),{dimensions:g,direction:m}=N(i,r,1);return{dimensions:g,direction:m,isValid:!0,message:`Valid Nifti-${s} header detected`,origin:a,version:s,orientation:r,spacing:o,header:i,arrayConstructor:function(t){switch(t){case l:return Uint8Array;case h:return Int16Array;case f:return Int32Array;case c:return Float32Array;case u:return Int8Array;case d:return Uint16Array;case p:return Uint32Array;default:throw new Error(`NIFTI datatypeCode ${t} is not yet supported`)}}(i.datatypeCode)}}catch(t){return console.error("Error reading Nifti header:",t),{isValid:!1,message:"Error reading Nifti header"}}}(_),v&&v.isValid&&s.abort(),a?.(v))}(t),i&&"function"==typeof i&&i(0,m)}}async function M(t){let{url:e}=t;return await async function(t){const e=t.substring(U.length+1),n=(e,n)=>{const s={volumeId:t,loaded:e,total:n};(0,i.triggerEvent)(i.eventTarget,o.NIFTI_VOLUME_PROGRESS,{data:s})},s=()=>{const e={volumeId:t};(0,i.triggerEvent)(i.eventTarget,o.NIFTI_VOLUME_LOADED,{data:e})},r=new AbortController;b.set(e,{controller:r,loading:!0});const a=await new Promise((t=>{S({url:e,onProgress:n,controller:r,onLoad:s,onHeader:t})})),{dimensions:l,direction:h,isValid:f,message:c,origin:u,version:d,header:p,spacing:g,arrayConstructor:m}=a,_=l[2];if(!f)return void console.error(c);const v=[];for(let t=0;t<_;t++){const n=`nifti:${e}?frame=${t}`,s=t;v.push(n);const r=[h[0],h[1],h[2],h[3],h[4],h[5]],a=6,o=[parseFloat((u[0]+s*h[6]*g[0]).toFixed(a)),parseFloat((u[1]+s*h[7]*g[1]).toFixed(a)),parseFloat((u[2]+s*h[8]*g[2]).toFixed(a))],f={frameOfReferenceUID:"1.2.840.10008.1.4",rows:l[1],columns:l[0],imageOrientationPatient:r,rowCosines:h.slice(0,3),columnCosines:h.slice(3,6),imagePositionPatient:o,sliceThickness:g[2],sliceLocation:u[2]+t*g[2],pixelSpacing:[g[0],g[1]],rowPixelSpacing:g[1],columnPixelSpacing:g[0]},c={samplesPerPixel:1,photometricInterpretation:"MONOCHROME2",rows:l[1],columns:l[0],bitsAllocated:8*m.BYTES_PER_ELEMENT,bitsStored:8*m.BYTES_PER_ELEMENT,highBit:8*m.BYTES_PER_ELEMENT-1,pixelRepresentation:1,planarConfiguration:0,pixelAspectRatio:"1\\1",redPaletteColorLookupTableDescriptor:[],greenPaletteColorLookupTableDescriptor:[],bluePaletteColorLookupTableDescriptor:[],redPaletteColorLookupTableData:[],greenPaletteColorLookupTableData:[],bluePaletteColorLookupTableData:[],smallestPixelValue:void 0,largestPixelValue:void 0},_={seriesDate:new Date,seriesTime:new Date};i.utilities.genericMetadataProvider.add(n,{type:"imagePixelModule",metadata:c}),i.utilities.genericMetadataProvider.add(n,{type:"imagePlaneModule",metadata:f}),i.utilities.genericMetadataProvider.add(n,{type:"generalSeriesModule",metadata:_}),i.utilities.genericMetadataProvider.add(n,{type:"niftiVersion",metadata:{version:d}}),i.utilities.genericMetadataProvider.addRaw(n,{type:"niftiHeader",metadata:{header:p}})}return b.delete(e),v}(e)}})(),r})()));
|
|
2
|
-
//# sourceMappingURL=index.js.map
|