"use strict";var R=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var se=(r,o)=>{for(var e in o)R(r,e,{get:o[e],enumerable:!0})},de=(r,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of oe(o))!le.call(r,t)&&t!==e&&R(r,t,{get:()=>o[t],enumerable:!(i=ne(o,t))||i.enumerable});return r};var pe=r=>de(R({},"__esModule",{value:!0}),r);var ue={};se(ue,{parseJEOL:()=>me});module.exports=pe(ue);var ie=require("iobuffer");var J={0:"bigEndian",1:"littleEndian"},K={0:"NONE",1:"GSX",2:"ALPHA",3:"ECLIPSE",4:"MASS_SPEC",5:"COMPILER",6:"OTHER_NMR",7:"UNKNOWN",8:"GEMINI",9:"UNITY",10:"ASPECT",11:"UX",12:"FELIX",13:"LAMBDA",14:"GE_1280",15:"GE_OMEGA",16:"CHEMAGNETICS",17:"CDFF",18:"GALACTIC",19:"TRIAD",20:"GENERIC_NMR",21:"GAMMA",22:"JCAMP_DX",23:"AMX",24:"DMX",25:"ECA",26:"ALICE",27:"NMR_PIPE",28:"SIMPSON"},W={0:"64Bit Float",1:"32Bit Float",2:"Reserved",3:"Reserved"},Z={1:"One_D",2:"Two_D",3:"Three_D",4:"Four_D",5:"Five_D",6:"Six_D",7:"Seven_D",8:"Eight_D",9:"not for NMR data formats",10:"not for NMR data formats",11:"not for NMR data formats",12:"Small_Two_D",13:"Small_Three_D",14:"Small_Four_D"},V={0:"None",1:"Real",2:"TPPI",3:"Complex",4:"Real_Complex",5:"Envelope"},Y={"-8":"Yotta","-6":"Exa","-7":"Zetta","-5":"Pecta","-4":"Tera","-3":"Giga","-2":"Mega","-1":"Kilo",0:"None",1:"Milli",2:"Micro",3:"Nano",4:"Pico",5:"Femto",6:"Atto",7:"Zepto"},Q={Yotta:24,Exa:21,Zetta:18,Pecta:15,Tera:12,Giga:9,Mega:6,Kilo:3,None:0,Milli:-3,Micro:-6,Nano:-9,Pico:-12,Femto:-15,Atto:-18,Zepto:-21},$={0:"None",1:"Abundance",2:"Ampere",3:"Candela",4:"Celsius",5:"Coulomb",6:"Degree",7:"Electronvolt",8:"Farad",9:"Sievert",10:"Gram",11:"Gray",12:"Henry",13:"Hertz",14:"Kelvin",15:"Joule",16:"Liter",17:"Lumen",18:"Lux",19:"Meter",20:"Mole",21:"Newton",22:"Ohm",23:"Pascal",24:"Percent",25:"Point",26:"Ppm",27:"Radian",28:"Second",29:"Siemens",30:"Steradian",31:"Tesla",32:"Volt",33:"Watt",34:"Weber",35:"Decibel",36:"Dalton",37:"Thompson",38:"Ugeneric",39:"LPercent ",40:"PPT",41:"PPB ",42:"Index"},G={0:"Ranged",1:"Listed",2:"Sparse",3:"Listed"},ee={0:"String",1:"Integer",2:"Float",3:"Complex",4:"Infinity"};function f(r,o){return r.paramArray.find(e=>e.name===o)||""}function ae(r,o){let e=r.paramArray.find(l=>l.name==="orders"),i=r.paramArray.find(l=>l.name==="factors"),t=r.paramArray.find(l=>l.name==="x_sweep"),d=r.paramArray.find(l=>l.name==="x_acq_time"),T=r.paramArray.find(l=>l.name==="x_points");if([e,i,t,d,T].some(l=>l===void 0)){o?.error("There is not all parameters to calculate the number of point of digital filter");return}let h=parseInt(e.value.slice(0,1),10),D=e.value.slice(1).length/h,U=0,n=new Int8Array(h),I=1,p=0;for(let l=0;l>4],T=t&15,F=$[r.readInt8()];e.push({prefix:d,power:T,base:F})}return e}function A(r,o){let e=[];for(let i=0;i!!Number(a)),i=e.readByte(),t.dataType=W[i>>6],t.dataFormat=Z[i&63],t.dataInstrument=K[e.readInt8()],t.translate=s(e,8,"readUint8"),t.dataAxisType=s(e,8,"readUint8").map(a=>V[a]),t.dataUnits=q(e,8),t.title=A(e,124);for(i in s(e,4,"readUint8"))d.push(G[i>>4]),d.push(G[i&15]);t.dataAxisRanged=d,t.dataPoints=s(e,8,"readUint32"),t.dataOffsetStart=s(e,8,"readUint32"),t.dataOffsetStop=s(e,8,"readUint32"),t.dataAxisStart=s(e,8,"readFloat64"),t.dataAxisStop=s(e,8,"readFloat64"),d=new Uint8Array(4);for(let a=0;a<4;a++)d[a]=e.readByte();let T=1990+(d[0]>>1),F=(d[0]<<3&8)+(d[1]>>5),h=d[2]&31;t.creationTime={year:T,month:F,day:h};for(let a=0;a<4;a++)d[a]=e.readByte();T=1990+(d[0]>>1),F=(d[0]<<3&8)+(d[1]>>5),h=d[2]&31,t.revisionTime={year:T,month:F,day:h},t.nodeName=A(e,16),t.site=A(e,128),t.author=A(e,128),t.comment=A(e,128);let D=[];for(let a=0;a<8;a++)D.push(A(e,32));t.dataAxisTitles=D,t.baseFreq=s(e,8,"readFloat64"),t.zeroPoint=s(e,8,"readFloat64"),t.reversed=s(e,8,"readBoolean"),e.skip(3),t.annotationOK=!!(e.readByte()>>7),t.historyUsed=e.readUint32(),t.historyLength=e.readUint32(),t.paramStart=e.readUint32(),t.paramLength=e.readUint32(),t.ListStart=s(e,8,"readUint32"),t.ListLength=s(e,8,"readUint32"),t.dataStart=e.readUint32(),t.dataLength=e.readUint32()<<32|e.readUint32(),t.contextStart=e.readUint32()<<32|e.readUint32(),t.contextLength=e.readUint32(),t.annoteStart=e.readUint32()<<32|e.readUint32(),t.annoteLength=e.readUint32(),t.totalSize=e.readUint32()<<32|e.readUint32(),t.unitLocation=s(e,8,"readUint8");let U=[];for(let a=0;a<2;a++){let u=[],E=e.readInt16();for(let S=0;S<5;S++)i=e.readInt16(),u.push(i);U.push({scaler:E,unit:u})}t.compoundUnit=U,t.endian==="littleEndian"&&e.setLittleEndian(),e.seek(t.paramStart);let n={parameterSize:e.readUint32(),lowIndex:e.readUint32(),highIndex:e.readUint32(),totalSize:e.readUint32()},I=[];for(let a=0;aa.name))},headers:t,parameters:n,data:p};return H.info.digitalFilter=ae(n,o),H}