{ "version": 3, "sources": [ "webpack://dicomParser/webpack/universalModuleDefinition", "webpack://dicomParser/external \"zlib\"", "webpack://dicomParser/./util/util.js", "webpack://dicomParser/./util/parseTM.js", "webpack://dicomParser/./util/parseDA.js", "webpack://dicomParser/./util/elementToString.js", "webpack://dicomParser/./util/dataSetToJS.js", "webpack://dicomParser/./util/createJPEGBasicOffsetTable.js", "webpack://dicomParser/./readTag.js", "webpack://dicomParser/./findEndOfEncapsulatedPixelData.js", "webpack://dicomParser/./findAndSetUNElementLength.js", "webpack://dicomParser/./byteArrayParser.js", "webpack://dicomParser/./dataSet.js", "webpack://dicomParser/./findItemDelimitationItem.js", "webpack://dicomParser/./readDicomElementImplicit.js", "webpack://dicomParser/./readSequenceItem.js", "webpack://dicomParser/./readSequenceElementImplicit.js", "webpack://dicomParser/./readSequenceElementExplicit.js", "webpack://dicomParser/./readDicomElementExplicit.js", "webpack://dicomParser/./parseDicomDataSet.js", "webpack://dicomParser/./alloc.js", "webpack://dicomParser/./version.js", "webpack://dicomParser/./bigEndianByteArrayParser.js", "webpack://dicomParser/./sharedCopy.js", "webpack://dicomParser/./byteStream.js", "webpack://dicomParser/./littleEndianByteArrayParser.js", "webpack://dicomParser/./readPart10Header.js", "webpack://dicomParser/./parseDicom.js", "webpack://dicomParser/./readEncapsulatedPixelDataFromFragments.js", "webpack://dicomParser/./readEncapsulatedImageFrame.js", "webpack://dicomParser/./readEncapsulatedPixelData.js", "webpack://dicomParser/./index.js", "webpack://dicomParser/webpack/bootstrap" ], "names": [ "root", "factory", "exports", "module", "require", "define", "amd", "this", "__WEBPACK_EXTERNAL_MODULE__0__", "stringVrs", "AE", "AS", "AT", "CS", "DA", "DS", "DT", "FL", "FD", "IS", "LO", "LT", "OB", "OD", "OF", "OW", "PN", "SH", "SL", "SQ", "SS", "ST", "TM", "UI", "UL", "UN", "undefined", "UR", "US", "UT", "isStringVr", "vr", "isPrivateTag", "tag", "parseInt", "parsePN", "personName", "stringValues", "split", "familyName", "givenName", "middleName", "prefix", "suffix", "parseTM", "time", "validate", "length", "hh", "substring", "mm", "ss", "fractionalStr", "ffffff", "Math", "pow", "isNaN", "hours", "minutes", "seconds", "fractionalSeconds", "isValidDate", "d", "m", "y", "daysInMonth", "parseDA", "date", "yyyy", "dd", "year", "month", "day", "explicitElementToString", "dataSet", "element", "textResult", "multiElementToString", "numItems", "func", "result", "i", "call", "toString", "util", "string", "num", "uint32", "toUpperCase", "uint16", "int16", "int32", "explicitDataSetToJS", "options", "omitPrivateAttibutes", "maxElementLength", "elements", "items", "sequenceItems", "push", "asString", "dataOffset", "isEndOfImageMarker", "position", "byteArray", "findLastImageFrameFragmentIndex", "pixelDataElement", "startFragment", "fragmentIndex", "fragments", "fragment", "createJPEGBasicOffsetTable", "encapsulatedPixelData", "hadUndefinedLength", "basicOffsetTable", "startFragmentIndex", "offset", "endFragmentIndex", "readTag", "byteStream", "groupNumber", "readUint16", "elementNumber", "substr", "findEndOfEncapsulatedElement", "warnings", "numFragments", "readUint32", "baseOffset", "seek", "findAndSetUNElementLength", "maxPosition", "readFixedString", "byte", "String", "fromCharCode", "getByteArrayParser", "defaultParser", "parser", "DataSet", "byteArrayParser", "index", "readInt16", "readInt32", "readFloat", "readDouble", "numMatching", "match", "Value", "fixedString", "trim", "replace", "value", "parseFloat", "bytes", "findItemDelimitationItemAndSetElementLength", "isSequence", "vrCallback", "nextTag", "readDicomElementImplicit", "untilTag", "readSequenceItemsImplicit", "readSequenceItem", "readSequenceItemImplicit", "item", "readDicomDataSetImplicitUndefinedLength", "parseDicomDataSet", "readSequenceItemExplicit", "readDicomElementExplicit", "readDicomDataSetExplicitUndefinedLength", "readSequenceItemsExplicit", "getDataLengthSizeInBytesForVR", "parseDicomDataSetExplicit", "parseDicomDataSetImplicit", "alloc", "Buffer", "Uint8Array", "byteArrayForParsingFloat", "Float32Array", "buffer", "Float64Array", "sharedCopy", "byteOffset", "slice", "ByteStream", "numBytes", "byteArrayView", "readPart10Header", "TransferSyntaxUID", "littleEndianByteStream", "littleEndianByteArrayParser", "isPart10", "getSize", "readPrefix", "x00020010", "metaHeaderDataSet", "readTheHeader", "BEI", "parseDicom", "Error", "readTransferSyntax", "transferSyntaxElement", "readDataSet", "transferSyntax", "explicit", "dataSetByteStream", "isNode", "Object", "prototype", "process", "bigEndianByteArrayParser", "inflater", "fullByteArrayCallback", "zlib", "deflatedBuffer", "inflatedBuffer", "inflateRawSync", "fullByteArrayBuffer", "copy", "pako", "deflated", "inflated", "inflateRaw", "fullByteArray", "set", "getDataSetByteStream", "e", "exception", "instanceDataSet", "propertyName", "hasOwnProperty", "concat", "mergeDataSets", "calculateBufferSize", "bufferSize", "readEncapsulatedPixelDataFromFragments", "fragmentZeroPosition", "pixelData", "pixelDataIndex", "fragmentOffset", "j", "findFragmentIndexWithOffset", "calculateNumberOfFragmentsForFrame", "frameIndex", "nextFrameOffset", "readEncapsulatedImageFrame", "deprecatedNoticeLogged", "readEncapsulatedPixelData", "frame", "console", "log", "dicomParser", "version", "LEI", "LEE", "installedModules", "__webpack_require__", "modules", "c", "name", "getter", "o", "defineProperty", "enumerable", "get", "r", "Symbol", "toStringTag", "t", "mode", "__esModule", "ns", "create", "key", "bind", "n", "object", "property", "p", "s", "moduleId", "l" ], "mappings": ";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,SACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,eAAgB,CAAC,QAASJ,GACP,iBAAZC,QACdA,QAAQ,gBAAkBD,EAAQG,QAAQ,SAE1CJ,EAAkB,YAAIC,EAAQD,EAAW,MAR3C,CASGO,KAAM,SAASC,GAClB,O,iBCVAL,EAAOD,QAAUM,G,0lDCAjB,IAAMC,EAAY,CAChBC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAA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QvDwG,EAAoBY,EAAI,SAASpH,EAAOqH,GAEvC,GADU,EAAPA,IAAUrH,EAAQwG,EAAoBxG,IAC/B,EAAPqH,EAAU,OAAOrH,EACpB,GAAW,EAAPqH,GAA8B,iBAAVrH,GAAsBA,GAASA,EAAMsH,WAAY,OAAOtH,EAChF,IAAIuH,EAAKhE,OAAOiE,OAAO,MAGvB,GAFAhB,EAAoBS,EAAEM,GACtBhE,OAAOuD,eAAeS,EAAI,UAAW,CAAER,YAAY,EAAM/G,MAAOA,IACtD,EAAPqH,GAA4B,iBAATrH,EAAmB,IAAI,IAAIyH,KAAOzH,EAAOwG,EAAoBlM,EAAEiN,EAAIE,EAAK,SAASA,GAAO,OAAOzH,EAAMyH,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRf,EAAoBmB,EAAI,SAAS1R,GAChC,IAAI2Q,EAAS3Q,GAAUA,EAAOqR,WAC7B,WAAwB,OAAOrR,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAuQ,EAAoBlM,EAAEsM,EAAQ,IAAKA,GAC5BA,GAIRJ,EAAoBK,EAAI,SAASe,EAAQC,GAAY,OAAOtE,OAAOC,UAAUsB,eAAepJ,KAAKkM,EAAQC,IAGzGrB,EAAoBsB,EAAI,GAIjBtB,EAAoBA,EAAoBuB,EAAI,GA9EnD,SAASvB,EAAoBwB,GAG5B,GAAGzB,EAAiByB,GACnB,OAAOzB,EAAiByB,GAAUhS,QAGnC,IAAIC,EAASsQ,EAAiByB,GAAY,CACzCvM,EAAGuM,EACHC,GAAG,EACHjS,QAAS,IAUV,OANAyQ,EAAQuB,GAAUtM,KAAKzF,EAAOD,QAASC,EAAQA,EAAOD,QAASwQ,GAG/DvQ,EAAOgS,GAAI,EAGJhS,EAAOD,Q,MAvBXuQ", "file": "dicomParser.min.js", "sourcesContent": [ "(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"zlib\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"dicom-parser\", [\"zlib\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"dicom-parser\"] = factory(require(\"zlib\"));\n\telse\n\t\troot[\"dicomParser\"] = factory(root[\"zlib\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE__0__) {\nreturn ", "module.exports = __WEBPACK_EXTERNAL_MODULE__0__;", "const stringVrs = {\n AE: true,\n AS: true,\n AT: false,\n CS: true,\n DA: true,\n DS: true,\n DT: true,\n FL: false,\n FD: false,\n IS: true,\n LO: true,\n LT: true,\n OB: false,\n OD: false,\n OF: false,\n OW: false,\n PN: true,\n SH: true,\n SL: false,\n SQ: false,\n SS: false,\n ST: true,\n TM: true,\n UI: true,\n UL: false,\n UN: undefined, // dunno\n UR: true,\n US: false,\n UT: true\n};\n\n/**\n * Tests to see if vr is a string or not.\n * @param vr\n * @returns true if string, false it not string, undefined if unknown vr or UN type\n */\nconst isStringVr = (vr) => stringVrs[vr];\n\n/**\n * Tests to see if a given tag in the format xggggeeee is a private tag or not\n * @param tag\n * @returns {boolean}\n */\nconst isPrivateTag = (tag) => {\n const lastGroupDigit = parseInt(tag[4], 10);\n const groupIsOdd = (lastGroupDigit % 2) === 1;\n\n\n return groupIsOdd;\n};\n\n/**\n * Parses a PN formatted string into a javascript object with properties for givenName, familyName, middleName, prefix and suffix\n * @param personName a string in the PN VR format\n * @param index\n * @returns {*} javascript object with properties for givenName, familyName, middleName, prefix and suffix or undefined if no element or data\n */\nconst parsePN = (personName) => {\n if (personName === undefined) {\n return undefined;\n }\n const stringValues = personName.split('^');\n\n\n return {\n familyName: stringValues[0],\n givenName: stringValues[1],\n middleName: stringValues[2],\n prefix: stringValues[3],\n suffix: stringValues[4]\n };\n};\n\nexport {\n isStringVr,\n isPrivateTag,\n parsePN\n};\n", "/**\n * Parses a TM formatted string into a javascript object with properties for hours, minutes, seconds and fractionalSeconds\n * @param {string} time - a string in the TM VR format\n * @param {boolean} [validate] - true if an exception should be thrown if the date is invalid\n * @returns {*} javascript object with properties for hours, minutes, seconds and fractionalSeconds or undefined if no element or data. Missing fields are set to undefined\n */\nexport default function parseTM (time, validate) {\n if (time.length >= 2) { // must at least have HH\n // 0123456789\n // HHMMSS.FFFFFF\n const hh = parseInt(time.substring(0, 2), 10);\n const mm = time.length >= 4 ? parseInt(time.substring(2, 4), 10) : undefined;\n const ss = time.length >= 6 ? parseInt(time.substring(4, 6), 10) : undefined;\n\n const fractionalStr = time.length >= 8 ? time.substring(7, 13) : undefined;\n const ffffff = fractionalStr ? (parseInt(fractionalStr, 10) * Math.pow(10, 6 - fractionalStr.length)) : undefined;\n\n if (validate) {\n if ((isNaN(hh)) ||\n (mm !== undefined && isNaN(mm)) ||\n (ss !== undefined && isNaN(ss)) ||\n (ffffff !== undefined && isNaN(ffffff)) ||\n (hh < 0 || hh > 23) ||\n (mm && (mm < 0 || mm > 59)) ||\n (ss && (ss < 0 || ss > 59)) ||\n (ffffff && (ffffff < 0 || ffffff > 999999))) {\n throw `invalid TM '${time}'`;\n }\n }\n\n return {\n hours: hh,\n minutes: mm,\n seconds: ss,\n fractionalSeconds: ffffff\n };\n }\n\n if (validate) {\n throw `invalid TM '${time}'`;\n }\n\n return undefined;\n}\n", "// algorithm based on http://stackoverflow.com/questions/1433030/validate-number-of-days-in-a-given-month\nfunction daysInMonth (m, y) { // m is 0 indexed: 0-11\n switch (m) {\n case 2 :\n return (y % 4 == 0 && y % 100) || y % 400 == 0 ? 29 : 28;\n case 9 : case 4 : case 6 : case 11 :\n return 30;\n default :\n return 31;\n }\n}\n\nfunction isValidDate (d, m, y) {\n // make year is a number\n if (isNaN(y)) {\n return false;\n }\n\n return m > 0 && m <= 12 && d > 0 && d <= daysInMonth(m, y);\n}\n\n\n/**\n * Parses a DA formatted string into a Javascript object\n * @param {string} date a string in the DA VR format\n * @param {boolean} [validate] - true if an exception should be thrown if the date is invalid\n * @returns {*} Javascript object with properties year, month and day or undefined if not present or not 8 bytes long\n */\nexport default function parseDA (date, validate) {\n if (date && date.length === 8) {\n var yyyy = parseInt(date.substring(0, 4), 10);\n var mm = parseInt(date.substring(4, 6), 10);\n var dd = parseInt(date.substring(6, 8), 10);\n\n if (validate) {\n if (isValidDate(dd, mm, yyyy) !== true) {\n throw `invalid DA '${date}'`;\n }\n }\n\n return {\n year: yyyy,\n month: mm,\n day: dd\n };\n }\n if (validate) {\n throw `invalid DA '${date}'`;\n }\n\n return undefined;\n}\n", "import * as util from './util.js';\n\n/**\n * Converts an explicit VR element to a string or undefined if it is not possible to convert.\n * Throws an error if an implicit element is supplied\n * @param dataSet\n * @param element\n * @returns {*}\n */\nexport default function explicitElementToString (dataSet, element) {\n if (dataSet === undefined || element === undefined) {\n throw 'dicomParser.explicitElementToString: missing required parameters';\n }\n if (element.vr === undefined) {\n throw 'dicomParser.explicitElementToString: cannot convert implicit element to string';\n }\n var vr = element.vr;\n var tag = element.tag;\n\n var textResult;\n\n function multiElementToString (numItems, func) {\n var result = '';\n\n for (var i = 0; i < numItems; i++) {\n if (i !== 0) {\n result += '/';\n }\n result += func.call(dataSet, tag, i).toString();\n }\n\n return result;\n }\n\n if (util.isStringVr(vr) === true) {\n textResult = dataSet.string(tag);\n } else if (vr === 'AT') {\n var num = dataSet.uint32(tag);\n\n if (num === undefined) {\n return undefined;\n }\n if (num < 0) {\n num = 0xFFFFFFFF + num + 1;\n }\n\n return `x${num.toString(16).toUpperCase()}`;\n } else if (vr === 'US') {\n textResult = multiElementToString(element.length / 2, dataSet.uint16);\n } else if (vr === 'SS') {\n textResult = multiElementToString(element.length / 2, dataSet.int16);\n } else if (vr === 'UL') {\n textResult = multiElementToString(element.length / 4, dataSet.uint32);\n } else if (vr === 'SL') {\n textResult = multiElementToString(element.length / 4, dataSet.int32);\n } else if (vr === 'FD') {\n textResult = multiElementToString(element.length / 8, dataSet.double);\n } else if (vr === 'FL') {\n textResult = multiElementToString(element.length / 4, dataSet.float);\n }\n\n return textResult;\n}\n", "import explicitElementToString from './elementToString.js';\nimport * as util from './util.js';\n\n/**\n * converts an explicit dataSet to a javascript object\n * @param dataSet\n * @param options\n */\nexport default function explicitDataSetToJS (dataSet, options) {\n if (dataSet === undefined) {\n throw 'dicomParser.explicitDataSetToJS: missing required parameter dataSet';\n }\n\n options = options || {\n omitPrivateAttibutes: true, // true if private elements should be omitted\n maxElementLength: 128 // maximum element length to try and convert to string format\n };\n\n var result = {\n\n };\n\n for (var tag in dataSet.elements) {\n var element = dataSet.elements[tag];\n\n // skip this element if it a private element and our options specify that we should\n if (options.omitPrivateAttibutes === true && util.isPrivateTag(tag)) {\n continue;\n }\n\n if (element.items) {\n // handle sequences\n var sequenceItems = [];\n\n for (var i = 0; i < element.items.length; i++) {\n sequenceItems.push(explicitDataSetToJS(element.items[i].dataSet, options));\n }\n result[tag] = sequenceItems;\n } else {\n var asString;\n\n asString = undefined;\n if (element.length < options.maxElementLength) {\n asString = explicitElementToString(dataSet, element);\n }\n\n if (asString !== undefined) {\n result[tag] = asString;\n } else {\n result[tag] = {\n dataOffset: element.dataOffset,\n length: element.length\n };\n }\n }\n }\n\n return result;\n}\n", "// Each JPEG image has an end of image marker 0xFFD9\nfunction isEndOfImageMarker (dataSet, position) {\n return (dataSet.byteArray[position] === 0xFF &&\n dataSet.byteArray[position + 1] === 0xD9);\n}\n\nfunction isFragmentEndOfImage (dataSet, pixelDataElement, fragmentIndex) {\n var fragment = pixelDataElement.fragments[fragmentIndex];\n // Need to check the last two bytes and the last three bytes for marker since odd length\n // fragments are zero padded\n\n if (isEndOfImageMarker(dataSet, fragment.position + fragment.length - 2) ||\n isEndOfImageMarker(dataSet, fragment.position + fragment.length - 3)) {\n return true;\n }\n\n return false;\n}\n\nfunction findLastImageFrameFragmentIndex (dataSet, pixelDataElement, startFragment) {\n for (var fragmentIndex = startFragment; fragmentIndex < pixelDataElement.fragments.length; fragmentIndex++) {\n if (isFragmentEndOfImage(dataSet, pixelDataElement, fragmentIndex)) {\n return fragmentIndex;\n }\n }\n}\n\n/**\n * Creates a basic offset table by scanning fragments for JPEG start of image and end Of Image markers\n * @param {object} dataSet - the parsed dicom dataset\n * @param {object} pixelDataElement - the pixel data element\n * @param [fragments] - optional array of objects describing each fragment (offset, position, length)\n * @returns {Array} basic offset table (array of offsets to beginning of each frame)\n */\nexport default function createJPEGBasicOffsetTable (dataSet, pixelDataElement, fragments) {\n // Validate parameters\n if (dataSet === undefined) {\n throw 'dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet';\n }\n if (pixelDataElement === undefined) {\n throw 'dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement';\n }\n if (pixelDataElement.tag !== 'x7fe00010') {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to non pixel data tag (expected tag = x7fe00010\\'';\n }\n if (pixelDataElement.encapsulatedPixelData !== true) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.hadUndefinedLength !== true) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.basicOffsetTable === undefined) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.fragments === undefined) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.fragments.length <= 0) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (fragments && fragments.length <= 0) {\n throw 'dicomParser.createJPEGBasicOffsetTable: parameter \\'fragments\\' must not be zero length';\n }\n\n // Default values\n fragments = fragments || pixelDataElement.fragments;\n\n var basicOffsetTable = [];\n\n var startFragmentIndex = 0;\n\n while (true) {\n // Add the offset for the start fragment\n basicOffsetTable.push(pixelDataElement.fragments[startFragmentIndex].offset);\n var endFragmentIndex = findLastImageFrameFragmentIndex(dataSet, pixelDataElement, startFragmentIndex);\n\n if (endFragmentIndex === undefined || endFragmentIndex === pixelDataElement.fragments.length - 1) {\n return basicOffsetTable;\n }\n startFragmentIndex = endFragmentIndex + 1;\n }\n}\n", "/**\n * Internal helper functions for parsing DICOM elements\n */\n\n/**\n * Reads a tag (group number and element number) from a byteStream\n * @param byteStream the byte stream to read from\n * @returns {string} the tag in format xggggeeee where gggg is the lowercase hex value of the group number\n * and eeee is the lower case hex value of the element number\n */\nexport default function readTag (byteStream) {\n if (byteStream === undefined) {\n throw 'dicomParser.readTag: missing required parameter \\'byteStream\\'';\n }\n\n const groupNumber = byteStream.readUint16() * 256 * 256;\n const elementNumber = byteStream.readUint16();\n const tag = `x${(`00000000${(groupNumber + elementNumber).toString(16)}`).substr(-8)}`;\n\n return tag;\n}\n", "import readTag from './readTag.js';\n\n/**\n * Internal helper functions for parsing DICOM elements\n */\n\n/**\n * Reads an encapsulated pixel data element and adds an array of fragments to the element\n * containing the offset and length of each fragment and any offsets from the basic offset\n * table\n * @param byteStream\n * @param element\n */\nexport default function findEndOfEncapsulatedElement (byteStream, element, warnings) {\n if (byteStream === undefined) {\n throw 'dicomParser.findEndOfEncapsulatedElement: missing required parameter \\'byteStream\\'';\n }\n\n if (element === undefined) {\n throw 'dicomParser.findEndOfEncapsulatedElement: missing required parameter \\'element\\'';\n }\n\n element.encapsulatedPixelData = true;\n element.basicOffsetTable = [];\n element.fragments = [];\n\n const basicOffsetTableItemTag = readTag(byteStream);\n\n if (basicOffsetTableItemTag !== 'xfffee000') {\n throw 'dicomParser.findEndOfEncapsulatedElement: basic offset table not found';\n }\n\n const basicOffsetTableItemlength = byteStream.readUint32();\n const numFragments = basicOffsetTableItemlength / 4;\n\n // Bad idea to not include the basic offset table, as it means writing the data out is inconsistent with reading it\n // but leave this for now. To fix later.\n for (let i = 0; i < numFragments; i++) {\n const offset = byteStream.readUint32();\n\n element.basicOffsetTable.push(offset);\n }\n\n const baseOffset = byteStream.position;\n\n while (byteStream.position < byteStream.byteArray.length) {\n const tag = readTag(byteStream);\n let length = byteStream.readUint32();\n\n if (tag === 'xfffee0dd') {\n byteStream.seek(length);\n element.length = byteStream.position - element.dataOffset;\n\n return;\n } else if (tag === 'xfffee000') {\n element.fragments.push({\n offset: byteStream.position - baseOffset - 8,\n position: byteStream.position,\n length\n });\n } else {\n if (warnings) {\n warnings.push(`unexpected tag ${tag} while searching for end of pixel data element with undefined length`);\n }\n\n if (length > byteStream.byteArray.length - byteStream.position) {\n // fix length\n length = byteStream.byteArray.length - byteStream.position;\n }\n\n element.fragments.push({\n offset: byteStream.position - baseOffset - 8,\n position: byteStream.position,\n length\n });\n\n byteStream.seek(length);\n element.length = byteStream.position - element.dataOffset;\n\n return;\n }\n\n byteStream.seek(length);\n }\n\n if (warnings) {\n warnings.push(`pixel data element ${element.tag} missing sequence delimiter tag xfffee0dd`);\n }\n}\n", "/**\n * Internal helper functions for parsing DICOM elements\n */\n\n/**\n * reads from the byte stream until it finds the magic number for the Sequence Delimitation\n * Item item and then sets the length of the element\n * @param byteStream\n * @param element\n */\nexport default function findAndSetUNElementLength (byteStream, element) {\n if (byteStream === undefined) {\n throw 'dicomParser.findAndSetUNElementLength: missing required parameter \\'byteStream\\'';\n }\n\n // group, element, length\n const itemDelimitationItemLength = 8;\n const maxPosition = byteStream.byteArray.length - itemDelimitationItemLength;\n\n while (byteStream.position <= maxPosition) {\n const groupNumber = byteStream.readUint16();\n\n if (groupNumber === 0xfffe) {\n const elementNumber = byteStream.readUint16();\n\n if (elementNumber === 0xe0dd) {\n // NOTE: It would be better to also check for the length to be 0 as part of the check above\n // but we will just log a warning for now\n const itemDelimiterLength = byteStream.readUint32();\n\n if (itemDelimiterLength !== 0) {\n byteStream.warnings(`encountered non zero length following item delimiter at position ${byteStream.position - 4} while reading element of undefined length with tag ${element.tag}`);\n }\n element.length = byteStream.position - element.dataOffset;\n\n return;\n }\n }\n }\n\n // No item delimitation item - silently set the length to the end\n // of the buffer and set the position past the end of the buffer\n element.length = byteStream.byteArray.length - element.dataOffset;\n byteStream.seek(byteStream.byteArray.length - byteStream.position);\n}\n", "/**\n * Internal helper functions common to parsing byte arrays of any type\n */\n\n/**\n * Reads a string of 8-bit characters from an array of bytes and advances\n * the position by length bytes. A null terminator will end the string\n * but will not affect advancement of the position. Trailing and leading\n * spaces are preserved (not trimmed)\n * @param byteArray the byteArray to read from\n * @param position the position in the byte array to read from\n * @param length the maximum number of bytes to parse\n * @returns {string} the parsed string\n * @throws error if buffer overread would occur\n * @access private\n */\nexport function readFixedString (byteArray, position, length) {\n if (length < 0) {\n throw 'dicomParser.readFixedString - length cannot be less than 0';\n }\n\n if (position + length > byteArray.length) {\n throw 'dicomParser.readFixedString: attempt to read past end of buffer';\n }\n\n var result = '';\n var byte;\n\n for (var i = 0; i < length; i++) {\n byte = byteArray[position + i];\n if (byte === 0) {\n position += length;\n\n return result;\n }\n result += String.fromCharCode(byte);\n }\n\n return result;\n}\n", "import { readFixedString } from './byteArrayParser.js';\n\n/**\n *\n * The DataSet class encapsulates a collection of DICOM Elements and provides various functions\n * to access the data in those elements\n *\n * Rules for handling padded spaces:\n * DS = Strip leading and trailing spaces\n * DT = Strip trailing spaces\n * IS = Strip leading and trailing spaces\n * PN = Strip trailing spaces\n * TM = Strip trailing spaces\n * AE = Strip leading and trailing spaces\n * CS = Strip leading and trailing spaces\n * SH = Strip leading and trailing spaces\n * LO = Strip leading and trailing spaces\n * LT = Strip trailing spaces\n * ST = Strip trailing spaces\n * UT = Strip trailing spaces\n *\n */\n\nfunction getByteArrayParser (element, defaultParser) {\n return (element.parser !== undefined ? element.parser : defaultParser);\n}\n\n/**\n * Constructs a new DataSet given byteArray and collection of elements\n * @param byteArrayParser\n * @param byteArray\n * @param elements\n * @constructor\n */\nexport default class DataSet {\n constructor (byteArrayParser, byteArray, elements) {\n this.byteArrayParser = byteArrayParser;\n this.byteArray = byteArray;\n this.elements = elements;\n }\n\n /**\n * Finds the element for tag and returns an unsigned int 16 if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} unsigned int 16 or undefined if the attribute is not present or has data of length 0\n */\n uint16 (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readUint16(this.byteArray, element.dataOffset + (index * 2));\n }\n\n return undefined;\n }\n\n /**\n * Finds the element for tag and returns an signed int 16 if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} signed int 16 or undefined if the attribute is not present or has data of length 0\n */\n int16 (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readInt16(this.byteArray, element.dataOffset + (index * 2));\n }\n\n return undefined;\n }\n\n /**\n * Finds the element for tag and returns an unsigned int 32 if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} unsigned int 32 or undefined if the attribute is not present or has data of length 0\n */\n uint32 (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readUint32(this.byteArray, element.dataOffset + (index * 4));\n }\n\n return undefined;\n }\n\n /**\n * Finds the element for tag and returns an signed int 32 if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} signed int 32 or undefined if the attribute is not present or has data of length 0\n */\n int32 (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readInt32(this.byteArray, element.dataOffset + (index * 4));\n }\n\n return undefined;\n }\n\n /**\n * Finds the element for tag and returns a 32 bit floating point number (VR=FL) if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} float or undefined if the attribute is not present or has data of length 0\n */\n float (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readFloat(this.byteArray, element.dataOffset + (index * 4));\n }\n\n return undefined;\n }\n\n /**\n * Finds the element for tag and returns a 64 bit floating point number (VR=FD) if it exists and has data\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the value in a multivalued element. Default is index 0 if not supplied\n * @returns {*} float or undefined if the attribute is not present or doesn't has data of length 0\n */\n double (tag, index) {\n var element = this.elements[tag];\n\n index = (index !== undefined) ? index : 0;\n if (element && element.length !== 0) {\n return getByteArrayParser(element, this.byteArrayParser).readDouble(this.byteArray, element.dataOffset + (index * 8));\n }\n\n return undefined;\n }\n\n /**\n * Returns the number of string values for the element\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @returns {*} the number of string values or undefined if the attribute is not present or has zero length data\n */\n numStringValues (tag) {\n var element = this.elements[tag];\n\n if (element && element.length > 0) {\n var fixedString = readFixedString(this.byteArray, element.dataOffset, element.length);\n var numMatching = fixedString.match(/\\\\/g);\n\n if (numMatching === null) {\n return 1;\n }\n\n return numMatching.length + 1;\n }\n\n return undefined;\n }\n\n /**\n * Returns a string for the element. If index is provided, the element is assumed to be\n * multi-valued and will return the component specified by index. Undefined is returned\n * if there is no component with the specified index, the element does not exist or is zero length.\n *\n * Use this function for VR types of AE, CS, SH and LO\n *\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the desired value in a multi valued string or undefined for the entire string\n * @returns {*}\n */\n string (tag, index) {\n var element = this.elements[tag];\n\n if( element && element.Value ) return element.Value;\n \n if (element && element.length > 0) {\n var fixedString = readFixedString(this.byteArray, element.dataOffset, element.length);\n\n if (index >= 0) {\n var values = fixedString.split('\\\\');\n // trim trailing spaces\n\n return values[index].trim();\n }\n // trim trailing spaces\n return fixedString.trim();\n }\n\n return undefined;\n }\n\n /**\n * Returns a string with the leading spaces preserved and trailing spaces removed.\n *\n * Use this function to access data for VRs of type UT, ST and LT\n *\n * @param tag\n * @param index\n * @returns {*}\n */\n text (tag, index) {\n var element = this.elements[tag];\n\n if (element && element.length > 0) {\n var fixedString = readFixedString(this.byteArray, element.dataOffset, element.length);\n\n if (index >= 0) {\n var values = fixedString.split('\\\\');\n\n\n return values[index].replace(/ +$/, '');\n }\n\n return fixedString.replace(/ +$/, '');\n }\n\n return undefined;\n }\n\n /**\n * Parses a string to a float for the specified index in a multi-valued element. If index is not specified,\n * the first value in a multi-valued VR will be parsed if present.\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the desired value in a multi valued string or undefined for the first value\n * @returns {*} a floating point number or undefined if not present or data not long enough\n */\n floatString (tag, index) {\n var element = this.elements[tag];\n\n if (element && element.length > 0) {\n index = (index !== undefined) ? index : 0;\n var value = this.string(tag, index);\n\n if (value !== undefined) {\n return parseFloat(value);\n }\n }\n\n return undefined;\n }\n\n /**\n * Parses a string to an integer for the specified index in a multi-valued element. If index is not specified,\n * the first value in a multi-valued VR will be parsed if present.\n * @param tag The DICOM tag in the format xGGGGEEEE\n * @param index the index of the desired value in a multi valued string or undefined for the first value\n * @returns {*} an integer or undefined if not present or data not long enough\n */\n intString (tag, index) {\n var element = this.elements[tag];\n\n if (element && element.length > 0) {\n index = (index !== undefined) ? index : 0;\n var value = this.string(tag, index);\n\n if (value !== undefined) {\n return parseInt(value);\n }\n }\n\n return undefined;\n }\n\n /**\n * Parses an element tag according to the 'AT' VR definition (VR=AT).\n * @param {String} A DICOM tag with in the format xGGGGEEEE.\n * @returns {String} A string representation of a data element tag or undefined if the field is not present or data is not long enough.\n */\n attributeTag (tag) {\n const element = this.elements[tag];\n\n if (element && element.length === 4) {\n const parser = getByteArrayParser(element, this.byteArrayParser).readUint16;\n const bytes = this.byteArray;\n const offset = element.dataOffset;\n\n return `x${(`00000000${(parser(bytes, offset) * 256 * 256 + parser(bytes, offset + 2)).toString(16)}`).substr(-8)}`;\n }\n\n return undefined;\n }\n}\n", "/**\n * Internal helper functions for parsing DICOM elements\n */\n\n/**\n * reads from the byte stream until it finds the magic numbers for the item delimitation item\n * and then sets the length of the element\n * @param byteStream\n * @param element\n */\nexport default function findItemDelimitationItemAndSetElementLength (byteStream, element) {\n if (byteStream === undefined) {\n throw 'dicomParser.readDicomElementImplicit: missing required parameter \\'byteStream\\'';\n }\n\n const itemDelimitationItemLength = 8; // group, element, length\n const maxPosition = byteStream.byteArray.length - itemDelimitationItemLength;\n\n while (byteStream.position <= maxPosition) {\n const groupNumber = byteStream.readUint16();\n\n if (groupNumber === 0xfffe) {\n const elementNumber = byteStream.readUint16();\n\n if (elementNumber === 0xe00d) {\n // NOTE: It would be better to also check for the length to be 0 as part of the check above\n // but we will just log a warning for now\n const itemDelimiterLength = byteStream.readUint32(); // the length\n\n if (itemDelimiterLength !== 0) {\n byteStream.warnings(`encountered non zero length following item delimiter at position ${byteStream.position - 4} while reading element of undefined length with tag ${element.tag}`);\n }\n\n element.length = byteStream.position - element.dataOffset;\n\n return;\n }\n }\n }\n\n // No item delimitation item - silently set the length to the end of the buffer and set the position past the end of the buffer\n element.length = byteStream.byteArray.length - element.dataOffset;\n byteStream.seek(byteStream.byteArray.length - byteStream.position);\n}\n", "import findItemDelimitationItemAndSetElementLength from './findItemDelimitationItem.js';\nimport readSequenceItemsImplicit from './readSequenceElementImplicit.js';\nimport readTag from './readTag.js';\nimport { isPrivateTag } from './util/util.js';\n\n/**\n * Internal helper functions for for parsing DICOM elements\n */\n\nconst isSequence = (element, byteStream, vrCallback) => {\n // if a data dictionary callback was provided, use that to verify that the element is a sequence.\n if (typeof vrCallback !== 'undefined') {\n return (vrCallback(element.tag) === 'SQ');\n }\n\n if ((byteStream.position + 4) <= byteStream.byteArray.length) {\n const nextTag = readTag(byteStream);\n\n byteStream.seek(-4);\n\n // Item start tag (fffe,e000) or sequence delimiter (i.e. end of sequence) tag (0fffe,e0dd)\n // These are the tags that could potentially be found directly after a sequence start tag (the delimiter\n // is found in the case of an empty sequence). This is not 100% safe because a non-sequence item\n // could have data that has these bytes, but this is how to do it without a data dictionary.\n return (nextTag === 'xfffee000') || (nextTag === 'xfffee0dd');\n }\n\n byteStream.warnings.push('eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR');\n\n return false;\n};\n\nexport default function readDicomElementImplicit (byteStream, untilTag, vrCallback) {\n if (byteStream === undefined) {\n throw 'dicomParser.readDicomElementImplicit: missing required parameter \\'byteStream\\'';\n }\n\n const element = {\n tag: readTag(byteStream),\n length: byteStream.readUint32(),\n dataOffset: byteStream.position\n };\n\n if (element.length === 4294967295) {\n element.hadUndefinedLength = true;\n }\n\n if (element.tag === untilTag) {\n return element;\n }\n\n if (isSequence(element, byteStream, vrCallback) && !isPrivateTag(element.tag)) {\n // parse the sequence\n readSequenceItemsImplicit(byteStream, element);\n\n return element;\n }\n\n // if element is not a sequence and has undefined length, we have to\n // scan the data for a magic number to figure out when it ends.\n if (element.hadUndefinedLength) {\n findItemDelimitationItemAndSetElementLength(byteStream, element);\n\n return element;\n }\n\n // non sequence element with known length, skip over the data part\n byteStream.seek(element.length);\n\n return element;\n}\n", "import readTag from './readTag.js';\n\n/**\n * Internal helper functions for parsing DICOM elements\n */\n\n/**\n * Reads the tag and length of a sequence item and returns them as an object with the following properties\n * tag : string for the tag of this element in the format xggggeeee\n * length: the number of bytes in this item or 4294967295 if undefined\n * dataOffset: the offset into the byteStream of the data for this item\n * @param byteStream the byte\n * @returns {{tag: string, length: integer, dataOffset: integer}}\n */\nexport default function readSequenceItem (byteStream) {\n if (byteStream === undefined) {\n throw 'dicomParser.readSequenceItem: missing required parameter \\'byteStream\\'';\n }\n\n const element = {\n tag: readTag(byteStream),\n length: byteStream.readUint32(),\n dataOffset: byteStream.position\n };\n\n if (element.tag !== 'xfffee000') {\n throw `dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ${byteStream.position}`;\n }\n\n return element;\n}\n", "import DataSet from './dataSet.js';\nimport readDicomElementImplicit from './readDicomElementImplicit.js';\nimport readSequenceItem from './readSequenceItem.js';\nimport readTag from './readTag.js';\nimport * as parseDicomDataSet from './parseDicomDataSet.js';\n\n/**\n * Internal helper functions for parsing DICOM elements\n */\n\nfunction readDicomDataSetImplicitUndefinedLength (byteStream, vrCallback) {\n const elements = {};\n\n while (byteStream.position < byteStream.byteArray.length) {\n const element = readDicomElementImplicit(byteStream, undefined, vrCallback);\n\n elements[element.tag] = element;\n\n // we hit an item delimiter tag, return the current offset to mark\n // the end of this sequence item\n if (element.tag === 'xfffee00d') {\n return new DataSet(byteStream.byteArrayParser, byteStream.byteArray, elements);\n }\n }\n\n // eof encountered - log a warning and return what we have for the element\n byteStream.warnings.push('eof encountered before finding sequence item delimiter in sequence item of undefined length');\n\n return new DataSet(byteStream.byteArrayParser, byteStream.byteArray, elements);\n}\n\nfunction readSequenceItemImplicit (byteStream, vrCallback) {\n const item = readSequenceItem(byteStream);\n\n if (item.length === 4294967295) {\n item.hadUndefinedLength = true;\n item.dataSet = readDicomDataSetImplicitUndefinedLength(byteStream, vrCallback);\n item.length = byteStream.position - item.dataOffset;\n } else {\n item.dataSet = new DataSet(byteStream.byteArrayParser, byteStream.byteArray, {});\n parseDicomDataSet.parseDicomDataSetImplicit(item.dataSet, byteStream, byteStream.position + item.length, { vrCallback });\n }\n\n return item;\n}\n\nfunction readSQElementUndefinedLengthImplicit (byteStream, element, vrCallback) {\n while ((byteStream.position + 4) <= byteStream.byteArray.length) {\n // end reading this sequence if the next tag is the sequence delimitation item\n const nextTag = readTag(byteStream);\n\n byteStream.seek(-4);\n\n if (nextTag === 'xfffee0dd') {\n // set the correct length\n element.length = byteStream.position - element.dataOffset;\n byteStream.seek(8);\n\n return element;\n }\n\n const item = readSequenceItemImplicit(byteStream, vrCallback);\n\n element.items.push(item);\n }\n\n byteStream.warnings.push('eof encountered before finding sequence delimiter in sequence of undefined length');\n element.length = byteStream.byteArray.length - element.dataOffset;\n}\n\nfunction readSQElementKnownLengthImplicit (byteStream, element, vrCallback) {\n const maxPosition = element.dataOffset + element.length;\n\n while (byteStream.position < maxPosition) {\n const item = readSequenceItemImplicit(byteStream, vrCallback);\n\n element.items.push(item);\n }\n}\n\n/**\n * Reads sequence items for an element in an implicit little endian byte stream\n * @param byteStream the implicit little endian byte stream\n * @param element the element to read the sequence items for\n * @param vrCallback an optional method that returns a VR string given a tag\n */\nexport default function readSequenceItemsImplicit (byteStream, element, vrCallback) {\n if (byteStream === undefined) {\n throw 'dicomParser.readSequenceItemsImplicit: missing required parameter \\'byteStream\\'';\n }\n\n if (element === undefined) {\n throw 'dicomParser.readSequenceItemsImplicit: missing required parameter \\'element\\'';\n }\n\n element.items = [];\n\n if (element.length === 4294967295) {\n readSQElementUndefinedLengthImplicit(byteStream, element, vrCallback);\n } else {\n readSQElementKnownLengthImplicit(byteStream, element, vrCallback);\n }\n}\n", "import DataSet from './dataSet.js';\nimport readDicomElementExplicit from './readDicomElementExplicit.js';\nimport readSequenceItem from './readSequenceItem.js';\nimport readTag from './readTag.js';\nimport * as parseDicomDataSet from './parseDicomDataSet.js';\n\n/**\n * Internal helper functions for parsing DICOM elements\n */\n\nfunction readDicomDataSetExplicitUndefinedLength (byteStream, warnings) {\n const elements = {};\n\n while (byteStream.position < byteStream.byteArray.length) {\n const element = readDicomElementExplicit(byteStream, warnings);\n\n elements[element.tag] = element;\n\n // we hit an item delimiter tag, return the current offset to mark\n // the end of this sequence item\n if (element.tag === 'xfffee00d') {\n return new DataSet(byteStream.byteArrayParser, byteStream.byteArray, elements);\n }\n }\n\n // eof encountered - log a warning and return what we have for the element\n warnings.push('eof encountered before finding item delimiter tag while reading sequence item of undefined length');\n\n return new DataSet(byteStream.byteArrayParser, byteStream.byteArray, elements);\n}\n\nfunction readSequenceItemExplicit (byteStream, warnings) {\n const item = readSequenceItem(byteStream);\n\n if (item.length === 4294967295) {\n item.hadUndefinedLength = true;\n item.dataSet = readDicomDataSetExplicitUndefinedLength(byteStream, warnings);\n item.length = byteStream.position - item.dataOffset;\n } else {\n item.dataSet = new DataSet(byteStream.byteArrayParser, byteStream.byteArray, {});\n parseDicomDataSet.parseDicomDataSetExplicit(item.dataSet, byteStream, byteStream.position + item.length);\n }\n\n return item;\n}\n\nfunction readSQElementUndefinedLengthExplicit (byteStream, element, warnings) {\n while ((byteStream.position + 4) <= byteStream.byteArray.length) {\n // end reading this sequence if the next tag is the sequence delimitation item\n const nextTag = readTag(byteStream);\n\n byteStream.seek(-4);\n if (nextTag === 'xfffee0dd') {\n // set the correct length\n element.length = byteStream.position - element.dataOffset;\n byteStream.seek(8);\n\n return element;\n }\n\n const item = readSequenceItemExplicit(byteStream, warnings);\n\n element.items.push(item);\n }\n\n warnings.push('eof encountered before finding sequence delimitation tag while reading sequence of undefined length');\n element.length = byteStream.position - element.dataOffset;\n}\n\nfunction readSQElementKnownLengthExplicit (byteStream, element, warnings) {\n const maxPosition = element.dataOffset + element.length;\n\n while (byteStream.position < maxPosition) {\n const item = readSequenceItemExplicit(byteStream, warnings);\n\n element.items.push(item);\n }\n}\n\nexport default function readSequenceItemsExplicit (byteStream, element, warnings) {\n if (byteStream === undefined) {\n throw 'dicomParser.readSequenceItemsExplicit: missing required parameter \\'byteStream\\'';\n }\n\n if (element === undefined) {\n throw 'dicomParser.readSequenceItemsExplicit: missing required parameter \\'element\\'';\n }\n\n element.items = [];\n\n if (element.length === 4294967295) {\n readSQElementUndefinedLengthExplicit(byteStream, element, warnings);\n } else {\n readSQElementKnownLengthExplicit(byteStream, element, warnings);\n }\n}\n", "import findEndOfEncapsulatedElement from './findEndOfEncapsulatedPixelData.js';\nimport findAndSetUNElementLength from './findAndSetUNElementLength.js';\nimport readSequenceItemsImplicit from './readSequenceElementImplicit.js';\nimport readTag from './readTag.js';\nimport findItemDelimitationItemAndSetElementLength from './findItemDelimitationItem.js';\nimport readSequenceItemsExplicit from './readSequenceElementExplicit.js';\n\n/**\n * Internal helper functions for for parsing DICOM elements\n */\n\nconst getDataLengthSizeInBytesForVR = (vr) => {\n if (vr === 'OB' ||\n vr === 'OD' ||\n vr === 'OL' ||\n vr === 'OW' ||\n vr === 'SQ' ||\n vr === 'OF' ||\n vr === 'UC' ||\n vr === 'UR' ||\n vr === 'UT' ||\n vr === 'UN') {\n return 4;\n }\n\n return 2;\n};\n\nexport default function readDicomElementExplicit (byteStream, warnings, untilTag) {\n if (byteStream === undefined) {\n throw 'dicomParser.readDicomElementExplicit: missing required parameter \\'byteStream\\'';\n }\n\n const element = {\n tag: readTag(byteStream),\n vr: byteStream.readFixedString(2)\n // length set below based on VR\n // dataOffset set below based on VR and size of length\n };\n\n const dataLengthSizeBytes = getDataLengthSizeInBytesForVR(element.vr);\n\n if (dataLengthSizeBytes === 2) {\n element.length = byteStream.readUint16();\n element.dataOffset = byteStream.position;\n } else {\n byteStream.seek(2);\n element.length = byteStream.readUint32();\n element.dataOffset = byteStream.position;\n }\n\n if (element.length === 4294967295) {\n element.hadUndefinedLength = true;\n }\n\n if (element.tag === untilTag) {\n return element;\n }\n\n // if VR is SQ, parse the sequence items\n if (element.vr === 'SQ') {\n readSequenceItemsExplicit(byteStream, element, warnings);\n\n return element;\n }\n\n if (element.length === 4294967295) {\n if (element.tag === 'x7fe00010') {\n findEndOfEncapsulatedElement(byteStream, element, warnings);\n\n return element;\n } else if (element.vr === 'UN') {\n readSequenceItemsImplicit(byteStream, element);\n\n return element;\n }\n\n findItemDelimitationItemAndSetElementLength(byteStream, element);\n\n return element;\n }\n\n byteStream.seek(element.length);\n\n return element;\n}\n", "import readDicomElementExplicit from './readDicomElementExplicit.js';\nimport readDicomElementImplicit from './readDicomElementImplicit.js';\n\n/**\n * Internal helper functions for parsing implicit and explicit DICOM data sets\n */\n\n/**\n * reads an explicit data set\n * @param byteStream the byte stream to read from\n * @param maxPosition the maximum position to read up to (optional - only needed when reading sequence items)\n */\nexport function parseDicomDataSetExplicit (dataSet, byteStream, maxPosition, options = {}) {\n maxPosition = (maxPosition === undefined) ? byteStream.byteArray.length : maxPosition;\n\n if (byteStream === undefined) {\n throw 'dicomParser.parseDicomDataSetExplicit: missing required parameter \\'byteStream\\'';\n }\n\n if (maxPosition < byteStream.position || maxPosition > byteStream.byteArray.length) {\n throw 'dicomParser.parseDicomDataSetExplicit: invalid value for parameter \\'maxP osition\\'';\n }\n\n const elements = dataSet.elements;\n\n while (byteStream.position < maxPosition) {\n const element = readDicomElementExplicit(byteStream, dataSet.warnings, options.untilTag);\n\n elements[element.tag] = element;\n if (element.tag === options.untilTag) {\n return;\n }\n }\n\n if (byteStream.position > maxPosition) {\n throw 'dicomParser:parseDicomDataSetExplicit: buffer overrun';\n }\n}\n\n/**\n * reads an implicit data set\n * @param byteStream the byte stream to read from\n * @param maxPosition the maximum position to read up to (optional - only needed when reading sequence items)\n */\nexport function parseDicomDataSetImplicit (dataSet, byteStream, maxPosition, options = {}) {\n maxPosition = (maxPosition === undefined) ? dataSet.byteArray.length : maxPosition;\n\n if (byteStream === undefined) {\n throw 'dicomParser.parseDicomDataSetImplicit: missing required parameter \\'byteStream\\'';\n }\n\n if (maxPosition < byteStream.position || maxPosition > byteStream.byteArray.length) {\n throw 'dicomParser.parseDicomDataSetImplicit: invalid value for parameter \\'maxPosition\\'';\n }\n\n const elements = dataSet.elements;\n\n while (byteStream.position < maxPosition) {\n const element = readDicomElementImplicit(byteStream, options.untilTag, options.vrCallback);\n\n elements[element.tag] = element;\n if (element.tag === options.untilTag) {\n return;\n }\n }\n}\n", "/**\n * Creates a new byteArray of the same type (Uint8Array or Buffer) of the specified length.\n * @param byteArray the underlying byteArray (either Uint8Array or Buffer)\n * @param length number of bytes of the Byte Array\n * @returns {object} Uint8Array or Buffer depending on the type of byteArray\n */\nexport default function alloc (byteArray, length) {\n if (typeof Buffer !== 'undefined' && byteArray instanceof Buffer) {\n return Buffer.alloc(length);\n } else if (byteArray instanceof Uint8Array) {\n return new Uint8Array(length);\n }\n throw 'dicomParser.alloc: unknown type for byteArray';\n}\n", "export default '1.8.12';\n", "/**\n * Internal helper functions for parsing different types from a big-endian byte array\n */\nexport default {\n\n /**\n *\n * Parses an unsigned int 16 from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed unsigned int 16\n * @throws error if buffer overread would occur\n * @access private\n */\n readUint16 (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readUint16: position cannot be less than 0';\n }\n if (position + 2 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readUint16: attempt to read past end of buffer';\n }\n\n return (byteArray[position] << 8) + byteArray[position + 1];\n },\n\n /**\n *\n * Parses a signed int 16 from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed signed int 16\n * @throws error if buffer overread would occur\n * @access private\n */\n readInt16 (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readInt16: position cannot be less than 0';\n }\n if (position + 2 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readInt16: attempt to read past end of buffer';\n }\n var int16 = (byteArray[position] << 8) + byteArray[position + 1];\n // fix sign\n\n if (int16 & 0x8000) {\n int16 = int16 - 0xFFFF - 1;\n }\n\n return int16;\n },\n\n /**\n * Parses an unsigned int 32 from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed unsigned int 32\n * @throws error if buffer overread would occur\n * @access private\n */\n readUint32 (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readUint32: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readUint32: attempt to read past end of buffer';\n }\n\n var uint32 = (256 * (256 * (256 * byteArray[position] +\n byteArray[position + 1]) +\n byteArray[position + 2]) +\n byteArray[position + 3]);\n\n return uint32;\n },\n\n /**\n * Parses a signed int 32 from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed signed int 32\n * @throws error if buffer overread would occur\n * @access private\n */\n readInt32 (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readInt32: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readInt32: attempt to read past end of buffer';\n }\n\n var int32 = ((byteArray[position] << 24) +\n (byteArray[position + 1] << 16) +\n (byteArray[position + 2] << 8) +\n byteArray[position + 3]);\n\n return int32;\n },\n\n /**\n * Parses 32-bit float from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed 32-bit float\n * @throws error if buffer overread would occur\n * @access private\n */\n readFloat (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readFloat: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readFloat: attempt to read past end of buffer';\n }\n\n // I am sure there is a better way than this but this should be safe\n var byteArrayForParsingFloat = new Uint8Array(4);\n\n byteArrayForParsingFloat[3] = byteArray[position];\n byteArrayForParsingFloat[2] = byteArray[position + 1];\n byteArrayForParsingFloat[1] = byteArray[position + 2];\n byteArrayForParsingFloat[0] = byteArray[position + 3];\n var floatArray = new Float32Array(byteArrayForParsingFloat.buffer);\n\n\n return floatArray[0];\n },\n\n /**\n * Parses 64-bit float from a big-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed 64-bit float\n * @throws error if buffer overread would occur\n * @access private\n */\n readDouble (byteArray, position) {\n if (position < 0) {\n throw 'bigEndianByteArrayParser.readDouble: position cannot be less than 0';\n }\n\n if (position + 8 > byteArray.length) {\n throw 'bigEndianByteArrayParser.readDouble: attempt to read past end of buffer';\n }\n\n // I am sure there is a better way than this but this should be safe\n var byteArrayForParsingFloat = new Uint8Array(8);\n\n byteArrayForParsingFloat[7] = byteArray[position];\n byteArrayForParsingFloat[6] = byteArray[position + 1];\n byteArrayForParsingFloat[5] = byteArray[position + 2];\n byteArrayForParsingFloat[4] = byteArray[position + 3];\n byteArrayForParsingFloat[3] = byteArray[position + 4];\n byteArrayForParsingFloat[2] = byteArray[position + 5];\n byteArrayForParsingFloat[1] = byteArray[position + 6];\n byteArrayForParsingFloat[0] = byteArray[position + 7];\n var floatArray = new Float64Array(byteArrayForParsingFloat.buffer);\n\n\n return floatArray[0];\n }\n};\n", "/**\n *\n * Internal helper function to create a shared copy of a byteArray\n *\n */\n\n/**\n * Creates a view of the underlying byteArray. The view is of the same type as the byteArray (e.g.\n * Uint8Array or Buffer) and shares the same underlying memory (changing one changes the other)\n * @param byteArray the underlying byteArray (either Uint8Array or Buffer)\n * @param byteOffset offset into the underlying byteArray to create the view of\n * @param length number of bytes in the view\n * @returns {object} Uint8Array or Buffer depending on the type of byteArray\n */\nexport default function sharedCopy (byteArray, byteOffset, length) {\n if (typeof Buffer !== 'undefined' && byteArray instanceof Buffer) {\n return byteArray.slice(byteOffset, byteOffset + length);\n } else if (byteArray instanceof Uint8Array) {\n return new Uint8Array(byteArray.buffer, byteArray.byteOffset + byteOffset, length);\n }\n throw 'dicomParser.from: unknown type for byteArray';\n}\n", "import sharedCopy from './sharedCopy.js';\nimport { readFixedString } from './byteArrayParser.js';\n\n/**\n *\n * Internal helper class to assist with parsing. Supports reading from a byte\n * stream contained in a Uint8Array. Example usage:\n *\n * var byteArray = new Uint8Array(32);\n * var byteStream = new dicomParser.ByteStream(dicomParser.littleEndianByteArrayParser, byteArray);\n *\n * */\n\n/**\n * Constructor for ByteStream objects.\n * @param byteArrayParser a parser for parsing the byte array\n * @param byteArray a Uint8Array containing the byte stream\n * @param position (optional) the position to start reading from. 0 if not specified\n * @constructor\n * @throws will throw an error if the byteArrayParser parameter is not present\n * @throws will throw an error if the byteArray parameter is not present or invalid\n * @throws will throw an error if the position parameter is not inside the byte array\n */\nexport default class ByteStream {\n constructor (byteArrayParser, byteArray, position) {\n if (byteArrayParser === undefined) {\n throw 'dicomParser.ByteStream: missing required parameter \\'byteArrayParser\\'';\n }\n if (byteArray === undefined) {\n throw 'dicomParser.ByteStream: missing required parameter \\'byteArray\\'';\n }\n if ((byteArray instanceof Uint8Array) === false &&\n ((typeof Buffer === 'undefined') ||\n (byteArray instanceof Buffer) === false)) {\n throw 'dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer';\n }\n if (position < 0) {\n throw 'dicomParser.ByteStream: parameter \\'position\\' cannot be less than 0';\n }\n if (position >= byteArray.length) {\n throw 'dicomParser.ByteStream: parameter \\'position\\' cannot be greater than or equal to \\'byteArray\\' length';\n }\n this.byteArrayParser = byteArrayParser;\n this.byteArray = byteArray;\n this.position = position ? position : 0;\n this.warnings = []; // array of string warnings encountered while parsing\n }\n\n /**\n * Safely seeks through the byte stream. Will throw an exception if an attempt\n * is made to seek outside of the byte array.\n * @param offset the number of bytes to add to the position\n * @throws error if seek would cause position to be outside of the byteArray\n */\n seek (offset) {\n if (this.position + offset < 0) {\n throw 'dicomParser.ByteStream.prototype.seek: cannot seek to position < 0';\n }\n this.position += offset;\n }\n\n /**\n * Returns a new ByteStream object from the current position and of the requested number of bytes\n * @param numBytes the length of the byte array for the ByteStream to contain\n * @returns {dicomParser.ByteStream}\n * @throws error if buffer overread would occur\n */\n readByteStream (numBytes) {\n if (this.position + numBytes > this.byteArray.length) {\n throw 'dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread';\n }\n var byteArrayView = sharedCopy(this.byteArray, this.position, numBytes);\n\n this.position += numBytes;\n\n return new ByteStream(this.byteArrayParser, byteArrayView);\n }\n\n getSize() {\n return this.byteArray.length;\n }\n\n /**\n *\n * Parses an unsigned int 16 from a byte array and advances\n * the position by 2 bytes\n *\n * @returns {*} the parsed unsigned int 16\n * @throws error if buffer overread would occur\n */\n readUint16 () {\n var result = this.byteArrayParser.readUint16(this.byteArray, this.position);\n\n this.position += 2;\n\n return result;\n }\n\n /**\n * Parses an unsigned int 32 from a byte array and advances\n * the position by 2 bytes\n *\n * @returns {*} the parse unsigned int 32\n * @throws error if buffer overread would occur\n */\n readUint32 () {\n var result = this.byteArrayParser.readUint32(this.byteArray, this.position);\n\n this.position += 4;\n\n return result;\n }\n\n /**\n * Reads a string of 8-bit characters from an array of bytes and advances\n * the position by length bytes. A null terminator will end the string\n * but will not effect advancement of the position.\n * @param length the maximum number of bytes to parse\n * @returns {string} the parsed string\n * @throws error if buffer overread would occur\n */\n readFixedString (length) {\n var result = readFixedString(this.byteArray, this.position, length);\n\n this.position += length;\n\n return result;\n }\n}\n", "/**\n * Internal helper functions for parsing different types from a little-endian byte array\n */\n\nexport default {\n\n /**\n *\n * Parses an unsigned int 16 from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed unsigned int 16\n * @throws error if buffer overread would occur\n * @access private\n */\n readUint16 (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readUint16: position cannot be less than 0';\n }\n\n if (position + 2 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readUint16: attempt to read past end of buffer';\n }\n\n return byteArray[position] + (byteArray[position + 1] * 256);\n },\n\n /**\n *\n * Parses a signed int 16 from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed signed int 16\n * @throws error if buffer overread would occur\n * @access private\n */\n readInt16 (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readInt16: position cannot be less than 0';\n }\n if (position + 2 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readInt16: attempt to read past end of buffer';\n }\n\n let int16 = byteArray[position] + (byteArray[position + 1] << 8);\n\n // fix sign\n if (int16 & 0x8000) {\n int16 = int16 - 0xFFFF - 1;\n }\n\n return int16;\n },\n\n\n /**\n * Parses an unsigned int 32 from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed unsigned int 32\n * @throws error if buffer overread would occur\n * @access private\n */\n readUint32 (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readUint32: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readUint32: attempt to read past end of buffer';\n }\n\n return (byteArray[position] +\n (byteArray[position + 1] * 256) +\n (byteArray[position + 2] * 256 * 256) +\n (byteArray[position + 3] * 256 * 256 * 256));\n },\n\n /**\n * Parses a signed int 32 from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed unsigned int 32\n * @throws error if buffer overread would occur\n * @access private\n */\n readInt32 (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readInt32: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readInt32: attempt to read past end of buffer';\n }\n\n return (byteArray[position] +\n (byteArray[position + 1] << 8) +\n (byteArray[position + 2] << 16) +\n (byteArray[position + 3] << 24));\n },\n\n /**\n * Parses 32-bit float from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed 32-bit float\n * @throws error if buffer overread would occur\n * @access private\n */\n readFloat (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readFloat: position cannot be less than 0';\n }\n\n if (position + 4 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readFloat: attempt to read past end of buffer';\n }\n\n // I am sure there is a better way than this but this should be safe\n const byteArrayForParsingFloat = new Uint8Array(4);\n\n byteArrayForParsingFloat[0] = byteArray[position];\n byteArrayForParsingFloat[1] = byteArray[position + 1];\n byteArrayForParsingFloat[2] = byteArray[position + 2];\n byteArrayForParsingFloat[3] = byteArray[position + 3];\n\n const floatArray = new Float32Array(byteArrayForParsingFloat.buffer);\n\n return floatArray[0];\n },\n\n /**\n * Parses 64-bit float from a little-endian byte array\n *\n * @param byteArray the byte array to read from\n * @param position the position in the byte array to read from\n * @returns {*} the parsed 64-bit float\n * @throws error if buffer overread would occur\n * @access private\n */\n readDouble (byteArray, position) {\n if (position < 0) {\n throw 'littleEndianByteArrayParser.readDouble: position cannot be less than 0';\n }\n\n if (position + 8 > byteArray.length) {\n throw 'littleEndianByteArrayParser.readDouble: attempt to read past end of buffer';\n }\n\n // I am sure there is a better way than this but this should be safe\n const byteArrayForParsingFloat = new Uint8Array(8);\n\n byteArrayForParsingFloat[0] = byteArray[position];\n byteArrayForParsingFloat[1] = byteArray[position + 1];\n byteArrayForParsingFloat[2] = byteArray[position + 2];\n byteArrayForParsingFloat[3] = byteArray[position + 3];\n byteArrayForParsingFloat[4] = byteArray[position + 4];\n byteArrayForParsingFloat[5] = byteArray[position + 5];\n byteArrayForParsingFloat[6] = byteArray[position + 6];\n byteArrayForParsingFloat[7] = byteArray[position + 7];\n\n const floatArray = new Float64Array(byteArrayForParsingFloat.buffer);\n\n return floatArray[0];\n }\n};\n", "import ByteStream from './byteStream.js';\nimport DataSet from './dataSet.js';\nimport littleEndianByteArrayParser from './littleEndianByteArrayParser.js';\nimport readDicomElementExplicit from './readDicomElementExplicit.js';\n\n/**\n * Parses a DICOM P10 byte array and returns a DataSet object with the parsed elements. If the options\n * argument is supplied and it contains the untilTag property, parsing will stop once that\n * tag is encoutered. This can be used to parse partial byte streams.\n *\n * @param byteArray the byte array\n * @param options Optional options values\n * TransferSyntaxUID: String to specify a default raw transfer syntax UID.\n * Use the LEI transfer syntax for raw files, or the provided one for SCP transfers.\n * @returns {DataSet}\n * @throws error if an error occurs while parsing. The exception object will contain a property dataSet with the\n * elements successfully parsed before the error.\n */\n\nexport default function readPart10Header (byteArray, options = {}) {\n if (byteArray === undefined) {\n throw 'dicomParser.readPart10Header: missing required parameter \\'byteArray\\'';\n }\n\n const { TransferSyntaxUID } = options;\n const littleEndianByteStream = new ByteStream(littleEndianByteArrayParser, byteArray);\n\n function readPrefix() {\n if (littleEndianByteStream.getSize() <= 132 && TransferSyntaxUID) {\n return false;\n }\n littleEndianByteStream.seek(128);\n const prefix = littleEndianByteStream.readFixedString(4);\n\n if (prefix !== 'DICM') {\n const { TransferSyntaxUID } = options || {};\n if (!TransferSyntaxUID) {\n throw 'dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.';\n }\n littleEndianByteStream.seek(0);\n return false;\n }\n return true;\n }\n\n // main function here\n function readTheHeader() {\n // Per the DICOM standard, the header is always encoded in Explicit VR Little Endian (see PS3.10, section 7.1)\n // so use littleEndianByteStream throughout this method regardless of the transfer syntax\n const isPart10 = readPrefix();\n\n const warnings = [];\n const elements = {};\n\n if (!isPart10) {\n littleEndianByteStream.position = 0;\n const metaHeaderDataSet = {\n elements: { x00020010: { tag: 'x00020010', vr: 'UI', Value: TransferSyntaxUID } },\n warnings,\n };\n // console.log('Returning metaHeaderDataSet', metaHeaderDataSet);\n return metaHeaderDataSet;\n }\n\n while (littleEndianByteStream.position < littleEndianByteStream.byteArray.length) {\n const position = littleEndianByteStream.position;\n const element = readDicomElementExplicit(littleEndianByteStream, warnings);\n\n if (element.tag > 'x0002ffff') {\n littleEndianByteStream.position = position;\n break;\n }\n // Cache the littleEndianByteArrayParser for meta header elements, since the rest of the data set may be big endian\n // and this parser will be needed later if the meta header values are to be read.\n element.parser = littleEndianByteArrayParser;\n elements[element.tag] = element;\n }\n\n const metaHeaderDataSet = new DataSet(littleEndianByteStream.byteArrayParser, littleEndianByteStream.byteArray, elements);\n\n metaHeaderDataSet.warnings = littleEndianByteStream.warnings;\n metaHeaderDataSet.position = littleEndianByteStream.position;\n\n return metaHeaderDataSet;\n }\n\n // This is where we actually start parsing\n return readTheHeader();\n}\n", "import alloc from './alloc.js';\nimport bigEndianByteArrayParser from './bigEndianByteArrayParser.js';\nimport ByteStream from './byteStream.js';\nimport DataSet from './dataSet.js';\nimport littleEndianByteArrayParser from './littleEndianByteArrayParser.js';\nimport readPart10Header from './readPart10Header.js';\nimport sharedCopy from './sharedCopy.js';\nimport * as byteArrayParser from './byteArrayParser.js';\nimport * as parseDicomDataSet from './parseDicomDataSet.js';\n\n// LEE (Little Endian Explicit) is the transfer syntax used in dimse operations when there is a split\n// between the header and data.\nconst LEE = '1.2.840.10008.1.2.1';\n\n// LEI (Little Endian Implicit) is the transfer syntax in raw files\nconst LEI = '1.2.840.10008.1.2';\n\n// BEI (Big Endian Implicit) is deprecated, but needs special parse handling\nconst BEI = '1.2.840.10008.1.2.2';\n\n/**\n * Parses a DICOM P10 byte array and returns a DataSet object with the parsed elements.\n * If the options argument is supplied and it contains the untilTag property, parsing\n * will stop once that tag is encoutered. This can be used to parse partial byte streams.\n *\n * @param byteArray the byte array\n * @param options object to control parsing behavior (optional)\n * @returns {DataSet}\n * @throws error if an error occurs while parsing. The exception object will contain a\n * property dataSet with the elements successfully parsed before the error.\n */\n\nexport default function parseDicom(byteArray, options = {}) {\n if (byteArray === undefined) {\n throw new Error('dicomParser.parseDicom: missing required parameter \\'byteArray\\'');\n }\n\n \n const readTransferSyntax = (metaHeaderDataSet) => {\n if (metaHeaderDataSet.elements.x00020010 === undefined) {\n throw new Error('dicomParser.parseDicom: missing required meta header attribute 0002,0010');\n }\n\n const transferSyntaxElement = metaHeaderDataSet.elements.x00020010;\n return transferSyntaxElement && transferSyntaxElement.Value ||\n byteArrayParser.readFixedString(byteArray, transferSyntaxElement.dataOffset, transferSyntaxElement.length);\n }\n\n function isExplicit(transferSyntax) {\n // implicit little endian\n if (transferSyntax === '1.2.840.10008.1.2') {\n return false;\n }\n\n // all other transfer syntaxes should be explicit\n return true;\n }\n\n function getDataSetByteStream(transferSyntax, position) {\n // Detect whether we are inside a browser or Node.js\n const isNode = (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]');\n\n if (transferSyntax === '1.2.840.10008.1.2.1.99') {\n // if an infalter callback is registered, use it\n if (options && options.inflater) {\n const fullByteArrayCallback = options.inflater(byteArray, position);\n\n return new ByteStream(littleEndianByteArrayParser, fullByteArrayCallback, 0);\n }\n // if running on node, use the zlib library to inflate\n // http://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js\n else if (isNode === true) {\n // inflate it\n const zlib = require('zlib');\n const deflatedBuffer = sharedCopy(byteArray, position, byteArray.length - position);\n const inflatedBuffer = zlib.inflateRawSync(deflatedBuffer);\n\n // create a single byte array with the full header bytes and the inflated bytes\n const fullByteArrayBuffer = alloc(byteArray, inflatedBuffer.length + position);\n\n byteArray.copy(fullByteArrayBuffer, 0, 0, position);\n inflatedBuffer.copy(fullByteArrayBuffer, position);\n\n return new ByteStream(littleEndianByteArrayParser, fullByteArrayBuffer, 0);\n }\n // if pako is defined - use it. This is the web browser path\n // https://github.com/nodeca/pako\n else if (typeof pako !== 'undefined') {\n // inflate it\n const deflated = byteArray.slice(position);\n const inflated = pako.inflateRaw(deflated);\n\n // create a single byte array with the full header bytes and the inflated bytes\n const fullByteArray = alloc(byteArray, inflated.length + position);\n\n fullByteArray.set(byteArray.slice(0, position), 0);\n fullByteArray.set(inflated, position);\n\n return new ByteStream(littleEndianByteArrayParser, fullByteArray, 0);\n }\n\n // throw exception since no inflater is available\n throw 'dicomParser.parseDicom: no inflater available to handle deflate transfer syntax';\n }\n\n // explicit big endian\n if (transferSyntax === BEI) {\n return new ByteStream(bigEndianByteArrayParser, byteArray, position);\n }\n\n // all other transfer syntaxes are little endian; only the pixel encoding differs\n // make a new stream so the metaheader warnings don't come along for the ride\n return new ByteStream(littleEndianByteArrayParser, byteArray, position);\n }\n\n function mergeDataSets(metaHeaderDataSet, instanceDataSet) {\n for (const propertyName in metaHeaderDataSet.elements) {\n if (metaHeaderDataSet.elements.hasOwnProperty(propertyName)) {\n instanceDataSet.elements[propertyName] = metaHeaderDataSet.elements[propertyName];\n }\n }\n\n if (metaHeaderDataSet.warnings !== undefined) {\n instanceDataSet.warnings = metaHeaderDataSet.warnings.concat(instanceDataSet.warnings);\n }\n\n return instanceDataSet;\n }\n\n function readDataSet(metaHeaderDataSet) {\n const transferSyntax = readTransferSyntax(metaHeaderDataSet);\n const explicit = isExplicit(transferSyntax);\n const dataSetByteStream = getDataSetByteStream(transferSyntax, metaHeaderDataSet.position);\n\n const elements = {};\n const dataSet = new DataSet(dataSetByteStream.byteArrayParser, dataSetByteStream.byteArray, elements);\n\n dataSet.warnings = dataSetByteStream.warnings;\n\n try {\n if (explicit) {\n parseDicomDataSet.parseDicomDataSetExplicit(dataSet, dataSetByteStream, dataSetByteStream.byteArray.length, options);\n } else {\n parseDicomDataSet.parseDicomDataSetImplicit(dataSet, dataSetByteStream, dataSetByteStream.byteArray.length, options);\n }\n } catch (e) {\n const ex = {\n exception: e,\n dataSet\n };\n\n throw ex;\n }\n\n return dataSet;\n }\n\n // main function here\n function parseTheByteStream() {\n const metaHeaderDataSet = readPart10Header(byteArray, options);\n const dataSet = readDataSet(metaHeaderDataSet);\n\n return mergeDataSets(metaHeaderDataSet, dataSet);\n }\n\n // This is where we actually start parsing\n return parseTheByteStream();\n}\n\nexport { LEI, LEE, BEI };", "import alloc from './alloc.js';\nimport ByteStream from './byteStream.js';\nimport readSequenceItem from './readSequenceItem.js';\nimport sharedCopy from './sharedCopy.js';\n\n/**\n * Functionality for extracting encapsulated pixel data\n */\n\nconst calculateBufferSize = (fragments, startFragment, numFragments) => {\n let bufferSize = 0;\n\n for (let i = startFragment; i < startFragment + numFragments; i++) {\n bufferSize += fragments[i].length;\n }\n\n return bufferSize;\n};\n\n/**\n * Returns the encapsulated pixel data from the specified fragments. Use this function when you know\n * the fragments you want to extract data from. See\n *\n * @param dataSet - the dataSet containing the encapsulated pixel data\n * @param pixelDataElement - the pixel data element (x7fe00010) to extract the fragment data from\n * @param startFragmentIndex - zero based index of the first fragment to extract from\n * @param [numFragments] - the number of fragments to extract from, default is 1\n * @param [fragments] - optional array of objects describing each fragment (offset, position, length)\n * @returns {object} byte array with the encapsulated pixel data\n */\nexport default function readEncapsulatedPixelDataFromFragments (dataSet, pixelDataElement, startFragmentIndex, numFragments, fragments) {\n // default values\n numFragments = numFragments || 1;\n fragments = fragments || pixelDataElement.fragments;\n\n // check parameters\n if (dataSet === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter \\'dataSet\\'';\n }\n if (pixelDataElement === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter \\'pixelDataElement\\'';\n }\n if (startFragmentIndex === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter \\'startFragmentIndex\\'';\n }\n if (numFragments === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter \\'numFragments\\'';\n }\n if (pixelDataElement.tag !== 'x7fe00010') {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to non pixel data tag (expected tag = x7fe00010';\n }\n if (pixelDataElement.encapsulatedPixelData !== true) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.hadUndefinedLength !== true) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.basicOffsetTable === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.fragments === undefined) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.fragments.length <= 0) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (startFragmentIndex < 0) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'startFragmentIndex\\' must be >= 0';\n }\n if (startFragmentIndex >= pixelDataElement.fragments.length) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'startFragmentIndex\\' must be < number of fragments';\n }\n if (numFragments < 1) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'numFragments\\' must be > 0';\n }\n if (startFragmentIndex + numFragments > pixelDataElement.fragments.length) {\n throw 'dicomParser.readEncapsulatedPixelDataFromFragments: parameter \\'startFragment\\' + \\'numFragments\\' < number of fragments';\n }\n\n // create byte stream on the data for this pixel data element\n const byteStream = new ByteStream(dataSet.byteArrayParser, dataSet.byteArray, pixelDataElement.dataOffset);\n\n // seek past the basic offset table (no need to parse it again since we already have)\n const basicOffsetTable = readSequenceItem(byteStream);\n\n if (basicOffsetTable.tag !== 'xfffee000') {\n throw 'dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000';\n }\n\n byteStream.seek(basicOffsetTable.length);\n\n const fragmentZeroPosition = byteStream.position;\n\n // tag + length\n const fragmentHeaderSize = 8;\n\n // if there is only one fragment, return a view on this array to avoid copying\n if (numFragments === 1) {\n return sharedCopy(byteStream.byteArray, fragmentZeroPosition + fragments[startFragmentIndex].offset + fragmentHeaderSize, fragments[startFragmentIndex].length);\n }\n\n // more than one fragment, combine all of the fragments into one buffer\n const bufferSize = calculateBufferSize(fragments, startFragmentIndex, numFragments);\n const pixelData = alloc(byteStream.byteArray, bufferSize);\n let pixelDataIndex = 0;\n\n for (let i = startFragmentIndex; i < startFragmentIndex + numFragments; i++) {\n let fragmentOffset = fragmentZeroPosition + fragments[i].offset + fragmentHeaderSize;\n\n for (let j = 0; j < fragments[i].length; j++) {\n pixelData[pixelDataIndex++] = byteStream.byteArray[fragmentOffset++];\n }\n }\n\n return pixelData;\n}\n", "import readEncapsulatedPixelDataFromFragments from './readEncapsulatedPixelDataFromFragments.js';\n\n/**\n * Functionality for extracting encapsulated pixel data\n */\n\nconst findFragmentIndexWithOffset = (fragments, offset) => {\n for (let i = 0; i < fragments.length; i++) {\n if (fragments[i].offset === offset) {\n return i;\n }\n }\n};\n\nconst calculateNumberOfFragmentsForFrame = (frameIndex, basicOffsetTable, fragments, startFragmentIndex) => {\n // special case for last frame\n if (frameIndex === basicOffsetTable.length - 1) {\n return fragments.length - startFragmentIndex;\n }\n\n // iterate through each fragment looking for the one matching the offset for the next frame\n const nextFrameOffset = basicOffsetTable[frameIndex + 1];\n\n for (let i = startFragmentIndex + 1; i < fragments.length; i++) {\n if (fragments[i].offset === nextFrameOffset) {\n return i - startFragmentIndex;\n }\n }\n\n throw 'dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table';\n};\n\n/**\n * Returns the pixel data for the specified frame in an encapsulated pixel data element that has a non\n * empty basic offset table. Note that this function will fail if the basic offset table is empty - in that\n * case you need to determine which fragments map to which frames and read them using\n * readEncapsulatedPixelDataFromFragments(). Also see the function createJEPGBasicOffsetTable() to see\n * how a basic offset table can be created for JPEG images\n *\n * @param dataSet - the dataSet containing the encapsulated pixel data\n * @param pixelDataElement - the pixel data element (x7fe00010) to extract the frame from\n * @param frameIndex - the zero based frame index\n * @param [basicOffsetTable] - optional array of starting offsets for frames\n * @param [fragments] - optional array of objects describing each fragment (offset, position, length)\n * @returns {object} with the encapsulated pixel data\n */\nexport default function readEncapsulatedImageFrame (dataSet, pixelDataElement, frameIndex, basicOffsetTable, fragments) {\n // default parameters\n basicOffsetTable = basicOffsetTable || pixelDataElement.basicOffsetTable;\n fragments = fragments || pixelDataElement.fragments;\n\n // Validate parameters\n if (dataSet === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: missing required parameter \\'dataSet\\'';\n }\n if (pixelDataElement === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: missing required parameter \\'pixelDataElement\\'';\n }\n if (frameIndex === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: missing required parameter \\'frameIndex\\'';\n }\n if (basicOffsetTable === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'pixelDataElement\\' does not have basicOffsetTable';\n }\n if (pixelDataElement.tag !== 'x7fe00010') {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'pixelDataElement\\' refers to non pixel data tag (expected tag = x7fe00010)';\n }\n if (pixelDataElement.encapsulatedPixelData !== true) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'pixelDataElement\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.hadUndefinedLength !== true) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'pixelDataElement\\' refers to pixel data element that does not have undefined length';\n }\n if (pixelDataElement.fragments === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'pixelDataElement\\' refers to pixel data element that does not have fragments';\n }\n if (basicOffsetTable.length === 0) {\n throw 'dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries';\n }\n if (frameIndex < 0) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'frameIndex\\' must be >= 0';\n }\n if (frameIndex >= basicOffsetTable.length) {\n throw 'dicomParser.readEncapsulatedImageFrame: parameter \\'frameIndex\\' must be < basicOffsetTable.length';\n }\n\n // find starting fragment based on the offset for the frame in the basic offset table\n const offset = basicOffsetTable[frameIndex];\n const startFragmentIndex = findFragmentIndexWithOffset(fragments, offset);\n\n if (startFragmentIndex === undefined) {\n throw 'dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry';\n }\n\n // calculate the number of fragments for this frame\n const numFragments = calculateNumberOfFragmentsForFrame(frameIndex, basicOffsetTable, fragments, startFragmentIndex);\n\n // now extract the frame from the fragments\n return readEncapsulatedPixelDataFromFragments(dataSet, pixelDataElement, startFragmentIndex, numFragments, fragments);\n}\n", "import readEncapsulatedImageFrame from './readEncapsulatedImageFrame.js';\nimport readEncapsulatedPixelDataFromFragments from './readEncapsulatedPixelDataFromFragments.js';\n\n/**\n * Functionality for extracting encapsulated pixel data\n */\n\nlet deprecatedNoticeLogged = false;\n\n/**\n * Returns the pixel data for the specified frame in an encapsulated pixel data element. If no basic offset\n * table is present, it assumes that all fragments are for one frame. Note that this assumption/logic is not\n * valid for multi-frame instances so this function has been deprecated and will eventually be removed. Code\n * should be updated to use readEncapsulatedPixelDataFromFragments() or readEncapsulatedImageFrame()\n *\n * @deprecated since version 1.6 - use readEncapsulatedPixelDataFromFragments() or readEncapsulatedImageFrame()\n * @param dataSet - the dataSet containing the encapsulated pixel data\n * @param pixelDataElement - the pixel data element (x7fe00010) to extract the frame from\n * @param frame - the zero based frame index\n * @returns {object} with the encapsulated pixel data\n */\nexport default function readEncapsulatedPixelData (dataSet, pixelDataElement, frame) {\n if (!deprecatedNoticeLogged) {\n deprecatedNoticeLogged = true;\n\n if (console && console.log) {\n console.log('WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated');\n }\n }\n\n if (dataSet === undefined) {\n throw 'dicomParser.readEncapsulatedPixelData: missing required parameter \\'dataSet\\'';\n }\n if (pixelDataElement === undefined) {\n throw 'dicomParser.readEncapsulatedPixelData: missing required parameter \\'element\\'';\n }\n if (frame === undefined) {\n throw 'dicomParser.readEncapsulatedPixelData: missing required parameter \\'frame\\'';\n }\n if (pixelDataElement.tag !== 'x7fe00010') {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'element\\' refers to non pixel data tag (expected tag = x7fe00010)';\n }\n if (pixelDataElement.encapsulatedPixelData !== true) {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'element\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.hadUndefinedLength !== true) {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'element\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.basicOffsetTable === undefined) {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'element\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (pixelDataElement.fragments === undefined) {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'element\\' refers to pixel data element that does not have encapsulated pixel data';\n }\n if (frame < 0) {\n throw 'dicomParser.readEncapsulatedPixelData: parameter \\'frame\\' must be >= 0';\n }\n\n // If the basic offset table is not empty, we can extract the frame\n if (pixelDataElement.basicOffsetTable.length !== 0) {\n return readEncapsulatedImageFrame(dataSet, pixelDataElement, frame);\n }\n\n // No basic offset table, assume all fragments are for one frame - NOTE that this is NOT a valid\n // assumption but is the original behavior so we are keeping it for now\n return readEncapsulatedPixelDataFromFragments(dataSet, pixelDataElement, 0, pixelDataElement.fragments.length);\n}\n", "import {\n isStringVr,\n isPrivateTag,\n parsePN,\n parseTM,\n parseDA,\n explicitElementToString,\n explicitDataSetToJS,\n createJPEGBasicOffsetTable\n} from './util/index.js';\n\nimport { parseDicomDataSetExplicit, parseDicomDataSetImplicit } from './parseDicomDataSet.js';\nimport { readFixedString } from './byteArrayParser.js';\n\nimport alloc from './alloc.js';\nimport version from './version.js';\nimport bigEndianByteArrayParser from './bigEndianByteArrayParser.js';\nimport ByteStream from './byteStream.js';\nimport sharedCopy from './sharedCopy.js';\nimport DataSet from './dataSet.js';\nimport findAndSetUNElementLength from './findAndSetUNElementLength.js';\nimport findEndOfEncapsulatedElement from './findEndOfEncapsulatedPixelData.js';\nimport findItemDelimitationItemAndSetElementLength from './findItemDelimitationItem.js';\nimport littleEndianByteArrayParser from './littleEndianByteArrayParser.js';\nimport parseDicom, { LEI, LEE } from './parseDicom.js';\nimport readDicomElementExplicit from './readDicomElementExplicit.js';\nimport readDicomElementImplicit from './readDicomElementImplicit.js';\nimport readEncapsulatedImageFrame from './readEncapsulatedImageFrame.js';\nimport readEncapsulatedPixelData from './readEncapsulatedPixelData.js';\nimport readEncapsulatedPixelDataFromFragments from './readEncapsulatedPixelDataFromFragments.js';\nimport readPart10Header from './readPart10Header.js';\nimport readSequenceItemsExplicit from './readSequenceElementExplicit.js';\nimport readSequenceItemsImplicit from './readSequenceElementImplicit.js';\nimport readSequenceItem from './readSequenceItem.js';\nimport readTag from './readTag.js';\n\nconst dicomParser = {\n isStringVr,\n isPrivateTag,\n parsePN,\n parseTM,\n parseDA,\n explicitElementToString,\n explicitDataSetToJS,\n createJPEGBasicOffsetTable,\n parseDicomDataSetExplicit,\n parseDicomDataSetImplicit,\n readFixedString,\n alloc,\n version,\n bigEndianByteArrayParser,\n ByteStream,\n sharedCopy,\n DataSet,\n findAndSetUNElementLength,\n findEndOfEncapsulatedElement,\n findItemDelimitationItemAndSetElementLength,\n littleEndianByteArrayParser,\n parseDicom,\n readDicomElementExplicit,\n readDicomElementImplicit,\n readEncapsulatedImageFrame,\n readEncapsulatedPixelData,\n readEncapsulatedPixelDataFromFragments,\n readPart10Header,\n readSequenceItemsExplicit,\n readSequenceItemsImplicit,\n readSequenceItem,\n readTag,\n LEI,\n LEE,\n};\n\nexport {\n isStringVr,\n isPrivateTag,\n parsePN,\n parseTM,\n parseDA,\n explicitElementToString,\n explicitDataSetToJS,\n createJPEGBasicOffsetTable,\n parseDicomDataSetExplicit,\n parseDicomDataSetImplicit,\n readFixedString,\n alloc,\n version,\n bigEndianByteArrayParser,\n ByteStream,\n sharedCopy,\n DataSet,\n findAndSetUNElementLength,\n findEndOfEncapsulatedElement,\n findItemDelimitationItemAndSetElementLength,\n littleEndianByteArrayParser,\n parseDicom,\n readDicomElementExplicit,\n readDicomElementImplicit,\n readEncapsulatedImageFrame,\n readEncapsulatedPixelData,\n readEncapsulatedPixelDataFromFragments,\n readPart10Header,\n readSequenceItemsExplicit,\n readSequenceItemsImplicit,\n readSequenceItem,\n readTag\n};\n\nexport default dicomParser;\n", " \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n" ], "sourceRoot": "" }