cod-dicomweb-server 1.3.15 → 1.3.17

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 CHANGED
@@ -2759,7 +2759,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2759
2759
  return readFile(directoryHandle, createStreamingFileName(seriesFileURL));
2760
2760
  case 9:
2761
2761
  fileSystemFile = _context3.sent;
2762
- if (!(fileSystemFile !== null && fileSystemFile !== void 0 && fileSystemFile.byteLength)) {
2762
+ if (fileSystemFile !== null && fileSystemFile !== void 0 && fileSystemFile.byteLength) {
2763
2763
  _context3.next = 12;
2764
2764
  break;
2765
2765
  }
@@ -344,7 +344,7 @@ class CodDicomWebServer {
344
344
  if (!seriesArrayBuffer?.byteLength) {
345
345
  const directoryHandle = await getDirectoryHandle();
346
346
  const fileSystemFile = (await readFile(directoryHandle, createStreamingFileName(seriesFileURL)));
347
- if (fileSystemFile?.byteLength) {
347
+ if (!fileSystemFile?.byteLength) {
348
348
  return false;
349
349
  }
350
350
  seriesArrayBuffer = new Uint8Array(fileSystemFile);
package/dist/umd/563.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * cod-dicomweb-server v1.3.15
3
+ * cod-dicomweb-server v1.3.17
4
4
  * git+https://github.com/gradienthealth/cod-dicomweb-server.git
5
5
  *
6
6
  * Copyright (c) Adithyan Dinesh and project contributors.
package/dist/umd/846.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * cod-dicomweb-server v1.3.15
3
+ * cod-dicomweb-server v1.3.17
4
4
  * git+https://github.com/gradienthealth/cod-dicomweb-server.git
5
5
  *
6
6
  * Copyright (c) Adithyan Dinesh and project contributors.
package/dist/umd/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * cod-dicomweb-server v1.3.15
3
+ * cod-dicomweb-server v1.3.17
4
4
  * git+https://github.com/gradienthealth/cod-dicomweb-server.git
5
5
  *
6
6
  * Copyright (c) Adithyan Dinesh and project contributors.
@@ -17,5 +17,5 @@ t.exports=function(t){return r=[function(e,r){e.exports=t},function(t,e,r){"use
17
17
  * Copyright 2019 Google LLC
18
18
  * SPDX-License-Identifier: Apache-2.0
19
19
  */
20
- const Gt=Symbol("Comlink.proxy"),Ct=Symbol("Comlink.endpoint"),qt=Symbol("Comlink.releaseProxy"),Ht=Symbol("Comlink.finalizer"),Wt=Symbol("Comlink.thrown"),zt=t=>"object"==typeof t&&null!==t||"function"==typeof t,Yt=new Map([["proxy",{canHandle:t=>zt(t)&&t[Gt],serialize(t){const{port1:e,port2:r}=new MessageChannel;return Jt(t,e),[r,[r]]},deserialize:t=>(t.start(),Kt(t))}],["throw",{canHandle:t=>zt(t)&&Wt in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function Jt(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(a){if(!a||!a.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:o,type:i,path:c}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(ae);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(i){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=ae(a.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[Gt]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;Jt(t,r),s=function(t,e){return re.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[Wt]:0}}Promise.resolve(s).catch((t=>({value:t,[Wt]:0}))).then((r=>{const[a,c]=ne(r);e.postMessage(Object.assign(Object.assign({},a),{id:o}),c),"RELEASE"===i&&(e.removeEventListener("message",n),Vt(e),Ht in t&&"function"==typeof t[Ht]&&t[Ht]())})).catch((t=>{const[r,n]=ne({value:new TypeError("Unserializable return value"),[Wt]:0});e.postMessage(Object.assign(Object.assign({},r),{id:o}),n)}))})),e.start&&e.start()}function Vt(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Kt(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),te(t,r,[],e)}function $t(t){if(t)throw new Error("Proxy has been released and is not useable")}function Qt(t){return oe(t,new Map,{type:"RELEASE"}).then((()=>{Vt(t)}))}const Zt=new WeakMap,Xt="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Zt.get(t)||0)-1;Zt.set(t,e),0===e&&Qt(t)}));function te(t,e,r=[],n=function(){}){let a=!1;const o=new Proxy(n,{get(n,i){if($t(a),i===qt)return()=>{!function(t){Xt&&Xt.unregister(t)}(o),Qt(t),e.clear(),a=!0};if("then"===i){if(0===r.length)return{then:()=>o};const n=oe(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(ae);return n.then.bind(n)}return te(t,e,[...r,i])},set(n,o,i){$t(a);const[c,u]=ne(i);return oe(t,e,{type:"SET",path:[...r,o].map((t=>t.toString())),value:c},u).then(ae)},apply(n,o,i){$t(a);const c=r[r.length-1];if(c===Ct)return oe(t,e,{type:"ENDPOINT"}).then(ae);if("bind"===c)return te(t,e,r.slice(0,-1));const[u,s]=ee(i);return oe(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(ae)},construct(n,o){$t(a);const[i,c]=ee(o);return oe(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:i},c).then(ae)}});return function(t,e){const r=(Zt.get(e)||0)+1;Zt.set(e,r),Xt&&Xt.register(t,e,t)}(o,t),o}function ee(t){const e=t.map(ne);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const re=new WeakMap;function ne(t){for(const[e,r]of Yt)if(r.canHandle(t)){const[n,a]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},a]}return[{type:"RAW",value:t},re.get(t)||[]]}function ae(t){switch(t.type){case"HANDLER":return Yt.get(t.name).deserialize(t.value);case"RAW":return t.value}}function oe(t,e,r,n){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(o,a),t.start&&t.start(),t.postMessage(Object.assign({id:o},r),n)}))}function ie(t){return ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie(t)}function ce(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ce=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ie(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(ie(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ue(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function se(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,fe(n.key),n)}}function fe(t){var e=function(t,e){if("object"!=ie(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ie(e)?e:e+""}const le=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=fe(r="workerRegistry"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"register",value:function(t,e){try{var r=e();if(!r)throw new I("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:Kt(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ce().mark((function t(e,r,n){var a,o;return ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=null===(a=this.workerRegistry[e])||void 0===a?void 0:a.instance){t.next=3;break}throw new I("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,o[r](n);case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(e,'":'),t.t0),new I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){ue(o,r,a,i,c,"next",t)}function c(t){ue(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.addEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.removeEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],e&&se(t.prototype,e),r&&se(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();function he(t){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(t)}function de(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */de=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==he(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(he(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function pe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function ye(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,me(n.key),n)}}function ve(t,e,r){return(e=me(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function me(t){var e=function(t,e){if("object"!=he(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=he(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==he(e)?e:e+""}var ge=new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ve(this,"dataRetriever",void 0),ve(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new Bt,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new le,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=ve(ve({},c.WORKER,le),c.REQUEST,Bt);if(!(t in e))throw new I("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new e[t],this.dataRetrieverMode=t}},{key:"register",value:function(t,e){this.dataRetriever.register(t,e)}},{key:"executeTask",value:(n=de().mark((function t(e,r,n){return de().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){pe(o,r,a,i,c,"next",t)}function c(t){pe(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){this.dataRetriever.addEventListener(t,e,r)}},{key:"removeEventListener",value:function(t,e,r){this.dataRetriever.removeEventListener(t,e,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],e&&ye(t.prototype,e),r&&ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}());function be(){return ge}function we(t){return we="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},we(t)}function Ee(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ee=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==we(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(we(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function xe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}Object.freeze(ge);var Pe={partial:function(t,e){return(r=Ee().mark((function r(){var n,a,o,i,c,u,s;return Ee().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.offsets,o=t.headers,i=t.directoryHandle,null!=a&&a.startByte&&null!=a&&a.endByte&&(o.Range="bytes=".concat(a.startByte,"-").concat(a.endByte-1)),c=xt(n,a),!i){r.next=11;break}return r.next=6,dt(i,c,{offsets:a,isJson:!1});case 6:if(null==(u=r.sent)||!u.byteLength){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:a}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:o}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:a}),i&&yt(i,c,t),r})).catch((function(t){throw new I("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){xe(o,n,a,i,c,"next",t)}function c(t){xe(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const Se=Pe;function Oe(t){return Oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oe(t)}function Le(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Le=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Oe(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Oe(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ke(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ae(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ke(Object(r),!0).forEach((function(e){je(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ke(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function je(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Te(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var Ie={stream:function(t,e){return(r=Le().mark((function r(){var n,a,o,i,c,u,s,f,l,h,d,p,y,v,m,g,b,w,E,x,P;return Le().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.headers,o=t.useSharedArrayBuffer,i=t.directoryHandle,c=new AbortController,u=null,s=null,r.prev=4,l=Et(n),!i){r.next=15;break}return r.next=9,dt(i,l,{isJson:!1});case 9:if(null==(h=r.sent)||!h.byteLength){r.next=15;break}return d=h.byteLength,p=new Uint8Array(h),e({url:n,position:d,fileArraybuffer:p,totalLength:d}),r.abrupt("return",p);case 15:return r.next=17,fetch(n,{headers:Ae({},a),signal:c.signal});case 17:if((y=r.sent).ok){r.next=20;break}throw new I("HTTP error! status: ".concat(y.status));case 20:if(v=null===(f=y.body)||void 0===f?void 0:f.getReader()){r.next=23;break}throw new I("Failed to get reader from response body");case 23:return g=!1,b=parseInt(y.headers.get("Content-Length")||"0",10),r.next=27,v.read();case 27:if(w=r.sent,g=w.done,w.value){r.next=31;break}throw new I("The fetched chunks does not have value");case 31:if(g){r.next=50;break}E=w.value.length,o?(u=new SharedArrayBuffer(b),s=new Uint8Array(u)):s=new Uint8Array(b),s.set(w.value),e({url:n,position:E,fileArraybuffer:s,totalLength:b});case 36:if(g){r.next=49;break}return r.next=39,v.read();case 39:if(!(m=r.sent).done){r.next=43;break}return g=!0,r.abrupt("continue",36);case 43:x=m.value,s.set(x,E),E+=x.length,e({isAppending:!0,url:n,position:E,chunk:o?void 0:x,totalLength:b}),r.next=36;break;case 49:i&&yt(i,l,s.slice().buffer);case 50:return r.abrupt("return",s);case 53:throw r.prev=53,r.t0=r.catch(4),P=new I("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 58:return r.prev=58,u=null,s=null,c.abort(),r.finish(58);case 63:case"end":return r.stop()}}),r,null,[[4,53,58,63]])})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){Te(o,n,a,i,c,"next",t)}function c(t){Te(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const De=Ie;function _e(t){return _e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_e(t)}function Fe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ne(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ne(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ue(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ue=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_e(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_e(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Me(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Re(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(t){Me(o,n,a,i,c,"next",t)}function c(t){Me(o,n,a,i,c,"throw",t)}i(void 0)}))}}function Be(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ce(n.key),n)}}function Ge(t,e,r){return(e=Ce(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ce(t){var e=function(t,e){if("object"!=_e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_e(e)?e:e+""}var qe=function(){return t=function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ge(this,"filePromises",{}),Ge(this,"files",{}),Ge(this,"options",{maxCacheSize:4294967296,domain:C.url.DOMAIN,enableOPFSCache:!1}),Ge(this,"fileManager",void 0),Ge(this,"metadataManager",void 0),Ge(this,"seriesUidFileUrls",{}),Ge(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Ge(this,"getOptions",(function(){return e.options}));var a=n.maxCacheSize,o=n.domain,i=n.disableWorker,u=n.enableOPFSCache;this.options.maxCacheSize=a||this.options.maxCacheSize,this.options.domain=o||this.options.domain,this.options.enableOPFSCache=!!u;var s=C.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=C.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new g,this.metadataManager=new Dt,i&&be().setDataRetrieverMode(c.REQUEST),function(t){var e=t.fileStreamingScriptName,n=t.filePartialScriptName,a=be();a.getDataRetrieverMode()===c.REQUEST?(a.register(e,De),a.register(n,Se)):(a.register(e,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:e})})),a.register(n,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:n})})))}({fileStreamingScriptName:s,filePartialScriptName:f})},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(l=Re(Ue().mark((function t(e){var r,n,a,c,f,l,h,d,p,y,v,m,g,b,w,E,x,P,S,O,L,k,A,j=this,T=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=T.length>1&&void 0!==T[1]?T[1]:{},a=(n=T.length>2&&void 0!==T[2]?T[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,f=n.fetchType,l=void 0===f?C.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new I("Url not provided");case 5:if(!(h=W(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new I("Metadata not found for ".concat(e));case 13:E=z(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),x=E.url,P=E.startByte,S=E.endByte,O=E.thumbnailUrl,L=E.isMultiframe,t.t0=d,t.next=t.t0===i.THUMBNAIL?17:t.t0===i.FRAME?21:t.t0===i.SERIES_METADATA||t.t0===i.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new I("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(x){t.next=23;break}throw new I("Url not found for frame");case 23:return k=x,l===o.BYTES_OPTIMIZED&&(k="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,u.FILE,x),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new I("File Arraybuffer is not found");if(L)return t;var e=(0,s.parseDicom)(new Uint8Array(t)).elements.x7fe00010,r=e.dataOffset,n=e.length;if(e.hadUndefinedLength&&e.fragments){var a=e.fragments[0];r=a.position,n=a.length}return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new I("Unsupported request type: ".concat(d));case 29:t.next=32;break;case 31:return t.abrupt("return",new Promise((function(t,n){return j.fetchFile(e,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,u.OTHERS,e)}catch(t){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",t)}t(r)})).catch((function(t){return n(t)}))})));case 32:t.next=39;break;case 34:throw t.prev=34,t.t1=t.catch(2),A=new I("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(A),A;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return l.apply(this,arguments)})},{key:"fetchFile",value:(f=Re(Ue().mark((function t(e,r){var n,a,i,c,u,s,f,l,h,d,p,y,v,m,g=this,b=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(n=b.length>2&&void 0!==b[2]?b[2]:{}).offsets,i=n.useSharedArrayBuffer,c=void 0!==i&&i,u=n.fetchType,s=void 0===u?C.Enums.FetchType.API_OPTIMIZED:u,f=s===o.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:a))){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){try{t(l.buffer)}catch(t){e(t)}})));case 5:if(t.t0=this.options.enableOPFSCache,!t.t0){t.next=10;break}return t.next=9,ct();case 9:t.t0=t.sent;case 10:return h=t.t0,d=be(),p=C.dataRetrieval,y=p.FILE_STREAMING_WORKER_NAME,v=p.FILE_PARTIAL_WORKER_NAME,this.filePromises[e]?(m=this.filePromises[e].promise,this.filePromises[e].requestCount++):(m=new Promise((function(t,n){var o=C.Enums.FetchType;if(s===o.API_OPTIMIZED){var i=function(t){if(t instanceof D)throw n(t.error),t.error;var r=t.data,a=r.url,o=r.position,c=r.fileArraybuffer;a===e&&c&&(g.options.enableOPFSCache?g.files[e]=c:g.fileManager.set(a,{data:c,position:o}),d.removeEventListener(y,"message",i))};d.addEventListener(y,"message",i),d.executeTask(y,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){d.removeEventListener(y,"message",i)}))}else if(s===o.BYTES_OPTIMIZED&&a){var u=a.startByte,f=a.endByte,l=e.split("?bytes=")[0],p=function(r){if(r instanceof D)throw n(r.error),r.error;var a=r.data,o=a.url,i=a.fileArraybuffer,c=a.offsets;o===l&&c.startByte===u&&c.endByte===f&&(g.options.enableOPFSCache?g.files[e]=i:g.fileManager.set(e,{data:i,position:i.length}),d.removeEventListener(v,"message",p),t())};d.addEventListener(v,"message",p),d.executeTask(v,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){d.removeEventListener(v,"message",p)}))}else n(new I("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]={promise:m,requestCount:1}),t.abrupt("return",new Promise((function(t,r){var n=!1,o=!1,i=function(o){if(o instanceof D)throw r(o.message),o.error;var i=o.data,u=i.url,s=i.position,f=i.chunk,l=i.totalLength;if(i.isAppending?f?g.options.enableOPFSCache?g.files[u].set(f,s-f.length):g.fileManager.append(u,f,s):g.fileManager.setPosition(u,s):g.fileManager.getTotalSize()>g.options.maxCacheSize&&g.fileManager.decacheNecessaryBytes(u,l),!n&&u===e&&s>a.endByte)try{var h=g.options.enableOPFSCache?g.files[u].slice(a.startByte,a.endByte):g.fileManager.get(u,a);t(null==h?void 0:h.buffer)}catch(t){r(t)}finally{c(u)}},c=function(t){var e,r;n=!0,(null===(e=g.filePromises[t])||void 0===e?void 0:e.requestCount)&&g.filePromises[t].requestCount--,!o||!g.filePromises[t]||null!==(r=g.filePromises[t])&&void 0!==r&&r.requestCount||(d.removeEventListener(y,"message",i),delete g.filePromises[t],delete g.files[t])};a&&!f&&d.addEventListener(y,"message",i),m.then((function(){var i,c;o=!0,n||(g.fileManager.getPosition(e)||g.files[e]?(c=g.options.enableOPFSCache?f||!a?g.files[e]:g.files[e].slice(a.startByte,a.endByte):g.fileManager.get(e,f?void 0:a),t(null===(i=c)||void 0===i?void 0:i.buffer)):r(new I("File - ".concat(e," not found"))))})).catch((function(t){o=!0,r(t)})).finally((function(){c(e)}))})));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"downloadSeriesFile",value:(a=Re(Ue().mark((function t(e){var r,n,a,o,i,c;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=null===(r=Array.from(this.seriesUidFileUrls[e]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===r?void 0:r.url)){t.next=14;break}if(o=this.fileManager.get(n),null!==(a=o)&&void 0!==a&&a.byteLength){t.next=13;break}return t.next=6,ct();case 6:return i=t.sent,t.next=9,dt(i,Et(n));case 9:if(null==(c=t.sent)||!c.byteLength){t.next=12;break}return t.abrupt("return",!1);case 12:o=new Uint8Array(c);case 13:return t.abrupt("return",mt(n.split("/").at(-1),o.buffer));case 14:return t.abrupt("return",!1);case 15:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===i.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=Fe(t,2),n=e[0];return e[1],n===r})))||void 0===n?void 0:n[1].metadata:Object.values(t.cod.instances).map((function(t){return t.metadata}))}}],e&&Be(t.prototype,e),n&&Be(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,a,f,l}();const He=qe,We={FetchType:o,CodDicomWebServer:qe,clearPartialFiles:gt}})(),n})()));
20
+ const Gt=Symbol("Comlink.proxy"),Ct=Symbol("Comlink.endpoint"),qt=Symbol("Comlink.releaseProxy"),Ht=Symbol("Comlink.finalizer"),Wt=Symbol("Comlink.thrown"),zt=t=>"object"==typeof t&&null!==t||"function"==typeof t,Yt=new Map([["proxy",{canHandle:t=>zt(t)&&t[Gt],serialize(t){const{port1:e,port2:r}=new MessageChannel;return Jt(t,e),[r,[r]]},deserialize:t=>(t.start(),Kt(t))}],["throw",{canHandle:t=>zt(t)&&Wt in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function Jt(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(a){if(!a||!a.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(r,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:o,type:i,path:c}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(ae);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(i){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=ae(a.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[Gt]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;Jt(t,r),s=function(t,e){return re.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[Wt]:0}}Promise.resolve(s).catch((t=>({value:t,[Wt]:0}))).then((r=>{const[a,c]=ne(r);e.postMessage(Object.assign(Object.assign({},a),{id:o}),c),"RELEASE"===i&&(e.removeEventListener("message",n),Vt(e),Ht in t&&"function"==typeof t[Ht]&&t[Ht]())})).catch((t=>{const[r,n]=ne({value:new TypeError("Unserializable return value"),[Wt]:0});e.postMessage(Object.assign(Object.assign({},r),{id:o}),n)}))})),e.start&&e.start()}function Vt(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Kt(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),te(t,r,[],e)}function $t(t){if(t)throw new Error("Proxy has been released and is not useable")}function Qt(t){return oe(t,new Map,{type:"RELEASE"}).then((()=>{Vt(t)}))}const Zt=new WeakMap,Xt="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Zt.get(t)||0)-1;Zt.set(t,e),0===e&&Qt(t)}));function te(t,e,r=[],n=function(){}){let a=!1;const o=new Proxy(n,{get(n,i){if($t(a),i===qt)return()=>{!function(t){Xt&&Xt.unregister(t)}(o),Qt(t),e.clear(),a=!0};if("then"===i){if(0===r.length)return{then:()=>o};const n=oe(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(ae);return n.then.bind(n)}return te(t,e,[...r,i])},set(n,o,i){$t(a);const[c,u]=ne(i);return oe(t,e,{type:"SET",path:[...r,o].map((t=>t.toString())),value:c},u).then(ae)},apply(n,o,i){$t(a);const c=r[r.length-1];if(c===Ct)return oe(t,e,{type:"ENDPOINT"}).then(ae);if("bind"===c)return te(t,e,r.slice(0,-1));const[u,s]=ee(i);return oe(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(ae)},construct(n,o){$t(a);const[i,c]=ee(o);return oe(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:i},c).then(ae)}});return function(t,e){const r=(Zt.get(e)||0)+1;Zt.set(e,r),Xt&&Xt.register(t,e,t)}(o,t),o}function ee(t){const e=t.map(ne);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const re=new WeakMap;function ne(t){for(const[e,r]of Yt)if(r.canHandle(t)){const[n,a]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},a]}return[{type:"RAW",value:t},re.get(t)||[]]}function ae(t){switch(t.type){case"HANDLER":return Yt.get(t.name).deserialize(t.value);case"RAW":return t.value}}function oe(t,e,r,n){return new Promise((a=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(o,a),t.start&&t.start(),t.postMessage(Object.assign({id:o},r),n)}))}function ie(t){return ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie(t)}function ce(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ce=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ie(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(ie(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ue(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function se(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,fe(n.key),n)}}function fe(t){var e=function(t,e){if("object"!=ie(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ie(e)?e:e+""}const le=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=fe(r="workerRegistry"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"register",value:function(t,e){try{var r=e();if(!r)throw new I("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:Kt(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ce().mark((function t(e,r,n){var a,o;return ce().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=null===(a=this.workerRegistry[e])||void 0===a?void 0:a.instance){t.next=3;break}throw new I("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,o[r](n);case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(e,'":'),t.t0),new I('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){ue(o,r,a,i,c,"next",t)}function c(t){ue(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.addEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"removeEventListener",value:function(t,e,r){var n=this.workerRegistry[t];n?n.nativeWorker.removeEventListener(e,r):console.error("Worker type '".concat(t,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],e&&se(t.prototype,e),r&&se(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();function he(t){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(t)}function de(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */de=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==he(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(he(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function pe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function ye(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,me(n.key),n)}}function ve(t,e,r){return(e=me(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function me(t){var e=function(t,e){if("object"!=he(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=he(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==he(e)?e:e+""}var ge=new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ve(this,"dataRetriever",void 0),ve(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new Bt,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new le,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=ve(ve({},c.WORKER,le),c.REQUEST,Bt);if(!(t in e))throw new I("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new e[t],this.dataRetrieverMode=t}},{key:"register",value:function(t,e){this.dataRetriever.register(t,e)}},{key:"executeTask",value:(n=de().mark((function t(e,r,n){return de().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var o=n.apply(t,e);function i(t){pe(o,r,a,i,c,"next",t)}function c(t){pe(o,r,a,i,c,"throw",t)}i(void 0)}))},function(t,e,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(t,e,r){this.dataRetriever.addEventListener(t,e,r)}},{key:"removeEventListener",value:function(t,e,r){this.dataRetriever.removeEventListener(t,e,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],e&&ye(t.prototype,e),r&&ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}());function be(){return ge}function we(t){return we="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},we(t)}function Ee(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ee=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==we(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(we(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function xe(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}Object.freeze(ge);var Pe={partial:function(t,e){return(r=Ee().mark((function r(){var n,a,o,i,c,u,s;return Ee().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.offsets,o=t.headers,i=t.directoryHandle,null!=a&&a.startByte&&null!=a&&a.endByte&&(o.Range="bytes=".concat(a.startByte,"-").concat(a.endByte-1)),c=xt(n,a),!i){r.next=11;break}return r.next=6,dt(i,c,{offsets:a,isJson:!1});case 6:if(null==(u=r.sent)||!u.byteLength){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:a}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:o}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:a}),i&&yt(i,c,t),r})).catch((function(t){throw new I("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){xe(o,n,a,i,c,"next",t)}function c(t){xe(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const Se=Pe;function Oe(t){return Oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oe(t)}function Le(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Le=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Oe(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Oe(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function ke(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ae(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ke(Object(r),!0).forEach((function(e){je(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ke(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function je(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Te(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var Ie={stream:function(t,e){return(r=Le().mark((function r(){var n,a,o,i,c,u,s,f,l,h,d,p,y,v,m,g,b,w,E,x,P;return Le().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.headers,o=t.useSharedArrayBuffer,i=t.directoryHandle,c=new AbortController,u=null,s=null,r.prev=4,l=Et(n),!i){r.next=15;break}return r.next=9,dt(i,l,{isJson:!1});case 9:if(null==(h=r.sent)||!h.byteLength){r.next=15;break}return d=h.byteLength,p=new Uint8Array(h),e({url:n,position:d,fileArraybuffer:p,totalLength:d}),r.abrupt("return",p);case 15:return r.next=17,fetch(n,{headers:Ae({},a),signal:c.signal});case 17:if((y=r.sent).ok){r.next=20;break}throw new I("HTTP error! status: ".concat(y.status));case 20:if(v=null===(f=y.body)||void 0===f?void 0:f.getReader()){r.next=23;break}throw new I("Failed to get reader from response body");case 23:return g=!1,b=parseInt(y.headers.get("Content-Length")||"0",10),r.next=27,v.read();case 27:if(w=r.sent,g=w.done,w.value){r.next=31;break}throw new I("The fetched chunks does not have value");case 31:if(g){r.next=50;break}E=w.value.length,o?(u=new SharedArrayBuffer(b),s=new Uint8Array(u)):s=new Uint8Array(b),s.set(w.value),e({url:n,position:E,fileArraybuffer:s,totalLength:b});case 36:if(g){r.next=49;break}return r.next=39,v.read();case 39:if(!(m=r.sent).done){r.next=43;break}return g=!0,r.abrupt("continue",36);case 43:x=m.value,s.set(x,E),E+=x.length,e({isAppending:!0,url:n,position:E,chunk:o?void 0:x,totalLength:b}),r.next=36;break;case 49:i&&yt(i,l,s.slice().buffer);case 50:return r.abrupt("return",s);case 53:throw r.prev=53,r.t0=r.catch(4),P=new I("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 58:return r.prev=58,u=null,s=null,c.abort(),r.finish(58);case 63:case"end":return r.stop()}}),r,null,[[4,53,58,63]])})),function(){var t=this,e=arguments;return new Promise((function(n,a){var o=r.apply(t,e);function i(t){Te(o,n,a,i,c,"next",t)}function c(t){Te(o,n,a,i,c,"throw",t)}i(void 0)}))})();var r}};const De=Ie;function _e(t){return _e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_e(t)}function Fe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,a,o,i,c=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,a=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ne(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ne(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ue(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ue=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new T(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(a,o,i,c){var u=l(t[a],t,o);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_e(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:t,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var s=l(e,r,n);if("normal"===s.type){if(a=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=y,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,a=e.iterator[n];if(a===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_e(e)+" is not iterable")}return g.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new O(f(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=I,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;j(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function Me(t,e,r,n,a,o,i){try{var c=t[o](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Re(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(t){Me(o,n,a,i,c,"next",t)}function c(t){Me(o,n,a,i,c,"throw",t)}i(void 0)}))}}function Be(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ce(n.key),n)}}function Ge(t,e,r){return(e=Ce(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ce(t){var e=function(t,e){if("object"!=_e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_e(e)?e:e+""}var qe=function(){return t=function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ge(this,"filePromises",{}),Ge(this,"files",{}),Ge(this,"options",{maxCacheSize:4294967296,domain:C.url.DOMAIN,enableOPFSCache:!1}),Ge(this,"fileManager",void 0),Ge(this,"metadataManager",void 0),Ge(this,"seriesUidFileUrls",{}),Ge(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Ge(this,"getOptions",(function(){return e.options}));var a=n.maxCacheSize,o=n.domain,i=n.disableWorker,u=n.enableOPFSCache;this.options.maxCacheSize=a||this.options.maxCacheSize,this.options.domain=o||this.options.domain,this.options.enableOPFSCache=!!u;var s=C.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=C.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new g,this.metadataManager=new Dt,i&&be().setDataRetrieverMode(c.REQUEST),function(t){var e=t.fileStreamingScriptName,n=t.filePartialScriptName,a=be();a.getDataRetrieverMode()===c.REQUEST?(a.register(e,De),a.register(n,Se)):(a.register(e,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:e})})),a.register(n,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:n})})))}({fileStreamingScriptName:s,filePartialScriptName:f})},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(l=Re(Ue().mark((function t(e){var r,n,a,c,f,l,h,d,p,y,v,m,g,b,w,E,x,P,S,O,L,k,A,j=this,T=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=T.length>1&&void 0!==T[1]?T[1]:{},a=(n=T.length>2&&void 0!==T[2]?T[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,f=n.fetchType,l=void 0===f?C.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new I("Url not provided");case 5:if(!(h=W(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new I("Metadata not found for ".concat(e));case 13:E=z(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),x=E.url,P=E.startByte,S=E.endByte,O=E.thumbnailUrl,L=E.isMultiframe,t.t0=d,t.next=t.t0===i.THUMBNAIL?17:t.t0===i.FRAME?21:t.t0===i.SERIES_METADATA||t.t0===i.INSTANCE_METADATA?27:28;break;case 17:if(O){t.next=19;break}throw new I("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,O),t.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:c}));case 21:if(x){t.next=23;break}throw new I("Url not found for frame");case 23:return k=x,l===o.BYTES_OPTIMIZED&&(k="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,u.FILE,x),t.abrupt("return",this.fetchFile(k,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new I("File Arraybuffer is not found");if(L)return t;var e=(0,s.parseDicom)(new Uint8Array(t)).elements.x7fe00010,r=e.dataOffset,n=e.length;if(e.hadUndefinedLength&&e.fragments){var a=e.fragments[0];r=a.position,n=a.length}return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new I("Unsupported request type: ".concat(d));case 29:t.next=32;break;case 31:return t.abrupt("return",new Promise((function(t,n){return j.fetchFile(e,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&j.addFileUrl(n,u.OTHERS,e)}catch(t){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",t)}t(r)})).catch((function(t){return n(t)}))})));case 32:t.next=39;break;case 34:throw t.prev=34,t.t1=t.catch(2),A=new I("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(A),A;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return l.apply(this,arguments)})},{key:"fetchFile",value:(f=Re(Ue().mark((function t(e,r){var n,a,i,c,u,s,f,l,h,d,p,y,v,m,g=this,b=arguments;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(n=b.length>2&&void 0!==b[2]?b[2]:{}).offsets,i=n.useSharedArrayBuffer,c=void 0!==i&&i,u=n.fetchType,s=void 0===u?C.Enums.FetchType.API_OPTIMIZED:u,f=s===o.BYTES_OPTIMIZED,!(l=this.fileManager.get(e,f?void 0:a))){t.next=5;break}return t.abrupt("return",new Promise((function(t,e){try{t(l.buffer)}catch(t){e(t)}})));case 5:if(t.t0=this.options.enableOPFSCache,!t.t0){t.next=10;break}return t.next=9,ct();case 9:t.t0=t.sent;case 10:return h=t.t0,d=be(),p=C.dataRetrieval,y=p.FILE_STREAMING_WORKER_NAME,v=p.FILE_PARTIAL_WORKER_NAME,this.filePromises[e]?(m=this.filePromises[e].promise,this.filePromises[e].requestCount++):(m=new Promise((function(t,n){var o=C.Enums.FetchType;if(s===o.API_OPTIMIZED){var i=function(t){if(t instanceof D)throw n(t.error),t.error;var r=t.data,a=r.url,o=r.position,c=r.fileArraybuffer;a===e&&c&&(g.options.enableOPFSCache?g.files[e]=c:g.fileManager.set(a,{data:c,position:o}),d.removeEventListener(y,"message",i))};d.addEventListener(y,"message",i),d.executeTask(y,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){d.removeEventListener(y,"message",i)}))}else if(s===o.BYTES_OPTIMIZED&&a){var u=a.startByte,f=a.endByte,l=e.split("?bytes=")[0],p=function(r){if(r instanceof D)throw n(r.error),r.error;var a=r.data,o=a.url,i=a.fileArraybuffer,c=a.offsets;o===l&&c.startByte===u&&c.endByte===f&&(g.options.enableOPFSCache?g.files[e]=i:g.fileManager.set(e,{data:i,position:i.length}),d.removeEventListener(v,"message",p),t())};d.addEventListener(v,"message",p),d.executeTask(v,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){d.removeEventListener(v,"message",p)}))}else n(new I("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]={promise:m,requestCount:1}),t.abrupt("return",new Promise((function(t,r){var n=!1,o=!1,i=function(o){if(o instanceof D)throw r(o.message),o.error;var i=o.data,u=i.url,s=i.position,f=i.chunk,l=i.totalLength;if(i.isAppending?f?g.options.enableOPFSCache?g.files[u].set(f,s-f.length):g.fileManager.append(u,f,s):g.fileManager.setPosition(u,s):g.fileManager.getTotalSize()>g.options.maxCacheSize&&g.fileManager.decacheNecessaryBytes(u,l),!n&&u===e&&s>a.endByte)try{var h=g.options.enableOPFSCache?g.files[u].slice(a.startByte,a.endByte):g.fileManager.get(u,a);t(null==h?void 0:h.buffer)}catch(t){r(t)}finally{c(u)}},c=function(t){var e,r;n=!0,(null===(e=g.filePromises[t])||void 0===e?void 0:e.requestCount)&&g.filePromises[t].requestCount--,!o||!g.filePromises[t]||null!==(r=g.filePromises[t])&&void 0!==r&&r.requestCount||(d.removeEventListener(y,"message",i),delete g.filePromises[t],delete g.files[t])};a&&!f&&d.addEventListener(y,"message",i),m.then((function(){var i,c;o=!0,n||(g.fileManager.getPosition(e)||g.files[e]?(c=g.options.enableOPFSCache?f||!a?g.files[e]:g.files[e].slice(a.startByte,a.endByte):g.fileManager.get(e,f?void 0:a),t(null===(i=c)||void 0===i?void 0:i.buffer)):r(new I("File - ".concat(e," not found"))))})).catch((function(t){o=!0,r(t)})).finally((function(){c(e)}))})));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"downloadSeriesFile",value:(a=Re(Ue().mark((function t(e){var r,n,a,o,i,c;return Ue().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=null===(r=Array.from(this.seriesUidFileUrls[e]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===r?void 0:r.url)){t.next=14;break}if(o=this.fileManager.get(n),null!==(a=o)&&void 0!==a&&a.byteLength){t.next=13;break}return t.next=6,ct();case 6:return i=t.sent,t.next=9,dt(i,Et(n));case 9:if(null!=(c=t.sent)&&c.byteLength){t.next=12;break}return t.abrupt("return",!1);case 12:o=new Uint8Array(c);case 13:return t.abrupt("return",mt(n.split("/").at(-1),o.buffer));case 14:return t.abrupt("return",!1);case 15:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===i.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=Fe(t,2),n=e[0];return e[1],n===r})))||void 0===n?void 0:n[1].metadata:Object.values(t.cod.instances).map((function(t){return t.metadata}))}}],e&&Be(t.prototype,e),n&&Be(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,a,f,l}();const He=qe,We={FetchType:o,CodDicomWebServer:qe,clearPartialFiles:gt}})(),n})()));
21
21
  //# sourceMappingURL=main.js.map