cod-dicomweb-server 1.3.3 → 1.3.5
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/README.md +4 -1
- package/dist/cjs/main.js +629 -101
- package/dist/esm/classes/CodDicomWebServer.d.ts +1 -0
- package/dist/esm/classes/CodDicomWebServer.js +10 -5
- package/dist/esm/classes/utils.js +1 -1
- package/dist/esm/constants/dataRetrieval.d.ts +4 -0
- package/dist/esm/constants/dataRetrieval.js +4 -0
- package/dist/esm/dataRetrieval/scripts/filePartial.d.ts +1 -0
- package/dist/esm/dataRetrieval/scripts/filePartial.js +16 -2
- package/dist/esm/dataRetrieval/scripts/fileStreaming.d.ts +1 -0
- package/dist/esm/dataRetrieval/scripts/fileStreaming.js +13 -1
- package/dist/esm/fileAccessSystemUtils.d.ts +12 -0
- package/dist/esm/fileAccessSystemUtils.js +84 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/metadataManager.d.ts +2 -2
- package/dist/esm/metadataManager.js +15 -11
- package/dist/esm/types/codDicomWebServerOptions.d.ts +2 -1
- package/dist/umd/563.js +19 -0
- package/dist/umd/563.js.map +1 -0
- package/dist/umd/846.js +19 -0
- package/dist/umd/846.js.map +1 -0
- package/dist/umd/main.js +4 -4
- package/dist/umd/main.js.map +1 -1
- package/package.json +4 -3
- package/dist/umd/614.js +0 -19
- package/dist/umd/614.js.map +0 -1
- package/dist/umd/66.js +0 -19
- package/dist/umd/66.js.map +0 -1
package/dist/umd/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* cod-dicomweb-server v1.
|
|
3
|
+
* cod-dicomweb-server v1.3.4
|
|
4
4
|
* git+https://github.com/gradienthealth/cod-dicomweb-server.git
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Adithyan Dinesh and project contributors.
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
!function(e
|
|
12
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(()=>(()=>{var t={915:function(t,e,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 i})),r.d(t,"isPrivateTag",(function(){return a})),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 D})),r.d(t,"readFixedString",(function(){return g})),r.d(t,"alloc",(function(){return _})),r.d(t,"version",(function(){return N})),r.d(t,"bigEndianByteArrayParser",(function(){return U})),r.d(t,"ByteStream",(function(){return B})),r.d(t,"sharedCopy",(function(){return M})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return v})),r.d(t,"findEndOfEncapsulatedElement",(function(){return m})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return G})),r.d(t,"parseDicom",(function(){return z})),r.d(t,"readDicomElementExplicit",(function(){return j})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return J})),r.d(t,"readEncapsulatedPixelData",(function(){return Q})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return Y})),r.d(t,"readPart10Header",(function(){return q})),r.d(t,"readSequenceItemsExplicit",(function(){return T})),r.d(t,"readSequenceItemsImplicit",(function(){return A})),r.d(t,"readSequenceItem",(function(){return O})),r.d(t,"readTag",(function(){return y}));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},i=function(e){return n[e]},a=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,i=6<=e.length?parseInt(e.substring(4,6),10):void 0,a=(a=8<=e.length?e.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}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),i=parseInt(e.substring(6,8),10);if(t&&!0!==c(i,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:i}}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,a=t.tag;function o(t,r){for(var n="",i=0;i<t;i++)0!==i&&(n+="/"),n+=r.call(e,a,i).toString();return n}if(!0===i(n))r=e.string(a);else{if("AT"===n){var s=e.uint32(a);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 i=e.elements[r];if(!0!==t.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],s=0;s<i.items.length;s++)o.push(l(i.items[s].dataSet,t));n[r]=o}else{var c=void 0;i.length<t.maxElementLength&&(c=f(e,i)),n[r]=void 0!==c?c:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function d(e,t,r){for(var n,i,a=r;a<t.fragments.length;a++)if(i=a,h(n=e,(i=t.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}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=[],i=0;;){n.push(t.fragments[i].offset);var a=d(e,t,i);if(void 0===a||a===t.fragments.length-1)return n;i=a+1}}function y(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 m(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"!==y(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,i=0;i<n;i++){var a=e.readUint32();t.basicOffsetTable.push(a)}for(var o=e.position;e.position<e.byteArray.length;){var s=y(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 v(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 g(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,i="",a=0;a<r;a++){if(0===(n=e[t+a]))return t+=r,i;i+=String.fromCharCode(n)}return i}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=g(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=g(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=g(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=y(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=y(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)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(A(e,n,r),a(n.tag)&&(n.items=void 0))),n}function O(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:y(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 L(e,t){var r=O(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,{}),D(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function A(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=y(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=L(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 i=L(e,r);t.items.push(i)}})(e,t,r)}function k(e,t){var r=O(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=j(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=y(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 i=k(e,r);t.items.push(i)}})(e,t,r)}var I=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 j(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(e),vr:e.readFixedString(2)};return 2===I(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?m(e,n,t):("UN"===n.vr?A: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 i=e.elements;t.position<r;){var a=j(t,e.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function D(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 i=e.elements;t.position<r;){var a=S(t,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function _(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 N="1.8.12",U={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 R(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 B=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=g(this.byteArray,this.position,e);return this.position+=e,t}}])&&R(t.prototype,r),n&&R(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),G={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 q(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 B(G,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}(),i=[],a={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,s=j(n,i);if("x0002ffff"<s.tag){n.position=o;break}s.parser=G,a[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,e.position=n.position,e}()}var C="1.2.840.10008.1.2.2";function z(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,i=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||g(e,t.dataOffset,t.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===C?U:G,e,i);if(t&&t.inflater)return n=t.inflater(e,i),new B(G,n,0);if(1==a){var o=r(0),s=M(e,i,e.length-i);return o=o.inflateRawSync(s),s=_(e,o.length+i),e.copy(s,0,0,i),o.copy(s,i),new B(G,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(i),s=pako.inflateRaw(o),(o=_(e,s.length+i)).set(e.slice(0,i),0),o.set(s,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?F:D)(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=q(e,t),a(n))}var W=function(e,t,r){for(var n=0,i=t;i<t+r;i++)n+=e[i].length;return n};function Y(e,t,r,n,i){if(i=i||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 a=new B(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=O(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(t.length);var o=a.position;if(1===n)return M(a.byteArray,o+i[r].offset+8,i[r].length);t=W(i,r,n);for(var s=_(a.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)s[c++]=a.byteArray[f++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},V=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var i=t[e+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function J(e,t,r,n,i){if(n=n||t.basicOffsetTable,i=i||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 a=n[r];if(void 0===(a=H(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return Y(e,t,a,V(r,n,i,a),i)}var K=!1;function Q(e,t,r){if(K||(K=!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?J(e,t,r):Y(e,t,0,t.fragments.length)}t.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:D,readFixedString:g,alloc:_,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:v,findEndOfEncapsulatedElement:m,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:j,readDicomElementImplicit:S,readEncapsulatedImageFrame:J,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:Y,readPart10Header:q,readSequenceItemsExplicit:T,readSequenceItemsImplicit:A,readSequenceItem:O,readTag:y,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 i in e)t.d(n,i,function(t){return e[t]}.bind(null,i));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 i=n[e]={i:e,l:!1,exports:{}};return r[e].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.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 i=n.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=n[i--].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:()=>$e,FetchType:()=>a,default:()=>Xe});var e={};r.r(e),r.d(e,{DataRetrieveMode:()=>s,FetchType:()=>a,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>P,FILE_EXTENSIONS:()=>S,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>L,FILE_STREAMING_WORKER_NAME:()=>A,THRESHOLD:()=>k});var a=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=function(e){return e[e.WORKER=0]="WORKER",e[e.REQUEST=1]="REQUEST",e}({}),c=r(915);function u(e){return u="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},u(e)}function f(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}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,d(n.key),n)}}function h(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t,r){return t=w(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,r||[],w(e).constructor):t.apply(e,r))}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&b(i,r.prototype),i}(e,arguments,w(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,e)},v(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(g=function(){return!!e})()}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}var E=function(e){function t(){return p(this,t),y(this,t,arguments)}return m(t,e),h(t)}(v(Error)),x=function(e){function t(e,r){var n;return p(this,t),f(n=y(this,t,[e]),"error",void 0),f(n,"message",void 0),n.message=e,n.error=r,n}return m(t,e),h(t)}(v(Event)),P="https://storage.googleapis.com",S=[".tar",".zip"],O="/dicomweb/",L="filePartial",A="fileStreaming",k=1e4;const T={Enums:e,url:t,dataRetrieval:i};function I(e){return I="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},I(e)}function j(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */j=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new F(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}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=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==I(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 F(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(I(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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,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(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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}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),m}},t}function F(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}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,N(n.key),n)}}function _(e,t,r){return(t=N(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function N(e){var t=function(e,t){if("object"!=I(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==I(t)?t:t+""}const U=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,"loaderRegistry",{}),_(this,"listenerCallback",(function(e,r,n){var i,a=null===(i=t.loaderRegistry[e])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(e){return e({data:n})}))}))},t=[{key:"register",value:function(e,t){try{if(!t)throw new E("Loader object for ".concat(e," is not provided"));this.loaderRegistry[e]={loaderObject:t,listeners:{}}}catch(e){throw console.warn(e),new E("throws")}}},{key:"executeTask",value:(n=j().mark((function e(t,r,n){var i,a,o=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(i=this.loaderRegistry[t])||void 0===i?void 0:i.loaderObject){e.next=3;break}throw new E("Loader ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,a[r](n,(function(e){return o.listenerCallback(t,"message",e)}));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 "').concat(t,'":'),e.t0),new E('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){F(a,r,i,o,s,"next",e)}function s(e){F(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]?n.listeners[t].push(r):n.listeners[t]=[r]:console.error("Loader '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]=(n.listeners[t]||[]).filter((function(e){return e!==r})):console.error("Loader '".concat(e,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],t&&D(e.prototype,t),r&&D(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();
|
|
14
|
+
t.exports=function(t){return r=[function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e),r.d(e,"isStringVr",(function(){return i})),r.d(e,"isPrivateTag",(function(){return a})),r.d(e,"parsePN",(function(){return o})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return u})),r.d(e,"explicitElementToString",(function(){return f})),r.d(e,"explicitDataSetToJS",(function(){return l})),r.d(e,"createJPEGBasicOffsetTable",(function(){return p})),r.d(e,"parseDicomDataSetExplicit",(function(){return _})),r.d(e,"parseDicomDataSetImplicit",(function(){return F})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return D})),r.d(e,"version",(function(){return N})),r.d(e,"bigEndianByteArrayParser",(function(){return U})),r.d(e,"ByteStream",(function(){return B})),r.d(e,"sharedCopy",(function(){return M})),r.d(e,"DataSet",(function(){return E})),r.d(e,"findAndSetUNElementLength",(function(){return m})),r.d(e,"findEndOfEncapsulatedElement",(function(){return v})),r.d(e,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(e,"littleEndianByteArrayParser",(function(){return G})),r.d(e,"parseDicom",(function(){return z})),r.d(e,"readDicomElementExplicit",(function(){return I})),r.d(e,"readDicomElementImplicit",(function(){return S})),r.d(e,"readEncapsulatedImageFrame",(function(){return V})),r.d(e,"readEncapsulatedPixelData",(function(){return Q})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return T})),r.d(e,"readSequenceItemsImplicit",(function(){return k})),r.d(e,"readSequenceItem",(function(){return O})),r.d(e,"readTag",(function(){return y}));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},i=function(t){return n[t]},a=function(t){if(t=parseInt(t[4],16),isNaN(t))throw"dicomParser.isPrivateTag: cannot parse last character of group";return t%2==1},o=function(t){if(void 0!==t)return{familyName:(t=t.split("^"))[0],givenName:t[1],middleName:t[2],prefix:t[3],suffix:t[4]}};function c(t,e){if(2<=t.length){var r=parseInt(t.substring(0,2),10),n=4<=t.length?parseInt(t.substring(2,4),10):void 0,i=6<=t.length?parseInt(t.substring(4,6),10):void 0,a=(a=8<=t.length?t.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(e&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}if(e)throw"invalid TM '".concat(t,"'")}function s(t,e,r){return!isNaN(r)&&0<e&&e<=12&&0<t&&t<=function(t,e){switch(t){case 2:return e%4==0&&e%100||e%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(e,r)}function u(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10);if(e&&!0!==s(i,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:i}}if(e)throw"invalid DA '".concat(t,"'")}function f(t,e){if(void 0===t||void 0===e)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=e.vr,a=e.tag;function o(e,r){for(var n="",i=0;i<e;i++)0!==i&&(n+="/"),n+=r.call(t,a,i).toString();return n}if(!0===i(n))r=t.string(a);else{if("AT"===n){var c=t.uint32(a);return void 0===c?void 0:"x".concat((c=c<0?4294967295+c+1:c).toString(16).toUpperCase())}"US"===n?r=o(e.length/2,t.uint16):"SS"===n?r=o(e.length/2,t.int16):"UL"===n?r=o(e.length/4,t.uint32):"SL"===n?r=o(e.length/4,t.int32):"FD"===n?r=o(e.length/8,t.double):"FL"===n&&(r=o(e.length/4,t.float))}return r}function l(t,e){if(void 0===t)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";e=e||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in t.elements){var i=t.elements[r];if(!0!==e.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],c=0;c<i.items.length;c++)o.push(l(i.items[c].dataSet,e));n[r]=o}else{var s=void 0;i.length<e.maxElementLength&&(s=f(t,i)),n[r]=void 0!==s?s:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(t,e){return 255===t.byteArray[e]&&217===t.byteArray[e+1]}function d(t,e,r){for(var n,i,a=r;a<e.fragments.length;a++)if(i=a,h(n=t,(i=e.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}function p(t,e,r){if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==e.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==e.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.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||e.fragments;for(var n=[],i=0;;){n.push(e.fragments[i].offset);var a=d(t,e,i);if(void 0===a||a===e.fragments.length-1)return n;i=a+1}}function y(t){if(void 0===t)throw"dicomParser.readTag: missing required parameter 'byteStream'";var e=256*t.readUint16()*256;return t=t.readUint16(),"x".concat("00000000".concat((e+t).toString(16)).substr(-8))}function v(t,e,r){if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(e.encapsulatedPixelData=!0,e.basicOffsetTable=[],e.fragments=[],"xfffee000"!==y(t))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=t.readUint32()/4,i=0;i<n;i++){var a=t.readUint32();e.basicOffsetTable.push(a)}for(var o=t.position;t.position<t.byteArray.length;){var c=y(t),s=t.readUint32();if("xfffee0dd"===c)return t.seek(s),void(e.length=t.position-e.dataOffset);if("xfffee000"!==c)return r&&r.push("unexpected tag ".concat(c," while searching for end of pixel data element with undefined length")),s>t.byteArray.length-t.position&&(s=t.byteArray.length-t.position),e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s)}r&&r.push("pixel data element ".concat(e.tag," missing sequence delimiter tag xfffee0dd"))}function m(t,e){if(void 0===t)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57565===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}function g(t,e,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(e+r>t.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,i="",a=0;a<r;a++){if(0===(n=t[e+a]))return e+=r,i;i+=String.fromCharCode(n)}return i}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e){return void 0!==t.parser?t.parser:e}var E=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.byteArrayParser=e,this.byteArray=r,this.elements=n}var e,r,n;return e=t,(r=[{key:"uint16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint16(this.byteArray,t.dataOffset+2*e)}},{key:"int16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt16(this.byteArray,t.dataOffset+2*e)}},{key:"uint32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint32(this.byteArray,t.dataOffset+4*e)}},{key:"int32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt32(this.byteArray,t.dataOffset+4*e)}},{key:"float",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readFloat(this.byteArray,t.dataOffset+4*e)}},{key:"double",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readDouble(this.byteArray,t.dataOffset+8*e)}},{key:"numStringValues",value:function(t){if((t=this.elements[t])&&0<t.length)return null===(t=g(this.byteArray,t.dataOffset,t.length).match(/\\/g))?1:t.length+1}},{key:"string",value:function(t,e){return(t=this.elements[t])&&t.Value?t.Value:t&&0<t.length?(t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].trim():t.trim()):void 0}},{key:"text",value:function(t,e){if((t=this.elements[t])&&0<t.length)return t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].replace(/ +$/,""):t.replace(/ +$/,"")}},{key:"floatString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseFloat(e)}},{key:"intString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseInt(e)}},{key:"attributeTag",value:function(t){if((r=this.elements[t])&&4===r.length){var e=w(r,this.byteArrayParser).readUint16,r=(t=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*e(t,r)*256+e(t,r+2)).toString(16)).substr(-8))}}}])&&b(e.prototype,r),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function x(t,e){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57357===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}var P=function(t,e){return void 0!==t.vr?"SQ"===t.vr:e.position+4<=e.byteArray.length?(t=y(e),e.seek(-4),"xfffee000"===t||"xfffee0dd"===t):(e.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(t),vr:void 0!==r?r(n):void 0,length:t.readUint32(),dataOffset:t.position}).length&&(n.hadUndefinedLength=!0),n.tag===e||(!P(n,t)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(t,n):t.seek(n.length):(k(t,n,r),a(n.tag)&&(n.items=void 0))),n}function O(t){if(void 0===t)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var e={tag:y(t),length:t.readUint32(),dataOffset:t.position};if("xfffee000"!==e.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(t.position);return e}function L(t,e){var r=O(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=S(t,void 0,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return t.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),F(r.dataSet,t,t.position+r.length,{vrCallback:e})),r}function k(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=L(t,r),e.items.push(n)}t.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),e.length=t.byteArray.length-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var i=L(t,r);e.items.push(i)}})(t,e,r)}function A(t,e){var r=O(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=I(t,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return e.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),_(r.dataSet,t,t.position+r.length)),r}function T(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=A(t,r),e.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),e.length=t.position-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var i=A(t,r);e.items.push(i)}})(t,e,r)}var j=function(t){return"OB"===t||"OD"===t||"OL"===t||"OW"===t||"SQ"===t||"OF"===t||"UC"===t||"UR"===t||"UT"===t||"UN"===t?4:2};function I(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(t),vr:t.readFixedString(2)};return 2===j(n.vr)?n.length=t.readUint16():(t.seek(2),n.length=t.readUint32()),n.dataOffset=t.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(t,n,e):4294967295===n.length?"x7fe00010"===n.tag?v(t,n,e):("UN"===n.vr?k:x)(t,n):t.seek(n.length)),n}function _(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var i=t.elements;e.position<r;){var a=I(e,t.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function F(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var i=t.elements;e.position<r;){var a=S(e,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function D(t,e){if("undefined"!=typeof Buffer&&t instanceof Buffer)return Buffer.alloc(e);if(t instanceof Uint8Array)return new Uint8Array(e);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(t[e]<<8)+t[e+1]},readInt16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=(t[e]<<8)+t[e+1])?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*t[e]+t[e+1])+t[e+2])+t[e+3]},readInt32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]},readFloat:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=t[e],r[2]=t[e+1],r[1]=t[e+2],r[0]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=t[e],r[6]=t[e+1],r[5]=t[e+2],r[4]=t[e+3],r[3]=t[e+4],r[2]=t[e+5],r[1]=t[e+6],r[0]=t[e+7],new Float64Array(r.buffer)[0]}};function M(t,e,r){if("undefined"!=typeof Buffer&&t instanceof Buffer)return t.slice(e,e+r);if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset+e,r);throw"dicomParser.from: unknown type for byteArray"}function R(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var B=function(){function t(e,r,n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),void 0===e)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=e,this.byteArray=r,this.position=n||0,this.warnings=[]}var e,r,n;return e=t,(r=[{key:"seek",value:function(t){if(this.position+t<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=t}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,e);return this.position+=e,new t(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var t=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,t}},{key:"readUint32",value:function(){var t=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,t}},{key:"readFixedString",value:function(t){var e=g(this.byteArray,this.position,t);return this.position+=t,e}}])&&R(e.prototype,r),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),G={readUint16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return t[e]+256*t[e+1]},readInt16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=t[e]+(t[e+1]<<8))?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return t[e]+256*t[e+1]+256*t[e+2]*256+256*t[e+3]*256*256},readInt32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24)},readFloat:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],r[4]=t[e+4],r[5]=t[e+5],r[6]=t[e+6],r[7]=t[e+7],new Float64Array(r.buffer)[0]}};function C(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=e.TransferSyntaxUID,n=new B(G,t);return function(){var t=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(e||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),i=[],a={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,c=I(n,i);if("x0002ffff"<c.tag){n.position=o;break}c.parser=G,a[c.tag]=c}return(t=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,t.position=n.position,t}()}var q="1.2.840.10008.1.2.2";function z(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,i=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(e=e.elements.x00020010)&&e.Value||g(t,e.dataOffset,e.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===q?U:G,t,i);if(e&&e.inflater)return n=e.inflater(t,i),new B(G,n,0);if(1==a){var o=r(0),c=M(t,i,t.length-i);return o=o.inflateRawSync(c),c=D(t,o.length+i),t.copy(c,0,0,i),o.copy(c,i),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=t.slice(i),c=pako.inflateRaw(o),(o=D(t,c.length+i)).set(t.slice(0,i),0),o.set(c,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?_:F)(n,o,o.byteArray.length,e)}catch(o){throw{exception:o,dataSet:n}}return n}return function(t,e){for(var r in t.elements)t.elements.hasOwnProperty(r)&&(e.elements[r]=t.elements[r]);return void 0!==t.warnings&&(e.warnings=t.warnings.concat(e.warnings)),e}(n=C(t,e),a(n))}var W=function(t,e,r){for(var n=0,i=e;i<e+r;i++)n+=t[i].length;return n};function H(t,e,r,n,i){if(i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===e)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"!==e.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.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>=e.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>e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(t.byteArrayParser,t.byteArray,e.dataOffset);if("xfffee000"!==(e=O(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(e.length);var o=a.position;if(1===n)return M(a.byteArray,o+i[r].offset+8,i[r].length);e=W(i,r,n);for(var c=D(a.byteArray,e),s=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)c[s++]=a.byteArray[f++];return c}var Y=function(t,e){for(var r=0;r<t.length;r++)if(t[r].offset===e)return r},J=function(t,e,r,n){if(t===e.length-1)return r.length-n;for(var i=e[t+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,i){if(n=n||e.basicOffsetTable,i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===e)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"!==e.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===e.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 a=n[r];if(void 0===(a=Y(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(t,e,a,J(r,n,i,a),i)}var K=!1;function Q(t,e,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.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!==e.basicOffsetTable.length?V(t,e,r):H(t,e,0,e.fragments.length)}e.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:c,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:_,parseDicomDataSetImplicit:F,readFixedString:g,alloc:D,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:H,readPart10Header:C,readSequenceItemsExplicit:T,readSequenceItemsImplicit:k,readSequenceItem:O,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},e.m=r,e.c=n,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(e){return t[e]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1);function e(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return r[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.m=t,r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.u=t=>t+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var e=r.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>Le,FetchType:()=>a,clearPartialFiles:()=>Xt,default:()=>ke});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>a,RequestType:()=>o});var e={};r.r(e),r.d(e,{DOMAIN:()=>P,FILE_EXTENSIONS:()=>S,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>L,FILE_STREAMING_WORKER_NAME:()=>k,FILE_SYSTEM_ROUTES:()=>j,IDB_DIR_HANDLE_KEY:()=>T,THRESHOLD:()=>A});var a=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),o=function(t){return t[t.FRAME=0]="FRAME",t[t.THUMBNAIL=1]="THUMBNAIL",t[t.SERIES_METADATA=2]="SERIES_METADATA",t[t.INSTANCE_METADATA=3]="INSTANCE_METADATA",t}({}),c=function(t){return t[t.WORKER=0]="WORKER",t[t.REQUEST=1]="REQUEST",t}({}),s=r(915);function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function f(t,e,r){return(e=d(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,d(n.key),n)}}function h(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function d(t){var e=function(t,e){if("object"!=u(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==u(e)?e:e+""}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y(t,e,r){return e=w(e),function(t,e){if(e&&("object"==u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,r||[],w(t).constructor):e.apply(t,r))}function v(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&b(i,r.prototype),i}(t,arguments,w(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,t)},m(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}var E=function(t){function e(){return p(this,e),y(this,e,arguments)}return v(e,t),h(e)}(m(Error)),x=function(t){function e(t,r){var n;return p(this,e),f(n=y(this,e,[t]),"error",void 0),f(n,"message",void 0),n.message=t,n.error=r,n}return v(e,t),h(e)}(m(Event)),P="https://storage.googleapis.com",S=[".tar",".zip"],O="/dicomweb/",L="filePartial",k="fileStreaming",A=1e4,T="indexed_db_directory_handle_key",j={Partial:"partial"};const I={Enums:t,url:e,dataRetrieval:i};function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function F(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */F=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==_(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function D(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function N(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,M(n.key),n)}}function U(t,e,r){return(e=M(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function M(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_(e)?e:e+""}const R=function(){return t=function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),U(this,"loaderRegistry",{}),U(this,"listenerCallback",(function(t,r,n){var i,a=null===(i=e.loaderRegistry[t])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(t){return t({data:n})}))}))},e=[{key:"register",value:function(t,e){try{if(!e)throw new E("Loader object for ".concat(t," is not provided"));this.loaderRegistry[t]={loaderObject:e,listeners:{}}}catch(t){throw console.warn(t),new E("throws")}}},{key:"executeTask",value:(n=F().mark((function t(e,r,n){var i,a,o=this;return F().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.loaderRegistry[e])||void 0===i?void 0:i.loaderObject){t.next=3;break}throw new E("Loader ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,a[r](n,(function(t){return o.listenerCallback(e,"message",t)}));case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on "').concat(e,'":'),t.t0),new E('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){D(a,r,i,o,c,"next",t)}function c(t){D(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]?n.listeners[e].push(r):n.listeners[e]=[r]:console.error("Loader '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]=(n.listeners[e]||[]).filter((function(t){return t!==r})):console.error("Loader '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],e&&N(t.prototype,e),r&&N(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2019 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
*/
|
|
20
|
-
const M=Symbol("Comlink.proxy"),R=Symbol("Comlink.endpoint"),B=Symbol("Comlink.releaseProxy"),G=Symbol("Comlink.finalizer"),q=Symbol("Comlink.thrown"),C=e=>"object"==typeof e&&null!==e||"function"==typeof e,z=new Map([["proxy",{canHandle:e=>C(e)&&e[M],serialize(e){const{port1:t,port2:r}=new MessageChannel;return W(e,t),[r,[r]]},deserialize:e=>(e.start(),H(e))}],["throw",{canHandle:e=>C(e)&&q 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 W(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(i){if(!i||!i.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,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(te);let u;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":u=r;break;case"SET":t[s.slice(-1)[0]]=te(i.data.value),u=!0;break;case"APPLY":u=r.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[M]:!0})}(new r(...c));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;W(e,r),u=function(e,t){return X.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[q]:0}}Promise.resolve(u).catch((e=>({value:e,[q]:0}))).then((r=>{const[i,s]=ee(r);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),"RELEASE"===o&&(t.removeEventListener("message",n),Y(t),G in e&&"function"==typeof e[G]&&e[G]())})).catch((e=>{const[r,n]=ee({value:new TypeError("Unserializable return value"),[q]:0});t.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),t.start&&t.start()}function Y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function H(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)}})),Z(e,r,[],t)}function V(e){if(e)throw new Error("Proxy has been released and is not useable")}function J(e){return re(e,new Map,{type:"RELEASE"}).then((()=>{Y(e)}))}const K=new WeakMap,Q="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(K.get(e)||0)-1;K.set(e,t),0===t&&J(e)}));function Z(e,t,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(V(i),o===B)return()=>{!function(e){Q&&Q.unregister(e)}(a),J(e),t.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=re(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(te);return n.then.bind(n)}return Z(e,t,[...r,o])},set(n,a,o){V(i);const[s,c]=ee(o);return re(e,t,{type:"SET",path:[...r,a].map((e=>e.toString())),value:s},c).then(te)},apply(n,a,o){V(i);const s=r[r.length-1];if(s===R)return re(e,t,{type:"ENDPOINT"}).then(te);if("bind"===s)return Z(e,t,r.slice(0,-1));const[c,u]=$(o);return re(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:c},u).then(te)},construct(n,a){V(i);const[o,s]=$(a);return re(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(te)}});return function(e,t){const r=(K.get(t)||0)+1;K.set(t,r),Q&&Q.register(e,t,e)}(a,e),a}function $(e){const t=e.map(ee);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const X=new WeakMap;function ee(e){for(const[t,r]of z)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},X.get(e)||[]]}function te(e){switch(e.type){case"HANDLER":return z.get(e.name).deserialize(e.value);case"RAW":return e.value}}function re(e,t,r,n){return new Promise((i=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},r),n)}))}function ne(e){return ne="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},ne(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,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ne(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(ne(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function ae(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function oe(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,se(n.key),n)}}function se(e){var t=function(e,t){if("object"!=ne(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ne(t)?t:t+""}const ce=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=se(r="workerRegistry"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"register",value:function(e,t){try{var r=t();if(!r)throw new E("WorkerFn of worker ".concat(e," is not creating a worker"));this.workerRegistry[e]={instance:H(r),nativeWorker:r}}catch(e){console.warn(e)}}},{key:"executeTask",value:(n=ie().mark((function e(t,r,n){var i,a;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(i=this.workerRegistry[t])||void 0===i?void 0:i.instance){e.next=3;break}throw new E("Worker ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,a[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 E('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){ae(a,r,i,o,s,"next",e)}function s(e){ae(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.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."))}},{key:"reset",value:function(){this.workerRegistry={}}}],t&&oe(e.prototype,t),r&&oe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();function ue(e){return ue="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},ue(e)}function fe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */fe=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ue(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(ue(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function le(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function he(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,pe(n.key),n)}}function de(e,t,r){return(t=pe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(e){var t=function(e,t){if("object"!=ue(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ue(t)?t:t+""}var ye=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),de(this,"dataRetriever",void 0),de(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new U,this.dataRetrieverMode=s.REQUEST):(this.dataRetriever=new ce,this.dataRetrieverMode=s.WORKER)},t=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(e){var t=de(de({},s.WORKER,ce),s.REQUEST,U);if(!(e in t))throw new E("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new t[e],this.dataRetrieverMode=e}},{key:"register",value:function(e,t){this.dataRetriever.register(e,t)}},{key:"executeTask",value:(n=fe().mark((function e(t,r,n){return fe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.dataRetriever.executeTask(t,r,n);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){le(a,r,i,o,s,"next",e)}function s(e){le(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){this.dataRetriever.addEventListener(e,t,r)}},{key:"removeEventListener",value:function(e,t,r){this.dataRetriever.removeEventListener(e,t,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],t&&he(e.prototype,t),r&&he(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}());function me(){return ye}function ve(e){return ve="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},ve(e)}function ge(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,i,a,o,s=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return be(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)?be(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 be(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 we(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,xe(n.key),n)}}function Ee(e,t,r){return(t=xe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xe(e){var t=function(e,t){if("object"!=ve(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ve(t)?t:t+""}const Pe=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),Ee(this,"files",{}),Ee(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=ge(t,2),n=r[0],i=r[1].position;return n.includes("?bytes=")?e:e+i}),0)}},{key:"remove",value:function(e){var t=this.getPosition(e);delete this.files[e],e.includes("?bytes=")||me().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",t)}},{key:"purge",value:function(){var e=this.getTotalSize();this.files={},me().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",e)}}])&&we(e.prototype,t),r&&we(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();function Se(e,t){if(e.includes(T.url.URL_VALIDATION_STRING)){var r,n=e.split(t+"/")[1],i=n.split("/studies")[0],a=i.split("/"),s=a[0],c=a.slice(1).join("/"),u=n.split(i+"/")[1].split("/"),f=u[1],l=u[3],h="",d=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(h=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):h=u[5],d=+u[7],r=o.FRAME;break;default:throw new E("Invalid type of request")}return{type:r,bucketName:s,bucketPrefix:c,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function Oe(e,t,r,n){var i;if(!e||null===(i=e.cod)||void 0===i||!i.instances)throw new E("Invalid seriesMetadata provided.");if(null==r)throw new E("Frame index is required.");var a,o=n.domain,s=n.bucketName,c=n.bucketPrefix;if(e.thumbnail){var u=e.thumbnail.uri;a="".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:a};var l,h,d=f.url,p=f.uri,y=f.headers,m=f.offset_tables,v=function(e,t,r,n){var i=e,a=T.url.FILE_EXTENSIONS.find((function(t){return e.includes(t)}));if(a){i=e.split(a)[0]+a}var o=i.split("studies/")[1];return i="".concat(t,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),i}(d||p,o,s,c),g=m.CustomOffsetTable,b=m.CustomOffsetTableLengths,w=!1;null!=g&&g.length&&null!=b&&b.length&&(h=(l=g[r])+b[r],w=!0);var x=y.start_byte,P=y.end_byte;return{url:v,startByte:void 0!==l?x+l:x,endByte:void 0!==h?x+h:P,thumbnailUrl:a,isMultiframe:w}}function Le(e){var t=e.domain,r=void 0===t?T.url.DOMAIN:t,n=e.bucketName,i=e.bucketPrefix,a=e.studyInstanceUID,o=e.seriesInstanceUID;if(n&&i&&a&&o)return"".concat(r,"/").concat(n,"/").concat(i,"/studies/").concat(a,"/series/").concat(o,"/metadata.json")}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 ke(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ke=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(Ae(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Te(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function Ie(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,je(n.key),n)}}function je(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+""}const Fe=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=je(r="metadata"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"addDeidMetadata",value:function(e){var t=e.deid_study_uid,r=e.deid_series_uid,n=e.cod;if(n&&t&&r)for(var i in n.instances){var a=n.instances[i];a.metadata.DeidStudyInstanceUID={Value:[t]},a.metadata.DeidSeriesInstanceUID={Value:[r]},a.metadata.DeidSopInstanceUID={Value:[i]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(e){return this.metadata[e]}},{key:"getMetadata",value:(n=ke().mark((function e(t,r){var n,i,a,o;return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Le(t)){e.next=3;break}throw new E("Error creating metadata json url");case 3:if(!(i=this.getMetadataFromCache(n))){e.next=6;break}return e.abrupt("return",i);case 6:return e.prev=6,e.next=9,fetch(n,{headers:r});case 9:if((a=e.sent).ok){e.next=12;break}throw new E("Failed to fetch metadata: ".concat(a.statusText));case 12:return e.next=14,a.json();case 14:return o=e.sent,this.addDeidMetadata(o),this.metadata[n]=o,e.abrupt("return",o);case 20:throw e.prev=20,e.t0=e.catch(6),console.error(e.t0),e.t0;case 24:case"end":return e.stop()}}),e,this,[[6,20]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){Te(a,r,i,o,s,"next",e)}function s(e){Te(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t){return i.apply(this,arguments)})}],t&&Ie(e.prototype,t),r&&Ie(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();function De(e){return De="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},De(e)}function _e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_e=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==De(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(De(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Ne(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}const Ue={partial:function(e,t){return(r=_e().mark((function r(){var n,i;return _e().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.url,i=e.headers,r.next=3,fetch(n,{headers:i}).then((function(e){return e.arrayBuffer()})).then((function(e){return t({url:n,fileArraybuffer:new Uint8Array(e)})})).catch((function(e){throw new E("filePartial.ts: Error when fetching file: "+(null==e?void 0:e.message))}));case 3:case"end":return r.stop()}}),r)})),function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){Ne(a,n,i,o,s,"next",e)}function s(e){Ne(a,n,i,o,s,"throw",e)}o(void 0)}))})();var r}};function Me(e){return Me="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},Me(e)}function Re(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Re=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Me(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(Me(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(r),!0).forEach((function(t){qe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Be(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function qe(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Me(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Me(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ce(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}const ze={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(e){e>0&&(this.maxFetchSize=e)},decreaseFetchedSize:function(e){e>0&&e<=this.fetchedSize&&(this.fetchedSize-=e)},stream:function(e,t){var r,n=this;return(r=Re().mark((function r(){var i,a,o,s,c,u,f,l,h,d,p,y,m,v,g,b;return Re().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=e.url,a=e.headers,o=e.useSharedArrayBuffer,s=new AbortController,c=null,u=null,r.prev=4,r.next=7,fetch(i,{headers:Ge({},a),signal:s.signal});case 7:if((l=r.sent).ok){r.next=10;break}throw new E("HTTP error! status: ".concat(l.status));case 10:if(h=null===(f=l.body)||void 0===f?void 0:f.getReader()){r.next=13;break}throw new E("Failed to get reader from response body");case 13:return p=!1,y=parseInt(l.headers.get("Content-Length")||"0",10),r.next=17,h.read();case 17:if(m=r.sent,p=m.done,m.value){r.next=21;break}throw new E("The fetched chunks does not have value");case 21:if(p){r.next=49;break}if(v=m.value.length,!(n.fetchedSize+v>n.maxFetchSize)){r.next=26;break}throw s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 26:n.fetchedSize+=v,o?(c=new SharedArrayBuffer(y),u=new Uint8Array(c)):u=new Uint8Array(y),u.set(m.value),t({url:i,position:v,fileArraybuffer:u});case 30:if(p){r.next=49;break}return r.next=33,h.read();case 33:if(!(d=r.sent).done){r.next=37;break}return p=!0,r.abrupt("continue",30);case 37:if(g=d.value,!(n.fetchedSize+g.length>n.maxFetchSize)){r.next=43;break}throw c=null,u=null,s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 43:n.fetchedSize+=g.length,u.set(g,v),v+=g.length,t({isAppending:!0,url:i,position:v,chunk:o?void 0:g}),r.next=30;break;case 49:r.next=56;break;case 51:throw r.prev=51,r.t0=r.catch(4),b=new E("fileStreaming.ts: "+r.t0.message||0),console.error(b.message,r.t0),b;case 56:return r.prev=56,c=null,u=null,s.abort(),r.finish(56);case 61:case"end":return r.stop()}}),r,null,[[4,51,56,61]])})),function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){Ce(a,n,i,o,s,"next",e)}function s(e){Ce(a,n,i,o,s,"throw",e)}o(void 0)}))})()}};function We(e){return We="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},We(e)}function Ye(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ye=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.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 a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(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 h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==We(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 a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.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,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}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 I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(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 i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(We(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"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(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);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=j,I.prototype={constructor:I,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 i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("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 i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):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),m},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),m}},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 i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function He(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function Ve(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){He(a,n,i,o,s,"next",e)}function s(e){He(a,n,i,o,s,"throw",e)}o(void 0)}))}}function Je(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,Qe(n.key),n)}}function Ke(e,t,r){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qe(e){var t=function(e,t){if("object"!=We(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=We(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==We(t)?t:t+""}var Ze=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),Ke(this,"filePromises",{}),Ke(this,"options",{maxWorkerFetchSize:1/0,domain:T.url.DOMAIN}),Ke(this,"fileManager",void 0),Ke(this,"metadataManager",void 0),Ke(this,"seriesUidFileUrls",{}),Ke(this,"setOptions",(function(e){Object.keys(e).forEach((function(r){void 0!==e[r]&&(t.options[r]=e[r])}))})),Ke(this,"getOptions",(function(){return t.options}));var i=n.maxWorkerFetchSize,a=n.domain,o=n.disableWorker;this.options.maxWorkerFetchSize=i||this.options.maxWorkerFetchSize,this.options.domain=a||this.options.domain;var c=T.dataRetrieval.FILE_STREAMING_WORKER_NAME,u=T.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Pe({fileStreamingWorkerName:c}),this.metadataManager=new Fe,o&&me().setDataRetrieverMode(s.REQUEST),function(e,t){var n=e.fileStreamingScriptName,i=e.filePartialScriptName,a=me();a.getDataRetrieverMode()===s.REQUEST?(a.register(n,ze),a.register(i,Ue)):(a.register(n,(function(){return new Worker(new URL(r.p+r.u(66),r.b),{name:n})})),a.register(i,(function(){return new Worker(new URL(r.p+r.u(614),r.b),{name:i})}))),a.executeTask(n,"setMaxFetchSize",t)}({fileStreamingScriptName:c,filePartialScriptName:u},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:(u=Ve(Ye().mark((function e(t){var r,n,i,s,u,f,l,h,d,p,y,m,v,g,b,w,x,P,S,O,L,A,k,I=this,j=arguments;return Ye().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=j.length>1&&void 0!==j[1]?j[1]:{},i=(n=j.length>2&&void 0!==j[2]?j[2]:{}).useSharedArrayBuffer,s=void 0!==i&&i,u=n.fetchType,f=void 0===u?T.Enums.FetchType.API_OPTIMIZED:u,e.prev=2,t){e.next=5;break}throw new E("Url not provided");case 5:if(!(l=Se(t,this.options.domain))){e.next=31;break}return h=l.type,d=l.bucketName,p=l.bucketPrefix,y=l.studyInstanceUID,m=l.seriesInstanceUID,v=l.sopInstanceUID,g=l.frameNumber,e.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:d,bucketPrefix:p,studyInstanceUID:y,seriesInstanceUID:m},r);case 10:if(b=e.sent){e.next=13;break}throw new E("Metadata not found for ".concat(t));case 13:w=Oe(b,v,g-1,{domain:this.options.domain,bucketName:d,bucketPrefix:p}),x=w.url,P=w.startByte,S=w.endByte,O=w.thumbnailUrl,L=w.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(O){e.next=19;break}throw new E("Thumbnail not found for ".concat(t));case 19:return this.addFileUrl(m,O),e.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:s}));case 21:if(x){e.next=23;break}throw new E("Url not found for frame");case 23:return A=x,f===a.BYTES_OPTIMIZED&&(A="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,x),e.abrupt("return",this.fetchFile(A,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:s,fetchType:f}).then((function(e){if(null==e||!e.byteLength)throw new E("File Arraybuffer is not found");if(L)return e;var t=(0,c.parseDicom)(new Uint8Array(e)).elements.x7fe00010,r=t.dataOffset,n=t.length;if(t.hadUndefinedLength&&t.fragments){var i=t.fragments[0];r=i.position,n=i.length}else r+=8;return e.slice(r,r+n)})));case 27:return e.abrupt("return",this.parseMetadata(b,h,v));case 28:throw new E("Unsupported request type: ".concat(h));case 29:e.next=32;break;case 31:return e.abrupt("return",new Promise((function(e,n){return I.fetchFile(t,r,{useSharedArrayBuffer:s}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,c.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 n(e)}))})));case 32:e.next=39;break;case 34:throw e.prev=34,e.t1=e.catch(2),k=new E("CodDicomWebServer.ts: ".concat(e.t1.message||"An error occured when fetching the COD")),console.error(k),k;case 39:case"end":return e.stop()}}),e,this,[[2,34]])}))),function(e){return u.apply(this,arguments)})},{key:"fetchFile",value:(i=Ve(Ye().mark((function e(t,r){var n,i,o,s,c,u,f,l,h,d,p,y,m,v,g,b,w=this,P=arguments;return Ye().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=(n=P.length>2&&void 0!==P[2]?P[2]:{}).offsets,o=n.useSharedArrayBuffer,s=void 0!==o&&o,c=n.fetchType,u=void 0===c?T.Enums.FetchType.API_OPTIMIZED:c,f=u===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(t,f?void 0:i))){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){try{e(l.buffer)}catch(e){t(e)}})));case 5:return h=this.getOptions(),d=h.maxWorkerFetchSize,p=me(),y=T.dataRetrieval,m=y.FILE_STREAMING_WORKER_NAME,v=y.FILE_PARTIAL_WORKER_NAME,g=y.THRESHOLD,this.filePromises[t]?b=this.filePromises[t]:(b=new Promise((function(e,n){if(w.fileManager.getTotalSize()+g>d)throw new E("CodDicomWebServer.ts: Maximum size(".concat(d,") for fetching files reached"));var a=T.Enums.FetchType;if(u===a.API_OPTIMIZED){var o=function(e){if(e instanceof x)throw n(e.error),e.error;var r=e.data,i=r.url,a=r.position,s=r.fileArraybuffer;i===t&&s&&(w.fileManager.set(i,{data:s,position:a}),p.removeEventListener(m,"message",o))};p.addEventListener(m,"message",o),p.executeTask(m,"stream",{url:t,headers:r,useSharedArrayBuffer:s}).then((function(){w.fileManager.getPosition(t)?e():n(new E("File - ".concat(t," not found")))})).catch((function(e){n(e)})).then((function(){p.removeEventListener(m,"message",o),delete w.filePromises[t]}))}else if(u===a.BYTES_OPTIMIZED&&i){var c=i.startByte,f=i.endByte;r.Range="bytes=".concat(c,"-").concat(f-1);var l=t.split("?bytes=")[0],h=function(e){if(e instanceof x)throw n(e.error),e.error;var r=e.data,i=r.url,a=r.fileArraybuffer;i===l&&(w.fileManager.set(t,{data:a,position:a.length}),p.removeEventListener(v,"message",h))};p.addEventListener(v,"message",h),p.executeTask(v,"partial",{url:l,headers:r,useSharedArrayBuffer:s}).then((function(){w.fileManager.getPosition(t)?e():n(new E("File - ".concat(t," not found")))})).catch((function(e){n(e)})).then((function(){p.removeEventListener(v,"message",h),delete w.filePromises[t]}))}else n(new E("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[t]=b),e.abrupt("return",new Promise((function(e,r){var n=!1,a=function(a){if(a instanceof x)throw r(a.message),a.error;var o=a.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&&i&&c>i.endByte)try{var f=w.fileManager.get(s,i);n=!0,e(null==f?void 0:f.buffer)}catch(e){r(e)}};i&&!f&&p.addEventListener(m,"message",a),b.then((function(){if(!n){var r=w.fileManager.get(t,f?void 0:i);n=!0,e(null==r?void 0:r.buffer)}})).catch((function(e){r(e)})).then((function(){p.removeEventListener(m,"message",a)}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.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&&Je(e.prototype,t),n&&Je(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,i,u}();const $e=Ze,Xe={FetchType:a,CodDicomWebServer:Ze}})(),n})()));
|
|
20
|
+
const B=Symbol("Comlink.proxy"),G=Symbol("Comlink.endpoint"),C=Symbol("Comlink.releaseProxy"),q=Symbol("Comlink.finalizer"),z=Symbol("Comlink.thrown"),W=t=>"object"==typeof t&&null!==t||"function"==typeof t,H=new Map([["proxy",{canHandle:t=>W(t)&&t[B],serialize(t){const{port1:e,port2:r}=new MessageChannel;return Y(t,e),[r,[r]]},deserialize:t=>(t.start(),V(t))}],["throw",{canHandle:t=>W(t)&&z in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function Y(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(i){if(!i||!i.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:c}=Object.assign({path:[]},i.data),s=(i.data.argumentList||[]).map(nt);let u;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(o){case"GET":u=r;break;case"SET":e[c.slice(-1)[0]]=nt(i.data.value),u=!0;break;case"APPLY":u=r.apply(e,s);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[B]:!0})}(new r(...s));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;Y(t,r),u=function(t,e){return et.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[z]:0}}Promise.resolve(u).catch((t=>({value:t,[z]:0}))).then((r=>{const[i,c]=rt(r);e.postMessage(Object.assign(Object.assign({},i),{id:a}),c),"RELEASE"===o&&(e.removeEventListener("message",n),J(e),q in t&&"function"==typeof t[q]&&t[q]())})).catch((t=>{const[r,n]=rt({value:new TypeError("Unserializable return value"),[z]:0});e.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),e.start&&e.start()}function J(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function V(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),X(t,r,[],e)}function K(t){if(t)throw new Error("Proxy has been released and is not useable")}function Q(t){return it(t,new Map,{type:"RELEASE"}).then((()=>{J(t)}))}const Z=new WeakMap,$="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Z.get(t)||0)-1;Z.set(t,e),0===e&&Q(t)}));function X(t,e,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(K(i),o===C)return()=>{!function(t){$&&$.unregister(t)}(a),Q(t),e.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=it(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(nt);return n.then.bind(n)}return X(t,e,[...r,o])},set(n,a,o){K(i);const[c,s]=rt(o);return it(t,e,{type:"SET",path:[...r,a].map((t=>t.toString())),value:c},s).then(nt)},apply(n,a,o){K(i);const c=r[r.length-1];if(c===G)return it(t,e,{type:"ENDPOINT"}).then(nt);if("bind"===c)return X(t,e,r.slice(0,-1));const[s,u]=tt(o);return it(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:s},u).then(nt)},construct(n,a){K(i);const[o,c]=tt(a);return it(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:o},c).then(nt)}});return function(t,e){const r=(Z.get(e)||0)+1;Z.set(e,r),$&&$.register(t,e,t)}(a,t),a}function tt(t){const e=t.map(rt);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const et=new WeakMap;function rt(t){for(const[e,r]of H)if(r.canHandle(t)){const[n,i]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},et.get(t)||[]]}function nt(t){switch(t.type){case"HANDLER":return H.get(t.name).deserialize(t.value);case"RAW":return t.value}}function it(t,e,r,n){return new Promise((i=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(a,i),t.start&&t.start(),t.postMessage(Object.assign({id:a},r),n)}))}function at(t){return at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},at(t)}function ot(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ot=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==at(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(at(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ct(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function st(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ut(n.key),n)}}function ut(t){var e=function(t,e){if("object"!=at(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=at(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==at(e)?e:e+""}const ft=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=ut(r="workerRegistry"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"register",value:function(t,e){try{var r=e();if(!r)throw new E("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:V(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ot().mark((function t(e,r,n){var i,a;return ot().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.workerRegistry[e])||void 0===i?void 0:i.instance){t.next=3;break}throw new E("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,a[r](n);case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(e,'":'),t.t0),new E('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){ct(a,r,i,o,c,"next",t)}function c(t){ct(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.addEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.removeEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],e&&st(t.prototype,e),r&&st(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ht(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ht=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==lt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(lt(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function dt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function yt(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==lt(e)?e:e+""}var mt=new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yt(this,"dataRetriever",void 0),yt(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new R,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new ft,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=yt(yt({},c.WORKER,ft),c.REQUEST,R);if(!(t in e))throw new E("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new e[t],this.dataRetrieverMode=t}},{key:"register",value:function(t,e){this.dataRetriever.register(t,e)}},{key:"executeTask",value:(n=ht().mark((function t(e,r,n){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){dt(a,r,i,o,c,"next",t)}function c(t){dt(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){this.dataRetriever.addEventListener(t,e,r)}},{key:"removeEventListener",value:function(t,e,r){this.dataRetriever.removeEventListener(t,e,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],e&&pt(t.prototype,e),r&&pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}());function gt(){return mt}function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function wt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Et(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Et(t,e):void 0}}(t,e)||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 Et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function xt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,St(n.key),n)}}function Pt(t,e,r){return(e=St(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function St(t){var e=function(t,e){if("object"!=bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==bt(e)?e:e+""}const Ot=function(){return t=function t(e){var r=e.fileStreamingScriptName;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Pt(this,"files",{}),Pt(this,"fileStreamingScriptName",void 0),this.fileStreamingScriptName=r},(e=[{key:"set",value:function(t,e){this.files[t]=e}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e)}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(t,e){var r=wt(e,2),n=r[0],i=r[1].position;return n.includes("?bytes=")?t:t+i}),0)}},{key:"remove",value:function(t){var e=this.getPosition(t);delete this.files[t],t.includes("?bytes=")||gt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",e)}},{key:"purge",value:function(){var t=this.getTotalSize();this.files={},gt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",t)}}])&&xt(t.prototype,e),r&&xt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function Lt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return kt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?kt(t,e):void 0}}(t,e)||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 kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function At(t,e){if(t.includes(I.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],i=n.split("/studies")[0],a=i.split("/"),c=a[0],s=a.slice(1).join("/"),u=n.split(i+"/")[1].split("/"),f=u[1],l=u[3],h="",d=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(h=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):h=u[5],d=+u[7],r=o.FRAME;break;default:throw new E("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:s,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function Tt(t,e,r,n){var i,a;if(!t||null===(i=t.cod)||void 0===i||!i.instances)throw new E("Invalid seriesMetadata provided.");if(null==r)throw new E("Frame index is required.");var o,c=n.domain,s=n.bucketName,u=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;o="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(a=Object.entries(t.cod.instances).find((function(t){var r=Lt(t,2),n=r[0];r[1];return n===e})))||void 0===a?void 0:a[1];if(!l)return{thumbnailUrl:o};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var i=t,a=I.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(a){i=t.split(a)[0]+a}var o=i.split("studies/")[1];return i="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),i}(p||y,c,s,u),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,x=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],x=!0);var P=v.start_byte,S=v.end_byte;return{url:g,startByte:void 0!==h?P+h:P,endByte:void 0!==d?P+d:S,thumbnailUrl:o,isMultiframe:x}}function jt(t){var e=t.domain,r=void 0===e?I.url.DOMAIN:e,n=t.bucketName,i=t.bucketPrefix,a=t.studyInstanceUID,o=t.seriesInstanceUID;if(n&&i&&a&&o)return"".concat(r,"/").concat(n,"/").concat(i,"/studies/").concat(a,"/series/").concat(o,"/metadata.json")}function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}function _t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_t=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==It(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(It(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Ft(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function Nt(t){var e=function(t,e){if("object"!=It(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=It(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==It(e)?e:e+""}const Ut=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=Nt(r="metadataPromises"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"addDeidMetadata",value:function(t){var e=t.deid_study_uid,r=t.deid_series_uid,n=t.cod;if(n&&e&&r)for(var i in n.instances){var a=n.instances[i];a.metadata.DeidStudyInstanceUID={Value:[e]},a.metadata.DeidSeriesInstanceUID={Value:[r]},a.metadata.DeidSopInstanceUID={Value:[i]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=_t().mark((function t(e,r){var n,i,a=this;return _t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=jt(e)){t.next=3;break}throw new E("Error creating metadata json url");case 3:if(!(i=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,i;case 7:case 12:return t.abrupt("return",t.sent);case 8:return t.prev=8,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new E("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return a.addDeidMetadata(t),t})),t.next=12,this.metadataPromises[n];case 15:throw t.prev=15,t.t0=t.catch(8),console.error(t.t0),t.t0;case 19:case"end":return t.stop()}}),t,this,[[8,15]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){Ft(a,r,i,o,c,"next",t)}function c(t){Ft(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e){return i.apply(this,arguments)})}],e&&Dt(t.prototype,e),r&&Dt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function Mt(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function Rt(t,e){let r;return(n,i)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=Mt(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>i(t.transaction(e,n).objectStore(e))))}let Bt;function Gt(){return Bt||(Bt=Rt("keyval-store","keyval")),Bt}function Ct(t,e=Gt()){return e("readonly",(e=>Mt(e.get(t))))}function qt(t){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qt(t)}function zt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */zt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==qt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(qt(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Wt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Ht(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){Wt(a,n,i,o,c,"next",t)}function c(t){Wt(a,n,i,o,c,"throw",t)}o(void 0)}))}}var Yt;function Jt(){return Vt.apply(this,arguments)}function Vt(){return(Vt=Ht(zt().mark((function t(){return zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,Yt){t.next=5;break}return t.next=4,Ct(T);case 4:Yt=t.sent;case 5:if(Yt){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:Yt=t.sent;case 9:return t.abrupt("return",Yt);case 12:t.prev=12,t.t0=t.catch(0),console.warn("Error getting directoryhandle: ".concat(t.t0.message));case 15:case"end":return t.stop()}}),t,null,[[0,12]])})))).apply(this,arguments)}function Kt(t,e,r){return Qt.apply(this,arguments)}function Qt(){return Qt=Ht(zt().mark((function t(e,r,n){var i,a,o,c,s,u,f,l,h;return zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:i=r.split("/"),a=e,t.prev=4,o=0;case 6:if(!(o<i.length-1)){t.next=13;break}return t.next=9,a.getDirectoryHandle(i[o]);case 9:a=t.sent;case 10:o++,t.next=6;break;case 13:return c=i.at(-1),t.next=16,a.getFileHandle(c);case 16:return s=t.sent,t.next=19,s.getFile().then((function(t){return t.arrayBuffer()}));case 19:return t.abrupt("return",t.sent);case 22:if(t.prev=22,t.t0=t.catch(4),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message)),!n||i[0]!==j.Partial){t.next=49;break}t.prev=26,u=i.at(-1).slice(0,r.lastIndexOf(".")).split("_")[0],i=i.slice(1),f=0;case 30:if(!(f<i.length-1)){t.next=37;break}return t.next=33,a.getDirectoryHandle(i[f]);case 33:a=t.sent;case 34:f++,t.next=30;break;case 37:return t.next=39,e.getFileHandle(u+".tar");case 39:return l=t.sent,t.next=42,l.getFile().then((function(t){return t.arrayBuffer()}));case 42:return h=t.sent,t.abrupt("return",h.slice(n.startByte,n.endByte));case 46:t.prev=46,t.t1=t.catch(26),console.warn("Error reading the file ".concat(r,": ").concat(t.t1.message));case 49:case"end":return t.stop()}}),t,null,[[4,22],[26,46]])}))),Qt.apply(this,arguments)}function Zt(t,e,r){return $t.apply(this,arguments)}function $t(){return $t=Ht(zt().mark((function t(e,r,n){var i,a,o,c,s,u;return zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,i=r.split("/"),a=e,o=0;case 4:if(!(o<i.length-1)){t.next=11;break}return t.next=7,a.getDirectoryHandle(i[o],{create:!0});case 7:a=t.sent;case 8:o++,t.next=4;break;case 11:return c=i[i.length-1],t.next=14,a.getFileHandle(c,{create:!0});case 14:return s=t.sent,t.next=17,s.createWritable();case 17:return u=t.sent,t.next=20,u.write(n);case 20:return t.next=22,u.close();case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(0),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 27:case"end":return t.stop()}}),t,null,[[0,24]])}))),$t.apply(this,arguments)}function Xt(){return te.apply(this,arguments)}function te(){return(te=Ht(zt().mark((function t(){return zt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Yt.removeEntry(j.Partial,{recursive:!0});case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),console.warn("Error clearing partial files: ".concat(t.t0.message));case 8:case"end":return t.stop()}}),t,null,[[0,5]])})))).apply(this,arguments)}function ee(t){return t.split("series/")[1]}function re(t,e){var r=t.split("series/")[1].split(".tar")[0],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(j.Partial,"/").concat(r).concat(n,".dcm")}function ne(t){return ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(t)}function ie(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ie=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ne(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ne(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ae(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var oe={partial:function(t,e){return(r=ie().mark((function r(){var n,i,a,o,c,s;return ie().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,i=t.offsets,a=t.headers,o=t.directoryHandle,null!=i&&i.startByte&&null!=i&&i.endByte&&(a.Range="bytes=".concat(i.startByte,"-").concat(i.endByte-1)),c=re(n,i),!o){r.next=10;break}return r.next=6,Kt(o,c,i);case 6:if(!(s=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(s),offsets:i}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:a}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:i}),o&&Zt(o,c,t)})).catch((function(t){throw new E("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){ae(a,n,i,o,c,"next",t)}function c(t){ae(a,n,i,o,c,"throw",t)}o(void 0)}))})();var r}};const ce=oe;function se(t){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},se(t)}function ue(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ue=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==se(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(se(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function fe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function le(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?fe(Object(r),!0).forEach((function(e){he(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function he(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=se(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=se(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==se(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function de(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var pe={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(t){t>0&&(this.maxFetchSize=t)},decreaseFetchedSize:function(t){t>0&&t<=this.fetchedSize&&(this.fetchedSize-=t)},stream:function(t,e){var r,n=this;return(r=ue().mark((function r(){var i,a,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,x,P;return ue().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=t.url,a=t.headers,o=t.useSharedArrayBuffer,c=t.directoryHandle,s=new AbortController,u=null,f=null,r.prev=4,h=ee(i),!c){r.next=13;break}return r.next=9,Kt(c,h);case 9:if(!(d=r.sent)){r.next=13;break}return e({url:i,position:d.byteLength,fileArraybuffer:new Uint8Array(d)}),r.abrupt("return");case 13:return r.next=15,fetch(i,{headers:le({},a),signal:s.signal});case 15:if((p=r.sent).ok){r.next=18;break}throw new E("HTTP error! status: ".concat(p.status));case 18:if(y=null===(l=p.body)||void 0===l?void 0:l.getReader()){r.next=21;break}throw new E("Failed to get reader from response body");case 21:return m=!1,g=parseInt(p.headers.get("Content-Length")||"0",10),r.next=25,y.read();case 25:if(b=r.sent,m=b.done,b.value){r.next=29;break}throw new E("The fetched chunks does not have value");case 29:if(m){r.next=58;break}if(w=b.value.length,!(n.fetchedSize+w>n.maxFetchSize)){r.next=34;break}throw s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 34:n.fetchedSize+=w,o?(u=new SharedArrayBuffer(g),f=new Uint8Array(u)):f=new Uint8Array(g),f.set(b.value),e({url:i,position:w,fileArraybuffer:f});case 38:if(m){r.next=57;break}return r.next=41,y.read();case 41:if(!(v=r.sent).done){r.next=45;break}return m=!0,r.abrupt("continue",38);case 45:if(x=v.value,!(n.fetchedSize+x.length>n.maxFetchSize)){r.next=51;break}throw u=null,f=null,s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 51:n.fetchedSize+=x.length,f.set(x,w),w+=x.length,e({isAppending:!0,url:i,position:w,chunk:o?void 0:x}),r.next=38;break;case 57:c&&Zt(c,h,f.slice().buffer);case 58:r.next=65;break;case 60:throw r.prev=60,r.t0=r.catch(4),P=new E("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 65:return r.prev=65,u=null,f=null,s.abort(),r.finish(65);case 70:case"end":return r.stop()}}),r,null,[[4,60,65,70]])})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){de(a,n,i,o,c,"next",t)}function c(t){de(a,n,i,o,c,"throw",t)}o(void 0)}))})()}};const ye=pe;function ve(t){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ve(t)}function me(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ge(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ge(t,e):void 0}}(t,e)||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 ge(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function be(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */be=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ve(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function L(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ve(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function we(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Ee(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){we(a,n,i,o,c,"next",t)}function c(t){we(a,n,i,o,c,"throw",t)}o(void 0)}))}}function xe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Se(n.key),n)}}function Pe(t,e,r){return(e=Se(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Se(t){var e=function(t,e){if("object"!=ve(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ve(e)?e:e+""}var Oe=function(){return t=function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Pe(this,"filePromises",{}),Pe(this,"options",{maxWorkerFetchSize:1/0,domain:I.url.DOMAIN,enableLocalCache:!1}),Pe(this,"fileManager",void 0),Pe(this,"metadataManager",void 0),Pe(this,"seriesUidFileUrls",{}),Pe(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Pe(this,"getOptions",(function(){return e.options}));var i=n.maxWorkerFetchSize,a=n.domain,o=n.disableWorker,s=n.enableLocalCache;this.options.maxWorkerFetchSize=i||this.options.maxWorkerFetchSize,this.options.domain=a||this.options.domain,this.options.enableLocalCache=!!s;var u=I.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=I.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Ot({fileStreamingScriptName:u}),this.metadataManager=new Ut,o&>().setDataRetrieverMode(c.REQUEST),function(t,e){var n=t.fileStreamingScriptName,i=t.filePartialScriptName,a=gt();a.getDataRetrieverMode()===c.REQUEST?(a.register(n,ye),a.register(i,ce)):(a.register(n,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:n})})),a.register(i,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:i})}))),a.executeTask(n,"setMaxFetchSize",e)}({fileStreamingScriptName:u,filePartialScriptName:f},this.options.maxWorkerFetchSize)},e=[{key:"addFileUrl",value:function(t,e){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].push(e):this.seriesUidFileUrls[t]=[e]}},{key:"fetchCod",value:(u=Ee(be().mark((function t(e){var r,n,i,c,u,f,l,h,d,p,y,v,m,g,b,w,x,P,S,O,L,k,A,T=this,j=arguments;return be().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=j.length>1&&void 0!==j[1]?j[1]:{},i=(n=j.length>2&&void 0!==j[2]?j[2]:{}).useSharedArrayBuffer,c=void 0!==i&&i,u=n.fetchType,f=void 0===u?I.Enums.FetchType.API_OPTIMIZED:u,t.prev=2,e){t.next=5;break}throw new E("Url not provided");case 5:if(!(l=At(e,this.options.domain))){t.next=31;break}return h=l.type,d=l.bucketName,p=l.bucketPrefix,y=l.studyInstanceUID,v=l.seriesInstanceUID,m=l.sopInstanceUID,g=l.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:d,bucketPrefix:p,studyInstanceUID:y,seriesInstanceUID:v},r);case 10:if(b=t.sent){t.next=13;break}throw new E("Metadata not found for ".concat(e));case 13:w=Tt(b,m,g-1,{domain:this.options.domain,bucketName:d,bucketPrefix:p}),x=w.url,P=w.startByte,S=w.endByte,O=w.thumbnailUrl,L=w.isMultiframe,t.t0=h,t.next=t.t0===o.THUMBNAIL?17:t.t0===o.FRAME?21:t.t0===o.SERIES_METADATA||t.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new E("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(v,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(x){t.next=23;break}throw new E("Url not found for frame");case 23:return k=x,f===a.BYTES_OPTIMIZED&&(k="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(v,x),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:c,fetchType:f}).then((function(t){if(null==t||!t.byteLength)throw new E("File Arraybuffer is not found");if(L)return t;var e=(0,s.parseDicom)(new Uint8Array(t)).elements.x7fe00010,r=e.dataOffset,n=e.length;if(e.hadUndefinedLength&&e.fragments){var i=e.fragments[0];r=i.position,n=i.length}else r+=8;return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(b,h,m));case 28:throw new E("Unsupported request type: ".concat(h));case 29:t.next=32;break;case 31:return t.abrupt("return",new Promise((function(t,n){return T.fetchFile(e,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&T.addFileUrl(n,e)}catch(t){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",t)}t(r)})).catch((function(t){return n(t)}))})));case 32:t.next=39;break;case 34:throw t.prev=34,t.t1=t.catch(2),A=new E("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(A),A;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return u.apply(this,arguments)})},{key:"fetchFile",value:(i=Ee(be().mark((function t(e,r){var n,i,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,P=this,S=arguments;return be().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=(n=S.length>2&&void 0!==S[2]?S[2]:{}).offsets,o=n.useSharedArrayBuffer,c=void 0!==o&&o,s=n.fetchType,u=void 0===s?I.Enums.FetchType.API_OPTIMIZED:s,f=u===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:i))){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){try{t(l.buffer)}catch(t){e(t)}})));case 5:if(t.t0=this.options.enableLocalCache,!t.t0){t.next=10;break}return t.next=9,Jt();case 9:t.t0=t.sent;case 10:return h=t.t0,d=this.getOptions(),p=d.maxWorkerFetchSize,y=gt(),v=I.dataRetrieval,m=v.FILE_STREAMING_WORKER_NAME,g=v.FILE_PARTIAL_WORKER_NAME,b=v.THRESHOLD,this.filePromises[e]?w=this.filePromises[e]:(w=new Promise((function(t,n){if(P.fileManager.getTotalSize()+b>p)throw new E("CodDicomWebServer.ts: Maximum size(".concat(p,") for fetching files reached"));var a=I.Enums.FetchType;if(u===a.API_OPTIMIZED){var o=function(t){if(t instanceof x)throw n(t.error),t.error;var r=t.data,i=r.url,a=r.position,c=r.fileArraybuffer;i===e&&c&&(P.fileManager.set(i,{data:c,position:a}),y.removeEventListener(m,"message",o))};y.addEventListener(m,"message",o),y.executeTask(m,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){y.removeEventListener(m,"message",o),delete P.filePromises[e]}))}else if(u===a.BYTES_OPTIMIZED&&i){var s=i.startByte,f=i.endByte,l=e.split("?bytes=")[0],d=function(r){if(r instanceof x)throw n(r.error),r.error;var i=r.data,a=i.url,o=i.fileArraybuffer,c=i.offsets;a===l&&c.startByte===s&&c.endByte===f&&(P.fileManager.set(e,{data:o,position:o.length}),y.removeEventListener(g,"message",d),t())};y.addEventListener(g,"message",d),y.executeTask(g,"partial",{url:l,offsets:{startByte:s,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){y.removeEventListener(g,"message",d),delete P.filePromises[e]}))}else n(new E("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]=w),t.abrupt("return",new Promise((function(t,r){var n=!1,a=function(a){if(a instanceof x)throw r(a.message),a.error;var o=a.data,c=o.url,s=o.position,u=o.chunk;if(o.isAppending&&(u?P.fileManager.append(c,u,s):P.fileManager.setPosition(c,s)),!n&&c===e&&i&&s>i.endByte)try{var f=P.fileManager.get(c,i);n=!0,t(null==f?void 0:f.buffer)}catch(t){r(t)}};i&&!f&&y.addEventListener(m,"message",a),w.then((function(){if(!n)if(P.fileManager.getPosition(e)){var a=P.fileManager.get(e,f?void 0:i);n=!0,t(null==a?void 0:a.buffer)}else r(new E("File - ".concat(e," not found")))})).catch((function(t){r(t)})).then((function(){y.removeEventListener(m,"message",a)}))})));case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){e.fileManager.remove(t)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){t.fileManager.remove(e)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===o.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=me(t,2),n=e[0];return e[1],n===r})))||void 0===n?void 0:n[1].metadata:Object.values(t.cod.instances).map((function(t){return t.metadata}))}}],e&&xe(t.prototype,e),n&&xe(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i,u}();const Le=Oe,ke={FetchType:a,CodDicomWebServer:Oe,clearPartialFiles:Xt}})(),n})()));
|
|
21
21
|
//# sourceMappingURL=main.js.map
|