cod-dicomweb-server 1.3.14 → 1.3.15
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/dist/umd/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* cod-dicomweb-server v1.3.
|
|
3
|
+
* cod-dicomweb-server v1.3.15
|
|
4
4
|
* git+https://github.com/gradienthealth/cod-dicomweb-server.git
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Adithyan Dinesh and project contributors.
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
!function(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
|
-
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 o})),r.d(e,"isPrivateTag",(function(){return a})),r.d(e,"parsePN",(function(){return i})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return s})),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 D})),r.d(e,"parseDicomDataSetImplicit",(function(){return _})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return F})),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 H})),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 $})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return z})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return j})),r.d(e,"readSequenceItemsImplicit",(function(){return A})),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},o=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},i=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,o=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!==o&&isNaN(o)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||o&&(o<0||59<o)||a&&(a<0||999999<a)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:o,fractionalSeconds:a}}if(e)throw"invalid TM '".concat(t,"'")}function u(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 s(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),o=parseInt(t.substring(6,8),10);if(e&&!0!==u(o,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:o}}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 i(e,r){for(var n="",o=0;o<e;o++)0!==o&&(n+="/"),n+=r.call(t,a,o).toString();return n}if(!0===o(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=i(e.length/2,t.uint16):"SS"===n?r=i(e.length/2,t.int16):"UL"===n?r=i(e.length/4,t.uint32):"SL"===n?r=i(e.length/4,t.int32):"FD"===n?r=i(e.length/8,t.double):"FL"===n&&(r=i(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 o=t.elements[r];if(!0!==e.omitPrivateAttibutes||!a(r))if(o.items){for(var i=[],c=0;c<o.items.length;c++)i.push(l(o.items[c].dataSet,e));n[r]=i}else{var u=void 0;o.length<e.maxElementLength&&(u=f(t,o)),n[r]=void 0!==u?u:{dataOffset:o.dataOffset,length:o.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,o,a=r;a<e.fragments.length;a++)if(o=a,h(n=t,(o=e.fragments[o]).position+o.length-2)||h(n,o.position+o.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=[],o=0;;){n.push(e.fragments[o].offset);var a=d(t,e,o);if(void 0===a||a===e.fragments.length-1)return n;o=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,o=0;o<n;o++){var a=t.readUint32();e.basicOffsetTable.push(a)}for(var i=t.position;t.position<t.byteArray.length;){var c=y(t),u=t.readUint32();if("xfffee0dd"===c)return t.seek(u),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")),u>t.byteArray.length-t.position&&(u=t.byteArray.length-t.position),e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u)}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,o="",a=0;a<r;a++){if(0===(n=t[e+a]))return e+=r,o;o+=String.fromCharCode(n)}return o}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):(A(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,{}),_(r.dataSet,t,t.position+r.length,{vrCallback:e})),r}function A(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 o=L(t,r);e.items.push(o)}})(t,e,r)}function k(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,{}),D(r.dataSet,t,t.position+r.length)),r}function j(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=k(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 o=k(t,r);e.items.push(o)}})(t,e,r)}var T=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===T(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?j(t,n,e):4294967295===n.length?"x7fe00010"===n.tag?v(t,n,e):("UN"===n.vr?A:x)(t,n):t.seek(n.length)),n}function D(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 o=t.elements;e.position<r;){var a=I(e,t.warnings,n.untilTag);if((o[a.tag]=a).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function _(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 o=t.elements;e.position<r;){var a=S(e,n.untilTag,n.vrCallback);if((o[a.tag]=a).tag===n.untilTag)return}}function F(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}(),o=[],a={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:o};for(;n.position<n.byteArray.length;){var i=n.position,c=I(n,o);if("x0002ffff"<c.tag){n.position=i;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 H(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,o=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"!==(i=o(n)),i=function(n,o){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,o);if(e&&e.inflater)return n=e.inflater(t,o),new B(G,n,0);if(1==a){var i=r(0),c=M(t,o,t.length-o);return i=i.inflateRawSync(c),c=F(t,i.length+o),t.copy(c,0,0,o),i.copy(c,o),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return i=t.slice(o),c=pako.inflateRaw(i),(i=F(t,c.length+o)).set(t.slice(0,o),0),i.set(c,o),new B(G,i,0)}(i,n.position);(n=new E(i.byteArrayParser,i.byteArray,{})).warnings=i.warnings;try{(a?D:_)(n,i,i.byteArray.length,e)}catch(i){throw{exception:i,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,o=e;o<e+r;o++)n+=t[o].length;return n};function z(t,e,r,n,o){if(o=o||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 i=a.position;if(1===n)return M(a.byteArray,i+o[r].offset+8,o[r].length);e=W(o,r,n);for(var c=F(a.byteArray,e),u=0,s=r;s<r+n;s++)for(var f=i+o[s].offset+8,l=0;l<o[s].length;l++)c[u++]=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 o=e[t+1],a=n+1;a<r.length;a++)if(r[a].offset===o)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,o){if(n=n||e.basicOffsetTable,o=o||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(o,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return z(t,e,a,J(r,n,o,a),o)}var K=!1;function $(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):z(t,e,0,e.fragments.length)}e.default={isStringVr:o,isPrivateTag:a,parsePN:i,parseTM:c,parseDA:s,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:D,parseDicomDataSetImplicit:_,readFixedString:g,alloc:F,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:H,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:z,readPart10Header:C,readSequenceItemsExplicit:j,readSequenceItemsImplicit:A,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 o in t)e.d(n,o,function(e){return t[e]}.bind(null,o));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 o=n[t]={i:t,l:!1,exports:{}};return r[t].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var o=e[n];if(void 0!==o)return o.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 o=n.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=n[o--].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:()=>qe,FetchType:()=>a,clearPartialFiles:()=>mt,default:()=>He});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>a,RequestType:()=>i,URLType:()=>u});var e={};r.r(e),r.d(e,{DOMAIN:()=>_,FILE_EXTENSIONS:()=>F,URL_VALIDATION_STRING:()=>N});var o={};r.r(o),r.d(o,{FILE_PARTIAL_WORKER_NAME:()=>U,FILE_STREAMING_WORKER_NAME:()=>M,FILE_SYSTEM_ROUTES:()=>G,IDB_DIR_HANDLE_KEY:()=>B,THRESHOLD:()=>R});var a=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),i=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}({}),u=function(t){return t[t.THUMBNAIL=0]="THUMBNAIL",t[t.FILE=1]="FILE",t[t.OTHERS=2]="OTHERS",t}({}),s=r(915);function f(t){return f="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},f(t)}function l(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,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(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)?h(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 h(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 d(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 p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach((function(e){v(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function y(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 v(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"!=f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==f(e)?e:e+""}const g=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,"files",{})},(e=[{key:"set",value:function(t,e){this.files[t]=p(p({},e),{},{lastModified:Date.now()})}},{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,this.files[t].lastModified=Date.now())}},{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.values(this.files).reduce((function(t,e){return t+e.data.byteLength}),0)}},{key:"remove",value:function(t){try{delete this.files[t],console.log("Removed ".concat(t," from CodDicomwebServer cache"))}catch(e){console.warn("Error removing ".concat(t," from CodDicomwebServer cache:"),e)}}},{key:"purge",value:function(){var t=this,e=Object.keys(this.files),r=this.getTotalSize();e.forEach((function(e){return t.remove(e)})),console.log("Purged ".concat(r-this.getTotalSize()," bytes from CodDicomwebServer cache"))}},{key:"decacheNecessaryBytes",value:function(t,e){var r=this,n=this.getTotalSize(),o=[],a=0;return Object.entries(this.files).sort((function(t,e){var r=l(t,2)[1],n=l(e,2)[1];return r.lastModified-n.lastModified})).forEach((function(r){var n=l(r,2),i=n[0],c=n[1];a<e&&i!==t&&(o.push(i),a+=c.data.byteLength)})),o.forEach((function(t){return r.remove(t)})),console.log("Decached ".concat(n-this.getTotalSize()," bytes")),a}}])&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function b(t){return b="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},b(t)}function w(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function E(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,P(n.key),n)}}function x(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t){var e=function(t,e){if("object"!=b(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==b(e)?e:e+""}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function O(t,e,r){return e=T(e),function(t,e){if(e&&("object"==b(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,k()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}function L(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&&j(t,e)}function A(t){var e="function"==typeof Map?new Map:void 0;return A=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(k())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&j(o,r.prototype),o}(t,arguments,T(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,t)},A(t)}function k(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(k=function(){return!!t})()}function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},j(t,e)}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}var I=function(t){function e(){return S(this,e),O(this,e,arguments)}return L(e,t),x(e)}(A(Error)),D=function(t){function e(t,r){var n;return S(this,e),w(n=O(this,e,[t]),"error",void 0),w(n,"message",void 0),n.message=t,n.error=r,n}return L(e,t),x(e)}(A(Event)),_="https://storage.googleapis.com",F=[".tar",".zip"],N="/dicomweb/",U="filePartial",M="fileStreaming",R=1e4,B="indexed_db_directory_handle_key",G={Partial:"partial"};const C={Enums:t,url:e,dataRetrieval:o};function q(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,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return H(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)?H(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 H(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 W(t,e){if(t.includes(C.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],o=n.split("/studies")[0],a=o.split("/"),c=a[0],u=a.slice(1).join("/"),s=n.split(o+"/")[1].split("/"),f=s[1],l=s[3],h="",d=1;switch(!0){case s.includes("thumbnail"):r=i.THUMBNAIL;break;case s.includes("metadata"):s.includes("instances")?(h=s[5],r=i.INSTANCE_METADATA):r=i.SERIES_METADATA;break;case s.includes("frames"):h=s[5],d=+s[7],r=i.FRAME;break;default:throw new I("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:u,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function z(t,e,r,n){var o,a;if(!t||null===(o=t.cod)||void 0===o||!o.instances)throw new I("Invalid seriesMetadata provided.");if(null==r)throw new I("Frame index is required.");var i,c=n.domain,u=n.bucketName,s=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;i="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(a=Object.entries(t.cod.instances).find((function(t){var r=q(t,2),n=r[0];r[1];return n===e})))||void 0===a?void 0:a[1];if(!l)return{thumbnailUrl:i};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var o=t,a=C.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(a){o=t.split(a)[0]+a}var i=o.split("studies/")[1];return o="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(i),o}(p||y,c,u,s),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,E=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],E=!0);var x=v.start_byte,P=v.end_byte;return{url:g,startByte:void 0!==h?x+h:x,endByte:void 0!==d?x+d:P,thumbnailUrl:i,isMultiframe:E}}function Y(t){var e=t.domain,r=void 0===e?C.url.DOMAIN:e,n=t.bucketName,o=t.bucketPrefix,a=t.studyInstanceUID,i=t.seriesInstanceUID;if(n&&o&&a&&i)return"".concat(r,"/").concat(n,"/").concat(o,"/studies/").concat(a,"/series/").concat(i,"/metadata.json")}function J(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function V(t,e){let r;return(n,o)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=J(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>o(t.transaction(e,n).objectStore(e))))}let K;function $(){return K||(K=V("keyval-store","keyval")),K}function Q(t,e=$()){return e("readonly",(e=>J(e.get(t))))}function Z(t){return Z="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},Z(t)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Z(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Z(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 tt(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,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}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 rt(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function nt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){rt(a,n,o,i,c,"next",t)}function c(t){rt(a,n,o,i,c,"throw",t)}i(void 0)}))}}function ot(t){var e,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new at(e.call(t));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function at(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return at=function(t){this.s=t,this.n=t.next},at.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new at(t)}var it;function ct(){return ut.apply(this,arguments)}function ut(){return(ut=nt(X().mark((function t(){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,it){t.next=5;break}return t.next=4,Q(B);case 4:it=t.sent;case 5:if(it){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:it=t.sent;case 9:return t.abrupt("return",it);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 st(t,e){return ft.apply(this,arguments)}function ft(){return ft=nt(X().mark((function t(e,r){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),ft.apply(this,arguments)}function lt(t,e){return ht.apply(this,arguments)}function ht(){return ht=nt(X().mark((function t(e,r){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),ht.apply(this,arguments)}function dt(t,e){return pt.apply(this,arguments)}function pt(){return pt=nt(X().mark((function t(e,r){var n,o,a,i,c,u=arguments;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:o=r.split("/"),a=e,t.prev=5,i=0;case 7:if(!(i<o.length-1)){t.next=14;break}return t.next=10,a.getDirectoryHandle(o[i],{create:!0});case 10:a=t.sent;case 11:i++,t.next=7;break;case 14:if(c=o.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",st(a,c));case 19:return t.abrupt("return",lt(a,c).catch(nt(X().mark((function t(){var i,c,u;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!o.includes(G.Partial)){t.next=23;break}t.prev=2,o.splice(o.findIndex((function(t){return t===G.Partial})),1),a=e,i=0;case 6:if(!(i<o.length-1)){t.next=13;break}return t.next=9,a.getDirectoryHandle(o[i],{create:!0});case 9:a=t.sent;case 10:i++,t.next=6;break;case 13:return c=o.at(-1).split("_")[0]+".tar",t.next=16,lt(a,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),pt.apply(this,arguments)}function yt(t,e,r){return vt.apply(this,arguments)}function vt(){return vt=nt(X().mark((function t(e,r,n){var o,a,i,c,u,s,f,l=arguments;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,a=r.split("/"),i=e,c=0;case 5:if(!(c<a.length-1)){t.next=12;break}return t.next=8,i.getDirectoryHandle(a[c],{create:!0});case 8:i=t.sent;case 9:c++,t.next=5;break;case 12:return u=a.at(-1),t.next=15,i.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!o){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),vt.apply(this,arguments)}function mt(){return gt.apply(this,arguments)}function gt(){return gt=nt(X().mark((function t(){var e;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=nt(X().mark((function t(r){var n,o,a,i,c,u;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!1,o=!1,t.prev=2,i=X().mark((function t(){var n,o,a;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=tt(u.value,2),o=n[0],"directory"!==(a=n[1]).kind){t.next=9;break}if(o.toLowerCase()!==G.Partial){t.next=7;break}return t.next=5,r.removeEntry(o,{recursive:!0}).catch((function(t){return console.warn("Failed to remove ".concat(o,":"),t)}));case 5:t.next=9;break;case 7:return t.next=9,e(a);case 9:case"end":return t.stop()}}),t)})),c=ot(r.entries());case 5:return t.next=7,c.next();case 7:if(!(n=!(u=t.sent).done)){t.next=12;break}return t.delegateYield(i(),"t0",9);case 9:n=!1,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(2),o=!0,a=t.t1;case 18:if(t.prev=18,t.prev=19,!n||null==c.return){t.next=23;break}return t.next=23,c.return();case 23:if(t.prev=23,!o){t.next=26;break}throw a;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})));return function(e){return t.apply(this,arguments)}}(),t.prev=1,t.next=4,e(it);case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),console.warn("Error clearing partial files: ".concat(t.t0.message));case 9:case"end":return t.stop()}}),t,null,[[1,6]])}))),gt.apply(this,arguments)}function bt(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=tt(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),o=n[0],a=(n[1],n[2]);return"".concat(r,"/").concat(o,"/").concat(a)}function wt(t){return"".concat(bt(t),"/").concat(t.split("series/")[1])}function Et(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(bt(t),"/").concat(G.Partial,"/").concat(r).concat(n,".dcm")}function xt(t){return"".concat(bt(t),"/metadata.json")}function Pt(t){return Pt="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},Pt(t)}function St(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */St=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Pt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Pt(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 Ot(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}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,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return At(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)?At(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 At(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 kt(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,jt(n.key),n)}}function jt(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Pt(e)?e:e+""}var Tt=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=jt(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,e){var r,n=t.cod,o=Lt((null===(r=e.match(/studies\/(.*?)\/metadata/))||void 0===r?void 0:r[1].split("/"))||[],3),a=o[0],i=(o[1],o[2]);if(n&&a&&i)for(var c in n.instances){var u=n.instances[c];u.metadata.DeidStudyInstanceUID={Value:[a]},u.metadata.DeidSeriesInstanceUID={Value:[i]},u.metadata.DeidSopInstanceUID={Value:[c]}}else console.warn("Missing required metadata properties: cod, studyUID, or seriesUID")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=St().mark((function t(e,r){var n,o,a,i,c,u=this;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Y(e)){t.next=3;break}throw new I("Error creating metadata json url");case 3:if(!(o=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,o;case 7:case 21:return t.abrupt("return",t.sent);case 8:return t.next=10,ct();case 10:return a=t.sent,i=xt(n),t.next=14,dt(a,i,{isJson:!0});case 14:if(!(c=t.sent)){t.next=17;break}return t.abrupt("return",c);case 17:return t.prev=17,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new I("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return u.addDeidMetadata(t,n),yt(a,i,t,!0).then((function(){return t}))})),t.next=21,this.metadataPromises[n];case 24:throw t.prev=24,t.t0=t.catch(17),console.error(t.t0),t.t0;case 28:case"end":return t.stop()}}),t,this,[[17,24]])})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var a=n.apply(t,e);function i(t){Ot(a,r,o,i,c,"next",t)}function c(t){Ot(a,r,o,i,c,"throw",t)}i(void 0)}))},function(t,e){return o.apply(this,arguments)})}],e&&kt(t.prototype,e),r&&kt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();const It=Tt;function Dt(t){return Dt="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},Dt(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,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Dt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Dt(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Nt(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,Mt(n.key),n)}}function Ut(t,e,r){return(e=Mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mt(t){var e=function(t,e){if("object"!=Dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Dt(e)?e:e+""}const Rt=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),Ut(this,"loaderRegistry",{}),Ut(this,"listenerCallback",(function(t,r,n){var o,a=null===(o=e.loaderRegistry[t])||void 0===o?void 0:o.listeners[r];a&&a.forEach((function(t){return t({data:n})}))}))},e=[{key:"register",value:function(t,e){try{if(!e)throw new I("Loader object for ".concat(t," is not provided"));this.loaderRegistry[t]={loaderObject:e,listeners:{}}}catch(t){throw console.warn(t),new I("throws")}}},{key:"executeTask",value:(n=_t().mark((function t(e,r,n){var o,a,i=this;return _t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(o=this.loaderRegistry[e])||void 0===o?void 0:o.loaderObject){t.next=3;break}throw new I("Loader ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,a[r](n,(function(t){return i.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 I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var a=n.apply(t,e);function i(t){Ft(a,r,o,i,c,"next",t)}function c(t){Ft(a,r,o,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return o.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&&Nt(t.prototype,e),r&&Nt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();
|
|
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 a})),r.d(e,"isPrivateTag",(function(){return o})),r.d(e,"parsePN",(function(){return i})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return s})),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 D})),r.d(e,"parseDicomDataSetImplicit",(function(){return _})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return F})),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 H})),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 $})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return z})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return j})),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},a=function(t){return n[t]},o=function(t){if(t=parseInt(t[4],16),isNaN(t))throw"dicomParser.isPrivateTag: cannot parse last character of group";return t%2==1},i=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,a=6<=t.length?parseInt(t.substring(4,6),10):void 0,o=(o=8<=t.length?t.substring(7,13):void 0)?parseInt(o,10)*Math.pow(10,6-o.length):void 0;if(e&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||void 0!==o&&isNaN(o)||r<0||23<r||n&&(n<0||59<n)||a&&(a<0||59<a)||o&&(o<0||999999<o)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:a,fractionalSeconds:o}}if(e)throw"invalid TM '".concat(t,"'")}function u(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 s(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),a=parseInt(t.substring(6,8),10);if(e&&!0!==u(a,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:a}}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,o=e.tag;function i(e,r){for(var n="",a=0;a<e;a++)0!==a&&(n+="/"),n+=r.call(t,o,a).toString();return n}if(!0===a(n))r=t.string(o);else{if("AT"===n){var c=t.uint32(o);return void 0===c?void 0:"x".concat((c=c<0?4294967295+c+1:c).toString(16).toUpperCase())}"US"===n?r=i(e.length/2,t.uint16):"SS"===n?r=i(e.length/2,t.int16):"UL"===n?r=i(e.length/4,t.uint32):"SL"===n?r=i(e.length/4,t.int32):"FD"===n?r=i(e.length/8,t.double):"FL"===n&&(r=i(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 a=t.elements[r];if(!0!==e.omitPrivateAttibutes||!o(r))if(a.items){for(var i=[],c=0;c<a.items.length;c++)i.push(l(a.items[c].dataSet,e));n[r]=i}else{var u=void 0;a.length<e.maxElementLength&&(u=f(t,a)),n[r]=void 0!==u?u:{dataOffset:a.dataOffset,length:a.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,a,o=r;o<e.fragments.length;o++)if(a=o,h(n=t,(a=e.fragments[a]).position+a.length-2)||h(n,a.position+a.length-3))return o}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=[],a=0;;){n.push(e.fragments[a].offset);var o=d(t,e,a);if(void 0===o||o===e.fragments.length-1)return n;a=o+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,a=0;a<n;a++){var o=t.readUint32();e.basicOffsetTable.push(o)}for(var i=t.position;t.position<t.byteArray.length;){var c=y(t),u=t.readUint32();if("xfffee0dd"===c)return t.seek(u),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")),u>t.byteArray.length-t.position&&(u=t.byteArray.length-t.position),e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u)}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,a="",o=0;o<r;o++){if(0===(n=t[e+o]))return e+=r,a;a+=String.fromCharCode(n)}return a}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)||o(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(t,n):t.seek(n.length):(k(t,n,r),o(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,{}),_(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 a=L(t,r);e.items.push(a)}})(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,{}),D(r.dataSet,t,t.position+r.length)),r}function j(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 a=A(t,r);e.items.push(a)}})(t,e,r)}var T=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===T(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?j(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 D(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 a=t.elements;e.position<r;){var o=I(e,t.warnings,n.untilTag);if((a[o.tag]=o).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function _(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 a=t.elements;e.position<r;){var o=S(e,n.untilTag,n.vrCallback);if((a[o.tag]=o).tag===n.untilTag)return}}function F(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}(),a=[],o={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:a};for(;n.position<n.byteArray.length;){var i=n.position,c=I(n,a);if("x0002ffff"<c.tag){n.position=i;break}c.parser=G,o[c.tag]=c}return(t=new E(n.byteArrayParser,n.byteArray,o)).warnings=n.warnings,t.position=n.position,t}()}var q="1.2.840.10008.1.2.2";function H(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,a=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 o(n){var o="1.2.840.10008.1.2"!==(i=a(n)),i=function(n,a){var o="[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,a);if(e&&e.inflater)return n=e.inflater(t,a),new B(G,n,0);if(1==o){var i=r(0),c=M(t,a,t.length-a);return i=i.inflateRawSync(c),c=F(t,i.length+a),t.copy(c,0,0,a),i.copy(c,a),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return i=t.slice(a),c=pako.inflateRaw(i),(i=F(t,c.length+a)).set(t.slice(0,a),0),i.set(c,a),new B(G,i,0)}(i,n.position);(n=new E(i.byteArrayParser,i.byteArray,{})).warnings=i.warnings;try{(o?D:_)(n,i,i.byteArray.length,e)}catch(i){throw{exception:i,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),o(n))}var W=function(t,e,r){for(var n=0,a=e;a<e+r;a++)n+=t[a].length;return n};function z(t,e,r,n,a){if(a=a||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 o=new B(t.byteArrayParser,t.byteArray,e.dataOffset);if("xfffee000"!==(e=O(o)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";o.seek(e.length);var i=o.position;if(1===n)return M(o.byteArray,i+a[r].offset+8,a[r].length);e=W(a,r,n);for(var c=F(o.byteArray,e),u=0,s=r;s<r+n;s++)for(var f=i+a[s].offset+8,l=0;l<a[s].length;l++)c[u++]=o.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 a=e[t+1],o=n+1;o<r.length;o++)if(r[o].offset===a)return o-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,a){if(n=n||e.basicOffsetTable,a=a||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 o=n[r];if(void 0===(o=Y(a,o)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return z(t,e,o,J(r,n,a,o),a)}var K=!1;function $(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):z(t,e,0,e.fragments.length)}e.default={isStringVr:a,isPrivateTag:o,parsePN:i,parseTM:c,parseDA:s,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:D,parseDicomDataSetImplicit:_,readFixedString:g,alloc:F,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:H,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:z,readPart10Header:C,readSequenceItemsExplicit:j,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 a in t)e.d(n,a,function(e){return t[e]}.bind(null,a));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 a=n[t]={i:t,l:!1,exports:{}};return r[t].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.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 a=n.length-1;a>-1&&(!t||!/^http(s?):/.test(t));)t=n[a--].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:()=>He,FetchType:()=>o,clearPartialFiles:()=>gt,default:()=>We});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>o,RequestType:()=>i,URLType:()=>u});var e={};r.r(e),r.d(e,{DOMAIN:()=>_,FILE_EXTENSIONS:()=>F,URL_VALIDATION_STRING:()=>N});var a={};r.r(a),r.d(a,{FILE_PARTIAL_WORKER_NAME:()=>U,FILE_STREAMING_WORKER_NAME:()=>M,FILE_SYSTEM_ROUTES:()=>G,IDB_DIR_HANDLE_KEY:()=>B,THRESHOLD:()=>R});var o=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),i=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}({}),u=function(t){return t[t.THUMBNAIL=0]="THUMBNAIL",t[t.FILE=1]="FILE",t[t.OTHERS=2]="OTHERS",t}({}),s=r(915);function f(t){return f="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},f(t)}function l(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,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(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)?h(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 h(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 d(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 p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach((function(e){v(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function y(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 v(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"!=f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==f(e)?e:e+""}const g=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,"files",{})},(e=[{key:"set",value:function(t,e){this.files[t]=p(p({},e),{},{lastModified:Date.now()})}},{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,this.files[t].lastModified=Date.now())}},{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.values(this.files).reduce((function(t,e){return t+e.data.byteLength}),0)}},{key:"remove",value:function(t){try{delete this.files[t],console.log("Removed ".concat(t," from CodDicomwebServer cache"))}catch(e){console.warn("Error removing ".concat(t," from CodDicomwebServer cache:"),e)}}},{key:"purge",value:function(){var t=this,e=Object.keys(this.files),r=this.getTotalSize();e.forEach((function(e){return t.remove(e)})),console.log("Purged ".concat(r-this.getTotalSize()," bytes from CodDicomwebServer cache"))}},{key:"decacheNecessaryBytes",value:function(t,e){var r=this,n=this.getTotalSize(),a=[],o=0;return Object.entries(this.files).sort((function(t,e){var r=l(t,2)[1],n=l(e,2)[1];return r.lastModified-n.lastModified})).forEach((function(r){var n=l(r,2),i=n[0],c=n[1];o<e&&i!==t&&(a.push(i),o+=c.data.byteLength)})),a.forEach((function(t){return r.remove(t)})),console.log("Decached ".concat(n-this.getTotalSize()," bytes")),o}}])&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function b(t){return b="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},b(t)}function w(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function E(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,P(n.key),n)}}function x(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t){var e=function(t,e){if("object"!=b(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==b(e)?e:e+""}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function O(t,e,r){return e=T(e),function(t,e){if(e&&("object"==b(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,A()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}function L(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&&j(t,e)}function k(t){var e="function"==typeof Map?new Map:void 0;return k=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(A())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var a=new(t.bind.apply(t,n));return r&&j(a,r.prototype),a}(t,arguments,T(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,t)},k(t)}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},j(t,e)}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}var I=function(t){function e(){return S(this,e),O(this,e,arguments)}return L(e,t),x(e)}(k(Error)),D=function(t){function e(t,r){var n;return S(this,e),w(n=O(this,e,[t]),"error",void 0),w(n,"message",void 0),n.message=t,n.error=r,n}return L(e,t),x(e)}(k(Event)),_="https://storage.googleapis.com",F=[".tar",".zip"],N="/dicomweb/",U="filePartial",M="fileStreaming",R=1e4,B="indexed_db_directory_handle_key",G={Partial:"partial"};const C={Enums:t,url:e,dataRetrieval:a};function q(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,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return H(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)?H(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 H(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 W(t,e){if(t.includes(C.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],a=n.split("/studies")[0],o=a.split("/"),c=o[0],u=o.slice(1).join("/"),s=n.split(a+"/")[1].split("/"),f=s[1],l=s[3],h="",d=1;switch(!0){case s.includes("thumbnail"):r=i.THUMBNAIL;break;case s.includes("metadata"):s.includes("instances")?(h=s[5],r=i.INSTANCE_METADATA):r=i.SERIES_METADATA;break;case s.includes("frames"):h=s[5],d=+s[7],r=i.FRAME;break;default:throw new I("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:u,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function z(t,e,r,n){var a,o;if(!t||null===(a=t.cod)||void 0===a||!a.instances)throw new I("Invalid seriesMetadata provided.");if(null==r)throw new I("Frame index is required.");var i,c=n.domain,u=n.bucketName,s=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;i="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(o=Object.entries(t.cod.instances).find((function(t){var r=q(t,2),n=r[0];r[1];return n===e})))||void 0===o?void 0:o[1];if(!l)return{thumbnailUrl:i};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var a=t,o=C.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(o){a=t.split(o)[0]+o}var i=a.split("studies/")[1];return a="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(i),a}(p||y,c,u,s),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,E=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],E=!0);var x=v.start_byte,P=v.end_byte;return{url:g,startByte:void 0!==h?x+h:x,endByte:void 0!==d?x+d:P,thumbnailUrl:i,isMultiframe:E}}function Y(t){var e=t.domain,r=void 0===e?C.url.DOMAIN:e,n=t.bucketName,a=t.bucketPrefix,o=t.studyInstanceUID,i=t.seriesInstanceUID;if(n&&a&&o&&i)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(o,"/series/").concat(i,"/metadata.json")}function J(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function V(t,e){let r;return(n,a)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=J(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>a(t.transaction(e,n).objectStore(e))))}let K;function $(){return K||(K=V("keyval-store","keyval")),K}function Q(t,e=$()){return e("readonly",(e=>J(e.get(t))))}function Z(t){return Z="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},Z(t)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Z(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Z(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 tt(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,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}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 rt(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function nt(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(t){rt(o,n,a,i,c,"next",t)}function c(t){rt(o,n,a,i,c,"throw",t)}i(void 0)}))}}function at(t){var e,r,n,a=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);a--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new ot(e.call(t));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function ot(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return ot=function(t){this.s=t,this.n=t.next},ot.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new ot(t)}var it;function ct(){return ut.apply(this,arguments)}function ut(){return(ut=nt(X().mark((function t(){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,it){t.next=5;break}return t.next=4,Q(B);case 4:it=t.sent;case 5:if(it){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:it=t.sent;case 9:return t.abrupt("return",it);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 st(t,e){return ft.apply(this,arguments)}function ft(){return ft=nt(X().mark((function t(e,r){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),ft.apply(this,arguments)}function lt(t,e){return ht.apply(this,arguments)}function ht(){return ht=nt(X().mark((function t(e,r){return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),ht.apply(this,arguments)}function dt(t,e){return pt.apply(this,arguments)}function pt(){return pt=nt(X().mark((function t(e,r){var n,a,o,i,c,u=arguments;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:a=r.split("/"),o=e,t.prev=5,i=0;case 7:if(!(i<a.length-1)){t.next=14;break}return t.next=10,o.getDirectoryHandle(a[i],{create:!0});case 10:o=t.sent;case 11:i++,t.next=7;break;case 14:if(c=a.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",st(o,c));case 19:return t.abrupt("return",lt(o,c).catch(nt(X().mark((function t(){var i,c,u;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!a.includes(G.Partial)){t.next=23;break}t.prev=2,a.splice(a.findIndex((function(t){return t===G.Partial})),1),o=e,i=0;case 6:if(!(i<a.length-1)){t.next=13;break}return t.next=9,o.getDirectoryHandle(a[i],{create:!0});case 9:o=t.sent;case 10:i++,t.next=6;break;case 13:return c=a.at(-1).split("_")[0]+".tar",t.next=16,lt(o,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),pt.apply(this,arguments)}function yt(t,e,r){return vt.apply(this,arguments)}function vt(){return vt=nt(X().mark((function t(e,r,n){var a,o,i,c,u,s,f,l=arguments;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,o=r.split("/"),i=e,c=0;case 5:if(!(c<o.length-1)){t.next=12;break}return t.next=8,i.getDirectoryHandle(o[c],{create:!0});case 8:i=t.sent;case 9:c++,t.next=5;break;case 12:return u=o.at(-1),t.next=15,i.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!a){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),vt.apply(this,arguments)}function mt(t,e){try{var r=new Blob([e],{type:"application/x-tar"}),n=URL.createObjectURL(r),a=document.createElement("a");return a.href=n,a.download=t,a.click(),URL.revokeObjectURL(n),!0}catch(e){return console.warn("Error downloading file - ".concat(t,": ")+e.message),!1}}function gt(){return bt.apply(this,arguments)}function bt(){return bt=nt(X().mark((function t(){var e;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=nt(X().mark((function t(r){var n,a,o,i,c,u;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!1,a=!1,t.prev=2,i=X().mark((function t(){var n,a,o;return X().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=tt(u.value,2),a=n[0],"directory"!==(o=n[1]).kind){t.next=9;break}if(a.toLowerCase()!==G.Partial){t.next=7;break}return t.next=5,r.removeEntry(a,{recursive:!0}).catch((function(t){return console.warn("Failed to remove ".concat(a,":"),t)}));case 5:t.next=9;break;case 7:return t.next=9,e(o);case 9:case"end":return t.stop()}}),t)})),c=at(r.entries());case 5:return t.next=7,c.next();case 7:if(!(n=!(u=t.sent).done)){t.next=12;break}return t.delegateYield(i(),"t0",9);case 9:n=!1,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(2),a=!0,o=t.t1;case 18:if(t.prev=18,t.prev=19,!n||null==c.return){t.next=23;break}return t.next=23,c.return();case 23:if(t.prev=23,!a){t.next=26;break}throw o;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})));return function(e){return t.apply(this,arguments)}}(),t.prev=1,t.next=4,e(it);case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),console.warn("Error clearing partial files: ".concat(t.t0.message));case 9:case"end":return t.stop()}}),t,null,[[1,6]])}))),bt.apply(this,arguments)}function wt(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=tt(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),a=n[0],o=(n[1],n[2]);return"".concat(r,"/").concat(a,"/").concat(o)}function Et(t){return"".concat(wt(t),"/").concat(t.split("series/")[1])}function xt(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(wt(t),"/").concat(G.Partial,"/").concat(r).concat(n,".dcm")}function Pt(t){return"".concat(wt(t),"/metadata.json")}function St(t){return St="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},St(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,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==St(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(St(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 Lt(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function kt(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,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return At(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)?At(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 At(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 jt(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,Tt(n.key),n)}}function Tt(t){var e=function(t,e){if("object"!=St(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=St(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==St(e)?e:e+""}var It=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=Tt(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,e){var r,n=t.cod,a=kt((null===(r=e.match(/studies\/(.*?)\/metadata/))||void 0===r?void 0:r[1].split("/"))||[],3),o=a[0],i=(a[1],a[2]);if(n&&o&&i)for(var c in n.instances){var u=n.instances[c];u.metadata.DeidStudyInstanceUID={Value:[o]},u.metadata.DeidSeriesInstanceUID={Value:[i]},u.metadata.DeidSopInstanceUID={Value:[c]}}else console.warn("Missing required metadata properties: cod, studyUID, or seriesUID")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=Ot().mark((function t(e,r){var n,a,o,i,c,u=this;return Ot().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Y(e)){t.next=3;break}throw new I("Error creating metadata json url");case 3:if(!(a=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,a;case 7:case 21:return t.abrupt("return",t.sent);case 8:return t.next=10,ct();case 10:return o=t.sent,i=Pt(n),t.next=14,dt(o,i,{isJson:!0});case 14:if(!(c=t.sent)){t.next=17;break}return t.abrupt("return",c);case 17:return t.prev=17,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new I("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return u.addDeidMetadata(t,n),yt(o,i,t,!0).then((function(){return t}))})),t.next=21,this.metadataPromises[n];case 24:throw t.prev=24,t.t0=t.catch(17),console.error(t.t0),t.t0;case 28:case"end":return t.stop()}}),t,this,[[17,24]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){Lt(o,r,a,i,c,"next",t)}function c(t){Lt(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e){return a.apply(this,arguments)})}],e&&jt(t.prototype,e),r&&jt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();const Dt=It;function _t(t){return _t="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(t)}function Ft(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ft=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_t(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_t(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 Nt(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Ut(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,Rt(n.key),n)}}function Mt(t,e,r){return(e=Rt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rt(t){var e=function(t,e){if("object"!=_t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_t(e)?e:e+""}const Bt=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),Mt(this,"loaderRegistry",{}),Mt(this,"listenerCallback",(function(t,r,n){var a,o=null===(a=e.loaderRegistry[t])||void 0===a?void 0:a.listeners[r];o&&o.forEach((function(t){return t({data:n})}))}))},e=[{key:"register",value:function(t,e){try{if(!e)throw new I("Loader object for ".concat(t," is not provided"));this.loaderRegistry[t]={loaderObject:e,listeners:{}}}catch(t){throw console.warn(t),new I("throws")}}},{key:"executeTask",value:(n=Ft().mark((function t(e,r,n){var a,o,i=this;return Ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=null===(a=this.loaderRegistry[e])||void 0===a?void 0:a.loaderObject){t.next=3;break}throw new I("Loader ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,o[r](n,(function(t){return i.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 I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){Nt(o,r,a,i,c,"next",t)}function c(t){Nt(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.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&&Ut(t.prototype,e),r&&Ut(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2019 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
*/
|
|
20
|
-
const Bt=Symbol("Comlink.proxy"),Gt=Symbol("Comlink.endpoint"),Ct=Symbol("Comlink.releaseProxy"),qt=Symbol("Comlink.finalizer"),Ht=Symbol("Comlink.thrown"),Wt=t=>"object"==typeof t&&null!==t||"function"==typeof t,zt=new Map([["proxy",{canHandle:t=>Wt(t)&&t[Bt],serialize(t){const{port1:e,port2:r}=new MessageChannel;return Yt(t,e),[r,[r]]},deserialize:t=>(t.start(),Vt(t))}],["throw",{canHandle:t=>Wt(t)&&Ht 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 Yt(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(o){if(!o||!o.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,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:a,type:i,path:c}=Object.assign({path:[]},o.data),u=(o.data.argumentList||[]).map(ne);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(i){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=ne(o.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[Bt]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;Yt(t,r),s=function(t,e){return ee.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[Ht]:0}}Promise.resolve(s).catch((t=>({value:t,[Ht]:0}))).then((r=>{const[o,c]=re(r);e.postMessage(Object.assign(Object.assign({},o),{id:a}),c),"RELEASE"===i&&(e.removeEventListener("message",n),Jt(e),qt in t&&"function"==typeof t[qt]&&t[qt]())})).catch((t=>{const[r,n]=re({value:new TypeError("Unserializable return value"),[Ht]:0});e.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),e.start&&e.start()}function Jt(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Vt(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)}})),Xt(t,r,[],e)}function Kt(t){if(t)throw new Error("Proxy has been released and is not useable")}function $t(t){return oe(t,new Map,{type:"RELEASE"}).then((()=>{Jt(t)}))}const Qt=new WeakMap,Zt="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Qt.get(t)||0)-1;Qt.set(t,e),0===e&&$t(t)}));function Xt(t,e,r=[],n=function(){}){let o=!1;const a=new Proxy(n,{get(n,i){if(Kt(o),i===Ct)return()=>{!function(t){Zt&&Zt.unregister(t)}(a),$t(t),e.clear(),o=!0};if("then"===i){if(0===r.length)return{then:()=>a};const n=oe(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(ne);return n.then.bind(n)}return Xt(t,e,[...r,i])},set(n,a,i){Kt(o);const[c,u]=re(i);return oe(t,e,{type:"SET",path:[...r,a].map((t=>t.toString())),value:c},u).then(ne)},apply(n,a,i){Kt(o);const c=r[r.length-1];if(c===Gt)return oe(t,e,{type:"ENDPOINT"}).then(ne);if("bind"===c)return Xt(t,e,r.slice(0,-1));const[u,s]=te(i);return oe(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(ne)},construct(n,a){Kt(o);const[i,c]=te(a);return oe(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:i},c).then(ne)}});return function(t,e){const r=(Qt.get(e)||0)+1;Qt.set(e,r),Zt&&Zt.register(t,e,t)}(a,t),a}function te(t){const e=t.map(re);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const ee=new WeakMap;function re(t){for(const[e,r]of zt)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},ee.get(t)||[]]}function ne(t){switch(t.type){case"HANDLER":return zt.get(t.name).deserialize(t.value);case"RAW":return t.value}}function oe(t,e,r,n){return new Promise((o=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(a,o),t.start&&t.start(),t.postMessage(Object.assign({id:a},r),n)}))}function ae(t){return ae="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},ae(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,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ae(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ae(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 ce(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ue(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 se(t){var e=function(t,e){if("object"!=ae(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ae(e)?e:e+""}const fe=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=se(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 I("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:Vt(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ie().mark((function t(e,r,n){var o,a;return ie().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(o=this.workerRegistry[e])||void 0===o?void 0:o.instance){t.next=3;break}throw new I("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 I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var a=n.apply(t,e);function i(t){ce(a,r,o,i,c,"next",t)}function c(t){ce(a,r,o,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return o.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&&ue(t.prototype,e),r&&ue(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function le(t){return le="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},le(t)}function he(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */he=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==le(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(le(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 de(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function pe(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,ve(n.key),n)}}function ye(t,e,r){return(e=ve(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ve(t){var e=function(t,e){if("object"!=le(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=le(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==le(e)?e:e+""}var me=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),ye(this,"dataRetriever",void 0),ye(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new Rt,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new fe,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=ye(ye({},c.WORKER,fe),c.REQUEST,Rt);if(!(t in e))throw new I("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=he().mark((function t(e,r,n){return he().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)})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var a=n.apply(t,e);function i(t){de(a,r,o,i,c,"next",t)}function c(t){de(a,r,o,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return o.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&&pe(t.prototype,e),r&&pe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}());function ge(){return me}function be(t){return be="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},be(t)}function we(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */we=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==be(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(be(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 Ee(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}Object.freeze(me);var xe={partial:function(t,e){return(r=we().mark((function r(){var n,o,a,i,c,u,s;return we().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,o=t.offsets,a=t.headers,i=t.directoryHandle,null!=o&&o.startByte&&null!=o&&o.endByte&&(a.Range="bytes=".concat(o.startByte,"-").concat(o.endByte-1)),c=Et(n,o),!i){r.next=11;break}return r.next=6,dt(i,c,{offsets:o,isJson:!1});case 6:if(null==(u=r.sent)||!u.byteLength){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:o}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:a}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:o}),i&&yt(i,c,t),r})).catch((function(t){throw new I("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,o){var a=r.apply(t,e);function i(t){Ee(a,n,o,i,c,"next",t)}function c(t){Ee(a,n,o,i,c,"throw",t)}i(void 0)}))})();var r}};const Pe=xe;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 Oe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Oe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Se(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],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,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 Le(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 Ae(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Le(Object(r),!0).forEach((function(e){ke(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Le(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ke(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 je(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var Te={stream:function(t,e){return(r=Oe().mark((function r(){var n,o,a,i,c,u,s,f,l,h,d,p,y,v,m,g,b,w,E,x,P;return Oe().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,o=t.headers,a=t.useSharedArrayBuffer,i=t.directoryHandle,c=new AbortController,u=null,s=null,r.prev=4,l=wt(n),!i){r.next=15;break}return r.next=9,dt(i,l,{isJson:!1});case 9:if(null==(h=r.sent)||!h.byteLength){r.next=15;break}return d=h.byteLength,p=new Uint8Array(h),e({url:n,position:d,fileArraybuffer:p,totalLength:d}),r.abrupt("return",p);case 15:return r.next=17,fetch(n,{headers:Ae({},o),signal:c.signal});case 17:if((y=r.sent).ok){r.next=20;break}throw new I("HTTP error! status: ".concat(y.status));case 20:if(v=null===(f=y.body)||void 0===f?void 0:f.getReader()){r.next=23;break}throw new I("Failed to get reader from response body");case 23:return g=!1,b=parseInt(y.headers.get("Content-Length")||"0",10),r.next=27,v.read();case 27:if(w=r.sent,g=w.done,w.value){r.next=31;break}throw new I("The fetched chunks does not have value");case 31:if(g){r.next=50;break}E=w.value.length,a?(u=new SharedArrayBuffer(b),s=new Uint8Array(u)):s=new Uint8Array(b),s.set(w.value),e({url:n,position:E,fileArraybuffer:s,totalLength:b});case 36:if(g){r.next=49;break}return r.next=39,v.read();case 39:if(!(m=r.sent).done){r.next=43;break}return g=!0,r.abrupt("continue",36);case 43:x=m.value,s.set(x,E),E+=x.length,e({isAppending:!0,url:n,position:E,chunk:a?void 0:x,totalLength:b}),r.next=36;break;case 49:i&&yt(i,l,s.slice().buffer);case 50:return r.abrupt("return",s);case 53:throw r.prev=53,r.t0=r.catch(4),P=new I("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 58:return r.prev=58,u=null,s=null,c.abort(),r.finish(58);case 63:case"end":return r.stop()}}),r,null,[[4,53,58,63]])})),function(){var t=this,e=arguments;return new Promise((function(n,o){var a=r.apply(t,e);function i(t){je(a,n,o,i,c,"next",t)}function c(t){je(a,n,o,i,c,"throw",t)}i(void 0)}))})();var r}};const Ie=Te;function De(t){return De="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},De(t)}function _e(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,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Fe(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)?Fe(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 Fe(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 Ne(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ne=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==De(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(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(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(De(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},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),j(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 o=n.arg;j(r)}return o}}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 Ue(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Me(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){Ue(a,n,o,i,c,"next",t)}function c(t){Ue(a,n,o,i,c,"throw",t)}i(void 0)}))}}function Re(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,Ge(n.key),n)}}function Be(t,e,r){return(e=Ge(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ge(t){var e=function(t,e){if("object"!=De(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=De(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==De(e)?e:e+""}var Ce=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),Be(this,"filePromises",{}),Be(this,"files",{}),Be(this,"options",{maxCacheSize:4294967296,domain:C.url.DOMAIN,enableOPFSCache:!1}),Be(this,"fileManager",void 0),Be(this,"metadataManager",void 0),Be(this,"seriesUidFileUrls",{}),Be(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Be(this,"getOptions",(function(){return e.options}));var o=n.maxCacheSize,a=n.domain,i=n.disableWorker,u=n.enableOPFSCache;this.options.maxCacheSize=o||this.options.maxCacheSize,this.options.domain=a||this.options.domain,this.options.enableOPFSCache=!!u;var s=C.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=C.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new g,this.metadataManager=new It,i&&ge().setDataRetrieverMode(c.REQUEST),function(t){var e=t.fileStreamingScriptName,n=t.filePartialScriptName,o=ge();o.getDataRetrieverMode()===c.REQUEST?(o.register(e,Ie),o.register(n,Pe)):(o.register(e,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:e})})),o.register(n,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:n})})))}({fileStreamingScriptName:s,filePartialScriptName:f})},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(f=Me(Ne().mark((function t(e){var r,n,o,c,f,l,h,d,p,y,v,m,g,b,w,E,x,P,S,O,L,A,k,j=this,T=arguments;return Ne().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=T.length>1&&void 0!==T[1]?T[1]:{},o=(n=T.length>2&&void 0!==T[2]?T[2]:{}).useSharedArrayBuffer,c=void 0!==o&&o,f=n.fetchType,l=void 0===f?C.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new I("Url not provided");case 5:if(!(h=W(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new I("Metadata not found for ".concat(e));case 13:E=z(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),x=E.url,P=E.startByte,S=E.endByte,O=E.thumbnailUrl,L=E.isMultiframe,t.t0=d,t.next=t.t0===i.THUMBNAIL?17:t.t0===i.FRAME?21:t.t0===i.SERIES_METADATA||t.t0===i.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new I("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(x){t.next=23;break}throw new I("Url not found for frame");case 23:return A=x,l===a.BYTES_OPTIMIZED&&(A="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,u.FILE,x),t.abrupt("return",this.fetchFile(A,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new I("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 o=e.fragments[0];r=o.position,n=o.length}return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new I("Unsupported request type: ".concat(d));case 29:t.next=32;break;case 31:return t.abrupt("return",new Promise((function(t,n){return j.fetchFile(e,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,u.OTHERS,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),k=new I("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(k),k;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return f.apply(this,arguments)})},{key:"fetchFile",value:(o=Me(Ne().mark((function t(e,r){var n,o,i,c,u,s,f,l,h,d,p,y,v,m,g=this,b=arguments;return Ne().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=(n=b.length>2&&void 0!==b[2]?b[2]:{}).offsets,i=n.useSharedArrayBuffer,c=void 0!==i&&i,u=n.fetchType,s=void 0===u?C.Enums.FetchType.API_OPTIMIZED:u,f=s===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:o))){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.enableOPFSCache,!t.t0){t.next=10;break}return t.next=9,ct();case 9:t.t0=t.sent;case 10:return h=t.t0,d=ge(),p=C.dataRetrieval,y=p.FILE_STREAMING_WORKER_NAME,v=p.FILE_PARTIAL_WORKER_NAME,this.filePromises[e]?(m=this.filePromises[e].promise,this.filePromises[e].requestCount++):(m=new Promise((function(t,n){var a=C.Enums.FetchType;if(s===a.API_OPTIMIZED){var i=function(t){if(t instanceof D)throw n(t.error),t.error;var r=t.data,o=r.url,a=r.position,c=r.fileArraybuffer;o===e&&c&&(g.options.enableOPFSCache?g.files[e]=c:g.fileManager.set(o,{data:c,position:a}),d.removeEventListener(y,"message",i))};d.addEventListener(y,"message",i),d.executeTask(y,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){d.removeEventListener(y,"message",i)}))}else if(s===a.BYTES_OPTIMIZED&&o){var u=o.startByte,f=o.endByte,l=e.split("?bytes=")[0],p=function(r){if(r instanceof D)throw n(r.error),r.error;var o=r.data,a=o.url,i=o.fileArraybuffer,c=o.offsets;a===l&&c.startByte===u&&c.endByte===f&&(g.options.enableOPFSCache?g.files[e]=i:g.fileManager.set(e,{data:i,position:i.length}),d.removeEventListener(v,"message",p),t())};d.addEventListener(v,"message",p),d.executeTask(v,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){d.removeEventListener(v,"message",p)}))}else n(new I("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]={promise:m,requestCount:1}),t.abrupt("return",new Promise((function(t,r){var n=!1,a=!1,i=function(a){if(a instanceof D)throw r(a.message),a.error;var i=a.data,u=i.url,s=i.position,f=i.chunk,l=i.totalLength;if(i.isAppending?f?g.options.enableOPFSCache?g.files[u].set(f,s-f.length):g.fileManager.append(u,f,s):g.fileManager.setPosition(u,s):g.fileManager.getTotalSize()>g.options.maxCacheSize&&g.fileManager.decacheNecessaryBytes(u,l),!n&&u===e&&s>o.endByte)try{var h=g.options.enableOPFSCache?g.files[u].slice(o.startByte,o.endByte):g.fileManager.get(u,o);t(null==h?void 0:h.buffer)}catch(t){r(t)}finally{c(u)}},c=function(t){var e,r;n=!0,(null===(e=g.filePromises[t])||void 0===e?void 0:e.requestCount)&&g.filePromises[t].requestCount--,!a||!g.filePromises[t]||null!==(r=g.filePromises[t])&&void 0!==r&&r.requestCount||(d.removeEventListener(y,"message",i),delete g.filePromises[t],delete g.files[t])};o&&!f&&d.addEventListener(y,"message",i),m.then((function(){var i,c;a=!0,n||(g.fileManager.getPosition(e)||g.files[e]?(c=g.options.enableOPFSCache?f||!o?g.files[e]:g.files[e].slice(o.startByte,o.endByte):g.fileManager.get(e,f?void 0:o),t(null===(i=c)||void 0===i?void 0:i.buffer)):r(new I("File - ".concat(e," not found"))))})).catch((function(t){a=!0,r(t)})).finally((function(){c(e)}))})));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"downloadSeriesFile",value:function(t){var e,r=null===(e=Array.from(this.seriesUidFileUrls[t]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===e?void 0:e.url;if(r){var n=this.fileManager.get(r);return function(t,e){try{var r=new Blob([e],{type:"application/x-tar"}),n=URL.createObjectURL(r),o=document.createElement("a");return o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n),!0}catch(e){return console.warn("Error downloading file - ".concat(t,": ")+e.message),!1}}(r.split("/").at(-1),n)}return!1}},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===i.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=_e(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&&Re(t.prototype,e),n&&Re(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,o,f}();const qe=Ce,He={FetchType:a,CodDicomWebServer:Ce,clearPartialFiles:mt}})(),n})()));
|
|
20
|
+
const Gt=Symbol("Comlink.proxy"),Ct=Symbol("Comlink.endpoint"),qt=Symbol("Comlink.releaseProxy"),Ht=Symbol("Comlink.finalizer"),Wt=Symbol("Comlink.thrown"),zt=t=>"object"==typeof t&&null!==t||"function"==typeof t,Yt=new Map([["proxy",{canHandle:t=>zt(t)&&t[Gt],serialize(t){const{port1:e,port2:r}=new MessageChannel;return Jt(t,e),[r,[r]]},deserialize:t=>(t.start(),Kt(t))}],["throw",{canHandle:t=>zt(t)&&Wt 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 Jt(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(a){if(!a||!a.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,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:o,type:i,path:c}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(ae);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(i){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=ae(a.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[Gt]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;Jt(t,r),s=function(t,e){return re.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[Wt]:0}}Promise.resolve(s).catch((t=>({value:t,[Wt]:0}))).then((r=>{const[a,c]=ne(r);e.postMessage(Object.assign(Object.assign({},a),{id:o}),c),"RELEASE"===i&&(e.removeEventListener("message",n),Vt(e),Ht in t&&"function"==typeof t[Ht]&&t[Ht]())})).catch((t=>{const[r,n]=ne({value:new TypeError("Unserializable return value"),[Wt]:0});e.postMessage(Object.assign(Object.assign({},r),{id:o}),n)}))})),e.start&&e.start()}function Vt(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Kt(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)}})),te(t,r,[],e)}function $t(t){if(t)throw new Error("Proxy has been released and is not useable")}function Qt(t){return oe(t,new Map,{type:"RELEASE"}).then((()=>{Vt(t)}))}const Zt=new WeakMap,Xt="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Zt.get(t)||0)-1;Zt.set(t,e),0===e&&Qt(t)}));function te(t,e,r=[],n=function(){}){let a=!1;const o=new Proxy(n,{get(n,i){if($t(a),i===qt)return()=>{!function(t){Xt&&Xt.unregister(t)}(o),Qt(t),e.clear(),a=!0};if("then"===i){if(0===r.length)return{then:()=>o};const n=oe(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(ae);return n.then.bind(n)}return te(t,e,[...r,i])},set(n,o,i){$t(a);const[c,u]=ne(i);return oe(t,e,{type:"SET",path:[...r,o].map((t=>t.toString())),value:c},u).then(ae)},apply(n,o,i){$t(a);const c=r[r.length-1];if(c===Ct)return oe(t,e,{type:"ENDPOINT"}).then(ae);if("bind"===c)return te(t,e,r.slice(0,-1));const[u,s]=ee(i);return oe(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(ae)},construct(n,o){$t(a);const[i,c]=ee(o);return oe(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:i},c).then(ae)}});return function(t,e){const r=(Zt.get(e)||0)+1;Zt.set(e,r),Xt&&Xt.register(t,e,t)}(o,t),o}function ee(t){const e=t.map(ne);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const re=new WeakMap;function ne(t){for(const[e,r]of Yt)if(r.canHandle(t)){const[n,a]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},a]}return[{type:"RAW",value:t},re.get(t)||[]]}function ae(t){switch(t.type){case"HANDLER":return Yt.get(t.name).deserialize(t.value);case"RAW":return t.value}}function oe(t,e,r,n){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(o,a),t.start&&t.start(),t.postMessage(Object.assign({id:o},r),n)}))}function ie(t){return ie="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},ie(t)}function ce(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ce=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ie(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(ie(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 ue(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function se(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,fe(n.key),n)}}function fe(t){var e=function(t,e){if("object"!=ie(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ie(e)?e:e+""}const le=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=fe(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 I("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:Kt(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ce().mark((function t(e,r,n){var a,o;return ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=null===(a=this.workerRegistry[e])||void 0===a?void 0:a.instance){t.next=3;break}throw new I("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,o[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 I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){ue(o,r,a,i,c,"next",t)}function c(t){ue(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.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&&se(t.prototype,e),r&&se(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();function he(t){return he="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},he(t)}function de(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */de=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==he(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(he(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 pe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function ye(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,me(n.key),n)}}function ve(t,e,r){return(e=me(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function me(t){var e=function(t,e){if("object"!=he(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=he(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==he(e)?e:e+""}var ge=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),ve(this,"dataRetriever",void 0),ve(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new Bt,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new le,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=ve(ve({},c.WORKER,le),c.REQUEST,Bt);if(!(t in e))throw new I("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=de().mark((function t(e,r,n){return de().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)})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){pe(o,r,a,i,c,"next",t)}function c(t){pe(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.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&&ye(t.prototype,e),r&&ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}());function be(){return ge}function we(t){return we="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},we(t)}function Ee(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ee=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==we(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(we(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 xe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}Object.freeze(ge);var Pe={partial:function(t,e){return(r=Ee().mark((function r(){var n,a,o,i,c,u,s;return Ee().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.offsets,o=t.headers,i=t.directoryHandle,null!=a&&a.startByte&&null!=a&&a.endByte&&(o.Range="bytes=".concat(a.startByte,"-").concat(a.endByte-1)),c=xt(n,a),!i){r.next=11;break}return r.next=6,dt(i,c,{offsets:a,isJson:!1});case 6:if(null==(u=r.sent)||!u.byteLength){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:a}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:o}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:a}),i&&yt(i,c,t),r})).catch((function(t){throw new I("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){xe(o,n,a,i,c,"next",t)}function c(t){xe(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const Se=Pe;function Oe(t){return Oe="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},Oe(t)}function Le(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Le=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Oe(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Oe(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 ke(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 Ae(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ke(Object(r),!0).forEach((function(e){je(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ke(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function je(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Te(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var Ie={stream:function(t,e){return(r=Le().mark((function r(){var n,a,o,i,c,u,s,f,l,h,d,p,y,v,m,g,b,w,E,x,P;return Le().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.headers,o=t.useSharedArrayBuffer,i=t.directoryHandle,c=new AbortController,u=null,s=null,r.prev=4,l=Et(n),!i){r.next=15;break}return r.next=9,dt(i,l,{isJson:!1});case 9:if(null==(h=r.sent)||!h.byteLength){r.next=15;break}return d=h.byteLength,p=new Uint8Array(h),e({url:n,position:d,fileArraybuffer:p,totalLength:d}),r.abrupt("return",p);case 15:return r.next=17,fetch(n,{headers:Ae({},a),signal:c.signal});case 17:if((y=r.sent).ok){r.next=20;break}throw new I("HTTP error! status: ".concat(y.status));case 20:if(v=null===(f=y.body)||void 0===f?void 0:f.getReader()){r.next=23;break}throw new I("Failed to get reader from response body");case 23:return g=!1,b=parseInt(y.headers.get("Content-Length")||"0",10),r.next=27,v.read();case 27:if(w=r.sent,g=w.done,w.value){r.next=31;break}throw new I("The fetched chunks does not have value");case 31:if(g){r.next=50;break}E=w.value.length,o?(u=new SharedArrayBuffer(b),s=new Uint8Array(u)):s=new Uint8Array(b),s.set(w.value),e({url:n,position:E,fileArraybuffer:s,totalLength:b});case 36:if(g){r.next=49;break}return r.next=39,v.read();case 39:if(!(m=r.sent).done){r.next=43;break}return g=!0,r.abrupt("continue",36);case 43:x=m.value,s.set(x,E),E+=x.length,e({isAppending:!0,url:n,position:E,chunk:o?void 0:x,totalLength:b}),r.next=36;break;case 49:i&&yt(i,l,s.slice().buffer);case 50:return r.abrupt("return",s);case 53:throw r.prev=53,r.t0=r.catch(4),P=new I("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 58:return r.prev=58,u=null,s=null,c.abort(),r.finish(58);case 63:case"end":return r.stop()}}),r,null,[[4,53,58,63]])})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){Te(o,n,a,i,c,"next",t)}function c(t){Te(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const De=Ie;function _e(t){return _e="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},_e(t)}function Fe(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,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ne(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)?Ne(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 Ne(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 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,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}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={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_e(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===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 o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_e(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(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,T.prototype={constructor:T,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(j),!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 a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},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),j(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 a=n.arg;j(r)}return a}}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 Me(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Re(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(t){Me(o,n,a,i,c,"next",t)}function c(t){Me(o,n,a,i,c,"throw",t)}i(void 0)}))}}function Be(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,Ce(n.key),n)}}function Ge(t,e,r){return(e=Ce(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ce(t){var e=function(t,e){if("object"!=_e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_e(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:e+""}var qe=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),Ge(this,"filePromises",{}),Ge(this,"files",{}),Ge(this,"options",{maxCacheSize:4294967296,domain:C.url.DOMAIN,enableOPFSCache:!1}),Ge(this,"fileManager",void 0),Ge(this,"metadataManager",void 0),Ge(this,"seriesUidFileUrls",{}),Ge(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Ge(this,"getOptions",(function(){return e.options}));var a=n.maxCacheSize,o=n.domain,i=n.disableWorker,u=n.enableOPFSCache;this.options.maxCacheSize=a||this.options.maxCacheSize,this.options.domain=o||this.options.domain,this.options.enableOPFSCache=!!u;var s=C.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=C.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new g,this.metadataManager=new Dt,i&&be().setDataRetrieverMode(c.REQUEST),function(t){var e=t.fileStreamingScriptName,n=t.filePartialScriptName,a=be();a.getDataRetrieverMode()===c.REQUEST?(a.register(e,De),a.register(n,Se)):(a.register(e,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:e})})),a.register(n,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:n})})))}({fileStreamingScriptName:s,filePartialScriptName:f})},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(l=Re(Ue().mark((function t(e){var r,n,a,c,f,l,h,d,p,y,v,m,g,b,w,E,x,P,S,O,L,k,A,j=this,T=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=T.length>1&&void 0!==T[1]?T[1]:{},a=(n=T.length>2&&void 0!==T[2]?T[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,f=n.fetchType,l=void 0===f?C.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new I("Url not provided");case 5:if(!(h=W(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new I("Metadata not found for ".concat(e));case 13:E=z(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),x=E.url,P=E.startByte,S=E.endByte,O=E.thumbnailUrl,L=E.isMultiframe,t.t0=d,t.next=t.t0===i.THUMBNAIL?17:t.t0===i.FRAME?21:t.t0===i.SERIES_METADATA||t.t0===i.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new I("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(x){t.next=23;break}throw new I("Url not found for frame");case 23:return k=x,l===o.BYTES_OPTIMIZED&&(k="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,u.FILE,x),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new I("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 a=e.fragments[0];r=a.position,n=a.length}return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new I("Unsupported request type: ".concat(d));case 29:t.next=32;break;case 31:return t.abrupt("return",new Promise((function(t,n){return j.fetchFile(e,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,u.OTHERS,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 I("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 l.apply(this,arguments)})},{key:"fetchFile",value:(f=Re(Ue().mark((function t(e,r){var n,a,i,c,u,s,f,l,h,d,p,y,v,m,g=this,b=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(n=b.length>2&&void 0!==b[2]?b[2]:{}).offsets,i=n.useSharedArrayBuffer,c=void 0!==i&&i,u=n.fetchType,s=void 0===u?C.Enums.FetchType.API_OPTIMIZED:u,f=s===o.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:a))){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.enableOPFSCache,!t.t0){t.next=10;break}return t.next=9,ct();case 9:t.t0=t.sent;case 10:return h=t.t0,d=be(),p=C.dataRetrieval,y=p.FILE_STREAMING_WORKER_NAME,v=p.FILE_PARTIAL_WORKER_NAME,this.filePromises[e]?(m=this.filePromises[e].promise,this.filePromises[e].requestCount++):(m=new Promise((function(t,n){var o=C.Enums.FetchType;if(s===o.API_OPTIMIZED){var i=function(t){if(t instanceof D)throw n(t.error),t.error;var r=t.data,a=r.url,o=r.position,c=r.fileArraybuffer;a===e&&c&&(g.options.enableOPFSCache?g.files[e]=c:g.fileManager.set(a,{data:c,position:o}),d.removeEventListener(y,"message",i))};d.addEventListener(y,"message",i),d.executeTask(y,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){d.removeEventListener(y,"message",i)}))}else if(s===o.BYTES_OPTIMIZED&&a){var u=a.startByte,f=a.endByte,l=e.split("?bytes=")[0],p=function(r){if(r instanceof D)throw n(r.error),r.error;var a=r.data,o=a.url,i=a.fileArraybuffer,c=a.offsets;o===l&&c.startByte===u&&c.endByte===f&&(g.options.enableOPFSCache?g.files[e]=i:g.fileManager.set(e,{data:i,position:i.length}),d.removeEventListener(v,"message",p),t())};d.addEventListener(v,"message",p),d.executeTask(v,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){d.removeEventListener(v,"message",p)}))}else n(new I("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]={promise:m,requestCount:1}),t.abrupt("return",new Promise((function(t,r){var n=!1,o=!1,i=function(o){if(o instanceof D)throw r(o.message),o.error;var i=o.data,u=i.url,s=i.position,f=i.chunk,l=i.totalLength;if(i.isAppending?f?g.options.enableOPFSCache?g.files[u].set(f,s-f.length):g.fileManager.append(u,f,s):g.fileManager.setPosition(u,s):g.fileManager.getTotalSize()>g.options.maxCacheSize&&g.fileManager.decacheNecessaryBytes(u,l),!n&&u===e&&s>a.endByte)try{var h=g.options.enableOPFSCache?g.files[u].slice(a.startByte,a.endByte):g.fileManager.get(u,a);t(null==h?void 0:h.buffer)}catch(t){r(t)}finally{c(u)}},c=function(t){var e,r;n=!0,(null===(e=g.filePromises[t])||void 0===e?void 0:e.requestCount)&&g.filePromises[t].requestCount--,!o||!g.filePromises[t]||null!==(r=g.filePromises[t])&&void 0!==r&&r.requestCount||(d.removeEventListener(y,"message",i),delete g.filePromises[t],delete g.files[t])};a&&!f&&d.addEventListener(y,"message",i),m.then((function(){var i,c;o=!0,n||(g.fileManager.getPosition(e)||g.files[e]?(c=g.options.enableOPFSCache?f||!a?g.files[e]:g.files[e].slice(a.startByte,a.endByte):g.fileManager.get(e,f?void 0:a),t(null===(i=c)||void 0===i?void 0:i.buffer)):r(new I("File - ".concat(e," not found"))))})).catch((function(t){o=!0,r(t)})).finally((function(){c(e)}))})));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"downloadSeriesFile",value:(a=Re(Ue().mark((function t(e){var r,n,a,o,i,c;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=null===(r=Array.from(this.seriesUidFileUrls[e]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===r?void 0:r.url)){t.next=14;break}if(o=this.fileManager.get(n),null!==(a=o)&&void 0!==a&&a.byteLength){t.next=13;break}return t.next=6,ct();case 6:return i=t.sent,t.next=9,dt(i,Et(n));case 9:if(null==(c=t.sent)||!c.byteLength){t.next=12;break}return t.abrupt("return",!1);case 12:o=new Uint8Array(c);case 13:return t.abrupt("return",mt(n.split("/").at(-1),o.buffer));case 14:return t.abrupt("return",!1);case 15:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===i.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=Fe(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&&Be(t.prototype,e),n&&Be(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,a,f,l}();const He=qe,We={FetchType:o,CodDicomWebServer:qe,clearPartialFiles:gt}})(),n})()));
|
|
21
21
|
//# sourceMappingURL=main.js.map
|