{"version":3,"file":"chromatography.js","sources":["../node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/ml-spectra-processing/src/x/xFindClosestIndex.js","../node_modules/ml-spectra-processing/src/x/xGetFromToIndex.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/ml-spectra-processing/src/x/xIsMonotone.js","../node_modules/d3-array/build/d3-array.js","../node_modules/spline-interpolator/index.js","../node_modules/ml-array-sum/lib-es6/index.js","../node_modules/ml-array-mean/lib-es6/index.js","../node_modules/ml-array-variance/lib-es6/index.js","../node_modules/ml-array-standard-deviation/lib-es6/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/fft.js/lib/fft.js","../node_modules/ml-spectra-processing/src/xy/xyCheck.js","../node_modules/ml-spectra-processing/src/xyArray/xyArrayWeightedMerge.js","../node_modules/ml-spectra-processing/src/xy/xyIntegration.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/util/constants.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/util/erfinv.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/shapes/1d/Shape1D.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/shapes/1d/gaussian/Gaussian.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/shapes/1d/lorentzian/Lorentzian.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/shapes/1d/pseudoVoigt/PseudoVoigt.js","../node_modules/ml-gsd/node_modules/ml-peak-shape-generator/lib-esm/util/getShape1D.js","../node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-peak-shape-generator/src/util/constants.js","../node_modules/ml-peak-shape-generator/src/util/erfinv.js","../node_modules/ml-peak-shape-generator/src/classes/Gaussian.js","../node_modules/ml-peak-shape-generator/src/classes/Lorentzian.js","../node_modules/ml-peak-shape-generator/src/classes/PseudoVoigt.js","../node_modules/ml-peak-shape-generator/src/classes/Gaussian2D.js","../node_modules/ml-peak-shape-generator/src/util/getShapeGenerator.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/views/base.js","../node_modules/ml-matrix/src/views/transpose.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-matrix/src/dc/evd.js","../node_modules/ml-matrix/src/dc/nipals.js","../node_modules/ml-gsd/src/post/broadenPeaks.js","../node_modules/ml-spectra-processing/src/xy/xySortX.js","../node_modules/ml-spectra-processing/src/xyObject/xyObjectSlotX.js","../src/Series.js","../src/Series1D.js","../src/Series2D.js","../src/seriesFromArray.js","../src/filter/meanFilter.js","../src/filter/percentageFilter.js","../node_modules/mf-parser/src/Kind.js","../node_modules/mf-parser/src/util/parseCharge.js","../node_modules/mf-parser/src/parse.js","../node_modules/mf-parser/src/Format.js","../node_modules/mf-parser/src/util/formatCharge.js","../node_modules/mf-parser/src/util/toDisplay.js","../node_modules/mf-parser/src/Style.js","../node_modules/mf-parser/src/util/toHtml.js","../node_modules/chemical-elements/src/elementsAndStableIsotopes.js","../node_modules/chemical-elements/src/elementsAndStableIsotopesObject.js","../node_modules/mf-parser/src/ensureCase.js","../node_modules/chemical-elements/src/constants.js","../node_modules/chemical-elements/src/elements.js","../node_modules/chemical-elements/src/elementsAndIsotopes.js","../node_modules/chemical-elements/src/elementsAndIsotopesObject.js","../node_modules/chemical-elements/src/elementsObject.js","../node_modules/chemical-elements/src/index.js","../node_modules/chemical-groups/src/groups.js","../node_modules/chemical-groups/src/groupsObject.js","../node_modules/mf-parser/src/util/getIsotopeRatioInfo.js","../node_modules/mf-parser/src/util/getIsotopesObject.js","../node_modules/mf-parser/src/util/getEA.js","../node_modules/mf-parser/src/util/getElements.js","../node_modules/chemical-elements/src/unsaturationsObject.js","../node_modules/mf-parser/src/util/partToAtoms.js","../node_modules/mf-parser/src/util/partToMF.js","../node_modules/mf-parser/src/util/getInfo.js","../node_modules/mf-parser/src/util/getIsotopesInfo.js","../node_modules/mf-parser/src/util/partsToDisplay.js","../node_modules/mf-parser/src/util/partsToMF.js","../node_modules/atom-sorter/src/index.js","../node_modules/mf-parser/src/util/toParts.js","../node_modules/mf-parser/src/MF.js","../node_modules/mf-parser/src/index.js","../src/ms/applyLockMass.js","../src/ms/calculateBpc.js","../src/ms/calculateEic.js","../node_modules/isotopic-distribution/node_modules/spectrum-generator/src/util/addBaseline.js","../node_modules/d3-random/src/defaultSource.js","../node_modules/d3-random/src/uniform.js","../node_modules/d3-random/src/normal.js","../node_modules/ml-xsadd/lib-es6/xsadd.js","../node_modules/isotopic-distribution/node_modules/spectrum-generator/src/util/addNoise.js","../node_modules/isotopic-distribution/node_modules/spectrum-generator/src/index.js","../node_modules/mf-utilities/src/getMsem.js","../node_modules/mf-utilities/src/getMsInfo.js","../node_modules/mf-utilities/src/processRange.js","../node_modules/mf-utilities/src/preprocessIonizations.js","../node_modules/isotopic-distribution/src/utils/sortX.js","../node_modules/isotopic-distribution/src/utils/sortY.js","../node_modules/isotopic-distribution/src/utils/join.js","../node_modules/isotopic-distribution/src/utils/topY.js","../node_modules/isotopic-distribution/src/utils/maxToOne.js","../node_modules/isotopic-distribution/src/utils/multiply.js","../node_modules/isotopic-distribution/src/utils/square.js","../node_modules/isotopic-distribution/src/utils/power.js","../node_modules/isotopic-distribution/src/utils/normalize.js","../node_modules/isotopic-distribution/src/utils/closestPointX.js","../node_modules/isotopic-distribution/src/Distribution.js","../node_modules/isotopic-distribution/src/IsotopicDistribution.js","../node_modules/isotopic-distribution/src/index.js","../node_modules/mf-matcher/src/unsaturationMatcher.js","../node_modules/mf-matcher/src/generalMatcher.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xAbsolute.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xAbsoluteMedian.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xAdd.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMultiply.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xDotProduct.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xCrossCorrelation.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xAutoCorrelation.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xBoxPlot.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xCorrelation.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xCumulative.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xDivide.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xFindClosestIndex.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xGetFromToIndex.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xGetTargetIndex.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xCheck.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMaxValue.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMinValue.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xHistogram.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xIsMonotone.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMaxIndex.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMean.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMinIndex.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMinMaxValues.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/erfcinv.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/rayleighCdf.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xNoiseSanPlot.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xNorm.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xParetoNormalization.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xPadding.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRotate.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRolling.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRollingAverage.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRollingMedian.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRollingMin.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xRollingMax.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xSubtract.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xSum.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMeanAbsoluteError.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/x/xMeanSquaredError.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/reim/reimAbsolute.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/reim/reimPhaseCorrection.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/reim/reimAutoPhaseCorrection.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/reim/reimFFT.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xreim/xreimZeroFilling.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xreim/xreimSortX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyCheck.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyJoinX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/utils/getSlots.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/xyArrayAlign.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/xyArrayMerge.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/xyArrayWeightedMerge.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/utils/getSlotsToFirst.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyArray/xyArrayAlignToFirst.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyAlign.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMaxYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyCumulativeDistributionStatistics.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyEnsureGrowingX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/zones/zonesNormalize.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyExtract.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyFilterXPositive.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyGetNMaxY.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyGrowingX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyIntegral.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyIntegration.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMaxClosestYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMaxY.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMaximaY.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMedian.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMinClosestYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMinYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyMinimaY.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyPeakInfo.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyRealMaxYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyRealMinYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyReduce.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyRolling.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyToXYObject.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyToXYArray.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyCalibrate.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xySortX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xy/xyUniqueX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectCheck.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectMaxXPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectMinXPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectBestPoints.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectJoinX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectMaxYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectMinYPoint.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectSlotX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectSortX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/xyObject/xyObjectToXY.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/zone/zoneToX.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixCenterZMean.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixMinMaxAbsoluteZ.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixMinMaxZ.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixHistogram.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixPQN.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/matrix/matrixZRescale.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/utils/createSequentialArray.js","../node_modules/mf-matcher/node_modules/ml-spectra-processing/src/index.js","../node_modules/mf-matcher/src/msemMatcher.js","../node_modules/mf-matcher/src/index.js","../node_modules/sum-object-keys/lib/index.js","../node_modules/mf-generator/src/index.js","../src/ms/calculateForMF.js","../src/ms/calculateLength.js","../src/ms/calculateTic.js","../node_modules/ml-ngmca/src/util/zeroInsteadOfNegative.js","../node_modules/ml-ngmca/src/stages/checkMatrixS.js","../node_modules/ml-ngmca/src/util/normBy.js","../node_modules/ml-ngmca/src/util/normProj.js","../node_modules/ml-ngmca/src/stages/updateMatrixA.js","../node_modules/ml-ngmca/src/util/getMax.js","../node_modules/ml-ngmca/src/stages/updateMatrixS.js","../node_modules/ml-ngmca/src/stages/initialize.js","../node_modules/ml-ngmca/src/stages/normalize.js","../node_modules/ml-ngmca/src/util/getMedians.js","../node_modules/ml-ngmca/src/util/dimMADstd.js","../node_modules/ml-ngmca/src/stages/updateLambda.js","../node_modules/ml-ngmca/src/nGMCA.js","../node_modules/ml-pca/src/pca.js","../src/util/estimateNbPureComponents.js","../src/ms/deconvolution.js","../src/ms/merge.js","../src/peaks/getPeaks.js","../src/util/filter.js","../src/util/getClosestData.js","../src/util/getMzVsTimesMatrix.js","../src/util/baselineCorrection.js","../src/util/integrate.js","../src/Chromatogram.js","../src/peaks/appendMass.js","../src/massFilter.js","../src/vectorify.js","../src/ms/cosineSimilarity.js","../src/spectraComparison.js","../node_modules/ml-regression-base/src/maybeToPrecision.js","../node_modules/ml-regression-base/src/checkArrayLength.js","../node_modules/ml-regression-base/src/index.js","../node_modules/ml-regression-polynomial/src/index.js","../src/scaleAlignment.js","../src/kovats.js","../src/peaks/appendKovats.js","../node_modules/binary-search/index.js","../src/getKovatsConversionFunction.js","../node_modules/ensure-string/lib-esm/index.js","../node_modules/dynamic-typing/src/parseString.js","../node_modules/jcampconverter/src/complexChromatogram.js","../node_modules/jcampconverter/src/convertToFloatArray.js","../node_modules/jcampconverter/src/parse/fastParseXYData.js","../node_modules/jcampconverter/src/parse/parsePeakTable.js","../node_modules/jcampconverter/src/parse/parseXYA.js","../node_modules/jcampconverter/src/2d/convertTo3DZ.js","../node_modules/jcampconverter/src/2d/generateContourLines.js","../node_modules/jcampconverter/src/2d/add2D.js","../node_modules/nmr-processing/src/constants/gyromagneticRatio.js","../node_modules/jcampconverter/src/postProcessingNMR.js","../node_modules/jcampconverter/src/profiling.js","../node_modules/jcampconverter/src/simpleChromatogram.js","../node_modules/jcampconverter/src/postProcessing.js","../node_modules/jcampconverter/src/prepareNtuplesDatatable.js","../node_modules/jcampconverter/src/prepareSpectrum.js","../node_modules/jcampconverter/src/convert.js","../src/from/jcamp.js","../node_modules/xy-parser/node_modules/ensure-string/src/index.js","../node_modules/ml-arrayxy-uniquex/src/index.js","../node_modules/xy-parser/src/index.js","../src/from/text.js","../node_modules/utf8/utf8.js","../node_modules/iobuffer/lib-esm/IOBuffer.js","../node_modules/netcdfjs/src/utils.js","../node_modules/netcdfjs/src/types.js","../node_modules/netcdfjs/src/data.js","../node_modules/netcdfjs/src/header.js","../node_modules/netcdfjs/src/toString.js","../node_modules/netcdfjs/src/index.js","../node_modules/netcdf-gcms/src/agilentGCMS.js","../node_modules/netcdf-gcms/src/brukerGCMS.js","../node_modules/netcdf-gcms/src/agilentHPLC.js","../node_modules/netcdf-gcms/src/finniganGCMS.js","../node_modules/netcdf-gcms/src/shimadzuGCMS.js","../node_modules/netcdf-gcms/src/advionGCMS.js","../node_modules/netcdf-gcms/src/aiaTemplate.js","../node_modules/netcdf-gcms/src/index.js","../src/from/netcdf.js","../node_modules/arraybuffer-xml-parser/src/traversable/defaultOptions.js","../node_modules/arraybuffer-xml-parser/src/XMLNode.js","../node_modules/arraybuffer-xml-parser/src/bufferUtils/arrayIndexOf.js","../node_modules/arraybuffer-xml-parser/src/bufferUtils/arrayTrim.js","../node_modules/arraybuffer-xml-parser/src/traversable/closingIndexForOpeningTag.js","../node_modules/arraybuffer-xml-parser/src/traversable/findClosingIndex.1.js","../node_modules/arraybuffer-xml-parser/src/util.js","../node_modules/arraybuffer-xml-parser/src/traversable/parseAttributesString.js","../node_modules/arraybuffer-xml-parser/src/traversable/getTraversable.js","../node_modules/arraybuffer-xml-parser/src/traversableToJSON.js","../node_modules/arraybuffer-xml-parser/src/parse.js","../node_modules/pako/dist/pako.esm.mjs","../node_modules/uint8-base64/lib-esm/decode.js","../node_modules/mzdata/src/util/decodeBase64.js","../node_modules/mzdata/src/mzdata/parseCvParam.js","../node_modules/mzdata/src/mzdata/processMetaData.js","../node_modules/mzdata/src/mzdata/processSpectrumList.js","../node_modules/mzdata/src/mzdata/parseMzData.js","../node_modules/camelcase/index.js","../node_modules/mzdata/src/mzml/parseCvParam.js","../node_modules/mzdata/src/mzml/processSpectrumList.js","../node_modules/mzdata/src/mzml/parseMzML.js","../node_modules/mzdata/src/mzxml/processSpectrumList.js","../node_modules/mzdata/src/mzxml/parseMzXML.js","../node_modules/mzdata/src/index.js","../src/from/xml.js"],"sourcesContent":["const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n  return toString.call(object).endsWith('Array]');\n}\n","(function(){function a(d){for(var e=0,f=d.length-1,g=void 0,h=void 0,i=void 0,j=c(e,f);!0;){if(f<=e)return d[j];if(f==e+1)return d[e]>d[f]&&b(d,e,f),d[j];for(g=c(e,f),d[g]>d[f]&&b(d,g,f),d[e]>d[f]&&b(d,e,f),d[g]>d[e]&&b(d,g,e),b(d,g,e+1),h=e+1,i=f;!0;){do h++;while(d[e]>d[h]);do i--;while(d[i]>d[e]);if(i<h)break;b(d,h,i)}b(d,e,i),i<=j&&(e=h),i>=j&&(f=i-1)}}var b=function b(d,e,f){var _ref;return _ref=[d[f],d[e]],d[e]=_ref[0],d[f]=_ref[1],_ref},c=function c(d,e){return~~((d+e)/2)};'undefined'!=typeof module&&module.exports?module.exports=a:window.median=a})();\n","import isArray from 'is-any-array';\nimport quickSelectMedian from 'median-quickselect';\n\nfunction median(input) {\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n\n  return quickSelectMedian(input.slice());\n}\n\nexport default median;\n","/**\n * Returns the closest index of a `target` in an ordered array\n * @param {array<Number>} array\n * @param {number} target\n */\n\nexport function xFindClosestIndex(array, target) {\n  let low = 0;\n  let high = array.length - 1;\n  let middle = 0;\n  while (high - low > 1) {\n    middle = low + ((high - low) >> 1);\n    if (array[middle] < target) {\n      low = middle;\n    } else if (array[middle] > target) {\n      high = middle;\n    } else {\n      return middle;\n    }\n  }\n\n  if (low < array.length - 1) {\n    if (Math.abs(target - array[low]) < Math.abs(array[low + 1] - target)) {\n      return low;\n    } else {\n      return low + 1;\n    }\n  } else {\n    return low;\n  }\n}\n","import { xFindClosestIndex } from './xFindClosestIndex';\n\n/**\n * Returns an object with {fromIndex, toIndex} for a specific from / to\n * @param {array} x\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n */\n\nexport function xGetFromToIndex(x, options = {}) {\n  let { fromIndex, toIndex, from, to } = options;\n\n  if (fromIndex === undefined) {\n    if (from !== undefined) {\n      fromIndex = xFindClosestIndex(x, from);\n    } else {\n      fromIndex = 0;\n    }\n  }\n  if (toIndex === undefined) {\n    if (to !== undefined) {\n      toIndex = xFindClosestIndex(x, to);\n    } else {\n      toIndex = x.length - 1;\n    }\n  }\n  if (fromIndex > toIndex) [fromIndex, toIndex] = [toIndex, fromIndex];\n  return { fromIndex, toIndex };\n}\n","import isArray from 'is-any-array';\n\nfunction _typeof(obj) {\n  \"@babel/helpers - typeof\";\n\n  if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n    _typeof = function (obj) {\n      return typeof obj;\n    };\n  } else {\n    _typeof = function (obj) {\n      return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n    };\n  }\n\n  return _typeof(obj);\n}\n\n/**\n * Fill an array with sequential numbers\n * @param {Array<number>} [input] - optional destination array (if not provided a new array will be created)\n * @param {object} [options={}]\n * @param {number} [options.from=0] - first value in the array\n * @param {number} [options.to=10] - last value in the array\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\n * @param {number} [options.step] - if not provided calculated from size\n * @return {Array<number>}\n */\n\nfunction sequentialFill() {\n  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  if (_typeof(input) === 'object' && !isArray(input)) {\n    options = input;\n    input = [];\n  }\n\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  var _options = options,\n      _options$from = _options.from,\n      from = _options$from === void 0 ? 0 : _options$from,\n      _options$to = _options.to,\n      to = _options$to === void 0 ? 10 : _options$to,\n      _options$size = _options.size,\n      size = _options$size === void 0 ? input.length : _options$size,\n      step = _options.step;\n\n  if (size !== 0 && step) {\n    throw new Error('step is defined by the array size');\n  }\n\n  if (!size) {\n    if (step) {\n      size = Math.floor((to - from) / step) + 1;\n    } else {\n      size = to - from + 1;\n    }\n  }\n\n  if (!step && size) {\n    step = (to - from) / (size - 1);\n  }\n\n  if (Array.isArray(input)) {\n    // only works with normal array\n    input.length = 0;\n\n    for (var i = 0; i < size; i++) {\n      input.push(from);\n      from += step;\n    }\n  } else {\n    if (input.length !== size) {\n      throw new Error('sequentialFill typed array must have the correct length');\n    }\n\n    for (var _i = 0; _i < size; _i++) {\n      input[_i] = from;\n      from += step;\n    }\n  }\n\n  return input;\n}\n\nexport { sequentialFill as default };\n","/**\n * Returns true if x is monotone\n * @param {Array} array\n * @return {boolean}\n */\nexport function xIsMonotone(array) {\n  if (array.length <= 2) {\n    return true;\n  }\n  if (array[0] === array[1]) {\n    // maybe a constant series\n    for (let i = 1; i < array.length - 1; i++) {\n      if (array[i] !== array[i + 1]) return false;\n    }\n    return true;\n  }\n\n  if (array[0] < array[array.length - 1]) {\n    for (let i = 0; i < array.length - 1; i++) {\n      if (array[i] >= array[i + 1]) return false;\n    }\n  } else {\n    for (let i = 0; i < array.length - 1; i++) {\n      if (array[i] <= array[i + 1]) return false;\n    }\n  }\n  return true;\n}\n","(function (global, factory) {\n  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n  typeof define === 'function' && define.amd ? define(['exports'], factory) :\n  (factory((global.d3_array = {})));\n}(this, function (exports) { 'use strict';\n\n  function ascending(a, b) {\n    return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;\n  }\n\n  function bisector(compare) {\n    if (compare.length === 1) compare = ascendingComparator(compare);\n    return {\n      left: function(a, x, lo, hi) {\n        if (lo == null) lo = 0;\n        if (hi == null) hi = a.length;\n        while (lo < hi) {\n          var mid = lo + hi >>> 1;\n          if (compare(a[mid], x) < 0) lo = mid + 1;\n          else hi = mid;\n        }\n        return lo;\n      },\n      right: function(a, x, lo, hi) {\n        if (lo == null) lo = 0;\n        if (hi == null) hi = a.length;\n        while (lo < hi) {\n          var mid = lo + hi >>> 1;\n          if (compare(a[mid], x) > 0) hi = mid;\n          else lo = mid + 1;\n        }\n        return lo;\n      }\n    };\n  }\n\n  function ascendingComparator(f) {\n    return function(d, x) {\n      return ascending(f(d), x);\n    };\n  }\n\n  var ascendingBisect = bisector(ascending);\n  var bisectRight = ascendingBisect.right;\n  var bisectLeft = ascendingBisect.left;\n\n  function descending(a, b) {\n    return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n  }\n\n  function number$1(x) {\n    return x === null ? NaN : +x;\n  }\n\n  function variance(array, f) {\n    var n = array.length,\n        m = 0,\n        a,\n        d,\n        s = 0,\n        i = -1,\n        j = 0;\n\n    if (f == null) {\n      while (++i < n) {\n        if (!isNaN(a = number$1(array[i]))) {\n          d = a - m;\n          m += d / ++j;\n          s += d * (a - m);\n        }\n      }\n    }\n\n    else {\n      while (++i < n) {\n        if (!isNaN(a = number$1(f(array[i], i, array)))) {\n          d = a - m;\n          m += d / ++j;\n          s += d * (a - m);\n        }\n      }\n    }\n\n    if (j > 1) return s / (j - 1);\n  }\n\n  function deviation(array, f) {\n    var v = variance(array, f);\n    return v ? Math.sqrt(v) : v;\n  }\n\n  function extent(array, f) {\n    var i = -1,\n        n = array.length,\n        a,\n        b,\n        c;\n\n    if (f == null) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; }\n      while (++i < n) if ((b = array[i]) != null) {\n        if (a > b) a = b;\n        if (c < b) c = b;\n      }\n    }\n\n    else {\n      while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = c = b; break; }\n      while (++i < n) if ((b = f(array[i], i, array)) != null) {\n        if (a > b) a = b;\n        if (c < b) c = b;\n      }\n    }\n\n    return [a, c];\n  }\n\n  function constant(x) {\n    return function() {\n      return x;\n    };\n  }\n\n  function identity(x) {\n    return x;\n  }\n\n  function range(start, stop, step) {\n    start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;\n\n    var i = -1,\n        n = Math.max(0, Math.ceil((stop - start) / step)) | 0,\n        range = new Array(n);\n\n    while (++i < n) {\n      range[i] = start + i * step;\n    }\n\n    return range;\n  }\n\n  var e10 = Math.sqrt(50);\n  var e5 = Math.sqrt(10);\n  var e2 = Math.sqrt(2);\n  function ticks(start, stop, count) {\n    var step = tickStep(start, stop, count);\n    return range(\n      Math.ceil(start / step) * step,\n      Math.floor(stop / step) * step + step / 2, // inclusive\n      step\n    );\n  }\n\n  function tickStep(start, stop, count) {\n    var step0 = Math.abs(stop - start) / Math.max(0, count),\n        step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),\n        error = step0 / step1;\n    if (error >= e10) step1 *= 10;\n    else if (error >= e5) step1 *= 5;\n    else if (error >= e2) step1 *= 2;\n    return stop < start ? -step1 : step1;\n  }\n\n  function sturges(values) {\n    return Math.ceil(Math.log(values.length) / Math.LN2) + 1;\n  }\n\n  function number(x) {\n    return +x;\n  }\n\n  function histogram() {\n    var value = identity,\n        domain = extent,\n        threshold = sturges;\n\n    function histogram(data) {\n      var i,\n          n = data.length,\n          x,\n          values = new Array(n);\n\n      // Coerce values to numbers.\n      for (i = 0; i < n; ++i) {\n        values[i] = +value(data[i], i, data);\n      }\n\n      var xz = domain(values),\n          x0 = +xz[0],\n          x1 = +xz[1],\n          tz = threshold(values, x0, x1);\n\n      // Convert number of thresholds into uniform thresholds.\n      if (!Array.isArray(tz)) tz = ticks(x0, x1, +tz);\n\n      // Coerce thresholds to numbers, ignoring any outside the domain.\n      var m = tz.length;\n      for (i = 0; i < m; ++i) tz[i] = +tz[i];\n      while (tz[0] <= x0) tz.shift(), --m;\n      while (tz[m - 1] >= x1) tz.pop(), --m;\n\n      var bins = new Array(m + 1),\n          bin;\n\n      // Initialize bins.\n      for (i = 0; i <= m; ++i) {\n        bin = bins[i] = [];\n        bin.x0 = i > 0 ? tz[i - 1] : x0;\n        bin.x1 = i < m ? tz[i] : x1;\n      }\n\n      // Assign data to bins by value, ignoring any outside the domain.\n      for (i = 0; i < n; ++i) {\n        x = values[i];\n        if (x0 <= x && x <= x1) {\n          bins[bisectRight(tz, x, 0, m)].push(data[i]);\n        }\n      }\n\n      return bins;\n    }\n\n    histogram.value = function(_) {\n      return arguments.length ? (value = typeof _ === \"function\" ? _ : constant(+_), histogram) : value;\n    };\n\n    histogram.domain = function(_) {\n      return arguments.length ? (domain = typeof _ === \"function\" ? _ : constant([+_[0], +_[1]]), histogram) : domain;\n    };\n\n    histogram.thresholds = function(_) {\n      if (!arguments.length) return threshold;\n      threshold = typeof _ === \"function\" ? _\n          : Array.isArray(_) ? constant(Array.prototype.map.call(_, number))\n          : constant(+_);\n      return histogram;\n    };\n\n    return histogram;\n  }\n\n  function quantile(array, p, f) {\n    if (f == null) f = number$1;\n    if (!(n = array.length)) return;\n    if ((p = +p) <= 0 || n < 2) return +f(array[0], 0, array);\n    if (p >= 1) return +f(array[n - 1], n - 1, array);\n    var n,\n        h = (n - 1) * p,\n        i = Math.floor(h),\n        a = +f(array[i], i, array),\n        b = +f(array[i + 1], i + 1, array);\n    return a + (b - a) * (h - i);\n  }\n\n  function freedmanDiaconis(values, min, max) {\n    values.sort(ascending);\n    return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));\n  }\n\n  function scott(values, min, max) {\n    return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));\n  }\n\n  function max(array, f) {\n    var i = -1,\n        n = array.length,\n        a,\n        b;\n\n    if (f == null) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }\n      while (++i < n) if ((b = array[i]) != null && b > a) a = b;\n    }\n\n    else {\n      while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }\n      while (++i < n) if ((b = f(array[i], i, array)) != null && b > a) a = b;\n    }\n\n    return a;\n  }\n\n  function mean(array, f) {\n    var s = 0,\n        n = array.length,\n        a,\n        i = -1,\n        j = n;\n\n    if (f == null) {\n      while (++i < n) if (!isNaN(a = number$1(array[i]))) s += a; else --j;\n    }\n\n    else {\n      while (++i < n) if (!isNaN(a = number$1(f(array[i], i, array)))) s += a; else --j;\n    }\n\n    if (j) return s / j;\n  }\n\n  function median(array, f) {\n    var numbers = [],\n        n = array.length,\n        a,\n        i = -1;\n\n    if (f == null) {\n      while (++i < n) if (!isNaN(a = number$1(array[i]))) numbers.push(a);\n    }\n\n    else {\n      while (++i < n) if (!isNaN(a = number$1(f(array[i], i, array)))) numbers.push(a);\n    }\n\n    return quantile(numbers.sort(ascending), 0.5);\n  }\n\n  function merge(arrays) {\n    var n = arrays.length,\n        m,\n        i = -1,\n        j = 0,\n        merged,\n        array;\n\n    while (++i < n) j += arrays[i].length;\n    merged = new Array(j);\n\n    while (--n >= 0) {\n      array = arrays[n];\n      m = array.length;\n      while (--m >= 0) {\n        merged[--j] = array[m];\n      }\n    }\n\n    return merged;\n  }\n\n  function min(array, f) {\n    var i = -1,\n        n = array.length,\n        a,\n        b;\n\n    if (f == null) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }\n      while (++i < n) if ((b = array[i]) != null && a > b) a = b;\n    }\n\n    else {\n      while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }\n      while (++i < n) if ((b = f(array[i], i, array)) != null && a > b) a = b;\n    }\n\n    return a;\n  }\n\n  function pairs(array) {\n    var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);\n    while (i < n) pairs[i] = [p, p = array[++i]];\n    return pairs;\n  }\n\n  function permute(array, indexes) {\n    var i = indexes.length, permutes = new Array(i);\n    while (i--) permutes[i] = array[indexes[i]];\n    return permutes;\n  }\n\n  function scan(array, compare) {\n    if (!(n = array.length)) return;\n    var i = 0,\n        n,\n        j = 0,\n        xi,\n        xj = array[j];\n\n    if (!compare) compare = ascending;\n\n    while (++i < n) if (compare(xi = array[i], xj) < 0 || compare(xj, xj) !== 0) xj = xi, j = i;\n\n    if (compare(xj, xj) === 0) return j;\n  }\n\n  function shuffle(array, i0, i1) {\n    var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),\n        t,\n        i;\n\n    while (m) {\n      i = Math.random() * m-- | 0;\n      t = array[m + i0];\n      array[m + i0] = array[i + i0];\n      array[i + i0] = t;\n    }\n\n    return array;\n  }\n\n  function sum(array, f) {\n    var s = 0,\n        n = array.length,\n        a,\n        i = -1;\n\n    if (f == null) {\n      while (++i < n) if (a = +array[i]) s += a; // Note: zero and null are equivalent.\n    }\n\n    else {\n      while (++i < n) if (a = +f(array[i], i, array)) s += a;\n    }\n\n    return s;\n  }\n\n  function transpose(matrix) {\n    if (!(n = matrix.length)) return [];\n    for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) {\n      for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {\n        row[j] = matrix[j][i];\n      }\n    }\n    return transpose;\n  }\n\n  function length(d) {\n    return d.length;\n  }\n\n  function zip() {\n    return transpose(arguments);\n  }\n\n  var version = \"0.7.1\";\n\n  exports.version = version;\n  exports.bisect = bisectRight;\n  exports.bisectRight = bisectRight;\n  exports.bisectLeft = bisectLeft;\n  exports.ascending = ascending;\n  exports.bisector = bisector;\n  exports.descending = descending;\n  exports.deviation = deviation;\n  exports.extent = extent;\n  exports.histogram = histogram;\n  exports.thresholdFreedmanDiaconis = freedmanDiaconis;\n  exports.thresholdScott = scott;\n  exports.thresholdSturges = sturges;\n  exports.max = max;\n  exports.mean = mean;\n  exports.median = median;\n  exports.merge = merge;\n  exports.min = min;\n  exports.pairs = pairs;\n  exports.permute = permute;\n  exports.quantile = quantile;\n  exports.range = range;\n  exports.scan = scan;\n  exports.shuffle = shuffle;\n  exports.sum = sum;\n  exports.ticks = ticks;\n  exports.tickStep = tickStep;\n  exports.transpose = transpose;\n  exports.variance = variance;\n  exports.zip = zip;\n\n}));","const {bisectRight} = require('d3-array')\n\nconst quincunx = (u, v, w, q) => {\n  const n = u.length - 1\n\n  u[0] = 0\n  v[0] = 0\n  w[0] = 0\n  v[1] = v[1] / u[1]\n  w[1] = w[1] / u[1]\n  for (let i = 2; i < n; ++i) {\n    u[i] = u[i] - u[i - 2] * w[i - 2] * w[i - 2] - u[i - 1] * v[i - 1] * v[i - 1]\n    v[i] = (v[i] - u[i - 1] * v[i - 1] * w[i - 1]) / u[i]\n    w[i] = w[i] / u[i]\n  }\n\n  for (let i = 2; i < n; ++i) {\n    q[i] = q[i] - v[i - 1] * q[i - 1] - w[i - 2] * q[i - 2]\n  }\n  for (let i = 1; i < n; ++i) {\n    q[i] = q[i] / u[i]\n  }\n\n  q[n - 2] = q[n - 2] - v[n - 2] * q[n - 1]\n  for (let i = n - 3; i > 0; --i) {\n    q[i] = q[i] - v[i] * q[i + 1] - w[i] * q[i + 2]\n  }\n}\n\nconst smoothingSpline = (x, y, sigma, lambda) => {\n  const n = x.length - 1\n  const h = new Array(n + 1)\n  const r = new Array(n + 1)\n  const f = new Array(n + 1)\n  const p = new Array(n + 1)\n  const q = new Array(n + 1)\n  const u = new Array(n + 1)\n  const v = new Array(n + 1)\n  const w = new Array(n + 1)\n  const params = x.map(() => [0, 0, 0, 0])\n  params.pop()\n\n  const mu = 2 * (1 - lambda) / (3 * lambda)\n  for (let i = 0; i < n; ++i) {\n    h[i] = x[i + 1] - x[i]\n    r[i] = 3 / h[i]\n  }\n  q[0] = 0\n  for (let i = 1; i < n; ++i) {\n    f[i] = -(r[i - 1] + r[i])\n    p[i] = 2 * (x[i + 1] - x[i - 1])\n    q[i] = 3 * (y[i + 1] - y[i]) / h[i] - 3 * (y[i] - y[i - 1]) / h[i - 1]\n  }\n  q[n] = 0\n\n  for (let i = 1; i < n; ++i) {\n    u[i] = r[i - 1] * r[i - 1] * sigma[i - 1] + f[i] * f[i] * sigma[i] + r[i] * r[i] * sigma[i + 1]\n    u[i] = mu * u[i] + p[i]\n  }\n  for (let i = 1; i < n - 1; ++i) {\n    v[i] = f[i] * r[i] * sigma[i] + r[i] * f[i + 1] * sigma[i + 1]\n    v[i] = mu * v[i] + h[i]\n  }\n  for (let i = 1; i < n - 2; ++i) {\n    w[i] = mu * r[i] * r[i + 1] * sigma[i + 1]\n  }\n\n  quincunx(u, v, w, q)\n\n  params[0][3] = y[0] - mu * r[0] * q[1] * sigma[0]\n  params[1][3] = y[1] - mu * (f[1] * q[1] + r[1] * q[2]) * sigma[0]\n  params[0][0] = q[1] / (3 * h[0])\n  params[0][1] = 0\n  params[0][2] = (params[1][3] - params[0][3]) / h[0] - q[1] * h[0] / 3\n  r[0] = 0\n  for (let i = 1; i < n; ++i) {\n    params[i][0] = (q[i + 1] - q[i]) / (3 * h[i])\n    params[i][1] = q[i]\n    params[i][2] = (q[i] + q[i - 1]) * h[i - 1] + params[i - 1][2]\n    params[i][3] = r[i - 1] * q[i - 1] + f[i] * q[i] + r[i] * q[i + 1]\n    params[i][3] = y[i] - mu * params[i][3] * sigma[i]\n  }\n  return params\n}\n\nclass SplineInterpolator {\n  constructor (xIn, yIn, lambda = 1) {\n    const indices = xIn.map((_, i) => i)\n    indices.sort((i, j) => xIn[i] - xIn[j])\n    const x = indices.map((i) => xIn[i])\n    const y = indices.map((i) => yIn[i])\n    const n = indices.length\n    const sigma = indices.map(() => 1)\n    this.n = n\n    this.x = x\n    this.y = y\n    this.params = smoothingSpline(x, y, sigma, lambda)\n  }\n\n  interpolate (v) {\n    if (v === this.x[this.n - 1]) {\n      return this.y[this.n - 1]\n    }\n    const i = Math.min(Math.max(0, bisectRight(this.x, v) - 1), this.n - 2)\n    const [a, b, c, d] = this.params[i]\n    v = v - this.x[i]\n    return a * v * v * v + b * v * v + c * v + d\n  }\n\n  max (step = 100) {\n    const xStart = this.x[0]\n    const xStop = this.x[this.n - 1]\n    const delta = (xStop - xStart) / step\n    let maxValue = -Infinity\n    for (let i = 0, x = xStart; i < step; ++i, x += delta) {\n      const y = this.interpolate(x)\n      if (y > maxValue) {\n        maxValue = y\n      }\n    }\n    return maxValue\n  }\n\n  min (step = 100) {\n    const xStart = this.x[0]\n    const xStop = this.x[this.n - 1]\n    const delta = (xStop - xStart) / step\n    let minValue = Infinity\n    for (let i = 0, x = xStart; i < step; ++i, x += delta) {\n      const y = this.interpolate(x)\n      if (y < minValue) {\n        minValue = y\n      }\n    }\n    return minValue\n  }\n\n  domain () {\n    return [this.x[0], this.x[this.x.length - 1]]\n  }\n\n  range () {\n    return [this.min(), this.max()]\n  }\n\n  curve (nInterval, domain = null) {\n    domain = domain || this.domain()\n    const delta = (domain[1] - domain[0]) / (nInterval - 1)\n    const vals = new Array(nInterval)\n    for (let i = 0; i < nInterval; ++i) {\n      const x = delta * i + domain[0]\n      vals[i] = [x, this.interpolate(x)]\n    }\n    return vals\n  }\n}\n\nmodule.exports = SplineInterpolator\n","import isArray from 'is-any-array';\n\nfunction sum(input) {\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n\n  var sumValue = 0;\n\n  for (var i = 0; i < input.length; i++) {\n    sumValue += input[i];\n  }\n\n  return sumValue;\n}\n\nexport default sum;\n","import sum from 'ml-array-sum';\n\nfunction mean(input) {\n  return sum(input) / input.length;\n}\n\nexport default mean;\n","import isArray from 'is-any-array';\nimport arrayMean from 'ml-array-mean';\n\nfunction variance(values) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  if (!isArray(values)) {\n    throw new TypeError('input must be an array');\n  }\n\n  var _options$unbiased = options.unbiased,\n      unbiased = _options$unbiased === void 0 ? true : _options$unbiased,\n      _options$mean = options.mean,\n      mean = _options$mean === void 0 ? arrayMean(values) : _options$mean;\n  var sqrError = 0;\n\n  for (var i = 0; i < values.length; i++) {\n    var x = values[i] - mean;\n    sqrError += x * x;\n  }\n\n  if (unbiased) {\n    return sqrError / (values.length - 1);\n  } else {\n    return sqrError / values.length;\n  }\n}\n\nexport { variance as default };\n","import variance from 'ml-array-variance';\n\nfunction standardDeviation(values) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  return Math.sqrt(variance(values, options));\n}\n\nexport { standardDeviation as default };\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n\n  var _options$fromIndex = options.fromIndex,\n      fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n      _options$toIndex = options.toIndex,\n      toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n  if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n    throw new Error('fromIndex must be a positive integer smaller than length');\n  }\n\n  if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n    throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n  }\n\n  var minValue = input[fromIndex];\n\n  for (var i = fromIndex + 1; i < toIndex; i++) {\n    if (input[i] < minValue) minValue = input[i];\n  }\n\n  return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n\n  var _options$fromIndex = options.fromIndex,\n      fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n      _options$toIndex = options.toIndex,\n      toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n  if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n    throw new Error('fromIndex must be a positive integer smaller than length');\n  }\n\n  if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n    throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n  }\n\n  var maxValue = input[fromIndex];\n\n  for (var i = fromIndex + 1; i < toIndex; i++) {\n    if (input[i] > maxValue) maxValue = input[i];\n  }\n\n  return maxValue;\n}\n\nexport default max;\n","'use strict';\n\nfunction FFT(size) {\n  this.size = size | 0;\n  if (this.size <= 1 || (this.size & (this.size - 1)) !== 0)\n    throw new Error('FFT size must be a power of two and bigger than 1');\n\n  this._csize = size << 1;\n\n  // NOTE: Use of `var` is intentional for old V8 versions\n  var table = new Array(this.size * 2);\n  for (var i = 0; i < table.length; i += 2) {\n    const angle = Math.PI * i / this.size;\n    table[i] = Math.cos(angle);\n    table[i + 1] = -Math.sin(angle);\n  }\n  this.table = table;\n\n  // Find size's power of two\n  var power = 0;\n  for (var t = 1; this.size > t; t <<= 1)\n    power++;\n\n  // Calculate initial step's width:\n  //   * If we are full radix-4 - it is 2x smaller to give inital len=8\n  //   * Otherwise it is the same as `power` to give len=4\n  this._width = power % 2 === 0 ? power - 1 : power;\n\n  // Pre-compute bit-reversal patterns\n  this._bitrev = new Array(1 << this._width);\n  for (var j = 0; j < this._bitrev.length; j++) {\n    this._bitrev[j] = 0;\n    for (var shift = 0; shift < this._width; shift += 2) {\n      var revShift = this._width - shift - 2;\n      this._bitrev[j] |= ((j >>> shift) & 3) << revShift;\n    }\n  }\n\n  this._out = null;\n  this._data = null;\n  this._inv = 0;\n}\nmodule.exports = FFT;\n\nFFT.prototype.fromComplexArray = function fromComplexArray(complex, storage) {\n  var res = storage || new Array(complex.length >>> 1);\n  for (var i = 0; i < complex.length; i += 2)\n    res[i >>> 1] = complex[i];\n  return res;\n};\n\nFFT.prototype.createComplexArray = function createComplexArray() {\n  const res = new Array(this._csize);\n  for (var i = 0; i < res.length; i++)\n    res[i] = 0;\n  return res;\n};\n\nFFT.prototype.toComplexArray = function toComplexArray(input, storage) {\n  var res = storage || this.createComplexArray();\n  for (var i = 0; i < res.length; i += 2) {\n    res[i] = input[i >>> 1];\n    res[i + 1] = 0;\n  }\n  return res;\n};\n\nFFT.prototype.completeSpectrum = function completeSpectrum(spectrum) {\n  var size = this._csize;\n  var half = size >>> 1;\n  for (var i = 2; i < half; i += 2) {\n    spectrum[size - i] = spectrum[i];\n    spectrum[size - i + 1] = -spectrum[i + 1];\n  }\n};\n\nFFT.prototype.transform = function transform(out, data) {\n  if (out === data)\n    throw new Error('Input and output buffers must be different');\n\n  this._out = out;\n  this._data = data;\n  this._inv = 0;\n  this._transform4();\n  this._out = null;\n  this._data = null;\n};\n\nFFT.prototype.realTransform = function realTransform(out, data) {\n  if (out === data)\n    throw new Error('Input and output buffers must be different');\n\n  this._out = out;\n  this._data = data;\n  this._inv = 0;\n  this._realTransform4();\n  this._out = null;\n  this._data = null;\n};\n\nFFT.prototype.inverseTransform = function inverseTransform(out, data) {\n  if (out === data)\n    throw new Error('Input and output buffers must be different');\n\n  this._out = out;\n  this._data = data;\n  this._inv = 1;\n  this._transform4();\n  for (var i = 0; i < out.length; i++)\n    out[i] /= this.size;\n  this._out = null;\n  this._data = null;\n};\n\n// radix-4 implementation\n//\n// NOTE: Uses of `var` are intentional for older V8 version that do not\n// support both `let compound assignments` and `const phi`\nFFT.prototype._transform4 = function _transform4() {\n  var out = this._out;\n  var size = this._csize;\n\n  // Initial step (permute and transform)\n  var width = this._width;\n  var step = 1 << width;\n  var len = (size / step) << 1;\n\n  var outOff;\n  var t;\n  var bitrev = this._bitrev;\n  if (len === 4) {\n    for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n      const off = bitrev[t];\n      this._singleTransform2(outOff, off, step);\n    }\n  } else {\n    // len === 8\n    for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n      const off = bitrev[t];\n      this._singleTransform4(outOff, off, step);\n    }\n  }\n\n  // Loop through steps in decreasing order\n  var inv = this._inv ? -1 : 1;\n  var table = this.table;\n  for (step >>= 2; step >= 2; step >>= 2) {\n    len = (size / step) << 1;\n    var quarterLen = len >>> 2;\n\n    // Loop through offsets in the data\n    for (outOff = 0; outOff < size; outOff += len) {\n      // Full case\n      var limit = outOff + quarterLen;\n      for (var i = outOff, k = 0; i < limit; i += 2, k += step) {\n        const A = i;\n        const B = A + quarterLen;\n        const C = B + quarterLen;\n        const D = C + quarterLen;\n\n        // Original values\n        const Ar = out[A];\n        const Ai = out[A + 1];\n        const Br = out[B];\n        const Bi = out[B + 1];\n        const Cr = out[C];\n        const Ci = out[C + 1];\n        const Dr = out[D];\n        const Di = out[D + 1];\n\n        // Middle values\n        const MAr = Ar;\n        const MAi = Ai;\n\n        const tableBr = table[k];\n        const tableBi = inv * table[k + 1];\n        const MBr = Br * tableBr - Bi * tableBi;\n        const MBi = Br * tableBi + Bi * tableBr;\n\n        const tableCr = table[2 * k];\n        const tableCi = inv * table[2 * k + 1];\n        const MCr = Cr * tableCr - Ci * tableCi;\n        const MCi = Cr * tableCi + Ci * tableCr;\n\n        const tableDr = table[3 * k];\n        const tableDi = inv * table[3 * k + 1];\n        const MDr = Dr * tableDr - Di * tableDi;\n        const MDi = Dr * tableDi + Di * tableDr;\n\n        // Pre-Final values\n        const T0r = MAr + MCr;\n        const T0i = MAi + MCi;\n        const T1r = MAr - MCr;\n        const T1i = MAi - MCi;\n        const T2r = MBr + MDr;\n        const T2i = MBi + MDi;\n        const T3r = inv * (MBr - MDr);\n        const T3i = inv * (MBi - MDi);\n\n        // Final values\n        const FAr = T0r + T2r;\n        const FAi = T0i + T2i;\n\n        const FCr = T0r - T2r;\n        const FCi = T0i - T2i;\n\n        const FBr = T1r + T3i;\n        const FBi = T1i - T3r;\n\n        const FDr = T1r - T3i;\n        const FDi = T1i + T3r;\n\n        out[A] = FAr;\n        out[A + 1] = FAi;\n        out[B] = FBr;\n        out[B + 1] = FBi;\n        out[C] = FCr;\n        out[C + 1] = FCi;\n        out[D] = FDr;\n        out[D + 1] = FDi;\n      }\n    }\n  }\n};\n\n// radix-2 implementation\n//\n// NOTE: Only called for len=4\nFFT.prototype._singleTransform2 = function _singleTransform2(outOff, off,\n                                                             step) {\n  const out = this._out;\n  const data = this._data;\n\n  const evenR = data[off];\n  const evenI = data[off + 1];\n  const oddR = data[off + step];\n  const oddI = data[off + step + 1];\n\n  const leftR = evenR + oddR;\n  const leftI = evenI + oddI;\n  const rightR = evenR - oddR;\n  const rightI = evenI - oddI;\n\n  out[outOff] = leftR;\n  out[outOff + 1] = leftI;\n  out[outOff + 2] = rightR;\n  out[outOff + 3] = rightI;\n};\n\n// radix-4\n//\n// NOTE: Only called for len=8\nFFT.prototype._singleTransform4 = function _singleTransform4(outOff, off,\n                                                             step) {\n  const out = this._out;\n  const data = this._data;\n  const inv = this._inv ? -1 : 1;\n  const step2 = step * 2;\n  const step3 = step * 3;\n\n  // Original values\n  const Ar = data[off];\n  const Ai = data[off + 1];\n  const Br = data[off + step];\n  const Bi = data[off + step + 1];\n  const Cr = data[off + step2];\n  const Ci = data[off + step2 + 1];\n  const Dr = data[off + step3];\n  const Di = data[off + step3 + 1];\n\n  // Pre-Final values\n  const T0r = Ar + Cr;\n  const T0i = Ai + Ci;\n  const T1r = Ar - Cr;\n  const T1i = Ai - Ci;\n  const T2r = Br + Dr;\n  const T2i = Bi + Di;\n  const T3r = inv * (Br - Dr);\n  const T3i = inv * (Bi - Di);\n\n  // Final values\n  const FAr = T0r + T2r;\n  const FAi = T0i + T2i;\n\n  const FBr = T1r + T3i;\n  const FBi = T1i - T3r;\n\n  const FCr = T0r - T2r;\n  const FCi = T0i - T2i;\n\n  const FDr = T1r - T3i;\n  const FDi = T1i + T3r;\n\n  out[outOff] = FAr;\n  out[outOff + 1] = FAi;\n  out[outOff + 2] = FBr;\n  out[outOff + 3] = FBi;\n  out[outOff + 4] = FCr;\n  out[outOff + 5] = FCi;\n  out[outOff + 6] = FDr;\n  out[outOff + 7] = FDi;\n};\n\n// Real input radix-4 implementation\nFFT.prototype._realTransform4 = function _realTransform4() {\n  var out = this._out;\n  var size = this._csize;\n\n  // Initial step (permute and transform)\n  var width = this._width;\n  var step = 1 << width;\n  var len = (size / step) << 1;\n\n  var outOff;\n  var t;\n  var bitrev = this._bitrev;\n  if (len === 4) {\n    for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n      const off = bitrev[t];\n      this._singleRealTransform2(outOff, off >>> 1, step >>> 1);\n    }\n  } else {\n    // len === 8\n    for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n      const off = bitrev[t];\n      this._singleRealTransform4(outOff, off >>> 1, step >>> 1);\n    }\n  }\n\n  // Loop through steps in decreasing order\n  var inv = this._inv ? -1 : 1;\n  var table = this.table;\n  for (step >>= 2; step >= 2; step >>= 2) {\n    len = (size / step) << 1;\n    var halfLen = len >>> 1;\n    var quarterLen = halfLen >>> 1;\n    var hquarterLen = quarterLen >>> 1;\n\n    // Loop through offsets in the data\n    for (outOff = 0; outOff < size; outOff += len) {\n      for (var i = 0, k = 0; i <= hquarterLen; i += 2, k += step) {\n        var A = outOff + i;\n        var B = A + quarterLen;\n        var C = B + quarterLen;\n        var D = C + quarterLen;\n\n        // Original values\n        var Ar = out[A];\n        var Ai = out[A + 1];\n        var Br = out[B];\n        var Bi = out[B + 1];\n        var Cr = out[C];\n        var Ci = out[C + 1];\n        var Dr = out[D];\n        var Di = out[D + 1];\n\n        // Middle values\n        var MAr = Ar;\n        var MAi = Ai;\n\n        var tableBr = table[k];\n        var tableBi = inv * table[k + 1];\n        var MBr = Br * tableBr - Bi * tableBi;\n        var MBi = Br * tableBi + Bi * tableBr;\n\n        var tableCr = table[2 * k];\n        var tableCi = inv * table[2 * k + 1];\n        var MCr = Cr * tableCr - Ci * tableCi;\n        var MCi = Cr * tableCi + Ci * tableCr;\n\n        var tableDr = table[3 * k];\n        var tableDi = inv * table[3 * k + 1];\n        var MDr = Dr * tableDr - Di * tableDi;\n        var MDi = Dr * tableDi + Di * tableDr;\n\n        // Pre-Final values\n        var T0r = MAr + MCr;\n        var T0i = MAi + MCi;\n        var T1r = MAr - MCr;\n        var T1i = MAi - MCi;\n        var T2r = MBr + MDr;\n        var T2i = MBi + MDi;\n        var T3r = inv * (MBr - MDr);\n        var T3i = inv * (MBi - MDi);\n\n        // Final values\n        var FAr = T0r + T2r;\n        var FAi = T0i + T2i;\n\n        var FBr = T1r + T3i;\n        var FBi = T1i - T3r;\n\n        out[A] = FAr;\n        out[A + 1] = FAi;\n        out[B] = FBr;\n        out[B + 1] = FBi;\n\n        // Output final middle point\n        if (i === 0) {\n          var FCr = T0r - T2r;\n          var FCi = T0i - T2i;\n          out[C] = FCr;\n          out[C + 1] = FCi;\n          continue;\n        }\n\n        // Do not overwrite ourselves\n        if (i === hquarterLen)\n          continue;\n\n        // In the flipped case:\n        // MAi = -MAi\n        // MBr=-MBi, MBi=-MBr\n        // MCr=-MCr\n        // MDr=MDi, MDi=MDr\n        var ST0r = T1r;\n        var ST0i = -T1i;\n        var ST1r = T0r;\n        var ST1i = -T0i;\n        var ST2r = -inv * T3i;\n        var ST2i = -inv * T3r;\n        var ST3r = -inv * T2i;\n        var ST3i = -inv * T2r;\n\n        var SFAr = ST0r + ST2r;\n        var SFAi = ST0i + ST2i;\n\n        var SFBr = ST1r + ST3i;\n        var SFBi = ST1i - ST3r;\n\n        var SA = outOff + quarterLen - i;\n        var SB = outOff + halfLen - i;\n\n        out[SA] = SFAr;\n        out[SA + 1] = SFAi;\n        out[SB] = SFBr;\n        out[SB + 1] = SFBi;\n      }\n    }\n  }\n};\n\n// radix-2 implementation\n//\n// NOTE: Only called for len=4\nFFT.prototype._singleRealTransform2 = function _singleRealTransform2(outOff,\n                                                                     off,\n                                                                     step) {\n  const out = this._out;\n  const data = this._data;\n\n  const evenR = data[off];\n  const oddR = data[off + step];\n\n  const leftR = evenR + oddR;\n  const rightR = evenR - oddR;\n\n  out[outOff] = leftR;\n  out[outOff + 1] = 0;\n  out[outOff + 2] = rightR;\n  out[outOff + 3] = 0;\n};\n\n// radix-4\n//\n// NOTE: Only called for len=8\nFFT.prototype._singleRealTransform4 = function _singleRealTransform4(outOff,\n                                                                     off,\n                                                                     step) {\n  const out = this._out;\n  const data = this._data;\n  const inv = this._inv ? -1 : 1;\n  const step2 = step * 2;\n  const step3 = step * 3;\n\n  // Original values\n  const Ar = data[off];\n  const Br = data[off + step];\n  const Cr = data[off + step2];\n  const Dr = data[off + step3];\n\n  // Pre-Final values\n  const T0r = Ar + Cr;\n  const T1r = Ar - Cr;\n  const T2r = Br + Dr;\n  const T3r = inv * (Br - Dr);\n\n  // Final values\n  const FAr = T0r + T2r;\n\n  const FBr = T1r;\n  const FBi = -T3r;\n\n  const FCr = T0r - T2r;\n\n  const FDr = T1r;\n  const FDi = T3r;\n\n  out[outOff] = FAr;\n  out[outOff + 1] = 0;\n  out[outOff + 2] = FBr;\n  out[outOff + 3] = FBi;\n  out[outOff + 4] = FCr;\n  out[outOff + 5] = 0;\n  out[outOff + 6] = FDr;\n  out[outOff + 7] = FDi;\n};\n","import isAnyArray from 'is-any-array';\n\n/**\n * Throw an error in no an object of x,y arrays\n * @param {DataXY} [data={}]\n */\nexport function xyCheck(data = {}) {\n  if (!isAnyArray(data.x) || !isAnyArray(data.y)) {\n    throw new Error('Data must be an object of x and y arrays');\n  }\n  if (data.x.length !== data.y.length) {\n    throw new Error('The x and y arrays mush have the same length');\n  }\n}\n","/**\n * Merge DataXY\n * We have an array of DataXY and the goal is to merge all the values for which the deltaX is small or equal to delta.\n * X values are weighted average\n * @param {Array<DataXY>} spectra\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @returns {DataXY}\n */\nexport function xyArrayWeightedMerge(spectra, options = {}) {\n  let { delta = 1 } = options;\n  if (typeof delta === 'number') {\n    let deltaNumber = delta;\n    delta = () => deltaNumber;\n  }\n  spectra = spectra.filter((spectrum) => spectrum.x.length > 0);\n\n  if (spectra.length === 0) return { x: [], y: [] };\n\n  let x = [];\n  let y = [];\n\n  const positions = new Array(spectra.length).fill(0);\n  const point = { x: 0, y: 0 };\n\n  nextValue(spectra, positions, point);\n  let slot = {\n    maxX: point.x + delta(point.x),\n    sumY: point.y,\n    sumXY: point.y * point.x,\n  };\n\n  while (spectra.length !== 0) {\n    nextValue(spectra, positions, point);\n    let sameSlot = point.x <= slot.maxX;\n    if (!sameSlot) {\n      if (slot.sumY > 0) {\n        x.push(slot.sumXY / slot.sumY);\n        y.push(slot.sumY);\n      }\n      slot.sumY = 0;\n      slot.sumXY = 0;\n    }\n\n    slot.sumY += point.y;\n    slot.sumXY += point.x * point.y;\n    slot.maxX = point.x + delta(point.x);\n\n    if (spectra.length === 0) {\n      if (slot.sumY > 0) {\n        x.push(slot.sumXY / slot.sumY);\n        y.push(slot.sumY);\n      }\n    }\n  }\n  return { x, y };\n}\n\nfunction nextValue(spectra, positions, point) {\n  let minIndex = 0;\n  let minX = spectra[0].x[positions[0]];\n\n  for (let i = 1; i < spectra.length; i++) {\n    let currentX = spectra[i].x[positions[i]];\n    if (currentX < minX) {\n      minX = currentX;\n      minIndex = i;\n    }\n  }\n\n  point.x = minX;\n  point.y = spectra[minIndex].y[positions[minIndex]];\n\n  positions[minIndex]++;\n\n  if (positions[minIndex] === spectra[minIndex].x.length) {\n    positions.splice(minIndex, 1);\n    spectra.splice(minIndex, 1);\n  }\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * Calculate integration\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number} xyIntegration value on the specified range\n */\n\nexport function xyIntegration(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n  let currentxyIntegration = 0;\n  for (let i = fromIndex; i < toIndex; i++) {\n    currentxyIntegration += ((x[i + 1] - x[i]) * (y[i + 1] + y[i])) / 2;\n  }\n\n  return currentxyIntegration;\n}\n","export const GAUSSIAN_EXP_FACTOR = -4 * Math.LN2;\nexport const ROOT_PI_OVER_LN2 = Math.sqrt(Math.PI / Math.LN2);\nexport const ROOT_THREE = Math.sqrt(3);\nexport const ROOT_2LN2 = Math.sqrt(2 * Math.LN2);\nexport const ROOT_2LN2_MINUS_ONE = Math.sqrt(2 * Math.LN2) - 1;\n//# sourceMappingURL=constants.js.map","// https://en.wikipedia.org/wiki/Error_function#Inverse_functions\n// This code yields to a good approximation\n// If needed a better implementation using polynomial can be found on https://en.wikipedia.org/wiki/Error_function#Inverse_functions\nexport default function erfinv(x) {\n    let a = 0.147;\n    if (x === 0)\n        return 0;\n    let ln1MinusXSqrd = Math.log(1 - x * x);\n    let lnEtcBy2Plus2 = ln1MinusXSqrd / 2 + 2 / (Math.PI * a);\n    let firstSqrt = Math.sqrt(lnEtcBy2Plus2 ** 2 - ln1MinusXSqrd / a);\n    let secondSqrt = Math.sqrt(firstSqrt - lnEtcBy2Plus2);\n    return secondSqrt * (x > 0 ? 1 : -1);\n}\n//# sourceMappingURL=erfinv.js.map","export class Shape1D {\n}\n//# sourceMappingURL=Shape1D.js.map","import { ROOT_2LN2, GAUSSIAN_EXP_FACTOR, ROOT_PI_OVER_LN2, } from '../../../util/constants';\nimport erfinv from '../../../util/erfinv';\nimport { Shape1D } from '../Shape1D';\nexport class Gaussian extends Shape1D {\n    constructor(options = {}) {\n        super();\n        const { fwhm = 500, sd, height } = options;\n        this.fwhm = sd ? widthToFWHM(2 * sd) : fwhm;\n        this.height =\n            height === undefined\n                ? Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI) / this.fwhm\n                : height;\n    }\n    fwhmToWidth(fwhm = this.fwhm) {\n        return fwhmToWidth(fwhm);\n    }\n    widthToFWHM(width) {\n        return widthToFWHM(width);\n    }\n    fct(x) {\n        return fct(x, this.fwhm);\n    }\n    getArea() {\n        return getArea({ fwhm: this.fwhm, height: this.height });\n    }\n    getFactor(area) {\n        return getFactor(area);\n    }\n    getData(options = {}) {\n        const { length, factor } = options;\n        return getData({ fwhm: this.fwhm, height: this.height, factor, length });\n    }\n}\n/**\n * Return a parameterized function of a gaussian shape (see README for equation).\n * @returns - the y value of gaussian with the current parameters.\n */\nexport function fct(x, fwhm) {\n    return Math.exp(GAUSSIAN_EXP_FACTOR * Math.pow(x / fwhm, 2));\n}\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n * for more information check the [mathworld page](https://mathworld.wolfram.com/GaussianFunction.html)\n * @returns fwhm\n */\nexport function widthToFWHM(width) {\n    return width * ROOT_2LN2;\n}\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * for more information check the [mathworld page](https://mathworld.wolfram.com/GaussianFunction.html)\n * @param fwhm - Full Width at Half Maximum.\n * @returns width\n */\nexport function fwhmToWidth(fwhm) {\n    return fwhm / ROOT_2LN2;\n}\n/**\n * Calculate the area of a specific shape.\n * @returns returns the area of the specific shape and parameters.\n */\nexport function getArea(options) {\n    let { fwhm, sd, height = 1 } = options;\n    if (sd)\n        fwhm = widthToFWHM(2 * sd);\n    if (fwhm === undefined) {\n        throw new Error('should pass fwhm or sd parameters');\n    }\n    return (height * ROOT_PI_OVER_LN2 * fwhm) / 2;\n}\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage.\n * @param [area=0.9999] Expected area to be covered.\n * @returns\n */\nexport function getFactor(area = 0.9999) {\n    return Math.sqrt(2) * erfinv(area);\n}\n/**\n * Calculate intensity array of a gaussian shape.\n * @returns {Float64Array} Intensity values.\n */\nexport function getData(options = {}) {\n    let { length, factor = getFactor(), fwhm = 500, sd, height } = options;\n    if (sd)\n        fwhm = widthToFWHM(2 * sd);\n    if (!height) {\n        height = Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI) / fwhm;\n    }\n    if (!length) {\n        length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n        if (length % 2 === 0)\n            length++;\n    }\n    const center = (length - 1) / 2;\n    const data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n        data[i] = fct(i - center, fwhm) * height;\n        data[length - 1 - i] = data[i];\n    }\n    return data;\n}\n//# sourceMappingURL=Gaussian.js.map","import { ROOT_THREE } from '../../../util/constants';\nimport { Shape1D } from '../Shape1D';\nexport class Lorentzian extends Shape1D {\n    constructor(options = {}) {\n        super();\n        const { fwhm = 500, height } = options;\n        this.fwhm = fwhm;\n        this.height = height === undefined ? 2 / Math.PI / fwhm : height;\n    }\n    fwhmToWidth(fwhm = this.fwhm) {\n        return fwhmToWidth(fwhm);\n    }\n    widthToFWHM(width) {\n        return widthToFWHM(width);\n    }\n    fct(x) {\n        return fct(x, this.fwhm);\n    }\n    getArea() {\n        return getArea({ fwhm: this.fwhm, height: this.height });\n    }\n    getFactor(area) {\n        return getFactor(area);\n    }\n    getData(options = {}) {\n        const { length, factor } = options;\n        return getData({ fwhm: this.fwhm, height: this.height, factor, length });\n    }\n}\n/**\n * Return a parameterized function of a lorentzian shape (see README for equation).\n * @param x - x value to calculate.\n * @param fwhm - full width half maximum\n * @returns - the y value of lorentzian with the current parameters.\n */\nexport function fct(x, fwhm) {\n    return Math.pow(fwhm, 2) / (4 * Math.pow(x, 2) + Math.pow(fwhm, 2));\n}\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n * for more information check the [mathworld page](https://mathworld.wolfram.com/LorentzianFunction.html)\n * @param width - Width between the inflection points\n * @returns fwhm\n */\nexport function widthToFWHM(width) {\n    return width * ROOT_THREE;\n}\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * for more information check the [mathworld page](https://mathworld.wolfram.com/LorentzianFunction.html)\n * @param fwhm - Full Width at Half Maximum.\n * @returns width\n */\nexport function fwhmToWidth(fwhm) {\n    return fwhm / ROOT_THREE;\n}\n/**\n * Calculate the area of a specific shape.\n * @returns returns the area of the specific shape and parameters.\n */\nexport function getArea(options) {\n    const { fwhm, height = 1 } = options;\n    if (fwhm === undefined) {\n        throw new Error('should pass fwhm or sd parameters');\n    }\n    return (height * Math.PI * fwhm) / 2;\n}\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage.\n * @param [area=0.9999] Expected area to be covered.\n * @returns\n */\nexport function getFactor(area = 0.9999) {\n    return 2 * Math.tan(Math.PI * (area - 0.5));\n}\n/**\n * Calculate intensity array of a lorentzian shape.\n * @returns {Float64Array} y values\n */\nexport function getData(options = {}) {\n    let { length, factor = getFactor(), fwhm = 500, height } = options;\n    if (!height) {\n        height = 2 / Math.PI / fwhm;\n    }\n    if (!length) {\n        length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n        if (length % 2 === 0)\n            length++;\n    }\n    const center = (length - 1) / 2;\n    const data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n        data[i] = fct(i - center, fwhm) * height;\n        data[length - 1 - i] = data[i];\n    }\n    return data;\n}\n//# sourceMappingURL=Lorentzian.js.map","import { GAUSSIAN_EXP_FACTOR, ROOT_2LN2_MINUS_ONE, ROOT_PI_OVER_LN2, } from '../../../util/constants';\nimport { Shape1D } from '../Shape1D';\nimport { fct as gaussian, getFactor as getFactorGaussian, } from '../gaussian/Gaussian';\nimport { fct as lorentzian, getFactor as getFactorLorentzian, } from '../lorentzian/Lorentzian';\nexport class PseudoVoigt extends Shape1D {\n    constructor(options = {}) {\n        super();\n        const { fwhm = 500, height, mu = 0.5 } = options;\n        this.mu = mu;\n        this.fwhm = fwhm;\n        this.height =\n            height === undefined\n                ? 1 /\n                    ((mu / Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI)) * fwhm +\n                        ((1 - mu) * fwhm * Math.PI) / 2)\n                : height;\n    }\n    fwhmToWidth(fwhm = this.fwhm, mu = this.mu) {\n        return fwhmToWidth(fwhm, mu);\n    }\n    widthToFWHM(width, mu = this.mu) {\n        return widthToFWHM(width, mu);\n    }\n    fct(x) {\n        return fct(x, this.fwhm, this.mu);\n    }\n    getArea() {\n        return getArea({ fwhm: this.fwhm, height: this.height, mu: this.mu });\n    }\n    getFactor(area) {\n        return getFactor(area);\n    }\n    getData(options = {}) {\n        const { length, factor } = options;\n        return getData({\n            fwhm: this.fwhm,\n            height: this.height,\n            mu: this.mu,\n            factor,\n            length,\n        });\n    }\n}\n/**\n * Return a parameterized function of a pseudo voigt shape (see README for equation).\n * @param x - x value to calculate.\n * @param fwhm - full width half maximum\n * @returns - the y value of pseudo voigt with the current parameters.\n */\nexport function fct(x, fwhm, mu) {\n    return (1 - mu) * lorentzian(x, fwhm) + mu * gaussian(x, fwhm);\n}\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n * @param width - Width between the inflection points\n * @param [mu=0.5] Ratio of gaussian contribution in the shape\n * @returns fwhm\n */\nexport function widthToFWHM(width, mu = 0.5) {\n    return width * (mu * ROOT_2LN2_MINUS_ONE + 1);\n}\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * @param fwhm - Full Width at Half Maximum.\n * @param [mu=0.5] Ratio of gaussian contribution in the shape\n * @returns width\n */\nexport function fwhmToWidth(fwhm, mu = 0.5) {\n    return fwhm / (mu * ROOT_2LN2_MINUS_ONE + 1);\n}\n/**\n * Calculate the area of a specific shape.\n * @returns returns the area of the specific shape and parameters.\n */\nexport function getArea(options) {\n    const { fwhm, height = 1, mu = 0.5 } = options;\n    if (fwhm === undefined) {\n        throw new Error('should pass fwhm or sd parameters');\n    }\n    return (fwhm * height * (mu * ROOT_PI_OVER_LN2 + (1 - mu) * Math.PI)) / 2;\n}\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage.\n * @param [area=0.9999] Expected area to be covered.\n * @returns\n */\nexport function getFactor(area = 0.9999, mu = 0.5) {\n    return mu < 1 ? getFactorLorentzian(area) : getFactorGaussian(area);\n}\n/**\n * Calculate intensity array of a pseudo voigt shape.\n * @returns {Float64Array} y values\n */\nexport function getData(options = {}) {\n    let { length, factor = getFactor(), fwhm = 500, height, mu = 0.5 } = options;\n    if (!height) {\n        height =\n            1 /\n                ((mu / Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI)) * fwhm +\n                    ((1 - mu) * fwhm * Math.PI) / 2);\n    }\n    if (!length) {\n        length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n        if (length % 2 === 0)\n            length++;\n    }\n    const center = (length - 1) / 2;\n    const data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n        data[i] = fct(i - center, fwhm, mu) * height;\n        data[length - 1 - i] = data[i];\n    }\n    return data;\n}\n//# sourceMappingURL=PseudoVoigt.js.map","import { Gaussian } from '../shapes/1d/gaussian/Gaussian';\nimport { Lorentzian } from '../shapes/1d/lorentzian/Lorentzian';\nimport { PseudoVoigt } from '../shapes/1d/pseudoVoigt/PseudoVoigt';\n/**\n * Generate a instance of a specific kind of shape.\n */\nexport function getShape1D(kind, shapeOptions = {}) {\n    switch (kind) {\n        case 'gaussian':\n            return new Gaussian(shapeOptions);\n        case 'lorentzian':\n            return new Lorentzian(shapeOptions);\n        case 'pseudoVoigt':\n            return new PseudoVoigt(shapeOptions);\n        default: {\n            const unHandled = kind;\n            // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n            throw Error(`Unknown distribution ${unHandled}`);\n        }\n    }\n}\n//# sourceMappingURL=getShape1D.js.map","/**\n * Apply Savitzky Golay algorithm\n * @param {array} [ys] Array of y values\n * @param {array|number} [xs] Array of X or deltaX\n * @param {object} [options={}]\n * @param {number} [options.windowSize=9]\n * @param {number} [options.derivative=0]\n * @param {number} [options.polynomial=3]\n * @return {array} Array containing the new ys (same length)\n */\n\nexport default function SavitzkyGolay(ys, xs, options = {}) {\n  let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n\n  if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n    throw new RangeError(\n      'Invalid window size (should be odd and at least 5 integer number)',\n    );\n  }\n  if (windowSize > ys.length) {\n    throw new RangeError(\n      `Window size is higher than the data length ${windowSize}>${ys.length}`,\n    );\n  }\n  if (derivative < 0 || !Number.isInteger(derivative)) {\n    throw new RangeError('Derivative should be a positive integer');\n  }\n  if (polynomial < 1 || !Number.isInteger(polynomial)) {\n    throw new RangeError('Polynomial should be a positive integer');\n  }\n  if (polynomial >= 6) {\n    // eslint-disable-next-line no-console\n    console.warn(\n      'You should not use polynomial grade higher than 5 if you are' +\n        ' not sure that your data arises from such a model. Possible polynomial oscillation problems',\n    );\n  }\n\n  let half = Math.floor(windowSize / 2);\n  let np = ys.length;\n  let ans = new Array(np);\n  let weights = fullWeights(windowSize, polynomial, derivative);\n  let hs = 0;\n  let constantH = true;\n  if (Array.isArray(xs)) {\n    constantH = false;\n  } else {\n    hs = Math.pow(xs, derivative);\n  }\n\n  //For the borders\n  for (let i = 0; i < half; i++) {\n    let wg1 = weights[half - i - 1];\n    let wg2 = weights[half + i + 1];\n    let d1 = 0;\n    let d2 = 0;\n    for (let l = 0; l < windowSize; l++) {\n      d1 += wg1[l] * ys[l];\n      d2 += wg2[l] * ys[np - windowSize + l];\n    }\n    if (constantH) {\n      ans[half - i - 1] = d1 / hs;\n      ans[np - half + i] = d2 / hs;\n    } else {\n      hs = getHs(xs, half - i - 1, half, derivative);\n      ans[half - i - 1] = d1 / hs;\n      hs = getHs(xs, np - half + i, half, derivative);\n      ans[np - half + i] = d2 / hs;\n    }\n  }\n\n  //For the internal points\n  let wg = weights[half];\n  for (let i = windowSize; i <= np; i++) {\n    let d = 0;\n    for (let l = 0; l < windowSize; l++) d += wg[l] * ys[l + i - windowSize];\n    if (!constantH) hs = getHs(xs, i - half - 1, half, derivative);\n    ans[i - half - 1] = d / hs;\n  }\n  return ans;\n}\n\nfunction getHs(h, center, half, derivative) {\n  let hs = 0;\n  let count = 0;\n  for (let i = center - half; i < center + half; i++) {\n    if (i >= 0 && i < h.length - 1) {\n      hs += h[i + 1] - h[i];\n      count++;\n    }\n  }\n  return Math.pow(hs / count, derivative);\n}\n\nfunction GramPoly(i, m, k, s) {\n  let Grampoly = 0;\n  if (k > 0) {\n    Grampoly =\n      ((4 * k - 2) / (k * (2 * m - k + 1))) *\n        (i * GramPoly(i, m, k - 1, s) + s * GramPoly(i, m, k - 1, s - 1)) -\n      (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n        GramPoly(i, m, k - 2, s);\n  } else {\n    if (k === 0 && s === 0) {\n      Grampoly = 1;\n    } else {\n      Grampoly = 0;\n    }\n  }\n  return Grampoly;\n}\n\nfunction GenFact(a, b) {\n  let gf = 1;\n  if (a >= b) {\n    for (let j = a - b + 1; j <= a; j++) {\n      gf *= j;\n    }\n  }\n  return gf;\n}\n\nfunction Weight(i, t, m, n, s) {\n  let sum = 0;\n  for (let k = 0; k <= n; k++) {\n    //console.log(k);\n    sum +=\n      (2 * k + 1) *\n      (GenFact(2 * m, k) / GenFact(2 * m + k + 1, k + 1)) *\n      GramPoly(i, m, k, 0) *\n      GramPoly(t, m, k, s);\n  }\n  return sum;\n}\n\n/**\n *\n * @param m  Number of points\n * @param n  Polynomial grade\n * @param s  Derivative\n */\nfunction fullWeights(m, n, s) {\n  let weights = new Array(m);\n  let np = Math.floor(m / 2);\n  for (let t = -np; t <= np; t++) {\n    weights[t + np] = new Array(m);\n    for (let j = -np; j <= np; j++) {\n      weights[t + np][j + np] = Weight(j, t, np, n, s);\n    }\n  }\n  return weights;\n}\n\n/*function entropy(data,h,options){\n    var trend = SavitzkyGolay(data,h,trendOptions);\n    var copy = new Array(data.length);\n    var sum = 0;\n    var max = 0;\n    for(var i=0;i<data.length;i++){\n        copy[i] = data[i]-trend[i];\n    }\n\n    sum/=data.length;\n    console.log(sum+\" \"+max);\n    console.log(stat.array.standardDeviation(copy));\n    console.log(Math.abs(stat.array.mean(copy))/stat.array.standardDeviation(copy));\n    return sum;\n\n}\n\n\n\nfunction guessWindowSize(data, h){\n    console.log(\"entropy \"+entropy(data,h,trendOptions));\n    return 5;\n}\n*/\n","import { getShape1D } from 'ml-peak-shape-generator';\nimport SG from 'ml-savitzky-golay-generalized';\n\n/**\n * Global spectra deconvolution\n * @param {object} data - Object data with x and y arrays\n * @param {Array<number>} [data.x] - Independent variable\n * @param {Array<number>} [data.y] - Dependent variable\n * @param {object} [options={}] - Options object\n * @param {object} [options.shape={}] - Object that specified the kind of shape to calculate the FWHM instead of width between inflection points. see https://mljs.github.io/peak-shape-generator/#inflectionpointswidthtofwhm\n * @param {object} [options.shape.kind='gaussian']\n * @param {object} [options.shape.options={}]\n * @param {object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options\n * @param {number} [options.sgOptions.windowSize = 9] - points to use in the approximations\n * @param {number} [options.sgOptions.polynomial = 3] - degree of the polynomial to use in the approximations\n * @param {number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n * @param {number} [options.noiseLevel = 0] - Noise threshold in spectrum units\n * @param {boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false)\n * @param {boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables\n * @param {boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors\n * to determine the true x,y values of the peak?\n * @param {number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2)\n * @param {number} [options.derivativeThreshold = -1] - Filters based on the amplitude of the first derivative\n * @return {Array<object>}\n */\nexport function gsd(data, options = {}) {\n  let {\n    noiseLevel,\n    sgOptions = {\n      windowSize: 9,\n      polynomial: 3,\n    },\n    shape = {},\n    smoothY = true,\n    heightFactor = 0,\n    broadRatio = 0.0,\n    maxCriteria = true,\n    minMaxRatio = 0.00025,\n    derivativeThreshold = -1,\n    realTopDetection = false,\n  } = options;\n\n  let { y: yIn, x } = data;\n\n  const y = yIn.slice();\n  let equalSpaced = isEqualSpaced(x);\n\n  if (maxCriteria === false) {\n    for (let i = 0; i < y.length; i++) {\n      y[i] *= -1;\n    }\n  }\n\n  if (noiseLevel === undefined) {\n    noiseLevel = equalSpaced ? getNoiseLevel(y) : 0;\n  }\n  for (let i = 0; i < y.length; i++) {\n    y[i] -= noiseLevel;\n  }\n  for (let i = 0; i < y.length; i++) {\n    if (y[i] < 0) {\n      y[i] = 0;\n    }\n  }\n  // If the max difference between delta x is less than 5%, then,\n  // we can assume it to be equally spaced variable\n  let yData = y;\n  let dY, ddY;\n  const { windowSize, polynomial } = sgOptions;\n\n  if (equalSpaced) {\n    if (smoothY) {\n      yData = SG(y, x[1] - x[0], {\n        windowSize,\n        polynomial,\n        derivative: 0,\n      });\n    }\n    dY = SG(y, x[1] - x[0], {\n      windowSize,\n      polynomial,\n      derivative: 1,\n    });\n    ddY = SG(y, x[1] - x[0], {\n      windowSize,\n      polynomial,\n      derivative: 2,\n    });\n  } else {\n    if (smoothY) {\n      yData = SG(y, x, {\n        windowSize,\n        polynomial,\n        derivative: 0,\n      });\n    }\n    dY = SG(y, x, {\n      windowSize,\n      polynomial,\n      derivative: 1,\n    });\n    ddY = SG(y, x, {\n      windowSize,\n      polynomial,\n      derivative: 2,\n    });\n  }\n\n  const xData = x;\n  const dX = x[1] - x[0];\n  let maxDdy = 0;\n  let maxY = 0;\n  for (let i = 0; i < yData.length; i++) {\n    if (Math.abs(ddY[i]) > maxDdy) {\n      maxDdy = Math.abs(ddY[i]);\n    }\n    if (Math.abs(yData[i]) > maxY) {\n      maxY = Math.abs(yData[i]);\n    }\n  }\n\n  let lastMax = null;\n  let lastMin = null;\n  let minddY = [];\n  let intervalL = [];\n  let intervalR = [];\n  let broadMask = [];\n\n  // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n  for (let i = 1; i < yData.length - 1; ++i) {\n    // filter based on derivativeThreshold\n    // console.log('pasa', y[i], dY[i], ddY[i]);\n    if (Math.abs(dY[i]) > derivativeThreshold) {\n      // Minimum in first derivative\n      if (\n        (dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n        (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])\n      ) {\n        lastMin = {\n          x: xData[i],\n          index: i,\n        };\n        if (dX > 0 && lastMax !== null) {\n          intervalL.push(lastMax);\n          intervalR.push(lastMin);\n        }\n      }\n\n      // Maximum in first derivative\n      if (\n        (dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n        (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])\n      ) {\n        lastMax = {\n          x: xData[i],\n          index: i,\n        };\n        if (dX < 0 && lastMin !== null) {\n          intervalL.push(lastMax);\n          intervalR.push(lastMin);\n        }\n      }\n    }\n\n    // Minimum in second derivative\n    if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n      minddY.push(i);\n      broadMask.push(Math.abs(ddY[i]) <= broadRatio * maxDdy);\n    }\n  }\n\n  let widthProcessor = shape.kind\n    ? getShape1D(shape.kind, shape.options).widthToFWHM\n    : (x) => x;\n\n  let signals = [];\n  let lastK = -1;\n  let possible, frequency, distanceJ, minDistance, gettingCloser;\n  for (let j = 0; j < minddY.length; ++j) {\n    frequency = xData[minddY[j]];\n    possible = -1;\n    let k = lastK + 1;\n    minDistance = Number.MAX_VALUE;\n    distanceJ = 0;\n    gettingCloser = true;\n    while (possible === -1 && k < intervalL.length && gettingCloser) {\n      distanceJ = Math.abs(frequency - (intervalL[k].x + intervalR[k].x) / 2);\n\n      // Still getting closer?\n      if (distanceJ < minDistance) {\n        minDistance = distanceJ;\n      } else {\n        gettingCloser = false;\n      }\n      if (distanceJ < Math.abs(intervalL[k].x - intervalR[k].x) / 2) {\n        possible = k;\n        lastK = k;\n      }\n      ++k;\n    }\n\n    if (possible !== -1) {\n      if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {\n        let width = Math.abs(intervalR[possible].x - intervalL[possible].x);\n        signals.push({\n          index: minddY[j],\n          x: frequency,\n          y: maxCriteria\n            ? yData[minddY[j]] + noiseLevel\n            : -yData[minddY[j]] - noiseLevel,\n          width: widthProcessor(width),\n          soft: broadMask[j],\n        });\n\n        signals[signals.length - 1].left = intervalL[possible];\n        signals[signals.length - 1].right = intervalR[possible];\n\n        if (heightFactor) {\n          let yLeft = yData[intervalL[possible].index];\n          let yRight = yData[intervalR[possible].index];\n          signals[signals.length - 1].height =\n            heightFactor *\n            (signals[signals.length - 1].y - (yLeft + yRight) / 2);\n        }\n      }\n    }\n  }\n\n  if (realTopDetection) {\n    determineRealTop(signals, xData, yData);\n  }\n\n  // Correct the values to fit the original spectra data\n  for (let j = 0; j < signals.length; j++) {\n    signals[j].base = noiseLevel;\n  }\n\n  signals.sort(function (a, b) {\n    return a.x - b.x;\n  });\n\n  return signals;\n}\n\nconst isEqualSpaced = (x) => {\n  let tmp;\n  let maxDx = 0;\n  let minDx = Number.MAX_SAFE_INTEGER;\n  for (let i = 0; i < x.length - 1; ++i) {\n    tmp = Math.abs(x[i + 1] - x[i]);\n    if (tmp < minDx) {\n      minDx = tmp;\n    }\n    if (tmp > maxDx) {\n      maxDx = tmp;\n    }\n  }\n  return (maxDx - minDx) / maxDx < 0.05;\n};\n\nconst getNoiseLevel = (y) => {\n  let mean = 0;\n\n  let stddev = 0;\n  let length = y.length;\n  for (let i = 0; i < length; ++i) {\n    mean += y[i];\n  }\n  mean /= length;\n  let averageDeviations = new Array(length);\n  for (let i = 0; i < length; ++i) {\n    averageDeviations[i] = Math.abs(y[i] - mean);\n  }\n  averageDeviations.sort((a, b) => a - b);\n  if (length % 2 === 1) {\n    stddev = averageDeviations[(length - 1) / 2] / 0.6745;\n  } else {\n    stddev =\n      (0.5 *\n        (averageDeviations[length / 2] + averageDeviations[length / 2 - 1])) /\n      0.6745;\n  }\n\n  return stddev;\n};\n\nconst determineRealTop = (peakList, x, y) => {\n  let alpha, beta, gamma, p, currentPoint;\n  for (let j = 0; j < peakList.length; j++) {\n    currentPoint = peakList[j].index; // peakList[j][2];\n    // The detected peak could be moved 1 or 2 units to left or right.\n    if (\n      y[currentPoint - 1] >= y[currentPoint - 2] &&\n      y[currentPoint - 1] >= y[currentPoint]\n    ) {\n      currentPoint--;\n    } else {\n      if (\n        y[currentPoint + 1] >= y[currentPoint] &&\n        y[currentPoint + 1] >= y[currentPoint + 2]\n      ) {\n        currentPoint++;\n      } else {\n        if (\n          y[currentPoint - 2] >= y[currentPoint - 3] &&\n          y[currentPoint - 2] >= y[currentPoint - 1]\n        ) {\n          currentPoint -= 2;\n        } else {\n          if (\n            y[currentPoint + 2] >= y[currentPoint + 1] &&\n            y[currentPoint + 2] >= y[currentPoint + 3]\n          ) {\n            currentPoint += 2;\n          }\n        }\n      }\n    }\n    // interpolation to a sin() function\n    if (\n      y[currentPoint - 1] > 0 &&\n      y[currentPoint + 1] > 0 &&\n      y[currentPoint] >= y[currentPoint - 1] &&\n      y[currentPoint] >= y[currentPoint + 1] &&\n      (y[currentPoint] !== y[currentPoint - 1] ||\n        y[currentPoint] !== y[currentPoint + 1])\n    ) {\n      alpha = 20 * Math.log10(y[currentPoint - 1]);\n      beta = 20 * Math.log10(y[currentPoint]);\n      gamma = 20 * Math.log10(y[currentPoint + 1]);\n      p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n      // console.log(alpha, beta, gamma, `p: ${p}`);\n      // console.log(x[currentPoint]+\" \"+tmp+\" \"+currentPoint);\n      peakList[j].x =\n        x[currentPoint] + (x[currentPoint] - x[currentPoint - 1]) * p;\n      peakList[j].y =\n        y[currentPoint] -\n        0.25 * (y[currentPoint - 1] - y[currentPoint + 1]) * p;\n    }\n  }\n};\n","export const GAUSSIAN_EXP_FACTOR = -4 * Math.LN2;\nexport const ROOT_PI_OVER_LN2 = Math.sqrt(Math.PI / Math.LN2);\nexport const ROOT_THREE = Math.sqrt(3);\nexport const ROOT_2LN2 = Math.sqrt(2 * Math.LN2);\nexport const ROOT_2LN2_MINUS_ONE = Math.sqrt(2 * Math.LN2) - 1;\n","// https://en.wikipedia.org/wiki/Error_function#Inverse_functions\n// This code yields to a good approximation\n\n// If needed a better implementation using polynomial can be found on https://en.wikipedia.org/wiki/Error_function#Inverse_functions\n\nexport default function erfinv(x) {\n  let a = 0.147;\n  if (x === 0) return 0;\n  let ln1MinusXSqrd = Math.log(1 - x * x);\n  let lnEtcBy2Plus2 = ln1MinusXSqrd / 2 + 2 / (Math.PI * a);\n  let firstSqrt = Math.sqrt(lnEtcBy2Plus2 ** 2 - ln1MinusXSqrd / a);\n  let secondSqrt = Math.sqrt(firstSqrt - lnEtcBy2Plus2);\n  return secondSqrt * (x > 0 ? 1 : -1);\n}\n","import {\n  ROOT_2LN2,\n  GAUSSIAN_EXP_FACTOR,\n  ROOT_PI_OVER_LN2,\n} from '../util/constants';\nimport erfinv from '../util/erfinv';\n\nexport class Gaussian {\n  /**\n   * @param {object} [options = {}]\n   * @param {number} [options.height=4*LN2/(PI*FWHM)] Define the height of the peak, by default area=1 (normalized)\n   * @param {number} [options.fwhm = 500] - Full Width at Half Maximum in the number of points in FWHM.\n   * @param {number} [options.sd] - Standard deviation, if it's defined options.fwhm will be ignored and the value will be computed sd * Math.sqrt(8 * Math.LN2);\n   */\n  constructor(options = {}) {\n    this.fwhm = options.sd\n      ? Gaussian.widthToFWHM(2 * options.sd)\n      : options.fwhm\n      ? options.fwhm\n      : 500;\n    this.height =\n      options.height === undefined\n        ? Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI) / this.fwhm\n        : options.height;\n  }\n  /**\n   * Calculate a gaussian shape\n   * @param {object} [options = {}]\n   * @param {number} [options.factor = 6] - Number of time to take fwhm to calculate length. Default covers 99.99 % of area.\n   * @param {number} [options.length = fwhm * factor + 1] - total number of points to calculate\n   * @return {Float64Array} y values\n   */\n\n  getData(options = {}) {\n    let { length, factor = this.getFactor() } = options;\n\n    if (!length) {\n      length = Math.min(Math.ceil(this.fwhm * factor), Math.pow(2, 25) - 1);\n      if (length % 2 === 0) length++;\n    }\n\n    const center = (length - 1) / 2;\n    const data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n      data[i] = this.fct(i - center) * this.height;\n      data[length - 1 - i] = data[i];\n    }\n\n    return data;\n  }\n\n  /**\n   * Return a parameterized function of a gaussian shape (see README for equation).\n   * @param {number} x - x value to calculate.\n   * @returns {number} - the y value of gaussian with the current parameters.\n   */\n  fct(x) {\n    return Gaussian.fct(x, this.fwhm);\n  }\n\n  /**\n   * Calculate the number of times FWHM allows to reach a specific area coverage\n   * @param {number} [area=0.9999]\n   * @returns {number}\n   */\n  getFactor(area = 0.9999) {\n    return Gaussian.getFactor(area);\n  }\n\n  /**\n   * Calculate the area of the shape.\n   * @returns {number} - returns the area.\n   */\n\n  getArea() {\n    return Gaussian.getArea(this.fwhm, { height: this.height });\n  }\n\n  /**\n   * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n   * //https://mathworld.wolfram.com/GaussianFunction.html\n   * @param {number} width - Width between the inflection points\n   * @returns {number} fwhm\n   */\n  widthToFWHM(width) {\n    //https://mathworld.wolfram.com/GaussianFunction.html\n    return Gaussian.widthToFWHM(width);\n  }\n\n  /**\n   * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n   * //https://mathworld.wolfram.com/GaussianFunction.html\n   * @param {number} fwhm - Full Width at Half Maximum.\n   * @returns {number} width\n   */\n  fwhmToWidth(fwhm = this.fwhm) {\n    return Gaussian.fwhmToWidth(fwhm);\n  }\n\n  /**\n   * set a new full width at half maximum\n   * @param {number} fwhm - full width at half maximum\n   */\n  setFWHM(fwhm) {\n    this.fwhm = fwhm;\n  }\n\n  /**\n   * set a new height\n   * @param {number} height - The maximal intensity of the shape.\n   */\n  setHeight(height) {\n    this.height = height;\n  }\n}\n\n/**\n * Return a parameterized function of a gaussian shape (see README for equation).\n * @param {number} x - x value to calculate.\n * @param {number} fwhm - full width half maximum\n * @returns {number} - the y value of gaussian with the current parameters.\n */\nGaussian.fct = function fct(x, fwhm = 500) {\n  return Math.exp(GAUSSIAN_EXP_FACTOR * Math.pow(x / fwhm, 2));\n};\n\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n * //https://mathworld.wolfram.com/GaussianFunction.html\n * @param {number} width - Width between the inflection points\n * @returns {number} fwhm\n */\nGaussian.widthToFWHM = function widthToFWHM(width) {\n  return width * ROOT_2LN2;\n};\n\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * //https://mathworld.wolfram.com/GaussianFunction.html\n * @param {number} fwhm - Full Width at Half Maximum.\n * @returns {number} width\n */\nGaussian.fwhmToWidth = function fwhmToWidth(fwhm) {\n  return fwhm / ROOT_2LN2;\n};\n\n/**\n * Calculate the area of a specific shape.\n * @param {number} fwhm - Full width at half maximum.\n * @param {object} [options = {}] - options.\n * @param {number} [options.height = 1] - Maximum y value of the shape.\n * @returns {number} - returns the area of the specific shape and parameters.\n */\n\nGaussian.getArea = function getArea(fwhm, options = {}) {\n  let { height = 1 } = options;\n  return (height * ROOT_PI_OVER_LN2 * fwhm) / 2;\n};\n\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage.\n * @param {number} [area=0.9999]\n * @returns {number}\n */\nGaussian.getFactor = function getFactor(area = 0.9999) {\n  return Math.sqrt(2) * erfinv(area);\n};\n","import { ROOT_THREE } from '../util/constants';\n\nexport class Lorentzian {\n  /**\n   * @param {object} [options = {}]\n   * @param {number} [options.height=2/(PI*FWHM)] Define the height of the peak, by default area=1 (normalized)\n   * @param {number} [options.fwhm = 500] - Full Width at Half Maximum in the number of points in FWHM.\n   * @param {number} [options.sd] - Standard deviation, if it's defined options.fwhm will be ignored and the value will be computed sd * Math.sqrt(8 * Math.LN2);\n   */\n  constructor(options = {}) {\n    this.fwhm = options.fwhm === undefined ? 500 : options.fwhm;\n    this.height =\n      options.height === undefined ? 2 / Math.PI / this.fwhm : options.height;\n  }\n  /**\n   * Calculate a lorentzian shape\n   * @param {object} [options = {}]\n   * @param {number} [options.factor = Math.tan(Math.PI * (0.9999 - 0.5))] - Number of time to take fwhm to calculate length. Default covers 99.99 % of area.\n   * @param {number} [options.length = fwhm * factor + 1] - total number of points to calculate\n   * @return {Float64Array} y values\n   */\n  getData(options = {}) {\n    let { length, factor = this.getFactor() } = options;\n\n    if (!length) {\n      length = Math.min(Math.ceil(this.fwhm * factor), Math.pow(2, 25) - 1);\n      if (length % 2 === 0) length++;\n    }\n\n    const center = (length - 1) / 2;\n    const data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n      data[i] = this.fct(i - center) * this.height;\n      data[length - 1 - i] = data[i];\n    }\n    return data;\n  }\n\n  /**\n   * Return a parameterized function of a lorentzian shape (see README for equation).\n   * @param {number} x - x value to calculate.\n   * @returns {number} - the y value of lorentzian with the current parameters.\n   */\n  fct(x) {\n    return Lorentzian.fct(x, this.fwhm);\n  }\n\n  /**\n   * Calculate the number of times FWHM allows to reach a specific area coverage\n   * @param {number} [area=0.9999]\n   * @returns {number}\n   */\n  getFactor(area = 0.9999) {\n    return Lorentzian.getFactor(area);\n  }\n\n  /**\n   * Calculate the area of the shape.\n   * @returns {number} - returns the area.\n   */\n\n  getArea() {\n    return Lorentzian.getArea(this.fwhm, { height: this.height });\n  }\n\n  /**\n   * Compute the value of width between the inflection points of a specific shape from Full Width at Half Maximum (FWHM).\n   * //https://mathworld.wolfram.com/LorentzianFunction.html\n   * @param {number} [fwhm] - Full Width at Half Maximum.\n   * @returns {number} width between the inflection points\n   */\n  fwhmToWidth(fwhm = this.fwhm) {\n    return Lorentzian.fwhmToWidth(fwhm);\n  }\n\n  /**\n   * Compute the value of Full Width at Half Maximum (FWHM) of a specific shape from the width between the inflection points.\n   * //https://mathworld.wolfram.com/LorentzianFunction.html\n   * @param {number} [width] Width between the inflection points\n   * @returns {number} fwhm\n   */\n  widthToFWHM(width) {\n    return Lorentzian.widthToFWHM(width);\n  }\n  /**\n   * set a new full width at half maximum\n   * @param {number} fwhm - full width at half maximum\n   */\n  setFWHM(fwhm) {\n    this.fwhm = fwhm;\n  }\n\n  /**\n   * set a new height\n   * @param {number} height - The maximal intensity of the shape.\n   */\n  setHeight(height) {\n    this.height = height;\n  }\n}\n\n/**\n * Return a parameterized function of a gaussian shape (see README for equation).\n * @param {number} x - x value to calculate.\n * @param {number} fwhm - full width half maximum\n * @returns {number} - the y value of gaussian with the current parameters.\n */\nLorentzian.fct = function fct(x, fwhm) {\n  const squareFWHM = fwhm * fwhm;\n  return squareFWHM / (4 * Math.pow(x, 2) + squareFWHM);\n};\n\n/**\n * Compute the value of width between the inflection points of a specific shape from Full Width at Half Maximum (FWHM).\n * //https://mathworld.wolfram.com/LorentzianFunction.html\n * @param {number} [fwhm] - Full Width at Half Maximum.\n * @returns {number} width between the inflection points\n */\nLorentzian.fwhmToWidth = function fwhmToWidth(fwhm) {\n  return fwhm / ROOT_THREE;\n};\n\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) of a specific shape from the width between the inflection points.\n * //https://mathworld.wolfram.com/LorentzianFunction.html\n * @param {number} [width] Width between the inflection points\n * @returns {number} fwhm\n */\nLorentzian.widthToFWHM = function widthToFWHM(width) {\n  return width * ROOT_THREE;\n};\n\n/**\n * Calculate the area of a specific shape.\n * @param {number} fwhm - Full width at half maximum.\n * @param {*} [options = {}] - options.\n * @param {number} [options.height = 1] - Maximum y value of the shape.\n * @returns {number} - returns the area of the specific shape and parameters.\n */\nLorentzian.getArea = function getArea(fwhm, options = {}) {\n  let { height = 1 } = options;\n\n  return (height * Math.PI * fwhm) / 2;\n};\n\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage\n * @param {number} [area=0.9999]\n * @returns {number}\n */\nLorentzian.getFactor = function getFactor(area = 0.9999) {\n  return 2 * Math.tan(Math.PI * (area - 0.5));\n};\n","import {\n  GAUSSIAN_EXP_FACTOR,\n  ROOT_2LN2_MINUS_ONE,\n  ROOT_PI_OVER_LN2,\n} from '../util/constants';\n\nimport { Gaussian } from './Gaussian';\nimport { Lorentzian } from './Lorentzian';\n\nexport class PseudoVoigt {\n  /**\n   * @param {object} [options={}]\n   * @param {number} [options.height=1/(mu*FWHM/sqrt(4*LN2/PI)+(1-mu)*fwhm*PI*0.5)] Define the height of the peak, by default area=1 (normalized)\n   * @param {number} [options.fwhm=500] - Full Width at Half Maximum in the number of points in FWHM.\n   * @param {number} [options.mu=0.5] - ratio of gaussian contribution.\n   */\n\n  constructor(options = {}) {\n    this.mu = options.mu === undefined ? 0.5 : options.mu;\n    this.fwhm = options.fwhm === undefined ? 500 : options.fwhm;\n    this.height =\n      options.height === undefined\n        ? 1 /\n          ((this.mu / Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI)) * this.fwhm +\n            ((1 - this.mu) * this.fwhm * Math.PI) / 2)\n        : options.height;\n  }\n\n  /**\n   * Calculate a linear combination of gaussian and lorentzian function width an same full width at half maximum\n   * @param { object } [options = {}]\n   * @param { number } [options.factor = 2 * Math.tan(Math.PI * (0.9999 - 0.5))] - Number of time to take fwhm in the calculation of the length.Default covers 99.99 % of area.\n   * @param { number } [options.length = fwhm * factor + 1] - total number of points to calculate\n   * @return { object } - { fwhm, data<Float64Array>} - An with the number of points at half maximum and the array of y values covering the 99.99 % of the area.\n   */\n\n  getData(options = {}) {\n    let { length, factor = this.getFactor() } = options;\n    if (!length) {\n      length = Math.ceil(this.fwhm * factor);\n      if (length % 2 === 0) length++;\n    }\n\n    const center = (length - 1) / 2;\n\n    let data = new Float64Array(length);\n    for (let i = 0; i <= center; i++) {\n      data[i] = this.fct(i - center) * this.height;\n      data[length - 1 - i] = data[i];\n    }\n\n    return data;\n  }\n\n  /**\n   * Return a parameterized function of a linear combination of Gaussian and Lorentzian shapes where the full width at half maximum are the same for both kind of shapes (see README for equation).\n   * @param {number} [x] x value to calculate.\n   * @returns {number} - the y value of a pseudo voigt with the current parameters.\n   */\n\n  fct(x) {\n    return PseudoVoigt.fct(x, this.fwhm, this.mu);\n  }\n\n  /**\n   * Calculate the number of times FWHM allows to reach a specific area coverage\n   * @param {number} [area=0.9999] - required area to be coverage\n   * @param {number} [mu=this.mu] - ratio of gaussian contribution.\n   * @returns {number}\n   */\n  getFactor(area = 0.9999, mu = this.mu) {\n    return PseudoVoigt.getFactor(area, mu);\n  }\n\n  /**\n   * Calculate the area of the shape.\n   * @returns {number} - returns the area.\n   */\n  getArea() {\n    return PseudoVoigt.getArea(this.fwhm, { height: this.height, mu: this.mu });\n  }\n\n  /**\n   * Compute the value of Full Width at Half Maximum (FMHM) from width between the inflection points.\n   * @param {number} width - width between the inflection points\n   * @param {number} [mu = 0.5] - ratio of gaussian contribution.\n   * @returns {number} Full Width at Half Maximum (FMHM).\n   */\n  widthToFWHM(width, mu) {\n    return PseudoVoigt.widthToFWHM(width, mu);\n  }\n  /**\n   * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n   * @param {number} fwhm - Full Width at Half Maximum.\n   * @param {number} [mu] - ratio of gaussian contribution.\n   * @returns {number} width between the inflection points.\n   */\n  fwhmToWidth(fwhm = this.fwhm, mu = this.mu) {\n    return PseudoVoigt.fwhmToWidth(fwhm, mu);\n  }\n\n  /**\n   * set a new full width at half maximum\n   * @param {number} fwhm - full width at half maximum\n   */\n  setFWHM(fwhm) {\n    this.fwhm = fwhm;\n  }\n\n  /**\n   * set a new height\n   * @param {number} height - The maximal intensity of the shape.\n   */\n  setHeight(height) {\n    this.height = height;\n  }\n\n  /**\n   * set a new mu\n   * @param {number} mu - ratio of gaussian contribution.\n   */\n  setMu(mu) {\n    this.mu = mu;\n  }\n}\n\n/**\n * Return a parameterized function of a gaussian shape (see README for equation).\n * @param {number} x - x value to calculate.\n * @param {number} fwhm - full width half maximum\n * @param {number} [mu=0.5] - ratio of gaussian contribution.\n * @returns {number} - the y value of gaussian with the current parameters.\n */\nPseudoVoigt.fct = function fct(x, fwhm, mu = 0.5) {\n  return (1 - mu) * Lorentzian.fct(x, fwhm) + mu * Gaussian.fct(x, fwhm);\n};\n\n/**\n * Compute the value of Full Width at Half Maximum (FMHM) from width between the inflection points.\n * @param {number} width - width between the inflection points\n * @param {number} [mu = 0.5] - ratio of gaussian contribution.\n * @returns {number} Full Width at Half Maximum (FMHM).\n */\nPseudoVoigt.widthToFWHM = function widthToFWHM(width, mu = 0.5) {\n  return width * (mu * ROOT_2LN2_MINUS_ONE + 1);\n};\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * @param {number} fwhm - Full Width at Half Maximum.\n * @param {number} [mu = 0.5] - ratio of gaussian contribution.\n * @returns {number} width between the inflection points.\n */\nPseudoVoigt.fwhmToWidth = function fwhmToWidth(fwhm, mu = 0.5) {\n  return fwhm / (mu * ROOT_2LN2_MINUS_ONE + 1);\n};\n\n/**\n * Calculate the area of a specific shape.\n * @param {number} fwhm - Full width at half maximum.\n * @param {*} [options = {}] - options.\n * @param {number} [options.height = 1] - Maximum y value of the shape.\n * @param {number} [options.mu = 0.5] - ratio of gaussian contribution.\n * @returns {number} - returns the area of the specific shape and parameters.\n */\nPseudoVoigt.getArea = function getArea(fwhm, options = {}) {\n  let { height = 1, mu = 0.5 } = options;\n  return (fwhm * height * (mu * ROOT_PI_OVER_LN2 + (1 - mu) * Math.PI)) / 2;\n};\n\n/**\n * Calculate the number of times FWHM allows to reach a specific area coverage\n * @param {number} [area=0.9999] - required area to be coverage\n * @param {number} [mu=this.mu] - ratio of gaussian contribution.\n * @returns {number}\n */\nPseudoVoigt.getFactor = function getFactor(area = 0.9999, mu = 0.5) {\n  return mu < 1 ? Lorentzian.getFactor(area) : Gaussian.getFactor(area);\n};\n","import { ROOT_2LN2, GAUSSIAN_EXP_FACTOR } from '../util/constants';\nimport erfinv from '../util/erfinv';\n\nlet axis = ['x', 'y'];\n\nexport class Gaussian2D {\n  /**\n   * @param {object} [options = {}]\n   * @param {number} [options.height=4*LN2/(PI*xFWHM*yFWHM)] Define the height of the peak, by default area=1 (normalized).\n   * @param {number} [options.fwhm = 500] - Full Width at Half Maximum in the number of points in FWHM used if x or y has not the fwhm property.\n   * @param {object} [options.x] - Options for x axis.\n   * @param {number} [options.x.fwhm = fwhm] - Full Width at Half Maximum in the number of points in FWHM for x axis.\n   * @param {number} [options.x.sd] - Standard deviation for x axis, if it's defined options.x.fwhm will be ignored and the value will be computed sd * Math.sqrt(8 * Math.LN2);\n   * @param {object} [options.y] - Options for y axis.\n   * @param {number} [options.y.fwhm = fwhm] - Full Width at Half Maximum in the number of points in FWHM for y axis.\n   * @param {number} [options.y.sd] - Standard deviation for y axis, if it's defined options.y.fwhm will be ignored and the value will be computed sd * Math.sqrt(8 * Math.LN2);\n   */\n  constructor(options = {}) {\n    let { fwhm: globalFWHM = 500 } = options;\n\n    for (let i of axis) {\n      let fwhm;\n      if (!options[i]) {\n        fwhm = globalFWHM;\n      } else {\n        fwhm = options[i].sd\n          ? Gaussian2D.widthToFWHM(2 * options[i].sd)\n          : options[i].fwhm || globalFWHM;\n      }\n      this[i] = { fwhm };\n    }\n\n    this.height =\n      options.height === undefined\n        ? -GAUSSIAN_EXP_FACTOR / Math.PI / this.x.fwhm / this.y.fwhm\n        : options.height;\n  }\n  /**\n   * Calculate a Gaussian2D shape\n   * @param {object} [options = {}]\n   * @param {number} [options.factor] - Number of time to take fwhm to calculate length. Default covers 99.99 % of area.\n   * @param {object} [options.x] - parameter for x axis.\n   * @param {number} [options.x.length=fwhm*factor+1] - length on x axis.\n   * @param {number} [options.x.factor=factor] - Number of time to take fwhm to calculate length. Default covers 99.99 % of area.\n   * @param {object} [options.y] - parameter for y axis.\n   * @param {number} [options.y.length=fwhm*factor+1] - length on y axis.\n   * @param {number} [options.y.factor=factor] - Number of time to take fwhm to calculate length. Default covers 99.99 % of area.\n   * @return {Array<Float64Array>} - z values.\n   */\n\n  getData(options = {}) {\n    let { x = {}, y = {}, factor = this.getFactor(), length } = options;\n\n    let xLength = x.length || length;\n    if (!xLength) {\n      let { factor: xFactor = factor } = x;\n      xLength = Math.min(Math.ceil(this.x.fwhm * xFactor), Math.pow(2, 25) - 1);\n      if (xLength % 2 === 0) xLength++;\n    }\n\n    let yLength = y.length || length;\n    if (!yLength) {\n      let { factor: yFactor = factor } = y;\n      yLength = Math.min(Math.ceil(this.y.fwhm * yFactor), Math.pow(2, 25) - 1);\n      if (yLength % 2 === 0) yLength++;\n    }\n\n    const xCenter = (xLength - 1) / 2;\n    const yCenter = (yLength - 1) / 2;\n    const data = new Array(xLength);\n    for (let i = 0; i < xLength; i++) {\n      data[i] = new Array(yLength);\n    }\n\n    for (let i = 0; i < xLength; i++) {\n      for (let j = 0; j < yLength; j++) {\n        data[i][j] = this.fct(i - xCenter, j - yCenter) * this.height;\n      }\n    }\n\n    return data;\n  }\n\n  /**\n   * Return the intensity value of a 2D gaussian shape (see README for equation).\n   * @param {number} x - x value to calculate.\n   * @param {number} y - y value to calculate.\n   * @returns {number} - the z value of bi-dimensional gaussian with the current parameters.\n   */\n  fct(x, y) {\n    return Gaussian2D.fct(x, y, this.x.fwhm, this.y.fwhm);\n  }\n\n  /**\n   * Calculate the number of times FWHM allows to reach a specific volume coverage.\n   * @param {number} [volume=0.9999]\n   * @returns {number}\n   */\n  getFactor(volume = 0.9999) {\n    return Gaussian2D.getFactor(volume);\n  }\n\n  /**\n   * Calculate the volume of the shape.\n   * @returns {number} - returns the volume.\n   */\n\n  getVolume() {\n    return Gaussian2D.getVolume(this.x.fwhm, this.y.fwhm, {\n      height: this.height,\n    });\n  }\n\n  /**\n   * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n   * //https://mathworld.wolfram.com/Gaussian2DFunction.html\n   * @param {number} width - Width between the inflection points\n   * @returns {number} fwhm\n   */\n  widthToFWHM(width) {\n    //https://mathworld.wolfram.com/Gaussian2DFunction.html\n    return Gaussian2D.widthToFWHM(width);\n  }\n\n  /**\n   * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n   * //https://mathworld.wolfram.com/Gaussian2DFunction.html\n   * @param {number} fwhm - Full Width at Half Maximum.\n   * @returns {number} width\n   */\n  fwhmToWidth(fwhm = this.x.fwhm) {\n    return Gaussian2D.fwhmToWidth(fwhm);\n  }\n\n  /**\n   * set a new full width at half maximum\n   * @param {number} fwhm - full width at half maximum\n   * @param {string|Array<string>} axisLabel - label of axis, if it is undefined fwhm is set to both axis.\n   */\n  setFWHM(fwhm, axisLabel) {\n    if (!axisLabel) axisLabel = axis;\n    if (!Array.isArray(axisLabel)) axisLabel = [axisLabel];\n    for (let i of axisLabel) {\n      let axisName = i.toLowerCase();\n      if (axisName !== 'y' && axisName !== 'x') {\n        throw new Error('axis label should be x or y');\n      }\n      this[axisName].fwhm = fwhm;\n    }\n  }\n\n  /**\n   * set a new height\n   * @param {number} height - The maximal intensity of the shape.\n   */\n  setHeight(height) {\n    this.height = height;\n  }\n}\n\n/**\n * Return a parameterized function of a Gaussian2D shape (see README for equation).\n * @param {number} x - x value to calculate.\n * @param {number} y - y value to calculate.\n * @param {number} fwhmX - full width half maximum in the x axis.\n * @param {number} fwhmY - full width half maximum in the y axis.\n * @returns {number} - the z value of bi-dimensional gaussian with the current parameters.\n */\nGaussian2D.fct = function fct(x, y, xFWHM = 500, yFWHM = 500) {\n  return Math.exp(\n    GAUSSIAN_EXP_FACTOR * (Math.pow(x / xFWHM, 2) + Math.pow(y / yFWHM, 2)),\n  );\n};\n\n/**\n * Compute the value of Full Width at Half Maximum (FWHM) from the width between the inflection points.\n * //https://mathworld.wolfram.com/Gaussian2DFunction.html\n * @param {number} width - Width between the inflection points\n * @returns {number} fwhm\n */\nGaussian2D.widthToFWHM = function widthToFWHM(width) {\n  return width * ROOT_2LN2;\n};\n\n/**\n * Compute the value of width between the inflection points from Full Width at Half Maximum (FWHM).\n * //https://mathworld.wolfram.com/Gaussian2DFunction.html\n * @param {number} fwhm - Full Width at Half Maximum.\n * @returns {number} width\n */\nGaussian2D.fwhmToWidth = function fwhmToWidth(fwhm) {\n  return fwhm / ROOT_2LN2;\n};\n\n/**\n * Calculate the volume of a specific shape.\n * @param {number} xFWHM - Full width at half maximum for x axis.\n * @param {number} yFWHM - Full width at half maximum for y axis.\n * @param {object} [options = {}] - options.\n * @param {number} [options.height = 1] - Maximum z value of the shape.\n * @returns {number} - returns the area of the specific shape and parameters.\n */\n\nGaussian2D.getVolume = function getVolume(xFWHM, yFWHM, options = {}) {\n  let { height = 1 } = options;\n  return (height * Math.PI * xFWHM * yFWHM) / Math.LN2 / 4;\n};\n\n/**@TODO look for a better factor\n * Calculate the number of times FWHM allows to reach a specific volume coverage.\n * @param {number} [volume=0.9999]\n * @returns {number}\n */\nGaussian2D.getFactor = function getFactor(volume = 0.9999) {\n  return Math.sqrt(2) * erfinv(volume);\n};\n","import { Gaussian } from '../classes/Gaussian';\nimport { Gaussian2D } from '../classes/Gaussian2D';\nimport { Lorentzian } from '../classes/Lorentzian';\nimport { PseudoVoigt } from '../classes/PseudoVoigt';\n\nexport function getShapeGenerator(options) {\n  let { kind = 'Gaussian', options: shapeOptions } = options;\n  switch (kind.toLowerCase().replace(/[^a-z^0-9]/g, '')) {\n    case 'gaussian':\n      return new Gaussian(shapeOptions);\n    case 'lorentzian':\n      return new Lorentzian(shapeOptions);\n    case 'pseudovoigt':\n      return new PseudoVoigt(shapeOptions);\n    case 'gaussian2d':\n      return new Gaussian2D(shapeOptions);\n    default:\n      throw new Error(`Unknown kind: ${kind}`);\n  }\n}\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport min from 'ml-array-min';\n\nfunction rescale(input) {\n  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  } else if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n\n  var output;\n\n  if (options.output !== undefined) {\n    if (!isArray(options.output)) {\n      throw new TypeError('output option must be an array if specified');\n    }\n\n    output = options.output;\n  } else {\n    output = new Array(input.length);\n  }\n\n  var currentMin = min(input);\n  var currentMax = max(input);\n\n  if (currentMin === currentMax) {\n    throw new RangeError('minimum and maximum input values are equal. Cannot rescale a constant array');\n  }\n\n  var _options$min = options.min,\n      minValue = _options$min === void 0 ? options.autoMinMax ? currentMin : 0 : _options$min,\n      _options$max = options.max,\n      maxValue = _options$max === void 0 ? options.autoMinMax ? currentMax : 1 : _options$max;\n\n  if (minValue >= maxValue) {\n    throw new RangeError('min option must be smaller than max option');\n  }\n\n  var factor = (maxValue - minValue) / (currentMax - currentMin);\n\n  for (var i = 0; i < input.length; i++) {\n    output[i] = (input[i] - currentMin) * factor + minValue;\n  }\n\n  return output;\n}\n\nexport { rescale as default };\n","const indent = ' '.repeat(2);\nconst indentData = ' '.repeat(4);\n\nexport function inspectMatrix() {\n  return inspectMatrixWithOptions(this);\n}\n\nexport function inspectMatrixWithOptions(matrix, options = {}) {\n  const { maxRows = 15, maxColumns = 10, maxNumSize = 8 } = options;\n  return `${matrix.constructor.name} {\n${indent}[\n${indentData}${inspectData(matrix, maxRows, maxColumns, maxNumSize)}\n${indent}]\n${indent}rows: ${matrix.rows}\n${indent}columns: ${matrix.columns}\n}`;\n}\n\nfunction inspectData(matrix, maxRows, maxColumns, maxNumSize) {\n  const { rows, columns } = matrix;\n  const maxI = Math.min(rows, maxRows);\n  const maxJ = Math.min(columns, maxColumns);\n  const result = [];\n  for (let i = 0; i < maxI; i++) {\n    let line = [];\n    for (let j = 0; j < maxJ; j++) {\n      line.push(formatNumber(matrix.get(i, j), maxNumSize));\n    }\n    result.push(`${line.join(' ')}`);\n  }\n  if (maxJ !== columns) {\n    result[result.length - 1] += ` ... ${columns - maxColumns} more columns`;\n  }\n  if (maxI !== rows) {\n    result.push(`... ${rows - maxRows} more rows`);\n  }\n  return result.join(`\\n${indentData}`);\n}\n\nfunction formatNumber(num, maxNumSize) {\n  const numStr = String(num);\n  if (numStr.length <= maxNumSize) {\n    return numStr.padEnd(maxNumSize, ' ');\n  }\n  const precise = num.toPrecision(maxNumSize - 2);\n  if (precise.length <= maxNumSize) {\n    return precise;\n  }\n  const exponential = num.toExponential(maxNumSize - 2);\n  const eIndex = exponential.indexOf('e');\n  const e = exponential.slice(eIndex);\n  return exponential.slice(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\n  AbstractMatrix.prototype.add = function add(value) {\n    if (typeof value === 'number') return this.addS(value);\n    return this.addM(value);\n  };\n\n  AbstractMatrix.prototype.addS = function addS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) + value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.addM = function addM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) + matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.add = function add(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.add(value);\n  };\n\n  AbstractMatrix.prototype.sub = function sub(value) {\n    if (typeof value === 'number') return this.subS(value);\n    return this.subM(value);\n  };\n\n  AbstractMatrix.prototype.subS = function subS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) - value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.subM = function subM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) - matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.sub = function sub(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.sub(value);\n  };\n  AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\n  AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\n  AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\n  AbstractMatrix.subtract = AbstractMatrix.sub;\n\n  AbstractMatrix.prototype.mul = function mul(value) {\n    if (typeof value === 'number') return this.mulS(value);\n    return this.mulM(value);\n  };\n\n  AbstractMatrix.prototype.mulS = function mulS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) * value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.mulM = function mulM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) * matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.mul = function mul(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.mul(value);\n  };\n  AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\n  AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\n  AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\n  AbstractMatrix.multiply = AbstractMatrix.mul;\n\n  AbstractMatrix.prototype.div = function div(value) {\n    if (typeof value === 'number') return this.divS(value);\n    return this.divM(value);\n  };\n\n  AbstractMatrix.prototype.divS = function divS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) / value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.divM = function divM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) / matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.div = function div(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.div(value);\n  };\n  AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\n  AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\n  AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\n  AbstractMatrix.divide = AbstractMatrix.div;\n\n  AbstractMatrix.prototype.mod = function mod(value) {\n    if (typeof value === 'number') return this.modS(value);\n    return this.modM(value);\n  };\n\n  AbstractMatrix.prototype.modS = function modS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) % value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.modM = function modM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) % matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.mod = function mod(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.mod(value);\n  };\n  AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\n  AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\n  AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\n  AbstractMatrix.modulus = AbstractMatrix.mod;\n\n  AbstractMatrix.prototype.and = function and(value) {\n    if (typeof value === 'number') return this.andS(value);\n    return this.andM(value);\n  };\n\n  AbstractMatrix.prototype.andS = function andS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) & value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.andM = function andM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) & matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.and = function and(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.and(value);\n  };\n\n  AbstractMatrix.prototype.or = function or(value) {\n    if (typeof value === 'number') return this.orS(value);\n    return this.orM(value);\n  };\n\n  AbstractMatrix.prototype.orS = function orS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) | value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.orM = function orM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) | matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.or = function or(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.or(value);\n  };\n\n  AbstractMatrix.prototype.xor = function xor(value) {\n    if (typeof value === 'number') return this.xorS(value);\n    return this.xorM(value);\n  };\n\n  AbstractMatrix.prototype.xorS = function xorS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) ^ value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.xorM = function xorM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) ^ matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.xor = function xor(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.xor(value);\n  };\n\n  AbstractMatrix.prototype.leftShift = function leftShift(value) {\n    if (typeof value === 'number') return this.leftShiftS(value);\n    return this.leftShiftM(value);\n  };\n\n  AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) << value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) << matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.leftShift = function leftShift(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.leftShift(value);\n  };\n\n  AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\n    if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\n    return this.signPropagatingRightShiftM(value);\n  };\n\n  AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) >> value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) >> matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.signPropagatingRightShift(value);\n  };\n\n  AbstractMatrix.prototype.rightShift = function rightShift(value) {\n    if (typeof value === 'number') return this.rightShiftS(value);\n    return this.rightShiftM(value);\n  };\n\n  AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) >>> value);\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) >>> matrix.get(i, j));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.rightShift = function rightShift(matrix, value) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.rightShift(value);\n  };\n  AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\n  AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\n  AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\n  AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\n\n  AbstractMatrix.prototype.not = function not() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, ~(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.not = function not(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.not();\n  };\n\n  AbstractMatrix.prototype.abs = function abs() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.abs(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.abs = function abs(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.abs();\n  };\n\n  AbstractMatrix.prototype.acos = function acos() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.acos(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.acos = function acos(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.acos();\n  };\n\n  AbstractMatrix.prototype.acosh = function acosh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.acosh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.acosh = function acosh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.acosh();\n  };\n\n  AbstractMatrix.prototype.asin = function asin() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.asin(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.asin = function asin(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.asin();\n  };\n\n  AbstractMatrix.prototype.asinh = function asinh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.asinh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.asinh = function asinh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.asinh();\n  };\n\n  AbstractMatrix.prototype.atan = function atan() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.atan(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.atan = function atan(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.atan();\n  };\n\n  AbstractMatrix.prototype.atanh = function atanh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.atanh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.atanh = function atanh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.atanh();\n  };\n\n  AbstractMatrix.prototype.cbrt = function cbrt() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.cbrt(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.cbrt = function cbrt(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.cbrt();\n  };\n\n  AbstractMatrix.prototype.ceil = function ceil() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.ceil(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.ceil = function ceil(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.ceil();\n  };\n\n  AbstractMatrix.prototype.clz32 = function clz32() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.clz32(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.clz32 = function clz32(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.clz32();\n  };\n\n  AbstractMatrix.prototype.cos = function cos() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.cos(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.cos = function cos(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.cos();\n  };\n\n  AbstractMatrix.prototype.cosh = function cosh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.cosh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.cosh = function cosh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.cosh();\n  };\n\n  AbstractMatrix.prototype.exp = function exp() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.exp(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.exp = function exp(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.exp();\n  };\n\n  AbstractMatrix.prototype.expm1 = function expm1() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.expm1(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.expm1 = function expm1(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.expm1();\n  };\n\n  AbstractMatrix.prototype.floor = function floor() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.floor(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.floor = function floor(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.floor();\n  };\n\n  AbstractMatrix.prototype.fround = function fround() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.fround(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.fround = function fround(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.fround();\n  };\n\n  AbstractMatrix.prototype.log = function log() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.log(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.log = function log(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.log();\n  };\n\n  AbstractMatrix.prototype.log1p = function log1p() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.log1p(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.log1p = function log1p(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.log1p();\n  };\n\n  AbstractMatrix.prototype.log10 = function log10() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.log10(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.log10 = function log10(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.log10();\n  };\n\n  AbstractMatrix.prototype.log2 = function log2() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.log2(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.log2 = function log2(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.log2();\n  };\n\n  AbstractMatrix.prototype.round = function round() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.round(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.round = function round(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.round();\n  };\n\n  AbstractMatrix.prototype.sign = function sign() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.sign(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.sign = function sign(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.sign();\n  };\n\n  AbstractMatrix.prototype.sin = function sin() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.sin(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.sin = function sin(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.sin();\n  };\n\n  AbstractMatrix.prototype.sinh = function sinh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.sinh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.sinh = function sinh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.sinh();\n  };\n\n  AbstractMatrix.prototype.sqrt = function sqrt() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.sqrt(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.sqrt = function sqrt(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.sqrt();\n  };\n\n  AbstractMatrix.prototype.tan = function tan() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.tan(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.tan = function tan(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.tan();\n  };\n\n  AbstractMatrix.prototype.tanh = function tanh() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.tanh(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.tanh = function tanh(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.tanh();\n  };\n\n  AbstractMatrix.prototype.trunc = function trunc() {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.trunc(this.get(i, j)));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.trunc = function trunc(matrix) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.trunc();\n  };\n\n  AbstractMatrix.pow = function pow(matrix, arg0) {\n    const newMatrix = new Matrix(matrix);\n    return newMatrix.pow(arg0);\n  };\n\n  AbstractMatrix.prototype.pow = function pow(value) {\n    if (typeof value === 'number') return this.powS(value);\n    return this.powM(value);\n  };\n\n  AbstractMatrix.prototype.powS = function powS(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.pow(this.get(i, j), value));\n      }\n    }\n    return this;\n  };\n\n  AbstractMatrix.prototype.powM = function powM(matrix) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (this.rows !== matrix.rows ||\n      this.columns !== matrix.columns) {\n      throw new RangeError('Matrices dimensions must be equal');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\n      }\n    }\n    return this;\n  };\n}\n","/**\n * @private\n * Check that a row index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkRowIndex(matrix, index, outer) {\n  let max = outer ? matrix.rows : matrix.rows - 1;\n  if (index < 0 || index > max) {\n    throw new RangeError('Row index out of range');\n  }\n}\n\n/**\n * @private\n * Check that a column index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkColumnIndex(matrix, index, outer) {\n  let max = outer ? matrix.columns : matrix.columns - 1;\n  if (index < 0 || index > max) {\n    throw new RangeError('Column index out of range');\n  }\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkRowVector(matrix, vector) {\n  if (vector.to1DArray) {\n    vector = vector.to1DArray();\n  }\n  if (vector.length !== matrix.columns) {\n    throw new RangeError(\n      'vector size must be the same as the number of columns',\n    );\n  }\n  return vector;\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkColumnVector(matrix, vector) {\n  if (vector.to1DArray) {\n    vector = vector.to1DArray();\n  }\n  if (vector.length !== matrix.rows) {\n    throw new RangeError('vector size must be the same as the number of rows');\n  }\n  return vector;\n}\n\nexport function checkIndices(matrix, rowIndices, columnIndices) {\n  return {\n    row: checkRowIndices(matrix, rowIndices),\n    column: checkColumnIndices(matrix, columnIndices),\n  };\n}\n\nexport function checkRowIndices(matrix, rowIndices) {\n  if (typeof rowIndices !== 'object') {\n    throw new TypeError('unexpected type for row indices');\n  }\n\n  let rowOut = rowIndices.some((r) => {\n    return r < 0 || r >= matrix.rows;\n  });\n\n  if (rowOut) {\n    throw new RangeError('row indices are out of range');\n  }\n\n  if (!Array.isArray(rowIndices)) rowIndices = Array.from(rowIndices);\n\n  return rowIndices;\n}\n\nexport function checkColumnIndices(matrix, columnIndices) {\n  if (typeof columnIndices !== 'object') {\n    throw new TypeError('unexpected type for column indices');\n  }\n\n  let columnOut = columnIndices.some((c) => {\n    return c < 0 || c >= matrix.columns;\n  });\n\n  if (columnOut) {\n    throw new RangeError('column indices are out of range');\n  }\n  if (!Array.isArray(columnIndices)) columnIndices = Array.from(columnIndices);\n\n  return columnIndices;\n}\n\nexport function checkRange(matrix, startRow, endRow, startColumn, endColumn) {\n  if (arguments.length !== 5) {\n    throw new RangeError('expected 4 arguments');\n  }\n  checkNumber('startRow', startRow);\n  checkNumber('endRow', endRow);\n  checkNumber('startColumn', startColumn);\n  checkNumber('endColumn', endColumn);\n  if (\n    startRow > endRow ||\n    startColumn > endColumn ||\n    startRow < 0 ||\n    startRow >= matrix.rows ||\n    endRow < 0 ||\n    endRow >= matrix.rows ||\n    startColumn < 0 ||\n    startColumn >= matrix.columns ||\n    endColumn < 0 ||\n    endColumn >= matrix.columns\n  ) {\n    throw new RangeError('Submatrix indices are out of range');\n  }\n}\n\nexport function newArray(length, value = 0) {\n  let array = [];\n  for (let i = 0; i < length; i++) {\n    array.push(value);\n  }\n  return array;\n}\n\nfunction checkNumber(name, value) {\n  if (typeof value !== 'number') {\n    throw new TypeError(`${name} must be a number`);\n  }\n}\n\nexport function checkNonEmpty(matrix) {\n  if (matrix.isEmpty()) {\n    throw new Error('Empty matrix has no elements to index');\n  }\n}\n","import { newArray } from './util';\n\nexport function sumByRow(matrix) {\n  let sum = newArray(matrix.rows);\n  for (let i = 0; i < matrix.rows; ++i) {\n    for (let j = 0; j < matrix.columns; ++j) {\n      sum[i] += matrix.get(i, j);\n    }\n  }\n  return sum;\n}\n\nexport function sumByColumn(matrix) {\n  let sum = newArray(matrix.columns);\n  for (let i = 0; i < matrix.rows; ++i) {\n    for (let j = 0; j < matrix.columns; ++j) {\n      sum[j] += matrix.get(i, j);\n    }\n  }\n  return sum;\n}\n\nexport function sumAll(matrix) {\n  let v = 0;\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      v += matrix.get(i, j);\n    }\n  }\n  return v;\n}\n\nexport function productByRow(matrix) {\n  let sum = newArray(matrix.rows, 1);\n  for (let i = 0; i < matrix.rows; ++i) {\n    for (let j = 0; j < matrix.columns; ++j) {\n      sum[i] *= matrix.get(i, j);\n    }\n  }\n  return sum;\n}\n\nexport function productByColumn(matrix) {\n  let sum = newArray(matrix.columns, 1);\n  for (let i = 0; i < matrix.rows; ++i) {\n    for (let j = 0; j < matrix.columns; ++j) {\n      sum[j] *= matrix.get(i, j);\n    }\n  }\n  return sum;\n}\n\nexport function productAll(matrix) {\n  let v = 1;\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      v *= matrix.get(i, j);\n    }\n  }\n  return v;\n}\n\nexport function varianceByRow(matrix, unbiased, mean) {\n  const rows = matrix.rows;\n  const cols = matrix.columns;\n  const variance = [];\n\n  for (let i = 0; i < rows; i++) {\n    let sum1 = 0;\n    let sum2 = 0;\n    let x = 0;\n    for (let j = 0; j < cols; j++) {\n      x = matrix.get(i, j) - mean[i];\n      sum1 += x;\n      sum2 += x * x;\n    }\n    if (unbiased) {\n      variance.push((sum2 - (sum1 * sum1) / cols) / (cols - 1));\n    } else {\n      variance.push((sum2 - (sum1 * sum1) / cols) / cols);\n    }\n  }\n  return variance;\n}\n\nexport function varianceByColumn(matrix, unbiased, mean) {\n  const rows = matrix.rows;\n  const cols = matrix.columns;\n  const variance = [];\n\n  for (let j = 0; j < cols; j++) {\n    let sum1 = 0;\n    let sum2 = 0;\n    let x = 0;\n    for (let i = 0; i < rows; i++) {\n      x = matrix.get(i, j) - mean[j];\n      sum1 += x;\n      sum2 += x * x;\n    }\n    if (unbiased) {\n      variance.push((sum2 - (sum1 * sum1) / rows) / (rows - 1));\n    } else {\n      variance.push((sum2 - (sum1 * sum1) / rows) / rows);\n    }\n  }\n  return variance;\n}\n\nexport function varianceAll(matrix, unbiased, mean) {\n  const rows = matrix.rows;\n  const cols = matrix.columns;\n  const size = rows * cols;\n\n  let sum1 = 0;\n  let sum2 = 0;\n  let x = 0;\n  for (let i = 0; i < rows; i++) {\n    for (let j = 0; j < cols; j++) {\n      x = matrix.get(i, j) - mean;\n      sum1 += x;\n      sum2 += x * x;\n    }\n  }\n  if (unbiased) {\n    return (sum2 - (sum1 * sum1) / size) / (size - 1);\n  } else {\n    return (sum2 - (sum1 * sum1) / size) / size;\n  }\n}\n\nexport function centerByRow(matrix, mean) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) - mean[i]);\n    }\n  }\n}\n\nexport function centerByColumn(matrix, mean) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) - mean[j]);\n    }\n  }\n}\n\nexport function centerAll(matrix, mean) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) - mean);\n    }\n  }\n}\n\nexport function getScaleByRow(matrix) {\n  const scale = [];\n  for (let i = 0; i < matrix.rows; i++) {\n    let sum = 0;\n    for (let j = 0; j < matrix.columns; j++) {\n      sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1);\n    }\n    scale.push(Math.sqrt(sum));\n  }\n  return scale;\n}\n\nexport function scaleByRow(matrix, scale) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) / scale[i]);\n    }\n  }\n}\n\nexport function getScaleByColumn(matrix) {\n  const scale = [];\n  for (let j = 0; j < matrix.columns; j++) {\n    let sum = 0;\n    for (let i = 0; i < matrix.rows; i++) {\n      sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1);\n    }\n    scale.push(Math.sqrt(sum));\n  }\n  return scale;\n}\n\nexport function scaleByColumn(matrix, scale) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) / scale[j]);\n    }\n  }\n}\n\nexport function getScaleAll(matrix) {\n  const divider = matrix.size - 1;\n  let sum = 0;\n  for (let j = 0; j < matrix.columns; j++) {\n    for (let i = 0; i < matrix.rows; i++) {\n      sum += Math.pow(matrix.get(i, j), 2) / divider;\n    }\n  }\n  return Math.sqrt(sum);\n}\n\nexport function scaleAll(matrix, scale) {\n  for (let i = 0; i < matrix.rows; i++) {\n    for (let j = 0; j < matrix.columns; j++) {\n      matrix.set(i, j, matrix.get(i, j) / scale);\n    }\n  }\n}\n","import rescale from 'ml-array-rescale';\n\nimport { inspectMatrix, inspectMatrixWithOptions } from './inspect';\nimport { installMathOperations } from './mathOperations';\nimport {\n  sumByRow,\n  sumByColumn,\n  sumAll,\n  productByRow,\n  productByColumn,\n  productAll,\n  varianceByRow,\n  varianceByColumn,\n  varianceAll,\n  centerByRow,\n  centerByColumn,\n  centerAll,\n  scaleByRow,\n  scaleByColumn,\n  scaleAll,\n  getScaleByRow,\n  getScaleByColumn,\n  getScaleAll,\n} from './stat';\nimport {\n  checkRowVector,\n  checkRowIndex,\n  checkColumnIndex,\n  checkColumnVector,\n  checkRange,\n  checkIndices,\n  checkNonEmpty,\n} from './util';\n\nexport class AbstractMatrix {\n  static from1DArray(newRows, newColumns, newData) {\n    let length = newRows * newColumns;\n    if (length !== newData.length) {\n      throw new RangeError('data length does not match given dimensions');\n    }\n    let newMatrix = new Matrix(newRows, newColumns);\n    for (let row = 0; row < newRows; row++) {\n      for (let column = 0; column < newColumns; column++) {\n        newMatrix.set(row, column, newData[row * newColumns + column]);\n      }\n    }\n    return newMatrix;\n  }\n\n  static rowVector(newData) {\n    let vector = new Matrix(1, newData.length);\n    for (let i = 0; i < newData.length; i++) {\n      vector.set(0, i, newData[i]);\n    }\n    return vector;\n  }\n\n  static columnVector(newData) {\n    let vector = new Matrix(newData.length, 1);\n    for (let i = 0; i < newData.length; i++) {\n      vector.set(i, 0, newData[i]);\n    }\n    return vector;\n  }\n\n  static zeros(rows, columns) {\n    return new Matrix(rows, columns);\n  }\n\n  static ones(rows, columns) {\n    return new Matrix(rows, columns).fill(1);\n  }\n\n  static rand(rows, columns, options = {}) {\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { random = Math.random } = options;\n    let matrix = new Matrix(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        matrix.set(i, j, random());\n      }\n    }\n    return matrix;\n  }\n\n  static randInt(rows, columns, options = {}) {\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { min = 0, max = 1000, random = Math.random } = options;\n    if (!Number.isInteger(min)) throw new TypeError('min must be an integer');\n    if (!Number.isInteger(max)) throw new TypeError('max must be an integer');\n    if (min >= max) throw new RangeError('min must be smaller than max');\n    let interval = max - min;\n    let matrix = new Matrix(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        let value = min + Math.round(random() * interval);\n        matrix.set(i, j, value);\n      }\n    }\n    return matrix;\n  }\n\n  static eye(rows, columns, value) {\n    if (columns === undefined) columns = rows;\n    if (value === undefined) value = 1;\n    let min = Math.min(rows, columns);\n    let matrix = this.zeros(rows, columns);\n    for (let i = 0; i < min; i++) {\n      matrix.set(i, i, value);\n    }\n    return matrix;\n  }\n\n  static diag(data, rows, columns) {\n    let l = data.length;\n    if (rows === undefined) rows = l;\n    if (columns === undefined) columns = rows;\n    let min = Math.min(l, rows, columns);\n    let matrix = this.zeros(rows, columns);\n    for (let i = 0; i < min; i++) {\n      matrix.set(i, i, data[i]);\n    }\n    return matrix;\n  }\n\n  static min(matrix1, matrix2) {\n    matrix1 = this.checkMatrix(matrix1);\n    matrix2 = this.checkMatrix(matrix2);\n    let rows = matrix1.rows;\n    let columns = matrix1.columns;\n    let result = new Matrix(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        result.set(i, j, Math.min(matrix1.get(i, j), matrix2.get(i, j)));\n      }\n    }\n    return result;\n  }\n\n  static max(matrix1, matrix2) {\n    matrix1 = this.checkMatrix(matrix1);\n    matrix2 = this.checkMatrix(matrix2);\n    let rows = matrix1.rows;\n    let columns = matrix1.columns;\n    let result = new this(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        result.set(i, j, Math.max(matrix1.get(i, j), matrix2.get(i, j)));\n      }\n    }\n    return result;\n  }\n\n  static checkMatrix(value) {\n    return AbstractMatrix.isMatrix(value) ? value : new Matrix(value);\n  }\n\n  static isMatrix(value) {\n    return value != null && value.klass === 'Matrix';\n  }\n\n  get size() {\n    return this.rows * this.columns;\n  }\n\n  apply(callback) {\n    if (typeof callback !== 'function') {\n      throw new TypeError('callback must be a function');\n    }\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        callback.call(this, i, j);\n      }\n    }\n    return this;\n  }\n\n  to1DArray() {\n    let array = [];\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        array.push(this.get(i, j));\n      }\n    }\n    return array;\n  }\n\n  to2DArray() {\n    let copy = [];\n    for (let i = 0; i < this.rows; i++) {\n      copy.push([]);\n      for (let j = 0; j < this.columns; j++) {\n        copy[i].push(this.get(i, j));\n      }\n    }\n    return copy;\n  }\n\n  toJSON() {\n    return this.to2DArray();\n  }\n\n  isRowVector() {\n    return this.rows === 1;\n  }\n\n  isColumnVector() {\n    return this.columns === 1;\n  }\n\n  isVector() {\n    return this.rows === 1 || this.columns === 1;\n  }\n\n  isSquare() {\n    return this.rows === this.columns;\n  }\n\n  isEmpty() {\n    return this.rows === 0 || this.columns === 0;\n  }\n\n  isSymmetric() {\n    if (this.isSquare()) {\n      for (let i = 0; i < this.rows; i++) {\n        for (let j = 0; j <= i; j++) {\n          if (this.get(i, j) !== this.get(j, i)) {\n            return false;\n          }\n        }\n      }\n      return true;\n    }\n    return false;\n  }\n\n  isEchelonForm() {\n    let i = 0;\n    let j = 0;\n    let previousColumn = -1;\n    let isEchelonForm = true;\n    let checked = false;\n    while (i < this.rows && isEchelonForm) {\n      j = 0;\n      checked = false;\n      while (j < this.columns && checked === false) {\n        if (this.get(i, j) === 0) {\n          j++;\n        } else if (this.get(i, j) === 1 && j > previousColumn) {\n          checked = true;\n          previousColumn = j;\n        } else {\n          isEchelonForm = false;\n          checked = true;\n        }\n      }\n      i++;\n    }\n    return isEchelonForm;\n  }\n\n  isReducedEchelonForm() {\n    let i = 0;\n    let j = 0;\n    let previousColumn = -1;\n    let isReducedEchelonForm = true;\n    let checked = false;\n    while (i < this.rows && isReducedEchelonForm) {\n      j = 0;\n      checked = false;\n      while (j < this.columns && checked === false) {\n        if (this.get(i, j) === 0) {\n          j++;\n        } else if (this.get(i, j) === 1 && j > previousColumn) {\n          checked = true;\n          previousColumn = j;\n        } else {\n          isReducedEchelonForm = false;\n          checked = true;\n        }\n      }\n      for (let k = j + 1; k < this.rows; k++) {\n        if (this.get(i, k) !== 0) {\n          isReducedEchelonForm = false;\n        }\n      }\n      i++;\n    }\n    return isReducedEchelonForm;\n  }\n\n  echelonForm() {\n    let result = this.clone();\n    let h = 0;\n    let k = 0;\n    while (h < result.rows && k < result.columns) {\n      let iMax = h;\n      for (let i = h; i < result.rows; i++) {\n        if (result.get(i, k) > result.get(iMax, k)) {\n          iMax = i;\n        }\n      }\n      if (result.get(iMax, k) === 0) {\n        k++;\n      } else {\n        result.swapRows(h, iMax);\n        let tmp = result.get(h, k);\n        for (let j = k; j < result.columns; j++) {\n          result.set(h, j, result.get(h, j) / tmp);\n        }\n        for (let i = h + 1; i < result.rows; i++) {\n          let factor = result.get(i, k) / result.get(h, k);\n          result.set(i, k, 0);\n          for (let j = k + 1; j < result.columns; j++) {\n            result.set(i, j, result.get(i, j) - result.get(h, j) * factor);\n          }\n        }\n        h++;\n        k++;\n      }\n    }\n    return result;\n  }\n\n  reducedEchelonForm() {\n    let result = this.echelonForm();\n    let m = result.columns;\n    let n = result.rows;\n    let h = n - 1;\n    while (h >= 0) {\n      if (result.maxRow(h) === 0) {\n        h--;\n      } else {\n        let p = 0;\n        let pivot = false;\n        while (p < n && pivot === false) {\n          if (result.get(h, p) === 1) {\n            pivot = true;\n          } else {\n            p++;\n          }\n        }\n        for (let i = 0; i < h; i++) {\n          let factor = result.get(i, p);\n          for (let j = p; j < m; j++) {\n            let tmp = result.get(i, j) - factor * result.get(h, j);\n            result.set(i, j, tmp);\n          }\n        }\n        h--;\n      }\n    }\n    return result;\n  }\n\n  set() {\n    throw new Error('set method is unimplemented');\n  }\n\n  get() {\n    throw new Error('get method is unimplemented');\n  }\n\n  repeat(options = {}) {\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { rows = 1, columns = 1 } = options;\n    if (!Number.isInteger(rows) || rows <= 0) {\n      throw new TypeError('rows must be a positive integer');\n    }\n    if (!Number.isInteger(columns) || columns <= 0) {\n      throw new TypeError('columns must be a positive integer');\n    }\n    let matrix = new Matrix(this.rows * rows, this.columns * columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        matrix.setSubMatrix(this, this.rows * i, this.columns * j);\n      }\n    }\n    return matrix;\n  }\n\n  fill(value) {\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, value);\n      }\n    }\n    return this;\n  }\n\n  neg() {\n    return this.mulS(-1);\n  }\n\n  getRow(index) {\n    checkRowIndex(this, index);\n    let row = [];\n    for (let i = 0; i < this.columns; i++) {\n      row.push(this.get(index, i));\n    }\n    return row;\n  }\n\n  getRowVector(index) {\n    return Matrix.rowVector(this.getRow(index));\n  }\n\n  setRow(index, array) {\n    checkRowIndex(this, index);\n    array = checkRowVector(this, array);\n    for (let i = 0; i < this.columns; i++) {\n      this.set(index, i, array[i]);\n    }\n    return this;\n  }\n\n  swapRows(row1, row2) {\n    checkRowIndex(this, row1);\n    checkRowIndex(this, row2);\n    for (let i = 0; i < this.columns; i++) {\n      let temp = this.get(row1, i);\n      this.set(row1, i, this.get(row2, i));\n      this.set(row2, i, temp);\n    }\n    return this;\n  }\n\n  getColumn(index) {\n    checkColumnIndex(this, index);\n    let column = [];\n    for (let i = 0; i < this.rows; i++) {\n      column.push(this.get(i, index));\n    }\n    return column;\n  }\n\n  getColumnVector(index) {\n    return Matrix.columnVector(this.getColumn(index));\n  }\n\n  setColumn(index, array) {\n    checkColumnIndex(this, index);\n    array = checkColumnVector(this, array);\n    for (let i = 0; i < this.rows; i++) {\n      this.set(i, index, array[i]);\n    }\n    return this;\n  }\n\n  swapColumns(column1, column2) {\n    checkColumnIndex(this, column1);\n    checkColumnIndex(this, column2);\n    for (let i = 0; i < this.rows; i++) {\n      let temp = this.get(i, column1);\n      this.set(i, column1, this.get(i, column2));\n      this.set(i, column2, temp);\n    }\n    return this;\n  }\n\n  addRowVector(vector) {\n    vector = checkRowVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) + vector[j]);\n      }\n    }\n    return this;\n  }\n\n  subRowVector(vector) {\n    vector = checkRowVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) - vector[j]);\n      }\n    }\n    return this;\n  }\n\n  mulRowVector(vector) {\n    vector = checkRowVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) * vector[j]);\n      }\n    }\n    return this;\n  }\n\n  divRowVector(vector) {\n    vector = checkRowVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) / vector[j]);\n      }\n    }\n    return this;\n  }\n\n  addColumnVector(vector) {\n    vector = checkColumnVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) + vector[i]);\n      }\n    }\n    return this;\n  }\n\n  subColumnVector(vector) {\n    vector = checkColumnVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) - vector[i]);\n      }\n    }\n    return this;\n  }\n\n  mulColumnVector(vector) {\n    vector = checkColumnVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) * vector[i]);\n      }\n    }\n    return this;\n  }\n\n  divColumnVector(vector) {\n    vector = checkColumnVector(this, vector);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        this.set(i, j, this.get(i, j) / vector[i]);\n      }\n    }\n    return this;\n  }\n\n  mulRow(index, value) {\n    checkRowIndex(this, index);\n    for (let i = 0; i < this.columns; i++) {\n      this.set(index, i, this.get(index, i) * value);\n    }\n    return this;\n  }\n\n  mulColumn(index, value) {\n    checkColumnIndex(this, index);\n    for (let i = 0; i < this.rows; i++) {\n      this.set(i, index, this.get(i, index) * value);\n    }\n    return this;\n  }\n\n  max() {\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(0, 0);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        if (this.get(i, j) > v) {\n          v = this.get(i, j);\n        }\n      }\n    }\n    return v;\n  }\n\n  maxIndex() {\n    checkNonEmpty(this);\n    let v = this.get(0, 0);\n    let idx = [0, 0];\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        if (this.get(i, j) > v) {\n          v = this.get(i, j);\n          idx[0] = i;\n          idx[1] = j;\n        }\n      }\n    }\n    return idx;\n  }\n\n  min() {\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(0, 0);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        if (this.get(i, j) < v) {\n          v = this.get(i, j);\n        }\n      }\n    }\n    return v;\n  }\n\n  minIndex() {\n    checkNonEmpty(this);\n    let v = this.get(0, 0);\n    let idx = [0, 0];\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        if (this.get(i, j) < v) {\n          v = this.get(i, j);\n          idx[0] = i;\n          idx[1] = j;\n        }\n      }\n    }\n    return idx;\n  }\n\n  maxRow(row) {\n    checkRowIndex(this, row);\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(row, 0);\n    for (let i = 1; i < this.columns; i++) {\n      if (this.get(row, i) > v) {\n        v = this.get(row, i);\n      }\n    }\n    return v;\n  }\n\n  maxRowIndex(row) {\n    checkRowIndex(this, row);\n    checkNonEmpty(this);\n    let v = this.get(row, 0);\n    let idx = [row, 0];\n    for (let i = 1; i < this.columns; i++) {\n      if (this.get(row, i) > v) {\n        v = this.get(row, i);\n        idx[1] = i;\n      }\n    }\n    return idx;\n  }\n\n  minRow(row) {\n    checkRowIndex(this, row);\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(row, 0);\n    for (let i = 1; i < this.columns; i++) {\n      if (this.get(row, i) < v) {\n        v = this.get(row, i);\n      }\n    }\n    return v;\n  }\n\n  minRowIndex(row) {\n    checkRowIndex(this, row);\n    checkNonEmpty(this);\n    let v = this.get(row, 0);\n    let idx = [row, 0];\n    for (let i = 1; i < this.columns; i++) {\n      if (this.get(row, i) < v) {\n        v = this.get(row, i);\n        idx[1] = i;\n      }\n    }\n    return idx;\n  }\n\n  maxColumn(column) {\n    checkColumnIndex(this, column);\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(0, column);\n    for (let i = 1; i < this.rows; i++) {\n      if (this.get(i, column) > v) {\n        v = this.get(i, column);\n      }\n    }\n    return v;\n  }\n\n  maxColumnIndex(column) {\n    checkColumnIndex(this, column);\n    checkNonEmpty(this);\n    let v = this.get(0, column);\n    let idx = [0, column];\n    for (let i = 1; i < this.rows; i++) {\n      if (this.get(i, column) > v) {\n        v = this.get(i, column);\n        idx[0] = i;\n      }\n    }\n    return idx;\n  }\n\n  minColumn(column) {\n    checkColumnIndex(this, column);\n    if (this.isEmpty()) {\n      return NaN;\n    }\n    let v = this.get(0, column);\n    for (let i = 1; i < this.rows; i++) {\n      if (this.get(i, column) < v) {\n        v = this.get(i, column);\n      }\n    }\n    return v;\n  }\n\n  minColumnIndex(column) {\n    checkColumnIndex(this, column);\n    checkNonEmpty(this);\n    let v = this.get(0, column);\n    let idx = [0, column];\n    for (let i = 1; i < this.rows; i++) {\n      if (this.get(i, column) < v) {\n        v = this.get(i, column);\n        idx[0] = i;\n      }\n    }\n    return idx;\n  }\n\n  diag() {\n    let min = Math.min(this.rows, this.columns);\n    let diag = [];\n    for (let i = 0; i < min; i++) {\n      diag.push(this.get(i, i));\n    }\n    return diag;\n  }\n\n  norm(type = 'frobenius') {\n    let result = 0;\n    if (type === 'max') {\n      return this.max();\n    } else if (type === 'frobenius') {\n      for (let i = 0; i < this.rows; i++) {\n        for (let j = 0; j < this.columns; j++) {\n          result = result + this.get(i, j) * this.get(i, j);\n        }\n      }\n      return Math.sqrt(result);\n    } else {\n      throw new RangeError(`unknown norm type: ${type}`);\n    }\n  }\n\n  cumulativeSum() {\n    let sum = 0;\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        sum += this.get(i, j);\n        this.set(i, j, sum);\n      }\n    }\n    return this;\n  }\n\n  dot(vector2) {\n    if (AbstractMatrix.isMatrix(vector2)) vector2 = vector2.to1DArray();\n    let vector1 = this.to1DArray();\n    if (vector1.length !== vector2.length) {\n      throw new RangeError('vectors do not have the same size');\n    }\n    let dot = 0;\n    for (let i = 0; i < vector1.length; i++) {\n      dot += vector1[i] * vector2[i];\n    }\n    return dot;\n  }\n\n  mmul(other) {\n    other = Matrix.checkMatrix(other);\n\n    let m = this.rows;\n    let n = this.columns;\n    let p = other.columns;\n\n    let result = new Matrix(m, p);\n\n    let Bcolj = new Float64Array(n);\n    for (let j = 0; j < p; j++) {\n      for (let k = 0; k < n; k++) {\n        Bcolj[k] = other.get(k, j);\n      }\n\n      for (let i = 0; i < m; i++) {\n        let s = 0;\n        for (let k = 0; k < n; k++) {\n          s += this.get(i, k) * Bcolj[k];\n        }\n\n        result.set(i, j, s);\n      }\n    }\n    return result;\n  }\n\n  strassen2x2(other) {\n    other = Matrix.checkMatrix(other);\n    let result = new Matrix(2, 2);\n    const a11 = this.get(0, 0);\n    const b11 = other.get(0, 0);\n    const a12 = this.get(0, 1);\n    const b12 = other.get(0, 1);\n    const a21 = this.get(1, 0);\n    const b21 = other.get(1, 0);\n    const a22 = this.get(1, 1);\n    const b22 = other.get(1, 1);\n\n    // Compute intermediate values.\n    const m1 = (a11 + a22) * (b11 + b22);\n    const m2 = (a21 + a22) * b11;\n    const m3 = a11 * (b12 - b22);\n    const m4 = a22 * (b21 - b11);\n    const m5 = (a11 + a12) * b22;\n    const m6 = (a21 - a11) * (b11 + b12);\n    const m7 = (a12 - a22) * (b21 + b22);\n\n    // Combine intermediate values into the output.\n    const c00 = m1 + m4 - m5 + m7;\n    const c01 = m3 + m5;\n    const c10 = m2 + m4;\n    const c11 = m1 - m2 + m3 + m6;\n\n    result.set(0, 0, c00);\n    result.set(0, 1, c01);\n    result.set(1, 0, c10);\n    result.set(1, 1, c11);\n    return result;\n  }\n\n  strassen3x3(other) {\n    other = Matrix.checkMatrix(other);\n    let result = new Matrix(3, 3);\n\n    const a00 = this.get(0, 0);\n    const a01 = this.get(0, 1);\n    const a02 = this.get(0, 2);\n    const a10 = this.get(1, 0);\n    const a11 = this.get(1, 1);\n    const a12 = this.get(1, 2);\n    const a20 = this.get(2, 0);\n    const a21 = this.get(2, 1);\n    const a22 = this.get(2, 2);\n\n    const b00 = other.get(0, 0);\n    const b01 = other.get(0, 1);\n    const b02 = other.get(0, 2);\n    const b10 = other.get(1, 0);\n    const b11 = other.get(1, 1);\n    const b12 = other.get(1, 2);\n    const b20 = other.get(2, 0);\n    const b21 = other.get(2, 1);\n    const b22 = other.get(2, 2);\n\n    const m1 = (a00 + a01 + a02 - a10 - a11 - a21 - a22) * b11;\n    const m2 = (a00 - a10) * (-b01 + b11);\n    const m3 = a11 * (-b00 + b01 + b10 - b11 - b12 - b20 + b22);\n    const m4 = (-a00 + a10 + a11) * (b00 - b01 + b11);\n    const m5 = (a10 + a11) * (-b00 + b01);\n    const m6 = a00 * b00;\n    const m7 = (-a00 + a20 + a21) * (b00 - b02 + b12);\n    const m8 = (-a00 + a20) * (b02 - b12);\n    const m9 = (a20 + a21) * (-b00 + b02);\n    const m10 = (a00 + a01 + a02 - a11 - a12 - a20 - a21) * b12;\n    const m11 = a21 * (-b00 + b02 + b10 - b11 - b12 - b20 + b21);\n    const m12 = (-a02 + a21 + a22) * (b11 + b20 - b21);\n    const m13 = (a02 - a22) * (b11 - b21);\n    const m14 = a02 * b20;\n    const m15 = (a21 + a22) * (-b20 + b21);\n    const m16 = (-a02 + a11 + a12) * (b12 + b20 - b22);\n    const m17 = (a02 - a12) * (b12 - b22);\n    const m18 = (a11 + a12) * (-b20 + b22);\n    const m19 = a01 * b10;\n    const m20 = a12 * b21;\n    const m21 = a10 * b02;\n    const m22 = a20 * b01;\n    const m23 = a22 * b22;\n\n    const c00 = m6 + m14 + m19;\n    const c01 = m1 + m4 + m5 + m6 + m12 + m14 + m15;\n    const c02 = m6 + m7 + m9 + m10 + m14 + m16 + m18;\n    const c10 = m2 + m3 + m4 + m6 + m14 + m16 + m17;\n    const c11 = m2 + m4 + m5 + m6 + m20;\n    const c12 = m14 + m16 + m17 + m18 + m21;\n    const c20 = m6 + m7 + m8 + m11 + m12 + m13 + m14;\n    const c21 = m12 + m13 + m14 + m15 + m22;\n    const c22 = m6 + m7 + m8 + m9 + m23;\n\n    result.set(0, 0, c00);\n    result.set(0, 1, c01);\n    result.set(0, 2, c02);\n    result.set(1, 0, c10);\n    result.set(1, 1, c11);\n    result.set(1, 2, c12);\n    result.set(2, 0, c20);\n    result.set(2, 1, c21);\n    result.set(2, 2, c22);\n    return result;\n  }\n\n  mmulStrassen(y) {\n    y = Matrix.checkMatrix(y);\n    let x = this.clone();\n    let r1 = x.rows;\n    let c1 = x.columns;\n    let r2 = y.rows;\n    let c2 = y.columns;\n    if (c1 !== r2) {\n      // eslint-disable-next-line no-console\n      console.warn(\n        `Multiplying ${r1} x ${c1} and ${r2} x ${c2} matrix: dimensions do not match.`,\n      );\n    }\n\n    // Put a matrix into the top left of a matrix of zeros.\n    // `rows` and `cols` are the dimensions of the output matrix.\n    function embed(mat, rows, cols) {\n      let r = mat.rows;\n      let c = mat.columns;\n      if (r === rows && c === cols) {\n        return mat;\n      } else {\n        let resultat = AbstractMatrix.zeros(rows, cols);\n        resultat = resultat.setSubMatrix(mat, 0, 0);\n        return resultat;\n      }\n    }\n\n    // Make sure both matrices are the same size.\n    // This is exclusively for simplicity:\n    // this algorithm can be implemented with matrices of different sizes.\n\n    let r = Math.max(r1, r2);\n    let c = Math.max(c1, c2);\n    x = embed(x, r, c);\n    y = embed(y, r, c);\n\n    // Our recursive multiplication function.\n    function blockMult(a, b, rows, cols) {\n      // For small matrices, resort to naive multiplication.\n      if (rows <= 512 || cols <= 512) {\n        return a.mmul(b); // a is equivalent to this\n      }\n\n      // Apply dynamic padding.\n      if (rows % 2 === 1 && cols % 2 === 1) {\n        a = embed(a, rows + 1, cols + 1);\n        b = embed(b, rows + 1, cols + 1);\n      } else if (rows % 2 === 1) {\n        a = embed(a, rows + 1, cols);\n        b = embed(b, rows + 1, cols);\n      } else if (cols % 2 === 1) {\n        a = embed(a, rows, cols + 1);\n        b = embed(b, rows, cols + 1);\n      }\n\n      let halfRows = parseInt(a.rows / 2, 10);\n      let halfCols = parseInt(a.columns / 2, 10);\n      // Subdivide input matrices.\n      let a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n      let b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n\n      let a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);\n      let b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);\n\n      let a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);\n      let b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);\n\n      let a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);\n      let b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);\n\n      // Compute intermediate values.\n      let m1 = blockMult(\n        AbstractMatrix.add(a11, a22),\n        AbstractMatrix.add(b11, b22),\n        halfRows,\n        halfCols,\n      );\n      let m2 = blockMult(AbstractMatrix.add(a21, a22), b11, halfRows, halfCols);\n      let m3 = blockMult(a11, AbstractMatrix.sub(b12, b22), halfRows, halfCols);\n      let m4 = blockMult(a22, AbstractMatrix.sub(b21, b11), halfRows, halfCols);\n      let m5 = blockMult(AbstractMatrix.add(a11, a12), b22, halfRows, halfCols);\n      let m6 = blockMult(\n        AbstractMatrix.sub(a21, a11),\n        AbstractMatrix.add(b11, b12),\n        halfRows,\n        halfCols,\n      );\n      let m7 = blockMult(\n        AbstractMatrix.sub(a12, a22),\n        AbstractMatrix.add(b21, b22),\n        halfRows,\n        halfCols,\n      );\n\n      // Combine intermediate values into the output.\n      let c11 = AbstractMatrix.add(m1, m4);\n      c11.sub(m5);\n      c11.add(m7);\n      let c12 = AbstractMatrix.add(m3, m5);\n      let c21 = AbstractMatrix.add(m2, m4);\n      let c22 = AbstractMatrix.sub(m1, m2);\n      c22.add(m3);\n      c22.add(m6);\n\n      // Crop output to the desired size (undo dynamic padding).\n      let resultat = AbstractMatrix.zeros(2 * c11.rows, 2 * c11.columns);\n      resultat = resultat.setSubMatrix(c11, 0, 0);\n      resultat = resultat.setSubMatrix(c12, c11.rows, 0);\n      resultat = resultat.setSubMatrix(c21, 0, c11.columns);\n      resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);\n      return resultat.subMatrix(0, rows - 1, 0, cols - 1);\n    }\n    return blockMult(x, y, r, c);\n  }\n\n  scaleRows(options = {}) {\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { min = 0, max = 1 } = options;\n    if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n    if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n    if (min >= max) throw new RangeError('min must be smaller than max');\n    let newMatrix = new Matrix(this.rows, this.columns);\n    for (let i = 0; i < this.rows; i++) {\n      const row = this.getRow(i);\n      if (row.length > 0) {\n        rescale(row, { min, max, output: row });\n      }\n      newMatrix.setRow(i, row);\n    }\n    return newMatrix;\n  }\n\n  scaleColumns(options = {}) {\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { min = 0, max = 1 } = options;\n    if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n    if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n    if (min >= max) throw new RangeError('min must be smaller than max');\n    let newMatrix = new Matrix(this.rows, this.columns);\n    for (let i = 0; i < this.columns; i++) {\n      const column = this.getColumn(i);\n      if (column.length) {\n        rescale(column, {\n          min: min,\n          max: max,\n          output: column,\n        });\n      }\n      newMatrix.setColumn(i, column);\n    }\n    return newMatrix;\n  }\n\n  flipRows() {\n    const middle = Math.ceil(this.columns / 2);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < middle; j++) {\n        let first = this.get(i, j);\n        let last = this.get(i, this.columns - 1 - j);\n        this.set(i, j, last);\n        this.set(i, this.columns - 1 - j, first);\n      }\n    }\n    return this;\n  }\n\n  flipColumns() {\n    const middle = Math.ceil(this.rows / 2);\n    for (let j = 0; j < this.columns; j++) {\n      for (let i = 0; i < middle; i++) {\n        let first = this.get(i, j);\n        let last = this.get(this.rows - 1 - i, j);\n        this.set(i, j, last);\n        this.set(this.rows - 1 - i, j, first);\n      }\n    }\n    return this;\n  }\n\n  kroneckerProduct(other) {\n    other = Matrix.checkMatrix(other);\n\n    let m = this.rows;\n    let n = this.columns;\n    let p = other.rows;\n    let q = other.columns;\n\n    let result = new Matrix(m * p, n * q);\n    for (let i = 0; i < m; i++) {\n      for (let j = 0; j < n; j++) {\n        for (let k = 0; k < p; k++) {\n          for (let l = 0; l < q; l++) {\n            result.set(p * i + k, q * j + l, this.get(i, j) * other.get(k, l));\n          }\n        }\n      }\n    }\n    return result;\n  }\n\n  kroneckerSum(other) {\n    other = Matrix.checkMatrix(other);\n    if (!this.isSquare() || !other.isSquare()) {\n      throw new Error('Kronecker Sum needs two Square Matrices');\n    }\n    let m = this.rows;\n    let n = other.rows;\n    let AxI = this.kroneckerProduct(Matrix.eye(n, n));\n    let IxB = Matrix.eye(m, m).kroneckerProduct(other);\n    return AxI.add(IxB);\n  }\n\n  transpose() {\n    let result = new Matrix(this.columns, this.rows);\n    for (let i = 0; i < this.rows; i++) {\n      for (let j = 0; j < this.columns; j++) {\n        result.set(j, i, this.get(i, j));\n      }\n    }\n    return result;\n  }\n\n  sortRows(compareFunction = compareNumbers) {\n    for (let i = 0; i < this.rows; i++) {\n      this.setRow(i, this.getRow(i).sort(compareFunction));\n    }\n    return this;\n  }\n\n  sortColumns(compareFunction = compareNumbers) {\n    for (let i = 0; i < this.columns; i++) {\n      this.setColumn(i, this.getColumn(i).sort(compareFunction));\n    }\n    return this;\n  }\n\n  subMatrix(startRow, endRow, startColumn, endColumn) {\n    checkRange(this, startRow, endRow, startColumn, endColumn);\n    let newMatrix = new Matrix(\n      endRow - startRow + 1,\n      endColumn - startColumn + 1,\n    );\n    for (let i = startRow; i <= endRow; i++) {\n      for (let j = startColumn; j <= endColumn; j++) {\n        newMatrix.set(i - startRow, j - startColumn, this.get(i, j));\n      }\n    }\n    return newMatrix;\n  }\n\n  subMatrixRow(indices, startColumn, endColumn) {\n    if (startColumn === undefined) startColumn = 0;\n    if (endColumn === undefined) endColumn = this.columns - 1;\n    if (\n      startColumn > endColumn ||\n      startColumn < 0 ||\n      startColumn >= this.columns ||\n      endColumn < 0 ||\n      endColumn >= this.columns\n    ) {\n      throw new RangeError('Argument out of range');\n    }\n\n    let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1);\n    for (let i = 0; i < indices.length; i++) {\n      for (let j = startColumn; j <= endColumn; j++) {\n        if (indices[i] < 0 || indices[i] >= this.rows) {\n          throw new RangeError(`Row index out of range: ${indices[i]}`);\n        }\n        newMatrix.set(i, j - startColumn, this.get(indices[i], j));\n      }\n    }\n    return newMatrix;\n  }\n\n  subMatrixColumn(indices, startRow, endRow) {\n    if (startRow === undefined) startRow = 0;\n    if (endRow === undefined) endRow = this.rows - 1;\n    if (\n      startRow > endRow ||\n      startRow < 0 ||\n      startRow >= this.rows ||\n      endRow < 0 ||\n      endRow >= this.rows\n    ) {\n      throw new RangeError('Argument out of range');\n    }\n\n    let newMatrix = new Matrix(endRow - startRow + 1, indices.length);\n    for (let i = 0; i < indices.length; i++) {\n      for (let j = startRow; j <= endRow; j++) {\n        if (indices[i] < 0 || indices[i] >= this.columns) {\n          throw new RangeError(`Column index out of range: ${indices[i]}`);\n        }\n        newMatrix.set(j - startRow, i, this.get(j, indices[i]));\n      }\n    }\n    return newMatrix;\n  }\n\n  setSubMatrix(matrix, startRow, startColumn) {\n    matrix = Matrix.checkMatrix(matrix);\n    if (matrix.isEmpty()) {\n      return this;\n    }\n    let endRow = startRow + matrix.rows - 1;\n    let endColumn = startColumn + matrix.columns - 1;\n    checkRange(this, startRow, endRow, startColumn, endColumn);\n    for (let i = 0; i < matrix.rows; i++) {\n      for (let j = 0; j < matrix.columns; j++) {\n        this.set(startRow + i, startColumn + j, matrix.get(i, j));\n      }\n    }\n    return this;\n  }\n\n  selection(rowIndices, columnIndices) {\n    let indices = checkIndices(this, rowIndices, columnIndices);\n    let newMatrix = new Matrix(rowIndices.length, columnIndices.length);\n    for (let i = 0; i < indices.row.length; i++) {\n      let rowIndex = indices.row[i];\n      for (let j = 0; j < indices.column.length; j++) {\n        let columnIndex = indices.column[j];\n        newMatrix.set(i, j, this.get(rowIndex, columnIndex));\n      }\n    }\n    return newMatrix;\n  }\n\n  trace() {\n    let min = Math.min(this.rows, this.columns);\n    let trace = 0;\n    for (let i = 0; i < min; i++) {\n      trace += this.get(i, i);\n    }\n    return trace;\n  }\n\n  clone() {\n    let newMatrix = new Matrix(this.rows, this.columns);\n    for (let row = 0; row < this.rows; row++) {\n      for (let column = 0; column < this.columns; column++) {\n        newMatrix.set(row, column, this.get(row, column));\n      }\n    }\n    return newMatrix;\n  }\n\n  sum(by) {\n    switch (by) {\n      case 'row':\n        return sumByRow(this);\n      case 'column':\n        return sumByColumn(this);\n      case undefined:\n        return sumAll(this);\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  product(by) {\n    switch (by) {\n      case 'row':\n        return productByRow(this);\n      case 'column':\n        return productByColumn(this);\n      case undefined:\n        return productAll(this);\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  mean(by) {\n    const sum = this.sum(by);\n    switch (by) {\n      case 'row': {\n        for (let i = 0; i < this.rows; i++) {\n          sum[i] /= this.columns;\n        }\n        return sum;\n      }\n      case 'column': {\n        for (let i = 0; i < this.columns; i++) {\n          sum[i] /= this.rows;\n        }\n        return sum;\n      }\n      case undefined:\n        return sum / this.size;\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  variance(by, options = {}) {\n    if (typeof by === 'object') {\n      options = by;\n      by = undefined;\n    }\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { unbiased = true, mean = this.mean(by) } = options;\n    if (typeof unbiased !== 'boolean') {\n      throw new TypeError('unbiased must be a boolean');\n    }\n    switch (by) {\n      case 'row': {\n        if (!Array.isArray(mean)) {\n          throw new TypeError('mean must be an array');\n        }\n        return varianceByRow(this, unbiased, mean);\n      }\n      case 'column': {\n        if (!Array.isArray(mean)) {\n          throw new TypeError('mean must be an array');\n        }\n        return varianceByColumn(this, unbiased, mean);\n      }\n      case undefined: {\n        if (typeof mean !== 'number') {\n          throw new TypeError('mean must be a number');\n        }\n        return varianceAll(this, unbiased, mean);\n      }\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  standardDeviation(by, options) {\n    if (typeof by === 'object') {\n      options = by;\n      by = undefined;\n    }\n    const variance = this.variance(by, options);\n    if (by === undefined) {\n      return Math.sqrt(variance);\n    } else {\n      for (let i = 0; i < variance.length; i++) {\n        variance[i] = Math.sqrt(variance[i]);\n      }\n      return variance;\n    }\n  }\n\n  center(by, options = {}) {\n    if (typeof by === 'object') {\n      options = by;\n      by = undefined;\n    }\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    const { center = this.mean(by) } = options;\n    switch (by) {\n      case 'row': {\n        if (!Array.isArray(center)) {\n          throw new TypeError('center must be an array');\n        }\n        centerByRow(this, center);\n        return this;\n      }\n      case 'column': {\n        if (!Array.isArray(center)) {\n          throw new TypeError('center must be an array');\n        }\n        centerByColumn(this, center);\n        return this;\n      }\n      case undefined: {\n        if (typeof center !== 'number') {\n          throw new TypeError('center must be a number');\n        }\n        centerAll(this, center);\n        return this;\n      }\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  scale(by, options = {}) {\n    if (typeof by === 'object') {\n      options = by;\n      by = undefined;\n    }\n    if (typeof options !== 'object') {\n      throw new TypeError('options must be an object');\n    }\n    let scale = options.scale;\n    switch (by) {\n      case 'row': {\n        if (scale === undefined) {\n          scale = getScaleByRow(this);\n        } else if (!Array.isArray(scale)) {\n          throw new TypeError('scale must be an array');\n        }\n        scaleByRow(this, scale);\n        return this;\n      }\n      case 'column': {\n        if (scale === undefined) {\n          scale = getScaleByColumn(this);\n        } else if (!Array.isArray(scale)) {\n          throw new TypeError('scale must be an array');\n        }\n        scaleByColumn(this, scale);\n        return this;\n      }\n      case undefined: {\n        if (scale === undefined) {\n          scale = getScaleAll(this);\n        } else if (typeof scale !== 'number') {\n          throw new TypeError('scale must be a number');\n        }\n        scaleAll(this, scale);\n        return this;\n      }\n      default:\n        throw new Error(`invalid option: ${by}`);\n    }\n  }\n\n  toString(options) {\n    return inspectMatrixWithOptions(this, options);\n  }\n}\n\nAbstractMatrix.prototype.klass = 'Matrix';\nif (typeof Symbol !== 'undefined') {\n  AbstractMatrix.prototype[\n    Symbol.for('nodejs.util.inspect.custom')\n  ] = inspectMatrix;\n}\n\nfunction compareNumbers(a, b) {\n  return a - b;\n}\n\n// Synonyms\nAbstractMatrix.random = AbstractMatrix.rand;\nAbstractMatrix.randomInt = AbstractMatrix.randInt;\nAbstractMatrix.diagonal = AbstractMatrix.diag;\nAbstractMatrix.prototype.diagonal = AbstractMatrix.prototype.diag;\nAbstractMatrix.identity = AbstractMatrix.eye;\nAbstractMatrix.prototype.negate = AbstractMatrix.prototype.neg;\nAbstractMatrix.prototype.tensorProduct =\n  AbstractMatrix.prototype.kroneckerProduct;\n\nexport default class Matrix extends AbstractMatrix {\n  constructor(nRows, nColumns) {\n    super();\n    if (Matrix.isMatrix(nRows)) {\n      // eslint-disable-next-line no-constructor-return\n      return nRows.clone();\n    } else if (Number.isInteger(nRows) && nRows >= 0) {\n      // Create an empty matrix\n      this.data = [];\n      if (Number.isInteger(nColumns) && nColumns >= 0) {\n        for (let i = 0; i < nRows; i++) {\n          this.data.push(new Float64Array(nColumns));\n        }\n      } else {\n        throw new TypeError('nColumns must be a positive integer');\n      }\n    } else if (Array.isArray(nRows)) {\n      // Copy the values from the 2D array\n      const arrayData = nRows;\n      nRows = arrayData.length;\n      nColumns = nRows ? arrayData[0].length : 0;\n      if (typeof nColumns !== 'number') {\n        throw new TypeError(\n          'Data must be a 2D array with at least one element',\n        );\n      }\n      this.data = [];\n      for (let i = 0; i < nRows; i++) {\n        if (arrayData[i].length !== nColumns) {\n          throw new RangeError('Inconsistent array dimensions');\n        }\n        this.data.push(Float64Array.from(arrayData[i]));\n      }\n    } else {\n      throw new TypeError(\n        'First argument must be a positive number or an array',\n      );\n    }\n    this.rows = nRows;\n    this.columns = nColumns;\n  }\n\n  set(rowIndex, columnIndex, value) {\n    this.data[rowIndex][columnIndex] = value;\n    return this;\n  }\n\n  get(rowIndex, columnIndex) {\n    return this.data[rowIndex][columnIndex];\n  }\n\n  removeRow(index) {\n    checkRowIndex(this, index);\n    this.data.splice(index, 1);\n    this.rows -= 1;\n    return this;\n  }\n\n  addRow(index, array) {\n    if (array === undefined) {\n      array = index;\n      index = this.rows;\n    }\n    checkRowIndex(this, index, true);\n    array = Float64Array.from(checkRowVector(this, array));\n    this.data.splice(index, 0, array);\n    this.rows += 1;\n    return this;\n  }\n\n  removeColumn(index) {\n    checkColumnIndex(this, index);\n    for (let i = 0; i < this.rows; i++) {\n      const newRow = new Float64Array(this.columns - 1);\n      for (let j = 0; j < index; j++) {\n        newRow[j] = this.data[i][j];\n      }\n      for (let j = index + 1; j < this.columns; j++) {\n        newRow[j - 1] = this.data[i][j];\n      }\n      this.data[i] = newRow;\n    }\n    this.columns -= 1;\n    return this;\n  }\n\n  addColumn(index, array) {\n    if (typeof array === 'undefined') {\n      array = index;\n      index = this.columns;\n    }\n    checkColumnIndex(this, index, true);\n    array = checkColumnVector(this, array);\n    for (let i = 0; i < this.rows; i++) {\n      const newRow = new Float64Array(this.columns + 1);\n      let j = 0;\n      for (; j < index; j++) {\n        newRow[j] = this.data[i][j];\n      }\n      newRow[j++] = array[i];\n      for (; j < this.columns + 1; j++) {\n        newRow[j] = this.data[i][j - 1];\n      }\n      this.data[i] = newRow;\n    }\n    this.columns += 1;\n    return this;\n  }\n}\n\ninstallMathOperations(AbstractMatrix, Matrix);\n","import { AbstractMatrix } from '../matrix';\n\nexport default class BaseView extends AbstractMatrix {\n  constructor(matrix, rows, columns) {\n    super();\n    this.matrix = matrix;\n    this.rows = rows;\n    this.columns = columns;\n  }\n}\n","import BaseView from './base';\n\nexport default class MatrixTransposeView extends BaseView {\n  constructor(matrix) {\n    super(matrix, matrix.columns, matrix.rows);\n  }\n\n  set(rowIndex, columnIndex, value) {\n    this.matrix.set(columnIndex, rowIndex, value);\n    return this;\n  }\n\n  get(rowIndex, columnIndex) {\n    return this.matrix.get(columnIndex, rowIndex);\n  }\n}\n","import { AbstractMatrix } from '../matrix';\n\nexport default class WrapperMatrix2D extends AbstractMatrix {\n  constructor(data) {\n    super();\n    this.data = data;\n    this.rows = data.length;\n    this.columns = data[0].length;\n  }\n\n  set(rowIndex, columnIndex, value) {\n    this.data[rowIndex][columnIndex] = value;\n    return this;\n  }\n\n  get(rowIndex, columnIndex) {\n    return this.data[rowIndex][columnIndex];\n  }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class LuDecomposition {\n  constructor(matrix) {\n    matrix = WrapperMatrix2D.checkMatrix(matrix);\n\n    let lu = matrix.clone();\n    let rows = lu.rows;\n    let columns = lu.columns;\n    let pivotVector = new Float64Array(rows);\n    let pivotSign = 1;\n    let i, j, k, p, s, t, v;\n    let LUcolj, kmax;\n\n    for (i = 0; i < rows; i++) {\n      pivotVector[i] = i;\n    }\n\n    LUcolj = new Float64Array(rows);\n\n    for (j = 0; j < columns; j++) {\n      for (i = 0; i < rows; i++) {\n        LUcolj[i] = lu.get(i, j);\n      }\n\n      for (i = 0; i < rows; i++) {\n        kmax = Math.min(i, j);\n        s = 0;\n        for (k = 0; k < kmax; k++) {\n          s += lu.get(i, k) * LUcolj[k];\n        }\n        LUcolj[i] -= s;\n        lu.set(i, j, LUcolj[i]);\n      }\n\n      p = j;\n      for (i = j + 1; i < rows; i++) {\n        if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {\n          p = i;\n        }\n      }\n\n      if (p !== j) {\n        for (k = 0; k < columns; k++) {\n          t = lu.get(p, k);\n          lu.set(p, k, lu.get(j, k));\n          lu.set(j, k, t);\n        }\n\n        v = pivotVector[p];\n        pivotVector[p] = pivotVector[j];\n        pivotVector[j] = v;\n\n        pivotSign = -pivotSign;\n      }\n\n      if (j < rows && lu.get(j, j) !== 0) {\n        for (i = j + 1; i < rows; i++) {\n          lu.set(i, j, lu.get(i, j) / lu.get(j, j));\n        }\n      }\n    }\n\n    this.LU = lu;\n    this.pivotVector = pivotVector;\n    this.pivotSign = pivotSign;\n  }\n\n  isSingular() {\n    let data = this.LU;\n    let col = data.columns;\n    for (let j = 0; j < col; j++) {\n      if (data.get(j, j) === 0) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  solve(value) {\n    value = Matrix.checkMatrix(value);\n\n    let lu = this.LU;\n    let rows = lu.rows;\n\n    if (rows !== value.rows) {\n      throw new Error('Invalid matrix dimensions');\n    }\n    if (this.isSingular()) {\n      throw new Error('LU matrix is singular');\n    }\n\n    let count = value.columns;\n    let X = value.subMatrixRow(this.pivotVector, 0, count - 1);\n    let columns = lu.columns;\n    let i, j, k;\n\n    for (k = 0; k < columns; k++) {\n      for (i = k + 1; i < columns; i++) {\n        for (j = 0; j < count; j++) {\n          X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n        }\n      }\n    }\n    for (k = columns - 1; k >= 0; k--) {\n      for (j = 0; j < count; j++) {\n        X.set(k, j, X.get(k, j) / lu.get(k, k));\n      }\n      for (i = 0; i < k; i++) {\n        for (j = 0; j < count; j++) {\n          X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n        }\n      }\n    }\n    return X;\n  }\n\n  get determinant() {\n    let data = this.LU;\n    if (!data.isSquare()) {\n      throw new Error('Matrix must be square');\n    }\n    let determinant = this.pivotSign;\n    let col = data.columns;\n    for (let j = 0; j < col; j++) {\n      determinant *= data.get(j, j);\n    }\n    return determinant;\n  }\n\n  get lowerTriangularMatrix() {\n    let data = this.LU;\n    let rows = data.rows;\n    let columns = data.columns;\n    let X = new Matrix(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        if (i > j) {\n          X.set(i, j, data.get(i, j));\n        } else if (i === j) {\n          X.set(i, j, 1);\n        } else {\n          X.set(i, j, 0);\n        }\n      }\n    }\n    return X;\n  }\n\n  get upperTriangularMatrix() {\n    let data = this.LU;\n    let rows = data.rows;\n    let columns = data.columns;\n    let X = new Matrix(rows, columns);\n    for (let i = 0; i < rows; i++) {\n      for (let j = 0; j < columns; j++) {\n        if (i <= j) {\n          X.set(i, j, data.get(i, j));\n        } else {\n          X.set(i, j, 0);\n        }\n      }\n    }\n    return X;\n  }\n\n  get pivotPermutationVector() {\n    return Array.from(this.pivotVector);\n  }\n}\n","export function hypotenuse(a, b) {\n  let r = 0;\n  if (Math.abs(a) > Math.abs(b)) {\n    r = b / a;\n    return Math.abs(a) * Math.sqrt(1 + r * r);\n  }\n  if (b !== 0) {\n    r = a / b;\n    return Math.abs(b) * Math.sqrt(1 + r * r);\n  }\n  return 0;\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class QrDecomposition {\n  constructor(value) {\n    value = WrapperMatrix2D.checkMatrix(value);\n\n    let qr = value.clone();\n    let m = value.rows;\n    let n = value.columns;\n    let rdiag = new Float64Array(n);\n    let i, j, k, s;\n\n    for (k = 0; k < n; k++) {\n      let nrm = 0;\n      for (i = k; i < m; i++) {\n        nrm = hypotenuse(nrm, qr.get(i, k));\n      }\n      if (nrm !== 0) {\n        if (qr.get(k, k) < 0) {\n          nrm = -nrm;\n        }\n        for (i = k; i < m; i++) {\n          qr.set(i, k, qr.get(i, k) / nrm);\n        }\n        qr.set(k, k, qr.get(k, k) + 1);\n        for (j = k + 1; j < n; j++) {\n          s = 0;\n          for (i = k; i < m; i++) {\n            s += qr.get(i, k) * qr.get(i, j);\n          }\n          s = -s / qr.get(k, k);\n          for (i = k; i < m; i++) {\n            qr.set(i, j, qr.get(i, j) + s * qr.get(i, k));\n          }\n        }\n      }\n      rdiag[k] = -nrm;\n    }\n\n    this.QR = qr;\n    this.Rdiag = rdiag;\n  }\n\n  solve(value) {\n    value = Matrix.checkMatrix(value);\n\n    let qr = this.QR;\n    let m = qr.rows;\n\n    if (value.rows !== m) {\n      throw new Error('Matrix row dimensions must agree');\n    }\n    if (!this.isFullRank()) {\n      throw new Error('Matrix is rank deficient');\n    }\n\n    let count = value.columns;\n    let X = value.clone();\n    let n = qr.columns;\n    let i, j, k, s;\n\n    for (k = 0; k < n; k++) {\n      for (j = 0; j < count; j++) {\n        s = 0;\n        for (i = k; i < m; i++) {\n          s += qr.get(i, k) * X.get(i, j);\n        }\n        s = -s / qr.get(k, k);\n        for (i = k; i < m; i++) {\n          X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n        }\n      }\n    }\n    for (k = n - 1; k >= 0; k--) {\n      for (j = 0; j < count; j++) {\n        X.set(k, j, X.get(k, j) / this.Rdiag[k]);\n      }\n      for (i = 0; i < k; i++) {\n        for (j = 0; j < count; j++) {\n          X.set(i, j, X.get(i, j) - X.get(k, j) * qr.get(i, k));\n        }\n      }\n    }\n\n    return X.subMatrix(0, n - 1, 0, count - 1);\n  }\n\n  isFullRank() {\n    let columns = this.QR.columns;\n    for (let i = 0; i < columns; i++) {\n      if (this.Rdiag[i] === 0) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  get upperTriangularMatrix() {\n    let qr = this.QR;\n    let n = qr.columns;\n    let X = new Matrix(n, n);\n    let i, j;\n    for (i = 0; i < n; i++) {\n      for (j = 0; j < n; j++) {\n        if (i < j) {\n          X.set(i, j, qr.get(i, j));\n        } else if (i === j) {\n          X.set(i, j, this.Rdiag[i]);\n        } else {\n          X.set(i, j, 0);\n        }\n      }\n    }\n    return X;\n  }\n\n  get orthogonalMatrix() {\n    let qr = this.QR;\n    let rows = qr.rows;\n    let columns = qr.columns;\n    let X = new Matrix(rows, columns);\n    let i, j, k, s;\n\n    for (k = columns - 1; k >= 0; k--) {\n      for (i = 0; i < rows; i++) {\n        X.set(i, k, 0);\n      }\n      X.set(k, k, 1);\n      for (j = k; j < columns; j++) {\n        if (qr.get(k, k) !== 0) {\n          s = 0;\n          for (i = k; i < rows; i++) {\n            s += qr.get(i, k) * X.get(i, j);\n          }\n\n          s = -s / qr.get(k, k);\n\n          for (i = k; i < rows; i++) {\n            X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n          }\n        }\n      }\n    }\n    return X;\n  }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class SingularValueDecomposition {\n  constructor(value, options = {}) {\n    value = WrapperMatrix2D.checkMatrix(value);\n\n    if (value.isEmpty()) {\n      throw new Error('Matrix must be non-empty');\n    }\n\n    let m = value.rows;\n    let n = value.columns;\n\n    const {\n      computeLeftSingularVectors = true,\n      computeRightSingularVectors = true,\n      autoTranspose = false,\n    } = options;\n\n    let wantu = Boolean(computeLeftSingularVectors);\n    let wantv = Boolean(computeRightSingularVectors);\n\n    let swapped = false;\n    let a;\n    if (m < n) {\n      if (!autoTranspose) {\n        a = value.clone();\n        // eslint-disable-next-line no-console\n        console.warn(\n          'Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose',\n        );\n      } else {\n        a = value.transpose();\n        m = a.rows;\n        n = a.columns;\n        swapped = true;\n        let aux = wantu;\n        wantu = wantv;\n        wantv = aux;\n      }\n    } else {\n      a = value.clone();\n    }\n\n    let nu = Math.min(m, n);\n    let ni = Math.min(m + 1, n);\n    let s = new Float64Array(ni);\n    let U = new Matrix(m, nu);\n    let V = new Matrix(n, n);\n\n    let e = new Float64Array(n);\n    let work = new Float64Array(m);\n\n    let si = new Float64Array(ni);\n    for (let i = 0; i < ni; i++) si[i] = i;\n\n    let nct = Math.min(m - 1, n);\n    let nrt = Math.max(0, Math.min(n - 2, m));\n    let mrc = Math.max(nct, nrt);\n\n    for (let k = 0; k < mrc; k++) {\n      if (k < nct) {\n        s[k] = 0;\n        for (let i = k; i < m; i++) {\n          s[k] = hypotenuse(s[k], a.get(i, k));\n        }\n        if (s[k] !== 0) {\n          if (a.get(k, k) < 0) {\n            s[k] = -s[k];\n          }\n          for (let i = k; i < m; i++) {\n            a.set(i, k, a.get(i, k) / s[k]);\n          }\n          a.set(k, k, a.get(k, k) + 1);\n        }\n        s[k] = -s[k];\n      }\n\n      for (let j = k + 1; j < n; j++) {\n        if (k < nct && s[k] !== 0) {\n          let t = 0;\n          for (let i = k; i < m; i++) {\n            t += a.get(i, k) * a.get(i, j);\n          }\n          t = -t / a.get(k, k);\n          for (let i = k; i < m; i++) {\n            a.set(i, j, a.get(i, j) + t * a.get(i, k));\n          }\n        }\n        e[j] = a.get(k, j);\n      }\n\n      if (wantu && k < nct) {\n        for (let i = k; i < m; i++) {\n          U.set(i, k, a.get(i, k));\n        }\n      }\n\n      if (k < nrt) {\n        e[k] = 0;\n        for (let i = k + 1; i < n; i++) {\n          e[k] = hypotenuse(e[k], e[i]);\n        }\n        if (e[k] !== 0) {\n          if (e[k + 1] < 0) {\n            e[k] = 0 - e[k];\n          }\n          for (let i = k + 1; i < n; i++) {\n            e[i] /= e[k];\n          }\n          e[k + 1] += 1;\n        }\n        e[k] = -e[k];\n        if (k + 1 < m && e[k] !== 0) {\n          for (let i = k + 1; i < m; i++) {\n            work[i] = 0;\n          }\n          for (let i = k + 1; i < m; i++) {\n            for (let j = k + 1; j < n; j++) {\n              work[i] += e[j] * a.get(i, j);\n            }\n          }\n          for (let j = k + 1; j < n; j++) {\n            let t = -e[j] / e[k + 1];\n            for (let i = k + 1; i < m; i++) {\n              a.set(i, j, a.get(i, j) + t * work[i]);\n            }\n          }\n        }\n        if (wantv) {\n          for (let i = k + 1; i < n; i++) {\n            V.set(i, k, e[i]);\n          }\n        }\n      }\n    }\n\n    let p = Math.min(n, m + 1);\n    if (nct < n) {\n      s[nct] = a.get(nct, nct);\n    }\n    if (m < p) {\n      s[p - 1] = 0;\n    }\n    if (nrt + 1 < p) {\n      e[nrt] = a.get(nrt, p - 1);\n    }\n    e[p - 1] = 0;\n\n    if (wantu) {\n      for (let j = nct; j < nu; j++) {\n        for (let i = 0; i < m; i++) {\n          U.set(i, j, 0);\n        }\n        U.set(j, j, 1);\n      }\n      for (let k = nct - 1; k >= 0; k--) {\n        if (s[k] !== 0) {\n          for (let j = k + 1; j < nu; j++) {\n            let t = 0;\n            for (let i = k; i < m; i++) {\n              t += U.get(i, k) * U.get(i, j);\n            }\n            t = -t / U.get(k, k);\n            for (let i = k; i < m; i++) {\n              U.set(i, j, U.get(i, j) + t * U.get(i, k));\n            }\n          }\n          for (let i = k; i < m; i++) {\n            U.set(i, k, -U.get(i, k));\n          }\n          U.set(k, k, 1 + U.get(k, k));\n          for (let i = 0; i < k - 1; i++) {\n            U.set(i, k, 0);\n          }\n        } else {\n          for (let i = 0; i < m; i++) {\n            U.set(i, k, 0);\n          }\n          U.set(k, k, 1);\n        }\n      }\n    }\n\n    if (wantv) {\n      for (let k = n - 1; k >= 0; k--) {\n        if (k < nrt && e[k] !== 0) {\n          for (let j = k + 1; j < n; j++) {\n            let t = 0;\n            for (let i = k + 1; i < n; i++) {\n              t += V.get(i, k) * V.get(i, j);\n            }\n            t = -t / V.get(k + 1, k);\n            for (let i = k + 1; i < n; i++) {\n              V.set(i, j, V.get(i, j) + t * V.get(i, k));\n            }\n          }\n        }\n        for (let i = 0; i < n; i++) {\n          V.set(i, k, 0);\n        }\n        V.set(k, k, 1);\n      }\n    }\n\n    let pp = p - 1;\n    let iter = 0;\n    let eps = Number.EPSILON;\n    while (p > 0) {\n      let k, kase;\n      for (k = p - 2; k >= -1; k--) {\n        if (k === -1) {\n          break;\n        }\n        const alpha =\n          Number.MIN_VALUE + eps * Math.abs(s[k] + Math.abs(s[k + 1]));\n        if (Math.abs(e[k]) <= alpha || Number.isNaN(e[k])) {\n          e[k] = 0;\n          break;\n        }\n      }\n      if (k === p - 2) {\n        kase = 4;\n      } else {\n        let ks;\n        for (ks = p - 1; ks >= k; ks--) {\n          if (ks === k) {\n            break;\n          }\n          let t =\n            (ks !== p ? Math.abs(e[ks]) : 0) +\n            (ks !== k + 1 ? Math.abs(e[ks - 1]) : 0);\n          if (Math.abs(s[ks]) <= eps * t) {\n            s[ks] = 0;\n            break;\n          }\n        }\n        if (ks === k) {\n          kase = 3;\n        } else if (ks === p - 1) {\n          kase = 1;\n        } else {\n          kase = 2;\n          k = ks;\n        }\n      }\n\n      k++;\n\n      switch (kase) {\n        case 1: {\n          let f = e[p - 2];\n          e[p - 2] = 0;\n          for (let j = p - 2; j >= k; j--) {\n            let t = hypotenuse(s[j], f);\n            let cs = s[j] / t;\n            let sn = f / t;\n            s[j] = t;\n            if (j !== k) {\n              f = -sn * e[j - 1];\n              e[j - 1] = cs * e[j - 1];\n            }\n            if (wantv) {\n              for (let i = 0; i < n; i++) {\n                t = cs * V.get(i, j) + sn * V.get(i, p - 1);\n                V.set(i, p - 1, -sn * V.get(i, j) + cs * V.get(i, p - 1));\n                V.set(i, j, t);\n              }\n            }\n          }\n          break;\n        }\n        case 2: {\n          let f = e[k - 1];\n          e[k - 1] = 0;\n          for (let j = k; j < p; j++) {\n            let t = hypotenuse(s[j], f);\n            let cs = s[j] / t;\n            let sn = f / t;\n            s[j] = t;\n            f = -sn * e[j];\n            e[j] = cs * e[j];\n            if (wantu) {\n              for (let i = 0; i < m; i++) {\n                t = cs * U.get(i, j) + sn * U.get(i, k - 1);\n                U.set(i, k - 1, -sn * U.get(i, j) + cs * U.get(i, k - 1));\n                U.set(i, j, t);\n              }\n            }\n          }\n          break;\n        }\n        case 3: {\n          const scale = Math.max(\n            Math.abs(s[p - 1]),\n            Math.abs(s[p - 2]),\n            Math.abs(e[p - 2]),\n            Math.abs(s[k]),\n            Math.abs(e[k]),\n          );\n          const sp = s[p - 1] / scale;\n          const spm1 = s[p - 2] / scale;\n          const epm1 = e[p - 2] / scale;\n          const sk = s[k] / scale;\n          const ek = e[k] / scale;\n          const b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2;\n          const c = sp * epm1 * (sp * epm1);\n          let shift = 0;\n          if (b !== 0 || c !== 0) {\n            if (b < 0) {\n              shift = 0 - Math.sqrt(b * b + c);\n            } else {\n              shift = Math.sqrt(b * b + c);\n            }\n            shift = c / (b + shift);\n          }\n          let f = (sk + sp) * (sk - sp) + shift;\n          let g = sk * ek;\n          for (let j = k; j < p - 1; j++) {\n            let t = hypotenuse(f, g);\n            if (t === 0) t = Number.MIN_VALUE;\n            let cs = f / t;\n            let sn = g / t;\n            if (j !== k) {\n              e[j - 1] = t;\n            }\n            f = cs * s[j] + sn * e[j];\n            e[j] = cs * e[j] - sn * s[j];\n            g = sn * s[j + 1];\n            s[j + 1] = cs * s[j + 1];\n            if (wantv) {\n              for (let i = 0; i < n; i++) {\n                t = cs * V.get(i, j) + sn * V.get(i, j + 1);\n                V.set(i, j + 1, -sn * V.get(i, j) + cs * V.get(i, j + 1));\n                V.set(i, j, t);\n              }\n            }\n            t = hypotenuse(f, g);\n            if (t === 0) t = Number.MIN_VALUE;\n            cs = f / t;\n            sn = g / t;\n            s[j] = t;\n            f = cs * e[j] + sn * s[j + 1];\n            s[j + 1] = -sn * e[j] + cs * s[j + 1];\n            g = sn * e[j + 1];\n            e[j + 1] = cs * e[j + 1];\n            if (wantu && j < m - 1) {\n              for (let i = 0; i < m; i++) {\n                t = cs * U.get(i, j) + sn * U.get(i, j + 1);\n                U.set(i, j + 1, -sn * U.get(i, j) + cs * U.get(i, j + 1));\n                U.set(i, j, t);\n              }\n            }\n          }\n          e[p - 2] = f;\n          iter = iter + 1;\n          break;\n        }\n        case 4: {\n          if (s[k] <= 0) {\n            s[k] = s[k] < 0 ? -s[k] : 0;\n            if (wantv) {\n              for (let i = 0; i <= pp; i++) {\n                V.set(i, k, -V.get(i, k));\n              }\n            }\n          }\n          while (k < pp) {\n            if (s[k] >= s[k + 1]) {\n              break;\n            }\n            let t = s[k];\n            s[k] = s[k + 1];\n            s[k + 1] = t;\n            if (wantv && k < n - 1) {\n              for (let i = 0; i < n; i++) {\n                t = V.get(i, k + 1);\n                V.set(i, k + 1, V.get(i, k));\n                V.set(i, k, t);\n              }\n            }\n            if (wantu && k < m - 1) {\n              for (let i = 0; i < m; i++) {\n                t = U.get(i, k + 1);\n                U.set(i, k + 1, U.get(i, k));\n                U.set(i, k, t);\n              }\n            }\n            k++;\n          }\n          iter = 0;\n          p--;\n          break;\n        }\n        // no default\n      }\n    }\n\n    if (swapped) {\n      let tmp = V;\n      V = U;\n      U = tmp;\n    }\n\n    this.m = m;\n    this.n = n;\n    this.s = s;\n    this.U = U;\n    this.V = V;\n  }\n\n  solve(value) {\n    let Y = value;\n    let e = this.threshold;\n    let scols = this.s.length;\n    let Ls = Matrix.zeros(scols, scols);\n\n    for (let i = 0; i < scols; i++) {\n      if (Math.abs(this.s[i]) <= e) {\n        Ls.set(i, i, 0);\n      } else {\n        Ls.set(i, i, 1 / this.s[i]);\n      }\n    }\n\n    let U = this.U;\n    let V = this.rightSingularVectors;\n\n    let VL = V.mmul(Ls);\n    let vrows = V.rows;\n    let urows = U.rows;\n    let VLU = Matrix.zeros(vrows, urows);\n\n    for (let i = 0; i < vrows; i++) {\n      for (let j = 0; j < urows; j++) {\n        let sum = 0;\n        for (let k = 0; k < scols; k++) {\n          sum += VL.get(i, k) * U.get(j, k);\n        }\n        VLU.set(i, j, sum);\n      }\n    }\n\n    return VLU.mmul(Y);\n  }\n\n  solveForDiagonal(value) {\n    return this.solve(Matrix.diag(value));\n  }\n\n  inverse() {\n    let V = this.V;\n    let e = this.threshold;\n    let vrows = V.rows;\n    let vcols = V.columns;\n    let X = new Matrix(vrows, this.s.length);\n\n    for (let i = 0; i < vrows; i++) {\n      for (let j = 0; j < vcols; j++) {\n        if (Math.abs(this.s[j]) > e) {\n          X.set(i, j, V.get(i, j) / this.s[j]);\n        }\n      }\n    }\n\n    let U = this.U;\n\n    let urows = U.rows;\n    let ucols = U.columns;\n    let Y = new Matrix(vrows, urows);\n\n    for (let i = 0; i < vrows; i++) {\n      for (let j = 0; j < urows; j++) {\n        let sum = 0;\n        for (let k = 0; k < ucols; k++) {\n          sum += X.get(i, k) * U.get(j, k);\n        }\n        Y.set(i, j, sum);\n      }\n    }\n\n    return Y;\n  }\n\n  get condition() {\n    return this.s[0] / this.s[Math.min(this.m, this.n) - 1];\n  }\n\n  get norm2() {\n    return this.s[0];\n  }\n\n  get rank() {\n    let tol = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON;\n    let r = 0;\n    let s = this.s;\n    for (let i = 0, ii = s.length; i < ii; i++) {\n      if (s[i] > tol) {\n        r++;\n      }\n    }\n    return r;\n  }\n\n  get diagonal() {\n    return Array.from(this.s);\n  }\n\n  get threshold() {\n    return (Number.EPSILON / 2) * Math.max(this.m, this.n) * this.s[0];\n  }\n\n  get leftSingularVectors() {\n    return this.U;\n  }\n\n  get rightSingularVectors() {\n    return this.V;\n  }\n\n  get diagonalMatrix() {\n    return Matrix.diag(this.s);\n  }\n}\n","import LuDecomposition from './dc/lu';\nimport QrDecomposition from './dc/qr';\nimport SingularValueDecomposition from './dc/svd';\nimport Matrix from './matrix';\nimport WrapperMatrix2D from './wrap/WrapperMatrix2D';\n\nexport function inverse(matrix, useSVD = false) {\n  matrix = WrapperMatrix2D.checkMatrix(matrix);\n  if (useSVD) {\n    return new SingularValueDecomposition(matrix).inverse();\n  } else {\n    return solve(matrix, Matrix.eye(matrix.rows));\n  }\n}\n\nexport function solve(leftHandSide, rightHandSide, useSVD = false) {\n  leftHandSide = WrapperMatrix2D.checkMatrix(leftHandSide);\n  rightHandSide = WrapperMatrix2D.checkMatrix(rightHandSide);\n  if (useSVD) {\n    return new SingularValueDecomposition(leftHandSide).solve(rightHandSide);\n  } else {\n    return leftHandSide.isSquare()\n      ? new LuDecomposition(leftHandSide).solve(rightHandSide)\n      : new QrDecomposition(leftHandSide).solve(rightHandSide);\n  }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class EigenvalueDecomposition {\n  constructor(matrix, options = {}) {\n    const { assumeSymmetric = false } = options;\n\n    matrix = WrapperMatrix2D.checkMatrix(matrix);\n    if (!matrix.isSquare()) {\n      throw new Error('Matrix is not a square matrix');\n    }\n\n    if (matrix.isEmpty()) {\n      throw new Error('Matrix must be non-empty');\n    }\n\n    let n = matrix.columns;\n    let V = new Matrix(n, n);\n    let d = new Float64Array(n);\n    let e = new Float64Array(n);\n    let value = matrix;\n    let i, j;\n\n    let isSymmetric = false;\n    if (assumeSymmetric) {\n      isSymmetric = true;\n    } else {\n      isSymmetric = matrix.isSymmetric();\n    }\n\n    if (isSymmetric) {\n      for (i = 0; i < n; i++) {\n        for (j = 0; j < n; j++) {\n          V.set(i, j, value.get(i, j));\n        }\n      }\n      tred2(n, e, d, V);\n      tql2(n, e, d, V);\n    } else {\n      let H = new Matrix(n, n);\n      let ort = new Float64Array(n);\n      for (j = 0; j < n; j++) {\n        for (i = 0; i < n; i++) {\n          H.set(i, j, value.get(i, j));\n        }\n      }\n      orthes(n, H, ort, V);\n      hqr2(n, e, d, V, H);\n    }\n\n    this.n = n;\n    this.e = e;\n    this.d = d;\n    this.V = V;\n  }\n\n  get realEigenvalues() {\n    return Array.from(this.d);\n  }\n\n  get imaginaryEigenvalues() {\n    return Array.from(this.e);\n  }\n\n  get eigenvectorMatrix() {\n    return this.V;\n  }\n\n  get diagonalMatrix() {\n    let n = this.n;\n    let e = this.e;\n    let d = this.d;\n    let X = new Matrix(n, n);\n    let i, j;\n    for (i = 0; i < n; i++) {\n      for (j = 0; j < n; j++) {\n        X.set(i, j, 0);\n      }\n      X.set(i, i, d[i]);\n      if (e[i] > 0) {\n        X.set(i, i + 1, e[i]);\n      } else if (e[i] < 0) {\n        X.set(i, i - 1, e[i]);\n      }\n    }\n    return X;\n  }\n}\n\nfunction tred2(n, e, d, V) {\n  let f, g, h, i, j, k, hh, scale;\n\n  for (j = 0; j < n; j++) {\n    d[j] = V.get(n - 1, j);\n  }\n\n  for (i = n - 1; i > 0; i--) {\n    scale = 0;\n    h = 0;\n    for (k = 0; k < i; k++) {\n      scale = scale + Math.abs(d[k]);\n    }\n\n    if (scale === 0) {\n      e[i] = d[i - 1];\n      for (j = 0; j < i; j++) {\n        d[j] = V.get(i - 1, j);\n        V.set(i, j, 0);\n        V.set(j, i, 0);\n      }\n    } else {\n      for (k = 0; k < i; k++) {\n        d[k] /= scale;\n        h += d[k] * d[k];\n      }\n\n      f = d[i - 1];\n      g = Math.sqrt(h);\n      if (f > 0) {\n        g = -g;\n      }\n\n      e[i] = scale * g;\n      h = h - f * g;\n      d[i - 1] = f - g;\n      for (j = 0; j < i; j++) {\n        e[j] = 0;\n      }\n\n      for (j = 0; j < i; j++) {\n        f = d[j];\n        V.set(j, i, f);\n        g = e[j] + V.get(j, j) * f;\n        for (k = j + 1; k <= i - 1; k++) {\n          g += V.get(k, j) * d[k];\n          e[k] += V.get(k, j) * f;\n        }\n        e[j] = g;\n      }\n\n      f = 0;\n      for (j = 0; j < i; j++) {\n        e[j] /= h;\n        f += e[j] * d[j];\n      }\n\n      hh = f / (h + h);\n      for (j = 0; j < i; j++) {\n        e[j] -= hh * d[j];\n      }\n\n      for (j = 0; j < i; j++) {\n        f = d[j];\n        g = e[j];\n        for (k = j; k <= i - 1; k++) {\n          V.set(k, j, V.get(k, j) - (f * e[k] + g * d[k]));\n        }\n        d[j] = V.get(i - 1, j);\n        V.set(i, j, 0);\n      }\n    }\n    d[i] = h;\n  }\n\n  for (i = 0; i < n - 1; i++) {\n    V.set(n - 1, i, V.get(i, i));\n    V.set(i, i, 1);\n    h = d[i + 1];\n    if (h !== 0) {\n      for (k = 0; k <= i; k++) {\n        d[k] = V.get(k, i + 1) / h;\n      }\n\n      for (j = 0; j <= i; j++) {\n        g = 0;\n        for (k = 0; k <= i; k++) {\n          g += V.get(k, i + 1) * V.get(k, j);\n        }\n        for (k = 0; k <= i; k++) {\n          V.set(k, j, V.get(k, j) - g * d[k]);\n        }\n      }\n    }\n\n    for (k = 0; k <= i; k++) {\n      V.set(k, i + 1, 0);\n    }\n  }\n\n  for (j = 0; j < n; j++) {\n    d[j] = V.get(n - 1, j);\n    V.set(n - 1, j, 0);\n  }\n\n  V.set(n - 1, n - 1, 1);\n  e[0] = 0;\n}\n\nfunction tql2(n, e, d, V) {\n  let g, h, i, j, k, l, m, p, r, dl1, c, c2, c3, el1, s, s2, iter;\n\n  for (i = 1; i < n; i++) {\n    e[i - 1] = e[i];\n  }\n\n  e[n - 1] = 0;\n\n  let f = 0;\n  let tst1 = 0;\n  let eps = Number.EPSILON;\n\n  for (l = 0; l < n; l++) {\n    tst1 = Math.max(tst1, Math.abs(d[l]) + Math.abs(e[l]));\n    m = l;\n    while (m < n) {\n      if (Math.abs(e[m]) <= eps * tst1) {\n        break;\n      }\n      m++;\n    }\n\n    if (m > l) {\n      iter = 0;\n      do {\n        iter = iter + 1;\n\n        g = d[l];\n        p = (d[l + 1] - g) / (2 * e[l]);\n        r = hypotenuse(p, 1);\n        if (p < 0) {\n          r = -r;\n        }\n\n        d[l] = e[l] / (p + r);\n        d[l + 1] = e[l] * (p + r);\n        dl1 = d[l + 1];\n        h = g - d[l];\n        for (i = l + 2; i < n; i++) {\n          d[i] -= h;\n        }\n\n        f = f + h;\n\n        p = d[m];\n        c = 1;\n        c2 = c;\n        c3 = c;\n        el1 = e[l + 1];\n        s = 0;\n        s2 = 0;\n        for (i = m - 1; i >= l; i--) {\n          c3 = c2;\n          c2 = c;\n          s2 = s;\n          g = c * e[i];\n          h = c * p;\n          r = hypotenuse(p, e[i]);\n          e[i + 1] = s * r;\n          s = e[i] / r;\n          c = p / r;\n          p = c * d[i] - s * g;\n          d[i + 1] = h + s * (c * g + s * d[i]);\n\n          for (k = 0; k < n; k++) {\n            h = V.get(k, i + 1);\n            V.set(k, i + 1, s * V.get(k, i) + c * h);\n            V.set(k, i, c * V.get(k, i) - s * h);\n          }\n        }\n\n        p = (-s * s2 * c3 * el1 * e[l]) / dl1;\n        e[l] = s * p;\n        d[l] = c * p;\n      } while (Math.abs(e[l]) > eps * tst1);\n    }\n    d[l] = d[l] + f;\n    e[l] = 0;\n  }\n\n  for (i = 0; i < n - 1; i++) {\n    k = i;\n    p = d[i];\n    for (j = i + 1; j < n; j++) {\n      if (d[j] < p) {\n        k = j;\n        p = d[j];\n      }\n    }\n\n    if (k !== i) {\n      d[k] = d[i];\n      d[i] = p;\n      for (j = 0; j < n; j++) {\n        p = V.get(j, i);\n        V.set(j, i, V.get(j, k));\n        V.set(j, k, p);\n      }\n    }\n  }\n}\n\nfunction orthes(n, H, ort, V) {\n  let low = 0;\n  let high = n - 1;\n  let f, g, h, i, j, m;\n  let scale;\n\n  for (m = low + 1; m <= high - 1; m++) {\n    scale = 0;\n    for (i = m; i <= high; i++) {\n      scale = scale + Math.abs(H.get(i, m - 1));\n    }\n\n    if (scale !== 0) {\n      h = 0;\n      for (i = high; i >= m; i--) {\n        ort[i] = H.get(i, m - 1) / scale;\n        h += ort[i] * ort[i];\n      }\n\n      g = Math.sqrt(h);\n      if (ort[m] > 0) {\n        g = -g;\n      }\n\n      h = h - ort[m] * g;\n      ort[m] = ort[m] - g;\n\n      for (j = m; j < n; j++) {\n        f = 0;\n        for (i = high; i >= m; i--) {\n          f += ort[i] * H.get(i, j);\n        }\n\n        f = f / h;\n        for (i = m; i <= high; i++) {\n          H.set(i, j, H.get(i, j) - f * ort[i]);\n        }\n      }\n\n      for (i = 0; i <= high; i++) {\n        f = 0;\n        for (j = high; j >= m; j--) {\n          f += ort[j] * H.get(i, j);\n        }\n\n        f = f / h;\n        for (j = m; j <= high; j++) {\n          H.set(i, j, H.get(i, j) - f * ort[j]);\n        }\n      }\n\n      ort[m] = scale * ort[m];\n      H.set(m, m - 1, scale * g);\n    }\n  }\n\n  for (i = 0; i < n; i++) {\n    for (j = 0; j < n; j++) {\n      V.set(i, j, i === j ? 1 : 0);\n    }\n  }\n\n  for (m = high - 1; m >= low + 1; m--) {\n    if (H.get(m, m - 1) !== 0) {\n      for (i = m + 1; i <= high; i++) {\n        ort[i] = H.get(i, m - 1);\n      }\n\n      for (j = m; j <= high; j++) {\n        g = 0;\n        for (i = m; i <= high; i++) {\n          g += ort[i] * V.get(i, j);\n        }\n\n        g = g / ort[m] / H.get(m, m - 1);\n        for (i = m; i <= high; i++) {\n          V.set(i, j, V.get(i, j) + g * ort[i]);\n        }\n      }\n    }\n  }\n}\n\nfunction hqr2(nn, e, d, V, H) {\n  let n = nn - 1;\n  let low = 0;\n  let high = nn - 1;\n  let eps = Number.EPSILON;\n  let exshift = 0;\n  let norm = 0;\n  let p = 0;\n  let q = 0;\n  let r = 0;\n  let s = 0;\n  let z = 0;\n  let iter = 0;\n  let i, j, k, l, m, t, w, x, y;\n  let ra, sa, vr, vi;\n  let notlast, cdivres;\n\n  for (i = 0; i < nn; i++) {\n    if (i < low || i > high) {\n      d[i] = H.get(i, i);\n      e[i] = 0;\n    }\n\n    for (j = Math.max(i - 1, 0); j < nn; j++) {\n      norm = norm + Math.abs(H.get(i, j));\n    }\n  }\n\n  while (n >= low) {\n    l = n;\n    while (l > low) {\n      s = Math.abs(H.get(l - 1, l - 1)) + Math.abs(H.get(l, l));\n      if (s === 0) {\n        s = norm;\n      }\n      if (Math.abs(H.get(l, l - 1)) < eps * s) {\n        break;\n      }\n      l--;\n    }\n\n    if (l === n) {\n      H.set(n, n, H.get(n, n) + exshift);\n      d[n] = H.get(n, n);\n      e[n] = 0;\n      n--;\n      iter = 0;\n    } else if (l === n - 1) {\n      w = H.get(n, n - 1) * H.get(n - 1, n);\n      p = (H.get(n - 1, n - 1) - H.get(n, n)) / 2;\n      q = p * p + w;\n      z = Math.sqrt(Math.abs(q));\n      H.set(n, n, H.get(n, n) + exshift);\n      H.set(n - 1, n - 1, H.get(n - 1, n - 1) + exshift);\n      x = H.get(n, n);\n\n      if (q >= 0) {\n        z = p >= 0 ? p + z : p - z;\n        d[n - 1] = x + z;\n        d[n] = d[n - 1];\n        if (z !== 0) {\n          d[n] = x - w / z;\n        }\n        e[n - 1] = 0;\n        e[n] = 0;\n        x = H.get(n, n - 1);\n        s = Math.abs(x) + Math.abs(z);\n        p = x / s;\n        q = z / s;\n        r = Math.sqrt(p * p + q * q);\n        p = p / r;\n        q = q / r;\n\n        for (j = n - 1; j < nn; j++) {\n          z = H.get(n - 1, j);\n          H.set(n - 1, j, q * z + p * H.get(n, j));\n          H.set(n, j, q * H.get(n, j) - p * z);\n        }\n\n        for (i = 0; i <= n; i++) {\n          z = H.get(i, n - 1);\n          H.set(i, n - 1, q * z + p * H.get(i, n));\n          H.set(i, n, q * H.get(i, n) - p * z);\n        }\n\n        for (i = low; i <= high; i++) {\n          z = V.get(i, n - 1);\n          V.set(i, n - 1, q * z + p * V.get(i, n));\n          V.set(i, n, q * V.get(i, n) - p * z);\n        }\n      } else {\n        d[n - 1] = x + p;\n        d[n] = x + p;\n        e[n - 1] = z;\n        e[n] = -z;\n      }\n\n      n = n - 2;\n      iter = 0;\n    } else {\n      x = H.get(n, n);\n      y = 0;\n      w = 0;\n      if (l < n) {\n        y = H.get(n - 1, n - 1);\n        w = H.get(n, n - 1) * H.get(n - 1, n);\n      }\n\n      if (iter === 10) {\n        exshift += x;\n        for (i = low; i <= n; i++) {\n          H.set(i, i, H.get(i, i) - x);\n        }\n        s = Math.abs(H.get(n, n - 1)) + Math.abs(H.get(n - 1, n - 2));\n        x = y = 0.75 * s;\n        w = -0.4375 * s * s;\n      }\n\n      if (iter === 30) {\n        s = (y - x) / 2;\n        s = s * s + w;\n        if (s > 0) {\n          s = Math.sqrt(s);\n          if (y < x) {\n            s = -s;\n          }\n          s = x - w / ((y - x) / 2 + s);\n          for (i = low; i <= n; i++) {\n            H.set(i, i, H.get(i, i) - s);\n          }\n          exshift += s;\n          x = y = w = 0.964;\n        }\n      }\n\n      iter = iter + 1;\n\n      m = n - 2;\n      while (m >= l) {\n        z = H.get(m, m);\n        r = x - z;\n        s = y - z;\n        p = (r * s - w) / H.get(m + 1, m) + H.get(m, m + 1);\n        q = H.get(m + 1, m + 1) - z - r - s;\n        r = H.get(m + 2, m + 1);\n        s = Math.abs(p) + Math.abs(q) + Math.abs(r);\n        p = p / s;\n        q = q / s;\n        r = r / s;\n        if (m === l) {\n          break;\n        }\n        if (\n          Math.abs(H.get(m, m - 1)) * (Math.abs(q) + Math.abs(r)) <\n          eps *\n            (Math.abs(p) *\n              (Math.abs(H.get(m - 1, m - 1)) +\n                Math.abs(z) +\n                Math.abs(H.get(m + 1, m + 1))))\n        ) {\n          break;\n        }\n        m--;\n      }\n\n      for (i = m + 2; i <= n; i++) {\n        H.set(i, i - 2, 0);\n        if (i > m + 2) {\n          H.set(i, i - 3, 0);\n        }\n      }\n\n      for (k = m; k <= n - 1; k++) {\n        notlast = k !== n - 1;\n        if (k !== m) {\n          p = H.get(k, k - 1);\n          q = H.get(k + 1, k - 1);\n          r = notlast ? H.get(k + 2, k - 1) : 0;\n          x = Math.abs(p) + Math.abs(q) + Math.abs(r);\n          if (x !== 0) {\n            p = p / x;\n            q = q / x;\n            r = r / x;\n          }\n        }\n\n        if (x === 0) {\n          break;\n        }\n\n        s = Math.sqrt(p * p + q * q + r * r);\n        if (p < 0) {\n          s = -s;\n        }\n\n        if (s !== 0) {\n          if (k !== m) {\n            H.set(k, k - 1, -s * x);\n          } else if (l !== m) {\n            H.set(k, k - 1, -H.get(k, k - 1));\n          }\n\n          p = p + s;\n          x = p / s;\n          y = q / s;\n          z = r / s;\n          q = q / p;\n          r = r / p;\n\n          for (j = k; j < nn; j++) {\n            p = H.get(k, j) + q * H.get(k + 1, j);\n            if (notlast) {\n              p = p + r * H.get(k + 2, j);\n              H.set(k + 2, j, H.get(k + 2, j) - p * z);\n            }\n\n            H.set(k, j, H.get(k, j) - p * x);\n            H.set(k + 1, j, H.get(k + 1, j) - p * y);\n          }\n\n          for (i = 0; i <= Math.min(n, k + 3); i++) {\n            p = x * H.get(i, k) + y * H.get(i, k + 1);\n            if (notlast) {\n              p = p + z * H.get(i, k + 2);\n              H.set(i, k + 2, H.get(i, k + 2) - p * r);\n            }\n\n            H.set(i, k, H.get(i, k) - p);\n            H.set(i, k + 1, H.get(i, k + 1) - p * q);\n          }\n\n          for (i = low; i <= high; i++) {\n            p = x * V.get(i, k) + y * V.get(i, k + 1);\n            if (notlast) {\n              p = p + z * V.get(i, k + 2);\n              V.set(i, k + 2, V.get(i, k + 2) - p * r);\n            }\n\n            V.set(i, k, V.get(i, k) - p);\n            V.set(i, k + 1, V.get(i, k + 1) - p * q);\n          }\n        }\n      }\n    }\n  }\n\n  if (norm === 0) {\n    return;\n  }\n\n  for (n = nn - 1; n >= 0; n--) {\n    p = d[n];\n    q = e[n];\n\n    if (q === 0) {\n      l = n;\n      H.set(n, n, 1);\n      for (i = n - 1; i >= 0; i--) {\n        w = H.get(i, i) - p;\n        r = 0;\n        for (j = l; j <= n; j++) {\n          r = r + H.get(i, j) * H.get(j, n);\n        }\n\n        if (e[i] < 0) {\n          z = w;\n          s = r;\n        } else {\n          l = i;\n          if (e[i] === 0) {\n            H.set(i, n, w !== 0 ? -r / w : -r / (eps * norm));\n          } else {\n            x = H.get(i, i + 1);\n            y = H.get(i + 1, i);\n            q = (d[i] - p) * (d[i] - p) + e[i] * e[i];\n            t = (x * s - z * r) / q;\n            H.set(i, n, t);\n            H.set(\n              i + 1,\n              n,\n              Math.abs(x) > Math.abs(z) ? (-r - w * t) / x : (-s - y * t) / z,\n            );\n          }\n\n          t = Math.abs(H.get(i, n));\n          if (eps * t * t > 1) {\n            for (j = i; j <= n; j++) {\n              H.set(j, n, H.get(j, n) / t);\n            }\n          }\n        }\n      }\n    } else if (q < 0) {\n      l = n - 1;\n\n      if (Math.abs(H.get(n, n - 1)) > Math.abs(H.get(n - 1, n))) {\n        H.set(n - 1, n - 1, q / H.get(n, n - 1));\n        H.set(n - 1, n, -(H.get(n, n) - p) / H.get(n, n - 1));\n      } else {\n        cdivres = cdiv(0, -H.get(n - 1, n), H.get(n - 1, n - 1) - p, q);\n        H.set(n - 1, n - 1, cdivres[0]);\n        H.set(n - 1, n, cdivres[1]);\n      }\n\n      H.set(n, n - 1, 0);\n      H.set(n, n, 1);\n      for (i = n - 2; i >= 0; i--) {\n        ra = 0;\n        sa = 0;\n        for (j = l; j <= n; j++) {\n          ra = ra + H.get(i, j) * H.get(j, n - 1);\n          sa = sa + H.get(i, j) * H.get(j, n);\n        }\n\n        w = H.get(i, i) - p;\n\n        if (e[i] < 0) {\n          z = w;\n          r = ra;\n          s = sa;\n        } else {\n          l = i;\n          if (e[i] === 0) {\n            cdivres = cdiv(-ra, -sa, w, q);\n            H.set(i, n - 1, cdivres[0]);\n            H.set(i, n, cdivres[1]);\n          } else {\n            x = H.get(i, i + 1);\n            y = H.get(i + 1, i);\n            vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;\n            vi = (d[i] - p) * 2 * q;\n            if (vr === 0 && vi === 0) {\n              vr =\n                eps *\n                norm *\n                (Math.abs(w) +\n                  Math.abs(q) +\n                  Math.abs(x) +\n                  Math.abs(y) +\n                  Math.abs(z));\n            }\n            cdivres = cdiv(\n              x * r - z * ra + q * sa,\n              x * s - z * sa - q * ra,\n              vr,\n              vi,\n            );\n            H.set(i, n - 1, cdivres[0]);\n            H.set(i, n, cdivres[1]);\n            if (Math.abs(x) > Math.abs(z) + Math.abs(q)) {\n              H.set(\n                i + 1,\n                n - 1,\n                (-ra - w * H.get(i, n - 1) + q * H.get(i, n)) / x,\n              );\n              H.set(\n                i + 1,\n                n,\n                (-sa - w * H.get(i, n) - q * H.get(i, n - 1)) / x,\n              );\n            } else {\n              cdivres = cdiv(\n                -r - y * H.get(i, n - 1),\n                -s - y * H.get(i, n),\n                z,\n                q,\n              );\n              H.set(i + 1, n - 1, cdivres[0]);\n              H.set(i + 1, n, cdivres[1]);\n            }\n          }\n\n          t = Math.max(Math.abs(H.get(i, n - 1)), Math.abs(H.get(i, n)));\n          if (eps * t * t > 1) {\n            for (j = i; j <= n; j++) {\n              H.set(j, n - 1, H.get(j, n - 1) / t);\n              H.set(j, n, H.get(j, n) / t);\n            }\n          }\n        }\n      }\n    }\n  }\n\n  for (i = 0; i < nn; i++) {\n    if (i < low || i > high) {\n      for (j = i; j < nn; j++) {\n        V.set(i, j, H.get(i, j));\n      }\n    }\n  }\n\n  for (j = nn - 1; j >= low; j--) {\n    for (i = low; i <= high; i++) {\n      z = 0;\n      for (k = low; k <= Math.min(j, high); k++) {\n        z = z + V.get(i, k) * H.get(k, j);\n      }\n      V.set(i, j, z);\n    }\n  }\n}\n\nfunction cdiv(xr, xi, yr, yi) {\n  let r, d;\n  if (Math.abs(yr) > Math.abs(yi)) {\n    r = yi / yr;\n    d = yr + r * yi;\n    return [(xr + r * xi) / d, (xi - r * xr) / d];\n  } else {\n    r = yr / yi;\n    d = yi + r * yr;\n    return [(r * xr + xi) / d, (r * xi - xr) / d];\n  }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class nipals {\n  constructor(X, options = {}) {\n    X = WrapperMatrix2D.checkMatrix(X);\n    let { Y } = options;\n    const {\n      scaleScores = false,\n      maxIterations = 1000,\n      terminationCriteria = 1e-10,\n    } = options;\n\n    let u;\n    if (Y) {\n      if (Array.isArray(Y) && typeof Y[0] === 'number') {\n        Y = Matrix.columnVector(Y);\n      } else {\n        Y = WrapperMatrix2D.checkMatrix(Y);\n      }\n      if (Y.rows !== X.rows) {\n        throw new Error('Y should have the same number of rows as X');\n      }\n      u = Y.getColumnVector(0);\n    } else {\n      u = X.getColumnVector(0);\n    }\n\n    let diff = 1;\n    let t, q, w, tOld;\n\n    for (\n      let counter = 0;\n      counter < maxIterations && diff > terminationCriteria;\n      counter++\n    ) {\n      w = X.transpose().mmul(u).div(u.transpose().mmul(u).get(0, 0));\n      w = w.div(w.norm());\n\n      t = X.mmul(w).div(w.transpose().mmul(w).get(0, 0));\n\n      if (counter > 0) {\n        diff = t.clone().sub(tOld).pow(2).sum();\n      }\n      tOld = t.clone();\n\n      if (Y) {\n        q = Y.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n        q = q.div(q.norm());\n\n        u = Y.mmul(q).div(q.transpose().mmul(q).get(0, 0));\n      } else {\n        u = t;\n      }\n    }\n\n    if (Y) {\n      let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n      p = p.div(p.norm());\n      let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n      let residual = u.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n      let yResidual = Y.clone().sub(\n        t.clone().mulS(residual.get(0, 0)).mmul(q.transpose()),\n      );\n\n      this.t = t;\n      this.p = p.transpose();\n      this.w = w.transpose();\n      this.q = q;\n      this.u = u;\n      this.s = t.transpose().mmul(t);\n      this.xResidual = xResidual;\n      this.yResidual = yResidual;\n      this.betas = residual;\n    } else {\n      this.w = w.transpose();\n      this.s = t.transpose().mmul(t).sqrt();\n      if (scaleScores) {\n        this.t = t.clone().div(this.s.get(0, 0));\n      } else {\n        this.t = t;\n      }\n      this.xResidual = X.sub(t.mmul(w.transpose()));\n    }\n  }\n}\n","/**\n * This method will allow to enlarge peaks and prevent overlap between peaks\n * Because peaks may not be symmetric after we add 2 properties, from and to.\n * @param {Array} peakList\n * @param {object} [options={}]\n * @param {number} [options.factor=2]\n * @param {boolean} [options.overlap=false] by default we don't allow overlap\n * @return {Array} peakList\n */\nexport function broadenPeaks(peakList, options = {}) {\n  const { factor = 2, overlap = false } = options;\n\n  for (let peak of peakList) {\n    if (!peak.right || !peak.left) {\n      peak.from = peak.x - (peak.width / 2) * factor;\n      peak.to = peak.x + (peak.width / 2) * factor;\n    } else {\n      peak.from = peak.x - (peak.x - peak.left.x) * factor;\n      peak.to = peak.x + (peak.right.x - peak.x) * factor;\n    }\n  }\n\n  if (!overlap) {\n    for (let i = 0; i < peakList.length - 1; i++) {\n      let peak = peakList[i];\n      let nextPeak = peakList[i + 1];\n      if (peak.to > nextPeak.from) {\n        peak.to = nextPeak.from = (peak.to + nextPeak.from) / 2;\n      }\n    }\n  }\n\n  for (let peak of peakList) {\n    peak.width = peak.to - peak.from;\n  }\n\n  return peakList;\n}\n","import { xIsMonotone } from '../x/xIsMonotone';\n/**\nimport { xIsMonotone } from '../x/xIsMonotone';\n * This function performs a quick sort of the x array while transforming the y array to preserve the coordinates.\n * @param {DataXY} [data] Object that contains property x (Array) and y (Array)\n */\nexport function xySortX(data) {\n  const { x, y } = data;\n\n  // no need to sort if it is already sorted\n  if (xIsMonotone(x) && x.length > 1) {\n    if (x[0] < x[1]) {\n      return {\n        x: Float64Array.from(x),\n        y: Float64Array.from(y),\n      };\n    } else {\n      return {\n        x: Float64Array.from(x).reverse(),\n        y: Float64Array.from(y).reverse(),\n      };\n    }\n  }\n\n  let xyObject = x\n    .map((val, index) => ({\n      x: val,\n      y: y[index],\n    }))\n    .sort((a, b) => a.x - b.x);\n\n  let response = {\n    x: new Float64Array(x.length),\n    y: new Float64Array(y.length),\n  };\n  for (let i = 0; i < x.length; i++) {\n    response.x[i] = xyObject[i].x;\n    response.y[i] = xyObject[i].y;\n  }\n\n  return response;\n}\n","/**\n *\n * @param {ArrayPoints} [points] array of growing points {x,y}\n * @param {object} [options={}]\n * @param {object} [slotWidth=1] limit to join the data\n */\nexport function xyObjectSlotX(points, options = {}) {\n  const { slotWidth = 1 } = options;\n  const halfSlot = slotWidth / 2;\n\n  // when we join we will use the center of mass\n  let result = [];\n  let current = {\n    x: Number.MIN_VALUE,\n    y: 0,\n  };\n  for (let point of points) {\n    let slot = point.x - ((point.x + halfSlot) % slotWidth) + halfSlot;\n    if (Math.abs(current.x - slot) > Number.EPSILON) {\n      current = {\n        x: slot,\n        y: 0,\n      };\n      result.push(current);\n    }\n    current.y += point.y;\n  }\n  return result;\n}\n","/**\n * Class allowing to manage a Serie\n */\nexport class Series {\n  constructor(array, dimension, options = {}) {\n    let { meta = {} } = options;\n    if (new.target === Series) {\n      throw new Error('You need to create either a 1D or 2D series');\n    }\n    this.data = array;\n    this.dimension = dimension;\n    this.meta = meta;\n    this.name = '';\n  }\n\n  getData() {\n    return this.data;\n  }\n\n  is1D() {\n    return this.dimension === 1;\n  }\n\n  is2D() {\n    return this.dimension === 2;\n  }\n\n  toJSON() {\n    return {\n      data: this.data,\n      meta: this.meta,\n    };\n  }\n\n  /**\n   * Specify an array of index to keep\n   * @param {Array} array\n   */\n  keep(array) {\n    const newData = [];\n    for (let i of array) {\n      newData.push(this.data[i]);\n    }\n    this.data = newData;\n    return this;\n  }\n}\n","import { Series } from './Series';\n\n/**\n * Class allowing to manage a Serie\n */\nexport class Series1D extends Series {\n  constructor(array) {\n    super(array, 1);\n  }\n}\n","import { Series } from './Series';\n\n/**\n * Class allowing to manage a 2D Serie\n */\nexport class Series2D extends Series {\n  constructor(array) {\n    super(array, 2);\n  }\n}\n","import isAnyArray from 'is-any-array';\n\nimport { Series1D } from './Series1D';\nimport { Series2D } from './Series2D';\n\nexport function seriesFromArray(array) {\n  // need to check if it is a 1D or 2D array (or 3D ?)\n  if (!isAnyArray(array)) {\n    throw new TypeError(\n      'seriesFromArray requires as parameter an array of numbers or array',\n    );\n  }\n\n  if (array.length === 0 || typeof array[0] === 'number') {\n    return new Series1D(array);\n  }\n\n  if (!isAnyArray(array[0])) {\n    throw new TypeError(\n      'seriesFromArray requires as parameter an array of numbers or array',\n    );\n  }\n\n  return new Series2D(array);\n}\n","import arrayMean from 'ml-array-mean';\n\nimport { seriesFromArray } from '../seriesFromArray';\n\nexport function meanFilter(chromatogram, seriesName, options = {}) {\n  const { factor = 2 } = options;\n\n  let series = chromatogram.getSeries(seriesName);\n  let filtered = [];\n  for (let i = 0; i < series.data.length; i++) {\n    filtered.push(applyFilter(series.data[i], factor));\n  }\n\n  return seriesFromArray(filtered);\n}\n\nfunction applyFilter(series, factor) {\n  let filtered = [[], []];\n  if (series[1].length === 0) return filtered;\n  const meanIntensity = factor * arrayMean(series[1]);\n  for (let i = 0; i < series[0].length; i++) {\n    if (series[1][i] > meanIntensity) {\n      filtered[0].push(series[0][i]);\n      filtered[1].push(series[1][i]);\n    }\n  }\n  return filtered;\n}\n","import arrayMax from 'ml-array-max';\n\nimport { seriesFromArray } from '../seriesFromArray';\n\nexport function percentageFilter(chromatogram, seriesName, options = {}) {\n  const { percentage = 0.1 } = options;\n\n  let series = chromatogram.getSeries(seriesName);\n  let filtered = [];\n\n  for (let i = 0; i < series.data.length; i++) {\n    filtered.push(applyFilter(series.data[i], percentage));\n  }\n\n  return seriesFromArray(filtered);\n}\n\nfunction applyFilter(series, percentage) {\n  let basePeak;\n  try {\n    basePeak = arrayMax(series[1]);\n  } catch (e) {\n    basePeak = 0;\n  }\n  let filtered = [[], []];\n  for (let i = 0; i < series[0].length; i++) {\n    if (series[1][i] > percentage * basePeak) {\n      filtered[0].push(series[0][i]);\n      filtered[1].push(series[1][i]);\n    }\n  }\n  return filtered;\n}\n","'use strict';\n/**\n * Define static variable corresponding to the various Kinds of a molecular formula part.\n */\n\nmodule.exports = {\n  BEGIN: 'begin',\n  ATOM: 'atom',\n  MULTIPLIER_RANGE: 'multiplierRange',\n  ISOTOPE: 'isotope',\n  ISOTOPE_RATIO: 'isotopeRatio',\n  CHARGE: 'charge',\n  SALT: 'salt',\n  OPENING_PARENTHESIS: 'openingParenthesis',\n  CLOSING_PARENTHESIS: 'closingParenthesis',\n  PRE_MULTIPLIER: 'preMultiplier',\n  MULTIPLIER: 'multiplier',\n  TEXT: 'text',\n  ANCHOR: 'anchor',\n  COMMENT: 'comment',\n};\n","'use strict';\n\n/**\n * Parse a string to extract the charge\n * The charge may be in the form --, +++, +3, -2, 4+, 2-\n * @param {*} charge\n */\n\nmodule.exports = function parseCharge(charge) {\n  charge = charge.replace(/[()]/g, '');\n  let chargeNumber = 0;\n  if (charge.match(/^[+-]+$/)) {\n    for (let i = 0; i < charge.length; i++) {\n      if (charge.charAt(i) === '+') chargeNumber++;\n      else chargeNumber--;\n    }\n  } else if (charge.match(/^[0-9]+[+-]$/)) {\n    chargeNumber = Number(\n      charge.charAt(charge.length - 1) + charge.substring(0, charge.length - 1),\n    );\n  } else {\n    chargeNumber = Number(charge);\n  }\n  return chargeNumber;\n};\n","'use strict';\n\nconst Kind = require('./Kind');\nconst parseCharge = require('./util/parseCharge');\n\n/**\n * Parse a mf to an array of kind / value\n * @param {String} mf\n */\n\nmodule.exports = function parse(mf) {\n  return new MFParser().parse(mf);\n};\n\nclass MFParser {\n  parse(mf = '') {\n    this.mf = mf;\n    this.i = 0;\n    this.result = [];\n\n    let lastKind = Kind.BEGIN;\n    while (this.i < mf.length) {\n      if (\n        this.result.length > 0 &&\n        this.result[this.result.length - 1].kind !== Kind.TEXT\n      ) {\n        lastKind = this.result[this.result.length - 1].kind;\n      }\n      let char = mf.charAt(this.i);\n      let ascii = mf.charCodeAt(this.i);\n      let nextAscii = 0;\n      if (this.i + 1 < mf.length) nextAscii = mf.charCodeAt(this.i + 1);\n\n      if (\n        (ascii > 47 && ascii < 58) ||\n        (char === '-' && nextAscii > 47 && nextAscii < 58)\n      ) {\n        // a number\n        let value = this.getNumber(ascii);\n        if (\n          lastKind === Kind.SALT ||\n          lastKind === Kind.BEGIN ||\n          lastKind === Kind.OPENING_PARENTHESIS\n        ) {\n          if (value.to) {\n            throw new MFError(\n              this.mf,\n              this.i,\n              'Premultiplier may not contain a -',\n            );\n          }\n          this.result.push({ kind: Kind.PRE_MULTIPLIER, value: value.from });\n        } else if (lastKind === Kind.ANCHOR) {\n          if (value.to) {\n            throw new MFError(this.mf, this.i, 'Anchor ID may not contain -');\n          }\n          this.result[this.result.length - 1].value = value.from;\n        } else {\n          if (value.to) {\n            this.result.push({\n              kind: Kind.MULTIPLIER_RANGE,\n              value: {\n                from: Math.min(value.from, value.to),\n                to: Math.max(value.from, value.to),\n              },\n            });\n          } else {\n            this.result.push({ kind: Kind.MULTIPLIER, value: value.from });\n          }\n        }\n        continue;\n      } else if (char === '.') {\n        // a point\n        this.result.push({ kind: Kind.SALT, value: char });\n        // it is not in a number otherwise it would have been taken before\n        // it must be in a salt\n      } else if (char === '#') {\n        // an anchor\n        this.result.push({ kind: Kind.ANCHOR, value: 0 });\n        // it is not in a number otherwise it would have been taken before\n        // it must be in a salt\n      } else if (ascii > 64 && ascii < 91) {\n        // an uppercase = new atom\n        let value = this.getAtom(ascii);\n        this.result.push({ kind: Kind.ATOM, value });\n        continue;\n      } else if (ascii > 96 && ascii < 123) {\n        // a lowercase\n        throw new MFError(\n          this.mf,\n          this.i,\n          'found a lowercase not following an uppercase',\n        );\n      } else if (char === '(') {\n        let charge = this.getParenthesisCharge(ascii);\n        if (charge) {\n          this.result.push({ kind: Kind.CHARGE, value: charge });\n        } else {\n          this.result.push({ kind: Kind.OPENING_PARENTHESIS, value: '(' });\n        }\n      } else if (char === ')') {\n        this.result.push({ kind: Kind.CLOSING_PARENTHESIS, value: ')' });\n      } else if (char === '[') {\n        // defines an isotope\n        let isotope = this.getIsotope(ascii);\n        this.result.push({ kind: Kind.ISOTOPE, value: isotope });\n      } else if (char === ']') {\n        throw new MFError(\n          this.mf,\n          this.i,\n          'should never meet an closing bracket not in isotopes',\n        );\n      } else if (char === '{') {\n        // can define an exotic isotopic ratio or mixtures of groups\n        let isotopeRatio = this.getCurlyBracketIsotopeRatio(ascii);\n        if (lastKind === Kind.ATOM) {\n          let lastResult = this.result[this.result.length - 1];\n          lastResult.kind = Kind.ISOTOPE_RATIO;\n          lastResult.value = {\n            atom: lastResult.value,\n            ratio: isotopeRatio,\n          };\n        } else {\n          throw new MFError(\n            this.mf,\n            this.i,\n            'isotopic composition has to follow an atom',\n          );\n        }\n      } else if (char === '}') {\n        throw new MFError(\n          this.mf,\n          this.i,\n          'found a unexpected closing curly bracket',\n        );\n      } else if (char === '+') {\n        // charge not in parenthesis\n        let charge = this.getNonParenthesisCharge(ascii);\n        this.result.push({ kind: Kind.CHARGE, value: charge });\n      } else if (char === '-') {\n        // charge not in parenthesis\n        let charge = this.getNonParenthesisCharge(ascii);\n        this.result.push({ kind: Kind.CHARGE, value: charge });\n      } else if (char === '$') {\n        // it is a comment after\n        this.result.push({\n          kind: Kind.COMMENT,\n          value: this.mf.substring(this.i + 1),\n        });\n        break;\n      } else {\n        this.result.push({ kind: Kind.TEXT, value: char });\n      }\n      this.i++;\n    }\n\n    this.checkParenthesis();\n    return this.result;\n  }\n\n  checkParenthesis() {\n    let counter = 0;\n    for (let line of this.result) {\n      if (line.kind === Kind.OPENING_PARENTHESIS) counter++;\n      if (line.kind === Kind.CLOSING_PARENTHESIS) counter--;\n    }\n    if (counter !== 0) {\n      throw new MFError(\n        this.mf,\n        this.i,\n        'number of opening and closing parenthesis not equal',\n      );\n    }\n  }\n\n  getNumber(ascii) {\n    let number = '';\n    let previous;\n    do {\n      previous = ascii;\n      number += String.fromCharCode(ascii);\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (\n      (ascii > 47 && ascii < 58) ||\n      ascii === 46 ||\n      ascii === 45 ||\n      ascii === 47\n    ); // number . - /\n    // we need to deal with the case there is a from / to\n    if (previous === 46) this.i--;\n    let indexOfDash = number.indexOf('-', 1);\n\n    if (indexOfDash > -1) {\n      return {\n        from: parseNumberWithDivision(number.substr(0, indexOfDash)),\n        to: parseNumberWithDivision(number.substr(indexOfDash + 1)),\n      };\n    }\n    return { from: parseNumberWithDivision(number) };\n  }\n\n  getAtom(ascii) {\n    let atom = '';\n    do {\n      atom += String.fromCharCode(ascii);\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (ascii > 96 && ascii < 123);\n    return atom;\n  }\n\n  getIsotope(ascii) {\n    // [13C]\n    let substring = '';\n    do {\n      substring += String.fromCharCode(ascii);\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (ascii !== 93 && this.i <= this.mf.length);\n\n    let atom = substring.replace(/[^a-zA-Z]/g, '');\n    let isotope = Number(substring.replace(/[^0-9]/g, ''));\n    return { atom, isotope };\n  }\n\n  getCurlyBracketIsotopeRatio(ascii) {\n    let substring = '';\n    let first = true;\n    do {\n      if (!first) {\n        substring += String.fromCharCode(ascii);\n      } else {\n        first = false;\n      }\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (ascii !== 125 && this.i <= this.mf.length); // closing curly bracket\n    if (substring.match(/^[0-9,]+$/)) {\n      return substring.split(',').map((a) => Number(a));\n    }\n    throw new MFError(\n      this.mf,\n      this.i,\n      'Curly brackets should contain only number and comma',\n    );\n  }\n\n  getParenthesisCharge(ascii) {\n    let substring = '';\n    let begin = this.i;\n    do {\n      substring += String.fromCharCode(ascii);\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (ascii !== 41 && this.i <= this.mf.length); // closing parenthesis\n    if (substring.match(/^\\([0-9+-]+$/)) {\n      return parseCharge(substring.substring(1));\n    } else {\n      this.i = begin;\n      return undefined;\n    }\n  }\n\n  getNonParenthesisCharge(ascii) {\n    let substring = '';\n    do {\n      substring += String.fromCharCode(ascii);\n      this.i++;\n      ascii = this.mf.charCodeAt(this.i);\n    } while (ascii === 43 || ascii === 45 || (ascii > 47 && ascii < 58));\n    this.i--;\n    return parseCharge(substring);\n  }\n}\nclass MFError extends SyntaxError {\n  constructor(mf, i, message) {\n    let text = `${message}\\n\\n${mf}\\n${' '.repeat(i)}^`;\n    super(text);\n  }\n}\n\nfunction parseNumberWithDivision(string) {\n  if (string.includes('/')) {\n    let parts = string.split('/');\n    if (parts.length !== 2) {\n      throw new TypeError('Can not parse MF with number like: ', string);\n    }\n    return Number(parts[0]) / Number(parts[1]);\n  } else {\n    return Number(string);\n  }\n}\n","'use strict';\n\n/**\n * Defines static variables corresponding to the various formatting possibilities\n */\n\nmodule.exports = {\n  SUBSCRIPT: 'subscript',\n  SUPERSCRIPT: 'superscript',\n  SUPERIMPOSE: 'superimpose',\n  TEXT: 'text',\n};\n","'use strict';\n\nmodule.exports = function formatCharge(charge) {\n  if (charge === 1) return '+';\n  if (charge > 1) return `+${charge}`;\n  if (charge < 0) return String(charge);\n  return '';\n};\n","'use strict';\n\nconst Format = require('../Format');\nconst Kind = require('../Kind');\n\nconst formatCharge = require('./formatCharge');\n\n/**\n * Converts an array of mf elements to an array of formatting information\n * @param {Array<Object>} result of the parse method\n */\n\nmodule.exports = function convertForDisplay(lines) {\n  let results = [];\n  let result = {};\n  for (let line of lines) {\n    switch (line.kind) {\n      case Kind.MULTIPLIER:\n        if (line.value !== 1) {\n          result = {\n            kind: Format.SUBSCRIPT,\n            value: String(line.value),\n          };\n          results.push(result);\n        }\n        break;\n      case Kind.MULTIPLIER_RANGE:\n        result = {\n          kind: Format.SUBSCRIPT,\n          value: `${String(line.value.from)}-${line.value.to}`,\n        };\n        results.push(result);\n        break;\n      case Kind.CHARGE:\n        if (result.kind === Format.SUBSCRIPT) {\n          result.kind = Format.SUPERIMPOSE;\n          result.over = formatCharge(line.value);\n          result.under = result.value;\n          result.value = undefined;\n        } else {\n          result = {\n            kind: Format.SUPERSCRIPT,\n            value: formatCharge(line.value),\n          };\n          results.push(result);\n        }\n\n        break;\n\n      case Kind.ISOTOPE:\n        result = {\n          kind: Format.SUPERSCRIPT,\n          value: line.value.isotope,\n        };\n        results.push(result);\n        result = {\n          kind: Format.TEXT,\n          value: line.value.atom,\n        };\n        results.push(result);\n        break;\n\n      case Kind.ISOTOPE_RATIO:\n        if (result.kind === Format.TEXT) {\n          result.value += line.value.atom;\n        } else {\n          result = {\n            kind: Format.TEXT,\n            value: line.value.atom,\n          };\n          results.push(result);\n        }\n        result = {\n          kind: Format.SUPERSCRIPT,\n          value: `{${line.value.ratio.join(',')}}`,\n        };\n        results.push(result);\n        break;\n      case Kind.SALT:\n        if (result.kind === Format.TEXT) {\n          result.value += ' • ';\n        } else {\n          result = {\n            kind: Format.TEXT,\n            value: ' • ',\n          };\n          results.push(result);\n        }\n        break;\n      default:\n        if (result.kind === Format.TEXT) {\n          result.value += line.value;\n        } else {\n          result = {\n            kind: Format.TEXT,\n            value: line.value,\n          };\n          results.push(result);\n        }\n    }\n  }\n  return results;\n};\n","'use strict';\n\nmodule.exports = {\n  SUPERIMPOSE:\n    'flex-direction: column;display: inline-flex;justify-content: center;text-align: left;vertical-align: middle;',\n  SUPERIMPOSE_SUP_SUB: 'line-height: 1; font-size: 70%',\n};\n","'use strict';\n\nconst Format = require('../Format');\nconst Style = require('../Style');\n\nmodule.exports = function getHtml(lines) {\n  let html = [];\n  for (let line of lines) {\n    switch (line.kind) {\n      case Format.SUBSCRIPT:\n        html.push(`<sub>${line.value}</sub>`);\n        break;\n      case Format.SUPERSCRIPT:\n        html.push(`<sup>${line.value}</sup>`);\n        break;\n      case Format.SUPERIMPOSE:\n        html.push(`<span style=\"${Style.SUPERIMPOSE}\">`);\n        html.push(\n          `<sup style=\"${Style.SUPERIMPOSE_SUP_SUB}\">${line.over}</sup>`,\n        );\n        html.push(\n          `<sub style=\"${Style.SUPERIMPOSE_SUP_SUB}\">${line.under}</sub>`,\n        );\n        html.push('</span>');\n        break;\n      default:\n        html.push(line.value);\n    }\n  }\n  return html.join('');\n};\n","'use strict';\n\nconst elements = JSON.parse(JSON.stringify(require('./elements.json')));\n\nelements.forEach((element) => {\n  element.isotopes = element.isotopes.filter((i) => i.abundance > 0);\n});\n\nmodule.exports = elements;\n","'use strict';\n\nconst elementsAndStableIsotopes = require('./elementsAndStableIsotopes.js');\n\nlet elementsAndStableIsotopesObject = {};\nelementsAndStableIsotopes.forEach((element) => {\n  elementsAndStableIsotopesObject[element.symbol] = element;\n});\n\nmodule.exports = elementsAndStableIsotopesObject;\n","'use strict';\n\nconst elements = Object.keys(\n  require('chemical-elements/src/elementsAndStableIsotopesObject.js'),\n).sort((a, b) => b.length - a.length);\n\n/**\n * Ensure that the mf has been entered with capital letters and not only lowercase\n * If there is only lowercase we try to capitalize the mf\n * @param {string} mf\n */\n\nfunction capitalize(mf) {\n  for (let i = 0; i < mf.length; i++) {\n    if (mf.charCodeAt(i) > 64 && mf.charCodeAt(i) < 91) {\n      return mf;\n    }\n  }\n  let parts = mf.replace(/([a-z]*)([^a-z]*)/g, '$1 $2 ').split(/ +/);\n  for (let i = 0; i < parts.length; i++) {\n    if (parts[i].match(/^[a-z]$/)) {\n      parts[i] = parts[i].toUpperCase();\n    } else if (parts[i].match(/^[a-z]+$/)) {\n      let newPart = '';\n      for (let j = 0; j < parts[i].length; j++) {\n        let two = parts[i].substr(j, 2);\n        let one = parts[i].charAt(j).toUpperCase();\n        if (\n          ['c', 'h', 'o', 'n'].includes(two.charAt(0)) &&\n          ['h', 'o', 'n'].includes(two.charAt(1))\n        ) {\n          newPart += two.toUpperCase();\n          j++;\n        } else {\n          two = two.charAt(0).toUpperCase() + two.charAt(1);\n          if (elements.includes(two)) {\n            newPart += two;\n            j++;\n          } else {\n            if (elements.includes(one)) {\n              newPart += one;\n            } else {\n              return mf;\n            }\n          }\n        }\n      }\n      parts[i] = newPart;\n    }\n  }\n  return parts.join('');\n}\n\nmodule.exports = capitalize;\n","'use strict';\n\nmodule.exports = {\n  ELECTRON_MASS: 5.4857990907e-4,\n};\n","'use strict';\n\nconst elements = require('./elements.json');\n\nconst data = elements.map((element) => ({\n  number: element.number,\n  symbol: element.symbol,\n  mass: element.mass,\n  name: element.name,\n  monoisotopicMass: element.monoisotopicMass,\n}));\n\nmodule.exports = data;\n","'use strict';\n\nmodule.exports = require('./elements.json');\n","'use strict';\n\nconst elements = require('./elements.json');\n\nlet elementsAndIsotopesObject = {};\nelements.forEach((element) => {\n  elementsAndIsotopesObject[element.symbol] = element;\n});\n\nmodule.exports = elementsAndIsotopesObject;\n","'use strict';\n\nconst elements = require('./elements.js');\n\nlet elementsObject = {};\nelements.forEach((element) => {\n  elementsObject[element.symbol] = element;\n});\n\nmodule.exports = elementsObject;\n","'use strict';\n\nconst { ELECTRON_MASS } = require('./constants');\nconst elements = require('./elements.js');\nconst elementsAndIsotopes = require('./elementsAndIsotopes.js');\nconst elementsAndIsotopesObject = require('./elementsAndIsotopesObject.js');\nconst elementsAndStableIsotopes = require('./elementsAndStableIsotopes.js');\nconst elementsAndStableIsotopesObject = require('./elementsAndStableIsotopesObject.js');\nconst elementsObject = require('./elementsObject.js');\n\nmodule.exports = {\n  elements,\n  elementsObject,\n  elementsAndIsotopes,\n  elementsAndIsotopesObject,\n  elementsAndStableIsotopes,\n  elementsAndStableIsotopesObject,\n  ELECTRON_MASS,\n};\n","'use strict';\nmodule.exports=[{\"symbol\":\"Abu\",\"name\":\"2-Aminobutyric acid diradical\",\"mf\":\"C4H7NO\",\"ocl\":{\"value\":\"dazHPBPOEgEInVZjcH@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGt\"},\"mass\":85.10463700109551,\"monoisotopicMass\":85.05276384961,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Acet\",\"name\":\"Acetyl\",\"mf\":\"C2H3O\",\"ocl\":{\"value\":\"gCaHDEeIi`@\",\"coordinates\":\"!BbOq~@Ha}\"},\"mass\":43.04469897995611,\"monoisotopicMass\":43.01838971626,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":2},{\"symbol\":\"H\",\"number\":3},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Acm\",\"name\":\"Acetamidomethyl\",\"mf\":\"C3H6NO\",\"ocl\":{\"value\":\"gGYHDPliJuS@@\",\"coordinates\":\"!BbOrH_Xc|_`BH_P\"},\"mass\":72.08596035030448,\"monoisotopicMass\":72.04493881738,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Adao\",\"name\":\"Adamantyloxy\",\"mf\":\"C10H15O\",\"ocl\":{\"value\":\"dc\\\\H`HAYRVeV^dUGZjjjj@@\",\"coordinates\":\"!B]BOXN`EP}CdB\\\\tbZ@Ijh~hRELdOBBp\"},\"mass\":151.2258752025074,\"monoisotopicMass\":151.11229010302,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Aib\",\"name\":\"alpha-Aminoisobutyric acid diradical\",\"mf\":\"C4H7NO\",\"ocl\":{\"value\":\"dazHPBPOGgEInfZj@@\",\"coordinates\":\"!Bb@I~@Ha}b@K|uwwWbGt\"},\"mass\":85.10463700109551,\"monoisotopicMass\":85.05276384961,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Ala\",\"name\":\"Alanine diradical\",\"mf\":\"C3H5NO\",\"kind\":\"aa\",\"oneLetter\":\"A\",\"alternativeOneLetter\":\"α\",\"ocl\":{\"value\":\"gNyDBaxmqR[fZjZ@\",\"coordinates\":\"!BbOr~@H`}bOr~Wxb}\"},\"mass\":71.07801959624871,\"monoisotopicMass\":71.03711378515,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Arg\",\"name\":\"Arginine diradical\",\"mf\":\"C6H12N4O\",\"kind\":\"aa\",\"oneLetter\":\"R\",\"alternativeOneLetter\":\"ρ\",\"ocl\":{\"value\":\"dkLhPBgSPOEgEInWUijjihr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHHa}b@I~@Ha}\"},\"mass\":156.18592219918227,\"monoisotopicMass\":156.10111102405,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Argp\",\"name\":\"Arginine triradical\",\"mf\":\"C6H11N4O\",\"ocl\":{\"value\":\"dglhpHpil@gWDEI[UYZfjji`T@\",\"coordinates\":\"!BbGvHGx@bGvH@ha}bOrH_Wxb@KW_Wx@bGt\"},\"mass\":155.1779814451265,\"monoisotopicMass\":155.09328599182,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Asn\",\"name\":\"Asparagine diradical\",\"mf\":\"C4H6N2O2\",\"kind\":\"aa\",\"oneLetter\":\"N\",\"alternativeOneLetter\":\"η\",\"ocl\":{\"value\":\"deeDPBeACqYqR[ezZjZL`@\",\"coordinates\":\"!BbGu~Ox`B_`BH_X`Bb@I~@Ha}\"},\"mass\":114.10280438280381,\"monoisotopicMass\":114.04292744137999,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Asnp\",\"name\":\"Asparagine triradical\",\"mf\":\"C4H5N2O2\",\"ocl\":{\"value\":\"dmUDpH[E@IEqgqRVvVijjXi@@\",\"coordinates\":\"!Bb@JH_Wxb@JH_Wxb@KW_Wx@bGt\"},\"mass\":113.09486362874803,\"monoisotopicMass\":113.03510240915,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Asp\",\"name\":\"Aspartic acid diradical\",\"mf\":\"C4H5NO3\",\"kind\":\"aa\",\"oneLetter\":\"D\",\"alternativeOneLetter\":\"δ\",\"ocl\":{\"value\":\"defLPBPYCqYqR[ezZjZL`@\",\"coordinates\":\"!BbGu~Ox`B_`BH_X`Bb@I~@Ha}\"},\"mass\":115.08756534162052,\"monoisotopicMass\":115.02694302429,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Aspp\",\"name\":\"Aspartic acid triradical\",\"mf\":\"C4H4NO3\",\"ocl\":{\"value\":\"dmVLpFcE@IEqgqRVvVijjXi@@\",\"coordinates\":\"!Bb@JH_Wxb@JH_Wxb@KW_Wx@bGt\"},\"mass\":114.07962458756472,\"monoisotopicMass\":114.01911799206,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":4},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Asu\",\"name\":\"alpha-Aminosuberic acid diradical\",\"mf\":\"C8H13NO3\",\"ocl\":{\"value\":\"dgnLPBP{CqYqR[euVfjjihr@@\",\"coordinates\":\"!BbGu~Ox`B_`BH_Xc|bOrH_X`BbGvHGx@bGt\"},\"mass\":171.19403496100773,\"monoisotopicMass\":171.08954328213002,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Asup\",\"name\":\"alpha-Aminosuberic acid triradical\",\"mf\":\"C8H12NO3\",\"ocl\":{\"value\":\"do^LpEcG@IMqoqRVuUejZjjibT@\",\"coordinates\":\"!BbOrH_Wxb@JH_Xc|bGvHHa}_c~H@m]}_`BH_P\"},\"mass\":170.18609420695194,\"monoisotopicMass\":170.0817182499,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Boc\",\"name\":\"t-Butoxycarbonyl\",\"mf\":\"C5H9O2\",\"ocl\":{\"value\":\"daxD`DpEeImjZj@@\",\"coordinates\":\"!B|Ou~_A||Ow}mC}_O@\"},\"mass\":101.12395611881479,\"monoisotopicMass\":101.06025452921,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Bom\",\"name\":\"Benzyloxymethyl\",\"mf\":\"C8H9O\",\"ocl\":{\"value\":\"deTH`DAYRUYTYj`@@@\",\"coordinates\":\"!B|Gsp__A||Owp_Gy|Gwp_Wy\"},\"mass\":121.15675888470227,\"monoisotopicMass\":121.06533990964,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Brz\",\"name\":\"2-Bromobenzyloxycarbonyl\",\"mf\":\"C8H6BrO2\",\"ocl\":{\"value\":\"dcLDPDpEd\\\\QImYgWYjB@@@\",\"coordinates\":\"!Bb@I~@Hb}b@JH_X`B_c}~@Hb}bGu~Op\"},\"mass\":214.03586932736317,\"monoisotopicMass\":212.95511703252,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"Br\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Bu\",\"name\":\"Butyl\",\"mf\":\"C4H9\",\"ocl\":{\"value\":\"gJPH@liJuP@\",\"coordinates\":\"!B@Fp@XpAl@FL\"},\"mass\":57.114410373442986,\"monoisotopicMass\":57.07042529007,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":9}]},{\"symbol\":\"Bum\",\"name\":\"t-Butoxymethyl\",\"mf\":\"C5H11O\",\"ocl\":{\"value\":\"gNqHDEeIVjj`@\",\"coordinates\":\"!B@FL@[@AcXs|@Xvp@\"},\"mass\":87.14043270260808,\"monoisotopicMass\":87.08098997409999,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Bz\",\"name\":\"Benzoyl\",\"mf\":\"C7H5O\",\"ocl\":{\"value\":\"didH`DAYR[e^FX@@@@\",\"coordinates\":\"!BbOq~@Ha}b@I~Oxa}bGu~Op\"},\"mass\":105.1142599717439,\"monoisotopicMass\":105.03403978072,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Bzl\",\"name\":\"Benzyl\",\"mf\":\"C7H7\",\"ocl\":{\"value\":\"daD@`@VTeeVz`@@@\",\"coordinates\":\"!B|Gsp_A|_gp_A}_g|\"},\"mass\":91.13073655553718,\"monoisotopicMass\":91.05477522561,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":7}]},{\"symbol\":\"Bn\",\"name\":\"Benzyl\",\"mf\":\"C7H7\",\"ocl\":{\"value\":\"daD@`@VTeeVz`@@@\",\"coordinates\":\"!B|Gsp_A|_gp_A}_g|\"},\"mass\":91.13073655553718,\"monoisotopicMass\":91.05477522561,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":7}]},{\"symbol\":\"Bzlo\",\"name\":\"Benzyloxy\",\"mf\":\"C7H7O\",\"ocl\":{\"value\":\"didH`HAYRUe^Fh@@@@\",\"coordinates\":\"!B|Gwp_OC}|Gq~_A}|Gu~_p\"},\"mass\":107.13014147985547,\"monoisotopicMass\":107.04968984518,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Cha\",\"name\":\"beta-Cyclohexylalanine diradical\",\"mf\":\"C9H15NO\",\"ocl\":{\"value\":\"dknHPBPOEgEInWe]NZjjjcH@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvH@gxbGvH_Wx\"},\"mass\":153.22184251721796,\"monoisotopicMass\":153.11536410745,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Chxo\",\"name\":\"Cyclohexyloxy\",\"mf\":\"C6H11O\",\"ocl\":{\"value\":\"daDH`HAYRVU[jjj@@\",\"coordinates\":\"!B|Gsp_A|_gp_A}_g|\"},\"mass\":99.15116859934332,\"monoisotopicMass\":99.08098997409999,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Cit\",\"name\":\"Citrulline diradical\",\"mf\":\"C6H11N3O2\",\"ocl\":{\"value\":\"dkODPBdttOEgEInWUijjihr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHHa}b@I~@Ha}\"},\"mass\":157.170683157999,\"monoisotopicMass\":157.08512660696,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Citp\",\"name\":\"Citrulline triradical\",\"mf\":\"C6H10N3O2\",\"ocl\":{\"value\":\"dgoDpHJ\\\\l@gWDEI[UYZfjji`T@\",\"coordinates\":\"!BbGvHGx@bGvH@ha}bOrH_Wxb@KW_Wx@bGt\"},\"mass\":156.16274240394318,\"monoisotopicMass\":156.07730157473,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":10},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Clz\",\"name\":\"2-Chlorobenzyloxycarbonyl\",\"mf\":\"C8H6ClO2\",\"ocl\":{\"value\":\"dcLDPDpEdXaImYgWYjB@@@\",\"coordinates\":\"!Bb@I~@Hb}b@JH_X`B_c}~@Hb}bGu~Op\"},\"mass\":169.58527912946118,\"monoisotopicMass\":169.00563211451998,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"Cl\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Cp\",\"name\":\"Cyclopentadienyl\",\"mf\":\"C5H5\",\"ocl\":{\"value\":\"gFpH@liLimRp@\",\"coordinates\":\"!B\\\\OtPThyEGl@fP\"},\"mass\":65.09338325395512,\"monoisotopicMass\":65.03912516115,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":5}]},{\"symbol\":\"Cys\",\"name\":\"Cysteine diradical\",\"mf\":\"C3H5NOS\",\"kind\":\"aa\",\"oneLetter\":\"C\",\"alternativeOneLetter\":\"ς\",\"ocl\":{\"value\":\"dazHpBPOEgG`aInVZjcH@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGt\"},\"mass\":103.14280700237578,\"monoisotopicMass\":103.00918495955,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Cysp\",\"name\":\"Cysteine triradical\",\"mf\":\"C3H4NOS\",\"ocl\":{\"value\":\"diFHHBD@f@agGoEIVVjjfLP@\",\"coordinates\":\"!BbGvHHa}_c~HM]}_`BH_P\"},\"mass\":102.13486624831998,\"monoisotopicMass\":102.00135992732,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":4},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"D\",\"name\":\"Deuterium\",\"mf\":\"[2H]\",\"ocl\":{\"value\":\"eFAAYhBLCEH@\",\"coordinates\":\"!B@FL\"},\"mass\":2.01410177812,\"monoisotopicMass\":2.01410177812,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"H\",\"number\":1,\"isotope\":2}]},{\"symbol\":\"Dde\",\"name\":\"Dde\",\"mf\":\"C10H13O2\",\"ocl\":{\"value\":\"dklD`FDEgHhihicIVZfZj@@\",\"coordinates\":\"!Bb@I~@Ha}upJH@m]}_`BH_Wx@b@I}bOrH\"},\"mass\":165.20939861871415,\"monoisotopicMass\":165.09155465812998,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Dnp\",\"name\":\"2,4-Dinitrophenyl\",\"mf\":\"C6H3N2O4\",\"ocl\":{\"value\":\"dkmB`bWatpVRd^VS{HhheEUFfBAbX@@\",\"coordinates\":\"!B_c~H_]]}b@I~Owx_`BH_]]}_c~H_]]}\"},\"mass\":167.09926376274353,\"monoisotopicMass\":167.00928158383,\"unsaturation\":11,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":3},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":4}]},{\"symbol\":\"Et\",\"name\":\"Ethyl\",\"mf\":\"C2H5\",\"ocl\":{\"value\":\"eMBAYRZ@\",\"coordinates\":\"!B@Fp@Xp\"},\"mass\":29.061175563749384,\"monoisotopicMass\":29.03912516115,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":2},{\"symbol\":\"H\",\"number\":5}]},{\"symbol\":\"Fmoc\",\"name\":\"Fluorenylmethoxycarbonyl\",\"mf\":\"C15H11O2\",\"ocl\":{\"value\":\"fde@b@DX@liMkLrjxeVCzLuT@@@P@@@\",\"coordinates\":\"!BbOq~@Ha}bOrH_]ARcm}Tv~i`pAeKv|@fpB[j[~iozfAKvp\"},\"mass\":223.24719659427882,\"monoisotopicMass\":223.07590459367,\"unsaturation\":19,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"For\",\"name\":\"Formyl\",\"mf\":\"CHO\",\"ocl\":{\"value\":\"eMJDVTfP@\",\"coordinates\":\"!B@Fp@Xp\"},\"mass\":29.018081575109303,\"monoisotopicMass\":29.0027396518,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":1},{\"symbol\":\"H\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Gln\",\"name\":\"Glutamine diradical\",\"mf\":\"C5H8N2O2\",\"kind\":\"aa\",\"oneLetter\":\"Q\",\"alternativeOneLetter\":\"ξ\",\"ocl\":{\"value\":\"dmUDPBUICqYqR[evfjihr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHGx@bGt\"},\"mass\":128.12942178765059,\"monoisotopicMass\":128.05857750584,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":8},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Glnp\",\"name\":\"Glutamine triradical\",\"mf\":\"C5H7N2O2\",\"ocl\":{\"value\":\"dcuDpH{MAYeqWqRVuejZjiad@\",\"coordinates\":\"!BbGvHGx@bGvH@ha}_c~HM]}_`BH_P\"},\"mass\":127.12148103359483,\"monoisotopicMass\":127.05075247361,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Glp\",\"name\":\"Pyroglutamine\",\"mf\":\"C5H5NO2\",\"ocl\":{\"value\":\"deVDPBRP|V\\\\TfygxYjjZL`@\",\"coordinates\":\"!Bb@I~@Ha}tEJNwr[@UMo@FXBN\"},\"mass\":111.09889631403748,\"monoisotopicMass\":111.03202840472,\"unsaturation\":6,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Glu\",\"name\":\"Glutamic acid diradical\",\"mf\":\"C5H7NO3\",\"kind\":\"aa\",\"oneLetter\":\"E\",\"alternativeOneLetter\":\"ε\",\"ocl\":{\"value\":\"dmVLPBRUCqYqR[evfjihr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHGx@bGt\"},\"mass\":129.11418274646732,\"monoisotopicMass\":129.04259308875,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Glup\",\"name\":\"Glutamic acid triradical\",\"mf\":\"C5H6NO3\",\"ocl\":{\"value\":\"dcvLpNcM@IeqWqRVuejZjiad@\",\"coordinates\":\"!BbGvHGx@bGvH@ha}_c~HM]}_`BH_P\"},\"mass\":128.10624199241153,\"monoisotopicMass\":128.03476805652002,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Gly\",\"name\":\"Glycine diradical\",\"mf\":\"C2H3NO\",\"kind\":\"aa\",\"oneLetter\":\"G\",\"alternativeOneLetter\":\"γ\",\"ocl\":{\"value\":\"gGYDBaxuqR[Yj@@\",\"coordinates\":\"!BbOq~@Ha}bOrH_P\"},\"mass\":57.051402191401905,\"monoisotopicMass\":57.021463720689994,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":2},{\"symbol\":\"H\",\"number\":3},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Hci\",\"name\":\"Homocitrulline diradical\",\"mf\":\"C7H13N3O2\",\"ocl\":{\"value\":\"dgoDPBVtLOEgEInWUZZjjfcH@\",\"coordinates\":\"!BbGu~Ox`B_`BH_Xc|bOrH_X`BbGvHGx@bGt\"},\"mass\":171.19730056284578,\"monoisotopicMass\":171.10077667142,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Hcip\",\"name\":\"Homocitrulline triradical\",\"mf\":\"C7H12N3O2\",\"ocl\":{\"value\":\"do_DpHI\\\\\\\\EdwFEI[UVVijjjfIP@\",\"coordinates\":\"!BbOrH_Wxb@JH_Xc|bGvHHa}_c~H@m]}_`BH_P\"},\"mass\":170.18935980879002,\"monoisotopicMass\":170.09295163918998,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"His\",\"name\":\"Histidine diradical\",\"mf\":\"C6H7N3O\",\"kind\":\"aa\",\"oneLetter\":\"H\",\"alternativeOneLetter\":\"ζ\",\"ocl\":{\"value\":\"dcOHPBGTCqYqR[eyUvZjejL`@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGwPTh{_UMo@FP\"},\"mass\":137.13951521745759,\"monoisotopicMass\":137.05891185847,\"unsaturation\":8,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Hisp\",\"name\":\"Histidine triradical\",\"mf\":\"C6H6N3O\",\"ocl\":{\"value\":\"dkoHpHHSAYUqwqRY]YXjjVjihy@@\",\"coordinates\":\"!BTmA}bL@fUHRN`H`BbGu~Ox`Buwu~@Ha}\"},\"mass\":136.13157446340182,\"monoisotopicMass\":136.05108682624,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Hser\",\"name\":\"Homoserine diradical\",\"mf\":\"C4H7NO2\",\"ocl\":{\"value\":\"diFDPBPP|V\\\\Tfy^Zjhr@@\",\"coordinates\":\"!BbGu~Ox`B_`BH_X`Bb@JH_P\"},\"mass\":101.10404192541378,\"monoisotopicMass\":101.04767846918,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Hserp\",\"name\":\"Homoserine triradical\",\"mf\":\"C4H6NO2\",\"ocl\":{\"value\":\"defDpJbPV^\\\\Q|TeVVjji`d@\",\"coordinates\":\"!Bb@JH_X`BbGu~Oxc|uwu~@Ha}\"},\"mass\":100.09610117135801,\"monoisotopicMass\":100.03985343695001,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Hyp\",\"name\":\"Hydroxyproline diradical\",\"mf\":\"C5H7NO2\",\"ocl\":{\"value\":\"deVDPBRP|V\\\\\\\\bfbbOCMUUIdE@@\",\"coordinates\":\"!Bb@I~@Ha}tEJNwr[@UMo@FUJO\"},\"mass\":113.11477782214904,\"monoisotopicMass\":113.04767846918,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Hypp\",\"name\":\"Hydroxyproline triradical\",\"mf\":\"C5H6NO2\",\"ocl\":{\"value\":\"dmvDpJaPB^\\\\Y|TeeWjZjjidRL`@\",\"coordinates\":\"!BBOpH_UARcc}TNtBY@HyRSpCQDr\\\\\"},\"mass\":112.10683706809326,\"monoisotopicMass\":112.03985343695001,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Ile\",\"name\":\"Isoleucine diradical\",\"mf\":\"C6H11NO\",\"kind\":\"aa\",\"oneLetter\":\"I\",\"alternativeOneLetter\":\"ι\",\"ocl\":{\"value\":\"defHPBPOEgEInVyjjdrT`@\",\"coordinates\":\"!BbGu~Oxc|_`BH_Xc|b@I~Oxa}\"},\"mass\":113.15787181078912,\"monoisotopicMass\":113.08406397853,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Ivdde\",\"name\":\"1-[4,4-dimethyl-2,6-dioxocyclohexylidene)-3-methylbutyl\",\"mf\":\"C13H19O2\",\"ocl\":{\"value\":\"f`a@b@NR@lyEEDhhigEVfjYjj`@@\",\"coordinates\":\"!BbOq~@Ha}urHGxuwu~@Ha}_`CW_Xa}bOq}b@JH\"},\"mass\":207.28925083325453,\"monoisotopicMass\":207.13850485151,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":19},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Leu\",\"name\":\"Leucine diradical\",\"mf\":\"C6H11NO\",\"kind\":\"aa\",\"oneLetter\":\"L\",\"alternativeOneLetter\":\"λ\",\"ocl\":{\"value\":\"defHPBPOEgEInWijjhr@@\",\"coordinates\":\"!BbGu~Ox`B_`BH_X`Bb@I~@Ha}\"},\"mass\":113.15787181078912,\"monoisotopicMass\":113.08406397853,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Lys\",\"name\":\"Lysine diradical\",\"mf\":\"C6H12N2O\",\"kind\":\"aa\",\"oneLetter\":\"K\",\"alternativeOneLetter\":\"κ\",\"ocl\":{\"value\":\"dmUHPBU@|V\\\\Tfy]YjjjL`@\",\"coordinates\":\"!BbGu~Ox`B_`BHoX`Bb@JH_X`BbKt\"},\"mass\":128.17251577629068,\"monoisotopicMass\":128.09496301519,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Lysp\",\"name\":\"Lysine triradical\",\"mf\":\"C6H11N2O\",\"ocl\":{\"value\":\"dcuHpH{PVY\\\\U|TeUYZjjjXY@@\",\"coordinates\":\"!Bb@JH_X`BbGvH@ha}_c~H@m]}_`BH_P\"},\"mass\":127.16457502223491,\"monoisotopicMass\":127.08713798295999,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Mbh\",\"name\":\"4,4'-Dimethoxybenzhydryl\",\"mf\":\"C15H15O2\",\"ocl\":{\"value\":\"fdy@b@G^@liLsJkzlcZmT@@@UP@@@\",\"coordinates\":\"!BbGvHGx_`BH_Xa}uwvHHc|_c}~Oxa}uwvHGxbGwW_P\"},\"mass\":227.27895961050194,\"monoisotopicMass\":227.10720472258998,\"unsaturation\":15,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Me\",\"name\":\"Methyl\",\"mf\":\"CH3\",\"ocl\":{\"value\":\"eFBAYc@@\",\"coordinates\":\"!B@FL\"},\"mass\":15.03455815890258,\"monoisotopicMass\":15.02347509669,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":1},{\"symbol\":\"H\",\"number\":3}]},{\"symbol\":\"Mebzl\",\"name\":\"4-Methylbenzyl\",\"mf\":\"C8H9\",\"ocl\":{\"value\":\"did@`@VTee]nh@H@@\",\"coordinates\":\"!B|Gsp__A|_gp_C}_gp_P\"},\"mass\":105.15735396038399,\"monoisotopicMass\":105.07042529007,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":9}]},{\"symbol\":\"Meobzl\",\"name\":\"4-Methoxybenzyl\",\"mf\":\"C8H9O\",\"ocl\":{\"value\":\"deTH`AAYRVUunh@J@@\",\"coordinates\":\"!B|Gsp__A|_gp_A}_gp_Wy\"},\"mass\":121.15675888470227,\"monoisotopicMass\":121.06533990964,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Met\",\"name\":\"Methionine diradical\",\"mf\":\"C5H9NOS\",\"kind\":\"aa\",\"oneLetter\":\"M\",\"alternativeOneLetter\":\"μ\",\"ocl\":{\"value\":\"defHpBPOEgDPaInWYjjhr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHHa}\"},\"mass\":131.19604181206938,\"monoisotopicMass\":131.04048508847,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mmt\",\"name\":\"4-Methoxytrityl\",\"mf\":\"C20H17O\",\"ocl\":{\"value\":\"ffcAB@B`V\\\\bdTTTRRRVvIhnRGMT@@@@AP@@@\",\"coordinates\":\"!BbKvHM^}_c}~@Hb}dXWHb}j|nHHc|AqOWoWxJV^Ho]\\\\BuwvHHb}\"},\"mass\":273.3491156779715,\"monoisotopicMass\":273.12794016748,\"unsaturation\":23,\"elements\":[{\"symbol\":\"C\",\"number\":20},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Mtc\",\"name\":\"2,2,5,7,8-pentamethylchroman-6-sulphonyl\",\"mf\":\"C14H19O3S\",\"ocl\":{\"value\":\"fleAa@DX\\\\AY`DYEHXhhilmiKW`rpDQUUD@@\",\"coordinates\":\"!BbGtBbGwWbGvHGxbGu~@Ha}uwu~Ox`B_c~H_Xa}b@H@_osW\"},\"mass\":267.36417906043516,\"monoisotopicMass\":267.10549064548,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":19},{\"symbol\":\"O\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mtr\",\"name\":\"4-Methoxy-2,3,6-trimethylbenzenesulphonyl\",\"mf\":\"C10H13O3S\",\"ocl\":{\"value\":\"do|LPDrpVXBLbdLTTTngYXBHj@@\",\"coordinates\":\"!BbOq}b@KWb@I~@Ha}bOsWHc|_c~H_Wx@b@JH_P\"},\"mass\":213.27359094915948,\"monoisotopicMass\":213.05854045209998,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"O\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mts\",\"name\":\"Mesitylene-2-sulphonyl\",\"mf\":\"C9H11O2S\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":183.24756861999438,\"monoisotopicMass\":183.04797576807,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"O\",\"number\":2},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mtt\",\"name\":\"4-Methyltrityl\",\"mf\":\"C20H17\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":257.3497107536532,\"monoisotopicMass\":257.13302554791,\"unsaturation\":23,\"elements\":[{\"symbol\":\"C\",\"number\":20},{\"symbol\":\"H\",\"number\":17}]},{\"symbol\":\"Nle\",\"name\":\"Norleucine diradical\",\"mf\":\"C6H11NO\",\"ocl\":{\"value\":\"defHPBPOEgEInWYjjhr@@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHHa}\"},\"mass\":113.15787181078912,\"monoisotopicMass\":113.08406397853,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Npys\",\"name\":\"3-Nitro-2-pyridinesulphenyl\",\"mf\":\"C5H3N2O2S\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":155.1545054234988,\"monoisotopicMass\":154.99152351908998,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":3},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":2},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Nva\",\"name\":\"Norvaline diradical\",\"mf\":\"C5H9NO\",\"ocl\":{\"value\":\"diFHPBPOEgEInWfjjL`@\",\"coordinates\":\"!BbGu~Ox`B_`BH_X`Bb@JH_P\"},\"mass\":99.13125440594231,\"monoisotopicMass\":99.06841391407,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Odmab\",\"name\":\"Odmab\",\"mf\":\"C20H26NO3\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":328.4260955245558,\"monoisotopicMass\":328.19126870111995,\"unsaturation\":15,\"elements\":[{\"symbol\":\"C\",\"number\":20},{\"symbol\":\"H\",\"number\":26},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Orn\",\"name\":\"Ornithine diradical\",\"mf\":\"C5H10N2O\",\"ocl\":{\"value\":\"deeHPBe@|V\\\\Tfy]fjjcH@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvHHa}\"},\"mass\":114.14589837144388,\"monoisotopicMass\":114.07931295072999,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":10},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Ornp\",\"name\":\"Ornithine triradical\",\"mf\":\"C5H9N2O\",\"ocl\":{\"value\":\"dmUHpHYPBQ\\\\Y|TeUejjjfJP@\",\"coordinates\":\"!BbGvHHa}b@JH_Wxb@KW_Wx@bGt\"},\"mass\":113.13795761738811,\"monoisotopicMass\":113.0714879185,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Pbf\",\"name\":\"2,2,4,6,7-pentamethyldihydrobenzofurane-5-sulfonyl\",\"mf\":\"C13H17O3S\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":253.33756165558833,\"monoisotopicMass\":253.08984058101998,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"O\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Pen\",\"name\":\"Penicillamine diradical\",\"mf\":\"C5H9NOS\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":131.19604181206938,\"monoisotopicMass\":131.04048508847,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Penp\",\"name\":\"Penicillamine triradical\",\"mf\":\"C5H8NOS\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":130.1881010580136,\"monoisotopicMass\":130.03266005624,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":8},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Ph\",\"name\":\"Phenyl\",\"mf\":\"C6H5\",\"ocl\":{\"value\":\"gOpH@liLkW@@@@\",\"coordinates\":\"!B|Owp_Gy|OwpWy\"},\"mass\":77.10411915069038,\"monoisotopicMass\":77.03912516115,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":5}]},{\"symbol\":\"Phe\",\"name\":\"Phenylalanine diradical\",\"mf\":\"C9H9NO\",\"kind\":\"aa\",\"oneLetter\":\"F\",\"alternativeOneLetter\":\"φ\",\"ocl\":{\"value\":\"dknHPBPOEgEInWe]NZj@@cH@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGvH@gxbGvH_Wx\"},\"mass\":147.1741979928833,\"monoisotopicMass\":147.06841391407002,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Phepcl\",\"name\":\"4-Chlorophenylalanine diradical\",\"mf\":\"C9H8ClNO\",\"ocl\":{\"value\":\"dg^HpBPOEgFxaInWe_Sfj`@bL`@\",\"coordinates\":\"!BbOq~@Ha}_c~H@m]}bGvH@gxbGvH_WxbGt\"},\"mass\":181.6191948214355,\"monoisotopicMass\":181.02944156384,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":8},{\"symbol\":\"Cl\",\"number\":1},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Pmc\",\"name\":\"2,2,5,7,8-Pentamethylchroman-6-sulphonyl\",\"mf\":\"C14H19O3S\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":267.36417906043516,\"monoisotopicMass\":267.10549064548,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":19},{\"symbol\":\"O\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Pro\",\"name\":\"Proline diradical\",\"mf\":\"C5H7NO\",\"kind\":\"aa\",\"oneLetter\":\"P\",\"alternativeOneLetter\":\"π\",\"ocl\":{\"value\":\"difHPBPOEgEInYxYjjhr@@\",\"coordinates\":\"!Bb@I~@Ha}tEJNwr[@UMo@FP\"},\"mass\":97.11537289783075,\"monoisotopicMass\":97.05276384961,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Pyr\",\"name\":\"Pyroglutamine\",\"mf\":\"C5H5NO2\",\"ocl\":{\"value\":\"deVDPBRP|V\\\\TfygxYjjZL`@\",\"coordinates\":\"!Bb@I~@Ha}tEJNwr[@UMo@FXBN\"},\"mass\":111.09889631403748,\"monoisotopicMass\":111.03202840472,\"unsaturation\":6,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Sar\",\"name\":\"Sarcosine diradical\",\"mf\":\"C3H5NO\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":71.07801959624871,\"monoisotopicMass\":71.03711378515,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Ser\",\"name\":\"Serine diradical\",\"mf\":\"C3H5NO2\",\"kind\":\"aa\",\"oneLetter\":\"S\",\"alternativeOneLetter\":\"σ\",\"ocl\":{\"value\":\"dazDPBS`|V\\\\TfyYjjL`@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}bGt\"},\"mass\":87.07742452056698,\"monoisotopicMass\":87.03202840472,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Serp\",\"name\":\"Serine triradical\",\"mf\":\"C3H4NO2\",\"ocl\":{\"value\":\"diFDpB`PBV\\\\^|TeYZjjXq@@\",\"coordinates\":\"!BbGvHHa}_c~HM]}_`BH_P\"},\"mass\":86.06948376651121,\"monoisotopicMass\":86.02420337249,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":4},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Sta\",\"name\":\"Statine diradical\",\"mf\":\"C8H15NO2\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":157.210511544801,\"monoisotopicMass\":157.11027872702002,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Stap\",\"name\":\"Statine triradical\",\"mf\":\"C8H14NO2\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":156.2025707907452,\"monoisotopicMass\":156.10245369479,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Tacm\",\"name\":\"Trimethylacetamidomethyl\",\"mf\":\"C6H12NO\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":114.16581256484488,\"monoisotopicMass\":114.09188901076,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Tbdms\",\"name\":\"t-Butyldimethylsilyl\",\"mf\":\"C6H15Si\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":115.2690253969541,\"monoisotopicMass\":115.09430201810001,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"Si\",\"number\":1}]},{\"symbol\":\"Tbu\",\"name\":\"t-Butyl\",\"mf\":\"C4H9\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":57.114410373442986,\"monoisotopicMass\":57.07042529007,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":9}]},{\"symbol\":\"Tbuo\",\"name\":\"t-Butoxy\",\"mf\":\"C4H9O\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":73.11381529776126,\"monoisotopicMass\":73.06533990964,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Tbuthio\",\"name\":\"t-Butylthio\",\"mf\":\"C4H9S\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":89.17919777957005,\"monoisotopicMass\":89.04249646446999,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Tfa\",\"name\":\"Trifluoroacetyl\",\"mf\":\"C2F3O\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":97.01608620597878,\"monoisotopicMass\":96.99012410776,\"unsaturation\":1,\"elements\":[{\"symbol\":\"C\",\"number\":2},{\"symbol\":\"F\",\"number\":3},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Thr\",\"name\":\"Threonine diradical\",\"mf\":\"C4H7NO2\",\"kind\":\"aa\",\"oneLetter\":\"T\",\"alternativeOneLetter\":\"τ\",\"ocl\":{\"value\":\"d@\"},\"mass\":101.10404192541378,\"monoisotopicMass\":101.04767846918,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Thrp\",\"name\":\"Threonine triradical\",\"mf\":\"C4H6NO2\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":100.09610117135801,\"monoisotopicMass\":100.03985343695001,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":4},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Tfsi\",\"name\":\"(Bis)(trifluoromethanesulfonyl)imide\",\"mf\":\"C2F6NO4S2\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":280.1457884908235,\"monoisotopicMass\":279.91729380789,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":2},{\"symbol\":\"F\",\"number\":6},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":4},{\"symbol\":\"S\",\"number\":2}]},{\"symbol\":\"Tips\",\"name\":\"Triisopropylsilyl\",\"mf\":\"C9H21Si\",\"ocl\":{\"value\":\"dmT@P@VX\\\\DffYjjjh@@\",\"coordinates\":\"!B_a@gHb\\\\]FBIuWxP^zi~KwxPFAt\"},\"mass\":157.34887761149452,\"monoisotopicMass\":157.14125221148,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":21},{\"symbol\":\"Si\",\"number\":1}]},{\"symbol\":\"Tms\",\"name\":\"Trimethylsilyl\",\"mf\":\"C3H9Si\",\"ocl\":{\"value\":\"gJPD@lqpRZj`@\",\"coordinates\":\"!BbOq~@GxbGt\"},\"mass\":73.1891731824137,\"monoisotopicMass\":73.04735182472,\"unsaturation\":-1,\"elements\":[{\"symbol\":\"C\",\"number\":3},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"Si\",\"number\":1}]},{\"symbol\":\"Tos\",\"name\":\"Tosyl\",\"mf\":\"C7H7O2S\",\"ocl\":{\"value\":\"dmtDPDpEf@cHiCDeafV@B@@\",\"coordinates\":\"!B|Ou||Ovw|Gwp_Gy|GwpWy|Gt\"},\"mass\":155.1943338103008,\"monoisotopicMass\":155.01667563914998,\"unsaturation\":7,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"O\",\"number\":2},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Trp\",\"name\":\"Tryptophan diradical\",\"mf\":\"C11H10N2O\",\"kind\":\"aa\",\"oneLetter\":\"W\",\"alternativeOneLetter\":\"ω\",\"ocl\":{\"value\":\"f`qQA@BFPCqXxiMr|rnhsoSUTa@QCD@@\",\"coordinates\":\"!BbOq~@Ha}_c~H@m]}bGwPTh{_UMojXL@YpB[@Ini`\"},\"mass\":186.21031375185538,\"monoisotopicMass\":186.07931295073,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":10},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Trpp\",\"name\":\"Tryptophan triradical\",\"mf\":\"C11H9N2O\",\"ocl\":{\"value\":\"fhiQC@HFB@I\\\\x~|TfYU_ebLDjhDHjibFd@\",\"coordinates\":\"!BTmA}bL@fUHR_Ihz@iVBeXHc|grZH_WxbOsW_Wx@bGt\"},\"mass\":185.20237299779959,\"monoisotopicMass\":185.07148791850003,\"unsaturation\":15,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Trt\",\"name\":\"Trityl\",\"mf\":\"C19H15\",\"ocl\":{\"value\":\"fbm@B@@KJSSLrjkyhnRGMT@@@@@@@@\",\"coordinates\":\"!BrHI~PGy_rMvW@l`BQCvWw\\\\bBAg}~PGy@]i}~W|c]cNwH`i_]_e|\"},\"mass\":243.32309334880637,\"monoisotopicMass\":243.11737548345,\"unsaturation\":23,\"elements\":[{\"symbol\":\"C\",\"number\":19},{\"symbol\":\"H\",\"number\":15}]},{\"symbol\":\"Tyr\",\"name\":\"Tyrosine diradical\",\"mf\":\"C9H9NO2\",\"kind\":\"aa\",\"oneLetter\":\"Y\",\"alternativeOneLetter\":\"ψ\",\"ocl\":{\"value\":\"dg^DPBRp|V\\\\Tfy^U}NZj@BHr@@\",\"coordinates\":\"!BbOq~@Ha}_c~H@m]}bGvH@gxbGvH_WxbGt\"},\"mass\":163.1736029172016,\"monoisotopicMass\":163.06332853364,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Tyrp\",\"name\":\"Tyrosine triradical\",\"mf\":\"C9H8NO2\",\"ocl\":{\"value\":\"do~DpEapBS\\\\[|Tee]YYnh@JjdbT@\",\"coordinates\":\"!B_`BHGx@bGvH@h`BbKvH@ha}_c~H@m]}_`BHoP\"},\"mass\":162.16566216314578,\"monoisotopicMass\":162.05550350141,\"unsaturation\":11,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":8},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Val\",\"name\":\"Valine\",\"mf\":\"C5H9NO\",\"kind\":\"aa\",\"oneLetter\":\"V\",\"alternativeOneLetter\":\"ν\",\"ocl\":{\"value\":\"diFHPBPOEgEInVfjjL`@\",\"coordinates\":\"!Bb@I~@Ha}_c~H@m]}_`BH_P\"},\"mass\":99.13125440594231,\"monoisotopicMass\":99.06841391407,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Valoh\",\"name\":\"beta-Hydroxyvaline diradical\",\"mf\":\"C5H9NO2\",\"ocl\":{\"value\":\"defDPBS`|V\\\\TfyZfjjcH@\",\"coordinates\":\"!Bb@I~@Ha}b@I~Oxa}Owy~OpA~\"},\"mass\":115.13065933026058,\"monoisotopicMass\":115.06332853364,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Valohp\",\"name\":\"beta-Hydroxyvaline triradical\",\"mf\":\"C5H8NO2\",\"ocl\":{\"value\":\"dmVDpFaPBQ\\\\Y|\\\\bTbaTjjjXq@@\",\"coordinates\":\"!BbGvHHa}_Xc|bGxb@KW_Wx@bGt\"},\"mass\":114.1227185762048,\"monoisotopicMass\":114.05550350141002,\"unsaturation\":3,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":8},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Xan\",\"name\":\"Xanthyl\",\"mf\":\"C13H9O\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":181.21043836837848,\"monoisotopicMass\":181.06533990964002,\"unsaturation\":17,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Xle\",\"name\":\"Leucine or Isoleucine diradical\",\"mf\":\"C6H11NO\",\"kind\":\"aa\",\"oneLetter\":\"J\",\"mass\":113.15787181078912,\"monoisotopicMass\":113.08406397853,\"unsaturation\":2,\"elements\":[{\"symbol\":\"C\",\"number\":6},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Z\",\"name\":\"Benzyloxycarbonyl\",\"mf\":\"C8H7O2\",\"ocl\":{\"value\":\"dmtD`DpEeImYVUfh@@@@\",\"coordinates\":\"!Bb@I~@Ha}b@JH_Xc|_c~H_Xa}_c|\"},\"mass\":135.14028230090898,\"monoisotopicMass\":135.04460446475,\"unsaturation\":9,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Damp\",\"name\":\"Desoxyadenosine monophosphate diradical\",\"mf\":\"C10H12N5O5P\",\"kind\":\"DNAp\",\"oneLetter\":\"A\",\"alternativeOneLetter\":\"α\",\"ocl\":{\"value\":\"fnsiS@IASUlJB]xGbkplxyDhhldhiEEUeSdTekUUUULBATXPlKd@@\",\"coordinates\":\"!Bqc}{JxyO|XoSWC}W]poGQ\\\\Ou}]rmx\\\\Ou}]{qpza|qb}MJwlk^sFO|X\"},\"mass\":313.2069506932622,\"monoisotopicMass\":313.05760550518,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":5},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dcmp\",\"name\":\"Desoxycytidine monophosphate diradical\",\"mf\":\"C9H12N3O6P\",\"kind\":\"DNAp\",\"oneLetter\":\"C\",\"alternativeOneLetter\":\"ς\",\"ocl\":{\"value\":\"fjmps@IQKB`g^BCqUxV\\\\\\\\bTTVRTTbb^iqNZjjjifVkBEa\\\\`@\",\"coordinates\":\"!Bqc}{JxyO|XoSWA}_W]poGQ\\\\GuMKuMh\\\\Gu}]{qpSF]tWQTvatP\"},\"mass\":289.18221329795364,\"monoisotopicMass\":289.04637211589,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dgmp\",\"name\":\"Desoxyguanosine monophosphate diradical\",\"mf\":\"C10H12N5O6P\",\"kind\":\"DNAp\",\"oneLetter\":\"G\",\"alternativeOneLetter\":\"γ\",\"ocl\":{\"value\":\"fakhs@IASUlJB]{hOEWaYqrIQQYIQRJJkQTyEIZuUUUSRtsUaBpnP@\",\"coordinates\":\"!Bqc}{JxyO|XoSWA}W]poGQ\\\\Gu}]rmx\\\\Ou}]{qpza|qb}MJwlk^sFza|q`\"},\"mass\":329.20635561758047,\"monoisotopicMass\":329.05252012475,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dtmp\",\"name\":\"Desoxythymidine monophosphate diradical\",\"mf\":\"C10H13N2O7P\",\"kind\":\"DNAp\",\"oneLetter\":\"T\",\"alternativeOneLetter\":\"τ\",\"ocl\":{\"value\":\"ff}Qs@IQaPSoAjCqUxV\\\\\\\\bTTVRTTbbZUNIsUUUULsSVDKBy@@\",\"coordinates\":\"!Bqc}{JxyO|XoSWC}_W]poGQ\\\\GuMKuMh\\\\Gu}]{qpSF]tWQTvaSZGQ\"},\"mass\":304.1935916616171,\"monoisotopicMass\":304.04603776326,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dump\",\"name\":\"Desoxyuridine monophosphate diradical\",\"mf\":\"C9H11N2O7P\",\"kind\":\"DNAp\",\"oneLetter\":\"U\",\"alternativeOneLetter\":\"υ\",\"ocl\":{\"value\":\"fjmQs@IQaPSoAJCqUxV\\\\\\\\bTTVRTTbb^iqNZjjjifYkBEa\\\\`@\",\"coordinates\":\"!Bqc}{JxyO|XoSWA}_W]poGQ\\\\GuMKuMh\\\\Gu}]{qpSF]tWQTvatP\"},\"mass\":290.1669742567703,\"monoisotopicMass\":290.0303876988,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Drmp\",\"name\":\"Desoxyribose monophosphate diradical\",\"mf\":\"C5H7O5P\",\"kind\":\"DNAp\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":178.08005138207807,\"monoisotopicMass\":178.00311032188,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"O\",\"number\":5},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dadp\",\"name\":\"Desoxyadenosine diphosphate diradical\",\"mf\":\"C10H13N5O8P2\",\"kind\":\"DNApp\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"fmwhH`IASM\\\\JBl{wQ`|U^F_AkbdlsjsSOoRtyEMYuUUUM@pSEQaBpnP@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGu}utnDM^HGwWzf~_Ih}M_`AKvto[_`@_`A~grZ_I`\"},\"mass\":393.1868682186928,\"monoisotopicMass\":393.02393639454,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Dcdp\",\"name\":\"Desoxycytidine diphosphate diradical\",\"mf\":\"C9H13N3O9P2\",\"kind\":\"DNApp\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fikqH`IQGB`kN|EoP^JoCOaUqrIQQYIQRJKGRJgDejjjjZYfZkBEa\\\\`@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGuMcqLX@m^H@gwWKB__t]Q_`@SFGx@Owx@_mQ\"},\"mass\":369.16213082338425,\"monoisotopicMass\":369.01270300525005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Dgdp\",\"name\":\"Desoxyguanosine diphosphate diradical\",\"mf\":\"C10H13N5O9P2\",\"kind\":\"DNApp\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"fcoiH`IASM\\\\JBl{wQ{Axj|L~CWEIYgUff_^fZ\\\\bflzjjjfiZifZlHVEr@@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGu}utnD@m^H@gwWzf~_Ih}M_`AKvto[_`@_`A~gr[j[y|f\"},\"mass\":409.186273143011,\"monoisotopicMass\":409.01885101411,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Dtdp\",\"name\":\"Desoxythymidine diphosphate diradical\",\"mf\":\"C10H14N2O10P2\",\"kind\":\"DNApp\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"fe{Ph`IQaPUg^Ct\\\\p^JoCO`uqrIQQYIQRJKEJQTxdmUUUSSMTsVDKBy@@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^HMQbGuMcqLX@m^H@gwWKB__t]Q_`@SFALX_`@_`A~w}D\"},\"mass\":384.1735091870477,\"monoisotopicMass\":384.01236865262,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Dudp\",\"name\":\"Desoxyuridine diphosphate diradical\",\"mf\":\"C9H12N2O10P2\",\"kind\":\"DNApp\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fikPh`IQaPUg^Bwhp^JoCOaUqrIQQYIQRJKGRJgDejjjjZYjYkBEa\\\\`@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGuMcqLX@m^H@gwWKB__t]Q_`@SFGx@Owx@_mQ\"},\"mass\":370.1468917822009,\"monoisotopicMass\":369.99671858816,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Datp\",\"name\":\"Desoxyadenosine triphosphate diradical\",\"mf\":\"C10H14N5O11P3\",\"kind\":\"DNAppp\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"eohZMJ@I@diehJAKGOFnakg`OESpr|Mo@yqrIQQYIQRJKYZQKVRcbIJjZjjjihFAhjZcAAXKb@@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGu}utnDM^H@gwWzf~_Ih}M_`AKvto[@hcW@`A~grZ_Igx@_`@@_c}~\"},\"mass\":473.16678574412344,\"monoisotopicMass\":472.9902672839,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Dctp\",\"name\":\"Desoxycytidine triphosphate diradical\",\"mf\":\"C9H14N3O12P3\",\"kind\":\"DNAppp\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fkopZ`IQGB`kN|Fk^{NCqUxY|I~BwGHeEEdeEHhl]HlYJ\\\\RVjjjiifVjfkBEa\\\\`@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGuMcqLX@m^H@gwWKB__t]Q_`@SFOrHupH@_mQ_`A~@@A~Owx\"},\"mass\":449.14204834881485,\"monoisotopicMass\":448.97903389461004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":12},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Dgtp\",\"name\":\"Desoxyguanosine triphosphate diradical\",\"mf\":\"C10H14N5O12P3\",\"kind\":\"DNAppp\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"e`TZCJ@I@diehJAKGOFnamgo`OESpr|CoByqrIQQYIQRJKYZQQYrT\\\\QIUSUUUUMRuMLtuVBBpWD@@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGu}utnD@m^H@gwWzf~_Ih}M_`AKvto[@hcW@`A~gr[j[y|f_`A~@@A~Owx\"},\"mass\":489.16619066844174,\"monoisotopicMass\":488.98518190347005,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":12},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Dttp\",\"name\":\"Desoxythymidine triphosphate diradical\",\"mf\":\"C10H15N2O13P3\",\"kind\":\"DNAppp\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"fgQZ`IQaPUg^BwhygnCqUxY|E~FwGHeEEdeEHhlTiDSISbRuUUUMLuMMMVDKBy@@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGuMcqLX@m^H@gwWKB__t]Q_`@SFALXHcW@`A~w}E~@Gx@@Gx_`\"},\"mass\":464.15342671247834,\"monoisotopicMass\":463.97869954198,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Dutp\",\"name\":\"Desoxyuridine triphosphate diradical\",\"mf\":\"C9H13N2O13P3\",\"kind\":\"DNAppp\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fkoQZ`IQaPUg^CUoQ{NCqUxY|I~BwGHeEEdeEHhl]HlYJ\\\\RVjjjiiffffkBEa\\\\`@\",\"coordinates\":\"!BIi[Rx{_grZOSXa}_]^H@mQbGuMcqLX@m^H@gwWKB__t]Q_`@SFOrHupH@_mQ_`A~@@A~Owx\"},\"mass\":450.1268093076315,\"monoisotopicMass\":449.96304947752,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Dade\",\"name\":\"Desoxyadenosine diradical\",\"mf\":\"C10H11N5O2\",\"kind\":\"DNA\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"fluha@IF]ELJ@|QNJRsN|rntyYpXuUUTBATXPlKd@@\",\"coordinates\":\"!B\\\\KqpQARcg|T^|X@@Id`zeHo@Ie}]vaLcg|T^qAMDDvN_xy\"},\"mass\":233.22703316783156,\"monoisotopicMass\":233.09127461582,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Dcyt\",\"name\":\"Desoxycytidine diradical\",\"mf\":\"C9H11N3O3\",\"kind\":\"DNA\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fhiqa@IVCBa`^HgEIYg^Y~gG^jjjiejpaXWH@\",\"coordinates\":\"!BBOpH_UARcc}TN|Y@PIe`zeIO@MDSIrpXTd}RSqLgTd|\"},\"mass\":209.202295772523,\"monoisotopicMass\":209.08004122653,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Dgua\",\"name\":\"Desoxyguanosine diradical\",\"mf\":\"C10H11N5O3\",\"kind\":\"DNA\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"fbmia@IF]ELJYAxb\\\\Tef]ye^Z\\\\lxLZjjjeZfkBEa\\\\`@\",\"coordinates\":\"!B\\\\KqpQARcg|T^|X@@Id`zeHo@Ie}]vaLcg|T^qAMDDvN_vaLcg|\"},\"mass\":249.22643809214986,\"monoisotopicMass\":249.08618923539,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Dthy\",\"name\":\"Desoxythymidine diradical\",\"mf\":\"C10H12N2O4\",\"kind\":\"DNA\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"fdyPQ@IVaPtP^HgEIYg^YuiqwjjjjYikBEa\\\\`@\",\"coordinates\":\"!BBOpH_UARcc}TN|Y@PIe`zeIO@MDSIrpXTd}RSqLgDr]RSp\"},\"mass\":224.2136741361865,\"monoisotopicMass\":224.07970687390002,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":4}]},{\"symbol\":\"Dura\",\"name\":\"Desoxyuridine diradical\",\"mf\":\"C9H10N2O4\",\"kind\":\"DNA\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fhiPQ@IVaPpP^HgEIYg^Y~gG^jjjifZpaXWH@\",\"coordinates\":\"!BBOpH_UARcc}TN|Y@PIe`zeIO@MDSIrpXTd}RSqLgTd|\"},\"mass\":210.1870567313397,\"monoisotopicMass\":210.06405680944,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":10},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":4}]},{\"symbol\":\"Amp\",\"name\":\"Adenosine monophosphate diradical\",\"mf\":\"C10H12N5O6P\",\"kind\":\"RNAp\",\"oneLetter\":\"A\",\"alternativeOneLetter\":\"α\",\"ocl\":{\"value\":\"fakhs@INBwlJ\\\\TgHOFwaEqrIQQSYQJIRIMLyxMVuUUUPLpEPQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@@\"},\"mass\":329.20635561758047,\"monoisotopicMass\":329.05252012475,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cmp\",\"name\":\"Cytidine monophosphate diradical\",\"mf\":\"C9H12N3O7P\",\"kind\":\"RNAp\",\"oneLetter\":\"C\",\"alternativeOneLetter\":\"ς\",\"ocl\":{\"value\":\"ff}qs@I^kBgENSdGc[pbxyDhhilheDiLv\\\\BVjjjjYfZbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":305.1816182222719,\"monoisotopicMass\":305.04128673546,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Gmp\",\"name\":\"Guanosine monophosphate diradical\",\"mf\":\"C10H12N5O7P\",\"kind\":\"RNAp\",\"oneLetter\":\"G\",\"alternativeOneLetter\":\"γ\",\"ocl\":{\"value\":\"fi{is@INBwlJ\\\\TgHp^MoBKcdRbbfrbTRdR\\\\SN^CUmUUUUKMSMQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtP@gD}D@\"},\"mass\":345.20576054189877,\"monoisotopicMass\":345.04743474432,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tmp\",\"name\":\"Thymidine monophosphate diradical\",\"mf\":\"C10H13N2O8P\",\"kind\":\"RNAp\",\"oneLetter\":\"T\",\"alternativeOneLetter\":\"τ\",\"ocl\":{\"value\":\"fncPK@I^aSbgIrtGc[pbxyDhhilheDiLjs`RuUUUSLuMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ump\",\"name\":\"Uridine monophosphate diradical\",\"mf\":\"C9H11N2O8P\",\"kind\":\"RNAp\",\"oneLetter\":\"U\",\"alternativeOneLetter\":\"υ\",\"ocl\":{\"value\":\"ff}PK@I^aSbgIsTGc[pbxyDhhilheDiLv\\\\BVjjjjYffbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":306.1663791810886,\"monoisotopicMass\":306.02530231837,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Rmp\",\"name\":\"Ribose monophosphate diradical\",\"mf\":\"C5H7O6P\",\"kind\":\"RNAp\",\"ocl\":{\"value\":\"d@\",\"coordinates\":\"\"},\"mass\":194.07945630639637,\"monoisotopicMass\":193.99802494145,\"unsaturation\":4,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Adp\",\"name\":\"Adenosine diphosphate diradical\",\"mf\":\"C10H13N5O9P2\",\"kind\":\"RNApp\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"fcoiH`INCt\\\\J\\\\UENU{Axv|F~DwGHeEEMeDheHd\\\\eHsg`u{UUUU@mAEMPQDqBId@@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPbOr_IorHbGtgD}F@RxPBuxc|_]^OTh}R_`CQ`MF@_`@_`A~\"},\"mass\":409.186273143011,\"monoisotopicMass\":409.01885101411,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Cdp\",\"name\":\"Cytidine diphosphate diradical\",\"mf\":\"C9H13N3O10P2\",\"kind\":\"RNApp\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fe{ph`I^[BgENbgHy`|[^E_CkcdRbbfrbTRdqrdYpIZjjjieijZbHfHQL`@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPb@K_cbpXbKtSItwPS]@Bux`Bo]\\\\lFGx@S]A~@C}~@Gx\"},\"mass\":385.1615357477025,\"monoisotopicMass\":385.00761762482,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Gdp\",\"name\":\"Guanosine diphosphate diradical\",\"mf\":\"C10H13N5O10P2\",\"kind\":\"RNApp\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"fkhh`INCt\\\\J\\\\UENY{NCqmxM|EnNQJJJ[JIQJQHzIRLyxM^uUUUTkUSLuQDSDHfP@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_I`JHbGtgD}F@RxPBux`B_]^OTh}R_`CQ`B\\\\StXA~@C}~@Gx\"},\"mass\":425.1856780673293,\"monoisotopicMass\":425.01376563368,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Tdp\",\"name\":\"Thymidine diphosphate diradical\",\"mf\":\"C10H14N2O11P2\",\"kind\":\"RNApp\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"fmgQh`I^aSbgQSglu`|[^C_@[bdls^rruo}LxDmUUUTruTsTQDqBId@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPbOs_cbpXbGtSItwPS]@Bux`B_]\\\\lFBpX_`AMtGx@Owx@_`\"},\"mass\":400.172914111366,\"monoisotopicMass\":400.00728327219,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Udp\",\"name\":\"Uridine diphosphate diradical\",\"mf\":\"C9H12N2O11P2\",\"kind\":\"RNApp\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fe{Qh`I^aSbgQSehy`|[^E_CkcdRbbfrbTRdqrdYpIZjjjiejfZbHfHQL`@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPb@K_cbpXbKtSItwPS]@Bux`Bo]\\\\lFGx@S]A~@C}~@Gx\"},\"mass\":386.14629670651925,\"monoisotopicMass\":385.99163320773005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Atp\",\"name\":\"Adenosine triphosphate diradical\",\"mf\":\"C10H14N5O12P3\",\"kind\":\"RNAppp\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"e`TZCJ@IG@nahJNEHdliemgo`OFspZ|CoByqrIQQSYQJIRIGIRWRL\\\\^AU]UUUUPKPQMTuABDpaBX`@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPbOr_IorHbGtgD}F@RxS|uxc|_]^OTh}R_`CQ`MF@@hcW@A~_`A~@@A~Owx\"},\"mass\":489.16619066844174,\"monoisotopicMass\":488.98518190347005,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":12},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Ctp\",\"name\":\"Cytidine triphosphate diradical\",\"mf\":\"C9H14N3O13P3\",\"kind\":\"RNAppp\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fgqZ`I^[BgENbgOQsO\\\\Gc[pkxK|MnNQJJJ[JIQJSGJPzQg@ejjjjfVffjZbHfHQL`@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@K_cbpXbGtSItwPS]C|ux`B_]\\\\lFGx@S]@BbM\\\\B@Gy~@Gx@@Gx_`\"},\"mass\":465.1414532731331,\"monoisotopicMass\":464.97394851418,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Gtp\",\"name\":\"Guanosine triphosphate diradical\",\"mf\":\"C10H14N5O13P3\",\"kind\":\"RNAppp\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"eh\\\\ZKJ@IG@nahJNEHdliemco`POFspZ|KoAyqrIQQSYQJIRIGQJQzQccpJkjjjjjeZjYZijbDIaBDq@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_I`JHbGtgD}F@RxPBux`B_]^OTh}R_`CQ`B\\\\StX@BbM_|@Gy~@Gx@@Gx_`\"},\"mass\":505.16559559276,\"monoisotopicMass\":504.98009652304,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Ttp\",\"name\":\"Thymidine triphosphate diradical\",\"mf\":\"C10H15N2O14P3\",\"kind\":\"RNAppp\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"eo`TGJ@IOHJNEGHdlnaiekg`OFspZ|Mo@yqrIQQSYQJIRY[ZPzQc`HjjjjjYZjVjZbDIaBDq@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@K_cbpXbGtSItwPS]@Bux`B_]\\\\lFBpX_`AMt@JHupH@_gx@_`@@_c}~\"},\"mass\":480.15283163679663,\"monoisotopicMass\":479.97361416155,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":14},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Utp\",\"name\":\"Uridine triphosphate diradical\",\"mf\":\"C9H13N2O14P3\",\"kind\":\"RNAppp\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fgPz`I^aSbgQSeoQsO\\\\Gc[pkxK|MnNQJJJ[JIQJSGJPzQg@ejjjjfVjVjZbHfHQL`@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@K_cbpXbGtSItwPS]C|ux`B_]\\\\lFGx@S]@BbM\\\\B@Gy~@Gx@@Gx_`\"},\"mass\":466.12621423194986,\"monoisotopicMass\":465.95796409709004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":14},{\"symbol\":\"P\",\"number\":3}]},{\"symbol\":\"Ade\",\"name\":\"Adenosine diradical\",\"mf\":\"C10H11N5O3\",\"kind\":\"RNA\",\"oneLetter\":\"A\",\"ocl\":{\"value\":\"fbmia@IV|gLJ\\\\Axj\\\\Tef[vyWV\\\\]zJZjjj`PJ`bIbDSH@\",\"coordinates\":\"!BBOpH_UARccFPEP{PId{RpBN[~i|BEP{iVA@fUARU@QTADBYPId\"},\"mass\":249.22643809214986,\"monoisotopicMass\":249.08618923539,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Cyt\",\"name\":\"Cytidine diradical\",\"mf\":\"C9H11N3O4\",\"kind\":\"RNA\",\"oneLetter\":\"C\",\"ocl\":{\"value\":\"fdypQ@INcBgK@|UNJRsM{\\\\~sg`uUUULmQDSDHfP@\",\"coordinates\":\"!BBOpH_UARccFPEP{PId{RpBN[~iRTBpgDq`@c`BNKB\\\\@c`\"},\"mass\":225.20170069684127,\"monoisotopicMass\":225.0749558461,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":4}]},{\"symbol\":\"Gua\",\"name\":\"Guanosine diradical\",\"mf\":\"C10H11N5O4\",\"kind\":\"RNA\",\"oneLetter\":\"G\",\"ocl\":{\"value\":\"fj}hQ@IV|gLJ\\\\JCqTxiKLwmroKNN}EMUUUTkTuDQLPbY@@\",\"coordinates\":\"!BBOpH_UARccFPEP{PId{RpBN[~k|BEP{iVA@fUARU@QTADBYiVA@fP\"},\"mass\":265.22584301646816,\"monoisotopicMass\":265.08110385496,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":4}]},{\"symbol\":\"Thy\",\"name\":\"Thymidine diradical\",\"mf\":\"C10H12N2O5\",\"kind\":\"RNA\",\"oneLetter\":\"T\",\"ocl\":{\"value\":\"fleQQ@INaSed`|UNJRsM{\\\\zlyxMUUUSMMDQLPbY@@\",\"coordinates\":\"!BBOpH_UARccFPEP{PId{RpBN[~iRTBpgDq`@c`BNKB\\\\lIpBN\"},\"mass\":240.21307906050478,\"monoisotopicMass\":240.07462149347,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":5}]},{\"symbol\":\"Ura\",\"name\":\"Uridine diradical\",\"mf\":\"C9H10N2O5\",\"kind\":\"RNA\",\"oneLetter\":\"U\",\"ocl\":{\"value\":\"fdyQQ@INaSeh`|UNJRsM{\\\\~sg`uUUULsQDSDHfP@\",\"coordinates\":\"!BBOpH_UARccFPEP{PId{RpBN[~iRTBpgDq`@c`BNKB\\\\@c`\"},\"mass\":226.18646165565798,\"monoisotopicMass\":226.05897142901,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":10},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":5}]},{\"symbol\":\"Dam\",\"name\":\"1,2′-O-dimethyladenosine monophosphate diradical 01A\",\"mf\":\"C12H16N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"œ\",\"ocl\":{\"value\":\"feghs@E^ct\\\\J\\\\udhOEw`eqrIQQQKZIQJQIiLxFK^uUUUUKLtuQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@SuH\"},\"mass\":357.2595904272741,\"monoisotopicMass\":357.08382025367,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dgm\",\"name\":\"1,2′-O-dimethylguanosine monophosphate diradical 01G\",\"mf\":\"C12H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ε\",\"ocl\":{\"value\":\"fmwis@E^ct\\\\J\\\\udlp^KoAKcdRbbbVtRbTbSbSNAbwmUUUURsMSUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@B\\\\StPAOT`\"},\"mass\":373.2589953515923,\"monoisotopicMass\":373.07873487324,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dim\",\"name\":\"1,2′-O-dimethylinosine monophosphate diradical 019A\",\"mf\":\"C12O7N4H15P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ξ\",\"ocl\":{\"value\":\"fegIs@E^cvENZrTXOEw`eqrIQQQKZIQJQIiLxFK^uUUUUKLtuQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@SuH\"},\"mass\":358.2443513860907,\"monoisotopicMass\":358.06783583658,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tia\",\"name\":\"2- methylthiomethylenethio-N6-isopentenyl-adenosine monophosphate diradical\",\"mf\":\"C17H24N5O6PS2\",\"kind\":\"NucleotideP\",\"oneLetter\":\"£\",\"ocl\":{\"value\":\"eh\\\\ZFJ@IG@nahJNEDl`OFspb\\\\V`cXHrIQQSYQJIRINIYIKQccpJkjjjjjAfBJjfjBDIaBDq@@\",\"coordinates\":\"!BpBYTvxBNFY|bEJObGvOS\\\\@Yt]~DUEJOctu~@Ha}`HzOSTwPTh~H@hc|_`BH_Xa}b@JH@gx@bGvH@h`B_`BH_P\"},\"mass\":489.50637075565066,\"monoisotopicMass\":489.09056286031,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":24},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":2}]},{\"symbol\":\"Mhc\",\"name\":\"2′‐O‐Methyl-5-hydroxymethylcytidine monophosphate diradical\",\"mf\":\"C11H16N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¡\",\"ocl\":{\"value\":\"fikpK@EA{BgM^rTXOEw`eqrIQQQKZIQJSJigHujjjjifYjkBHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@HoTuOSU@HC~NKA`HoQLgSUAMT@a}oS_|BBpXKAaMT@CQ\"},\"mass\":349.2342579562838,\"monoisotopicMass\":349.06750148395,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Odg\",\"name\":\"N2,2′-O-dimethylguanosine monophosphate diradical 02G\",\"mf\":\"C12H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"γ\",\"ocl\":{\"value\":\"fmwis@E^ct\\\\J\\\\udlp^KoAKcdRbbbVtRbTbSbsNAbwmUUUURsMSUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@B\\\\StPAOT`\"},\"mass\":373.2589953515923,\"monoisotopicMass\":373.07873487324,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ntg\",\"name\":\"N2,N2,2′-O-trimethylguanosine monophosphate diradical 022G\",\"mf\":\"C13H18N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"|\",\"ocl\":{\"value\":\"fcois@E^ct\\\\J\\\\udlp^KoAKcdRbbbVtRbTbSbTYpLVcjjjjjVYjZjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuHgD}D@tPBNOt}R\"},\"mass\":387.2856127564392,\"monoisotopicMass\":387.0943849377,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Otg\",\"name\":\"N2,7,2′-O-trimethylguanosine monophosphate diradical 027G\",\"mf\":\"C13H20N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"æ\",\"ocl\":{\"value\":\"fcoisBE^bN\\\\J\\\\udjp^KoAKcFU}dRbbbVtRbTbRlQYpLVcjjjjjVYjjjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKFPMD@IqOQ@D}R\"},\"mass\":389.30149426455074,\"monoisotopicMass\":389.11003500216,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Rya\",\"name\":\"2′-O-ribosyladenosine monophosphate diradical 00A\",\"mf\":\"C15H20N5O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"^\",\"ocl\":{\"value\":\"e`\\\\ZIL@DaegobFAIO@hlm`OGSp\\\\\\\\\\\\bbbfrRbdTT\\\\rbRQUCDQTrusuUUUUMUU@pET@@@\",\"coordinates\":\"!BIlAKaMARw}DBbMF@bGuMtHc|KAbH_ZU`@GzH_WwW@h`XKFjKB_jXB\\\\SiVA`zmG_Irp_hQKctvOSR\\\\lIrp\"},\"mass\":445.3217759066577,\"monoisotopicMass\":445.09986424130005,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ryg\",\"name\":\"2′-O-ribosylguanosine monophosphate diradical 00G\",\"mf\":\"C15H20N5O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ℑ\",\"ocl\":{\"value\":\"ehRZEL@DaegobFAIO@hlm`POGSp\\\\\\\\\\\\bbbfrRbdTT\\\\rbRQbhXbJfVn^jjjjijjjVZfj@@@\",\"coordinates\":\"!BIlAKaMARw}DBbMF@bGuMtH`BKAbH_ZU`@GzH_WwW@h`XKFjKB_jXB\\\\SiVA`zmG_Irp_hQKctvOSR\\\\lt]|gK@\"},\"mass\":461.321180830976,\"monoisotopicMass\":461.09477886087,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tmu\",\"name\":\"2-thio-2′-O-methyluridine monophosphate diradical 02U\",\"mf\":\"C10H13N2O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∏\",\"ocl\":{\"value\":\"fncQp`EAaSfleZCq]x^BDnNQJJJI[QJIRYlyFmUUUULsSQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@\"},\"mass\":336.25837906774416,\"monoisotopicMass\":336.01810893766003,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dmut\",\"name\":\"3,2′-O-dimethyluridine monophosphate diradical 03U\",\"mf\":\"C11H15N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"σ\",\"ocl\":{\"value\":\"fasPK@EAaSfoYKtGb{pRxyDhhhemDheIhv\\\\cVjjjjfYjZHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXOxyMT@\"},\"mass\":334.2196139907822,\"monoisotopicMass\":334.05660244729,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Amc\",\"name\":\"N4-acetyl-2′-O-methylcytidine monophosphate diradical 042C\",\"mf\":\"C12H16N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ℵ\",\"ocl\":{\"value\":\"fe{pK@EA[BgM^rTXOEw`eqrIQQQKZIQJSMJLyFmUUUULsMMQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@caLgSU@\"},\"mass\":361.244993853019,\"monoisotopicMass\":361.06750148395,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tmc\",\"name\":\"N4,N4,2′-O-trimethylcytidine monophosphate diradical 044C\",\"mf\":\"C12H18N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"β\",\"ocl\":{\"value\":\"fikqs@EA[BgM^rTGb{pRxyDhhhemDheIfhsdZuUUUTsLuTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@cbpX\"},\"mass\":347.2614704368123,\"monoisotopicMass\":347.08823692884005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dcy\",\"name\":\"N4,2′-O-dimethylcytidine monophosphate diradical 04C\",\"mf\":\"C11H16N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"λ\",\"ocl\":{\"value\":\"fasqs@EA[BgM^rTGb{pRxyDhhhemDheIff\\\\cVjjjjfYfjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@lF@\"},\"mass\":333.23485303196554,\"monoisotopicMass\":333.07258686438,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Muo\",\"name\":\"2′-O-methyluridine 5-oxyacetic acid methyl ester monophosphate diradical 0503U\",\"mf\":\"C13H17N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ͽ\",\"ocl\":{\"value\":\"fkoQk@EAaSfoYJwj}`|W^BWGHeEEDmheDiLjlif\\\\cVjjjjfYjZZhbIbDSH@\",\"coordinates\":\"!BKAb@tURD@m\\\\YpMAMpBYMcvjbOplIwx@bGuMc}\\\\Bb@JH@dvOcuKPSXa}bGvHH`BbGu~Oxc|bGt\"},\"mass\":408.25518206531905,\"monoisotopicMass\":408.05699637046,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Xmu\",\"name\":\"5-carboxymethylaminomethyl-2′-O-methyluridine monophosphate diradical 051U\",\"mf\":\"C13H18N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\")\",\"ocl\":{\"value\":\"fkopk@EAGBgM^rWns`|W^BWGHeEEDmheDiLjleF\\\\cVjjjjfYjZfhbIbDSH@\",\"coordinates\":\"!BKAb@tURD@m\\\\YpMAMpBYMcvjb@HlIwx@bGuMc}\\\\Bb@JH@dvOcuKPSXa}bGvH@h`BbGvH@gx@bKt\"},\"mass\":407.2704211065024,\"monoisotopicMass\":407.07298078755,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mmu\",\"name\":\"5-methoxycarbonylmethyl-2′-O-methyluridine monophosphate diradical 0521U\",\"mf\":\"C13H17N2O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∩\",\"ocl\":{\"value\":\"fcwPk@EAaSfoYKvZp^KoAKcdRbbbVtRbTfUVfYrMZjjjjYfifjHbXaDr@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lI}mK_`B@cm\\\\Bb@HlI}]}_`A~@BpgIqLXKH`Bb@I~@Ha}_c~HHa}\"},\"mass\":392.2557771410008,\"monoisotopicMass\":392.06208175089,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cue\",\"name\":\"5-(carboxyhydroxymethyl)-2′-O-methyluridine methyl ester monophosphate diradical 0522U\",\"mf\":\"C13H17N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∩\",\"ocl\":{\"value\":\"fkoQk@EAaSfoYKtZ}`|W^BWGHeEEDmheDiLjhYf\\\\cVjjjjfYjZZhbIbDSH@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lI}mK_`B@cm\\\\Bb@HlI}]}_`A~@BpgIqLXKH`Bb@I~@Gx@bGu~Oxc|bGt\"},\"mass\":408.25518206531905,\"monoisotopicMass\":408.05699637046,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cyu\",\"name\":\"5-carbamoylmethyl-2′-O-methyluridine monophosphate diradical 053U\",\"mf\":\"C12H16N3O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"~\",\"ocl\":{\"value\":\"fmgqK@EAWBgM^rWlp^KoAKcdRbbbVtRbTfUVcNQkUUUUSLuLuDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXKAaMTDuPOxxlF@\"},\"mass\":377.24439877733727,\"monoisotopicMass\":377.06241610352,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ipu\",\"name\":\"5-(isopentenylaminomethyl)-2′-O-methyluridine monophosphate diradical 0583U\",\"mf\":\"C16H24N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¼\",\"ocl\":{\"value\":\"fgpK@EAGBgM^rWhOEw`eqrIQQQKZIQJSJkIJLyFmUUUULsTuMTQDqBId@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lI}mK_`B@cm\\\\Bb@HlI}]}_`A~@BpgIqLXKH`Bb@I~@Ha}b@JH_Xc|_`BH_P\"},\"mass\":417.35146347240624,\"monoisotopicMass\":417.13010174179004,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":24},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mcy\",\"name\":\"5,2′-O-dimethylcytidine monophosphate diradical monophosphate diradical 05C\",\"mf\":\"C11H16N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"τ\",\"ocl\":{\"value\":\"fasqs@EA{BgM^rTGb{pRxyDhhhemDheIeV\\\\cVjjjjfYfjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXKAaMT@\"},\"mass\":333.23485303196554,\"monoisotopicMass\":333.07258686438,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dmuf\",\"name\":\"5,2′-O-dimethyluridine monophosphate diradical 05U\",\"mf\":\"C11H15N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"\\\\\",\"ocl\":{\"value\":\"fasPK@EAaSfoYKtGb{pRxyDhhhemDheIeV\\\\cVjjjjfYjZHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXKAaMT@\"},\"mass\":334.2196139907822,\"monoisotopicMass\":334.05660244729,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tma\",\"name\":\"N6,N6,2′-O-trimethyladenosine monophosphate diradical 066A\",\"mf\":\"C13H18N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"η\",\"ocl\":{\"value\":\"fmwhs@E^ct\\\\J\\\\udhOEw`eqrIQQQKZIQJQIkQg@q[vjjjj`Y`JjBHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@SuHXK@\"},\"mass\":371.2862078321209,\"monoisotopicMass\":371.09947031813005,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Nda\",\"name\":\"N6,2′-O-dimethyladenosine monophosphate diradical 06A\",\"mf\":\"C12H16N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"χ\",\"ocl\":{\"value\":\"feghs@E^ct\\\\J\\\\udhOEw`eqrIQQQKZIQJQIkLxFK^uUUUTCLAUADSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@FBp\"},\"mass\":357.2595904272741,\"monoisotopicMass\":357.08382025367,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Fmc\",\"name\":\"5-formyl-2′-O-methylcytidine monophosphate diradical 071C\",\"mf\":\"C10H12N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"°\",\"ocl\":{\"value\":\"faspK@I^[BgENSghOFwaEqrIQQSYQJIRYULxDmUUUTsLttQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":333.1917590433254,\"monoisotopicMass\":333.03620135502996,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Omi\",\"name\":\"2′-O-methylinosine monophosphate diradical 09A\",\"mf\":\"C11H13N4O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≤\",\"ocl\":{\"value\":\"fi{Is@E^cvENZrTXOEw`eqrIQQQKZIQJQIig@q[vjjjjiYffhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@\"},\"mass\":344.21773398124395,\"monoisotopicMass\":344.05218577211997,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Opu\",\"name\":\"2′-O-methylpseudouridine monophosphate diradical 09U\",\"mf\":\"C10H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Z\",\"ocl\":{\"value\":\"fncPK@@qaSfoYJtGb{pRxyDhhhemDheIfsdZuUUULuMMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Oma\",\"name\":\"2′-O-methyladenosine monophosphate diradical 0A\",\"mf\":\"C11H14N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\":\",\"ocl\":{\"value\":\"fi{hs@E^ct\\\\J\\\\udhOEw`eqrIQQQKZIQJQIig@q[vjjjj`Y`J`bIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@MD@\"},\"mass\":343.2329730224273,\"monoisotopicMass\":343.06817018921,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Omc\",\"name\":\"2′-O-methylcytidine monophosphate diradical 0C\",\"mf\":\"C10H14N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"B\",\"ocl\":{\"value\":\"fncqs@EA[BgM^rTGb{pRxyDhhhemDheIfsdZuUUUTsLuDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@\"},\"mass\":319.2082356271187,\"monoisotopicMass\":319.05693679992004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Omg\",\"name\":\"2′-O-methylguanosine monophosphate diradical 0G\",\"mf\":\"C11H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"#\",\"ocl\":{\"value\":\"fegis@E^ct\\\\J\\\\udlp^KoAKcdRbbbVtRbTbSbYpLV}jjjjjVYjZbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@HoTuOSU@HEF@`H_R\\\\StPAKA@a}_S_|BD}RSuKQ@B\\\\StP@\"},\"mass\":359.23237794674554,\"monoisotopicMass\":359.06308480878,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Omu\",\"name\":\"2′-O-methyluridinemonophosphate diradical 0U\",\"mf\":\"C10H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"J\",\"ocl\":{\"value\":\"fncPK@EAaSfoYJtGb{pRxyDhhhemDheIfsdZuUUUTsMMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuOSU@HC~NKA`H_QLgSUAMT@a}_S_|BBpXSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cdg\",\"name\":\"7-cyano-7-deazaguanosine monophosphate diradical 100G\",\"mf\":\"C12H12N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"φ\",\"ocl\":{\"value\":\"fmwis@INzM\\\\J\\\\TgLp^MoBKcdRbbfrbTRdRUbSN^CWmUUUUKLuSuDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StPCFP@\"},\"mass\":369.22723233536925,\"monoisotopicMass\":369.04743474432,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Azg\",\"name\":\"7-aminomethyl-7-deazaguanosine monophosphate diradical 101G\",\"mf\":\"C12H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∉\",\"ocl\":{\"value\":\"fmwis@INzM\\\\J\\\\TgLp^MoBKcdRbbfrbTRdRUbSN^CWmUUUUKLuSUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StPA`z`\"},\"mass\":373.2589953515923,\"monoisotopicMass\":373.07873487324,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Eqo\",\"name\":\"epoxyqueuosine monophosphate diradical 102G\",\"mf\":\"C17H22N5O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ς\",\"ocl\":{\"value\":\"el^ZEL@IGNaehJNEDlig`TPOFspb\\\\\\\\bTTTvTRbTbRlRjbbfXx|Bjz~aAajjjjiYfjZjjjjHPfDHSD@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StP@{ULY@TEIKA@a}tPA}BOpHAEP\"},\"mass\":487.3585341325581,\"monoisotopicMass\":487.11042892533,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Aes\",\"name\":\"archaeosine monophosphate diradical 103G\",\"mf\":\"C12H15N6O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"(\",\"ocl\":{\"value\":\"fcoYs@INzM^xTxiNY`|[^DWGHeEEMeDheHdkDhsg`u{UUUURsMTmTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StP@{UFCj\"},\"mass\":386.2577578089824,\"monoisotopicMass\":386.07398384544,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Goq\",\"name\":\"galactosyl-queuosine monophosphate diradical 104G\",\"mf\":\"C23H32N5O14P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"9\",\"ocl\":{\"value\":\"ekXzGL@IGNaehJNEDliod\\\\VU]SPOFspb\\\\\\\\bTTTvTRbTbRlRjbTrTrbfRXx|Bjz^AyEjjjjiYfjZijjjjjjbDIaBDq@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_IorHbGtgD}F@RxRH_WwW@hbOTh}RIlCQ`B\\\\StXC[UB[@RxSPT`JHbGwQ`H`BaEQ~@Ha}bOq~Ox`BbGu~@Ha}bOrH@`\"},\"mass\":633.4999767508004,\"monoisotopicMass\":633.16833772591,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":23},{\"symbol\":\"H\",\"number\":32},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":14},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Gaq\",\"name\":\"glutamyl-queuosine monophosphate diradical105G\",\"mf\":\"C22H29N6O12P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⊄\",\"ocl\":{\"value\":\"emWVCL@IGNaejXJNEDlioh\\\\YUPOFspb\\\\\\\\bTTTvTRbTbRlRjbTJTtrTXx|Bjz^AjjjjiYfjZijfjfjbDIaBDq@@\",\"coordinates\":\"!BTmB@c`JHUMmMtL@YtEHYgxQTaDoQ`L@YFY|gKMARH`Ygy|fpAfN`Hz@`H{PTb\\\\ltEIRtHBNHaTv|@YFYPTha}b@I~@Ha}_c~H@ha}bOq~@Ha}\"},\"mass\":600.473311954707,\"monoisotopicMass\":600.15810739451,\"unsaturation\":22,\"elements\":[{\"symbol\":\"C\",\"number\":22},{\"symbol\":\"H\",\"number\":29},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":12},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Moq\",\"name\":\"mannosyl-queuosine monophosphate diradical 106G\",\"mf\":\"C23H32N5O14P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"8\",\"ocl\":{\"value\":\"ekXzGL@IGNaehJNEDliod\\\\VU]SPOFspb\\\\\\\\bTTTvTRbTbRlRjbTrTrbfRXx|Bjz^AyEjjjjiYfjZijjjjjjbDIaBDq@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_IorHbGtgD}F@RxRH_WwW@hbOTh}RIlCQ`B\\\\StXC[UB[@RxSPT`JHbGwQ`H`BaEQ~@Ha}bOq~Ox`BbGu~@Ha}bOrH@`\"},\"mass\":633.4999767508004,\"monoisotopicMass\":633.16833772591,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":23},{\"symbol\":\"H\",\"number\":32},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":14},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Qus\",\"name\":\"queuosine monophosphate diradical 10G\",\"mf\":\"C17H22N5O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Q\",\"ocl\":{\"value\":\"edZZIL@IGNaehJNEDliohPOFspb\\\\\\\\bTTTvTRbTbRlRjbTKGG`UWSpMUUUUKLuSUMUTPaLHPfH@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPHoWtw@aOTd}RqdCQ@B\\\\StP@{ULY@RpQPTopHBGwQ@@QT\"},\"mass\":471.35912920823984,\"monoisotopicMass\":471.11551430576,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cpo\",\"name\":\"1-methyl-3-(3-amino-3-carboxypropyl)pseudouridine monophosphate diradical 1309U\",\"mf\":\"C14H20N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"α\",\"ocl\":{\"value\":\"fgpk@OAWBgENSgi{`|[^DWGHeEEMeDheIhjbihs`RuUUTsTuSUMQDSDHfP@\",\"coordinates\":\"!BTh|SI~ioOwy`iR\\\\SiV|SFGxw}FH_]]}DqbH@gx_c|SFA`lIqOW_Xa}uwu~Ox`BbGu~Ox`B_`BH_P\"},\"mass\":421.2970385113492,\"monoisotopicMass\":421.08863085201,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mls\",\"name\":\"1-methylinosine monophosphate diradical 19A\",\"mf\":\"C11H13N4O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"O\",\"ocl\":{\"value\":\"fi{Is@INBvENJSghOFwaEqrIQQSYQJIRIMIgOAjvjjjjefZZhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}R\"},\"mass\":344.21773398124395,\"monoisotopicMass\":344.05218577211997,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mpu\",\"name\":\"1-methylpseudouridine monophosphate diradical 19U\",\"mf\":\"C10H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"]\",\"ocl\":{\"value\":\"fncPK@OAaSbgIrtGc[pbxyDhhilheDiLjs`RuUUTsTuMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mad\",\"name\":\"1-methyladenosine monophosphate diradical 1A\",\"mf\":\"C11H14N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"\\\"\",\"ocl\":{\"value\":\"fi{hs@INBwlJ\\\\TgHOFwaEqrIQQSYQJIRIMIgOAjvjjjjefZZhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}R\"},\"mass\":343.2329730224273,\"monoisotopicMass\":343.06817018921,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mgs\",\"name\":\"1-methylguanosine monophosphate diradical 1G\",\"mf\":\"C11H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"K\",\"ocl\":{\"value\":\"fegis@INBwlJ\\\\TgHp^MoBKcdRbbfrbTRdR\\\\RYspZmjjjjiYfijbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtP@gD}D@SuH\"},\"mass\":359.23237794674554,\"monoisotopicMass\":359.06308480878,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Msu\",\"name\":\"5-aminomethyl-2-selenouridine monophosphate diradical 20510U\",\"mf\":\"C10H14N3O7PSe\",\"kind\":\"NucleotideP\",\"oneLetter\":\"π\",\"ocl\":{\"value\":\"fasqp`I^{BgEIrtGc[p\\\\bQ\\\\\\\\bTTTvTRbTfUSNAKUUUULsTuDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":398.1676241841323,\"monoisotopicMass\":398.97345859992004,\"unsaturation\":null,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"Se\",\"number\":1}]},{\"symbol\":\"Mse\",\"name\":\"5-methylaminomethyl-2-selenouridine monophosphate diradical 20511U\",\"mf\":\"C11H16N3O7PSe\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≅\",\"ocl\":{\"value\":\"fikqp`I^{BgEIrtGc[p\\\\bQ\\\\\\\\bTTTvTRbTfUVYpIZjjjifZfjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTBpX\"},\"mass\":412.19424158897914,\"monoisotopicMass\":412.98910866438,\"unsaturation\":null,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"Se\",\"number\":1}]},{\"symbol\":\"Cse\",\"name\":\"5-carboxymethylaminomethyl-2-selenouridine monophosphate diradical 2051U\",\"mf\":\"C12H16N3O9PSe\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⊥\",\"ocl\":{\"value\":\"fcwqH`I^{BgEIru^p^MoArIEqrIQQSYQJIRYUYJLxDmUUUTsMSTuDQLPbY@@\",\"coordinates\":\"!BKAb@tURDM\\\\YpMAMpBYMcx`BKB]~@Ha}SXW@h`Bb@IMcx}RtDvH_Xa}b@JH@ha}b@I~@Ha}\"},\"mass\":456.20378733435086,\"monoisotopicMass\":456.97893790352,\"unsaturation\":null,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"Se\",\"number\":1}]},{\"symbol\":\"Agm\",\"name\":\"agmatidine monophosphate diradical 20C\",\"mf\":\"C14H26N7O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¿\",\"ocl\":{\"value\":\"fgxs@I^BuY{piqR\\\\`|[^DWGHeEEMeDeEHmUddhsgbuUUUSTuUUMIDSDHfP@\",\"coordinates\":\"!BDqc_tTnD_]\\\\fpH}MgrYRc}_|Dr_W_Wx@ThWM_|bOqRc}ARctu~@Gx@urH@gx@b@I~@H`BbGu~@@\"},\"mass\":419.373876184194,\"monoisotopicMass\":419.16821858483,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":26},{\"symbol\":\"N\",\"number\":7},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Sou\",\"name\":\"2-selenouridine monophosphate diradical 20U\",\"mf\":\"C9H11N2O7PSe\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ω\",\"ocl\":{\"value\":\"ff}Qp`I^aSbdyjCqmxNQHnNQJJJ[JIQJSMg@ejjjjfYihbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":369.1263628137839,\"monoisotopicMass\":369.9469094988,\"unsaturation\":null,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"Se\",\"number\":1}]},{\"symbol\":\"Agu\",\"name\":\"5-aminomethyl-2-geranylthiouridine monophosphate diradical 21510U\",\"mf\":\"C20H30N3O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Δ\",\"ocl\":{\"value\":\"ed\\\\\\\\NB@IOIhJNEDla`OFsp\\\\BHgGHeEEMeDheHdjdcEdhqpEUUUUURsUSMTuQBDpaBXdDt@\",\"coordinates\":\"!BDr__cdo[_X`fgx}RgqeRtM]}Dqa~O}\\\\BTmBH_]]}uwuRtMAMcuI~O}\\\\BupJH_]]}_`A~Oxa}uwu~Oxa}_cW_Xa}\"},\"mass\":487.5074340654907,\"monoisotopicMass\":487.15420849000003,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":20},{\"symbol\":\"H\",\"number\":30},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mgu\",\"name\":\"5-methylaminomethyl-2-geranylthiouridine monophosphate diradical 21511U\",\"mf\":\"C21H32N3O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"h\",\"ocl\":{\"value\":\"elR\\\\NB@IOIhJNEDla`OFsp\\\\BHgGHeEEMeDheHdjdlileFN@jjjjjjVZjYjijbDIaBDqHIh\",\"coordinates\":\"!BTv^cbn{__@fw|}RwqeRdK]}Tva~_{_|TiCp_[]}mwuRdIAMsuI~_{]|mwsp_[]}mwu~_{_||Gvw_Wy|Gu~_{]}|Gt\"},\"mass\":501.5340514703375,\"monoisotopicMass\":501.16985855446006,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":21},{\"symbol\":\"H\",\"number\":32},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Cgu\",\"name\":\"5-carboxymethylaminomethyl-2-geranylthiouridine monophosphate diradical 2151U\",\"mf\":\"C22H32N3O9PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"f\",\"ocl\":{\"value\":\"ef^\\\\IB@IOIhJNEDla`XPOFsp\\\\BHgGHeEEMeDheHdjdlhehbhqpEUUUUURsUSMUMMTPaLHPfIAM@\",\"coordinates\":\"!BTv^cbn{_@fw|}RwqeRdK]}Tva~_{]|TiCp[_}muRdIAMsuI~_{]|mwsp_[]}mwu~_{]||Gvw_[_}_g}~_{]||Ou~_{]}|Gt\"},\"mass\":545.5435972157093,\"monoisotopicMass\":545.1596877935999,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":22},{\"symbol\":\"H\",\"number\":32},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mha\",\"name\":\"2-methylthio-N6-(cis-hydroxyisopentenyl) adenosine monophosphate diradical 2160A\",\"mf\":\"C16H22N5O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≠\",\"ocl\":{\"value\":\"e`TZNB@IG@nahJNEDlo`OFspb\\\\V`cHeEEMeDheHdxeleDqqxEUuUUUU@sAETuTDHSBDIbP[P\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQb@KQwuRDFALYpHCQt]WHc|TmCQw}~N`ME~@Gx@upJH@h`B_`BH_X`BbGvHGxbGt\"},\"mass\":459.41437086899504,\"monoisotopicMass\":459.09775624102,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mpa\",\"name\":\"2-methylthio-N6-isopentenyladenosine monophosphate diradical 2161A\",\"mf\":\"C16H22N5O6PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"*\",\"ocl\":{\"value\":\"eohZFB@IG@nahJNEDl`OFspb\\\\V`cHeEEMeDheHdxeleFNO@jnjjjjhFXHjfjBDIaBDq@@\",\"coordinates\":\"!BpBYTvxBNFY|bEJObGvOS\\\\@Yt]~DUEJOctu~@Ha}`HzOSTwPTh~H@h`B_`BH_Xa}bOrH@ha}b@I~@Ha}\"},\"mass\":443.4149659446768,\"monoisotopicMass\":443.10284162145,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mca\",\"name\":\"2-methylthio-N6-threonylcarbamoyladenosine monophosphate diradical 2162A\",\"mf\":\"C16H21N6O10PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"[\",\"ocl\":{\"value\":\"ebVVEB@IG@nachJNEDlm`XTPOFspb\\\\V`cHeEEMeDheHdxemLhhhqqxEUuUUUU@sAESUMUABDpaBX`@\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQb@KQwuRDFALYpHCQt]W@h`BTmCQw}~N`ME~@Gx@upJH@h`B_`BH_Wxb@JH_WxbOrHo]^}_`BH_P\"},\"mass\":520.4113480993399,\"monoisotopicMass\":520.07774907193,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":21},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mva\",\"name\":\"2-methylthio-N6-hydroxynorvalylcarbamoyladenosine monophosphate diradical 2163A\",\"mf\":\"C17H23N6O10PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≈\",\"ocl\":{\"value\":\"ej^VEB@IG@nachJNEDlm`XTPOFspb\\\\V`cHeEEMeDheHdxemLhhiVNO@jnjjjjhFXHjZijjBDIaBDq@@\",\"coordinates\":\"!BpBYTvxBNFY|BbEJObGvOS\\\\@Yt]~DUEJOctu~@Ha}`HzOSTwPTh~H@h`B_`BH_Xa}bOrH@gx@bGvHGx@bGwW@h`B_c~H@ha}\"},\"mass\":534.4379655041866,\"monoisotopicMass\":534.09339913639,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":23},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mya\",\"name\":\"2-methylthio cyclic N6-threonylcarbamoyladenosine monophosphate diradical 2164A\",\"mf\":\"C17H20N5O9PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ÿ\",\"ocl\":{\"value\":\"elVZIB@IG@nkhJNEDlcghPOFspb\\\\V`cHeEEMeDheHdxeihiUFNO@jnkojjjjhFXHjfZjbHPfDHSD@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_IorHbGtgD}F@RxRH_WwW@hbOTh}RIqOQ`MF@cuKW@hQTcttfpL@YS]@BbGvH@Gx\"},\"mass\":501.4080351062552,\"monoisotopicMass\":501.07193541570007,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Hta\",\"name\":\"hydroxy-N6-threonylcarbamoyladenosine monophosphate diradical 2165A\",\"mf\":\"C15H19N6O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"«\",\"ocl\":{\"value\":\"elZVML@IG@fnehJNEDligo`TPOFspb\\\\\\\\bTTTvTRbTbSVTrbbeXx|BjZjjjj`Y`JZijjBDIaBDq@@\",\"coordinates\":\"!BpBYTvxBNFY|bEJObGvOS\\\\@Yt]~DUEJOctu~@Ha}`HzOSTwPTh~HH`BbGvH_Xc|_`BH_Xc|_`BH_]_|bOq~Oxc|bGt\"},\"mass\":490.31934821268436,\"monoisotopicMass\":490.08494245264,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":19},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Lyd\",\"name\":\"2-lysidine monophosphate diradical 21C\",\"mf\":\"C15H24N5O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"}\",\"ocl\":{\"value\":\"eo`ZAL@IGOFmhJNEDlkg`OFspb\\\\\\\\bTTTvTRbTbSVRTtXxBJjjjjfYjZjfhaBXPaLP@\",\"coordinates\":\"!BTh|SI~ioOwy`iR\\\\SiV|SFGxw}FH_]]}Dqa~Oxc|_c|SFA`lIqOW_Xa}_c~HHa}bOrH_WxbOq~@Ha}\"},\"mass\":433.3541339985626,\"monoisotopicMass\":433.13624975064994,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":24},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Gtu\",\"name\":\"2-geranylthiouridine monophosphate diradical 21U\",\"mf\":\"C19H27N2O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Γ\",\"ocl\":{\"value\":\"e`XTNB@IOHJNEDln`OFsp\\\\BHgGHeEEMeDheHdtmEdhqpEUUUUURsUKUMTPaLHPfIAu@\",\"coordinates\":\"!BTv^cbn{__@fw|}RwqeRdK]}Tva~_{_|TiCp_[]}mwuRdIAMsuI~_{]||Gvw_Wy|Gvw_Wy|Gu~_{]}|Gt\"},\"mass\":458.46617269514235,\"monoisotopicMass\":458.12765938888003,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":19},{\"symbol\":\"H\",\"number\":27},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Tyg\",\"name\":\"N2,N2,7-trimethylguanosine cap monophosphate diradical (cap TMG) 2279553N\",\"mf\":\"C13H20N5O10P2\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¶\",\"ocl\":{\"value\":\"e`TZEBHIG@aihJNEHdleck`OFspz|MgDJTef[vVVe_gifNO@jijjjjjUijifjhaBXPaLP@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPbOr_I`JHbGtgD}F@RxS|uxc|_]^OTh}RIlA~@B\\\\StXCQ`Gx@Owx@_h{_cuH\"},\"mass\":468.2734710359255,\"monoisotopicMass\":468.06854085929,\"unsaturation\":13,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Tmg\",\"name\":\"N2,N2,7-trimethylguanosine monophosphate diradical 227G\",\"mf\":\"C13H20N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∠\",\"ocl\":{\"value\":\"fcoisBINCt\\\\J\\\\TgLp^MoBKbFY}dRbbfrbTRdRUbtYspZcjjjjiYfjjjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}Rqd@gD}D@tPBNOt}R\"},\"mass\":389.30149426455074,\"monoisotopicMass\":389.11003500216,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dgu\",\"name\":\"N2,N2-dimethylguanosine monophosphate diradical 22G\",\"mf\":\"C12H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"R\",\"ocl\":{\"value\":\"fmwis@INBwlJ\\\\TgHp^MoBKcdRbbfrbTRdR\\\\RcN^CWmUUUUKLuMUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RIqOQ@MD@cc}OT`\"},\"mass\":373.2589953515923,\"monoisotopicMass\":373.07873487324,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Atu\",\"name\":\"5-aminomethyl-2-thiouridine monophosphate diradical 2510U\",\"mf\":\"C10H14N3O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∫\",\"ocl\":{\"value\":\"fasqp`I^{BgEIrtGc[p\\\\DQ\\\\\\\\bTTTvTRbTfUSNAKUUUULsTuDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":351.27302303324575,\"monoisotopicMass\":351.02900797432005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mou\",\"name\":\"5-methylaminomethyl-2-thiouridine monophosphate diradical 2511U\",\"mf\":\"C11H16N3O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"S\",\"ocl\":{\"value\":\"fikqp`I^{BgEIrtGc[p\\\\DQ\\\\\\\\bTTTvTRbTfUVYpIZjjjifZfjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTBpX\"},\"mass\":365.2996404380926,\"monoisotopicMass\":365.04465803878,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Ctu\",\"name\":\"5-carboxymethylaminomethyl-2-thiouridine monophosphate diradical 251U\",\"mf\":\"C12H16N3O9PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"$\",\"ocl\":{\"value\":\"fcwqH`I^{BgEIru^p^MoApQEqrIQQSYQJIRYUYJLxDmUUUTsMSTuDQLPbY@@\",\"coordinates\":\"!BKAb@tURDM\\\\YpMAMpBYMcx`BKB]~@Ha}SXW@h`Bb@IMcx}RtDvH_Xa}b@JH@ha}b@I~@Ha}\"},\"mass\":409.3091861834643,\"monoisotopicMass\":409.03448727792,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Myu\",\"name\":\"5-methoxycarbonylmethyl-2-thiouridine monophosphate diradical 2521U\",\"mf\":\"C12H15N2O9PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"3\",\"ocl\":{\"value\":\"fmgQH`I^aSbdyZNXOFw`xHbxyDhhilheDiLjmLs`RuUUUSLuLuQDSDHfP@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{WHc|KB_W_Wx@_`@lIr\\\\SFBrH@h`B_`BH_WxbOrH_P\"},\"mass\":394.2945422179627,\"monoisotopicMass\":394.02358824126003,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Cou\",\"name\":\"5-carbamoylmethyl-2-thiouridine monophosphate diradical 253U\",\"mf\":\"C11H14N3O8PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"l\",\"ocl\":{\"value\":\"fe{pH`I^gBgEIrtXOFw`xHbxyDhhilheDiLjmF\\\\BVjjjjYfifhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTC~NKA`\"},\"mass\":379.2831638542993,\"monoisotopicMass\":379.02392259389,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Cau\",\"name\":\"5-carboxymethyl-2-thiouridine monophosphate diradical 2540U\",\"mf\":\"C11H13N2O9PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"℘\",\"ocl\":{\"value\":\"fe{QH`I^aSbdyZNXOFw`xHbxyDhhilheDiLjmF\\\\BVjjjjYfifhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTC~NKA`\"},\"mass\":380.26792481311594,\"monoisotopicMass\":380.00793817680005,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Tau\",\"name\":\"5-taurinomethyl-2-thiouridine monophosphate diradical 254U\",\"mf\":\"C12H18N3O10PS2\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∃\",\"ocl\":{\"value\":\"fgpj`I^{BgEIrwY{`|[^C`bKblHrIQQSYQJIRYUYIRLxDmUUUTsMSUKTQDqBId@@\",\"coordinates\":\"!BKAb@tURD@m\\\\YpMAMpBYMcx`BKB]~@Ha}SXW@h`Bb@IMcx}RtDvH_Xa}b@JH@ha}b@JH__rH_]^H_P\"},\"mass\":459.3892600220213,\"monoisotopicMass\":459.01712313635005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":2}]},{\"symbol\":\"Itu\",\"name\":\"5-(isopentenylaminomethyl)-2-thiouridine monophosphate diradical 2583U\",\"mf\":\"C15H22N3O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"½\",\"ocl\":{\"value\":\"fkoqp`I^{BgEIrtGc[p\\\\DQ\\\\\\\\bTTTvTRbTfUVRTYpIZjjjifZfijbHfHQL`@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{W@h`BKB_W_Wx@_`@lIr\\\\SFBrH@h`B_`BH_Xc|bGvH@gx@bGt\"},\"mass\":419.3902285493682,\"monoisotopicMass\":419.09160823216,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Mth\",\"name\":\"5-methyl-2-thiouridine monophosphate diradical 25U\",\"mf\":\"C10H13N2O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"F\",\"ocl\":{\"value\":\"fncQp`I^aSbdyZCqmxNBHnNQJJJ[JIQJSJlxDmUUUTsMSQDSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":336.25837906774416,\"monoisotopicMass\":336.01810893766003,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dmg\",\"name\":\"N2,7-dimethylguanosine monophosphate diradical 27G\",\"mf\":\"C12H18N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∨\",\"ocl\":{\"value\":\"fmwisBINCt\\\\J\\\\TgLp^MoBKbFY}dRbbfrbTRdRUbKN^CWmUUUUKLuUUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StPAOT`\"},\"mass\":375.27487685970397,\"monoisotopicMass\":375.0943849377,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dma\",\"name\":\"2,8-dimethyladenosine monophosphate diradical 28A\",\"mf\":\"C12H16N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"±\",\"ocl\":{\"value\":\"feghs@INCv\\\\J\\\\UdhOFw`eqrIQQSYQJJJQKqLyxK^uUUUPMLAUADSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpP@c`a}_S_|BD}RSuKQ@B\\\\StP@\"},\"mass\":357.2595904272741,\"monoisotopicMass\":357.08382025367,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mas\",\"name\":\"2-methyladenosine monophosphate diradical 2A\",\"mf\":\"C11H14N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"/\",\"ocl\":{\"value\":\"fi{hs@INBt\\\\J\\\\TgHOFwaEqrIQQSYQJIRINIgOAjvjjjjAf@j`bIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtP@gD}D@\"},\"mass\":343.2329730224273,\"monoisotopicMass\":343.06817018921,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tcy\",\"name\":\"2-thiocytidine monophosphate diradical 2C\",\"mf\":\"C9H12N3O6PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"%\",\"ocl\":{\"value\":\"ff}pp`I^kBgEIrCqmxNBHnNQJJJ[JIQJSMg@ejjjjfYfhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":321.2470007040807,\"monoisotopicMass\":321.01844329029,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Nmg\",\"name\":\"N2-methylguanosine monophosphate diradical 2G\",\"mf\":\"C11H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"L\",\"ocl\":{\"value\":\"fegis@INBwlJ\\\\TgHp^MoBKcdRbbfrbTRdR\\\\VYspZmjjjjiYfijbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtP@gD}D@SuH\"},\"mass\":359.23237794674554,\"monoisotopicMass\":359.06308480878,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Thu\",\"name\":\"2-thiouridine monophosphate diradical 2U\",\"mf\":\"C9H11N2O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"2\",\"ocl\":{\"value\":\"ff}Qp`I^aSbdyjCqmxNBHnNQJJJ[JIQJSMg@ejjjjfYihbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":322.2317616628973,\"monoisotopicMass\":322.0024588732,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Ahu\",\"name\":\"3-(3-amino-3-carboxypropyl)-5,6-dihydrouridine monophosphate diradical 308U\",\"mf\":\"C13H20N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ð\",\"ocl\":{\"value\":\"fkopk@I^gBgENSens`|[^DWGHeEEMeDheIhueMF\\\\BVjjjjZfijfhbIbDSH@\",\"coordinates\":\"!BTh|SI~ioOwy`iR\\\\SiV|SFGxw}FH_]]}DqbH@gx_c|SFA`lIqOW_Xa}_c~HHa}_c~H@gx@bGt\"},\"mass\":409.28630261461393,\"monoisotopicMass\":409.08863085201,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"App\",\"name\":\"3-(3-amino-3-carboxypropyl)pseudouridine monophosphate diradical 309U\",\"mf\":\"C13H18N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Þ\",\"ocl\":{\"value\":\"fkopk@OAgBgENSens`|[^DWGHeEEMeDheIhueMF\\\\BVjjjfZfijfhbIbDSH@\",\"coordinates\":\"!BTh|SI~ioOwy`iR\\\\SiV|SFGxw}FH_]]}DqbH@gx_c|SFA`lIqOW_Xa}_c~HHa}_c~H@gx@bGt\"},\"mass\":407.2704211065024,\"monoisotopicMass\":407.07298078755,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Apu\",\"name\":\"3-(3-amino-3-carboxypropyl)uridine monophosphate diradical 30U\",\"mf\":\"C13H18N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"X\",\"ocl\":{\"value\":\"fkopk@I^gBgENSens`|[^DWGHeEEMeDheIhueMF\\\\BVjjjjYfijfhbIbDSH@\",\"coordinates\":\"!BTh|SI~ioOwy`iR\\\\SiV|SFGxw}FH_]]}DqbH@gx_c|SFA`lIqOW_Xa}_c~HHa}_c~H@gx@bGt\"},\"mass\":407.2704211065024,\"monoisotopicMass\":407.07298078755,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mws\",\"name\":\"methylwyosine monophosphate diradical 342G\",\"mf\":\"C15H18N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∑\",\"ocl\":{\"value\":\"eghZNL@IG@nahJNEDli`OFspb\\\\\\\\bTTTvTRbTbb\\\\rVSGG`SPrvuUUUUKMTsUUIBDpaBX`@\",\"coordinates\":\"!B_`CW@mF@ctvDUI|fRxPYgtwP[zV_IorHFY|gD}F@RxPYg|@YgrZOTh{_cuJOS]F@tXAKaI|fw}EMt@\"},\"mass\":411.3070845499097,\"monoisotopicMass\":411.0943849377,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Uhw\",\"name\":\"undermodified hydroxywybutosine monophosphate diradical 3470G\",\"mf\":\"C18H23N6O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"š\",\"ocl\":{\"value\":\"ejQVEL@IG@nahXJNEDliolRPOFspb\\\\\\\\bTTTvTRbTbb\\\\rVVTttXx|BZFVvjjjjiYjfZjjfjRDIaBDq@@\",\"coordinates\":\"!BKB^@ceS[H`Yg}ARpAeMtHa}KAcPTh{_S]CjXES[pAeMtH}MtEK@IdnDpBXBbES[UMo@F]ARaERH_X`B_`BH_WxbOq~@Ha}\"},\"mass\":514.3839139947949,\"monoisotopicMass\":514.12132796199,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":18},{\"symbol\":\"H\",\"number\":23},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Acw\",\"name\":\"7-aminocarboxypropylwyosine monophosphate diradical 347G\",\"mf\":\"C18H23N6O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ω\",\"ocl\":{\"value\":\"eb^VIL@IG@na`XJNEDlid\\\\POFspb\\\\\\\\bTTTvTRbTbb\\\\rVRrfcGG`SPrvuUUUUKMTsUUSUIBDpaBX`@\",\"coordinates\":\"!BDr]RcwwWpAg_tUS[cm~DUAf_XJUTvx}MaEP@_gwWcm~DUDnDUMo|urH@m_@FWwW_]^NwuS[bGtYgx`BbGu~Ox`B_`BH_P\"},\"mass\":498.38450907047655,\"monoisotopicMass\":498.12641334242,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":18},{\"symbol\":\"H\",\"number\":23},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hwy\",\"name\":\"methylated undermodified hydroxywybutosine monophosphate diradical 3480G\",\"mf\":\"C19H25N6O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"y\",\"ocl\":{\"value\":\"efYVEL@IG@nahXJNEDliolRPOFspb\\\\\\\\bTTTvTRbTbb\\\\rVVTttsGG`SPrvuUUUUKMTsUUTuTdHSBDIb@@\",\"coordinates\":\"!B`HyRtL@f_XbDRxz@UHS_chc|S]BN`MAMwxyKaL@fUHS_cmG_chCjXI|YzfA}bL@fpBYTaHz@F\\\\BH@gx@upJH@ha}_`CWHc|_`@\"},\"mass\":528.4105313996416,\"monoisotopicMass\":528.1369780264499,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":19},{\"symbol\":\"H\",\"number\":25},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hwb\",\"name\":\"hydroxywybutosine monophosphate diradical 34830G\",\"mf\":\"C21H27N6O12P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⊆\",\"ocl\":{\"value\":\"ee[VCL@IG@nahXJNEDliobZV^POFspb\\\\\\\\bTTTvTRbTbb\\\\rVVTtRbfsGG`SPrvuUUUUKMTsUUULuUIBDpaBX`@\",\"coordinates\":\"!BKB^@ceS[@h`Yg}ARpAeMtHa}KAcPTh{_S]CjXES[pAeMtH}MtEK@IdnDpBXBbES[UMo@F]ARaERH_X`B_`BH_X`B_c~H_]]}bGu~Ox`B_c~H_P\"},\"mass\":586.4466945498602,\"monoisotopicMass\":586.14245733005,\"unsaturation\":22,\"elements\":[{\"symbol\":\"C\",\"number\":21},{\"symbol\":\"H\",\"number\":27},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":12},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Pwb\",\"name\":\"peroxywybutosine monophosphate diradical 34832G\",\"mf\":\"C21H27N6O13P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"W\",\"ocl\":{\"value\":\"emWVKL@IG@nadXJNEDliohZV^QPOFspb\\\\\\\\bTTTvTRbTbb\\\\rVVTRfTTvXx|BZFVvjjjjiYjfZjjjYjjRDIaBDq@@\",\"coordinates\":\"!BKB^@ceS[@h`Yg}ARpAeMtHa}KAcPTh{_S]CjXES[pAeMtH}MtEK@IdnDpB[|bES[UMo@F]ARaERH_X`B_`BH_X`Bb@I~Oxa}uwvH_Wxb@I~Oxa}\"},\"mass\":602.4460994741785,\"monoisotopicMass\":602.1373719496199,\"unsaturation\":22,\"elements\":[{\"symbol\":\"C\",\"number\":21},{\"symbol\":\"H\",\"number\":27},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Wyb\",\"name\":\"wybutosine monophosphate diradical 3483G\",\"mf\":\"C21H27N6O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Y\",\"ocl\":{\"value\":\"eiSVML@IG@na`XJNEDlilRZVPOFspb\\\\\\\\bTTTvTRbTbb\\\\rVVRbTTvXx|BZFVvjjjjiYjfZjjfZjdaBXPaLP@\",\"coordinates\":\"!BsJ\\\\@ciP{@`YWuARPAeMT@a}sNaPThxSUCjhIP{PAeMTD}MTEI@IllDPB[|BIP{eCm@FUARAIPH_Pc|BGtHGzBGtw_Pa}_k|HGzBGt\"},\"mass\":570.4472896255419,\"monoisotopicMass\":570.14754271048,\"unsaturation\":22,\"elements\":[{\"symbol\":\"C\",\"number\":21},{\"symbol\":\"H\",\"number\":27},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Awo\",\"name\":\"7-aminocarboxypropylwyosine methyl ester monophosphate diradical 348G\",\"mf\":\"C19H25N6O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⇑\",\"ocl\":{\"value\":\"ejQVIL@IG@na`XJNEDlid\\\\POFspb\\\\\\\\bTTTvTRbTbb\\\\rVVRffXx|BZFVvjjjjiYjfZjjZjRDIaBDq@@\",\"coordinates\":\"!B`HyRtL@f_XbDRxz@UHS_ch`BS]BN`MAMwxyKaL@fUHS_cmG_chCjXI|YzfA}bL@fpBYTaHz@F\\\\BHHa}bOq~@Ha}_c~H@ha}\"},\"mass\":512.4111264753234,\"monoisotopicMass\":512.14206340688,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":19},{\"symbol\":\"H\",\"number\":25},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Wyo\",\"name\":\"wyosine monophosphate diradical 34G\",\"mf\":\"C14H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"€\",\"ocl\":{\"value\":\"ek`ZNL@IG@nahJNEDli`OFspb\\\\\\\\bTTTvTRbTbb\\\\rVXx|BZFVvjjjjiYjfZjdaBXPaLP@\",\"coordinates\":\"!B_`CWMF@ctvDUI|fRxPYgtwP[zV_IorHFY|gD}F@RxPYg|@YgrZOTh{_cuJOS]F@tXAKaI|fw}D\"},\"mass\":397.2804671450629,\"monoisotopicMass\":397.07873487324,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Pdu\",\"name\":\"3-methylpseudouridine monophosphate diradical 39U\",\"mf\":\"C10H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"κ\",\"ocl\":{\"value\":\"fncPK@OAaSbgIrtGc[pbxyDhhilheDiMFs`RuUUTsTuMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@HoWtw@`lFC~NSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mri\",\"name\":\"3-methyluridine monophosphate diradical 3U\",\"mf\":\"C10H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"δ\",\"ocl\":{\"value\":\"fncPK@I^aSbgIrtGc[pbxyDhhilheDiMFs`RuUUUSLuMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@HoWtw@`lFC~NSU@\"},\"mass\":320.1929965859354,\"monoisotopicMass\":320.04095238282997,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Acc\",\"name\":\"N4-acetylcytidine monophosphate diradical 42C\",\"mf\":\"C11H14N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"M\",\"ocl\":{\"value\":\"fikpK@I^kBgENSghOFwaEqrIQQSYQJIRYiQg@ejjjjfYffhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuPOxxSItuP\"},\"mass\":347.21837644817225,\"monoisotopicMass\":347.05185141949,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Iws\",\"name\":\"isowyosine monophosphate diradical 42G\",\"mf\":\"C14H16N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⊇\",\"ocl\":{\"value\":\"ek`ZNL@IG@fnhJNEDla`OFspb\\\\\\\\bTTTvTRbTbSbRrXx|BjzfVjjjjiYjYjjdaBXPaLP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RStwQ@MD@RpQ_qcQSU@\"},\"mass\":397.2804671450629,\"monoisotopicMass\":397.07873487324,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":14},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dmc\",\"name\":\"N4,N4-dimethylcytidine monophosphate diradical 44C\",\"mf\":\"C11H16N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"μ\",\"ocl\":{\"value\":\"fasqs@I^kBgENSdGc[pbxyDhhilheDiLuF\\\\BVjjjjYfZjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBGpcbpXBGtSItuPSU@H_Wtw@`lFDuPOxxlF@\"},\"mass\":333.23485303196554,\"monoisotopicMass\":333.07258686438,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Adw\",\"name\":\"7-aminocarboxypropyl-demethylwyosine monophosphate diradical 47G\",\"mf\":\"C17H21N6O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¥\",\"ocl\":{\"value\":\"elVVIL@IG@fnohJNEDlahTPOFspb\\\\\\\\bTTTvTRbTbSbRrrTtXx|BjzfVjjjjiYjYjjijdaBXPaLP@\",\"coordinates\":\"!B`MERc|@Y_]^DUH{_UMo_tXa}SXPTh{_w}GjXES[pAg_t]F@cm@Il@f@haTvuS[pAgPThQTbGvH@ha}_c~HGx@bGt\"},\"mass\":484.3578916656298,\"monoisotopicMass\":484.1107632779601,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":17},{\"symbol\":\"H\",\"number\":21},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ncd\",\"name\":\"N4-methylcytidine monophosphate diradical 4C\",\"mf\":\"C10H14N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ν\",\"ocl\":{\"value\":\"fncqs@I^kBgENSdGc[pbxyDhhilheDiLts`RuUUUSLsUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuPKA`\"},\"mass\":319.2082356271187,\"monoisotopicMass\":319.05693679992004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dmw\",\"name\":\"4-demethylwyosine monophosphate diradical 4G\",\"mf\":\"C13H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"†\",\"ocl\":{\"value\":\"fcis@INBwlJ\\\\TgHp^MoBKcdRbbfrbTRdR\\\\RVYspZ}fnjjjjefifjiHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RStwQ@MD@RpQ_qcQ\"},\"mass\":383.253849740216,\"monoisotopicMass\":383.06308480878,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mtu\",\"name\":\"5-methoxyuridine monophosphate diradical 501U\",\"mf\":\"C10H13N2O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"5\",\"ocl\":{\"value\":\"fasQK@I^aSbgIsUhOFwaEqrIQQSYQJIRYULxDmUUUTsMSTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":336.19240151025366,\"monoisotopicMass\":336.03586700240004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Uoa\",\"name\":\"uridine 5-oxyacetic acid monophosphate diradical 502U\",\"mf\":\"C11H13N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"V\",\"ocl\":{\"value\":\"fmgQk@I^aSbgIsUlu`|[^DWGHeEEMeDheIeUeF\\\\BVjjjjYfiijHbXaDr@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{WHc|KB_W_Wx@_`@lIr\\\\SFBrHHc|_`BH_Xc|_`BH_P\"},\"mass\":380.2019472556255,\"monoisotopicMass\":380.02569624154,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ume\",\"name\":\"uridine 5-oxyacetic acid methyl ester monophosphate diradical 503U\",\"mf\":\"C12H15N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"υ\",\"ocl\":{\"value\":\"fcwQk@I^aSbgIsUlu`|[^DWGHeEEMeDheIeUeLs`RuUUUSLuMMTQDqBId@@\",\"coordinates\":\"!BKAb@tURDM\\\\YpMAMpBYMcxc|KB]~@Ha}SXWHc|bOqMcx}RtDvH_Xa}bOrH@ha}_c~HHa}\"},\"mass\":394.2285646604723,\"monoisotopicMass\":394.041346306,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hxc\",\"name\":\"5-hydroxycytidine monophosphate diradical 50C\",\"mf\":\"C9H12N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ç\",\"ocl\":{\"value\":\"fncpK@I^[BgENSfhOFwaEqrIQQSYQJIRYUg@ejjjjfYfjHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":321.1810231465902,\"monoisotopicMass\":321.03620135502996,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hxu\",\"name\":\"5-hydroxyuridine monophosphate diradical 50U\",\"mf\":\"C9H11N2O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∝\",\"ocl\":{\"value\":\"fncQK@I^aSbgIsUhOFwaEqrIQQSYQJIRYUg@ejjjjfYjZHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":322.1657841054069,\"monoisotopicMass\":322.02021693794,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Amu\",\"name\":\"5-aminomethyluridine monophosphate diradical 510U\",\"mf\":\"C10H14N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∪\",\"ocl\":{\"value\":\"faspK@I^{BgENSehOFwaEqrIQQSYQJIRYULxDmUUUTsMSTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":335.207640551437,\"monoisotopicMass\":335.05185141949,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mau\",\"name\":\"5-methylaminomethyluridine monophosphate diradical 511U\",\"mf\":\"C11H16N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"{\",\"ocl\":{\"value\":\"fikpK@I^{BgENSehOFwaEqrIQQSYQJIRYUYg@ejjjjfYjZhbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTBpX\"},\"mass\":349.2342579562838,\"monoisotopicMass\":349.06750148395,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hmc\",\"name\":\"5-hydroxymethylcytidine monophosphate diradical 51C\",\"mf\":\"C10H14N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∅\",\"ocl\":{\"value\":\"faspK@I^[BgENSghOFwaEqrIQQSYQJIRYULxDmUUUTsLuTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":335.207640551437,\"monoisotopicMass\":335.05185141949,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cur\",\"name\":\"5-carboxymethylaminomethyluridine monophosphate diradical 51U\",\"mf\":\"C12H16N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"!\",\"ocl\":{\"value\":\"fcwpk@I^{BgENSej}`|[^DWGHeEEMeDheIeUdhs`RuUUUSLuMSTQDqBId@@\",\"coordinates\":\"!BKAb@tURDM\\\\YpMAMpBYMcx`BKB]~@Ha}SXW@h`Bb@IMcx}RtDvH_Xa}b@JH@ha}b@I~@Ha}\"},\"mass\":393.24380370165557,\"monoisotopicMass\":393.05733072309,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Chr\",\"name\":\"5-carboxyhydroxymethyluridine monophosphate diradical 520U\",\"mf\":\"C11H13N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≥\",\"ocl\":{\"value\":\"fmgQk@I^aSbgIrwlu`|[^DWGHeEEMeDheIeUCF\\\\BVjjjjYfiijHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tTuPOxxlF@\"},\"mass\":380.2019472556255,\"monoisotopicMass\":380.02569624154,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mcu\",\"name\":\"5-methoxycarbonylmethyluridine monophosphate diradical 521U\",\"mf\":\"C12H15N2O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"1\",\"ocl\":{\"value\":\"fmgPk@I^aSbgIrt\\\\p^MoBKcdRbbfrbTRdrjtsNAKUUUULsTsUDQLPbY@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{WHc|KB_W_Wx@_`@lIr\\\\SFBrH@h`B_`BH_WxbOrH_P\"},\"mass\":378.229159736154,\"monoisotopicMass\":378.04643168643,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hme\",\"name\":\"5-(carboxyhydroxymethyl)uridine methyl ester monophosphate diradical 522U\",\"mf\":\"C12H15N2O11P\",\"kind\":\"NucleotideP\",\"oneLetter\":\",\",\"ocl\":{\"value\":\"fcwQk@I^aSbgIrwlu`|[^DWGHeEEMeDheIeUCLs`RuUUUSLuMMTQDqBId@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{WHc|KB_W_Wx@_`@lIr\\\\SFBrHHc|_`A~@Ha}_c~H@ha}\"},\"mass\":394.2285646604723,\"monoisotopicMass\":394.041346306,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cxu\",\"name\":\"5-carboxymethyluridine monophosphate diradical 52U\",\"mf\":\"C11H13N2O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"◊\",\"ocl\":{\"value\":\"fe{Pk@I^aSbgIrt\\\\p^MoBKcdRbbfrbTRdrjtYpIZjjjifZfZbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTC~NKA`\"},\"mass\":364.2025423313072,\"monoisotopicMass\":364.03078162197,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hmu\",\"name\":\"5-carbamoylhydroxymethyluridine monophosphate diradical 531U\",\"mf\":\"C11H14N3O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"r\",\"ocl\":{\"value\":\"fmgpk@I^WBgENSeoY`|[^DWGHeEEMeDheIeUCF\\\\BVjjjjYfiijHbXaDr@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tTuPOxxlF@\"},\"mass\":379.21718629680873,\"monoisotopicMass\":379.04168065863,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ymu\",\"name\":\"5-carbamoylmethyluridine monophosphate diradical 53U\",\"mf\":\"C11H14N3O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"&\",\"ocl\":{\"value\":\"fe{qK@I^gBgENSehp^MoBKcdRbbfrbTRdrjtYpIZjjjifZfZbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSUAMTC~NKA`\"},\"mass\":363.2177813724905,\"monoisotopicMass\":363.04676603906006,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ttu\",\"name\":\"5-taurinomethyluridine monophosphate diradical 54U\",\"mf\":\"C12H18N3O11PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ê\",\"ocl\":{\"value\":\"fgqh`I^{BgENSenswAxv|HnJpcHeEEMeDheIeUdeHs`RuUUUSLuMTmQDSDHfP@\",\"coordinates\":\"!BKAb@tURD@m\\\\YpMAMpBYMcx`BKB]~@Ha}SXW@h`Bb@IMcx}RtDvH_Xa}b@JH@ha}b@JH__rH_]^H_P\"},\"mass\":443.32387754021244,\"monoisotopicMass\":443.03996658152005,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Cmu\",\"name\":\"5-cyanomethyluridine monophosphate diradical 55U\",\"mf\":\"C11H12N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ѷ\",\"ocl\":{\"value\":\"fikpK@I^GBgENSehOFwaEqrIQQSYQJIRYUYg@ejjjjfYj[hbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tPCQ\"},\"mass\":345.20249494006066,\"monoisotopicMass\":345.03620135502996,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Pyu\",\"name\":\"5-(isopentenylaminomethyl)uridine monophosphate diradical 583U\",\"mf\":\"C15H22N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"¾\",\"ocl\":{\"value\":\"fkopK@I^{BgENSehOFwaEqrIQQSYQJIRYUYIQg@ejjjjfYjZfjHbXaDr@@\",\"coordinates\":\"!BS]@lFJU`@Gyoza`lzf@lIwx@`H{W@h`BKB_W_Wx@_`@lIr\\\\SFBrH@h`B_`BH_Xc|bGvH@gx@bGt\"},\"mass\":403.32484606755946,\"monoisotopicMass\":403.11445167733,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":22},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mdu\",\"name\":\"5-methyldihydrouridine monophosphate diradical 58U\",\"mf\":\"C10H15N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ρ\",\"ocl\":{\"value\":\"fncPK@I^aSbgIrtGc[pbxyDhhilheDiLjs`RuUUUSTuMDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":322.20887809404695,\"monoisotopicMass\":322.05660244729,\"unsaturation\":8,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mcd\",\"name\":\"5-methylcytidine monophosphate diradical 5C\",\"mf\":\"C10H14N3O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"?\",\"ocl\":{\"value\":\"fncqs@I^[BgENSdGc[pbxyDhhilheDiLjs`RuUUUSLsUDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@\"},\"mass\":319.2082356271187,\"monoisotopicMass\":319.05693679992004,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hia\",\"name\":\"N6-(cis-hydroxyisopentenyl)adenosine monophosphate diradical 60A\",\"mf\":\"C15H20N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"`\",\"ocl\":{\"value\":\"eg`ZNL@IG@fnhJNEDlk`OFspb\\\\\\\\bTTTvTRbTbSVRTSGG`USUUUUTCLATuTDHSBDIbPSH\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQb@KQwuRDFALYpHCQt]W@h`BTmCQw}~N`ME~@Gx@b@JH@ha}bOrH_Wxb@JH_P\"},\"mass\":413.3229660580212,\"monoisotopicMass\":413.11003500216003,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":20},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mta\",\"name\":\"2-methylthio-N6-methyladenosine monophosphate diradical 621A\",\"mf\":\"C12H16N5O6PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"∞\",\"ocl\":{\"value\":\"fmwhp`CQstZLDxipEfGa[qZDYEIlheDdhXdmDmKR\\\\u{MUUUU@aEUAFPTdmH@\",\"coordinates\":\"!BBGw|B@a}_S\\\\H@a}TEJNOuP{Ntm@fPBN[~iRSpHUCneXDBYTEITAEPDiVA@fTBYU@Sj[p\"},\"mass\":389.3243778334011,\"monoisotopicMass\":389.05589142807,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Tca\",\"name\":\"N6-threonylcarbamoyladenosine monophosphate diradical 62A\",\"mf\":\"C15H19N6O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"6\",\"ocl\":{\"value\":\"edRVEL@IG@fnehJNEDligo`POFspb\\\\\\\\bTTTvTRbTbSVTrbbcGG`USUUUUTCLASUMUABDpaBX`@\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQbOsQwuRDFALYpHCQt]W@h`BTmCQw}~N`ME~@Gx@b@JH@ha}_c~H@ha}_c~H@ha}uwu~@Ha}\"},\"mass\":474.31994328836606,\"monoisotopicMass\":474.09002783307,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":19},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hva\",\"name\":\"N6-hydroxynorvalylcarbamoyladenosine monophosphate diradical 63A\",\"mf\":\"C16H21N6O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"√\",\"ocl\":{\"value\":\"elZVIB@IG@fnehJNDligo`POEQql|HgGHeEEMeDheHdueLhhiVNO@jfjjjjhFXBfjZj`aBXPaLP@\",\"coordinates\":\"!BpBYTvxBNFY|bEJObGvOS\\\\@Yt]~DUEJOctu~@Ha}`HzOSTwPTh~HH`BbGvH_Xc|_`BH_Xc|_`BH_]_|bOq~Oxc|bGt\"},\"mass\":488.34656069321284,\"monoisotopicMass\":488.10567789753003,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":21},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Aya\",\"name\":\"N6-acetyladenosine monophosphate diradical 64A\",\"mf\":\"C12H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"⇓\",\"ocl\":{\"value\":\"fmwis@INBwlJ\\\\TgLp^MoBKcdRbbfrbTRdRZrcN^CUmUUUTCLASTDQLPbY@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}RIqOQ@@\"},\"mass\":371.2431138434808,\"monoisotopicMass\":371.06308480878,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Gca\",\"name\":\"N6-glycinylcarbamoyladenosine monophosphate diradical 65A\",\"mf\":\"C13H15N6O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"≡\",\"ocl\":{\"value\":\"eohVIL@IG@fnehJNEDlikg`OFspb\\\\\\\\bTTTvTRbTbSVTrTXx|BjZjjjj`Y`JZfhHPfDHSD@@\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQb@KQwuRDFALYpHCQt]W@h`BTmCQw}~N`ME~@Gx@bOrHHa}_c~H@ha}bOq~@Ha}\"},\"mass\":430.2673035543541,\"monoisotopicMass\":430.06381308458,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":13},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tya\",\"name\":\"N6-methyl-N6-threonylcarbamoyladenosinemonophosphate diradical 662A\",\"mf\":\"C16H21N6O10P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"E\",\"ocl\":{\"value\":\"elZVEL@IG@fnmhJNEDleo`XPOFspb\\\\\\\\bTTTvTRbTbSVbaTTTXx|BjZjjjj`Y`JfjZjBDIaBDq@@\",\"coordinates\":\"!BzfC@IeKPaDn}bHCQb@KQwuRDFALYpHCQt]W@h`BTmCQw}~N`ME~@Gx@bOrHHa}_`A~Ox`BbGu~Ox`BbGwW_Wx@bGt\"},\"mass\":488.34656069321284,\"monoisotopicMass\":488.10567789753003,\"unsaturation\":18,\"elements\":[{\"symbol\":\"C\",\"number\":16},{\"symbol\":\"H\",\"number\":21},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Nna\",\"name\":\"N6,N6-dimethyladenosine monophosphate diradical 66A\",\"mf\":\"C12H16N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"ζ\",\"ocl\":{\"value\":\"feghs@INBwlJ\\\\TgHOFwaEqrIQQSYQJIRIMZLyxMVuUUUPLpEUADSDHfP@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}RFBp\"},\"mass\":357.2595904272741,\"monoisotopicMass\":357.08382025367,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Fya\",\"name\":\"N6-formyladenosine monophosphate diradical 67A\",\"mf\":\"C11H12N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ϩ\",\"ocl\":{\"value\":\"fegis@INBwlJ\\\\TgLp^MoBKcdRbbfrbTRdRZrYspZmjjjj`Y`JZBHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}RtP@\"},\"mass\":357.216496438634,\"monoisotopicMass\":357.04743474432,\"unsaturation\":16,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Hma\",\"name\":\"N6-hydroxymethyladenosine monophosphate diradical 68A\",\"mf\":\"C11H14N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"Ϫ\",\"ocl\":{\"value\":\"fegis@INBwlJ\\\\TgLp^MoBKcdRbbfrbTRdRZrYspZmjjjj`Y`JjBHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@D}RtP@\"},\"mass\":359.23237794674554,\"monoisotopicMass\":359.06308480878,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Cca\",\"name\":\"cyclic N6-threonylcarbamoyladenosine monophosphate diradical 69A\",\"mf\":\"C15H17N6O9P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"e\",\"ocl\":{\"value\":\"ehRVIL@IG@fnehJNEDliko`OFspb\\\\\\\\bTTTvTRbTbSVTRRtXx|BjZvNjjjj`Y`IjfjbHPfDHSD`z`\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_IorHbGtgD}F@RxRH_WwW@hbOTh}RtXCQ`A`l_`A`iVCjKAcjX@A~@h`Bup\"},\"mass\":456.30465685593623,\"monoisotopicMass\":456.07946314904,\"unsaturation\":20,\"elements\":[{\"symbol\":\"C\",\"number\":15},{\"symbol\":\"H\",\"number\":17},{\"symbol\":\"N\",\"number\":6},{\"symbol\":\"O\",\"number\":9},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Fcy\",\"name\":\"5-formylcytidine monophosphate diradical71C\",\"mf\":\"C10H12N3O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\">\",\"ocl\":{\"value\":\"faspK@I^[BgENSghOFwaEqrIQQSYQJIRYULxDmUUUTsLttQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFBpXSU@@tP\"},\"mass\":333.1917590433254,\"monoisotopicMass\":333.03620135502996,\"unsaturation\":12,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":12},{\"symbol\":\"N\",\"number\":3},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Tur\",\"name\":\"4-thiouridine monophosphate diradical 74U\",\"mf\":\"C9H11N2O7PS\",\"kind\":\"NucleotideP\",\"oneLetter\":\"4\",\"ocl\":{\"value\":\"ff}Qp`I^aSbgIrCqmxQ\\\\ZaFQJJJ[JIQJSMg@ejjjjfYihbIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":322.2317616628973,\"monoisotopicMass\":322.0024588732,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Meg\",\"name\":\"7-methylguanosine monophosphate diradical 7G\",\"mf\":\"C11H15N5O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"7\",\"ocl\":{\"value\":\"fegisDINCt\\\\J\\\\TgLp^MoBKbF\\\\bTTTvTRbTbRlSN^CWmUUUUKLuSTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RqdCQ@B\\\\StP@\"},\"mass\":360.2403187008013,\"monoisotopicMass\":360.07090984101,\"unsaturation\":13,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mea\",\"name\":\"8-methyladenosine monophosphate diradical 8A\",\"mf\":\"C11H14N5O6P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"â\",\"ocl\":{\"value\":\"fi{hs@INCt\\\\J\\\\UdhOFw`eqrIQQSYQJJJQKigOA[vjjjjAi`J`bIbDSH@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpP@c`a}_S_|BD}RSuKQ@MD@\"},\"mass\":343.2329730224273,\"monoisotopicMass\":343.06817018921,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":14},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":6},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Dhu\",\"name\":\"dihydrouridine monophosphate diradical 8U\",\"mf\":\"C9H13N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"D\",\"ocl\":{\"value\":\"ff}PK@I^aSbgIsTGc[pbxyDhhilheDiLv\\\\BVjjjjZffbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":308.1822606892002,\"monoisotopicMass\":308.04095238282997,\"unsaturation\":8,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Ins\",\"name\":\"inosine monophosphate diradical 9A\",\"mf\":\"C10H11N4O7P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"I\",\"ocl\":{\"value\":\"fakIs@INBvENJSghOFwaEqrIQQSYQJIRIMLyxMVuUUUTlsSTQDqBId@@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOq_qopHBGtgD}D@RpPH_Wtw@aOTd}RtPCQ@@\"},\"mass\":330.1911165763972,\"monoisotopicMass\":330.03653570766,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":4},{\"symbol\":\"O\",\"number\":7},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Pis\",\"name\":\"pseudouridine monophosphate diradical 9U\",\"mf\":\"C9H11N2O8P\",\"kind\":\"NucleotideP\",\"oneLetter\":\"P\",\"ocl\":{\"value\":\"ff}PK@OAaSbgIsTGc[pbxyDhhilheDiLv\\\\BVjjjfZffbHfHQL`@\",\"coordinates\":\"!BNuSFPDlDTEHt_pHtP@H_TuPBOpcbpXBGtSItuPSU@H_Wtw@`lFDuP\"},\"mass\":306.1663791810886,\"monoisotopicMass\":306.02530231837,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":9},{\"symbol\":\"H\",\"number\":11},{\"symbol\":\"N\",\"number\":2},{\"symbol\":\"O\",\"number\":8},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Pqb\",\"name\":\"preQ0base 100G diradical (base)\",\"mf\":\"C7H5N5O\",\"kind\":\"Nucleotide\",\"oneLetter\":\"ψ\",\"ocl\":{\"value\":\"dk^h@DxYLLbbTTRekiujYj^`@\",\"coordinates\":\"!B|Gwp_Gy|Gwp_[lk_gp_Ag_wrYRs}|f\"},\"mass\":175.1477760289729,\"monoisotopicMass\":175.04940980287,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":5},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Pqg\",\"name\":\"preQ1base 101G diradical (base)\",\"mf\":\"C7H9N5O\",\"kind\":\"Nucleotide\",\"oneLetter\":\"∇\",\"ocl\":{\"value\":\"dk^h@DxYLLbbTTRckiUjYij`@\",\"coordinates\":\"!BWyfe[tlDWye_fXx@RpRe[wtHSuHH@a}\"},\"mass\":179.179539045196,\"monoisotopicMass\":179.08070993179,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":7},{\"symbol\":\"H\",\"number\":9},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Qba\",\"name\":\"Qbase 10G diradical (base)\",\"mf\":\"C12H15N5O3\",\"kind\":\"Nucleotide\",\"oneLetter\":\"∴\",\"ocl\":{\"value\":\"fbmi`@D\\\\EHpHyrJIQQJMJIPtyIPTmSMMUMUP@@\",\"coordinates\":\"!BRpQ_f^i`RpQKAEARzfA_f_pHtP@H_Pc|BGuPThxUCl{RtBYTd|\"},\"mass\":277.27967290184347,\"monoisotopicMass\":277.11748936431,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":15},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":3}]},{\"symbol\":\"Dgc\",\"name\":\"N2,7-dimethylguanosine cap (cap DMG) diradical 279553N\",\"mf\":\"C12H18N5O11P2\",\"kind\":\"Nucleotide\",\"oneLetter\":\"®\",\"ocl\":{\"value\":\"e`TZMBHIG@aihJNEHdlemck`OFspz|OgDJ\\\\bTTTvTRbTbRvbtfKGG`UPuUUUUJtuTmUTPaLHPfH@@\",\"coordinates\":\"!BvuPfpDnDtEK_t_rHtXBH_TwPbOr_IorHbGtgD}F@RxS|uxc|_]^OTh}RIlBH_]F@IqOQ`@A~_c|bH}RbGt\"},\"mass\":470.24625855539705,\"monoisotopicMass\":470.04780541440005,\"unsaturation\":13,\"elements\":[{\"symbol\":\"C\",\"number\":12},{\"symbol\":\"H\",\"number\":18},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Dpa\",\"name\":\"5′-(3′-dephosphoacetyl-CoA) diradical 4155N\",\"mf\":\"C23H35N7O16P3S\",\"kind\":\"Nucleotide\",\"oneLetter\":\"♣\",\"ocl\":{\"value\":\"elz~@jDCHlemnSTLBAEKBjfckgbV]XpEfCpB|IoCtHZy{lbdvbbfrbTRdRNRdnTbefRTrRTdTRrFVfjjjj`V`bZjjfjZjZ`bbLSaRP@\",\"coordinates\":\"!BvtmKaMmKUMlfgto[tDw_cosWt]~H@dvObGv_F_sWbOpgKMG_R}m}bHa}HbOSX}M_cQw}G_OwzH_[wW_c~H_Wx@G{|bM]}bGvHGxbGu~Oxa}bOq~Oxa}_c~H_WxuwvH_P\"},\"mass\":790.5483266874629,\"monoisotopicMass\":790.1073852418399,\"unsaturation\":21,\"elements\":[{\"symbol\":\"C\",\"number\":23},{\"symbol\":\"H\",\"number\":35},{\"symbol\":\"N\",\"number\":7},{\"symbol\":\"O\",\"number\":16},{\"symbol\":\"P\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dpm\",\"name\":\"5′-(3′-dephosphomalonyl-CoA) diradical 4255N\",\"mf\":\"C24H35N7O18P3S\",\"kind\":\"Nucleotide\",\"oneLetter\":\"♥\",\"ocl\":{\"value\":\"efq~DjDCHlemnSTLBAEKBjfckgbV]XrzpEfCpB|IoCtHZy{lbdvbbfrbTRdRNRdnTbefRTrRTrdbbVPrtuUUUTBtDSUUTuSUSSTDTQb\\\\JR@@\",\"coordinates\":\"!BIlB_Ib[@pAe`zni`FALSF@A~FBq~OrpXbGveX@A~_c~OTa`lzf@_ha}_]_Q`MF@bOpXKA`loXbH__rHb@JHoX`B@m]}uwx@bGu~Ox`BbKvH@ha}_c~H@hb}b@JH_Xc|_`BH_X`B_`BHoP\"},\"mass\":834.5578724328346,\"monoisotopicMass\":834.0972144809799,\"unsaturation\":23,\"elements\":[{\"symbol\":\"C\",\"number\":24},{\"symbol\":\"H\",\"number\":35},{\"symbol\":\"N\",\"number\":7},{\"symbol\":\"O\",\"number\":18},{\"symbol\":\"P\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dsc\",\"name\":\"5′-(3′-dephosphosuccinyl-CoA) radical 4355N\",\"mf\":\"C25H37N7O18P3S\",\"kind\":\"Nucleotide\",\"oneLetter\":\"♦\",\"ocl\":{\"value\":\"eny~DjDCHlemnSTLBAEKBjfckgbV]XzvpOFCpB|IoCtHZy{lbdvbbfrbTRdRNRdnTbefRTrRTrTdTRrFVfjjjj`V`bZjjfjZjZfhHhcDxTd@@\",\"coordinates\":\"!B[~kjXFjiV[Ry|fcm}MtGwWctvH_]Q_c}KaGwWbGvN`H}MgrX@_gx@h`gKB\\\\lbGvOSX}M@m^H@gwWbGvH@ha}_Xc|bGxb@I~@Ha}b@JH_X`B_`BH_X`BbGvH@ha}_c~H@ha}b@I~@Ha}\"},\"mass\":848.5844898376815,\"monoisotopicMass\":848.11286454544,\"unsaturation\":23,\"elements\":[{\"symbol\":\"C\",\"number\":25},{\"symbol\":\"H\",\"number\":37},{\"symbol\":\"N\",\"number\":7},{\"symbol\":\"O\",\"number\":18},{\"symbol\":\"P\",\"number\":3},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dpc\",\"name\":\"5′-(3′-dephospho-CoA) radical 455N\",\"mf\":\"C21H32N7O13P2S\",\"kind\":\"Nucleotide\",\"oneLetter\":\"♠\",\"ocl\":{\"value\":\"ek_^KBDIG@nabYXJNEHdliemh\\\\QPEfspZ|CPcKmnrIQQSYQJIRIGIRWJQRsIJYIccpJkjjjjjAZBIjjjZijjBDIaBDq@@\",\"coordinates\":\"!B[zW[UI|YchAMc{vHcuJH@m~NbGuKvwvHb@JNwx}Rgqe}bHa}@h`gDr\\\\Sb@JOTh}R@m]~@@A~b@I~@H`B_X`_hb}_`CW@h`B_`BH@gx@upJH@gx@b@I~@@\"},\"mass\":684.5310558604504,\"monoisotopicMass\":684.1254042880199,\"unsaturation\":19,\"elements\":[{\"symbol\":\"C\",\"number\":21},{\"symbol\":\"H\",\"number\":32},{\"symbol\":\"N\",\"number\":7},{\"symbol\":\"O\",\"number\":13},{\"symbol\":\"P\",\"number\":2},{\"symbol\":\"S\",\"number\":1}]},{\"symbol\":\"Dpe\",\"name\":\"5′-diphosphate end 552N\",\"mf\":\"O3P\",\"kind\":\"Nucleotide\",\"oneLetter\":\"ϒ\",\"ocl\":{\"value\":\"gJQdebGF^Dx|duK@@\",\"coordinates\":\"!BbOq~@GxbGt\"},\"mass\":78.97197677137483,\"monoisotopicMass\":78.95850585713,\"unsaturation\":1,\"elements\":[{\"symbol\":\"O\",\"number\":3},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Mgc\",\"name\":\"7-methylguanosine cap (cap 0) diradical 79553N\",\"mf\":\"C11H16N5O11P2\",\"kind\":\"Nucleotide\",\"oneLetter\":\"©\",\"ocl\":{\"value\":\"eohZMBHIG@aihJNEHdlemck`OFspz|GgDJ\\\\bTTTvTRbTbRvbtcXx|BjFjjjjiVfjejjHPfDHSD@@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_I`JHbGtgD}F@RxPBux`B_]^OTh}RIlBH_]F@IqOQ`@A~_c|BbHa}\"},\"mass\":456.2196411505502,\"monoisotopicMass\":456.03215534994,\"unsaturation\":13,\"elements\":[{\"symbol\":\"C\",\"number\":11},{\"symbol\":\"H\",\"number\":16},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":11},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Gyy\",\"name\":\"guanylylated 5′ end (cap G) diradical 9553N\",\"mf\":\"C10H13N5O10P2\",\"kind\":\"Nucleotide\",\"oneLetter\":\"ϑ\",\"ocl\":{\"value\":\"fkhh`INCt\\\\J\\\\UENY{NCqmxM|EnNQJJJ[JIQJQHzIRLyxM^uUUUTkSULuQDSDHfP@\",\"coordinates\":\"!BvuPfpDnDtEK_tPJHtXBH_TwPb@J_I`JHbGtgD}F@RxPBux`B_]^OTh}R_`CQ`B\\\\StXA~@C}~@Gx\"},\"mass\":425.1856780673293,\"monoisotopicMass\":425.01376563368,\"unsaturation\":14,\"elements\":[{\"symbol\":\"C\",\"number\":10},{\"symbol\":\"H\",\"number\":13},{\"symbol\":\"N\",\"number\":5},{\"symbol\":\"O\",\"number\":10},{\"symbol\":\"P\",\"number\":2}]},{\"symbol\":\"Furp\",\"name\":\"furan phosphate radical\",\"mf\":\"C5H6O4P\",\"kind\":\"RNAp\",\"oneLetter\":\"⬠\",\"ocl\":{\"value\":\"dmtBPDpnAYcpRZ}eeYjii@@\",\"coordinates\":\"!BNvw|Vso|kUl{[So|PPAGuU\\\\z`pP\"},\"mass\":161.072705703704,\"monoisotopicMass\":161.00037067008,\"unsaturation\":5,\"elements\":[{\"symbol\":\"C\",\"number\":5},{\"symbol\":\"H\",\"number\":6},{\"symbol\":\"O\",\"number\":4},{\"symbol\":\"P\",\"number\":1}]},{\"symbol\":\"Phg\",\"ocl\":{\"value\":\"dcNHPBPOEgEInVuWYj`@@@\"},\"name\":\"Phenyl glycine diradical\",\"mf\":\"C8H7NO\",\"kind\":\"aa\",\"mass\":133.1475805880365,\"monoisotopicMass\":133.05276384961002,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":1}]},{\"symbol\":\"Hpg\",\"ocl\":{\"value\":\"dknDPBPp|V\\\\Tfy[WWYj`@`@@\",\"coordinates\":\"!BbOq~@Ha}bOq~Oxa}bGwW_Wx?_c?W_Wx?\"},\"name\":\"4-hydroxyphenylglycine diradical\",\"mf\":\"C8H7NO2\",\"kind\":\"aa\",\"mass\":149.14698551235477,\"monoisotopicMass\":149.04767846918,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":2}]},{\"symbol\":\"Dpg\",\"ocl\":{\"value\":\"dg^LPBS[CqYqR[emYTyj`BH@@\",\"coordinates\":\"!BbOr~@Hb}bOr~Wxb}bKvWo[y_oe}HoY^}Uwt\"},\"name\":\"3,5-dihydroxyphenylglycine diradical\",\"mf\":\"C8H7NO3\",\"kind\":\"aa\",\"mass\":165.14639043667304,\"monoisotopicMass\":165.04259308875,\"unsaturation\":10,\"elements\":[{\"symbol\":\"C\",\"number\":8},{\"symbol\":\"H\",\"number\":7},{\"symbol\":\"N\",\"number\":1},{\"symbol\":\"O\",\"number\":3}]}]","'use strict';\n\nconst groups = require('./groups');\n\nconst groupsObject = {};\ngroups.forEach((e) => {\n  if (groupsObject[e.symbol]) {\n    console.log('The symbol ' + e.symbol + ' is used more than once');\n  }\n  groupsObject[e.symbol] = e;\n});\n\nmodule.exports = groupsObject;\n","'use strict';\n\nconst elements = require('chemical-elements').elementsAndStableIsotopesObject;\n\nfunction getIsotopeRatioInfo(value) {\n  let result = { mass: 0, monoisotopicMass: 0 };\n  let element = elements[value.atom];\n  if (!element) throw new Error(`Element not found: ${value.atom}`);\n  let isotopesArray = element.isotopes;\n  let ratios = normalize(value.ratio);\n  let max = Math.max(...ratios);\n  if (ratios.length > isotopesArray.length) {\n    throw new Error(\n      `the number of specified ratios is bigger that the number of stable isotopes: ${value.atom}`,\n    );\n  }\n  for (let i = 0; i < ratios.length; i++) {\n    result.mass += ratios[i] * isotopesArray[i].mass;\n    if (max === ratios[i] && result.monoisotopicMass === 0) {\n      result.monoisotopicMass = isotopesArray[i].mass;\n    }\n  }\n  return result;\n}\n\nfunction normalize(array) {\n  let sum = array.reduce((prev, current) => prev + current, 0);\n  return array.map((a) => a / sum);\n}\n\nmodule.exports = getIsotopeRatioInfo;\n","'use strict';\n\nconst elements = require('chemical-elements/src/elementsAndIsotopesObject.js');\n\nconst isotopes = {};\nObject.keys(elements).forEach((key) => {\n  let e = elements[key];\n  e.isotopes.forEach((i) => {\n    isotopes[i.nominal + key] = {\n      abundance: i.abundance,\n      mass: i.mass,\n    };\n  });\n});\n\nmodule.exports = isotopes;\n","'use strict';\n\nconst elements = require('chemical-elements').elementsObject;\nconst groups = require('chemical-groups/src/groupsObject.js');\n\nconst Kind = require('../Kind');\n\nconst getIsotopeRatioInfo = require('./getIsotopeRatioInfo');\nconst isotopes = require('./getIsotopesObject');\n\n/**\n *\n * @param {*} parts\n * @param {*} [options={}]\n */\nmodule.exports = function getEA(parts) {\n  let results = {};\n  for (let part of parts) {\n    for (let line of part) {\n      switch (line.kind) {\n        case Kind.ISOTOPE: {\n          let isotope = isotopes[line.value.isotope + line.value.atom];\n          if (!isotope) {\n            throw new Error(\n              `Unknown isotope: ${line.value.isotope}${line.value.atom}`,\n            );\n          }\n          addMass(results, line.value.atom, isotope.mass * line.multiplier);\n          break;\n        }\n\n        case Kind.ISOTOPE_RATIO: {\n          let isotopeRatioInfo = getIsotopeRatioInfo(line.value);\n          addMass(\n            results,\n            line.value.atom,\n            isotopeRatioInfo.mass * line.multiplier,\n          );\n          break;\n        }\n\n        case Kind.ATOM: {\n          let element = elements[line.value];\n          if (!element) {\n            element = groups[line.value];\n            if (!element) throw Error(`Unknown element: ${line.value}`);\n            // need to explode group ????\n          }\n          addMass(results, line.value, element.mass * line.multiplier);\n          break;\n        }\n\n        case Kind.CHARGE:\n          break;\n        default:\n          throw new Error('partToMF unhandled Kind: ', line.kind);\n      }\n    }\n  }\n\n  let eas = [];\n  let sum = 0;\n  for (let key in results) {\n    sum += results[key];\n    eas.push({\n      element: key,\n      mass: results[key],\n    });\n  }\n\n  eas.forEach((ea) => {\n    ea.ratio = ea.mass / sum;\n  });\n  return eas;\n};\n\nfunction addMass(results, atom, mass) {\n  if (!results[atom]) results[atom] = 0;\n  results[atom] += mass;\n}\n","'use strict';\n\nconst {\n  elementsObject,\n  elementsAndIsotopesObject,\n} = require('chemical-elements');\n\nconst Kind = require('../Kind');\n\n/**\n *\n * @param {*} parts\n * @param {*} [options={}]\n */\nmodule.exports = function getElements(parts) {\n  const elements = [];\n  for (const part of parts) {\n    for (const line of part) {\n      let number = line.multiplier;\n      switch (line.kind) {\n        case Kind.ATOM: {\n          let symbol = line.value;\n          let element = elementsObject[symbol];\n          if (!element) {\n            throw new Error(`element unknown: ${symbol} - ${line}`);\n          }\n          addElement(elements, { symbol, number });\n          break;\n        }\n        case Kind.ISOTOPE: {\n          let element = elementsAndIsotopesObject[line.value.atom];\n          if (!element) {\n            throw new Error(`element unknown: ${part.value.atom} - ${line}`);\n          }\n          let isotope = element.isotopes.filter(\n            (a) => a.nominal === line.value.isotope,\n          )[0];\n          if (!isotope) {\n            throw new Error(`isotope unknown: ${line.value.isotope} - ${line}`);\n          }\n          addElement(elements, {\n            symbol: line.value.atom,\n            number,\n            isotope: line.value.isotope,\n          });\n          break;\n        }\n        default:\n          throw new Error(`unknown type: ${line.kind}`);\n      }\n    }\n  }\n  return elements;\n};\n\nfunction addElement(elements, newElement) {\n  for (let element of elements) {\n    if (\n      element.symbol === newElement.symbol &&\n      element.isotope === newElement.isotope\n    ) {\n      element.number += newElement.number;\n      return;\n    }\n  }\n  elements.push(newElement);\n}\n","'use strict';\n\nmodule.exports = {\n  O: 0,\n  N: 1,\n  H: -1,\n  Na: -1,\n  K: -1,\n  Li: -1,\n  Ca: -2,\n  C: 2,\n  F: -1,\n  Si: 2,\n  Cl: -1,\n  Br: -1,\n  I: -1,\n  S: 0,\n  P: 1,\n};\n","'use strict';\n\nconst Kind = require('../Kind');\n\n/**\n * Convert a MF part to an array of atoms\n * This procedure will suppress the isotopes !\n * This is mainly used to make queries\n */\n\nmodule.exports = function partToAtoms(part) {\n  let atoms = {};\n  for (let line of part) {\n    switch (line.kind) {\n      case Kind.ISOTOPE:\n        if (!atoms[line.value.atom]) atoms[line.value.atom] = 0;\n        atoms[line.value.atom] += line.multiplier;\n        break;\n      case Kind.ISOTOPE_RATIO:\n        if (!atoms[line.value.atom]) atoms[line.value.atom] = 0;\n        atoms[line.value.atom] += line.multiplier;\n        break;\n      case Kind.ATOM:\n        if (!atoms[line.value]) atoms[line.value] = 0;\n        atoms[line.value] += line.multiplier;\n        break;\n      case Kind.CHARGE:\n        break;\n      case Kind.ANCHOR:\n        break;\n      default:\n        throw new Error('partToMF unhandled Kind: ', line.kind);\n    }\n  }\n  return atoms;\n};\n","'use strict';\n\nconst Kind = require('../Kind');\n\nmodule.exports = function partToMF(part, options = {}) {\n  let mf = [];\n  for (let line of part) {\n    switch (line.kind) {\n      case Kind.ISOTOPE:\n        if (line.multiplier !== 0) {\n          mf.push(\n            `[${line.value.isotope}${line.value.atom}]${\n              line.multiplier !== 1 ? line.multiplier : ''\n            }`,\n          );\n        }\n        break;\n      case Kind.ISOTOPE_RATIO:\n        if (line.multiplier !== 0) {\n          mf.push(\n            `${line.value.atom}{${line.value.ratio.join(',')}}${\n              line.multiplier !== 1 ? line.multiplier : ''\n            }`,\n          );\n        }\n        break;\n      case Kind.ATOM:\n        if (line.multiplier !== 0) {\n          mf.push(line.value + (line.multiplier !== 1 ? line.multiplier : ''));\n        }\n        break;\n      case Kind.CHARGE:\n        if (line.value === 0 || options.neutral) break;\n        mf.push(`(${line.value > 0 ? `+${line.value}` : line.value})`);\n        break;\n      default:\n    }\n  }\n  return mf.join('');\n};\n","'use strict';\n\nconst { ELECTRON_MASS } = require('chemical-elements/src/constants');\nconst elements = require('chemical-elements/src/elementsAndIsotopesObject.js');\nconst unsaturations = require('chemical-elements/src/unsaturationsObject.js');\nconst groups = require('chemical-groups/src/groupsObject.js');\n\nconst Kind = require('../Kind');\n\nconst getIsotopeRatioInfo = require('./getIsotopeRatioInfo');\nconst isotopes = require('./getIsotopesObject');\nconst partToAtoms = require('./partToAtoms');\nconst partToMF = require('./partToMF');\n\n/**\n *\n * @param {*} parts\n * @param {*} [options={}]\n */\nmodule.exports = function getInfo(parts, options = {}) {\n  let { customUnsaturations = {} } = options;\n  if (parts.length === 0) return {};\n  if (parts.length === 1) {\n    return getProcessedPart(parts[0], customUnsaturations);\n  }\n\n  let result = { parts: [] };\n  for (let part of parts) {\n    result.parts.push(getProcessedPart(part, customUnsaturations));\n  }\n\n  result.monoisotopicMass = 0;\n  result.mass = 0;\n  result.charge = 0;\n  result.mf = result.parts.map((a) => a.mf).join('.');\n  result.parts.forEach((a) => {\n    result.mass += a.mass;\n    result.monoisotopicMass += a.monoisotopicMass;\n    result.charge += a.charge;\n  });\n  return result;\n};\n\nfunction getProcessedPart(part, customUnsaturations) {\n  let currentPart = {\n    mass: 0,\n    monoisotopicMass: 0,\n    charge: 0,\n    mf: '',\n    atoms: partToAtoms(part),\n  };\n  let unsaturation = 0;\n  let validUnsaturation = true;\n  currentPart.mf = partToMF(part);\n\n  for (let line of part) {\n    let currentElement = '';\n    switch (line.kind) {\n      case Kind.ATOM: {\n        currentElement = line.value;\n        let element = elements[line.value];\n\n        // todo should we have a kind GROUP ?\n        if (!element) {\n          element = groups[line.value];\n          if (!element) throw Error(`Unknown element: ${line.value}`);\n          if (!customUnsaturations[line.value]) {\n            customUnsaturations[line.value] = element.unsaturation;\n          }\n        }\n        if (!element) throw new Error(`Unknown element: ${line.value}`);\n        currentPart.monoisotopicMass +=\n          element.monoisotopicMass * line.multiplier;\n        currentPart.mass += element.mass * line.multiplier;\n        break;\n      }\n      case Kind.ISOTOPE: {\n        currentElement = line.value.atom;\n        let isotope = isotopes[line.value.isotope + line.value.atom];\n        if (!isotope) {\n          throw new Error(\n            `Unknown isotope: ${line.value.isotope}${line.value.atom}`,\n          );\n        }\n        currentPart.monoisotopicMass += isotope.mass * line.multiplier;\n        currentPart.mass += isotope.mass * line.multiplier;\n        break;\n      }\n      case Kind.ISOTOPE_RATIO: {\n        currentElement = line.value.atom;\n        let isotopeRatioInfo = getIsotopeRatioInfo(line.value);\n        currentPart.monoisotopicMass +=\n          isotopeRatioInfo.monoisotopicMass * line.multiplier;\n        currentPart.mass += isotopeRatioInfo.mass * line.multiplier;\n        break;\n      }\n      case Kind.CHARGE:\n        currentPart.charge = line.value;\n        if (validUnsaturation) {\n          unsaturation -= line.value;\n        }\n        break;\n      default:\n        throw new Error('Unimplemented Kind in getInfo', line.kind);\n    }\n    if (currentElement) {\n      if (customUnsaturations[currentElement] !== undefined) {\n        unsaturation += customUnsaturations[currentElement] * line.multiplier;\n      } else if (unsaturations[currentElement] !== undefined) {\n        unsaturation += unsaturations[currentElement] * line.multiplier;\n      } else {\n        validUnsaturation = false;\n      }\n    }\n  }\n\n  // need to calculate the observedMonoisotopicMass\n  if (currentPart.charge) {\n    currentPart.observedMonoisotopicMass =\n      (currentPart.monoisotopicMass - currentPart.charge * ELECTRON_MASS) /\n      Math.abs(currentPart.charge);\n  }\n  if (validUnsaturation) {\n    currentPart.unsaturation = unsaturation / 2 + 1;\n  }\n  return currentPart;\n}\n","'use strict';\n\nconst elements = require('chemical-elements/src/elementsAndStableIsotopesObject.js');\n\nconst Kind = require('../Kind');\n\nconst isotopes = require('./getIsotopesObject');\n\n/**\n *\n * @param {*} parts\n * @param {*} options\n */\nmodule.exports = function getIsotopesInfo(parts) {\n  if (parts.length === 0) return [];\n  if (parts.length > 1) {\n    throw new Error('getIsotopesInfo can not be applied on multipart MF');\n  }\n\n  return getProcessedPart(parts[0]);\n};\n\nfunction getProcessedPart(part) {\n  let result = {\n    charge: 0,\n    isotopes: [],\n  };\n  for (let line of part) {\n    switch (line.kind) {\n      case Kind.ISOTOPE: {\n        let isotope = isotopes[line.value.isotope + line.value.atom];\n        if (!isotope) {\n          throw Error('unknown isotope:', line.value.atom, line.value.isotope);\n        }\n        result.isotopes.push({\n          atom: `[${line.value.isotope}${line.value.atom}]`,\n          number: line.multiplier,\n          distribution: [{ x: isotope.mass, y: 1 }],\n        });\n        break;\n      }\n      case Kind.ISOTOPE_RATIO:\n        {\n          let element = elements[line.value.atom];\n          if (!element) throw new Error('unknown element:', line.value);\n\n          let distribution = getDistribution(\n            element.isotopes,\n            line.value.ratio,\n          );\n          result.isotopes.push({\n            atom: `${line.value.atom}{${line.value.ratio.join(',')}}`,\n            number: line.multiplier,\n            distribution,\n          });\n        }\n        break;\n      case Kind.ATOM: {\n        let element = elements[line.value];\n        if (!element) throw new Error('unknown element:', line.value);\n        result.isotopes.push({\n          atom: line.value,\n          number: line.multiplier,\n          distribution: element.isotopes.map((e) => ({\n            x: e.mass,\n            y: e.abundance,\n          })),\n        });\n        break;\n      }\n      case Kind.CHARGE:\n        result.charge += line.value;\n        break;\n      default:\n        throw new Error('partToMF unhandled Kind: ', line.kind);\n    }\n  }\n  return result;\n}\n\nfunction getDistribution(isotopesArray, ratio) {\n  let ratios = normalize(ratio);\n  let result = [];\n  if (ratios.length > isotopesArray.length) {\n    throw new Error(\n      `the number of specified ratios is bigger that the number of stable isotopes: ${isotopes}`,\n    );\n  }\n  for (let i = 0; i < ratios.length; i++) {\n    result.push({\n      x: isotopesArray[i].mass,\n      y: ratios[i],\n    });\n  }\n  return result;\n}\n\nfunction normalize(array) {\n  let sum = array.reduce((prev, current) => prev + current, 0);\n  return array.map((a) => a / sum);\n}\n","'use strict';\n\nconst Kind = require('../Kind');\n\nconst toDisplay = require('./toDisplay');\n/**\n * Converts an array of mf elements to an array of formatting information\n * @param {Array<Object>} result of the parse method\n */\n\nmodule.exports = function partsToDisplay(parts) {\n  let lines = [];\n  for (let part of parts) {\n    if (lines.length > 0) lines.push({ kind: Kind.SALT, value: '•' });\n    for (let partLine of part) {\n      lines.push(partLine);\n      if (partLine.multiplier) {\n        lines.push({\n          kind: Kind.MULTIPLIER,\n          value: partLine.multiplier,\n        });\n      }\n    }\n  }\n\n  return toDisplay(lines);\n};\n","'use strict';\n\nconst partToMF = require('./partToMF');\n\nmodule.exports = function partsToMF(parts, options) {\n  let mf = [];\n  for (let part of parts) {\n    mf.push(partToMF(part, options));\n  }\n  return mf.join(' . ');\n};\n","'use strict';\n\nfunction atomSorter(a, b) {\n  if (a === b) return 0;\n  if (a === 'C') return -1;\n  if (b === 'C') return 1;\n  if (a === 'H') return -1;\n  if (b === 'H') return 1;\n  if (a < b) return -1;\n  return 1;\n}\n\nmodule.exports = atomSorter;\n","'use strict';\n\nconst atomSorter = require('atom-sorter');\nconst groups = require('chemical-groups/src/groupsObject.js');\n\nconst Kind = require('../Kind');\n\n/**\n *\n * @param {*} lines\n * @param {object} [options={}]\n * @param {boolean} [options.expand=true] - Should we expand the groups\n */\n\nmodule.exports = function toParts(lines, options = {}) {\n  const { expand: shouldExpandGroups = true } = options;\n  let parts = [];\n  let currentPart = createNewPart();\n  let previousKind = Kind.BEGIN;\n  parts.push(currentPart);\n  for (let line of lines) {\n    switch (line.kind) {\n      case Kind.ATOM:\n      case Kind.ISOTOPE_RATIO:\n      case Kind.ISOTOPE:\n      case Kind.CHARGE:\n        currentPart.lines.push(Object.assign({}, line, { multiplier: 1 }));\n        break;\n      case Kind.OPENING_PARENTHESIS:\n        openingParenthesis(currentPart);\n        break;\n      case Kind.CLOSING_PARENTHESIS:\n        closingParenthesis(currentPart);\n        break;\n      case Kind.PRE_MULTIPLIER:\n        preMultiplier(currentPart, line);\n        break;\n      case Kind.MULTIPLIER:\n        postMultiplier(currentPart, line.value, previousKind);\n        break;\n      case Kind.SALT:\n        globalPartMultiplier(currentPart);\n        currentPart = createNewPart();\n        parts.push(currentPart);\n        break;\n      case Kind.ANCHOR: // we ignore anchors to create the parts and canonized MF\n        break;\n      case Kind.COMMENT: // we ignore comments to create the parts and canonized MF\n        break;\n      case Kind.TEXT:\n        break;\n      default:\n        throw new Error(`Can not process mf having: ${line.kind}`);\n    }\n    previousKind = line.kind;\n  }\n  globalPartMultiplier(currentPart);\n  if (shouldExpandGroups) expandGroups(parts);\n  return combineAtomsIsotopesCharges(parts);\n};\n\nfunction createNewPart() {\n  let currentMultiplier = { value: 1, fromIndex: 0 };\n  return { lines: [], multipliers: [currentMultiplier], currentMultiplier };\n}\n\nfunction openingParenthesis(currentPart) {\n  currentPart.currentMultiplier = {\n    value: 1,\n    fromIndex: currentPart.lines.length,\n  };\n  currentPart.multipliers.push(currentPart.currentMultiplier);\n}\n\nfunction closingParenthesis(currentPart) {\n  currentPart.currentMultiplier = currentPart.multipliers.pop();\n  if (currentPart.currentMultiplier !== 1) {\n    for (\n      let i = currentPart.currentMultiplier.fromIndex;\n      i < currentPart.lines.length;\n      i++\n    ) {\n      currentPart.lines[i].multiplier *= currentPart.currentMultiplier.value;\n    }\n  }\n}\n\nfunction preMultiplier(currentPart, line) {\n  currentPart.currentMultiplier.value *= line.value;\n}\n\nfunction globalPartMultiplier(currentPart) {\n  for (\n    let i = currentPart.multipliers[0].fromIndex;\n    i < currentPart.lines.length;\n    i++\n  ) {\n    currentPart.lines[i].multiplier *= currentPart.multipliers[0].value;\n  }\n}\n\nfunction postMultiplier(currentPart, value, previousKind) {\n  if (previousKind === Kind.CLOSING_PARENTHESIS) {\n    // need to apply to everything till the previous parenthesis\n    for (\n      let i = currentPart.currentMultiplier.fromIndex;\n      i < currentPart.lines.length;\n      i++\n    ) {\n      currentPart.lines[i].multiplier *= value;\n    }\n  } else {\n    // just applies to the previous element\n    currentPart.lines[currentPart.lines.length - 1].multiplier *= value;\n  }\n}\n\nfunction expandGroups(parts) {\n  for (let part of parts) {\n    let expanded = false;\n    for (let i = 0; i < part.lines.length; i++) {\n      let line = part.lines[i];\n      if (line.kind === Kind.ATOM) {\n        let group = groups[line.value];\n\n        if (group) {\n          expanded = true;\n          for (let element of group.elements) {\n            if (element.isotope) {\n              part.lines.push({\n                kind: 'isotope',\n                value: { atom: element.symbol, isotope: element.isotope },\n                multiplier: line.multiplier * element.number,\n              });\n            } else {\n              part.lines.push({\n                kind: 'atom',\n                value: element.symbol,\n                multiplier: line.multiplier * element.number,\n              });\n            }\n          }\n          part.lines[i] = undefined;\n        }\n      }\n    }\n    if (expanded) part.lines = part.lines.filter((a) => a);\n  }\n}\n\nfunction combineAtomsIsotopesCharges(parts) {\n  let results = [];\n  for (let part of parts) {\n    let result = [];\n    results.push(result);\n    calculateAndSortKeys(part);\n\n    let currentKey = '';\n    for (let key of part.keys) {\n      if (key.key === Kind.CHARGE) {\n        if (currentKey !== key.key) {\n          result.push({\n            kind: Kind.CHARGE,\n            value: key.value.value * key.value.multiplier,\n          });\n        } else {\n          result[result.length - 1].value +=\n            key.value.value * key.value.multiplier;\n        }\n      } else {\n        if (currentKey !== key.key) {\n          result.push(key.value);\n        } else {\n          result[result.length - 1].multiplier += key.value.multiplier;\n        }\n      }\n      currentKey = key.key;\n    }\n\n    result.sort((a, b) => {\n      if (a.kind === Kind.CHARGE) return 1;\n      if (b.kind === Kind.CHARGE) return -1;\n\n      let atomA = a.kind === Kind.ATOM ? a.value : a.value.atom;\n      let atomB = b.kind === Kind.ATOM ? b.value : b.value.atom;\n      if (atomA !== atomB) return atomSorter(atomA, atomB);\n      // same atome but some isotopes ...\n      if (a.kind === Kind.ATOM) return -1;\n      if (b.kind === Kind.ATOM) return 1;\n      if (a.kind === Kind.ISOTOPE) return -1;\n      if (b.kind === Kind.ISOTOPE) return 1;\n      if (a.kind === Kind.ISOTOPE_RATIO) return -1;\n      if (b.kind === Kind.ISOTOPE_RATIO) return 1;\n      return 0;\n    });\n  }\n  return results;\n}\n\nfunction calculateAndSortKeys(part) {\n  part.keys = [];\n  for (let line of part.lines) {\n    part.keys.push({ key: getKey(line), value: line });\n  }\n  part.keys.sort((a, b) => stringComparator(a.key, b.key));\n}\n\nfunction getKey(line) {\n  let key = [line.kind];\n\n  switch (line.kind) {\n    case Kind.CHARGE:\n      break;\n    default:\n      if (typeof line.value === 'string') {\n        key.push(line.value);\n      } else {\n        for (let prop of Object.keys(line.value).sort()) {\n          key.push(line.value[prop]);\n        }\n      }\n  }\n  return key.join('-');\n}\n\nfunction stringComparator(a, b) {\n  if (a < b) return -1;\n  if (a > b) return 1;\n  return 0;\n}\n","'use strict';\n\nconst ensureCase = require('./ensureCase');\nconst parse = require('./parse');\nconst getEA = require('./util/getEA');\nconst getElements = require('./util/getElements');\nconst getInfo = require('./util/getInfo');\nconst getIsotopesInfo = require('./util/getIsotopesInfo');\nconst partsToDisplay = require('./util/partsToDisplay');\nconst partsToMF = require('./util/partsToMF');\nconst toDisplay = require('./util/toDisplay');\nconst toHtml = require('./util/toHtml');\nconst toParts = require('./util/toParts');\n\nclass MF {\n  constructor(mf, options = {}) {\n    if (options.ensureCase) {\n      mf = ensureCase(mf);\n    }\n    this.parsed = parse(mf);\n    this.cache = {};\n  }\n\n  toDisplay() {\n    if (!this.cache.displayed) this.cache.displayed = toDisplay(this.parsed);\n    return this.cache.displayed;\n  }\n\n  toHtml() {\n    if (!this.cache.html) {\n      this.toDisplay();\n      this.cache.html = toHtml(this.cache.displayed);\n    }\n    return this.cache.html;\n  }\n\n  toParts(options) {\n    if (!this.cache.parts) {\n      this.cache.parts = toParts(this.parsed, options);\n    }\n    return this.cache.parts;\n  }\n\n  /**\n   * Returns an object with the global MF, global charge, monoisotopic mass and mass\n   * as well as the same informations for all the parts\n   * @param {object} [options={}] options\n   */\n  getInfo(options = {}) {\n    if (!this.cache.info) {\n      this.toParts();\n      this.cache.info = getInfo(this.cache.parts, options);\n    }\n    return this.cache.info;\n  }\n\n  /**\n   * Returns an object with the elemental analysis\n   */\n  getEA(options = {}) {\n    if (!this.cache.ea) {\n      this.toParts();\n      this.cache.ea = getEA(this.cache.parts, options);\n    }\n    return this.cache.ea;\n  }\n\n  /**\n   * Get the different elements for each part\n   * @returns an array\n   */\n  getElements() {\n    if (!this.cache.elements) {\n      this.toParts();\n      this.cache.elements = getElements(this.cache.parts);\n    }\n    return this.cache.elements;\n  }\n\n  /**\n   * Returns an array with each atom and isotopic composition\n   */\n  getIsotopesInfo(options = {}) {\n    if (!this.cache.isotopesInfo) {\n      this.toParts();\n      this.cache.isotopesInfo = getIsotopesInfo(this.cache.parts, options);\n    }\n    return this.cache.isotopesInfo;\n  }\n\n  /**\n   * Get a canonized MF\n   */\n  toMF() {\n    if (!this.cache.mf) {\n      this.toParts();\n      this.cache.mf = partsToMF(this.cache.parts);\n    }\n    return this.cache.mf;\n  }\n\n  /**\n   * Get a canonized MF\n   */\n  toNeutralMF() {\n    if (!this.cache.neutralMF) {\n      this.toParts();\n      this.cache.neutralMF = partsToMF(this.cache.parts, { neutral: true });\n    }\n    return this.cache.neutralMF;\n  }\n\n  canonize() {\n    this.toParts();\n    this.cache.displayed = partsToDisplay(this.cache.parts);\n    this.cache.html = undefined;\n  }\n}\n\nmodule.exports = MF;\n","'use strict';\n\nconst parse = require('./parse');\nconst toDisplay = require('./util/toDisplay');\nconst toHtml = require('./util/toHtml');\n\n/**\n * Parse a molecular formula and converts it to an HTML code\n * @param {String} mf String containing the molecular formula\n */\nfunction parseToHtml(mf) {\n  let parsed = parse(mf);\n  let display = toDisplay(parsed);\n  return toHtml(display);\n}\n\nmodule.exports = {\n  Kind: require('./Kind'),\n  Format: require('./Format'),\n  Style: require('./Style'),\n  parse: require('./parse'),\n  ensureCase: require('./ensureCase'),\n  toDisplay,\n  toHtml,\n  parseToHtml,\n  MF: require('./MF'),\n};\n","import { MF } from 'mf-parser';\n\nexport function applyLockMass(chromatogram, mfs, options = {}) {\n  const { oddReference = true, maxShift = 0.1 } = options;\n\n  // allows mf as string or array\n  if (typeof mfs === 'string') {\n    mfs = [mfs];\n  }\n\n  // calculate the mass reference values\n  const referenceMass = mfs.map((mf) => {\n    let info = new MF(mf).getInfo();\n    return info.observedMonoisotopicMass || info.monoisotopicMass;\n  });\n\n  const ms = chromatogram.getSeries('ms').data;\n\n  // check where is the reference values\n  let referenceIndexShift = Number(oddReference);\n  let msIndexShift = Number(!oddReference);\n  const newSize = ms.length >> 1;\n  let referencesCount = new Array(referenceMass.length).fill(0);\n\n  // applying the changes for all the spectra\n  let previousValidDifference = Number.MAX_VALUE;\n  let usingPreviousValidDifference = false;\n  for (let i = 0; i < newSize; i++) {\n    let massIndex = 2 * i + msIndexShift;\n    let referenceIndex = 2 * i + referenceIndexShift;\n\n    // calculate the difference between theory and experimental (the smallest)\n    let difference = Number.MAX_VALUE;\n    let closestIndex = -1;\n    for (let j = 0; j < referenceMass.length; j++) {\n      for (let k = 0; k < ms[referenceIndex][0].length; k++) {\n        if (\n          Math.abs(difference) >\n          Math.abs(referenceMass[j] - ms[referenceIndex][0][k])\n        ) {\n          difference = referenceMass[j] - ms[referenceIndex][0][k];\n          closestIndex = j;\n        }\n      }\n    }\n    if (\n      Math.abs(difference) > maxShift &&\n      Math.abs(previousValidDifference) < maxShift\n    ) {\n      difference = previousValidDifference;\n      usingPreviousValidDifference = true;\n    } else {\n      usingPreviousValidDifference = false;\n    }\n    // apply identified lock mass\n    if (Math.abs(difference) < maxShift) {\n      previousValidDifference = difference;\n      if (!usingPreviousValidDifference) {\n        if (closestIndex !== -1) {\n          referencesCount[closestIndex] += 1;\n        }\n      }\n      for (let m = 0; m < ms[massIndex][0].length; m++) {\n        ms[massIndex][0][m] += difference;\n      }\n    }\n  }\n\n  const referenceUsed = {\n    total: newSize,\n    totalFound: referencesCount.reduce((prev, current) => current + prev, 0),\n    mfs: {},\n    percent: 0,\n  };\n  for (let r = 0; r < referenceMass.length; r++) {\n    referenceUsed.mfs[mfs[r]] = referencesCount[r];\n  }\n  referenceUsed.percent =\n    (referenceUsed.totalFound / referenceUsed.total) * 100;\n\n  // remove the time and the mass spectra that contains the reference\n  chromatogram.filter((index) => index % 2 !== referenceIndexShift);\n\n  return referenceUsed;\n}\n","import max from 'ml-array-max';\n\n/**\n * Calculate bpc\n * @param {Chromatogram} chromatogram - GC/MS chromatogram where make the peak picking\n * @return {Array} - Calculated bpc\n */\nexport function calculateBpc(chromatogram) {\n  const ms = chromatogram.getSeries('ms');\n  const massSpectra = ms.data;\n  const bpc = [];\n  for (const massSpectrum of massSpectra) {\n    if (massSpectrum[1].length > 0) {\n      bpc.push(max(massSpectrum[1]));\n    } else {\n      bpc.push(0);\n    }\n  }\n\n  return bpc;\n}\n","/**\n * Calculate the Extracted Ion Chromatogram\n * @param {object} chromatogram\n * @param {string|number} targetMass\n * @param {object} [options={}]\n * @param {number} [options.slotWidth=1]\n * @returns\n */\n\nexport function calculateEic(chromatogram, targetMass, options = {}) {\n  const { slotWidth = 1 } = options;\n  if (!targetMass) {\n    throw new Error(\n      'targetMass must be defined and a number or string of comma separated numbers',\n    );\n  }\n  if (!isNaN(targetMass)) {\n    targetMass = [targetMass];\n  } else if (typeof targetMass === 'string') {\n    targetMass = targetMass.split(/[ ,;\\r\\n\\t]+/).map((value) => Number(value));\n  }\n  for (let mass of targetMass) {\n    if (isNaN(mass)) {\n      throw new Error(\n        'targetMass must be defined and a number or string of comma separated numbers',\n      );\n    }\n  }\n\n  const halfWidth = slotWidth / 2;\n  const ms = chromatogram.getSeries('ms');\n  const massSpectra = ms.data;\n\n  const result = new Array(massSpectra.length).fill(0);\n  for (let mass of targetMass) {\n    for (let i = 0; i < massSpectra.length; i++) {\n      let massSpectrum = massSpectra[i];\n      for (let j = 0; j < massSpectrum[0].length; j++) {\n        if (Math.abs(massSpectrum[0][j] - mass) <= halfWidth) {\n          result[i] += massSpectrum[1][j];\n        }\n      }\n    }\n  }\n\n  return result;\n}\n","export default function addBaseline(data, baselineFct) {\n  if (!baselineFct) return data;\n  let xs = data.x;\n  let ys = data.y;\n  for (let i = 0; i < xs.length; i++) {\n    ys[i] += baselineFct(xs[i]);\n  }\n  return data;\n}\n","export default Math.random;\n","import defaultSource from \"./defaultSource.js\";\n\nexport default (function sourceRandomUniform(source) {\n  function randomUniform(min, max) {\n    min = min == null ? 0 : +min;\n    max = max == null ? 1 : +max;\n    if (arguments.length === 1) max = min, min = 0;\n    else max -= min;\n    return function() {\n      return source() * max + min;\n    };\n  }\n\n  randomUniform.source = sourceRandomUniform;\n\n  return randomUniform;\n})(defaultSource);\n","import defaultSource from \"./defaultSource.js\";\n\nexport default (function sourceRandomNormal(source) {\n  function randomNormal(mu, sigma) {\n    var x, r;\n    mu = mu == null ? 0 : +mu;\n    sigma = sigma == null ? 1 : +sigma;\n    return function() {\n      var y;\n\n      // If available, use the second previously-generated uniform random.\n      if (x != null) y = x, x = null;\n\n      // Otherwise, generate a new x and y.\n      else do {\n        x = source() * 2 - 1;\n        y = source() * 2 - 1;\n        r = x * x + y * y;\n      } while (!r || r > 1);\n\n      return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);\n    };\n  }\n\n  randomNormal.source = sourceRandomNormal;\n\n  return randomNormal;\n})(defaultSource);\n","const LOOP = 8;\nconst FLOAT_MUL = 1 / 16777216;\nconst sh1 = 15;\nconst sh2 = 18;\nconst sh3 = 11;\nfunction multiply_uint32(n, m) {\n    n >>>= 0;\n    m >>>= 0;\n    const nlo = n & 0xffff;\n    const nhi = n - nlo;\n    return (((nhi * m) >>> 0) + nlo * m) >>> 0;\n}\nexport default class XSadd {\n    constructor(seed = Date.now()) {\n        this.state = new Uint32Array(4);\n        this.init(seed);\n        this.random = this.getFloat.bind(this);\n    }\n    /**\n     * Returns a 32-bit integer r (0 <= r < 2^32)\n     */\n    getUint32() {\n        this.nextState();\n        return (this.state[3] + this.state[2]) >>> 0;\n    }\n    /**\n     * Returns a floating point number r (0.0 <= r < 1.0)\n     */\n    getFloat() {\n        return (this.getUint32() >>> 8) * FLOAT_MUL;\n    }\n    init(seed) {\n        if (!Number.isInteger(seed)) {\n            throw new TypeError('seed must be an integer');\n        }\n        this.state[0] = seed;\n        this.state[1] = 0;\n        this.state[2] = 0;\n        this.state[3] = 0;\n        for (let i = 1; i < LOOP; i++) {\n            this.state[i & 3] ^=\n                (i +\n                    multiply_uint32(1812433253, this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0))) >>>\n                    0;\n        }\n        this.periodCertification();\n        for (let i = 0; i < LOOP; i++) {\n            this.nextState();\n        }\n    }\n    periodCertification() {\n        if (this.state[0] === 0 &&\n            this.state[1] === 0 &&\n            this.state[2] === 0 &&\n            this.state[3] === 0) {\n            this.state[0] = 88; // X\n            this.state[1] = 83; // S\n            this.state[2] = 65; // A\n            this.state[3] = 68; // D\n        }\n    }\n    nextState() {\n        let t = this.state[0];\n        t ^= t << sh1;\n        t ^= t >>> sh2;\n        t ^= this.state[3] << sh3;\n        this.state[0] = this.state[1];\n        this.state[1] = this.state[2];\n        this.state[2] = this.state[3];\n        this.state[3] = t;\n    }\n}\n","import { randomUniform, randomNormal } from 'd3-random';\nimport XSAdd from 'ml-xsadd';\n\nexport default function addNoise(data, percent = 0, options = {}) {\n  const { distribution = 'uniform', seed } = options;\n\n  let generateRandomNumber;\n  switch (distribution) {\n    case 'uniform': {\n      generateRandomNumber = getRandom(randomUniform, seed, -0.5, 0.5);\n      break;\n    }\n    case 'normal': {\n      generateRandomNumber = getRandom(randomNormal, seed);\n      break;\n    }\n    default:\n      throw new Error(`Unknown distribution ${options.distribution}`);\n  }\n\n  if (!percent) return data;\n  let ys = data.y;\n  let factor = (percent * findMax(ys)) / 100;\n  for (let i = 0; i < ys.length; i++) {\n    ys[i] += generateRandomNumber() * factor;\n  }\n  return data;\n}\n\nfunction getRandom(func, seed, ...args) {\n  return typeof seed === 'number'\n    ? func.source(new XSAdd(seed).random)(...args)\n    : func(...args);\n}\n\nfunction findMax(array) {\n  let max = Number.MIN_VALUE;\n  for (let item of array) {\n    if (item > max) max = item;\n  }\n  return max;\n}\n","import { getShapeGenerator } from 'ml-peak-shape-generator';\n\nimport addBaseline from './util/addBaseline.js';\nimport addNoise from './util/addNoise.js';\n\nexport class SpectrumGenerator {\n  /**\n   *\n   * @param {object} [options={}]\n   * @param {number} [options.from=0]\n   * @param {number} [options.to=0]\n   * @param {function} [options.nbPoints=10001]\n   * @param {number} [options.factor] default value depends of the shape in order to cover 99.99% of the surface\n   * @param {object} [options.shape={kind:'gaussian'}]\n   * @param {string} [options.shape.kind] kind of shape, gaussian, lorentzian or pseudovoigt\n   * @param {object} [options.shape.options] options for the shape (like `mu` for pseudovoigt)\n   */\n  constructor(options = {}) {\n    options = Object.assign(\n      {},\n      {\n        from: 0,\n        to: 1000,\n        nbPoints: 10001,\n        peakWidthFct: () => 5,\n        shape: {\n          kind: 'gaussian',\n        },\n      },\n      options,\n    );\n\n    this.from = options.from;\n    this.to = options.to;\n    this.nbPoints = options.nbPoints;\n    this.interval = (this.to - this.from) / (this.nbPoints - 1);\n    this.peakWidthFct = options.peakWidthFct;\n    this.maxPeakHeight = Number.MIN_SAFE_INTEGER;\n\n    let shapeGenerator = getShapeGenerator(options.shape);\n    this.shape = shapeGenerator;\n\n    assertNumber(this.from, 'from');\n    assertNumber(this.to, 'to');\n    assertInteger(this.nbPoints, 'nbPoints');\n\n    if (this.to <= this.from) {\n      throw new RangeError('to option must be larger than from');\n    }\n\n    if (typeof this.peakWidthFct !== 'function') {\n      throw new TypeError('peakWidthFct option must be a function');\n    }\n\n    this.reset();\n  }\n\n  addPeaks(peaks, options) {\n    if (\n      !Array.isArray(peaks) &&\n      (typeof peaks !== 'object' ||\n        peaks.x === undefined ||\n        peaks.y === undefined ||\n        !Array.isArray(peaks.x) ||\n        !Array.isArray(peaks.y) ||\n        peaks.x.length !== peaks.y.length)\n    ) {\n      throw new TypeError(\n        'peaks must be an array or an object containing x[] and y[]',\n      );\n    }\n    if (Array.isArray(peaks)) {\n      for (const peak of peaks) {\n        this.addPeak(peak, options);\n      }\n    } else {\n      for (let i = 0; i < peaks.x.length; i++) {\n        this.addPeak([peaks.x[i], peaks.y[i]], options);\n      }\n    }\n\n    return this;\n  }\n\n  /**\n   *\n   * @param {[x,y]|[x,y,w]|{x,y,width}} [peak]\n   * @param {*} options\n   */\n  addPeak(peak, options = {}) {\n    if (\n      typeof peak !== 'object' ||\n      (peak.length !== 2 &&\n        peak.length !== 3 &&\n        (peak.x === undefined || peak.y === undefined))\n    ) {\n      throw new Error(\n        'peak must be an array with two (or three) values or an object with {x,y,width?}',\n      );\n    }\n\n    let xPosition;\n    let intensity;\n    let peakWidth;\n    let peakShapeOptions;\n    if (Array.isArray(peak)) {\n      [xPosition, intensity, peakWidth, peakShapeOptions] = peak;\n    } else {\n      xPosition = peak.x;\n      intensity = peak.y;\n      peakWidth = peak.width;\n      peakShapeOptions = peak.shape;\n    }\n    if (intensity > this.maxPeakHeight) this.maxPeakHeight = intensity;\n\n    let {\n      width = peakWidth === undefined\n        ? this.peakWidthFct(xPosition)\n        : peakWidth,\n      widthLeft,\n      widthRight,\n      shape: shapeOptions = {},\n    } = options;\n\n    if (peakShapeOptions) {\n      shapeOptions = { ...shapeOptions, ...peakShapeOptions };\n    }\n\n    let shapeGenerator = shapeOptions\n      ? getShapeGenerator(shapeOptions)\n      : this.shape;\n\n    if (!widthLeft) widthLeft = width;\n    if (!widthRight) widthRight = width;\n\n    let factor =\n      options.factor === undefined\n        ? shapeGenerator.getFactor()\n        : options.factor;\n\n    const firstValue = xPosition - (widthLeft / 2) * factor;\n    const lastValue = xPosition + (widthRight / 2) * factor;\n\n    const firstPoint = Math.max(\n      0,\n      Math.floor((firstValue - this.from) / this.interval),\n    );\n    const lastPoint = Math.min(\n      this.nbPoints - 1,\n      Math.ceil((lastValue - this.from) / this.interval),\n    );\n    const middlePoint = Math.round((xPosition - this.from) / this.interval);\n    // PEAK SHAPE MAY BE ASYMMETRC (widthLeft and widthRight) !\n    // we calculate the left part of the shape\n\n    shapeGenerator.setFWHM(widthLeft);\n    for (let index = firstPoint; index < Math.max(middlePoint, 0); index++) {\n      this.data.y[index] +=\n        intensity * shapeGenerator.fct(this.data.x[index] - xPosition);\n    }\n\n    // we calculate the right part of the gaussian\n    shapeGenerator.setFWHM(widthRight);\n    for (\n      let index = Math.min(middlePoint, lastPoint);\n      index <= lastPoint;\n      index++\n    ) {\n      this.data.y[index] +=\n        intensity * shapeGenerator.fct(this.data.x[index] - xPosition);\n    }\n\n    return this;\n  }\n\n  addBaseline(baselineFct) {\n    addBaseline(this.data, baselineFct);\n    return this;\n  }\n\n  addNoise(percent, options) {\n    addNoise(this.data, percent, options);\n    return this;\n  }\n\n  getSpectrum(options = {}) {\n    if (typeof options === 'boolean') {\n      options = { copy: options };\n    }\n    const { copy = true, threshold = 0 } = options;\n    if (threshold) {\n      let minPeakHeight = this.maxPeakHeight * threshold;\n      let x = [];\n      let y = [];\n      for (let i = 0; i < this.data.x.length; i++) {\n        if (this.data.y[i] >= minPeakHeight) {\n          x.push(this.data.x[i]);\n          y.push(this.data.y[i]);\n        }\n      }\n      return { x, y };\n    }\n    if (copy) {\n      return {\n        x: this.data.x.slice(),\n        y: this.data.y.slice(),\n      };\n    } else {\n      return this.data;\n    }\n  }\n\n  reset() {\n    const spectrum = (this.data = {\n      x: new Float64Array(this.nbPoints),\n      y: new Float64Array(this.nbPoints),\n    });\n\n    for (let i = 0; i < this.nbPoints; i++) {\n      spectrum.x[i] = this.from + i * this.interval;\n    }\n\n    return this;\n  }\n}\n\nfunction assertInteger(value, name) {\n  if (!Number.isInteger(value)) {\n    throw new TypeError(`${name} option must be an integer`);\n  }\n}\n\nfunction assertNumber(value, name) {\n  if (!Number.isFinite(value)) {\n    throw new TypeError(`${name} option must be a number`);\n  }\n}\n\nexport function generateSpectrum(peaks, options = {}) {\n  const generator = new SpectrumGenerator(options);\n\n  generator.addPeaks(peaks, options);\n  if (options.baseline) generator.addBaseline(options.baseline);\n  if (options.noise) generator.addNoise(options.noise.percent, options.noise);\n  return generator.getSpectrum({\n    threshold: options.threshold,\n  });\n}\n","'use strict';\n\nconst { ELECTRON_MASS } = require('chemical-elements/src/constants');\n\nmodule.exports = function getMsem(em, charge) {\n  if (charge > 0) {\n    return em / charge - ELECTRON_MASS;\n  } else if (charge < 0) {\n    return em / (charge * -1) + ELECTRON_MASS;\n  } else {\n    return 0;\n  }\n};\n","'use strict';\n\nconst getMsem = require('./getMsem');\n\n/**\n * Returns an object containing:\n * {ms: {em, charge, ionization}, ionization: {}}\n * We return the ionization in order to know which one has been selected\n */\n\nmodule.exports = function getMsInfo(entry, options = {}) {\n  const {\n    allowNeutralMolecules,\n    ionization = { mf: '', em: 0, charge: 0 },\n    forceIonization = false,\n    targetMass,\n  } = options;\n\n  let realIonization = ionization;\n  if (!forceIonization && entry.ionization && entry.ionization.mf !== '') {\n    realIonization = entry.ionization;\n  }\n\n  let ms = {\n    ionization: realIonization.mf,\n    em: 0,\n    charge: entry.charge + realIonization.charge,\n  };\n\n  if (ms.charge !== 0) {\n    ms.em = getMsem(entry.em + realIonization.em, ms.charge);\n  } else if (allowNeutralMolecules) {\n    ms.em = entry.em + realIonization.em;\n  }\n  if (targetMass) {\n    ms.delta = targetMass - ms.em;\n    ms.ppm = ((targetMass - ms.em) / ms.em) * 1e6;\n  }\n  return {\n    ms,\n    ionization: realIonization,\n  };\n};\n","'use strict';\n\nfunction processRange(string, comment, options = {}) {\n  const { limit } = options;\n  let results = [];\n  let parts = string.split(/(-?[0-9]+--?[0-9]+)/).filter((v) => v); // remove empty parts\n\n  let position = -1;\n  let mfs = [];\n  for (let i = 0; i < parts.length; i++) {\n    let part = parts[i];\n    if (!~part.search(/-?[0-9]--?[0-9]/)) {\n      position++;\n      mfs[position] = {\n        mf: part,\n        min: 1,\n        max: 1,\n      };\n    } else {\n      let min = part.replace(/^(-?[0-9]*)-(-?[0-9]*)/, '$1') >> 0;\n      let max = part.replace(/^(-?[0-9]*)-(-?[0-9]*)/, '$2') >> 0;\n      mfs[position].min = Math.min(min, max);\n      mfs[position].max = Math.max(min, max);\n    }\n  }\n\n  let currents = new Array(mfs.length);\n  for (let i = 0; i < currents.length; i++) {\n    currents[i] = mfs[i].min;\n  }\n\n  position = 0;\n  while (position < currents.length) {\n    if (currents[position] < mfs[position].max) {\n      results.push(getMF(mfs, currents, comment));\n      currents[position]++;\n      for (let i = 0; i < position; i++) {\n        currents[i] = mfs[i].min;\n      }\n      position = 0;\n    } else {\n      position++;\n    }\n    if (results.length > limit) {\n      throw Error(`processRange generates to many fragments (over ${limit})`);\n    }\n  }\n\n  results.push(getMF(mfs, currents, comment));\n  return results;\n}\n\nfunction getMF(mfs, currents, comment) {\n  let mf = '';\n  for (let i = 0; i < mfs.length; i++) {\n    if (currents[i] === 0) {\n      // TODO we need to remove from currents[i] till we reach another part of the MF\n      mf += removeMFLastPart(mfs[i].mf);\n    } else {\n      mf += mfs[i].mf;\n      if (currents[i] !== 1) {\n        mf += currents[i];\n      }\n    }\n  }\n  if (comment) mf += `$${comment}`;\n  return mf;\n}\n\n/*\n   Allows to remove the last part of a MF. Useful when you have something with '0' times.\n   C10H -> C10\n   C10((Me)N) -> C10\n   C10Ala -> C10\n   C10Ala((Me)N) -> C10Ala\n   */\nfunction removeMFLastPart(mf) {\n  let parenthesis = 0;\n  let start = true;\n  for (let i = mf.length - 1; i >= 0; i--) {\n    let ascii = mf.charCodeAt(i);\n\n    if (ascii > 96 && ascii < 123) {\n      // lowercase\n      if (!start && !parenthesis) {\n        return mf.substr(0, i + 1);\n      }\n    } else if (ascii > 64 && ascii < 91) {\n      // uppercase\n      if (!start && !parenthesis) {\n        return mf.substr(0, i + 1);\n      }\n      start = false;\n    } else if (ascii === 40) {\n      // (\n      parenthesis--;\n      if (!parenthesis) return mf.substr(0, i);\n    } else if (ascii === 41) {\n      // )\n      parenthesis++;\n    } else {\n      start = false;\n      if (!parenthesis) return mf.substr(0, i + 1);\n    }\n  }\n  return '';\n}\n\nmodule.exports = processRange;\n","'use strict';\n\nconst MF = require('mf-parser/src/MF');\n\nconst processRange = require('./processRange');\n\nmodule.exports = function preprocessIonizations(ionizationsString = '') {\n  if (Array.isArray(ionizationsString)) return ionizationsString;\n  let ionizations = ionizationsString.split(/ *[.,;\\t\\r\\n]+ */);\n\n  // it is allowed to have ranges in Ionizations. We need to explode them.\n\n  let results = [];\n\n  for (let ionization of ionizations) {\n    let parts = processRange(ionization);\n    for (let part of parts) {\n      let info = new MF(part).getInfo();\n      results.push({\n        mf: part,\n        em: info.monoisotopicMass,\n        charge: info.charge,\n      });\n    }\n  }\n\n  return results;\n};\n","'use strict';\n\nmodule.exports = function sortX() {\n  this.ySorted = false;\n  if (this.xSorted) return this;\n  this.array.sort((a, b) => a.x - b.x);\n  this.xSorted = true;\n  return this;\n};\n","'use strict';\n\nmodule.exports = function sortY() {\n  this.xSorted = false;\n  if (this.ySorted) return this;\n  this.array.sort((a, b) => b.y - a.y);\n  this.ySorted = true;\n  return this;\n};\n","'use strict';\n\n/**\n * Join x values if there are similar\n */\n\nmodule.exports = function joinX(threshold = Number.EPSILON) {\n  // when we join we will use the center of mass\n  let result = [];\n  this.sortX();\n  let current = {\n    x: Number.MIN_SAFE_INTEGER,\n    y: 0,\n  };\n  for (let item of this.array) {\n    if (item.x - current.x <= threshold) {\n      // weighted sum\n      current.x =\n        (item.y / (current.y + item.y)) * (item.x - current.x) + current.x;\n      current.y += item.y;\n    } else {\n      current = {\n        x: item.x,\n        y: item.y,\n      };\n      result.push(current);\n    }\n  }\n  this.array = result;\n  this.ySorted = false;\n  return this;\n};\n","'use strict';\n\nmodule.exports = function topY(limit) {\n  if (!limit) return this;\n  if (this.array.length <= limit) return this;\n  this.sortY();\n  this.array.splice(limit);\n  return this;\n};\n","'use strict';\n\n/**\n * Sum of Y to 1\n */\n\nmodule.exports = function maxToOne() {\n  if (this.array.length === 0) return this;\n  let currentMax = this.array[0].y;\n  for (let item of this.array) {\n    if (item.y > currentMax) currentMax = item.y;\n  }\n  for (let item of this.array) {\n    item.y /= currentMax;\n  }\n  return this;\n};\n","'use strict';\n\nmodule.exports = function multiply(b, options = {}) {\n  const { minY = 1e-8, maxLines = 5000, deltaX = 1e-2 } = options;\n  const result = new this.constructor();\n\n  this.sortY();\n  b.sortY();\n\n  for (let entryA of this.array) {\n    for (let entryB of b.array) {\n      let y = entryA.y * entryB.y;\n      if (y > minY) result.push(entryA.x + entryB.x, y);\n      if (result.length > maxLines) {\n        result.join(deltaX);\n        result.topY(maxLines / 2);\n      }\n    }\n  }\n  result.join(deltaX);\n  result.topY(maxLines / 2);\n  this.move(result);\n  return this;\n};\n","'use strict';\n\nmodule.exports = function square(options = {}) {\n  return this.multiply(this, options);\n};\n","'use strict';\n\n// https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n\nmodule.exports = function power(p, options = {}) {\n  if (p <= 0) throw new Error('power must be larger than 0');\n  if (p === 1) return this;\n  if (p === 2) {\n    return this.square();\n  }\n\n  p--;\n  let base = this.copy(); // linear time\n  while (p !== 0) {\n    if ((p & 1) !== 0) {\n      this.multiply(base, options); // executed <= log2(p) times\n    }\n    p >>= 1;\n    if (p !== 0) base.square(options); // executed <= log2(p) times\n  }\n\n  return this;\n};\n","'use strict';\n\n/**\n * Sum of Y to 1\n */\n\nmodule.exports = function normalize() {\n  let sum = 0;\n  for (let item of this.array) {\n    sum += item.y;\n  }\n  for (let item of this.array) {\n    item.y /= sum;\n  }\n  return this;\n};\n","'use strict';\n\nmodule.exports = function closestPointX(target) {\n  this.sortX();\n\n  let low = 0;\n  let high = this.array.length - 1;\n  let middle = 0;\n  while (high - low > 1) {\n    middle = low + ((high - low) >> 1);\n    if (this.array[middle].x < target) {\n      low = middle;\n    } else if (this.array[middle].x > target) {\n      high = middle;\n    } else {\n      return this.array[middle];\n    }\n  }\n\n  if (low < this.array.length - 1) {\n    if (\n      Math.abs(target - this.array[low].x) <\n      Math.abs(this.array[low + 1].x - target)\n    ) {\n      return this.array[low];\n    } else {\n      return this.array[low + 1];\n    }\n  } else {\n    return this.array[low];\n  }\n};\n","'use strict';\n\nclass Distribution {\n  constructor(array) {\n    if (Array.isArray(array)) {\n      this.array = array;\n      this.xSorted = false;\n      this.ySorted = false;\n    } else {\n      this.array = [];\n      this.xSorted = true;\n      this.ySorted = true;\n    }\n  }\n\n  get length() {\n    return this.array.length;\n  }\n\n  get xs() {\n    return this.array.map((p) => p.x);\n  }\n\n  get ys() {\n    return this.array.map((p) => p.y);\n  }\n\n  get minX() {\n    if (!this.xSorted) this.sortX();\n    return this.array[0].x;\n  }\n\n  get maxX() {\n    if (!this.xSorted) this.sortX();\n    return this.array[this.array.length - 1].x;\n  }\n\n  get minY() {\n    if (!this.ySorted) this.sortY();\n    return this.array[0].y;\n  }\n\n  get maxY() {\n    if (!this.ySorted) this.sortY();\n    return this.array[this.array.length - 1];\n  }\n}\n\nDistribution.prototype.multiplyY = function multiplyY(value) {\n  this.array.forEach((item) => (item.y *= value));\n};\n\nDistribution.prototype.setArray = function setArray(array) {\n  this.array = array;\n  this.xSorted = false;\n  this.ySorted = false;\n};\n\nDistribution.prototype.move = function move(other) {\n  this.xSorted = other.xSorted;\n  this.ySorted = other.ySorted;\n  this.array = other.array;\n};\n\nDistribution.prototype.copy = function copy() {\n  let distCopy = new this.constructor();\n  distCopy.xSorted = this.xSorted;\n  distCopy.ySorted = this.ySorted;\n  distCopy.array = JSON.parse(JSON.stringify(this.array));\n  return distCopy;\n};\n\nDistribution.prototype.push = function push(x, y) {\n  this.array.push({ x, y });\n  this.xSorted = false;\n  this.ySorted = false;\n};\n\n/**\n * Appen another distribution to the current distribution\n * @param {*} distribution\n */\nDistribution.prototype.append = function append(distribution) {\n  for (let item of distribution.array) {\n    this.array.push(item);\n  }\n  this.xSorted = false;\n  this.ySorted = false;\n};\n\nDistribution.prototype.sortX = require('./utils/sortX.js');\nDistribution.prototype.sortY = require('./utils/sortY.js');\nDistribution.prototype.join = require('./utils/join.js');\nDistribution.prototype.topY = require('./utils/topY.js');\nDistribution.prototype.maxToOne = require('./utils/maxToOne.js');\nDistribution.prototype.multiply = require('./utils/multiply.js');\nDistribution.prototype.square = require('./utils/square.js');\nDistribution.prototype.power = require('./utils/power.js');\nDistribution.prototype.normalize = require('./utils/normalize.js');\nDistribution.prototype.closestPointX = require('./utils/closestPointX.js');\n\nmodule.exports = Distribution;\n","'use strict';\n\nconst ELECTRON_MASS = require('chemical-elements').ELECTRON_MASS;\nconst SpectrumGenerator = require('spectrum-generator').SpectrumGenerator;\nconst MF = require('mf-parser').MF;\nconst getMsInfo = require('mf-utilities/src/getMsInfo');\nconst preprocessIonizations = require('mf-utilities/src/preprocessIonizations');\n\nconst Distribution = require('./Distribution');\n\n/**\n * An object containing two arrays\n * @typedef {object} XY\n * @property {Array<number>} x - The x array\n * @property {Array<number>} y - The y array\n */\n\nclass IsotopicDistribution {\n  /**\n   * Class that manage isotopic distribution\n   * @param {string|array} value - Molecular formula or an array of parts\n   * @param {object} [options={}]\n   * @param {string} [options.ionizations=''] - string containing a comma separated list of modifications\n   * @param {number} [options.fwhm=0.01] - Amount of Dalton under which 2 peaks are joined\n   * @param {number} [options.maxLines=5000] - Maximal number of lines during calculations\n   * @param {number} [options.minY=1e-8] - Minimal signal height during calculations\n   * @param {number} [options.ensureCase=false] - Ensure uppercase / lowercase\n   * @param {number} [options.allowNeutral=true] - Should we keep the distribution if the molecule has no charge\n   */\n\n  constructor(value, options = {}) {\n    if (Array.isArray(value)) {\n      this.parts = JSON.parse(JSON.stringify(value));\n      for (let part of this.parts) {\n        part.confidence = 0;\n        part.isotopesInfo = new MF(\n          `${part.mf}(${part.ionization.mf})`,\n        ).getIsotopesInfo();\n      }\n    } else {\n      let mf = new MF(value, { ensureCase: options.ensureCase });\n      let mfInfo = mf.getInfo();\n      let ionizations = preprocessIonizations(options.ionizations);\n      let parts = mfInfo.parts || [mfInfo];\n      this.parts = [];\n      for (let partOriginal of parts) {\n        // we calculate information for each part\n        for (const ionization of ionizations) {\n          let part = JSON.parse(JSON.stringify(partOriginal));\n          part.em = part.monoisotopicMass; // TODO: To remove !!! we change the name !?\n          part.isotopesInfo = new MF(\n            `${part.mf}(${ionization.mf})`,\n          ).getIsotopesInfo();\n          part.confidence = 0;\n          let msInfo = getMsInfo(part, {\n            ionization,\n          });\n          part.ionization = msInfo.ionization;\n          part.ms = msInfo.ms;\n          this.parts.push(part);\n        }\n      }\n    }\n\n    this.cachedDistribution = undefined;\n    this.fwhm = options.fwhm === undefined ? 0.01 : options.fwhm;\n    // if fwhm is under 1e-8 there are some artifacts in the spectra\n    if (this.fwhm < 1e-8) this.fwhm = 1e-8;\n    this.minY = options.minY === undefined ? 1e-8 : options.minY;\n    this.maxLines = options.maxLines || 5000;\n    this.allowNeutral =\n      options.allowNeutral === undefined ? true : options.allowNeutral;\n  }\n\n  getParts() {\n    return this.parts;\n  }\n\n  /**\n   * @return {Distribution} returns the total distribution (for all parts)\n   */\n  getDistribution() {\n    if (this.cachedDistribution) return this.cachedDistribution;\n    let options = {\n      maxLines: this.maxLines,\n      minY: this.minY,\n      deltaX: this.fwhm,\n    };\n    let finalDistribution = new Distribution();\n    this.confidence = 0;\n    // TODO need to cache each part without ionization\n    // in case of many ionization we don't need to recalculate everything !\n    for (let part of this.parts) {\n      let totalDistribution = new Distribution([\n        {\n          x: 0,\n          y: 1,\n        },\n      ]);\n      let charge = part.ms.charge;\n      let absoluteCharge = Math.abs(charge);\n      if (charge || this.allowNeutral) {\n        for (let isotope of part.isotopesInfo.isotopes) {\n          if (isotope.number < 0) return [];\n          if (isotope.number > 0) {\n            let isotopeDistribution = new Distribution(isotope.distribution);\n            isotopeDistribution.power(isotope.number, options);\n            totalDistribution.multiply(isotopeDistribution, options);\n          }\n        }\n        this.confidence += totalDistribution.array.reduce(\n          (sum, value) => sum + value.y,\n          0,\n        );\n\n        // we finally deal with the charge\n\n        if (charge) {\n          totalDistribution.array.forEach((e) => {\n            e.x = (e.x - ELECTRON_MASS * charge) / absoluteCharge;\n          });\n        }\n\n        if (totalDistribution.array) {\n          totalDistribution.sortX();\n          part.fromX = totalDistribution.array[0].x;\n          part.toX =\n            totalDistribution.array[totalDistribution.array.length - 1].x;\n        }\n\n        if (\n          part.ms.target &&\n          part.ms.target.intensity &&\n          part.ms.target.intensity !== 1\n        ) {\n          // intensity is the value of the monoisotopic mass !\n          // need to find the intensity of the peak corresponding\n          // to the monoisotopic mass\n          if (part.ms.target.mass) {\n            let target = totalDistribution.closestPointX(part.ms.target.mass);\n            totalDistribution.multiplyY(part.ms.target.intensity / target.y);\n          } else {\n            totalDistribution.multiplyY(part.ms.target.intensity);\n          }\n        } else if (part.intensity && part.intensity !== 1) {\n          totalDistribution.multiplyY(part.intensity);\n        }\n\n        part.isotopicDistribution = totalDistribution.array;\n\n        if (finalDistribution.array.length === 0) {\n          finalDistribution = totalDistribution;\n        } else {\n          finalDistribution.append(totalDistribution);\n        }\n      }\n    }\n    if (finalDistribution) finalDistribution.join(this.fwhm);\n    this.confidence /= this.parts.length;\n    this.cachedDistribution = finalDistribution;\n    return finalDistribution;\n  }\n\n  getCSV() {\n    return this.getText({ delimiter: ', ' });\n  }\n\n  getTSV() {\n    return this.getText({ delimiter: '\\t' });\n  }\n\n  getTable(options = {}) {\n    const { maxValue, xLabel = 'x', yLabel = 'y' } = options;\n    let points = this.getDistribution().array;\n    let factor = 1;\n    if (maxValue) {\n      let maxY = this.getMaxY(points);\n      factor = maxValue / maxY;\n    }\n    return points.map((point) => {\n      let newPoint = {};\n      newPoint[xLabel] = point.x;\n      newPoint[yLabel] = point.y * factor;\n      return newPoint;\n    });\n  }\n\n  getText(options = {}) {\n    const { delimiter = '\\t', numberDecimals = 3 } = options;\n    let points = this.getDistribution().array;\n    let csv = [];\n    for (let point of points) {\n      csv.push(\n        `${point.x.toFixed(5)}${delimiter}${(point.y * 100).toFixed(\n          numberDecimals,\n        )}`,\n      );\n    }\n    return csv.join('\\n');\n  }\n\n  getMaxY(points) {\n    let maxY = points[0].y;\n    for (let point of points) {\n      if (point.y > maxY) maxY = point.y;\n    }\n    return maxY;\n  }\n\n  getSumY(points) {\n    let sumY = 0;\n    for (let point of points) {\n      sumY += point.y;\n    }\n    return sumY;\n  }\n\n  /**\n   * Returns the isotopic distirubtion\n   * @param {object} [options={}]\n   * @param {number} [options.maxValue=100]\n   * @param {number} [options.sumValue] // if sumValue is defined, maxValue is ignored\n   * @return {XY} an object containing 2 properties: x:[] and y:[]\n   */\n  getXY(options = {}) {\n    const { maxValue = 100, sumValue } = options;\n    let points = this.getDistribution().array;\n    if (points.length === 0) return [];\n    let factor = 1;\n    if (sumValue) {\n      let sumY = this.getSumY(points);\n      factor = sumY / sumValue;\n    } else if (maxValue) {\n      let maxY = this.getMaxY(points);\n      factor = maxY / maxValue;\n    }\n\n    return {\n      x: points.map((a) => a.x),\n      y: points.map((a) => a.y / factor),\n    };\n  }\n\n  /**\n   * Returns the isotopic distribution as the sum of gaussian\n   * @param {object} [options={}]\n   * @param {number} [options.gaussianWidth=10]\n   * @param {number} [options.threshold=0.00001] // minimal height to return point\n   * @param {number} [options.maxLength=1e6] // minimal height to return point\n   * @param {number} [options.maxValue] // rescale Y to reach maxValue\n   * @param {function} [options.peakWidthFct=(mz)=>(this.fwhm)]\n   * @return {XY} isotopic distribution as an object containing 2 properties: x:[] and y:[]\n   */\n\n  getGaussian(options = {}) {\n    const {\n      peakWidthFct = () => this.fwhm,\n      threshold = 0.00001,\n      gaussianWidth = 10,\n      maxValue,\n      maxLength = 1e6,\n    } = options;\n\n    let points = this.getTable({ maxValue });\n    if (points.length === 0) return { x: [], y: [] };\n    const from = Math.floor(options.from || points[0].x - 2);\n    const to = Math.ceil(options.to || points[points.length - 1].x + 2);\n    const nbPoints = Math.round(((to - from) * gaussianWidth) / this.fwhm + 1);\n    if (nbPoints > maxLength) {\n      throw Error(\n        `Number of points is over the maxLength: ${nbPoints}>${maxLength}`,\n      );\n    }\n    let gaussianOptions = {\n      from,\n      to,\n      nbPoints,\n      peakWidthFct,\n    };\n\n    let spectrumGenerator = new SpectrumGenerator(gaussianOptions);\n    for (let point of points) {\n      spectrumGenerator.addPeak([point.x, point.y]);\n    }\n    let spectrum = spectrumGenerator.getSpectrum({ threshold });\n    return spectrum;\n  }\n}\n\nmodule.exports = IsotopicDistribution;\n","'use strict';\n\nconst IsotopicDistribution = require('./IsotopicDistribution');\n\nmodule.exports = IsotopicDistribution;\n","'use strict';\n\n/**\n * @param {object}   [entry={}}]\n * @param {object}   [options={}}]\n * @param {number}   [options.min=-Infinity] - Minimal unsaturation\n * @param {number}   [options.max=+Infinity] - Maximal unsaturation\n * @param {number}   [options.onlyInteger=false] - Integer unsaturation\n * @param {number}   [options.onlyNonInteger=false] - Non integer unsaturation\n * @return {boolean}\n */\n\nmodule.exports = function unsaturationMatcher(entry, options = {}) {\n  const {\n    min = Number.MIN_SAFE_INTEGER,\n    max = Number.MAX_SAFE_INTEGER,\n    onlyInteger,\n    onlyNonInteger,\n  } = options;\n\n  if (entry.unsaturation !== undefined) {\n    if (entry.unsaturation < min || entry.unsaturation > max) return false;\n    if (onlyInteger && !Number.isInteger(entry.unsaturation)) return false;\n    if (onlyNonInteger && Number.isInteger(entry.unsaturation)) return false;\n  }\n  return true;\n};\n","'use strict';\n\n/**\n * Returns true if the entry containing MF information match\n * @param {object}   [entry={}}] - object containing mw, ...\n * @param {object}   [options={}}]\n * @param {number}   [options.minMW=0] - Minimal molecular weight\n * @param {number}   [options.maxMW=+Infinity] - Maximal molecular weight\n * @param {number}   [options.minEM=0] - Minimal monoisotopic mass\n * @param {number}   [options.maxEM=+Infinity] - Maximal monoisotopic mass\n * @param {number}   [options.minCharge=-Infinity] - Minimal charge\n * @param {number}   [options.maxCharge=+Infinity] - Maximal charge\n * @param {object}   [options.unsaturation={}}]\n * @param {number}   [options.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number}   [options.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {number}   [options.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {number}   [options.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {object}   [options.atoms] - object of atom:{min, max}\n * @return {boolean}\n */\n\nmodule.exports = function generalMatcher(entry, options = {}) {\n  const {\n    minMW = 0,\n    maxMW = +Infinity,\n    minEM = 0,\n    maxEM = +Infinity,\n    minCharge = Number.MIN_SAFE_INTEGER,\n    maxCharge = Number.MAX_SAFE_INTEGER,\n    unsaturation = {},\n    atoms,\n  } = options;\n\n  if (entry.mw !== undefined) {\n    if (entry.mw < minMW || entry.mw > maxMW) return false;\n  }\n\n  if (entry.em !== undefined) {\n    if (entry.em < minEM || entry.em > maxEM) return false;\n  }\n\n  if (entry.charge !== undefined) {\n    if (entry.charge < minCharge || entry.charge > maxCharge) return false;\n  }\n\n  if (unsaturation !== undefined && entry.unsaturation !== undefined) {\n    if (!require('./unsaturationMatcher')(entry, unsaturation)) return false;\n  }\n\n  if (entry.atoms !== undefined && atoms) {\n    // all the atoms of the entry must fit in the range\n    for (let atom of Object.keys(entry.atoms)) {\n      if (!atoms[atom]) return false;\n      if (entry.atoms[atom] < atoms[atom].min) return false;\n      if (entry.atoms[atom] > atoms[atom].max) return false;\n    }\n  }\n  return true;\n};\n","/**\n * This function returns an array with absolute values\n * @param {Array<Number>} array\n * @return {Number}\n */\nexport function xAbsolute(array) {\n  let tmpArray = array.slice();\n  for (let i = 0; i < tmpArray.length; i++) {\n    if (tmpArray[i] < 0) tmpArray[i] *= -1;\n  }\n\n  return tmpArray;\n}\n","import median from 'ml-array-median';\n\nimport { xAbsolute } from './xAbsolute';\n/**\n * This function calculates the median after taking the reimAbsolute values of the points\n * @param {Array<Number>} array - the array that will be rotated\n * @return {Number}\n */\nexport function xAbsoluteMedian(array) {\n  return median(xAbsolute(array));\n}\n","import isAnyArray from 'is-any-array';\n\n/**\n * This function xAdd the first array by the second array or a constant value to each element of the first array\n * @param {Array<Number>} array1 - the array that will be rotated\n * @param {Array|Number} array2\n * @return {Array}\n */\nexport function xAdd(array1, array2) {\n  let isConstant = false;\n  let constant;\n  if (isAnyArray(array2)) {\n    if (array1.length !== array2.length) {\n      throw new Error('sub: size of array1 and array2 must be identical');\n    }\n  } else {\n    isConstant = true;\n    constant = Number(array2);\n  }\n\n  let array3 = new Array(array1.length);\n  if (isConstant) {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] + constant;\n    }\n  } else {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] + array2[i];\n    }\n  }\n\n  return array3;\n}\n","import isAnyArray from 'is-any-array';\n/**\n * This function xMultiply the first array by the second array or a constant value to each element of the first array\n * @param {Array} array1 - the array that will be rotated\n * @param {Array|Number} array2\n * @return {Float64Array}\n */\nexport function xMultiply(array1, array2) {\n  let isConstant = false;\n  let constant;\n  if (isAnyArray(array2)) {\n    if (array1.length !== array2.length) {\n      throw new Error('sub: size of array1 and array2 must be identical');\n    }\n  } else {\n    isConstant = true;\n    constant = Number(array2);\n  }\n\n  let array3 = new Float64Array(array1.length);\n  if (isConstant) {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] * constant;\n    }\n  } else {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] * array2[i];\n    }\n  }\n\n  return array3;\n}\n","import { xMultiply } from './xMultiply';\n\nexport function xDotProduct(A, B) {\n  let g = xMultiply(A, B);\n  let result = 0;\n  for (let i = 0; i < A.length; i++) {\n    result += g[i];\n  }\n  return result;\n}\n","import { xDotProduct } from './xDotProduct';\n\n/**\n * Calculates the cross-correlation between 2 vectors\n * @param {Array<Number>} [A] - fixed array\n * @param {Array<Number>} [B] - sweeping array\n * @param {object} [options={}]\n * @param {number} [options.tau=1] - sweep increment size (in number of points, min=1, max=A.length)\n * @param {number} [options.lag=A.length - 1] - scalar lag parameter\n */\n\nexport function xCrossCorrelation(A, B, options = {}) {\n  let { tau = 1, lag = A.length - 1 } = options;\n  let result = new Float64Array(1 + (2 * lag) / tau);\n  if (A.length === B.length) {\n    let n = B.length;\n    let g = new Float64Array(2 * n);\n    let q = new Float64Array(2 * n);\n    for (let i = 0; i < n; i++) {\n      q[n + i] = B[i];\n    }\n    for (let i = n * 2 - (tau - 1); i > 0; i -= tau) {\n      let k = 0;\n      for (let j = i; j < n * 2; j++) {\n        g[k] = q[j];\n        k++;\n      }\n      let w = [];\n      for (let l = 0; l < n; l++) {\n        w[l] = g[l];\n      }\n      result[(k - (n - lag)) / tau] = xDotProduct(A, w);\n    }\n  }\n  return result;\n}\n","import { xCrossCorrelation } from './xCrossCorrelation';\n\n/**\n * Calculates the auto-correlation of a vector\n * @param {Array<Number>} [A] - the array that will be fixed\n * @param {object} [options={}]\n * @param {number} [options.tau=1] - sweep increment size (in number of points, min=1, max=A.length)\n * @param {number} [options.lag=A.length - 1] - scalar lag parameter\n */\n\nexport function xAutoCorrelation(A, options = {}) {\n  return xCrossCorrelation(A, A, options);\n}\n","/**\n * This function xSubtract the first array by the second array or a constant value from each element of the first array\n * @param {Array<Number>} array1 - the array that will be rotated\n * @return {object}\n */\nexport function xBoxPlot(array) {\n  array = array.slice(0).sort((a, b) => a - b);\n  if (array.length < 5) {\n    throw Error(\n      'xBoxPlot: can not calculate info if array contains less than 3 elements',\n    );\n  }\n  let info = {\n    Q1: 0.0,\n    Q2: 0.0,\n    Q3: 0.0,\n    min: array[0],\n    max: array[array.length - 1],\n  };\n  let q1max, q3min;\n  if (array.length % 2 === 1) {\n    // odd\n    let middle = (array.length - 1) / 2;\n    info.Q2 = array[middle];\n    q1max = middle - 1;\n    q3min = middle + 1;\n  } else {\n    // even\n    q3min = array.length / 2;\n    q1max = q3min - 1;\n    info.Q2 = (array[q1max] + array[q3min]) / 2;\n  }\n  if (q1max % 2 === 0) {\n    info.Q1 = array[q1max / 2];\n    info.Q3 = array[(array.length + q3min - 1) / 2];\n  } else {\n    info.Q1 = (array[(q1max + 1) / 2] + array[(q1max - 1) / 2]) / 2;\n    let middleOver = (array.length + q3min) / 2;\n    info.Q3 = (array[middleOver] + array[middleOver - 1]) / 2;\n  }\n  return info;\n}\n","/**\n\n/**\n * Calculates the correlation between 2 vectors\n * https://en.wikipedia.org/wiki/Correlation_and_dependence\n *\n * @param {Array<Number>} [A] - the array that will be rotated\n * @param {Array<Number>} [B]\n * @return {Array}\n */\nexport function xCorrelation(A, B) {\n  let n = A.length;\n  let sumA = 0;\n  let sumA2 = 0;\n  let sumB = 0;\n  let sumB2 = 0;\n  let sumAB = 0;\n  for (let i = 0; i < n; i++) {\n    let a = A[i];\n    let b = B[i];\n    sumA += a;\n    sumA2 += a ** 2;\n    sumB += b;\n    sumB2 += b ** 2;\n    sumAB += a * b;\n  }\n  return (\n    (n * sumAB - sumA * sumB) /\n    (Math.sqrt(n * sumA2 - sumA ** 2) * Math.sqrt(n * sumB2 - sumB ** 2))\n  );\n}\n","import isArray from 'is-any-array';\n\n/**\n * Calculate a new array of the same size that is the cumulative values\n * @param {Array<number>} isArray\n * @returns {Array<number}\n */\nexport function xCumulative(array) {\n  if (!isArray(array)) {\n    throw new TypeError('input must be an array');\n  }\n\n  let newArray = new Float64Array(array.length);\n  if (array.length < 1) return newArray;\n\n  newArray[0] = array[0];\n  for (let i = 1; i < array.length; i++) {\n    newArray[i] = newArray[i - 1] + array[i];\n  }\n  return newArray;\n}\n","import isAnyArray from 'is-any-array';\n\n/**\n * This function divide the first array by the second array or a constant value to each element of the first array\n * @param {Array<Number>} array1 - the array that will be rotated\n * @param {Array<Number>|Number} array2\n * @return {Array}\n */\nexport function xDivide(array1, array2) {\n  let isConstant = false;\n  let constant;\n  if (isAnyArray(array2)) {\n    if (array1.length !== array2.length) {\n      throw new Error('sub: size of array1 and array2 must be identical');\n    }\n  } else {\n    isConstant = true;\n    constant = Number(array2);\n  }\n\n  let array3 = new Array(array1.length);\n  if (isConstant) {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] / constant;\n    }\n  } else {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] / array2[i];\n    }\n  }\n\n  return array3;\n}\n","/**\n * Returns the closest index of a `target` in an ordered array\n * @param {array<Number>} array\n * @param {number} target\n */\n\nexport function xFindClosestIndex(array, target) {\n  let low = 0;\n  let high = array.length - 1;\n  let middle = 0;\n  while (high - low > 1) {\n    middle = low + ((high - low) >> 1);\n    if (array[middle] < target) {\n      low = middle;\n    } else if (array[middle] > target) {\n      high = middle;\n    } else {\n      return middle;\n    }\n  }\n\n  if (low < array.length - 1) {\n    if (Math.abs(target - array[low]) < Math.abs(array[low + 1] - target)) {\n      return low;\n    } else {\n      return low + 1;\n    }\n  } else {\n    return low;\n  }\n}\n","import { xFindClosestIndex } from './xFindClosestIndex';\n\n/**\n * Returns an object with {fromIndex, toIndex} for a specific from / to\n * @param {array} x\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n */\n\nexport function xGetFromToIndex(x, options = {}) {\n  let { fromIndex, toIndex, from, to } = options;\n\n  if (fromIndex === undefined) {\n    if (from !== undefined) {\n      fromIndex = xFindClosestIndex(x, from);\n    } else {\n      fromIndex = 0;\n    }\n  }\n  if (toIndex === undefined) {\n    if (to !== undefined) {\n      toIndex = xFindClosestIndex(x, to);\n    } else {\n      toIndex = x.length - 1;\n    }\n  }\n  if (fromIndex > toIndex) [fromIndex, toIndex] = [toIndex, fromIndex];\n  return { fromIndex, toIndex };\n}\n","import { xFindClosestIndex } from './xFindClosestIndex';\n\n/**\n *  Returns the targetIndex\n * @param {array} [x]\n * @param {object} [options={}]\n * @param {number} [options.target]\n * @param {number} [options.targetIndex=0]\n * @param {number}\n */\n\nexport function xGetTargetIndex(x, options = {}) {\n  let { target, targetIndex } = options;\n  if (targetIndex === undefined) {\n    if (target !== undefined) {\n      return xFindClosestIndex(x, target);\n    } else {\n      return 0;\n    }\n  }\n  return targetIndex;\n}\n","import isArray from 'is-any-array';\n\n/**\n * Checks if input is valdi\n * @param {Array<number>} input\n\n */\nexport function xCheck(input) {\n  if (!isArray(input)) {\n    throw new TypeError('input must be an array');\n  }\n\n  if (input.length === 0) {\n    throw new TypeError('input must not be empty');\n  }\n}\n\nexport function xCheckLengths(array1, array2) {\n  if (array1.length !== array2.length) {\n    throw new TypeError('Length of array1 and array2 must be identical');\n  }\n}\n","import { xCheck } from './xCheck';\n\n/**\n * Computes the maximal value of an array of values\n * @param {Array<number>} array\n * @param {object} [options={}]\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number}\n */\nexport function xMaxValue(array, options = {}) {\n  xCheck(array);\n  const { fromIndex = 0, toIndex = array.length - 1 } = options;\n  let maxValue = array[fromIndex];\n\n  for (let i = fromIndex + 1; i <= toIndex; i++) {\n    if (array[i] > maxValue) {\n      maxValue = array[i];\n    }\n  }\n  return maxValue;\n}\n","import { xCheck } from './xCheck';\n\n/**\n * Computes the minimal value of an array of values\n * @param {Array<number>} array\n * @param {object} [options={}]\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number}\n */\nexport function xMinValue(array, options = {}) {\n  xCheck(array);\n  const { fromIndex = 0, toIndex = array.length - 1 } = options;\n  let minValue = array[fromIndex];\n\n  for (let i = fromIndex + 1; i <= toIndex; i++) {\n    if (array[i] < minValue) {\n      minValue = array[i];\n    }\n  }\n  return minValue;\n}\n","import fill from 'ml-array-sequential-fill';\n\nimport { xAbsolute } from './xAbsolute';\nimport { xCheck } from './xCheck';\nimport { xMaxValue } from './xMaxValue';\nimport { xMinValue } from './xMinValue';\n\n/**\n * Calculates an histogram of defined number of slots\n * @param {array} [array] Array containing values\n * @param {number} [options.nbSlots=256] Number of slots\n * @param {number} [options.min=minValue] Minimum value to calculate used to calculate slot size\n * @param {number} [options.max=maxValue] Maximal value to calculate used to calculate slot size\n * @param {number} [options.logBaseX] We can first apply a log on x axis\n * @param {number} [options.logBaseY] We can apply a log on the resulting histogram\n * @param {boolean} [options.absolute] Take the absolute value\n * @param {number} [options.centerX=true] Center the X value. We will enlarge the first and last values.\n * @param {DataXY} [options.histogram={x:[], y:[]}] Previously existing histogram to continue to fill\n * @return {DataXY} {x,y} of the histogram\n */\n\nexport function xHistogram(array, options = {}) {\n  xCheck(array);\n  let histogram = options.histogram;\n  const {\n    centerX = true,\n    nbSlots = histogram === undefined ? 256 : histogram.x.length,\n    logBaseX,\n    logBaseY,\n    absolute = false,\n  } = options;\n\n  if (absolute) {\n    array = xAbsolute(array);\n  }\n\n  if (logBaseX) {\n    array = array.slice();\n    const logOfBase = Math.log10(logBaseX);\n    for (let i = 0; i < array.length; i++) {\n      array[i] = Math.log10(array[i]) / logOfBase;\n    }\n  }\n\n  const { min = xMinValue(array), max = xMaxValue(array) } = options;\n  const slotSize = (max - min) / (nbSlots + Number.EPSILON);\n\n  const y = histogram === undefined ? new Float64Array(nbSlots) : histogram.y;\n  const x =\n    histogram === undefined\n      ? fill({\n          from: min + (centerX ? slotSize / 2 : 0),\n          to: max - (centerX ? slotSize / 2 : 0),\n          size: nbSlots,\n        })\n      : histogram.x;\n  for (let i = 0; i < array.length; i++) {\n    const index = Math.max(\n      Math.min(\n        ((array[i] - min - Number.EPSILON) / slotSize) >> 0,\n        nbSlots - 1,\n      ),\n      0,\n    );\n    y[index]++;\n  }\n\n  if (logBaseY) {\n    const logOfBase = Math.log10(logBaseY);\n    for (let i = 0; i < y.length; i++) {\n      y[i] = Math.log10(y[i] + 1) / logOfBase;\n    }\n  }\n\n  return { x, y };\n}\n","/**\n * Returns true if x is monotone\n * @param {Array} array\n * @return {boolean}\n */\nexport function xIsMonotone(array) {\n  if (array.length <= 2) {\n    return true;\n  }\n  if (array[0] === array[1]) {\n    // maybe a constant series\n    for (let i = 1; i < array.length - 1; i++) {\n      if (array[i] !== array[i + 1]) return false;\n    }\n    return true;\n  }\n\n  if (array[0] < array[array.length - 1]) {\n    for (let i = 0; i < array.length - 1; i++) {\n      if (array[i] >= array[i + 1]) return false;\n    }\n  } else {\n    for (let i = 0; i < array.length - 1; i++) {\n      if (array[i] <= array[i + 1]) return false;\n    }\n  }\n  return true;\n}\n","import { xCheck } from './xCheck';\n/**\n * Computes the index of the maximum of the given values\n * @param {Array<number>} array\n * @return {number}\n */\nexport function xMaxIndex(array) {\n  xCheck(array);\n\n  let maxIndex = 0;\n\n  for (let i = 1; i < array.length; i++) {\n    if (array[i] > array[maxIndex]) {\n      maxIndex = i;\n    }\n  }\n  return maxIndex;\n}\n","import { xCheck } from './xCheck';\n\n/**\n * Computes the maximal value of an array of values\n * @param {Array<number>} array\n * @param {object} [options={}]\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number}\n */\nexport function xMean(array, options = {}) {\n  xCheck(array);\n  const { fromIndex = 0, toIndex = array.length - 1 } = options;\n  let sumValue = array[fromIndex];\n\n  for (let i = fromIndex + 1; i <= toIndex; i++) {\n    sumValue += array[i];\n  }\n  return sumValue / (toIndex - fromIndex + 1);\n}\n","import { xCheck } from './xCheck';\n\n/**\n * Computes the index of the minimum of the given values\n * @param {Array<number>} array\n * @return {number}\n */\nexport function xMinIndex(array) {\n  xCheck(array);\n  let minIndex = 0;\n  for (let i = 1; i < array.length; i++) {\n    if (array[i] < array[minIndex]) {\n      minIndex = i;\n    }\n  }\n  return minIndex;\n}\n","import { xCheck } from './xCheck';\n\n/**\nimport { xCheck } from './xCheck';\n * return min and max values of an array\n * @param {Array<number>} array\n * @returns {object} Object with 2 properties, min and max\n */\nexport function xMinMaxValues(array) {\n  xCheck(array);\n\n  let min = array[0];\n  let max = array[0];\n\n  for (let value of array) {\n    if (value < min) min = value;\n    if (value > max) max = value;\n  }\n\n  return { min, max };\n}\n","/* eslint-disable no-loss-of-precision */\n\n/*\nAdapted from: https://github.com/compute-io/erfcinv/blob/aa116e23883839359e310ad41a7c42f72815fc1e/lib/number.js\n\nThe MIT License (MIT)\n\nCopyright (c) 2014-2015 The Compute.io Authors. All rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\nBoost Software License - Version 1.0 - August 17th, 2003\n\nPermission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the \"Software\") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:\n\nThe copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n// Coefficients for erfcinv on [0, 0.5]:\nconst Y1 = 8.91314744949340820313e-2;\nconst P1 = [\n  -5.38772965071242932965e-3, 8.22687874676915743155e-3,\n  2.19878681111168899165e-2, -3.65637971411762664006e-2,\n  -1.26926147662974029034e-2, 3.34806625409744615033e-2,\n  -8.36874819741736770379e-3, -5.08781949658280665617e-4,\n];\nconst Q1 = [\n  8.86216390456424707504e-4, -2.33393759374190016776e-3,\n  7.95283687341571680018e-2, -5.27396382340099713954e-2,\n  -7.1228902341542847553e-1, 6.62328840472002992063e-1, 1.56221558398423026363,\n  -1.56574558234175846809, -9.70005043303290640362e-1, 1,\n];\n\n// Coefficients for erfcinv for 0.5 > 1-x >= 0:\nconst Y2 = 2.249481201171875;\nconst P2 = [\n  -3.67192254707729348546, 2.11294655448340526258e1, 1.7445385985570866523e1,\n  -4.46382324441786960818e1, -1.88510648058714251895e1,\n  1.76447298408374015486e1, 8.37050328343119927838, 1.05264680699391713268e-1,\n  -2.02433508355938759655e-1,\n];\nconst Q2 = [\n  1.72114765761200282724, -2.26436933413139721736e1, 1.08268667355460159008e1,\n  4.85609213108739935468e1, -2.01432634680485188801e1,\n  -2.86608180499800029974e1, 3.9713437953343869095, 6.24264124854247537712, 1,\n];\n\n// Coefficients for erfcinv for sqrt( -log(1-x)):\nconst Y3 = 8.07220458984375e-1;\nconst P3 = [\n  -6.81149956853776992068e-10, 2.85225331782217055858e-8,\n  -6.79465575181126350155e-7, 2.14558995388805277169e-3,\n  2.90157910005329060432e-2, 1.42869534408157156766e-1,\n  3.37785538912035898924e-1, 3.87079738972604337464e-1,\n  1.17030156341995252019e-1, -1.63794047193317060787e-1,\n  -1.31102781679951906451e-1,\n];\nconst Q3 = [\n  1.105924229346489121e-2, 1.52264338295331783612e-1, 8.48854343457902036425e-1,\n  2.59301921623620271374, 4.77846592945843778382, 5.38168345707006855425,\n  3.46625407242567245975, 1,\n];\n\nconst Y4 = 9.3995571136474609375e-1;\nconst P4 = [\n  2.66339227425782031962e-12, -2.30404776911882601748e-10,\n  4.60469890584317994083e-6, 1.57544617424960554631e-4,\n  1.87123492819559223345e-3, 9.50804701325919603619e-3,\n  1.85573306514231072324e-2, -2.22426529213447927281e-3,\n  -3.50353787183177984712e-2,\n];\nconst Q4 = [\n  7.64675292302794483503e-5, 2.63861676657015992959e-3,\n  3.41589143670947727934e-2, 2.20091105764131249824e-1,\n  7.62059164553623404043e-1, 1.3653349817554063097, 1,\n];\n\nconst Y5 = 9.8362827301025390625e-1;\nconst P5 = [\n  9.9055709973310326855e-17, -2.81128735628831791805e-14,\n  4.62596163522878599135e-9, 4.49696789927706453732e-7,\n  1.49624783758342370182e-5, 2.09386317487588078668e-4,\n  1.05628862152492910091e-3, -1.12951438745580278863e-3,\n  -1.67431005076633737133e-2,\n];\nconst Q5 = [\n  2.82243172016108031869e-7, 2.75335474764726041141e-5,\n  9.64011807005165528527e-4, 1.60746087093676504695e-2,\n  1.38151865749083321638e-1, 5.91429344886417493481e-1, 1,\n];\n\nfunction polyval(c, x) {\n  let p = 0;\n  for (const coef of c) {\n    p = p * x + coef;\n  }\n  return p;\n}\n\n/**\n * Calculates a rational approximation.\n *\n * @private\n * @param {Number} x\n * @param {Number} v\n * @param {Array} P - array of polynomial coefficients\n * @param {Array} Q - array of polynomial coefficients\n * @param {Number} Y\n * @returns {Number} rational approximation\n */\nfunction calc(x, v, P, Q, Y) {\n  const s = x - v;\n  const r = polyval(P, s) / polyval(Q, s);\n  return Y * x + r * x;\n}\n\n/**\n * Evaluates the complementary inverse error function for an input value.\n *\n * @private\n * @param {Number} x - input value\n * @returns {Number} evaluated complementary inverse error function\n */\nexport default function erfcinv(x) {\n  let sign = false;\n  let val;\n  let q;\n  let g;\n  let r;\n\n  // [1] Special cases...\n\n  // NaN:\n  if (Number.isNaN(x)) {\n    return NaN;\n  }\n  // x not on the interval: [0,2]\n  if (x < 0 || x > 2) {\n    throw new RangeError(\n      `erfcinv()::invalid input argument. Value must be on the interval [0,2]. Value: \\`${x}\\`.`,\n    );\n  }\n  if (x === 0) {\n    return Number.POSITIVE_INFINITY;\n  }\n  if (x === 2) {\n    return Number.NEGATIVE_INFINITY;\n  }\n  if (x === 1) {\n    return 0;\n  }\n  // [2] Get the sign and make use of `erfc` reflection formula: `erfc(-z)=2 - erfc(z)`...\n  if (x > 1) {\n    q = 2 - x;\n    x = 1 - q;\n    sign = true;\n  } else {\n    q = x;\n    x = 1 - x;\n  }\n  // [3] |x| <= 0.5\n  if (x <= 0.5) {\n    g = x * (x + 10);\n    r = polyval(P1, x) / polyval(Q1, x);\n    val = g * Y1 + g * r;\n    return sign ? -val : val;\n  }\n\n  // [4] 1-|x| >= 0.25\n  if (q >= 0.25) {\n    g = Math.sqrt(-2 * Math.log(q));\n    q = q - 0.25;\n    r = polyval(P2, q) / polyval(Q2, q);\n    val = g / (Y2 + r);\n    return sign ? -val : val;\n  }\n  q = Math.sqrt(-Math.log(q));\n\n  // [5] q < 3\n  if (q < 3) {\n    return calc(q, 1.125, P3, Q3, Y3);\n  }\n  // [6] q < 6\n  if (q < 6) {\n    return calc(q, 3, P4, Q4, Y4);\n  }\n  // Note that the smallest number in JavaScript is 5e-324. Math.sqrt( -Math.log( 5e-324 ) ) ~27.2844\n  return calc(q, 6, P5, Q5, Y5);\n\n  // Note that in the boost library, they are able to go to much smaller values, as 128 bit long doubles support ~1e-5000; something which JavaScript does not natively support.\n}\n","export default function rayleighCdf(x, sigma = 1) {\n  if (x < 0) {\n    return 0;\n  }\n  return -Math.expm1(-Math.pow(x, 2) / (2 * Math.pow(sigma, 2)));\n}\n","import fill from 'ml-array-sequential-fill';\nimport SplineInterpolator from 'spline-interpolator';\n\nimport erfcinv from './erfcinv';\nimport rayleighCdf from './rayleighCdf';\n\n/**\n * Determine noise level by san plot methodology (https://doi.org/10.1002/mrc.4882)\n * @param {Array} data - real or magnitude spectra data.\n * @param {object} [options = {}]\n * @param {array} [options.mask] - boolean array to filter data, if the i-th element is true then the i-th element of the distribution will be ignored.\n * @param {number} [options.scaleFactor=1] - factor to scale the data input[i]*=scaleFactor.\n * @param {number} [options.cutOff] - percent of positive signal distribution where the noise level will be determined, if it is not defined the program calculate it.\n * @param {number} [options.factorStd=5] - factor times std to determine what will be marked as signals.\n * @param {boolean} [options.refine=true] - if true the noise level will be recalculated get out the signals using factorStd.\n * @param {boolean} [options.fixOffset=true] - If the baseline is correct, the midpoint of distribution should be zero. if true, the distribution will be centered.\n * @param {number} [options.logBaseY=2] - log scale to apply in the intensity axis in order to avoid big numbers.\n */\n\nexport function xNoiseSanPlot(data, options = {}) {\n  const {\n    mask,\n    cutOff,\n    refine = true,\n    magnitudeMode = false,\n    scaleFactor = 1,\n    factorStd = 5,\n    fixOffset = true,\n  } = options;\n\n  let input;\n  if (Array.isArray(mask) && mask.length === data.length) {\n    input = new Float64Array(data.filter((_e, i) => !mask[i]));\n  } else {\n    input = new Float64Array(data);\n  }\n\n  if (scaleFactor > 1) {\n    for (let i = 0; i < input.length; i++) {\n      input[i] *= scaleFactor;\n    }\n  }\n  input = input.sort().reverse();\n\n  if (fixOffset && !magnitudeMode) {\n    let medianIndex = Math.floor(input.length / 2);\n    let median = 0.5 * (input[medianIndex] + input[medianIndex + 1]);\n    for (let i = 0; i < input.length; i++) {\n      input[i] -= median;\n    }\n  }\n\n  let firstNegativeValueIndex =\n    input[input.length - 1] >= 0 ? input.length : input.findIndex((e) => e < 0);\n  let lastPositiveValueIndex = firstNegativeValueIndex - 1;\n  for (let i = lastPositiveValueIndex; i >= 0; i--) {\n    if (input[i] > 0) {\n      lastPositiveValueIndex = i;\n      break;\n    }\n  }\n\n  let signPositive = input.slice(0, lastPositiveValueIndex + 1);\n  let signNegative = input.slice(firstNegativeValueIndex);\n\n  let cutOffDist = cutOff || determineCutOff(signPositive, { magnitudeMode });\n\n  let pIndex = Math.floor(signPositive.length * cutOffDist);\n  let initialNoiseLevelPositive = signPositive[pIndex];\n\n  let skyPoint = signPositive[0];\n\n  let initialNoiseLevelNegative;\n  if (signNegative.length > 0) {\n    let nIndex = Math.floor(signNegative.length * (1 - cutOffDist));\n    initialNoiseLevelNegative = -1 * signNegative[nIndex];\n  } else {\n    initialNoiseLevelNegative = 0;\n  }\n\n  let noiseLevelPositive = initialNoiseLevelPositive;\n  let noiseLevelNegative = initialNoiseLevelNegative;\n  let cloneSignPositive = signPositive.slice();\n  let cloneSignNegative = signNegative.slice();\n\n  let cutOffSignalsIndexPlus = 0;\n  let cutOffSignalsIndexNeg = 2;\n  if (refine) {\n    let cutOffSignals = noiseLevelPositive * factorStd;\n    cutOffSignalsIndexPlus = signPositive.findIndex((e) => e < cutOffSignals);\n\n    if (cutOffSignalsIndexPlus > -1) {\n      cloneSignPositive = signPositive.slice(cutOffSignalsIndexPlus);\n      noiseLevelPositive =\n        cloneSignPositive[Math.floor(cloneSignPositive.length * cutOffDist)];\n    }\n\n    cutOffSignals = noiseLevelNegative * factorStd;\n    cutOffSignalsIndexNeg = signNegative.findIndex((e) => e < cutOffSignals);\n    if (cutOffSignalsIndexNeg > -1) {\n      cloneSignNegative = signNegative.slice(cutOffSignalsIndexNeg);\n      noiseLevelNegative =\n        cloneSignPositive[\n          Math.floor(cloneSignNegative.length * (1 - cutOffDist))\n        ];\n    }\n  }\n  let correctionFactor = -simpleNormInv(cutOffDist / 2, { magnitudeMode });\n  initialNoiseLevelPositive = initialNoiseLevelPositive / correctionFactor;\n  initialNoiseLevelNegative = initialNoiseLevelNegative / correctionFactor;\n\n  let effectiveCutOffDist, refinedCorrectionFactor;\n\n  if (refine && cutOffSignalsIndexPlus > -1) {\n    effectiveCutOffDist =\n      (cutOffDist * cloneSignPositive.length + cutOffSignalsIndexPlus) /\n      (cloneSignPositive.length + cutOffSignalsIndexPlus);\n    refinedCorrectionFactor =\n      -1 * simpleNormInv(effectiveCutOffDist / 2, { magnitudeMode });\n\n    noiseLevelPositive /= refinedCorrectionFactor;\n\n    if (cutOffSignalsIndexNeg > -1) {\n      effectiveCutOffDist =\n        (cutOffDist * cloneSignNegative.length + cutOffSignalsIndexNeg) /\n        (cloneSignNegative.length + cutOffSignalsIndexNeg);\n      refinedCorrectionFactor =\n        -1 * simpleNormInv(effectiveCutOffDist / 2, { magnitudeMode });\n      if (noiseLevelNegative !== 0) {\n        noiseLevelNegative /= refinedCorrectionFactor;\n      }\n    }\n  } else {\n    noiseLevelPositive /= correctionFactor;\n    noiseLevelNegative /= correctionFactor;\n  }\n\n  return {\n    positive: noiseLevelPositive,\n    negative: noiseLevelNegative,\n    snr: skyPoint / noiseLevelPositive,\n    sanplot: generateSanPlot(input, {\n      fromTo: {\n        positive: { from: 0, to: lastPositiveValueIndex },\n        negative: { from: firstNegativeValueIndex, to: input.length },\n      },\n    }),\n  };\n}\n\nfunction determineCutOff(signPositive, options = {}) {\n  let {\n    magnitudeMode = false,\n    considerList = { from: 0.5, step: 0.1, to: 0.9 },\n  } = options;\n  //generate a list of values for\n  let cutOff = [];\n  let indexMax = signPositive.length - 1;\n  for (let i = 0.01; i <= 0.99; i += 0.01) {\n    let index = Math.round(indexMax * i);\n    let value =\n      -signPositive[index] / simpleNormInv([i / 2], { magnitudeMode });\n    cutOff.push([i, value]);\n  }\n\n  let minKi = Number.MAX_SAFE_INTEGER;\n  let { from, to, step } = considerList;\n  let delta = step / 2;\n  let whereToCutStat = 0.5;\n  for (let i = from; i <= to; i += step) {\n    let floor = i - delta;\n    let top = i + delta;\n    let elementsOfCutOff = cutOff.filter((e) => e[0] < top && e[0] > floor);\n    let averageValue = elementsOfCutOff.reduce((a, b) => a + Math.abs(b[1]), 0);\n    let kiSqrt = 0;\n    for (let j = 0; j < elementsOfCutOff.length; j++) {\n      kiSqrt += Math.pow(elementsOfCutOff[j][1] - averageValue, 2);\n    }\n\n    if (kiSqrt < minKi) {\n      minKi = kiSqrt;\n      whereToCutStat = i;\n    }\n  }\n\n  return whereToCutStat;\n}\n\nfunction simpleNormInv(data, options = {}) {\n  const { magnitudeMode = false } = options;\n\n  if (!Array.isArray(data)) data = [data];\n\n  let from = 0;\n  let to = 2;\n  let step = 0.01;\n  let xTraining = createArray(from, to, step);\n\n  let result = new Float64Array(data.length);\n  let yTraining = new Float64Array(xTraining.length);\n  if (magnitudeMode) {\n    let factor = 1;\n    for (let i = 0; i < yTraining.length; i++) {\n      let finalInput = xTraining[i] * factor;\n      yTraining[i] = 1 - rayleighCdf(finalInput);\n    }\n    let interp = new SplineInterpolator(xTraining, yTraining);\n    for (let i = 0; i < result.length; i++) {\n      let yValue = 2 * data[i];\n      result[i] = -1 * interp.interpolate(yValue);\n    }\n  } else {\n    for (let i = 0; i < result.length; i++) {\n      result[i] = -1 * Math.SQRT2 * erfcinv(2 * data[i]);\n    }\n  }\n  return result.length === 1 ? result[0] : result;\n}\n\nfunction createArray(from, to, step) {\n  let result = new Array(Math.abs((from - to) / step + 1));\n  for (let i = 0; i < result.length; i++) {\n    result[i] = from + i * step;\n  }\n  return result;\n}\n\nfunction generateSanPlot(array, options = {}) {\n  const { fromTo, logBaseY = 2 } = options;\n\n  let sanplot = {};\n  for (let key in fromTo) {\n    let { from, to } = fromTo[key];\n    sanplot[key] =\n      from !== to\n        ? scale(array.slice(from, to), {\n            logBaseY,\n          })\n        : { x: [], y: [] };\n    if (key === 'negative') {\n      sanplot[key].y.reverse();\n    }\n  }\n  return sanplot;\n}\n\nfunction scale(array, options = {}) {\n  const { log10, abs } = Math;\n  const { logBaseY } = options;\n  if (logBaseY) {\n    array = array.slice();\n    const logOfBase = log10(logBaseY);\n    for (let i = 0; i < array.length; i++) {\n      array[i] = log10(abs(array[i])) / logOfBase;\n    }\n  }\n\n  const xAxis = fill({\n    from: 0,\n    to: array.length - 1,\n    size: array.length,\n  });\n\n  return { x: xAxis, y: array };\n}\n","/**\n * This function calculate the norm of a vector\n * @example xNorm([3, 4]) -> 5\n * @param {Array} array - the array that will be rotated\n * @return {number} calculated norm\n */\nexport function xNorm(array) {\n  let result = 0;\n  for (let i = 0; i < array.length; i++) {\n    result += array[i] ** 2;\n  }\n  return Math.sqrt(result);\n}\n","import sd from 'ml-array-standard-deviation';\n\nimport { xCheck } from './xCheck';\n\n/**\n * Pareto scaling, which uses the square root of standard deviation as the scaling factor, circumvents the amplification of noise by retaining a small portion of magnitude information.\n * Noda, I. (2008). Scaling techniques to enhance two-dimensional correlation spectra. Journal of Molecular Structure, 883, 216-227.\n * DOI: 10.1016/j.molstruc.2007.12.026\n * @param {Array<Number>} array\n * @return {Array}\n */\nexport function xParetoNormalization(array) {\n  xCheck(array);\n  let result = [];\n  const sqrtSD = Math.sqrt(sd(array));\n\n  for (let item of array) {\n    result.push(item / sqrtSD);\n  }\n  return result;\n}\n","import { xCheck } from './xCheck';\n\n/**\n * This function pads an array\n * @param {Array} array - the array that will be padded\n * @param {object} [options={}]\n * @param {string} [options.algorithm=''] '', value, circular, duplicate\n * @param {number} [options.size=0] padding size before first element and after last element\n * @param {number} [options.value=0] value to use for padding (if algorithm='value')\n * @return {Array}\n */\nexport function xPadding(array, options = {}) {\n  const { size = 0, value = 0, algorithm = '' } = options;\n  xCheck(array);\n\n  if (!algorithm) {\n    if (array instanceof Float64Array) {\n      return array.slice();\n    } else {\n      return Float64Array.from(array);\n    }\n  }\n\n  let result = new Float64Array(array.length + size * 2);\n\n  for (let i = 0; i < array.length; i++) {\n    result[i + size] = array[i];\n  }\n\n  let fromEnd = size + array.length;\n  let toEnd = 2 * size + array.length;\n\n  switch (algorithm.toLowerCase()) {\n    case 'value':\n      for (let i = 0; i < size; i++) {\n        result[i] = value;\n      }\n      for (let i = fromEnd; i < toEnd; i++) {\n        result[i] = value;\n      }\n      break;\n    case 'duplicate':\n      for (let i = 0; i < size; i++) {\n        result[i] = array[0];\n      }\n      for (let i = fromEnd; i < toEnd; i++) {\n        result[i] = array[array.length - 1];\n      }\n      break;\n    case 'circular':\n      for (let i = 0; i < size; i++) {\n        result[i] =\n          array[(array.length - (size % array.length) + i) % array.length];\n      }\n      for (let i = 0; i < size; i++) {\n        result[i + fromEnd] = array[i % array.length];\n      }\n      break;\n    default:\n      throw Error('xPadding: unknown algorithm');\n  }\n\n  return result;\n}\n","/**\n * This function performs a circular shift to a new array\n * Positive values of shifts will shift to the right and negative values will do to the left\n * @example xRotate([1,2,3,4],1) -> [4,1,2,3]\n * @example xRotate([1,2,3,4],-1) -> [2,3,4,1]\n * @param {Array} array - the array that will be rotated\n * @param {number} shift\n * @return {Array}\n */\nexport function xRotate(array, shift) {\n  shift = shift % array.length;\n  if (shift < 0) shift += array.length;\n  let result = new Float64Array(array.length);\n  result.set(array.slice(array.length - shift));\n  result.set(array.slice(0, array.length - shift), shift);\n  return result;\n}\n","import { xCheck } from './xCheck';\nimport { xPadding } from './xPadding';\n/**\n * This function calculates a rolling average\n * @param {Array<Number>} array - the array that will be rotated\n * @param {function} fct callback function that from an array returns a value.\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {string} [options.padding.size=0] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm='value'] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xRolling(array, fct, options = {}) {\n  xCheck(array);\n  if (typeof fct !== 'function') throw Error('fct has to be a function');\n\n  const { window = 5, padding = {} } = options;\n  const { size = window - 1, algorithm, value } = padding;\n\n  array = xPadding(array, { size, algorithm, value }); // ensure we get a copy and it is float64\n\n  const newArray = [];\n  for (let i = 0; i < array.length - window + 1; i++) {\n    let subArray = new Float64Array(array.buffer, i * 8, window);\n    // we will send a view to the original buffer\n    newArray.push(fct(subArray));\n  }\n\n  return newArray;\n}\n","import mean from 'ml-array-mean';\n\nimport { xRolling } from './xRolling';\n\n/**\n * This function calculates a rolling average\n * @param {Array<Number>} array - the array that will be rotated\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {string} [options.padding.size=window-1] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm=''] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xRollingAverage(array, options = {}) {\n  return xRolling(array, mean, options);\n}\n","import median from 'ml-array-median';\n\nimport { xRolling } from './xRolling';\n\n/**\n * This function calculates a rolling average\n * @param {Array<Number>} array - the array that will be rotated\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {string} [options.padding.size=window-1] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm=''] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xRollingMedian(array, options = {}) {\n  return xRolling(array, median, options);\n}\n","import min from 'ml-array-min';\n\nimport { xRolling } from './xRolling';\n\n/**\n * This function calculates a minimum within a rolling window\n * @param {Array<Number>} array - the array that will be rotated\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {string} [options.padding.size=window-1] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm=''] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xRollingMin(array, options = {}) {\n  return xRolling(array, min, options);\n}\n","import max from 'ml-array-max';\n\nimport { xRolling } from './xRolling';\n\n/**\n * This function calculates a maximum within a rolling window\n * @param {Array<Number>} array - the array that will be rotated\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {string} [options.padding.size=window-1] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm=''] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xRollingMax(array, options = {}) {\n  return xRolling(array, max, options);\n}\n","import isAnyArray from 'is-any-array';\n/**\n * This function xSubtract the first array by the second array or a constant value from each element of the first array\n * @param {Array} array1 - the array that will be rotated\n * @param {Array|Number} array2\n * @return {Array}\n */\nexport function xSubtract(array1, array2) {\n  let isConstant = false;\n  let constant;\n  if (isAnyArray(array2)) {\n    if (array1.length !== array2.length) {\n      throw new Error('sub: size of array1 and array2 must be identical');\n    }\n  } else {\n    isConstant = true;\n    constant = Number(array2);\n  }\n\n  let array3 = new Array(array1.length);\n  if (isConstant) {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] - constant;\n    }\n  } else {\n    for (let i = 0; i < array1.length; i++) {\n      array3[i] = array1[i] - array2[i];\n    }\n  }\n\n  return array3;\n}\n","import { xCheck } from './xCheck';\n\n/**\n * Calculate the sum of the values\n * @param {DataXY} [array={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.fromIndex=0] - First point for xSum\n * @param {number} [options.toIndex=x.length-1] - Last point for xSum\n * @return {number} xSum value on the specified range\n */\n\nexport function xSum(array, options = {}) {\n  const { fromIndex = 0, toIndex = array.length - 1 } = options;\n  xCheck(array);\n\n  let sumValue = array[fromIndex];\n  for (let i = fromIndex + 1; i <= toIndex; i++) {\n    sumValue += array[i];\n  }\n  return sumValue;\n}\n","import { xCheckLengths } from './xCheck.js';\n/**\n * This function calculates the mean absolute error\n * @param {Array<number>} array1 -\n * @param {Array<number>} array2\n * @return {Number}\n */\nexport function xMeanAbsoluteError(array1, array2) {\n  xCheckLengths(array1, array2);\n  let sum = 0;\n  for (let i = 0; i < array1.length; i++) {\n    sum += Math.abs(array1[i] - array2[i]);\n  }\n  return sum / array1.length;\n}\n","import { xCheckLengths } from './xCheck.js';\n\n/**\n * This function calculates the mean squared error\n * @param {Array<number>} array1 -\n * @param {Array<number>} array2\n * @return {Number}\n */\nexport function xMeanSquaredError(array1, array2) {\n  xCheckLengths(array1, array2);\n  let sum = 0;\n  for (let i = 0; i < array1.length; i++) {\n    sum += Math.pow(array1[i] - array2[i], 2);\n  }\n  return sum / array1.length;\n}\n","/**\n * Calculates reimAbsolute value of a complex spectrum\n * @param {object} [reim] - An object of kind {re:[], im:[]}.\n * @return {Float64Array}\n */\nexport function reimAbsolute(data) {\n  const length = data.re.length;\n  const re = data.re;\n  const im = data.im;\n  const newArray = new Float64Array(length);\n  for (let i = 0; i < length; i++) {\n    newArray[i] = Math.sqrt(re[i] ** 2 + im[i] ** 2);\n  }\n\n  return newArray;\n}\n","/**\n * Phase correction filter\n * @param {object} reim - An object of kind {re:[], im:[]}\n * @param {number} [phi0=0] - Angle in radians for zero order phase correction\n * @param {number} [phi1=0] - Angle in radians for first order phase correction\n * @return {object} returns a new object {re:[], im:[]}\n */\nexport function reimPhaseCorrection(data, phi0, phi1) {\n  phi0 = Number.isFinite(phi0) ? phi0 : 0;\n  phi1 = Number.isFinite(phi1) ? phi1 : 0;\n\n  const re = data.re;\n  const im = data.im;\n  const length = data.re.length;\n\n  const delta = phi1 / length;\n  const alpha = 2 * Math.pow(Math.sin(delta / 2), 2);\n  const beta = Math.sin(delta);\n  let cosTheta = Math.cos(phi0);\n  let sinTheta = Math.sin(phi0);\n\n  const newRe = new Float64Array(length);\n  const newIm = new Float64Array(length);\n  for (let i = 0; i < length; i++) {\n    newRe[i] = re[i] * cosTheta - im[i] * sinTheta;\n    newIm[i] = re[i] * sinTheta + im[i] * cosTheta;\n    // calculate angles i+1 from i\n    let newCosTheta = cosTheta - (alpha * cosTheta + beta * sinTheta);\n    let newSinTheta = sinTheta - (alpha * sinTheta - beta * cosTheta);\n    cosTheta = newCosTheta;\n    sinTheta = newSinTheta;\n  }\n\n  return { re: newRe, im: newIm };\n}\n","import { xNoiseSanPlot } from '../x/xNoiseSanPlot';\n\nimport { reimAbsolute } from './reimAbsolute';\nimport { reimPhaseCorrection } from './reimPhaseCorrection';\n/**\n * Implementation of the algorithm for automatic phase correction: A robust, general automatic phase\n * correction algorithm for high-resolution NMR data. 10.1002/mrc.4586\n * @param {object} data - { re, im } real and imaginary data.\n * @param {object} options -\n * @param {Number} options.minRegSize - min number of points to auto phase a region.\n * @param {Number} options.maxDistanceToJoin - max distance between regions (in number of points) to join two regions\n * @param {boolean} options.magnitudeMode - if true it uses magnitude spectrum.boolean\n * @param {Number} options.factorNoise - scale the cutoff like factorStd * noiseLevel.\n */\n\nconst defaultOptions = {\n  minRegSize: 30,\n  maxDistanceToJoin: 256,\n  magnitudeMode: true,\n  factorNoise: 3,\n};\n\nexport function reimAutoPhaseCorrection(data, options = {}) {\n  const { re, im } = data;\n  const length = re.length;\n\n  options = Object.assign(defaultOptions, options);\n\n  const { magnitudeMode, minRegSize } = options;\n\n  let magnitudeData = magnitudeMode ? reimAbsolute(data) : re;\n\n  let ds = holoborodko(magnitudeData);\n  let peaksDs = robustBaseLineRegionsDetection(ds, options);\n  let peaksSp = robustBaseLineRegionsDetection(magnitudeData, options);\n  let finalPeaks = new Array(length);\n  for (let i = 0; i < length; i++) {\n    finalPeaks[i] = peaksSp[i] & peaksDs[i];\n  }\n\n  // Once the regions are detected, we auto phase each of them separately.\n  // TODO: This part can be put inside a function\n  let i = -1;\n  let x0 = 0;\n  let res = [];\n  while (i < length) {\n    //phase first region\n    let reTmp = [];\n    let imTmp = [];\n\n    //Look for the first 1 in the array\n    while (!finalPeaks[++i] && i < length) {\n      //TODO: Add some extra points(0.1 ppm) at rigth and left sides of the region.\n      x0 = i;\n    }\n    for (; finalPeaks[i] && i < length; i++) {\n      reTmp.push(re[i]);\n      imTmp.push(im[i]);\n      i++;\n    }\n\n    if (reTmp.length > minRegSize) {\n      res.push(autoPhaseRegion(reTmp, imTmp, x0));\n    }\n  }\n  // TODO: Still some corrections needed. In the paper they remove the outlayers interatively\n  // until they can perform a regression witout bad points. Can someone help here?\n  let [ph1, ph0] = weightedLinearRegression(\n    res.map((r) => r.x0 / length),\n    res.map((r) => r.ph0),\n    res.map((r) => r.area / 1e11),\n  );\n  let phased = reimPhaseCorrection(\n    { re, im },\n    (ph0 * Math.PI) / 180,\n    (ph1 * Math.PI) / 180,\n  );\n  return { data: phased, ph0, ph1 };\n}\n\nfunction autoPhaseRegion(re, im, x0) {\n  let start = -180;\n  let stop = 180;\n  let nSteps = 6;\n  let maxSteps = 5;\n\n  let bestAng = 0;\n  let minArea = Number.MAX_SAFE_INTEGER;\n  while (maxSteps > 0) {\n    let dAng = (stop - start) / (nSteps + 1);\n    for (let i = start; i <= stop; i += dAng) {\n      let phased = reimPhaseCorrection({ re, im }, toRadians(i), 0);\n      let negArea = getNegArea(phased.re);\n      if (negArea < minArea) {\n        [minArea, bestAng] = [negArea, i];\n      }\n    }\n    start = bestAng - dAng;\n    stop = bestAng + dAng;\n    maxSteps--;\n  }\n\n  // Calculate the area for the best angle\n  let phased = reimPhaseCorrection({ re, im }, toRadians(bestAng), 0);\n  let area = 0;\n  let sumX = 0;\n  for (let j = 0; j < re.length; j++) {\n    area += phased.re[j];\n    sumX += phased.re[j] * (j + x0);\n  }\n\n  return { ph0: bestAng, area, x0: sumX / area };\n}\n\nfunction holoborodko(s) {\n  let dk = new Float64Array(s.length);\n  for (let i = 5; i < s.length - 5; i++) {\n    dk[i] =\n      (42 * (s[i + 1] - s[i - 1]) +\n        48 * (s[i + 2] - s[i - 2]) +\n        27 * (s[i + 3] + s[i - 3]) +\n        8 * (s[i + 4] - s[i - 4]) +\n        s[i + 5] -\n        s[i - 5]) /\n      512;\n  }\n  //Fill the borders\n  for (let i = 0; i < 5; i++) {\n    dk[i] = dk[5];\n    dk[s.length - i - 1] = dk[s.length - 6];\n  }\n\n  return dk;\n}\n\nfunction robustBaseLineRegionsDetection(s, options) {\n  const { maxDistanceToJoin, magnitudeMode, factorNoise } = options;\n\n  let mask = new Array(s.length);\n  for (let i = 0; i < s.length; i++) {\n    mask[i] = false;\n  }\n\n  let change = true;\n  while (change) {\n    let noiseLevel = xNoiseSanPlot(s, { magnitudeMode });\n    let cutOff = factorNoise * noiseLevel.positive;\n    change = false;\n    for (let i = 0; i < s.length; i++) {\n      if (Math.abs(s[i]) > cutOff && !mask[i]) {\n        change = true;\n        mask[i] = true;\n      }\n    }\n  }\n  // Clean up mask by merging peaks blocks, separated by just a few points(4??).\n  let count = 0;\n  let prev = 0;\n  for (let i = 0; i < s.length; i++) {\n    if (!mask[i]) {\n      count++;\n    } else {\n      if (count < maxDistanceToJoin) {\n        for (let j = 0; j <= count; j++) {\n          mask[prev + j] = true;\n        }\n      }\n      while (mask[++i] && i < s.length);\n      prev = i;\n      count = 0;\n    }\n  }\n\n  return mask;\n}\n\nfunction weightedLinearRegression(x, y, w) {\n  let sxtw = 0;\n  let swx = 0;\n  let sw = 0;\n  let sxtwy = 0;\n  let swy = 0;\n  for (let i = 0; i < x.length; i++) {\n    sxtw += x[i] * x[i] * w[i];\n    swx += x[i] * w[i];\n    sw += w[i];\n    sxtwy += x[i] * w[i] * y[i];\n    swy += w[i] * y[i];\n  }\n\n  /* Just to know what is the matrix system that we solve\n   let Mx=[[sxtw, swx], [swx, sw]];\n   let My=[[sxtwy], [swy]];\n  */\n\n  //Mx inverse\n  let detMx = sxtw * sw - swx * swx;\n  let inMx = [\n    [sw / detMx, -swx / detMx],\n    [-swx / detMx, sxtw / detMx],\n  ];\n\n  return [\n    inMx[0][0] * sxtwy + inMx[0][1] * swy,\n    inMx[1][0] * sxtwy + inMx[1][1] * swy,\n  ];\n}\n\nconst toRadians = (degree) => (degree * Math.PI) / 180;\n\nconst getNegArea = (data) => {\n  let area = 0;\n  for (let i = 0; i < data.length; i++) {\n    if (data[i] < 0) area -= data[i];\n  }\n  return area;\n};\n","import FFT from 'fft.js';\n\nimport { xRotate } from '../x/xRotate';\n\nexport function reimFFT(data, options = {}) {\n  const { inverse = false, applyZeroShift = false } = options;\n\n  let { re, im } = data;\n  const size = re.length;\n  const csize = size << 1;\n\n  let complexArray = new Float64Array(csize);\n  for (let i = 0; i < csize; i += 2) {\n    complexArray[i] = re[i >>> 1];\n    complexArray[i + 1] = im[i >>> 1];\n  }\n\n  let fft = new FFT(size);\n  let output = new Float64Array(csize);\n  if (inverse) {\n    if (applyZeroShift) complexArray = zeroShift(complexArray, true);\n    fft.inverseTransform(output, complexArray);\n  } else {\n    fft.transform(output, complexArray);\n    if (applyZeroShift) output = zeroShift(output);\n  }\n\n  let newRe = new Float64Array(size);\n  let newIm = new Float64Array(size);\n  for (let i = 0; i < csize; i += 2) {\n    newRe[i >>> 1] = output[i];\n    newIm[i >>> 1] = output[i + 1];\n  }\n\n  return { re: newRe, im: newIm };\n}\n\nconst zeroShift = (data, inverse) => {\n  let middle = inverse\n    ? Math.ceil(data.length / 2)\n    : Math.floor(data.length / 2);\n  return xRotate(data, middle);\n};\n","/**\n * This function make a zero filling to re and im part.\n * @param {object} data Object of kind {x:[], re:[], im:[]}.\n * @param {number} totalLength - final number of points\n * @return {SD}\n */\nexport function xreimZeroFilling(data, totalLength) {\n  let length = data.x.length;\n  if (totalLength === 0 || length === totalLength) return data;\n\n  if (length > totalLength) {\n    return {\n      x: data.x.slice(0, totalLength),\n      re: data.re.slice(0, totalLength),\n      im: data.im.slice(0, totalLength),\n    };\n  }\n\n  const x = data.x;\n  const re = data.re;\n  const im = data.im;\n\n  const newX = new Float64Array(totalLength);\n  const newRE = new Float64Array(totalLength);\n  const newIM = new Float64Array(totalLength);\n\n  for (let i = 0; i < length; i++) {\n    newX[i] = x[i];\n    newRE[i] = re[i];\n    newIM[i] = im[i];\n  }\n  const deltaX = (x[x.length - 1] - x[0]) / (length - 1);\n  for (let i = length; i < totalLength; i++) {\n    newX[i] = newX[i - 1] + deltaX;\n  }\n\n  return {\n    x: newX,\n    re: newRE,\n    im: newIM,\n  };\n}\n","/**\n * Sort object of array, x has to be monotone.\n * @param {object} data Object of kind {x:[], re:[], im:[]}.\n * @return {SD}\n */\n\nexport function xreimSortX(data) {\n  const { x, re, im } = data;\n\n  if (x.length !== re.length || x.length !== im.length) {\n    throw TypeError('xreimSortX: length of x, re and im must be identical');\n  }\n\n  if (x.length < 2 || x[0] < x[1]) return data;\n\n  return {\n    x: x.slice(0).reverse(),\n    re: re.slice(0).reverse(),\n    im: im.slice(0).reverse(),\n  };\n}\n","import isAnyArray from 'is-any-array';\n\n/**\n * Throw an error in no an object of x,y arrays\n * @param {DataXY} [data={}]\n */\nexport function xyCheck(data = {}) {\n  if (!isAnyArray(data.x) || !isAnyArray(data.y)) {\n    throw new Error('Data must be an object of x and y arrays');\n  }\n  if (data.x.length !== data.y.length) {\n    throw new Error('The x and y arrays mush have the same length');\n  }\n}\n","import { xyCheck } from './xyCheck';\n/**\n * Join x / y values when difference in X is closer than delta.\n * When joining, y values are summed and x values are weighted average\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @return {DataXY} An object with the xyIntegration function\n */\n\nexport function xyJoinX(data = {}, options = {}) {\n  xyCheck(data);\n  const { delta = 1 } = options;\n  const deltaIsFunction = typeof delta === 'function';\n  const x = Array.from(data.x);\n  const y = Array.from(data.y);\n  if (x.length < 2) {\n    return { x, y };\n  }\n  let position = 0;\n\n  for (let i = 1; i < x.length; i++) {\n    let difference = x[i] - x[i - 1];\n    let currentDelta = deltaIsFunction ? delta((x[i] + x[i - 1]) / 2) : delta;\n\n    if (difference <= currentDelta) {\n      // we join\n      if (y[position] !== 0 || y[i] !== 0) {\n        x[position] =\n          (x[position] * y[position] + x[i] * y[i]) / (y[position] + y[i]);\n        y[position] += y[i];\n      }\n    } else {\n      position++;\n      x[position] = x[i];\n      y[position] = y[i];\n    }\n  }\n\n  x.length = position + 1;\n  y.length = position + 1;\n  return { x, y };\n}\n","export function getSlots(spectra, options = {}) {\n  const { delta = 1 } = options;\n  const deltaIsFunction = typeof delta === 'function';\n\n  let possibleXs = Float64Array.from(\n    [].concat(...spectra.map((spectrum) => spectrum.x)),\n  ).sort();\n\n  if (possibleXs.length < 1) {\n    throw new Error('xyArrayMerge can not process empty arrays');\n  }\n\n  let currentSlot = {\n    from: possibleXs[0],\n    to: possibleXs[0],\n    average: possibleXs[0],\n    sum: possibleXs[0],\n    number: 1,\n  };\n  let slots = [currentSlot];\n  for (let i = 1; i < possibleXs.length; i++) {\n    let currentDelta = deltaIsFunction ? delta(possibleXs[i]) : delta;\n    if (possibleXs[i] - currentSlot.to <= currentDelta) {\n      currentSlot.to = possibleXs[i];\n      currentSlot.number++;\n      currentSlot.sum += possibleXs[i];\n      currentSlot.average = currentSlot.sum / currentSlot.number;\n    } else {\n      currentSlot = {\n        from: possibleXs[i],\n        to: possibleXs[i],\n        average: possibleXs[i],\n        sum: possibleXs[i],\n        number: 1,\n      };\n      slots.push(currentSlot);\n    }\n  }\n  return slots;\n}\n","import { xyJoinX } from '../xy/xyJoinX';\n\nimport { getSlots } from './utils/getSlots';\n\n/**\n * Aligns spectra\n * @param {Array<DataXY>} spectra\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @returns {object} {x:[], ys[[]]}\n */\nexport function xyArrayAlign(spectra, options = {}) {\n  const { delta = 1 } = options;\n\n  // we start by checking that the spectra don't have peaks too close and we simplify them\n  spectra = spectra.map((spectrum) => xyJoinX(spectrum, { delta }));\n\n  const slots = getSlots(spectra, options);\n  let x = Float64Array.from(slots.map((slot) => slot.average));\n  let ys = new Array(spectra.length)\n    .fill()\n    .map(() => new Float64Array(x.length));\n\n  let positions = new Uint32Array(spectra.length);\n  for (let i = 0; i < slots.length; i++) {\n    let slot = slots[i];\n    for (let j = 0; j < spectra.length; j++) {\n      let spectrum = spectra[j];\n      while (\n        positions[j] < spectrum.x.length &&\n        spectrum.x[positions[j]] <= slot.to\n      ) {\n        ys[j][i] += spectrum.y[positions[j]];\n        positions[j]++;\n      }\n    }\n  }\n\n  return { x, ys };\n}\n","import { xyJoinX } from '../xy/xyJoinX';\n\nimport { getSlots } from './utils/getSlots';\n/**\n * Merge DataXY\n * We have an array of DataXY and the goal is to merge all the values that are the closest possible\n * @param {Array<DataXY>} spectra\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n */\nexport function xyArrayMerge(spectra, options = {}) {\n  const { delta = 1 } = options;\n  // we start by checking that the spectra don't have peaks too close and we simplify them\n  spectra = spectra.map((spectrum) => xyJoinX(spectrum, { delta }));\n\n  // at first we will calculate the X values (simple mean)\n  let slots = getSlots(spectra, options);\n\n  let x = Float64Array.from(slots.map((slot) => slot.average));\n  let y = new Float64Array(x.length);\n\n  let positions = new Uint32Array(spectra.length);\n  for (let i = 0; i < slots.length; i++) {\n    let slot = slots[i];\n    for (let j = 0; j < spectra.length; j++) {\n      let spectrum = spectra[j];\n      while (\n        positions[j] < spectrum.x.length &&\n        spectrum.x[positions[j]] <= slot.to\n      ) {\n        y[i] += spectrum.y[positions[j]];\n        positions[j]++;\n      }\n    }\n  }\n\n  return { x, y };\n}\n","/**\n * Merge DataXY\n * We have an array of DataXY and the goal is to merge all the values for which the deltaX is small or equal to delta.\n * X values are weighted average\n * @param {Array<DataXY>} spectra\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @returns {DataXY}\n */\nexport function xyArrayWeightedMerge(spectra, options = {}) {\n  let { delta = 1 } = options;\n  if (typeof delta === 'number') {\n    let deltaNumber = delta;\n    delta = () => deltaNumber;\n  }\n  spectra = spectra.filter((spectrum) => spectrum.x.length > 0);\n\n  if (spectra.length === 0) return { x: [], y: [] };\n\n  let x = [];\n  let y = [];\n\n  const positions = new Array(spectra.length).fill(0);\n  const point = { x: 0, y: 0 };\n\n  nextValue(spectra, positions, point);\n  let slot = {\n    maxX: point.x + delta(point.x),\n    sumY: point.y,\n    sumXY: point.y * point.x,\n  };\n\n  while (spectra.length !== 0) {\n    nextValue(spectra, positions, point);\n    let sameSlot = point.x <= slot.maxX;\n    if (!sameSlot) {\n      if (slot.sumY > 0) {\n        x.push(slot.sumXY / slot.sumY);\n        y.push(slot.sumY);\n      }\n      slot.sumY = 0;\n      slot.sumXY = 0;\n    }\n\n    slot.sumY += point.y;\n    slot.sumXY += point.x * point.y;\n    slot.maxX = point.x + delta(point.x);\n\n    if (spectra.length === 0) {\n      if (slot.sumY > 0) {\n        x.push(slot.sumXY / slot.sumY);\n        y.push(slot.sumY);\n      }\n    }\n  }\n  return { x, y };\n}\n\nfunction nextValue(spectra, positions, point) {\n  let minIndex = 0;\n  let minX = spectra[0].x[positions[0]];\n\n  for (let i = 1; i < spectra.length; i++) {\n    let currentX = spectra[i].x[positions[i]];\n    if (currentX < minX) {\n      minX = currentX;\n      minIndex = i;\n    }\n  }\n\n  point.x = minX;\n  point.y = spectra[minIndex].y[positions[minIndex]];\n\n  positions[minIndex]++;\n\n  if (positions[minIndex] === spectra[minIndex].x.length) {\n    positions.splice(minIndex, 1);\n    spectra.splice(minIndex, 1);\n  }\n}\n","import { xyArrayWeightedMerge } from '../xyArrayWeightedMerge';\n\nexport function getSlotsToFirst(spectra, options = {}) {\n  const { delta = 1 } = options;\n  const deltaIsFunction = typeof delta === 'function';\n\n  let firstXs = spectra[0].x;\n  let slots = [];\n  // we first create the slots based on the first spectrum\n  for (let i = 0; i < firstXs.length; i++) {\n    let currentDelta = deltaIsFunction ? delta(firstXs[i]) : delta;\n    slots.push({\n      from: firstXs[i] - currentDelta,\n      to: firstXs[i] + currentDelta,\n      value: firstXs[i],\n    });\n  }\n\n  let otherXs = xyArrayWeightedMerge(spectra.slice(1), options).x;\n  let currentPosition = 0;\n  for (let slot of slots) {\n    while (\n      otherXs[currentPosition] < slot.to &&\n      currentPosition < otherXs.length\n    ) {\n      if (otherXs[currentPosition] < slot.from) {\n        let currentDelta = deltaIsFunction\n          ? delta(otherXs[currentPosition])\n          : delta;\n        slots.push({\n          from: otherXs[currentPosition] - currentDelta,\n          to: otherXs[currentPosition] + currentDelta,\n          value: otherXs[currentPosition],\n        });\n      }\n      currentPosition++;\n    }\n  }\n  for (let i = currentPosition; i < otherXs.length; i++) {\n    let currentDelta = deltaIsFunction ? delta(otherXs[i]) : delta;\n    slots.push({\n      from: otherXs[i] - currentDelta,\n      to: otherXs[i] + currentDelta,\n      value: otherXs[i],\n    });\n  }\n\n  slots.sort((a, b) => a.value - b.value);\n\n  // we prevent slots overlap in the first spectrum\n  for (let i = 0; i < slots.length - 1; i++) {\n    if (slots[i].to > slots[i + 1].from) {\n      let middle = (slots[i].value + slots[i + 1].value) / 2;\n      slots[i].to = middle;\n      slots[i + 1].from = middle;\n    }\n  }\n  return slots;\n}\n","import { getSlotsToFirst } from './utils/getSlotsToFirst';\n\n/**\n * We align all the spectra to the first array of X.\n * The alignment is based on the X values of the first spectrum and the `delta` error allowed. If some x values are missing in the first specdtrum we will add them\n * @param {Array<DataXY>} spectra\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @returns {object} {x:[], ys[[]]\n */\nexport function xyArrayAlignToFirst(spectra, options = {}) {\n  const slots = getSlotsToFirst(spectra, options);\n  let x = Float64Array.from(slots.map((slot) => slot.value));\n  let ys = new Array(spectra.length)\n    .fill()\n    .map(() => new Float64Array(x.length));\n\n  let positions = new Uint32Array(spectra.length);\n  for (let i = 0; i < slots.length; i++) {\n    let slot = slots[i];\n    for (let j = 0; j < spectra.length; j++) {\n      let spectrum = spectra[j];\n      while (\n        positions[j] < spectrum.x.length &&\n        spectrum.x[positions[j]] < slot.to\n      ) {\n        ys[j][i] += spectrum.y[positions[j]];\n        positions[j]++;\n      }\n    }\n  }\n\n  return { x, ys };\n}\n","/**\n * xyAlign will align data of two spectra by verifying wether x values are in a certain range (`delta`).\n * The two spectra should not have two consecutive x values which difference is\n * smaller than `delta` to achieve good results!\n * @param {DataXY} data1 First spectrum data\n * @param {DataXY} data2 Second spectrum data\n * @param {object} [options={}]\n * @param {number|function} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line. It may also be a function that allows to change `delta` depending on the X values of the spectrum\n * @param {boolean} [options.common=true] If `true`, only the data considered as common to both spectra is kept. If `false`, the data y arrays are completed with zeroes where no common values are found\n * @param {string} [options.x='x1'] Defines what x values should be kept (`x1` : spectrum 1 x values, `x2` spectrum 2 x values, `weighted`: weighted average of both spectra x values)\n */\nexport function xyAlign(data1, data2, options = {}) {\n  const { delta = 1, common = true, x = 'x1' } = options;\n\n  let result = {\n    x: [],\n    y1: [],\n    y2: [],\n  };\n\n  let i = 0;\n  let j = 0;\n\n  let length1 = data1.x.length;\n  let length2 = data2.x.length;\n\n  while (i < length1 && j < length2) {\n    let maxDiff = 0;\n\n    if (typeof delta === 'function') {\n      let mean = (data1.x[i] + data2.x[j]) / 2; // is this a good thing to do?\n      maxDiff = delta(mean);\n    } else {\n      maxDiff = delta;\n    }\n\n    let difference = data1.x[i] - data2.x[j];\n\n    if (Math.abs(difference) > maxDiff) {\n      if (difference > 0) {\n        if (!common) {\n          result.x.push(data2.x[j]);\n          result.y1.push(0);\n          result.y2.push(data2.y[j]);\n          if (j === length2 - 1) {\n            while (i < length1) {\n              result.x.push(data1.x[i]);\n              result.y1.push(data1.y[i]);\n              result.y2.push(0);\n              i++;\n            }\n          }\n        }\n        // console.log({ i, j }, result);\n        j++;\n      } else {\n        if (!common) {\n          result.x.push(data1.x[i]);\n          result.y1.push(data1.y[i]);\n          result.y2.push(0);\n          if (i === length1 - 1) {\n            while (j < length2) {\n              result.x.push(data2.x[j]);\n              result.y1.push(0);\n              result.y2.push(data2.y[j]);\n              j++;\n            }\n          }\n        }\n        // console.log({ i, j }, result);\n        i++;\n      }\n    } else {\n      let weightedX =\n        (data1.x[i] * data1.y[i] + data2.x[j] * data2.y[j]) /\n        (data1.y[i] + data2.y[j]);\n\n      switch (x) {\n        case 'x1':\n          result.x.push(data1.x[i]);\n          break;\n        case 'x2':\n          result.x.push(data2.x[j]);\n          break;\n        case 'weighted':\n          result.x.push(weightedX);\n          break;\n        default:\n          throw new Error(`Error: Unknown x option value: ${x}`);\n      }\n\n      result.y1.push(data1.y[i]);\n      result.y2.push(data2.y[j]);\n\n      // console.log({ i, j }, result);\n\n      i++;\n      j++;\n    }\n  }\n  return result;\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n/**\n * Finds the max y value in a range and return a {x,y} point\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {object}\n */\n\nexport function xyMaxYPoint(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n\n  let current = { x: x[fromIndex], y: y[fromIndex], index: fromIndex };\n  for (let i = fromIndex; i <= toIndex; i++) {\n    if (y[i] > current.y) current = { x: x[i], y: y[i], index: i };\n  }\n\n  return current;\n}\n","import max from 'ml-array-max';\n\nimport { xCumulative } from '../x/xCumulative';\n\nimport { xyCheck } from './xyCheck';\nimport { xyMaxYPoint } from './xyMaxYPoint';\n/**\n * Cumulative Distribution Statistics\n * @param {DataXY} [data] array of points {x,y}\n * @returns {object} x0, x25, x50, x75, x100, mode (x for maxY)\n */\n\nconst STEPS = [0.25, 0.5, 0.75];\n\nexport function xyCumulativeDistributionStatistics(data) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length === 0) {\n    throw new Error(\n      'xyCumulativeDistributionStatistics: Array length must be greater than 0',\n    );\n  }\n  const cumulativeSum = xCumulative(y);\n  const maxY = max(cumulativeSum);\n  for (let i = 0; i < cumulativeSum.length; i++) {\n    cumulativeSum[i] /= maxY;\n  }\n\n  const result = {};\n\n  // need to find the x values closest to STEPS/100\n  result.x0 = x[0];\n  result.x100 = x[x.length - 1];\n\n  let currentStep = 0;\n  breakPoint: for (let i = 1; i < cumulativeSum.length; i++) {\n    while (STEPS[currentStep] < cumulativeSum[i]) {\n      result[`x${STEPS[currentStep] * 100}`] =\n        x[i - 1] +\n        (x[i] - x[i - 1]) *\n          ((STEPS[currentStep] - cumulativeSum[i - 1]) /\n            (cumulativeSum[i] - cumulativeSum[i - 1]));\n      currentStep++;\n      if (currentStep === STEPS.length) break breakPoint;\n    }\n  }\n  result.xMode = xyMaxYPoint(data).x;\n\n  let sumXY = 0;\n  let sumY = 0;\n  for (let i = 0; i < x.length; i++) {\n    sumXY += x[i] * y[i];\n    sumY += y[i];\n  }\n  result.xMean = sumXY / sumY;\n\n  return result;\n}\n","import { xyCheck } from './xyCheck';\n\n/**\n * Filters x,y values to allow strictly growing values in x axis.\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {DataXY}\n */\nexport function xyEnsureGrowingX(data = {}) {\n  xyCheck(data);\n  const x = Array.from(data.x);\n  const y = Array.from(data.y);\n  let prevX = -Infinity;\n  let ansX = [];\n  let ansY = [];\n\n  for (let index = 0; index < x.length; index++) {\n    if (prevX < x[index]) {\n      ansX.push(x[index]);\n      ansY.push(y[index]);\n      prevX = x[index];\n    }\n  }\n  return { x: ansX, y: ansY };\n}\n","/**\n * Normalize an array of zones:\n * - ensure than from < to\n * - merge overlapping zones\n * @param {Array<Zone>} [zones=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.MIN_VALUE]\n * @param {number} [options.to=Number.MAX_VALUE]\n */\n\nexport function zonesNormalize(zones = [], options = {}) {\n  if (zones.length === 0) return [];\n  zones = JSON.parse(JSON.stringify(zones)).map((zone) =>\n    zone.from > zone.to ? { from: zone.to, to: zone.from } : zone,\n  );\n  let { from = Number.NEGATIVE_INFINITY, to = Number.POSITIVE_INFINITY } =\n    options;\n  if (from > to) {\n    [from, to] = [to, from];\n  }\n\n  zones = zones.sort((a, b) => {\n    if (a.from !== b.from) return a.from - b.from;\n    return a.to - b.to;\n  });\n\n  zones.forEach((zone) => {\n    if (from > zone.from) zone.from = from;\n    if (to < zone.to) zone.to = to;\n  });\n\n  zones = zones.filter((zone) => zone.from <= zone.to);\n  if (zones.length === 0) return [];\n\n  let currentZone = zones[0];\n  let result = [currentZone];\n  for (let zone of zones) {\n    if (zone.from <= currentZone.to) {\n      currentZone.to = zone.to;\n    } else {\n      currentZone = zone;\n      result.push(currentZone);\n    }\n  }\n  return result;\n}\n","import { zonesNormalize } from '../zones/zonesNormalize';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * xyExtract zones from a XY data\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {Array} [options.zones=[]]\n * @return {Array} Array of points\n */\n\nexport function xyExtract(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  let { zones } = options;\n\n  zones = zonesNormalize(zones);\n\n  if (!Array.isArray(zones) || zones.length === 0) return data;\n\n  let newX = [];\n  let newY = [];\n\n  let currentZone = zones[0];\n  let position = 0;\n  loop: for (let i = 0; i < x.length; i++) {\n    while (currentZone.to < x[i]) {\n      position++;\n      currentZone = zones[position];\n      if (!currentZone) {\n        i = x.length;\n        break loop;\n      }\n    }\n    if (x[i] >= currentZone.from) {\n      newX.push(x[i]);\n      newY.push(y[i]);\n    }\n  }\n  return { x: newX, y: newY };\n}\n","import { xyCheck } from './xyCheck';\n/**\n * Filter out all the points for which x <= 0. Useful to display log scale data\n * @param {DataXY} [data={}]\n * @return {{x:[],y:[]}} An object with the filtered data\n */\n\nexport function xyFilterXPositive(data = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  const newX = [];\n  const newY = [];\n  for (let i = 0; i < x.length; i++) {\n    if (x[i] > 0) {\n      newX.push(x[i]);\n      newY.push(y[i]);\n    }\n  }\n\n  return { x: newX, y: newY };\n}\n","import { xyCheck } from './xyCheck';\n\n/**\n * Returns the numberMaxPoints points with the bigger y.\n * @param {DataXY} data - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {number} numberMaxPoints Number of points to keep\n * @returns {object} The points filtered to keep the `numberMaxPoints` most intense points of the input\n */\nexport function xyGetNMaxY(data, numberMaxPoints) {\n  xyCheck(data);\n  if (data.x.length <= numberMaxPoints) {\n    return data;\n  } else {\n    let newX = new Array(numberMaxPoints);\n    let newY = new Array(numberMaxPoints);\n\n    // slice() is used to make a copy of the array, because sort() is IPM\n    let threshold = data.y.slice().sort((a, b) => b - a)[numberMaxPoints - 1];\n\n    let index = 0;\n    for (let i = 0; i < data.x.length; i++) {\n      if (data.y[i] >= threshold) {\n        newX[index] = data.x[i];\n        newY[index] = data.y[i];\n        index++;\n      }\n      if (index === numberMaxPoints) {\n        return { x: newX, y: newY };\n      }\n    }\n  }\n}\n","/**\n * Order object of array, x has to be monotone.\n * Ensure x is growing\n * @param {DataXY} data Object of kind {x:[], y:[]}.\n * @return {SD}\n */\n\nexport function xyGrowingX(data) {\n  const { x, y } = data;\n\n  if (x.length !== y.length) {\n    throw TypeError('sortX: length of x and y must be identical');\n  }\n\n  if (x.length < 2 || x[0] < x[1]) return data;\n\n  return {\n    x: x.slice(0).reverse(),\n    y: y.slice(0).reverse(),\n  };\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n/**\n * Generate a X / Y of the xyIntegral\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @param {boolean} [options.reverse=false] - Integrate from the larger value to the smallest value\n * @return {{x:[],y:[]}} An object with the xyIntegration function\n */\n\nexport function xyIntegral(data = {}, options = {}) {\n  const { reverse = false } = options;\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n\n  let xyIntegration = 0;\n  let currentxyIntegral;\n  if (reverse) {\n    currentxyIntegral = { x: [x[toIndex]], y: [0] };\n    for (let i = toIndex; i > fromIndex; i--) {\n      xyIntegration += ((x[i] - x[i - 1]) * (y[i - 1] + y[i])) / 2;\n      currentxyIntegral.x.push(x[i - 1]);\n      currentxyIntegral.y.push(xyIntegration);\n    }\n    currentxyIntegral.x.reverse();\n    currentxyIntegral.y.reverse();\n  } else {\n    currentxyIntegral = { x: [x[fromIndex]], y: [0] };\n    for (let i = fromIndex; i < toIndex; i++) {\n      xyIntegration += ((x[i + 1] - x[i]) * (y[i + 1] + y[i])) / 2;\n      currentxyIntegral.x.push(x[i + 1]);\n      currentxyIntegral.y.push(xyIntegration);\n    }\n  }\n\n  return currentxyIntegral;\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * Calculate integration\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number} xyIntegration value on the specified range\n */\n\nexport function xyIntegration(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n  let currentxyIntegration = 0;\n  for (let i = fromIndex; i < toIndex; i++) {\n    currentxyIntegration += ((x[i + 1] - x[i]) * (y[i + 1] + y[i])) / 2;\n  }\n\n  return currentxyIntegration;\n}\n","import { xFindClosestIndex } from '../x/xFindClosestIndex';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * Find the closest maximum going up hill\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.target]\n * @param {number} [options.targetIndex=0]\n * @return {{x,y,xIndex}} An object with the x/y value\n */\n\nexport function xyMaxClosestYPoint(data, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n\n  let { target, targetIndex } = options;\n\n  if (targetIndex === undefined) {\n    if (target !== undefined) {\n      targetIndex = xFindClosestIndex(x, target);\n    } else {\n      targetIndex = 0;\n    }\n  }\n\n  let previousIndex = Number.MIN_SAFE_INTEGER;\n  let currentIndex = targetIndex;\n\n  let xyMaxY = y[targetIndex];\n\n  while (currentIndex !== previousIndex) {\n    previousIndex = currentIndex;\n    if (currentIndex > 0 && y[currentIndex - 1] > xyMaxY) {\n      currentIndex--;\n    } else if (currentIndex < x.length - 1 && y[currentIndex + 1] > xyMaxY) {\n      currentIndex++;\n    }\n    xyMaxY = y[currentIndex];\n  }\n  return {\n    x: x[currentIndex],\n    y: y[currentIndex],\n    index: currentIndex,\n  };\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n/**\n * Finds the max value in a zone\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {number} Max y on the specified range\n */\n\nexport function xyMaxY(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n\n  let currentxyMaxY = y[fromIndex];\n  for (let i = fromIndex; i <= toIndex; i++) {\n    if (y[i] > currentxyMaxY) currentxyMaxY = y[i];\n  }\n\n  return currentxyMaxY;\n}\n","import { xyCheck } from './xyCheck';\n/**\n * Finds all the max values\n * If the values are equal the middle\n * of the equal part will be the position of the signal!\n *\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {Array} Array of points\n */\n\nexport function xyMaximaY(data = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 3) return [];\n  let maxima = [];\n  let startEqualIndex = -1;\n  for (let i = 1; i < x.length - 1; i++) {\n    if (y[i - 1] < y[i] && y[i + 1] < y[i]) {\n      maxima.push({ x: x[i], y: y[i], index: i });\n    } else if (y[i - 1] < y[i] && y[i + 1] === y[i]) {\n      startEqualIndex = i;\n    } else if (y[i - 1] === y[i] && y[i + 1] < y[i]) {\n      let index = ((i + startEqualIndex) / 2) >> 0;\n      maxima.push({ x: x[index], y: y[index], index });\n    }\n  }\n  return maxima;\n}\n","/* *\n * Finds the median x value for an object with properties x and y (arrays of the same length)\n * @param {object} data x should be sorted in increasing order\n * @returns {number} the median of x values\n */\n\nexport function xyMedian(data) {\n  const { x, y } = data;\n\n  let sumY = 0;\n  let cumSumY = 0;\n  let i;\n\n  if (x.length === 0) {\n    return NaN;\n  }\n\n  if (x.length === 1) {\n    return x[0];\n  }\n\n  for (i = 0; i < y.length; i++) {\n    sumY += y[i];\n  }\n\n  for (i = 0; i < y.length; i++) {\n    cumSumY += y[i];\n    if (cumSumY > sumY / 2) {\n      return x[i];\n    } else if (cumSumY === sumY / 2) {\n      return 0.5 * (x[i] + x[i + 1]);\n    }\n  }\n}\n","import { xFindClosestIndex } from '../x/xFindClosestIndex';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * Find the closest minimum going down hill\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.target]\n * @param {number} [options.targetIndex=0]\n * @return {{x,y,xIndex}} An object with the x/y value\n */\n\nexport function xyMinClosestYPoint(data, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n\n  let { target, targetIndex } = options;\n\n  if (targetIndex === undefined) {\n    if (target !== undefined) {\n      targetIndex = xFindClosestIndex(x, target);\n    } else {\n      targetIndex = 0;\n    }\n  }\n\n  let previousIndex = Number.MIN_SAFE_INTEGER;\n  let currentIndex = targetIndex;\n\n  let minY = y[targetIndex];\n\n  while (currentIndex !== previousIndex) {\n    previousIndex = currentIndex;\n    if (currentIndex > 0 && y[currentIndex - 1] < minY) {\n      currentIndex--;\n    } else if (currentIndex < x.length - 1 && y[currentIndex + 1] < minY) {\n      currentIndex++;\n    }\n    minY = y[currentIndex];\n  }\n  return {\n    x: x[currentIndex],\n    y: y[currentIndex],\n    index: currentIndex,\n  };\n}\n","import { xGetFromToIndex } from '../x/xGetFromToIndex';\n\nimport { xyCheck } from './xyCheck';\n/**\n * Finds the max y value in a range and return a {x,y} point\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from] - First value for xyIntegration in the X scale\n * @param {number} [options.fromIndex=0] - First point for xyIntegration\n * @param {number} [options.to] - Last value for xyIntegration in the X scale\n * @param {number} [options.toIndex=x.length-1] - Last point for xyIntegration\n * @return {object}\n */\n\nexport function xyMinYPoint(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 2) return 0;\n\n  const { fromIndex, toIndex } = xGetFromToIndex(x, options);\n\n  let current = { x: x[fromIndex], y: y[fromIndex], index: fromIndex };\n  for (let i = fromIndex; i <= toIndex; i++) {\n    if (y[i] < current.y) current = { x: x[i], y: y[i], index: i };\n  }\n\n  return current;\n}\n","import { xyCheck } from './xyCheck';\n/**\n * Finds all the min values\n * If the values are equal the middle\n * of the equal part will be the position of the signal!\n *\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {Array} Array of points\n */\n\nexport function xyMinimaY(data = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 3) return [];\n  let maxima = [];\n  let startEqualIndex = -1;\n  for (let i = 1; i < x.length - 1; i++) {\n    if (y[i - 1] > y[i] && y[i + 1] > y[i]) {\n      maxima.push({ x: x[i], y: y[i], index: i });\n    } else if (y[i - 1] > y[i] && y[i + 1] === y[i]) {\n      startEqualIndex = i;\n    } else if (y[i - 1] === y[i] && y[i + 1] > y[i]) {\n      let index = ((i + startEqualIndex) / 2) >> 0;\n      maxima.push({ x: x[index], y: y[index], index });\n    }\n  }\n  return maxima;\n}\n","import { xFindClosestIndex } from '../x/xFindClosestIndex';\n\nimport { xyCheck } from './xyCheck';\n\n/**\n * Returns an information about a signal\n *\n * We expect ordered data and equidistant X axis\n * You can use the method helper if required:\n * ML.ArrayPoints.uniqueX\n * ML.ArrayPoints.sortX\n * ML.ArrayPoints.equallySpaced\n *\n * @param {object} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.target]\n * @param {number} [options.targetIndex]\n * @return {object} Information about signal\n */\n\nexport function xyPeakInfo(data = {}, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  if (x.length < 3) return undefined;\n  let { targetIndex, target } = options;\n  if (targetIndex === undefined) {\n    if (target !== undefined) {\n      targetIndex = xFindClosestIndex(x, target);\n    }\n  }\n\n  if (targetIndex === undefined) {\n    throw new Error('xyPeakInfo: need to specify target or targetIndex');\n  }\n\n  let i = targetIndex;\n  let currentDiff = y[i] - y[i + 1];\n\n  let multiplier = currentDiff < 0 ? -1 : 1;\n  currentDiff *= multiplier;\n  while (i < x.length - 1) {\n    i++;\n    let newDiff = (y[i] - y[i + 1]) * multiplier;\n    if (newDiff < currentDiff) break;\n    currentDiff = newDiff;\n  }\n  let after = { x: x[i], y: y[i] };\n\n  i = targetIndex;\n  currentDiff = (y[i] - y[i - 1]) * multiplier;\n  while (i > 1) {\n    i--;\n    let newDiff = (y[i] - y[i - 1]) * multiplier;\n    if (newDiff < currentDiff) break;\n    currentDiff = newDiff;\n  }\n  let before = { x: x[i], y: y[i] };\n\n  return {\n    inflectionBefore: before,\n    inflectionAfter: after,\n    extrema: { x: x[targetIndex], y: y[targetIndex] },\n    inflectionMiddle: {\n      x: (before.x + after.x) / 2,\n      y: (before.y + after.y) / 2,\n    },\n    width: Math.abs(before.x - after.x),\n  };\n}\n","import { xGetTargetIndex } from '../x/xGetTargetIndex';\n\nimport { xyCheck } from './xyCheck';\n/**\n * Find the closest minimum going down hill\n * @param {object} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.target]\n * @param {number} [options.targetIndex=0]\n * @return {{x,y,xIndex}} An object with the x/y value\n */\n\nexport function xyRealMaxYPoint(data, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  const targetIndex = xGetTargetIndex(x, options);\n  // interpolation to a sin() function\n  if (\n    y[targetIndex - 1] > 0 &&\n    y[targetIndex + 1] > 0 &&\n    y[targetIndex] >= y[targetIndex - 1] &&\n    y[targetIndex] >= y[targetIndex + 1]\n  ) {\n    let alpha = 20 * Math.log10(y[targetIndex - 1]);\n    let beta = 20 * Math.log10(y[targetIndex]);\n    let gamma = 20 * Math.log10(y[targetIndex + 1]);\n    let p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n    return {\n      x: x[targetIndex] + (x[targetIndex] - x[targetIndex - 1]) * p,\n      y: y[targetIndex] - 0.25 * (y[targetIndex - 1] - y[targetIndex + 1]) * p,\n      index: targetIndex,\n    };\n  } else {\n    return {\n      x: x[targetIndex],\n      y: y[targetIndex],\n      index: targetIndex,\n    };\n  }\n}\n","import { xGetTargetIndex } from '../x/xGetTargetIndex';\n\nimport { xyCheck } from './xyCheck';\n\nexport function xyRealMinYPoint(data, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n\n  const targetIndex = xGetTargetIndex(x, options);\n  // interpolation to a sin() function\n  if (\n    y[targetIndex - 1] < 0 &&\n    y[targetIndex + 1] < 0 &&\n    y[targetIndex] <= y[targetIndex - 1] &&\n    y[targetIndex] <= y[targetIndex + 1]\n  ) {\n    let alpha = 20 * Math.log10(-y[targetIndex - 1]);\n    let beta = 20 * Math.log10(-y[targetIndex]);\n    let gamma = 20 * Math.log10(-y[targetIndex + 1]);\n    let p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n    return {\n      x: x[targetIndex] + (x[targetIndex] - x[targetIndex - 1]) * p,\n      y: y[targetIndex] - 0.25 * (y[targetIndex - 1] - y[targetIndex + 1]) * p,\n      index: targetIndex,\n    };\n  } else {\n    return {\n      x: x[targetIndex],\n      y: y[targetIndex],\n      index: targetIndex,\n    };\n  }\n}\n","import { xFindClosestIndex } from '../x/xFindClosestIndex';\nimport { zonesNormalize } from '../zones/zonesNormalize';\n\nimport { xyCheck } from './xyCheck';\n/**\n * xyReduce the number of points while keeping visually the same noise. Practical to\n * display many spectra as SVG.\n * SHOULD NOT BE USED FOR DATA PROCESSING !!!\n * You should rather use ml-xy-equally-spaced to make further processing\n * @param {DataXY} [data={}] - Object that contains property x (an ordered increasing array) and y (an array)\n * @param {object} [options={}]\n * @param {number} [options.from=x[0]]\n * @param {number} [options.to=x[x.length-1]]\n * @param {number} [options.nbPoints=4001] Number of points\n * @param {number} [options.zones=[]] Array of zones to keep (from/to object)\n * @param {number} [options.optimize=false] If optimize we may have less than nbPoints at the end\n */\n\nexport function xyReduce(data, options = {}) {\n  xyCheck(data);\n  const { x, y } = data;\n  let {\n    from = x[0],\n    to = x[x.length - 1],\n    nbPoints = 4001,\n    optimize = false,\n    zones = [],\n  } = options;\n\n  zones = zonesNormalize(zones, { from, to });\n  if (zones.length === 0) zones = [{ from, to }]; // we take everything\n\n  // for each zone we should know the first index, the last index and the number of points\n\n  let totalPoints = 0;\n  for (let zone of zones) {\n    zone.fromIndex = xFindClosestIndex(x, zone.from);\n    zone.toIndex = xFindClosestIndex(x, zone.to);\n    if (zone.fromIndex > 0 && x[zone.fromIndex] > zone.from) {\n      zone.fromIndex--;\n    }\n    if (zone.toIndex < x.length - 1 && x[zone.toIndex] < zone.to) {\n      zone.toIndex++;\n    }\n\n    zone.nbPoints = zone.toIndex - zone.fromIndex + 1;\n    totalPoints += zone.nbPoints;\n  }\n  // we calculate the number of points per zone that we should keep\n  if (totalPoints > nbPoints) {\n    // need to xyReduce number of points\n    let ratio = nbPoints / totalPoints;\n    let currentTotal = 0;\n    for (let i = 0; i < zones.length - 1; i++) {\n      const zone = zones[i];\n      zone.nbPoints = Math.round(zone.nbPoints * ratio);\n      currentTotal += zone.nbPoints;\n    }\n    zones[zones.length - 1].nbPoints = nbPoints - currentTotal;\n  } else {\n    let newX = new Float64Array(totalPoints);\n    let newY = new Float64Array(totalPoints);\n    let index = 0;\n    for (let zone of zones) {\n      for (let i = zone.fromIndex; i < zone.toIndex + 1; i++) {\n        newX[index] = x[i];\n        newY[index] = y[i];\n        index++;\n      }\n    }\n    return {\n      x: newX,\n      y: newY,\n    };\n  }\n\n  let newX = [];\n  let newY = [];\n  for (let zone of zones) {\n    if (!zone.nbPoints) continue;\n    appendFromTo(zone.fromIndex, zone.toIndex, zone.nbPoints);\n  }\n  return { x: newX, y: newY };\n\n  function appendFromTo(fromIndex, toIndex, zoneNbPoints) {\n    if (zoneNbPoints === 1) {\n      newX.push(x[Math.round((toIndex - fromIndex) / 2)]);\n      newY.push(y[Math.round((toIndex - fromIndex) / 2)]);\n      return;\n    }\n    if (zoneNbPoints === 2) {\n      newX.push(x[fromIndex], x[toIndex]);\n      newY.push(y[fromIndex], y[toIndex]);\n      return;\n    }\n    newX.push(x[fromIndex]);\n    newY.push(y[fromIndex]);\n    let minY = Number.MAX_VALUE;\n    let xyMaxY = Number.MIN_VALUE;\n    if (zoneNbPoints % 2 === 0) {\n      zoneNbPoints = zoneNbPoints / 2 + 1;\n    } else {\n      zoneNbPoints = (zoneNbPoints - 1) / 2 + 1;\n    }\n\n    // we will need to make some kind of min / max because there are too many points\n    // we will always keep the first point and the last point\n    let slot = (x[toIndex] - x[fromIndex]) / (zoneNbPoints - 1);\n    let currentX = x[fromIndex] + slot;\n    let first = true;\n    for (let i = fromIndex + 1; i <= toIndex; i++) {\n      if (first) {\n        minY = y[i];\n        xyMaxY = y[i];\n        first = false;\n      } else {\n        if (y[i] < minY) minY = y[i];\n        if (y[i] > xyMaxY) xyMaxY = y[i];\n      }\n      if (x[i] >= currentX || i === toIndex) {\n        if (optimize) {\n          if (minY > newY[newX.length - 1]) {\n            // we can skip the intermediate value\n          } else if (xyMaxY < newY[newX.length - 1]) {\n            // we can skip the intermediate value\n            xyMaxY = minY;\n          } else {\n            newX.push(currentX - slot / 2);\n            newY.push(minY);\n          }\n        } else {\n          newX.push(currentX - slot / 2);\n          newY.push(minY);\n        }\n\n        newX.push(currentX);\n        newY.push(xyMaxY);\n\n        currentX += slot;\n        first = true;\n      }\n    }\n  }\n}\n","import { xRolling } from '../x/xRolling';\nimport { xRollingAverage } from '../x/xRollingAverage';\n/**\n * This function calculates a rolling average\n *\n * This methods will recalculate the x values by using xRollingAverage\n * @param {ArrayPoints} [points] array of points {x,y}\n * @param {object} [options={}]\n * @param {number} [options.window=5] rolling window\n * @param {function} [fct] callback function that from an array returns a value.\n * @param {string} [options.padding.size=0] none, value, circular, duplicate\n * @param {string} [options.padding.algorithm='value'] none, value, circular, duplicate\n * @param {number} [options.padding.value=0] value to use for padding (if algorithm='value')\n * @return {Array<Number>}\n */\nexport function xyRolling(points, fct, options = {}) {\n  let { x, y } = points;\n\n  y = xRolling(y, fct, options);\n\n  if (x.length !== y.length) {\n    x = xRollingAverage(x, options);\n  }\n\n  return { x, y };\n}\n","import { xyCheck } from './xyCheck';\n\n/**\n *\n * @param {DataXY} [data] array of points {x,y}\n * @returns {DataPoints}\n */\nexport function xyToXYObject(data) {\n  xyCheck(data);\n  const { x, y } = data;\n  let objectArray = [];\n  for (let i = 0; i < x.length; i++) {\n    objectArray.push({ x: x[i], y: y[i] });\n  }\n  return objectArray;\n}\n","import { xyCheck } from './xyCheck';\n\n/**\n * Convert a DataXY to an array of array containing x,y\n * @param {DataXY} [data] array of points {x,y}\n * @returns {Array<Array<number,number>>}\n */\nexport function xyToXYArray(data) {\n  xyCheck(data);\n  const { x, y } = data;\n  let objectArray = [];\n  for (let i = 0; i < x.length; i++) {\n    objectArray.push([x[i], y[i]]);\n  }\n\n  return objectArray;\n}\n","import mean from 'ml-array-mean';\nimport { gsd } from 'ml-gsd';\n\nimport { xFindClosestIndex } from '../x/xFindClosestIndex';\n\n/**\n * Calibrates the data based on a range and means of peaks in this range\n * Based on a range we will make a peak picking using global spectra deconvolution\n * The selected nbPeaks will then be taken into account to calculate an average X value.\n * The difference between the targetX and the averageX value will be returned\n * @param {DataXY} [data] array of points {x,y}\n * @param {Object} [range={}]\n * @param {number} [range.from] - Beginning of the range where the interest signal is localed\n * @param {number} [range.to] - End of the range where the interest signal is localed\n * @param {Object} [options={}]\n * @param {number} [options.nbPeaks=1] Number of peaks to consider to calculate mean (sorted by height)\n * @param {number} [options.targetX=0] Expected value for the mean of the peaks position\n * @param {number} [options.gsd={}] GSD options. You may check options here: http://mljs.github.io/global-spectral-deconvolution/#gsd\n * @param {number} [options.gsd.minMaxRatio=0.2] - GSD Threshold to determine if a given peak should be considered as a noise.\n * @returns {number} difference between targetX and currentX\n */\n\nexport function xyCalibrate(data, range = {}, options = {}) {\n  const {\n    targetX = 0,\n    nbPeaks = 1,\n    gsd: gsdOptions = {\n      minMaxRatio: 0.1,\n      realTopDetection: true,\n      smoothY: true,\n      sgOptions: {\n        windowSize: 7,\n        polynomial: 3,\n      },\n    },\n  } = options;\n  let { from, to } = range;\n  if (from === undefined || to === undefined) return 0;\n\n  const fromIndex = xFindClosestIndex(data.x, from);\n  const toIndex = xFindClosestIndex(data.x, to);\n  const sliceddata = {\n    x: data.x.slice(fromIndex, toIndex),\n    y: data.y.slice(fromIndex, toIndex),\n  };\n\n  let peaks = gsd(sliceddata, gsdOptions)\n    .sort((a, b) => b.y - a.y)\n    .slice(0, nbPeaks);\n\n  if (peaks.length === 0) return 0;\n\n  const middle = mean(peaks.map((peak) => peak.x));\n\n  return targetX - middle;\n}\n","import { xIsMonotone } from '../x/xIsMonotone';\n/**\nimport { xIsMonotone } from '../x/xIsMonotone';\n * This function performs a quick sort of the x array while transforming the y array to preserve the coordinates.\n * @param {DataXY} [data] Object that contains property x (Array) and y (Array)\n */\nexport function xySortX(data) {\n  const { x, y } = data;\n\n  // no need to sort if it is already sorted\n  if (xIsMonotone(x) && x.length > 1) {\n    if (x[0] < x[1]) {\n      return {\n        x: Float64Array.from(x),\n        y: Float64Array.from(y),\n      };\n    } else {\n      return {\n        x: Float64Array.from(x).reverse(),\n        y: Float64Array.from(y).reverse(),\n      };\n    }\n  }\n\n  let xyObject = x\n    .map((val, index) => ({\n      x: val,\n      y: y[index],\n    }))\n    .sort((a, b) => a.x - b.x);\n\n  let response = {\n    x: new Float64Array(x.length),\n    y: new Float64Array(y.length),\n  };\n  for (let i = 0; i < x.length; i++) {\n    response.x[i] = xyObject[i].x;\n    response.y[i] = xyObject[i].y;\n  }\n\n  return response;\n}\n","import { xyCheck } from './xyCheck';\nimport { xySortX } from './xySortX';\n\n/**\n * Ensure x values are unique\n * @param {DataXY} [data] Object that contains property x (Array) and y (Array)\n * @param {Object} [options={}] Object containing a property algorithm (can be 'sum' or 'average', the latter being the default value), and a property isSorted (boolean indicating if the x-array is sorted).\n * @param {string} [options.algorithm='average'] either 'average' or 'sum'\n * @param {boolean} [options.isSorted=true] if false the DataXY has to be sorted first\n * @returns {DataXY}\n */\nexport function xyUniqueX(data, options = {}) {\n  xyCheck(data);\n\n  const { algorithm = 'average', isSorted = true } = options;\n\n  if (!isSorted) {\n    data = xySortX(data);\n  }\n\n  switch (algorithm) {\n    case 'average':\n      return average(data);\n    case 'sum':\n      return sum(data);\n    default:\n      throw new Error(`xyUniqueX: unknown algorithm: ${algorithm}`);\n  }\n}\n\nfunction average(data) {\n  let x = [];\n  let y = [];\n  let cumulativeY = data.y[0];\n  let divider = 1;\n  for (let i = 1; i < data.x.length; i++) {\n    if (!(data.x[i] === data.x[i - 1])) {\n      x.push(data.x[i - 1]);\n      y.push(cumulativeY / divider);\n      cumulativeY = 0;\n      divider = 0;\n    }\n    cumulativeY += data.y[i];\n    divider++;\n  }\n  x.push(data.x[data.x.length - 1]);\n  y.push(cumulativeY / divider);\n  return { x, y };\n}\n\nfunction sum(data) {\n  let x = [];\n  let y = [];\n  let cumulativeY = data.y[0];\n  for (let i = 1; i < data.x.length; i++) {\n    if (!(data.x[i] === data.x[i - 1])) {\n      x.push(data.x[i - 1]);\n      y.push(cumulativeY);\n      cumulativeY = 0;\n    }\n    cumulativeY += data.y[i];\n  }\n  x.push(data.x[data.x.length - 1]);\n  y.push(cumulativeY);\n  return { x, y };\n}\n","/**\n * Throw an error in no an object of x,y arrays\n * @param {ArrayPoints} [points=[]]\n */\nexport function xyObjectCheck(points = []) {\n  if (!Array.isArray(points)) {\n    throw new Error('ArrayPoints must be an array of {x,y} object');\n  }\n  if (\n    points.length > 0 &&\n    (points[0].x === undefined || points[0].y === undefined)\n  ) {\n    throw new Error('ArrayPoints must be an array of {x,y} object');\n  }\n}\n","import { xyObjectCheck } from './xyObjectCheck';\n/**\n * Finds the max x value and return a {x,y,index} point\n * @param {DataXY} [points=[]] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {object}\n */\n\nexport function xyObjectMaxXPoint(points = []) {\n  xyObjectCheck(points);\n\n  if (points.length < 1) return {};\n\n  let current = {\n    x: points[0].x,\n    y: points[0].y,\n    index: 0,\n  };\n\n  for (let i = 1; i < points.length; i++) {\n    if (points[i].x > current.x) {\n      current = {\n        x: points[i].x,\n        y: points[i].y,\n        index: i,\n      };\n    }\n  }\n\n  return current;\n}\n","import { xyObjectCheck } from './xyObjectCheck';\n\n/**\n * Finds the min x value and return a {x,y,index} point\n * @param {DataXY} [points=[]] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {object}\n */\n\nexport function xyObjectMinXPoint(points = []) {\n  xyObjectCheck(points);\n\n  if (points.length < 1) return {};\n\n  let current = {\n    x: points[0].x,\n    y: points[0].y,\n    index: 0,\n  };\n\n  for (let i = 1; i < points.length; i++) {\n    if (points[i].x < current.x) {\n      current = {\n        x: points[i].x,\n        y: points[i].y,\n        index: i,\n      };\n    }\n  }\n\n  return current;\n}\n","import { xyObjectMaxXPoint } from './xyObjectMaxXPoint';\nimport { xyObjectMinXPoint } from './xyObjectMinXPoint';\n\n/**\n * Filter the array by taking the higher points (max y value) and only\n * keep one per slot.\n * There are 2 different slots, the smallest one will have the\n * new property `close` to true\n * @param {array} points - array of all the points\n * @param {object} [options={}]\n * @param {number} [options.from] - min X value of the window to consider\n * @param {number} [options.to] - max X value of the window to consider\n * @param {number} [options.limit=20] - max number of points\n * @param {number} [options.threshold=0.01] - minimal intensity compare to more intense point\n * @param {number} [options.numberSlots=10] - define the number of slots and indirectly the slot width\n * @param {number} [options.numberCloseSlots=50]\n * @returns {array} - copy of points with 'close' property\n */\n\nexport function xyObjectBestPoints(points, options = {}) {\n  const {\n    from = xyObjectMinXPoint(points).x,\n    to = xyObjectMaxXPoint(points).x,\n    limit = 20,\n    threshold = 0.01,\n    numberCloseSlots = 50,\n    numberSlots = 10,\n  } = options;\n  let slot = (to - from) / numberSlots;\n  let closeSlot = (to - from) / numberCloseSlots;\n  let selected = points\n    .filter((point) => point.x >= from && point.x <= to)\n    .map((point) => {\n      return {\n        point,\n        monoisotopic: false,\n      };\n    });\n\n  selected = selected.sort((a, b) => {\n    if (a.monoisotopic && !b.monoisotopic) return -1;\n    if (b.monoisotopic && !a.monoisotopic) return 1;\n    return b.point.y - a.point.y;\n  });\n\n  let toReturn = [];\n  if (selected.length === 0) return [];\n  let minY = selected[0].point.y * threshold;\n  peakLoop: for (let item of selected) {\n    if (item.point.y < minY) {\n      if (item.monoisotopic) {\n        continue;\n      } else {\n        break;\n      }\n    }\n    let close = false;\n    for (let existing of toReturn) {\n      if (Math.abs(existing.x - item.point.x) < closeSlot) {\n        continue peakLoop;\n      }\n      if (Math.abs(existing.x - item.point.x) < slot) {\n        close = true;\n      }\n    }\n    let newPeak = JSON.parse(JSON.stringify(item.point));\n    newPeak.close = close;\n    toReturn.push(newPeak);\n    if (toReturn.length === limit) break;\n  }\n  return toReturn.sort((a, b) => a.x - b.x);\n}\n","/**\n *\n * @param {ArrayPoints} [points] array of growing points {x,y}\n * @param {object} [options={}]\n * @param {object} [xError=Number.EPSILON] limit to join the data\n */\nexport function xyObjectJoinX(points, options = {}) {\n  const { xError = Number.EPSILON } = options;\n\n  // when we join we will use the center of mass\n  let result = [];\n  let current = {\n    x: Number.MIN_SAFE_INTEGER,\n    y: 0,\n  };\n  for (let point of points) {\n    if (point.x - current.x <= xError) {\n      // weighted sum\n      if (current.y !== 0 || point.y !== 0) {\n        current.x =\n          (point.y / (current.y + point.y)) * (point.x - current.x) + current.x;\n        current.y += point.y;\n      }\n    } else {\n      current = {\n        x: point.x,\n        y: point.y,\n      };\n      result.push(current);\n    }\n  }\n  return result;\n}\n","import { xyObjectCheck } from './xyObjectCheck';\n/**\n * Finds the max y value and return a {x,y,index} point\n * @param {DataXY} [points=[]] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {object}\n */\n\nexport function xyObjectMaxYPoint(points = []) {\n  xyObjectCheck(points);\n\n  if (points.length < 1) return {};\n\n  let current = {\n    x: points[0].x,\n    y: points[0].y,\n    index: 0,\n  };\n\n  for (let i = 1; i < points.length; i++) {\n    if (points[i].y > current.y) {\n      current = {\n        x: points[i].x,\n        y: points[i].y,\n        index: i,\n      };\n    }\n  }\n\n  return current;\n}\n","import { xyObjectCheck } from './xyObjectCheck';\n\n/**\n * Finds the min y value and return a {x,y,index} point\n * @param {DataXY} [points=[]] - Object that contains property x (an ordered increasing array) and y (an array)\n * @return {object}\n */\n\nexport function xyObjectMinYPoint(points = []) {\n  xyObjectCheck(points);\n\n  if (points.length < 1) return {};\n\n  let current = {\n    x: points[0].x,\n    y: points[0].y,\n    index: 0,\n  };\n\n  for (let i = 1; i < points.length; i++) {\n    if (points[i].y < current.y) {\n      current = {\n        x: points[i].x,\n        y: points[i].y,\n        index: i,\n      };\n    }\n  }\n\n  return current;\n}\n","/**\n *\n * @param {ArrayPoints} [points] array of growing points {x,y}\n * @param {object} [options={}]\n * @param {object} [slotWidth=1] limit to join the data\n */\nexport function xyObjectSlotX(points, options = {}) {\n  const { slotWidth = 1 } = options;\n  const halfSlot = slotWidth / 2;\n\n  // when we join we will use the center of mass\n  let result = [];\n  let current = {\n    x: Number.MIN_VALUE,\n    y: 0,\n  };\n  for (let point of points) {\n    let slot = point.x - ((point.x + halfSlot) % slotWidth) + halfSlot;\n    if (Math.abs(current.x - slot) > Number.EPSILON) {\n      current = {\n        x: slot,\n        y: 0,\n      };\n      result.push(current);\n    }\n    current.y += point.y;\n  }\n  return result;\n}\n","/**\n * Sorts an array of points\n * @param {ArrayPoints} [points] array of points {x,y}\n */\n\nexport function xyObjectSortX(points) {\n  return points.sort((a, b) => a.x - b.x);\n}\n","/**\n *\n * @param {ArrayPoints} [points] array of points {x,y}\n */\nexport function xyObjectToXY(points) {\n  return {\n    x: points.map((entry) => entry.x),\n    y: points.map((entry) => entry.y),\n  };\n}\n","export function zoneToX(zone, size) {\n  const { from, to } = zone;\n  let array = new Float64Array(size);\n  let step = (to - from) / (size - 1);\n  for (let i = 0; i < size; i++) {\n    array[i] = from + step * i;\n  }\n  return array;\n}\n","/**\n * Center mean of columns\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n */\nexport function matrixCenterZMean(matrix) {\n  const nbRows = matrix.length;\n  const nbColumns = matrix[0].length;\n  const newMatrix = new Array(nbRows);\n  for (let row = 0; row < nbRows; row++) {\n    newMatrix[row] = new Float64Array(nbColumns);\n  }\n  for (let column = 0; column < nbColumns; column++) {\n    let mean = 0;\n    for (let row = 0; row < nbRows; row++) {\n      mean += matrix[row][column];\n    }\n    mean /= nbRows;\n    for (let row = 0; row < nbRows; row++) {\n      newMatrix[row][column] = matrix[row][column] - mean;\n    }\n  }\n  return newMatrix;\n}\n","/**\n * Get min and max of the absolute values of Z\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n *\n */\nexport function matrixMinMaxAbsoluteZ(matrix) {\n  if (matrix.length === 0 || matrix[0].length === 0) {\n    return { min: undefined, max: undefined };\n  }\n  const nbRows = matrix.length;\n  const nbColumns = matrix[0].length;\n\n  let min = Number.POSITIVE_INFINITY;\n  let max = Number.NEGATIVE_INFINITY;\n\n  for (let column = 0; column < nbColumns; column++) {\n    for (let row = 0; row < nbRows; row++) {\n      let value = matrix[row][column];\n      if (value < 0) value *= -1;\n      if (value < min) min = value;\n      if (value > max) max = value;\n    }\n  }\n\n  return { min, max };\n}\n","/**\n * Get min and max Z\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n *\n */\nexport function matrixMinMaxZ(matrix) {\n  if (matrix.length === 0 || matrix[0].length === 0) {\n    return { min: undefined, max: undefined };\n  }\n  const nbRows = matrix.length;\n  const nbColumns = matrix[0].length;\n\n  let min = matrix[0][0];\n  let max = matrix[0][0];\n\n  for (let column = 0; column < nbColumns; column++) {\n    for (let row = 0; row < nbRows; row++) {\n      if (matrix[row][column] < min) min = matrix[row][column];\n      if (matrix[row][column] > max) max = matrix[row][column];\n    }\n  }\n\n  return { min, max };\n}\n","import { xHistogram } from '../x/xHistogram';\n\nimport { matrixMinMaxAbsoluteZ } from './matrixMinMaxAbsoluteZ';\nimport { matrixMinMaxZ } from './matrixMinMaxZ';\n\n/**\nimport { matrixMinMaxZ } from './matrixMinMaxZ';\nimport { xHistogram } from '../x/xHistogram';\nimport { matrixMinMaxAbsoluteZ } from './matrixMinMaxAbsoluteZ';\n * Calculates an histogram of defined number of slots\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n * @param {number} [options.nbSlots=256] Number of slots\n * @param {number} [options.min=minValue] Minimum value to calculate used to calculate slot size\n * @param {number} [options.max=maxValue] Maximal value to calculate used to calculate slot size\n * @param {number} [options.logBaseX] We can first apply a log on x axi\n * @param {number} [options.logBaseY] We can apply a log on the resulting histogra\n * @param {boolean} [options.absolute] Take the absolute value\n * @param {number} [options.centerX=true] Center the X value. We will enlarge the first and\n * @return {DataXY} {x,y} of the histogram\n *\n */\n\nexport function matrixHistogram(matrix, options = {}) {\n  const { logBaseY, logBaseX, absolute } = options;\n  options = JSON.parse(JSON.stringify(options));\n  delete options.logBaseY;\n  if (matrix.length === 0 || matrix[0].length === 0) {\n    throw new Error(\n      'matrixHistogram: matrix should have at least one column and one row',\n    );\n  }\n\n  if (options.min === undefined || options.max === undefined) {\n    const minMax = absolute\n      ? matrixMinMaxAbsoluteZ(matrix)\n      : matrixMinMaxZ(matrix);\n    if (options.min === undefined) {\n      options.min = logBaseX\n        ? Math.log(minMax.min) / Math.log(logBaseX)\n        : minMax.min;\n    }\n    if (options.max === undefined) {\n      options.max = logBaseX\n        ? Math.log(minMax.max) / Math.log(logBaseX)\n        : minMax.max;\n    }\n  }\n\n  let histogram = xHistogram(matrix[0], options);\n  options.histogram = histogram;\n\n  const nbRows = matrix.length;\n  for (let row = 1; row < nbRows; row++) {\n    xHistogram(matrix[row], options);\n  }\n\n  const y = histogram.y;\n  if (logBaseY) {\n    const logOfBase = Math.log10(logBaseY);\n    for (let i = 0; i < y.length; i++) {\n      y[i] = Math.log10(y[i] + 1) / logOfBase;\n    }\n  }\n\n  return histogram;\n}\n","import median from 'ml-array-median';\nimport { Matrix } from 'ml-matrix';\n\n/**\n * Performs a Probabilistic quotient normalization (PQN) over the dataset to account dilution based in median spectrum.\n * Dieterle, F., Ross, A., Schlotterbeck, G., & Senn, H. (2006). Probabilistic quotient normalization as robust method to account for dilution of complex biological mixtures. Application in 1H NMR metabonomics. Analytical chemistry, 78(13), 4281-4290.\n * DOI: 10.1021/ac051632c\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n * @param {Object} [options={}]\n * @param {number} [options.max=100] - Normalization integral constant.\n * @return {Object} { data, medianOfQuotients }.\n * data: Normalized dataset.\n * medianOfQuotients: The median of quotients of each variables.\n */\nexport function matrixPQN(matrix, options = {}) {\n  const { max = 100 } = options;\n  matrix = new Matrix(matrix);\n  for (let i = 0; i < matrix.rows; i++) {\n    const normalizationFactor = matrix.getRowVector(i).norm() / max;\n    const row = matrix.getRowVector(i).div(normalizationFactor);\n    matrix.setRow(i, row);\n  }\n\n  let referenceSpectrum = [];\n  for (let i = 0; i < matrix.columns; i++) {\n    const currentVariable = matrix.getColumn(i);\n    referenceSpectrum.push(median(currentVariable));\n  }\n\n  let medianOfQuotients = [];\n  for (let i = 0; i < matrix.columns; i++) {\n    let quotients = matrix.getColumnVector(i).div(referenceSpectrum[i]);\n    medianOfQuotients.push(median(quotients.getColumn(0)));\n  }\n\n  for (let i = 0; i < matrix.rows; i++) {\n    matrix.mulRow(i, 1 / medianOfQuotients[i]);\n  }\n\n  return {\n    data: matrix.to2DArray(),\n    medianOfQuotients: medianOfQuotients,\n  };\n}\n","/**\n * Rescale columns\n * @param {Array<Array<Number>>} [matrix] - matrix [rows][cols].\n * @param {object} [options={}]\n * @param {object} [options.min=0]\n * @param {object} [options.max=1]\n *\n */\nexport function matrixZRescale(matrix, options = {}) {\n  const { min = 0, max = 1 } = options;\n  const nbRows = matrix.length;\n  const nbColumns = matrix[0].length;\n  const newMatrix = new Array(nbRows);\n  for (let row = 0; row < nbRows; row++) {\n    newMatrix[row] = new Float64Array(nbColumns);\n  }\n  for (let column = 0; column < nbColumns; column++) {\n    let currentMin = matrix[0][column];\n    let currentMax = matrix[0][column];\n    for (let row = 1; row < nbRows; row++) {\n      if (matrix[row][column] < currentMin) currentMin = matrix[row][column];\n      if (matrix[row][column] > currentMax) currentMax = matrix[row][column];\n    }\n\n    const factor = (max - min) / (currentMax - currentMin);\n\n    for (let row = 0; row < nbRows; row++) {\n      newMatrix[row][column] =\n        (matrix[row][column] - currentMin) * factor + min;\n    }\n  }\n  return newMatrix;\n}\n","/**\n * Create an array with sequential numbers between from and to of length\n * @param {number} [options.from=0]\n * @param {number} [options.to=1]\n * @param {number} [options.length=1001]\n */\nexport function createSequentialArray(options = {}) {\n  const { from = 0, to = 1, length = 1000 } = options;\n  const array = new Float64Array(length);\n  let step = (to - from) / (array.length - 1);\n  for (let i = 0; i < array.length; i++) {\n    array[i] = from + step * i;\n  }\n  return array;\n}\n","/**\n * @typedef {Object} DataXY\n * @property {Array<Number>} x Array of x values\n * @property {Array<Number>} y Array of y values\n */\n\n/**\n * @typedef {Object} Point\n * @property {Number} x value of the x coordinate\n * @property {Number} y value of the y coordinate\n */\n\n/**\n * @typedef {Object} Zone\n * @property {Number} from first value defining the zone\n * @property {Number} to last value defining the zone\n */\n\n/**\n * @typedef {Array<Point>} ArrayPoints\n */\n\n/**\n * @typedef {Object} DataReIm\n * @property {Array<Number>} re Array of re values\n * @property {Array<Number>} im Array of im values\n */\n\nexport * from './x/xAbsolute';\nexport * from './x/xAbsoluteMedian';\nexport * from './x/xAdd';\nexport * from './x/xAutoCorrelation';\nexport * from './x/xBoxPlot';\nexport * from './x/xCorrelation';\nexport * from './x/xCrossCorrelation';\nexport * from './x/xCumulative';\nexport * from './x/xDivide';\nexport * from './x/xFindClosestIndex';\nexport * from './x/xGetFromToIndex';\nexport * from './x/xGetTargetIndex';\nexport * from './x/xHistogram';\nexport * from './x/xIsMonotone';\nexport * from './x/xMaxIndex';\nexport * from './x/xMaxValue';\nexport * from './x/xMean';\nexport * from './x/xMinIndex';\nexport * from './x/xMinMaxValues';\nexport * from './x/xMinValue';\nexport * from './x/xMultiply';\nexport * from './x/xNoiseSanPlot';\nexport * from './x/xNorm';\nexport * from './x/xParetoNormalization';\nexport * from './x/xPadding';\nexport * from './x/xRotate';\nexport * from './x/xRolling';\nexport * from './x/xRollingAverage';\nexport * from './x/xRollingMedian';\nexport * from './x/xRollingMin';\nexport * from './x/xRollingMax';\nexport * from './x/xSubtract';\nexport * from './x/xSum';\nexport * from './x/xMeanAbsoluteError';\nexport * from './x/xMeanSquaredError';\nexport * from './x/xDotProduct';\n\nexport * from './reim/reimAbsolute';\nexport * from './reim/reimAutoPhaseCorrection';\nexport * from './reim/reimPhaseCorrection';\nexport * from './reim/reimFFT';\n\nexport * from './xreim/xreimZeroFilling';\nexport * from './xreim/xreimSortX';\n\nexport * from './xyArray/xyArrayAlign';\nexport * from './xyArray/xyArrayMerge';\nexport * from './xyArray/xyArrayWeightedMerge';\nexport * from './xyArray/xyArrayAlignToFirst';\n\nexport * from './xy/xyAlign';\nexport * from './xy/xyCheck';\nexport * from './xy/xyCumulativeDistributionStatistics';\nexport * from './xy/xyEnsureGrowingX';\nexport * from './xy/xyExtract';\nexport * from './xy/xyFilterXPositive';\nexport * from './xy/xyGetNMaxY';\nexport * from './xy/xyGrowingX';\nexport * from './xy/xyIntegral';\nexport * from './xy/xyIntegration';\nexport * from './xy/xyJoinX';\nexport * from './xy/xyMaxClosestYPoint';\nexport * from './xy/xyMaxY';\nexport * from './xy/xyMaxYPoint';\nexport * from './xy/xyMaximaY';\nexport * from './xy/xyMedian';\nexport * from './xy/xyMinClosestYPoint';\nexport * from './xy/xyMinYPoint';\nexport * from './xy/xyMinimaY';\nexport * from './xy/xyPeakInfo';\nexport * from './xy/xyRealMaxYPoint';\nexport * from './xy/xyRealMinYPoint';\nexport * from './xy/xyReduce';\nexport * from './xy/xyRolling';\nexport * from './xy/xyToXYObject';\nexport * from './xy/xyToXYArray';\nexport * from './xy/xyCalibrate';\nexport * from './xy/xyUniqueX';\nexport * from './xy/xySortX';\n\nexport * from './xyObject/xyObjectBestPoints';\nexport * from './xyObject/xyObjectJoinX';\nexport * from './xyObject/xyObjectMaxXPoint';\nexport * from './xyObject/xyObjectMinXPoint';\nexport * from './xyObject/xyObjectMaxYPoint';\nexport * from './xyObject/xyObjectMinYPoint';\nexport * from './xyObject/xyObjectSlotX';\nexport * from './xyObject/xyObjectSortX';\nexport * from './xyObject/xyObjectToXY';\n\nexport * from './zone/zoneToX';\n\nexport * from './zones/zonesNormalize';\n\nexport * from './matrix/matrixCenterZMean';\nexport * from './matrix/matrixHistogram';\nexport * from './matrix/matrixMinMaxZ';\nexport * from './matrix/matrixMinMaxAbsoluteZ';\nexport * from './matrix/matrixPQN';\nexport * from './matrix/matrixZRescale';\n\nexport * from './utils/createSequentialArray';\n","'use strict';\n\nconst getMsInfo = require('mf-utilities/src/getMsInfo.js');\nconst xFindClosestIndex = require('ml-spectra-processing').xFindClosestIndex;\n\n/**\n * @param {object}         [entry={}}]\n * @param {object}         [options={}}]\n * @param {object}         [options.ionization={ mf: '', em: 0, charge: 0 }] - ionization method\n * @param {boolean}        [options.forceIonization=false] - If true ignore existing ionizations\n * @param {number}         [options.precision=1000] - The precision on the experimental mass\n * @param {number}         [options.targetMass] - Target mass, allows to calculate error and filter results\n * @param {Array<number>}  [options.targetMasses] - Target masses: SORTED array of numbers\n * @param {Array<number>}  [options.targetIntensities] - Target intensities: SORTED array of numbers\n * @param {number}         [options.minEM=0] - Minimal monoisotopic mass\n * @param {number}         [options.maxEM=+Infinity] - Maximal monoisotopic mass\n * @param {number}         [options.minMSEM=0] - Minimal monoisotopic mass observed by mass\n * @param {number}         [options.maxMSEM=+Infinity] - Maximal monoisotopic mass observed by mass\n * @param {number}         [options.minCharge=-Infinity] - Minimal charge\n * @param {number}         [options.maxCharge=+Infinity] - Maximal charge\n * @param {object}         [options.unsaturation={}}]\n * @param {number}         [options.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number}         [options.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {number}         [options.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {number}         [options.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {object}         [options.atoms] - object of atom:{min, max}\n * @param {Function}       [options.callback] - a function that contains information about the current MF\n * @return {boolean}\n */\n\n/**\n * We always recalculate msem\n */\n\nmodule.exports = function msemMatcher(entry, options = {}) {\n  const {\n    ionization = { mf: '', em: 0, charge: 0 },\n    forceIonization = false,\n    precision = 1000,\n    minCharge = Number.MIN_SAFE_INTEGER,\n    maxCharge = Number.MAX_SAFE_INTEGER,\n    unsaturation = {},\n    targetMass, // if present we will calculate the errors\n    targetMasses, // if present we will calculate the smallest error\n    targetIntensities, // if present it will be added in the report\n    minEM = -Infinity,\n    maxEM = +Infinity,\n    minMSEM = -Infinity,\n    maxMSEM = +Infinity,\n    atoms,\n    callback,\n  } = options;\n\n  let msInfo = getMsInfo(entry, {\n    ionization,\n    forceIonization,\n    targetMass,\n  });\n  let ms = msInfo.ms;\n\n  if (entry.em !== undefined) {\n    if (entry.em < minEM || entry.em > maxEM) return false;\n  }\n\n  if (ms.em !== undefined) {\n    if (ms.em < minMSEM || ms.em > maxMSEM) return false;\n  }\n\n  if (targetMass && Math.abs(ms.ppm) > precision) return false;\n\n  if (entry.charge !== undefined) {\n    if (ms.charge < minCharge || ms.charge > maxCharge) return false;\n  }\n  if (unsaturation !== undefined && entry.unsaturation !== undefined) {\n    if (!require('./unsaturationMatcher')(entry, unsaturation)) {\n      return false;\n    }\n  }\n  if (entry.atoms !== undefined && atoms) {\n    // all the atoms of the entry must fit in the range\n    for (let atom of Object.keys(entry.atoms)) {\n      if (!atoms[atom]) return false;\n      if (entry.atoms[atom] < atoms[atom].min) return false;\n      if (entry.atoms[atom] > atoms[atom].max) return false;\n    }\n  }\n\n  if (targetMasses && targetMasses.length > 0) {\n    let index = xFindClosestIndex(targetMasses, ms.em);\n    let closestMass = targetMasses[index];\n    msInfo = getMsInfo(entry, {\n      ionization,\n      forceIonization,\n      targetMass: closestMass,\n    });\n    msInfo.ms.target = { mass: closestMass };\n    if (targetIntensities) {\n      msInfo.ms.target.intensity = targetIntensities[index];\n    }\n    // need to find the closest targetMasses\n    if (Math.abs(msInfo.ms.ppm) > precision) return false;\n  }\n\n  if (callback) {\n    if (!callback(entry)) return false;\n  }\n\n  return msInfo;\n};\n","'use strict';\n\nmodule.exports = {\n  general: require('./generalMatcher'),\n  msem: require('./msemMatcher'),\n};\n","'use strict';\n\n/**\n * Modify object a to join it with b and make the sum of each of the keys\n * @param {*} a\n * @param {*} source1\n *\n * @return {object}\n */\n\nfunction sum(target) {\n    for (var i = 1; i < arguments.length; i++) {\n        let toSum = arguments[i];\n        for (var key of Object.keys(toSum)) {\n            if (target[key]) {\n                target[key] += toSum[key];\n            } else {\n                target[key] = toSum[key];\n            }\n        }\n    }\n    return target;\n}\n\nmodule.exports = sum;\n","'use strict';\n\nconst { ELECTRON_MASS } = require('chemical-elements/src/constants');\nconst MF = require('mf-parser').MF;\nconst matcher = require('mf-matcher').msem;\nconst preprocessIonizations = require('mf-utilities/src/preprocessIonizations');\nconst processRange = require('mf-utilities/src/processRange');\nconst sum = require('sum-object-keys');\n/**\n * Generate all the possible combinations of molecular formula and calculate\n * for each of them the monoisotopic mass and observed moniisotopic mass (m/z)\n * In the molecular formula there may be a comment after the '$' symbol\n *\n * @param keys\n * @param {object}        [options={}]\n * @param {number}        [options.limit=10000000] - Maximum number of results\n * @param {boolean}       [options.estimate=false] - estimate the number of MF without filters\n * @param {boolean}       [canonizeMF=true] - Canonize molecular formula\n * @param {boolean}       [uniqueMFs=true] - Force canonization and make MF unique\n * @param {string}        [ionizations=''] - Comma separated list of ionizations (to charge the molecule)\n * @param {number}        [options.filter.minMass=0] - Minimal monoisotopic mass\n * @param {number}        [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass\n * @param {number}        [options.filter.minEM=0] - Minimal neutral monoisotopic mass\n * @param {number}        [options.filter.maxEM=+Infinity] - Maximal neutral monoisotopic mass\n * @param {number}        [options.filter.precision=1000] - The precision on the experimental mass\n * @param {number}        [options.filter.targetMass] - Target mass, allows to calculate error and filter results\n * @param {Array<number>} [options.filter.targetMasses] - Target masses: SORTED array of numbers\n * @param {number}        [options.filter.precision=1000] - Precision\n * @param {number}        [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number}        [options.filter.maxCharge=+Infinity] - Maximal charge\n * @param {object}        [options.filter.unsaturation={}}]\n * @param {number}        [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number}        [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {number}        [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {number}        [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {object}        [options.filter.atoms] - object of atom:{min, max}\n * @param {function}      [options.filter.callback] - a function to filter the MF\n * @param {string}        [options.filterFct]\n * @param {object}        [options.links]\n * @param {boolean}       [options.links.filter] We filter all the MF that do not match the '*X'\n * @returns {Array}\n */\n\nmodule.exports = function generateMFs(keys, options = {}) {\n  options = { ...options };\n\n  let { limit = 100000, uniqueMFs = true, estimate = false } = options;\n\n  options.filterFctVariables = {};\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i];\n    if (typeof key === 'object' && key.name) {\n      options.filterFctVariables[key.name] = i;\n      keys[i] = key.value;\n    }\n  }\n\n  if (options.filterFct) {\n    // we create a real javascript function\n    let variables = Object.keys(options.filterFctVariables);\n    variables.push('mm', 'mz', 'charge', 'unsaturation', 'atoms');\n    // eslint-disable-next-line no-new-func\n    options.filterFct = new Function(\n      ...variables,\n      `return ${options.filterFct}`,\n    );\n  }\n\n  if (uniqueMFs === true) options.canonizeMF = true;\n  if (options.canonizeMF === undefined) options.canonizeMF = true;\n  options.ionizations = preprocessIonizations(options.ionizations);\n\n  if (!Array.isArray(keys)) {\n    throw new Error('You need to specify an array of strings or arrays');\n  }\n\n  // we allow String delimited by \". or ;\" instead of an array\n  for (let i = 0; i < keys.length; i++) {\n    if (!Array.isArray(keys[i])) {\n      keys[i] = keys[i].split(/[.,]/);\n    }\n  }\n\n  // we allow ranges in a string ...\n  // problem with ranges is that we need to know to what the range applies\n  for (let i = 0; i < keys.length; i++) {\n    let parts = keys[i];\n    let newParts = [];\n    for (let j = 0; j < parts.length; j++) {\n      let part = parts[j];\n      let comment = part.replace(/^([^$]*\\$|.*)/, '');\n      part = part.replace(/\\$.*/, '').replace(/\\s/g, '');\n      if (part.match(/[0-9]-[0-9-]/)) {\n        // deal with negative numbers\n        // there are ranges ... we are in trouble !\n        newParts = newParts.concat(processRange(part, comment, { limit }));\n      } else {\n        newParts.push(parts[j]); // the part with the comments !\n      }\n    }\n    keys[i] = newParts;\n  }\n\n  if (estimate) {\n    let total = keys.reduce(\n      (previous, current) => previous * current.length,\n      1,\n    );\n    return total * options.ionizations.length;\n  }\n\n  let results = [];\n  let sizes = [];\n  let currents = [];\n  for (let i = 0; i < keys.length; i++) {\n    sizes.push(keys[i].length - 1);\n    currents.push(0);\n  }\n  let position = 0;\n  let evolution = 0;\n  while (position < currents.length) {\n    if (currents[position] < sizes[position]) {\n      evolution++;\n      appendResult(results, currents, keys, options);\n      currents[position]++;\n      for (let i = 0; i < position; i++) {\n        currents[i] = 0;\n      }\n      position = 0;\n    } else {\n      position++;\n    }\n    if (evolution > limit) {\n      throw new Error(\n        `You have reached the limit of ${limit}. You could still change this value using the limit option but it is likely to crash.`,\n      );\n    }\n  }\n\n  appendResult(results, currents, keys, options);\n  if (uniqueMFs) {\n    let uniqueMFsObject = {};\n    results.forEach((result) => {\n      uniqueMFsObject[result.mf + result.ionization.mf] = result;\n    });\n    results = Object.keys(uniqueMFsObject).map((k) => uniqueMFsObject[k]);\n  }\n  results.sort((a, b) => a.em - b.em);\n  return results;\n};\n\nlet ems = {};\n\n// internal method used as a cache\nfunction getMonoisotopicMass(mfString) {\n  if (!ems[mfString]) {\n    // we need to calculate based on the mf but not very often ...\n    let mf = new MF(mfString);\n    let info = mf.getInfo();\n    ems[mfString] = {\n      em: info.monoisotopicMass,\n      charge: info.charge,\n      mw: info.mass,\n      unsaturation: (info.unsaturation - 1) * 2,\n      atoms: info.atoms,\n    };\n  }\n  return ems[mfString];\n}\n\nfunction getEMFromParts(parts, currents, ionization) {\n  let charge = 0;\n  let em = 0;\n  let mw = 0;\n  let unsaturation = 0;\n  let validUnsaturation = true;\n  let atoms = {};\n\n  for (let i = 0; i < parts.length; i++) {\n    let part = parts[i][currents[i]];\n    if (part) {\n      let info = getMonoisotopicMass(part);\n      charge += info.charge;\n      em += info.em;\n      mw += info.mw;\n      sum(atoms, info.atoms);\n      if (info.unsaturation && validUnsaturation) {\n        unsaturation += info.unsaturation;\n      }\n    }\n  }\n\n  return {\n    charge,\n    em,\n    mw,\n    ionization: ionization,\n    unsaturation: validUnsaturation ? unsaturation / 2 + 1 : undefined,\n    atoms,\n  };\n}\n\nfunction appendResult(results, currents, keys, options = {}) {\n  const { canonizeMF, filter, ionizations, links = {} } = options;\n  // this script is designed to combine molecular formula\n  // that may contain comments after a \"$\" sign\n  // therefore we should put all the comments at the ned\n\n  if (links.filter) {\n    let stars = [];\n    for (let i = 0; i < keys.length; i++) {\n      let anchors = keys[i][currents[i]].match(/#[0-9]+/g);\n      if (anchors) stars.push(...anchors);\n    }\n    if (stars.length % 2 === 1) return;\n    stars = stars.sort();\n    for (let i = 0; i < stars.length; i += 2) {\n      if (stars[i] !== stars[i + 1]) return;\n    }\n  }\n\n  for (let ionization of ionizations) {\n    let result = getEMFromParts(keys, currents, ionization);\n    if (options.filterFct) {\n      let variables = [];\n      for (let key in options.filterFctVariables) {\n        variables.push(currents[options.filterFctVariables[key]]);\n      }\n\n      variables.push(\n        result.em,\n        (result.em + ionization.em - ionization.charge * ELECTRON_MASS) /\n          Math.abs(ionization.charge),\n        result.charge + result.ionization.charge,\n        result.unsaturation,\n        result.atoms,\n      );\n      if (!options.filterFct.apply(null, variables)) continue;\n    }\n\n    let match = matcher(result, filter);\n    if (!match) continue;\n    result.ms = match.ms;\n    result.ionization = match.ionization;\n    result.parts = [];\n    result.mf = '';\n\n    let comments = [];\n    for (let i = 0; i < keys.length; i++) {\n      let key = keys[i][currents[i]];\n      if (key) {\n        if (key.indexOf('$') > -1) {\n          comments.push(key.replace(/^[^$]*\\$/, ''));\n          key = key.replace(/\\$.*/, '');\n        }\n        result.parts[i] = key;\n        result.mf += key;\n      }\n    }\n    if (canonizeMF) {\n      result.mf = new MF(result.mf).toMF();\n    }\n    if (comments.length > 0) {\n      result.comment = comments.join(' ');\n    }\n    results.push(result);\n  }\n}\n","import IsotopicDistribution from 'isotopic-distribution';\nimport generateMFs from 'mf-generator';\nimport { xyObjectSlotX } from 'ml-spectra-processing';\n/**\n * Calculate tic for specific molecular formula and ionizations\n *\n * The system will take all the peaks with an intensity over 5% (default value)\n * @param {Chromatogram} chromatogram - GC/MS chromatogram where make the peak picking\n * @param {string} targetMF - mass for which to extract the spectrum\n * @param {object} [options={}]\n * @param {number} [options.slotWidth=1] - Width of the slot around the mass of targetMF\n * @param {number} [options.threshold=0.05] - Minimal height for peaks\n * @param {number} [options.ionizations='H+'] - List of allowed ionisation\n * @return {Array} - Calculated mass for targetMass\n */\nexport function calculateForMF(chromatogram, targetMF, options = {}) {\n  const { threshold = 0.05, slotWidth = 1, ionizations = 'H+' } = options;\n\n  if (typeof targetMF !== 'string') {\n    throw Error('targetMF must be defined and a string');\n  }\n\n  const mfs = generateMFs([targetMF]).map((info) => info.mf);\n\n  const halfWidth = slotWidth / 2;\n\n  const ms = chromatogram.getSeries('ms');\n\n  let masses = [];\n  for (let mf of mfs) {\n    let isotopicDistribution = new IsotopicDistribution(mf, {\n      ionizations,\n    });\n    // we add isotopicDistribution in all the parts\n    isotopicDistribution.getDistribution();\n\n    let parts = isotopicDistribution.getParts();\n\n    masses = masses.concat(...parts.map((part) => part.isotopicDistribution));\n  }\n\n  masses.sort((a, b) => a.x - b.x);\n  masses = xyObjectSlotX(masses, { slotWidth }).filter(\n    (mass) => mass.y > threshold,\n  );\n\n  let massSpectra = ms.data;\n  let result = new Array(massSpectra.length).fill(0);\n  for (let targetMass of masses) {\n    for (let i = 0; i < massSpectra.length; i++) {\n      let massSpectrum = massSpectra[i];\n      for (let j = 0; j < massSpectrum[0].length; j++) {\n        if (Math.abs(massSpectrum[0][j] - targetMass.x) <= halfWidth) {\n          result[i] += massSpectrum[1][j];\n        }\n      }\n    }\n  }\n  return result;\n}\n","export function calculateLength(chromatogram, seriesName) {\n  const series2D = chromatogram.getSeries(seriesName);\n  const spectra = series2D.data;\n  const length = spectra.map((spectrum) => spectrum[0].length);\n  return length;\n}\n","import sum from 'ml-array-sum';\n\nexport function calculateTic(chromatogram) {\n  const ms = chromatogram.getSeries('ms');\n  const massSpectra = ms.data;\n  const tic = [];\n  for (const massSpectrum of massSpectra) {\n    if (massSpectrum[1].length > 0) {\n      tic.push(sum(massSpectrum[1]));\n    } else {\n      tic.push(0);\n    }\n  }\n\n  return tic;\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function zeroInsteadOfNegative(X) {\n  let rows = X.rows;\n  let columns = X.columns;\n  let newMatrix = new Matrix(X);\n  for (let r = 0; r < rows; r++) {\n    for (let c = 0; c < columns; c++) {\n      if (newMatrix.get(r, c) < 0) {\n        newMatrix.set(r, c, 0);\n      }\n    }\n  }\n  return newMatrix;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function checkMatrixS(data, originalMatrix) {\n  let { A, S } = data;\n  //check if is there at least one element cero\n  let indices = [];\n  let sum = S.sum('row');\n\n  for (let i = 0; i < sum.length; i++) {\n    if (sum[i] === 0) {\n      indices.push(i);\n      continue;\n    } else {\n      for (let j = 0; j < S.columns; j++) {\n        if (isNaN(S.get(i, j))) {\n          indices.push(i);\n          break;\n        }\n      }\n    }\n  }\n  // if there than just one zero or NaN element\n  // run a NMF with the residual matrix Y - A*B\n  if (indices.length > 0) {\n    let temp = fastExtractNMF(\n      originalMatrix.clone().subM(A.mmul(S)),\n      indices.length,\n    );\n    for (let i = 0; i < indices.length; i++) {\n      for (let j = 0; j < S.columns; j++) {\n        S.set(indices[i], j, temp.S.get(i, j));\n      }\n      for (let j = 0; j < A.rows; j++) {\n        A.set(j, indices[i], temp.A.get(j, i));\n      }\n    }\n  }\n\n  return Object.assign({}, data, { A, S });\n}\n\nfunction fastExtractNMF(residual, r) {\n  if (r <= 0) return { A: [], S: [] };\n\n  const { columns, rows } = residual;\n\n  let A = Matrix.zeros(rows, r);\n  let S = Matrix.zeros(r, columns);\n  for (let i = 0; i < r; i++) {\n    residual = zeroInsteadOfNegative(residual);\n    if (residual.sum() === 0) continue;\n    let res2 = Matrix.pow(residual, 2).sum('column');\n    //find the max of the first column\n\n    let maxIndex = 0;\n    for (let j = 1; j < res2.length; j++) {\n      if (res2[maxIndex] < res2[j]) maxIndex = j;\n    }\n\n    if (res2[maxIndex] > 0) {\n      let sqrtMaxValue = Math.sqrt(res2[maxIndex]);\n      for (let j = 0; j < rows; j++) {\n        let value = residual.get(j, maxIndex) / sqrtMaxValue;\n        A.set(j, i, value);\n      }\n      let temp = A.getColumnVector(i).transpose().mmul(residual);\n      for (let j = 0; j < columns; j++) {\n        S.set(i, j, Math.max(temp.get(0, j), 0));\n      }\n      let subtracting = A.getColumnVector(i).mmul(S.getRowVector(i));\n      residual = residual.sub(subtracting);\n    }\n  }\n  return { A, S };\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function normBy(x, by = 'column') {\n  let norms = Matrix.mul(x, x).sum(by);\n  let length = norms.length;\n  for (let i = 0; i < length; i++) {\n    norms[i] = Math.sqrt(norms[i]);\n  }\n  return by === 'row'\n    ? Matrix.from1DArray(length, 1, norms)\n    : Matrix.from1DArray(1, length, norms);\n}\n","import { normBy } from './normBy';\n\nexport function normProj(X, normLimits) {\n  let norms;\n  let r = X.rows;\n  let c = X.columns;\n  if (normLimits.rows === r) {\n    norms = normBy(X, 'row');\n    //select rows with norm > 0 then multiply twise by the min\n    for (let i = 0; i < r; i++) {\n      if (norms.get(i, 0) <= 0) continue;\n      for (let j = 0; j < c; j++) {\n        let value =\n          X.get(i, j) *\n          Math.min(norms.get(i, 0), normLimits.get(i, 0) / norms.get(i, 0));\n        X.set(i, j, value);\n      }\n    }\n  } else {\n    norms = normBy(X, 'column');\n    for (let i = 0; i < c; i++) {\n      if (norms.get(0, i) <= 0) continue;\n      for (let j = 0; j < r; j++) {\n        let value =\n          X.get(j, i) *\n          Math.min(norms.get(0, i), normLimits.get(0, i) / norms.get(0, i));\n        X.set(j, i, value);\n      }\n    }\n  }\n  return X;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\nimport { normProj } from '../util/normProj';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixA(Ainit, S, originalMatrix, options) {\n  let {\n    maxFBIteration,\n    toleranceFB,\n    normConstrained = false,\n    lambda,\n  } = options;\n  let St = S.transpose();\n  let H = S.mmul(St);\n  let YSt = originalMatrix.mmul(St);\n  let evd = new EVD(H, { assumeSymmetric: true });\n  let L = Math.max(...evd.realEigenvalues);\n  let A = Ainit;\n  let prevA = A.clone();\n  let t = 1;\n\n  let gradient = (a) => a.mmul(H).sub(YSt);\n  let proximal;\n  if (normConstrained) {\n    let normLimits = normBy(Ainit, 'column');\n    proximal = (x, threshold) =>\n      normProj(zeroInsteadOfNegative(x.subS(threshold)), normLimits);\n  } else {\n    proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n  }\n\n  for (let i = 0; i < maxFBIteration; i++) {\n    let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n    let w = (t - 1) / tNext;\n    t = tNext;\n    let B = Matrix.mul(A, w + 1).sub(Matrix.mul(prevA, w));\n    prevA = A.clone();\n    A = proximal(B.sub(gradient(B).divS(L)), lambda / L);\n    if (Matrix.sub(prevA, A).norm() / A.norm() < toleranceFB) {\n      break;\n    }\n  }\n  return A;\n}\n","export function getMax(array = []) {\n  let max = Number.MIN_SAFE_INTEGER;\n  for (let i = 0; i < array.length; i++) {\n    if (max < array[i]) max = array[i];\n  }\n  return max;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { getMax } from '../util/getMax';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixS(A, Sinit, originalMatrix, lambda, options) {\n  let { maxFBIteration, toleranceFB } = options;\n  let At = A.transpose();\n  let H = At.mmul(A);\n  let AtY = At.mmul(originalMatrix);\n  let evd = new EVD(H, { assumeSymmetric: true });\n  let L = getMax(evd.realEigenvalues);\n  let t = 1;\n  let S = Sinit.clone();\n  let prevS = S.clone();\n  let gradient = (s) => H.mmul(s).sub(AtY);\n  let proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n\n  for (let i = 0; i < maxFBIteration; i++) {\n    let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n    let w = (t - 1) / tNext;\n    t = tNext;\n    // R = S_k + w [S_k - S_(k-1)] = (1 + w) .* S_k - w .* S_(k-1)\n    let R = Matrix.mul(S, 1 + w).sub(Matrix.mul(prevS, w));\n    prevS = S.clone();\n    S = proximal(R.sub(gradient(R).divS(L)), lambda / L);\n    if (Matrix.sub(prevS, S).norm() / S.norm() < toleranceFB) {\n      break;\n    }\n  }\n  return S;\n}\n","import { Matrix, solve } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nimport { checkMatrixS } from './checkMatrixS';\nimport { updateMatrixA } from './updateMatrixA';\nimport { updateMatrixS } from './updateMatrixS';\n\nexport function initialize(originalMatrix, options = {}) {\n  const {\n    rank,\n    randGenerator,\n    maxInitFBIteration,\n    toleranceFBInit,\n    maxFBIteration,\n    toleranceFB,\n    normConstrained,\n  } = options;\n\n  let result = {};\n  let rows = originalMatrix.rows;\n\n  result.A = Matrix.rand(rows, rank, { random: randGenerator });\n\n  for (let iter = 0; iter < maxInitFBIteration; iter++) {\n    //select columns with sum positive from A\n    let sumC = result.A.sum('column');\n    for (let i = 0; i < sumC.length; i++) {\n      while (sumC[i] === 0) {\n        sumC[i] = 0;\n        for (let j = 0; j < rows; j++) {\n          result.A.set(j, i, randGenerator());\n          sumC[i] += result.A.get(j, i);\n        }\n      }\n    }\n\n    //resolve the system of equation Lx = D for x, then select just non negative values;\n    result.S = zeroInsteadOfNegative(solve(result.A, originalMatrix));\n\n    //select rows with positive sum by row\n    let sumR = result.S.sum('row');\n    let positiveSumRowIndexS = [];\n    let positiveSumRowS = [];\n    for (let i = 0; i < sumR.length; i++) {\n      if (sumR[i] > 0) {\n        positiveSumRowIndexS.push(i);\n        positiveSumRowS.push(result.S.getRow(i));\n      }\n    }\n\n    positiveSumRowS = Matrix.checkMatrix(positiveSumRowS);\n\n    // solve the system of linear equation xL = D for x. knowing that D/L = (L'\\D')'.\n    let candidateA = zeroInsteadOfNegative(\n      solve(positiveSumRowS.transpose(), originalMatrix.transpose()),\n    );\n\n    //then, set the columns of A with an index equal to the row index with sum > 0 into S\n    //this step complete the last transpose of D/L = (L'\\D')'.\n    for (let i = 0; i < positiveSumRowIndexS.length; i++) {\n      let colCandidate = candidateA.getRow(i);\n      for (let j = 0; j < rows; j++) {\n        result.A.set(j, positiveSumRowIndexS[i], colCandidate[j]);\n      }\n    }\n\n    let prevS = result.S.clone();\n    result.S = updateMatrixS(result.A, result.S, originalMatrix, 0, {\n      maxFBIteration,\n      toleranceFB,\n    });\n\n    result = checkMatrixS(result, originalMatrix);\n\n    result.A = updateMatrixA(result.A, result.S, originalMatrix, 0, {\n      maxFBIteration,\n      toleranceFB,\n      normConstrained,\n    });\n\n    if (\n      Matrix.sub(prevS, result.S).norm() / result.S.norm() <\n      toleranceFBInit\n    ) {\n      break;\n    }\n  }\n  return result;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\n\nexport function normalize(data, options) {\n  const { normOnA } = options;\n  let DS = normBy(data.S.transpose(), 'column');\n  let DA = normBy(data.A, 'column');\n  let D = Matrix.mul(DS, DA);\n  let onS, onA;\n  if (normOnA) {\n    onS = (index, c) =>\n      (data.S.get(index, c) * D.get(0, index)) / DS.get(0, index);\n    onA = (index, r) => data.A.get(r, index) / DA.get(0, index);\n  } else {\n    onS = (index, c) => data.S.get(index, c) / DS.get(0, index);\n    onA = (index, r) =>\n      (data.A.get(r, index) * D.get(0, index)) / DA.get(0, index);\n  }\n  const sColumns = data.S.columns;\n  const aRows = data.A.rows;\n  for (let index = 0; index < D.columns; index++) {\n    let valueForS, valueForA;\n    if (D.get(0, index) > 0) {\n      valueForS = onS;\n      valueForA = onA;\n    } else {\n      valueForA = () => 0;\n      valueForS = () => 0;\n    }\n    for (let c = 0; c < sColumns; c++) {\n      data.S.set(index, c, valueForS(index, c));\n    }\n    for (let r = 0; r < aRows; r++) {\n      data.A.set(r, index, valueForA(index, r));\n    }\n  }\n  return data;\n}\n","import median from 'median-quickselect';\nimport { Matrix } from 'ml-matrix';\n\nexport function getMedians(X, by) {\n  let medians = [];\n  let rows = X.rows;\n  let columns = X.columns;\n  switch (by) {\n    case 'column':\n      for (let i = 0; i < columns; i++) {\n        medians.push(median(X.getColumn(i)));\n      }\n      medians = Matrix.from1DArray(1, columns, medians);\n      break;\n    default:\n      for (let i = 0; i < rows; i++) {\n        medians.push(median(X.getRow(i)));\n      }\n      medians = Matrix.from1DArray(rows, 1, medians);\n  }\n  return medians;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { getMedians } from './getMedians';\n\nexport function dimMADstd(X, by) {\n  let medians = getMedians(X, by);\n  let matrix = X.clone();\n  matrix =\n    by === 'column'\n      ? matrix.subRowVector(medians.to1DArray())\n      : matrix.subColumnVector(medians.to1DArray());\n  return Matrix.mul(getMedians(matrix.abs(), by), 1.4826);\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { dimMADstd } from '../util/dimMADstd';\n\nexport function updateLambda(data, originalMatrix, options = {}) {\n  let { refinementBeginning, tauMAD } = options;\n  let { iteration, lambda, A, S } = data;\n\n  if (refinementBeginning <= iteration) return lambda;\n\n  let sigmaResidue;\n  if (options.lambdaInf !== undefined) {\n    sigmaResidue = options.lambdaInf / options.tauMAD;\n  } else if (options.addStd !== undefined) {\n    sigmaResidue = options.addStd;\n  } else {\n    let alY = Matrix.sub(originalMatrix, A.mmul(S)).to1DArray();\n    let result = dimMADstd(Matrix.from1DArray(1, alY.length, alY), 'row');\n    sigmaResidue = result.get(0, 0);\n  }\n  let nextLambda = Math.max(\n    tauMAD * sigmaResidue,\n    lambda - 1 / (refinementBeginning - iteration),\n  );\n  return nextLambda;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { checkMatrixS } from './stages/checkMatrixS';\nimport { initialize } from './stages/initialize';\nimport { normalize } from './stages/normalize';\nimport { updateLambda } from './stages/updateLambda';\nimport { updateMatrixA } from './stages/updateMatrixA';\nimport { updateMatrixS } from './stages/updateMatrixS';\n\n/**\n * Performing non-negative matrix factorization solving argmin_(A >= 0, S >= 0) 1 / 2 * ||Y - AS||_2^2 + lambda * ||S||_1\n * @param {Matrix||Array<Array>} originalMatrix - Matrix to be separated.\n * @param {Number} rank - The maximum number of linearly independent column/row vectors in the matrix.\n * @param {Object} [options = {}] - Options of ngmca factorization method.\n * @param {Number} [options.maximumIteration = 500] - Maximum number of iterations.\n * @param {Number} [options.maxFBIteration = 80] - Maximum number of iterations of the Forward-Backward subroutine.\n * @param {Object} [options.randGenerator = Math.random] - Random number generator for the subroutine of initialization.\n * @param {Number} [options.maxInitFBIteration = 50] - Maximum number of iterations of the Forward-Backward subroutine at the initialization.\n * @param {Number} [options.toleranceFB = 1e-5] - relative difference tolerance for convergence of the Forward-Backward sub-iterations.\n * @param {Number} [options.toleranceFBInit = 0] - relative difference tolerance for convergence of the Forward-Backward sub-iterations at the initialization.\n * @param {Number} [options.phaseRatio = 0.8] - transition between decreasing thresholding phase and refinement phase in percent of the iterations.\n * @param {Number} [options.tauMAD = 1] - constant coefficient for the final threshold computation.\n * @param {Boolean} [options.useTranspose = false] - if true the originalMatrix is transposed.\n */\n\nexport function nGMCA(originalMatrix, rank, options = {}) {\n  const {\n    maximumIteration = 500,\n    maxFBIteration = 80,\n    maxInitFBIteration = 50,\n    toleranceFBInit = 0,\n    toleranceFB = 0.00001,\n    phaseRatio = 0.8,\n    randGenerator = Math.random,\n    tauMAD = 1,\n    useTranspose = false,\n  } = options;\n\n  let { normConstrained = false } = options;\n  originalMatrix = Matrix.checkMatrix(originalMatrix);\n  if (useTranspose) originalMatrix = originalMatrix.transpose();\n  let refinementBeginning = Math.floor(phaseRatio * maximumIteration);\n\n  let data = initialize(originalMatrix, {\n    rank,\n    randGenerator,\n    maxInitFBIteration,\n    toleranceFBInit,\n    maxFBIteration,\n    toleranceFB,\n  });\n\n  data = normalize(data, { normOnA: true });\n  data.lambda = data.A.transpose()\n    .mmul(data.A.mmul(data.S).sub(originalMatrix))\n    .abs()\n    .max();\n\n  for (let iter = 0; iter < maximumIteration; iter++) {\n    data.iteration = iter;\n    data.S = updateMatrixS(\n      data.A,\n      data.S,\n      originalMatrix,\n      data.lambda,\n      options,\n    );\n    data = checkMatrixS(data, originalMatrix);\n    data = normalize(data, { normOnA: false });\n\n    if (iter > refinementBeginning) normConstrained = true;\n\n    data.A = updateMatrixA(data.A, data.S, originalMatrix, {\n      maxFBIteration,\n      toleranceFB,\n      normConstrained,\n      lambda: 0,\n    });\n\n    data = normalize(data, { normOnA: true });\n\n    data.lambda = updateLambda(data, originalMatrix, {\n      refinementBeginning,\n      tauMAD,\n    });\n  }\n\n  if (useTranspose) {\n    let temp = data.A.transpose();\n    data.A = data.S.transpose();\n    data.S = temp;\n  }\n  return data;\n}\n","import { Matrix, MatrixTransposeView, EVD, SVD, NIPALS } from 'ml-matrix';\r\n\r\n/**\r\n * Creates new PCA (Principal Component Analysis) from the dataset\r\n * @param {Matrix} dataset - dataset or covariance matrix.\r\n * @param {Object} [options]\r\n * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix.\r\n * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\r\n * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS.\r\n * @param {boolean} [options.center=true] - should the data be centered (subtract the mean).\r\n * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation).\r\n * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`.\r\n * */\r\nexport class PCA {\r\n  constructor(dataset, options = {}) {\r\n    if (dataset === true) {\r\n      const model = options;\r\n      this.center = model.center;\r\n      this.scale = model.scale;\r\n      this.means = model.means;\r\n      this.stdevs = model.stdevs;\r\n      this.U = Matrix.checkMatrix(model.U);\r\n      this.S = model.S;\r\n      this.R = model.R;\r\n      this.excludedFeatures = model.excludedFeatures || [];\r\n      return;\r\n    }\r\n\r\n    dataset = new Matrix(dataset);\r\n\r\n    const {\r\n      isCovarianceMatrix = false,\r\n      method = 'SVD',\r\n      nCompNIPALS = 2,\r\n      center = true,\r\n      scale = false,\r\n      ignoreZeroVariance = false,\r\n    } = options;\r\n\r\n    this.center = center;\r\n    this.scale = scale;\r\n    this.means = null;\r\n    this.stdevs = null;\r\n    this.excludedFeatures = [];\r\n\r\n    if (isCovarianceMatrix) {\r\n      // User provided a covariance matrix instead of dataset.\r\n      this._computeFromCovarianceMatrix(dataset);\r\n      return;\r\n    }\r\n\r\n    this._adjust(dataset, ignoreZeroVariance);\r\n    switch (method) {\r\n      case 'covarianceMatrix': {\r\n        // User provided a dataset but wants us to compute and use the covariance matrix.\r\n        const covarianceMatrix = new MatrixTransposeView(dataset)\r\n          .mmul(dataset)\r\n          .div(dataset.rows - 1);\r\n        this._computeFromCovarianceMatrix(covarianceMatrix);\r\n        break;\r\n      }\r\n      case 'NIPALS': {\r\n        this._computeWithNIPALS(dataset, nCompNIPALS);\r\n        break;\r\n      }\r\n      case 'SVD': {\r\n        const svd = new SVD(dataset, {\r\n          computeLeftSingularVectors: false,\r\n          computeRightSingularVectors: true,\r\n          autoTranspose: true,\r\n        });\r\n\r\n        this.U = svd.rightSingularVectors;\r\n\r\n        const singularValues = svd.diagonal;\r\n        const eigenvalues = [];\r\n        for (const singularValue of singularValues) {\r\n          eigenvalues.push(\r\n            (singularValue * singularValue) / (dataset.rows - 1),\r\n          );\r\n        }\r\n        this.S = eigenvalues;\r\n        break;\r\n      }\r\n      default: {\r\n        throw new Error(`unknown method: ${method}`);\r\n      }\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Load a PCA model from JSON\r\n   * @param {Object} model\r\n   * @return {PCA}\r\n   */\r\n  static load(model) {\r\n    if (typeof model.name !== 'string') {\r\n      throw new TypeError('model must have a name property');\r\n    }\r\n    if (model.name !== 'PCA') {\r\n      throw new RangeError(`invalid model: ${model.name}`);\r\n    }\r\n    return new PCA(true, model);\r\n  }\r\n\r\n  /**\r\n   * Project the dataset into the PCA space\r\n   * @param {Matrix} dataset\r\n   * @param {Object} options\r\n   * @return {Matrix} dataset projected in the PCA space\r\n   */\r\n  predict(dataset, options = {}) {\r\n    const { nComponents = this.U.columns } = options;\r\n    dataset = new Matrix(dataset);\r\n    if (this.center) {\r\n      dataset.subRowVector(this.means);\r\n      if (this.scale) {\r\n        for (let i of this.excludedFeatures) {\r\n          dataset.removeColumn(i);\r\n        }\r\n        dataset.divRowVector(this.stdevs);\r\n      }\r\n    }\r\n    let predictions = dataset.mmul(this.U);\r\n    return predictions.subMatrix(0, predictions.rows - 1, 0, nComponents - 1);\r\n  }\r\n\r\n  /**\r\n   * Calculates the inverse PCA transform\r\n   * @param {Matrix} dataset\r\n   * @return {Matrix} dataset projected in the PCA space\r\n   */\r\n  invert(dataset) {\r\n    dataset = Matrix.checkMatrix(dataset);\r\n\r\n    let inverse = dataset.mmul(this.U.transpose());\r\n\r\n    if (this.center) {\r\n      if (this.scale) {\r\n        inverse.mulRowVector(this.stdevs);\r\n      }\r\n      inverse.addRowVector(this.means);\r\n    }\r\n\r\n    return inverse;\r\n  }\r\n\r\n  /**\r\n   * Returns the proportion of variance for each component\r\n   * @return {[number]}\r\n   */\r\n  getExplainedVariance() {\r\n    let sum = 0;\r\n    for (const s of this.S) {\r\n      sum += s;\r\n    }\r\n    return this.S.map((value) => value / sum);\r\n  }\r\n\r\n  /**\r\n   * Returns the cumulative proportion of variance\r\n   * @return {[number]}\r\n   */\r\n  getCumulativeVariance() {\r\n    let explained = this.getExplainedVariance();\r\n    for (let i = 1; i < explained.length; i++) {\r\n      explained[i] += explained[i - 1];\r\n    }\r\n    return explained;\r\n  }\r\n\r\n  /**\r\n   * Returns the Eigenvectors of the covariance matrix\r\n   * @returns {Matrix}\r\n   */\r\n  getEigenvectors() {\r\n    return this.U;\r\n  }\r\n\r\n  /**\r\n   * Returns the Eigenvalues (on the diagonal)\r\n   * @returns {[number]}\r\n   */\r\n  getEigenvalues() {\r\n    return this.S;\r\n  }\r\n\r\n  /**\r\n   * Returns the standard deviations of the principal components\r\n   * @returns {[number]}\r\n   */\r\n  getStandardDeviations() {\r\n    return this.S.map((x) => Math.sqrt(x));\r\n  }\r\n\r\n  /**\r\n   * Returns the loadings matrix\r\n   * @return {Matrix}\r\n   */\r\n  getLoadings() {\r\n    return this.U.transpose();\r\n  }\r\n\r\n  /**\r\n   * Export the current model to a JSON object\r\n   * @return {Object} model\r\n   */\r\n  toJSON() {\r\n    return {\r\n      name: 'PCA',\r\n      center: this.center,\r\n      scale: this.scale,\r\n      means: this.means,\r\n      stdevs: this.stdevs,\r\n      U: this.U,\r\n      S: this.S,\r\n      excludedFeatures: this.excludedFeatures,\r\n    };\r\n  }\r\n\r\n  _adjust(dataset, ignoreZeroVariance) {\r\n    if (this.center) {\r\n      const mean = dataset.mean('column');\r\n      const stdevs = this.scale\r\n        ? dataset.standardDeviation('column', { mean })\r\n        : null;\r\n      this.means = mean;\r\n      dataset.subRowVector(mean);\r\n      if (this.scale) {\r\n        for (let i = 0; i < stdevs.length; i++) {\r\n          if (stdevs[i] === 0) {\r\n            if (ignoreZeroVariance) {\r\n              dataset.removeColumn(i);\r\n              stdevs.splice(i, 1);\r\n              this.excludedFeatures.push(i);\r\n              i--;\r\n            } else {\r\n              throw new RangeError(\r\n                `Cannot scale the dataset (standard deviation is zero at index ${i}`,\r\n              );\r\n            }\r\n          }\r\n        }\r\n        this.stdevs = stdevs;\r\n        dataset.divRowVector(stdevs);\r\n      }\r\n    }\r\n  }\r\n\r\n  _computeFromCovarianceMatrix(dataset) {\r\n    const evd = new EVD(dataset, { assumeSymmetric: true });\r\n    this.U = evd.eigenvectorMatrix;\r\n    this.U.flipRows();\r\n    this.S = evd.realEigenvalues;\r\n    this.S.reverse();\r\n  }\r\n\r\n  _computeWithNIPALS(dataset, nCompNIPALS) {\r\n    this.U = new Matrix(nCompNIPALS, dataset.columns);\r\n    this.S = [];\r\n\r\n    let x = dataset;\r\n    for (let i = 0; i < nCompNIPALS; i++) {\r\n      let dc = new NIPALS(x);\r\n\r\n      this.U.setRow(i, dc.w.transpose());\r\n      this.S.push(Math.pow(dc.s.get(0, 0), 2));\r\n\r\n      x = dc.xResidual;\r\n    }\r\n    this.U = this.U.transpose(); // to be compatible with API\r\n  }\r\n}\r\n","import { PCA } from 'ml-pca';\n\n/**\n * Estimate the number of pure components of each range by NIPALS PCA\n * @param {Chromatogram} chromatogram - GC/MS chromatogram where make the estimation\n * @param {Object} options - options with range and the matrix\n * @param {Object} [options.range] - Range of retention times.\n * @param {Number} [options.range.from] - lower limit in the retention time.\n * @param {Number} [options.range.to] - upper limit in the retention time.\n * @param {Array<Array>} [options.matrix] - matrix to compute the number of pure components, if does not exist it will be computed.\n */\n\nexport function estimateNbPureComponents(chromatogram, options = {}) {\n  let { range, matrix } = options;\n\n  if (!matrix) matrix = chromatogram.getMzVsTimesMatrix(range).matrix;\n\n  let pca = new PCA(matrix, {\n    method: 'NIPALS',\n    nCompNIPALS: 10,\n    scale: true,\n    ignoreZeroVariance: true,\n  });\n  let s = pca.getExplainedVariance();\n  let rank = 1;\n  let cumulative = s[0];\n  while ((cumulative - s[rank]) / cumulative < 0.88 && rank < s.length) {\n    cumulative += s[rank];\n    rank++;\n  }\n  return rank;\n}\n","import { nGMCA } from 'ml-ngmca';\n\nimport { estimateNbPureComponents } from '../util/estimateNbPureComponents';\n\n/**\n * Performing non-negative matrix factorization solving argmin_(A >= 0, S >= 0) 1 / 2 * ||Y - AS||_2^2 + lambda * ||S||_1\n * @param {Chromatogram} chromatogram - GC/MS chromatogram where make the estimation.\n * @param {Object} [options = {}] - Options of ngmca factorization method\n * @param {Number} [options.rank] - number of pure components, if it's undefined it will be estimated by explained variance of PCA.\n * @param {Object} [options.range] - Range with from to.\n * @param {Number} [options.range.from] - lower limit in the retention time.\n * @param {Number} [options.range.to] - upper limit in the retention time.\n * @param {Number} [options.nmfOptions = {}] - options to Non negative factorization (deconvolution method).\n * @param {Number} [options.nmfOptions.maximumIteration = 500] - Maximum number of iterations.\n * @param {Number} [options.nmfOptions.maxFBIteration = 80] - Maximum number of iterations of the Forward-Backward subroutine.\n * @param {Number} [options.nmfOptions.toleranceFB = 1e-5] - relative difference tolerance for convergence of the Forward-Backward sub-iterations.\n * @param {Number} [options.nmfOptions.phaseRatio = 0.8] - transition between decreasing thresholding phase and refinement phase in percent of the iterations.\n * @param {Boolean} [options.useTranspose = false] - if true the originalMatrix is transposed.\n */\n\nexport function deconvolution(chromatogram, options = {}) {\n  let { range, rank, nmfOptions = {} } = options;\n  let { matrix, mzAxis, times } = chromatogram.getMzVsTimesMatrix(range);\n\n  if (!rank) rank = estimateNbPureComponents(chromatogram, { range, matrix });\n\n  if (rank < 1) {\n    throw new RangeError(\n      `Rank should be a positive number for ${range.from} - ${range.to}`,\n    );\n  }\n\n  let result = nGMCA(matrix, rank, nmfOptions);\n  let maxByRow = [];\n  for (let i = 0; i < result.S.rows; i++) {\n    maxByRow.push(result.S.maxRow(i));\n  }\n\n  result.S.scale('row', { scale: maxByRow });\n  result.A.scale('column', {\n    scale: maxByRow.map((e) => 1 / e),\n  });\n\n  return Object.assign(\n    { matrix, times, mzAxis, rank },\n    { profile: result.A, component: result.S },\n  );\n}\n","import {\n  xySortX,\n  xGetFromToIndex,\n  xyArrayWeightedMerge,\n} from 'ml-spectra-processing';\n\nexport function merge(chromatogram, options = {}) {\n  let { mergeThreshold = 0.3, seriesName = 'ms', range = {} } = options;\n\n  const time = chromatogram.getTimes();\n\n  chromatogram.requiresSeries(seriesName);\n  let series = chromatogram.series[seriesName];\n  if (series.dimension !== 2) {\n    throw new Error(`The series \"${seriesName}\" is not of dimension 2`);\n  }\n\n  if (!range || range.from > time[time.length - 1] || range.to < time[0]) {\n    return { x: [], y: [] };\n  }\n  let { fromIndex, toIndex } = xGetFromToIndex(time, range);\n\n  let data = series.data\n    .slice(fromIndex, toIndex + 1)\n    .map((datum) => xySortX({ x: datum[0], y: datum[1] }));\n\n  return {\n    ...xyArrayWeightedMerge(data, { delta: mergeThreshold }),\n    from: {\n      index: fromIndex,\n      time: time[fromIndex],\n    },\n    to: {\n      index: toIndex,\n      time: time[toIndex],\n    },\n  };\n}\n","import median from 'ml-array-median';\nimport { gsd, broadenPeaks } from 'ml-gsd';\n\nexport function getPeaks(chromatogram, options = {}) {\n  const {\n    heightFilter = 2,\n    seriesName = 'tic',\n    broadenPeaksOptions = { factor: 1, overlap: false },\n  } = options;\n\n  const series = chromatogram.getSeries(seriesName).data;\n  const times = chromatogram.getTimes();\n  // first peak selection\n  let peakList = gsd(\n    { x: times, y: series },\n    {\n      noiseLevel: 0,\n      realTopDetection: false,\n      smoothY: true,\n      sgOptions: { windowSize: 5, polynomial: 2 },\n      heightFactor: 2,\n    },\n  );\n  // filter height by factor\n  let medianHeight = median(series);\n\n  peakList = peakList.filter((val) => val.height > medianHeight * heightFilter);\n\n  peakList.sort((a, b) => a.x - b.x);\n\n  if (broadenPeaksOptions) {\n    peakList = broadenPeaks(peakList, broadenPeaksOptions);\n  }\n\n  return peakList.map((peak) => ({\n    from: peak.from,\n    to: peak.to,\n    inflectionPoints: {\n      from: Math.min(peak.left.x, peak.right.x),\n      to: Math.max(peak.left.x, peak.right.x),\n    },\n    retentionTime: peak.x,\n    intensity: peak.y,\n  }));\n}\n","export function filter(chromatogram, callback, options = {}) {\n  const { copy = false } = options;\n  if (copy) {\n    chromatogram = chromatogram.copy();\n  }\n\n  let times = chromatogram.getTimes();\n  let newTimes = [];\n  let indexToKeep = [];\n  for (let i = 0; i < times.length; i++) {\n    if (callback(i, times[i])) {\n      indexToKeep.push(i);\n      newTimes.push(times[i]);\n    }\n  }\n  chromatogram.times = newTimes;\n\n  for (let key of chromatogram.getSeriesNames()) {\n    const series = chromatogram.getSeries(key);\n    series.keep(indexToKeep);\n  }\n\n  return chromatogram;\n}\n","export function getClosestData(chromatogram, time, options = {}) {\n  const { seriesName = 'ms' } = options;\n  chromatogram.requiresSeries(seriesName);\n  let closest = chromatogram.getClosestTime(time);\n  return {\n    rt: chromatogram.getTimes()[closest],\n    index: closest,\n    data: chromatogram.getSeries(seriesName).data[closest],\n  };\n}\n","import { Matrix } from 'ml-matrix';\nimport { xFindClosestIndex } from 'ml-spectra-processing';\n\n/**\n * Return the submatrix, times, and mass x axis for each range\n * @param {Object} range - from - to of the TIC\n * @param {Number} [range.from] - lower limit in the retention time\n * @param {Number} [range.to] - upper limit in the retention time\n * @return {Object} - submatrix, times and m/z axis of the range.\n */\nexport function getMzVsTimesMatrix(chromatogram, range) {\n  let { from, to } = range;\n  let fromIndex = chromatogram.getClosestTime(from);\n  let toIndex = chromatogram.getClosestTime(to);\n\n  let data = chromatogram.series.ms.data.slice(fromIndex, toIndex);\n  let times = chromatogram.times.slice(fromIndex, toIndex);\n\n  let mzAxis = new Set();\n  for (let i = 0; i < data.length; i++) {\n    let spectrum = data[i];\n    for (let j = 0; j < spectrum[0].length; j++) {\n      mzAxis.add(Math.round(spectrum[0][j]));\n    }\n  }\n  mzAxis = Array.from(mzAxis).sort((a, b) => a - b);\n  const nbPoints = mzAxis.length;\n  const matrix = new Matrix(data.length, nbPoints);\n  for (let i = 0; i < data.length; i++) {\n    let element = data[i];\n    for (let j = 0; j < element[0].length; j++) {\n      let xValue = Math.round(element[0][j]);\n      let index = xFindClosestIndex(mzAxis, xValue);\n      matrix.set(i, index, element[1][j]);\n    }\n  }\n  return { times, mzAxis, matrix };\n}\n","export function baselineCorrection(points, fromTo, kind) {\n  const deltaTime = points.x[fromTo.toIndex] - points.x[fromTo.fromIndex];\n  const fromHeight = points.y[fromTo.fromIndex];\n  const toHeight = points.y[fromTo.toIndex];\n  let baseline = 0;\n  let from = 0;\n  let to = 0;\n  switch (kind) {\n    case 'trapezoid':\n      baseline = (deltaTime * (fromHeight + toHeight)) / 2;\n      from = fromHeight;\n      to = toHeight;\n      break;\n    case 'min':\n      from = Math.min(fromHeight, toHeight);\n      to = from;\n      baseline = deltaTime * from;\n      break;\n    default:\n      throw new Error(`Unknown baseline method \"${kind}\"`);\n  }\n  return {\n    value: baseline,\n    from,\n    to,\n  };\n}\n","import { xGetFromToIndex, xyIntegration } from 'ml-spectra-processing';\n\nimport { baselineCorrection } from './baselineCorrection';\n\nexport function integrate(chromatogram, ranges, options = {}) {\n  const { baseline, seriesName = 'tic' } = options;\n\n  if (!Array.isArray(ranges)) {\n    throw new Error('Ranges must be an array of type [{from,to}]');\n  }\n  if (ranges.length === 0) {\n    return [];\n  }\n\n  chromatogram.requiresSeries(seriesName);\n  let series = chromatogram.series[seriesName];\n  if (series.dimension !== 1) {\n    throw new Error(`The series \"${seriesName}\" is not of dimension 1`);\n  }\n\n  const time = chromatogram.getTimes();\n  let results = [];\n\n  for (let range of ranges) {\n    const fromTo = xGetFromToIndex(time, range);\n    const integral = integrateRange(\n      { x: time, y: series.data },\n      fromTo,\n      baseline,\n    );\n    results.push(integral);\n  }\n\n  return results;\n}\n\nfunction integrateRange(points, fromTo, baseline) {\n  let integration = xyIntegration(points, fromTo);\n\n  if (baseline) {\n    let correction = baselineCorrection(points, fromTo, baseline);\n    return {\n      integration: integration - correction.value,\n      from: {\n        time: points.x[fromTo.fromIndex],\n        index: fromTo.fromIndex,\n        baseline: correction.from,\n      },\n      to: {\n        time: points.x[fromTo.toIndex],\n        index: fromTo.toIndex,\n        baseline: correction.to,\n      },\n    };\n  } else {\n    return {\n      integration,\n      from: {\n        time: points.x[fromTo.fromIndex],\n        index: fromTo.fromIndex,\n        baseline: 0,\n      },\n      to: {\n        time: points.x[fromTo.toIndex],\n        index: fromTo.toIndex,\n        baseline: 0,\n      },\n    };\n  }\n}\n","import isAnyArray from 'is-any-array';\nimport { xFindClosestIndex } from 'ml-spectra-processing';\n\nimport { meanFilter } from './filter/meanFilter';\nimport { percentageFilter } from './filter/percentageFilter';\nimport { applyLockMass } from './ms/applyLockMass';\nimport { calculateBpc } from './ms/calculateBpc';\nimport { calculateEic } from './ms/calculateEic';\nimport { calculateForMF } from './ms/calculateForMF';\nimport { calculateLength } from './ms/calculateLength';\nimport { calculateTic } from './ms/calculateTic';\nimport { deconvolution } from './ms/deconvolution';\nimport { merge } from './ms/merge';\nimport { getPeaks } from './peaks/getPeaks';\nimport { seriesFromArray } from './seriesFromArray';\nimport { filter } from './util/filter';\nimport { getClosestData } from './util/getClosestData';\nimport { getMzVsTimesMatrix } from './util/getMzVsTimesMatrix';\nimport { integrate } from './util/integrate';\n\nexport class Chromatogram {\n  constructor(times, series) {\n    this.series = {};\n    this.times = [];\n    if (!isAnyArray(times)) {\n      throw new TypeError('times must be an array');\n    }\n    this.times = times;\n    if (series) {\n      for (const [name, value] of Object.entries(series)) {\n        this.addSeries(name, value);\n      }\n    }\n  }\n\n  get length() {\n    return this.times.length;\n  }\n\n  getSeries(seriesName) {\n    this.requiresSeries(seriesName);\n    return this.series[seriesName];\n  }\n\n  getSeries1D(seriesName) {\n    const series = this.getSeries(seriesName);\n    if (!series.is1D()) {\n      throw new Error(`series ${seriesName} is not a 1D series`);\n    }\n    return series;\n  }\n\n  getSeries2D(seriesName) {\n    const series = this.getSeries(seriesName);\n    if (!series.is2D()) {\n      throw new Error(`series ${seriesName} is not a 2D series`);\n    }\n    return series;\n  }\n\n  getSeriesNames() {\n    return Object.keys(this.series);\n  }\n\n  hasMass() {\n    return this.hasSeries('ms');\n  }\n\n  deleteSeries(seriesName) {\n    this.requiresSeries(seriesName);\n    delete this.series[seriesName];\n    return this;\n  }\n\n  addSeries(seriesName, array, options = {}) {\n    if (this.hasSeries(seriesName) && !options.force) {\n      throw new Error(`A series with name \"${seriesName}\" already exists`);\n    }\n    if (this.times.length !== array.length) {\n      throw new Error(`The series size is not the same as the times size`);\n    }\n    this.series[seriesName] = seriesFromArray(array);\n    this.series[seriesName].name = seriesName;\n    return this;\n  }\n\n  hasSeries(seriesName) {\n    return typeof this.series[seriesName] !== 'undefined';\n  }\n\n  requiresSeries(seriesName) {\n    if (!this.hasSeries(seriesName)) {\n      throw new Error(`The series \"${seriesName}\" does not exist`);\n    }\n  }\n\n  get firstTime() {\n    return this.times[0];\n  }\n\n  get lastTime() {\n    return this.times[this.length - 1];\n  }\n\n  getTimes() {\n    return this.times;\n  }\n\n  setTimes(times) {\n    if (times.length !== this.times.length) {\n      throw new Error('New times must have the same length as the old ones');\n    }\n    this.times = times;\n  }\n\n  rescaleTime(conversionFunction) {\n    this.times = this.times.map((time) => conversionFunction(time));\n    return this;\n  }\n\n  filter(callback, options) {\n    return filter(this, callback, options);\n  }\n\n  getPeaks(options) {\n    return getPeaks(this, options);\n  }\n\n  calculateTic(options = {}) {\n    if (!this.hasSeries('tic') || options.force) {\n      const tic = calculateTic(this);\n      this.addSeries('tic', tic, { force: true });\n    }\n\n    return this;\n  }\n\n  calculateLength(seriesName, options = {}) {\n    if (!this.hasSeries('length') || options.force) {\n      const length = calculateLength(this, seriesName);\n      this.addSeries('length', length, { force: true });\n    }\n    return this;\n  }\n\n  calculateBpc(options = {}) {\n    if (!this.hasSeries('bpc') || options.force) {\n      const bpc = calculateBpc(this);\n      this.addSeries('bpc', bpc, { force: true });\n    }\n    return this;\n  }\n\n  calculateEic(targetMass, options = {}) {\n    const {\n      seriesName = `ms${targetMass}±${options.slotWidth / 2 || 0.5}`,\n      cache = false,\n    } = options;\n    if (cache && this.hasSeries(seriesName)) return this.getSeries(seriesName);\n    const result = calculateEic(this, targetMass, options);\n    this.addSeries(seriesName, result, options);\n    return this.getSeries(seriesName);\n  }\n\n  calculateForMF(targetMF, options = {}) {\n    const {\n      seriesName = `${targetMF}(${options.ionizations || 'H+'})±${\n        options.slotWidth / 2 || 0.5\n      }${options.threshold ? `(${options.threshold})` : ''}`,\n      cache = false,\n    } = options;\n    if (cache && this.hasSeries(seriesName)) return this.getSeries(seriesName);\n    const result = calculateForMF(this, targetMF, options);\n    this.addSeries(seriesName, result, options);\n    return this.getSeries(seriesName);\n  }\n\n  integrate(ranges, options) {\n    return integrate(this, ranges, options);\n  }\n\n  merge(options) {\n    return merge(this, options);\n  }\n\n  getClosestTime(time) {\n    return xFindClosestIndex(this.getTimes(), time);\n  }\n\n  getClosestData(time, options = {}) {\n    return getClosestData(this, time, options);\n  }\n\n  copy() {\n    const json = JSON.parse(JSON.stringify(this));\n    return fromJSON(json);\n  }\n\n  meanFilter(seriesName, options = {}) {\n    const { seriesName: newSeriesName = 'msMean' } = options;\n    if (this.hasSeries(newSeriesName) && !options.force) {\n      throw new Error(`A series with name \"${seriesName}\" already exists`);\n    }\n    const newSeries = meanFilter(this, seriesName, options);\n    this.series[newSeriesName] = newSeries;\n    return newSeries;\n  }\n\n  percentageFilter(seriesName, options = {}) {\n    const { seriesName: newSeriesName = 'msPercentage' } = options;\n    if (this.hasSeries(newSeriesName) && !options.force) {\n      throw new Error(`A series with name \"${seriesName}\" already exists`);\n    }\n    const newSeries = percentageFilter(this, seriesName, options);\n    this.series[newSeriesName] = newSeries;\n    return newSeries;\n  }\n\n  applyLockMass(mfs, options) {\n    return applyLockMass(this, mfs, options);\n  }\n\n  getMzVsTimesMatrix(range = {}) {\n    return getMzVsTimesMatrix(this, range);\n  }\n\n  deconvolution(options = {}) {\n    return deconvolution(this, options);\n  }\n\n  toJSON() {\n    return {\n      times: this.times,\n      series: this.series,\n    };\n  }\n}\n\nexport function fromJSON(json) {\n  let series = json.series;\n  let times = json.times;\n  let chromatogram = new Chromatogram(times);\n\n  if (Array.isArray(series)) {\n    for (let i = 0; i < series.length; i++) {\n      chromatogram.addSeries(series[i].name, series[i].data);\n    }\n  } else {\n    for (let key of Object.keys(series)) {\n      chromatogram.addSeries(key, series[key].data, {\n        meta: series[key].meta,\n      });\n    }\n  }\n  return chromatogram;\n}\n","import { merge } from '../ms/merge';\n\n/**\n * Append MS spectra to a list of peaks\n * @param {Chromatogram} chromatogram\n * @param {Array<object>} peaks - Array of range {from:, to:}\n * @param {object} [options={}] - Options for the integral filtering\n * @param {number} [options.mergeThreshold=0.3] - Peaks that are under this value (in Da) will be merged\n * @param {number} [options.seriesName='ms'] - Maximum number of peaks for each mass spectra (when is Number.MAX_VALUE there's no filter)\n * @return {Array<object>} - A copy of ranges with ms appended\n */\nexport function appendMass(chromatogram, peaks, options = {}) {\n  const { mergeThreshold = 0.3, seriesName = 'ms' } = options;\n  const result = [];\n  // integrate MS\n  for (const peak of peaks) {\n    const massSpectrum = merge(chromatogram, {\n      mergeThreshold,\n      seriesName,\n      range: peak,\n    });\n    result.push({\n      ...peak,\n      ms: massSpectrum,\n    });\n  }\n  return result;\n}\n","export function massFilter(massXYObject, options = {}) {\n  const {\n    thresholdFactor = 0,\n    maxNumberPeaks = Number.MAX_VALUE,\n    groupWidth = 0,\n  } = options;\n\n  let max = -1;\n  let massList = new Array(massXYObject.x.length);\n  for (let i = 0; i < massXYObject.x.length; ++i) {\n    massList[i] = {\n      x: massXYObject.x[i],\n      y: massXYObject.y[i],\n    };\n\n    if (massXYObject.y[i] > max) {\n      max = massXYObject.y[i];\n    }\n  }\n\n  // filters based in thresholdFactor\n  max *= thresholdFactor;\n  let filteredList = massList.filter((val) => val.y > max);\n\n  // filters based in maxNumberPeaks\n  if (filteredList.length > maxNumberPeaks || groupWidth !== 0) {\n    filteredList.sort((a, b) => b.y - a.y);\n\n    // filters based in groupWidth\n    filteredList = moreDistinct(filteredList, maxNumberPeaks, groupWidth);\n\n    filteredList.sort((a, b) => a.x - b.x);\n  }\n\n  let ans = {\n    x: new Array(filteredList.length),\n    y: new Array(filteredList.length),\n  };\n  for (let i = 0; i < filteredList.length; ++i) {\n    ans.x[i] = filteredList[i].x;\n    ans.y[i] = filteredList[i].y;\n  }\n\n  return ans;\n}\n\n/**\n * Filters based in groupWidth\n * @ignore\n * @param {Array<object>} list - Sorted list of XY-objects to be filtered\n * @param {number} maxNumberPeaks - Maximum number of peaks for each mass spectra\n * @param {number} groupWidth - When find a max can't be another max in a radius of this size\n * @return {Array<object>} - List of XY-objects filtered\n */\nexport function moreDistinct(list, maxNumberPeaks, groupWidth) {\n  let len = 0;\n  if (maxNumberPeaks > list.length) {\n    maxNumberPeaks = list.length;\n  }\n  let filteredList = new Array(maxNumberPeaks);\n\n  for (let i = 0; i < list.length && len < maxNumberPeaks; ++i) {\n    let outRange = true;\n    for (let j = 0; j < len && outRange; ++j) {\n      outRange =\n        outRange &&\n        !(\n          list[i].x > filteredList[j].x - groupWidth &&\n          list[i].x < filteredList[j].x + groupWidth\n        );\n    }\n    if (outRange) {\n      filteredList[len++] = list[i];\n    }\n  }\n  filteredList.length = len;\n\n  return filteredList;\n}\n","import { massFilter } from './massFilter';\n\nexport function vectorify(ranges, options = {}) {\n  const { massPower = 3, intPower = 0.6 } = options;\n  let filter =\n    options.thresholdFactor || options.maxNumberPeaks || options.groupWidth;\n\n  let vector = new Array(ranges.length);\n  if (filter) {\n    const filterOptions = {\n      thresholdFactor: options.thresholdFactor,\n      maxNumberPeaks: options.maxNumberPeaks,\n      groupWidth: options.groupWidth,\n    };\n\n    for (let i = 0; i < ranges.length; ++i) {\n      let len = ranges[i].ms.x.length;\n      vector[i] = {\n        x: ranges[i].ms.x,\n        y: new Array(len),\n      };\n      for (let j = 0; j < len; ++j) {\n        vector[i].y[j] =\n          Math.pow(ranges[i].ms.x[j], massPower) *\n          Math.pow(ranges[i].ms.y[j], intPower);\n      }\n\n      vector[i] = massFilter(vector[i], filterOptions);\n    }\n  } else {\n    for (let i = 0; i < ranges.length; ++i) {\n      let len = ranges[i].ms.x.length;\n      vector[i] = {\n        x: ranges[i].ms.x,\n        y: new Array(len),\n      };\n      for (let j = 0; j < len; ++j) {\n        vector[i].y[j] =\n          Math.pow(ranges[i].ms.x[j], massPower) *\n          Math.pow(ranges[i].ms.y[j], intPower);\n      }\n    }\n  }\n\n  return vector;\n}\n","export function cosineSimilarity(ms1x, ms1y, ms2x, ms2y) {\n  let index1 = 0;\n  let index2 = 0;\n\n  let product = 0;\n  let norm1 = 0;\n  let norm2 = 0;\n\n  while (index1 < ms1x.length || index2 < ms2x.length) {\n    let w1 = ms1y[index1];\n    let w2 = ms2y[index2];\n    if (index2 === ms2x.length || ms1x[index1] < ms2x[index2]) {\n      norm1 += w1 * w1;\n      ++index1;\n    } else if (index1 === ms1x.length || ms2x[index2] < ms1x[index1]) {\n      norm2 += w2 * w2;\n      ++index2;\n    } else {\n      product += w1 * w2;\n      norm1 += w1 * w1;\n      norm2 += w2 * w2;\n      ++index1;\n      ++index2;\n    }\n  }\n\n  let norm1Norm2 = norm1 * norm2;\n  if (norm1Norm2 === 0) {\n    return 0;\n  } else {\n    return (product * product) / norm1Norm2;\n  }\n}\n","import { cosineSimilarity } from './ms/cosineSimilarity';\nimport { appendMass } from './peaks/appendMass';\nimport { getPeaks } from './peaks/getPeaks';\nimport { vectorify } from './vectorify';\n\n/**\n * Preprocessing task over the signalsj\n * @ignore\n * @param {Chromatogram} chromatogram - Chromatogram to process\n * @param {object} [options] - Options object (same as spectraComparison)\n * @return {{peaks: Array<object>, integratedMs: Array<object>, vector: Array<object>}} - Array of peaks, integrated mass spectra and weighted mass spectra\n */\nfunction preprocessing(chromatogram, options) {\n  // peak picking\n  let peaks = getPeaks(chromatogram, options);\n  peaks = peaks.sort((a, b) => a.from - b.to);\n\n  // integrate mass in the peaks\n  let integratedMs = appendMass(chromatogram, peaks, options);\n  let vector = vectorify(integratedMs, options);\n  return {\n    peaks,\n    integratedMs,\n    vector,\n  };\n}\n\nconst defaultOptions = {\n  thresholdFactor: 0,\n  maxNumberPeaks: Number.MAX_VALUE,\n  groupWidth: 0,\n  heightFilter: 2,\n  massPower: 3,\n  intPower: 0.6,\n  similarityThreshold: 0.7,\n};\n\nexport function spectraComparison(chrom1, chrom2, options = {}) {\n  options = Object.assign({}, defaultOptions, options);\n\n  // peak picking\n  let reference = preprocessing(chrom1, options);\n  let sample = preprocessing(chrom2, options);\n\n  // similarity between MS\n  const len = Math.max(sample.peaks.length, reference.peaks.length);\n  let similarityPeaks = {\n    chrom1: new Array(len),\n    chrom2: new Array(len),\n    similarity: new Array(len),\n  };\n  let similarLen = 0;\n\n  // Similarity matrix\n  for (let i = 0; i < sample.peaks.length; ++i) {\n    let max = { similarity: -3 };\n    let biggerCounter = 0;\n    for (let j = 0; j < reference.peaks.length; ++j) {\n      let sim = cosineSimilarity(\n        sample.vector[i].x,\n        sample.vector[i].y,\n        reference.vector[j].x,\n        reference.vector[j].y,\n      );\n\n      if (sim > options.similarityThreshold && sim > max.similarity) {\n        max = {\n          similarity: sim,\n          chrom1: reference.peaks[j],\n          chrom2: sample.peaks[i],\n        };\n      }\n      if (sim > options.similarityThreshold) {\n        ++biggerCounter;\n      }\n    }\n    if (biggerCounter === 1) {\n      similarityPeaks.chrom1[similarLen] = max.chrom1;\n      similarityPeaks.chrom2[similarLen] = max.chrom2;\n      similarityPeaks.similarity[similarLen++] = max.similarity;\n    }\n  }\n\n  similarityPeaks.chrom1.length = similarLen;\n  similarityPeaks.chrom2.length = similarLen;\n\n  let duplicates = {};\n  for (let i = 0; i < similarLen; ++i) {\n    if (duplicates[similarityPeaks.chrom1[i].retentionTime]) {\n      duplicates[similarityPeaks.chrom1[i].retentionTime].push(i);\n    } else {\n      duplicates[similarityPeaks.chrom1[i].retentionTime] = [i];\n    }\n  }\n\n  let peaksChrom1 = [];\n  let peaksChrom2 = [];\n  let peaksSimilarity = [];\n  for (let val in duplicates) {\n    if (duplicates[val].length === 1) {\n      peaksChrom1.push(similarityPeaks.chrom1[duplicates[val][0]]);\n      peaksChrom2.push(similarityPeaks.chrom2[duplicates[val][0]]);\n      peaksSimilarity.push(similarityPeaks.similarity[duplicates[val][0]]);\n    }\n  }\n\n  return {\n    peaksFirst: peaksChrom1,\n    peaksSecond: peaksChrom2,\n    peaksSimilarity: peaksSimilarity,\n  };\n}\n","export default function maybeToPrecision(value, digits) {\n  if (value < 0) {\n    value = 0 - value;\n    if (typeof digits === 'number') {\n      return `- ${value.toPrecision(digits)}`;\n    } else {\n      return `- ${value.toString()}`;\n    }\n  } else {\n    if (typeof digits === 'number') {\n      return value.toPrecision(digits);\n    } else {\n      return value.toString();\n    }\n  }\n}\n","import isAnyArray from 'is-any-array';\n\nexport default function checkArraySize(x, y) {\n  if (!isAnyArray(x) || !isAnyArray(y)) {\n    throw new TypeError('x and y must be arrays');\n  }\n  if (x.length !== y.length) {\n    throw new RangeError('x and y arrays must have the same length');\n  }\n}\n","import isAnyArray from 'is-any-array';\n\nexport { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\nexport default class BaseRegression {\n  constructor() {\n    if (new.target === BaseRegression) {\n      throw new Error('BaseRegression must be subclassed');\n    }\n  }\n\n  predict(x) {\n    if (typeof x === 'number') {\n      return this._predict(x);\n    } else if (isAnyArray(x)) {\n      const y = [];\n      for (let i = 0; i < x.length; i++) {\n        y.push(this._predict(x[i]));\n      }\n      return y;\n    } else {\n      throw new TypeError('x must be a number or array');\n    }\n  }\n\n  _predict() {\n    throw new Error('_predict must be implemented');\n  }\n\n  train() {\n    // Do nothing for this package\n  }\n\n  toString() {\n    return '';\n  }\n\n  toLaTeX() {\n    return '';\n  }\n\n  /**\n   * Return the correlation coefficient of determination (r) and chi-square.\n   * @param {Array<number>} x\n   * @param {Array<number>} y\n   * @return {object}\n   */\n  score(x, y) {\n    if (!isAnyArray(x) || !isAnyArray(y) || x.length !== y.length) {\n      throw new Error('x and y must be arrays of the same length');\n    }\n\n    const n = x.length;\n    const y2 = new Array(n);\n    for (let i = 0; i < n; i++) {\n      y2[i] = this._predict(x[i]);\n    }\n\n    let xSum = 0;\n    let ySum = 0;\n    let chi2 = 0;\n    let rmsd = 0;\n    let xSquared = 0;\n    let ySquared = 0;\n    let xY = 0;\n    for (let i = 0; i < n; i++) {\n      xSum += y2[i];\n      ySum += y[i];\n      xSquared += y2[i] * y2[i];\n      ySquared += y[i] * y[i];\n      xY += y2[i] * y[i];\n      if (y[i] !== 0) {\n        chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n      }\n      rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n    }\n\n    const r =\n      (n * xY - xSum * ySum) /\n      Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n    return {\n      r: r,\n      r2: r * r,\n      chi2: chi2,\n      rmsd: Math.sqrt(rmsd / n),\n    };\n  }\n}\n","import { Matrix, MatrixTransposeView, solve } from 'ml-matrix';\nimport BaseRegression, {\n  checkArrayLength,\n  maybeToPrecision,\n} from 'ml-regression-base';\n\nexport default class PolynomialRegression extends BaseRegression {\n  constructor(x, y, degree) {\n    super();\n    if (x === true) {\n      this.degree = y.degree;\n      this.powers = y.powers;\n      this.coefficients = y.coefficients;\n    } else {\n      checkArrayLength(x, y);\n      regress(this, x, y, degree);\n    }\n  }\n\n  _predict(x) {\n    let y = 0;\n    for (let k = 0; k < this.powers.length; k++) {\n      y += this.coefficients[k] * Math.pow(x, this.powers[k]);\n    }\n    return y;\n  }\n\n  toJSON() {\n    return {\n      name: 'polynomialRegression',\n      degree: this.degree,\n      powers: this.powers,\n      coefficients: this.coefficients,\n    };\n  }\n\n  toString(precision) {\n    return this._toFormula(precision, false);\n  }\n\n  toLaTeX(precision) {\n    return this._toFormula(precision, true);\n  }\n\n  _toFormula(precision, isLaTeX) {\n    let sup = '^';\n    let closeSup = '';\n    let times = ' * ';\n    if (isLaTeX) {\n      sup = '^{';\n      closeSup = '}';\n      times = '';\n    }\n\n    let fn = '';\n    let str = '';\n    for (let k = 0; k < this.coefficients.length; k++) {\n      str = '';\n      if (this.coefficients[k] !== 0) {\n        if (this.powers[k] === 0) {\n          str = maybeToPrecision(this.coefficients[k], precision);\n        } else {\n          if (this.powers[k] === 1) {\n            str = `${maybeToPrecision(this.coefficients[k], precision) +\n              times}x`;\n          } else {\n            str = `${maybeToPrecision(this.coefficients[k], precision) +\n              times}x${sup}${this.powers[k]}${closeSup}`;\n          }\n        }\n\n        if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n          str = ` + ${str}`;\n        } else if (k !== this.coefficients.length - 1) {\n          str = ` ${str}`;\n        }\n      }\n      fn = str + fn;\n    }\n    if (fn.charAt(0) === '+') {\n      fn = fn.slice(1);\n    }\n\n    return `f(x) = ${fn}`;\n  }\n\n  static load(json) {\n    if (json.name !== 'polynomialRegression') {\n      throw new TypeError('not a polynomial regression model');\n    }\n    return new PolynomialRegression(true, json);\n  }\n}\n\nfunction regress(pr, x, y, degree) {\n  const n = x.length;\n  let powers;\n  if (Array.isArray(degree)) {\n    powers = degree;\n    degree = powers.length;\n  } else {\n    degree++;\n    powers = new Array(degree);\n    for (let k = 0; k < degree; k++) {\n      powers[k] = k;\n    }\n  }\n  const F = new Matrix(n, degree);\n  const Y = new Matrix([y]);\n  for (let k = 0; k < degree; k++) {\n    for (let i = 0; i < n; i++) {\n      if (powers[k] === 0) {\n        F.set(i, k, 1);\n      } else {\n        F.set(i, k, Math.pow(x[i], powers[k]));\n      }\n    }\n  }\n\n  const FT = new MatrixTransposeView(F);\n  const A = FT.mmul(F);\n  const B = FT.mmul(new MatrixTransposeView(Y));\n\n  pr.degree = degree - 1;\n  pr.powers = powers;\n  pr.coefficients = solve(A, B).to1DArray();\n}\n","import Regression from 'ml-regression-polynomial';\n\nexport function scaleAlignment(reference, sample, options = {}) {\n  const { computeQuality = false, polynomialDegree = 3 } = options;\n  let referenceTime = reference.map((val) => val.retentionTime);\n  let sampleTime = sample.map((val) => val.retentionTime);\n\n  const regression = new Regression(\n    sampleTime,\n    referenceTime,\n    polynomialDegree,\n  );\n\n  let error = new Array(sample.length);\n  for (let i = 0; i < sample.length; i++) {\n    error[i] =\n      reference[i].retentionTime - regression.predict(sample[i].retentionTime);\n  }\n\n  let ans = {\n    scaleRegression: regression,\n  };\n\n  if (computeQuality) {\n    let score = regression.score(sampleTime, referenceTime);\n    ans.r2 = score.r2;\n    ans.error = error;\n  }\n  return ans;\n}\n","import max from 'ml-array-max';\n\n/**\n * Calculates the Kovats retention index for a mass spectra of a n-alkane\n * @param {object} ms - A mass spectra object\n * @param {Array<number>} ms.x - Array of masses\n * @param {Array<number>} ms.y - Array of intensities\n * @return {number} - Kovats retention index\n */\nexport function kovats(ms, options = {}) {\n  const { threshold = 0.01 } = options;\n  // we normalize the data and filter them\n  let maxY = max(ms.y);\n  let masses = [];\n  let intensities = [];\n  for (let i = 0; i < ms.x.length; i++) {\n    if (ms.y[i] / maxY > threshold) {\n      masses.push(ms.x[i]);\n      intensities.push(ms.y[i] / maxY);\n    }\n  }\n\n  // we find candidates\n  let nAlcaneMasses = [];\n  let fragmentMasses = [];\n\n  for (let i = 0; i < masses.length; i++) {\n    if ((masses[i] - 2) % 14 === 0) {\n      nAlcaneMasses.push(masses[i]);\n    }\n    if ((masses[i] - 1) % 14 === 0) {\n      fragmentMasses.push(masses[i]);\n    }\n  }\n\n  if (nAlcaneMasses.length === 0) return {};\n\n  let biggestMass = nAlcaneMasses.sort((a, b) => b - a)[0];\n  fragmentMasses = fragmentMasses.filter((mass) => mass < biggestMass);\n\n  return {\n    index: (100 * (biggestMass - 2)) / 14,\n    numberFragments: fragmentMasses.length,\n    percentFragments: fragmentMasses.length / ((biggestMass - 2) / 14),\n  };\n}\n","import { kovats } from '../kovats';\n\nexport function appendKovats(peaks) {\n  const result = [];\n  for (let peak of peaks) {\n    result.push({ ...peak, kovats: kovats(peak.ms) });\n  }\n  return result;\n}\n","module.exports = function(haystack, needle, comparator, low, high) {\n  var mid, cmp;\n\n  if(low === undefined)\n    low = 0;\n\n  else {\n    low = low|0;\n    if(low < 0 || low >= haystack.length)\n      throw new RangeError(\"invalid lower bound\");\n  }\n\n  if(high === undefined)\n    high = haystack.length - 1;\n\n  else {\n    high = high|0;\n    if(high < low || high >= haystack.length)\n      throw new RangeError(\"invalid upper bound\");\n  }\n\n  while(low <= high) {\n    // The naive `low + high >>> 1` could fail for array lengths > 2**31\n    // because `>>>` converts its operands to int32. `low + (high - low >>> 1)`\n    // works for array lengths <= 2**32-1 which is also Javascript's max array\n    // length.\n    mid = low + ((high - low) >>> 1);\n    cmp = +comparator(haystack[mid], needle, mid, haystack);\n\n    // Too low.\n    if(cmp < 0.0)\n      low  = mid + 1;\n\n    // Too high.\n    else if(cmp > 0.0)\n      high = mid - 1;\n\n    // Key found.\n    else\n      return mid;\n  }\n\n  // Key not found.\n  return ~low;\n}\n","import binarySearch from 'binary-search';\n\nconst ascValue = (a, b) => a.index - b.index;\nconst ascTime = (a, b) => a.time - b.time;\n\nexport function getKovatsConversionFunction(peaks, options = {}) {\n  const { revert = false } = options;\n\n  const kovatsConversionTable = peaks.map((peak) => ({\n    time: peak.x,\n    index: peak.kovats.index,\n  }));\n\n  if (revert) {\n    const indexes = kovatsConversionTable.sort(ascValue);\n\n    return (index) => {\n      let position = binarySearch(indexes, { index }, ascValue);\n\n      if (position < 0) {\n        position = ~position;\n\n        // handle extreme cases\n        if (position === 0 || position === indexes.length) {\n          return 0;\n        }\n\n        let smallerAlcane = indexes[position - 1].time;\n        let largerAlcane = indexes[position].time;\n        return (\n          ((index - indexes[position - 1].index) *\n            (largerAlcane - smallerAlcane)) /\n            100 +\n          smallerAlcane\n        );\n      } else {\n        return indexes[position].time;\n      }\n    };\n  } else {\n    const times = kovatsConversionTable.sort(ascTime);\n\n    return (time) => {\n      let position = binarySearch(times, { time }, ascTime);\n      if (position < 0) {\n        position = ~position;\n\n        // handle extreme cases\n        if (position === 0 || position === times.length) {\n          return 0;\n        }\n\n        let smallerAlcane = times[position - 1].time;\n        let largerAlcane = times[position].time;\n        return (\n          (100 * (time - smallerAlcane)) / (largerAlcane - smallerAlcane) +\n          times[position - 1].index\n        );\n      } else {\n        return times[position].index;\n      }\n    };\n  }\n}\n","/**\n * Ensure that the data is string. If it is an ArrayBuffer it will be converted to string using TextDecoder.\n * @param blob\n * @param options\n * @returns\n */\nexport function ensureString(blob, options = {}) {\n    if (typeof blob === 'string') {\n        return blob;\n    }\n    if (ArrayBuffer.isView(blob) || blob instanceof ArrayBuffer) {\n        const { encoding = guessEncoding(blob) } = options;\n        const decoder = new TextDecoder(encoding);\n        return decoder.decode(blob);\n    }\n    throw new TypeError(`blob must be a string, ArrayBuffer or ArrayBufferView`);\n}\nfunction guessEncoding(blob) {\n    const uint8 = ArrayBuffer.isView(blob)\n        ? new Uint8Array(blob.buffer, blob.byteOffset, blob.byteLength)\n        : new Uint8Array(blob);\n    if (uint8.length >= 2) {\n        if (uint8[0] === 0xfe && uint8[1] === 0xff) {\n            return 'utf-16be';\n        }\n        if (uint8[0] === 0xff && uint8[1] === 0xfe) {\n            return 'utf-16le';\n        }\n    }\n    return 'utf-8';\n}\n//# sourceMappingURL=index.js.map","/**\n * Dynamically type a string\n * @param {string} value String to dynamically type\n * @returns {boolean|string|number}\n */\nexport function parseString(value) {\n  if (value.length === 4 || value.length === 5) {\n    let lowercase = value.toLowerCase();\n\n    if (lowercase === 'true') return true;\n    if (lowercase === 'false') return false;\n  }\n  let number = Number(value);\n  if (number === 0 && !value.includes('0')) {\n    return value;\n  }\n  if (!Number.isNaN(number)) return number;\n  return value;\n}\n","const GC_MS_FIELDS = ['TIC', '.RIC', 'SCANNUMBER'];\n\nexport function complexChromatogram(result) {\n  let spectra = result.spectra;\n  let length = spectra.length;\n  let chromatogram = {\n    times: new Array(length),\n    series: {\n      ms: {\n        dimension: 2,\n        data: new Array(length),\n      },\n    },\n  };\n\n  let existingGCMSFields = [];\n  for (let i = 0; i < GC_MS_FIELDS.length; i++) {\n    let label = convertMSFieldToLabel(GC_MS_FIELDS[i]);\n    if (spectra[0][label]) {\n      existingGCMSFields.push(label);\n      chromatogram.series[label] = {\n        dimension: 1,\n        data: new Array(length),\n      };\n    }\n  }\n\n  for (let i = 0; i < length; i++) {\n    let spectrum = spectra[i];\n    chromatogram.times[i] = spectrum.pageValue;\n    for (let j = 0; j < existingGCMSFields.length; j++) {\n      chromatogram.series[existingGCMSFields[j]].data[i] = parseFloat(\n        spectrum[existingGCMSFields[j]],\n      );\n    }\n    if (spectrum.data) {\n      chromatogram.series.ms.data[i] = [spectrum.data.x, spectrum.data.y];\n    }\n  }\n  result.chromatogram = chromatogram;\n}\n\nexport function isMSField(canonicDataLabel) {\n  return GC_MS_FIELDS.indexOf(canonicDataLabel) !== -1;\n}\n\nexport function convertMSFieldToLabel(value) {\n  return value.toLowerCase().replace(/[^a-z0-9]/g, '');\n}\n","export default function convertToFloatArray(stringArray) {\n  let floatArray = [];\n  for (let i = 0; i < stringArray.length; i++) {\n    floatArray.push(parseFloat(stringArray[i]));\n  }\n  return floatArray;\n}\n","export default function fastParseXYData(spectrum, value) {\n  // TODO need to deal with result\n  //  console.log(value);\n  // we check if deltaX is defined otherwise we calculate it\n\n  let yFactor = spectrum.yFactor;\n  let deltaX = spectrum.deltaX;\n\n  spectrum.isXYdata = true;\n  let currentData = { x: [], y: [] };\n  spectrum.data = currentData;\n\n  let currentX = spectrum.firstX;\n  let currentY = spectrum.firstY;\n\n  // we skip the first line\n  //\n  let endLine = false;\n  let ascii;\n  let i = 0;\n  for (; i < value.length; i++) {\n    ascii = value.charCodeAt(i);\n    if (ascii === 13 || ascii === 10) {\n      endLine = true;\n    } else {\n      if (endLine) break;\n    }\n  }\n\n  // we proceed taking the i after the first line\n  let newLine = true;\n  let isDifference = false;\n  let isLastDifference = false;\n  let lastDifference = 0;\n  let isDuplicate = false;\n  let inComment = false;\n  let currentValue = 0; // can be a difference or a duplicate\n  let lastValue = 0; // must be the real last value\n  let isNegative = false;\n  let inValue = false;\n  let skipFirstValue = false;\n  let decimalPosition = 0;\n  for (; i <= value.length; i++) {\n    if (i === value.length) ascii = 13;\n    else ascii = value.charCodeAt(i);\n    if (inComment) {\n      // we should ignore the text if we are after $$\n      if (ascii === 13 || ascii === 10) {\n        newLine = true;\n        inComment = false;\n      }\n    } else {\n      // when is it a new value ?\n      // when it is not a digit, . or comma\n      // it is a number that is either new or we continue\n      if (ascii <= 57 && ascii >= 48) {\n        // a number\n        inValue = true;\n        if (decimalPosition > 0) {\n          currentValue += (ascii - 48) / Math.pow(10, decimalPosition++);\n        } else {\n          currentValue *= 10;\n          currentValue += ascii - 48;\n        }\n      } else if (ascii === 44 || ascii === 46) {\n        // a \",\" or \".\"\n        inValue = true;\n        decimalPosition++;\n      } else {\n        if (inValue) {\n          // need to process the previous value\n          if (newLine) {\n            newLine = false; // we don't check the X value\n            // console.log(\"NEW LINE\",isDifference, lastDifference);\n            // if new line and lastDifference, the first value is just a check !\n            // that we don't check ...\n            if (isLastDifference) skipFirstValue = true;\n          } else {\n            // need to deal with duplicate and differences\n            if (skipFirstValue) {\n              skipFirstValue = false;\n            } else {\n              if (isDifference) {\n                lastDifference = isNegative ? 0 - currentValue : currentValue;\n                isLastDifference = true;\n                isDifference = false;\n              } else if (!isDuplicate) {\n                lastValue = isNegative ? 0 - currentValue : currentValue;\n              }\n              let duplicate = isDuplicate ? currentValue - 1 : 1;\n              for (let j = 0; j < duplicate; j++) {\n                if (isLastDifference) {\n                  currentY += lastDifference;\n                } else {\n                  currentY = lastValue;\n                }\n                currentData.x.push(currentX);\n                currentData.y.push(currentY * yFactor);\n                currentX += deltaX;\n              }\n            }\n          }\n          isNegative = false;\n          currentValue = 0;\n          decimalPosition = 0;\n          inValue = false;\n          isDuplicate = false;\n        }\n\n        // positive SQZ digits @ A B C D E F G H I (ascii 64-73)\n        if (ascii < 74 && ascii > 63) {\n          inValue = true;\n          isLastDifference = false;\n          currentValue = ascii - 64;\n        } else if (ascii > 96 && ascii < 106) {\n          // negative SQZ digits a b c d e f g h i (ascii 97-105)\n          inValue = true;\n          isLastDifference = false;\n          currentValue = ascii - 96;\n          isNegative = true;\n        } else if (ascii === 115) {\n          // DUP digits S T U V W X Y Z s (ascii 83-90, 115)\n          inValue = true;\n          isDuplicate = true;\n          currentValue = 9;\n        } else if (ascii > 82 && ascii < 91) {\n          inValue = true;\n          isDuplicate = true;\n          currentValue = ascii - 82;\n        } else if (ascii > 73 && ascii < 83) {\n          // positive DIF digits % J K L M N O P Q R (ascii 37, 74-82)\n          inValue = true;\n          isDifference = true;\n          currentValue = ascii - 73;\n        } else if (ascii > 105 && ascii < 115) {\n          // negative DIF digits j k l m n o p q r (ascii 106-114)\n          inValue = true;\n          isDifference = true;\n          currentValue = ascii - 105;\n          isNegative = true;\n        } else if (ascii === 36 && value.charCodeAt(i + 1) === 36) {\n          // $ sign, we need to check the next one\n          inValue = true;\n          inComment = true;\n        } else if (ascii === 37) {\n          // positive DIF digits % J K L M N O P Q R (ascii 37, 74-82)\n          inValue = true;\n          isDifference = true;\n          currentValue = 0;\n          isNegative = false;\n        } else if (ascii === 45) {\n          // a \"-\"\n          // check if after there is a number, decimal or comma\n          let ascii2 = value.charCodeAt(i + 1);\n          if (\n            (ascii2 >= 48 && ascii2 <= 57) ||\n            ascii2 === 44 ||\n            ascii2 === 46\n          ) {\n            inValue = true;\n            if (!newLine) isLastDifference = false;\n            isNegative = true;\n          }\n        } else if (ascii === 13 || ascii === 10) {\n          newLine = true;\n          inComment = false;\n        }\n        // and now analyse the details ... space or tabulation\n        // if \"+\" we just don't care\n      }\n    }\n  }\n}\n","const removeCommentRegExp = /\\$\\$.*/;\nconst peakTableSplitRegExp = /[,\\t ]+/;\n\nexport default function parsePeakTable(spectrum, value, result) {\n  spectrum.isPeaktable = true;\n\n  if (!spectrum.variables || Object.keys(spectrum.variables) === 2) {\n    parseXY(spectrum, value, result);\n  } else {\n    parseXYZ(spectrum, value, result);\n  }\n\n  // we will add the data in the variables\n  if (spectrum.variables) {\n    for (let key in spectrum.variables) {\n      spectrum.variables[key].data = spectrum.data[key];\n    }\n  }\n}\n\nfunction parseXY(spectrum, value, result) {\n  let currentData = { x: [], y: [] };\n  spectrum.data = currentData;\n\n  // counts for around 20% of the time\n  let lines = value.split(/,? *,?[;\\r\\n]+ */);\n\n  for (let i = 1; i < lines.length; i++) {\n    let values = lines[i]\n      .trim()\n      .replace(removeCommentRegExp, '')\n      .split(peakTableSplitRegExp);\n    if (values.length % 2 === 0) {\n      for (let j = 0; j < values.length; j = j + 2) {\n        // takes around 40% of the time to add and parse the 2 values nearly exclusively because of parseFloat\n        currentData.x.push(parseFloat(values[j]) * spectrum.xFactor);\n        currentData.y.push(parseFloat(values[j + 1]) * spectrum.yFactor);\n      }\n    } else {\n      result.logs.push(`Format error: ${values}`);\n    }\n  }\n}\n\nfunction parseXYZ(spectrum, value, result) {\n  let currentData = {};\n  let variables = Object.keys(spectrum.variables);\n  let numberOfVariables = variables.length;\n  variables.forEach((variable) => (currentData[variable] = []));\n  spectrum.data = currentData;\n\n  // counts for around 20% of the time\n  let lines = value.split(/,? *,?[;\\r\\n]+ */);\n\n  for (let i = 1; i < lines.length; i++) {\n    let values = lines[i]\n      .trim()\n      .replace(removeCommentRegExp, '')\n      .split(peakTableSplitRegExp);\n    if (values.length % numberOfVariables === 0) {\n      for (let j = 0; j < values.length; j++) {\n        // todo should try to find a xFactor (y, ...)\n        currentData[variables[j % numberOfVariables]].push(\n          parseFloat(values[j]),\n        );\n      }\n    } else {\n      result.logs.push(`Format error: ${values}`);\n    }\n  }\n}\n","export default function parseXYA(spectrum, value) {\n  let removeSymbolRegExp = /(\\(+|\\)+|<+|>+|\\s+)/g;\n\n  spectrum.isXYAdata = true;\n  let values;\n  let currentData = { x: [], y: [] };\n  spectrum.data = currentData;\n\n  let lines = value.split(/,? *,?[;\\r\\n]+ */);\n\n  for (let i = 1; i < lines.length; i++) {\n    values = lines[i].trim().replace(removeSymbolRegExp, '').split(',');\n    currentData.x.push(parseFloat(values[0]));\n    currentData.y.push(parseFloat(values[1]));\n  }\n}\n","import getMedian from 'ml-array-median';\n\nexport default function convertTo3DZ(spectra) {\n  let minZ = spectra[0].data.y[0];\n  let maxZ = minZ;\n  let ySize = spectra.length;\n  let xSize = spectra[0].data.x.length;\n\n  let z = new Array(ySize);\n  for (let i = 0; i < ySize; i++) {\n    z[i] = spectra[i].data.y;\n    for (let j = 0; j < xSize; j++) {\n      let value = z[i][j];\n      if (value < minZ) minZ = value;\n      if (value > maxZ) maxZ = value;\n    }\n  }\n\n  const firstX = spectra[0].data.x[0];\n  const lastX = spectra[0].data.x[spectra[0].data.x.length - 1]; // has to be -2 because it is a 1D array [x,y,x,y,...]\n  const firstY = spectra[0].pageValue;\n  const lastY = spectra[ySize - 1].pageValue;\n\n  // Because the min / max value are the only information about the matrix if we invert\n  // min and max we need to invert the array\n  if (firstX > lastX) {\n    for (let spectrum of z) {\n      spectrum.reverse();\n    }\n  }\n  if (firstY > lastY) {\n    z.reverse();\n  }\n\n  const medians = [];\n  for (let i = 0; i < z.length; i++) {\n    const row = Float64Array.from(z[i]);\n    for (let i = 0; i < row.length; i++) {\n      if (row[i] < 0) row[i] = -row[i];\n    }\n    medians.push(getMedian(row));\n  }\n  const median = getMedian(medians);\n\n  return {\n    z: z,\n    minX: Math.min(firstX, lastX),\n    maxX: Math.max(firstX, lastX),\n    minY: Math.min(firstY, lastY),\n    maxY: Math.max(firstY, lastY),\n    minZ: minZ,\n    maxZ: maxZ,\n    noise: median,\n  };\n}\n","export default function generateContourLines(zData, options) {\n  let noise = zData.noise;\n  let z = zData.z;\n  let povarHeight0, povarHeight1, povarHeight2, povarHeight3;\n  let isOver0, isOver1, isOver2, isOver3;\n  let nbSubSpectra = z.length;\n  let nbPovars = z[0].length;\n  let pAx, pAy, pBx, pBy;\n\n  let x0 = zData.minX;\n  let xN = zData.maxX;\n  let dx = (xN - x0) / (nbPovars - 1);\n  let y0 = zData.minY;\n  let yN = zData.maxY;\n  let dy = (yN - y0) / (nbSubSpectra - 1);\n  let minZ = zData.minZ;\n  let maxZ = zData.maxZ;\n\n  // System.out.prvarln('y0 '+y0+' yN '+yN);\n  // -------------------------\n  // Povars attribution\n  //\n  // 0----1\n  // |  / |\n  // | /  |\n  // 2----3\n  //\n  // ---------------------d------\n\n  let iter = options.nbContourLevels * 2;\n  let contourLevels = new Array(iter);\n  let lineZValue;\n  for (let level = 0; level < iter; level++) {\n    // multiply by 2 for positif and negatif\n    let contourLevel = {};\n    contourLevels[level] = contourLevel;\n    let side = level % 2;\n    let factor =\n      (maxZ - options.noiseMultiplier * noise) *\n      Math.exp((level >> 1) - options.nbContourLevels);\n    if (side === 0) {\n      lineZValue = factor + options.noiseMultiplier * noise;\n    } else {\n      lineZValue = 0 - factor - options.noiseMultiplier * noise;\n    }\n    let lines = [];\n    contourLevel.zValue = lineZValue;\n    contourLevel.lines = lines;\n\n    if (lineZValue <= minZ || lineZValue >= maxZ) continue;\n\n    for (let iSubSpectra = 0; iSubSpectra < nbSubSpectra - 1; iSubSpectra++) {\n      let subSpectra = z[iSubSpectra];\n      let subSpectraAfter = z[iSubSpectra + 1];\n      for (let povar = 0; povar < nbPovars - 1; povar++) {\n        povarHeight0 = subSpectra[povar];\n        povarHeight1 = subSpectra[povar + 1];\n        povarHeight2 = subSpectraAfter[povar];\n        povarHeight3 = subSpectraAfter[povar + 1];\n\n        isOver0 = povarHeight0 > lineZValue;\n        isOver1 = povarHeight1 > lineZValue;\n        isOver2 = povarHeight2 > lineZValue;\n        isOver3 = povarHeight3 > lineZValue;\n\n        // Example povar0 is over the plane and povar1 and\n        // povar2 are below, we find the varersections and add\n        // the segment\n        if (isOver0 !== isOver1 && isOver0 !== isOver2) {\n          pAx =\n            povar + (lineZValue - povarHeight0) / (povarHeight1 - povarHeight0);\n          pAy = iSubSpectra;\n          pBx = povar;\n          pBy =\n            iSubSpectra +\n            (lineZValue - povarHeight0) / (povarHeight2 - povarHeight0);\n          lines.push(pAx * dx + x0);\n          lines.push(pAy * dy + y0);\n          lines.push(pBx * dx + x0);\n          lines.push(pBy * dy + y0);\n        }\n        // remove push does not help !!!!\n        if (isOver3 !== isOver1 && isOver3 !== isOver2) {\n          pAx = povar + 1;\n          pAy =\n            iSubSpectra +\n            1 -\n            (lineZValue - povarHeight3) / (povarHeight1 - povarHeight3);\n          pBx =\n            povar +\n            1 -\n            (lineZValue - povarHeight3) / (povarHeight2 - povarHeight3);\n          pBy = iSubSpectra + 1;\n          lines.push(pAx * dx + x0);\n          lines.push(pAy * dy + y0);\n          lines.push(pBx * dx + x0);\n          lines.push(pBy * dy + y0);\n        }\n        // test around the diagonal\n        if (isOver1 !== isOver2) {\n          pAx =\n            (povar +\n              1 -\n              (lineZValue - povarHeight1) / (povarHeight2 - povarHeight1)) *\n              dx +\n            x0;\n          pAy =\n            (iSubSpectra +\n              (lineZValue - povarHeight1) / (povarHeight2 - povarHeight1)) *\n              dy +\n            y0;\n          if (isOver1 !== isOver0) {\n            pBx =\n              povar +\n              1 -\n              (lineZValue - povarHeight1) / (povarHeight0 - povarHeight1);\n            pBy = iSubSpectra;\n            lines.push(pAx);\n            lines.push(pAy);\n            lines.push(pBx * dx + x0);\n            lines.push(pBy * dy + y0);\n          }\n          if (isOver2 !== isOver0) {\n            pBx = povar;\n            pBy =\n              iSubSpectra +\n              1 -\n              (lineZValue - povarHeight2) / (povarHeight0 - povarHeight2);\n            lines.push(pAx);\n            lines.push(pAy);\n            lines.push(pBx * dx + x0);\n            lines.push(pBy * dy + y0);\n          }\n          if (isOver1 !== isOver3) {\n            pBx = povar + 1;\n            pBy =\n              iSubSpectra +\n              (lineZValue - povarHeight1) / (povarHeight3 - povarHeight1);\n            lines.push(pAx);\n            lines.push(pAy);\n            lines.push(pBx * dx + x0);\n            lines.push(pBy * dy + y0);\n          }\n          if (isOver2 !== isOver3) {\n            pBx =\n              povar +\n              (lineZValue - povarHeight2) / (povarHeight3 - povarHeight2);\n            pBy = iSubSpectra + 1;\n            lines.push(pAx);\n            lines.push(pAy);\n            lines.push(pBx * dx + x0);\n            lines.push(pBy * dy + y0);\n          }\n        }\n      }\n    }\n  }\n\n  return {\n    minX: zData.minX,\n    maxX: zData.maxX,\n    minY: zData.minY,\n    maxY: zData.maxY,\n    segments: contourLevels,\n  };\n}\n","import convertTo3DZ from './convertTo3DZ';\nimport generateContourLines from './generateContourLines';\n\nexport default function add2D(result, options) {\n  let zData = convertTo3DZ(result.spectra);\n  if (!options.noContour) {\n    result.contourLines = generateContourLines(zData, options);\n    delete zData.z;\n  }\n  result.minMax = zData;\n}\n","// sources:\n// https://en.wikipedia.org/wiki/Gyromagnetic_ratio\n\n// TODO: #13 can we have a better source and more digits ? @jwist\n\nexport const gyromagneticRatio = {\n  '1H': 267.52218744e6,\n  '2H': 41.065e6,\n  '3H': 285.3508e6,\n  '3He': -203.789e6,\n  '7Li': 103.962e6,\n  '13C': 67.28284e6,\n  '14N': 19.331e6,\n  '15N': -27.116e6,\n  '17O': -36.264e6,\n  '19F': 251.662e6,\n  '23Na': 70.761e6,\n  '27Al': 69.763e6,\n  '29Si': -53.19e6,\n  '31P': 108.291e6,\n  '57Fe': 8.681e6,\n  '63Cu': 71.118e6,\n  '67Zn': 16.767e6,\n  '129Xe': -73.997e6,\n};\n","import { gyromagneticRatio } from 'nmr-processing';\n\nexport default function postProcessingNMR(entriesFlat) {\n  // specific NMR functions\n\n  for (let entry of entriesFlat) {\n    let observeFrequency = 0;\n    let shiftOffsetVal = 0;\n    for (let spectrum of entry.spectra) {\n      if (entry.ntuples && entry.ntuples.symbol) {\n        if (!observeFrequency && spectrum.observeFrequency) {\n          observeFrequency = spectrum.observeFrequency;\n        }\n        if (!shiftOffsetVal && spectrum.shiftOffsetVal) {\n          shiftOffsetVal = spectrum.shiftOffsetVal;\n        }\n      } else {\n        observeFrequency = spectrum.observeFrequency;\n        shiftOffsetVal = spectrum.shiftOffsetVal;\n      }\n\n      if (observeFrequency) {\n        if (spectrum.xUnits && spectrum.xUnits.toUpperCase().includes('HZ')) {\n          spectrum.xUnits = 'PPM';\n          spectrum.xFactor = spectrum.xFactor / observeFrequency;\n          spectrum.firstX = spectrum.firstX / observeFrequency;\n          spectrum.lastX = spectrum.lastX / observeFrequency;\n          spectrum.deltaX = spectrum.deltaX / observeFrequency;\n          for (let i = 0; i < spectrum.data.x.length; i++) {\n            spectrum.data.x[i] /= observeFrequency;\n          }\n        }\n      }\n      if (shiftOffsetVal) {\n        let shift = spectrum.firstX - shiftOffsetVal;\n        spectrum.firstX = spectrum.firstX - shift;\n        spectrum.lastX = spectrum.lastX - shift;\n        for (let i = 0; i < spectrum.data.x.length; i++) {\n          spectrum.data.x[i] -= shift;\n        }\n      }\n\n      // we will check if some nucleus are missing ...\n      if (entry.ntuples && entry.ntuples.nucleus && entry.ntuples.symbol) {\n        for (let i = 0; i < entry.ntuples.nucleus.length; i++) {\n          let symbol = entry.ntuples.symbol[i];\n          let nucleus = entry.ntuples.nucleus[i];\n          if (symbol.startsWith('F') && !nucleus) {\n            if (symbol === 'F1') {\n              // if F1 is defined we will use F2\n              if (entry.tmp.$NUC2) {\n                entry.ntuples.nucleus[i] = entry.tmp.$NUC2;\n              } else {\n                let f2index = entry.ntuples.symbol.indexOf('F2');\n                if (f2index && entry.ntuples.nucleus[f2index]) {\n                  entry.ntuples.nucleus[i] = entry.ntuples.nucleus[f2index];\n                }\n              }\n            }\n            if (symbol === 'F2') entry.ntuples.nucleus[i] = entry.tmp.$NUC1;\n          }\n          if (symbol === 'F2') {\n            entry.yType = entry.ntuples.nucleus[0];\n          }\n        }\n      }\n\n      if (\n        observeFrequency &&\n        entry.ntuples &&\n        entry.ntuples.symbol &&\n        entry.ntuples.nucleus\n      ) {\n        let unit = '';\n        let pageSymbolIndex = entry.ntuples.symbol.indexOf(spectrum.pageSymbol);\n        if (entry.ntuples.units && entry.ntuples.units[pageSymbolIndex]) {\n          unit = entry.ntuples.units[pageSymbolIndex];\n        }\n        if (unit !== 'PPM') {\n          if (pageSymbolIndex !== 0) {\n            throw Error('Not sure about this ntuples format');\n          }\n\n          let ratio0 = gyromagneticRatio[entry.ntuples.nucleus[0]];\n          let ratio1 = gyromagneticRatio[entry.ntuples.nucleus[1]];\n          if (!ratio0 || !ratio1) {\n            throw Error('Problem with determination of gyromagnetic ratio');\n          }\n          let ratio = (ratio0 / ratio1) * observeFrequency;\n          spectrum.pageValue /= ratio;\n        }\n      }\n    }\n  }\n}\n","export default function profiling(result, action, options) {\n  if (result.profiling) {\n    result.profiling.push({\n      action,\n      time: Date.now() - options.start,\n    });\n  }\n}\n","export default function simpleChromatogram(result) {\n  let data = result.spectra[0].data;\n  result.chromatogram = {\n    times: data.x.slice(),\n    series: {\n      intensity: {\n        dimension: 1,\n        data: data.y.slice(),\n      },\n    },\n  };\n}\n","import add2D from './2d/add2D';\nimport { complexChromatogram } from './complexChromatogram';\nimport postProcessingNMR from './postProcessingNMR';\nimport profiling from './profiling';\nimport simpleChromatogram from './simpleChromatogram';\n\nexport default function postProcessing(entriesFlat, result, options) {\n  // converting Hz to ppm\n  postProcessingNMR(entriesFlat);\n\n  for (let entry of entriesFlat) {\n    if (Object.keys(entry.ntuples).length > 0) {\n      let newNtuples = [];\n      let keys = Object.keys(entry.ntuples);\n      for (let i = 0; i < keys.length; i++) {\n        let key = keys[i];\n        let values = entry.ntuples[key];\n        for (let j = 0; j < values.length; j++) {\n          if (!newNtuples[j]) newNtuples[j] = {};\n          newNtuples[j][key] = values[j];\n        }\n      }\n      entry.ntuples = newNtuples;\n    }\n\n    if (entry.twoD && options.wantXY) {\n      add2D(entry, options);\n\n      profiling(result, 'Finished countour plot calculation', options);\n\n      if (!options.keepSpectra) {\n        delete entry.spectra;\n      }\n    }\n\n    // maybe it is a GC (HPLC) / MS. In this case we add a new format\n    if (options.chromatogram) {\n      if (entry.spectra.length > 1) {\n        complexChromatogram(entry);\n      } else {\n        simpleChromatogram(entry);\n      }\n      profiling(result, 'Finished chromatogram calculation', options);\n    }\n\n    delete entry.tmp;\n  }\n}\n","export default function prepareNtuplesDatatable(currentEntry, spectrum, kind) {\n  let xIndex = -1;\n  let yIndex = -1;\n  let firstVariable = '';\n  let secondVariable = '';\n  if (kind.indexOf('++') > 0) {\n    firstVariable = kind.replace(/.*\\(([a-zA-Z0-9]+)\\+\\+.*/, '$1');\n    secondVariable = kind.replace(/.*\\.\\.([a-zA-Z0-9]+).*/, '$1');\n  } else {\n    kind = kind.replace(/[^a-zA-Z]/g, '');\n    firstVariable = kind.charAt(0);\n    secondVariable = kind.charAt(1);\n    spectrum.variables = {};\n    for (let symbol of kind) {\n      let lowerCaseSymbol = symbol.toLowerCase();\n      let index = currentEntry.ntuples.symbol.indexOf(symbol);\n      if (index === -1) throw Error(`Symbol undefined: ${symbol}`);\n      spectrum.variables[lowerCaseSymbol] = {};\n      for (let key in currentEntry.ntuples) {\n        if (currentEntry.ntuples[key][index]) {\n          spectrum.variables[lowerCaseSymbol][key.replace(/^var/, '')] =\n            currentEntry.ntuples[key][index];\n        }\n      }\n    }\n  }\n  xIndex = currentEntry.ntuples.symbol.indexOf(firstVariable);\n  yIndex = currentEntry.ntuples.symbol.indexOf(secondVariable);\n\n  if (xIndex === -1) xIndex = 0;\n  if (yIndex === -1) yIndex = 0;\n\n  if (currentEntry.ntuples.first) {\n    if (currentEntry.ntuples.first.length > xIndex) {\n      spectrum.firstX = currentEntry.ntuples.first[xIndex];\n    }\n    if (currentEntry.ntuples.first.length > yIndex) {\n      spectrum.firstY = currentEntry.ntuples.first[yIndex];\n    }\n  }\n  if (currentEntry.ntuples.last) {\n    if (currentEntry.ntuples.last.length > xIndex) {\n      spectrum.lastX = currentEntry.ntuples.last[xIndex];\n    }\n    if (currentEntry.ntuples.last.length > yIndex) {\n      spectrum.lastY = currentEntry.ntuples.last[yIndex];\n    }\n  }\n  if (\n    currentEntry.ntuples.vardim &&\n    currentEntry.ntuples.vardim.length > xIndex\n  ) {\n    spectrum.nbPoints = currentEntry.ntuples.vardim[xIndex];\n  }\n  if (currentEntry.ntuples.factor) {\n    if (currentEntry.ntuples.factor.length > xIndex) {\n      spectrum.xFactor = currentEntry.ntuples.factor[xIndex];\n    }\n    if (currentEntry.ntuples.factor.length > yIndex) {\n      spectrum.yFactor = currentEntry.ntuples.factor[yIndex];\n    }\n  }\n  if (currentEntry.ntuples.units) {\n    if (currentEntry.ntuples.units.length > xIndex) {\n      if (\n        currentEntry.ntuples.varname &&\n        currentEntry.ntuples.varname[xIndex]\n      ) {\n        spectrum.xUnits = `${currentEntry.ntuples.varname[xIndex]} [${currentEntry.ntuples.units[xIndex]}]`;\n      } else {\n        spectrum.xUnits = currentEntry.ntuples.units[xIndex];\n      }\n    }\n    if (currentEntry.ntuples.units.length > yIndex) {\n      if (\n        currentEntry.ntuples.varname &&\n        currentEntry.ntuples.varname[yIndex]\n      ) {\n        spectrum.yUnits = `${currentEntry.ntuples.varname[yIndex]} [${currentEntry.ntuples.units[yIndex]}]`;\n      } else {\n        spectrum.yUnits = currentEntry.ntuples.units[yIndex];\n      }\n    }\n  }\n}\n","export default function prepareSpectrum(spectrum) {\n  if (!spectrum.xFactor) spectrum.xFactor = 1;\n  if (!spectrum.yFactor) spectrum.yFactor = 1;\n}\n","import { parseString } from 'dynamic-typing';\nimport { ensureString } from 'ensure-string';\n\nimport { isMSField, convertMSFieldToLabel } from './complexChromatogram';\nimport convertToFloatArray from './convertToFloatArray';\nimport fastParseXYData from './parse/fastParseXYData';\nimport parsePeakTable from './parse/parsePeakTable';\nimport parseXYA from './parse/parseXYA';\nimport postProcessing from './postProcessing';\nimport prepareNtuplesDatatable from './prepareNtuplesDatatable';\nimport prepareSpectrum from './prepareSpectrum';\nimport profiling from './profiling';\n\n// the following RegExp can only be used for XYdata, some peakTables have values with a \"E-5\" ...\nconst ntuplesSeparatorRegExp = /[ \\t]*,[ \\t]*/;\n\nclass Spectrum {}\n\nconst defaultOptions = {\n  keepRecordsRegExp: /^$/,\n  canonicDataLabels: true,\n  canonicMetadataLabels: false,\n  dynamicTyping: true,\n  withoutXY: false,\n  chromatogram: false,\n  keepSpectra: false,\n  noContour: false,\n  nbContourLevels: 7,\n  noiseMultiplier: 5,\n  profiling: false,\n};\n\n/**\n *\n * @param {string|ArrayBuffer} jcamp\n * @param {object} [options]\n * @param {number} [options.keepRecordsRegExp=/^$/] By default we don't keep meta information\n * @param {number} [options.canonicDataLabels=true] Canonize the Labels (uppercase without symbol)\n * @param {number} [options.canonicMetadataLabels=false] Canonize the metadata Labels (uppercase without symbol)\n * @param {number} [options.dynamicTyping=false] Convert numbers to Number\n * @param {number} [options.withoutXY=false] Remove the XY data\n * @param {number} [options.chromatogram=false] Special post-processing for GC / HPLC / MS\n * @param {number} [options.keepSpectra=false] Force to keep the spectra in case of 2D\n * @param {number} [options.noContour=false] Don't calculate countour in case of 2D\n * @param {number} [options.nbContourLevels=7] Number of positive / negative contour levels to calculate\n * @param {number} [options.noiseMultiplier=5] Define for 2D the level as 5 times the median as default\n * @param {number} [options.profiling=false] Add profiling information\n */\n\nexport default function convert(jcamp, options = {}) {\n  jcamp = ensureString(jcamp);\n  options = { ...defaultOptions, ...options };\n  options.wantXY = !options.withoutXY;\n  options.start = Date.now();\n\n  let entriesFlat = [];\n\n  let result = {\n    profiling: options.profiling ? [] : false,\n    logs: [],\n    entries: [],\n  };\n\n  let tmpResult = { children: [] };\n  let currentEntry = tmpResult;\n  let parentsStack = [];\n\n  let spectrum = new Spectrum();\n\n  if (typeof jcamp !== 'string') {\n    throw new TypeError('the JCAMP should be a string');\n  }\n\n  profiling(result, 'Before split to LDRS', options);\n\n  let ldrs = jcamp.replace(/[\\r\\n]+##/g, '\\n##').split('\\n##');\n\n  profiling(result, 'Split to LDRS', options);\n\n  if (ldrs[0]) ldrs[0] = ldrs[0].replace(/^[\\r\\n ]*##/, '');\n\n  for (let ldr of ldrs) {\n    // This is a new LDR\n    let position = ldr.indexOf('=');\n    let dataLabel = position > 0 ? ldr.substring(0, position) : ldr;\n    let dataValue = position > 0 ? ldr.substring(position + 1).trim() : '';\n\n    let canonicDataLabel = dataLabel.replace(/[_ -]/g, '').toUpperCase();\n\n    if (canonicDataLabel === 'DATATABLE') {\n      let endLine = dataValue.indexOf('\\n');\n      if (endLine === -1) endLine = dataValue.indexOf('\\r');\n      if (endLine > 0) {\n        // ##DATA TABLE= (X++(I..I)), XYDATA\n        // We need to find the variables\n\n        let infos = dataValue.substring(0, endLine).split(/[ ,;\\t]+/);\n        prepareNtuplesDatatable(currentEntry, spectrum, infos[0]);\n\n        spectrum.datatable = infos[0];\n        if (infos[1] && infos[1].indexOf('PEAKS') > -1) {\n          canonicDataLabel = 'PEAKTABLE';\n        } else if (\n          infos[1] &&\n          (infos[1].indexOf('XYDATA') || infos[0].indexOf('++') > 0)\n        ) {\n          canonicDataLabel = 'XYDATA';\n          spectrum.deltaX =\n            (spectrum.lastX - spectrum.firstX) / (spectrum.nbPoints - 1);\n        }\n      }\n    }\n\n    if (canonicDataLabel === 'XYDATA') {\n      if (options.wantXY) {\n        prepareSpectrum(spectrum);\n        // well apparently we should still consider it is a PEAK TABLE if there are no '++' after\n        if (dataValue.match(/.*\\+\\+.*/)) {\n          // ex: (X++(Y..Y))\n          spectrum.deltaX =\n            (spectrum.lastX - spectrum.firstX) / (spectrum.nbPoints - 1);\n\n          fastParseXYData(spectrum, dataValue, result);\n        } else {\n          parsePeakTable(spectrum, dataValue, result);\n        }\n        currentEntry.spectra.push(spectrum);\n        spectrum = new Spectrum();\n      }\n      continue;\n    } else if (canonicDataLabel === 'PEAKTABLE') {\n      if (options.wantXY) {\n        prepareSpectrum(spectrum);\n        parsePeakTable(spectrum, dataValue, result);\n        currentEntry.spectra.push(spectrum);\n        spectrum = new Spectrum();\n      }\n      continue;\n    }\n    if (canonicDataLabel === 'PEAKASSIGNMENTS') {\n      if (options.wantXY) {\n        if (dataValue.match(/.*(XYA).*/)) {\n          // ex: (XYA)\n          parseXYA(spectrum, dataValue);\n        }\n        currentEntry.spectra.push(spectrum);\n        spectrum = new Spectrum();\n      }\n      continue;\n    }\n\n    if (canonicDataLabel === 'TITLE') {\n      let parentEntry = currentEntry;\n      if (!parentEntry.children) {\n        parentEntry.children = [];\n      }\n      currentEntry = {\n        spectra: [],\n        ntuples: {},\n        info: {},\n        meta: {},\n        tmp: {}, // tmp information we need to keep for postprocessing\n      };\n      parentEntry.children.push(currentEntry);\n      parentsStack.push(parentEntry);\n      entriesFlat.push(currentEntry);\n      currentEntry.title = dataValue;\n    } else if (canonicDataLabel === 'DATATYPE') {\n      currentEntry.dataType = dataValue;\n      if (dataValue.match(/(^nd|\\snd\\s)/i)) {\n        currentEntry.twoD = true;\n      }\n    } else if (canonicDataLabel === 'NTUPLES') {\n      if (dataValue.match(/(^nd|\\snd\\s)/i)) {\n        currentEntry.twoD = true;\n      }\n    } else if (canonicDataLabel === 'DATACLASS') {\n      currentEntry.dataClass = dataValue;\n    } else if (canonicDataLabel === 'XUNITS') {\n      spectrum.xUnits = dataValue;\n    } else if (canonicDataLabel === 'YUNITS') {\n      spectrum.yUnits = dataValue;\n    } else if (canonicDataLabel === 'FIRSTX') {\n      spectrum.firstX = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'LASTX') {\n      spectrum.lastX = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'FIRSTY') {\n      spectrum.firstY = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'LASTY') {\n      spectrum.lastY = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'NPOINTS') {\n      spectrum.nbPoints = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'XFACTOR') {\n      spectrum.xFactor = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'YFACTOR') {\n      spectrum.yFactor = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'MAXX') {\n      spectrum.maxX = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'MINX') {\n      spectrum.minX = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'MAXY') {\n      spectrum.maxY = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'MINY') {\n      spectrum.minY = parseFloat(dataValue);\n    } else if (canonicDataLabel === 'DELTAX') {\n      spectrum.deltaX = parseFloat(dataValue);\n    } else if (\n      canonicDataLabel === '.OBSERVEFREQUENCY' ||\n      canonicDataLabel === '$SFO1'\n    ) {\n      if (!spectrum.observeFrequency) {\n        spectrum.observeFrequency = parseFloat(dataValue);\n      }\n    } else if (canonicDataLabel === '.OBSERVENUCLEUS') {\n      if (!spectrum.xType) {\n        currentEntry.xType = dataValue.replace(/[^a-zA-Z0-9]/g, '');\n      }\n    } else if (canonicDataLabel === '$OFFSET') {\n      // OFFSET for Bruker spectra\n      currentEntry.shiftOffsetNum = 0;\n      if (!spectrum.shiftOffsetVal) {\n        spectrum.shiftOffsetVal = parseFloat(dataValue);\n      }\n    } else if (canonicDataLabel === '$REFERENCEPOINT') {\n      // OFFSET for Varian spectra\n      // if we activate this part it does not work for ACD specmanager\n      //         } else if (canonicDataLabel=='.SHIFTREFERENCE') {   // OFFSET FOR Bruker Spectra\n      //                 var parts = dataValue.split(/ *, */);\n      //                 currentEntry.shiftOffsetNum = parseInt(parts[2].trim());\n      //                 spectrum.shiftOffsetVal = parseFloat(parts[3].trim());\n    } else if (canonicDataLabel === 'VARNAME') {\n      currentEntry.ntuples.varname = dataValue.split(ntuplesSeparatorRegExp);\n    } else if (canonicDataLabel === 'SYMBOL') {\n      currentEntry.ntuples.symbol = dataValue.split(ntuplesSeparatorRegExp);\n    } else if (canonicDataLabel === 'VARTYPE') {\n      currentEntry.ntuples.vartype = dataValue.split(ntuplesSeparatorRegExp);\n    } else if (canonicDataLabel === 'VARFORM') {\n      currentEntry.ntuples.varform = dataValue.split(ntuplesSeparatorRegExp);\n    } else if (canonicDataLabel === 'VARDIM') {\n      currentEntry.ntuples.vardim = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === 'UNITS') {\n      currentEntry.ntuples.units = dataValue.split(ntuplesSeparatorRegExp);\n    } else if (canonicDataLabel === 'FACTOR') {\n      currentEntry.ntuples.factor = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === 'FIRST') {\n      currentEntry.ntuples.first = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === 'LAST') {\n      currentEntry.ntuples.last = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === 'MIN') {\n      currentEntry.ntuples.min = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === 'MAX') {\n      currentEntry.ntuples.max = convertToFloatArray(\n        dataValue.split(ntuplesSeparatorRegExp),\n      );\n    } else if (canonicDataLabel === '.NUCLEUS') {\n      if (currentEntry.ntuples) {\n        currentEntry.ntuples.nucleus = dataValue.split(ntuplesSeparatorRegExp);\n      }\n    } else if (canonicDataLabel === 'PAGE') {\n      spectrum.page = dataValue.trim();\n      spectrum.pageValue = parseFloat(dataValue.replace(/^.*=/, ''));\n      spectrum.pageSymbol = spectrum.page.replace(/[=].*/, '');\n    } else if (canonicDataLabel === 'RETENTIONTIME') {\n      spectrum.pageValue = parseFloat(dataValue);\n    } else if (isMSField(canonicDataLabel)) {\n      spectrum[convertMSFieldToLabel(canonicDataLabel)] = dataValue;\n    } else if (canonicDataLabel === 'SAMPLEDESCRIPTION') {\n      spectrum.sampleDescription = dataValue;\n    } else if (canonicDataLabel.startsWith('$NUC')) {\n      if (!currentEntry.tmp[canonicDataLabel] && !dataValue.includes('off')) {\n        currentEntry.tmp[canonicDataLabel] = dataValue.replace(/[<>]/g, '');\n      }\n    } else if (canonicDataLabel === 'END') {\n      currentEntry = parentsStack.pop();\n    }\n\n    if (\n      currentEntry &&\n      currentEntry.info &&\n      currentEntry.meta &&\n      canonicDataLabel.match(options.keepRecordsRegExp)\n    ) {\n      let value = dataValue.trim();\n      let target, label;\n      if (dataLabel.startsWith('$')) {\n        label = options.canonicMetadataLabels\n          ? canonicDataLabel.substring(1)\n          : dataLabel.substring(1);\n        target = currentEntry.meta;\n      } else {\n        label = options.canonicDataLabels ? canonicDataLabel : dataLabel;\n        target = currentEntry.info;\n      }\n\n      if (options.dynamicTyping) {\n        value = parseString(value);\n      }\n      if (target[label]) {\n        if (!Array.isArray(target[label])) {\n          target[label] = [target[label]];\n        }\n        target[label].push(value);\n      } else {\n        target[label] = value;\n      }\n    }\n  }\n\n  profiling(result, 'Finished parsing', options);\n\n  postProcessing(entriesFlat, result, options);\n\n  profiling(result, 'Total time', options);\n\n  /*\n  if (result.children && result.children.length>0) {\n    result = { ...result, ...result.children[0] };\n  }\n  */\n  result.entries = tmpResult.children;\n  result.flatten = entriesFlat;\n\n  return result;\n}\n","import { convert as converter } from 'jcampconverter';\n\nimport { fromJSON } from '../Chromatogram';\n\nexport function fromJcamp(jcamp) {\n  const data = converter(jcamp, { chromatogram: true }).flatten[0].chromatogram;\n  return fromJSON(data);\n}\n","/**\n * Ensure that the data is string. If it is an ArrayBuffer it will be converted to string using TextDecoder.\n * @param {string|ArrayBuffer} blob\n * @param {object} [options={}]\n * @param {string} [options.encoding='utf8']\n * @returns {string}\n */\n\nexport function ensureString(blob, options = {}) {\n  const { encoding = 'utf8' } = options;\n  if (ArrayBuffer.isView(blob) || blob instanceof ArrayBuffer) {\n    const decoder = new TextDecoder(encoding);\n    return decoder.decode(blob);\n  }\n  return blob;\n}\n","/**\n * In place modification of the 2 arrays to make X unique and sum the Y if X has the same value\n * @param {object} [points={}] : Object of points contains property x (an array) and y (an array)\n * @return points\n */\n\nexport default function uniqueX(points = {}) {\n  const { x, y } = points;\n  if (x.length < 2) return;\n  if (x.length !== y.length) {\n    throw new Error('The X and Y arrays mush have the same length');\n  }\n\n  let current = x[0];\n  let counter = 0;\n\n  for (let i = 1; i < x.length; i++) {\n    if (current !== x[i]) {\n      counter++;\n      current = x[i];\n      x[counter] = x[i];\n      if (i !== counter) {\n        y[counter] = 0;\n      }\n    }\n    if (i !== counter) {\n      y[counter] += y[i];\n    }\n  }\n\n  x.length = counter + 1;\n  y.length = counter + 1;\n}\n","import { ensureString } from \"ensure-string\";\nimport mlArrayMax from \"ml-array-max\";\nimport uniqueXFunction from \"ml-arrayxy-uniquex\";\nimport { xIsMonotone } from \"ml-spectra-processing\";\n\n/**\n * Parse a text-file and convert it to an array of XY points\n * @param {string} text - csv or tsv strings\n * @param {object} [options={}]\n * @param {boolean} [options.rescale = false] - will set the maximum value to 1\n * @param {boolean} [options.uniqueX = false] - Make the X values unique (works only with 'xxyy' format). If the X value is repeated the sum of Y is done.\n * @param {number} [options.xColumn = 0] - A number that specifies the x column\n * @param {number} [options.yColumn = 1] - A number that specifies the y column\n * @param {boolean} [options.bestGuess=false] Will try to guess which columns are the best\n * @param {number} [options.numberColumns=Number.MAX_SAFE_INTEGER] If the file has 10 columns and you specify here 2 it will reflow the file\n * @param {number} [options.maxNumberColumns = (Math.max(xColumn, yColumn)+1)] - A number that specifies the maximum number of y columns\n * @param {number} [options.minNumberColumns = (Math.min(xColumn, yColumn)+1)] - A number that specifies the minimum number of y columns\n * @param {boolean} [options.keepInfo = false] - shoud we keep the non numeric lines. In this case the system will return an object {data, info}\n * @return {object{x:<Array<number>>,y:<Array<number>>}\n */\nexport function parseXY(text, options = {}) {\n  let {\n    rescale = false,\n    uniqueX = false,\n    xColumn = 0,\n    yColumn = 1,\n    keepInfo = false,\n    bestGuess = false,\n    numberColumns = Number.MAX_SAFE_INTEGER,\n    maxNumberColumns = Number.MAX_SAFE_INTEGER,\n    minNumberColumns = 2,\n  } = options;\n\n  text = ensureString(text);\n\n  maxNumberColumns = Math.max(maxNumberColumns, xColumn + 1, yColumn + 1);\n  minNumberColumns = Math.max(xColumn + 1, yColumn + 1, minNumberColumns);\n\n  let lines = text.split(/[\\r\\n]+/);\n\n  let matrix = [];\n  let info = [];\n  let position = 0;\n  for (let l = 0; l < lines.length; l++) {\n    let line = lines[l].trim();\n    // we will consider only lines that contains only numbers\n    if (line.match(/[0-9]+/) && line.match(/^[0-9eE,;. \\t+-]+$/)) {\n      let fields = line.split(/,[; \\t]+|[; \\t]+/);\n      if (fields.length === 1) {\n        fields = line.split(/[,; \\t]+/);\n      }\n      if (\n        fields &&\n        fields.length >= minNumberColumns && // we filter lines that have not enough or too many columns\n        fields.length <= maxNumberColumns\n      ) {\n        matrix.push(fields.map((value) => parseFloat(value.replace(\",\", \".\"))));\n        position++;\n      }\n    } else if (line) {\n      info.push({ position, value: line });\n    }\n  }\n\n  if (bestGuess) {\n    if (\n      matrix[0] &&\n      matrix[0].length === 3 &&\n      options.xColumn === undefined &&\n      options.yColumn === undefined\n    ) {\n      // is the first column a seuqnetial number ?\n      let skipFirstColumn = true;\n      for (let i = 0; i < matrix.length - 1; i++) {\n        if (Math.abs(matrix[i][0] - matrix[i + 1][0]) !== 1) {\n          skipFirstColumn = false;\n        }\n      }\n      if (skipFirstColumn) {\n        xColumn = 1;\n        yColumn = 2;\n      }\n    }\n    if (matrix[0] && matrix[0].length > 3) {\n      let xs = [];\n      for (let row of matrix) {\n        for (let i = xColumn; i < row.length; i += 2) {\n          xs.push(row[i]);\n        }\n      }\n      if (xIsMonotone(xs)) {\n        numberColumns = 2;\n      }\n    }\n  }\n\n  if (numberColumns) {\n    const newMatrix = [];\n    for (const row of matrix) {\n      for (let i = 0; i < row.length; i += numberColumns) {\n        newMatrix.push(row.slice(i, i + numberColumns));\n      }\n    }\n    matrix = newMatrix;\n  }\n  const result = {\n    x: matrix.map((row) => row[xColumn]),\n    y: matrix.map((row) => row[yColumn]),\n  };\n\n  if (uniqueX) {\n    uniqueXFunction(result);\n  }\n\n  if (rescale) {\n    let maxY = mlArrayMax(result.y);\n    for (let i = 0; i < result.y.length; i++) {\n      result.y[i] /= maxY;\n    }\n  }\n\n  if (!keepInfo) return result;\n\n  return {\n    info,\n    data: result,\n  };\n}\n","import { parseXY } from 'xy-parser';\n\nimport { Chromatogram } from '../Chromatogram';\n\nexport function fromText(text, options = {}) {\n  const data = parseXY(text, options);\n\n  const time = data.x;\n  let series = {\n    intensity: data.y,\n  };\n\n  return new Chromatogram(time, series);\n}\n","/*! https://mths.be/utf8js v3.0.0 by @mathias */\n;(function(root) {\n\n\tvar stringFromCharCode = String.fromCharCode;\n\n\t// Taken from https://mths.be/punycode\n\tfunction ucs2decode(string) {\n\t\tvar output = [];\n\t\tvar counter = 0;\n\t\tvar length = string.length;\n\t\tvar value;\n\t\tvar extra;\n\t\twhile (counter < length) {\n\t\t\tvalue = string.charCodeAt(counter++);\n\t\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t\t// high surrogate, and there is a next character\n\t\t\t\textra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) { // low surrogate\n\t\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t\t} else {\n\t\t\t\t\t// unmatched surrogate; only append this code unit, in case the next\n\t\t\t\t\t// code unit is the high surrogate of a surrogate pair\n\t\t\t\t\toutput.push(value);\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toutput.push(value);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t// Taken from https://mths.be/punycode\n\tfunction ucs2encode(array) {\n\t\tvar length = array.length;\n\t\tvar index = -1;\n\t\tvar value;\n\t\tvar output = '';\n\t\twhile (++index < length) {\n\t\t\tvalue = array[index];\n\t\t\tif (value > 0xFFFF) {\n\t\t\t\tvalue -= 0x10000;\n\t\t\t\toutput += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n\t\t\t\tvalue = 0xDC00 | value & 0x3FF;\n\t\t\t}\n\t\t\toutput += stringFromCharCode(value);\n\t\t}\n\t\treturn output;\n\t}\n\n\tfunction checkScalarValue(codePoint) {\n\t\tif (codePoint >= 0xD800 && codePoint <= 0xDFFF) {\n\t\t\tthrow Error(\n\t\t\t\t'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +\n\t\t\t\t' is not a scalar value'\n\t\t\t);\n\t\t}\n\t}\n\t/*--------------------------------------------------------------------------*/\n\n\tfunction createByte(codePoint, shift) {\n\t\treturn stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);\n\t}\n\n\tfunction encodeCodePoint(codePoint) {\n\t\tif ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence\n\t\t\treturn stringFromCharCode(codePoint);\n\t\t}\n\t\tvar symbol = '';\n\t\tif ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);\n\t\t}\n\t\telse if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence\n\t\t\tcheckScalarValue(codePoint);\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);\n\t\t\tsymbol += createByte(codePoint, 6);\n\t\t}\n\t\telse if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence\n\t\t\tsymbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);\n\t\t\tsymbol += createByte(codePoint, 12);\n\t\t\tsymbol += createByte(codePoint, 6);\n\t\t}\n\t\tsymbol += stringFromCharCode((codePoint & 0x3F) | 0x80);\n\t\treturn symbol;\n\t}\n\n\tfunction utf8encode(string) {\n\t\tvar codePoints = ucs2decode(string);\n\t\tvar length = codePoints.length;\n\t\tvar index = -1;\n\t\tvar codePoint;\n\t\tvar byteString = '';\n\t\twhile (++index < length) {\n\t\t\tcodePoint = codePoints[index];\n\t\t\tbyteString += encodeCodePoint(codePoint);\n\t\t}\n\t\treturn byteString;\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\tfunction readContinuationByte() {\n\t\tif (byteIndex >= byteCount) {\n\t\t\tthrow Error('Invalid byte index');\n\t\t}\n\n\t\tvar continuationByte = byteArray[byteIndex] & 0xFF;\n\t\tbyteIndex++;\n\n\t\tif ((continuationByte & 0xC0) == 0x80) {\n\t\t\treturn continuationByte & 0x3F;\n\t\t}\n\n\t\t// If we end up here, it’s not a continuation byte\n\t\tthrow Error('Invalid continuation byte');\n\t}\n\n\tfunction decodeSymbol() {\n\t\tvar byte1;\n\t\tvar byte2;\n\t\tvar byte3;\n\t\tvar byte4;\n\t\tvar codePoint;\n\n\t\tif (byteIndex > byteCount) {\n\t\t\tthrow Error('Invalid byte index');\n\t\t}\n\n\t\tif (byteIndex == byteCount) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Read first byte\n\t\tbyte1 = byteArray[byteIndex] & 0xFF;\n\t\tbyteIndex++;\n\n\t\t// 1-byte sequence (no continuation bytes)\n\t\tif ((byte1 & 0x80) == 0) {\n\t\t\treturn byte1;\n\t\t}\n\n\t\t// 2-byte sequence\n\t\tif ((byte1 & 0xE0) == 0xC0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x1F) << 6) | byte2;\n\t\t\tif (codePoint >= 0x80) {\n\t\t\t\treturn codePoint;\n\t\t\t} else {\n\t\t\t\tthrow Error('Invalid continuation byte');\n\t\t\t}\n\t\t}\n\n\t\t// 3-byte sequence (may include unpaired surrogates)\n\t\tif ((byte1 & 0xF0) == 0xE0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tbyte3 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;\n\t\t\tif (codePoint >= 0x0800) {\n\t\t\t\tcheckScalarValue(codePoint);\n\t\t\t\treturn codePoint;\n\t\t\t} else {\n\t\t\t\tthrow Error('Invalid continuation byte');\n\t\t\t}\n\t\t}\n\n\t\t// 4-byte sequence\n\t\tif ((byte1 & 0xF8) == 0xF0) {\n\t\t\tbyte2 = readContinuationByte();\n\t\t\tbyte3 = readContinuationByte();\n\t\t\tbyte4 = readContinuationByte();\n\t\t\tcodePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |\n\t\t\t\t(byte3 << 0x06) | byte4;\n\t\t\tif (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {\n\t\t\t\treturn codePoint;\n\t\t\t}\n\t\t}\n\n\t\tthrow Error('Invalid UTF-8 detected');\n\t}\n\n\tvar byteArray;\n\tvar byteCount;\n\tvar byteIndex;\n\tfunction utf8decode(byteString) {\n\t\tbyteArray = ucs2decode(byteString);\n\t\tbyteCount = byteArray.length;\n\t\tbyteIndex = 0;\n\t\tvar codePoints = [];\n\t\tvar tmp;\n\t\twhile ((tmp = decodeSymbol()) !== false) {\n\t\t\tcodePoints.push(tmp);\n\t\t}\n\t\treturn ucs2encode(codePoints);\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\troot.version = '3.0.0';\n\troot.encode = utf8encode;\n\troot.decode = utf8decode;\n\n}(typeof exports === 'undefined' ? this.utf8 = {} : exports));\n","import { decode, encode } from 'utf8';\nconst defaultByteLength = 1024 * 8;\nexport class IOBuffer {\n    /**\n     * @param data - The data to construct the IOBuffer with.\n     * If data is a number, it will be the new buffer's length<br>\n     * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>\n     * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n     * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n     * @param options\n     */\n    constructor(data = defaultByteLength, options = {}) {\n        let dataIsGiven = false;\n        if (typeof data === 'number') {\n            data = new ArrayBuffer(data);\n        }\n        else {\n            dataIsGiven = true;\n            this.lastWrittenByte = data.byteLength;\n        }\n        const offset = options.offset ? options.offset >>> 0 : 0;\n        const byteLength = data.byteLength - offset;\n        let dvOffset = offset;\n        if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n            if (data.byteLength !== data.buffer.byteLength) {\n                dvOffset = data.byteOffset + offset;\n            }\n            data = data.buffer;\n        }\n        if (dataIsGiven) {\n            this.lastWrittenByte = byteLength;\n        }\n        else {\n            this.lastWrittenByte = 0;\n        }\n        this.buffer = data;\n        this.length = byteLength;\n        this.byteLength = byteLength;\n        this.byteOffset = dvOffset;\n        this.offset = 0;\n        this.littleEndian = true;\n        this._data = new DataView(this.buffer, dvOffset, byteLength);\n        this._mark = 0;\n        this._marks = [];\n    }\n    /**\n     * Checks if the memory allocated to the buffer is sufficient to store more\n     * bytes after the offset.\n     * @param byteLength - The needed memory in bytes.\n     * @returns `true` if there is sufficient space and `false` otherwise.\n     */\n    available(byteLength = 1) {\n        return this.offset + byteLength <= this.length;\n    }\n    /**\n     * Check if little-endian mode is used for reading and writing multi-byte\n     * values.\n     * @returns `true` if little-endian mode is used, `false` otherwise.\n     */\n    isLittleEndian() {\n        return this.littleEndian;\n    }\n    /**\n     * Set little-endian mode for reading and writing multi-byte values.\n     */\n    setLittleEndian() {\n        this.littleEndian = true;\n        return this;\n    }\n    /**\n     * Check if big-endian mode is used for reading and writing multi-byte values.\n     * @returns `true` if big-endian mode is used, `false` otherwise.\n     */\n    isBigEndian() {\n        return !this.littleEndian;\n    }\n    /**\n     * Switches to big-endian mode for reading and writing multi-byte values.\n     */\n    setBigEndian() {\n        this.littleEndian = false;\n        return this;\n    }\n    /**\n     * Move the pointer n bytes forward.\n     * @param n - Number of bytes to skip.\n     */\n    skip(n = 1) {\n        this.offset += n;\n        return this;\n    }\n    /**\n     * Move the pointer to the given offset.\n     * @param offset\n     */\n    seek(offset) {\n        this.offset = offset;\n        return this;\n    }\n    /**\n     * Store the current pointer offset.\n     * @see {@link IOBuffer#reset}\n     */\n    mark() {\n        this._mark = this.offset;\n        return this;\n    }\n    /**\n     * Move the pointer back to the last pointer offset set by mark.\n     * @see {@link IOBuffer#mark}\n     */\n    reset() {\n        this.offset = this._mark;\n        return this;\n    }\n    /**\n     * Push the current pointer offset to the mark stack.\n     * @see {@link IOBuffer#popMark}\n     */\n    pushMark() {\n        this._marks.push(this.offset);\n        return this;\n    }\n    /**\n     * Pop the last pointer offset from the mark stack, and set the current\n     * pointer offset to the popped value.\n     * @see {@link IOBuffer#pushMark}\n     */\n    popMark() {\n        const offset = this._marks.pop();\n        if (offset === undefined) {\n            throw new Error('Mark stack empty');\n        }\n        this.seek(offset);\n        return this;\n    }\n    /**\n     * Move the pointer offset back to 0.\n     */\n    rewind() {\n        this.offset = 0;\n        return this;\n    }\n    /**\n     * Make sure the buffer has sufficient memory to write a given byteLength at\n     * the current pointer offset.\n     * If the buffer's memory is insufficient, this method will create a new\n     * buffer (a copy) with a length that is twice (byteLength + current offset).\n     * @param byteLength\n     */\n    ensureAvailable(byteLength = 1) {\n        if (!this.available(byteLength)) {\n            const lengthNeeded = this.offset + byteLength;\n            const newLength = lengthNeeded * 2;\n            const newArray = new Uint8Array(newLength);\n            newArray.set(new Uint8Array(this.buffer));\n            this.buffer = newArray.buffer;\n            this.length = this.byteLength = newLength;\n            this._data = new DataView(this.buffer);\n        }\n        return this;\n    }\n    /**\n     * Read a byte and return false if the byte's value is 0, or true otherwise.\n     * Moves pointer forward by one byte.\n     */\n    readBoolean() {\n        return this.readUint8() !== 0;\n    }\n    /**\n     * Read a signed 8-bit integer and move pointer forward by 1 byte.\n     */\n    readInt8() {\n        return this._data.getInt8(this.offset++);\n    }\n    /**\n     * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n     */\n    readUint8() {\n        return this._data.getUint8(this.offset++);\n    }\n    /**\n     * Alias for {@link IOBuffer#readUint8}.\n     */\n    readByte() {\n        return this.readUint8();\n    }\n    /**\n     * Read `n` bytes and move pointer forward by `n` bytes.\n     */\n    readBytes(n = 1) {\n        const bytes = new Uint8Array(n);\n        for (let i = 0; i < n; i++) {\n            bytes[i] = this.readByte();\n        }\n        return bytes;\n    }\n    /**\n     * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n     */\n    readInt16() {\n        const value = this._data.getInt16(this.offset, this.littleEndian);\n        this.offset += 2;\n        return value;\n    }\n    /**\n     * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n     */\n    readUint16() {\n        const value = this._data.getUint16(this.offset, this.littleEndian);\n        this.offset += 2;\n        return value;\n    }\n    /**\n     * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n     */\n    readInt32() {\n        const value = this._data.getInt32(this.offset, this.littleEndian);\n        this.offset += 4;\n        return value;\n    }\n    /**\n     * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n     */\n    readUint32() {\n        const value = this._data.getUint32(this.offset, this.littleEndian);\n        this.offset += 4;\n        return value;\n    }\n    /**\n     * Read a 32-bit floating number and move pointer forward by 4 bytes.\n     */\n    readFloat32() {\n        const value = this._data.getFloat32(this.offset, this.littleEndian);\n        this.offset += 4;\n        return value;\n    }\n    /**\n     * Read a 64-bit floating number and move pointer forward by 8 bytes.\n     */\n    readFloat64() {\n        const value = this._data.getFloat64(this.offset, this.littleEndian);\n        this.offset += 8;\n        return value;\n    }\n    /**\n     * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n     */\n    readChar() {\n        return String.fromCharCode(this.readInt8());\n    }\n    /**\n     * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n     */\n    readChars(n = 1) {\n        let result = '';\n        for (let i = 0; i < n; i++) {\n            result += this.readChar();\n        }\n        return result;\n    }\n    /**\n     * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n     * forward by `n` bytes.\n     */\n    readUtf8(n = 1) {\n        const bString = this.readChars(n);\n        return decode(bString);\n    }\n    /**\n     * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n     * forward by 1 byte.\n     */\n    writeBoolean(value) {\n        this.writeUint8(value ? 0xff : 0x00);\n        return this;\n    }\n    /**\n     * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n     */\n    writeInt8(value) {\n        this.ensureAvailable(1);\n        this._data.setInt8(this.offset++, value);\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n     * byte.\n     */\n    writeUint8(value) {\n        this.ensureAvailable(1);\n        this._data.setUint8(this.offset++, value);\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * An alias for {@link IOBuffer#writeUint8}.\n     */\n    writeByte(value) {\n        return this.writeUint8(value);\n    }\n    /**\n     * Write all elements of `bytes` as uint8 values and move pointer forward by\n     * `bytes.length` bytes.\n     */\n    writeBytes(bytes) {\n        this.ensureAvailable(bytes.length);\n        for (let i = 0; i < bytes.length; i++) {\n            this._data.setUint8(this.offset++, bytes[i]);\n        }\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 16-bit signed integer and move pointer forward by 2\n     * bytes.\n     */\n    writeInt16(value) {\n        this.ensureAvailable(2);\n        this._data.setInt16(this.offset, value, this.littleEndian);\n        this.offset += 2;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n     * bytes.\n     */\n    writeUint16(value) {\n        this.ensureAvailable(2);\n        this._data.setUint16(this.offset, value, this.littleEndian);\n        this.offset += 2;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 32-bit signed integer and move pointer forward by 4\n     * bytes.\n     */\n    writeInt32(value) {\n        this.ensureAvailable(4);\n        this._data.setInt32(this.offset, value, this.littleEndian);\n        this.offset += 4;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n     * bytes.\n     */\n    writeUint32(value) {\n        this.ensureAvailable(4);\n        this._data.setUint32(this.offset, value, this.littleEndian);\n        this.offset += 4;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 32-bit floating number and move pointer forward by 4\n     * bytes.\n     */\n    writeFloat32(value) {\n        this.ensureAvailable(4);\n        this._data.setFloat32(this.offset, value, this.littleEndian);\n        this.offset += 4;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write `value` as a 64-bit floating number and move pointer forward by 8\n     * bytes.\n     */\n    writeFloat64(value) {\n        this.ensureAvailable(8);\n        this._data.setFloat64(this.offset, value, this.littleEndian);\n        this.offset += 8;\n        this._updateLastWrittenByte();\n        return this;\n    }\n    /**\n     * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n     * and move pointer forward by 1 byte.\n     */\n    writeChar(str) {\n        return this.writeUint8(str.charCodeAt(0));\n    }\n    /**\n     * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n     * and move pointer forward by `str.length` bytes.\n     */\n    writeChars(str) {\n        for (let i = 0; i < str.length; i++) {\n            this.writeUint8(str.charCodeAt(i));\n        }\n        return this;\n    }\n    /**\n     * UTF-8 encode and write `str` to the current pointer offset and move pointer\n     * forward according to the encoded length.\n     */\n    writeUtf8(str) {\n        const bString = encode(str);\n        return this.writeChars(bString);\n    }\n    /**\n     * Export a Uint8Array view of the internal buffer.\n     * The view starts at the byte offset and its length\n     * is calculated to stop at the last written byte or the original length.\n     */\n    toArray() {\n        return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n    }\n    /**\n     * Update the last written byte offset\n     * @private\n     */\n    _updateLastWrittenByte() {\n        if (this.offset > this.lastWrittenByte) {\n            this.lastWrittenByte = this.offset;\n        }\n    }\n}\n//# sourceMappingURL=IOBuffer.js.map","'use strict';\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf(statement, reason) {\n  if (statement) {\n    throw new TypeError(`Not a valid NetCDF v3.x file: ${reason}`);\n  }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding(buffer) {\n  if ((buffer.offset % 4) !== 0) {\n    buffer.skip(4 - (buffer.offset % 4));\n  }\n}\n\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName(buffer) {\n  // Read name\n  var nameLength = buffer.readUint32();\n  var name = buffer.readChars(nameLength);\n\n  // validate name\n  // TODO\n\n  // Apply padding\n  padding(buffer);\n  return name;\n}\n\nmodule.exports.notNetcdf = notNetcdf;\nmodule.exports.padding = padding;\nmodule.exports.readName = readName;\n","'use strict';\n\nconst notNetcdf = require('./utils').notNetcdf;\n\nconst types = {\n  BYTE: 1,\n  CHAR: 2,\n  SHORT: 3,\n  INT: 4,\n  FLOAT: 5,\n  DOUBLE: 6\n};\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str(type) {\n  switch (Number(type)) {\n    case types.BYTE:\n      return 'byte';\n    case types.CHAR:\n      return 'char';\n    case types.SHORT:\n      return 'short';\n    case types.INT:\n      return 'int';\n    case types.FLOAT:\n      return 'float';\n    case types.DOUBLE:\n      return 'double';\n      /* istanbul ignore next */\n    default:\n      return 'undefined';\n  }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes(type) {\n  switch (Number(type)) {\n    case types.BYTE:\n      return 1;\n    case types.CHAR:\n      return 1;\n    case types.SHORT:\n      return 2;\n    case types.INT:\n      return 4;\n    case types.FLOAT:\n      return 4;\n    case types.DOUBLE:\n      return 8;\n      /* istanbul ignore next */\n    default:\n      return -1;\n  }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num(type) {\n  switch (String(type)) {\n    case 'byte':\n      return types.BYTE;\n    case 'char':\n      return types.CHAR;\n    case 'short':\n      return types.SHORT;\n    case 'int':\n      return types.INT;\n    case 'float':\n      return types.FLOAT;\n    case 'double':\n      return types.DOUBLE;\n      /* istanbul ignore next */\n    default:\n      return -1;\n  }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array<number>|number}\n */\nfunction readNumber(size, bufferReader) {\n  if (size !== 1) {\n    var numbers = new Array(size);\n    for (var i = 0; i < size; i++) {\n      numbers[i] = bufferReader();\n    }\n    return numbers;\n  } else {\n    return bufferReader();\n  }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array<number>|number}\n */\nfunction readType(buffer, type, size) {\n  switch (type) {\n    case types.BYTE:\n      return buffer.readBytes(size);\n    case types.CHAR:\n      return trimNull(buffer.readChars(size));\n    case types.SHORT:\n      return readNumber(size, buffer.readInt16.bind(buffer));\n    case types.INT:\n      return readNumber(size, buffer.readInt32.bind(buffer));\n    case types.FLOAT:\n      return readNumber(size, buffer.readFloat32.bind(buffer));\n    case types.DOUBLE:\n      return readNumber(size, buffer.readFloat64.bind(buffer));\n      /* istanbul ignore next */\n    default:\n      notNetcdf(true, `non valid type ${type}`);\n      return undefined;\n  }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull(value) {\n  if (value.charCodeAt(value.length - 1) === 0) {\n    return value.substring(0, value.length - 1);\n  }\n  return value;\n}\n\nmodule.exports = types;\nmodule.exports.num2str = num2str;\nmodule.exports.num2bytes = num2bytes;\nmodule.exports.str2num = str2num;\nmodule.exports.readType = readType;\n","'use strict';\n\nconst types = require('./types');\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord(buffer, variable) {\n  // variable type\n  const type = types.str2num(variable.type);\n\n  // size of the data\n  var size = variable.size / types.num2bytes(type);\n\n  // iterates over the data\n  var data = new Array(size);\n  for (var i = 0; i < size; i++) {\n    data[i] = types.readType(buffer, type, 1);\n  }\n\n  return data;\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record(buffer, variable, recordDimension) {\n  // variable type\n  const type = types.str2num(variable.type);\n  const width = variable.size ? variable.size / types.num2bytes(type) : 1;\n\n  // size of the data\n  // TODO streaming data\n  var size = recordDimension.length;\n\n  // iterates over the data\n  var data = new Array(size);\n  const step = recordDimension.recordStep;\n\n  for (var i = 0; i < size; i++) {\n    var currentOffset = buffer.offset;\n    data[i] = types.readType(buffer, type, width);\n    buffer.seek(currentOffset + step);\n  }\n\n  return data;\n}\n\nmodule.exports.nonRecord = nonRecord;\nmodule.exports.record = record;\n","'use strict';\n\nconst utils = require('./utils');\nconst types = require('./types');\n\n// Grammar constants\nconst ZERO = 0;\nconst NC_DIMENSION = 10;\nconst NC_VARIABLE = 11;\nconst NC_ATTRIBUTE = 12;\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n *  * `recordDimension`: Number with the length of record dimension\n *  * `dimensions`: List of dimensions\n *  * `globalAttributes`: List of global attributes\n *  * `variables`: List of variables\n */\nfunction header(buffer, version) {\n  // Length of record dimension\n  // sum of the varSize's of all the record variables.\n  var header = { recordDimension: { length: buffer.readUint32() } };\n\n  // Version\n  header.version = version;\n\n  // List of dimensions\n  var dimList = dimensionsList(buffer);\n  header.recordDimension.id = dimList.recordId; // id of the unlimited dimension\n  header.recordDimension.name = dimList.recordName; // name of the unlimited dimension\n  header.dimensions = dimList.dimensions;\n\n  // List of global attributes\n  header.globalAttributes = attributesList(buffer);\n\n  // List of variables\n  var variables = variablesList(buffer, dimList.recordId, version);\n  header.variables = variables.variables;\n  header.recordDimension.recordStep = variables.recordStep;\n\n  return header;\n}\n\nconst NC_UNLIMITED = 0;\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - Ojbect containing the following properties:\n *  * `dimensions` that is an array of dimension object:\n  *  * `name`: String with the name of the dimension\n  *  * `size`: Number with the size of the dimension dimensions: dimensions\n *  * `recordId`: the id of the dimension that has unlimited size or undefined,\n *  * `recordName`: name of the dimension that has unlimited size\n */\nfunction dimensionsList(buffer) {\n  var recordId, recordName;\n  const dimList = buffer.readUint32();\n  if (dimList === ZERO) {\n    utils.notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions');\n    return [];\n  } else {\n    utils.notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions');\n\n    // Length of dimensions\n    const dimensionSize = buffer.readUint32();\n    var dimensions = new Array(dimensionSize);\n    for (var dim = 0; dim < dimensionSize; dim++) {\n      // Read name\n      var name = utils.readName(buffer);\n\n      // Read dimension size\n      const size = buffer.readUint32();\n      if (size === NC_UNLIMITED) { // in netcdf 3 one field can be of size unlimmited\n        recordId = dim;\n        recordName = name;\n      }\n\n      dimensions[dim] = {\n        name: name,\n        size: size\n      };\n    }\n  }\n  return {\n    dimensions: dimensions,\n    recordId: recordId,\n    recordName: recordName\n  };\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array<object>} - List of attributes with:\n *  * `name`: String with the name of the attribute\n *  * `type`: String with the type of the attribute\n *  * `value`: A number or string with the value of the attribute\n */\nfunction attributesList(buffer) {\n  const gAttList = buffer.readUint32();\n  if (gAttList === ZERO) {\n    utils.notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes');\n    return [];\n  } else {\n    utils.notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes');\n\n    // Length of attributes\n    const attributeSize = buffer.readUint32();\n    var attributes = new Array(attributeSize);\n    for (var gAtt = 0; gAtt < attributeSize; gAtt++) {\n      // Read name\n      var name = utils.readName(buffer);\n\n      // Read type\n      var type = buffer.readUint32();\n      utils.notNetcdf(((type < 1) || (type > 6)), `non valid type ${type}`);\n\n      // Read attribute\n      var size = buffer.readUint32();\n      var value = types.readType(buffer, type, size);\n\n      // Apply padding\n      utils.padding(buffer);\n\n      attributes[gAtt] = {\n        name: name,\n        type: types.num2str(type),\n        value: value\n      };\n    }\n  }\n  return attributes;\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id of the unlimited dimension (also called record dimension)\n *                            This value may be undefined if there is no unlimited dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n *  * `name`: String with the name of the variable\n *  * `dimensions`: Array with the dimension IDs of the variable\n *  * `attributes`: Array with the attributes of the variable\n *  * `type`: String with the type of the variable\n *  * `size`: Number with the size of the variable\n *  * `offset`: Number with the offset where of the variable begins\n *  * `record`: True if is a record variable, false otherwise (unlimited size)\n */\n\nfunction variablesList(buffer, recordId, version) {\n  const varList = buffer.readUint32();\n  var recordStep = 0;\n  if (varList === ZERO) {\n    utils.notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of variables');\n    return [];\n  } else {\n    utils.notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables');\n\n    // Length of variables\n    const variableSize = buffer.readUint32();\n    var variables = new Array(variableSize);\n    for (var v = 0; v < variableSize; v++) {\n      // Read name\n      var name = utils.readName(buffer);\n\n      // Read dimensionality of the variable\n      const dimensionality = buffer.readUint32();\n\n      // Index into the list of dimensions\n      var dimensionsIds = new Array(dimensionality);\n      for (var dim = 0; dim < dimensionality; dim++) {\n        dimensionsIds[dim] = buffer.readUint32();\n      }\n\n      // Read variables size\n      var attributes = attributesList(buffer);\n\n      // Read type\n      var type = buffer.readUint32();\n      utils.notNetcdf(((type < 1) && (type > 6)), `non valid type ${type}`);\n\n      // Read variable size\n      // The 32-bit varSize field is not large enough to contain the size of variables that require\n      // more than 2^32 - 4 bytes, so 2^32 - 1 is used in the varSize field for such variables.\n      const varSize = buffer.readUint32();\n\n      // Read offset\n      var offset = buffer.readUint32();\n      if (version === 2) {\n        utils.notNetcdf((offset > 0), 'offsets larger than 4GB not supported');\n        offset = buffer.readUint32();\n      }\n\n      let record = false;\n      // Count amount of record variables\n      if ((typeof recordId !== 'undefined') && (dimensionsIds[0] === recordId)) {\n        recordStep += varSize;\n        record = true;\n      }\n      variables[v] = {\n        name: name,\n        dimensions: dimensionsIds,\n        attributes,\n        type: types.num2str(type),\n        size: varSize,\n        offset,\n        record\n      };\n    }\n  }\n\n  return {\n    variables: variables,\n    recordStep: recordStep\n  };\n}\n\nmodule.exports = header;\n","'use strict';\n\nfunction toString() {\n  let result = [];\n\n  result.push('DIMENSIONS');\n  for (let dimension of this.dimensions) {\n    result.push(`  ${dimension.name.padEnd(30)} = size: ${dimension.size}`);\n  }\n\n  result.push('');\n  result.push('GLOBAL ATTRIBUTES');\n  for (let attribute of this.globalAttributes) {\n    result.push(`  ${attribute.name.padEnd(30)} = ${attribute.value}`);\n  }\n\n  let variables = JSON.parse(JSON.stringify(this.variables));\n  result.push('');\n  result.push('VARIABLES:');\n  for (let variable of variables) {\n    variable.value = this.getDataVariable(variable);\n    let stringify = JSON.stringify(variable.value);\n    if (stringify.length > 50) stringify = stringify.substring(0, 50);\n    if (!isNaN(variable.value.length)) {\n      stringify += ` (length: ${variable.value.length})`;\n    }\n    result.push(`  ${variable.name.padEnd(30)} = ${stringify}`);\n  }\n  return result.join('\\n');\n}\n\nmodule.exports = toString;\n","'use strict';\n\nconst { IOBuffer } = require('iobuffer');\n\nconst utils = require('./utils');\nconst data = require('./data');\nconst readHeader = require('./header');\nconst toString = require('./toString');\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @constructor\n */\nclass NetCDFReader {\n  constructor(data) {\n    const buffer = new IOBuffer(data);\n    buffer.setBigEndian();\n\n    // Validate that it's a NetCDF file\n    utils.notNetcdf(buffer.readChars(3) !== 'CDF', 'should start with CDF');\n\n    // Check the NetCDF format\n    const version = buffer.readByte();\n    utils.notNetcdf(version > 2, 'unknown version');\n\n    // Read the header\n    this.header = readHeader(buffer, version);\n    this.buffer = buffer;\n  }\n\n  /**\n   * @return {string} - Version for the NetCDF format\n   */\n  get version() {\n    if (this.header.version === 1) {\n      return 'classic format';\n    } else {\n      return '64-bit offset format';\n    }\n  }\n\n  /**\n   * @return {object} - Metadata for the record dimension\n   *  * `length`: Number of elements in the record dimension\n   *  * `id`: Id number in the list of dimensions for the record dimension\n   *  * `name`: String with the name of the record dimension\n   *  * `recordStep`: Number with the record variables step size\n   */\n  get recordDimension() {\n    return this.header.recordDimension;\n  }\n\n  /**\n   * @return {Array<object>} - List of dimensions with:\n   *  * `name`: String with the name of the dimension\n   *  * `size`: Number with the size of the dimension\n   */\n  get dimensions() {\n    return this.header.dimensions;\n  }\n\n  /**\n   * @return {Array<object>} - List of global attributes with:\n   *  * `name`: String with the name of the attribute\n   *  * `type`: String with the type of the attribute\n   *  * `value`: A number or string with the value of the attribute\n   */\n  get globalAttributes() {\n    return this.header.globalAttributes;\n  }\n\n  /**\n   * Returns the value of an attribute\n   * @param {string} attributeName\n   * @return {string} Value of the attributeName or null\n   */\n  getAttribute(attributeName) {\n    const attribute = this.globalAttributes.find(\n      (val) => val.name === attributeName\n    );\n    if (attribute) return attribute.value;\n    return null;\n  }\n\n  /**\n   * Returns the value of a variable as a string\n   * @param {string} variableName\n   * @return {string} Value of the variable as a string or null\n   */\n  getDataVariableAsString(variableName) {\n    const variable = this.getDataVariable(variableName);\n    if (variable) return variable.join('');\n    return null;\n  }\n\n  /**\n   * @return {Array<object>} - List of variables with:\n   *  * `name`: String with the name of the variable\n   *  * `dimensions`: Array with the dimension IDs of the variable\n   *  * `attributes`: Array with the attributes of the variable\n   *  * `type`: String with the type of the variable\n   *  * `size`: Number with the size of the variable\n   *  * `offset`: Number with the offset where of the variable begins\n   *  * `record`: True if is a record variable, false otherwise\n   */\n  get variables() {\n    return this.header.variables;\n  }\n\n  toString() {\n    return toString.call(this);\n  }\n\n  /**\n   * Retrieves the data for a given variable\n   * @param {string|object} variableName - Name of the variable to search or variable object\n   * @return {Array} - List with the variable values\n   */\n  getDataVariable(variableName) {\n    let variable;\n    if (typeof variableName === 'string') {\n      // search the variable\n      variable = this.header.variables.find(function (val) {\n        return val.name === variableName;\n      });\n    } else {\n      variable = variableName;\n    }\n\n    // throws if variable not found\n    utils.notNetcdf(\n      variable === undefined,\n      `variable not found: ${variableName}`\n    );\n\n    // go to the offset position\n    this.buffer.seek(variable.offset);\n\n    if (variable.record) {\n      // record variable case\n      return data.record(this.buffer, variable, this.header.recordDimension);\n    } else {\n      // non-record variable case\n      return data.nonRecord(this.buffer, variable);\n    }\n  }\n\n  /**\n   * Check if a dataVariable exists\n   * @param {string} variableName - Name of the variable to find\n   * @return {boolean}\n   */\n  dataVariableExists(variableName) {\n    const variable = this.header.variables.find(function (val) {\n      return val.name === variableName;\n    });\n    return variable !== undefined;\n  }\n\n  /**\n   * Check if an attribute exists\n   * @param {string} attributeName - Name of the attribute to find\n   * @return {boolean}\n   */\n  attributeExists(attributeName) {\n    const attribute = this.globalAttributes.find(\n      (val) => val.name === attributeName\n    );\n    return attribute !== undefined;\n  }\n}\n\nmodule.exports = NetCDFReader;\n","'use strict';\n\n/* reader.toString() provides the following information\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1+C2\n      ms_template_revision           = 1.0.1\n      netcdf_revision                = 2.3.2\n      languages                      = English\n      administrative_comments        = 1% CH2Cl2\n      dataset_origin                 = Santa Clara, CA\n      netcdf_file_date_time_stamp    = 20161012052159+0200\n      experiment_title               = P071 Essence super BP\n      experiment_date_time_stamp     = 20070923040800+0200\n      operator_name                  = SC\n      external_file_ref_0            = FIRE_RTL.M\n      experiment_type                = Centroided Mass Spectrum\n      number_of_times_processed      = 1\n      number_of_times_calibrated     = 0\n      sample_state                   = Other State\n      test_separation_type           = No Chromatography\n      test_ms_inlet                  = Capillary Direct\n      test_ionization_mode           = Electron Impact\n      test_ionization_polarity       = Positive Polarity\n      test_detector_type             = Electron Multiplier\n      test_resolution_type           = Constant Resolution\n      test_scan_function             = Mass Scan\n      test_scan_direction            = Up\n      test_scan_law                  = Linear\n      raw_data_mass_format           = Float\n      raw_data_time_format           = Short\n      raw_data_intensity_format      = Float\n\n    VARIABLES:\n      error_log                      = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 64)\n      a_d_sampling_rate              = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      a_d_coaddition_factor          = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6402)\n      scan_acquisition_time          = [5.25,5.84,6.428999999999999,7.019,7.609,8.199,8.7 (length: 6401)\n      scan_duration                  = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      inter_scan_time                = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      resolution                     = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      actual_scan_number             = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 (length: 6401)\n      total_intensity                = [3134,3157,3085,3134,3093,3113,3061,3057,3030,3166 (length: 6401)\n      mass_range_min                 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 6401)\n      mass_range_max                 = [206.89999389648438,206.89999389648438,207,207.100 (length: 6401)\n      time_range_min                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      time_range_max                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 6401)\n      scan_index                     = [0,11,22,33,44,55,66,76,88,99,111,122,134,145,156, (length: 6401)\n      point_count                    = [11,11,11,11,11,11,10,12,11,12,11,12,11,11,11,11,1 (length: 6401)\n      flag_count                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 6401)\n      mass_values                    = [16,17,18.100000381469727,28,32,35,36,38,40,44.099 (length: 157201)\n      time_values                    = [9.969209968386869e+36,9.969209968386869e+36,9.969 (length: 157201)\n      intensity_values               = [37,293,1243,737,420,45,196,72,22,35,34,28,299,123 (length: 157201)\n      instrument_name                = [\"G\",\"a\",\"s\",\" \",\"C\",\"h\",\"r\",\"o\",\"m\",\"a\",\"t\",\"o\",\" (length: 32)\n      instrument_id                  = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_mfr                 = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_model               = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_serial_no           = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_sw_version          = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_fw_version          = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_os_version          = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_app_version         = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_comments            = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n*/\n\nfunction agilentGCMS(reader) {\n  const time = reader.getDataVariable('scan_acquisition_time');\n  const tic = reader.getDataVariable('total_intensity');\n\n  // variables to get the mass-intensity values\n  const pointCount = reader.getDataVariable('point_count');\n  const massValues = reader.getDataVariable('mass_values');\n  const intensityValues = reader.getDataVariable('intensity_values');\n\n  let ms = new Array(pointCount.length);\n  let index = 0;\n  for (let i = 0; i < ms.length; i++) {\n    let size = pointCount[i];\n    ms[i] = [new Array(size), new Array(size)];\n\n    for (let j = 0; j < size; j++) {\n      ms[i][0][j] = massValues[index];\n      ms[i][1][j] = intensityValues[index++];\n    }\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n      {\n        name: 'ms',\n        dimension: 2,\n        data: ms,\n      },\n    ],\n  };\n}\n\nmodule.exports = agilentGCMS;\n","'use strict';\n\n/* reader.toString() provides the following information\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1+C2\n      ms_template_revision           = 1.0.1\n      netcdf_revision                = 2.3.2\n      languages                      = English\n      netcdf_file_date_time_stamp    = 20170428032023+0000\n      experiment_title               = MS51762A16\n    11829FC03_3__60_40\n      experiment_date_time_stamp     = 20160930202145-0001\n      operator_name                  = Begemann/Eikenberg/Roettger\n      pre_experiment_program_name    = otofControl 3.4.16.0\n      post_experiment_program_name   = Bruker Compass DataAnalysis 4.2\n      source_file_reference          = X:\\2016\\MS5\\1700\\MS51762A16.d\n      source_file_format             = Bruker Daltonics Data File\n      experiment_type                = Centroided Mass Spectrum\n      sample_state                   = Other State\n      test_separation_type           = No Chromatography\n      test_ms_inlet                  = Direct Inlet Probe\n      test_ionization_mode           = Electrospray Ionization\n      test_ionization_polarity       = Positive Polarity\n      test_detector_type             = Electron Multiplier\n      test_resolution_type           = Proportional Resolution\n      test_scan_function             = Mass Scan\n      test_scan_direction            = Up\n      test_scan_law                  = Linear\n      raw_data_mass_format           = Double\n      raw_data_time_format           = Float\n      raw_data_intensity_format      = Float\n      units                          = Seconds\n      scale_factor                   = 1\n\n    VARIABLES:\n      error_log                      = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 64)\n      a_d_sampling_rate              = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4513)\n      a_d_coaddition_factor          = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4514)\n      scan_acquisition_time          = [0.329,0.73,1.132,1.534,1.936,2.337,2.739,3.14,3.5 (length: 4513)\n      scan_duration                  = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4513)\n      inter_scan_time                = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4513)\n      resolution                     = [106.6623112889557,110.7855343519544,104.407495112 (length: 4513)\n      actual_scan_number             = [0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34, (length: 4513)\n      total_intensity                = [5297.4945068359375,6172.123912811279,5934.7557412 (length: 4513)\n      mass_range_min                 = [49.99999997418507,49.99999997418507,49.9999999741 (length: 4513)\n      mass_range_max                 = [1599.9999564432276,1599.9999564432276,1599.999956 (length: 4513)\n      time_range_min                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4513)\n      time_range_max                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 4513)\n      scan_index                     = [0,60,128,195,265,324,399,472,542,596,671,738,803, (length: 4513)\n      point_count                    = [60,68,67,70,59,75,73,70,54,75,67,65,64,73,56,69,6 (length: 4513)\n      flag_count                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 4513)\n      mass_values                    = [51.53516375878996,95.32974890044508,106.334477231 (length: 1176507)\n      intensity_values               = [76.99999237060547,80,90,78.99799346923828,80.9352 (length: 1176507)\n      instrument_name                = [\"m\",\"i\",\"c\",\"r\",\"O\",\"T\",\"O\",\"F\",\"\",\" \",\" \",\" \",\"  (length: 32)\n      instrument_id                  = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_mfr                 = [\"B\",\"r\",\"u\",\"k\",\"e\",\"r\",\" \",\"D\",\"a\",\"l\",\"t\",\"o\",\" (length: 32)\n      instrument_model               = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_serial_no           = [\"2\",\"1\",\"3\",\"7\",\"5\",\"0\",\".\",\"1\",\"0\",\"3\",\"5\",\"9\",\" (length: 32)\n      instrument_sw_version          = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_fw_version          = [\"\",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\"  (length: 32)\n      instrument_os_version          = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_app_version         = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_comments            = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n*/\n\nfunction finniganGCMS(reader) {\n  const time = reader.getDataVariable('scan_acquisition_time');\n  const tic = reader.getDataVariable('total_intensity');\n\n  // variables to get the mass-intensity values\n  let scanIndex = reader.getDataVariable('scan_index');\n  const massValues = reader.getDataVariable('mass_values');\n  const intensityValues = reader.getDataVariable('intensity_values');\n  scanIndex.push(massValues.length);\n\n  let ms = new Array(time.length);\n  let index = 0;\n  for (let i = 0; i < ms.length; i++) {\n    let size = scanIndex[i + 1] - scanIndex[i];\n    ms[i] = [new Array(size), new Array(size)];\n\n    for (let j = 0; j < size; j++) {\n      ms[i][0][j] = massValues[index];\n      ms[i][1][j] = intensityValues[index++];\n    }\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n      {\n        name: 'ms',\n        dimension: 2,\n        data: ms,\n      },\n    ],\n  };\n}\n\nmodule.exports = finniganGCMS;\n","'use strict';\n\n/* reader.toString() provides the following information\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1+C2\n      aia_template_revision          = 1.0\n      netcdf_revision                = 2.3\n      languages                      = English only\n      injection_date_time_stamp      = 20181030174305+0000\n      HP_injection_time              = 30-Oct-18, 17:43:05\n      experiment_title               = SequenceLine: 1  Inj: 1\n      operator_name                  = SYSTEM\n      separation_experiment_type     = liquid chromatography\n      source_file_reference          = C:\\CHEM32\\1\\DATA\\MINGMING\\MW-1-MEO-I IC-90 2018-10-30 17-42-13\\MW-2-6-6 IC 90.D\n      sample_name                    = MW-2-6-6 IC 90\n      sample_id                      =\n      detector_unit                  = mAU\n      detection_method_name          = POS 3 IC 90-10 31 MIN.M\n      detector_name                  = DAD1 A, Sig=254,4 Ref=360,100\n      retention_unit                 = seconds\n\n   VARIABLES:\n      detector_maximum_value         = [130.9263458251953] (length: 1)\n      detector_minimum_value         = [-0.1758841574192047] (length: 1)\n      actual_run_time_length         = [1860] (length: 1)\n      actual_delay_time              = [0.012000000104308128] (length: 1)\n      actual_sampling_interval       = [0.4000000059604645] (length: 1)\n      ordinate_values                = [-0.07588416337966919,-0.07525086402893066,-0.0740 (length: 4651)\n      peak_retention_time            = [196.0651397705078,332.5663757324219,527.549865722 (length: 8)\n      peak_start_time                = [186.81199645996094,239.21200561523438,502.4119873 (length: 8)\n      peak_end_time                  = [220.81201171875,471.5176696777344,572.47869873046 (length: 8)\n      peak_width                     = [4.974428176879883,62.90694808959961,11.9328641891 (length: 8)\n      peak_area                      = [556.7650146484375,419.825439453125,66.56610107421 (length: 8)\n      peak_area_percent              = [7.0321502685546875,5.302552223205566,0.8407546877 (length: 8)\n      peak_height                    = [100.07515716552734,5.1860527992248535,4.827196121 (length: 8)\n      peak_height_percent            = [29.76352310180664,1.5423927307128906,1.4356645345 (length: 8)\n      peak_asymmetry                 = [1.4555920362472534,0.8351489901542664,1.707817316 (length: 8)\n      baseline_start_time            = [186.81199645996094,239.21200561523438,502.4119873 (length: 8)\n      baseline_start_value           = [1.9561424255371094,0.9857341647148132,1.127734780 (length: 8)\n      baseline_stop_time             = [220.81201171875,471.5176696777344,572.47869873046 (length: 8)\n      baseline_stop_value            = [1.1907591819763184,1.10896897315979,1.18347382545 (length: 8)\n      peak_start_detection_code      = [\"B\",\"\",\"B\",\"\",\"B\",\"\",\"B\",\"\",\"V\",\"\",\"B\",\"\",\"B\",\"\", (length: 16)\n      peak_stop_detection_code       = [\"B\",\"\",\"B\",\"\",\"B\",\"\",\"V\",\"\",\"B\",\"\",\"B\",\"\",\"B\",\"\", (length: 16)\n      migration_time                 = [196.0651397705078,332.5663757324219,527.549865722 (length: 8)\n      peak_area_square_root          = [23.595869064331055,20.489643096923828,8.158804893 (length: 8)\n      manually_reintegrated_peaks    = [0,0,0,0,0,0,0,0] (length: 8)\n*/\n\nfunction agilentHPLC(reader) {\n  const intensities = reader.getDataVariable('ordinate_values');\n  const numberPoints = intensities.length;\n  const detector = reader.getAttribute('detector_name');\n  let channel;\n  if (detector.match(/dad/i)) {\n    channel = `uv${Number(detector.replace(/.*Sig=([0-9]+).*/, '$1'))}`;\n  } else if (detector.match(/tic/i)) {\n    channel = 'tic';\n  } else {\n    channel = 'unknown';\n  }\n  const delayTime = reader.getDataVariable('actual_delay_time')[0];\n  const runtimeLength = reader.getDataVariable('actual_run_time_length')[0];\n  let samplingInterval;\n  if (reader.dataVariableExists('actual_sampling_interval')) {\n    samplingInterval = reader.getDataVariable('actual_sampling_interval')[0];\n\n    if (\n      Math.abs(delayTime + samplingInterval * numberPoints - runtimeLength) > 3\n    ) {\n      throw new Error(\n        'The expected last time does not correspond to the runtimeLength',\n      );\n    }\n  } else {\n    samplingInterval = (runtimeLength - delayTime) / numberPoints;\n  }\n\n  let times = [];\n  let time = delayTime;\n  for (let i = 0; i < numberPoints; i++) {\n    times.push(time);\n    time += samplingInterval;\n  }\n\n  return {\n    times,\n    series: [\n      {\n        name: channel,\n        dimension: 1,\n        data: intensities,\n      },\n    ],\n  };\n}\n\nmodule.exports = agilentHPLC;\n","'use strict';\n\n/* reader.toString() provides the following information\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1+C2\n      ms_template_revision           = 1.0.1\n      administrative_comments        =\n      dataset_owner                  =\n      experiment_title               =\n      experiment_date_time_stamp     = 20150902041002+0100\n      netcdf_file_date_time_stamp    = 20151026063419+0000\n      experiment_type                = Centroided Mass Spectrum\n      netcdf_revision                = 2.3.2\n      operator_name                  = DSQ\n      source_file_reference          = G:\\FCO\\FCO_CIO\\K2\\MP2013\\T1 IL database 2013\\9. IL Data Entry\\12_HU_HIFS\\IL database\\RAW files\\Lukoil-Disel-150901.RAW\n      source_file_date_time_stamp    = 20150902041002+0100\n      source_file_format             = Finnigan\n      languages                      = English\n      external_file_ref_0            =\n      instrument_number              = 1\n      sample_prep_comments           =\n      sample_comments                = Lukoil Disel 0,5 % CS2 1 % inkt\n      test_separation_type           =\n      test_ms_inlet                  =\n      test_ionization_mode           =\n      test_ionization_polarity       = Positive Polarity\n      test_detector_type             = Conversion Dynode Electron Multiplier\n      test_scan_function             = Mass Scan\n      test_scan_direction            =\n      test_scan_law                  = Linear\n      number_of_scans                = 11832\n      raw_data_mass_format           = Double\n      raw_data_intensity_format      = Long\n      actual_run_time                = 3519.6410000000005\n      actual_delay_time              = 82.328\n      global_mass_min                = 0\n      global_mass_max                = 450\n      calibrated_mass_min            = 0\n      calibrated_mass_max            = 0\n      mass_axis_label                = M/Z\n      intensity_axis_label           = Abundance\n\n    VARIABLES:\n      error_log                      = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 64)\n      instrument_name                = [\"L\",\"C\",\"Q\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 32)\n      instrument_id                  = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 32)\n      instrument_mfr                 = [\"F\",\"i\",\"n\",\"n\",\"i\",\"g\",\"a\",\"n\",\"-\",\"M\",\"A\",\"T\",\" (length: 32)\n      instrument_model               = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 32)\n      instrument_sw_version          = [\"3\",\".\",\"1\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 32)\n      instrument_os_version          = [\"W\",\"i\",\"n\",\"d\",\"o\",\"w\",\"s\",\" \",\"V\",\"i\",\"s\",\"t\",\" (length: 32)\n      scan_index                     = [0,34,74,113,145,177,211,239,267,299,341,374,400,4 (length: 11832)\n      point_count                    = [34,40,39,32,32,34,28,28,32,42,33,26,29,34,31,28,2 (length: 11832)\n      flag_count                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 11832)\n      a_d_sampling_rate              = [1000,1000,1000,1000,1000,1000,1000,1000,1000,1000 (length: 11832)\n      scan_acquisition_time          = [82.328,82.625,82.76599999999999,83.063,83.188,83. (length: 11832)\n      scan_duration                  = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 11832)\n      mass_range_min                 = [35,16,35,16,35,16,35,16,35,16,35,16,35,16,35,16,3 (length: 11832)\n      mass_range_max                 = [450,150,450,150,450,150,450,150,450,150,450,150,4 (length: 11832)\n      scan_type                      = [65537,65537,65537,65537,65537,65537,65537,65537,6 (length: 11832)\n      resolution                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 11832)\n      total_intensity                = [375220,1054339,228245,576718,58280,288629,29815,1 (length: 11832)\n      mass_values                    = [36.3023681640625,36.98402404785156,38.08326721191 (length: 1366002)\n      intensity_values               = [335,287,331,266,2423,448,9009,833,261,661,4003,21 (length: 1366002)\n\n*/\n\nfunction finniganGCMS(reader) {\n  const time = reader.getDataVariable('scan_acquisition_time');\n  const tic = reader.getDataVariable('total_intensity');\n\n  // variables to get the mass-intensity values\n  let scanIndex = reader.getDataVariable('scan_index');\n  const massValues = reader.getDataVariable('mass_values');\n  const intensityValues = reader.getDataVariable('intensity_values');\n  scanIndex.push(massValues.length);\n\n  let ms = new Array(time.length);\n  let index = 0;\n  for (let i = 0; i < ms.length; i++) {\n    let size = scanIndex[i + 1] - scanIndex[i];\n    ms[i] = [new Array(size), new Array(size)];\n\n    for (let j = 0; j < size; j++) {\n      ms[i][0][j] = massValues[index];\n      ms[i][1][j] = intensityValues[index++];\n    }\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n      {\n        name: 'ms',\n        dimension: 2,\n        data: ms,\n      },\n    ],\n  };\n}\n\nmodule.exports = finniganGCMS;\n","'use strict';\n\n/* reader.toString() provides the following information\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1+C2\n      ms_template_revision           = 1.0.1\n      netcdf_revision                = 2.3.2\n      languages                      = English\n      administrative_comments        =\n      netcdf_file_date_time_stamp    = 20180913165502+0000\n      experiment_title               =\n      experiment_date_time_stamp     = 20180910165319+0000\n      operator_name                  = Admin\n      source_file_reference          = D:\\GCMSsolution\\Data\\Chromatograms\\Cato\\bormann_CB000_Test2.qgd\n      source_file_format             = Shimadzu GCMSsolution\n      source_file_date_time_stamp    = 20180910165319+0000\n      experiment_type                = Centroided Mass Spectrum\n      sample_internal_id             =\n      sample_comments                =\n      sample_state                   = Other State\n      test_separation_type           = Gas-Solid Chromatography\n      test_ms_inlet                  = Other Probe\n      test_ionization_mode           = Electron Impact\n      test_ionization_polarity       = Positive Polarity\n      test_electron_energy           = 70\n      test_detector_type             = Electron Multiplier\n      test_resolution_type           = Constant Resolution\n      test_scan_function             = Mass Scan\n      test_scan_direction            = Up\n      test_scan_law                  = Quadratic\n      test_scan_time                 = 0\n      raw_data_mass_format           = Double\n      raw_data_time_format           = Long\n      raw_data_intensity_format      = Long\n      units                          = Seconds\n      scale_factor                   = 1\n      long_name                      = Seconds\n      starting_scan_number           = 0\n      actual_run_time_length         = 1289\n      actual_delay_time              = 0\n      raw_data_uniform_sampling_flag = 1\n\n    VARIABLES:\n      error_log                      = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 64)\n      a_d_sampling_rate              = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      a_d_coaddition_factor          = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      scan_acquisition_time          = [144,144.3,144.6,144.9,145.2,145.5,145.8,146.1,146 (length: 3820)\n      scan_duration                  = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      inter_scan_time                = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      resolution                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      actual_scan_number             = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2 (length: 3820)\n      total_intensity                = [63566,61702,61873,59738,58321,59001,59364,59871,6 (length: 3820)\n      mass_range_min                 = [35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,3 (length: 3820)\n      mass_range_max                 = [500,500,500,500,500,500,500,500,500,500,500,500,5 (length: 3820)\n      time_range_min                 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      time_range_max                 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      scan_index                     = [0,466,932,1398,1863,2329,2795,3260,3726,4192,4658 (length: 3820)\n      point_count                    = [466,466,466,465,466,466,465,466,466,466,466,466,4 (length: 3820)\n      flag_count                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 3820)\n      mass_values                    = [35,36,37.1,38.1,39.1,40.15,41.1,42.1,43.15,44.1,4 (length: 1779397)\n      intensity_values               = [26,111,412,785,3098,485,5772,7391,11213,711,687,1 (length: 1779397)\n      instrument_name                = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_id                  = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n      instrument_mfr                 = [\"S\",\"h\",\"i\",\"m\",\"a\",\"d\",\"z\",\"u\",\" \",\"C\",\"o\",\"r\",\" (length: 32)\n      instrument_model               = [\"G\",\"C\",\"M\",\"S\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\", (length: 32)\n      instrument_serial_no           = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 32)\n      instrument_sw_version          = [\"4\",\".\",\"2\",\"0\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\", (length: 32)\n      instrument_fw_version          = [\"G\",\"C\",\"M\",\"S\",\"-\",\"Q\",\"P\",\"2\",\"0\",\"1\",\"0\",\"1\",\" (length: 32)\n      instrument_os_version          = [\"W\",\"i\",\"n\",\"d\",\"o\",\"w\",\"s\",\"\",\"\",\"\",\"\",\"\",\"\",\"\", (length: 32)\n      instrument_app_version         = [\"G\",\"C\",\"M\",\"S\",\"s\",\"o\",\"l\",\"u\",\"t\",\"i\",\"o\",\"n\",\" (length: 32)\n      instrument_comments            = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" (length: 32)\n*/\n\nfunction shimadzuGCMS(reader) {\n  const time = reader.getDataVariable('scan_acquisition_time');\n  const tic = reader.getDataVariable('total_intensity');\n\n  // variables to get the mass-intensity values\n  let scanIndex = reader.getDataVariable('scan_index');\n  const massValues = reader.getDataVariable('mass_values');\n  const intensityValues = reader.getDataVariable('intensity_values');\n  scanIndex.push(massValues.length);\n\n  let ms = new Array(time.length);\n  let index = 0;\n  for (let i = 0; i < ms.length; i++) {\n    let size = scanIndex[i + 1] - scanIndex[i];\n    ms[i] = [new Array(size), new Array(size)];\n\n    for (let j = 0; j < size; j++) {\n      ms[i][0][j] = massValues[index];\n      ms[i][1][j] = intensityValues[index++];\n    }\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n      {\n        name: 'ms',\n        dimension: 2,\n        data: ms,\n      },\n    ],\n  };\n}\n\nmodule.exports = shimadzuGCMS;\n","'use strict';\n\n/* reader.toString() provides the following information\n    DIMENSIONS\n      point_number                   = size: 0\n      scan_number                    = size: 60\n      error_number                   = size: 1\n      _64_byte_string                = size: 64\n\n    GLOBAL ATTRIBUTES\n      dataset_completeness           = C1\n      ms_template_revision           = 1.0.1\n      netcdf_revision                = 4.2\n      languages                      = English\n      administrative_comments        =\n      netcdf_file_date_time_stamp    = 202003031432433600000\n      experiment_date_time_stamp     = 202003031432433600000\n      source_file_reference          = JC-012_cleavage test_Scan1_is1.datx 2020.03.03 14:32:43\n      source_file_format             = Advion ExpressIon Compact Mass Spectrometer Data System\n      source_file_date_time_stamp    = 202003031432433600000\n      experiment_title               =\n      experiment_type                = Continuum Mass Spectrum\n      test_ionization_mode           = Electrospray Ionization\n      test_ionization_polarity       = Positive Polarity\n      sample_state                   = Other State\n      test_separation_type           = No Chromatography\n      test_ms_inlet                  = Direct Inlet Probe\n      test_detector_type             = Electron Multiplier\n      test_resolution_type           = Constant Resolution\n      test_scan_function             = Mass Scan\n      test_scan_direction            = Up\n      test_scan_law                  = Linear\n      raw_data_mass_format           = Float\n      raw_data_time_format           = Double\n      raw_data_intensity_format      = Float\n      units                          = Seconds\n      global_mass_min                = 9.949999809265137\n      global_mass_max                = 1199.75\n      actual_run_time_length         = 133.46099853515625\n      starting_scan_number           = 1\n      actual_delay_time              = 0\n      raw_data_uniform_sampling_flag = 0\n\n    VARIABLES:\n      error_log                      = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\" (length: 64)\n      scan_index                     = [0,3096,6282,9865,13409,16765,20281,23603,27099,30 (length: 60)\n      point_count                    = [3096,3186,3583,3544,3356,3516,3322,3496,3351,3031 (length: 60)\n      flag_count                     = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (length: 60)\n      actual_scan_number             = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 (length: 60)\n      a_d_coaddition_factor          = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      a_d_sampling_rate              = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      inter_scan_time                = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      mass_range_min                 = [9.949999809265137,9.949999809265137,9.94999980926 (length: 60)\n      mass_range_max                 = [164.6999969482422,169.1999969482422,189.050003051 (length: 60)\n      scan_acquisition_time          = [0.08100000023841858,2.3420000076293945,4.60300016 (length: 60)\n      scan_duration                  = [2.261000007390976,2.261000156402588,2.25999975204 (length: 60)\n      resolution                     = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      time_range_min                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      time_range_max                 = [-9999,-9999,-9999,-9999,-9999,-9999,-9999,-9999,- (length: 60)\n      total_intensity                = [4498210816,4468554240,5001547264,5405233152,50000 (length: 60)\n      mass_values                    = [9.949999809265137,83.5,83.55000305175781,83.59999 (length: 199393)\n      intensity_values               = [0,818716,462148,0,735558,952901,0,165241,421829,0 (length: 199393)\n*/\n\nfunction advionGCMS(reader) {\n  const time = reader.getDataVariable('scan_acquisition_time');\n  const tic = reader.getDataVariable('total_intensity');\n\n  // variables to get the mass-intensity values\n  let scanIndex = reader.getDataVariable('scan_index');\n  const massValues = reader.getDataVariable('mass_values');\n  const intensityValues = reader.getDataVariable('intensity_values');\n  scanIndex.push(massValues.length);\n\n  let ms = new Array(time.length);\n  let index = 0;\n  for (let i = 0; i < ms.length; i++) {\n    let size = scanIndex[i + 1] - scanIndex[i];\n    ms[i] = [new Array(size), new Array(size)];\n\n    for (let j = 0; j < size; j++) {\n      ms[i][0][j] = massValues[index];\n      ms[i][1][j] = intensityValues[index++];\n    }\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n      {\n        name: 'ms',\n        dimension: 2,\n        data: ms,\n      },\n    ],\n  };\n}\n\nmodule.exports = advionGCMS;\n","'use strict';\n\nfunction aiaTemplate(reader) {\n  let time = [];\n  const tic = reader.getDataVariable('ordinate_values');\n\n  // variables to get the time\n  const delayTime = Number(reader.getDataVariable('actual_delay_time'));\n  const interval = Number(reader.getDataVariable('actual_sampling_interval'));\n\n  let currentTime = delayTime;\n  for (let i = 0; i < tic.length; i++) {\n    time.push(currentTime);\n    currentTime += interval;\n  }\n\n  return {\n    times: time,\n    series: [\n      {\n        name: 'tic',\n        dimension: 1,\n        data: tic,\n      },\n    ],\n  };\n}\n\nmodule.exports = aiaTemplate;\n","'use strict';\n\nconst NetCDFReader = require('netcdfjs');\n\nconst agilentGCMS = require('./agilentGCMS');\nconst brukerGCMS = require('./brukerGCMS');\nconst agilentHPLC = require('./agilentHPLC');\nconst finniganGCMS = require('./finniganGCMS');\nconst shimadzuGCMS = require('./shimadzuGCMS');\nconst advionGCMS = require('./advionGCMS');\nconst aiaTemplate = require('./aiaTemplate');\n\n/**\n * Reads a NetCDF file and returns a formatted JSON with the data from it\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @param {object} [options={}]\n * @param {boolean} [options.meta] - add meta information\n * @param {boolean} [options.variables] -add variables information\n * @return {{times, series}} - JSON with the time, TIC and mass spectra values\n */\nfunction netcdfGcms(data, options = {}) {\n  let reader = new NetCDFReader(data);\n  const globalAttributes = reader.globalAttributes;\n\n  let instrument_mfr =\n    reader.dataVariableExists('instrument_mfr') &&\n    reader.getDataVariableAsString('instrument_mfr');\n  let dataset_origin = reader.attributeExists('dataset_origin');\n  let mass_values = reader.dataVariableExists('mass_values');\n  let detector_name = reader.getAttribute('detector_name');\n  let aia_template_revision = reader.attributeExists('aia_template_revision');\n  let source_file_format = reader.getAttribute('source_file_format');\n\n  let ans;\n\n  if (mass_values && dataset_origin) {\n    ans = agilentGCMS(reader);\n  } else if (\n    mass_values &&\n    instrument_mfr &&\n    instrument_mfr.match(/finnigan/i)\n  ) {\n    ans = finniganGCMS(reader);\n  } else if (mass_values && instrument_mfr && instrument_mfr.match(/bruker/i)) {\n    ans = brukerGCMS(reader);\n  } else if (mass_values && instrument_mfr && instrument_mfr.match(/bruker/i)) {\n    ans = brukerGCMS(reader);\n  } else if (\n    mass_values &&\n    source_file_format &&\n    source_file_format.match(/shimadzu/i)\n  ) {\n    ans = shimadzuGCMS(reader);\n  } else if (\n    mass_values &&\n    source_file_format &&\n    source_file_format.match(/advion/i)\n  ) {\n    ans = advionGCMS(reader);\n  } else if (detector_name && detector_name.match(/(dad|tic)/i)) {\n    // diode array agilent HPLC\n    ans = agilentHPLC(reader);\n  } else if (aia_template_revision) {\n    ans = aiaTemplate(reader);\n  } else {\n    throw new TypeError('Unknown file format');\n  }\n\n  if (options.meta) {\n    ans.meta = addMeta(globalAttributes);\n  }\n\n  if (options.variables) {\n    ans.variables = addVariables(reader);\n  }\n\n  return ans;\n}\n\n/**\n * Reads a NetCDF file with Agilent GCMS format and returns a formatted JSON with the data from it\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @return {{times, series}} - JSON with the time, TIC and mass spectra values\n */\nfunction fromAgilentGCMS(data) {\n  return agilentGCMS(new NetCDFReader(data));\n}\n\n/**\n * Reads a NetCDF file with Agilent HPLC format and returns a formatted JSON with the data from it\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @return {{times, series}} - JSON with the time, TIC and mass spectra values\n */\nfunction fromAgilentHPLC(data) {\n  return agilentHPLC(new NetCDFReader(data));\n}\n\n/**\n * Reads a NetCDF file with Finnigan format and returns a formatted JSON with the data from it\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @return {{times, series}} - JSON with the time, TIC and mass spectra values\n */\nfunction fromFinniganGCMS(data) {\n  return finniganGCMS(new NetCDFReader(data));\n}\n\nfunction fromAiaTemplate(data) {\n  return aiaTemplate(new NetCDFReader(data));\n}\n\nfunction addMeta(globalAttributes) {\n  let ans = {};\n  for (const item of globalAttributes) {\n    ans[item.name] = item.value;\n  }\n  return ans;\n}\n\nfunction addVariables(reader) {\n  for (let variable of reader.variables) {\n    variable.value = reader.getDataVariable(variable);\n  }\n  return reader.variables;\n}\n\nmodule.exports = netcdfGcms;\nmodule.exports.fromAgilentGCMS = fromAgilentGCMS;\nmodule.exports.fromAgilentHPLC = fromAgilentHPLC;\nmodule.exports.fromFinniganGCMS = fromFinniganGCMS;\nmodule.exports.fromAiaTemplate = fromAiaTemplate;\n","import netcdfJSON from 'netcdf-gcms';\n\nimport { fromJSON } from '../Chromatogram';\n\nexport function fromNetCDF(netcdf) {\n  return fromJSON(netcdfJSON(netcdf));\n}\n","const utf8Decoder = new TextDecoder();\n\nexport const decoder = {\n  decode: (array) => {\n    return utf8Decoder.decode(array);\n  },\n};\n\nexport const defaultOptions = {\n  trimValues: true,\n  attributeNamePrefix: '$',\n  attributesNodeName: false,\n  ignoreAttributes: false,\n  ignoreNameSpace: false,\n  allowBooleanAttributes: false,\n  dynamicTypingAttributeValue: true,\n\n  textNodeName: '#text',\n\n  dynamicTypingNodeValue: true,\n  arrayMode: false,\n  cdataTagName: false,\n  tagValueProcessor: (value) => {\n    return decoder.decode(value).replace(/\\r/g, '');\n  },\n  attributeValueProcessor: (value) => value,\n  stopNodes: [],\n};\n","export class XMLNode {\n  constructor(tagName, parent, value) {\n    this.tagName = tagName;\n    this.parent = parent;\n    this.children = Object.create({}); //child tags\n    this.attributes = Object.create({}); //attributes map\n    this.value = value; //text only\n    this.startIndex = -1;\n  }\n  addChild(child) {\n    if (Array.isArray(this.children[child.tagName])) {\n      //already presents\n      this.children[child.tagName].push(child);\n    } else {\n      this.children[child.tagName] = [child];\n    }\n  }\n}\n","export function arrayIndexOf(array, referenceArray, index = 0) {\n  let found = 0;\n  let foundIndex = -1;\n  for (let i = index; i < array.length && found < referenceArray.length; i++) {\n    if (array[i] === referenceArray[found]) {\n      if (!found) {\n        foundIndex = i;\n      }\n      found++;\n    } else {\n      if (found > 0) {\n        let j = 0;\n        for (\n          ;\n          j <= found && array[foundIndex + j] === array[foundIndex + found];\n          j++\n        );\n        if (j < found + 1) {\n          foundIndex = -1;\n          found = 0;\n        } else {\n          foundIndex++;\n        }\n      } else {\n        found = 0;\n        foundIndex = -1;\n      }\n    }\n  }\n  if (found !== referenceArray.length) {\n    foundIndex = -1;\n  }\n  return foundIndex;\n}\n","export function arrayTrim(array) {\n  let i = 0;\n  let j = array.length - 1;\n  for (; i < array.length && array[i] <= 0x20; i++);\n  for (; j >= i && array[j] <= 0x20; j--);\n  if (i === 0 && j === array.length - 1) return array;\n  return array.subarray(i, j + 1);\n}\n","import { decoder } from './getTraversable';\n\nexport function closingIndexForOpeningTag(data, i) {\n  let attrBoundary;\n  let endIndex = 0;\n  for (let index = i; index < data.length; index++) {\n    let byte = data[index];\n    if (attrBoundary) {\n      if (byte === attrBoundary) attrBoundary = 0; //reset\n    } else if (byte === 0x22 || byte === 0x27) {\n      attrBoundary = byte;\n    } else if (byte === 0x3e) {\n      return {\n        data: decoder.decode(data.subarray(i, i + endIndex)),\n        index,\n      };\n    } else if (byte === 0x09) {\n      byte = 0x20;\n    }\n    endIndex++;\n  }\n}\n","import { arrayIndexOf } from '../bufferUtils/arrayIndexOf';\n\nexport function findClosingIndex(xmlData, str, i, errMsg) {\n  const closingIndex = arrayIndexOf(xmlData, str, i);\n  if (closingIndex === -1) {\n    throw new Error(errMsg);\n  } else {\n    return closingIndex + str.length - 1;\n  }\n}\n","const nameStartChar =\n  ':A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD';\nconst nameChar = `${nameStartChar}\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040`;\nconst nameRegexp = `[${nameStartChar}][${nameChar}]*`;\n// eslint-disable-next-line no-misleading-character-class\nconst regexName = new RegExp(`^${nameRegexp}$`);\n\nexport function getAllMatches(string, regex) {\n  return Array.from(string.matchAll(regex));\n}\n\nexport function isName(string) {\n  return regexName.exec(string) !== null;\n}\n\nexport function isEmptyObject(obj) {\n  // fastest implementation: https://jsbench.me/qfkqv692c8/1\n  // eslint-disable-next-line no-unreachable-loop\n  for (const key in obj) {\n    return false;\n  }\n  return true;\n}\n\n/**\n * Copy all the properties of a into b.\n * @param {object} target\n * @param {object} source\n */\nexport function merge(target, source, arrayMode) {\n  if (!source) return;\n  for (const key in source) {\n    if (arrayMode === 'strict') {\n      target[key] = [source[key]];\n    } else {\n      target[key] = source[key];\n    }\n  }\n}\n\n/**\n * Check if a tag name should be treated as array\n *\n * @param tagName the node tagName\n * @param arrayMode the array mode option\n * @param parentTagName the parent tag name\n * @returns {boolean} true if node should be parsed as array\n */\nexport function isTagNameInArrayMode(tagName, arrayMode, parentTagName) {\n  if (arrayMode === false) {\n    return false;\n  } else if (arrayMode instanceof RegExp) {\n    return arrayMode.test(tagName);\n  } else if (typeof arrayMode === 'function') {\n    return !!arrayMode(tagName, parentTagName);\n  }\n\n  return arrayMode === 'strict';\n}\n","import { parseString } from 'dynamic-typing';\n\nimport { getAllMatches, isEmptyObject } from '../util';\n\nconst newLocal = '([^\\\\s=]+)\\\\s*(=\\\\s*([\\'\"])(.*?)\\\\3)?';\nconst attrsRegx = new RegExp(newLocal, 'g');\n\n//Attributes are strings so no point in using arrayBuffers here\nexport function parseAttributesString(string, options) {\n  if (options.ignoreAttributes) {\n    return;\n  }\n  string = string.replace(/\\r?\\n/g, ' ');\n\n  const matches = getAllMatches(string, attrsRegx);\n  const attributes = {};\n  for (let match of matches) {\n    const attrName = resolveNameSpace(match[1], options);\n    if (attrName.length) {\n      if (match[4] !== undefined) {\n        if (options.trimValues) {\n          match[4] = match[4].trim();\n        }\n        match[4] = options.attributeValueProcessor(match[4], attrName);\n        attributes[attrName] = stringParseValue(\n          match[4],\n          options.dynamicTypingAttributeValue,\n        );\n      } else if (options.allowBooleanAttributes) {\n        attributes[attrName] = true;\n      }\n    }\n  }\n  if (isEmptyObject(attributes)) return;\n  return attributes;\n}\n\nfunction stringParseValue(value, shouldParse) {\n  if (shouldParse && typeof value === 'string') {\n    return parseString(value);\n  } else {\n    return value === undefined ? '' : value;\n  }\n}\n\nfunction resolveNameSpace(tagName, options) {\n  if (options.ignoreNameSpace) {\n    const tags = tagName.split(':');\n    const prefix = tagName.charAt(0) === '/' ? '/' : '';\n    if (tags[0] === 'xmlns') {\n      return '';\n    }\n    if (tags.length === 2) {\n      tagName = prefix + tags[1];\n    }\n  }\n  return tagName;\n}\n","import { XMLNode } from '../XMLNode';\nimport { arrayIndexOf } from '../bufferUtils/arrayIndexOf';\nimport { arrayTrim } from '../bufferUtils/arrayTrim';\n\nimport { closingIndexForOpeningTag } from './closingIndexForOpeningTag';\nimport { findClosingIndex } from './findClosingIndex.1';\nimport { parseAttributesString } from './parseAttributesString';\n\nconst utf8Decoder = new TextDecoder();\n\nexport const decoder = {\n  decode: (array) => {\n    return utf8Decoder.decode(array);\n  },\n};\n\nexport function getTraversable(xmlData, options) {\n  const traversable = new XMLNode('!xml');\n  let currentNode = traversable;\n  let dataSize = 0;\n  let dataIndex = 0;\n\n  for (let i = 0; i < xmlData.length; i++) {\n    if (xmlData[i] === 0x3c) {\n      // <\n      const xmlData1 = xmlData[i + 1];\n      const xmlData2 = xmlData[i + 2];\n      if (xmlData1 === 0x2f) {\n        // </ Closing Tag\n        const closeIndex = findClosingIndex(\n          xmlData,\n          [0x3e], //>\n          i,\n          'Closing Tag is not closed.',\n        );\n        let tagName = decoder.decode(\n          arrayTrim(xmlData.subarray(i + 2, closeIndex), {}),\n        );\n        tagName = removeNameSpaceIfNeeded(tagName, options);\n        if (currentNode) {\n          const value = options.trimValues\n            ? arrayTrim(xmlData.subarray(dataIndex, dataIndex + dataSize))\n            : xmlData.subarray(dataIndex, dataIndex + dataSize);\n          if (currentNode.value === undefined) {\n            currentNode.value = value;\n          } else {\n            currentNode.value = concat(currentNode.value, value);\n          }\n        }\n        if (\n          options.stopNodes.length &&\n          options.stopNodes.includes(currentNode.tagName)\n        ) {\n          currentNode.children = [];\n          if (currentNode.attributes === undefined) {\n            currentNode.attributes = {};\n          }\n          currentNode.value = xmlData.subarray(currentNode.startIndex + 1, i);\n        }\n        currentNode = currentNode.parent;\n        i = closeIndex;\n        dataSize = 0;\n        dataIndex = i + 1;\n      } else if (xmlData1 === 0x3f) {\n        // <? PI, processing instruction\n        i = findClosingIndex(xmlData, [0x3f, 0x3e], i, 'Pi Tag is not closed.');\n      } else if (\n        //!-- comment\n        xmlData1 === 0x21 &&\n        xmlData2 === 0x2d &&\n        xmlData[i + 3] === 0x2d\n      ) {\n        i = findClosingIndex(\n          xmlData,\n          [0x2d, 0x2d, 0x3e], //-->\n          i,\n          'Comment is not closed.',\n        );\n        if (currentNode && dataSize !== 0) {\n          if (currentNode.tagName !== '!xml') {\n            currentNode.value = concat(\n              currentNode.value,\n              options.trimValues\n                ? arrayTrim(xmlData.subarray(dataIndex, dataSize + dataIndex))\n                : xmlData.subarray(dataIndex, dataSize + dataIndex),\n            );\n          }\n        }\n        dataSize = 0;\n        dataIndex = i + 1;\n        //!D\n      } else if (xmlData1 === 0x21 && xmlData2 === 0x44) {\n        // <!D\n        const closeIndex = findClosingIndex(\n          xmlData,\n          [0x3e], //>\n          i,\n          'DOCTYPE is not closed.',\n        );\n        const tagExp = xmlData.subarray(i, closeIndex);\n        if (arrayIndexOf(tagExp, [0x5b]) >= 0) {\n          i = arrayIndexOf(xmlData, [0x5d, 0x3e], i) + 1;\n        } else {\n          i = closeIndex;\n        } //![\n      } else if (xmlData1 === 0x21 && xmlData2 === 0x5b) {\n        // <![CDATA[some stuff]]>\n        const closeIndex =\n          findClosingIndex(\n            xmlData,\n            [0x5d, 0x5d, 0x3e], //]]>\n            i,\n            'CDATA is not closed.',\n          ) - 2;\n        const tagExp = xmlData.subarray(i + 9, closeIndex);\n\n        //considerations\n        //1. CDATA will always have parent node\n        //2. A tag with CDATA is not a leaf node so it's value would be string type.\n        if (dataSize !== 0) {\n          const value = options.trimValues\n            ? arrayTrim(xmlData.subarray(dataIndex, dataIndex + dataSize))\n            : xmlData.subarray(dataIndex, dataIndex + dataSize);\n\n          currentNode.value = concat(currentNode.value, value);\n        }\n\n        if (options.cdataTagName) {\n          //add cdata node\n          const childNode = new XMLNode(\n            options.cdataTagName,\n            currentNode,\n            tagExp,\n          );\n          currentNode.addChild(childNode);\n          //add rest value to parent node\n          if (tagExp) {\n            childNode.value = tagExp;\n          }\n        } else {\n          currentNode.value = concat(currentNode.value, tagExp);\n        }\n\n        i = closeIndex + 2;\n        dataSize = 0;\n        dataIndex = i + 1;\n      } else {\n        //Opening a normal tag\n        const parsedOpeningTag = closingIndexForOpeningTag(xmlData, i + 1);\n        let tagData = parsedOpeningTag.data.replace(/\\r?\\n|\\t/g, ' ');\n        const closeIndex = parsedOpeningTag.index;\n        const separatorIndex = tagData.indexOf(' ');\n        let shouldBuildAttributesMap = true;\n        let tagName =\n          separatorIndex >= 0\n            ? tagData.substr(0, separatorIndex).replace(/\\s+$/, '')\n            : tagData;\n        let tagAttributes =\n          separatorIndex >= 0 ? tagData.substr(separatorIndex + 1) : '';\n        if (options.ignoreNameSpace) {\n          const colonIndex = tagName.indexOf(':');\n          if (colonIndex !== -1) {\n            tagName = tagName.substr(colonIndex + 1);\n            shouldBuildAttributesMap =\n              tagName !== parsedOpeningTag.data.substr(colonIndex + 1);\n          }\n        }\n\n        //save text to parent node\n        if (currentNode && dataSize !== 0) {\n          if (currentNode.tagName !== '!xml') {\n            currentNode.value = concat(\n              currentNode.value,\n              options.trimValues\n                ? arrayTrim(xmlData.subarray(dataIndex, dataIndex + dataSize))\n                : xmlData.subarray(dataIndex, dataIndex + dataSize),\n            );\n          }\n        }\n\n        if (tagData.length > 0 && tagData[tagData.length - 1] === '/') {\n          //selfClosing tag\n\n          if (tagAttributes) {\n            // <abc def=\"123\"/>\n            tagAttributes = tagAttributes.substr(0, tagAttributes.length - 1);\n          } else {\n            // <abc/>\n            tagName = tagName.substr(0, tagName.length - 1);\n          }\n\n          const childNode = new XMLNode(tagName, currentNode, '');\n          if (tagAttributes) {\n            childNode.attributes = parseAttributesString(\n              tagAttributes,\n              options,\n            );\n          }\n          currentNode.addChild(childNode);\n        } else {\n          //opening tag\n\n          const childNode = new XMLNode(tagName, currentNode);\n          if (\n            options.stopNodes.length &&\n            options.stopNodes.includes(childNode.tagName)\n          ) {\n            childNode.startIndex = closeIndex;\n          }\n          if (tagAttributes && shouldBuildAttributesMap) {\n            childNode.attributes = parseAttributesString(\n              tagAttributes,\n              options,\n            );\n          }\n          currentNode.addChild(childNode);\n          currentNode = childNode;\n        }\n        i = closeIndex;\n        dataSize = 0;\n        dataIndex = i + 1;\n      }\n    } else {\n      dataSize++;\n    }\n  }\n  return traversable;\n}\n\nfunction concat(a, b) {\n  if (a === undefined) {\n    a = typeof b === 'string' ? '' : new Uint8Array(0);\n  }\n  if (b === undefined) {\n    b = typeof a === 'string' ? '' : new Uint8Array(0);\n  }\n  if (typeof a === 'string' && typeof b === 'string') {\n    return a + b;\n  } else if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {\n    const arrayConcat = new Uint8Array(a.length + b.length);\n    arrayConcat.set(a);\n    arrayConcat.set(b, a.length);\n    return arrayConcat;\n  } else {\n    throw new Error(\n      `Unsuported value type for concatenation: ${typeof a} ${typeof b}`,\n    );\n  }\n}\n\nfunction removeNameSpaceIfNeeded(tagName, options) {\n  if (!options.ignoreNameSpace) return tagName;\n  const colonIndex = tagName.indexOf(':');\n  if (colonIndex !== -1) {\n    tagName = tagName.substr(colonIndex + 1);\n  }\n}\n","import { parseString } from 'dynamic-typing';\n\nimport { isTagNameInArrayMode, merge, isEmptyObject } from './util';\n\n/**\n *\n * @param {*} node\n * @param {*} options\n * @param {*} parentTagName\n * @returns\n */\nexport function traversableToJSON(node, options, parentTagName) {\n  const { dynamicTypingNodeValue, tagValueProcessor, arrayMode } = options;\n  const result = {};\n\n  if (tagValueProcessor) {\n    node.value = node.value && tagValueProcessor(node.value, node);\n  }\n  if (typeof node.value === 'string' && dynamicTypingNodeValue) {\n    node.value = parseString(node.value);\n  }\n  // when no child node or attr is present\n  if (\n    (!node.children || isEmptyObject(node.children)) &&\n    (!node.attributes || isEmptyObject(node.attributes))\n  ) {\n    return node.value === undefined ? '' : node.value;\n  }\n\n  // otherwise create a textnode if node has some text\n  if (node.value !== undefined && node.value.length !== 0) {\n    const asArray = isTagNameInArrayMode(\n      node.tagName,\n      arrayMode,\n      parentTagName,\n    );\n\n    result[options.textNodeName] = asArray ? [node.value] : node.value;\n  }\n\n  if (node.attributes && !isEmptyObject(node.attributes)) {\n    let attributes = options.parseAttributesString ? {} : node.attributes;\n    if (options.attributeNamePrefix) {\n      // need to rename the attributes\n      const renamedAttributes = {};\n      for (let key in node.attributes) {\n        renamedAttributes[options.attributeNamePrefix + key] =\n          node.attributes[key];\n      }\n      attributes = renamedAttributes;\n    }\n    if (options.attributesNodeName) {\n      let encapsulatedAttributes = {};\n      encapsulatedAttributes[options.attributesNodeName] = attributes;\n      attributes = encapsulatedAttributes;\n    }\n    merge(result, attributes, arrayMode);\n  }\n\n  const keys = Object.keys(node.children);\n  for (let index = 0; index < keys.length; index++) {\n    const tagName = keys[index];\n    if (node.children[tagName] && node.children[tagName].length > 1) {\n      result[tagName] = [];\n      for (let tag in node.children[tagName]) {\n        if (Object.prototype.hasOwnProperty.call(node.children[tagName], tag)) {\n          result[tagName].push(\n            traversableToJSON(node.children[tagName][tag], options, tagName),\n          );\n        }\n      }\n    } else {\n      const subResult = traversableToJSON(\n        node.children[tagName][0],\n        options,\n        tagName,\n      );\n      const asArray =\n        (arrayMode === true && typeof subResult === 'object') ||\n        isTagNameInArrayMode(tagName, arrayMode, parentTagName);\n      result[tagName] = asArray ? [subResult] : subResult;\n    }\n  }\n\n  return result;\n}\n","import { defaultOptions } from './traversable/defaultOptions';\nimport { getTraversable } from './traversable/getTraversable';\nimport { traversableToJSON } from './traversableToJSON';\n\n/**\n * Parse an ArrayBuffer or Uint8Array representing an XML\n * @param {ArrayBuffer|Uint8Arra} xmlData\n * @param {object} [options={}]\n * @param {string} [attributeNamePrefix='$']\n * @param {boolean} [attributesNodeName=false]\n * @param {string} [textNodeName='#text']\n * @param {boolean} [trimValues=true] should we remove ascii < 32\n * @param {boolean} [ignoreAttributes=false] skip attributes\n * @param {boolean} [ignoreNameSpace=false]\n * @param {boolean} [dynamicTypingAttributeValue=true] Parse attribute values that looks like number or boolean\n * @param {boolean} [allowBooleanAttributes=false]\n * @param {boolean} [dynamicTypingNodeValue=true] Parse tag values that looks like number or boolean\n * @param {boolean} [arrayMode=false]\n * @param {boolean} [cdataTagName=false]\n * @param {function} [tagValueProcessor=(v, node) => decoder.decode(v)] Tag values can be modified during parsing. By default we decode the tag value (a Uint8Array) using TextDecoder\n * @param {function} [attributeValueProcessor=(v) => v] Attribute values can be modified during parsing\n * @param {boolean} [stopNodes=[]] prevent further parsing\n *\n * @returns {object}\n */\nexport function parse(xmlData, options = {}) {\n  if (typeof xmlData === 'string') {\n    const encoder = new TextEncoder();\n    xmlData = encoder.encode(xmlData);\n  }\n\n  if (!ArrayBuffer.isView(xmlData)) {\n    xmlData = new Uint8Array(xmlData);\n  }\n\n  options = { ...defaultOptions, ...options };\n\n  const traversable = getTraversable(xmlData, options);\n\n  return traversableToJSON(traversable, options);\n}\n","\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n/* eslint-disable space-unary-ops */\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//const Z_FILTERED          = 1;\n//const Z_HUFFMAN_ONLY      = 2;\n//const Z_RLE               = 3;\nconst Z_FIXED$1               = 4;\n//const Z_DEFAULT_STRATEGY  = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nconst Z_BINARY              = 0;\nconst Z_TEXT                = 1;\n//const Z_ASCII             = 1; // = Z_TEXT\nconst Z_UNKNOWN$1             = 2;\n\n/*============================================================================*/\n\n\nfunction zero$1(buf) { let len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nconst STORED_BLOCK = 0;\nconst STATIC_TREES = 1;\nconst DYN_TREES    = 2;\n/* The three kinds of block type */\n\nconst MIN_MATCH$1    = 3;\nconst MAX_MATCH$1    = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nconst LENGTH_CODES$1  = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nconst LITERALS$1      = 256;\n/* number of literal bytes 0..255 */\n\nconst L_CODES$1       = LITERALS$1 + 1 + LENGTH_CODES$1;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nconst D_CODES$1       = 30;\n/* number of distance codes */\n\nconst BL_CODES$1      = 19;\n/* number of codes used to transfer the bit lengths */\n\nconst HEAP_SIZE$1     = 2 * L_CODES$1 + 1;\n/* maximum heap size */\n\nconst MAX_BITS$1      = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nconst Buf_size      = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nconst MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nconst END_BLOCK   = 256;\n/* end of block literal code */\n\nconst REP_3_6     = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nconst REPZ_3_10   = 17;\n/* repeat a zero length 3-10 times  (3 bits of repeat count) */\n\nconst REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times  (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nconst extra_lbits =   /* extra bits for each length code */\n  new Uint8Array([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]);\n\nconst extra_dbits =   /* extra bits for each distance code */\n  new Uint8Array([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]);\n\nconst extra_blbits =  /* extra bits for each bit length code */\n  new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]);\n\nconst bl_order =\n  new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nconst DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1\nconst static_ltree  = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nconst static_dtree  = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nconst _dist_code    = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nconst _length_code  = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nconst base_length   = new Array(LENGTH_CODES$1);\nzero$1(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nconst base_dist     = new Array(D_CODES$1);\nzero$1(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n  this.static_tree  = static_tree;  /* static tree or NULL */\n  this.extra_bits   = extra_bits;   /* extra bits for each code or NULL */\n  this.extra_base   = extra_base;   /* base index for extra_bits */\n  this.elems        = elems;        /* max number of elements in the tree */\n  this.max_length   = max_length;   /* max bit length for the codes */\n\n  // show if `static_tree` has data or dummy - needed for monomorphic objects\n  this.has_stree    = static_tree && static_tree.length;\n}\n\n\nlet static_l_desc;\nlet static_d_desc;\nlet static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n  this.dyn_tree = dyn_tree;     /* the dynamic tree */\n  this.max_code = 0;            /* largest code with non zero frequency */\n  this.stat_desc = stat_desc;   /* the corresponding static tree */\n}\n\n\n\nconst d_code = (dist) => {\n\n  return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n};\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nconst put_short = (s, w) => {\n//    put_byte(s, (uch)((w) & 0xff));\n//    put_byte(s, (uch)((ush)(w) >> 8));\n  s.pending_buf[s.pending++] = (w) & 0xff;\n  s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n};\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nconst send_bits = (s, value, length) => {\n\n  if (s.bi_valid > (Buf_size - length)) {\n    s.bi_buf |= (value << s.bi_valid) & 0xffff;\n    put_short(s, s.bi_buf);\n    s.bi_buf = value >> (Buf_size - s.bi_valid);\n    s.bi_valid += length - Buf_size;\n  } else {\n    s.bi_buf |= (value << s.bi_valid) & 0xffff;\n    s.bi_valid += length;\n  }\n};\n\n\nconst send_code = (s, c, tree) => {\n\n  send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n};\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nconst bi_reverse = (code, len) => {\n\n  let res = 0;\n  do {\n    res |= code & 1;\n    code >>>= 1;\n    res <<= 1;\n  } while (--len > 0);\n  return res >>> 1;\n};\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nconst bi_flush = (s) => {\n\n  if (s.bi_valid === 16) {\n    put_short(s, s.bi_buf);\n    s.bi_buf = 0;\n    s.bi_valid = 0;\n\n  } else if (s.bi_valid >= 8) {\n    s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n    s.bi_buf >>= 8;\n    s.bi_valid -= 8;\n  }\n};\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n *    above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n *     array bl_count contains the frequencies for each bit length.\n *     The length opt_len is updated; static_len is also updated if stree is\n *     not null.\n */\nconst gen_bitlen = (s, desc) =>\n//    deflate_state *s;\n//    tree_desc *desc;    /* the tree descriptor */\n{\n  const tree            = desc.dyn_tree;\n  const max_code        = desc.max_code;\n  const stree           = desc.stat_desc.static_tree;\n  const has_stree       = desc.stat_desc.has_stree;\n  const extra           = desc.stat_desc.extra_bits;\n  const base            = desc.stat_desc.extra_base;\n  const max_length      = desc.stat_desc.max_length;\n  let h;              /* heap index */\n  let n, m;           /* iterate over the tree elements */\n  let bits;           /* bit length */\n  let xbits;          /* extra bits */\n  let f;              /* frequency */\n  let overflow = 0;   /* number of elements with bit length too large */\n\n  for (bits = 0; bits <= MAX_BITS$1; bits++) {\n    s.bl_count[bits] = 0;\n  }\n\n  /* In a first pass, compute the optimal bit lengths (which may\n   * overflow in the case of the bit length tree).\n   */\n  tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n  for (h = s.heap_max + 1; h < HEAP_SIZE$1; h++) {\n    n = s.heap[h];\n    bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n    if (bits > max_length) {\n      bits = max_length;\n      overflow++;\n    }\n    tree[n * 2 + 1]/*.Len*/ = bits;\n    /* We overwrite tree[n].Dad which is no longer needed */\n\n    if (n > max_code) { continue; } /* not a leaf node */\n\n    s.bl_count[bits]++;\n    xbits = 0;\n    if (n >= base) {\n      xbits = extra[n - base];\n    }\n    f = tree[n * 2]/*.Freq*/;\n    s.opt_len += f * (bits + xbits);\n    if (has_stree) {\n      s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n    }\n  }\n  if (overflow === 0) { return; }\n\n  // Trace((stderr,\"\\nbit length overflow\\n\"));\n  /* This happens for example on obj2 and pic of the Calgary corpus */\n\n  /* Find the first bit length which could increase: */\n  do {\n    bits = max_length - 1;\n    while (s.bl_count[bits] === 0) { bits--; }\n    s.bl_count[bits]--;      /* move one leaf down the tree */\n    s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n    s.bl_count[max_length]--;\n    /* The brother of the overflow item also moves one step up,\n     * but this does not affect bl_count[max_length]\n     */\n    overflow -= 2;\n  } while (overflow > 0);\n\n  /* Now recompute all bit lengths, scanning in increasing frequency.\n   * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n   * lengths instead of fixing only the wrong ones. This idea is taken\n   * from 'ar' written by Haruhiko Okumura.)\n   */\n  for (bits = max_length; bits !== 0; bits--) {\n    n = s.bl_count[bits];\n    while (n !== 0) {\n      m = s.heap[--h];\n      if (m > max_code) { continue; }\n      if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n        // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n        s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n        tree[m * 2 + 1]/*.Len*/ = bits;\n      }\n      n--;\n    }\n  }\n};\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n *     zero code length.\n */\nconst gen_codes = (tree, max_code, bl_count) =>\n//    ct_data *tree;             /* the tree to decorate */\n//    int max_code;              /* largest code with non zero frequency */\n//    ushf *bl_count;            /* number of codes at each bit length */\n{\n  const next_code = new Array(MAX_BITS$1 + 1); /* next code value for each bit length */\n  let code = 0;              /* running code value */\n  let bits;                  /* bit index */\n  let n;                     /* code index */\n\n  /* The distribution counts are first used to generate the code values\n   * without bit reversal.\n   */\n  for (bits = 1; bits <= MAX_BITS$1; bits++) {\n    next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n  }\n  /* Check that the bit counts in bl_count are consistent. The last code\n   * must be all ones.\n   */\n  //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n  //        \"inconsistent bit counts\");\n  //Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n\n  for (n = 0;  n <= max_code; n++) {\n    let len = tree[n * 2 + 1]/*.Len*/;\n    if (len === 0) { continue; }\n    /* Now reverse the bits */\n    tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len);\n\n    //Tracecv(tree != static_ltree, (stderr,\"\\nn %3d %c l %2d c %4x (%x) \",\n    //     n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));\n  }\n};\n\n\n/* ===========================================================================\n * Initialize the various 'constant' tables.\n */\nconst tr_static_init = () => {\n\n  let n;        /* iterates over tree elements */\n  let bits;     /* bit counter */\n  let length;   /* length value */\n  let code;     /* code value */\n  let dist;     /* distance index */\n  const bl_count = new Array(MAX_BITS$1 + 1);\n  /* number of codes at each bit length for an optimal tree */\n\n  // do check in _tr_init()\n  //if (static_init_done) return;\n\n  /* For some embedded targets, global variables are not initialized: */\n/*#ifdef NO_INIT_GLOBAL_POINTERS\n  static_l_desc.static_tree = static_ltree;\n  static_l_desc.extra_bits = extra_lbits;\n  static_d_desc.static_tree = static_dtree;\n  static_d_desc.extra_bits = extra_dbits;\n  static_bl_desc.extra_bits = extra_blbits;\n#endif*/\n\n  /* Initialize the mapping length (0..255) -> length code (0..28) */\n  length = 0;\n  for (code = 0; code < LENGTH_CODES$1 - 1; code++) {\n    base_length[code] = length;\n    for (n = 0; n < (1 << extra_lbits[code]); n++) {\n      _length_code[length++] = code;\n    }\n  }\n  //Assert (length == 256, \"tr_static_init: length != 256\");\n  /* Note that the length 255 (match length 258) can be represented\n   * in two different ways: code 284 + 5 bits or code 285, so we\n   * overwrite length_code[255] to use the best encoding:\n   */\n  _length_code[length - 1] = code;\n\n  /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n  dist = 0;\n  for (code = 0; code < 16; code++) {\n    base_dist[code] = dist;\n    for (n = 0; n < (1 << extra_dbits[code]); n++) {\n      _dist_code[dist++] = code;\n    }\n  }\n  //Assert (dist == 256, \"tr_static_init: dist != 256\");\n  dist >>= 7; /* from now on, all distances are divided by 128 */\n  for (; code < D_CODES$1; code++) {\n    base_dist[code] = dist << 7;\n    for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n      _dist_code[256 + dist++] = code;\n    }\n  }\n  //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n  /* Construct the codes of the static literal tree */\n  for (bits = 0; bits <= MAX_BITS$1; bits++) {\n    bl_count[bits] = 0;\n  }\n\n  n = 0;\n  while (n <= 143) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 8;\n    n++;\n    bl_count[8]++;\n  }\n  while (n <= 255) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 9;\n    n++;\n    bl_count[9]++;\n  }\n  while (n <= 279) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 7;\n    n++;\n    bl_count[7]++;\n  }\n  while (n <= 287) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 8;\n    n++;\n    bl_count[8]++;\n  }\n  /* Codes 286 and 287 do not exist, but we must include them in the\n   * tree construction to get a canonical Huffman tree (longest code\n   * all ones)\n   */\n  gen_codes(static_ltree, L_CODES$1 + 1, bl_count);\n\n  /* The static distance tree is trivial: */\n  for (n = 0; n < D_CODES$1; n++) {\n    static_dtree[n * 2 + 1]/*.Len*/ = 5;\n    static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n  }\n\n  // Now data ready and we can init static trees\n  static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS$1 + 1, L_CODES$1, MAX_BITS$1);\n  static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0,          D_CODES$1, MAX_BITS$1);\n  static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0,         BL_CODES$1, MAX_BL_BITS);\n\n  //static_init_done = true;\n};\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nconst init_block = (s) => {\n\n  let n; /* iterates over tree elements */\n\n  /* Initialize the trees. */\n  for (n = 0; n < L_CODES$1;  n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n  for (n = 0; n < D_CODES$1;  n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n  for (n = 0; n < BL_CODES$1; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n  s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n  s.opt_len = s.static_len = 0;\n  s.last_lit = s.matches = 0;\n};\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nconst bi_windup = (s) =>\n{\n  if (s.bi_valid > 8) {\n    put_short(s, s.bi_buf);\n  } else if (s.bi_valid > 0) {\n    //put_byte(s, (Byte)s->bi_buf);\n    s.pending_buf[s.pending++] = s.bi_buf;\n  }\n  s.bi_buf = 0;\n  s.bi_valid = 0;\n};\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nconst copy_block = (s, buf, len, header) =>\n//DeflateState *s;\n//charf    *buf;    /* the input data */\n//unsigned len;     /* its length */\n//int      header;  /* true if block header must be written */\n{\n  bi_windup(s);        /* align on byte boundary */\n\n  if (header) {\n    put_short(s, len);\n    put_short(s, ~len);\n  }\n//  while (len--) {\n//    put_byte(s, *buf++);\n//  }\n  s.pending_buf.set(s.window.subarray(buf, buf + len), s.pending);\n  s.pending += len;\n};\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nconst smaller = (tree, n, m, depth) => {\n\n  const _n2 = n * 2;\n  const _m2 = m * 2;\n  return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n         (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n};\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nconst pqdownheap = (s, tree, k) =>\n//    deflate_state *s;\n//    ct_data *tree;  /* the tree to restore */\n//    int k;               /* node to move down */\n{\n  const v = s.heap[k];\n  let j = k << 1;  /* left son of k */\n  while (j <= s.heap_len) {\n    /* Set j to the smallest of the two sons: */\n    if (j < s.heap_len &&\n      smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n      j++;\n    }\n    /* Exit if v is smaller than both sons */\n    if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n    /* Exchange v with the smallest son */\n    s.heap[k] = s.heap[j];\n    k = j;\n\n    /* And continue down the tree, setting j to the left son of k */\n    j <<= 1;\n  }\n  s.heap[k] = v;\n};\n\n\n// inlined manually\n// const SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nconst compress_block = (s, ltree, dtree) =>\n//    deflate_state *s;\n//    const ct_data *ltree; /* literal tree */\n//    const ct_data *dtree; /* distance tree */\n{\n  let dist;           /* distance of matched string */\n  let lc;             /* match length or unmatched char (if dist == 0) */\n  let lx = 0;         /* running index in l_buf */\n  let code;           /* the code to send */\n  let extra;          /* number of extra bits to send */\n\n  if (s.last_lit !== 0) {\n    do {\n      dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n      lc = s.pending_buf[s.l_buf + lx];\n      lx++;\n\n      if (dist === 0) {\n        send_code(s, lc, ltree); /* send a literal byte */\n        //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n      } else {\n        /* Here, lc is the match length - MIN_MATCH */\n        code = _length_code[lc];\n        send_code(s, code + LITERALS$1 + 1, ltree); /* send the length code */\n        extra = extra_lbits[code];\n        if (extra !== 0) {\n          lc -= base_length[code];\n          send_bits(s, lc, extra);       /* send the extra length bits */\n        }\n        dist--; /* dist is now the match distance - 1 */\n        code = d_code(dist);\n        //Assert (code < D_CODES, \"bad d_code\");\n\n        send_code(s, code, dtree);       /* send the distance code */\n        extra = extra_dbits[code];\n        if (extra !== 0) {\n          dist -= base_dist[code];\n          send_bits(s, dist, extra);   /* send the extra distance bits */\n        }\n      } /* literal or match pair ? */\n\n      /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n      //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n      //       \"pendingBuf overflow\");\n\n    } while (lx < s.last_lit);\n  }\n\n  send_code(s, END_BLOCK, ltree);\n};\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n *     and corresponding code. The length opt_len is updated; static_len is\n *     also updated if stree is not null. The field max_code is set.\n */\nconst build_tree = (s, desc) =>\n//    deflate_state *s;\n//    tree_desc *desc; /* the tree descriptor */\n{\n  const tree     = desc.dyn_tree;\n  const stree    = desc.stat_desc.static_tree;\n  const has_stree = desc.stat_desc.has_stree;\n  const elems    = desc.stat_desc.elems;\n  let n, m;          /* iterate over heap elements */\n  let max_code = -1; /* largest code with non zero frequency */\n  let node;          /* new node being created */\n\n  /* Construct the initial heap, with least frequent element in\n   * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n   * heap[0] is not used.\n   */\n  s.heap_len = 0;\n  s.heap_max = HEAP_SIZE$1;\n\n  for (n = 0; n < elems; n++) {\n    if (tree[n * 2]/*.Freq*/ !== 0) {\n      s.heap[++s.heap_len] = max_code = n;\n      s.depth[n] = 0;\n\n    } else {\n      tree[n * 2 + 1]/*.Len*/ = 0;\n    }\n  }\n\n  /* The pkzip format requires that at least one distance code exists,\n   * and that at least one bit should be sent even if there is only one\n   * possible code. So to avoid special checks later on we force at least\n   * two codes of non zero frequency.\n   */\n  while (s.heap_len < 2) {\n    node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n    tree[node * 2]/*.Freq*/ = 1;\n    s.depth[node] = 0;\n    s.opt_len--;\n\n    if (has_stree) {\n      s.static_len -= stree[node * 2 + 1]/*.Len*/;\n    }\n    /* node is 0 or 1 so it does not have extra bits */\n  }\n  desc.max_code = max_code;\n\n  /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n   * establish sub-heaps of increasing lengths:\n   */\n  for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n  /* Construct the Huffman tree by repeatedly combining the least two\n   * frequent nodes.\n   */\n  node = elems;              /* next internal node of the tree */\n  do {\n    //pqremove(s, tree, n);  /* n = node of least frequency */\n    /*** pqremove ***/\n    n = s.heap[1/*SMALLEST*/];\n    s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n    pqdownheap(s, tree, 1/*SMALLEST*/);\n    /***/\n\n    m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n    s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n    s.heap[--s.heap_max] = m;\n\n    /* Create a new node father of n and m */\n    tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n    s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n    tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n    /* and insert the new node in the heap */\n    s.heap[1/*SMALLEST*/] = node++;\n    pqdownheap(s, tree, 1/*SMALLEST*/);\n\n  } while (s.heap_len >= 2);\n\n  s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n  /* At this point, the fields freq and dad are set. We can now\n   * generate the bit lengths.\n   */\n  gen_bitlen(s, desc);\n\n  /* The field len is now set, we can generate the bit codes */\n  gen_codes(tree, max_code, s.bl_count);\n};\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nconst scan_tree = (s, tree, max_code) =>\n//    deflate_state *s;\n//    ct_data *tree;   /* the tree to be scanned */\n//    int max_code;    /* and its largest code of non zero frequency */\n{\n  let n;                     /* iterates over all tree elements */\n  let prevlen = -1;          /* last emitted length */\n  let curlen;                /* length of current code */\n\n  let nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n  let count = 0;             /* repeat count of the current code */\n  let max_count = 7;         /* max repeat count */\n  let min_count = 4;         /* min repeat count */\n\n  if (nextlen === 0) {\n    max_count = 138;\n    min_count = 3;\n  }\n  tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n  for (n = 0; n <= max_code; n++) {\n    curlen = nextlen;\n    nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n    if (++count < max_count && curlen === nextlen) {\n      continue;\n\n    } else if (count < min_count) {\n      s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n    } else if (curlen !== 0) {\n\n      if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n      s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n    } else if (count <= 10) {\n      s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n    } else {\n      s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n    }\n\n    count = 0;\n    prevlen = curlen;\n\n    if (nextlen === 0) {\n      max_count = 138;\n      min_count = 3;\n\n    } else if (curlen === nextlen) {\n      max_count = 6;\n      min_count = 3;\n\n    } else {\n      max_count = 7;\n      min_count = 4;\n    }\n  }\n};\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nconst send_tree = (s, tree, max_code) =>\n//    deflate_state *s;\n//    ct_data *tree; /* the tree to be scanned */\n//    int max_code;       /* and its largest code of non zero frequency */\n{\n  let n;                     /* iterates over all tree elements */\n  let prevlen = -1;          /* last emitted length */\n  let curlen;                /* length of current code */\n\n  let nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n  let count = 0;             /* repeat count of the current code */\n  let max_count = 7;         /* max repeat count */\n  let min_count = 4;         /* min repeat count */\n\n  /* tree[max_code+1].Len = -1; */  /* guard already set */\n  if (nextlen === 0) {\n    max_count = 138;\n    min_count = 3;\n  }\n\n  for (n = 0; n <= max_code; n++) {\n    curlen = nextlen;\n    nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n    if (++count < max_count && curlen === nextlen) {\n      continue;\n\n    } else if (count < min_count) {\n      do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n    } else if (curlen !== 0) {\n      if (curlen !== prevlen) {\n        send_code(s, curlen, s.bl_tree);\n        count--;\n      }\n      //Assert(count >= 3 && count <= 6, \" 3_6?\");\n      send_code(s, REP_3_6, s.bl_tree);\n      send_bits(s, count - 3, 2);\n\n    } else if (count <= 10) {\n      send_code(s, REPZ_3_10, s.bl_tree);\n      send_bits(s, count - 3, 3);\n\n    } else {\n      send_code(s, REPZ_11_138, s.bl_tree);\n      send_bits(s, count - 11, 7);\n    }\n\n    count = 0;\n    prevlen = curlen;\n    if (nextlen === 0) {\n      max_count = 138;\n      min_count = 3;\n\n    } else if (curlen === nextlen) {\n      max_count = 6;\n      min_count = 3;\n\n    } else {\n      max_count = 7;\n      min_count = 4;\n    }\n  }\n};\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nconst build_bl_tree = (s) => {\n\n  let max_blindex;  /* index of last bit length code of non zero freq */\n\n  /* Determine the bit length frequencies for literal and distance trees */\n  scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n  scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n  /* Build the bit length tree: */\n  build_tree(s, s.bl_desc);\n  /* opt_len now includes the length of the tree representations, except\n   * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n   */\n\n  /* Determine the number of bit length codes to send. The pkzip format\n   * requires that at least 4 bit length codes be sent. (appnote.txt says\n   * 3 but the actual value used is 4.)\n   */\n  for (max_blindex = BL_CODES$1 - 1; max_blindex >= 3; max_blindex--) {\n    if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n      break;\n    }\n  }\n  /* Update opt_len to include the bit length tree and counts */\n  s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n  //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n  //        s->opt_len, s->static_len));\n\n  return max_blindex;\n};\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nconst send_all_trees = (s, lcodes, dcodes, blcodes) =>\n//    deflate_state *s;\n//    int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n  let rank;                    /* index in bl_order */\n\n  //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n  //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n  //        \"too many codes\");\n  //Tracev((stderr, \"\\nbl counts: \"));\n  send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n  send_bits(s, dcodes - 1,   5);\n  send_bits(s, blcodes - 4,  4); /* not -3 as stated in appnote.txt */\n  for (rank = 0; rank < blcodes; rank++) {\n    //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n    send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n  }\n  //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n  send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n  //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n  send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n  //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n};\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n *    a) There are no non-portable control characters belonging to the\n *       \"black list\" (0..6, 14..25, 28..31).\n *    b) There is at least one printable character belonging to the\n *       \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n *   \"gray list\" that is ignored in this detection algorithm:\n *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nconst detect_data_type = (s) => {\n  /* black_mask is the bit mask of black-listed bytes\n   * set bits 0..6, 14..25, and 28..31\n   * 0xf3ffc07f = binary 11110011111111111100000001111111\n   */\n  let black_mask = 0xf3ffc07f;\n  let n;\n\n  /* Check for non-textual (\"black-listed\") bytes. */\n  for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n    if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n      return Z_BINARY;\n    }\n  }\n\n  /* Check for textual (\"white-listed\") bytes. */\n  if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n      s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n    return Z_TEXT;\n  }\n  for (n = 32; n < LITERALS$1; n++) {\n    if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n      return Z_TEXT;\n    }\n  }\n\n  /* There are no \"black-listed\" or \"white-listed\" bytes:\n   * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n   */\n  return Z_BINARY;\n};\n\n\nlet static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nconst _tr_init$1 = (s) =>\n{\n\n  if (!static_init_done) {\n    tr_static_init();\n    static_init_done = true;\n  }\n\n  s.l_desc  = new TreeDesc(s.dyn_ltree, static_l_desc);\n  s.d_desc  = new TreeDesc(s.dyn_dtree, static_d_desc);\n  s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n  s.bi_buf = 0;\n  s.bi_valid = 0;\n\n  /* Initialize the first block of the first file: */\n  init_block(s);\n};\n\n\n/* ===========================================================================\n * Send a stored block\n */\nconst _tr_stored_block$1 = (s, buf, stored_len, last) =>\n//DeflateState *s;\n//charf *buf;       /* input block */\n//ulg stored_len;   /* length of input block */\n//int last;         /* one if this is the last block for a file */\n{\n  send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);    /* send block type */\n  copy_block(s, buf, stored_len, true); /* with header */\n};\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nconst _tr_align$1 = (s) => {\n  send_bits(s, STATIC_TREES << 1, 3);\n  send_code(s, END_BLOCK, static_ltree);\n  bi_flush(s);\n};\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nconst _tr_flush_block$1 = (s, buf, stored_len, last) =>\n//DeflateState *s;\n//charf *buf;       /* input block, or NULL if too old */\n//ulg stored_len;   /* length of input block */\n//int last;         /* one if this is the last block for a file */\n{\n  let opt_lenb, static_lenb;  /* opt_len and static_len in bytes */\n  let max_blindex = 0;        /* index of last bit length code of non zero freq */\n\n  /* Build the Huffman trees unless a stored block is forced */\n  if (s.level > 0) {\n\n    /* Check if the file is binary or text */\n    if (s.strm.data_type === Z_UNKNOWN$1) {\n      s.strm.data_type = detect_data_type(s);\n    }\n\n    /* Construct the literal and distance trees */\n    build_tree(s, s.l_desc);\n    // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n    //        s->static_len));\n\n    build_tree(s, s.d_desc);\n    // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n    //        s->static_len));\n    /* At this point, opt_len and static_len are the total bit lengths of\n     * the compressed block data, excluding the tree representations.\n     */\n\n    /* Build the bit length tree for the above two trees, and get the index\n     * in bl_order of the last bit length code to send.\n     */\n    max_blindex = build_bl_tree(s);\n\n    /* Determine the best encoding. Compute the block lengths in bytes. */\n    opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n    static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n    // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n    //        opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n    //        s->last_lit));\n\n    if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n  } else {\n    // Assert(buf != (char*)0, \"lost buf\");\n    opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n  }\n\n  if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n    /* 4: two words for the lengths */\n\n    /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n     * Otherwise we can't have processed more than WSIZE input bytes since\n     * the last block flush, because compression would have been\n     * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n     * transform a block into a stored block.\n     */\n    _tr_stored_block$1(s, buf, stored_len, last);\n\n  } else if (s.strategy === Z_FIXED$1 || static_lenb === opt_lenb) {\n\n    send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n    compress_block(s, static_ltree, static_dtree);\n\n  } else {\n    send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n    send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n    compress_block(s, s.dyn_ltree, s.dyn_dtree);\n  }\n  // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n  /* The above check is made mod 2^32, for files larger than 512 MB\n   * and uLong implemented on 32 bits.\n   */\n  init_block(s);\n\n  if (last) {\n    bi_windup(s);\n  }\n  // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n  //       s->compressed_len-7*last));\n};\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nconst _tr_tally$1 = (s, dist, lc) =>\n//    deflate_state *s;\n//    unsigned dist;  /* distance of matched string */\n//    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n  //let out_length, in_length, dcode;\n\n  s.pending_buf[s.d_buf + s.last_lit * 2]     = (dist >>> 8) & 0xff;\n  s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n  s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n  s.last_lit++;\n\n  if (dist === 0) {\n    /* lc is the unmatched char */\n    s.dyn_ltree[lc * 2]/*.Freq*/++;\n  } else {\n    s.matches++;\n    /* Here, lc is the match length - MIN_MATCH */\n    dist--;             /* dist = match distance - 1 */\n    //Assert((ush)dist < (ush)MAX_DIST(s) &&\n    //       (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n    //       (ush)d_code(dist) < (ush)D_CODES,  \"_tr_tally: bad match\");\n\n    s.dyn_ltree[(_length_code[lc] + LITERALS$1 + 1) * 2]/*.Freq*/++;\n    s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n  }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n//  /* Try to guess if it is profitable to stop the current block here */\n//  if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n//    /* Compute an upper bound for the compressed length */\n//    out_length = s.last_lit*8;\n//    in_length = s.strstart - s.block_start;\n//\n//    for (dcode = 0; dcode < D_CODES; dcode++) {\n//      out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n//    }\n//    out_length >>>= 3;\n//    //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n//    //       s->last_lit, in_length, out_length,\n//    //       100L - out_length*100L/in_length));\n//    if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n//      return true;\n//    }\n//  }\n//#endif\n\n  return (s.last_lit === s.lit_bufsize - 1);\n  /* We avoid equality with lit_bufsize because of wraparound at 64K\n   * on 16 bit machines and because stored blocks are restricted to\n   * 64K-1 bytes.\n   */\n};\n\nvar _tr_init_1  = _tr_init$1;\nvar _tr_stored_block_1 = _tr_stored_block$1;\nvar _tr_flush_block_1  = _tr_flush_block$1;\nvar _tr_tally_1 = _tr_tally$1;\nvar _tr_align_1 = _tr_align$1;\n\nvar trees = {\n\t_tr_init: _tr_init_1,\n\t_tr_stored_block: _tr_stored_block_1,\n\t_tr_flush_block: _tr_flush_block_1,\n\t_tr_tally: _tr_tally_1,\n\t_tr_align: _tr_align_1\n};\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It isn't worth it to make additional optimizations as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nconst adler32 = (adler, buf, len, pos) => {\n  let s1 = (adler & 0xffff) |0,\n      s2 = ((adler >>> 16) & 0xffff) |0,\n      n = 0;\n\n  while (len !== 0) {\n    // Set limit ~ twice less than 5552, to keep\n    // s2 in 31-bits, because we force signed ints.\n    // in other case %= will fail.\n    n = len > 2000 ? 2000 : len;\n    len -= n;\n\n    do {\n      s1 = (s1 + buf[pos++]) |0;\n      s2 = (s2 + s1) |0;\n    } while (--n);\n\n    s1 %= 65521;\n    s2 %= 65521;\n  }\n\n  return (s1 | (s2 << 16)) |0;\n};\n\n\nvar adler32_1 = adler32;\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nconst makeTable = () => {\n  let c, table = [];\n\n  for (var n = 0; n < 256; n++) {\n    c = n;\n    for (var k = 0; k < 8; k++) {\n      c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n    }\n    table[n] = c;\n  }\n\n  return table;\n};\n\n// Create table on load. Just 255 signed longs. Not a problem.\nconst crcTable = new Uint32Array(makeTable());\n\n\nconst crc32 = (crc, buf, len, pos) => {\n  const t = crcTable;\n  const end = pos + len;\n\n  crc ^= -1;\n\n  for (let i = pos; i < end; i++) {\n    crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n  }\n\n  return (crc ^ (-1)); // >>> 0;\n};\n\n\nvar crc32_1 = crc32;\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar messages = {\n  2:      'need dictionary',     /* Z_NEED_DICT       2  */\n  1:      'stream end',          /* Z_STREAM_END      1  */\n  0:      '',                    /* Z_OK              0  */\n  '-1':   'file error',          /* Z_ERRNO         (-1) */\n  '-2':   'stream error',        /* Z_STREAM_ERROR  (-2) */\n  '-3':   'data error',          /* Z_DATA_ERROR    (-3) */\n  '-4':   'insufficient memory', /* Z_MEM_ERROR     (-4) */\n  '-5':   'buffer error',        /* Z_BUF_ERROR     (-5) */\n  '-6':   'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar constants$2 = {\n\n  /* Allowed flush values; see deflate() and inflate() below for details */\n  Z_NO_FLUSH:         0,\n  Z_PARTIAL_FLUSH:    1,\n  Z_SYNC_FLUSH:       2,\n  Z_FULL_FLUSH:       3,\n  Z_FINISH:           4,\n  Z_BLOCK:            5,\n  Z_TREES:            6,\n\n  /* Return codes for the compression/decompression functions. Negative values\n  * are errors, positive values are used for special but normal events.\n  */\n  Z_OK:               0,\n  Z_STREAM_END:       1,\n  Z_NEED_DICT:        2,\n  Z_ERRNO:           -1,\n  Z_STREAM_ERROR:    -2,\n  Z_DATA_ERROR:      -3,\n  Z_MEM_ERROR:       -4,\n  Z_BUF_ERROR:       -5,\n  //Z_VERSION_ERROR: -6,\n\n  /* compression levels */\n  Z_NO_COMPRESSION:         0,\n  Z_BEST_SPEED:             1,\n  Z_BEST_COMPRESSION:       9,\n  Z_DEFAULT_COMPRESSION:   -1,\n\n\n  Z_FILTERED:               1,\n  Z_HUFFMAN_ONLY:           2,\n  Z_RLE:                    3,\n  Z_FIXED:                  4,\n  Z_DEFAULT_STRATEGY:       0,\n\n  /* Possible values of the data_type field (though see inflate()) */\n  Z_BINARY:                 0,\n  Z_TEXT:                   1,\n  //Z_ASCII:                1, // = Z_TEXT (deprecated)\n  Z_UNKNOWN:                2,\n\n  /* The deflate compression method */\n  Z_DEFLATED:               8\n  //Z_NULL:                 null // Use -1 or null inline, depending on var type\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nconst { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = trees;\n\n\n\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nconst {\n  Z_NO_FLUSH: Z_NO_FLUSH$2, Z_PARTIAL_FLUSH, Z_FULL_FLUSH: Z_FULL_FLUSH$1, Z_FINISH: Z_FINISH$3, Z_BLOCK: Z_BLOCK$1,\n  Z_OK: Z_OK$3, Z_STREAM_END: Z_STREAM_END$3, Z_STREAM_ERROR: Z_STREAM_ERROR$2, Z_DATA_ERROR: Z_DATA_ERROR$2, Z_BUF_ERROR: Z_BUF_ERROR$1,\n  Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION$1,\n  Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY$1,\n  Z_UNKNOWN,\n  Z_DEFLATED: Z_DEFLATED$2\n} = constants$2;\n\n/*============================================================================*/\n\n\nconst MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nconst MAX_WBITS$1 = 15;\n/* 32K LZ77 window */\nconst DEF_MEM_LEVEL = 8;\n\n\nconst LENGTH_CODES  = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nconst LITERALS      = 256;\n/* number of literal bytes 0..255 */\nconst L_CODES       = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nconst D_CODES       = 30;\n/* number of distance codes */\nconst BL_CODES      = 19;\n/* number of codes used to transfer the bit lengths */\nconst HEAP_SIZE     = 2 * L_CODES + 1;\n/* maximum heap size */\nconst MAX_BITS  = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nconst MIN_MATCH = 3;\nconst MAX_MATCH = 258;\nconst MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nconst PRESET_DICT = 0x20;\n\nconst INIT_STATE = 42;\nconst EXTRA_STATE = 69;\nconst NAME_STATE = 73;\nconst COMMENT_STATE = 91;\nconst HCRC_STATE = 103;\nconst BUSY_STATE = 113;\nconst FINISH_STATE = 666;\n\nconst BS_NEED_MORE      = 1; /* block not completed, need more input or more output */\nconst BS_BLOCK_DONE     = 2; /* block flush performed */\nconst BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nconst BS_FINISH_DONE    = 4; /* finish done, accept no more input or output */\n\nconst OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nconst err = (strm, errorCode) => {\n  strm.msg = messages[errorCode];\n  return errorCode;\n};\n\nconst rank = (f) => {\n  return ((f) << 1) - ((f) > 4 ? 9 : 0);\n};\n\nconst zero = (buf) => {\n  let len = buf.length; while (--len >= 0) { buf[len] = 0; }\n};\n\n\n/* eslint-disable new-cap */\nlet HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask;\n// This hash causes less collisions, https://github.com/nodeca/pako/issues/135\n// But breaks binary compatibility\n//let HASH_FAST = (s, prev, data) => ((prev << 8) + (prev >> 8) + (data << 4)) & s.hash_mask;\nlet HASH = HASH_ZLIB;\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nconst flush_pending = (strm) => {\n  const s = strm.state;\n\n  //_tr_flush_bits(s);\n  let len = s.pending;\n  if (len > strm.avail_out) {\n    len = strm.avail_out;\n  }\n  if (len === 0) { return; }\n\n  strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n  strm.next_out += len;\n  s.pending_out += len;\n  strm.total_out += len;\n  strm.avail_out -= len;\n  s.pending -= len;\n  if (s.pending === 0) {\n    s.pending_out = 0;\n  }\n};\n\n\nconst flush_block_only = (s, last) => {\n  _tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n  s.block_start = s.strstart;\n  flush_pending(s.strm);\n};\n\n\nconst put_byte = (s, b) => {\n  s.pending_buf[s.pending++] = b;\n};\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nconst putShortMSB = (s, b) => {\n\n  //  put_byte(s, (Byte)(b >> 8));\n//  put_byte(s, (Byte)(b & 0xff));\n  s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n  s.pending_buf[s.pending++] = b & 0xff;\n};\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read.  All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nconst read_buf = (strm, buf, start, size) => {\n\n  let len = strm.avail_in;\n\n  if (len > size) { len = size; }\n  if (len === 0) { return 0; }\n\n  strm.avail_in -= len;\n\n  // zmemcpy(buf, strm->next_in, len);\n  buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n  if (strm.state.wrap === 1) {\n    strm.adler = adler32_1(strm.adler, buf, len, start);\n  }\n\n  else if (strm.state.wrap === 2) {\n    strm.adler = crc32_1(strm.adler, buf, len, start);\n  }\n\n  strm.next_in += len;\n  strm.total_in += len;\n\n  return len;\n};\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nconst longest_match = (s, cur_match) => {\n\n  let chain_length = s.max_chain_length;      /* max hash chain length */\n  let scan = s.strstart; /* current string */\n  let match;                       /* matched string */\n  let len;                           /* length of current match */\n  let best_len = s.prev_length;              /* best match length so far */\n  let nice_match = s.nice_match;             /* stop if match long enough */\n  const limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n      s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n  const _win = s.window; // shortcut\n\n  const wmask = s.w_mask;\n  const prev  = s.prev;\n\n  /* Stop when cur_match becomes <= limit. To simplify the code,\n   * we prevent matches with the string of window index 0.\n   */\n\n  const strend = s.strstart + MAX_MATCH;\n  let scan_end1  = _win[scan + best_len - 1];\n  let scan_end   = _win[scan + best_len];\n\n  /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n   * It is easy to get rid of this optimization if necessary.\n   */\n  // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n  /* Do not waste too much time if we already have a good match: */\n  if (s.prev_length >= s.good_match) {\n    chain_length >>= 2;\n  }\n  /* Do not look for matches beyond the end of the input. This is necessary\n   * to make deflate deterministic.\n   */\n  if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n  // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n  do {\n    // Assert(cur_match < s->strstart, \"no future\");\n    match = cur_match;\n\n    /* Skip to next match if the match length cannot increase\n     * or if the match length is less than 2.  Note that the checks below\n     * for insufficient lookahead only occur occasionally for performance\n     * reasons.  Therefore uninitialized memory will be accessed, and\n     * conditional jumps will be made that depend on those values.\n     * However the length of the match is limited to the lookahead, so\n     * the output of deflate is not affected by the uninitialized values.\n     */\n\n    if (_win[match + best_len]     !== scan_end  ||\n        _win[match + best_len - 1] !== scan_end1 ||\n        _win[match]                !== _win[scan] ||\n        _win[++match]              !== _win[scan + 1]) {\n      continue;\n    }\n\n    /* The check at best_len-1 can be removed because it will be made\n     * again later. (This heuristic is not always a win.)\n     * It is not necessary to compare scan[2] and match[2] since they\n     * are always equal when the other bytes match, given that\n     * the hash keys are equal and that HASH_BITS >= 8.\n     */\n    scan += 2;\n    match++;\n    // Assert(*scan == *match, \"match[2]?\");\n\n    /* We check for insufficient lookahead only every 8th comparison;\n     * the 256th check will be made at strstart+258.\n     */\n    do {\n      /*jshint noempty:false*/\n    } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             scan < strend);\n\n    // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n    len = MAX_MATCH - (strend - scan);\n    scan = strend - MAX_MATCH;\n\n    if (len > best_len) {\n      s.match_start = cur_match;\n      best_len = len;\n      if (len >= nice_match) {\n        break;\n      }\n      scan_end1  = _win[scan + best_len - 1];\n      scan_end   = _win[scan + best_len];\n    }\n  } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n  if (best_len <= s.lookahead) {\n    return best_len;\n  }\n  return s.lookahead;\n};\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n *    At least one byte has been read, or avail_in == 0; reads are\n *    performed for at least two bytes (required for the zip translate_eol\n *    option -- not supported here).\n */\nconst fill_window = (s) => {\n\n  const _w_size = s.w_size;\n  let p, n, m, more, str;\n\n  //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n  do {\n    more = s.window_size - s.lookahead - s.strstart;\n\n    // JS ints have 32 bit, block below not needed\n    /* Deal with !@#$% 64K limit: */\n    //if (sizeof(int) <= 2) {\n    //    if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n    //        more = wsize;\n    //\n    //  } else if (more == (unsigned)(-1)) {\n    //        /* Very unlikely, but possible on 16 bit machine if\n    //         * strstart == 0 && lookahead == 1 (input done a byte at time)\n    //         */\n    //        more--;\n    //    }\n    //}\n\n\n    /* If the window is almost full and there is insufficient lookahead,\n     * move the upper half to the lower one to make room in the upper half.\n     */\n    if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n      s.window.set(s.window.subarray(_w_size, _w_size + _w_size), 0);\n      s.match_start -= _w_size;\n      s.strstart -= _w_size;\n      /* we now have strstart >= MAX_DIST */\n      s.block_start -= _w_size;\n\n      /* Slide the hash table (could be avoided with 32 bit values\n       at the expense of memory usage). We slide even when level == 0\n       to keep the hash table consistent if we switch back to level > 0\n       later. (Using level 0 permanently is not an optimal usage of\n       zlib, so we don't care about this pathological case.)\n       */\n\n      n = s.hash_size;\n      p = n;\n\n      do {\n        m = s.head[--p];\n        s.head[p] = (m >= _w_size ? m - _w_size : 0);\n      } while (--n);\n\n      n = _w_size;\n      p = n;\n\n      do {\n        m = s.prev[--p];\n        s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n        /* If n is not on any hash chain, prev[n] is garbage but\n         * its value will never be used.\n         */\n      } while (--n);\n\n      more += _w_size;\n    }\n    if (s.strm.avail_in === 0) {\n      break;\n    }\n\n    /* If there was no sliding:\n     *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n     *    more == window_size - lookahead - strstart\n     * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n     * => more >= window_size - 2*WSIZE + 2\n     * In the BIG_MEM or MMAP case (not yet supported),\n     *   window_size == input_size + MIN_LOOKAHEAD  &&\n     *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n     * Otherwise, window_size == 2*WSIZE so more >= 2.\n     * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n     */\n    //Assert(more >= 2, \"more < 2\");\n    n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n    s.lookahead += n;\n\n    /* Initialize the hash value now that we have some input: */\n    if (s.lookahead + s.insert >= MIN_MATCH) {\n      str = s.strstart - s.insert;\n      s.ins_h = s.window[str];\n\n      /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n      s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n//#if MIN_MATCH != 3\n//        Call update_hash() MIN_MATCH-3 more times\n//#endif\n      while (s.insert) {\n        /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n        s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n\n        s.prev[str & s.w_mask] = s.head[s.ins_h];\n        s.head[s.ins_h] = str;\n        str++;\n        s.insert--;\n        if (s.lookahead + s.insert < MIN_MATCH) {\n          break;\n        }\n      }\n    }\n    /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n     * but this is not important since only literal bytes will be emitted.\n     */\n\n  } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n  /* If the WIN_INIT bytes after the end of the current data have never been\n   * written, then zero those bytes in order to avoid memory check reports of\n   * the use of uninitialized (or uninitialised as Julian writes) bytes by\n   * the longest match routines.  Update the high water mark for the next\n   * time through here.  WIN_INIT is set to MAX_MATCH since the longest match\n   * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n   */\n//  if (s.high_water < s.window_size) {\n//    const curr = s.strstart + s.lookahead;\n//    let init = 0;\n//\n//    if (s.high_water < curr) {\n//      /* Previous high water mark below current data -- zero WIN_INIT\n//       * bytes or up to end of window, whichever is less.\n//       */\n//      init = s.window_size - curr;\n//      if (init > WIN_INIT)\n//        init = WIN_INIT;\n//      zmemzero(s->window + curr, (unsigned)init);\n//      s->high_water = curr + init;\n//    }\n//    else if (s->high_water < (ulg)curr + WIN_INIT) {\n//      /* High water mark at or above current data, but below current data\n//       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n//       * to end of window, whichever is less.\n//       */\n//      init = (ulg)curr + WIN_INIT - s->high_water;\n//      if (init > s->window_size - s->high_water)\n//        init = s->window_size - s->high_water;\n//      zmemzero(s->window + s->high_water, (unsigned)init);\n//      s->high_water += init;\n//    }\n//  }\n//\n//  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n//    \"not enough room for search\");\n};\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nconst deflate_stored = (s, flush) => {\n\n  /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n   * to pending_buf_size, and each stored block has a 5 byte header:\n   */\n  let max_block_size = 0xffff;\n\n  if (max_block_size > s.pending_buf_size - 5) {\n    max_block_size = s.pending_buf_size - 5;\n  }\n\n  /* Copy as much as possible from input to output: */\n  for (;;) {\n    /* Fill the window as much as possible: */\n    if (s.lookahead <= 1) {\n\n      //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n      //  s->block_start >= (long)s->w_size, \"slide too late\");\n//      if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n//        s.block_start >= s.w_size)) {\n//        throw  new Error(\"slide too late\");\n//      }\n\n      fill_window(s);\n      if (s.lookahead === 0 && flush === Z_NO_FLUSH$2) {\n        return BS_NEED_MORE;\n      }\n\n      if (s.lookahead === 0) {\n        break;\n      }\n      /* flush the current block */\n    }\n    //Assert(s->block_start >= 0L, \"block gone\");\n//    if (s.block_start < 0) throw new Error(\"block gone\");\n\n    s.strstart += s.lookahead;\n    s.lookahead = 0;\n\n    /* Emit a stored block if pending_buf will be full: */\n    const max_start = s.block_start + max_block_size;\n\n    if (s.strstart === 0 || s.strstart >= max_start) {\n      /* strstart == 0 is possible when wraparound on 16-bit machine */\n      s.lookahead = s.strstart - max_start;\n      s.strstart = max_start;\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n\n\n    }\n    /* Flush if we may have to slide, otherwise block_start may become\n     * negative and the data will be gone:\n     */\n    if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n\n  s.insert = 0;\n\n  if (flush === Z_FINISH$3) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n\n  if (s.strstart > s.block_start) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n\n  return BS_NEED_MORE;\n};\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nconst deflate_fast = (s, flush) => {\n\n  let hash_head;        /* head of the hash chain */\n  let bflush;           /* set if current block must be flushed */\n\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the next match, plus MIN_MATCH bytes to insert the\n     * string following the next match.\n     */\n    if (s.lookahead < MIN_LOOKAHEAD) {\n      fill_window(s);\n      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) {\n        break; /* flush the current block */\n      }\n    }\n\n    /* Insert the string window[strstart .. strstart+2] in the\n     * dictionary, and set hash_head to the head of the hash chain:\n     */\n    hash_head = 0/*NIL*/;\n    if (s.lookahead >= MIN_MATCH) {\n      /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n      s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n      s.head[s.ins_h] = s.strstart;\n      /***/\n    }\n\n    /* Find the longest match, discarding those <= prev_length.\n     * At this point we have always match_length < MIN_MATCH\n     */\n    if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n      /* To simplify the code, we prevent matches with the string\n       * of window index 0 (in particular we have to avoid a match\n       * of the string with itself at the start of the input file).\n       */\n      s.match_length = longest_match(s, hash_head);\n      /* longest_match() sets match_start */\n    }\n    if (s.match_length >= MIN_MATCH) {\n      // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n      /*** _tr_tally_dist(s, s.strstart - s.match_start,\n                     s.match_length - MIN_MATCH, bflush); ***/\n      bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n      s.lookahead -= s.match_length;\n\n      /* Insert new strings in the hash table only if the match length\n       * is not too large. This saves time but degrades compression.\n       */\n      if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n        s.match_length--; /* string at strstart already in table */\n        do {\n          s.strstart++;\n          /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n          s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n          s.head[s.ins_h] = s.strstart;\n          /***/\n          /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n           * always MIN_MATCH bytes ahead.\n           */\n        } while (--s.match_length !== 0);\n        s.strstart++;\n      } else\n      {\n        s.strstart += s.match_length;\n        s.match_length = 0;\n        s.ins_h = s.window[s.strstart];\n        /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n        s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n\n//#if MIN_MATCH != 3\n//                Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n        /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n         * matter since it will be recomputed at next deflate call.\n         */\n      }\n    } else {\n      /* No match, output a literal byte */\n      //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n      bflush = _tr_tally(s, 0, s.window[s.strstart]);\n\n      s.lookahead--;\n      s.strstart++;\n    }\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n  if (flush === Z_FINISH$3) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n};\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nconst deflate_slow = (s, flush) => {\n\n  let hash_head;          /* head of hash chain */\n  let bflush;              /* set if current block must be flushed */\n\n  let max_insert;\n\n  /* Process the input block. */\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the next match, plus MIN_MATCH bytes to insert the\n     * string following the next match.\n     */\n    if (s.lookahead < MIN_LOOKAHEAD) {\n      fill_window(s);\n      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH$2) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) { break; } /* flush the current block */\n    }\n\n    /* Insert the string window[strstart .. strstart+2] in the\n     * dictionary, and set hash_head to the head of the hash chain:\n     */\n    hash_head = 0/*NIL*/;\n    if (s.lookahead >= MIN_MATCH) {\n      /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n      s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n      s.head[s.ins_h] = s.strstart;\n      /***/\n    }\n\n    /* Find the longest match, discarding those <= prev_length.\n     */\n    s.prev_length = s.match_length;\n    s.prev_match = s.match_start;\n    s.match_length = MIN_MATCH - 1;\n\n    if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n        s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n      /* To simplify the code, we prevent matches with the string\n       * of window index 0 (in particular we have to avoid a match\n       * of the string with itself at the start of the input file).\n       */\n      s.match_length = longest_match(s, hash_head);\n      /* longest_match() sets match_start */\n\n      if (s.match_length <= 5 &&\n         (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n        /* If prev_match is also MIN_MATCH, match_start is garbage\n         * but we will ignore the current match anyway.\n         */\n        s.match_length = MIN_MATCH - 1;\n      }\n    }\n    /* If there was a match at the previous step and the current\n     * match is not better, output the previous match:\n     */\n    if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n      max_insert = s.strstart + s.lookahead - MIN_MATCH;\n      /* Do not insert strings in hash table beyond this. */\n\n      //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n      /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n                     s.prev_length - MIN_MATCH, bflush);***/\n      bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n      /* Insert in hash table all strings up to the end of the match.\n       * strstart-1 and strstart are already inserted. If there is not\n       * enough lookahead, the last two strings are not inserted in\n       * the hash table.\n       */\n      s.lookahead -= s.prev_length - 1;\n      s.prev_length -= 2;\n      do {\n        if (++s.strstart <= max_insert) {\n          /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n          s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n          s.head[s.ins_h] = s.strstart;\n          /***/\n        }\n      } while (--s.prev_length !== 0);\n      s.match_available = 0;\n      s.match_length = MIN_MATCH - 1;\n      s.strstart++;\n\n      if (bflush) {\n        /*** FLUSH_BLOCK(s, 0); ***/\n        flush_block_only(s, false);\n        if (s.strm.avail_out === 0) {\n          return BS_NEED_MORE;\n        }\n        /***/\n      }\n\n    } else if (s.match_available) {\n      /* If there was no match at the previous position, output a\n       * single literal. If there was a match but the current match\n       * is longer, truncate the previous match to a single literal.\n       */\n      //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n      /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n      bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n\n      if (bflush) {\n        /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n        flush_block_only(s, false);\n        /***/\n      }\n      s.strstart++;\n      s.lookahead--;\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n    } else {\n      /* There is no previous match to compare with, wait for\n       * the next step to decide.\n       */\n      s.match_available = 1;\n      s.strstart++;\n      s.lookahead--;\n    }\n  }\n  //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n  if (s.match_available) {\n    //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n    /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n    bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n\n    s.match_available = 0;\n  }\n  s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n  if (flush === Z_FINISH$3) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n\n  return BS_BLOCK_DONE;\n};\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one.  Do not maintain a hash table.  (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nconst deflate_rle = (s, flush) => {\n\n  let bflush;            /* set if current block must be flushed */\n  let prev;              /* byte at distance one to match */\n  let scan, strend;      /* scan goes up to strend for length of run */\n\n  const _win = s.window;\n\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the longest run, plus one for the unrolled loop.\n     */\n    if (s.lookahead <= MAX_MATCH) {\n      fill_window(s);\n      if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH$2) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) { break; } /* flush the current block */\n    }\n\n    /* See how many times the previous byte repeats */\n    s.match_length = 0;\n    if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n      scan = s.strstart - 1;\n      prev = _win[scan];\n      if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n        strend = s.strstart + MAX_MATCH;\n        do {\n          /*jshint noempty:false*/\n        } while (prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 scan < strend);\n        s.match_length = MAX_MATCH - (strend - scan);\n        if (s.match_length > s.lookahead) {\n          s.match_length = s.lookahead;\n        }\n      }\n      //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n    }\n\n    /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n    if (s.match_length >= MIN_MATCH) {\n      //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n      /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n      bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n      s.lookahead -= s.match_length;\n      s.strstart += s.match_length;\n      s.match_length = 0;\n    } else {\n      /* No match, output a literal byte */\n      //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n      bflush = _tr_tally(s, 0, s.window[s.strstart]);\n\n      s.lookahead--;\n      s.strstart++;\n    }\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = 0;\n  if (flush === Z_FINISH$3) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n};\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nconst deflate_huff = (s, flush) => {\n\n  let bflush;             /* set if current block must be flushed */\n\n  for (;;) {\n    /* Make sure that we have a literal to write. */\n    if (s.lookahead === 0) {\n      fill_window(s);\n      if (s.lookahead === 0) {\n        if (flush === Z_NO_FLUSH$2) {\n          return BS_NEED_MORE;\n        }\n        break;      /* flush the current block */\n      }\n    }\n\n    /* Output a literal byte */\n    s.match_length = 0;\n    //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n    /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n    bflush = _tr_tally(s, 0, s.window[s.strstart]);\n    s.lookahead--;\n    s.strstart++;\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = 0;\n  if (flush === Z_FINISH$3) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n};\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n\n  this.good_length = good_length;\n  this.max_lazy = max_lazy;\n  this.nice_length = nice_length;\n  this.max_chain = max_chain;\n  this.func = func;\n}\n\nconst configuration_table = [\n  /*      good lazy nice chain */\n  new Config(0, 0, 0, 0, deflate_stored),          /* 0 store only */\n  new Config(4, 4, 8, 4, deflate_fast),            /* 1 max speed, no lazy matches */\n  new Config(4, 5, 16, 8, deflate_fast),           /* 2 */\n  new Config(4, 6, 32, 32, deflate_fast),          /* 3 */\n\n  new Config(4, 4, 16, 16, deflate_slow),          /* 4 lazy matches */\n  new Config(8, 16, 32, 32, deflate_slow),         /* 5 */\n  new Config(8, 16, 128, 128, deflate_slow),       /* 6 */\n  new Config(8, 32, 128, 256, deflate_slow),       /* 7 */\n  new Config(32, 128, 258, 1024, deflate_slow),    /* 8 */\n  new Config(32, 258, 258, 4096, deflate_slow)     /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nconst lm_init = (s) => {\n\n  s.window_size = 2 * s.w_size;\n\n  /*** CLEAR_HASH(s); ***/\n  zero(s.head); // Fill with NIL (= 0);\n\n  /* Set the default configuration parameters:\n   */\n  s.max_lazy_match = configuration_table[s.level].max_lazy;\n  s.good_match = configuration_table[s.level].good_length;\n  s.nice_match = configuration_table[s.level].nice_length;\n  s.max_chain_length = configuration_table[s.level].max_chain;\n\n  s.strstart = 0;\n  s.block_start = 0;\n  s.lookahead = 0;\n  s.insert = 0;\n  s.match_length = s.prev_length = MIN_MATCH - 1;\n  s.match_available = 0;\n  s.ins_h = 0;\n};\n\n\nfunction DeflateState() {\n  this.strm = null;            /* pointer back to this zlib stream */\n  this.status = 0;            /* as the name implies */\n  this.pending_buf = null;      /* output still pending */\n  this.pending_buf_size = 0;  /* size of pending_buf */\n  this.pending_out = 0;       /* next pending byte to output to the stream */\n  this.pending = 0;           /* nb of bytes in the pending buffer */\n  this.wrap = 0;              /* bit 0 true for zlib, bit 1 true for gzip */\n  this.gzhead = null;         /* gzip header information to write */\n  this.gzindex = 0;           /* where in extra, name, or comment */\n  this.method = Z_DEFLATED$2; /* can only be DEFLATED */\n  this.last_flush = -1;   /* value of flush param for previous deflate call */\n\n  this.w_size = 0;  /* LZ77 window size (32K by default) */\n  this.w_bits = 0;  /* log2(w_size)  (8..16) */\n  this.w_mask = 0;  /* w_size - 1 */\n\n  this.window = null;\n  /* Sliding window. Input bytes are read into the second half of the window,\n   * and move to the first half later to keep a dictionary of at least wSize\n   * bytes. With this organization, matches are limited to a distance of\n   * wSize-MAX_MATCH bytes, but this ensures that IO is always\n   * performed with a length multiple of the block size.\n   */\n\n  this.window_size = 0;\n  /* Actual size of window: 2*wSize, except when the user input buffer\n   * is directly used as sliding window.\n   */\n\n  this.prev = null;\n  /* Link to older string with same hash index. To limit the size of this\n   * array to 64K, this link is maintained only for the last 32K strings.\n   * An index in this array is thus a window index modulo 32K.\n   */\n\n  this.head = null;   /* Heads of the hash chains or NIL. */\n\n  this.ins_h = 0;       /* hash index of string to be inserted */\n  this.hash_size = 0;   /* number of elements in hash table */\n  this.hash_bits = 0;   /* log2(hash_size) */\n  this.hash_mask = 0;   /* hash_size-1 */\n\n  this.hash_shift = 0;\n  /* Number of bits by which ins_h must be shifted at each input\n   * step. It must be such that after MIN_MATCH steps, the oldest\n   * byte no longer takes part in the hash key, that is:\n   *   hash_shift * MIN_MATCH >= hash_bits\n   */\n\n  this.block_start = 0;\n  /* Window position at the beginning of the current output block. Gets\n   * negative when the window is moved backwards.\n   */\n\n  this.match_length = 0;      /* length of best match */\n  this.prev_match = 0;        /* previous match */\n  this.match_available = 0;   /* set if previous match exists */\n  this.strstart = 0;          /* start of string to insert */\n  this.match_start = 0;       /* start of matching string */\n  this.lookahead = 0;         /* number of valid bytes ahead in window */\n\n  this.prev_length = 0;\n  /* Length of the best match at previous step. Matches not greater than this\n   * are discarded. This is used in the lazy match evaluation.\n   */\n\n  this.max_chain_length = 0;\n  /* To speed up deflation, hash chains are never searched beyond this\n   * length.  A higher limit improves compression ratio but degrades the\n   * speed.\n   */\n\n  this.max_lazy_match = 0;\n  /* Attempt to find a better match only when the current match is strictly\n   * smaller than this value. This mechanism is used only for compression\n   * levels >= 4.\n   */\n  // That's alias to max_lazy_match, don't use directly\n  //this.max_insert_length = 0;\n  /* Insert new strings in the hash table only if the match length is not\n   * greater than this length. This saves time but degrades compression.\n   * max_insert_length is used only for compression levels <= 3.\n   */\n\n  this.level = 0;     /* compression level (1..9) */\n  this.strategy = 0;  /* favor or force Huffman coding*/\n\n  this.good_match = 0;\n  /* Use a faster search when the previous match is longer than this */\n\n  this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n              /* used by trees.c: */\n\n  /* Didn't use ct_data typedef below to suppress compiler warning */\n\n  // struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */\n  // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n  // struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */\n\n  // Use flat array of DOUBLE size, with interleaved fata,\n  // because JS does not support effective\n  this.dyn_ltree  = new Uint16Array(HEAP_SIZE * 2);\n  this.dyn_dtree  = new Uint16Array((2 * D_CODES + 1) * 2);\n  this.bl_tree    = new Uint16Array((2 * BL_CODES + 1) * 2);\n  zero(this.dyn_ltree);\n  zero(this.dyn_dtree);\n  zero(this.bl_tree);\n\n  this.l_desc   = null;         /* desc. for literal tree */\n  this.d_desc   = null;         /* desc. for distance tree */\n  this.bl_desc  = null;         /* desc. for bit length tree */\n\n  //ush bl_count[MAX_BITS+1];\n  this.bl_count = new Uint16Array(MAX_BITS + 1);\n  /* number of codes at each bit length for an optimal tree */\n\n  //int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */\n  this.heap = new Uint16Array(2 * L_CODES + 1);  /* heap used to build the Huffman trees */\n  zero(this.heap);\n\n  this.heap_len = 0;               /* number of elements in the heap */\n  this.heap_max = 0;               /* element of largest frequency */\n  /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n   * The same heap array is used to build all trees.\n   */\n\n  this.depth = new Uint16Array(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n  zero(this.depth);\n  /* Depth of each subtree used as tie breaker for trees of equal frequency\n   */\n\n  this.l_buf = 0;          /* buffer index for literals or lengths */\n\n  this.lit_bufsize = 0;\n  /* Size of match buffer for literals/lengths.  There are 4 reasons for\n   * limiting lit_bufsize to 64K:\n   *   - frequencies can be kept in 16 bit counters\n   *   - if compression is not successful for the first block, all input\n   *     data is still in the window so we can still emit a stored block even\n   *     when input comes from standard input.  (This can also be done for\n   *     all blocks if lit_bufsize is not greater than 32K.)\n   *   - if compression is not successful for a file smaller than 64K, we can\n   *     even emit a stored file instead of a stored block (saving 5 bytes).\n   *     This is applicable only for zip (not gzip or zlib).\n   *   - creating new Huffman trees less frequently may not provide fast\n   *     adaptation to changes in the input data statistics. (Take for\n   *     example a binary file with poorly compressible code followed by\n   *     a highly compressible string table.) Smaller buffer sizes give\n   *     fast adaptation but have of course the overhead of transmitting\n   *     trees more frequently.\n   *   - I can't count above 4\n   */\n\n  this.last_lit = 0;      /* running index in l_buf */\n\n  this.d_buf = 0;\n  /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n   * the same number of elements. To use different lengths, an extra flag\n   * array would be necessary.\n   */\n\n  this.opt_len = 0;       /* bit length of current block with optimal trees */\n  this.static_len = 0;    /* bit length of current block with static trees */\n  this.matches = 0;       /* number of string matches in current block */\n  this.insert = 0;        /* bytes at end of window left to insert */\n\n\n  this.bi_buf = 0;\n  /* Output buffer. bits are inserted starting at the bottom (least\n   * significant bits).\n   */\n  this.bi_valid = 0;\n  /* Number of valid bits in bi_buf.  All bits above the last valid bit\n   * are always zero.\n   */\n\n  // Used for window memory init. We safely ignore it for JS. That makes\n  // sense only for pointers and memory check tools.\n  //this.high_water = 0;\n  /* High water mark offset in window for initialized bytes -- bytes above\n   * this are set to zero in order to avoid memory check warnings when\n   * longest match routines access bytes past the input.  This is then\n   * updated to the new high water mark.\n   */\n}\n\n\nconst deflateResetKeep = (strm) => {\n\n  if (!strm || !strm.state) {\n    return err(strm, Z_STREAM_ERROR$2);\n  }\n\n  strm.total_in = strm.total_out = 0;\n  strm.data_type = Z_UNKNOWN;\n\n  const s = strm.state;\n  s.pending = 0;\n  s.pending_out = 0;\n\n  if (s.wrap < 0) {\n    s.wrap = -s.wrap;\n    /* was made negative by deflate(..., Z_FINISH); */\n  }\n  s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n  strm.adler = (s.wrap === 2) ?\n    0  // crc32(0, Z_NULL, 0)\n  :\n    1; // adler32(0, Z_NULL, 0)\n  s.last_flush = Z_NO_FLUSH$2;\n  _tr_init(s);\n  return Z_OK$3;\n};\n\n\nconst deflateReset = (strm) => {\n\n  const ret = deflateResetKeep(strm);\n  if (ret === Z_OK$3) {\n    lm_init(strm.state);\n  }\n  return ret;\n};\n\n\nconst deflateSetHeader = (strm, head) => {\n\n  if (!strm || !strm.state) { return Z_STREAM_ERROR$2; }\n  if (strm.state.wrap !== 2) { return Z_STREAM_ERROR$2; }\n  strm.state.gzhead = head;\n  return Z_OK$3;\n};\n\n\nconst deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n\n  if (!strm) { // === Z_NULL\n    return Z_STREAM_ERROR$2;\n  }\n  let wrap = 1;\n\n  if (level === Z_DEFAULT_COMPRESSION$1) {\n    level = 6;\n  }\n\n  if (windowBits < 0) { /* suppress zlib wrapper */\n    wrap = 0;\n    windowBits = -windowBits;\n  }\n\n  else if (windowBits > 15) {\n    wrap = 2;           /* write gzip wrapper instead */\n    windowBits -= 16;\n  }\n\n\n  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED$2 ||\n    windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n    strategy < 0 || strategy > Z_FIXED) {\n    return err(strm, Z_STREAM_ERROR$2);\n  }\n\n\n  if (windowBits === 8) {\n    windowBits = 9;\n  }\n  /* until 256-byte window bug fixed */\n\n  const s = new DeflateState();\n\n  strm.state = s;\n  s.strm = strm;\n\n  s.wrap = wrap;\n  s.gzhead = null;\n  s.w_bits = windowBits;\n  s.w_size = 1 << s.w_bits;\n  s.w_mask = s.w_size - 1;\n\n  s.hash_bits = memLevel + 7;\n  s.hash_size = 1 << s.hash_bits;\n  s.hash_mask = s.hash_size - 1;\n  s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n  s.window = new Uint8Array(s.w_size * 2);\n  s.head = new Uint16Array(s.hash_size);\n  s.prev = new Uint16Array(s.w_size);\n\n  // Don't need mem init magic for JS.\n  //s.high_water = 0;  /* nothing written to s->window yet */\n\n  s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n  s.pending_buf_size = s.lit_bufsize * 4;\n\n  //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n  //s->pending_buf = (uchf *) overlay;\n  s.pending_buf = new Uint8Array(s.pending_buf_size);\n\n  // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n  //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n  s.d_buf = 1 * s.lit_bufsize;\n\n  //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n  s.l_buf = (1 + 2) * s.lit_bufsize;\n\n  s.level = level;\n  s.strategy = strategy;\n  s.method = method;\n\n  return deflateReset(strm);\n};\n\nconst deflateInit = (strm, level) => {\n\n  return deflateInit2(strm, level, Z_DEFLATED$2, MAX_WBITS$1, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY$1);\n};\n\n\nconst deflate$2 = (strm, flush) => {\n\n  let beg, val; // for gzip header write only\n\n  if (!strm || !strm.state ||\n    flush > Z_BLOCK$1 || flush < 0) {\n    return strm ? err(strm, Z_STREAM_ERROR$2) : Z_STREAM_ERROR$2;\n  }\n\n  const s = strm.state;\n\n  if (!strm.output ||\n      (!strm.input && strm.avail_in !== 0) ||\n      (s.status === FINISH_STATE && flush !== Z_FINISH$3)) {\n    return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$1 : Z_STREAM_ERROR$2);\n  }\n\n  s.strm = strm; /* just in case */\n  const old_flush = s.last_flush;\n  s.last_flush = flush;\n\n  /* Write the header */\n  if (s.status === INIT_STATE) {\n\n    if (s.wrap === 2) { // GZIP header\n      strm.adler = 0;  //crc32(0L, Z_NULL, 0);\n      put_byte(s, 31);\n      put_byte(s, 139);\n      put_byte(s, 8);\n      if (!s.gzhead) { // s->gzhead == Z_NULL\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, s.level === 9 ? 2 :\n                    (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n                     4 : 0));\n        put_byte(s, OS_CODE);\n        s.status = BUSY_STATE;\n      }\n      else {\n        put_byte(s, (s.gzhead.text ? 1 : 0) +\n                    (s.gzhead.hcrc ? 2 : 0) +\n                    (!s.gzhead.extra ? 0 : 4) +\n                    (!s.gzhead.name ? 0 : 8) +\n                    (!s.gzhead.comment ? 0 : 16)\n        );\n        put_byte(s, s.gzhead.time & 0xff);\n        put_byte(s, (s.gzhead.time >> 8) & 0xff);\n        put_byte(s, (s.gzhead.time >> 16) & 0xff);\n        put_byte(s, (s.gzhead.time >> 24) & 0xff);\n        put_byte(s, s.level === 9 ? 2 :\n                    (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n                     4 : 0));\n        put_byte(s, s.gzhead.os & 0xff);\n        if (s.gzhead.extra && s.gzhead.extra.length) {\n          put_byte(s, s.gzhead.extra.length & 0xff);\n          put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n        }\n        if (s.gzhead.hcrc) {\n          strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending, 0);\n        }\n        s.gzindex = 0;\n        s.status = EXTRA_STATE;\n      }\n    }\n    else // DEFLATE header\n    {\n      let header = (Z_DEFLATED$2 + ((s.w_bits - 8) << 4)) << 8;\n      let level_flags = -1;\n\n      if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n        level_flags = 0;\n      } else if (s.level < 6) {\n        level_flags = 1;\n      } else if (s.level === 6) {\n        level_flags = 2;\n      } else {\n        level_flags = 3;\n      }\n      header |= (level_flags << 6);\n      if (s.strstart !== 0) { header |= PRESET_DICT; }\n      header += 31 - (header % 31);\n\n      s.status = BUSY_STATE;\n      putShortMSB(s, header);\n\n      /* Save the adler32 of the preset dictionary: */\n      if (s.strstart !== 0) {\n        putShortMSB(s, strm.adler >>> 16);\n        putShortMSB(s, strm.adler & 0xffff);\n      }\n      strm.adler = 1; // adler32(0L, Z_NULL, 0);\n    }\n  }\n\n//#ifdef GZIP\n  if (s.status === EXTRA_STATE) {\n    if (s.gzhead.extra/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n\n      while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            break;\n          }\n        }\n        put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n        s.gzindex++;\n      }\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (s.gzindex === s.gzhead.extra.length) {\n        s.gzindex = 0;\n        s.status = NAME_STATE;\n      }\n    }\n    else {\n      s.status = NAME_STATE;\n    }\n  }\n  if (s.status === NAME_STATE) {\n    if (s.gzhead.name/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n      //int val;\n\n      do {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            val = 1;\n            break;\n          }\n        }\n        // JS specific: little magic to add zero terminator to end of string\n        if (s.gzindex < s.gzhead.name.length) {\n          val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n        } else {\n          val = 0;\n        }\n        put_byte(s, val);\n      } while (val !== 0);\n\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (val === 0) {\n        s.gzindex = 0;\n        s.status = COMMENT_STATE;\n      }\n    }\n    else {\n      s.status = COMMENT_STATE;\n    }\n  }\n  if (s.status === COMMENT_STATE) {\n    if (s.gzhead.comment/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n      //int val;\n\n      do {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            val = 1;\n            break;\n          }\n        }\n        // JS specific: little magic to add zero terminator to end of string\n        if (s.gzindex < s.gzhead.comment.length) {\n          val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n        } else {\n          val = 0;\n        }\n        put_byte(s, val);\n      } while (val !== 0);\n\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (val === 0) {\n        s.status = HCRC_STATE;\n      }\n    }\n    else {\n      s.status = HCRC_STATE;\n    }\n  }\n  if (s.status === HCRC_STATE) {\n    if (s.gzhead.hcrc) {\n      if (s.pending + 2 > s.pending_buf_size) {\n        flush_pending(strm);\n      }\n      if (s.pending + 2 <= s.pending_buf_size) {\n        put_byte(s, strm.adler & 0xff);\n        put_byte(s, (strm.adler >> 8) & 0xff);\n        strm.adler = 0; //crc32(0L, Z_NULL, 0);\n        s.status = BUSY_STATE;\n      }\n    }\n    else {\n      s.status = BUSY_STATE;\n    }\n  }\n//#endif\n\n  /* Flush as much pending output as possible */\n  if (s.pending !== 0) {\n    flush_pending(strm);\n    if (strm.avail_out === 0) {\n      /* Since avail_out is 0, deflate will be called again with\n       * more output space, but possibly with both pending and\n       * avail_in equal to zero. There won't be anything to do,\n       * but this is not an error situation so make sure we\n       * return OK instead of BUF_ERROR at next call of deflate:\n       */\n      s.last_flush = -1;\n      return Z_OK$3;\n    }\n\n    /* Make sure there is something to do and avoid duplicate consecutive\n     * flushes. For repeated and useless calls with Z_FINISH, we keep\n     * returning Z_STREAM_END instead of Z_BUF_ERROR.\n     */\n  } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n    flush !== Z_FINISH$3) {\n    return err(strm, Z_BUF_ERROR$1);\n  }\n\n  /* User must not provide more input after the first FINISH: */\n  if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n    return err(strm, Z_BUF_ERROR$1);\n  }\n\n  /* Start a new block or continue the current one.\n   */\n  if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n    (flush !== Z_NO_FLUSH$2 && s.status !== FINISH_STATE)) {\n    let bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n      (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n        configuration_table[s.level].func(s, flush));\n\n    if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n      s.status = FINISH_STATE;\n    }\n    if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n      if (strm.avail_out === 0) {\n        s.last_flush = -1;\n        /* avoid BUF_ERROR next call, see above */\n      }\n      return Z_OK$3;\n      /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n       * of deflate should use the same flush parameter to make sure\n       * that the flush is complete. So we don't have to output an\n       * empty block here, this will be done at next call. This also\n       * ensures that for a very small output buffer, we emit at most\n       * one empty block.\n       */\n    }\n    if (bstate === BS_BLOCK_DONE) {\n      if (flush === Z_PARTIAL_FLUSH) {\n        _tr_align(s);\n      }\n      else if (flush !== Z_BLOCK$1) { /* FULL_FLUSH or SYNC_FLUSH */\n\n        _tr_stored_block(s, 0, 0, false);\n        /* For a full flush, this empty block will be recognized\n         * as a special marker by inflate_sync().\n         */\n        if (flush === Z_FULL_FLUSH$1) {\n          /*** CLEAR_HASH(s); ***/             /* forget history */\n          zero(s.head); // Fill with NIL (= 0);\n\n          if (s.lookahead === 0) {\n            s.strstart = 0;\n            s.block_start = 0;\n            s.insert = 0;\n          }\n        }\n      }\n      flush_pending(strm);\n      if (strm.avail_out === 0) {\n        s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n        return Z_OK$3;\n      }\n    }\n  }\n  //Assert(strm->avail_out > 0, \"bug2\");\n  //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n  if (flush !== Z_FINISH$3) { return Z_OK$3; }\n  if (s.wrap <= 0) { return Z_STREAM_END$3; }\n\n  /* Write the trailer */\n  if (s.wrap === 2) {\n    put_byte(s, strm.adler & 0xff);\n    put_byte(s, (strm.adler >> 8) & 0xff);\n    put_byte(s, (strm.adler >> 16) & 0xff);\n    put_byte(s, (strm.adler >> 24) & 0xff);\n    put_byte(s, strm.total_in & 0xff);\n    put_byte(s, (strm.total_in >> 8) & 0xff);\n    put_byte(s, (strm.total_in >> 16) & 0xff);\n    put_byte(s, (strm.total_in >> 24) & 0xff);\n  }\n  else\n  {\n    putShortMSB(s, strm.adler >>> 16);\n    putShortMSB(s, strm.adler & 0xffff);\n  }\n\n  flush_pending(strm);\n  /* If avail_out is zero, the application will call deflate again\n   * to flush the rest.\n   */\n  if (s.wrap > 0) { s.wrap = -s.wrap; }\n  /* write the trailer only once! */\n  return s.pending !== 0 ? Z_OK$3 : Z_STREAM_END$3;\n};\n\n\nconst deflateEnd = (strm) => {\n\n  if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n    return Z_STREAM_ERROR$2;\n  }\n\n  const status = strm.state.status;\n  if (status !== INIT_STATE &&\n    status !== EXTRA_STATE &&\n    status !== NAME_STATE &&\n    status !== COMMENT_STATE &&\n    status !== HCRC_STATE &&\n    status !== BUSY_STATE &&\n    status !== FINISH_STATE\n  ) {\n    return err(strm, Z_STREAM_ERROR$2);\n  }\n\n  strm.state = null;\n\n  return status === BUSY_STATE ? err(strm, Z_DATA_ERROR$2) : Z_OK$3;\n};\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nconst deflateSetDictionary = (strm, dictionary) => {\n\n  let dictLength = dictionary.length;\n\n  if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n    return Z_STREAM_ERROR$2;\n  }\n\n  const s = strm.state;\n  const wrap = s.wrap;\n\n  if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n    return Z_STREAM_ERROR$2;\n  }\n\n  /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n  if (wrap === 1) {\n    /* adler32(strm->adler, dictionary, dictLength); */\n    strm.adler = adler32_1(strm.adler, dictionary, dictLength, 0);\n  }\n\n  s.wrap = 0;   /* avoid computing Adler-32 in read_buf */\n\n  /* if dictionary would fill window, just replace the history */\n  if (dictLength >= s.w_size) {\n    if (wrap === 0) {            /* already empty otherwise */\n      /*** CLEAR_HASH(s); ***/\n      zero(s.head); // Fill with NIL (= 0);\n      s.strstart = 0;\n      s.block_start = 0;\n      s.insert = 0;\n    }\n    /* use the tail */\n    // dictionary = dictionary.slice(dictLength - s.w_size);\n    let tmpDict = new Uint8Array(s.w_size);\n    tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n    dictionary = tmpDict;\n    dictLength = s.w_size;\n  }\n  /* insert dictionary into window and hash */\n  const avail = strm.avail_in;\n  const next = strm.next_in;\n  const input = strm.input;\n  strm.avail_in = dictLength;\n  strm.next_in = 0;\n  strm.input = dictionary;\n  fill_window(s);\n  while (s.lookahead >= MIN_MATCH) {\n    let str = s.strstart;\n    let n = s.lookahead - (MIN_MATCH - 1);\n    do {\n      /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n      s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n\n      s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n      s.head[s.ins_h] = str;\n      str++;\n    } while (--n);\n    s.strstart = str;\n    s.lookahead = MIN_MATCH - 1;\n    fill_window(s);\n  }\n  s.strstart += s.lookahead;\n  s.block_start = s.strstart;\n  s.insert = s.lookahead;\n  s.lookahead = 0;\n  s.match_length = s.prev_length = MIN_MATCH - 1;\n  s.match_available = 0;\n  strm.next_in = next;\n  strm.input = input;\n  strm.avail_in = avail;\n  s.wrap = wrap;\n  return Z_OK$3;\n};\n\n\nvar deflateInit_1 = deflateInit;\nvar deflateInit2_1 = deflateInit2;\nvar deflateReset_1 = deflateReset;\nvar deflateResetKeep_1 = deflateResetKeep;\nvar deflateSetHeader_1 = deflateSetHeader;\nvar deflate_2$1 = deflate$2;\nvar deflateEnd_1 = deflateEnd;\nvar deflateSetDictionary_1 = deflateSetDictionary;\nvar deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nmodule.exports.deflateBound = deflateBound;\nmodule.exports.deflateCopy = deflateCopy;\nmodule.exports.deflateParams = deflateParams;\nmodule.exports.deflatePending = deflatePending;\nmodule.exports.deflatePrime = deflatePrime;\nmodule.exports.deflateTune = deflateTune;\n*/\n\nvar deflate_1$2 = {\n\tdeflateInit: deflateInit_1,\n\tdeflateInit2: deflateInit2_1,\n\tdeflateReset: deflateReset_1,\n\tdeflateResetKeep: deflateResetKeep_1,\n\tdeflateSetHeader: deflateSetHeader_1,\n\tdeflate: deflate_2$1,\n\tdeflateEnd: deflateEnd_1,\n\tdeflateSetDictionary: deflateSetDictionary_1,\n\tdeflateInfo: deflateInfo\n};\n\nconst _has = (obj, key) => {\n  return Object.prototype.hasOwnProperty.call(obj, key);\n};\n\nvar assign = function (obj /*from1, from2, from3, ...*/) {\n  const sources = Array.prototype.slice.call(arguments, 1);\n  while (sources.length) {\n    const source = sources.shift();\n    if (!source) { continue; }\n\n    if (typeof source !== 'object') {\n      throw new TypeError(source + 'must be non-object');\n    }\n\n    for (const p in source) {\n      if (_has(source, p)) {\n        obj[p] = source[p];\n      }\n    }\n  }\n\n  return obj;\n};\n\n\n// Join array of chunks to single array.\nvar flattenChunks = (chunks) => {\n  // calculate data length\n  let len = 0;\n\n  for (let i = 0, l = chunks.length; i < l; i++) {\n    len += chunks[i].length;\n  }\n\n  // join chunks\n  const result = new Uint8Array(len);\n\n  for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n    let chunk = chunks[i];\n    result.set(chunk, pos);\n    pos += chunk.length;\n  }\n\n  return result;\n};\n\nvar common = {\n\tassign: assign,\n\tflattenChunks: flattenChunks\n};\n\n// String encode/decode helpers\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safari\n//\nlet STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n  _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nvar string2buf = (str) => {\n  if (typeof TextEncoder === 'function' && TextEncoder.prototype.encode) {\n    return new TextEncoder().encode(str);\n  }\n\n  let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n  // count binary size\n  for (m_pos = 0; m_pos < str_len; m_pos++) {\n    c = str.charCodeAt(m_pos);\n    if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n      c2 = str.charCodeAt(m_pos + 1);\n      if ((c2 & 0xfc00) === 0xdc00) {\n        c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n        m_pos++;\n      }\n    }\n    buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n  }\n\n  // allocate buffer\n  buf = new Uint8Array(buf_len);\n\n  // convert\n  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n    c = str.charCodeAt(m_pos);\n    if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n      c2 = str.charCodeAt(m_pos + 1);\n      if ((c2 & 0xfc00) === 0xdc00) {\n        c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n        m_pos++;\n      }\n    }\n    if (c < 0x80) {\n      /* one byte */\n      buf[i++] = c;\n    } else if (c < 0x800) {\n      /* two bytes */\n      buf[i++] = 0xC0 | (c >>> 6);\n      buf[i++] = 0x80 | (c & 0x3f);\n    } else if (c < 0x10000) {\n      /* three bytes */\n      buf[i++] = 0xE0 | (c >>> 12);\n      buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n      buf[i++] = 0x80 | (c & 0x3f);\n    } else {\n      /* four bytes */\n      buf[i++] = 0xf0 | (c >>> 18);\n      buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n      buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n      buf[i++] = 0x80 | (c & 0x3f);\n    }\n  }\n\n  return buf;\n};\n\n// Helper\nconst buf2binstring = (buf, len) => {\n  // On Chrome, the arguments in a function call that are allowed is `65534`.\n  // If the length of the buffer is smaller than that, we can use this optimization,\n  // otherwise we will take a slower path.\n  if (len < 65534) {\n    if (buf.subarray && STR_APPLY_UIA_OK) {\n      return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n    }\n  }\n\n  let result = '';\n  for (let i = 0; i < len; i++) {\n    result += String.fromCharCode(buf[i]);\n  }\n  return result;\n};\n\n\n// convert array to string\nvar buf2string = (buf, max) => {\n  const len = max || buf.length;\n\n  if (typeof TextDecoder === 'function' && TextDecoder.prototype.decode) {\n    return new TextDecoder().decode(buf.subarray(0, max));\n  }\n\n  let i, out;\n\n  // Reserve max possible length (2 words per char)\n  // NB: by unknown reasons, Array is significantly faster for\n  //     String.fromCharCode.apply than Uint16Array.\n  const utf16buf = new Array(len * 2);\n\n  for (out = 0, i = 0; i < len;) {\n    let c = buf[i++];\n    // quick process ascii\n    if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n    let c_len = _utf8len[c];\n    // skip 5 & 6 byte codes\n    if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n    // apply mask on first byte\n    c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n    // join the rest\n    while (c_len > 1 && i < len) {\n      c = (c << 6) | (buf[i++] & 0x3f);\n      c_len--;\n    }\n\n    // terminated by end of string?\n    if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n    if (c < 0x10000) {\n      utf16buf[out++] = c;\n    } else {\n      c -= 0x10000;\n      utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n      utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n    }\n  }\n\n  return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max   - length limit (mandatory);\nvar utf8border = (buf, max) => {\n\n  max = max || buf.length;\n  if (max > buf.length) { max = buf.length; }\n\n  // go back from last position, until start of sequence found\n  let pos = max - 1;\n  while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n  // Very small and broken sequence,\n  // return max, because we should return something anyway.\n  if (pos < 0) { return max; }\n\n  // If we came to start of buffer - that means buffer is too small,\n  // return max too.\n  if (pos === 0) { return max; }\n\n  return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\nvar strings = {\n\tstring2buf: string2buf,\n\tbuf2string: buf2string,\n\tutf8border: utf8border\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n  /* next input byte */\n  this.input = null; // JS specific, because we have no pointers\n  this.next_in = 0;\n  /* number of bytes available at input */\n  this.avail_in = 0;\n  /* total number of input bytes read so far */\n  this.total_in = 0;\n  /* next output byte should be put there */\n  this.output = null; // JS specific, because we have no pointers\n  this.next_out = 0;\n  /* remaining free space at output */\n  this.avail_out = 0;\n  /* total number of bytes output so far */\n  this.total_out = 0;\n  /* last error message, NULL if no error */\n  this.msg = ''/*Z_NULL*/;\n  /* not visible by applications */\n  this.state = null;\n  /* best guess about the data type: binary or text */\n  this.data_type = 2/*Z_UNKNOWN*/;\n  /* adler32 value of the uncompressed data */\n  this.adler = 0;\n}\n\nvar zstream = ZStream;\n\nconst toString$1 = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nconst {\n  Z_NO_FLUSH: Z_NO_FLUSH$1, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH: Z_FINISH$2,\n  Z_OK: Z_OK$2, Z_STREAM_END: Z_STREAM_END$2,\n  Z_DEFAULT_COMPRESSION,\n  Z_DEFAULT_STRATEGY,\n  Z_DEFLATED: Z_DEFLATED$1\n} = constants$2;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overridden.\n **/\n\n/**\n * Deflate.result -> Uint8Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `header` (Object) - custom header for gzip\n *   - `text` (Boolean) - true if compressed data believed to be text\n *   - `time` (Number) - modification time, unix timestamp\n *   - `os` (Number) - operation system code\n *   - `extra` (Array) - array of bytes with extra data (max 65536)\n *   - `name` (String) - file name (binary string)\n *   - `comment` (String) - comment (binary string)\n *   - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n *   , chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])\n *   , chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * const deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true);  // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate$1(options) {\n  this.options = common.assign({\n    level: Z_DEFAULT_COMPRESSION,\n    method: Z_DEFLATED$1,\n    chunkSize: 16384,\n    windowBits: 15,\n    memLevel: 8,\n    strategy: Z_DEFAULT_STRATEGY\n  }, options || {});\n\n  let opt = this.options;\n\n  if (opt.raw && (opt.windowBits > 0)) {\n    opt.windowBits = -opt.windowBits;\n  }\n\n  else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n    opt.windowBits += 16;\n  }\n\n  this.err    = 0;      // error code, if happens (0 = Z_OK)\n  this.msg    = '';     // error message\n  this.ended  = false;  // used to avoid multiple onEnd() calls\n  this.chunks = [];     // chunks of compressed data\n\n  this.strm = new zstream();\n  this.strm.avail_out = 0;\n\n  let status = deflate_1$2.deflateInit2(\n    this.strm,\n    opt.level,\n    opt.method,\n    opt.windowBits,\n    opt.memLevel,\n    opt.strategy\n  );\n\n  if (status !== Z_OK$2) {\n    throw new Error(messages[status]);\n  }\n\n  if (opt.header) {\n    deflate_1$2.deflateSetHeader(this.strm, opt.header);\n  }\n\n  if (opt.dictionary) {\n    let dict;\n    // Convert data if needed\n    if (typeof opt.dictionary === 'string') {\n      // If we need to compress text, change encoding to utf8.\n      dict = strings.string2buf(opt.dictionary);\n    } else if (toString$1.call(opt.dictionary) === '[object ArrayBuffer]') {\n      dict = new Uint8Array(opt.dictionary);\n    } else {\n      dict = opt.dictionary;\n    }\n\n    status = deflate_1$2.deflateSetDictionary(this.strm, dict);\n\n    if (status !== Z_OK$2) {\n      throw new Error(messages[status]);\n    }\n\n    this._dict_set = true;\n  }\n}\n\n/**\n * Deflate#push(data[, flush_mode]) -> Boolean\n * - data (Uint8Array|ArrayBuffer|String): input data. Strings will be\n *   converted to utf8 byte sequence.\n * - flush_mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must\n * have `flush_mode` Z_FINISH (or `true`). That will flush internal pending\n * buffers and call [[Deflate#onEnd]].\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true);  // push last chunk\n * ```\n **/\nDeflate$1.prototype.push = function (data, flush_mode) {\n  const strm = this.strm;\n  const chunkSize = this.options.chunkSize;\n  let status, _flush_mode;\n\n  if (this.ended) { return false; }\n\n  if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n  else _flush_mode = flush_mode === true ? Z_FINISH$2 : Z_NO_FLUSH$1;\n\n  // Convert data if needed\n  if (typeof data === 'string') {\n    // If we need to compress text, change encoding to utf8.\n    strm.input = strings.string2buf(data);\n  } else if (toString$1.call(data) === '[object ArrayBuffer]') {\n    strm.input = new Uint8Array(data);\n  } else {\n    strm.input = data;\n  }\n\n  strm.next_in = 0;\n  strm.avail_in = strm.input.length;\n\n  for (;;) {\n    if (strm.avail_out === 0) {\n      strm.output = new Uint8Array(chunkSize);\n      strm.next_out = 0;\n      strm.avail_out = chunkSize;\n    }\n\n    // Make sure avail_out > 6 to avoid repeating markers\n    if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n      this.onData(strm.output.subarray(0, strm.next_out));\n      strm.avail_out = 0;\n      continue;\n    }\n\n    status = deflate_1$2.deflate(strm, _flush_mode);\n\n    // Ended => flush and finish\n    if (status === Z_STREAM_END$2) {\n      if (strm.next_out > 0) {\n        this.onData(strm.output.subarray(0, strm.next_out));\n      }\n      status = deflate_1$2.deflateEnd(this.strm);\n      this.onEnd(status);\n      this.ended = true;\n      return status === Z_OK$2;\n    }\n\n    // Flush if out buffer full\n    if (strm.avail_out === 0) {\n      this.onData(strm.output);\n      continue;\n    }\n\n    // Flush if requested and has data\n    if (_flush_mode > 0 && strm.next_out > 0) {\n      this.onData(strm.output.subarray(0, strm.next_out));\n      strm.avail_out = 0;\n      continue;\n    }\n\n    if (strm.avail_in === 0) break;\n  }\n\n  return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array): output data.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate$1.prototype.onData = function (chunk) {\n  this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n *   other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH). By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate$1.prototype.onEnd = function (status) {\n  // On success - join\n  if (status === Z_OK$2) {\n    this.result = common.flattenChunks(this.chunks);\n  }\n  this.chunks = [];\n  this.err = status;\n  this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array\n * - data (Uint8Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n *   negative windowBits implicitly.\n *\n * ##### Example:\n *\n * ```javascript\n * const pako = require('pako')\n * const data = new Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate$1(input, options) {\n  const deflator = new Deflate$1(options);\n\n  deflator.push(input, true);\n\n  // That will never happens, if you don't cheat with options :)\n  if (deflator.err) { throw deflator.msg || messages[deflator.err]; }\n\n  return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array\n * - data (Uint8Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw$1(input, options) {\n  options = options || {};\n  options.raw = true;\n  return deflate$1(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array\n * - data (Uint8Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip$1(input, options) {\n  options = options || {};\n  options.gzip = true;\n  return deflate$1(input, options);\n}\n\n\nvar Deflate_1$1 = Deflate$1;\nvar deflate_2 = deflate$1;\nvar deflateRaw_1$1 = deflateRaw$1;\nvar gzip_1$1 = gzip$1;\nvar constants$1 = constants$2;\n\nvar deflate_1$1 = {\n\tDeflate: Deflate_1$1,\n\tdeflate: deflate_2,\n\tdeflateRaw: deflateRaw_1$1,\n\tgzip: gzip_1$1,\n\tconstants: constants$1\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nconst BAD$1 = 30;       /* got a data error -- remain here until reset */\nconst TYPE$1 = 12;      /* i: waiting for type bits, including last-flag bit */\n\n/*\n   Decode literal, length, and distance codes and write out the resulting\n   literal and match bytes until either not enough input or output is\n   available, an end-of-block is encountered, or a data error is encountered.\n   When large enough input and output buffers are supplied to inflate(), for\n   example, a 16K input buffer and a 64K output buffer, more than 95% of the\n   inflate execution time is spent in this routine.\n\n   Entry assumptions:\n\n        state.mode === LEN\n        strm.avail_in >= 6\n        strm.avail_out >= 258\n        start >= strm.avail_out\n        state.bits < 8\n\n   On return, state.mode is one of:\n\n        LEN -- ran out of enough output space or enough available input\n        TYPE -- reached end of block code, inflate() to interpret next block\n        BAD -- error in block data\n\n   Notes:\n\n    - The maximum input bits used by a length/distance pair is 15 bits for the\n      length code, 5 bits for the length extra, 15 bits for the distance code,\n      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.\n      Therefore if strm.avail_in >= 6, then there is enough input to avoid\n      checking for available input while decoding.\n\n    - The maximum bytes that a single length/distance pair can output is 258\n      bytes, which is the maximum length that can be coded.  inflate_fast()\n      requires strm.avail_out >= 258 for each loop to avoid checking for\n      output space.\n */\nvar inffast = function inflate_fast(strm, start) {\n  let _in;                    /* local strm.input */\n  let last;                   /* have enough input while in < last */\n  let _out;                   /* local strm.output */\n  let beg;                    /* inflate()'s initial strm.output */\n  let end;                    /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n  let dmax;                   /* maximum distance from zlib header */\n//#endif\n  let wsize;                  /* window size or zero if not using window */\n  let whave;                  /* valid bytes in the window */\n  let wnext;                  /* window write index */\n  // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n  let s_window;               /* allocated sliding window, if wsize != 0 */\n  let hold;                   /* local strm.hold */\n  let bits;                   /* local strm.bits */\n  let lcode;                  /* local strm.lencode */\n  let dcode;                  /* local strm.distcode */\n  let lmask;                  /* mask for first level of length codes */\n  let dmask;                  /* mask for first level of distance codes */\n  let here;                   /* retrieved table entry */\n  let op;                     /* code bits, operation, extra bits, or */\n                              /*  window position, window bytes to copy */\n  let len;                    /* match length, unused bytes */\n  let dist;                   /* match distance */\n  let from;                   /* where to copy match from */\n  let from_source;\n\n\n  let input, output; // JS specific, because we have no pointers\n\n  /* copy state to local variables */\n  const state = strm.state;\n  //here = state.here;\n  _in = strm.next_in;\n  input = strm.input;\n  last = _in + (strm.avail_in - 5);\n  _out = strm.next_out;\n  output = strm.output;\n  beg = _out - (start - strm.avail_out);\n  end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n  dmax = state.dmax;\n//#endif\n  wsize = state.wsize;\n  whave = state.whave;\n  wnext = state.wnext;\n  s_window = state.window;\n  hold = state.hold;\n  bits = state.bits;\n  lcode = state.lencode;\n  dcode = state.distcode;\n  lmask = (1 << state.lenbits) - 1;\n  dmask = (1 << state.distbits) - 1;\n\n\n  /* decode literals and length/distances until end-of-block or not enough\n     input data or output space */\n\n  top:\n  do {\n    if (bits < 15) {\n      hold += input[_in++] << bits;\n      bits += 8;\n      hold += input[_in++] << bits;\n      bits += 8;\n    }\n\n    here = lcode[hold & lmask];\n\n    dolen:\n    for (;;) { // Goto emulation\n      op = here >>> 24/*here.bits*/;\n      hold >>>= op;\n      bits -= op;\n      op = (here >>> 16) & 0xff/*here.op*/;\n      if (op === 0) {                          /* literal */\n        //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n        //        \"inflate:         literal '%c'\\n\" :\n        //        \"inflate:         literal 0x%02x\\n\", here.val));\n        output[_out++] = here & 0xffff/*here.val*/;\n      }\n      else if (op & 16) {                     /* length base */\n        len = here & 0xffff/*here.val*/;\n        op &= 15;                           /* number of extra bits */\n        if (op) {\n          if (bits < op) {\n            hold += input[_in++] << bits;\n            bits += 8;\n          }\n          len += hold & ((1 << op) - 1);\n          hold >>>= op;\n          bits -= op;\n        }\n        //Tracevv((stderr, \"inflate:         length %u\\n\", len));\n        if (bits < 15) {\n          hold += input[_in++] << bits;\n          bits += 8;\n          hold += input[_in++] << bits;\n          bits += 8;\n        }\n        here = dcode[hold & dmask];\n\n        dodist:\n        for (;;) { // goto emulation\n          op = here >>> 24/*here.bits*/;\n          hold >>>= op;\n          bits -= op;\n          op = (here >>> 16) & 0xff/*here.op*/;\n\n          if (op & 16) {                      /* distance base */\n            dist = here & 0xffff/*here.val*/;\n            op &= 15;                       /* number of extra bits */\n            if (bits < op) {\n              hold += input[_in++] << bits;\n              bits += 8;\n              if (bits < op) {\n                hold += input[_in++] << bits;\n                bits += 8;\n              }\n            }\n            dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n            if (dist > dmax) {\n              strm.msg = 'invalid distance too far back';\n              state.mode = BAD$1;\n              break top;\n            }\n//#endif\n            hold >>>= op;\n            bits -= op;\n            //Tracevv((stderr, \"inflate:         distance %u\\n\", dist));\n            op = _out - beg;                /* max distance in output */\n            if (dist > op) {                /* see if copy from window */\n              op = dist - op;               /* distance back in window */\n              if (op > whave) {\n                if (state.sane) {\n                  strm.msg = 'invalid distance too far back';\n                  state.mode = BAD$1;\n                  break top;\n                }\n\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n//                if (len <= op - whave) {\n//                  do {\n//                    output[_out++] = 0;\n//                  } while (--len);\n//                  continue top;\n//                }\n//                len -= op - whave;\n//                do {\n//                  output[_out++] = 0;\n//                } while (--op > whave);\n//                if (op === 0) {\n//                  from = _out - dist;\n//                  do {\n//                    output[_out++] = output[from++];\n//                  } while (--len);\n//                  continue top;\n//                }\n//#endif\n              }\n              from = 0; // window index\n              from_source = s_window;\n              if (wnext === 0) {           /* very common case */\n                from += wsize - op;\n                if (op < len) {         /* some from window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = _out - dist;  /* rest from output */\n                  from_source = output;\n                }\n              }\n              else if (wnext < op) {      /* wrap around window */\n                from += wsize + wnext - op;\n                op -= wnext;\n                if (op < len) {         /* some from end of window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = 0;\n                  if (wnext < len) {  /* some from start of window */\n                    op = wnext;\n                    len -= op;\n                    do {\n                      output[_out++] = s_window[from++];\n                    } while (--op);\n                    from = _out - dist;      /* rest from output */\n                    from_source = output;\n                  }\n                }\n              }\n              else {                      /* contiguous in window */\n                from += wnext - op;\n                if (op < len) {         /* some from window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = _out - dist;  /* rest from output */\n                  from_source = output;\n                }\n              }\n              while (len > 2) {\n                output[_out++] = from_source[from++];\n                output[_out++] = from_source[from++];\n                output[_out++] = from_source[from++];\n                len -= 3;\n              }\n              if (len) {\n                output[_out++] = from_source[from++];\n                if (len > 1) {\n                  output[_out++] = from_source[from++];\n                }\n              }\n            }\n            else {\n              from = _out - dist;          /* copy direct from output */\n              do {                        /* minimum length is three */\n                output[_out++] = output[from++];\n                output[_out++] = output[from++];\n                output[_out++] = output[from++];\n                len -= 3;\n              } while (len > 2);\n              if (len) {\n                output[_out++] = output[from++];\n                if (len > 1) {\n                  output[_out++] = output[from++];\n                }\n              }\n            }\n          }\n          else if ((op & 64) === 0) {          /* 2nd level distance code */\n            here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n            continue dodist;\n          }\n          else {\n            strm.msg = 'invalid distance code';\n            state.mode = BAD$1;\n            break top;\n          }\n\n          break; // need to emulate goto via \"continue\"\n        }\n      }\n      else if ((op & 64) === 0) {              /* 2nd level length code */\n        here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n        continue dolen;\n      }\n      else if (op & 32) {                     /* end-of-block */\n        //Tracevv((stderr, \"inflate:         end of block\\n\"));\n        state.mode = TYPE$1;\n        break top;\n      }\n      else {\n        strm.msg = 'invalid literal/length code';\n        state.mode = BAD$1;\n        break top;\n      }\n\n      break; // need to emulate goto via \"continue\"\n    }\n  } while (_in < last && _out < end);\n\n  /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n  len = bits >> 3;\n  _in -= len;\n  bits -= len << 3;\n  hold &= (1 << bits) - 1;\n\n  /* update state and return */\n  strm.next_in = _in;\n  strm.next_out = _out;\n  strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n  strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n  state.hold = hold;\n  state.bits = bits;\n  return;\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\n//const ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\n\nconst lbase = new Uint16Array([ /* Length codes 257..285 base */\n  3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n  35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n]);\n\nconst lext = new Uint8Array([ /* Length codes 257..285 extra */\n  16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n  19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n]);\n\nconst dbase = new Uint16Array([ /* Distance codes 0..29 base */\n  1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n  257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n  8193, 12289, 16385, 24577, 0, 0\n]);\n\nconst dext = new Uint8Array([ /* Distance codes 0..29 extra */\n  16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n  23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n  28, 28, 29, 29, 64, 64\n]);\n\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) =>\n{\n  const bits = opts.bits;\n      //here = opts.here; /* table entry for duplication */\n\n  let len = 0;               /* a code's length in bits */\n  let sym = 0;               /* index of code symbols */\n  let min = 0, max = 0;          /* minimum and maximum code lengths */\n  let root = 0;              /* number of index bits for root table */\n  let curr = 0;              /* number of index bits for current table */\n  let drop = 0;              /* code bits to drop for sub-table */\n  let left = 0;                   /* number of prefix codes available */\n  let used = 0;              /* code entries in table used */\n  let huff = 0;              /* Huffman code */\n  let incr;              /* for incrementing code, index */\n  let fill;              /* index for replicating entries */\n  let low;               /* low bits for current root entry */\n  let mask;              /* mask for low root bits */\n  let next;             /* next available space in table */\n  let base = null;     /* base value table to use */\n  let base_index = 0;\n//  let shoextra;    /* extra bits table to use */\n  let end;                    /* use base and extra for symbol > end */\n  const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1];    /* number of codes of each length */\n  const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1];     /* offsets in table for each length */\n  let extra = null;\n  let extra_index = 0;\n\n  let here_bits, here_op, here_val;\n\n  /*\n   Process a set of code lengths to create a canonical Huffman code.  The\n   code lengths are lens[0..codes-1].  Each length corresponds to the\n   symbols 0..codes-1.  The Huffman code is generated by first sorting the\n   symbols by length from short to long, and retaining the symbol order\n   for codes with equal lengths.  Then the code starts with all zero bits\n   for the first code of the shortest length, and the codes are integer\n   increments for the same length, and zeros are appended as the length\n   increases.  For the deflate format, these bits are stored backwards\n   from their more natural integer increment ordering, and so when the\n   decoding tables are built in the large loop below, the integer codes\n   are incremented backwards.\n\n   This routine assumes, but does not check, that all of the entries in\n   lens[] are in the range 0..MAXBITS.  The caller must assure this.\n   1..MAXBITS is interpreted as that code length.  zero means that that\n   symbol does not occur in this code.\n\n   The codes are sorted by computing a count of codes for each length,\n   creating from that a table of starting indices for each length in the\n   sorted table, and then entering the symbols in order in the sorted\n   table.  The sorted table is work[], with that space being provided by\n   the caller.\n\n   The length counts are used for other purposes as well, i.e. finding\n   the minimum and maximum length codes, determining if there are any\n   codes at all, checking for a valid set of lengths, and looking ahead\n   at length counts to determine sub-table sizes when building the\n   decoding tables.\n   */\n\n  /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n  for (len = 0; len <= MAXBITS; len++) {\n    count[len] = 0;\n  }\n  for (sym = 0; sym < codes; sym++) {\n    count[lens[lens_index + sym]]++;\n  }\n\n  /* bound code lengths, force root to be within code lengths */\n  root = bits;\n  for (max = MAXBITS; max >= 1; max--) {\n    if (count[max] !== 0) { break; }\n  }\n  if (root > max) {\n    root = max;\n  }\n  if (max === 0) {                     /* no symbols to code at all */\n    //table.op[opts.table_index] = 64;  //here.op = (var char)64;    /* invalid code marker */\n    //table.bits[opts.table_index] = 1;   //here.bits = (var char)1;\n    //table.val[opts.table_index++] = 0;   //here.val = (var short)0;\n    table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n    //table.op[opts.table_index] = 64;\n    //table.bits[opts.table_index] = 1;\n    //table.val[opts.table_index++] = 0;\n    table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n    opts.bits = 1;\n    return 0;     /* no symbols, but wait for decoding to report error */\n  }\n  for (min = 1; min < max; min++) {\n    if (count[min] !== 0) { break; }\n  }\n  if (root < min) {\n    root = min;\n  }\n\n  /* check for an over-subscribed or incomplete set of lengths */\n  left = 1;\n  for (len = 1; len <= MAXBITS; len++) {\n    left <<= 1;\n    left -= count[len];\n    if (left < 0) {\n      return -1;\n    }        /* over-subscribed */\n  }\n  if (left > 0 && (type === CODES$1 || max !== 1)) {\n    return -1;                      /* incomplete set */\n  }\n\n  /* generate offsets into symbol table for each length for sorting */\n  offs[1] = 0;\n  for (len = 1; len < MAXBITS; len++) {\n    offs[len + 1] = offs[len] + count[len];\n  }\n\n  /* sort symbols by length, by symbol order within each length */\n  for (sym = 0; sym < codes; sym++) {\n    if (lens[lens_index + sym] !== 0) {\n      work[offs[lens[lens_index + sym]]++] = sym;\n    }\n  }\n\n  /*\n   Create and fill in decoding tables.  In this loop, the table being\n   filled is at next and has curr index bits.  The code being used is huff\n   with length len.  That code is converted to an index by dropping drop\n   bits off of the bottom.  For codes where len is less than drop + curr,\n   those top drop + curr - len bits are incremented through all values to\n   fill the table with replicated entries.\n\n   root is the number of index bits for the root table.  When len exceeds\n   root, sub-tables are created pointed to by the root entry with an index\n   of the low root bits of huff.  This is saved in low to check for when a\n   new sub-table should be started.  drop is zero when the root table is\n   being filled, and drop is root when sub-tables are being filled.\n\n   When a new sub-table is needed, it is necessary to look ahead in the\n   code lengths to determine what size sub-table is needed.  The length\n   counts are used for this, and so count[] is decremented as codes are\n   entered in the tables.\n\n   used keeps track of how many table entries have been allocated from the\n   provided *table space.  It is checked for LENS and DIST tables against\n   the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n   the initial root table size constants.  See the comments in inftrees.h\n   for more information.\n\n   sym increments through all symbols, and the loop terminates when\n   all codes of length max, i.e. all codes, have been processed.  This\n   routine permits incomplete codes, so another loop after this one fills\n   in the rest of the decoding tables with invalid code markers.\n   */\n\n  /* set up for code type */\n  // poor man optimization - use if-else instead of switch,\n  // to avoid deopts in old v8\n  if (type === CODES$1) {\n    base = extra = work;    /* dummy value--not used */\n    end = 19;\n\n  } else if (type === LENS$1) {\n    base = lbase;\n    base_index -= 257;\n    extra = lext;\n    extra_index -= 257;\n    end = 256;\n\n  } else {                    /* DISTS */\n    base = dbase;\n    extra = dext;\n    end = -1;\n  }\n\n  /* initialize opts for loop */\n  huff = 0;                   /* starting code */\n  sym = 0;                    /* starting code symbol */\n  len = min;                  /* starting code length */\n  next = table_index;              /* current table to fill in */\n  curr = root;                /* current table index bits */\n  drop = 0;                   /* current bits to drop from code for index */\n  low = -1;                   /* trigger new sub-table when len > root */\n  used = 1 << root;          /* use root table entries */\n  mask = used - 1;            /* mask for comparing low */\n\n  /* check available table space */\n  if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n    (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n    return 1;\n  }\n\n  /* process all codes and make table entries */\n  for (;;) {\n    /* create table entry */\n    here_bits = len - drop;\n    if (work[sym] < end) {\n      here_op = 0;\n      here_val = work[sym];\n    }\n    else if (work[sym] > end) {\n      here_op = extra[extra_index + work[sym]];\n      here_val = base[base_index + work[sym]];\n    }\n    else {\n      here_op = 32 + 64;         /* end of block */\n      here_val = 0;\n    }\n\n    /* replicate for those indices with low len bits equal to huff */\n    incr = 1 << (len - drop);\n    fill = 1 << curr;\n    min = fill;                 /* save offset to next table */\n    do {\n      fill -= incr;\n      table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n    } while (fill !== 0);\n\n    /* backwards increment the len-bit code huff */\n    incr = 1 << (len - 1);\n    while (huff & incr) {\n      incr >>= 1;\n    }\n    if (incr !== 0) {\n      huff &= incr - 1;\n      huff += incr;\n    } else {\n      huff = 0;\n    }\n\n    /* go to next symbol, update count, len */\n    sym++;\n    if (--count[len] === 0) {\n      if (len === max) { break; }\n      len = lens[lens_index + work[sym]];\n    }\n\n    /* create new sub-table if needed */\n    if (len > root && (huff & mask) !== low) {\n      /* if first time, transition to sub-tables */\n      if (drop === 0) {\n        drop = root;\n      }\n\n      /* increment past last table */\n      next += min;            /* here min is 1 << curr */\n\n      /* determine length of next table */\n      curr = len - drop;\n      left = 1 << curr;\n      while (curr + drop < max) {\n        left -= count[curr + drop];\n        if (left <= 0) { break; }\n        curr++;\n        left <<= 1;\n      }\n\n      /* check for enough space */\n      used += 1 << curr;\n      if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n        (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n        return 1;\n      }\n\n      /* point entry in root table to sub-table */\n      low = huff & mask;\n      /*table.op[low] = curr;\n      table.bits[low] = root;\n      table.val[low] = next - opts.table_index;*/\n      table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n    }\n  }\n\n  /* fill in remaining table entry if code is incomplete (guaranteed to have\n   at most one remaining entry, since if the code is incomplete, the\n   maximum code length that was allowed to get this far is one bit) */\n  if (huff !== 0) {\n    //table.op[next + huff] = 64;            /* invalid code marker */\n    //table.bits[next + huff] = len - drop;\n    //table.val[next + huff] = 0;\n    table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n  }\n\n  /* set return parameters */\n  //opts.table_index += used;\n  opts.bits = root;\n  return 0;\n};\n\n\nvar inftrees = inflate_table;\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n\n\n\n\n\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nconst {\n  Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,\n  Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,\n  Z_DEFLATED\n} = constants$2;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nconst    HEAD = 1;       /* i: waiting for magic header */\nconst    FLAGS = 2;      /* i: waiting for method and flags (gzip) */\nconst    TIME = 3;       /* i: waiting for modification time (gzip) */\nconst    OS = 4;         /* i: waiting for extra flags and operating system (gzip) */\nconst    EXLEN = 5;      /* i: waiting for extra length (gzip) */\nconst    EXTRA = 6;      /* i: waiting for extra bytes (gzip) */\nconst    NAME = 7;       /* i: waiting for end of file name (gzip) */\nconst    COMMENT = 8;    /* i: waiting for end of comment (gzip) */\nconst    HCRC = 9;       /* i: waiting for header crc (gzip) */\nconst    DICTID = 10;    /* i: waiting for dictionary check value */\nconst    DICT = 11;      /* waiting for inflateSetDictionary() call */\nconst        TYPE = 12;      /* i: waiting for type bits, including last-flag bit */\nconst        TYPEDO = 13;    /* i: same, but skip check to exit inflate on new block */\nconst        STORED = 14;    /* i: waiting for stored size (length and complement) */\nconst        COPY_ = 15;     /* i/o: same as COPY below, but only first time in */\nconst        COPY = 16;      /* i/o: waiting for input or output to copy stored block */\nconst        TABLE = 17;     /* i: waiting for dynamic block table lengths */\nconst        LENLENS = 18;   /* i: waiting for code length code lengths */\nconst        CODELENS = 19;  /* i: waiting for length/lit and distance code lengths */\nconst            LEN_ = 20;      /* i: same as LEN below, but only first time in */\nconst            LEN = 21;       /* i: waiting for length/lit/eob code */\nconst            LENEXT = 22;    /* i: waiting for length extra bits */\nconst            DIST = 23;      /* i: waiting for distance code */\nconst            DISTEXT = 24;   /* i: waiting for distance extra bits */\nconst            MATCH = 25;     /* o: waiting for output space to copy string */\nconst            LIT = 26;       /* o: waiting for output space to write literal */\nconst    CHECK = 27;     /* i: waiting for 32-bit check value */\nconst    LENGTH = 28;    /* i: waiting for 32-bit length (gzip) */\nconst    DONE = 29;      /* finished check, done -- remain here until reset */\nconst    BAD = 30;       /* got a data error -- remain here until reset */\nconst    MEM = 31;       /* got an inflate() memory error -- remain here until reset */\nconst    SYNC = 32;      /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\n//const ENOUGH =  (ENOUGH_LENS+ENOUGH_DISTS);\n\nconst MAX_WBITS = 15;\n/* 32K LZ77 window */\nconst DEF_WBITS = MAX_WBITS;\n\n\nconst zswap32 = (q) => {\n\n  return  (((q >>> 24) & 0xff) +\n          ((q >>> 8) & 0xff00) +\n          ((q & 0xff00) << 8) +\n          ((q & 0xff) << 24));\n};\n\n\nfunction InflateState() {\n  this.mode = 0;             /* current inflate mode */\n  this.last = false;          /* true if processing last block */\n  this.wrap = 0;              /* bit 0 true for zlib, bit 1 true for gzip */\n  this.havedict = false;      /* true if dictionary provided */\n  this.flags = 0;             /* gzip header method and flags (0 if zlib) */\n  this.dmax = 0;              /* zlib header max distance (INFLATE_STRICT) */\n  this.check = 0;             /* protected copy of check value */\n  this.total = 0;             /* protected copy of output count */\n  // TODO: may be {}\n  this.head = null;           /* where to save gzip header information */\n\n  /* sliding window */\n  this.wbits = 0;             /* log base 2 of requested window size */\n  this.wsize = 0;             /* window size or zero if not using window */\n  this.whave = 0;             /* valid bytes in the window */\n  this.wnext = 0;             /* window write index */\n  this.window = null;         /* allocated sliding window, if needed */\n\n  /* bit accumulator */\n  this.hold = 0;              /* input bit accumulator */\n  this.bits = 0;              /* number of bits in \"in\" */\n\n  /* for string and stored block copying */\n  this.length = 0;            /* literal or length of data to copy */\n  this.offset = 0;            /* distance back to copy string from */\n\n  /* for table and code decoding */\n  this.extra = 0;             /* extra bits needed */\n\n  /* fixed and dynamic code tables */\n  this.lencode = null;          /* starting table for length/literal codes */\n  this.distcode = null;         /* starting table for distance codes */\n  this.lenbits = 0;           /* index bits for lencode */\n  this.distbits = 0;          /* index bits for distcode */\n\n  /* dynamic table building */\n  this.ncode = 0;             /* number of code length code lengths */\n  this.nlen = 0;              /* number of length code lengths */\n  this.ndist = 0;             /* number of distance code lengths */\n  this.have = 0;              /* number of code lengths in lens[] */\n  this.next = null;              /* next available space in codes[] */\n\n  this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n  this.work = new Uint16Array(288); /* work area for code table building */\n\n  /*\n   because we don't have pointers in js, we use lencode and distcode directly\n   as buffers so we don't need codes\n  */\n  //this.codes = new Int32Array(ENOUGH);       /* space for code tables */\n  this.lendyn = null;              /* dynamic table for length/literal codes (JS specific) */\n  this.distdyn = null;             /* dynamic table for distance codes (JS specific) */\n  this.sane = 0;                   /* if false, allow invalid distance too far */\n  this.back = 0;                   /* bits back of last unprocessed length/lit */\n  this.was = 0;                    /* initial length of match */\n}\n\n\nconst inflateResetKeep = (strm) => {\n\n  if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n  const state = strm.state;\n  strm.total_in = strm.total_out = state.total = 0;\n  strm.msg = ''; /*Z_NULL*/\n  if (state.wrap) {       /* to support ill-conceived Java test suite */\n    strm.adler = state.wrap & 1;\n  }\n  state.mode = HEAD;\n  state.last = 0;\n  state.havedict = 0;\n  state.dmax = 32768;\n  state.head = null/*Z_NULL*/;\n  state.hold = 0;\n  state.bits = 0;\n  //state.lencode = state.distcode = state.next = state.codes;\n  state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n  state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n  state.sane = 1;\n  state.back = -1;\n  //Tracev((stderr, \"inflate: reset\\n\"));\n  return Z_OK$1;\n};\n\n\nconst inflateReset = (strm) => {\n\n  if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n  const state = strm.state;\n  state.wsize = 0;\n  state.whave = 0;\n  state.wnext = 0;\n  return inflateResetKeep(strm);\n\n};\n\n\nconst inflateReset2 = (strm, windowBits) => {\n  let wrap;\n\n  /* get the state */\n  if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n  const state = strm.state;\n\n  /* extract wrap request from windowBits parameter */\n  if (windowBits < 0) {\n    wrap = 0;\n    windowBits = -windowBits;\n  }\n  else {\n    wrap = (windowBits >> 4) + 1;\n    if (windowBits < 48) {\n      windowBits &= 15;\n    }\n  }\n\n  /* set number of window bits, free window if different */\n  if (windowBits && (windowBits < 8 || windowBits > 15)) {\n    return Z_STREAM_ERROR$1;\n  }\n  if (state.window !== null && state.wbits !== windowBits) {\n    state.window = null;\n  }\n\n  /* update state and reset the rest of it */\n  state.wrap = wrap;\n  state.wbits = windowBits;\n  return inflateReset(strm);\n};\n\n\nconst inflateInit2 = (strm, windowBits) => {\n\n  if (!strm) { return Z_STREAM_ERROR$1; }\n  //strm.msg = Z_NULL;                 /* in case we return an error */\n\n  const state = new InflateState();\n\n  //if (state === Z_NULL) return Z_MEM_ERROR;\n  //Tracev((stderr, \"inflate: allocated\\n\"));\n  strm.state = state;\n  state.window = null/*Z_NULL*/;\n  const ret = inflateReset2(strm, windowBits);\n  if (ret !== Z_OK$1) {\n    strm.state = null/*Z_NULL*/;\n  }\n  return ret;\n};\n\n\nconst inflateInit = (strm) => {\n\n  return inflateInit2(strm, DEF_WBITS);\n};\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter.  This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time.  However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nlet virgin = true;\n\nlet lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\n\nconst fixedtables = (state) => {\n\n  /* build fixed huffman tables if first call (may not be thread safe) */\n  if (virgin) {\n    lenfix = new Int32Array(512);\n    distfix = new Int32Array(32);\n\n    /* literal/length table */\n    let sym = 0;\n    while (sym < 144) { state.lens[sym++] = 8; }\n    while (sym < 256) { state.lens[sym++] = 9; }\n    while (sym < 280) { state.lens[sym++] = 7; }\n    while (sym < 288) { state.lens[sym++] = 8; }\n\n    inftrees(LENS,  state.lens, 0, 288, lenfix,   0, state.work, { bits: 9 });\n\n    /* distance table */\n    sym = 0;\n    while (sym < 32) { state.lens[sym++] = 5; }\n\n    inftrees(DISTS, state.lens, 0, 32,   distfix, 0, state.work, { bits: 5 });\n\n    /* do this just once */\n    virgin = false;\n  }\n\n  state.lencode = lenfix;\n  state.lenbits = 9;\n  state.distcode = distfix;\n  state.distbits = 5;\n};\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning.  If window does not exist yet, create it.  This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nconst updatewindow = (strm, src, end, copy) => {\n\n  let dist;\n  const state = strm.state;\n\n  /* if it hasn't been done already, allocate space for the window */\n  if (state.window === null) {\n    state.wsize = 1 << state.wbits;\n    state.wnext = 0;\n    state.whave = 0;\n\n    state.window = new Uint8Array(state.wsize);\n  }\n\n  /* copy state->wsize or less output bytes into the circular window */\n  if (copy >= state.wsize) {\n    state.window.set(src.subarray(end - state.wsize, end), 0);\n    state.wnext = 0;\n    state.whave = state.wsize;\n  }\n  else {\n    dist = state.wsize - state.wnext;\n    if (dist > copy) {\n      dist = copy;\n    }\n    //zmemcpy(state->window + state->wnext, end - copy, dist);\n    state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n    copy -= dist;\n    if (copy) {\n      //zmemcpy(state->window, end - copy, copy);\n      state.window.set(src.subarray(end - copy, end), 0);\n      state.wnext = copy;\n      state.whave = state.wsize;\n    }\n    else {\n      state.wnext += dist;\n      if (state.wnext === state.wsize) { state.wnext = 0; }\n      if (state.whave < state.wsize) { state.whave += dist; }\n    }\n  }\n  return 0;\n};\n\n\nconst inflate$2 = (strm, flush) => {\n\n  let state;\n  let input, output;          // input/output buffers\n  let next;                   /* next input INDEX */\n  let put;                    /* next output INDEX */\n  let have, left;             /* available input and output */\n  let hold;                   /* bit buffer */\n  let bits;                   /* bits in bit buffer */\n  let _in, _out;              /* save starting available input and output */\n  let copy;                   /* number of stored or match bytes to copy */\n  let from;                   /* where to copy match bytes from */\n  let from_source;\n  let here = 0;               /* current decoding table entry */\n  let here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n  //let last;                   /* parent table entry */\n  let last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n  let len;                    /* length to copy for repeats, bits to drop */\n  let ret;                    /* return code */\n  const hbuf = new Uint8Array(4);    /* buffer for gzip header crc calculation */\n  let opts;\n\n  let n; // temporary variable for NEED_BITS\n\n  const order = /* permutation of code lengths */\n    new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);\n\n\n  if (!strm || !strm.state || !strm.output ||\n      (!strm.input && strm.avail_in !== 0)) {\n    return Z_STREAM_ERROR$1;\n  }\n\n  state = strm.state;\n  if (state.mode === TYPE) { state.mode = TYPEDO; }    /* skip check */\n\n\n  //--- LOAD() ---\n  put = strm.next_out;\n  output = strm.output;\n  left = strm.avail_out;\n  next = strm.next_in;\n  input = strm.input;\n  have = strm.avail_in;\n  hold = state.hold;\n  bits = state.bits;\n  //---\n\n  _in = have;\n  _out = left;\n  ret = Z_OK$1;\n\n  inf_leave: // goto emulation\n  for (;;) {\n    switch (state.mode) {\n      case HEAD:\n        if (state.wrap === 0) {\n          state.mode = TYPEDO;\n          break;\n        }\n        //=== NEEDBITS(16);\n        while (bits < 16) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if ((state.wrap & 2) && hold === 0x8b1f) {  /* gzip header */\n          state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n          //=== CRC2(state.check, hold);\n          hbuf[0] = hold & 0xff;\n          hbuf[1] = (hold >>> 8) & 0xff;\n          state.check = crc32_1(state.check, hbuf, 2, 0);\n          //===//\n\n          //=== INITBITS();\n          hold = 0;\n          bits = 0;\n          //===//\n          state.mode = FLAGS;\n          break;\n        }\n        state.flags = 0;           /* expect zlib header */\n        if (state.head) {\n          state.head.done = false;\n        }\n        if (!(state.wrap & 1) ||   /* check if zlib header allowed */\n          (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n          strm.msg = 'incorrect header check';\n          state.mode = BAD;\n          break;\n        }\n        if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n          strm.msg = 'unknown compression method';\n          state.mode = BAD;\n          break;\n        }\n        //--- DROPBITS(4) ---//\n        hold >>>= 4;\n        bits -= 4;\n        //---//\n        len = (hold & 0x0f)/*BITS(4)*/ + 8;\n        if (state.wbits === 0) {\n          state.wbits = len;\n        }\n        else if (len > state.wbits) {\n          strm.msg = 'invalid window size';\n          state.mode = BAD;\n          break;\n        }\n\n        // !!! pako patch. Force use `options.windowBits` if passed.\n        // Required to always use max window size by default.\n        state.dmax = 1 << state.wbits;\n        //state.dmax = 1 << len;\n\n        //Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n        strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n        state.mode = hold & 0x200 ? DICTID : TYPE;\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        break;\n      case FLAGS:\n        //=== NEEDBITS(16); */\n        while (bits < 16) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.flags = hold;\n        if ((state.flags & 0xff) !== Z_DEFLATED) {\n          strm.msg = 'unknown compression method';\n          state.mode = BAD;\n          break;\n        }\n        if (state.flags & 0xe000) {\n          strm.msg = 'unknown header flags set';\n          state.mode = BAD;\n          break;\n        }\n        if (state.head) {\n          state.head.text = ((hold >> 8) & 1);\n        }\n        if (state.flags & 0x0200) {\n          //=== CRC2(state.check, hold);\n          hbuf[0] = hold & 0xff;\n          hbuf[1] = (hold >>> 8) & 0xff;\n          state.check = crc32_1(state.check, hbuf, 2, 0);\n          //===//\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = TIME;\n        /* falls through */\n      case TIME:\n        //=== NEEDBITS(32); */\n        while (bits < 32) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if (state.head) {\n          state.head.time = hold;\n        }\n        if (state.flags & 0x0200) {\n          //=== CRC4(state.check, hold)\n          hbuf[0] = hold & 0xff;\n          hbuf[1] = (hold >>> 8) & 0xff;\n          hbuf[2] = (hold >>> 16) & 0xff;\n          hbuf[3] = (hold >>> 24) & 0xff;\n          state.check = crc32_1(state.check, hbuf, 4, 0);\n          //===\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = OS;\n        /* falls through */\n      case OS:\n        //=== NEEDBITS(16); */\n        while (bits < 16) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if (state.head) {\n          state.head.xflags = (hold & 0xff);\n          state.head.os = (hold >> 8);\n        }\n        if (state.flags & 0x0200) {\n          //=== CRC2(state.check, hold);\n          hbuf[0] = hold & 0xff;\n          hbuf[1] = (hold >>> 8) & 0xff;\n          state.check = crc32_1(state.check, hbuf, 2, 0);\n          //===//\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = EXLEN;\n        /* falls through */\n      case EXLEN:\n        if (state.flags & 0x0400) {\n          //=== NEEDBITS(16); */\n          while (bits < 16) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          state.length = hold;\n          if (state.head) {\n            state.head.extra_len = hold;\n          }\n          if (state.flags & 0x0200) {\n            //=== CRC2(state.check, hold);\n            hbuf[0] = hold & 0xff;\n            hbuf[1] = (hold >>> 8) & 0xff;\n            state.check = crc32_1(state.check, hbuf, 2, 0);\n            //===//\n          }\n          //=== INITBITS();\n          hold = 0;\n          bits = 0;\n          //===//\n        }\n        else if (state.head) {\n          state.head.extra = null/*Z_NULL*/;\n        }\n        state.mode = EXTRA;\n        /* falls through */\n      case EXTRA:\n        if (state.flags & 0x0400) {\n          copy = state.length;\n          if (copy > have) { copy = have; }\n          if (copy) {\n            if (state.head) {\n              len = state.head.extra_len - state.length;\n              if (!state.head.extra) {\n                // Use untyped array for more convenient processing later\n                state.head.extra = new Uint8Array(state.head.extra_len);\n              }\n              state.head.extra.set(\n                input.subarray(\n                  next,\n                  // extra field is limited to 65536 bytes\n                  // - no need for additional size check\n                  next + copy\n                ),\n                /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n                len\n              );\n              //zmemcpy(state.head.extra + len, next,\n              //        len + copy > state.head.extra_max ?\n              //        state.head.extra_max - len : copy);\n            }\n            if (state.flags & 0x0200) {\n              state.check = crc32_1(state.check, input, copy, next);\n            }\n            have -= copy;\n            next += copy;\n            state.length -= copy;\n          }\n          if (state.length) { break inf_leave; }\n        }\n        state.length = 0;\n        state.mode = NAME;\n        /* falls through */\n      case NAME:\n        if (state.flags & 0x0800) {\n          if (have === 0) { break inf_leave; }\n          copy = 0;\n          do {\n            // TODO: 2 or 1 bytes?\n            len = input[next + copy++];\n            /* use constant limit because in js we should not preallocate memory */\n            if (state.head && len &&\n                (state.length < 65536 /*state.head.name_max*/)) {\n              state.head.name += String.fromCharCode(len);\n            }\n          } while (len && copy < have);\n\n          if (state.flags & 0x0200) {\n            state.check = crc32_1(state.check, input, copy, next);\n          }\n          have -= copy;\n          next += copy;\n          if (len) { break inf_leave; }\n        }\n        else if (state.head) {\n          state.head.name = null;\n        }\n        state.length = 0;\n        state.mode = COMMENT;\n        /* falls through */\n      case COMMENT:\n        if (state.flags & 0x1000) {\n          if (have === 0) { break inf_leave; }\n          copy = 0;\n          do {\n            len = input[next + copy++];\n            /* use constant limit because in js we should not preallocate memory */\n            if (state.head && len &&\n                (state.length < 65536 /*state.head.comm_max*/)) {\n              state.head.comment += String.fromCharCode(len);\n            }\n          } while (len && copy < have);\n          if (state.flags & 0x0200) {\n            state.check = crc32_1(state.check, input, copy, next);\n          }\n          have -= copy;\n          next += copy;\n          if (len) { break inf_leave; }\n        }\n        else if (state.head) {\n          state.head.comment = null;\n        }\n        state.mode = HCRC;\n        /* falls through */\n      case HCRC:\n        if (state.flags & 0x0200) {\n          //=== NEEDBITS(16); */\n          while (bits < 16) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          if (hold !== (state.check & 0xffff)) {\n            strm.msg = 'header crc mismatch';\n            state.mode = BAD;\n            break;\n          }\n          //=== INITBITS();\n          hold = 0;\n          bits = 0;\n          //===//\n        }\n        if (state.head) {\n          state.head.hcrc = ((state.flags >> 9) & 1);\n          state.head.done = true;\n        }\n        strm.adler = state.check = 0;\n        state.mode = TYPE;\n        break;\n      case DICTID:\n        //=== NEEDBITS(32); */\n        while (bits < 32) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        strm.adler = state.check = zswap32(hold);\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = DICT;\n        /* falls through */\n      case DICT:\n        if (state.havedict === 0) {\n          //--- RESTORE() ---\n          strm.next_out = put;\n          strm.avail_out = left;\n          strm.next_in = next;\n          strm.avail_in = have;\n          state.hold = hold;\n          state.bits = bits;\n          //---\n          return Z_NEED_DICT$1;\n        }\n        strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n        state.mode = TYPE;\n        /* falls through */\n      case TYPE:\n        if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n        /* falls through */\n      case TYPEDO:\n        if (state.last) {\n          //--- BYTEBITS() ---//\n          hold >>>= bits & 7;\n          bits -= bits & 7;\n          //---//\n          state.mode = CHECK;\n          break;\n        }\n        //=== NEEDBITS(3); */\n        while (bits < 3) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.last = (hold & 0x01)/*BITS(1)*/;\n        //--- DROPBITS(1) ---//\n        hold >>>= 1;\n        bits -= 1;\n        //---//\n\n        switch ((hold & 0x03)/*BITS(2)*/) {\n          case 0:                             /* stored block */\n            //Tracev((stderr, \"inflate:     stored block%s\\n\",\n            //        state.last ? \" (last)\" : \"\"));\n            state.mode = STORED;\n            break;\n          case 1:                             /* fixed block */\n            fixedtables(state);\n            //Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n            //        state.last ? \" (last)\" : \"\"));\n            state.mode = LEN_;             /* decode codes */\n            if (flush === Z_TREES) {\n              //--- DROPBITS(2) ---//\n              hold >>>= 2;\n              bits -= 2;\n              //---//\n              break inf_leave;\n            }\n            break;\n          case 2:                             /* dynamic block */\n            //Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n            //        state.last ? \" (last)\" : \"\"));\n            state.mode = TABLE;\n            break;\n          case 3:\n            strm.msg = 'invalid block type';\n            state.mode = BAD;\n        }\n        //--- DROPBITS(2) ---//\n        hold >>>= 2;\n        bits -= 2;\n        //---//\n        break;\n      case STORED:\n        //--- BYTEBITS() ---// /* go to byte boundary */\n        hold >>>= bits & 7;\n        bits -= bits & 7;\n        //---//\n        //=== NEEDBITS(32); */\n        while (bits < 32) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n          strm.msg = 'invalid stored block lengths';\n          state.mode = BAD;\n          break;\n        }\n        state.length = hold & 0xffff;\n        //Tracev((stderr, \"inflate:       stored length %u\\n\",\n        //        state.length));\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = COPY_;\n        if (flush === Z_TREES) { break inf_leave; }\n        /* falls through */\n      case COPY_:\n        state.mode = COPY;\n        /* falls through */\n      case COPY:\n        copy = state.length;\n        if (copy) {\n          if (copy > have) { copy = have; }\n          if (copy > left) { copy = left; }\n          if (copy === 0) { break inf_leave; }\n          //--- zmemcpy(put, next, copy); ---\n          output.set(input.subarray(next, next + copy), put);\n          //---//\n          have -= copy;\n          next += copy;\n          left -= copy;\n          put += copy;\n          state.length -= copy;\n          break;\n        }\n        //Tracev((stderr, \"inflate:       stored end\\n\"));\n        state.mode = TYPE;\n        break;\n      case TABLE:\n        //=== NEEDBITS(14); */\n        while (bits < 14) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n        //--- DROPBITS(5) ---//\n        hold >>>= 5;\n        bits -= 5;\n        //---//\n        state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n        //--- DROPBITS(5) ---//\n        hold >>>= 5;\n        bits -= 5;\n        //---//\n        state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n        //--- DROPBITS(4) ---//\n        hold >>>= 4;\n        bits -= 4;\n        //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n        if (state.nlen > 286 || state.ndist > 30) {\n          strm.msg = 'too many length or distance symbols';\n          state.mode = BAD;\n          break;\n        }\n//#endif\n        //Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n        state.have = 0;\n        state.mode = LENLENS;\n        /* falls through */\n      case LENLENS:\n        while (state.have < state.ncode) {\n          //=== NEEDBITS(3);\n          while (bits < 3) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n          //--- DROPBITS(3) ---//\n          hold >>>= 3;\n          bits -= 3;\n          //---//\n        }\n        while (state.have < 19) {\n          state.lens[order[state.have++]] = 0;\n        }\n        // We have separate tables & no pointers. 2 commented lines below not needed.\n        //state.next = state.codes;\n        //state.lencode = state.next;\n        // Switch to use dynamic table\n        state.lencode = state.lendyn;\n        state.lenbits = 7;\n\n        opts = { bits: state.lenbits };\n        ret = inftrees(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n        state.lenbits = opts.bits;\n\n        if (ret) {\n          strm.msg = 'invalid code lengths set';\n          state.mode = BAD;\n          break;\n        }\n        //Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n        state.have = 0;\n        state.mode = CODELENS;\n        /* falls through */\n      case CODELENS:\n        while (state.have < state.nlen + state.ndist) {\n          for (;;) {\n            here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n            here_bits = here >>> 24;\n            here_op = (here >>> 16) & 0xff;\n            here_val = here & 0xffff;\n\n            if ((here_bits) <= bits) { break; }\n            //--- PULLBYTE() ---//\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n            //---//\n          }\n          if (here_val < 16) {\n            //--- DROPBITS(here.bits) ---//\n            hold >>>= here_bits;\n            bits -= here_bits;\n            //---//\n            state.lens[state.have++] = here_val;\n          }\n          else {\n            if (here_val === 16) {\n              //=== NEEDBITS(here.bits + 2);\n              n = here_bits + 2;\n              while (bits < n) {\n                if (have === 0) { break inf_leave; }\n                have--;\n                hold += input[next++] << bits;\n                bits += 8;\n              }\n              //===//\n              //--- DROPBITS(here.bits) ---//\n              hold >>>= here_bits;\n              bits -= here_bits;\n              //---//\n              if (state.have === 0) {\n                strm.msg = 'invalid bit length repeat';\n                state.mode = BAD;\n                break;\n              }\n              len = state.lens[state.have - 1];\n              copy = 3 + (hold & 0x03);//BITS(2);\n              //--- DROPBITS(2) ---//\n              hold >>>= 2;\n              bits -= 2;\n              //---//\n            }\n            else if (here_val === 17) {\n              //=== NEEDBITS(here.bits + 3);\n              n = here_bits + 3;\n              while (bits < n) {\n                if (have === 0) { break inf_leave; }\n                have--;\n                hold += input[next++] << bits;\n                bits += 8;\n              }\n              //===//\n              //--- DROPBITS(here.bits) ---//\n              hold >>>= here_bits;\n              bits -= here_bits;\n              //---//\n              len = 0;\n              copy = 3 + (hold & 0x07);//BITS(3);\n              //--- DROPBITS(3) ---//\n              hold >>>= 3;\n              bits -= 3;\n              //---//\n            }\n            else {\n              //=== NEEDBITS(here.bits + 7);\n              n = here_bits + 7;\n              while (bits < n) {\n                if (have === 0) { break inf_leave; }\n                have--;\n                hold += input[next++] << bits;\n                bits += 8;\n              }\n              //===//\n              //--- DROPBITS(here.bits) ---//\n              hold >>>= here_bits;\n              bits -= here_bits;\n              //---//\n              len = 0;\n              copy = 11 + (hold & 0x7f);//BITS(7);\n              //--- DROPBITS(7) ---//\n              hold >>>= 7;\n              bits -= 7;\n              //---//\n            }\n            if (state.have + copy > state.nlen + state.ndist) {\n              strm.msg = 'invalid bit length repeat';\n              state.mode = BAD;\n              break;\n            }\n            while (copy--) {\n              state.lens[state.have++] = len;\n            }\n          }\n        }\n\n        /* handle error breaks in while */\n        if (state.mode === BAD) { break; }\n\n        /* check for end-of-block code (better have one) */\n        if (state.lens[256] === 0) {\n          strm.msg = 'invalid code -- missing end-of-block';\n          state.mode = BAD;\n          break;\n        }\n\n        /* build code tables -- note: do not change the lenbits or distbits\n           values here (9 and 6) without reading the comments in inftrees.h\n           concerning the ENOUGH constants, which depend on those values */\n        state.lenbits = 9;\n\n        opts = { bits: state.lenbits };\n        ret = inftrees(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n        // We have separate tables & no pointers. 2 commented lines below not needed.\n        // state.next_index = opts.table_index;\n        state.lenbits = opts.bits;\n        // state.lencode = state.next;\n\n        if (ret) {\n          strm.msg = 'invalid literal/lengths set';\n          state.mode = BAD;\n          break;\n        }\n\n        state.distbits = 6;\n        //state.distcode.copy(state.codes);\n        // Switch to use dynamic table\n        state.distcode = state.distdyn;\n        opts = { bits: state.distbits };\n        ret = inftrees(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n        // We have separate tables & no pointers. 2 commented lines below not needed.\n        // state.next_index = opts.table_index;\n        state.distbits = opts.bits;\n        // state.distcode = state.next;\n\n        if (ret) {\n          strm.msg = 'invalid distances set';\n          state.mode = BAD;\n          break;\n        }\n        //Tracev((stderr, 'inflate:       codes ok\\n'));\n        state.mode = LEN_;\n        if (flush === Z_TREES) { break inf_leave; }\n        /* falls through */\n      case LEN_:\n        state.mode = LEN;\n        /* falls through */\n      case LEN:\n        if (have >= 6 && left >= 258) {\n          //--- RESTORE() ---\n          strm.next_out = put;\n          strm.avail_out = left;\n          strm.next_in = next;\n          strm.avail_in = have;\n          state.hold = hold;\n          state.bits = bits;\n          //---\n          inffast(strm, _out);\n          //--- LOAD() ---\n          put = strm.next_out;\n          output = strm.output;\n          left = strm.avail_out;\n          next = strm.next_in;\n          input = strm.input;\n          have = strm.avail_in;\n          hold = state.hold;\n          bits = state.bits;\n          //---\n\n          if (state.mode === TYPE) {\n            state.back = -1;\n          }\n          break;\n        }\n        state.back = 0;\n        for (;;) {\n          here = state.lencode[hold & ((1 << state.lenbits) - 1)];  /*BITS(state.lenbits)*/\n          here_bits = here >>> 24;\n          here_op = (here >>> 16) & 0xff;\n          here_val = here & 0xffff;\n\n          if (here_bits <= bits) { break; }\n          //--- PULLBYTE() ---//\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n          //---//\n        }\n        if (here_op && (here_op & 0xf0) === 0) {\n          last_bits = here_bits;\n          last_op = here_op;\n          last_val = here_val;\n          for (;;) {\n            here = state.lencode[last_val +\n                    ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n            here_bits = here >>> 24;\n            here_op = (here >>> 16) & 0xff;\n            here_val = here & 0xffff;\n\n            if ((last_bits + here_bits) <= bits) { break; }\n            //--- PULLBYTE() ---//\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n            //---//\n          }\n          //--- DROPBITS(last.bits) ---//\n          hold >>>= last_bits;\n          bits -= last_bits;\n          //---//\n          state.back += last_bits;\n        }\n        //--- DROPBITS(here.bits) ---//\n        hold >>>= here_bits;\n        bits -= here_bits;\n        //---//\n        state.back += here_bits;\n        state.length = here_val;\n        if (here_op === 0) {\n          //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n          //        \"inflate:         literal '%c'\\n\" :\n          //        \"inflate:         literal 0x%02x\\n\", here.val));\n          state.mode = LIT;\n          break;\n        }\n        if (here_op & 32) {\n          //Tracevv((stderr, \"inflate:         end of block\\n\"));\n          state.back = -1;\n          state.mode = TYPE;\n          break;\n        }\n        if (here_op & 64) {\n          strm.msg = 'invalid literal/length code';\n          state.mode = BAD;\n          break;\n        }\n        state.extra = here_op & 15;\n        state.mode = LENEXT;\n        /* falls through */\n      case LENEXT:\n        if (state.extra) {\n          //=== NEEDBITS(state.extra);\n          n = state.extra;\n          while (bits < n) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n          //--- DROPBITS(state.extra) ---//\n          hold >>>= state.extra;\n          bits -= state.extra;\n          //---//\n          state.back += state.extra;\n        }\n        //Tracevv((stderr, \"inflate:         length %u\\n\", state.length));\n        state.was = state.length;\n        state.mode = DIST;\n        /* falls through */\n      case DIST:\n        for (;;) {\n          here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n          here_bits = here >>> 24;\n          here_op = (here >>> 16) & 0xff;\n          here_val = here & 0xffff;\n\n          if ((here_bits) <= bits) { break; }\n          //--- PULLBYTE() ---//\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n          //---//\n        }\n        if ((here_op & 0xf0) === 0) {\n          last_bits = here_bits;\n          last_op = here_op;\n          last_val = here_val;\n          for (;;) {\n            here = state.distcode[last_val +\n                    ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n            here_bits = here >>> 24;\n            here_op = (here >>> 16) & 0xff;\n            here_val = here & 0xffff;\n\n            if ((last_bits + here_bits) <= bits) { break; }\n            //--- PULLBYTE() ---//\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n            //---//\n          }\n          //--- DROPBITS(last.bits) ---//\n          hold >>>= last_bits;\n          bits -= last_bits;\n          //---//\n          state.back += last_bits;\n        }\n        //--- DROPBITS(here.bits) ---//\n        hold >>>= here_bits;\n        bits -= here_bits;\n        //---//\n        state.back += here_bits;\n        if (here_op & 64) {\n          strm.msg = 'invalid distance code';\n          state.mode = BAD;\n          break;\n        }\n        state.offset = here_val;\n        state.extra = (here_op) & 15;\n        state.mode = DISTEXT;\n        /* falls through */\n      case DISTEXT:\n        if (state.extra) {\n          //=== NEEDBITS(state.extra);\n          n = state.extra;\n          while (bits < n) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n          //--- DROPBITS(state.extra) ---//\n          hold >>>= state.extra;\n          bits -= state.extra;\n          //---//\n          state.back += state.extra;\n        }\n//#ifdef INFLATE_STRICT\n        if (state.offset > state.dmax) {\n          strm.msg = 'invalid distance too far back';\n          state.mode = BAD;\n          break;\n        }\n//#endif\n        //Tracevv((stderr, \"inflate:         distance %u\\n\", state.offset));\n        state.mode = MATCH;\n        /* falls through */\n      case MATCH:\n        if (left === 0) { break inf_leave; }\n        copy = _out - left;\n        if (state.offset > copy) {         /* copy from window */\n          copy = state.offset - copy;\n          if (copy > state.whave) {\n            if (state.sane) {\n              strm.msg = 'invalid distance too far back';\n              state.mode = BAD;\n              break;\n            }\n// (!) This block is disabled in zlib defaults,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n//          Trace((stderr, \"inflate.c too far\\n\"));\n//          copy -= state.whave;\n//          if (copy > state.length) { copy = state.length; }\n//          if (copy > left) { copy = left; }\n//          left -= copy;\n//          state.length -= copy;\n//          do {\n//            output[put++] = 0;\n//          } while (--copy);\n//          if (state.length === 0) { state.mode = LEN; }\n//          break;\n//#endif\n          }\n          if (copy > state.wnext) {\n            copy -= state.wnext;\n            from = state.wsize - copy;\n          }\n          else {\n            from = state.wnext - copy;\n          }\n          if (copy > state.length) { copy = state.length; }\n          from_source = state.window;\n        }\n        else {                              /* copy from output */\n          from_source = output;\n          from = put - state.offset;\n          copy = state.length;\n        }\n        if (copy > left) { copy = left; }\n        left -= copy;\n        state.length -= copy;\n        do {\n          output[put++] = from_source[from++];\n        } while (--copy);\n        if (state.length === 0) { state.mode = LEN; }\n        break;\n      case LIT:\n        if (left === 0) { break inf_leave; }\n        output[put++] = state.length;\n        left--;\n        state.mode = LEN;\n        break;\n      case CHECK:\n        if (state.wrap) {\n          //=== NEEDBITS(32);\n          while (bits < 32) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            // Use '|' instead of '+' to make sure that result is signed\n            hold |= input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          _out -= left;\n          strm.total_out += _out;\n          state.total += _out;\n          if (_out) {\n            strm.adler = state.check =\n                /*UPDATE(state.check, put - _out, _out);*/\n                (state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));\n\n          }\n          _out = left;\n          // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n          if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n            strm.msg = 'incorrect data check';\n            state.mode = BAD;\n            break;\n          }\n          //=== INITBITS();\n          hold = 0;\n          bits = 0;\n          //===//\n          //Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n        }\n        state.mode = LENGTH;\n        /* falls through */\n      case LENGTH:\n        if (state.wrap && state.flags) {\n          //=== NEEDBITS(32);\n          while (bits < 32) {\n            if (have === 0) { break inf_leave; }\n            have--;\n            hold += input[next++] << bits;\n            bits += 8;\n          }\n          //===//\n          if (hold !== (state.total & 0xffffffff)) {\n            strm.msg = 'incorrect length check';\n            state.mode = BAD;\n            break;\n          }\n          //=== INITBITS();\n          hold = 0;\n          bits = 0;\n          //===//\n          //Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n        }\n        state.mode = DONE;\n        /* falls through */\n      case DONE:\n        ret = Z_STREAM_END$1;\n        break inf_leave;\n      case BAD:\n        ret = Z_DATA_ERROR$1;\n        break inf_leave;\n      case MEM:\n        return Z_MEM_ERROR$1;\n      case SYNC:\n        /* falls through */\n      default:\n        return Z_STREAM_ERROR$1;\n    }\n  }\n\n  // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n  /*\n     Return from inflate(), updating the total counts and the check value.\n     If there was no progress during the inflate() call, return a buffer\n     error.  Call updatewindow() to create and/or update the window state.\n     Note: a memory error from inflate() is non-recoverable.\n   */\n\n  //--- RESTORE() ---\n  strm.next_out = put;\n  strm.avail_out = left;\n  strm.next_in = next;\n  strm.avail_in = have;\n  state.hold = hold;\n  state.bits = bits;\n  //---\n\n  if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n                      (state.mode < CHECK || flush !== Z_FINISH$1))) {\n    if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n  }\n  _in -= strm.avail_in;\n  _out -= strm.avail_out;\n  strm.total_in += _in;\n  strm.total_out += _out;\n  state.total += _out;\n  if (state.wrap && _out) {\n    strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n      (state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));\n  }\n  strm.data_type = state.bits + (state.last ? 64 : 0) +\n                    (state.mode === TYPE ? 128 : 0) +\n                    (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n  if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {\n    ret = Z_BUF_ERROR;\n  }\n  return ret;\n};\n\n\nconst inflateEnd = (strm) => {\n\n  if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n    return Z_STREAM_ERROR$1;\n  }\n\n  let state = strm.state;\n  if (state.window) {\n    state.window = null;\n  }\n  strm.state = null;\n  return Z_OK$1;\n};\n\n\nconst inflateGetHeader = (strm, head) => {\n\n  /* check state */\n  if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }\n  const state = strm.state;\n  if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }\n\n  /* save header structure */\n  state.head = head;\n  head.done = false;\n  return Z_OK$1;\n};\n\n\nconst inflateSetDictionary = (strm, dictionary) => {\n  const dictLength = dictionary.length;\n\n  let state;\n  let dictid;\n  let ret;\n\n  /* check state */\n  if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }\n  state = strm.state;\n\n  if (state.wrap !== 0 && state.mode !== DICT) {\n    return Z_STREAM_ERROR$1;\n  }\n\n  /* check for correct dictionary identifier */\n  if (state.mode === DICT) {\n    dictid = 1; /* adler32(0, null, 0)*/\n    /* dictid = adler32(dictid, dictionary, dictLength); */\n    dictid = adler32_1(dictid, dictionary, dictLength, 0);\n    if (dictid !== state.check) {\n      return Z_DATA_ERROR$1;\n    }\n  }\n  /* copy dictionary to window using updatewindow(), which will amend the\n   existing dictionary if appropriate */\n  ret = updatewindow(strm, dictionary, dictLength, dictLength);\n  if (ret) {\n    state.mode = MEM;\n    return Z_MEM_ERROR$1;\n  }\n  state.havedict = 1;\n  // Tracev((stderr, \"inflate:   dictionary set\\n\"));\n  return Z_OK$1;\n};\n\n\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nmodule.exports.inflateCopy = inflateCopy;\nmodule.exports.inflateGetDictionary = inflateGetDictionary;\nmodule.exports.inflateMark = inflateMark;\nmodule.exports.inflatePrime = inflatePrime;\nmodule.exports.inflateSync = inflateSync;\nmodule.exports.inflateSyncPoint = inflateSyncPoint;\nmodule.exports.inflateUndermine = inflateUndermine;\n*/\n\nvar inflate_1$2 = {\n\tinflateReset: inflateReset_1,\n\tinflateReset2: inflateReset2_1,\n\tinflateResetKeep: inflateResetKeep_1,\n\tinflateInit: inflateInit_1,\n\tinflateInit2: inflateInit2_1,\n\tinflate: inflate_2$1,\n\tinflateEnd: inflateEnd_1,\n\tinflateGetHeader: inflateGetHeader_1,\n\tinflateSetDictionary: inflateSetDictionary_1,\n\tinflateInfo: inflateInfo\n};\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n  /* true if compressed data believed to be text */\n  this.text       = 0;\n  /* modification time */\n  this.time       = 0;\n  /* extra flags (not used when writing a gzip file) */\n  this.xflags     = 0;\n  /* operating system */\n  this.os         = 0;\n  /* pointer to extra field or Z_NULL if none */\n  this.extra      = null;\n  /* extra field length (valid if extra != Z_NULL) */\n  this.extra_len  = 0; // Actually, we don't need it in JS,\n                       // but leave for few code modifications\n\n  //\n  // Setup limits is not necessary because in js we should not preallocate memory\n  // for inflate use constant limit in 65536 bytes\n  //\n\n  /* space at extra (only when reading header) */\n  // this.extra_max  = 0;\n  /* pointer to zero-terminated file name or Z_NULL */\n  this.name       = '';\n  /* space at name (only when reading header) */\n  // this.name_max   = 0;\n  /* pointer to zero-terminated comment or Z_NULL */\n  this.comment    = '';\n  /* space at comment (only when reading header) */\n  // this.comm_max   = 0;\n  /* true if there was or will be a header crc */\n  this.hcrc       = 0;\n  /* true when done reading gzip header (not used when writing a gzip file) */\n  this.done       = false;\n}\n\nvar gzheader = GZheader;\n\nconst toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/