UNPKG

cod-dicomweb-server

Version:

A wadors server proxy that get data from a Cloud Optimized Dicom format.

20 lines 118 kB
/*! * * cod-dicomweb-server v1.2.4 * git+https://github.com/gradienthealth/cod-dicomweb-server.git * * Copyright (c) Adithyan Dinesh and project contributors. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={915:function(e,t,r){ /*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */ e.exports=function(e){return r=[function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t),r.d(t,"isStringVr",(function(){return i})),r.d(t,"isPrivateTag",(function(){return a})),r.d(t,"parsePN",(function(){return o})),r.d(t,"parseTM",(function(){return s})),r.d(t,"parseDA",(function(){return u})),r.d(t,"explicitElementToString",(function(){return f})),r.d(t,"explicitDataSetToJS",(function(){return l})),r.d(t,"createJPEGBasicOffsetTable",(function(){return p})),r.d(t,"parseDicomDataSetExplicit",(function(){return F})),r.d(t,"parseDicomDataSetImplicit",(function(){return D})),r.d(t,"readFixedString",(function(){return g})),r.d(t,"alloc",(function(){return _})),r.d(t,"version",(function(){return N})),r.d(t,"bigEndianByteArrayParser",(function(){return U})),r.d(t,"ByteStream",(function(){return B})),r.d(t,"sharedCopy",(function(){return M})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return v})),r.d(t,"findEndOfEncapsulatedElement",(function(){return m})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return G})),r.d(t,"parseDicom",(function(){return z})),r.d(t,"readDicomElementExplicit",(function(){return j})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return J})),r.d(t,"readEncapsulatedPixelData",(function(){return Q})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return Y})),r.d(t,"readPart10Header",(function(){return q})),r.d(t,"readSequenceItemsExplicit",(function(){return T})),r.d(t,"readSequenceItemsImplicit",(function(){return A})),r.d(t,"readSequenceItem",(function(){return O})),r.d(t,"readTag",(function(){return y}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},i=function(e){return n[e]},a=function(e){if(e=parseInt(e[4],16),isNaN(e))throw"dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},o=function(e){if(void 0!==e)return{familyName:(e=e.split("^"))[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}};function s(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),n=4<=e.length?parseInt(e.substring(2,4),10):void 0,i=6<=e.length?parseInt(e.substring(4,6),10):void 0,a=(a=8<=e.length?e.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}if(t)throw"invalid TM '".concat(e,"'")}function c(e,t,r){return!isNaN(r)&&0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r)}function u(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(4,6),10),i=parseInt(e.substring(6,8),10);if(t&&!0!==c(i,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:i}}if(t)throw"invalid DA '".concat(e,"'")}function f(e,t){if(void 0===e||void 0===t)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===t.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=t.vr,a=t.tag;function o(t,r){for(var n="",i=0;i<t;i++)0!==i&&(n+="/"),n+=r.call(e,a,i).toString();return n}if(!0===i(n))r=e.string(a);else{if("AT"===n){var s=e.uint32(a);return void 0===s?void 0:"x".concat((s=s<0?4294967295+s+1:s).toString(16).toUpperCase())}"US"===n?r=o(t.length/2,e.uint16):"SS"===n?r=o(t.length/2,e.int16):"UL"===n?r=o(t.length/4,e.uint32):"SL"===n?r=o(t.length/4,e.int32):"FD"===n?r=o(t.length/8,e.double):"FL"===n&&(r=o(t.length/4,e.float))}return r}function l(e,t){if(void 0===e)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in e.elements){var i=e.elements[r];if(!0!==t.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],s=0;s<i.items.length;s++)o.push(l(i.items[s].dataSet,t));n[r]=o}else{var c=void 0;i.length<t.maxElementLength&&(c=f(e,i)),n[r]=void 0!==c?c:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function d(e,t,r){for(var n,i,a=r;a<t.fragments.length;a++)if(i=a,h(n=e,(i=t.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}function p(e,t,r){if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var n=[],i=0;;){n.push(t.fragments[i].offset);var a=d(e,t,i);if(void 0===a||a===t.fragments.length-1)return n;i=a+1}}function y(e){if(void 0===e)throw"dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256;return e=e.readUint16(),"x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function m(e,t,r){if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==y(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,i=0;i<n;i++){var a=e.readUint32();t.basicOffsetTable.push(a)}for(var o=e.position;e.position<e.byteArray.length;){var s=y(e),c=e.readUint32();if("xfffee0dd"===s)return e.seek(c),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),c>e.byteArray.length-e.position&&(c=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c)}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"))}function v(e,t){if(void 0===e)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57565===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}function g(e,t,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,i="",a=0;a<r;a++){if(0===(n=e[t+a]))return t+=r,i;i+=String.fromCharCode(n)}return i}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function w(e,t){return void 0!==e.parser?e.parser:t}var E=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.byteArrayParser=t,this.byteArray=r,this.elements=n}var t,r,n;return t=e,(r=[{key:"uint16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){if((e=this.elements[e])&&0<e.length)return null===(e=g(this.byteArray,e.dataOffset,e.length).match(/\\/g))?1:e.length+1}},{key:"string",value:function(e,t){return(e=this.elements[e])&&e.Value?e.Value:e&&0<e.length?(e=g(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].trim():e.trim()):void 0}},{key:"text",value:function(e,t){if((e=this.elements[e])&&0<e.length)return e=g(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseFloat(t)}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseInt(t)}},{key:"attributeTag",value:function(e){if((r=this.elements[e])&&4===r.length){var t=w(r,this.byteArrayParser).readUint16,r=(e=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*t(e,r)*256+t(e,r+2)).toString(16)).substr(-8))}}}])&&b(t.prototype,r),n&&b(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function x(e,t){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57357===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}var P=function(e,t){return void 0!==e.vr?"SQ"===e.vr:t.position+4<=t.byteArray.length?(e=y(t),t.seek(-4),"xfffee000"===e||"xfffee0dd"===e):(t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(e),vr:void 0!==r?r(n):void 0,length:e.readUint32(),dataOffset:e.position}).length&&(n.hadUndefinedLength=!0),n.tag===t||(!P(n,e)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(A(e,n,r),a(n.tag)&&(n.items=void 0))),n}function O(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:y(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function L(e,t){var r=O(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=S(e,void 0,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),D(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function A(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=y(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=L(e,r),t.items.push(n)}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var i=L(e,r);t.items.push(i)}})(e,t,r)}function k(e,t){var r=O(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=j(e,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),F(r.dataSet,e,e.position+r.length)),r}function T(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=y(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=k(e,r),t.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var i=k(e,r);t.items.push(i)}})(e,t,r)}var I=function(e){return"OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function j(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(e),vr:e.readFixedString(2)};return 2===I(n.vr)?n.length=e.readUint16():(e.seek(2),n.length=e.readUint32()),n.dataOffset=e.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(e,n,t):4294967295===n.length?"x7fe00010"===n.tag?m(e,n,t):("UN"===n.vr?A:x)(e,n):e.seek(n.length)),n}function F(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var i=e.elements;t.position<r;){var a=j(t,e.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function D(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var i=e.elements;t.position<r;){var a=S(t,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function _(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=(e[t]<<8)+e[t+1])?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function M(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw"dicomParser.from: unknown type for byteArray"}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var B=function(){function e(t,r,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=t,this.byteArray=r,this.position=n||0,this.warnings=[]}var t,r,n;return t=e,(r=[{key:"seek",value:function(e){if(this.position+e<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e}},{key:"readByteStream",value:function(t){if(this.position+t>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,t);return this.position+=t,new e(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=g(this.byteArray,this.position,e);return this.position+=e,t}}])&&R(t.prototype,r),n&&R(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),G={readUint16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=e[t]+(e[t+1]<<8))?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function q(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=t.TransferSyntaxUID,n=new B(G,e);return function(){var e=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(t||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),i=[],a={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,s=j(n,i);if("x0002ffff"<s.tag){n.position=o;break}s.parser=G,a[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,e.position=n.position,e}()}var C="1.2.840.10008.1.2.2";function z(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,i=function(t){if(void 0===t.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(t=t.elements.x00020010)&&t.Value||g(e,t.dataOffset,t.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===C?U:G,e,i);if(t&&t.inflater)return n=t.inflater(e,i),new B(G,n,0);if(1==a){var o=r(0),s=M(e,i,e.length-i);return o=o.inflateRawSync(s),s=_(e,o.length+i),e.copy(s,0,0,i),o.copy(s,i),new B(G,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(i),s=pako.inflateRaw(o),(o=_(e,s.length+i)).set(e.slice(0,i),0),o.set(s,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?F:D)(n,o,o.byteArray.length,t)}catch(o){throw{exception:o,dataSet:n}}return n}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(n=q(e,t),a(n))}var W=function(e,t,r){for(var n=0,i=t;i<t+r;i++)n+=e[i].length;return n};function Y(e,t,r,n,i){if(i=i||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=O(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(t.length);var o=a.position;if(1===n)return M(a.byteArray,o+i[r].offset+8,i[r].length);t=W(i,r,n);for(var s=_(a.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)s[c++]=a.byteArray[f++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},V=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var i=t[e+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function J(e,t,r,n,i){if(n=n||t.basicOffsetTable,i=i||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var a=n[r];if(void 0===(a=H(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return Y(e,t,a,V(r,n,i,a),i)}var K=!1;function Q(e,t,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?J(e,t,r):Y(e,t,0,t.fragments.length)}t.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:D,readFixedString:g,alloc:_,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:v,findEndOfEncapsulatedElement:m,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:j,readDicomElementImplicit:S,readEncapsulatedImageFrame:J,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:Y,readPart10Header:q,readSequenceItemsExplicit:T,readSequenceItemsImplicit:A,readSequenceItem:O,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},t.m=r,t.c=n,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(t){return e[t]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1);function t(e){if(n[e])return n[e].exports;var i=n[e]={i:e,l:!1,exports:{}};return r[e].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.m=e,r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.u=e=>e+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=n[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>$e,FetchType:()=>a,default:()=>Xe});var e={};r.r(e),r.d(e,{DataRetrieveMode:()=>s,FetchType:()=>a,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>P,FILE_EXTENSIONS:()=>S,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>L,FILE_STREAMING_WORKER_NAME:()=>A,THRESHOLD:()=>k});var a=function(e){return e[e.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",e[e.API_OPTIMIZED=1]="API_OPTIMIZED",e}({}),o=function(e){return e[e.FRAME=0]="FRAME",e[e.THUMBNAIL=1]="THUMBNAIL",e[e.SERIES_METADATA=2]="SERIES_METADATA",e[e.INSTANCE_METADATA=3]="INSTANCE_METADATA",e}({}),s=function(e){return e[e.WORKER=0]="WORKER",e[e.REQUEST=1]="REQUEST",e}({}),c=r(915);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function f(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function h(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t,r){return t=w(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,r||[],w(e).constructor):t.apply(e,r))}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&b(i,r.prototype),i}(e,arguments,w(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,e)},v(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(g=function(){return!!e})()}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}var E=function(e){function t(){return p(this,t),y(this,t,arguments)}return m(t,e),h(t)}(v(Error)),x=function(e){function t(e,r){var n;return p(this,t),f(n=y(this,t,[e]),"error",void 0),f(n,"message",void 0),n.message=e,n.error=r,n}return m(t,e),h(t)}(v(Event)),P="https://storage.googleapis.com",S=[".tar",".zip"],O="/dicomweb/",L="filePartial",A="fileStreaming",k=1e4;const T={Enums:e,url:t,dataRetrieval:i};function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function j(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */j=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new F(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(D([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==I(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function D(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(I(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function F(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function D(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,N(n.key),n)}}function _(e,t,r){return(t=N(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function N(e){var t=function(e,t){if("object"!=I(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==I(t)?t:t+""}const U=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,"loaderRegistry",{}),_(this,"listenerCallback",(function(e,r,n){var i,a=null===(i=t.loaderRegistry[e])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(e){return e({data:n})}))}))},t=[{key:"register",value:function(e,t){try{if(!t)throw new E("Loader object for ".concat(e," is not provided"));this.loaderRegistry[e]={loaderObject:t,listeners:{}}}catch(e){throw console.warn(e),new E("throws")}}},{key:"executeTask",value:(n=j().mark((function e(t,r,n){var i,a,o=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(i=this.loaderRegistry[t])||void 0===i?void 0:i.loaderObject){e.next=3;break}throw new E("Loader ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,a[r](n,(function(e){return o.listenerCallback(t,"message",e)}));case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on "').concat(t,'":'),e.t0),new E('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){F(a,r,i,o,s,"next",e)}function s(e){F(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]?n.listeners[t].push(r):n.listeners[t]=[r]:console.error("Loader '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]=(n.listeners[t]||[]).filter((function(e){return e!==r})):console.error("Loader '".concat(e,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],t&&D(e.prototype,t),r&&D(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}(); /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */ const M=Symbol("Comlink.proxy"),R=Symbol("Comlink.endpoint"),B=Symbol("Comlink.releaseProxy"),G=Symbol("Comlink.finalizer"),q=Symbol("Comlink.thrown"),C=e=>"object"==typeof e&&null!==e||"function"==typeof e,z=new Map([["proxy",{canHandle:e=>C(e)&&e[M],serialize(e){const{port1:t,port2:r}=new MessageChannel;return W(e,t),[r,[r]]},deserialize:e=>(e.start(),H(e))}],["throw",{canHandle:e=>C(e)&&q in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function W(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(i){if(!i||!i.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(te);let u;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),r=s.reduce(((e,t)=>e[t]),e);switch(o){case"GET":u=r;break;case"SET":t[s.slice(-1)[0]]=te(i.data.value),u=!0;break;case"APPLY":u=r.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[M]:!0})}(new r(...c));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;W(e,r),u=function(e,t){return X.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[q]:0}}Promise.resolve(u).catch((e=>({value:e,[q]:0}))).then((r=>{const[i,s]=ee(r);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),"RELEASE"===o&&(t.removeEventListener("message",n),Y(t),G in e&&"function"==typeof e[G]&&e[G]())})).catch((e=>{const[r,n]=ee({value:new TypeError("Unserializable return value"),[q]:0});t.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),t.start&&t.start()}function Y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function H(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),Z(e,r,[],t)}function V(e){if(e)throw new Error("Proxy has been released and is not useable")}function J(e){return re(e,new Map,{type:"RELEASE"}).then((()=>{Y(e)}))}const K=new WeakMap,Q="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(K.get(e)||0)-1;K.set(e,t),0===t&&J(e)}));function Z(e,t,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(V(i),o===B)return()=>{!function(e){Q&&Q.unregister(e)}(a),J(e),t.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=re(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(te);return n.then.