cod-dicomweb-server 1.3.7 → 1.3.8
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/cjs/main.js +21 -11
- package/dist/esm/metadataManager.d.ts +1 -1
- package/dist/esm/metadataManager.js +10 -9
- package/dist/umd/563.js +1 -1
- package/dist/umd/846.js +1 -1
- package/dist/umd/main.js +3 -3
- package/dist/umd/main.js.map +1 -1
- package/package.json +1 -1
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.7
|
|
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 i})),r.d(e,"isPrivateTag",(function(){return a})),r.d(e,"parsePN",(function(){return o})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return u})),r.d(e,"explicitElementToString",(function(){return f})),r.d(e,"explicitDataSetToJS",(function(){return l})),r.d(e,"createJPEGBasicOffsetTable",(function(){return p})),r.d(e,"parseDicomDataSetExplicit",(function(){return _})),r.d(e,"parseDicomDataSetImplicit",(function(){return F})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return D})),r.d(e,"version",(function(){return N})),r.d(e,"bigEndianByteArrayParser",(function(){return U})),r.d(e,"ByteStream",(function(){return B})),r.d(e,"sharedCopy",(function(){return R})),r.d(e,"DataSet",(function(){return E})),r.d(e,"findAndSetUNElementLength",(function(){return m})),r.d(e,"findEndOfEncapsulatedElement",(function(){return v})),r.d(e,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(e,"littleEndianByteArrayParser",(function(){return G})),r.d(e,"parseDicom",(function(){return z})),r.d(e,"readDicomElementExplicit",(function(){return I})),r.d(e,"readDicomElementImplicit",(function(){return S})),r.d(e,"readEncapsulatedImageFrame",(function(){return V})),r.d(e,"readEncapsulatedPixelData",(function(){return Q})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return T})),r.d(e,"readSequenceItemsImplicit",(function(){return A})),r.d(e,"readSequenceItem",(function(){return L})),r.d(e,"readTag",(function(){return y}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},i=function(t){return n[t]},a=function(t){if(t=parseInt(t[4],16),isNaN(t))throw"dicomParser.isPrivateTag: cannot parse last character of group";return t%2==1},o=function(t){if(void 0!==t)return{familyName:(t=t.split("^"))[0],givenName:t[1],middleName:t[2],prefix:t[3],suffix:t[4]}};function c(t,e){if(2<=t.length){var r=parseInt(t.substring(0,2),10),n=4<=t.length?parseInt(t.substring(2,4),10):void 0,i=6<=t.length?parseInt(t.substring(4,6),10):void 0,a=(a=8<=t.length?t.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(e&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}if(e)throw"invalid TM '".concat(t,"'")}function s(t,e,r){return!isNaN(r)&&0<e&&e<=12&&0<t&&t<=function(t,e){switch(t){case 2:return e%4==0&&e%100||e%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(e,r)}function u(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10);if(e&&!0!==s(i,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:i}}if(e)throw"invalid DA '".concat(t,"'")}function f(t,e){if(void 0===t||void 0===e)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=e.vr,a=e.tag;function o(e,r){for(var n="",i=0;i<e;i++)0!==i&&(n+="/"),n+=r.call(t,a,i).toString();return n}if(!0===i(n))r=t.string(a);else{if("AT"===n){var c=t.uint32(a);return void 0===c?void 0:"x".concat((c=c<0?4294967295+c+1:c).toString(16).toUpperCase())}"US"===n?r=o(e.length/2,t.uint16):"SS"===n?r=o(e.length/2,t.int16):"UL"===n?r=o(e.length/4,t.uint32):"SL"===n?r=o(e.length/4,t.int32):"FD"===n?r=o(e.length/8,t.double):"FL"===n&&(r=o(e.length/4,t.float))}return r}function l(t,e){if(void 0===t)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";e=e||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in t.elements){var i=t.elements[r];if(!0!==e.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],c=0;c<i.items.length;c++)o.push(l(i.items[c].dataSet,e));n[r]=o}else{var s=void 0;i.length<e.maxElementLength&&(s=f(t,i)),n[r]=void 0!==s?s:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(t,e){return 255===t.byteArray[e]&&217===t.byteArray[e+1]}function d(t,e,r){for(var n,i,a=r;a<e.fragments.length;a++)if(i=a,h(n=t,(i=e.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}function p(t,e,r){if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==e.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==e.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||e.fragments;for(var n=[],i=0;;){n.push(e.fragments[i].offset);var a=d(t,e,i);if(void 0===a||a===e.fragments.length-1)return n;i=a+1}}function y(t){if(void 0===t)throw"dicomParser.readTag: missing required parameter 'byteStream'";var e=256*t.readUint16()*256;return t=t.readUint16(),"x".concat("00000000".concat((e+t).toString(16)).substr(-8))}function v(t,e,r){if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(e.encapsulatedPixelData=!0,e.basicOffsetTable=[],e.fragments=[],"xfffee000"!==y(t))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=t.readUint32()/4,i=0;i<n;i++){var a=t.readUint32();e.basicOffsetTable.push(a)}for(var o=t.position;t.position<t.byteArray.length;){var c=y(t),s=t.readUint32();if("xfffee0dd"===c)return t.seek(s),void(e.length=t.position-e.dataOffset);if("xfffee000"!==c)return r&&r.push("unexpected tag ".concat(c," while searching for end of pixel data element with undefined length")),s>t.byteArray.length-t.position&&(s=t.byteArray.length-t.position),e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s)}r&&r.push("pixel data element ".concat(e.tag," missing sequence delimiter tag xfffee0dd"))}function m(t,e){if(void 0===t)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57565===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}function g(t,e,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(e+r>t.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,i="",a=0;a<r;a++){if(0===(n=t[e+a]))return e+=r,i;i+=String.fromCharCode(n)}return i}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e){return void 0!==t.parser?t.parser:e}var E=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.byteArrayParser=e,this.byteArray=r,this.elements=n}var e,r,n;return e=t,(r=[{key:"uint16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint16(this.byteArray,t.dataOffset+2*e)}},{key:"int16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt16(this.byteArray,t.dataOffset+2*e)}},{key:"uint32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint32(this.byteArray,t.dataOffset+4*e)}},{key:"int32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt32(this.byteArray,t.dataOffset+4*e)}},{key:"float",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readFloat(this.byteArray,t.dataOffset+4*e)}},{key:"double",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readDouble(this.byteArray,t.dataOffset+8*e)}},{key:"numStringValues",value:function(t){if((t=this.elements[t])&&0<t.length)return null===(t=g(this.byteArray,t.dataOffset,t.length).match(/\\/g))?1:t.length+1}},{key:"string",value:function(t,e){return(t=this.elements[t])&&t.Value?t.Value:t&&0<t.length?(t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].trim():t.trim()):void 0}},{key:"text",value:function(t,e){if((t=this.elements[t])&&0<t.length)return t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].replace(/ +$/,""):t.replace(/ +$/,"")}},{key:"floatString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseFloat(e)}},{key:"intString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseInt(e)}},{key:"attributeTag",value:function(t){if((r=this.elements[t])&&4===r.length){var e=w(r,this.byteArrayParser).readUint16,r=(t=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*e(t,r)*256+e(t,r+2)).toString(16)).substr(-8))}}}])&&b(e.prototype,r),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function x(t,e){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57357===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}var P=function(t,e){return void 0!==t.vr?"SQ"===t.vr:e.position+4<=e.byteArray.length?(t=y(e),e.seek(-4),"xfffee000"===t||"xfffee0dd"===t):(e.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(t),vr:void 0!==r?r(n):void 0,length:t.readUint32(),dataOffset:t.position}).length&&(n.hadUndefinedLength=!0),n.tag===e||(!P(n,t)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(t,n):t.seek(n.length):(A(t,n,r),a(n.tag)&&(n.items=void 0))),n}function L(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 O(t,e){var r=L(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=S(t,void 0,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return t.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),F(r.dataSet,t,t.position+r.length,{vrCallback:e})),r}function 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=O(t,r),e.items.push(n)}t.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),e.length=t.byteArray.length-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var i=O(t,r);e.items.push(i)}})(t,e,r)}function k(t,e){var r=L(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=I(t,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return e.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),_(r.dataSet,t,t.position+r.length)),r}function T(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=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 i=k(t,r);e.items.push(i)}})(t,e,r)}var j=function(t){return"OB"===t||"OD"===t||"OL"===t||"OW"===t||"SQ"===t||"OF"===t||"UC"===t||"UR"===t||"UT"===t||"UN"===t?4:2};function I(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(t),vr:t.readFixedString(2)};return 2===j(n.vr)?n.length=t.readUint16():(t.seek(2),n.length=t.readUint32()),n.dataOffset=t.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(t,n,e):4294967295===n.length?"x7fe00010"===n.tag?v(t,n,e):("UN"===n.vr?A:x)(t,n):t.seek(n.length)),n}function _(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var i=t.elements;e.position<r;){var a=I(e,t.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function F(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var i=t.elements;e.position<r;){var a=S(e,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function D(t,e){if("undefined"!=typeof Buffer&&t instanceof Buffer)return Buffer.alloc(e);if(t instanceof Uint8Array)return new Uint8Array(e);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(t[e]<<8)+t[e+1]},readInt16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=(t[e]<<8)+t[e+1])?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*t[e]+t[e+1])+t[e+2])+t[e+3]},readInt32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]},readFloat:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=t[e],r[2]=t[e+1],r[1]=t[e+2],r[0]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=t[e],r[6]=t[e+1],r[5]=t[e+2],r[4]=t[e+3],r[3]=t[e+4],r[2]=t[e+5],r[1]=t[e+6],r[0]=t[e+7],new Float64Array(r.buffer)[0]}};function R(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 M(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=R(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}}])&&M(e.prototype,r),n&&M(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),G={readUint16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return t[e]+256*t[e+1]},readInt16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=t[e]+(t[e+1]<<8))?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return t[e]+256*t[e+1]+256*t[e+2]*256+256*t[e+3]*256*256},readInt32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24)},readFloat:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],r[4]=t[e+4],r[5]=t[e+5],r[6]=t[e+6],r[7]=t[e+7],new Float64Array(r.buffer)[0]}};function C(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=e.TransferSyntaxUID,n=new B(G,t);return function(){var t=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(e||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),i=[],a={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,c=I(n,i);if("x0002ffff"<c.tag){n.position=o;break}c.parser=G,a[c.tag]=c}return(t=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,t.position=n.position,t}()}var q="1.2.840.10008.1.2.2";function z(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,i=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(e=e.elements.x00020010)&&e.Value||g(t,e.dataOffset,e.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===q?U:G,t,i);if(e&&e.inflater)return n=e.inflater(t,i),new B(G,n,0);if(1==a){var o=r(0),c=R(t,i,t.length-i);return o=o.inflateRawSync(c),c=D(t,o.length+i),t.copy(c,0,0,i),o.copy(c,i),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=t.slice(i),c=pako.inflateRaw(o),(o=D(t,c.length+i)).set(t.slice(0,i),0),o.set(c,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?_:F)(n,o,o.byteArray.length,e)}catch(o){throw{exception:o,dataSet:n}}return n}return function(t,e){for(var r in t.elements)t.elements.hasOwnProperty(r)&&(e.elements[r]=t.elements[r]);return void 0!==t.warnings&&(e.warnings=t.warnings.concat(e.warnings)),e}(n=C(t,e),a(n))}var W=function(t,e,r){for(var n=0,i=e;i<e+r;i++)n+=t[i].length;return n};function H(t,e,r,n,i){if(i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(t.byteArrayParser,t.byteArray,e.dataOffset);if("xfffee000"!==(e=L(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(e.length);var o=a.position;if(1===n)return R(a.byteArray,o+i[r].offset+8,i[r].length);e=W(i,r,n);for(var c=D(a.byteArray,e),s=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)c[s++]=a.byteArray[f++];return c}var Y=function(t,e){for(var r=0;r<t.length;r++)if(t[r].offset===e)return r},J=function(t,e,r,n){if(t===e.length-1)return r.length-n;for(var i=e[t+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,i){if(n=n||e.basicOffsetTable,i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var a=n[r];if(void 0===(a=Y(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(t,e,a,J(r,n,i,a),i)}var K=!1;function Q(t,e,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==e.basicOffsetTable.length?V(t,e,r):H(t,e,0,e.fragments.length)}e.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:c,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:_,parseDicomDataSetImplicit:F,readFixedString:g,alloc:D,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:R,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:H,readPart10Header:C,readSequenceItemsExplicit:T,readSequenceItemsImplicit:A,readSequenceItem:L,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},e.m=r,e.c=n,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(e){return t[e]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1);function e(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return r[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.m=t,r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.u=t=>t+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var e=r.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>Ae,FetchType:()=>a,clearPartialFiles:()=>te,default:()=>ke});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>a,RequestType:()=>o,URLType:()=>s});var e={};r.r(e),r.d(e,{DOMAIN:()=>S,FILE_EXTENSIONS:()=>L,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>A,FILE_STREAMING_WORKER_NAME:()=>k,FILE_SYSTEM_ROUTES:()=>I,IDB_DIR_HANDLE_KEY:()=>j,THRESHOLD:()=>T});var a=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),o=function(t){return t[t.FRAME=0]="FRAME",t[t.THUMBNAIL=1]="THUMBNAIL",t[t.SERIES_METADATA=2]="SERIES_METADATA",t[t.INSTANCE_METADATA=3]="INSTANCE_METADATA",t}({}),c=function(t){return t[t.WORKER=0]="WORKER",t[t.REQUEST=1]="REQUEST",t}({}),s=function(t){return t[t.THUMBNAIL=0]="THUMBNAIL",t[t.FILE=1]="FILE",t[t.OTHERS=2]="OTHERS",t}({}),u=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,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function h(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 d(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function p(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+""}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e,r){return e=E(e),function(t,e){if(e&&("object"==f(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,b()?Reflect.construct(e,r||[],E(t).constructor):e.apply(t,r))}function m(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&&w(t,e)}function g(t){var e="function"==typeof Map?new Map:void 0;return g=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(b())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&w(i,r.prototype),i}(t,arguments,E(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},g(t)}function b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(b=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}var x=function(t){function e(){return y(this,e),v(this,e,arguments)}return m(e,t),d(e)}(g(Error)),P=function(t){function e(t,r){var n;return y(this,e),l(n=v(this,e,[t]),"error",void 0),l(n,"message",void 0),n.message=t,n.error=r,n}return m(e,t),d(e)}(g(Event)),S="https://storage.googleapis.com",L=[".tar",".zip"],O="/dicomweb/",A="filePartial",k="fileStreaming",T=1e4,j="indexed_db_directory_handle_key",I={Partial:"partial"};const _={Enums:t,url:e,dataRetrieval:i};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 D(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */D=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==F(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(F(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function N(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function U(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 R(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 B=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),R(this,"loaderRegistry",{}),R(this,"listenerCallback",(function(t,r,n){var i,a=null===(i=e.loaderRegistry[t])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(t){return t({data:n})}))}))},e=[{key:"register",value:function(t,e){try{if(!e)throw new x("Loader object for ".concat(t," is not provided"));this.loaderRegistry[t]={loaderObject:e,listeners:{}}}catch(t){throw console.warn(t),new x("throws")}}},{key:"executeTask",value:(n=D().mark((function t(e,r,n){var i,a,o=this;return D().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.loaderRegistry[e])||void 0===i?void 0:i.loaderObject){t.next=3;break}throw new x("Loader ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,a[r](n,(function(t){return o.listenerCallback(e,"message",t)}));case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on "').concat(e,'":'),t.t0),new x('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){N(a,r,i,o,c,"next",t)}function c(t){N(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]?n.listeners[e].push(r):n.listeners[e]=[r]:console.error("Loader '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]=(n.listeners[e]||[]).filter((function(t){return t!==r})):console.error("Loader '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],e&&U(t.prototype,e),r&&U(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();
|
|
14
|
+
t.exports=function(t){return r=[function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e),r.d(e,"isStringVr",(function(){return i})),r.d(e,"isPrivateTag",(function(){return a})),r.d(e,"parsePN",(function(){return o})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return u})),r.d(e,"explicitElementToString",(function(){return f})),r.d(e,"explicitDataSetToJS",(function(){return l})),r.d(e,"createJPEGBasicOffsetTable",(function(){return p})),r.d(e,"parseDicomDataSetExplicit",(function(){return F})),r.d(e,"parseDicomDataSetImplicit",(function(){return _})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return D})),r.d(e,"version",(function(){return N})),r.d(e,"bigEndianByteArrayParser",(function(){return U})),r.d(e,"ByteStream",(function(){return B})),r.d(e,"sharedCopy",(function(){return M})),r.d(e,"DataSet",(function(){return E})),r.d(e,"findAndSetUNElementLength",(function(){return m})),r.d(e,"findEndOfEncapsulatedElement",(function(){return v})),r.d(e,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(e,"littleEndianByteArrayParser",(function(){return G})),r.d(e,"parseDicom",(function(){return z})),r.d(e,"readDicomElementExplicit",(function(){return I})),r.d(e,"readDicomElementImplicit",(function(){return S})),r.d(e,"readEncapsulatedImageFrame",(function(){return V})),r.d(e,"readEncapsulatedPixelData",(function(){return Q})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return T})),r.d(e,"readSequenceItemsImplicit",(function(){return A})),r.d(e,"readSequenceItem",(function(){return L})),r.d(e,"readTag",(function(){return y}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},i=function(t){return n[t]},a=function(t){if(t=parseInt(t[4],16),isNaN(t))throw"dicomParser.isPrivateTag: cannot parse last character of group";return t%2==1},o=function(t){if(void 0!==t)return{familyName:(t=t.split("^"))[0],givenName:t[1],middleName:t[2],prefix:t[3],suffix:t[4]}};function c(t,e){if(2<=t.length){var r=parseInt(t.substring(0,2),10),n=4<=t.length?parseInt(t.substring(2,4),10):void 0,i=6<=t.length?parseInt(t.substring(4,6),10):void 0,a=(a=8<=t.length?t.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(e&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}if(e)throw"invalid TM '".concat(t,"'")}function s(t,e,r){return!isNaN(r)&&0<e&&e<=12&&0<t&&t<=function(t,e){switch(t){case 2:return e%4==0&&e%100||e%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(e,r)}function u(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10);if(e&&!0!==s(i,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:i}}if(e)throw"invalid DA '".concat(t,"'")}function f(t,e){if(void 0===t||void 0===e)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=e.vr,a=e.tag;function o(e,r){for(var n="",i=0;i<e;i++)0!==i&&(n+="/"),n+=r.call(t,a,i).toString();return n}if(!0===i(n))r=t.string(a);else{if("AT"===n){var c=t.uint32(a);return void 0===c?void 0:"x".concat((c=c<0?4294967295+c+1:c).toString(16).toUpperCase())}"US"===n?r=o(e.length/2,t.uint16):"SS"===n?r=o(e.length/2,t.int16):"UL"===n?r=o(e.length/4,t.uint32):"SL"===n?r=o(e.length/4,t.int32):"FD"===n?r=o(e.length/8,t.double):"FL"===n&&(r=o(e.length/4,t.float))}return r}function l(t,e){if(void 0===t)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";e=e||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in t.elements){var i=t.elements[r];if(!0!==e.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],c=0;c<i.items.length;c++)o.push(l(i.items[c].dataSet,e));n[r]=o}else{var s=void 0;i.length<e.maxElementLength&&(s=f(t,i)),n[r]=void 0!==s?s:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(t,e){return 255===t.byteArray[e]&&217===t.byteArray[e+1]}function d(t,e,r){for(var n,i,a=r;a<e.fragments.length;a++)if(i=a,h(n=t,(i=e.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}function p(t,e,r){if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==e.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==e.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||e.fragments;for(var n=[],i=0;;){n.push(e.fragments[i].offset);var a=d(t,e,i);if(void 0===a||a===e.fragments.length-1)return n;i=a+1}}function y(t){if(void 0===t)throw"dicomParser.readTag: missing required parameter 'byteStream'";var e=256*t.readUint16()*256;return t=t.readUint16(),"x".concat("00000000".concat((e+t).toString(16)).substr(-8))}function v(t,e,r){if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(e.encapsulatedPixelData=!0,e.basicOffsetTable=[],e.fragments=[],"xfffee000"!==y(t))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=t.readUint32()/4,i=0;i<n;i++){var a=t.readUint32();e.basicOffsetTable.push(a)}for(var o=t.position;t.position<t.byteArray.length;){var c=y(t),s=t.readUint32();if("xfffee0dd"===c)return t.seek(s),void(e.length=t.position-e.dataOffset);if("xfffee000"!==c)return r&&r.push("unexpected tag ".concat(c," while searching for end of pixel data element with undefined length")),s>t.byteArray.length-t.position&&(s=t.byteArray.length-t.position),e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-o-8,position:t.position,length:s}),t.seek(s)}r&&r.push("pixel data element ".concat(e.tag," missing sequence delimiter tag xfffee0dd"))}function m(t,e){if(void 0===t)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57565===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}function g(t,e,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(e+r>t.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,i="",a=0;a<r;a++){if(0===(n=t[e+a]))return e+=r,i;i+=String.fromCharCode(n)}return i}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e){return void 0!==t.parser?t.parser:e}var E=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.byteArrayParser=e,this.byteArray=r,this.elements=n}var e,r,n;return e=t,(r=[{key:"uint16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint16(this.byteArray,t.dataOffset+2*e)}},{key:"int16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt16(this.byteArray,t.dataOffset+2*e)}},{key:"uint32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint32(this.byteArray,t.dataOffset+4*e)}},{key:"int32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt32(this.byteArray,t.dataOffset+4*e)}},{key:"float",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readFloat(this.byteArray,t.dataOffset+4*e)}},{key:"double",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readDouble(this.byteArray,t.dataOffset+8*e)}},{key:"numStringValues",value:function(t){if((t=this.elements[t])&&0<t.length)return null===(t=g(this.byteArray,t.dataOffset,t.length).match(/\\/g))?1:t.length+1}},{key:"string",value:function(t,e){return(t=this.elements[t])&&t.Value?t.Value:t&&0<t.length?(t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].trim():t.trim()):void 0}},{key:"text",value:function(t,e){if((t=this.elements[t])&&0<t.length)return t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].replace(/ +$/,""):t.replace(/ +$/,"")}},{key:"floatString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseFloat(e)}},{key:"intString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseInt(e)}},{key:"attributeTag",value:function(t){if((r=this.elements[t])&&4===r.length){var e=w(r,this.byteArrayParser).readUint16,r=(t=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*e(t,r)*256+e(t,r+2)).toString(16)).substr(-8))}}}])&&b(e.prototype,r),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function x(t,e){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57357===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}var P=function(t,e){return void 0!==t.vr?"SQ"===t.vr:e.position+4<=e.byteArray.length?(t=y(e),e.seek(-4),"xfffee000"===t||"xfffee0dd"===t):(e.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(t),vr:void 0!==r?r(n):void 0,length:t.readUint32(),dataOffset:t.position}).length&&(n.hadUndefinedLength=!0),n.tag===e||(!P(n,t)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(t,n):t.seek(n.length):(A(t,n,r),a(n.tag)&&(n.items=void 0))),n}function L(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 O(t,e){var r=L(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=O(t,r),e.items.push(n)}t.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),e.length=t.byteArray.length-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var i=O(t,r);e.items.push(i)}})(t,e,r)}function k(t,e){var r=L(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,{}),F(r.dataSet,t,t.position+r.length)),r}function T(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=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 i=k(t,r);e.items.push(i)}})(t,e,r)}var j=function(t){return"OB"===t||"OD"===t||"OL"===t||"OW"===t||"SQ"===t||"OF"===t||"UC"===t||"UR"===t||"UT"===t||"UN"===t?4:2};function I(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(t),vr:t.readFixedString(2)};return 2===j(n.vr)?n.length=t.readUint16():(t.seek(2),n.length=t.readUint32()),n.dataOffset=t.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(t,n,e):4294967295===n.length?"x7fe00010"===n.tag?v(t,n,e):("UN"===n.vr?A:x)(t,n):t.seek(n.length)),n}function F(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var i=t.elements;e.position<r;){var a=I(e,t.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function _(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var i=t.elements;e.position<r;){var a=S(e,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function D(t,e){if("undefined"!=typeof Buffer&&t instanceof Buffer)return Buffer.alloc(e);if(t instanceof Uint8Array)return new Uint8Array(e);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(t[e]<<8)+t[e+1]},readInt16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=(t[e]<<8)+t[e+1])?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*t[e]+t[e+1])+t[e+2])+t[e+3]},readInt32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]},readFloat:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=t[e],r[2]=t[e+1],r[1]=t[e+2],r[0]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=t[e],r[6]=t[e+1],r[5]=t[e+2],r[4]=t[e+3],r[3]=t[e+4],r[2]=t[e+5],r[1]=t[e+6],r[0]=t[e+7],new Float64Array(r.buffer)[0]}};function M(t,e,r){if("undefined"!=typeof Buffer&&t instanceof Buffer)return t.slice(e,e+r);if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset+e,r);throw"dicomParser.from: unknown type for byteArray"}function R(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var B=function(){function t(e,r,n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),void 0===e)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=e,this.byteArray=r,this.position=n||0,this.warnings=[]}var e,r,n;return e=t,(r=[{key:"seek",value:function(t){if(this.position+t<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=t}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,e);return this.position+=e,new t(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var t=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,t}},{key:"readUint32",value:function(){var t=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,t}},{key:"readFixedString",value:function(t){var e=g(this.byteArray,this.position,t);return this.position+=t,e}}])&&R(e.prototype,r),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),G={readUint16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return t[e]+256*t[e+1]},readInt16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=t[e]+(t[e+1]<<8))?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return t[e]+256*t[e+1]+256*t[e+2]*256+256*t[e+3]*256*256},readInt32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24)},readFloat:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],r[4]=t[e+4],r[5]=t[e+5],r[6]=t[e+6],r[7]=t[e+7],new Float64Array(r.buffer)[0]}};function C(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=e.TransferSyntaxUID,n=new B(G,t);return function(){var t=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(e||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),i=[],a={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,c=I(n,i);if("x0002ffff"<c.tag){n.position=o;break}c.parser=G,a[c.tag]=c}return(t=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,t.position=n.position,t}()}var q="1.2.840.10008.1.2.2";function z(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,i=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(e=e.elements.x00020010)&&e.Value||g(t,e.dataOffset,e.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===q?U:G,t,i);if(e&&e.inflater)return n=e.inflater(t,i),new B(G,n,0);if(1==a){var o=r(0),c=M(t,i,t.length-i);return o=o.inflateRawSync(c),c=D(t,o.length+i),t.copy(c,0,0,i),o.copy(c,i),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=t.slice(i),c=pako.inflateRaw(o),(o=D(t,c.length+i)).set(t.slice(0,i),0),o.set(c,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?F:_)(n,o,o.byteArray.length,e)}catch(o){throw{exception:o,dataSet:n}}return n}return function(t,e){for(var r in t.elements)t.elements.hasOwnProperty(r)&&(e.elements[r]=t.elements[r]);return void 0!==t.warnings&&(e.warnings=t.warnings.concat(e.warnings)),e}(n=C(t,e),a(n))}var W=function(t,e,r){for(var n=0,i=e;i<e+r;i++)n+=t[i].length;return n};function H(t,e,r,n,i){if(i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(t.byteArrayParser,t.byteArray,e.dataOffset);if("xfffee000"!==(e=L(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(e.length);var o=a.position;if(1===n)return M(a.byteArray,o+i[r].offset+8,i[r].length);e=W(i,r,n);for(var c=D(a.byteArray,e),s=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)c[s++]=a.byteArray[f++];return c}var Y=function(t,e){for(var r=0;r<t.length;r++)if(t[r].offset===e)return r},J=function(t,e,r,n){if(t===e.length-1)return r.length-n;for(var i=e[t+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,i){if(n=n||e.basicOffsetTable,i=i||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var a=n[r];if(void 0===(a=Y(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(t,e,a,J(r,n,i,a),i)}var K=!1;function Q(t,e,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==e.basicOffsetTable.length?V(t,e,r):H(t,e,0,e.fragments.length)}e.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:c,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:_,readFixedString:g,alloc:D,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:H,readPart10Header:C,readSequenceItemsExplicit:T,readSequenceItemsImplicit:A,readSequenceItem:L,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},e.m=r,e.c=n,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(e){return t[e]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1);function e(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return r[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.m=t,r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.u=t=>t+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var e=r.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>Te,FetchType:()=>a,clearPartialFiles:()=>re,default:()=>je});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>a,RequestType:()=>o,URLType:()=>s});var e={};r.r(e),r.d(e,{DOMAIN:()=>S,FILE_EXTENSIONS:()=>L,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>A,FILE_STREAMING_WORKER_NAME:()=>k,FILE_SYSTEM_ROUTES:()=>I,IDB_DIR_HANDLE_KEY:()=>j,THRESHOLD:()=>T});var a=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),o=function(t){return t[t.FRAME=0]="FRAME",t[t.THUMBNAIL=1]="THUMBNAIL",t[t.SERIES_METADATA=2]="SERIES_METADATA",t[t.INSTANCE_METADATA=3]="INSTANCE_METADATA",t}({}),c=function(t){return t[t.WORKER=0]="WORKER",t[t.REQUEST=1]="REQUEST",t}({}),s=function(t){return t[t.THUMBNAIL=0]="THUMBNAIL",t[t.FILE=1]="FILE",t[t.OTHERS=2]="OTHERS",t}({}),u=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,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function h(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 d(t,e,r){return e&&h(t.prototype,e),r&&h(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function p(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+""}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e,r){return e=E(e),function(t,e){if(e&&("object"==f(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,b()?Reflect.construct(e,r||[],E(t).constructor):e.apply(t,r))}function m(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&&w(t,e)}function g(t){var e="function"==typeof Map?new Map:void 0;return g=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(b())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&w(i,r.prototype),i}(t,arguments,E(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},g(t)}function b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(b=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}var x=function(t){function e(){return y(this,e),v(this,e,arguments)}return m(e,t),d(e)}(g(Error)),P=function(t){function e(t,r){var n;return y(this,e),l(n=v(this,e,[t]),"error",void 0),l(n,"message",void 0),n.message=t,n.error=r,n}return m(e,t),d(e)}(g(Event)),S="https://storage.googleapis.com",L=[".tar",".zip"],O="/dicomweb/",A="filePartial",k="fileStreaming",T=1e4,j="indexed_db_directory_handle_key",I={Partial:"partial"};const F={Enums:t,url:e,dataRetrieval:i};function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function D(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */D=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==_(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function N(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function U(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,R(n.key),n)}}function M(t,e,r){return(e=R(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function R(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_(e)?e:e+""}const B=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),M(this,"loaderRegistry",{}),M(this,"listenerCallback",(function(t,r,n){var i,a=null===(i=e.loaderRegistry[t])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(t){return t({data:n})}))}))},e=[{key:"register",value:function(t,e){try{if(!e)throw new x("Loader object for ".concat(t," is not provided"));this.loaderRegistry[t]={loaderObject:e,listeners:{}}}catch(t){throw console.warn(t),new x("throws")}}},{key:"executeTask",value:(n=D().mark((function t(e,r,n){var i,a,o=this;return D().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.loaderRegistry[e])||void 0===i?void 0:i.loaderObject){t.next=3;break}throw new x("Loader ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,a[r](n,(function(t){return o.listenerCallback(e,"message",t)}));case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on "').concat(e,'":'),t.t0),new x('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){N(a,r,i,o,c,"next",t)}function c(t){N(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]?n.listeners[e].push(r):n.listeners[e]=[r]:console.error("Loader '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.loaderRegistry[t];n?n.listeners[e]=(n.listeners[e]||[]).filter((function(t){return t!==r})):console.error("Loader '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],e&&U(t.prototype,e),r&&U(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2019 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
*/
|
|
20
|
-
const G=Symbol("Comlink.proxy"),C=Symbol("Comlink.endpoint"),q=Symbol("Comlink.releaseProxy"),z=Symbol("Comlink.finalizer"),W=Symbol("Comlink.thrown"),H=t=>"object"==typeof t&&null!==t||"function"==typeof t,Y=new Map([["proxy",{canHandle:t=>H(t)&&t[G],serialize(t){const{port1:e,port2:r}=new MessageChannel;return J(t,e),[r,[r]]},deserialize:t=>(t.start(),K(t))}],["throw",{canHandle:t=>H(t)&&W 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 J(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(i){if(!i||!i.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:c}=Object.assign({path:[]},i.data),s=(i.data.argumentList||[]).map(it);let u;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(o){case"GET":u=r;break;case"SET":e[c.slice(-1)[0]]=it(i.data.value),u=!0;break;case"APPLY":u=r.apply(e,s);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[G]:!0})}(new r(...s));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;J(t,r),u=function(t,e){return rt.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[W]:0}}Promise.resolve(u).catch((t=>({value:t,[W]:0}))).then((r=>{const[i,c]=nt(r);e.postMessage(Object.assign(Object.assign({},i),{id:a}),c),"RELEASE"===o&&(e.removeEventListener("message",n),V(e),z in t&&"function"==typeof t[z]&&t[z]())})).catch((t=>{const[r,n]=nt({value:new TypeError("Unserializable return value"),[W]:0});e.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),e.start&&e.start()}function V(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function K(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)}})),tt(t,r,[],e)}function Q(t){if(t)throw new Error("Proxy has been released and is not useable")}function Z(t){return at(t,new Map,{type:"RELEASE"}).then((()=>{V(t)}))}const $=new WeakMap,X="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=($.get(t)||0)-1;$.set(t,e),0===e&&Z(t)}));function tt(t,e,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(Q(i),o===q)return()=>{!function(t){X&&X.unregister(t)}(a),Z(t),e.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=at(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(it);return n.then.bind(n)}return tt(t,e,[...r,o])},set(n,a,o){Q(i);const[c,s]=nt(o);return at(t,e,{type:"SET",path:[...r,a].map((t=>t.toString())),value:c},s).then(it)},apply(n,a,o){Q(i);const c=r[r.length-1];if(c===C)return at(t,e,{type:"ENDPOINT"}).then(it);if("bind"===c)return tt(t,e,r.slice(0,-1));const[s,u]=et(o);return at(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:s},u).then(it)},construct(n,a){Q(i);const[o,c]=et(a);return at(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:o},c).then(it)}});return function(t,e){const r=($.get(e)||0)+1;$.set(e,r),X&&X.register(t,e,t)}(a,t),a}function et(t){const e=t.map(nt);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const rt=new WeakMap;function nt(t){for(const[e,r]of Y)if(r.canHandle(t)){const[n,i]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},rt.get(t)||[]]}function it(t){switch(t.type){case"HANDLER":return Y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function at(t,e,r,n){return new Promise((i=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(a,i),t.start&&t.start(),t.postMessage(Object.assign({id:a},r),n)}))}function ot(t){return ot="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},ot(t)}function ct(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ct=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ot(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ot(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function st(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function 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,ft(n.key),n)}}function ft(t){var e=function(t,e){if("object"!=ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ot(e)?e:e+""}const lt=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=ft(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 x("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:K(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ct().mark((function t(e,r,n){var i,a;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.workerRegistry[e])||void 0===i?void 0:i.instance){t.next=3;break}throw new x("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 x('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){st(a,r,i,o,c,"next",t)}function c(t){st(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.addEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.removeEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],e&&ut(t.prototype,e),r&&ut(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function ht(t){return ht="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},ht(t)}function dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */dt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ht(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ht(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function pt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function yt(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 vt(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"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ht(e)?e:e+""}var gt=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),vt(this,"dataRetriever",void 0),vt(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new B,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new lt,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=vt(vt({},c.WORKER,lt),c.REQUEST,B);if(!(t in e))throw new x("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=dt().mark((function t(e,r,n){return dt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){pt(a,r,i,o,c,"next",t)}function c(t){pt(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){this.dataRetriever.addEventListener(t,e,r)}},{key:"removeEventListener",value:function(t,e,r){this.dataRetriever.removeEventListener(t,e,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],e&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}());function bt(){return gt}function wt(t){return wt="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},wt(t)}function Et(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return xt(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)?xt(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 xt(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 Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lt(n.key),n)}}function St(t,e,r){return(e=Lt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lt(t){var e=function(t,e){if("object"!=wt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wt(e)?e:e+""}const Ot=function(){return t=function t(e){var r=e.fileStreamingScriptName;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),St(this,"files",{}),St(this,"fileStreamingScriptName",void 0),this.fileStreamingScriptName=r},(e=[{key:"set",value:function(t,e){this.files[t]=e}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e)}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(t,e){var r=Et(e,2),n=r[0],i=r[1].position;return n.includes("?bytes=")?t:t+i}),0)}},{key:"remove",value:function(t){var e=this.getPosition(t);delete this.files[t],t.includes("?bytes=")||bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",e)}},{key:"purge",value:function(){var t=this.getTotalSize();this.files={},bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",t)}}])&&Pt(t.prototype,e),r&&Pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function At(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return kt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?kt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Tt(t,e){if(t.includes(_.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],i=n.split("/studies")[0],a=i.split("/"),c=a[0],s=a.slice(1).join("/"),u=n.split(i+"/")[1].split("/"),f=u[1],l=u[3],h="",d=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(h=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):h=u[5],d=+u[7],r=o.FRAME;break;default:throw new x("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:s,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function jt(t,e,r,n){var i,a;if(!t||null===(i=t.cod)||void 0===i||!i.instances)throw new x("Invalid seriesMetadata provided.");if(null==r)throw new x("Frame index is required.");var o,c=n.domain,s=n.bucketName,u=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;o="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(a=Object.entries(t.cod.instances).find((function(t){var r=At(t,2),n=r[0];r[1];return n===e})))||void 0===a?void 0:a[1];if(!l)return{thumbnailUrl:o};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var i=t,a=_.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(a){i=t.split(a)[0]+a}var o=i.split("studies/")[1];return i="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),i}(p||y,c,s,u),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,E=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],E=!0);var P=v.start_byte,S=v.end_byte;return{url:g,startByte:void 0!==h?P+h:P,endByte:void 0!==d?P+d:S,thumbnailUrl:o,isMultiframe:E}}function It(t){var e=t.domain,r=void 0===e?_.url.DOMAIN:e,n=t.bucketName,i=t.bucketPrefix,a=t.studyInstanceUID,o=t.seriesInstanceUID;if(n&&i&&a&&o)return"".concat(r,"/").concat(n,"/").concat(i,"/studies/").concat(a,"/series/").concat(o,"/metadata.json")}function _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,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==_t(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(_t(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Dt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function 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,Ut(n.key),n)}}function Ut(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 Rt=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=Ut(r="metadataPromises"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"addDeidMetadata",value:function(t){var e=t.deid_study_uid,r=t.deid_series_uid,n=t.cod;if(n&&e&&r)for(var i in n.instances){var a=n.instances[i];a.metadata.DeidStudyInstanceUID={Value:[e]},a.metadata.DeidSeriesInstanceUID={Value:[r]},a.metadata.DeidSopInstanceUID={Value:[i]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=Ft().mark((function t(e,r){var n,i,a=this;return Ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=It(e)){t.next=3;break}throw new x("Error creating metadata json url");case 3:if(!(i=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,i;case 7:case 12:return t.abrupt("return",t.sent);case 8:return t.prev=8,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new x("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return a.addDeidMetadata(t),t})),t.next=12,this.metadataPromises[n];case 15:throw t.prev=15,t.t0=t.catch(8),console.error(t.t0),t.t0;case 19:case"end":return t.stop()}}),t,this,[[8,15]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){Dt(a,r,i,o,c,"next",t)}function c(t){Dt(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e){return i.apply(this,arguments)})}],e&&Nt(t.prototype,e),r&&Nt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function Mt(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function Bt(t,e){let r;return(n,i)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=Mt(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>i(t.transaction(e,n).objectStore(e))))}let Gt;function Ct(){return Gt||(Gt=Bt("keyval-store","keyval")),Gt}function qt(t,e=Ct()){return e("readonly",(e=>Mt(e.get(t))))}function zt(t){return zt="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},zt(t)}function Wt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Wt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==zt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(zt(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Ht(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Yt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){Ht(a,n,i,o,c,"next",t)}function c(t){Ht(a,n,i,o,c,"throw",t)}o(void 0)}))}}var Jt;function Vt(){return Kt.apply(this,arguments)}function Kt(){return(Kt=Yt(Wt().mark((function t(){return Wt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,Jt){t.next=5;break}return t.next=4,qt(j);case 4:Jt=t.sent;case 5:if(Jt){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:Jt=t.sent;case 9:return t.abrupt("return",Jt);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 Qt(t,e,r){return Zt.apply(this,arguments)}function Zt(){return Zt=Yt(Wt().mark((function t(e,r,n){var i,a,o,c,s,u,f,l,h;return Wt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:i=r.split("/"),a=e,t.prev=4,o=0;case 6:if(!(o<i.length-1)){t.next=13;break}return t.next=9,a.getDirectoryHandle(i[o]);case 9:a=t.sent;case 10:o++,t.next=6;break;case 13:return c=i.at(-1),t.next=16,a.getFileHandle(c);case 16:return s=t.sent,t.next=19,s.getFile().then((function(t){return t.arrayBuffer()}));case 19:return t.abrupt("return",t.sent);case 22:if(t.prev=22,t.t0=t.catch(4),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message)),!n||i[0]!==I.Partial){t.next=49;break}t.prev=26,u=i.at(-1).slice(0,r.lastIndexOf(".")).split("_")[0],i=i.slice(1),f=0;case 30:if(!(f<i.length-1)){t.next=37;break}return t.next=33,a.getDirectoryHandle(i[f]);case 33:a=t.sent;case 34:f++,t.next=30;break;case 37:return t.next=39,e.getFileHandle(u+".tar");case 39:return l=t.sent,t.next=42,l.getFile().then((function(t){return t.arrayBuffer()}));case 42:return h=t.sent,t.abrupt("return",h.slice(n.startByte,n.endByte));case 46:t.prev=46,t.t1=t.catch(26),console.warn("Error reading the file ".concat(r,": ").concat(t.t1.message));case 49:case"end":return t.stop()}}),t,null,[[4,22],[26,46]])}))),Zt.apply(this,arguments)}function $t(t,e,r){return Xt.apply(this,arguments)}function Xt(){return Xt=Yt(Wt().mark((function t(e,r,n){var i,a,o,c,s,u;return Wt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,i=r.split("/"),a=e,o=0;case 4:if(!(o<i.length-1)){t.next=11;break}return t.next=7,a.getDirectoryHandle(i[o],{create:!0});case 7:a=t.sent;case 8:o++,t.next=4;break;case 11:return c=i[i.length-1],t.next=14,a.getFileHandle(c,{create:!0});case 14:return s=t.sent,t.next=17,s.createWritable();case 17:return u=t.sent,t.next=20,u.write(n);case 20:return t.next=22,u.close();case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(0),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 27:case"end":return t.stop()}}),t,null,[[0,24]])}))),Xt.apply(this,arguments)}function te(){return ee.apply(this,arguments)}function ee(){return(ee=Yt(Wt().mark((function t(){return Wt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Jt.removeEntry(I.Partial,{recursive:!0});case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),console.warn("Error clearing partial files: ".concat(t.t0.message));case 8:case"end":return t.stop()}}),t,null,[[0,5]])})))).apply(this,arguments)}function re(t){return t.split("series/")[1]}function ne(t,e){var r=t.split("series/")[1].split(".tar")[0],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(I.Partial,"/").concat(r).concat(n,".dcm")}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 ae(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ae=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ie(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ie(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function oe(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var ce={partial:function(t,e){return(r=ae().mark((function r(){var n,i,a,o,c,s;return ae().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,i=t.offsets,a=t.headers,o=t.directoryHandle,null!=i&&i.startByte&&null!=i&&i.endByte&&(a.Range="bytes=".concat(i.startByte,"-").concat(i.endByte-1)),c=ne(n,i),!o){r.next=10;break}return r.next=6,Qt(o,c,i);case 6:if(!(s=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(s),offsets:i}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:a}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:i}),o&&$t(o,c,t)})).catch((function(t){throw new x("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){oe(a,n,i,o,c,"next",t)}function c(t){oe(a,n,i,o,c,"throw",t)}o(void 0)}))})();var r}};const se=ce;function ue(t){return ue="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},ue(t)}function fe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */fe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ue(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ue(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function 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 he(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){de(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 de(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ue(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ue(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var ye={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(t){t>0&&(this.maxFetchSize=t)},decreaseFetchedSize:function(t){t>0&&t<=this.fetchedSize&&(this.fetchedSize-=t)},stream:function(t,e){var r,n=this;return(r=fe().mark((function r(){var i,a,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,E,P;return fe().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=t.url,a=t.headers,o=t.useSharedArrayBuffer,c=t.directoryHandle,s=new AbortController,u=null,f=null,r.prev=4,h=re(i),!c){r.next=13;break}return r.next=9,Qt(c,h);case 9:if(!(d=r.sent)){r.next=13;break}return e({url:i,position:d.byteLength,fileArraybuffer:new Uint8Array(d)}),r.abrupt("return");case 13:return r.next=15,fetch(i,{headers:he({},a),signal:s.signal});case 15:if((p=r.sent).ok){r.next=18;break}throw new x("HTTP error! status: ".concat(p.status));case 18:if(y=null===(l=p.body)||void 0===l?void 0:l.getReader()){r.next=21;break}throw new x("Failed to get reader from response body");case 21:return m=!1,g=parseInt(p.headers.get("Content-Length")||"0",10),r.next=25,y.read();case 25:if(b=r.sent,m=b.done,b.value){r.next=29;break}throw new x("The fetched chunks does not have value");case 29:if(m){r.next=58;break}if(w=b.value.length,!(n.fetchedSize+w>n.maxFetchSize)){r.next=34;break}throw s.abort(),new x("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 34:n.fetchedSize+=w,o?(u=new SharedArrayBuffer(g),f=new Uint8Array(u)):f=new Uint8Array(g),f.set(b.value),e({url:i,position:w,fileArraybuffer:f});case 38:if(m){r.next=57;break}return r.next=41,y.read();case 41:if(!(v=r.sent).done){r.next=45;break}return m=!0,r.abrupt("continue",38);case 45:if(E=v.value,!(n.fetchedSize+E.length>n.maxFetchSize)){r.next=51;break}throw u=null,f=null,s.abort(),new x("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 51:n.fetchedSize+=E.length,f.set(E,w),w+=E.length,e({isAppending:!0,url:i,position:w,chunk:o?void 0:E}),r.next=38;break;case 57:c&&$t(c,h,f.slice().buffer);case 58:r.next=65;break;case 60:throw r.prev=60,r.t0=r.catch(4),P=new x("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 65:return r.prev=65,u=null,f=null,s.abort(),r.finish(65);case 70:case"end":return r.stop()}}),r,null,[[4,60,65,70]])})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){pe(a,n,i,o,c,"next",t)}function c(t){pe(a,n,i,o,c,"throw",t)}o(void 0)}))})()}};const ve=ye;function me(t){return me="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},me(t)}function ge(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return be(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)?be(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 be(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 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,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==me(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(me(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Ee(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function xe(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){Ee(a,n,i,o,c,"next",t)}function c(t){Ee(a,n,i,o,c,"throw",t)}o(void 0)}))}}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,Le(n.key),n)}}function Se(t,e,r){return(e=Le(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Le(t){var e=function(t,e){if("object"!=me(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==me(e)?e:e+""}var Oe=function(){return t=function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Se(this,"filePromises",{}),Se(this,"options",{maxWorkerFetchSize:1/0,domain:_.url.DOMAIN,enableLocalCache:!1}),Se(this,"fileManager",void 0),Se(this,"metadataManager",void 0),Se(this,"seriesUidFileUrls",{}),Se(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Se(this,"getOptions",(function(){return e.options}));var i=n.maxWorkerFetchSize,a=n.domain,o=n.disableWorker,s=n.enableLocalCache;this.options.maxWorkerFetchSize=i||this.options.maxWorkerFetchSize,this.options.domain=a||this.options.domain,this.options.enableLocalCache=!!s;var u=_.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=_.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Ot({fileStreamingScriptName:u}),this.metadataManager=new Rt,o&&bt().setDataRetrieverMode(c.REQUEST),function(t,e){var n=t.fileStreamingScriptName,i=t.filePartialScriptName,a=bt();a.getDataRetrieverMode()===c.REQUEST?(a.register(n,ve),a.register(i,se)):(a.register(n,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:n})})),a.register(i,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:i})}))),a.executeTask(n,"setMaxFetchSize",e)}({fileStreamingScriptName:u,filePartialScriptName:f},this.options.maxWorkerFetchSize)},e=[{key:"addFileUrl",value:function(t,e,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=xe(we().mark((function t(e){var r,n,i,c,f,l,h,d,p,y,v,m,g,b,w,E,P,S,L,O,A,k,T,j=this,I=arguments;return we().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=I.length>1&&void 0!==I[1]?I[1]:{},i=(n=I.length>2&&void 0!==I[2]?I[2]:{}).useSharedArrayBuffer,c=void 0!==i&&i,f=n.fetchType,l=void 0===f?_.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new x("Url not provided");case 5:if(!(h=Tt(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 x("Metadata not found for ".concat(e));case 13:E=jt(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),P=E.url,S=E.startByte,L=E.endByte,O=E.thumbnailUrl,A=E.isMultiframe,t.t0=d,t.next=t.t0===o.THUMBNAIL?17:t.t0===o.FRAME?21:t.t0===o.SERIES_METADATA||t.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new x("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,s.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(P){t.next=23;break}throw new x("Url not found for frame");case 23:return k=P,l===a.BYTES_OPTIMIZED&&(k="".concat(P,"?bytes=").concat(S,"-").concat(L)),this.addFileUrl(m,s.FILE,P),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:S,endByte:L},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new x("File Arraybuffer is not found");if(A)return t;var e=(0,u.parseDicom)(new Uint8Array(t)).elements.x7fe00010,r=e.dataOffset,n=e.length;if(e.hadUndefinedLength&&e.fragments){var i=e.fragments[0];r=i.position,n=i.length}else r+=8;return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new x("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,u.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,s.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),T=new x("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(T),T;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return f.apply(this,arguments)})},{key:"fetchFile",value:(i=xe(we().mark((function t(e,r){var n,i,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,E=this,S=arguments;return we().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=(n=S.length>2&&void 0!==S[2]?S[2]:{}).offsets,o=n.useSharedArrayBuffer,c=void 0!==o&&o,s=n.fetchType,u=void 0===s?_.Enums.FetchType.API_OPTIMIZED:s,f=u===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:i))){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){try{t(l.buffer)}catch(t){e(t)}})));case 5:if(t.t0=this.options.enableLocalCache,!t.t0){t.next=10;break}return t.next=9,Vt();case 9:t.t0=t.sent;case 10:return h=t.t0,d=this.getOptions(),p=d.maxWorkerFetchSize,y=bt(),v=_.dataRetrieval,m=v.FILE_STREAMING_WORKER_NAME,g=v.FILE_PARTIAL_WORKER_NAME,b=v.THRESHOLD,this.filePromises[e]?w=this.filePromises[e]:(w=new Promise((function(t,n){if(E.fileManager.getTotalSize()+b>p)throw new x("CodDicomWebServer.ts: Maximum size(".concat(p,") for fetching files reached"));var a=_.Enums.FetchType;if(u===a.API_OPTIMIZED){var o=function(t){if(t instanceof P)throw n(t.error),t.error;var r=t.data,i=r.url,a=r.position,c=r.fileArraybuffer;i===e&&c&&(E.fileManager.set(i,{data:c,position:a}),y.removeEventListener(m,"message",o))};y.addEventListener(m,"message",o),y.executeTask(m,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){y.removeEventListener(m,"message",o),delete E.filePromises[e]}))}else if(u===a.BYTES_OPTIMIZED&&i){var s=i.startByte,f=i.endByte,l=e.split("?bytes=")[0],d=function(r){if(r instanceof P)throw n(r.error),r.error;var i=r.data,a=i.url,o=i.fileArraybuffer,c=i.offsets;a===l&&c.startByte===s&&c.endByte===f&&(E.fileManager.set(e,{data:o,position:o.length}),y.removeEventListener(g,"message",d),t())};y.addEventListener(g,"message",d),y.executeTask(g,"partial",{url:l,offsets:{startByte:s,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){y.removeEventListener(g,"message",d),delete E.filePromises[e]}))}else n(new x("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]=w),t.abrupt("return",new Promise((function(t,r){var n=!1,a=function(a){if(a instanceof P)throw r(a.message),a.error;var o=a.data,c=o.url,s=o.position,u=o.chunk;if(o.isAppending&&(u?E.fileManager.append(c,u,s):E.fileManager.setPosition(c,s)),!n&&c===e&&i&&s>i.endByte)try{var f=E.fileManager.get(c,i);n=!0,t(null==f?void 0:f.buffer)}catch(t){r(t)}};i&&!f&&y.addEventListener(m,"message",a),w.then((function(){if(!n)if(E.fileManager.getPosition(e)){var a=E.fileManager.get(e,f?void 0:i);n=!0,t(null==a?void 0:a.buffer)}else r(new x("File - ".concat(e," not found")))})).catch((function(t){r(t)})).then((function(){y.removeEventListener(m,"message",a)}))})));case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"downloadSeriesFile",value:function(t){var e,r=null===(e=Array.from(this.seriesUidFileUrls[t]).find((function(t){var e=t.url;return t.type===s.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),i=document.createElement("a");return i.href=n,i.download=t,i.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===o.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=ge(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&&Pe(t.prototype,e),n&&Pe(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i,f}();const Ae=Oe,ke={FetchType:a,CodDicomWebServer:Oe,clearPartialFiles:te}})(),n})()));
|
|
20
|
+
const G=Symbol("Comlink.proxy"),C=Symbol("Comlink.endpoint"),q=Symbol("Comlink.releaseProxy"),z=Symbol("Comlink.finalizer"),W=Symbol("Comlink.thrown"),H=t=>"object"==typeof t&&null!==t||"function"==typeof t,Y=new Map([["proxy",{canHandle:t=>H(t)&&t[G],serialize(t){const{port1:e,port2:r}=new MessageChannel;return J(t,e),[r,[r]]},deserialize:t=>(t.start(),K(t))}],["throw",{canHandle:t=>H(t)&&W 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 J(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(i){if(!i||!i.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:c}=Object.assign({path:[]},i.data),s=(i.data.argumentList||[]).map(it);let u;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(o){case"GET":u=r;break;case"SET":e[c.slice(-1)[0]]=it(i.data.value),u=!0;break;case"APPLY":u=r.apply(e,s);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[G]:!0})}(new r(...s));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;J(t,r),u=function(t,e){return rt.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[W]:0}}Promise.resolve(u).catch((t=>({value:t,[W]:0}))).then((r=>{const[i,c]=nt(r);e.postMessage(Object.assign(Object.assign({},i),{id:a}),c),"RELEASE"===o&&(e.removeEventListener("message",n),V(e),z in t&&"function"==typeof t[z]&&t[z]())})).catch((t=>{const[r,n]=nt({value:new TypeError("Unserializable return value"),[W]:0});e.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),e.start&&e.start()}function V(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function K(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)}})),tt(t,r,[],e)}function Q(t){if(t)throw new Error("Proxy has been released and is not useable")}function Z(t){return at(t,new Map,{type:"RELEASE"}).then((()=>{V(t)}))}const $=new WeakMap,X="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=($.get(t)||0)-1;$.set(t,e),0===e&&Z(t)}));function tt(t,e,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(Q(i),o===q)return()=>{!function(t){X&&X.unregister(t)}(a),Z(t),e.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=at(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(it);return n.then.bind(n)}return tt(t,e,[...r,o])},set(n,a,o){Q(i);const[c,s]=nt(o);return at(t,e,{type:"SET",path:[...r,a].map((t=>t.toString())),value:c},s).then(it)},apply(n,a,o){Q(i);const c=r[r.length-1];if(c===C)return at(t,e,{type:"ENDPOINT"}).then(it);if("bind"===c)return tt(t,e,r.slice(0,-1));const[s,u]=et(o);return at(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:s},u).then(it)},construct(n,a){Q(i);const[o,c]=et(a);return at(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:o},c).then(it)}});return function(t,e){const r=($.get(e)||0)+1;$.set(e,r),X&&X.register(t,e,t)}(a,t),a}function et(t){const e=t.map(nt);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const rt=new WeakMap;function nt(t){for(const[e,r]of Y)if(r.canHandle(t)){const[n,i]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},rt.get(t)||[]]}function it(t){switch(t.type){case"HANDLER":return Y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function at(t,e,r,n){return new Promise((i=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(a,i),t.start&&t.start(),t.postMessage(Object.assign({id:a},r),n)}))}function ot(t){return ot="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},ot(t)}function ct(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ct=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ot(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ot(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function st(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function 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,ft(n.key),n)}}function ft(t){var e=function(t,e){if("object"!=ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ot(e)?e:e+""}const lt=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=ft(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 x("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:K(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ct().mark((function t(e,r,n){var i,a;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=null===(i=this.workerRegistry[e])||void 0===i?void 0:i.instance){t.next=3;break}throw new x("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 x('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){st(a,r,i,o,c,"next",t)}function c(t){st(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.addEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.removeEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],e&&ut(t.prototype,e),r&&ut(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function ht(t){return ht="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},ht(t)}function dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */dt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==ht(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(ht(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function pt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function yt(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 vt(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"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ht(e)?e:e+""}var gt=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),vt(this,"dataRetriever",void 0),vt(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new B,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new lt,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=vt(vt({},c.WORKER,lt),c.REQUEST,B);if(!(t in e))throw new x("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=dt().mark((function t(e,r,n){return dt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){pt(a,r,i,o,c,"next",t)}function c(t){pt(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){this.dataRetriever.addEventListener(t,e,r)}},{key:"removeEventListener",value:function(t,e,r){this.dataRetriever.removeEventListener(t,e,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],e&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}());function bt(){return gt}function wt(t){return wt="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},wt(t)}function Et(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return xt(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)?xt(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 xt(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 Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lt(n.key),n)}}function St(t,e,r){return(e=Lt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lt(t){var e=function(t,e){if("object"!=wt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wt(e)?e:e+""}const Ot=function(){return t=function t(e){var r=e.fileStreamingScriptName;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),St(this,"files",{}),St(this,"fileStreamingScriptName",void 0),this.fileStreamingScriptName=r},(e=[{key:"set",value:function(t,e){this.files[t]=e}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e)}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(t,e){var r=Et(e,2),n=r[0],i=r[1].position;return n.includes("?bytes=")?t:t+i}),0)}},{key:"remove",value:function(t){var e=this.getPosition(t);delete this.files[t],t.includes("?bytes=")||bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",e)}},{key:"purge",value:function(){var t=this.getTotalSize();this.files={},bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",t)}}])&&Pt(t.prototype,e),r&&Pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function At(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return kt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?kt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Tt(t,e){if(t.includes(F.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],i=n.split("/studies")[0],a=i.split("/"),c=a[0],s=a.slice(1).join("/"),u=n.split(i+"/")[1].split("/"),f=u[1],l=u[3],h="",d=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(h=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):h=u[5],d=+u[7],r=o.FRAME;break;default:throw new x("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:s,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function jt(t,e,r,n){var i,a;if(!t||null===(i=t.cod)||void 0===i||!i.instances)throw new x("Invalid seriesMetadata provided.");if(null==r)throw new x("Frame index is required.");var o,c=n.domain,s=n.bucketName,u=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;o="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(a=Object.entries(t.cod.instances).find((function(t){var r=At(t,2),n=r[0];r[1];return n===e})))||void 0===a?void 0:a[1];if(!l)return{thumbnailUrl:o};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var i=t,a=F.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(a){i=t.split(a)[0]+a}var o=i.split("studies/")[1];return i="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),i}(p||y,c,s,u),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,E=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],E=!0);var P=v.start_byte,S=v.end_byte;return{url:g,startByte:void 0!==h?P+h:P,endByte:void 0!==d?P+d:S,thumbnailUrl:o,isMultiframe:E}}function It(t){var e=t.domain,r=void 0===e?F.url.DOMAIN:e,n=t.bucketName,i=t.bucketPrefix,a=t.studyInstanceUID,o=t.seriesInstanceUID;if(n&&i&&a&&o)return"".concat(r,"/").concat(n,"/").concat(i,"/studies/").concat(a,"/series/").concat(o,"/metadata.json")}function Ft(t){return Ft="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},Ft(t)}function _t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_t=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==Ft(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Ft(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Dt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Nt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ut(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)?Ut(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 Ut(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 Mt(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 Rt(t){var e=function(t,e){if("object"!=Ft(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Ft(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ft(e)?e:e+""}const Bt=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=Rt(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,i=Nt(null===(r=e.match(/studies\/(.*?)\/metadata/))||void 0===r?void 0:r[1].split("/"),3),a=i[0],o=(i[1],i[2]);if(n&&a&&o)for(var c in n.instances){var s=n.instances[c];s.metadata.DeidStudyInstanceUID={Value:[a]},s.metadata.DeidSeriesInstanceUID={Value:[o]},s.metadata.DeidSopInstanceUID={Value:[c]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=_t().mark((function t(e,r){var n,i,a=this;return _t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=It(e)){t.next=3;break}throw new x("Error creating metadata json url");case 3:if(!(i=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,i;case 7:case 12:return t.abrupt("return",t.sent);case 8:return t.prev=8,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new x("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return a.addDeidMetadata(t,n),t})),t.next=12,this.metadataPromises[n];case 15:throw t.prev=15,t.t0=t.catch(8),console.error(t.t0),t.t0;case 19:case"end":return t.stop()}}),t,this,[[8,15]])})),i=function(){var t=this,e=arguments;return new Promise((function(r,i){var a=n.apply(t,e);function o(t){Dt(a,r,i,o,c,"next",t)}function c(t){Dt(a,r,i,o,c,"throw",t)}o(void 0)}))},function(t,e){return i.apply(this,arguments)})}],e&&Mt(t.prototype,e),r&&Mt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i}();function Gt(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function Ct(t,e){let r;return(n,i)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=Gt(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>i(t.transaction(e,n).objectStore(e))))}let qt;function zt(){return qt||(qt=Ct("keyval-store","keyval")),qt}function Wt(t,e=zt()){return e("readonly",(e=>Gt(e.get(t))))}function Ht(t){return Ht="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},Ht(t)}function Yt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Yt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==Ht(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Ht(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Jt(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){Jt(a,n,i,o,c,"next",t)}function c(t){Jt(a,n,i,o,c,"throw",t)}o(void 0)}))}}var Kt;function Qt(){return Zt.apply(this,arguments)}function Zt(){return(Zt=Vt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,Kt){t.next=5;break}return t.next=4,Wt(j);case 4:Kt=t.sent;case 5:if(Kt){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:Kt=t.sent;case 9:return t.abrupt("return",Kt);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 $t(t,e,r){return Xt.apply(this,arguments)}function Xt(){return Xt=Vt(Yt().mark((function t(e,r,n){var i,a,o,c,s,u,f,l,h;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:i=r.split("/"),a=e,t.prev=4,o=0;case 6:if(!(o<i.length-1)){t.next=13;break}return t.next=9,a.getDirectoryHandle(i[o]);case 9:a=t.sent;case 10:o++,t.next=6;break;case 13:return c=i.at(-1),t.next=16,a.getFileHandle(c);case 16:return s=t.sent,t.next=19,s.getFile().then((function(t){return t.arrayBuffer()}));case 19:return t.abrupt("return",t.sent);case 22:if(t.prev=22,t.t0=t.catch(4),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message)),!n||i[0]!==I.Partial){t.next=49;break}t.prev=26,u=i.at(-1).slice(0,r.lastIndexOf(".")).split("_")[0],i=i.slice(1),f=0;case 30:if(!(f<i.length-1)){t.next=37;break}return t.next=33,a.getDirectoryHandle(i[f]);case 33:a=t.sent;case 34:f++,t.next=30;break;case 37:return t.next=39,e.getFileHandle(u+".tar");case 39:return l=t.sent,t.next=42,l.getFile().then((function(t){return t.arrayBuffer()}));case 42:return h=t.sent,t.abrupt("return",h.slice(n.startByte,n.endByte));case 46:t.prev=46,t.t1=t.catch(26),console.warn("Error reading the file ".concat(r,": ").concat(t.t1.message));case 49:case"end":return t.stop()}}),t,null,[[4,22],[26,46]])}))),Xt.apply(this,arguments)}function te(t,e,r){return ee.apply(this,arguments)}function ee(){return ee=Vt(Yt().mark((function t(e,r,n){var i,a,o,c,s,u;return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,i=r.split("/"),a=e,o=0;case 4:if(!(o<i.length-1)){t.next=11;break}return t.next=7,a.getDirectoryHandle(i[o],{create:!0});case 7:a=t.sent;case 8:o++,t.next=4;break;case 11:return c=i[i.length-1],t.next=14,a.getFileHandle(c,{create:!0});case 14:return s=t.sent,t.next=17,s.createWritable();case 17:return u=t.sent,t.next=20,u.write(n);case 20:return t.next=22,u.close();case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(0),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 27:case"end":return t.stop()}}),t,null,[[0,24]])}))),ee.apply(this,arguments)}function re(){return ne.apply(this,arguments)}function ne(){return(ne=Vt(Yt().mark((function t(){return Yt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Kt.removeEntry(I.Partial,{recursive:!0});case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),console.warn("Error clearing partial files: ".concat(t.t0.message));case 8:case"end":return t.stop()}}),t,null,[[0,5]])})))).apply(this,arguments)}function ie(t){return t.split("series/")[1]}function ae(t,e){var r=t.split("series/")[1].split(".tar")[0],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(I.Partial,"/").concat(r).concat(n,".dcm")}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 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,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==oe(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(oe(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function se(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var ue={partial:function(t,e){return(r=ce().mark((function r(){var n,i,a,o,c,s;return ce().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,i=t.offsets,a=t.headers,o=t.directoryHandle,null!=i&&i.startByte&&null!=i&&i.endByte&&(a.Range="bytes=".concat(i.startByte,"-").concat(i.endByte-1)),c=ae(n,i),!o){r.next=10;break}return r.next=6,$t(o,c,i);case 6:if(!(s=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(s),offsets:i}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:a}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:i}),o&&te(o,c,t)})).catch((function(t){throw new x("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){se(a,n,i,o,c,"next",t)}function c(t){se(a,n,i,o,c,"throw",t)}o(void 0)}))})();var r}};const fe=ue;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,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==le(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(le(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function de(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 pe(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?de(Object(r),!0).forEach((function(e){ye(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ye(t,e,r){return(e=function(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+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ve(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}var me={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(t){t>0&&(this.maxFetchSize=t)},decreaseFetchedSize:function(t){t>0&&t<=this.fetchedSize&&(this.fetchedSize-=t)},stream:function(t,e){var r,n=this;return(r=he().mark((function r(){var i,a,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,E,P;return he().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(i=t.url,a=t.headers,o=t.useSharedArrayBuffer,c=t.directoryHandle,s=new AbortController,u=null,f=null,r.prev=4,h=ie(i),!c){r.next=13;break}return r.next=9,$t(c,h);case 9:if(!(d=r.sent)){r.next=13;break}return e({url:i,position:d.byteLength,fileArraybuffer:new Uint8Array(d)}),r.abrupt("return");case 13:return r.next=15,fetch(i,{headers:pe({},a),signal:s.signal});case 15:if((p=r.sent).ok){r.next=18;break}throw new x("HTTP error! status: ".concat(p.status));case 18:if(y=null===(l=p.body)||void 0===l?void 0:l.getReader()){r.next=21;break}throw new x("Failed to get reader from response body");case 21:return m=!1,g=parseInt(p.headers.get("Content-Length")||"0",10),r.next=25,y.read();case 25:if(b=r.sent,m=b.done,b.value){r.next=29;break}throw new x("The fetched chunks does not have value");case 29:if(m){r.next=58;break}if(w=b.value.length,!(n.fetchedSize+w>n.maxFetchSize)){r.next=34;break}throw s.abort(),new x("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 34:n.fetchedSize+=w,o?(u=new SharedArrayBuffer(g),f=new Uint8Array(u)):f=new Uint8Array(g),f.set(b.value),e({url:i,position:w,fileArraybuffer:f});case 38:if(m){r.next=57;break}return r.next=41,y.read();case 41:if(!(v=r.sent).done){r.next=45;break}return m=!0,r.abrupt("continue",38);case 45:if(E=v.value,!(n.fetchedSize+E.length>n.maxFetchSize)){r.next=51;break}throw u=null,f=null,s.abort(),new x("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 51:n.fetchedSize+=E.length,f.set(E,w),w+=E.length,e({isAppending:!0,url:i,position:w,chunk:o?void 0:E}),r.next=38;break;case 57:c&&te(c,h,f.slice().buffer);case 58:r.next=65;break;case 60:throw r.prev=60,r.t0=r.catch(4),P=new x("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 65:return r.prev=65,u=null,f=null,s.abort(),r.finish(65);case 70:case"end":return r.stop()}}),r,null,[[4,60,65,70]])})),function(){var t=this,e=arguments;return new Promise((function(n,i){var a=r.apply(t,e);function o(t){ve(a,n,i,o,c,"next",t)}function c(t){ve(a,n,i,o,c,"throw",t)}o(void 0)}))})()}};const ge=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(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,c=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ee(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)?Ee(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 Ee(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 xe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */xe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,o=Object.create(a.prototype),c=new j(n||[]);return i(o,"_invoke",{value:O(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(i,a,o,c){var s=l(t[i],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==be(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,c)}))}c(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var c=n.delegate;if(c){var s=A(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(e,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,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(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function 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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(be(e)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(L.prototype),u(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new L(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),u(P,s,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return c.type="throw",c.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],c=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Pe(t,e,r,n,i,a,o){try{var c=t[a](o),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Se(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function o(t){Pe(a,n,i,o,c,"next",t)}function c(t){Pe(a,n,i,o,c,"throw",t)}o(void 0)}))}}function Le(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,Ae(n.key),n)}}function Oe(t,e,r){return(e=Ae(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ae(t){var e=function(t,e){if("object"!=be(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==be(e)?e:e+""}var ke=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),Oe(this,"filePromises",{}),Oe(this,"options",{maxWorkerFetchSize:1/0,domain:F.url.DOMAIN,enableLocalCache:!1}),Oe(this,"fileManager",void 0),Oe(this,"metadataManager",void 0),Oe(this,"seriesUidFileUrls",{}),Oe(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Oe(this,"getOptions",(function(){return e.options}));var i=n.maxWorkerFetchSize,a=n.domain,o=n.disableWorker,s=n.enableLocalCache;this.options.maxWorkerFetchSize=i||this.options.maxWorkerFetchSize,this.options.domain=a||this.options.domain,this.options.enableLocalCache=!!s;var u=F.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=F.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Ot({fileStreamingScriptName:u}),this.metadataManager=new Bt,o&&bt().setDataRetrieverMode(c.REQUEST),function(t,e){var n=t.fileStreamingScriptName,i=t.filePartialScriptName,a=bt();a.getDataRetrieverMode()===c.REQUEST?(a.register(n,ge),a.register(i,fe)):(a.register(n,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:n})})),a.register(i,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:i})}))),a.executeTask(n,"setMaxFetchSize",e)}({fileStreamingScriptName:u,filePartialScriptName:f},this.options.maxWorkerFetchSize)},e=[{key:"addFileUrl",value:function(t,e,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=Se(xe().mark((function t(e){var r,n,i,c,f,l,h,d,p,y,v,m,g,b,w,E,P,S,L,O,A,k,T,j=this,I=arguments;return xe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=I.length>1&&void 0!==I[1]?I[1]:{},i=(n=I.length>2&&void 0!==I[2]?I[2]:{}).useSharedArrayBuffer,c=void 0!==i&&i,f=n.fetchType,l=void 0===f?F.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new x("Url not provided");case 5:if(!(h=Tt(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 x("Metadata not found for ".concat(e));case 13:E=jt(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),P=E.url,S=E.startByte,L=E.endByte,O=E.thumbnailUrl,A=E.isMultiframe,t.t0=d,t.next=t.t0===o.THUMBNAIL?17:t.t0===o.FRAME?21:t.t0===o.SERIES_METADATA||t.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new x("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,s.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(P){t.next=23;break}throw new x("Url not found for frame");case 23:return k=P,l===a.BYTES_OPTIMIZED&&(k="".concat(P,"?bytes=").concat(S,"-").concat(L)),this.addFileUrl(m,s.FILE,P),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:S,endByte:L},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new x("File Arraybuffer is not found");if(A)return t;var e=(0,u.parseDicom)(new Uint8Array(t)).elements.x7fe00010,r=e.dataOffset,n=e.length;if(e.hadUndefinedLength&&e.fragments){var i=e.fragments[0];r=i.position,n=i.length}else r+=8;return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new x("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,u.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,s.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),T=new x("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(T),T;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return f.apply(this,arguments)})},{key:"fetchFile",value:(i=Se(xe().mark((function t(e,r){var n,i,o,c,s,u,f,l,h,d,p,y,v,m,g,b,w,E=this,S=arguments;return xe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=(n=S.length>2&&void 0!==S[2]?S[2]:{}).offsets,o=n.useSharedArrayBuffer,c=void 0!==o&&o,s=n.fetchType,u=void 0===s?F.Enums.FetchType.API_OPTIMIZED:s,f=u===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:i))){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){try{t(l.buffer)}catch(t){e(t)}})));case 5:if(t.t0=this.options.enableLocalCache,!t.t0){t.next=10;break}return t.next=9,Qt();case 9:t.t0=t.sent;case 10:return h=t.t0,d=this.getOptions(),p=d.maxWorkerFetchSize,y=bt(),v=F.dataRetrieval,m=v.FILE_STREAMING_WORKER_NAME,g=v.FILE_PARTIAL_WORKER_NAME,b=v.THRESHOLD,this.filePromises[e]?w=this.filePromises[e]:(w=new Promise((function(t,n){if(E.fileManager.getTotalSize()+b>p)throw new x("CodDicomWebServer.ts: Maximum size(".concat(p,") for fetching files reached"));var a=F.Enums.FetchType;if(u===a.API_OPTIMIZED){var o=function(t){if(t instanceof P)throw n(t.error),t.error;var r=t.data,i=r.url,a=r.position,c=r.fileArraybuffer;i===e&&c&&(E.fileManager.set(i,{data:c,position:a}),y.removeEventListener(m,"message",o))};y.addEventListener(m,"message",o),y.executeTask(m,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){y.removeEventListener(m,"message",o),delete E.filePromises[e]}))}else if(u===a.BYTES_OPTIMIZED&&i){var s=i.startByte,f=i.endByte,l=e.split("?bytes=")[0],d=function(r){if(r instanceof P)throw n(r.error),r.error;var i=r.data,a=i.url,o=i.fileArraybuffer,c=i.offsets;a===l&&c.startByte===s&&c.endByte===f&&(E.fileManager.set(e,{data:o,position:o.length}),y.removeEventListener(g,"message",d),t())};y.addEventListener(g,"message",d),y.executeTask(g,"partial",{url:l,offsets:{startByte:s,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){y.removeEventListener(g,"message",d),delete E.filePromises[e]}))}else n(new x("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]=w),t.abrupt("return",new Promise((function(t,r){var n=!1,a=function(a){if(a instanceof P)throw r(a.message),a.error;var o=a.data,c=o.url,s=o.position,u=o.chunk;if(o.isAppending&&(u?E.fileManager.append(c,u,s):E.fileManager.setPosition(c,s)),!n&&c===e&&i&&s>i.endByte)try{var f=E.fileManager.get(c,i);n=!0,t(null==f?void 0:f.buffer)}catch(t){r(t)}};i&&!f&&y.addEventListener(m,"message",a),w.then((function(){if(!n)if(E.fileManager.getPosition(e)){var a=E.fileManager.get(e,f?void 0:i);n=!0,t(null==a?void 0:a.buffer)}else r(new x("File - ".concat(e," not found")))})).catch((function(t){r(t)})).then((function(){y.removeEventListener(m,"message",a)}))})));case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"downloadSeriesFile",value:function(t){var e,r=null===(e=Array.from(this.seriesUidFileUrls[t]).find((function(t){var e=t.url;return t.type===s.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),i=document.createElement("a");return i.href=n,i.download=t,i.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===o.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=we(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&&Le(t.prototype,e),n&&Le(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i,f}();const Te=ke,je={FetchType:a,CodDicomWebServer:ke,clearPartialFiles:re}})(),n})()));
|
|
21
21
|
//# sourceMappingURL=main.js.map
|