nifti-reader-js
Advanced tools
Comparing version 0.6.4 to 0.6.5
{ | ||
"name": "nifti-reader-js", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "A JavaScript NIfTI file format reader.", | ||
"main": "src/nifti.js", | ||
"main": "dist/src/nifti.js", | ||
"types": "dist/src/nifti.d.ts", | ||
"directories": { | ||
@@ -13,11 +14,18 @@ "test": "tests" | ||
"devDependencies": { | ||
"@types/chai": "^4.3.5", | ||
"@types/mocha": "^10.0.1", | ||
"chai": "^4.3.7", | ||
"esbuild": "*", | ||
"jsdoc-to-markdown": "*", | ||
"mocha": "*" | ||
"mocha": "*", | ||
"ts-node": "^10.9.1", | ||
"tsify": "^5.0.4", | ||
"typescript": "^5.0.4" | ||
}, | ||
"scripts": { | ||
"test": "mocha --timeout 0 tests", | ||
"build": "rm -rf build; mkdir build; esbuild src/nifti.js --bundle --outfile=build/nifti-reader.js; esbuild src/nifti.js --bundle --minify --outfile=build/nifti-reader-min.js", | ||
"test": "mocha -r ts-node/register __tests__/**/*.spec.ts", | ||
"test-js": "npm run build; npm run release; mocha --timeout 0 tests", | ||
"build": "rm -rf build; mkdir build; tsc; esbuild dist/src/nifti.js --bundle --outfile=build/nifti-reader.js; esbuild dist/src/nifti.js --bundle --minify --outfile=build/nifti-reader-min.js", | ||
"release": "rm release/current/*.js; cp build/*.js release/current/.", | ||
"doc": "rm -rf build; mkdir build; ./node_modules/.bin/jsdoc2md src/*.js > build/docs.md" | ||
"doc": "rm -rf build; mkdir build; ./node_modules/.bin/jsdoc2md dist/src/*.js > build/docs.md" | ||
}, | ||
@@ -24,0 +32,0 @@ "repository": { |
@@ -1,54 +0,54 @@ | ||
"use strict";(()=>{var H=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+i+'" is not supported')});var vt=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var Tt=vt((He,bt)=>{"use strict";var zt=zt||{};zt.NIFTIEXTENSION=zt.NIFTIEXTENSION||function(i,t,e,n){if(i%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=i,this.ecode=t,this.edata=e,this.littleEndian=n};zt.NIFTIEXTENSION.prototype.toArrayBuffer=function(){let i=new Uint8Array(this.esize);i.set(this.data.buffer,8);let t=new DataView(i.buffer);return t.setInt32(0,this.esize,this.littleEndian),t.setInt32(4,this.ecode,this.littleEndian),i.buffer};var _e=typeof bt;_e!=="undefined"&&bt.exports&&(bt.exports=zt.NIFTIEXTENSION)});var kt=vt((Qe,Zt)=>{"use strict";var P=P||{};P.Utils=P.Utils||{};P.NIFTIEXTENSION=P.NIFTIEXTENSION||(typeof H<"u"?Tt():null);P.Utils.crcTable=null;P.Utils.GUNZIP_MAGIC_COOKIE1=31;P.Utils.GUNZIP_MAGIC_COOKIE2=139;P.Utils.getStringAt=function(i,t,e){var n="",r,s;for(r=t;r<e;r+=1)s=i.getUint8(r),s!==0&&(n+=String.fromCharCode(s));return n};P.Utils.getByteAt=function(i,t){return i.getInt8(t)};P.Utils.getShortAt=function(i,t,e){return i.getInt16(t,e)};P.Utils.getIntAt=function(i,t,e){return i.getInt32(t,e)};P.Utils.getFloatAt=function(i,t,e){return i.getFloat32(t,e)};P.Utils.getDoubleAt=function(i,t,e){return i.getFloat64(t,e)};P.Utils.getLongAt=function(i,t,e){var n,r=[],s=0;for(n=0;n<8;n+=1)r[n]=P.Utils.getByteAt(i,t+n,e);for(n=r.length-1;n>=0;n--)s=s*256+r[n];return s};P.Utils.getExtensionsAt=function(i,t,e,n){let r=[],s=t;for(;s<n;){let l=e,a=P.Utils.getIntAt(i,s,e);if(!a)break;if(a+s>n&&(l=!l,a=P.Utils.getIntAt(i,s,l),a+s>n))throw new Error("This does not appear to be a valid NIFTI extension");if(a%16!=0)throw new Error("This does not appear to be a NIFTI extension");let h=P.Utils.getIntAt(i,s+4,l),f=i.buffer.slice(s+8,s+a);console.log("extensionByteIndex: "+(s+8)+" esize: "+a),console.log(f);let o=new P.NIFTIEXTENSION(a,h,f,l);r.push(o),s+=a}return r};P.Utils.toArrayBuffer=function(i){var t,e,n;for(t=new ArrayBuffer(i.length),e=new Uint8Array(t),n=0;n<i.length;n+=1)e[n]=i[n];return t};P.Utils.isString=function(i){return typeof i=="string"||i instanceof String};P.Utils.formatNumber=function(i,t){var e=0;return P.Utils.isString(i)?e=Number(i):e=i,t?e=e.toPrecision(5):e=e.toPrecision(7),parseFloat(e)};P.Utils.makeCRCTable=function(){for(var i,t=[],e=0;e<256;e++){i=e;for(var n=0;n<8;n++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i}return t};P.Utils.crc32=function(i){for(var t=P.Utils.crcTable||(P.Utils.crcTable=P.Utils.makeCRCTable()),e=-1,n=0;n<i.byteLength;n++)e=e>>>8^t[(e^i.getUint8(n))&255];return(e^-1)>>>0};var Fe=typeof Zt;Fe!=="undefined"&&Zt.exports&&(Zt.exports=P.Utils)});var li=vt((We,Yt)=>{"use strict";var $e=Tt(),u=u||{};u.Utils=u.Utils||(typeof H<"u"?kt():null);u.NIFTIEXTENSION=u.NIFTIEXTENSION||(typeof H<"u"?Tt():null);u.NIFTI1=u.NIFTI1||function(){this.littleEndian=!1,this.dim_info=0,this.dims=[],this.intent_p1=0,this.intent_p2=0,this.intent_p3=0,this.intent_code=0,this.datatypeCode=0,this.numBitsPerVoxel=0,this.slice_start=0,this.slice_end=0,this.slice_code=0,this.pixDims=[],this.vox_offset=0,this.scl_slope=1,this.scl_inter=0,this.xyzt_units=0,this.cal_max=0,this.cal_min=0,this.slice_duration=0,this.toffset=0,this.description="",this.aux_file="",this.intent_name="",this.qform_code=0,this.sform_code=0,this.quatern_b=0,this.quatern_c=0,this.quatern_d=0,this.qoffset_x=0,this.qoffset_y=0,this.qoffset_z=0,this.affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],this.magic=0,this.isHDR=!1,this.extensionFlag=[0,0,0,0],this.extensionSize=0,this.extensionCode=0,this.extensions=[]};u.NIFTI1.TYPE_NONE=0;u.NIFTI1.TYPE_BINARY=1;u.NIFTI1.TYPE_UINT8=2;u.NIFTI1.TYPE_INT16=4;u.NIFTI1.TYPE_INT32=8;u.NIFTI1.TYPE_FLOAT32=16;u.NIFTI1.TYPE_COMPLEX64=32;u.NIFTI1.TYPE_FLOAT64=64;u.NIFTI1.TYPE_RGB24=128;u.NIFTI1.TYPE_INT8=256;u.NIFTI1.TYPE_UINT16=512;u.NIFTI1.TYPE_UINT32=768;u.NIFTI1.TYPE_INT64=1024;u.NIFTI1.TYPE_UINT64=1280;u.NIFTI1.TYPE_FLOAT128=1536;u.NIFTI1.TYPE_COMPLEX128=1792;u.NIFTI1.TYPE_COMPLEX256=2048;u.NIFTI1.XFORM_UNKNOWN=0;u.NIFTI1.XFORM_SCANNER_ANAT=1;u.NIFTI1.XFORM_ALIGNED_ANAT=2;u.NIFTI1.XFORM_TALAIRACH=3;u.NIFTI1.XFORM_MNI_152=4;u.NIFTI1.SPATIAL_UNITS_MASK=7;u.NIFTI1.TEMPORAL_UNITS_MASK=56;u.NIFTI1.UNITS_UNKNOWN=0;u.NIFTI1.UNITS_METER=1;u.NIFTI1.UNITS_MM=2;u.NIFTI1.UNITS_MICRON=3;u.NIFTI1.UNITS_SEC=8;u.NIFTI1.UNITS_MSEC=16;u.NIFTI1.UNITS_USEC=24;u.NIFTI1.UNITS_HZ=32;u.NIFTI1.UNITS_PPM=40;u.NIFTI1.UNITS_RADS=48;u.NIFTI1.MAGIC_COOKIE=348;u.NIFTI1.STANDARD_HEADER_SIZE=348;u.NIFTI1.MAGIC_NUMBER_LOCATION=344;u.NIFTI1.MAGIC_NUMBER=[110,43,49];u.NIFTI1.MAGIC_NUMBER2=[110,105,49];u.NIFTI1.EXTENSION_HEADER_SIZE=8;u.NIFTI1.prototype.readHeader=function(i){var t=new DataView(i),e=u.Utils.getIntAt(t,0,this.littleEndian),n,r,s,l;if(e!==u.NIFTI1.MAGIC_COOKIE&&(this.littleEndian=!0,e=u.Utils.getIntAt(t,0,this.littleEndian)),e!==u.NIFTI1.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=u.Utils.getByteAt(t,39),n=0;n<8;n+=1)l=40+n*2,this.dims[n]=u.Utils.getShortAt(t,l,this.littleEndian);for(this.intent_p1=u.Utils.getFloatAt(t,56,this.littleEndian),this.intent_p2=u.Utils.getFloatAt(t,60,this.littleEndian),this.intent_p3=u.Utils.getFloatAt(t,64,this.littleEndian),this.intent_code=u.Utils.getShortAt(t,68,this.littleEndian),this.datatypeCode=u.Utils.getShortAt(t,70,this.littleEndian),this.numBitsPerVoxel=u.Utils.getShortAt(t,72,this.littleEndian),this.slice_start=u.Utils.getShortAt(t,74,this.littleEndian),n=0;n<8;n+=1)l=76+n*4,this.pixDims[n]=u.Utils.getFloatAt(t,l,this.littleEndian);if(this.vox_offset=u.Utils.getFloatAt(t,108,this.littleEndian),this.scl_slope=u.Utils.getFloatAt(t,112,this.littleEndian),this.scl_inter=u.Utils.getFloatAt(t,116,this.littleEndian),this.slice_end=u.Utils.getShortAt(t,120,this.littleEndian),this.slice_code=u.Utils.getByteAt(t,122),this.xyzt_units=u.Utils.getByteAt(t,123),this.cal_max=u.Utils.getFloatAt(t,124,this.littleEndian),this.cal_min=u.Utils.getFloatAt(t,128,this.littleEndian),this.slice_duration=u.Utils.getFloatAt(t,132,this.littleEndian),this.toffset=u.Utils.getFloatAt(t,136,this.littleEndian),this.description=u.Utils.getStringAt(t,148,228),this.aux_file=u.Utils.getStringAt(t,228,252),this.qform_code=u.Utils.getShortAt(t,252,this.littleEndian),this.sform_code=u.Utils.getShortAt(t,254,this.littleEndian),this.quatern_b=u.Utils.getFloatAt(t,256,this.littleEndian),this.quatern_c=u.Utils.getFloatAt(t,260,this.littleEndian),this.quatern_d=u.Utils.getFloatAt(t,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=u.Utils.getFloatAt(t,268,this.littleEndian),this.qoffset_y=u.Utils.getFloatAt(t,272,this.littleEndian),this.qoffset_z=u.Utils.getFloatAt(t,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){let a=this.quatern_a,h=this.quatern_b,f=this.quatern_c,o=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[a*a+h*h-f*f-o*o,2*h*f-2*a*o,2*h*o+2*a*f],[2*h*f+2*a*o,a*a+f*f-h*h-o*o,2*f*o-2*a*h],[2*h*o-2*a*f,2*f*o+2*a*h,a*a+o*o-f*f-h*h]],r=0;r<3;r+=1)for(s=0;s<3;s+=1)this.affine[r][s]=this.quatern_R[r][s]*this.pixDims[s+1],s===2&&(this.affine[r][s]*=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(r=0;r<3;r+=1)for(s=0;s<4;s+=1)l=280+(r*4+s)*4,this.affine[r][s]=u.Utils.getFloatAt(t,l,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=u.Utils.getStringAt(t,328,344),this.magic=u.Utils.getStringAt(t,344,348),this.isHDR=this.magic===u.NIFTI1.MAGIC_NUMBER2,t.byteLength>u.NIFTI1.MAGIC_COOKIE&&(this.extensionFlag[0]=u.Utils.getByteAt(t,348),this.extensionFlag[1]=u.Utils.getByteAt(t,348+1),this.extensionFlag[2]=u.Utils.getByteAt(t,348+2),this.extensionFlag[3]=u.Utils.getByteAt(t,348+3),this.extensionFlag[0]&&(this.extensions=u.Utils.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))};u.NIFTI1.prototype.toFormattedString=function(){var i=u.Utils.formatNumber,t="";return t+="Dim Info = "+this.dim_info+` | ||
`,t+="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]+` | ||
`,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+` | ||
`,t+="Intent Code = "+this.intent_code+` | ||
`,t+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`) | ||
`,t+="Bits Per Voxel = "+this.numBitsPerVoxel+` | ||
`,t+="Slice Start = "+this.slice_start+` | ||
`,t+="Voxel Dimensions (1-8): "+i(this.pixDims[0])+", "+i(this.pixDims[1])+", "+i(this.pixDims[2])+", "+i(this.pixDims[3])+", "+i(this.pixDims[4])+", "+i(this.pixDims[5])+", "+i(this.pixDims[6])+", "+i(this.pixDims[7])+` | ||
`,t+="Image Offset = "+this.vox_offset+` | ||
`,t+="Data Scale: Slope = "+i(this.scl_slope)+" Intercept = "+i(this.scl_inter)+` | ||
`,t+="Slice End = "+this.slice_end+` | ||
`,t+="Slice Code = "+this.slice_code+` | ||
`,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(u.NIFTI1.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(u.NIFTI1.TEMPORAL_UNITS_MASK&this.xyzt_units)+`) | ||
`,t+="Display Range: Max = "+i(this.cal_max)+" Min = "+i(this.cal_min)+` | ||
`,t+="Slice Duration = "+this.slice_duration+` | ||
`,t+="Time Axis Shift = "+this.toffset+` | ||
`,t+='Description: "'+this.description+`" | ||
`,t+='Auxiliary File: "'+this.aux_file+`" | ||
`,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`) | ||
`,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`) | ||
`,t+="Quaternion Parameters: b = "+i(this.quatern_b)+" c = "+i(this.quatern_c)+" d = "+i(this.quatern_d)+` | ||
`,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+` | ||
`,t+="S-Form Parameters X: "+i(this.affine[0][0])+", "+i(this.affine[0][1])+", "+i(this.affine[0][2])+", "+i(this.affine[0][3])+` | ||
`,t+="S-Form Parameters Y: "+i(this.affine[1][0])+", "+i(this.affine[1][1])+", "+i(this.affine[1][2])+", "+i(this.affine[1][3])+` | ||
`,t+="S-Form Parameters Z: "+i(this.affine[2][0])+", "+i(this.affine[2][1])+", "+i(this.affine[2][2])+", "+i(this.affine[2][3])+` | ||
`,t+='Intent Name: "'+this.intent_name+`" | ||
`,this.extensionFlag[0]&&(t+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+` | ||
`),t};u.NIFTI1.prototype.getDatatypeCodeString=function(i){return i===u.NIFTI1.TYPE_UINT8?"1-Byte Unsigned Integer":i===u.NIFTI1.TYPE_INT16?"2-Byte Signed Integer":i===u.NIFTI1.TYPE_INT32?"4-Byte Signed Integer":i===u.NIFTI1.TYPE_FLOAT32?"4-Byte Float":i===u.NIFTI1.TYPE_FLOAT64?"8-Byte Float":i===u.NIFTI1.TYPE_RGB24?"RGB":i===u.NIFTI1.TYPE_INT8?"1-Byte Signed Integer":i===u.NIFTI1.TYPE_UINT16?"2-Byte Unsigned Integer":i===u.NIFTI1.TYPE_UINT32?"4-Byte Unsigned Integer":i===u.NIFTI1.TYPE_INT64?"8-Byte Signed Integer":i===u.NIFTI1.TYPE_UINT64?"8-Byte Unsigned Integer":"Unknown"};u.NIFTI1.prototype.getTransformCodeString=function(i){return i===u.NIFTI1.XFORM_SCANNER_ANAT?"Scanner":i===u.NIFTI1.XFORM_ALIGNED_ANAT?"Aligned":i===u.NIFTI1.XFORM_TALAIRACH?"Talairach":i===u.NIFTI1.XFORM_MNI_152?"MNI":"Unknown"};u.NIFTI1.prototype.getUnitsCodeString=function(i){return i===u.NIFTI1.UNITS_METER?"Meters":i===u.NIFTI1.UNITS_MM?"Millimeters":i===u.NIFTI1.UNITS_MICRON?"Microns":i===u.NIFTI1.UNITS_SEC?"Seconds":i===u.NIFTI1.UNITS_MSEC?"Milliseconds":i===u.NIFTI1.UNITS_USEC?"Microseconds":i===u.NIFTI1.UNITS_HZ?"Hz":i===u.NIFTI1.UNITS_PPM?"PPM":i===u.NIFTI1.UNITS_RADS?"Rads":"Unknown"};u.NIFTI1.prototype.getQformMat=function(){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])};u.NIFTI1.prototype.convertNiftiQFormToNiftiSForm=function(i,t,e,n,r,s,l,a,h,f){var o=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],c,p=i,m=t,g=e,d,v,E;return o[3][0]=o[3][1]=o[3][2]=0,o[3][3]=1,c=1-(p*p+m*m+g*g),c<1e-7?(c=1/Math.sqrt(p*p+m*m+g*g),p*=c,m*=c,g*=c,c=0):c=Math.sqrt(c),d=l>0?l:1,v=a>0?a:1,E=h>0?h:1,f<0&&(E=-E),o[0][0]=(c*c+p*p-m*m-g*g)*d,o[0][1]=2*(p*m-c*g)*v,o[0][2]=2*(p*g+c*m)*E,o[1][0]=2*(p*m+c*g)*d,o[1][1]=(c*c+m*m-p*p-g*g)*v,o[1][2]=2*(m*g-c*p)*E,o[2][0]=2*(p*g-c*m)*d,o[2][1]=2*(m*g+c*p)*v,o[2][2]=(c*c+g*g-m*m-p*p)*E,o[0][3]=n,o[1][3]=r,o[2][3]=s,o};u.NIFTI1.prototype.convertNiftiSFormToNEMA=function(i){var t,e,n,r,s,l,a,h,f,o,c,p,m,g,d,v,E,A,x,y,L,z,U,T,Z,C,b,S,q,w,O,D,B,k;if(d=0,b=[[0,0,0],[0,0,0],[0,0,0]],S=[[0,0,0],[0,0,0],[0,0,0]],t=i[0][0],e=i[0][1],n=i[0][2],r=i[1][0],s=i[1][1],l=i[1][2],a=i[2][0],h=i[2][1],f=i[2][2],o=Math.sqrt(t*t+r*r+a*a),o===0||(t/=o,r/=o,a/=o,o=Math.sqrt(e*e+s*s+h*h),o===0))return null;if(e/=o,s/=o,h/=o,o=t*e+r*s+a*h,Math.abs(o)>1e-4){if(e-=o*t,s-=o*r,h-=o*a,o=Math.sqrt(e*e+s*s+h*h),o===0)return null;e/=o,s/=o,h/=o}if(o=Math.sqrt(n*n+l*l+f*f),o===0?(n=r*h-a*s,l=a*e-h*t,f=t*s-r*e):(n/=o,l/=o,f/=o),o=t*n+r*l+a*f,Math.abs(o)>1e-4){if(n-=o*t,l-=o*r,f-=o*a,o=Math.sqrt(n*n+l*l+f*f),o===0)return null;n/=o,l/=o,f/=o}if(o=e*n+s*l+h*f,Math.abs(o)>1e-4){if(n-=o*e,l-=o*s,f-=o*h,o=Math.sqrt(n*n+l*l+f*f),o===0)return null;n/=o,l/=o,f/=o}if(b[0][0]=t,b[0][1]=e,b[0][2]=n,b[1][0]=r,b[1][1]=s,b[1][2]=l,b[2][0]=a,b[2][1]=h,b[2][2]=f,c=this.nifti_mat33_determ(b),c===0)return null;for(C=-666,x=z=U=T=1,y=2,L=3,m=1;m<=3;m+=1)for(g=1;g<=3;g+=1)if(m!==g){for(d=1;d<=3;d+=1)if(!(m===d||g===d))for(S[0][0]=S[0][1]=S[0][2]=S[1][0]=S[1][1]=S[1][2]=S[2][0]=S[2][1]=S[2][2]=0,v=-1;v<=1;v+=2)for(E=-1;E<=1;E+=2)for(A=-1;A<=1;A+=2)S[0][m-1]=v,S[1][g-1]=E,S[2][d-1]=A,p=this.nifti_mat33_determ(S),p*c>0&&(Z=this.nifti_mat33_mul(S,b),o=Z[0][0]+Z[1][1]+Z[2][2],o>C&&(C=o,x=m,y=g,L=d,z=v,U=E,T=A))}switch(q=w=O=D=B=k=0,x*z){case 1:q="X",D="+";break;case-1:q="X",D="-";break;case 2:q="Y",D="+";break;case-2:q="Y",D="-";break;case 3:q="Z",D="+";break;case-3:q="Z",D="-";break}switch(y*U){case 1:w="X",B="+";break;case-1:w="X",B="-";break;case 2:w="Y",B="+";break;case-2:w="Y",B="-";break;case 3:w="Z",B="+";break;case-3:w="Z",B="-";break}switch(L*T){case 1:O="X",k="+";break;case-1:O="X",k="-";break;case 2:O="Y",k="+";break;case-2:O="Y",k="-";break;case 3:O="Z",k="+";break;case-3:O="Z",k="-";break}return q+w+O+D+B+k};u.NIFTI1.prototype.nifti_mat33_mul=function(i,t){var e=[[0,0,0],[0,0,0],[0,0,0]],n,r;for(n=0;n<3;n+=1)for(r=0;r<3;r+=1)e[n][r]=i[n][0]*t[0][r]+i[n][1]*t[1][r]+i[n][2]*t[2][r];return e};u.NIFTI1.prototype.nifti_mat33_determ=function(i){var t,e,n,r,s,l,a,h,f;return t=i[0][0],e=i[0][1],n=i[0][2],r=i[1][0],s=i[1][1],l=i[1][2],a=i[2][0],h=i[2][1],f=i[2][2],t*s*f-t*h*l-r*e*f+r*h*n+a*e*l-a*s*n};u.NIFTI1.prototype.getExtensionLocation=function(){return u.NIFTI1.MAGIC_COOKIE+4};u.NIFTI1.prototype.getExtensionSize=function(i){return u.Utils.getIntAt(i,this.getExtensionLocation(),this.littleEndian)};u.NIFTI1.prototype.getExtensionCode=function(i){return u.Utils.getIntAt(i,this.getExtensionLocation()+4,this.littleEndian)};u.NIFTI1.prototype.addExtension=function(i,t=-1){t==-1?this.extensions.push(i):this.extensions.splice(t,0,i),this.vox_offset+=i.esize};u.NIFTI1.prototype.removeExtension=function(i){let t=this.extensions[i];t&&(this.vox_offset-=t.esize),this.extensions.splice(i,1)};u.NIFTI1.prototype.toArrayBuffer=function(i=!1){let n=352;if(i)for(let a of this.extensions)n+=a.esize;let r=new Uint8Array(n),s=new DataView(r.buffer);s.setInt32(0,348,this.littleEndian),s.setUint8(39,this.dim_info);for(let a=0;a<8;a++)s.setUint16(40+2*a,this.dims[a],this.littleEndian);s.setFloat32(56,this.intent_p1,this.littleEndian),s.setFloat32(60,this.intent_p2,this.littleEndian),s.setFloat32(64,this.intent_p3,this.littleEndian),s.setInt16(68,this.intent_code,this.littleEndian),s.setInt16(70,this.datatypeCode,this.littleEndian),s.setInt16(72,this.numBitsPerVoxel,this.littleEndian),s.setInt16(74,this.slice_start,this.littleEndian);for(let a=0;a<8;a++)s.setFloat32(76+4*a,this.pixDims[a],this.littleEndian);s.setFloat32(108,this.vox_offset,this.littleEndian),s.setFloat32(112,this.scl_slope,this.littleEndian),s.setFloat32(116,this.scl_inter,this.littleEndian),s.setInt16(120,this.slice_end,this.littleEndian),s.setUint8(122,this.slice_code),s.setUint8(123,this.xyzt_units),s.setFloat32(124,this.cal_max,this.littleEndian),s.setFloat32(128,this.cal_min,this.littleEndian),s.setFloat32(132,this.slice_duration,this.littleEndian),s.setFloat32(136,this.toffset,this.littleEndian),r.set(Buffer.from(this.description),148),r.set(Buffer.from(this.aux_file),228),s.setInt16(252,this.qform_code,this.littleEndian),s.setInt16(254,this.sform_code,this.littleEndian),s.setFloat32(256,this.quatern_b,this.littleEndian),s.setFloat32(260,this.quatern_c,this.littleEndian),s.setFloat32(264,this.quatern_d,this.littleEndian),s.setFloat32(268,this.qoffset_x,this.littleEndian),s.setFloat32(272,this.qoffset_y,this.littleEndian),s.setFloat32(276,this.qoffset_z,this.littleEndian);let l=this.affine.flat();for(let a=0;a<12;a++)s.setFloat32(280+4*a,l[a],this.littleEndian);if(r.set(Buffer.from(this.intent_name),328),r.set(Buffer.from(this.magic),344),i){r.set(Uint8Array.from([1,0,0,0]),348);let a=this.getExtensionLocation();for(let h of this.extensions)s.setInt32(a,h.esize,h.littleEndian),s.setInt32(a+4,h.ecode,h.littleEndian),r.set(new Uint8Array(h.edata),a+8),a+=h.esize}else r.set(new Uint8Array(4).fill(0),348);return r.buffer};var ye=typeof Yt;ye!=="undefined"&&Yt.exports&&(Yt.exports=u.NIFTI1)});var zi=vt((tn,Xt)=>{"use strict";var I=I||{};I.Utils=I.Utils||(typeof H<"u"?kt():null);I.NIFTI1=I.NIFTI1||(typeof H<"u"?li():null);I.NIFTIEXTENSION=I.NIFTIEXTENSION||(typeof H<"u"?Tt():null);I.NIFTI2=I.NIFTI2||function(){this.littleEndian=!1,this.dim_info=0,this.dims=[],this.intent_p1=0,this.intent_p2=0,this.intent_p3=0,this.intent_code=0,this.datatypeCode=0,this.numBitsPerVoxel=0,this.slice_start=0,this.slice_end=0,this.slice_code=0,this.pixDims=[],this.vox_offset=0,this.scl_slope=1,this.scl_inter=0,this.xyzt_units=0,this.cal_max=0,this.cal_min=0,this.slice_duration=0,this.toffset=0,this.description="",this.aux_file="",this.intent_name="",this.qform_code=0,this.sform_code=0,this.quatern_b=0,this.quatern_c=0,this.quatern_d=0,this.qoffset_x=0,this.qoffset_y=0,this.qoffset_z=0,this.affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],this.magic=0,this.extensionFlag=[0,0,0,0],this.extensions=[]};I.NIFTI2.MAGIC_COOKIE=540;I.NIFTI2.MAGIC_NUMBER_LOCATION=4;I.NIFTI2.MAGIC_NUMBER=[110,43,50,0,13,10,26,10];I.NIFTI2.MAGIC_NUMBER2=[110,105,50,0,13,10,26,10];I.NIFTI2.prototype.readHeader=function(i){var t=new DataView(i),e=I.Utils.getIntAt(t,0,this.littleEndian),n,r,s,l,a;if(e!==I.NIFTI2.MAGIC_COOKIE&&(this.littleEndian=!0,e=I.Utils.getIntAt(t,0,this.littleEndian)),e!==I.NIFTI2.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.magic=I.Utils.getStringAt(t,4,12),this.datatypeCode=I.Utils.getShortAt(t,12,this.littleEndian),this.numBitsPerVoxel=I.Utils.getShortAt(t,14,this.littleEndian),n=0;n<8;n+=1)l=16+n*8,this.dims[n]=I.Utils.getLongAt(t,l,this.littleEndian);for(this.intent_p1=I.Utils.getDoubleAt(t,80,this.littleEndian),this.intent_p2=I.Utils.getDoubleAt(t,88,this.littleEndian),this.intent_p3=I.Utils.getDoubleAt(t,96,this.littleEndian),n=0;n<8;n+=1)l=104+n*8,this.pixDims[n]=I.Utils.getDoubleAt(t,l,this.littleEndian);for(this.vox_offset=I.Utils.getLongAt(t,168,this.littleEndian),this.scl_slope=I.Utils.getDoubleAt(t,176,this.littleEndian),this.scl_inter=I.Utils.getDoubleAt(t,184,this.littleEndian),this.cal_max=I.Utils.getDoubleAt(t,192,this.littleEndian),this.cal_min=I.Utils.getDoubleAt(t,200,this.littleEndian),this.slice_duration=I.Utils.getDoubleAt(t,208,this.littleEndian),this.toffset=I.Utils.getDoubleAt(t,216,this.littleEndian),this.slice_start=I.Utils.getLongAt(t,224,this.littleEndian),this.slice_end=I.Utils.getLongAt(t,232,this.littleEndian),this.description=I.Utils.getStringAt(t,240,240+80),this.aux_file=I.Utils.getStringAt(t,320,320+24),this.qform_code=I.Utils.getIntAt(t,344,this.littleEndian),this.sform_code=I.Utils.getIntAt(t,348,this.littleEndian),this.quatern_b=I.Utils.getDoubleAt(t,352,this.littleEndian),this.quatern_c=I.Utils.getDoubleAt(t,360,this.littleEndian),this.quatern_d=I.Utils.getDoubleAt(t,368,this.littleEndian),this.qoffset_x=I.Utils.getDoubleAt(t,376,this.littleEndian),this.qoffset_y=I.Utils.getDoubleAt(t,384,this.littleEndian),this.qoffset_z=I.Utils.getDoubleAt(t,392,this.littleEndian),r=0;r<3;r+=1)for(s=0;s<4;s+=1)l=400+(r*4+s)*8,this.affine[r][s]=I.Utils.getDoubleAt(t,l,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=I.Utils.getIntAt(t,496,this.littleEndian),this.xyzt_units=I.Utils.getIntAt(t,500,this.littleEndian),this.intent_code=I.Utils.getIntAt(t,504,this.littleEndian),this.intent_name=I.Utils.getStringAt(t,508,508+16),this.dim_info=I.Utils.getByteAt(t,524),t.byteLength>I.NIFTI2.MAGIC_COOKIE&&(this.extensionFlag[0]=I.Utils.getByteAt(t,540),this.extensionFlag[1]=I.Utils.getByteAt(t,540+1),this.extensionFlag[2]=I.Utils.getByteAt(t,540+2),this.extensionFlag[3]=I.Utils.getByteAt(t,540+3),this.extensionFlag[0]&&(this.extensions=I.Utils.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))};I.NIFTI2.prototype.toFormattedString=function(){var i=I.Utils.formatNumber,t="";return t+="Datatype = "+ +this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`) | ||
`,t+="Bits Per Voxel = = "+this.numBitsPerVoxel+` | ||
`,t+="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]+` | ||
`,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+` | ||
`,t+="Voxel Dimensions (1-8): "+i(this.pixDims[0])+", "+i(this.pixDims[1])+", "+i(this.pixDims[2])+", "+i(this.pixDims[3])+", "+i(this.pixDims[4])+", "+i(this.pixDims[5])+", "+i(this.pixDims[6])+", "+i(this.pixDims[7])+` | ||
`,t+="Image Offset = "+this.vox_offset+` | ||
`,t+="Data Scale: Slope = "+i(this.scl_slope)+" Intercept = "+i(this.scl_inter)+` | ||
`,t+="Display Range: Max = "+i(this.cal_max)+" Min = "+i(this.cal_min)+` | ||
`,t+="Slice Duration = "+this.slice_duration+` | ||
`,t+="Time Axis Shift = "+this.toffset+` | ||
`,t+="Slice Start = "+this.slice_start+` | ||
`,t+="Slice End = "+this.slice_end+` | ||
`,t+='Description: "'+this.description+`" | ||
`,t+='Auxiliary File: "'+this.aux_file+`" | ||
`,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`) | ||
`,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`) | ||
`,t+="Quaternion Parameters: b = "+i(this.quatern_b)+" c = "+i(this.quatern_c)+" d = "+i(this.quatern_d)+` | ||
`,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+` | ||
`,t+="S-Form Parameters X: "+i(this.affine[0][0])+", "+i(this.affine[0][1])+", "+i(this.affine[0][2])+", "+i(this.affine[0][3])+` | ||
`,t+="S-Form Parameters Y: "+i(this.affine[1][0])+", "+i(this.affine[1][1])+", "+i(this.affine[1][2])+", "+i(this.affine[1][3])+` | ||
`,t+="S-Form Parameters Z: "+i(this.affine[2][0])+", "+i(this.affine[2][1])+", "+i(this.affine[2][2])+", "+i(this.affine[2][3])+` | ||
`,t+="Slice Code = "+this.slice_code+` | ||
`,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(I.NIFTI1.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(I.NIFTI1.TEMPORAL_UNITS_MASK&this.xyzt_units)+`) | ||
`,t+="Intent Code = "+this.intent_code+` | ||
`,t+='Intent Name: "'+this.intent_name+`" | ||
`,t+="Dim Info = "+this.dim_info+` | ||
`,t};I.NIFTI2.prototype.getExtensionLocation=function(){return I.NIFTI2.MAGIC_COOKIE+4};I.NIFTI2.prototype.getExtensionSize=I.NIFTI1.prototype.getExtensionSize;I.NIFTI2.prototype.getExtensionCode=I.NIFTI1.prototype.getExtensionCode;I.NIFTI2.prototype.addExtension=I.NIFTI1.prototype.addExtension;I.NIFTI2.prototype.removeExtension=I.NIFTI1.prototype.removeExtension;I.NIFTI2.prototype.getDatatypeCodeString=I.NIFTI1.prototype.getDatatypeCodeString;I.NIFTI2.prototype.getTransformCodeString=I.NIFTI1.prototype.getTransformCodeString;I.NIFTI2.prototype.getUnitsCodeString=I.NIFTI1.prototype.getUnitsCodeString;I.NIFTI2.prototype.getQformMat=I.NIFTI1.prototype.getQformMat;I.NIFTI2.prototype.convertNiftiQFormToNiftiSForm=I.NIFTI1.prototype.convertNiftiQFormToNiftiSForm;I.NIFTI2.prototype.convertNiftiSFormToNEMA=I.NIFTI1.prototype.convertNiftiSFormToNEMA;I.NIFTI2.prototype.nifti_mat33_mul=I.NIFTI1.prototype.nifti_mat33_mul;I.NIFTI2.prototype.nifti_mat33_determ=I.NIFTI1.prototype.nifti_mat33_determ;I.NIFTI2.prototype.toArrayBuffer=function(i=!1){let n=544;if(i)for(let a of this.extensions)n+=a.esize;let r=new Uint8Array(n),s=new DataView(r.buffer);s.setInt32(0,540,this.littleEndian),r.set(Buffer.from(this.magic),4),s.setInt16(12,this.datatypeCode,this.littleEndian),s.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let a=0;a<8;a++)s.setBigInt64(16+8*a,BigInt(this.dims[a]),this.littleEndian);s.setFloat64(80,this.intent_p1,this.littleEndian),s.setFloat64(88,this.intent_p2,this.littleEndian),s.setFloat64(96,this.intent_p3,this.littleEndian);for(let a=0;a<8;a++)s.setFloat64(104+8*a,this.pixDims[a],this.littleEndian);s.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),s.setFloat64(176,this.scl_slope,this.littleEndian),s.setFloat64(184,this.scl_inter,this.littleEndian),s.setFloat64(192,this.cal_max,this.littleEndian),s.setFloat64(200,this.cal_min,this.littleEndian),s.setFloat64(208,this.slice_duration,this.littleEndian),s.setFloat64(216,this.toffset,this.littleEndian),s.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),s.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),r.set(Buffer.from(this.description),240),r.set(Buffer.from(this.aux_file),320),s.setInt32(344,this.qform_code,this.littleEndian),s.setInt32(348,this.sform_code,this.littleEndian),s.setFloat64(352,this.quatern_b,this.littleEndian),s.setFloat64(360,this.quatern_c,this.littleEndian),s.setFloat64(368,this.quatern_d,this.littleEndian),s.setFloat64(376,this.qoffset_x,this.littleEndian),s.setFloat64(384,this.qoffset_y,this.littleEndian),s.setFloat64(392,this.qoffset_z,this.littleEndian);let l=this.affine.flat();for(let a=0;a<12;a++)s.setFloat64(400+8*a,l[a],this.littleEndian);if(s.setInt32(496,this.slice_code,this.littleEndian),s.setInt32(500,this.xyzt_units,this.littleEndian),s.setInt32(504,this.intent_code,this.littleEndian),r.set(Buffer.from(this.intent_name),508),s.setUint8(524,this.dim_info),i){r.set(Uint8Array.from([1,0,0,0]),540);let a=this.getExtensionLocation();for(let h of this.extensions)s.setInt32(a,h.esize,h.littleEndian),s.setInt32(a+4,h.ecode,h.littleEndian),r.set(new Uint8Array(h.edata),a+8),a+=h.esize}else r.set(new Uint8Array(4).fill(0),540);return r.buffer};var Ae=typeof Xt;Ae!=="undefined"&&Xt.exports&&(Xt.exports=I.NIFTI2)});var Bi=vt(qi=>{"use strict";var Di={};qi.default=function(i,t,e,n,r){var s=new Worker(Di[t]||(Di[t]=URL.createObjectURL(new Blob([i+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return s.onmessage=function(l){var a=l.data,h=a.$e$;if(h){var f=new Error(h[0]);f.code=h[1],f.stack=h[2],r(f,null)}else r(null,a)},s.postMessage(e,n),s}});var de=vt(_=>{"use strict";var Ue=Bi(),M=Uint8Array,V=Uint16Array,_t=Uint32Array,Ft=new M([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]),yt=new M([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]),Dt=new M([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Gi=function(i,t){for(var e=new V(31),n=0;n<31;++n)e[n]=t+=1<<i[n-1];for(var r=new _t(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)r[s]=s-e[n]<<5|n;return[e,r]},Li=Gi(Ft,2),gi=Li[0],jt=Li[1];gi[28]=258,jt[258]=28;var Ri=Gi(yt,0),bi=Ri[0],hi=Ri[1],qt=new V(32768);for(G=0;G<32768;++G)lt=(G&43690)>>>1|(G&21845)<<1,lt=(lt&52428)>>>2|(lt&13107)<<2,lt=(lt&61680)>>>4|(lt&3855)<<4,qt[G]=((lt&65280)>>>8|(lt&255)<<8)>>>1;var lt,G,it=function(i,t,e){for(var n=i.length,r=0,s=new V(t);r<n;++r)i[r]&&++s[i[r]-1];var l=new V(t);for(r=0;r<t;++r)l[r]=l[r-1]+s[r-1]<<1;var a;if(e){a=new V(1<<t);var h=15-t;for(r=0;r<n;++r)if(i[r])for(var f=r<<4|i[r],o=t-i[r],c=l[i[r]-1]++<<o,p=c|(1<<o)-1;c<=p;++c)a[qt[c]>>>h]=f}else for(a=new V(n),r=0;r<n;++r)i[r]&&(a[r]=qt[l[i[r]-1]++]>>>15-i[r]);return a},ht=new M(288);for(G=0;G<144;++G)ht[G]=8;var G;for(G=144;G<256;++G)ht[G]=9;var G;for(G=256;G<280;++G)ht[G]=7;var G;for(G=280;G<288;++G)ht[G]=8;var G,Nt=new M(32);for(G=0;G<32;++G)Nt[G]=5;var G,Zi=it(ht,9,0),ki=it(ht,9,1),Yi=it(Nt,5,0),Xi=it(Nt,5,1),Kt=function(i){for(var t=i[0],e=1;e<i.length;++e)i[e]>t&&(t=i[e]);return t},tt=function(i,t,e){var n=t/8|0;return(i[n]|i[n+1]<<8)>>(t&7)&e},Ht=function(i,t){var e=t/8|0;return(i[e]|i[e+1]<<8|i[e+2]<<16)>>(t&7)},Ot=function(i){return(i+7)/8|0},et=function(i,t,e){(t==null||t<0)&&(t=0),(e==null||e>i.length)&&(e=i.length);var n=new(i.BYTES_PER_ELEMENT==2?V:i.BYTES_PER_ELEMENT==4?_t:M)(e-t);return n.set(i.subarray(t,e)),n};_.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 Vi=["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"],N=function(i,t,e){var n=new Error(t||Vi[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,N),!e)throw n;return n},Pt=function(i,t,e){var n=i.length;if(!n||e&&e.f&&!e.l)return t||new M(0);var r=!t||e,s=!e||e.i;e||(e={}),t||(t=new M(n*3));var l=function(Rt){var Mt=t.length;if(Rt>Mt){var gt=new M(Math.max(Mt*2,Rt));gt.set(t),t=gt}},a=e.f||0,h=e.p||0,f=e.b||0,o=e.l,c=e.d,p=e.m,m=e.n,g=n*8;do{if(!o){a=tt(i,h,1);var d=tt(i,h+1,3);if(h+=3,d)if(d==1)o=ki,c=Xi,p=9,m=5;else if(d==2){var x=tt(i,h,31)+257,y=tt(i,h+10,15)+4,L=x+tt(i,h+5,31)+1;h+=14;for(var z=new M(L),U=new M(19),T=0;T<y;++T)U[Dt[T]]=tt(i,h+T*3,7);h+=y*3;for(var Z=Kt(U),C=(1<<Z)-1,b=it(U,Z,1),T=0;T<L;){var S=b[tt(i,h,C)];h+=S&15;var v=S>>>4;if(v<16)z[T++]=v;else{var q=0,w=0;for(v==16?(w=3+tt(i,h,3),h+=2,q=z[T-1]):v==17?(w=3+tt(i,h,7),h+=3):v==18&&(w=11+tt(i,h,127),h+=7);w--;)z[T++]=q}}var O=z.subarray(0,x),D=z.subarray(x);p=Kt(O),m=Kt(D),o=it(O,p,1),c=it(D,m,1)}else N(1);else{var v=Ot(h)+4,E=i[v-4]|i[v-3]<<8,A=v+E;if(A>n){s&&N(0);break}r&&l(f+E),t.set(i.subarray(v,A),f),e.b=f+=E,e.p=h=A*8,e.f=a;continue}if(h>g){s&&N(0);break}}r&&l(f+131072);for(var B=(1<<p)-1,k=(1<<m)-1,j=h;;j=h){var q=o[Ht(i,h)&B],J=q>>>4;if(h+=q&15,h>g){s&&N(0);break}if(q||N(2),J<256)t[f++]=J;else if(J==256){j=h,o=null;break}else{var K=J-254;if(J>264){var T=J-257,st=Ft[T];K=tt(i,h,(1<<st)-1)+gi[T],h+=st}var rt=c[Ht(i,h)&k],$=rt>>>4;rt||N(3),h+=rt&15;var D=bi[$];if($>3){var st=yt[$];D+=Ht(i,h)&(1<<st)-1,h+=st}if(h>g){s&&N(0);break}r&&l(f+131072);for(var X=f+K;f<X;f+=4)t[f]=t[f-D],t[f+1]=t[f+1-D],t[f+2]=t[f+2-D],t[f+3]=t[f+3-D];f=X}}e.l=o,e.p=j,e.b=f,e.f=a,o&&(a=1,e.m=p,e.d=c,e.n=m)}while(!a);return f==t.length?t:et(t,0,f)},at=function(i,t,e){e<<=t&7;var n=t/8|0;i[n]|=e,i[n+1]|=e>>>8},mt=function(i,t,e){e<<=t&7;var n=t/8|0;i[n]|=e,i[n+1]|=e>>>8,i[n+2]|=e>>>16},Qt=function(i,t){for(var e=[],n=0;n<i.length;++n)i[n]&&e.push({s:n,f:i[n]});var r=e.length,s=e.slice();if(!r)return[ft,0];if(r==1){var l=new M(e[0].s+1);return l[e[0].s]=1,[l,1]}e.sort(function(L,z){return L.f-z.f}),e.push({s:-1,f:25001});var a=e[0],h=e[1],f=0,o=1,c=2;for(e[0]={s:-1,f:a.f+h.f,l:a,r:h};o!=r-1;)a=e[e[f].f<e[c].f?f++:c++],h=e[f!=o&&e[f].f<e[c].f?f++:c++],e[o++]={s:-1,f:a.f+h.f,l:a,r:h};for(var p=s[0].s,n=1;n<r;++n)s[n].s>p&&(p=s[n].s);var m=new V(p+1),g=$t(e[o-1],m,0);if(g>t){var n=0,d=0,v=g-t,E=1<<v;for(s.sort(function(z,U){return m[U.s]-m[z.s]||z.f-U.f});n<r;++n){var A=s[n].s;if(m[A]>t)d+=E-(1<<g-m[A]),m[A]=t;else break}for(d>>>=v;d>0;){var x=s[n].s;m[x]<t?d-=1<<t-m[x]++-1:++n}for(;n>=0&&d;--n){var y=s[n].s;m[y]==t&&(--m[y],++d)}g=t}return[new M(m),g]},$t=function(i,t,e){return i.s==-1?Math.max($t(i.l,t,e+1),$t(i.r,t,e+1)):t[i.s]=e},ui=function(i){for(var t=i.length;t&&!i[--t];);for(var e=new V(++t),n=0,r=i[0],s=1,l=function(h){e[n++]=h},a=1;a<=t;++a)if(i[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)l(32754);s>2&&(l(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(l(r),--s;s>6;s-=6)l(8304);s>2&&(l(s-3<<5|8208),s=0)}for(;s--;)l(r);s=1,r=i[a]}return[e.subarray(0,n),t]},dt=function(i,t){for(var e=0,n=0;n<t.length;++n)e+=i[n]*t[n];return e},Wt=function(i,t,e){var n=e.length,r=Ot(t+2);i[r]=n&255,i[r+1]=n>>>8,i[r+2]=i[r]^255,i[r+3]=i[r+1]^255;for(var s=0;s<n;++s)i[r+s+4]=e[s];return(r+4+n)*8},ci=function(i,t,e,n,r,s,l,a,h,f,o){at(t,o++,e),++r[256];for(var c=Qt(r,15),p=c[0],m=c[1],g=Qt(s,15),d=g[0],v=g[1],E=ui(p),A=E[0],x=E[1],y=ui(d),L=y[0],z=y[1],U=new V(19),T=0;T<A.length;++T)U[A[T]&31]++;for(var T=0;T<L.length;++T)U[L[T]&31]++;for(var Z=Qt(U,7),C=Z[0],b=Z[1],S=19;S>4&&!C[Dt[S-1]];--S);var q=f+5<<3,w=dt(r,ht)+dt(s,Nt)+l,O=dt(r,p)+dt(s,d)+l+14+3*S+dt(U,C)+(2*U[16]+3*U[17]+7*U[18]);if(q<=w&&q<=O)return Wt(t,o,i.subarray(h,h+f));var D,B,k,j;if(at(t,o,1+(O<w)),o+=2,O<w){D=it(p,m,0),B=p,k=it(d,v,0),j=d;var J=it(C,b,0);at(t,o,x-257),at(t,o+5,z-1),at(t,o+10,S-4),o+=14;for(var T=0;T<S;++T)at(t,o+3*T,C[Dt[T]]);o+=3*S;for(var K=[A,L],st=0;st<2;++st)for(var rt=K[st],T=0;T<rt.length;++T){var $=rt[T]&31;at(t,o,J[$]),o+=C[$],$>15&&(at(t,o,rt[T]>>>5&127),o+=rt[T]>>>12)}}else D=Zi,B=ht,k=Yi,j=Nt;for(var T=0;T<a;++T)if(n[T]>255){var $=n[T]>>>18&31;mt(t,o,D[$+257]),o+=B[$+257],$>7&&(at(t,o,n[T]>>>23&31),o+=Ft[$]);var X=n[T]&31;mt(t,o,k[X]),o+=j[X],X>3&&(mt(t,o,n[T]>>>5&8191),o+=yt[X])}else mt(t,o,D[n[T]]),o+=B[n[T]];return mt(t,o,D[256]),o+B[256]},Ki=new _t([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ft=new M(0),Hi=function(i,t,e,n,r,s){var l=i.length,a=new M(n+l+5*(1+Math.ceil(l/7e3))+r),h=a.subarray(n,a.length-r),f=0;if(!t||l<8)for(var o=0;o<=l;o+=65535){var c=o+65535;c>=l&&(h[f>>3]=s),f=Wt(h,f+1,i.subarray(o,c))}else{for(var p=Ki[t-1],m=p>>>13,g=p&8191,d=(1<<e)-1,v=new V(32768),E=new V(d+1),A=Math.ceil(e/3),x=2*A,y=function(oi){return(i[oi]^i[oi+1]<<A^i[oi+2]<<x)&d},L=new _t(25e3),z=new V(288),U=new V(32),T=0,Z=0,o=0,C=0,b=0,S=0;o<l;++o){var q=y(o),w=o&32767,O=E[q];if(v[w]=O,E[q]=w,b<=o){var D=l-o;if((T>7e3||C>24576)&&D>423){f=ci(i,h,0,L,z,U,Z,C,S,o-S,f),C=T=Z=0,S=o;for(var B=0;B<286;++B)z[B]=0;for(var B=0;B<30;++B)U[B]=0}var k=2,j=0,J=g,K=w-O&32767;if(D>2&&q==y(o-K))for(var st=Math.min(m,D)-1,rt=Math.min(32767,o),$=Math.min(258,D);K<=rt&&--J&&w!=O;){if(i[o+k]==i[o+k-K]){for(var X=0;X<$&&i[o+X]==i[o+X-K];++X);if(X>k){if(k=X,j=K,X>st)break;for(var Rt=Math.min(K,X-2),Mt=0,B=0;B<Rt;++B){var gt=o-K+B+32768&32767,Ee=v[gt],wi=gt-Ee+32768&32767;wi>Mt&&(Mt=wi,O=gt)}}}w=O,O=v[w],K+=w-O+32768&32767}if(j){L[C++]=268435456|jt[k]<<18|hi[j];var Ci=jt[k]&31,Mi=hi[j]&31;Z+=Ft[Ci]+yt[Mi],++z[257+Ci],++U[Mi],b=o+k,++T}else L[C++]=i[o],++z[i[o]]}}f=ci(i,h,s,L,z,U,Z,C,S,o-S,f),!s&&f&7&&(f=Wt(h,f+1,ft))}return et(a,0,n+Ot(f)+r)},Qi=function(){for(var i=new Int32Array(256),t=0;t<256;++t){for(var e=t,n=9;--n;)e=(e&1&&-306674912)^e>>>1;i[t]=e}return i}(),At=function(){var i=-1;return{p:function(t){for(var e=i,n=0;n<t.length;++n)e=Qi[e&255^t[n]]^e>>>8;i=e},d:function(){return~i}}},Ti=function(){var i=1,t=0;return{p:function(e){for(var n=i,r=t,s=e.length|0,l=0;l!=s;){for(var a=Math.min(l+2655,s);l<a;++l)r+=n+=e[l];n=(n&65535)+15*(n>>16),r=(r&65535)+15*(r>>16)}i=n,t=r},d:function(){return i%=65521,t%=65521,(i&255)<<24|i>>>8<<16|(t&255)<<8|t>>>8}}},pt=function(i,t,e,n,r){return Hi(i,t.level==null?6:t.level,t.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):12+t.mem,e,n,!r)},Gt=function(i,t){var e={};for(var n in i)e[n]=i[n];for(var n in t)e[n]=t[n];return e},Oi=function(i,t,e){for(var n=i(),r=i.toString(),s=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),l=0;l<n.length;++l){var a=n[l],h=s[l];if(typeof a=="function"){t+=";"+h+"=";var f=a.toString();if(a.prototype)if(f.indexOf("[native code]")!=-1){var o=f.indexOf(" ",8)+1;t+=f.slice(o,f.indexOf("(",o))}else{t+=f;for(var c in a.prototype)t+=";"+h+".prototype."+c+"="+a.prototype[c].toString()}else t+=f}else e[h]=a}return[t,e]},Vt=[],xe=function(i){var t=[];for(var e in i)i[e].buffer&&t.push((i[e]=new i[e].constructor(i[e])).buffer);return t},ji=function(i,t,e,n){var r;if(!Vt[e]){for(var s="",l={},a=i.length-1,h=0;h<a;++h)r=Oi(i[h],s,l),s=r[0],l=r[1];Vt[e]=Oi(i[a],s,l)}var f=Gt({},Vt[e][1]);return Ue.default(Vt[e][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",e,f,xe(f),n)},Ut=function(){return[M,V,_t,Ft,yt,Dt,gi,bi,ki,Xi,qt,Vi,it,Kt,tt,Ht,Ot,et,N,Pt,Ct,It,mi]},xt=function(){return[M,V,_t,Ft,yt,Dt,jt,hi,Zi,ht,Yi,Nt,qt,Ki,ft,it,at,mt,Qt,$t,ui,dt,Wt,ci,Ot,et,Hi,pt,Lt,It]},$i=function(){return[di,Ei,R,At,Qi]},Wi=function(){return[Ni,ie]},Ji=function(){return[_i,R,Ti]},te=function(){return[ee]},It=function(i){return postMessage(i,[i.buffer])},mi=function(i){return i&&i.size&&new M(i.size)},St=function(i,t,e,n,r,s){var l=ji(e,n,r,function(a,h){l.terminate(),s(a,h)});return l.postMessage([i,t],t.consume?[i.buffer]:[]),function(){l.terminate()}},nt=function(i){return i.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(t){return i.push(t.data[0],t.data[1])}},wt=function(i,t,e,n,r){var s,l=ji(i,n,r,function(a,h){a?(l.terminate(),t.ondata.call(t,a)):(h[1]&&l.terminate(),t.ondata.call(t,a,h[0],h[1]))});l.postMessage(e),t.push=function(a,h){t.ondata||N(5),s&&t.ondata(N(4,0,1),null,!!h),l.postMessage([a,s=h],[a.buffer])},t.terminate=function(){l.terminate()}},Q=function(i,t){return i[t]|i[t+1]<<8},Y=function(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16|i[t+3]<<24)>>>0},fi=function(i,t){return Y(i,t)+Y(i,t+4)*4294967296},R=function(i,t,e){for(;e;++t)i[t]=e,e>>>=8},di=function(i,t){var e=t.filename;if(i[0]=31,i[1]=139,i[2]=8,i[8]=t.level<2?4:t.level==9?2:0,i[9]=3,t.mtime!=0&&R(i,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),e){i[3]=8;for(var n=0;n<=e.length;++n)i[n+10]=e.charCodeAt(n)}},Ni=function(i){(i[0]!=31||i[1]!=139||i[2]!=8)&&N(6,"invalid gzip data");var t=i[3],e=10;t&4&&(e+=i[10]|(i[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!i[e++]);return e+(t&2)},ie=function(i){var t=i.length;return(i[t-4]|i[t-3]<<8|i[t-2]<<16|i[t-1]<<24)>>>0},Ei=function(i){return 10+(i.filename&&i.filename.length+1||0)},_i=function(i,t){var e=t.level,n=e==0?0:e<6?1:e==9?3:2;i[0]=120,i[1]=n<<6|(n?32-2*n:1)},ee=function(i){((i[0]&15)!=8||i[0]>>>4>7||(i[0]<<8|i[1])%31)&&N(6,"invalid zlib data"),i[1]&32&&N(6,"invalid zlib data: preset dictionaries not supported")};function Fi(i,t){return!t&&typeof i=="function"&&(t=i,i={}),this.ondata=t,i}var ot=function(){function i(t,e){!e&&typeof t=="function"&&(e=t,t={}),this.ondata=e,this.o=t||{}}return i.prototype.p=function(t,e){this.ondata(pt(t,this.o,0,0,!e),e)},i.prototype.push=function(t,e){this.ondata||N(5),this.d&&N(4),this.d=e,this.p(t,e||!1)},i}();_.Deflate=ot;var ne=function(){function i(t,e){wt([xt,function(){return[nt,ot]}],this,Fi.call(this,t,e),function(n){var r=new ot(n.data);onmessage=nt(r)},6)}return i}();_.AsyncDeflate=ne;function se(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[xt],function(n){return It(Lt(n.data[0],n.data[1]))},0,e)}_.deflate=se;function Lt(i,t){return pt(i,t||{},0,0)}_.deflateSync=Lt;var W=function(){function i(t){this.s={},this.p=new M(0),this.ondata=t}return i.prototype.e=function(t){this.ondata||N(5),this.d&&N(4);var e=this.p.length,n=new M(e+t.length);n.set(this.p),n.set(t,e),this.p=n},i.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=Pt(this.p,this.o,this.s);this.ondata(et(n,e,this.s.b),this.d),this.o=et(n,this.s.b-32768),this.s.b=this.o.length,this.p=et(this.p,this.s.p/8|0),this.s.p&=7},i.prototype.push=function(t,e){this.e(t),this.c(e)},i}();_.Inflate=W;var yi=function(){function i(t){this.ondata=t,wt([Ut,function(){return[nt,W]}],this,0,function(){var e=new W;onmessage=nt(e)},7)}return i}();_.AsyncInflate=yi;function Ai(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[Ut],function(n){return It(Ct(n.data[0],mi(n.data[1])))},1,e)}_.inflate=Ai;function Ct(i,t){return Pt(i,t)}_.inflateSync=Ct;var Jt=function(){function i(t,e){this.c=At(),this.l=0,this.v=1,ot.call(this,t,e)}return i.prototype.push=function(t,e){ot.prototype.push.call(this,t,e)},i.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=pt(t,this.o,this.v&&Ei(this.o),e&&8,!e);this.v&&(di(n,this.o),this.v=0),e&&(R(n,n.length-8,this.c.d()),R(n,n.length-4,this.l)),this.ondata(n,e)},i}();_.Gzip=Jt;_.Compress=Jt;var re=function(){function i(t,e){wt([xt,$i,function(){return[nt,ot,Jt]}],this,Fi.call(this,t,e),function(n){var r=new Jt(n.data);onmessage=nt(r)},8)}return i}();_.AsyncGzip=re;_.AsyncCompress=re;function ae(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[xt,$i,function(){return[ti]}],function(n){return It(ti(n.data[0],n.data[1]))},2,e)}_.gzip=ae;_.compress=ae;function ti(i,t){t||(t={});var e=At(),n=i.length;e.p(i);var r=pt(i,t,Ei(t),8),s=r.length;return di(r,t),R(r,s-8,e.d()),R(r,s-4,n),r}_.gzipSync=ti;_.compressSync=ti;var ii=function(){function i(t){this.v=1,W.call(this,t)}return i.prototype.push=function(t,e){if(W.prototype.e.call(this,t),this.v){var n=this.p.length>3?Ni(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}e&&(this.p.length<8&&N(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),W.prototype.c.call(this,e)},i}();_.Gunzip=ii;var oe=function(){function i(t){this.ondata=t,wt([Ut,Wi,function(){return[nt,W,ii]}],this,0,function(){var e=new ii;onmessage=nt(e)},9)}return i}();_.AsyncGunzip=oe;function le(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[Ut,Wi,function(){return[ei]}],function(n){return It(ei(n.data[0]))},3,e)}_.gunzip=le;function ei(i,t){return Pt(i.subarray(Ni(i),-8),t||new M(ie(i)))}_.gunzipSync=ei;var Ii=function(){function i(t,e){this.c=Ti(),this.v=1,ot.call(this,t,e)}return i.prototype.push=function(t,e){ot.prototype.push.call(this,t,e)},i.prototype.p=function(t,e){this.c.p(t);var n=pt(t,this.o,this.v&&2,e&&4,!e);this.v&&(_i(n,this.o),this.v=0),e&&R(n,n.length-4,this.c.d()),this.ondata(n,e)},i}();_.Zlib=Ii;var Se=function(){function i(t,e){wt([xt,Ji,function(){return[nt,ot,Ii]}],this,Fi.call(this,t,e),function(n){var r=new Ii(n.data);onmessage=nt(r)},10)}return i}();_.AsyncZlib=Se;function we(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[xt,Ji,function(){return[vi]}],function(n){return It(vi(n.data[0],n.data[1]))},4,e)}_.zlib=we;function vi(i,t){t||(t={});var e=Ti();e.p(i);var n=pt(i,t,2,4);return _i(n,t),R(n,n.length-4,e.d()),n}_.zlibSync=vi;var ni=function(){function i(t){this.v=1,W.call(this,t)}return i.prototype.push=function(t,e){if(W.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&&N(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),W.prototype.c.call(this,e)},i}();_.Unzlib=ni;var fe=function(){function i(t){this.ondata=t,wt([Ut,te,function(){return[nt,W,ni]}],this,0,function(){var e=new ni;onmessage=nt(e)},11)}return i}();_.AsyncUnzlib=fe;function he(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),St(i,t,[Ut,te,function(){return[si]}],function(n){return It(si(n.data[0],mi(n.data[1])))},5,e)}_.unzlib=he;function si(i,t){return Pt((ee(i),i.subarray(2,-4)),t)}_.unzlibSync=si;var ue=function(){function i(t){this.G=ii,this.I=W,this.Z=ni,this.ondata=t}return i.prototype.push=function(t,e){if(this.ondata||N(5),this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new M(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,s=function(){r.ondata.apply(r,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,e),this.p=null}}},i}();_.Decompress=ue;var Ce=function(){function i(t){this.G=oe,this.I=yi,this.Z=fe,this.ondata=t}return i.prototype.push=function(t,e){ue.prototype.push.call(this,t,e)},i}();_.AsyncDecompress=Ce;function Me(i,t,e){return e||(e=t,t={}),typeof e!="function"&&N(7),i[0]==31&&i[1]==139&&i[2]==8?le(i,t,e):(i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31?Ai(i,t,e):he(i,t,e)}_.decompress=Me;function ze(i,t){return i[0]==31&&i[1]==139&&i[2]==8?ei(i,t):(i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31?Ct(i,t):si(i,t)}_.decompressSync=ze;var Ui=function(i,t,e,n){for(var r in i){var s=i[r],l=t+r,a=n;Array.isArray(s)&&(a=Gt(n,s[1]),s=s[0]),s instanceof M?e[l]=[s,a]:(e[l+="/"]=[new M(0),a],Ui(s,l,e,n))}},Pi=typeof TextEncoder<"u"&&new TextEncoder,pi=typeof TextDecoder<"u"&&new TextDecoder,ce=0;try{pi.decode(ft,{stream:!0}),ce=1}catch{}var Ie=function(i){for(var t="",e=0;;){var n=i[e++],r=(n>127)+(n>223)+(n>239);if(e+r>i.length)return[t,et(i,e-1)];r?r==3?(n=((n&15)<<18|(i[e++]&63)<<12|(i[e++]&63)<<6|i[e++]&63)-65536,t+=String.fromCharCode(55296|n>>10,56320|n&1023)):r&1?t+=String.fromCharCode((n&31)<<6|i[e++]&63):t+=String.fromCharCode((n&15)<<12|(i[e++]&63)<<6|i[e++]&63):t+=String.fromCharCode(n)}},De=function(){function i(t){this.ondata=t,ce?this.t=new TextDecoder:this.p=ft}return i.prototype.push=function(t,e){if(this.ondata||N(5),e=!!e,this.t){this.ondata(this.t.decode(t,{stream:!0}),e),e&&(this.t.decode().length&&N(8),this.t=null);return}this.p||N(4);var n=new M(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=Ie(n),s=r[0],l=r[1];e?(l.length&&N(8),this.p=null):this.p=l,this.ondata(s,e)},i}();_.DecodeUTF8=De;var qe=function(){function i(t){this.ondata=t}return i.prototype.push=function(t,e){this.ondata||N(5),this.d&&N(4),this.ondata(ct(t),this.d=e||!1)},i}();_.EncodeUTF8=qe;function ct(i,t){if(t){for(var e=new M(i.length),n=0;n<i.length;++n)e[n]=i.charCodeAt(n);return e}if(Pi)return Pi.encode(i);for(var r=i.length,s=new M(i.length+(i.length>>1)),l=0,a=function(o){s[l++]=o},n=0;n<r;++n){if(l+5>s.length){var h=new M(l+8+(r-n<<1));h.set(s),s=h}var f=i.charCodeAt(n);f<128||t?a(f):f<2048?(a(192|f>>6),a(128|f&63)):f>55295&&f<57344?(f=65536+(f&1023<<10)|i.charCodeAt(++n)&1023,a(240|f>>18),a(128|f>>12&63),a(128|f>>6&63),a(128|f&63)):(a(224|f>>12),a(128|f>>6&63),a(128|f&63))}return et(s,0,l)}_.strToU8=ct;function xi(i,t){if(t){for(var e="",n=0;n<i.length;n+=16384)e+=String.fromCharCode.apply(null,i.subarray(n,n+16384));return e}else{if(pi)return pi.decode(i);var r=Ie(i),s=r[0],l=r[1];return l.length&&N(8),s}}_.strFromU8=xi;var ve=function(i){return i==1?3:i<6?2:i==9?1:0},pe=function(i,t){return t+30+Q(i,t+26)+Q(i,t+28)},ge=function(i,t,e){var n=Q(i,t+28),r=xi(i.subarray(t+46,t+46+n),!(Q(i,t+8)&2048)),s=t+46+n,l=Y(i,t+20),a=e&&l==4294967295?Te(i,s):[l,Y(i,t+24),Y(i,t+42)],h=a[0],f=a[1],o=a[2];return[Q(i,t+10),h,f,r,s+Q(i,t+30)+Q(i,t+32),o]},Te=function(i,t){for(;Q(i,t)!=1;t+=4+Q(i,t+2));return[fi(i,t+12),fi(i,t+4),fi(i,t+20)]},ut=function(i){var t=0;if(i)for(var e in i){var n=i[e].length;n>65535&&N(9),t+=n+4}return t},Et=function(i,t,e,n,r,s,l,a){var h=n.length,f=e.extra,o=a&&a.length,c=ut(f);R(i,t,l!=null?33639248:67324752),t+=4,l!=null&&(i[t++]=20,i[t++]=e.os),i[t]=20,t+=2,i[t++]=e.flag<<1|(s==null&&8),i[t++]=r&&8,i[t++]=e.compression&255,i[t++]=e.compression>>8;var p=new Date(e.mtime==null?Date.now():e.mtime),m=p.getFullYear()-1980;if((m<0||m>119)&&N(10),R(i,t,m<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),t+=4,s!=null&&(R(i,t,e.crc),R(i,t+4,s),R(i,t+8,e.size)),R(i,t+12,h),R(i,t+14,c),t+=16,l!=null&&(R(i,t,o),R(i,t+6,e.attrs),R(i,t+10,l),t+=14),i.set(n,t),t+=h,c)for(var g in f){var d=f[g],v=d.length;R(i,t,+g),R(i,t+2,v),i.set(d,t+4),t+=4+v}return o&&(i.set(a,t),t+=o),t},Si=function(i,t,e,n,r){R(i,t,101010256),R(i,t+8,e),R(i,t+10,e),R(i,t+12,n),R(i,t+16,r)},Bt=function(){function i(t){this.filename=t,this.c=At(),this.size=0,this.compression=0}return i.prototype.process=function(t,e){this.ondata(null,t,e)},i.prototype.push=function(t,e){this.ondata||N(5),this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},i}();_.ZipPassThrough=Bt;var Be=function(){function i(t,e){var n=this;e||(e={}),Bt.call(this,t),this.d=new ot(e,function(r,s){n.ondata(null,r,s)}),this.compression=8,this.flag=ve(e.level)}return i.prototype.process=function(t,e){try{this.d.push(t,e)}catch(n){this.ondata(n,null,e)}},i.prototype.push=function(t,e){Bt.prototype.push.call(this,t,e)},i}();_.ZipDeflate=Be;var Oe=function(){function i(t,e){var n=this;e||(e={}),Bt.call(this,t),this.d=new ne(e,function(r,s,l){n.ondata(r,s,l)}),this.compression=8,this.flag=ve(e.level),this.terminate=this.d.terminate}return i.prototype.process=function(t,e){this.d.push(t,e)},i.prototype.push=function(t,e){Bt.prototype.push.call(this,t,e)},i}();_.AsyncZipDeflate=Oe;var Pe=function(){function i(t){this.ondata=t,this.u=[],this.d=1}return i.prototype.add=function(t){var e=this;if(this.ondata||N(5),this.d&2)this.ondata(N(4+(this.d&1)*8,0,1),null,!1);else{var n=ct(t.filename),r=n.length,s=t.comment,l=s&&ct(s),a=r!=t.filename.length||l&&s.length!=l.length,h=r+ut(t.extra)+30;r>65535&&this.ondata(N(11,0,1),null,!1);var f=new M(h);Et(f,0,t,n,a);var o=[f],c=function(){for(var v=0,E=o;v<E.length;v++){var A=E[v];e.ondata(null,A,!1)}o=[]},p=this.d;this.d=0;var m=this.u.length,g=Gt(t,{f:n,u:a,o:l,t:function(){t.terminate&&t.terminate()},r:function(){if(c(),p){var v=e.u[m+1];v?v.r():e.d=1}p=1}}),d=0;t.ondata=function(v,E,A){if(v)e.ondata(v,E,A),e.terminate();else if(d+=E.length,o.push(E),A){var x=new M(16);R(x,0,134695760),R(x,4,t.crc),R(x,8,d),R(x,12,t.size),o.push(x),g.c=d,g.b=h+d+16,g.crc=t.crc,g.size=t.size,p&&g.r(),p=1}else p&&c()},this.u.push(g)}},i.prototype.end=function(){var t=this;if(this.d&2){this.ondata(N(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){t.d&1&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},i.prototype.e=function(){for(var t=0,e=0,n=0,r=0,s=this.u;r<s.length;r++){var l=s[r];n+=46+l.f.length+ut(l.extra)+(l.o?l.o.length:0)}for(var a=new M(n+22),h=0,f=this.u;h<f.length;h++){var l=f[h];Et(a,t,l,l.f,l.u,l.c,e,l.o),t+=46+l.f.length+ut(l.extra)+(l.o?l.o.length:0),e+=l.b}Si(a,t,this.u.length,n,e),this.ondata(null,a,!0),this.d=2},i.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++){var n=e[t];n.t()}this.d=2},i}();_.Zip=Pe;function Ge(i,t,e){e||(e=t,t={}),typeof e!="function"&&N(7);var n={};Ui(i,"",n,t);var r=Object.keys(n),s=r.length,l=0,a=0,h=s,f=new Array(s),o=[],c=function(){for(var v=0;v<o.length;++v)o[v]()},p=function(v,E){ri(function(){e(v,E)})};ri(function(){p=e});var m=function(){var v=new M(a+22),E=l,A=a-l;a=0;for(var x=0;x<h;++x){var y=f[x];try{var L=y.c.length;Et(v,a,y,y.f,y.u,L);var z=30+y.f.length+ut(y.extra),U=a+z;v.set(y.c,U),Et(v,l,y,y.f,y.u,L,a,y.m),l+=16+z+(y.m?y.m.length:0),a=U+L}catch(T){return p(T,null)}}Si(v,l,f.length,A,E),p(null,v)};s||m();for(var g=function(v){var E=r[v],A=n[E],x=A[0],y=A[1],L=At(),z=x.length;L.p(x);var U=ct(E),T=U.length,Z=y.comment,C=Z&&ct(Z),b=C&&C.length,S=ut(y.extra),q=y.level==0?0:8,w=function(O,D){if(O)c(),p(O,null);else{var B=D.length;f[v]=Gt(y,{size:z,crc:L.d(),c:D,f:U,m:C,u:T!=E.length||C&&Z.length!=b,compression:q}),l+=30+T+S+B,a+=76+2*(T+S)+(b||0)+B,--s||m()}};if(T>65535&&w(N(11,0,1),null),!q)w(null,x);else if(z<16e4)try{w(null,Lt(x,y))}catch(O){w(O,null)}else o.push(se(x,y,w))},d=0;d<h;++d)g(d);return c}_.zip=Ge;function Le(i,t){t||(t={});var e={},n=[];Ui(i,"",e,t);var r=0,s=0;for(var l in e){var a=e[l],h=a[0],f=a[1],o=f.level==0?0:8,c=ct(l),p=c.length,m=f.comment,g=m&&ct(m),d=g&&g.length,v=ut(f.extra);p>65535&&N(11);var E=o?Lt(h,f):h,A=E.length,x=At();x.p(h),n.push(Gt(f,{size:h.length,crc:x.d(),c:E,f:c,m:g,u:p!=l.length||g&&m.length!=d,o:r,compression:o})),r+=30+p+v+A,s+=76+2*(p+v)+(d||0)+A}for(var y=new M(s+22),L=r,z=s-r,U=0;U<n.length;++U){var c=n[U];Et(y,c.o,c,c.f,c.u,c.c.length);var T=30+c.f.length+ut(c.extra);y.set(c.c,c.o+T),Et(y,r,c,c.f,c.u,c.c.length,c.o,c.m),r+=16+T+(c.m?c.m.length:0)}return Si(y,r,n.length,z,L),y}_.zipSync=Le;var me=function(){function i(){}return i.prototype.push=function(t,e){this.ondata(null,t,e)},i.compression=0,i}();_.UnzipPassThrough=me;var Re=function(){function i(){var t=this;this.i=new W(function(e,n){t.ondata(null,e,n)})}return i.prototype.push=function(t,e){try{this.i.push(t,e)}catch(n){this.ondata(n,null,e)}},i.compression=8,i}();_.UnzipInflate=Re;var be=function(){function i(t,e){var n=this;e<32e4?this.i=new W(function(r,s){n.ondata(null,r,s)}):(this.i=new yi(function(r,s,l){n.ondata(r,s,l)}),this.terminate=this.i.terminate)}return i.prototype.push=function(t,e){this.i.terminate&&(t=et(t,0)),this.i.push(t,e)},i.compression=8,i}();_.AsyncUnzipInflate=be;var Ze=function(){function i(t){this.onfile=t,this.k=[],this.o={0:me},this.p=ft}return i.prototype.push=function(t,e){var n=this;if(this.onfile||N(5),this.p||N(4),this.c>0){var r=Math.min(this.c,t.length),s=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(s,!this.c):this.k[0].push(s),t=t.subarray(r),t.length)return this.push(t,e)}else{var l=0,a=0,h=void 0,f=void 0;this.p.length?t.length?(f=new M(this.p.length+t.length),f.set(this.p),f.set(t,this.p.length)):f=this.p:f=t;for(var o=f.length,c=this.c,p=c&&this.d,m=function(){var E,A=Y(f,a);if(A==67324752){l=1,h=a,g.d=null,g.c=0;var x=Q(f,a+6),y=Q(f,a+8),L=x&2048,z=x&8,U=Q(f,a+26),T=Q(f,a+28);if(o>a+30+U+T){var Z=[];g.k.unshift(Z),l=2;var C=Y(f,a+18),b=Y(f,a+22),S=xi(f.subarray(a+30,a+=30+U),!L);C==4294967295?(E=z?[-2]:Te(f,a),C=E[0],b=E[1]):z&&(C=-1),a+=T,g.c=C;var q,w={name:S,compression:y,start:function(){if(w.ondata||N(5),!C)w.ondata(null,ft,!0);else{var O=n.o[y];O||w.ondata(N(14,"unknown compression type "+y,1),null,!1),q=C<0?new O(S):new O(S,C,b),q.ondata=function(j,J,K){w.ondata(j,J,K)};for(var D=0,B=Z;D<B.length;D++){var k=B[D];q.push(k,!1)}n.k[0]==Z&&n.c?n.d=q:q.push(ft,!0)}},terminate:function(){q&&q.terminate&&q.terminate()}};C>=0&&(w.size=C,w.originalSize=b),g.onfile(w)}return"break"}else if(c){if(A==134695760)return h=a+=12+(c==-2&&8),l=3,g.c=0,"break";if(A==33639248)return h=a-=4,l=3,g.c=0,"break"}},g=this;a<o-4;++a){var d=m();if(d==="break")break}if(this.p=ft,c<0){var v=l?f.subarray(0,h-12-(c==-2&&8)-(Y(f,h-16)==134695760&&4)):f.subarray(0,a);p?p.push(v,!!l):this.k[+(l==2)].push(v)}if(l&2)return this.push(f.subarray(a),e);this.p=f.subarray(a)}e&&(this.c&&N(13),this.p=null)},i.prototype.register=function(t){this.o[t.compression]=t},i}();_.Unzip=Ze;var ri=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(i){i()};function ke(i,t,e){e||(e=t,t={}),typeof e!="function"&&N(7);var n=[],r=function(){for(var d=0;d<n.length;++d)n[d]()},s={},l=function(d,v){ri(function(){e(d,v)})};ri(function(){l=e});for(var a=i.length-22;Y(i,a)!=101010256;--a)if(!a||i.length-a>65558)return l(N(13,0,1),null),r;var h=Q(i,a+8);if(h){var f=h,o=Y(i,a+16),c=o==4294967295;if(c){if(a=Y(i,a-12),Y(i,a)!=101075792)return l(N(13,0,1),null),r;f=h=Y(i,a+32),o=Y(i,a+48)}for(var p=t&&t.filter,m=function(d){var v=ge(i,o,c),E=v[0],A=v[1],x=v[2],y=v[3],L=v[4],z=v[5],U=pe(i,z);o=L;var T=function(C,b){C?(r(),l(C,null)):(b&&(s[y]=b),--h||l(null,s))};if(!p||p({name:y,size:A,originalSize:x,compression:E}))if(!E)T(null,et(i,U,U+A));else if(E==8){var Z=i.subarray(U,U+A);if(A<32e4)try{T(null,Ct(Z,new M(x)))}catch(C){T(C,null)}else n.push(Ai(Z,{size:x},T))}else T(N(14,"unknown compression type "+E,1),null);else T(null,null)},g=0;g<f;++g)m(g)}else l(null,{});return r}_.unzip=ke;function Ye(i,t){for(var e={},n=i.length-22;Y(i,n)!=101010256;--n)(!n||i.length-n>65558)&&N(13);var r=Q(i,n+8);if(!r)return{};var s=Y(i,n+16),l=s==4294967295;l&&(n=Y(i,n-12),Y(i,n)!=101075792&&N(13),r=Y(i,n+32),s=Y(i,n+48));for(var a=t&&t.filter,h=0;h<r;++h){var f=ge(i,s,l),o=f[0],c=f[1],p=f[2],m=f[3],g=f[4],d=f[5],v=pe(i,d);s=g,(!a||a({name:m,size:c,originalSize:p,compression:o}))&&(o?o==8?e[m]=Ct(i.subarray(v,v+c),new M(p)):N(14,"unknown compression type "+o):e[m]=et(i,v,v+c))}return e}_.unzipSync=Ye});var Ve=vt((rn,ai)=>{var F=F||{};F.NIFTI1=F.NIFTI1||(typeof H<"u"?li():null);F.NIFTI2=F.NIFTI2||(typeof H<"u"?zi():null);F.NIFTIEXTENSION=F.NIFTIEXTENSION||(typeof H<"u"?Tt():null);F.Utils=F.Utils||(typeof H<"u"?kt():null);var Ne=Ne||(typeof H<"u"?de():null);F.isNIFTI1=function(i,t=!1){var e,n,r,s;return i.byteLength<F.NIFTI1.STANDARD_HEADER_SIZE?!1:(e=new DataView(i),e&&(n=e.getUint8(F.NIFTI1.MAGIC_NUMBER_LOCATION)),r=e.getUint8(F.NIFTI1.MAGIC_NUMBER_LOCATION+1),s=e.getUint8(F.NIFTI1.MAGIC_NUMBER_LOCATION+2),t&&n===F.NIFTI1.MAGIC_NUMBER2[0]&&r===F.NIFTI1.MAGIC_NUMBER2[1]&&s===F.NIFTI1.MAGIC_NUMBER2[2]?!0:n===F.NIFTI1.MAGIC_NUMBER[0]&&r===F.NIFTI1.MAGIC_NUMBER[1]&&s===F.NIFTI1.MAGIC_NUMBER[2])};F.isNIFTI2=function(i,t=!1){var e,n,r,s;return i.byteLength<F.NIFTI1.STANDARD_HEADER_SIZE?!1:(e=new DataView(i),n=e.getUint8(F.NIFTI2.MAGIC_NUMBER_LOCATION),r=e.getUint8(F.NIFTI2.MAGIC_NUMBER_LOCATION+1),s=e.getUint8(F.NIFTI2.MAGIC_NUMBER_LOCATION+2),t&&n===F.NIFTI2.MAGIC_NUMBER2[0]&&r===F.NIFTI2.MAGIC_NUMBER2[1]&&s===F.NIFTI2.MAGIC_NUMBER2[2]?!0:n===F.NIFTI2.MAGIC_NUMBER[0]&&r===F.NIFTI2.MAGIC_NUMBER[1]&&s===F.NIFTI2.MAGIC_NUMBER[2])};F.isNIFTI=function(i,t=!1){return F.isNIFTI1(i,t)||F.isNIFTI2(i,t)};F.isCompressed=function(i){var t,e,n;return!!(i&&(t=new DataView(i),e=t.getUint8(0),n=t.getUint8(1),e===F.Utils.GUNZIP_MAGIC_COOKIE1||n===F.Utils.GUNZIP_MAGIC_COOKIE2))};F.decompress=function(i){return Ne.decompressSync(new Uint8Array(i)).buffer};F.readHeader=function(i,t=!1){var e=null;return F.isCompressed(i)&&(i=F.decompress(i)),F.isNIFTI1(i,t)?e=new F.NIFTI1:F.isNIFTI2(i,t)&&(e=new F.NIFTI2),e?e.readHeader(i):console.error("That file does not appear to be NIFTI!"),e};F.hasExtension=function(i){return i.extensionFlag[0]!=0};F.readImage=function(i,t){var e=i.vox_offset,n=1,r=1;i.dims[4]&&(n=i.dims[4]),i.dims[5]&&(r=i.dims[5]);var s=i.dims[1]*i.dims[2]*i.dims[3]*n*r*(i.numBitsPerVoxel/8);return t.slice(e,e+s)};F.readExtension=function(i,t){var e=i.getExtensionLocation(),n=i.extensionSize;return t.slice(e,e+n)};F.readExtensionData=function(i,t){var e=i.getExtensionLocation(),n=i.extensionSize;return t.slice(e+8,e+n)};var Xe=typeof ai;Xe!=="undefined"&&ai.exports&&(ai.exports=F)});Ve();})(); | ||
"use strict";(()=>{var Di=Object.defineProperty;var Oi=(i,t,e)=>t in i?Di(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var It=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var E=(i,t,e)=>(Oi(i,typeof t!="symbol"?t+"":t,e),e);var ke=It(Ye=>{"use strict";var Ze={};Ye.default=function(i,t,e,n,r){var a=new Worker(Ze[t]||(Ze[t]=URL.createObjectURL(new Blob([i+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return a.onmessage=function(s){var l=s.data,o=l.$e$;if(o){var f=new Error(o[0]);f.code=o[1],f.stack=o[2],r(f,null)}else r(null,l)},a.postMessage(e,n),a}});var wi=It(I=>{"use strict";var qi=ke(),D=Uint8Array,K=Uint16Array,wt=Uint32Array,Ct=new D([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]),Nt=new D([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]),Gt=new D([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ve=function(i,t){for(var e=new K(31),n=0;n<31;++n)e[n]=t+=1<<i[n-1];for(var r=new wt(e[30]),n=1;n<30;++n)for(var a=e[n];a<e[n+1];++a)r[a]=a-e[n]<<5|n;return[e,r]},He=Ve(Ct,2),ye=He[0],Wt=He[1];ye[28]=258,Wt[258]=28;var Ke=Ve(Nt,0),Qe=Ke[0],pe=Ke[1],Lt=new K(32768);for(L=0;L<32768;++L)vt=(L&43690)>>>1|(L&21845)<<1,vt=(vt&52428)>>>2|(vt&13107)<<2,vt=(vt&61680)>>>4|(vt&3855)<<4,Lt[L]=((vt&65280)>>>8|(vt&255)<<8)>>>1;var vt,L,nt=function(i,t,e){for(var n=i.length,r=0,a=new K(t);r<n;++r)i[r]&&++a[i[r]-1];var s=new K(t);for(r=0;r<t;++r)s[r]=s[r-1]+a[r-1]<<1;var l;if(e){l=new K(1<<t);var o=15-t;for(r=0;r<n;++r)if(i[r])for(var f=r<<4|i[r],u=t-i[r],h=s[i[r]-1]++<<u,v=h|(1<<u)-1;h<=v;++h)l[Lt[h]>>>o]=f}else for(l=new K(n),r=0;r<n;++r)i[r]&&(l[r]=Lt[s[i[r]-1]++]>>>15-i[r]);return l},pt=new D(288);for(L=0;L<144;++L)pt[L]=8;var L;for(L=144;L<256;++L)pt[L]=9;var L;for(L=256;L<280;++L)pt[L]=7;var L;for(L=280;L<288;++L)pt[L]=8;var L,Tt=new D(32);for(L=0;L<32;++L)Tt[L]=5;var L,$e=nt(pt,9,0),We=nt(pt,9,1),Je=nt(Tt,5,0),ti=nt(Tt,5,1),Kt=function(i){for(var t=i[0],e=1;e<i.length;++e)i[e]>t&&(t=i[e]);return t},it=function(i,t,e){var n=t/8|0;return(i[n]|i[n+1]<<8)>>(t&7)&e},Qt=function(i,t){var e=t/8|0;return(i[e]|i[e+1]<<8|i[e+2]<<16)>>(t&7)},Zt=function(i){return(i+7)/8|0},rt=function(i,t,e){(t==null||t<0)&&(t=0),(e==null||e>i.length)&&(e=i.length);var n=new(i.BYTES_PER_ELEMENT==2?K:i.BYTES_PER_ELEMENT==4?wt:D)(e-t);return n.set(i.subarray(t,e)),n};I.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 ei=["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"],_=function(i,t,e){var n=new Error(t||ei[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,_),!e)throw n;return n},Yt=function(i,t,e){var n=i.length;if(!n||e&&e.f&&!e.l)return t||new D(0);var r=!t||e,a=!e||e.i;e||(e={}),t||(t=new D(n*3));var s=function(Vt){var bt=t.length;if(Vt>bt){var xt=new D(Math.max(bt*2,Vt));xt.set(t),t=xt}},l=e.f||0,o=e.p||0,f=e.b||0,u=e.l,h=e.d,v=e.m,m=e.n,g=n*8;do{if(!u){l=it(i,o,1);var p=it(i,o+1,3);if(o+=3,p)if(p==1)u=We,h=ti,v=9,m=5;else if(p==2){var T=it(i,o,31)+257,x=it(i,o+10,15)+4,R=T+it(i,o+5,31)+1;o+=14;for(var q=new D(R),M=new D(19),d=0;d<x;++d)M[Gt[d]]=it(i,o+d*3,7);o+=x*3;for(var Y=Kt(M),N=(1<<Y)-1,V=nt(M,Y,1),d=0;d<R;){var z=V[it(i,o,N)];o+=z&15;var c=z>>>4;if(c<16)q[d++]=c;else{var w=0,F=0;for(c==16?(F=3+it(i,o,3),o+=2,w=q[d-1]):c==17?(F=3+it(i,o,7),o+=3):c==18&&(F=11+it(i,o,127),o+=7);F--;)q[d++]=w}}var G=q.subarray(0,T),B=q.subarray(T);v=Kt(G),m=Kt(B),u=nt(G,v,1),h=nt(B,m,1)}else _(1);else{var c=Zt(o)+4,y=i[c-4]|i[c-3]<<8,A=c+y;if(A>n){a&&_(0);break}r&&s(f+y),t.set(i.subarray(c,A),f),e.b=f+=y,e.p=o=A*8,e.f=l;continue}if(o>g){a&&_(0);break}}r&&s(f+131072);for(var P=(1<<v)-1,k=(1<<m)-1,X=o;;X=o){var w=u[Qt(i,o)&P],et=w>>>4;if(o+=w&15,o>g){a&&_(0);break}if(w||_(2),et<256)t[f++]=et;else if(et==256){X=o,u=null;break}else{var Q=et-254;if(et>264){var d=et-257,ot=Ct[d];Q=it(i,o,(1<<ot)-1)+ye[d],o+=ot}var ft=h[Qt(i,o)&k],W=ft>>>4;ft||_(3),o+=ft&15;var B=Qe[W];if(W>3){var ot=Nt[W];B+=Qt(i,o)&(1<<ot)-1,o+=ot}if(o>g){a&&_(0);break}r&&s(f+131072);for(var H=f+Q;f<H;f+=4)t[f]=t[f-B],t[f+1]=t[f+1-B],t[f+2]=t[f+2-B],t[f+3]=t[f+3-B];f=H}}e.l=u,e.p=X,e.b=f,e.f=l,u&&(l=1,e.m=v,e.d=h,e.n=m)}while(!l);return f==t.length?t:rt(t,0,f)},ht=function(i,t,e){e<<=t&7;var n=t/8|0;i[n]|=e,i[n+1]|=e>>>8},Ut=function(i,t,e){e<<=t&7;var n=t/8|0;i[n]|=e,i[n+1]|=e>>>8,i[n+2]|=e>>>16},$t=function(i,t){for(var e=[],n=0;n<i.length;++n)i[n]&&e.push({s:n,f:i[n]});var r=e.length,a=e.slice();if(!r)return[gt,0];if(r==1){var s=new D(e[0].s+1);return s[e[0].s]=1,[s,1]}e.sort(function(R,q){return R.f-q.f}),e.push({s:-1,f:25001});var l=e[0],o=e[1],f=0,u=1,h=2;for(e[0]={s:-1,f:l.f+o.f,l,r:o};u!=r-1;)l=e[e[f].f<e[h].f?f++:h++],o=e[f!=u&&e[f].f<e[h].f?f++:h++],e[u++]={s:-1,f:l.f+o.f,l,r:o};for(var v=a[0].s,n=1;n<r;++n)a[n].s>v&&(v=a[n].s);var m=new K(v+1),g=Jt(e[u-1],m,0);if(g>t){var n=0,p=0,c=g-t,y=1<<c;for(a.sort(function(q,M){return m[M.s]-m[q.s]||q.f-M.f});n<r;++n){var A=a[n].s;if(m[A]>t)p+=y-(1<<g-m[A]),m[A]=t;else break}for(p>>>=c;p>0;){var T=a[n].s;m[T]<t?p-=1<<t-m[T]++-1:++n}for(;n>=0&&p;--n){var x=a[n].s;m[x]==t&&(--m[x],++p)}g=t}return[new D(m),g]},Jt=function(i,t,e){return i.s==-1?Math.max(Jt(i.l,t,e+1),Jt(i.r,t,e+1)):t[i.s]=e},de=function(i){for(var t=i.length;t&&!i[--t];);for(var e=new K(++t),n=0,r=i[0],a=1,s=function(o){e[n++]=o},l=1;l<=t;++l)if(i[l]==r&&l!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(r),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(r);a=1,r=i[l]}return[e.subarray(0,n),t]},St=function(i,t){for(var e=0,n=0;n<t.length;++n)e+=i[n]*t[n];return e},te=function(i,t,e){var n=e.length,r=Zt(t+2);i[r]=n&255,i[r+1]=n>>>8,i[r+2]=i[r]^255,i[r+3]=i[r+1]^255;for(var a=0;a<n;++a)i[r+a+4]=e[a];return(r+4+n)*8},me=function(i,t,e,n,r,a,s,l,o,f,u){ht(t,u++,e),++r[256];for(var h=$t(r,15),v=h[0],m=h[1],g=$t(a,15),p=g[0],c=g[1],y=de(v),A=y[0],T=y[1],x=de(p),R=x[0],q=x[1],M=new K(19),d=0;d<A.length;++d)M[A[d]&31]++;for(var d=0;d<R.length;++d)M[R[d]&31]++;for(var Y=$t(M,7),N=Y[0],V=Y[1],z=19;z>4&&!N[Gt[z-1]];--z);var w=f+5<<3,F=St(r,pt)+St(a,Tt)+s,G=St(r,v)+St(a,p)+s+14+3*z+St(M,N)+(2*M[16]+3*M[17]+7*M[18]);if(w<=F&&w<=G)return te(t,u,i.subarray(o,o+f));var B,P,k,X;if(ht(t,u,1+(G<F)),u+=2,G<F){B=nt(v,m,0),P=v,k=nt(p,c,0),X=p;var et=nt(N,V,0);ht(t,u,T-257),ht(t,u+5,q-1),ht(t,u+10,z-4),u+=14;for(var d=0;d<z;++d)ht(t,u+3*d,N[Gt[d]]);u+=3*z;for(var Q=[A,R],ot=0;ot<2;++ot)for(var ft=Q[ot],d=0;d<ft.length;++d){var W=ft[d]&31;ht(t,u,et[W]),u+=N[W],W>15&&(ht(t,u,ft[d]>>>5&127),u+=ft[d]>>>12)}}else B=$e,P=pt,k=Je,X=Tt;for(var d=0;d<l;++d)if(n[d]>255){var W=n[d]>>>18&31;Ut(t,u,B[W+257]),u+=P[W+257],W>7&&(ht(t,u,n[d]>>>23&31),u+=Ct[W]);var H=n[d]&31;Ut(t,u,k[H]),u+=X[H],H>3&&(Ut(t,u,n[d]>>>5&8191),u+=Nt[H])}else Ut(t,u,B[n[d]]),u+=P[n[d]];return Ut(t,u,B[256]),u+P[256]},ii=new wt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),gt=new D(0),ni=function(i,t,e,n,r,a){var s=i.length,l=new D(n+s+5*(1+Math.ceil(s/7e3))+r),o=l.subarray(n,l.length-r),f=0;if(!t||s<8)for(var u=0;u<=s;u+=65535){var h=u+65535;h>=s&&(o[f>>3]=a),f=te(o,f+1,i.subarray(u,h))}else{for(var v=ii[t-1],m=v>>>13,g=v&8191,p=(1<<e)-1,c=new K(32768),y=new K(p+1),A=Math.ceil(e/3),T=2*A,x=function(ve){return(i[ve]^i[ve+1]<<A^i[ve+2]<<T)&p},R=new wt(25e3),q=new K(288),M=new K(32),d=0,Y=0,u=0,N=0,V=0,z=0;u<s;++u){var w=x(u),F=u&32767,G=y[w];if(c[F]=G,y[w]=F,V<=u){var B=s-u;if((d>7e3||N>24576)&&B>423){f=me(i,o,0,R,q,M,Y,N,z,u-z,f),N=d=Y=0,z=u;for(var P=0;P<286;++P)q[P]=0;for(var P=0;P<30;++P)M[P]=0}var k=2,X=0,et=g,Q=F-G&32767;if(B>2&&w==x(u-Q))for(var ot=Math.min(m,B)-1,ft=Math.min(32767,u),W=Math.min(258,B);Q<=ft&&--et&&F!=G;){if(i[u+k]==i[u+k-Q]){for(var H=0;H<W&&i[u+H]==i[u+H-Q];++H);if(H>k){if(k=H,X=Q,H>ot)break;for(var Vt=Math.min(Q,H-2),bt=0,P=0;P<Vt;++P){var xt=u-Q+P+32768&32767,zi=c[xt],Ge=xt-zi+32768&32767;Ge>bt&&(bt=Ge,G=xt)}}}F=G,G=c[F],Q+=F-G+32768&32767}if(X){R[N++]=268435456|Wt[k]<<18|pe[X];var Le=Wt[k]&31,Re=pe[X]&31;Y+=Ct[Le]+Nt[Re],++q[257+Le],++M[Re],V=u+k,++d}else R[N++]=i[u],++q[i[u]]}}f=me(i,o,a,R,q,M,Y,N,z,u-z,f),!a&&f&7&&(f=te(o,f+1,gt))}return rt(l,0,n+Zt(f)+r)},ri=function(){for(var i=new Int32Array(256),t=0;t<256;++t){for(var e=t,n=9;--n;)e=(e&1&&-306674912)^e>>>1;i[t]=e}return i}(),Ft=function(){var i=-1;return{p:function(t){for(var e=i,n=0;n<t.length;++n)e=ri[e&255^t[n]]^e>>>8;i=e},d:function(){return~i}}},Ae=function(){var i=1,t=0;return{p:function(e){for(var n=i,r=t,a=e.length|0,s=0;s!=a;){for(var l=Math.min(s+2655,a);s<l;++s)r+=n+=e[s];n=(n&65535)+15*(n>>16),r=(r&65535)+15*(r>>16)}i=n,t=r},d:function(){return i%=65521,t%=65521,(i&255)<<24|i>>>8<<16|(t&255)<<8|t>>>8}}},yt=function(i,t,e,n,r){return ni(i,t.level==null?6:t.level,t.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):12+t.mem,e,n,!r)},kt=function(i,t){var e={};for(var n in i)e[n]=i[n];for(var n in t)e[n]=t[n];return e},Xe=function(i,t,e){for(var n=i(),r=i.toString(),a=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<n.length;++s){var l=n[s],o=a[s];if(typeof l=="function"){t+=";"+o+"=";var f=l.toString();if(l.prototype)if(f.indexOf("[native code]")!=-1){var u=f.indexOf(" ",8)+1;t+=f.slice(u,f.indexOf("(",u))}else{t+=f;for(var h in l.prototype)t+=";"+o+".prototype."+h+"="+l.prototype[h].toString()}else t+=f}else e[o]=l}return[t,e]},Ht=[],Bi=function(i){var t=[];for(var e in i)i[e].buffer&&t.push((i[e]=new i[e].constructor(i[e])).buffer);return t},si=function(i,t,e,n){var r;if(!Ht[e]){for(var a="",s={},l=i.length-1,o=0;o<l;++o)r=Xe(i[o],a,s),a=r[0],s=r[1];Ht[e]=Xe(i[l],a,s)}var f=kt({},Ht[e][1]);return qi.default(Ht[e][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",e,f,Bi(f),n)},zt=function(){return[D,K,wt,Ct,Nt,Gt,ye,Qe,We,ti,Lt,ei,nt,Kt,it,Qt,Zt,rt,_,Yt,Bt,_t,xe]},Dt=function(){return[D,K,wt,Ct,Nt,Gt,Wt,pe,$e,pt,Je,Tt,Lt,ii,gt,nt,ht,Ut,$t,Jt,de,St,te,me,Zt,rt,ni,yt,Xt,_t]},ai=function(){return[Ue,Te,Z,Ft,ri]},oi=function(){return[Se,hi]},li=function(){return[Me,Z,Ae]},fi=function(){return[ui]},_t=function(i){return postMessage(i,[i.buffer])},xe=function(i){return i&&i.size&&new D(i.size)},Ot=function(i,t,e,n,r,a){var s=si(e,n,r,function(l,o){s.terminate(),a(l,o)});return s.postMessage([i,t],t.consume?[i.buffer]:[]),function(){s.terminate()}},st=function(i){return i.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(t){return i.push(t.data[0],t.data[1])}},qt=function(i,t,e,n,r){var a,s=si(i,n,r,function(l,o){l?(s.terminate(),t.ondata.call(t,l)):(o[1]&&s.terminate(),t.ondata.call(t,l,o[0],o[1]))});s.postMessage(e),t.push=function(l,o){t.ondata||_(5),a&&t.ondata(_(4,0,1),null,!!o),s.postMessage([l,a=o],[l.buffer])},t.terminate=function(){s.terminate()}},$=function(i,t){return i[t]|i[t+1]<<8},j=function(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16|i[t+3]<<24)>>>0},ge=function(i,t){return j(i,t)+j(i,t+4)*4294967296},Z=function(i,t,e){for(;e;++t)i[t]=e,e>>>=8},Ue=function(i,t){var e=t.filename;if(i[0]=31,i[1]=139,i[2]=8,i[8]=t.level<2?4:t.level==9?2:0,i[9]=3,t.mtime!=0&&Z(i,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),e){i[3]=8;for(var n=0;n<=e.length;++n)i[n+10]=e.charCodeAt(n)}},Se=function(i){(i[0]!=31||i[1]!=139||i[2]!=8)&&_(6,"invalid gzip data");var t=i[3],e=10;t&4&&(e+=i[10]|(i[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!i[e++]);return e+(t&2)},hi=function(i){var t=i.length;return(i[t-4]|i[t-3]<<8|i[t-2]<<16|i[t-1]<<24)>>>0},Te=function(i){return 10+(i.filename&&i.filename.length+1||0)},Me=function(i,t){var e=t.level,n=e==0?0:e<6?1:e==9?3:2;i[0]=120,i[1]=n<<6|(n?32-2*n:1)},ui=function(i){((i[0]&15)!=8||i[0]>>>4>7||(i[0]<<8|i[1])%31)&&_(6,"invalid zlib data"),i[1]&32&&_(6,"invalid zlib data: preset dictionaries not supported")};function we(i,t){return!t&&typeof i=="function"&&(t=i,i={}),this.ondata=t,i}var ut=function(){function i(t,e){!e&&typeof t=="function"&&(e=t,t={}),this.ondata=e,this.o=t||{}}return i.prototype.p=function(t,e){this.ondata(yt(t,this.o,0,0,!e),e)},i.prototype.push=function(t,e){this.ondata||_(5),this.d&&_(4),this.d=e,this.p(t,e||!1)},i}();I.Deflate=ut;var ci=function(){function i(t,e){qt([Dt,function(){return[st,ut]}],this,we.call(this,t,e),function(n){var r=new ut(n.data);onmessage=st(r)},6)}return i}();I.AsyncDeflate=ci;function vi(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[Dt],function(n){return _t(Xt(n.data[0],n.data[1]))},0,e)}I.deflate=vi;function Xt(i,t){return yt(i,t||{},0,0)}I.deflateSync=Xt;var J=function(){function i(t){this.s={},this.p=new D(0),this.ondata=t}return i.prototype.e=function(t){this.ondata||_(5),this.d&&_(4);var e=this.p.length,n=new D(e+t.length);n.set(this.p),n.set(t,e),this.p=n},i.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=Yt(this.p,this.o,this.s);this.ondata(rt(n,e,this.s.b),this.d),this.o=rt(n,this.s.b-32768),this.s.b=this.o.length,this.p=rt(this.p,this.s.p/8|0),this.s.p&=7},i.prototype.push=function(t,e){this.e(t),this.c(e)},i}();I.Inflate=J;var Ce=function(){function i(t){this.ondata=t,qt([zt,function(){return[st,J]}],this,0,function(){var e=new J;onmessage=st(e)},7)}return i}();I.AsyncInflate=Ce;function Ne(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[zt],function(n){return _t(Bt(n.data[0],xe(n.data[1])))},1,e)}I.inflate=Ne;function Bt(i,t){return Yt(i,t)}I.inflateSync=Bt;var ee=function(){function i(t,e){this.c=Ft(),this.l=0,this.v=1,ut.call(this,t,e)}return i.prototype.push=function(t,e){ut.prototype.push.call(this,t,e)},i.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=yt(t,this.o,this.v&&Te(this.o),e&&8,!e);this.v&&(Ue(n,this.o),this.v=0),e&&(Z(n,n.length-8,this.c.d()),Z(n,n.length-4,this.l)),this.ondata(n,e)},i}();I.Gzip=ee;I.Compress=ee;var gi=function(){function i(t,e){qt([Dt,ai,function(){return[st,ut,ee]}],this,we.call(this,t,e),function(n){var r=new ee(n.data);onmessage=st(r)},8)}return i}();I.AsyncGzip=gi;I.AsyncCompress=gi;function pi(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[Dt,ai,function(){return[ie]}],function(n){return _t(ie(n.data[0],n.data[1]))},2,e)}I.gzip=pi;I.compress=pi;function ie(i,t){t||(t={});var e=Ft(),n=i.length;e.p(i);var r=yt(i,t,Te(t),8),a=r.length;return Ue(r,t),Z(r,a-8,e.d()),Z(r,a-4,n),r}I.gzipSync=ie;I.compressSync=ie;var ne=function(){function i(t){this.v=1,J.call(this,t)}return i.prototype.push=function(t,e){if(J.prototype.e.call(this,t),this.v){var n=this.p.length>3?Se(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}e&&(this.p.length<8&&_(6,"invalid gzip data"),this.p=this.p.subarray(0,-8)),J.prototype.c.call(this,e)},i}();I.Gunzip=ne;var di=function(){function i(t){this.ondata=t,qt([zt,oi,function(){return[st,J,ne]}],this,0,function(){var e=new ne;onmessage=st(e)},9)}return i}();I.AsyncGunzip=di;function mi(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[zt,oi,function(){return[re]}],function(n){return _t(re(n.data[0]))},3,e)}I.gunzip=mi;function re(i,t){return Yt(i.subarray(Se(i),-8),t||new D(hi(i)))}I.gunzipSync=re;var _e=function(){function i(t,e){this.c=Ae(),this.v=1,ut.call(this,t,e)}return i.prototype.push=function(t,e){ut.prototype.push.call(this,t,e)},i.prototype.p=function(t,e){this.c.p(t);var n=yt(t,this.o,this.v&&2,e&&4,!e);this.v&&(Me(n,this.o),this.v=0),e&&Z(n,n.length-4,this.c.d()),this.ondata(n,e)},i}();I.Zlib=_e;var Pi=function(){function i(t,e){qt([Dt,li,function(){return[st,ut,_e]}],this,we.call(this,t,e),function(n){var r=new _e(n.data);onmessage=st(r)},10)}return i}();I.AsyncZlib=Pi;function bi(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[Dt,li,function(){return[Ee]}],function(n){return _t(Ee(n.data[0],n.data[1]))},4,e)}I.zlib=bi;function Ee(i,t){t||(t={});var e=Ae();e.p(i);var n=yt(i,t,2,4);return Me(n,t),Z(n,n.length-4,e.d()),n}I.zlibSync=Ee;var se=function(){function i(t){this.v=1,J.call(this,t)}return i.prototype.push=function(t,e){if(J.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&&_(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),J.prototype.c.call(this,e)},i}();I.Unzlib=se;var _i=function(){function i(t){this.ondata=t,qt([zt,fi,function(){return[st,J,se]}],this,0,function(){var e=new se;onmessage=st(e)},11)}return i}();I.AsyncUnzlib=_i;function Ei(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),Ot(i,t,[zt,fi,function(){return[ae]}],function(n){return _t(ae(n.data[0],xe(n.data[1])))},5,e)}I.unzlib=Ei;function ae(i,t){return Yt((ui(i),i.subarray(2,-4)),t)}I.unzlibSync=ae;var Ii=function(){function i(t){this.G=ne,this.I=J,this.Z=se,this.ondata=t}return i.prototype.push=function(t,e){if(this.ondata||_(5),this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new D(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,a=function(){r.ondata.apply(r,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(a):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(a):new this.Z(a),this.s.push(this.p,e),this.p=null}}},i}();I.Decompress=Ii;var Gi=function(){function i(t){this.G=di,this.I=Ce,this.Z=_i,this.ondata=t}return i.prototype.push=function(t,e){Ii.prototype.push.call(this,t,e)},i}();I.AsyncDecompress=Gi;function Li(i,t,e){return e||(e=t,t={}),typeof e!="function"&&_(7),i[0]==31&&i[1]==139&&i[2]==8?mi(i,t,e):(i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31?Ne(i,t,e):Ei(i,t,e)}I.decompress=Li;function Ri(i,t){return i[0]==31&&i[1]==139&&i[2]==8?re(i,t):(i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31?Bt(i,t):ae(i,t)}I.decompressSync=Ri;var Fe=function(i,t,e,n){for(var r in i){var a=i[r],s=t+r,l=n;Array.isArray(a)&&(l=kt(n,a[1]),a=a[0]),a instanceof D?e[s]=[a,l]:(e[s+="/"]=[new D(0),l],Fe(a,s,e,n))}},je=typeof TextEncoder<"u"&&new TextEncoder,Ie=typeof TextDecoder<"u"&&new TextDecoder,yi=0;try{Ie.decode(gt,{stream:!0}),yi=1}catch{}var Ai=function(i){for(var t="",e=0;;){var n=i[e++],r=(n>127)+(n>223)+(n>239);if(e+r>i.length)return[t,rt(i,e-1)];r?r==3?(n=((n&15)<<18|(i[e++]&63)<<12|(i[e++]&63)<<6|i[e++]&63)-65536,t+=String.fromCharCode(55296|n>>10,56320|n&1023)):r&1?t+=String.fromCharCode((n&31)<<6|i[e++]&63):t+=String.fromCharCode((n&15)<<12|(i[e++]&63)<<6|i[e++]&63):t+=String.fromCharCode(n)}},Zi=function(){function i(t){this.ondata=t,yi?this.t=new TextDecoder:this.p=gt}return i.prototype.push=function(t,e){if(this.ondata||_(5),e=!!e,this.t){this.ondata(this.t.decode(t,{stream:!0}),e),e&&(this.t.decode().length&&_(8),this.t=null);return}this.p||_(4);var n=new D(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=Ai(n),a=r[0],s=r[1];e?(s.length&&_(8),this.p=null):this.p=s,this.ondata(a,e)},i}();I.DecodeUTF8=Zi;var Yi=function(){function i(t){this.ondata=t}return i.prototype.push=function(t,e){this.ondata||_(5),this.d&&_(4),this.ondata(mt(t),this.d=e||!1)},i}();I.EncodeUTF8=Yi;function mt(i,t){if(t){for(var e=new D(i.length),n=0;n<i.length;++n)e[n]=i.charCodeAt(n);return e}if(je)return je.encode(i);for(var r=i.length,a=new D(i.length+(i.length>>1)),s=0,l=function(u){a[s++]=u},n=0;n<r;++n){if(s+5>a.length){var o=new D(s+8+(r-n<<1));o.set(a),a=o}var f=i.charCodeAt(n);f<128||t?l(f):f<2048?(l(192|f>>6),l(128|f&63)):f>55295&&f<57344?(f=65536+(f&1023<<10)|i.charCodeAt(++n)&1023,l(240|f>>18),l(128|f>>12&63),l(128|f>>6&63),l(128|f&63)):(l(224|f>>12),l(128|f>>6&63),l(128|f&63))}return rt(a,0,s)}I.strToU8=mt;function ze(i,t){if(t){for(var e="",n=0;n<i.length;n+=16384)e+=String.fromCharCode.apply(null,i.subarray(n,n+16384));return e}else{if(Ie)return Ie.decode(i);var r=Ai(i),a=r[0],s=r[1];return s.length&&_(8),a}}I.strFromU8=ze;var xi=function(i){return i==1?3:i<6?2:i==9?1:0},Ui=function(i,t){return t+30+$(i,t+26)+$(i,t+28)},Si=function(i,t,e){var n=$(i,t+28),r=ze(i.subarray(t+46,t+46+n),!($(i,t+8)&2048)),a=t+46+n,s=j(i,t+20),l=e&&s==4294967295?Ti(i,a):[s,j(i,t+24),j(i,t+42)],o=l[0],f=l[1],u=l[2];return[$(i,t+10),o,f,r,a+$(i,t+30)+$(i,t+32),u]},Ti=function(i,t){for(;$(i,t)!=1;t+=4+$(i,t+2));return[ge(i,t+12),ge(i,t+4),ge(i,t+20)]},dt=function(i){var t=0;if(i)for(var e in i){var n=i[e].length;n>65535&&_(9),t+=n+4}return t},Mt=function(i,t,e,n,r,a,s,l){var o=n.length,f=e.extra,u=l&&l.length,h=dt(f);Z(i,t,s!=null?33639248:67324752),t+=4,s!=null&&(i[t++]=20,i[t++]=e.os),i[t]=20,t+=2,i[t++]=e.flag<<1|(a==null&&8),i[t++]=r&&8,i[t++]=e.compression&255,i[t++]=e.compression>>8;var v=new Date(e.mtime==null?Date.now():e.mtime),m=v.getFullYear()-1980;if((m<0||m>119)&&_(10),Z(i,t,m<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>>1),t+=4,a!=null&&(Z(i,t,e.crc),Z(i,t+4,a),Z(i,t+8,e.size)),Z(i,t+12,o),Z(i,t+14,h),t+=16,s!=null&&(Z(i,t,u),Z(i,t+6,e.attrs),Z(i,t+10,s),t+=14),i.set(n,t),t+=o,h)for(var g in f){var p=f[g],c=p.length;Z(i,t,+g),Z(i,t+2,c),i.set(p,t+4),t+=4+c}return u&&(i.set(l,t),t+=u),t},De=function(i,t,e,n,r){Z(i,t,101010256),Z(i,t+8,e),Z(i,t+10,e),Z(i,t+12,n),Z(i,t+16,r)},Rt=function(){function i(t){this.filename=t,this.c=Ft(),this.size=0,this.compression=0}return i.prototype.process=function(t,e){this.ondata(null,t,e)},i.prototype.push=function(t,e){this.ondata||_(5),this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},i}();I.ZipPassThrough=Rt;var ki=function(){function i(t,e){var n=this;e||(e={}),Rt.call(this,t),this.d=new ut(e,function(r,a){n.ondata(null,r,a)}),this.compression=8,this.flag=xi(e.level)}return i.prototype.process=function(t,e){try{this.d.push(t,e)}catch(n){this.ondata(n,null,e)}},i.prototype.push=function(t,e){Rt.prototype.push.call(this,t,e)},i}();I.ZipDeflate=ki;var Xi=function(){function i(t,e){var n=this;e||(e={}),Rt.call(this,t),this.d=new ci(e,function(r,a,s){n.ondata(r,a,s)}),this.compression=8,this.flag=xi(e.level),this.terminate=this.d.terminate}return i.prototype.process=function(t,e){this.d.push(t,e)},i.prototype.push=function(t,e){Rt.prototype.push.call(this,t,e)},i}();I.AsyncZipDeflate=Xi;var ji=function(){function i(t){this.ondata=t,this.u=[],this.d=1}return i.prototype.add=function(t){var e=this;if(this.ondata||_(5),this.d&2)this.ondata(_(4+(this.d&1)*8,0,1),null,!1);else{var n=mt(t.filename),r=n.length,a=t.comment,s=a&&mt(a),l=r!=t.filename.length||s&&a.length!=s.length,o=r+dt(t.extra)+30;r>65535&&this.ondata(_(11,0,1),null,!1);var f=new D(o);Mt(f,0,t,n,l);var u=[f],h=function(){for(var c=0,y=u;c<y.length;c++){var A=y[c];e.ondata(null,A,!1)}u=[]},v=this.d;this.d=0;var m=this.u.length,g=kt(t,{f:n,u:l,o:s,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),v){var c=e.u[m+1];c?c.r():e.d=1}v=1}}),p=0;t.ondata=function(c,y,A){if(c)e.ondata(c,y,A),e.terminate();else if(p+=y.length,u.push(y),A){var T=new D(16);Z(T,0,134695760),Z(T,4,t.crc),Z(T,8,p),Z(T,12,t.size),u.push(T),g.c=p,g.b=o+p+16,g.crc=t.crc,g.size=t.size,v&&g.r(),v=1}else v&&h()},this.u.push(g)}},i.prototype.end=function(){var t=this;if(this.d&2){this.ondata(_(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){t.d&1&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},i.prototype.e=function(){for(var t=0,e=0,n=0,r=0,a=this.u;r<a.length;r++){var s=a[r];n+=46+s.f.length+dt(s.extra)+(s.o?s.o.length:0)}for(var l=new D(n+22),o=0,f=this.u;o<f.length;o++){var s=f[o];Mt(l,t,s,s.f,s.u,s.c,e,s.o),t+=46+s.f.length+dt(s.extra)+(s.o?s.o.length:0),e+=s.b}De(l,t,this.u.length,n,e),this.ondata(null,l,!0),this.d=2},i.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++){var n=e[t];n.t()}this.d=2},i}();I.Zip=ji;function Vi(i,t,e){e||(e=t,t={}),typeof e!="function"&&_(7);var n={};Fe(i,"",n,t);var r=Object.keys(n),a=r.length,s=0,l=0,o=a,f=new Array(a),u=[],h=function(){for(var c=0;c<u.length;++c)u[c]()},v=function(c,y){oe(function(){e(c,y)})};oe(function(){v=e});var m=function(){var c=new D(l+22),y=s,A=l-s;l=0;for(var T=0;T<o;++T){var x=f[T];try{var R=x.c.length;Mt(c,l,x,x.f,x.u,R);var q=30+x.f.length+dt(x.extra),M=l+q;c.set(x.c,M),Mt(c,s,x,x.f,x.u,R,l,x.m),s+=16+q+(x.m?x.m.length:0),l=M+R}catch(d){return v(d,null)}}De(c,s,f.length,A,y),v(null,c)};a||m();for(var g=function(c){var y=r[c],A=n[y],T=A[0],x=A[1],R=Ft(),q=T.length;R.p(T);var M=mt(y),d=M.length,Y=x.comment,N=Y&&mt(Y),V=N&&N.length,z=dt(x.extra),w=x.level==0?0:8,F=function(G,B){if(G)h(),v(G,null);else{var P=B.length;f[c]=kt(x,{size:q,crc:R.d(),c:B,f:M,m:N,u:d!=y.length||N&&Y.length!=V,compression:w}),s+=30+d+z+P,l+=76+2*(d+z)+(V||0)+P,--a||m()}};if(d>65535&&F(_(11,0,1),null),!w)F(null,T);else if(q<16e4)try{F(null,Xt(T,x))}catch(G){F(G,null)}else u.push(vi(T,x,F))},p=0;p<o;++p)g(p);return h}I.zip=Vi;function Hi(i,t){t||(t={});var e={},n=[];Fe(i,"",e,t);var r=0,a=0;for(var s in e){var l=e[s],o=l[0],f=l[1],u=f.level==0?0:8,h=mt(s),v=h.length,m=f.comment,g=m&&mt(m),p=g&&g.length,c=dt(f.extra);v>65535&&_(11);var y=u?Xt(o,f):o,A=y.length,T=Ft();T.p(o),n.push(kt(f,{size:o.length,crc:T.d(),c:y,f:h,m:g,u:v!=s.length||g&&m.length!=p,o:r,compression:u})),r+=30+v+c+A,a+=76+2*(v+c)+(p||0)+A}for(var x=new D(a+22),R=r,q=a-r,M=0;M<n.length;++M){var h=n[M];Mt(x,h.o,h,h.f,h.u,h.c.length);var d=30+h.f.length+dt(h.extra);x.set(h.c,h.o+d),Mt(x,r,h,h.f,h.u,h.c.length,h.o,h.m),r+=16+d+(h.m?h.m.length:0)}return De(x,r,n.length,q,R),x}I.zipSync=Hi;var Mi=function(){function i(){}return i.prototype.push=function(t,e){this.ondata(null,t,e)},i.compression=0,i}();I.UnzipPassThrough=Mi;var Ki=function(){function i(){var t=this;this.i=new J(function(e,n){t.ondata(null,e,n)})}return i.prototype.push=function(t,e){try{this.i.push(t,e)}catch(n){this.ondata(n,null,e)}},i.compression=8,i}();I.UnzipInflate=Ki;var Qi=function(){function i(t,e){var n=this;e<32e4?this.i=new J(function(r,a){n.ondata(null,r,a)}):(this.i=new Ce(function(r,a,s){n.ondata(r,a,s)}),this.terminate=this.i.terminate)}return i.prototype.push=function(t,e){this.i.terminate&&(t=rt(t,0)),this.i.push(t,e)},i.compression=8,i}();I.AsyncUnzipInflate=Qi;var $i=function(){function i(t){this.onfile=t,this.k=[],this.o={0:Mi},this.p=gt}return i.prototype.push=function(t,e){var n=this;if(this.onfile||_(5),this.p||_(4),this.c>0){var r=Math.min(this.c,t.length),a=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(a,!this.c):this.k[0].push(a),t=t.subarray(r),t.length)return this.push(t,e)}else{var s=0,l=0,o=void 0,f=void 0;this.p.length?t.length?(f=new D(this.p.length+t.length),f.set(this.p),f.set(t,this.p.length)):f=this.p:f=t;for(var u=f.length,h=this.c,v=h&&this.d,m=function(){var y,A=j(f,l);if(A==67324752){s=1,o=l,g.d=null,g.c=0;var T=$(f,l+6),x=$(f,l+8),R=T&2048,q=T&8,M=$(f,l+26),d=$(f,l+28);if(u>l+30+M+d){var Y=[];g.k.unshift(Y),s=2;var N=j(f,l+18),V=j(f,l+22),z=ze(f.subarray(l+30,l+=30+M),!R);N==4294967295?(y=q?[-2]:Ti(f,l),N=y[0],V=y[1]):q&&(N=-1),l+=d,g.c=N;var w,F={name:z,compression:x,start:function(){if(F.ondata||_(5),!N)F.ondata(null,gt,!0);else{var G=n.o[x];G||F.ondata(_(14,"unknown compression type "+x,1),null,!1),w=N<0?new G(z):new G(z,N,V),w.ondata=function(X,et,Q){F.ondata(X,et,Q)};for(var B=0,P=Y;B<P.length;B++){var k=P[B];w.push(k,!1)}n.k[0]==Y&&n.c?n.d=w:w.push(gt,!0)}},terminate:function(){w&&w.terminate&&w.terminate()}};N>=0&&(F.size=N,F.originalSize=V),g.onfile(F)}return"break"}else if(h){if(A==134695760)return o=l+=12+(h==-2&&8),s=3,g.c=0,"break";if(A==33639248)return o=l-=4,s=3,g.c=0,"break"}},g=this;l<u-4;++l){var p=m();if(p==="break")break}if(this.p=gt,h<0){var c=s?f.subarray(0,o-12-(h==-2&&8)-(j(f,o-16)==134695760&&4)):f.subarray(0,l);v?v.push(c,!!s):this.k[+(s==2)].push(c)}if(s&2)return this.push(f.subarray(l),e);this.p=f.subarray(l)}e&&(this.c&&_(13),this.p=null)},i.prototype.register=function(t){this.o[t.compression]=t},i}();I.Unzip=$i;var oe=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(i){i()};function Wi(i,t,e){e||(e=t,t={}),typeof e!="function"&&_(7);var n=[],r=function(){for(var p=0;p<n.length;++p)n[p]()},a={},s=function(p,c){oe(function(){e(p,c)})};oe(function(){s=e});for(var l=i.length-22;j(i,l)!=101010256;--l)if(!l||i.length-l>65558)return s(_(13,0,1),null),r;var o=$(i,l+8);if(o){var f=o,u=j(i,l+16),h=u==4294967295;if(h){if(l=j(i,l-12),j(i,l)!=101075792)return s(_(13,0,1),null),r;f=o=j(i,l+32),u=j(i,l+48)}for(var v=t&&t.filter,m=function(p){var c=Si(i,u,h),y=c[0],A=c[1],T=c[2],x=c[3],R=c[4],q=c[5],M=Ui(i,q);u=R;var d=function(N,V){N?(r(),s(N,null)):(V&&(a[x]=V),--o||s(null,a))};if(!v||v({name:x,size:A,originalSize:T,compression:y}))if(!y)d(null,rt(i,M,M+A));else if(y==8){var Y=i.subarray(M,M+A);if(A<32e4)try{d(null,Bt(Y,new D(T)))}catch(N){d(N,null)}else n.push(Ne(Y,{size:T},d))}else d(_(14,"unknown compression type "+y,1),null);else d(null,null)},g=0;g<f;++g)m(g)}else s(null,{});return r}I.unzip=Wi;function Ji(i,t){for(var e={},n=i.length-22;j(i,n)!=101010256;--n)(!n||i.length-n>65558)&&_(13);var r=$(i,n+8);if(!r)return{};var a=j(i,n+16),s=a==4294967295;s&&(n=j(i,n-12),j(i,n)!=101075792&&_(13),r=j(i,n+32),a=j(i,n+48));for(var l=t&&t.filter,o=0;o<r;++o){var f=Si(i,a,s),u=f[0],h=f[1],v=f[2],m=f[3],g=f[4],p=f[5],c=Ui(i,p);a=g,(!l||l({name:m,size:h,originalSize:v,compression:u}))&&(u?u==8?e[m]=Bt(i.subarray(c,c+h),new D(v)):_(14,"unknown compression type "+u):e[m]=rt(i,c,c+h))}return e}I.unzipSync=Ji});var qe=It(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.NIFTIEXTENSION=void 0;var Oe=class{esize;ecode;edata;littleEndian;constructor(t,e,n,r){if(t%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=t,this.ecode=e,this.edata=n,this.littleEndian=r}toArrayBuffer(){let t=new Uint8Array(this.esize),e=new Uint8Array(this.edata);t.set(e,8);let n=new DataView(t.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),t.buffer}};le.NIFTIEXTENSION=Oe});var jt=It(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.Utils=void 0;var tn=qe(),lt=class{static getStringAt(t,e,n){var r="",a,s;for(a=e;a<n;a+=1)s=t.getUint8(a),s!==0&&(r+=String.fromCharCode(s));return r}static getIntAt(t,e,n){return t.getInt32(e,n)}static getFloatAt(t,e,n){return t.getFloat32(e,n)}static getDoubleAt(t,e,n){return t.getFloat64(e,n)}static getLongAt(t,e,n){var r,a=[],s=0;for(r=0;r<8;r+=1)a[r]=lt.getByteAt(t,e+r);for(r=a.length-1;r>=0;r--)s=s*256+a[r];return s}static getExtensionsAt(t,e,n,r){let a=[],s=e;for(;s<r;){let l=n,o=lt.getIntAt(t,s,n);if(!o)break;if(o+s>r&&(l=!l,o=lt.getIntAt(t,s,l),o+s>r))throw new Error("This does not appear to be a valid NIFTI extension");if(o%16!=0)throw new Error("This does not appear to be a NIFTI extension");let f=lt.getIntAt(t,s+4,l),u=t.buffer.slice(s+8,s+o);console.log("extensionByteIndex: "+(s+8)+" esize: "+o),console.log(u);let h=new tn.NIFTIEXTENSION(o,f,u,l);a.push(h),s+=o}return a}static toArrayBuffer(t){var e,n,r;for(e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r<t.length;r+=1)n[r]=t[r];return e}static isString(t){return typeof t=="string"||t instanceof String}static formatNumber(t,e=void 0){let n;return lt.isString(t)?n=Number(t):n=t,e?n=n.toPrecision(5):n=n.toPrecision(7),parseFloat(n)}static makeCRCTable(){let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e}static crc32(t){lt.crcTable||(lt.crcTable=lt.makeCRCTable());let e=lt.crcTable,n=-1;for(var r=0;r<t.byteLength;r++)n=n>>>8^e[(n^t.getUint8(r))&255];return(n^-1)>>>0}},Et=lt;E(Et,"crcTable",null),E(Et,"GUNZIP_MAGIC_COOKIE1",31),E(Et,"GUNZIP_MAGIC_COOKIE2",139),E(Et,"getByteAt",function(t,e){return t.getInt8(e)}),E(Et,"getShortAt",function(t,e,n){return t.getInt16(e,n)});fe.Utils=Et});var ue=It(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.NIFTI1=void 0;var U=jt(),b=class{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=[];readHeader(t){var e=new DataView(t),n=U.Utils.getIntAt(e,0,this.littleEndian),r,a,s,l;if(n!==b.MAGIC_COOKIE&&(this.littleEndian=!0,n=U.Utils.getIntAt(e,0,this.littleEndian)),n!==b.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=U.Utils.getByteAt(e,39),r=0;r<8;r+=1)l=40+r*2,this.dims[r]=U.Utils.getShortAt(e,l,this.littleEndian);for(this.intent_p1=U.Utils.getFloatAt(e,56,this.littleEndian),this.intent_p2=U.Utils.getFloatAt(e,60,this.littleEndian),this.intent_p3=U.Utils.getFloatAt(e,64,this.littleEndian),this.intent_code=U.Utils.getShortAt(e,68,this.littleEndian),this.datatypeCode=U.Utils.getShortAt(e,70,this.littleEndian),this.numBitsPerVoxel=U.Utils.getShortAt(e,72,this.littleEndian),this.slice_start=U.Utils.getShortAt(e,74,this.littleEndian),r=0;r<8;r+=1)l=76+r*4,this.pixDims[r]=U.Utils.getFloatAt(e,l,this.littleEndian);if(this.vox_offset=U.Utils.getFloatAt(e,108,this.littleEndian),this.scl_slope=U.Utils.getFloatAt(e,112,this.littleEndian),this.scl_inter=U.Utils.getFloatAt(e,116,this.littleEndian),this.slice_end=U.Utils.getShortAt(e,120,this.littleEndian),this.slice_code=U.Utils.getByteAt(e,122),this.xyzt_units=U.Utils.getByteAt(e,123),this.cal_max=U.Utils.getFloatAt(e,124,this.littleEndian),this.cal_min=U.Utils.getFloatAt(e,128,this.littleEndian),this.slice_duration=U.Utils.getFloatAt(e,132,this.littleEndian),this.toffset=U.Utils.getFloatAt(e,136,this.littleEndian),this.description=U.Utils.getStringAt(e,148,228),this.aux_file=U.Utils.getStringAt(e,228,252),this.qform_code=U.Utils.getShortAt(e,252,this.littleEndian),this.sform_code=U.Utils.getShortAt(e,254,this.littleEndian),this.quatern_b=U.Utils.getFloatAt(e,256,this.littleEndian),this.quatern_c=U.Utils.getFloatAt(e,260,this.littleEndian),this.quatern_d=U.Utils.getFloatAt(e,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=U.Utils.getFloatAt(e,268,this.littleEndian),this.qoffset_y=U.Utils.getFloatAt(e,272,this.littleEndian),this.qoffset_z=U.Utils.getFloatAt(e,276,this.littleEndian),this.qform_code>0){let o=this.quatern_a,f=this.quatern_b,u=this.quatern_c,h=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[o*o+f*f-u*u-h*h,2*f*u-2*o*h,2*f*h+2*o*u],[2*f*u+2*o*h,o*o+u*u-f*f-h*h,2*u*h-2*o*f],[2*f*h-2*o*u,2*u*h+2*o*f,o*o+h*h-u*u-f*f]],a=0;a<3;a+=1)for(s=0;s<3;s+=1)this.affine[a][s]=this.quatern_R[a][s]*this.pixDims[s+1],s===2&&(this.affine[a][s]*=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(a=0;a<3;a+=1)for(s=0;s<4;s+=1)l=280+(a*4+s)*4,this.affine[a][s]=U.Utils.getFloatAt(e,l,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=U.Utils.getStringAt(e,328,344),this.magic=U.Utils.getStringAt(e,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,b.MAGIC_NUMBER2),e.byteLength>b.MAGIC_COOKIE&&(this.extensionFlag[0]=U.Utils.getByteAt(e,348),this.extensionFlag[1]=U.Utils.getByteAt(e,348+1),this.extensionFlag[2]=U.Utils.getByteAt(e,348+2),this.extensionFlag[3]=U.Utils.getByteAt(e,348+3),this.extensionFlag[0]&&(this.extensions=U.Utils.getExtensionsAt(e,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var t=U.Utils.formatNumber,e="";return e+="Dim Info = "+this.dim_info+` | ||
`,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]+` | ||
`,e+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+` | ||
`,e+="Intent Code = "+this.intent_code+` | ||
`,e+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`) | ||
`,e+="Bits Per Voxel = "+this.numBitsPerVoxel+` | ||
`,e+="Slice Start = "+this.slice_start+` | ||
`,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])+` | ||
`,e+="Image Offset = "+this.vox_offset+` | ||
`,e+="Data Scale: Slope = "+t(this.scl_slope)+" Intercept = "+t(this.scl_inter)+` | ||
`,e+="Slice End = "+this.slice_end+` | ||
`,e+="Slice Code = "+this.slice_code+` | ||
`,e+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(b.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(b.TEMPORAL_UNITS_MASK&this.xyzt_units)+`) | ||
`,e+="Display Range: Max = "+t(this.cal_max)+" Min = "+t(this.cal_min)+` | ||
`,e+="Slice Duration = "+this.slice_duration+` | ||
`,e+="Time Axis Shift = "+this.toffset+` | ||
`,e+='Description: "'+this.description+`" | ||
`,e+='Auxiliary File: "'+this.aux_file+`" | ||
`,e+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`) | ||
`,e+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`) | ||
`,e+="Quaternion Parameters: b = "+t(this.quatern_b)+" c = "+t(this.quatern_c)+" d = "+t(this.quatern_d)+` | ||
`,e+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+` | ||
`,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])+` | ||
`,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])+` | ||
`,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])+` | ||
`,e+='Intent Name: "'+this.intent_name+`" | ||
`,this.extensionFlag[0]&&(e+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+` | ||
`),e}getDatatypeCodeString=function(t){return t===b.TYPE_UINT8?"1-Byte Unsigned Integer":t===b.TYPE_INT16?"2-Byte Signed Integer":t===b.TYPE_INT32?"4-Byte Signed Integer":t===b.TYPE_FLOAT32?"4-Byte Float":t===b.TYPE_FLOAT64?"8-Byte Float":t===b.TYPE_RGB24?"RGB":t===b.TYPE_INT8?"1-Byte Signed Integer":t===b.TYPE_UINT16?"2-Byte Unsigned Integer":t===b.TYPE_UINT32?"4-Byte Unsigned Integer":t===b.TYPE_INT64?"8-Byte Signed Integer":t===b.TYPE_UINT64?"8-Byte Unsigned Integer":"Unknown"};getTransformCodeString=function(t){return t===b.XFORM_SCANNER_ANAT?"Scanner":t===b.XFORM_ALIGNED_ANAT?"Aligned":t===b.XFORM_TALAIRACH?"Talairach":t===b.XFORM_MNI_152?"MNI":"Unknown"};getUnitsCodeString=function(t){return t===b.UNITS_METER?"Meters":t===b.UNITS_MM?"Millimeters":t===b.UNITS_MICRON?"Microns":t===b.UNITS_SEC?"Seconds":t===b.UNITS_MSEC?"Milliseconds":t===b.UNITS_USEC?"Microseconds":t===b.UNITS_HZ?"Hz":t===b.UNITS_PPM?"PPM":t===b.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,n,r,a,s,l,o,f,u){var h=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],v,m=t,g=e,p=n,c,y,A;return h[3][0]=h[3][1]=h[3][2]=0,h[3][3]=1,v=1-(m*m+g*g+p*p),v<1e-7?(v=1/Math.sqrt(m*m+g*g+p*p),m*=v,g*=v,p*=v,v=0):v=Math.sqrt(v),c=l>0?l:1,y=o>0?o:1,A=f>0?f:1,u<0&&(A=-A),h[0][0]=(v*v+m*m-g*g-p*p)*c,h[0][1]=2*(m*g-v*p)*y,h[0][2]=2*(m*p+v*g)*A,h[1][0]=2*(m*g+v*p)*c,h[1][1]=(v*v+g*g-m*m-p*p)*y,h[1][2]=2*(g*p-v*m)*A,h[2][0]=2*(m*p-v*g)*c,h[2][1]=2*(g*p+v*m)*y,h[2][2]=(v*v+p*p-g*g-m*m)*A,h[0][3]=r,h[1][3]=a,h[2][3]=s,h}convertNiftiSFormToNEMA(t){var e,n,r,a,s,l,o,f,u,h,v,m,g,p,c,y,A,T,x,R,q,M,d,Y,N,V,z,w,F,G,B,P,k,X;if(c=0,z=[[0,0,0],[0,0,0],[0,0,0]],w=[[0,0,0],[0,0,0],[0,0,0]],e=t[0][0],n=t[0][1],r=t[0][2],a=t[1][0],s=t[1][1],l=t[1][2],o=t[2][0],f=t[2][1],u=t[2][2],h=Math.sqrt(e*e+a*a+o*o),h===0||(e/=h,a/=h,o/=h,h=Math.sqrt(n*n+s*s+f*f),h===0))return null;if(n/=h,s/=h,f/=h,h=e*n+a*s+o*f,Math.abs(h)>1e-4){if(n-=h*e,s-=h*a,f-=h*o,h=Math.sqrt(n*n+s*s+f*f),h===0)return null;n/=h,s/=h,f/=h}if(h=Math.sqrt(r*r+l*l+u*u),h===0?(r=a*f-o*s,l=o*n-f*e,u=e*s-a*n):(r/=h,l/=h,u/=h),h=e*r+a*l+o*u,Math.abs(h)>1e-4){if(r-=h*e,l-=h*a,u-=h*o,h=Math.sqrt(r*r+l*l+u*u),h===0)return null;r/=h,l/=h,u/=h}if(h=n*r+s*l+f*u,Math.abs(h)>1e-4){if(r-=h*n,l-=h*s,u-=h*f,h=Math.sqrt(r*r+l*l+u*u),h===0)return null;r/=h,l/=h,u/=h}if(z[0][0]=e,z[0][1]=n,z[0][2]=r,z[1][0]=a,z[1][1]=s,z[1][2]=l,z[2][0]=o,z[2][1]=f,z[2][2]=u,v=this.nifti_mat33_determ(z),v===0)return null;for(V=-666,x=M=d=Y=1,R=2,q=3,g=1;g<=3;g+=1)for(p=1;p<=3;p+=1)if(g!==p){for(c=1;c<=3;c+=1)if(!(g===c||p===c))for(w[0][0]=w[0][1]=w[0][2]=w[1][0]=w[1][1]=w[1][2]=w[2][0]=w[2][1]=w[2][2]=0,y=-1;y<=1;y+=2)for(A=-1;A<=1;A+=2)for(T=-1;T<=1;T+=2)w[0][g-1]=y,w[1][p-1]=A,w[2][c-1]=T,m=this.nifti_mat33_determ(w),m*v>0&&(N=this.nifti_mat33_mul(w,z),h=N[0][0]+N[1][1]+N[2][2],h>V&&(V=h,x=g,R=p,q=c,M=y,d=A,Y=T))}switch(F=G=B=P=k=X="",x*M){case 1:F="X",P="+";break;case-1:F="X",P="-";break;case 2:F="Y",P="+";break;case-2:F="Y",P="-";break;case 3:F="Z",P="+";break;case-3:F="Z",P="-";break}switch(R*d){case 1:G="X",k="+";break;case-1:G="X",k="-";break;case 2:G="Y",k="+";break;case-2:G="Y",k="-";break;case 3:G="Z",k="+";break;case-3:G="Z",k="-";break}switch(q*Y){case 1:B="X",X="+";break;case-1:B="X",X="-";break;case 2:B="Y",X="+";break;case-2:B="Y",X="-";break;case 3:B="Z",X="+";break;case-3:B="Z",X="-";break}return F+G+B+P+k+X}nifti_mat33_mul=function(t,e){var n=[[0,0,0],[0,0,0],[0,0,0]],r,a;for(r=0;r<3;r+=1)for(a=0;a<3;a+=1)n[r][a]=t[r][0]*e[0][a]+t[r][1]*e[1][a]+t[r][2]*e[2][a];return n};nifti_mat33_determ=function(t){var e,n,r,a,s,l,o,f,u;return e=t[0][0],n=t[0][1],r=t[0][2],a=t[1][0],s=t[1][1],l=t[1][2],o=t[2][0],f=t[2][1],u=t[2][2],e*s*u-e*f*l-a*n*u+a*f*r+o*n*l-o*s*r};getExtensionLocation(){return b.MAGIC_COOKIE+4}getExtensionSize(t){return U.Utils.getIntAt(t,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(t){return U.Utils.getIntAt(t,this.getExtensionLocation()+4,this.littleEndian)}addExtension(t,e=-1){e==-1?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 r=352;if(t)for(let o of this.extensions)r+=o.esize;let a=new Uint8Array(r),s=new DataView(a.buffer);s.setInt32(0,348,this.littleEndian),s.setUint8(39,this.dim_info);for(let o=0;o<8;o++)s.setUint16(40+2*o,this.dims[o],this.littleEndian);s.setFloat32(56,this.intent_p1,this.littleEndian),s.setFloat32(60,this.intent_p2,this.littleEndian),s.setFloat32(64,this.intent_p3,this.littleEndian),s.setInt16(68,this.intent_code,this.littleEndian),s.setInt16(70,this.datatypeCode,this.littleEndian),s.setInt16(72,this.numBitsPerVoxel,this.littleEndian),s.setInt16(74,this.slice_start,this.littleEndian);for(let o=0;o<8;o++)s.setFloat32(76+4*o,this.pixDims[o],this.littleEndian);s.setFloat32(108,this.vox_offset,this.littleEndian),s.setFloat32(112,this.scl_slope,this.littleEndian),s.setFloat32(116,this.scl_inter,this.littleEndian),s.setInt16(120,this.slice_end,this.littleEndian),s.setUint8(122,this.slice_code),s.setUint8(123,this.xyzt_units),s.setFloat32(124,this.cal_max,this.littleEndian),s.setFloat32(128,this.cal_min,this.littleEndian),s.setFloat32(132,this.slice_duration,this.littleEndian),s.setFloat32(136,this.toffset,this.littleEndian),a.set(Buffer.from(this.description),148),a.set(Buffer.from(this.aux_file),228),s.setInt16(252,this.qform_code,this.littleEndian),s.setInt16(254,this.sform_code,this.littleEndian),s.setFloat32(256,this.quatern_b,this.littleEndian),s.setFloat32(260,this.quatern_c,this.littleEndian),s.setFloat32(264,this.quatern_d,this.littleEndian),s.setFloat32(268,this.qoffset_x,this.littleEndian),s.setFloat32(272,this.qoffset_y,this.littleEndian),s.setFloat32(276,this.qoffset_z,this.littleEndian);let l=this.affine.flat();for(let o=0;o<12;o++)s.setFloat32(280+4*o,l[o],this.littleEndian);if(a.set(Buffer.from(this.intent_name),328),a.set(Buffer.from(this.magic),344),t){a.set(Uint8Array.from([1,0,0,0]),348);let o=this.getExtensionLocation();for(let f of this.extensions)s.setInt32(o,f.esize,f.littleEndian),s.setInt32(o+4,f.ecode,f.littleEndian),a.set(new Uint8Array(f.edata),o+8),o+=f.esize}else a.set(new Uint8Array(4).fill(0),348);return a.buffer}},S=b;E(S,"TYPE_NONE",0),E(S,"TYPE_BINARY",1),E(S,"TYPE_UINT8",2),E(S,"TYPE_INT16",4),E(S,"TYPE_INT32",8),E(S,"TYPE_FLOAT32",16),E(S,"TYPE_COMPLEX64",32),E(S,"TYPE_FLOAT64",64),E(S,"TYPE_RGB24",128),E(S,"TYPE_INT8",256),E(S,"TYPE_UINT16",512),E(S,"TYPE_UINT32",768),E(S,"TYPE_INT64",1024),E(S,"TYPE_UINT64",1280),E(S,"TYPE_FLOAT128",1536),E(S,"TYPE_COMPLEX128",1792),E(S,"TYPE_COMPLEX256",2048),E(S,"XFORM_UNKNOWN",0),E(S,"XFORM_SCANNER_ANAT",1),E(S,"XFORM_ALIGNED_ANAT",2),E(S,"XFORM_TALAIRACH",3),E(S,"XFORM_MNI_152",4),E(S,"SPATIAL_UNITS_MASK",7),E(S,"TEMPORAL_UNITS_MASK",56),E(S,"UNITS_UNKNOWN",0),E(S,"UNITS_METER",1),E(S,"UNITS_MM",2),E(S,"UNITS_MICRON",3),E(S,"UNITS_SEC",8),E(S,"UNITS_MSEC",16),E(S,"UNITS_USEC",24),E(S,"UNITS_HZ",32),E(S,"UNITS_PPM",40),E(S,"UNITS_RADS",48),E(S,"MAGIC_COOKIE",348),E(S,"STANDARD_HEADER_SIZE",348),E(S,"MAGIC_NUMBER_LOCATION",344),E(S,"MAGIC_NUMBER",[110,43,49]),E(S,"MAGIC_NUMBER2",[110,105,49]),E(S,"EXTENSION_HEADER_SIZE",8);he.NIFTI1=S});var Be=It(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.NIFTI2=void 0;var tt=ue(),C=jt(),Pt=class{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;readHeader(t){var e=new DataView(t),n=C.Utils.getIntAt(e,0,this.littleEndian),r,a,s,l,o;if(n!==Pt.MAGIC_COOKIE&&(this.littleEndian=!0,n=C.Utils.getIntAt(e,0,this.littleEndian)),n!==Pt.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.magic=C.Utils.getStringAt(e,4,12),this.datatypeCode=C.Utils.getShortAt(e,12,this.littleEndian),this.numBitsPerVoxel=C.Utils.getShortAt(e,14,this.littleEndian),r=0;r<8;r+=1)l=16+r*8,this.dims[r]=C.Utils.getLongAt(e,l,this.littleEndian);for(this.intent_p1=C.Utils.getDoubleAt(e,80,this.littleEndian),this.intent_p2=C.Utils.getDoubleAt(e,88,this.littleEndian),this.intent_p3=C.Utils.getDoubleAt(e,96,this.littleEndian),r=0;r<8;r+=1)l=104+r*8,this.pixDims[r]=C.Utils.getDoubleAt(e,l,this.littleEndian);for(this.vox_offset=C.Utils.getLongAt(e,168,this.littleEndian),this.scl_slope=C.Utils.getDoubleAt(e,176,this.littleEndian),this.scl_inter=C.Utils.getDoubleAt(e,184,this.littleEndian),this.cal_max=C.Utils.getDoubleAt(e,192,this.littleEndian),this.cal_min=C.Utils.getDoubleAt(e,200,this.littleEndian),this.slice_duration=C.Utils.getDoubleAt(e,208,this.littleEndian),this.toffset=C.Utils.getDoubleAt(e,216,this.littleEndian),this.slice_start=C.Utils.getLongAt(e,224,this.littleEndian),this.slice_end=C.Utils.getLongAt(e,232,this.littleEndian),this.description=C.Utils.getStringAt(e,240,240+80),this.aux_file=C.Utils.getStringAt(e,320,320+24),this.qform_code=C.Utils.getIntAt(e,344,this.littleEndian),this.sform_code=C.Utils.getIntAt(e,348,this.littleEndian),this.quatern_b=C.Utils.getDoubleAt(e,352,this.littleEndian),this.quatern_c=C.Utils.getDoubleAt(e,360,this.littleEndian),this.quatern_d=C.Utils.getDoubleAt(e,368,this.littleEndian),this.qoffset_x=C.Utils.getDoubleAt(e,376,this.littleEndian),this.qoffset_y=C.Utils.getDoubleAt(e,384,this.littleEndian),this.qoffset_z=C.Utils.getDoubleAt(e,392,this.littleEndian),a=0;a<3;a+=1)for(s=0;s<4;s+=1)l=400+(a*4+s)*8,this.affine[a][s]=C.Utils.getDoubleAt(e,l,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=C.Utils.getIntAt(e,496,this.littleEndian),this.xyzt_units=C.Utils.getIntAt(e,500,this.littleEndian),this.intent_code=C.Utils.getIntAt(e,504,this.littleEndian),this.intent_name=C.Utils.getStringAt(e,508,508+16),this.dim_info=C.Utils.getByteAt(e,524),e.byteLength>Pt.MAGIC_COOKIE&&(this.extensionFlag[0]=C.Utils.getByteAt(e,540),this.extensionFlag[1]=C.Utils.getByteAt(e,540+1),this.extensionFlag[2]=C.Utils.getByteAt(e,540+2),this.extensionFlag[3]=C.Utils.getByteAt(e,540+3),this.extensionFlag[0]&&(this.extensions=C.Utils.getExtensionsAt(e,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var t=C.Utils.formatNumber,e="";return e+="Datatype = "+ +this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`) | ||
`,e+="Bits Per Voxel = = "+this.numBitsPerVoxel+` | ||
`,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]+` | ||
`,e+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+` | ||
`,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])+` | ||
`,e+="Image Offset = "+this.vox_offset+` | ||
`,e+="Data Scale: Slope = "+t(this.scl_slope)+" Intercept = "+t(this.scl_inter)+` | ||
`,e+="Display Range: Max = "+t(this.cal_max)+" Min = "+t(this.cal_min)+` | ||
`,e+="Slice Duration = "+this.slice_duration+` | ||
`,e+="Time Axis Shift = "+this.toffset+` | ||
`,e+="Slice Start = "+this.slice_start+` | ||
`,e+="Slice End = "+this.slice_end+` | ||
`,e+='Description: "'+this.description+`" | ||
`,e+='Auxiliary File: "'+this.aux_file+`" | ||
`,e+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`) | ||
`,e+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`) | ||
`,e+="Quaternion Parameters: b = "+t(this.quatern_b)+" c = "+t(this.quatern_c)+" d = "+t(this.quatern_d)+` | ||
`,e+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+` | ||
`,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])+` | ||
`,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])+` | ||
`,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])+` | ||
`,e+="Slice Code = "+this.slice_code+` | ||
`,e+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(tt.NIFTI1.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(tt.NIFTI1.TEMPORAL_UNITS_MASK&this.xyzt_units)+`) | ||
`,e+="Intent Code = "+this.intent_code+` | ||
`,e+='Intent Name: "'+this.intent_name+`" | ||
`,e+="Dim Info = "+this.dim_info+` | ||
`,e}getExtensionLocation=function(){return Pt.MAGIC_COOKIE+4};getExtensionSize=tt.NIFTI1.prototype.getExtensionSize;getExtensionCode=tt.NIFTI1.prototype.getExtensionCode;addExtension=tt.NIFTI1.prototype.addExtension;removeExtension=tt.NIFTI1.prototype.removeExtension;getDatatypeCodeString=tt.NIFTI1.prototype.getDatatypeCodeString;getTransformCodeString=tt.NIFTI1.prototype.getTransformCodeString;getUnitsCodeString=tt.NIFTI1.prototype.getUnitsCodeString;getQformMat=tt.NIFTI1.prototype.getQformMat;convertNiftiQFormToNiftiSForm=tt.NIFTI1.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=tt.NIFTI1.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=tt.NIFTI1.prototype.nifti_mat33_mul;nifti_mat33_determ=tt.NIFTI1.prototype.nifti_mat33_determ;toArrayBuffer(t=!1){let r=544;if(t)for(let o of this.extensions)r+=o.esize;let a=new Uint8Array(r),s=new DataView(a.buffer);s.setInt32(0,540,this.littleEndian),a.set(Buffer.from(this.magic),4),s.setInt16(12,this.datatypeCode,this.littleEndian),s.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let o=0;o<8;o++)s.setBigInt64(16+8*o,BigInt(this.dims[o]),this.littleEndian);s.setFloat64(80,this.intent_p1,this.littleEndian),s.setFloat64(88,this.intent_p2,this.littleEndian),s.setFloat64(96,this.intent_p3,this.littleEndian);for(let o=0;o<8;o++)s.setFloat64(104+8*o,this.pixDims[o],this.littleEndian);s.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),s.setFloat64(176,this.scl_slope,this.littleEndian),s.setFloat64(184,this.scl_inter,this.littleEndian),s.setFloat64(192,this.cal_max,this.littleEndian),s.setFloat64(200,this.cal_min,this.littleEndian),s.setFloat64(208,this.slice_duration,this.littleEndian),s.setFloat64(216,this.toffset,this.littleEndian),s.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),s.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),a.set(Buffer.from(this.description),240),a.set(Buffer.from(this.aux_file),320),s.setInt32(344,this.qform_code,this.littleEndian),s.setInt32(348,this.sform_code,this.littleEndian),s.setFloat64(352,this.quatern_b,this.littleEndian),s.setFloat64(360,this.quatern_c,this.littleEndian),s.setFloat64(368,this.quatern_d,this.littleEndian),s.setFloat64(376,this.qoffset_x,this.littleEndian),s.setFloat64(384,this.qoffset_y,this.littleEndian),s.setFloat64(392,this.qoffset_z,this.littleEndian);let l=this.affine.flat();for(let o=0;o<12;o++)s.setFloat64(400+8*o,l[o],this.littleEndian);if(s.setInt32(496,this.slice_code,this.littleEndian),s.setInt32(500,this.xyzt_units,this.littleEndian),s.setInt32(504,this.intent_code,this.littleEndian),a.set(Buffer.from(this.intent_name),508),s.setUint8(524,this.dim_info),t){a.set(Uint8Array.from([1,0,0,0]),540);let o=this.getExtensionLocation();for(let f of this.extensions)s.setInt32(o,f.esize,f.littleEndian),s.setInt32(o+4,f.ecode,f.littleEndian),a.set(new Uint8Array(f.edata),o+8),o+=f.esize}else a.set(new Uint8Array(4).fill(0),540);return a.buffer}},At=Pt;E(At,"MAGIC_COOKIE",540),E(At,"MAGIC_NUMBER_LOCATION",4),E(At,"MAGIC_NUMBER",[110,43,50,0,13,10,26,10]),E(At,"MAGIC_NUMBER2",[110,105,50,0,13,10,26,10]);ce.NIFTI2=At});var dn=It(O=>{var en=O&&O.__createBinding||(Object.create?function(i,t,e,n){n===void 0&&(n=e);var r=Object.getOwnPropertyDescriptor(t,e);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,r)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]}),nn=O&&O.__setModuleDefault||(Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t}),rn=O&&O.__importStar||function(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e in i)e!=="default"&&Object.prototype.hasOwnProperty.call(i,e)&&en(t,i,e);return nn(t,i),t};Object.defineProperty(O,"__esModule",{value:!0});O.readExtensionData=O.readExtension=O.readImage=O.hasExtension=O.readHeader=O.decompress=O.isCompressed=O.isNIFTI=O.isNIFTI2=O.isNIFTI1=O.NIFTIEXTENSION=O.Utils=O.NIFTI2=O.NIFTI1=void 0;var sn=rn(wi()),at=ue(),ct=Be(),Ci=jt(),an=ue();Object.defineProperty(O,"NIFTI1",{enumerable:!0,get:function(){return an.NIFTI1}});var on=Be();Object.defineProperty(O,"NIFTI2",{enumerable:!0,get:function(){return on.NIFTI2}});var ln=jt();Object.defineProperty(O,"Utils",{enumerable:!0,get:function(){return ln.Utils}});var fn=qe();Object.defineProperty(O,"NIFTIEXTENSION",{enumerable:!0,get:function(){return fn.NIFTIEXTENSION}});function Pe(i,t=!1){var e,n,r,a;return i.byteLength<at.NIFTI1.STANDARD_HEADER_SIZE?!1:(e=new DataView(i),e&&(n=e.getUint8(at.NIFTI1.MAGIC_NUMBER_LOCATION)),r=e.getUint8(at.NIFTI1.MAGIC_NUMBER_LOCATION+1),a=e.getUint8(at.NIFTI1.MAGIC_NUMBER_LOCATION+2),t&&n===at.NIFTI1.MAGIC_NUMBER2[0]&&r===at.NIFTI1.MAGIC_NUMBER2[1]&&a===at.NIFTI1.MAGIC_NUMBER2[2]?!0:n===at.NIFTI1.MAGIC_NUMBER[0]&&r===at.NIFTI1.MAGIC_NUMBER[1]&&a===at.NIFTI1.MAGIC_NUMBER[2])}O.isNIFTI1=Pe;function be(i,t=!1){var e,n,r,a;return i.byteLength<at.NIFTI1.STANDARD_HEADER_SIZE?!1:(e=new DataView(i),n=e.getUint8(ct.NIFTI2.MAGIC_NUMBER_LOCATION),r=e.getUint8(ct.NIFTI2.MAGIC_NUMBER_LOCATION+1),a=e.getUint8(ct.NIFTI2.MAGIC_NUMBER_LOCATION+2),t&&n===ct.NIFTI2.MAGIC_NUMBER2[0]&&r===ct.NIFTI2.MAGIC_NUMBER2[1]&&a===ct.NIFTI2.MAGIC_NUMBER2[2]?!0:n===ct.NIFTI2.MAGIC_NUMBER[0]&&r===ct.NIFTI2.MAGIC_NUMBER[1]&&a===ct.NIFTI2.MAGIC_NUMBER[2])}O.isNIFTI2=be;function hn(i,t=!1){return Pe(i,t)||be(i,t)}O.isNIFTI=hn;function Ni(i){var t,e,n;return!!(i&&(t=new DataView(i),e=t.getUint8(0),n=t.getUint8(1),e===Ci.Utils.GUNZIP_MAGIC_COOKIE1||n===Ci.Utils.GUNZIP_MAGIC_COOKIE2))}O.isCompressed=Ni;function Fi(i){return sn.decompressSync(new Uint8Array(i)).buffer}O.decompress=Fi;function un(i,t=!1){var e=null;return Ni(i)&&(i=Fi(i)),Pe(i,t)?e=new at.NIFTI1:be(i,t)&&(e=new ct.NIFTI2),e?e.readHeader(i):console.error("That file does not appear to be NIFTI!"),e}O.readHeader=un;function cn(i){return i.extensionFlag[0]!=0}O.hasExtension=cn;function vn(i,t){var e=i.vox_offset,n=1,r=1;i.dims[4]&&(n=i.dims[4]),i.dims[5]&&(r=i.dims[5]);var a=i.dims[1]*i.dims[2]*i.dims[3]*n*r*(i.numBitsPerVoxel/8);return t.slice(e,e+a)}O.readImage=vn;function gn(i,t){var e=i.getExtensionLocation(),n=i.extensionSize;return t.slice(e,e+n)}O.readExtension=gn;function pn(i,t){var e=i.getExtensionLocation(),n=i.extensionSize;return t.slice(e+8,e+n)}O.readExtensionData=pn});dn();})(); |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/5D_small.nii'); | ||
var buf = fs.readFileSync('./data/5D_small.nii'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ var nifti1 = null; |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/5D_zeros.nii.gz'); | ||
var buf = fs.readFileSync('./data/5D_zeros.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ var nifti1 = null; |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/big.nii.gz'); | ||
var buf = fs.readFileSync('./data/big.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ var nifti1 = null; |
@@ -10,6 +10,6 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
// var buf = fs.readFileSync('./tests/data/afni.nii.gz'); | ||
var buf = fs.readFileSync('./tests/data/with_extension.nii.gz'); | ||
var buf = fs.readFileSync('./data/with_extension.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -16,0 +16,0 @@ var nifti1 = null; |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/avg152T1_LR_nifti.nii.gz'); | ||
var buf = fs.readFileSync('./data/avg152T1_LR_nifti.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ var nifti1 = null; |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/little.nii.gz'); | ||
var buf = fs.readFileSync('./data/little.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ var nifti1 = null; |
@@ -19,7 +19,7 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/air.hdr.gz'); | ||
var buf = fs.readFileSync('./data/air.hdr.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
var ibuf = fs.readFileSync('./tests/data/air.img.gz'); | ||
var ibuf = fs.readFileSync('./data/air.img.gz'); | ||
var idata = nifti.Utils.toArrayBuffer(ibuf); | ||
@@ -88,3 +88,5 @@ | ||
clone = nifti.readHeader(bytes, true); | ||
assert.deepEqual(clone, nifti1); | ||
var nifti1Text = JSON.stringify(nifti1); | ||
var cloneText = JSON.stringify(clone); | ||
assert.equal(cloneText, nifti1Text); | ||
}); | ||
@@ -91,0 +93,0 @@ |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/avg152T1_LR_nifti.nii'); | ||
var buf = fs.readFileSync('./data/avg152T1_LR_nifti.nii'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -63,5 +63,7 @@ var nifti1 = null; | ||
clone = nifti.readHeader(bytes); | ||
assert.deepEqual(clone, nifti1); | ||
var nifti1Text = JSON.stringify(nifti1); | ||
var cloneText = JSON.stringify(clone); | ||
assert.equal(cloneText, nifti1Text); | ||
}); | ||
}); | ||
}); |
@@ -9,5 +9,5 @@ /*jslint browser: true, node: true */ | ||
var nifti = require("../src/nifti.js"); | ||
var nifti = require("../dist/src/nifti.js"); | ||
var buf = fs.readFileSync("./tests/data/avg152T1_LR_nifti2.nii.gz"); | ||
var buf = fs.readFileSync("./data/avg152T1_LR_nifti2.nii.gz"); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -14,0 +14,0 @@ var nifti2 = null; |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/avg152T1_LR_nifti2.nii.gz'); | ||
var buf = fs.readFileSync('./data/avg152T1_LR_nifti2.nii.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -68,3 +68,5 @@ var nifti2 = null; | ||
clone = nifti.readHeader(bytes); | ||
assert.deepEqual(clone, nifti2); | ||
var nifti2Text = JSON.stringify(nifti2); | ||
var cloneText = JSON.stringify(clone); | ||
assert.equal(cloneText, nifti2Text); | ||
}); | ||
@@ -71,0 +73,0 @@ |
@@ -19,7 +19,7 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/air2.hdr.gz'); | ||
var buf = fs.readFileSync('./data/air2.hdr.gz'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
var ibuf = fs.readFileSync('./tests/data/air2.img.gz'); | ||
var ibuf = fs.readFileSync('./data/air2.img.gz'); | ||
var idata = nifti.Utils.toArrayBuffer(ibuf); | ||
@@ -88,3 +88,5 @@ | ||
clone = nifti.readHeader(bytes, true); | ||
assert.deepEqual(clone, nifti2); | ||
var nifti2Text = JSON.stringify(nifti2); | ||
var cloneText = JSON.stringify(clone); | ||
assert.equal(cloneText, nifti2Text); | ||
}); | ||
@@ -91,0 +93,0 @@ |
@@ -10,5 +10,5 @@ | ||
var nifti = require('../src/nifti.js'); | ||
var nifti = require('../dist/src/nifti.js'); | ||
var buf = fs.readFileSync('./tests/data/not-nifti.nii'); | ||
var buf = fs.readFileSync('./data/not-nifti.nii'); | ||
var data = nifti.Utils.toArrayBuffer(buf); | ||
@@ -15,0 +15,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3560225
121
10975
1
9
24
2