cod-dicomweb-server 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +103 -0
- package/dist/{16.index.js → 16.js} +2 -2
- package/dist/16.js.map +1 -0
- package/dist/{170.index.js → 170.js} +3 -3
- package/dist/170.js.map +1 -0
- package/dist/{index.js → main.js} +4 -4
- package/dist/main.js.map +1 -0
- package/dist/types/classes/CodDicomWebServer.d.ts +3 -2
- package/dist/types/classes/utils.d.ts +5 -5
- package/dist/types/metadataManager.d.ts +7 -1
- package/package.json +9 -6
- package/dist/16.index.js.map +0 -1
- package/dist/170.index.js.map +0 -1
- package/dist/index.js.map +0 -1
- /package/dist/types/webWorker/{registerWorker.d.ts → registerWorkers.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* cod-dicomweb-server v1.1
|
|
3
|
+
* cod-dicomweb-server v1.2.1
|
|
4
4
|
* git+https://github.com/gradienthealth/cod-dicomweb-server.git
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Adithyan Dinesh and project contributors.
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={915:function(e,t,r){
|
|
13
13
|
/*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */
|
|
14
|
-
e.exports=function(e){return r=[function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t),r.d(t,"isStringVr",(function(){return a})),r.d(t,"isPrivateTag",(function(){return i})),r.d(t,"parsePN",(function(){return o})),r.d(t,"parseTM",(function(){return s})),r.d(t,"parseDA",(function(){return u})),r.d(t,"explicitElementToString",(function(){return f})),r.d(t,"explicitDataSetToJS",(function(){return l})),r.d(t,"createJPEGBasicOffsetTable",(function(){return p})),r.d(t,"parseDicomDataSetExplicit",(function(){return F})),r.d(t,"parseDicomDataSetImplicit",(function(){return U})),r.d(t,"readFixedString",(function(){return v})),r.d(t,"alloc",(function(){return N})),r.d(t,"version",(function(){return _})),r.d(t,"bigEndianByteArrayParser",(function(){return j})),r.d(t,"ByteStream",(function(){return R})),r.d(t,"sharedCopy",(function(){return B})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return g})),r.d(t,"findEndOfEncapsulatedElement",(function(){return y})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return q})),r.d(t,"parseDicom",(function(){return C})),r.d(t,"readDicomElementExplicit",(function(){return D})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return V})),r.d(t,"readEncapsulatedPixelData",(function(){return $})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(t,"readPart10Header",(function(){return G})),r.d(t,"readSequenceItemsExplicit",(function(){return T})),r.d(t,"readSequenceItemsImplicit",(function(){return I})),r.d(t,"readSequenceItem",(function(){return A})),r.d(t,"readTag",(function(){return m}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},a=function(e){return n[e]},i=function(e){if(e=parseInt(e[4],16),isNaN(e))throw"dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},o=function(e){if(void 0!==e)return{familyName:(e=e.split("^"))[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}};function s(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),n=4<=e.length?parseInt(e.substring(2,4),10):void 0,a=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=(i=8<=e.length?e.substring(7,13):void 0)?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||void 0!==i&&isNaN(i)||r<0||23<r||n&&(n<0||59<n)||a&&(a<0||59<a)||i&&(i<0||999999<i)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:a,fractionalSeconds:i}}if(t)throw"invalid TM '".concat(e,"'")}function c(e,t,r){return!isNaN(r)&&0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r)}function u(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(4,6),10),a=parseInt(e.substring(6,8),10);if(t&&!0!==c(a,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:a}}if(t)throw"invalid DA '".concat(e,"'")}function f(e,t){if(void 0===e||void 0===t)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===t.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=t.vr,i=t.tag;function o(t,r){for(var n="",a=0;a<t;a++)0!==a&&(n+="/"),n+=r.call(e,i,a).toString();return n}if(!0===a(n))r=e.string(i);else{if("AT"===n){var s=e.uint32(i);return void 0===s?void 0:"x".concat((s=s<0?4294967295+s+1:s).toString(16).toUpperCase())}"US"===n?r=o(t.length/2,e.uint16):"SS"===n?r=o(t.length/2,e.int16):"UL"===n?r=o(t.length/4,e.uint32):"SL"===n?r=o(t.length/4,e.int32):"FD"===n?r=o(t.length/8,e.double):"FL"===n&&(r=o(t.length/4,e.float))}return r}function l(e,t){if(void 0===e)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in e.elements){var a=e.elements[r];if(!0!==t.omitPrivateAttibutes||!i(r))if(a.items){for(var o=[],s=0;s<a.items.length;s++)o.push(l(a.items[s].dataSet,t));n[r]=o}else{var c=void 0;a.length<t.maxElementLength&&(c=f(e,a)),n[r]=void 0!==c?c:{dataOffset:a.dataOffset,length:a.length}}}return n}function d(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function h(e,t,r){for(var n,a,i=r;i<t.fragments.length;i++)if(a=i,d(n=e,(a=t.fragments[a]).position+a.length-2)||d(n,a.position+a.length-3))return i}function p(e,t,r){if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var n=[],a=0;;){n.push(t.fragments[a].offset);var i=h(e,t,a);if(void 0===i||i===t.fragments.length-1)return n;a=i+1}}function m(e){if(void 0===e)throw"dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256;return e=e.readUint16(),"x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function y(e,t,r){if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==m(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,a=0;a<n;a++){var i=e.readUint32();t.basicOffsetTable.push(i)}for(var o=e.position;e.position<e.byteArray.length;){var s=m(e),c=e.readUint32();if("xfffee0dd"===s)return e.seek(c),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),c>e.byteArray.length-e.position&&(c=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c)}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"))}function g(e,t){if(void 0===e)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57565===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}function v(e,t,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,a="",i=0;i<r;i++){if(0===(n=e[t+i]))return t+=r,a;a+=String.fromCharCode(n)}return a}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function w(e,t){return void 0!==e.parser?e.parser:t}var E=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.byteArrayParser=t,this.byteArray=r,this.elements=n}var t,r,n;return t=e,(r=[{key:"uint16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){if((e=this.elements[e])&&0<e.length)return null===(e=v(this.byteArray,e.dataOffset,e.length).match(/\\/g))?1:e.length+1}},{key:"string",value:function(e,t){return(e=this.elements[e])&&e.Value?e.Value:e&&0<e.length?(e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].trim():e.trim()):void 0}},{key:"text",value:function(e,t){if((e=this.elements[e])&&0<e.length)return e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseFloat(t)}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseInt(t)}},{key:"attributeTag",value:function(e){if((r=this.elements[e])&&4===r.length){var t=w(r,this.byteArrayParser).readUint16,r=(e=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*t(e,r)*256+t(e,r+2)).toString(16)).substr(-8))}}}])&&b(t.prototype,r),n&&b(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function x(e,t){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57357===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}var P=function(e,t){return void 0!==e.vr?"SQ"===e.vr:t.position+4<=t.byteArray.length?(e=m(t),t.seek(-4),"xfffee000"===e||"xfffee0dd"===e):(t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=m(e),vr:void 0!==r?r(n):void 0,length:e.readUint32(),dataOffset:e.position}).length&&(n.hadUndefinedLength=!0),n.tag===t||(!P(n,e)||i(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(I(e,n,r),i(n.tag)&&(n.items=void 0))),n}function A(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:m(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function O(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=S(e,void 0,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),U(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function I(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=O(e,r),t.items.push(n)}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=O(e,r);t.items.push(a)}})(e,t,r)}function k(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=D(e,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),F(r.dataSet,e,e.position+r.length)),r}function T(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=k(e,r),t.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=k(e,r);t.items.push(a)}})(e,t,r)}var L=function(e){return"OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function D(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:m(e),vr:e.readFixedString(2)};return 2===L(n.vr)?n.length=e.readUint16():(e.seek(2),n.length=e.readUint32()),n.dataOffset=e.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(e,n,t):4294967295===n.length?"x7fe00010"===n.tag?y(e,n,t):("UN"===n.vr?I:x)(e,n):e.seek(n.length)),n}function F(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var a=e.elements;t.position<r;){var i=D(t,e.warnings,n.untilTag);if((a[i.tag]=i).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function U(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var a=e.elements;t.position<r;){var i=S(t,n.untilTag,n.vrCallback);if((a[i.tag]=i).tag===n.untilTag)return}}function N(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw"dicomParser.alloc: unknown type for byteArray"}var _="1.8.12",j={readUint16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=(e[t]<<8)+e[t+1])?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function B(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw"dicomParser.from: unknown type for byteArray"}function M(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var R=function(){function e(t,r,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=t,this.byteArray=r,this.position=n||0,this.warnings=[]}var t,r,n;return t=e,(r=[{key:"seek",value:function(e){if(this.position+e<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e}},{key:"readByteStream",value:function(t){if(this.position+t>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=B(this.byteArray,this.position,t);return this.position+=t,new e(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=v(this.byteArray,this.position,e);return this.position+=e,t}}])&&M(t.prototype,r),n&&M(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),q={readUint16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=e[t]+(e[t+1]<<8))?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function G(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=t.TransferSyntaxUID,n=new R(q,e);return function(){var e=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(t||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),a=[],i={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:a};for(;n.position<n.byteArray.length;){var o=n.position,s=D(n,a);if("x0002ffff"<s.tag){n.position=o;break}s.parser=q,i[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,i)).warnings=n.warnings,e.position=n.position,e}()}var W="1.2.840.10008.1.2.2";function C(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,a=function(t){if(void 0===t.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(t=t.elements.x00020010)&&t.Value||v(e,t.dataOffset,t.length)};function i(n){var i="1.2.840.10008.1.2"!==(o=a(n)),o=function(n,a){var i="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new R(n===W?j:q,e,a);if(t&&t.inflater)return n=t.inflater(e,a),new R(q,n,0);if(1==i){var o=r(0),s=B(e,a,e.length-a);return o=o.inflateRawSync(s),s=N(e,o.length+a),e.copy(s,0,0,a),o.copy(s,a),new R(q,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(a),s=pako.inflateRaw(o),(o=N(e,s.length+a)).set(e.slice(0,a),0),o.set(s,a),new R(q,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(i?F:U)(n,o,o.byteArray.length,t)}catch(o){throw{exception:o,dataSet:n}}return n}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(n=G(e,t),i(n))}var z=function(e,t,r){for(var n=0,a=t;a<t+r;a++)n+=e[a].length;return n};function H(e,t,r,n,a){if(a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new R(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=A(i)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===n)return B(i.byteArray,o+a[r].offset+8,a[r].length);t=z(a,r,n);for(var s=N(i.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+a[u].offset+8,l=0;l<a[u].length;l++)s[c++]=i.byteArray[f++];return s}var J=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Y=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var a=t[e+1],i=n+1;i<r.length;i++)if(r[i].offset===a)return i-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(e,t,r,n,a){if(n=n||t.basicOffsetTable,a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=n[r];if(void 0===(i=J(a,i)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(e,t,i,Y(r,n,a,i),a)}var Z=!1;function $(e,t,r){if(Z||(Z=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?V(e,t,r):H(e,t,0,t.fragments.length)}t.default={isStringVr:a,isPrivateTag:i,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:U,readFixedString:v,alloc:N,version:_,bigEndianByteArrayParser:j,ByteStream:R,sharedCopy:B,DataSet:E,findAndSetUNElementLength:g,findEndOfEncapsulatedElement:y,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:q,parseDicom:C,readDicomElementExplicit:D,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:H,readPart10Header:G,readSequenceItemsExplicit:T,readSequenceItemsImplicit:I,readSequenceItem:A,readTag:m,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},t.m=r,t.c=n,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(t){return e[t]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1);function t(e){if(n[e])return n[e].exports;var a=n[e]={i:e,l:!1,exports:{}};return r[e].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.m=e,r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.u=e=>e+".index.js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var a=n.length-1;a>-1&&(!e||!/^http(s?):/.test(e));)e=n[a--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>de,FetchType:()=>i,default:()=>he});var e={};r.r(e),r.d(e,{FetchType:()=>i,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>W,FILE_EXTENSIONS:()=>C,URL_VALIDATION_STRING:()=>z});var a={};r.r(a),r.d(a,{FILE_PARTIAL_WORKER_NAME:()=>H,FILE_STREAMING_WORKER_NAME:()=>J,THRESHOLD:()=>Y});var i=function(e){return e[e.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",e[e.API_OPTIMIZED=1]="API_OPTIMIZED",e}({}),o=function(e){return e[e.FRAME=0]="FRAME",e[e.THUMBNAIL=1]="THUMBNAIL",e[e.SERIES_METADATA=2]="SERIES_METADATA",e[e.INSTANCE_METADATA=3]="INSTANCE_METADATA",e}({}),s=r(915);
|
|
14
|
+
e.exports=function(e){return r=[function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t),r.d(t,"isStringVr",(function(){return a})),r.d(t,"isPrivateTag",(function(){return i})),r.d(t,"parsePN",(function(){return o})),r.d(t,"parseTM",(function(){return s})),r.d(t,"parseDA",(function(){return u})),r.d(t,"explicitElementToString",(function(){return f})),r.d(t,"explicitDataSetToJS",(function(){return l})),r.d(t,"createJPEGBasicOffsetTable",(function(){return p})),r.d(t,"parseDicomDataSetExplicit",(function(){return F})),r.d(t,"parseDicomDataSetImplicit",(function(){return U})),r.d(t,"readFixedString",(function(){return v})),r.d(t,"alloc",(function(){return N})),r.d(t,"version",(function(){return j})),r.d(t,"bigEndianByteArrayParser",(function(){return _})),r.d(t,"ByteStream",(function(){return R})),r.d(t,"sharedCopy",(function(){return M})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return g})),r.d(t,"findEndOfEncapsulatedElement",(function(){return y})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return q})),r.d(t,"parseDicom",(function(){return G})),r.d(t,"readDicomElementExplicit",(function(){return L})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return V})),r.d(t,"readEncapsulatedPixelData",(function(){return $})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(t,"readPart10Header",(function(){return C})),r.d(t,"readSequenceItemsExplicit",(function(){return I})),r.d(t,"readSequenceItemsImplicit",(function(){return k})),r.d(t,"readSequenceItem",(function(){return A})),r.d(t,"readTag",(function(){return m}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},a=function(e){return n[e]},i=function(e){if(e=parseInt(e[4],16),isNaN(e))throw"dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},o=function(e){if(void 0!==e)return{familyName:(e=e.split("^"))[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}};function s(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),n=4<=e.length?parseInt(e.substring(2,4),10):void 0,a=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=(i=8<=e.length?e.substring(7,13):void 0)?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||void 0!==i&&isNaN(i)||r<0||23<r||n&&(n<0||59<n)||a&&(a<0||59<a)||i&&(i<0||999999<i)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:a,fractionalSeconds:i}}if(t)throw"invalid TM '".concat(e,"'")}function c(e,t,r){return!isNaN(r)&&0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r)}function u(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(4,6),10),a=parseInt(e.substring(6,8),10);if(t&&!0!==c(a,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:a}}if(t)throw"invalid DA '".concat(e,"'")}function f(e,t){if(void 0===e||void 0===t)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===t.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=t.vr,i=t.tag;function o(t,r){for(var n="",a=0;a<t;a++)0!==a&&(n+="/"),n+=r.call(e,i,a).toString();return n}if(!0===a(n))r=e.string(i);else{if("AT"===n){var s=e.uint32(i);return void 0===s?void 0:"x".concat((s=s<0?4294967295+s+1:s).toString(16).toUpperCase())}"US"===n?r=o(t.length/2,e.uint16):"SS"===n?r=o(t.length/2,e.int16):"UL"===n?r=o(t.length/4,e.uint32):"SL"===n?r=o(t.length/4,e.int32):"FD"===n?r=o(t.length/8,e.double):"FL"===n&&(r=o(t.length/4,e.float))}return r}function l(e,t){if(void 0===e)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in e.elements){var a=e.elements[r];if(!0!==t.omitPrivateAttibutes||!i(r))if(a.items){for(var o=[],s=0;s<a.items.length;s++)o.push(l(a.items[s].dataSet,t));n[r]=o}else{var c=void 0;a.length<t.maxElementLength&&(c=f(e,a)),n[r]=void 0!==c?c:{dataOffset:a.dataOffset,length:a.length}}}return n}function d(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function h(e,t,r){for(var n,a,i=r;i<t.fragments.length;i++)if(a=i,d(n=e,(a=t.fragments[a]).position+a.length-2)||d(n,a.position+a.length-3))return i}function p(e,t,r){if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var n=[],a=0;;){n.push(t.fragments[a].offset);var i=h(e,t,a);if(void 0===i||i===t.fragments.length-1)return n;a=i+1}}function m(e){if(void 0===e)throw"dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256;return e=e.readUint16(),"x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function y(e,t,r){if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==m(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,a=0;a<n;a++){var i=e.readUint32();t.basicOffsetTable.push(i)}for(var o=e.position;e.position<e.byteArray.length;){var s=m(e),c=e.readUint32();if("xfffee0dd"===s)return e.seek(c),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),c>e.byteArray.length-e.position&&(c=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c)}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"))}function g(e,t){if(void 0===e)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57565===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}function v(e,t,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,a="",i=0;i<r;i++){if(0===(n=e[t+i]))return t+=r,a;a+=String.fromCharCode(n)}return a}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function w(e,t){return void 0!==e.parser?e.parser:t}var E=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.byteArrayParser=t,this.byteArray=r,this.elements=n}var t,r,n;return t=e,(r=[{key:"uint16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){if((e=this.elements[e])&&0<e.length)return null===(e=v(this.byteArray,e.dataOffset,e.length).match(/\\/g))?1:e.length+1}},{key:"string",value:function(e,t){return(e=this.elements[e])&&e.Value?e.Value:e&&0<e.length?(e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].trim():e.trim()):void 0}},{key:"text",value:function(e,t){if((e=this.elements[e])&&0<e.length)return e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseFloat(t)}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseInt(t)}},{key:"attributeTag",value:function(e){if((r=this.elements[e])&&4===r.length){var t=w(r,this.byteArrayParser).readUint16,r=(e=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*t(e,r)*256+t(e,r+2)).toString(16)).substr(-8))}}}])&&b(t.prototype,r),n&&b(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function x(e,t){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57357===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}var P=function(e,t){return void 0!==e.vr?"SQ"===e.vr:t.position+4<=t.byteArray.length?(e=m(t),t.seek(-4),"xfffee000"===e||"xfffee0dd"===e):(t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=m(e),vr:void 0!==r?r(n):void 0,length:e.readUint32(),dataOffset:e.position}).length&&(n.hadUndefinedLength=!0),n.tag===t||(!P(n,e)||i(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(k(e,n,r),i(n.tag)&&(n.items=void 0))),n}function A(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:m(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function O(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=S(e,void 0,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),U(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function k(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=O(e,r),t.items.push(n)}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=O(e,r);t.items.push(a)}})(e,t,r)}function T(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=L(e,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),F(r.dataSet,e,e.position+r.length)),r}function I(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=T(e,r),t.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=T(e,r);t.items.push(a)}})(e,t,r)}var D=function(e){return"OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function L(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:m(e),vr:e.readFixedString(2)};return 2===D(n.vr)?n.length=e.readUint16():(e.seek(2),n.length=e.readUint32()),n.dataOffset=e.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?I(e,n,t):4294967295===n.length?"x7fe00010"===n.tag?y(e,n,t):("UN"===n.vr?k:x)(e,n):e.seek(n.length)),n}function F(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var a=e.elements;t.position<r;){var i=L(t,e.warnings,n.untilTag);if((a[i.tag]=i).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function U(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var a=e.elements;t.position<r;){var i=S(t,n.untilTag,n.vrCallback);if((a[i.tag]=i).tag===n.untilTag)return}}function N(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw"dicomParser.alloc: unknown type for byteArray"}var j="1.8.12",_={readUint16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=(e[t]<<8)+e[t+1])?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function M(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw"dicomParser.from: unknown type for byteArray"}function B(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var R=function(){function e(t,r,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=t,this.byteArray=r,this.position=n||0,this.warnings=[]}var t,r,n;return t=e,(r=[{key:"seek",value:function(e){if(this.position+e<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e}},{key:"readByteStream",value:function(t){if(this.position+t>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,t);return this.position+=t,new e(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=v(this.byteArray,this.position,e);return this.position+=e,t}}])&&B(t.prototype,r),n&&B(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),q={readUint16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=e[t]+(e[t+1]<<8))?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function C(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=t.TransferSyntaxUID,n=new R(q,e);return function(){var e=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(t||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),a=[],i={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:a};for(;n.position<n.byteArray.length;){var o=n.position,s=L(n,a);if("x0002ffff"<s.tag){n.position=o;break}s.parser=q,i[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,i)).warnings=n.warnings,e.position=n.position,e}()}var W="1.2.840.10008.1.2.2";function G(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,a=function(t){if(void 0===t.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(t=t.elements.x00020010)&&t.Value||v(e,t.dataOffset,t.length)};function i(n){var i="1.2.840.10008.1.2"!==(o=a(n)),o=function(n,a){var i="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new R(n===W?_:q,e,a);if(t&&t.inflater)return n=t.inflater(e,a),new R(q,n,0);if(1==i){var o=r(0),s=M(e,a,e.length-a);return o=o.inflateRawSync(s),s=N(e,o.length+a),e.copy(s,0,0,a),o.copy(s,a),new R(q,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(a),s=pako.inflateRaw(o),(o=N(e,s.length+a)).set(e.slice(0,a),0),o.set(s,a),new R(q,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(i?F:U)(n,o,o.byteArray.length,t)}catch(o){throw{exception:o,dataSet:n}}return n}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(n=C(e,t),i(n))}var z=function(e,t,r){for(var n=0,a=t;a<t+r;a++)n+=e[a].length;return n};function H(e,t,r,n,a){if(a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new R(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=A(i)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===n)return M(i.byteArray,o+a[r].offset+8,a[r].length);t=z(a,r,n);for(var s=N(i.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+a[u].offset+8,l=0;l<a[u].length;l++)s[c++]=i.byteArray[f++];return s}var J=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},Y=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var a=t[e+1],i=n+1;i<r.length;i++)if(r[i].offset===a)return i-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(e,t,r,n,a){if(n=n||t.basicOffsetTable,a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=n[r];if(void 0===(i=J(a,i)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(e,t,i,Y(r,n,a,i),a)}var Z=!1;function $(e,t,r){if(Z||(Z=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?V(e,t,r):H(e,t,0,t.fragments.length)}t.default={isStringVr:a,isPrivateTag:i,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:U,readFixedString:v,alloc:N,version:j,bigEndianByteArrayParser:_,ByteStream:R,sharedCopy:M,DataSet:E,findAndSetUNElementLength:g,findEndOfEncapsulatedElement:y,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:q,parseDicom:G,readDicomElementExplicit:L,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:H,readPart10Header:C,readSequenceItemsExplicit:I,readSequenceItemsImplicit:k,readSequenceItem:A,readTag:m,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},t.m=r,t.c=n,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(t){return e[t]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1);function t(e){if(n[e])return n[e].exports;var a=n[e]={i:e,l:!1,exports:{}};return r[e].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.m=e,r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.u=e=>e+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var a=n.length-1;a>-1&&(!e||!/^http(s?):/.test(e));)e=n[a--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>de,FetchType:()=>i,default:()=>he});var e={};r.r(e),r.d(e,{FetchType:()=>i,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>W,FILE_EXTENSIONS:()=>G,URL_VALIDATION_STRING:()=>z});var a={};r.r(a),r.d(a,{FILE_PARTIAL_WORKER_NAME:()=>H,FILE_STREAMING_WORKER_NAME:()=>J,THRESHOLD:()=>Y});var i=function(e){return e[e.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",e[e.API_OPTIMIZED=1]="API_OPTIMIZED",e}({}),o=function(e){return e[e.FRAME=0]="FRAME",e[e.THUMBNAIL=1]="THUMBNAIL",e[e.SERIES_METADATA=2]="SERIES_METADATA",e[e.INSTANCE_METADATA=3]="INSTANCE_METADATA",e}({}),s=r(915);
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2019 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
*/
|
|
20
|
-
const c=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),f=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.finalizer"),d=Symbol("Comlink.thrown"),h=e=>"object"==typeof e&&null!==e||"function"==typeof e,p=new Map([["proxy",{canHandle:e=>h(e)&&e[c],serialize(e){const{port1:t,port2:r}=new MessageChannel;return m(e,t),[r,[r]]},deserialize:e=>(e.start(),g(e))}],["throw",{canHandle:e=>h(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function m(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(a){if(!a||!a.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:i,type:o,path:s}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(O);let f;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),r=s.reduce(((e,t)=>e[t]),e);switch(o){case"GET":f=r;break;case"SET":t[s.slice(-1)[0]]=O(a.data.value),f=!0;break;case"APPLY":f=r.apply(t,u);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[c]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;m(e,r),f=function(e,t){return S.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[d]:0}}Promise.resolve(f).catch((e=>({value:e,[d]:0}))).then((r=>{const[a,s]=A(r);t.postMessage(Object.assign(Object.assign({},a),{id:i}),s),"RELEASE"===o&&(t.removeEventListener("message",n),y(t),l in e&&"function"==typeof e[l]&&e[l]())})).catch((e=>{const[r,n]=A({value:new TypeError("Unserializable return value"),[d]:0});t.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),t.start&&t.start()}function y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function g(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),x(e,r,[],t)}function v(e){if(e)throw new Error("Proxy has been released and is not useable")}function b(e){return I(e,new Map,{type:"RELEASE"}).then((()=>{y(e)}))}const w=new WeakMap,E="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(w.get(e)||0)-1;w.set(e,t),0===t&&b(e)}));function x(e,t,r=[],n=function(){}){let a=!1;const i=new Proxy(n,{get(n,o){if(v(a),o===f)return()=>{!function(e){E&&E.unregister(e)}(i),b(e),t.clear(),a=!0};if("then"===o){if(0===r.length)return{then:()=>i};const n=I(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(O);return n.then.bind(n)}return x(e,t,[...r,o])},set(n,i,o){v(a);const[s,c]=A(o);return I(e,t,{type:"SET",path:[...r,i].map((e=>e.toString())),value:s},c).then(O)},apply(n,i,o){v(a);const s=r[r.length-1];if(s===u)return I(e,t,{type:"ENDPOINT"}).then(O);if("bind"===s)return x(e,t,r.slice(0,-1));const[c,f]=P(o);return I(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:c},f).then(O)},construct(n,i){v(a);const[o,s]=P(i);return I(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(O)}});return function(e,t){const r=(w.get(t)||0)+1;w.set(t,r),E&&E.register(e,t,e)}(i,e),i}function P(e){const t=e.map(A);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const S=new WeakMap;function A(e){for(const[t,r]of p)if(r.canHandle(e)){const[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},S.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return p.get(e.name).deserialize(e.value);case"RAW":return e.value}}function I(e,t,r,n){return new Promise((a=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)}))}function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function T(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */T=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new F(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(U([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==k(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=I(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function I(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,I(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function U(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(k(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=U,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),D(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;D(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:U(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function L(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function D(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,F(n.key),n)}}function F(e){var t=function(e,t){if("object"!=k(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==k(t)?t:t+""}var U=new(function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=F(r="workerRegistry"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"registerWorker",value:function(e,t){try{var r=t();if(!r)return;this.workerRegistry[e]={instance:g(r),nativeWorker:r}}catch(e){console.warn(e)}}},{key:"executeTask",value:(n=T().mark((function e(t,r,n){var a,i;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null===(a=this.workerRegistry[t])||void 0===a?void 0:a.instance){e.next=3;break}throw new Error("Worker ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,i[r](n);case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(t,'":'),e.t0),new Error('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,a){var i=n.apply(e,t);function o(e){L(i,r,a,o,s,"next",e)}function s(e){L(i,r,a,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.addEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.removeEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}}],t&&D(e.prototype,t),r&&D(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a}());function N(){return U}function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return B(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?B(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function M(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,q(n.key),n)}}function R(e,t,r){return(t=q(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}const G=function(){return e=function e(t){var r=t.fileStreamingWorkerName;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),R(this,"files",{}),R(this,"fileStreamingWorkerName",void 0),this.fileStreamingWorkerName=r},(t=[{key:"set",value:function(e,t){this.files[e]=t}},{key:"get",value:function(e,t){return!this.files[e]||t&&this.files[e].position<=t.endByte?null:t?this.files[e].data.slice(t.startByte,t.endByte):this.files[e].data}},{key:"setPosition",value:function(e,t){this.files[e]&&(this.files[e].position=t)}},{key:"getPosition",value:function(e){var t;return null===(t=this.files[e])||void 0===t?void 0:t.position}},{key:"append",value:function(e,t,r){this.files[e]&&r&&(this.files[e].data.set(t,r-t.length),this.setPosition(e,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(e,t){var r=j(t,2),n=r[0],a=r[1].position;return n.includes("?bytes=")?e:e+a}),0)}},{key:"remove",value:function(e){var t=this.getPosition(e);delete this.files[e],e.includes("?bytes=")||N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",t)}},{key:"purge",value:function(){var e=this.getTotalSize();this.files={},N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",e)}}])&&M(e.prototype,t),r&&M(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();var W="https://storage.googleapis.com",C=[".tar",".zip"],z="/dicomweb/",H="filePartial",J="fileStreaming",Y=1e4;const V={Enums:e,url:t,worker:a};function Z(e,t){if(e.includes(V.url.URL_VALIDATION_STRING)){var r,n=e.split(t+"/")[1],a=n.split("/studies")[0],i=a.split("/"),s=i[0],c=i.slice(1).join("/"),u=n.split(a+"/")[1].split("/"),f=u[1],l=u[3],d="",h=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(d=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):d=u[5],h=+(u[7]||h),r=o.FRAME;break;default:throw new Error("Invalid type of request")}return{type:r,bucketName:s,bucketPrefix:c,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:d,frameNumber:h}}}function $(e,t,r,n){var a;if(!e||null===(a=e.cod)||void 0===a||!a.instances||!e.thumbnail)throw new Error("Invalid seriesMetadata provided.");if(!t)throw new Error("SOP Instance UID is required.");if(null==r)throw new Error("Frame index is required.");var i=Object.values(e.cod.instances).find((function(e){var r;return(null===(r=e.metadata["00080018"])||void 0===r||null===(r=r.Value)||void 0===r?void 0:r[0])===t}));if(!i)throw new Error("Instance with SOPInstanceUID ".concat(t," not found."));var o,s,c=n.domain,u=n.bucketName,f=n.bucketPrefix,l=i.url,d=i.uri,h=i.headers,p=i.offset_tables,m=function(e,t,r,n){var a=e,i=V.url.FILE_EXTENSIONS.find((function(t){return e.includes(t)}));if(i){a=e.split(i)[0]+i}var o=a.split("studies/")[1];return a="".concat(t,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),a}(l||d,c,u,f),y=p||{},g=y.CustomOffsetTable,v=y.CustomOffsetTableLengths,b=!1;null!=g&&g.length&&null!=v&&v.length&&(s=(o=g[r])+v[r],b=!0);var w=h.start_byte,E=h.end_byte,x=void 0!==o?w+o:w,P=void 0!==s?w+s:E,S=e.thumbnail.uri;return{url:m,startByte:x,endByte:P,thumbnailUrl:"".concat(c,"/").concat(S.split("gs://")[1]),isMultiframe:b}}function K(e){var t=e.domain,r=void 0===t?V.url.DOMAIN:t,n=e.bucketName,a=e.bucketPrefix,i=e.studyInstanceUID,o=e.seriesInstanceUID;if(n&&a&&i&&o)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(i,"/series/").concat(o,"/metadata.json")}function Q(e){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(e)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new L(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(D([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Q(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=I(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function I(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,I(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function D(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(Q(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;T(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function ee(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}var te={};function re(e,t){return ne.apply(this,arguments)}function ne(){var e;return e=X().mark((function e(t,r){var n,a,i;return X().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=K(t)){e.next=3;break}throw new Error("Error creating metadata json url");case 3:if(!te[n]){e.next=5;break}return e.abrupt("return",te[n]);case 5:return e.prev=5,e.next=8,fetch(n,{headers:r});case 8:if((a=e.sent).ok){e.next=11;break}throw new Error("Failed to fetch metadata: ".concat(a.statusText));case 11:return e.next=13,a.json();case 13:return i=e.sent,te[n]=i,e.abrupt("return",i);case 18:throw e.prev=18,e.t0=e.catch(5),console.error(e.t0),e.t0;case 22:case"end":return e.stop()}}),e,null,[[5,18]])})),ne=function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){ee(i,n,a,o,s,"next",e)}function s(e){ee(i,n,a,o,s,"throw",e)}o(void 0)}))},ne.apply(this,arguments)}function ae(e){return ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ae(e)}function ie(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new L(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(D([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ae(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=I(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function I(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,I(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function D(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(ae(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;T(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function oe(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function se(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){oe(i,n,a,o,s,"next",e)}function s(e){oe(i,n,a,o,s,"throw",e)}o(void 0)}))}}function ce(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fe(n.key),n)}}function ue(e,t,r){return(t=fe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fe(e){var t=function(e,t){if("object"!=ae(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ae(t)?t:t+""}var le=function(){return e=function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue(this,"filePromises",{}),ue(this,"options",{maxWorkerFetchSize:1/0,domain:V.url.DOMAIN}),ue(this,"fileManager",void 0),ue(this,"seriesUidFileUrls",{}),ue(this,"setOptions",(function(e){Object.keys(e).forEach((function(r){void 0===!e[r]&&(t.options[r]=e[r])}))})),ue(this,"getOptions",(function(){return t.options}));var a=n.maxWorkerFetchSize,i=n.domain;this.options.maxWorkerFetchSize=a||this.options.maxWorkerFetchSize,this.options.domain=i||this.options.domain;var o=V.worker.FILE_STREAMING_WORKER_NAME,s=V.worker.FILE_PARTIAL_WORKER_NAME;this.fileManager=new G({fileStreamingWorkerName:o}),function(e,t){var n=e.fileStreamingWorkerName,a=e.filePartialWorkerName,i=N();i.registerWorker(n,(function(){return new Worker(new URL(r.p+r.u(170),r.b),{name:n})})),i.executeTask(n,"setMaxFetchSize",t),i.registerWorker(a,(function(){return new Worker(new URL(r.p+r.u(16),r.b),{name:a})}))}({fileStreamingWorkerName:o,filePartialWorkerName:s},this.options.maxWorkerFetchSize)},t=[{key:"addFileUrl",value:function(e,t){this.seriesUidFileUrls[e]?this.seriesUidFileUrls[e].push(t):this.seriesUidFileUrls[e]=[t]}},{key:"fetchCod",value:(c=se(ie().mark((function e(t,r){var n,a,c,u,f,l,d,h,p,m,y,g,v,b,w,E,x,P,S,A,O,I,k=this,T=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=T.length>2&&void 0!==T[2]?T[2]:{},c=(a=T.length>3&&void 0!==T[3]?T[3]:{}).useSharedArrayBuffer,u=void 0!==c&&c,f=a.fetchType,l=void 0===f?V.Enums.FetchType.API_OPTIMIZED:f,e.prev=2,!(d=Z(t,this.options.domain))){e.next=25;break}return h=d.type,p=d.bucketName,m=d.bucketPrefix,y=d.studyInstanceUID,g=d.seriesInstanceUID,v=d.sopInstanceUID,b=d.frameNumber,e.next=8,re({domain:this.options.domain,bucketName:p,bucketPrefix:m,studyInstanceUID:y,seriesInstanceUID:g},n);case 8:if(w=e.sent){e.next=11;break}throw new Error("Metadata not found for ".concat(t));case 11:E=$(w,v,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:m}),x=E.url,P=E.startByte,S=E.endByte,A=E.thumbnailUrl,O=E.isMultiframe,e.t0=h,e.next=e.t0===o.THUMBNAIL?15:e.t0===o.FRAME?17:e.t0===o.SERIES_METADATA||e.t0===o.INSTANCE_METADATA?21:22;break;case 15:return this.addFileUrl(g,A),e.abrupt("return",this.fetchFile(A,n,{useSharedArrayBuffer:u}));case 17:return I=x,l===i.BYTES_OPTIMIZED&&(I="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(g,x),e.abrupt("return",this.fetchFile(I,n,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:u,fetchType:l}).then((function(e){if(null==e||!e.byteLength)throw new Error("File Arraybuffer is not found");if(O)return e;var t=(0,s.parseDicom)(new Uint8Array(e)).elements.x7fe00010,r=t.dataOffset,n=t.length;if(t.hadUndefinedLength&&t.fragments){var a=t.fragments[0];r=a.position,n=a.length}else r+=8;return e.slice(r,r+n)})));case 21:return e.abrupt("return",this.parseMetadata(w,h,v));case 22:throw new Error("Unsupported request type: ".concat(h));case 23:e.next=26;break;case 25:return e.abrupt("return",new Promise((function(e,r){return k.fetchFile(t,n,{useSharedArrayBuffer:u}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&k.addFileUrl(n,t)}catch(e){console.warn("There is some issue parsing the file.",e)}e(r)})).catch((function(e){return r(e)}))})));case 26:e.next=32;break;case 28:throw e.prev=28,e.t1=e.catch(2),console.error(e.t1),e.t1;case 32:case"end":return e.stop()}}),e,this,[[2,28]])}))),function(e,t){return c.apply(this,arguments)})},{key:"fetchFile",value:(a=se(ie().mark((function e(t,r){var n,a,o,s,c,u,f,l,d,h,p,m,y,g,v,b,w=this,E=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=(n=E.length>2&&void 0!==E[2]?E[2]:{}).offsets,o=n.useSharedArrayBuffer,s=void 0!==o&&o,c=n.fetchType,u=void 0===c?V.Enums.FetchType.API_OPTIMIZED:c,f=u===i.BYTES_OPTIMIZED,!(l=this.fileManager.get(t,f?void 0:a))){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){try{e(l.buffer)}catch(e){t(e)}})));case 5:return d=this.getOptions(),h=d.maxWorkerFetchSize,p=N(),m=V.worker,y=m.FILE_STREAMING_WORKER_NAME,g=m.FILE_PARTIAL_WORKER_NAME,v=m.THRESHOLD,this.filePromises[t]?b=this.filePromises[t]:(b=new Promise((function(e,n){if(w.fileManager.getTotalSize()+v>h)throw new Error("fileStreaming.ts: Maximum size(".concat(h,") for fetching files reached"));var i=V.Enums.FetchType;if(u===i.API_OPTIMIZED){var o=function(e){if(e instanceof ErrorEvent)throw n(e.error),e.error;var r=e.data,a=r.url,i=r.position,s=r.fileArraybuffer;a===t&&s&&(w.fileManager.set(a,{data:s,position:i}),p.removeEventListener(y,"message",o))};p.addEventListener(y,"message",o),p.executeTask(y,"stream",{url:t,headers:r,useSharedArrayBuffer:s}).then((function(){e()})).catch((function(e){p.removeEventListener(y,"message",o),n(e)})).then((function(){return delete w.filePromises[t]}))}else if(u===i.BYTES_OPTIMIZED&&a){var c=a.startByte,f=a.endByte;r.Range="bytes=".concat(c,"-").concat(f-1);var l=t.split("?bytes=")[0];p.executeTask(g,"partial",{url:l,headers:r,useSharedArrayBuffer:s}).then((function(r){r?(w.fileManager.set(t,{data:new Uint8Array(r),position:r.byteLength}),e()):n(new Error("File - ".concat(l," not found")))})).catch((function(e){n(e)})).then((function(){return delete w.filePromises[t]}))}else n("Offsets is needed in bytes optimized fetching")})),this.filePromises[t]=b),e.abrupt("return",new Promise((function(e,r){var n=!1,i=function(i){if(i instanceof ErrorEvent)throw r(i.message),i.error;var o=i.data,s=o.url,c=o.position,u=o.chunk;if(o.isAppending&&(u?w.fileManager.append(s,u,c):w.fileManager.setPosition(s,c)),!n&&s===t&&a&&c>a.endByte)try{var f=w.fileManager.get(s,a);n=!0,e(null==f?void 0:f.buffer)}catch(e){r(e)}};a&&!f&&p.addEventListener(y,"message",i),b.then((function(){if(!n){var r=w.fileManager.get(t,f?void 0:a);n=!0,e(null==r?void 0:r.buffer)}})).catch((function(e){r(e)})).then((function(){p.removeEventListener(y,"message",i)}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"delete",value:function(e){var t=this,r=this.seriesUidFileUrls[e];r&&r.forEach((function(e){t.fileManager.remove(e)})),delete this.seriesUidFileUrls[e]}},{key:"deleteAll",value:function(){var e=this;Object.values(this.seriesUidFileUrls).forEach((function(t){t.forEach((function(t){e.fileManager.remove(t)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(e,t,r){return t===o.INSTANCE_METADATA?e.cod.instances[r].metadata:Object.values(e.cod.instances).map((function(e){return e.metadata}))}}],t&&ce(e.prototype,t),n&&ce(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,a,c}();const de=le,he={FetchType:i,CodDicomWebServer:le}})(),n})()));
|
|
21
|
-
//# sourceMappingURL=
|
|
20
|
+
const c=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),f=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.finalizer"),d=Symbol("Comlink.thrown"),h=e=>"object"==typeof e&&null!==e||"function"==typeof e,p=new Map([["proxy",{canHandle:e=>h(e)&&e[c],serialize(e){const{port1:t,port2:r}=new MessageChannel;return m(e,t),[r,[r]]},deserialize:e=>(e.start(),g(e))}],["throw",{canHandle:e=>h(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function m(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(a){if(!a||!a.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:i,type:o,path:s}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(O);let f;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),r=s.reduce(((e,t)=>e[t]),e);switch(o){case"GET":f=r;break;case"SET":t[s.slice(-1)[0]]=O(a.data.value),f=!0;break;case"APPLY":f=r.apply(t,u);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[c]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;m(e,r),f=function(e,t){return S.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[d]:0}}Promise.resolve(f).catch((e=>({value:e,[d]:0}))).then((r=>{const[a,s]=A(r);t.postMessage(Object.assign(Object.assign({},a),{id:i}),s),"RELEASE"===o&&(t.removeEventListener("message",n),y(t),l in e&&"function"==typeof e[l]&&e[l]())})).catch((e=>{const[r,n]=A({value:new TypeError("Unserializable return value"),[d]:0});t.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),t.start&&t.start()}function y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function g(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),x(e,r,[],t)}function v(e){if(e)throw new Error("Proxy has been released and is not useable")}function b(e){return k(e,new Map,{type:"RELEASE"}).then((()=>{y(e)}))}const w=new WeakMap,E="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(w.get(e)||0)-1;w.set(e,t),0===t&&b(e)}));function x(e,t,r=[],n=function(){}){let a=!1;const i=new Proxy(n,{get(n,o){if(v(a),o===f)return()=>{!function(e){E&&E.unregister(e)}(i),b(e),t.clear(),a=!0};if("then"===o){if(0===r.length)return{then:()=>i};const n=k(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(O);return n.then.bind(n)}return x(e,t,[...r,o])},set(n,i,o){v(a);const[s,c]=A(o);return k(e,t,{type:"SET",path:[...r,i].map((e=>e.toString())),value:s},c).then(O)},apply(n,i,o){v(a);const s=r[r.length-1];if(s===u)return k(e,t,{type:"ENDPOINT"}).then(O);if("bind"===s)return x(e,t,r.slice(0,-1));const[c,f]=P(o);return k(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:c},f).then(O)},construct(n,i){v(a);const[o,s]=P(i);return k(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(O)}});return function(e,t){const r=(w.get(t)||0)+1;w.set(t,r),E&&E.register(e,t,e)}(i,e),i}function P(e){const t=e.map(A);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const S=new WeakMap;function A(e){for(const[t,r]of p)if(r.canHandle(e)){const[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},S.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return p.get(e.name).deserialize(e.value);case"RAW":return e.value}}function k(e,t,r,n){return new Promise((a=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)}))}function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function I(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */I=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new F(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(U([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==T(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function U(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(T(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=U,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;L(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:U(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function D(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function L(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,F(n.key),n)}}function F(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}var U=new(function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=F(r="workerRegistry"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"registerWorker",value:function(e,t){try{var r=t();if(!r)throw new Error("WorkerFn of worker ".concat(e," is not creating a worker"));this.workerRegistry[e]={instance:g(r),nativeWorker:r}}catch(e){console.warn(e)}}},{key:"executeTask",value:(n=I().mark((function e(t,r,n){var a,i;return I().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null===(a=this.workerRegistry[t])||void 0===a?void 0:a.instance){e.next=3;break}throw new Error("Worker ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,i[r](n);case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(t,'":'),e.t0),new Error('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,a){var i=n.apply(e,t);function o(e){D(i,r,a,o,s,"next",e)}function s(e){D(i,r,a,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.addEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.removeEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}}],t&&L(e.prototype,t),r&&L(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a}());function N(){return U}function j(e){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(e)}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?M(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function B(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,q(n.key),n)}}function R(e,t,r){return(t=q(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e){var t=function(e,t){if("object"!=j(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==j(t)?t:t+""}const C=function(){return e=function e(t){var r=t.fileStreamingWorkerName;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),R(this,"files",{}),R(this,"fileStreamingWorkerName",void 0),this.fileStreamingWorkerName=r},(t=[{key:"set",value:function(e,t){this.files[e]=t}},{key:"get",value:function(e,t){return!this.files[e]||t&&this.files[e].position<=t.endByte?null:t?this.files[e].data.slice(t.startByte,t.endByte):this.files[e].data}},{key:"setPosition",value:function(e,t){this.files[e]&&(this.files[e].position=t)}},{key:"getPosition",value:function(e){var t;return null===(t=this.files[e])||void 0===t?void 0:t.position}},{key:"append",value:function(e,t,r){this.files[e]&&r&&(this.files[e].data.set(t,r-t.length),this.setPosition(e,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(e,t){var r=_(t,2),n=r[0],a=r[1].position;return n.includes("?bytes=")?e:e+a}),0)}},{key:"remove",value:function(e){var t=this.getPosition(e);delete this.files[e],e.includes("?bytes=")||N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",t)}},{key:"purge",value:function(){var e=this.getTotalSize();this.files={},N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",e)}}])&&B(e.prototype,t),r&&B(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();var W="https://storage.googleapis.com",G=[".tar",".zip"],z="/dicomweb/",H="filePartial",J="fileStreaming",Y=1e4;const V={Enums:e,url:t,worker:a};function Z(e,t){if(e.includes(V.url.URL_VALIDATION_STRING)){var r,n=e.split(t+"/")[1],a=n.split("/studies")[0],i=a.split("/"),s=i[0],c=i.slice(1).join("/"),u=n.split(a+"/")[1].split("/"),f=u[1],l=u[3],d="",h=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(d=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):d=u[5],h=+u[7],r=o.FRAME;break;default:throw new Error("Invalid type of request")}return{type:r,bucketName:s,bucketPrefix:c,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:d,frameNumber:h}}}function $(e,t,r,n){var a;if(!e||null===(a=e.cod)||void 0===a||!a.instances)throw new Error("Invalid seriesMetadata provided.");if(null==r)throw new Error("Frame index is required.");var i,o=n.domain,s=n.bucketName,c=n.bucketPrefix;if(e.thumbnail){var u=e.thumbnail.uri;i="".concat(o,"/").concat(u.split("gs://")[1])}var f=Object.values(e.cod.instances).find((function(e){var r;return(null===(r=e.metadata["00080018"])||void 0===r||null===(r=r.Value)||void 0===r?void 0:r[0])===t}));if(!f)return{thumbnailUrl:i};var l,d,h=f.url,p=f.uri,m=f.headers,y=f.offset_tables,g=function(e,t,r,n){var a=e,i=V.url.FILE_EXTENSIONS.find((function(t){return e.includes(t)}));if(i){a=e.split(i)[0]+i}var o=a.split("studies/")[1];return a="".concat(t,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),a}(h||p,o,s,c),v=y.CustomOffsetTable,b=y.CustomOffsetTableLengths,w=!1;null!=v&&v.length&&null!=b&&b.length&&(d=(l=v[r])+b[r],w=!0);var E=m.start_byte,x=m.end_byte;return{url:g,startByte:void 0!==l?E+l:E,endByte:void 0!==d?E+d:x,thumbnailUrl:i,isMultiframe:w}}function K(e){var t=e.domain,r=void 0===t?V.url.DOMAIN:t,n=e.bucketName,a=e.bucketPrefix,i=e.studyInstanceUID,o=e.seriesInstanceUID;if(n&&a&&i&&o)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(i,"/series/").concat(o,"/metadata.json")}function Q(e){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(e)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new D(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(L([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Q(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(Q(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;I(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function ee(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function te(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,re(n.key),n)}}function re(e){var t=function(e,t){if("object"!=Q(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Q(t)?t:t+""}const ne=function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=re(r="metadata"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"getMetadataFromCache",value:function(e){return this.metadata[e]}},{key:"getMetadata",value:(n=X().mark((function e(t,r){var n,a,i,o;return X().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=K(t)){e.next=3;break}throw new Error("Error creating metadata json url");case 3:if(!(a=this.getMetadataFromCache(n))){e.next=6;break}return e.abrupt("return",a);case 6:return e.prev=6,e.next=9,fetch(n,{headers:r});case 9:if((i=e.sent).ok){e.next=12;break}throw new Error("Failed to fetch metadata: ".concat(i.statusText));case 12:return e.next=14,i.json();case 14:return o=e.sent,this.metadata[n]=o,e.abrupt("return",o);case 19:throw e.prev=19,e.t0=e.catch(6),console.error(e.t0),e.t0;case 23:case"end":return e.stop()}}),e,this,[[6,19]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,a){var i=n.apply(e,t);function o(e){ee(i,r,a,o,s,"next",e)}function s(e){ee(i,r,a,o,s,"throw",e)}o(void 0)}))},function(e,t){return a.apply(this,arguments)})}],t&&te(e.prototype,t),r&&te(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a}();function ae(e){return ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ae(e)}function ie(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new D(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(L([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ae(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(ae(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;I(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function oe(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function se(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){oe(i,n,a,o,s,"next",e)}function s(e){oe(i,n,a,o,s,"throw",e)}o(void 0)}))}}function ce(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fe(n.key),n)}}function ue(e,t,r){return(t=fe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fe(e){var t=function(e,t){if("object"!=ae(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ae(t)?t:t+""}var le=function(){return e=function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue(this,"filePromises",{}),ue(this,"options",{maxWorkerFetchSize:1/0,domain:V.url.DOMAIN}),ue(this,"fileManager",void 0),ue(this,"metadataManager",void 0),ue(this,"seriesUidFileUrls",{}),ue(this,"setOptions",(function(e){Object.keys(e).forEach((function(r){void 0!==e[r]&&(t.options[r]=e[r])}))})),ue(this,"getOptions",(function(){return t.options}));var a=n.maxWorkerFetchSize,i=n.domain;this.options.maxWorkerFetchSize=a||this.options.maxWorkerFetchSize,this.options.domain=i||this.options.domain;var o=V.worker.FILE_STREAMING_WORKER_NAME,s=V.worker.FILE_PARTIAL_WORKER_NAME;this.fileManager=new C({fileStreamingWorkerName:o}),this.metadataManager=new ne,function(e,t){var n=e.fileStreamingWorkerName,a=e.filePartialWorkerName,i=N();i.registerWorker(n,(function(){return new Worker(new URL(r.p+r.u(170),r.b),{name:n})})),i.executeTask(n,"setMaxFetchSize",t),i.registerWorker(a,(function(){return new Worker(new URL(r.p+r.u(16),r.b),{name:a})}))}({fileStreamingWorkerName:o,filePartialWorkerName:s},this.options.maxWorkerFetchSize)},t=[{key:"addFileUrl",value:function(e,t){this.seriesUidFileUrls[e]?this.seriesUidFileUrls[e].push(t):this.seriesUidFileUrls[e]=[t]}},{key:"fetchCod",value:(c=se(ie().mark((function e(t,r){var n,a,c,u,f,l,d,h,p,m,y,g,v,b,w,E,x,P,S,A,O,k,T,I=this,D=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=D.length>2&&void 0!==D[2]?D[2]:{},c=(a=D.length>3&&void 0!==D[3]?D[3]:{}).useSharedArrayBuffer,u=void 0!==c&&c,f=a.fetchType,l=void 0===f?V.Enums.FetchType.API_OPTIMIZED:f,e.prev=2,t){e.next=5;break}throw new Error("Url not provided");case 5:if(!(d=Z(t,this.options.domain))){e.next=31;break}return h=d.type,p=d.bucketName,m=d.bucketPrefix,y=d.studyInstanceUID,g=d.seriesInstanceUID,v=d.sopInstanceUID,b=d.frameNumber,e.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:m,studyInstanceUID:y,seriesInstanceUID:g},n);case 10:if(w=e.sent){e.next=13;break}throw new Error("Metadata not found for ".concat(t));case 13:E=$(w,v,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:m}),x=E.url,P=E.startByte,S=E.endByte,A=E.thumbnailUrl,O=E.isMultiframe,e.t0=h,e.next=e.t0===o.THUMBNAIL?17:e.t0===o.FRAME?21:e.t0===o.SERIES_METADATA||e.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(A){e.next=19;break}throw new Error("Thumbnail not found for ".concat(t));case 19:return this.addFileUrl(g,A),e.abrupt("return",this.fetchFile(A,n,{useSharedArrayBuffer:u}));case 21:if(x){e.next=23;break}throw new Error("Url not found for frame");case 23:return k=x,l===i.BYTES_OPTIMIZED&&(k="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(g,x),e.abrupt("return",this.fetchFile(k,n,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:u,fetchType:l}).then((function(e){if(null==e||!e.byteLength)throw new Error("File Arraybuffer is not found");if(O)return e;var t=(0,s.parseDicom)(new Uint8Array(e)).elements.x7fe00010,r=t.dataOffset,n=t.length;if(t.hadUndefinedLength&&t.fragments){var a=t.fragments[0];r=a.position,n=a.length}else r+=8;return e.slice(r,r+n)})));case 27:return e.abrupt("return",this.parseMetadata(w,h,v));case 28:throw new Error("Unsupported request type: ".concat(h));case 29:e.next=32;break;case 31:return e.abrupt("return",new Promise((function(e,r){return I.fetchFile(t,n,{useSharedArrayBuffer:u}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&I.addFileUrl(n,t)}catch(e){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",e)}e(r)})).catch((function(e){return r(e)}))})));case 32:e.next=39;break;case 34:throw e.prev=34,e.t1=e.catch(2),T=new Error("CodDicomWebServer.ts: ".concat(e.t1.message||"An error occured when fetching the COD")),console.error(T),T;case 39:case"end":return e.stop()}}),e,this,[[2,34]])}))),function(e,t){return c.apply(this,arguments)})},{key:"fetchFile",value:(a=se(ie().mark((function e(t,r){var n,a,o,s,c,u,f,l,d,h,p,m,y,g,v,b,w=this,E=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=(n=E.length>2&&void 0!==E[2]?E[2]:{}).offsets,o=n.useSharedArrayBuffer,s=void 0!==o&&o,c=n.fetchType,u=void 0===c?V.Enums.FetchType.API_OPTIMIZED:c,f=u===i.BYTES_OPTIMIZED,!(l=this.fileManager.get(t,f?void 0:a))){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){try{e(l.buffer)}catch(e){t(e)}})));case 5:return d=this.getOptions(),h=d.maxWorkerFetchSize,p=N(),m=V.worker,y=m.FILE_STREAMING_WORKER_NAME,g=m.FILE_PARTIAL_WORKER_NAME,v=m.THRESHOLD,this.filePromises[t]?b=this.filePromises[t]:(b=new Promise((function(e,n){if(w.fileManager.getTotalSize()+v>h)throw new Error("CodDicomWebServer.ts: Maximum size(".concat(h,") for fetching files reached"));var i=V.Enums.FetchType;if(u===i.API_OPTIMIZED){var o=function(e){if(e instanceof ErrorEvent)throw n(e.error),e.error;var r=e.data,a=r.url,i=r.position,s=r.fileArraybuffer;a===t&&s&&(w.fileManager.set(a,{data:s,position:i}),p.removeEventListener(y,"message",o))};p.addEventListener(y,"message",o),p.executeTask(y,"stream",{url:t,headers:r,useSharedArrayBuffer:s}).then((function(){e()})).catch((function(e){p.removeEventListener(y,"message",o),n(e)})).then((function(){return delete w.filePromises[t]}))}else if(u===i.BYTES_OPTIMIZED&&a){var c=a.startByte,f=a.endByte;r.Range="bytes=".concat(c,"-").concat(f-1);var l=t.split("?bytes=")[0];p.executeTask(g,"partial",{url:l,headers:r,useSharedArrayBuffer:s}).then((function(r){r?(w.fileManager.set(t,{data:new Uint8Array(r),position:r.byteLength}),e()):n(new Error("File - ".concat(l," not found")))})).catch((function(e){n(e)})).then((function(){return delete w.filePromises[t]}))}else n(new Error("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[t]=b),e.abrupt("return",new Promise((function(e,r){var n=!1,i=function(i){if(i instanceof ErrorEvent)throw r(i.message),i.error;var o=i.data,s=o.url,c=o.position,u=o.chunk;if(o.isAppending&&(u?w.fileManager.append(s,u,c):w.fileManager.setPosition(s,c)),!n&&s===t&&a&&c>a.endByte)try{var f=w.fileManager.get(s,a);n=!0,e(null==f?void 0:f.buffer)}catch(e){r(e)}};a&&!f&&p.addEventListener(y,"message",i),b.then((function(){if(!n){var r=w.fileManager.get(t,f?void 0:a);n=!0,e(null==r?void 0:r.buffer)}})).catch((function(e){r(e)})).then((function(){p.removeEventListener(y,"message",i)}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"delete",value:function(e){var t=this,r=this.seriesUidFileUrls[e];r&&r.forEach((function(e){t.fileManager.remove(e)})),delete this.seriesUidFileUrls[e]}},{key:"deleteAll",value:function(){var e=this;Object.values(this.seriesUidFileUrls).forEach((function(t){t.forEach((function(t){e.fileManager.remove(t)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(e,t,r){var n;return t===o.INSTANCE_METADATA?null===(n=Object.values(e.cod.instances).find((function(e){var t;return(null===(t=e.metadata["00080018"])||void 0===t||null===(t=t.Value)||void 0===t?void 0:t[0])===r})))||void 0===n?void 0:n.metadata:Object.values(e.cod.instances).map((function(e){return e.metadata}))}}],t&&ce(e.prototype,t),n&&ce(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,a,c}();const de=le,he={FetchType:i,CodDicomWebServer:le}})(),n})()));
|
|
21
|
+
//# sourceMappingURL=main.js.map
|