cod-dicomweb-server 1.3.10 → 1.3.11
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 +0 -3
- package/dist/esm/classes/CodDicomWebServer.js +0 -4
- package/dist/umd/563.js +1 -1
- package/dist/umd/846.js +1 -1
- package/dist/umd/main.js +2 -2
- package/dist/umd/main.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/main.js
CHANGED
|
@@ -2439,9 +2439,6 @@ var CodDicomWebServer = /*#__PURE__*/function () {
|
|
|
2439
2439
|
var _pixelDataElement$fra = pixelDataElement.fragments[0];
|
|
2440
2440
|
dataOffset = _pixelDataElement$fra.position;
|
|
2441
2441
|
length = _pixelDataElement$fra.length;
|
|
2442
|
-
} else {
|
|
2443
|
-
// Adding 8 bytes for 4 bytes tag + 4 bytes length for uncomppressed pixelData
|
|
2444
|
-
dataOffset += 8;
|
|
2445
2442
|
}
|
|
2446
2443
|
return arraybuffer.slice(dataOffset, dataOffset + length);
|
|
2447
2444
|
}
|
|
@@ -110,10 +110,6 @@ class CodDicomWebServer {
|
|
|
110
110
|
if (pixelDataElement.hadUndefinedLength && pixelDataElement.fragments) {
|
|
111
111
|
({ position: dataOffset, length } = pixelDataElement.fragments[0]);
|
|
112
112
|
}
|
|
113
|
-
else {
|
|
114
|
-
// Adding 8 bytes for 4 bytes tag + 4 bytes length for uncomppressed pixelData
|
|
115
|
-
dataOffset += 8;
|
|
116
|
-
}
|
|
117
113
|
return arraybuffer.slice(dataOffset, dataOffset + length);
|
|
118
114
|
}
|
|
119
115
|
});
|
package/dist/umd/563.js
CHANGED
package/dist/umd/846.js
CHANGED
package/dist/umd/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* cod-dicomweb-server v1.3.
|
|
3
|
+
* cod-dicomweb-server v1.3.11
|
|
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 G=Symbol("Comlink.proxy"),C=Symbol("Comlink.endpoint"),q=Symbol("Comlink.releaseProxy"),z=Symbol("Comlink.finalizer"),W=Symbol("Comlink.thrown"),H=t=>"object"==typeof t&&null!==t||"function"==typeof t,Y=new Map([["proxy",{canHandle:t=>H(t)&&t[G],serialize(t){const{port1:e,port2:r}=new MessageChannel;return J(t,e),[r,[r]]},deserialize:t=>(t.start(),K(t))}],["throw",{canHandle:t=>H(t)&&W in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function J(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(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:i,type:o,path:c}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(at);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(o){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=at(a.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[G]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;J(t,r),s=function(t,e){return rt.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[W]:0}}Promise.resolve(s).catch((t=>({value:t,[W]:0}))).then((r=>{const[a,c]=nt(r);e.postMessage(Object.assign(Object.assign({},a),{id:i}),c),"RELEASE"===o&&(e.removeEventListener("message",n),V(e),z in t&&"function"==typeof t[z]&&t[z]())})).catch((t=>{const[r,n]=nt({value:new TypeError("Unserializable return value"),[W]:0});e.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),e.start&&e.start()}function V(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function K(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),tt(t,r,[],e)}function $(t){if(t)throw new Error("Proxy has been released and is not useable")}function Q(t){return it(t,new Map,{type:"RELEASE"}).then((()=>{V(t)}))}const Z=new WeakMap,X="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Z.get(t)||0)-1;Z.set(t,e),0===e&&Q(t)}));function tt(t,e,r=[],n=function(){}){let a=!1;const i=new Proxy(n,{get(n,o){if($(a),o===q)return()=>{!function(t){X&&X.unregister(t)}(i),Q(t),e.clear(),a=!0};if("then"===o){if(0===r.length)return{then:()=>i};const n=it(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(at);return n.then.bind(n)}return tt(t,e,[...r,o])},set(n,i,o){$(a);const[c,u]=nt(o);return it(t,e,{type:"SET",path:[...r,i].map((t=>t.toString())),value:c},u).then(at)},apply(n,i,o){$(a);const c=r[r.length-1];if(c===C)return it(t,e,{type:"ENDPOINT"}).then(at);if("bind"===c)return tt(t,e,r.slice(0,-1));const[u,s]=et(o);return it(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(at)},construct(n,i){$(a);const[o,c]=et(i);return it(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:o},c).then(at)}});return function(t,e){const r=(Z.get(e)||0)+1;Z.set(e,r),X&&X.register(t,e,t)}(i,t),i}function et(t){const e=t.map(nt);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const rt=new WeakMap;function nt(t){for(const[e,r]of Y)if(r.canHandle(t)){const[n,a]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},a]}return[{type:"RAW",value:t},rt.get(t)||[]]}function at(t){switch(t.type){case"HANDLER":return Y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function it(t,e,r,n){return new Promise((a=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(i,a),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)}))}function ot(t){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ot(t)}function ct(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ct=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ot(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ot(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 ut(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function st(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ft(n.key),n)}}function ft(t){var e=function(t,e){if("object"!=ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ot(e)?e:e+""}const lt=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=ft(r="workerRegistry"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"register",value:function(t,e){try{var r=e();if(!r)throw new E("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:K(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ct().mark((function t(e,r,n){var a,i;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null===(a=this.workerRegistry[e])||void 0===a?void 0:a.instance){t.next=3;break}throw new E("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,i[r](n);case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(e,'":'),t.t0),new E('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){ut(i,r,a,o,c,"next",t)}function c(t){ut(i,r,a,o,c,"throw",t)}o(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&&st(t.prototype,e),r&&st(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */dt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ht(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ht(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 pt(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mt(n.key),n)}}function vt(t,e,r){return(e=mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mt(t){var e=function(t,e){if("object"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ht(e)?e:e+""}var gt=new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),vt(this,"dataRetriever",void 0),vt(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new B,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new lt,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=vt(vt({},c.WORKER,lt),c.REQUEST,B);if(!(t in e))throw new E("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new e[t],this.dataRetrieverMode=t}},{key:"register",value:function(t,e){this.dataRetriever.register(t,e)}},{key:"executeTask",value:(n=dt().mark((function t(e,r,n){return dt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){pt(i,r,a,o,c,"next",t)}function c(t){pt(i,r,a,o,c,"throw",t)}o(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&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}());function bt(){return gt}function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}function xt(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Et(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Et(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function St(t,e,r){return(e=Ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ot(t){var e=function(t,e){if("object"!=wt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wt(e)?e:e+""}const Lt=function(){return t=function t(e){var r=e.fileStreamingScriptName;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),St(this,"files",{}),St(this,"fileStreamingScriptName",void 0),this.fileStreamingScriptName=r},(e=[{key:"set",value:function(t,e){this.files[t]=e}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e)}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(t,e){var r=xt(e,2),n=r[0],a=r[1].position;return n.includes("?bytes=")?t:t+a}),0)}},{key:"remove",value:function(t){var e=this.getPosition(t);delete this.files[t],t.includes("?bytes=")||bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",e)}},{key:"purge",value:function(){var t=this.getTotalSize();this.files={},bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",t)}}])&&Pt(t.prototype,e),r&&Pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,a,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return At(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?At(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function At(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Tt(t,e){if(t.includes(F.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],a=n.split("/studies")[0],i=a.split("/"),c=i[0],u=i.slice(1).join("/"),s=n.split(a+"/")[1].split("/"),f=s[1],l=s[3],h="",d=1;switch(!0){case s.includes("thumbnail"):r=o.THUMBNAIL;break;case s.includes("metadata"):s.includes("instances")?(h=s[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case s.includes("frames"):h=s[5],d=+s[7],r=o.FRAME;break;default:throw new E("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:u,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function jt(t,e,r,n){var a,i;if(!t||null===(a=t.cod)||void 0===a||!a.instances)throw new E("Invalid seriesMetadata provided.");if(null==r)throw new E("Frame index is required.");var o,c=n.domain,u=n.bucketName,s=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;o="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(i=Object.entries(t.cod.instances).find((function(t){var r=kt(t,2),n=r[0];r[1];return n===e})))||void 0===i?void 0:i[1];if(!l)return{thumbnailUrl:o};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var a=t,i=F.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(i){a=t.split(i)[0]+i}var o=a.split("studies/")[1];return a="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),a}(p||y,c,u,s),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,x=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],x=!0);var P=v.start_byte,S=v.end_byte;return{url:g,startByte:void 0!==h?P+h:P,endByte:void 0!==d?P+d:S,thumbnailUrl:o,isMultiframe:x}}function It(t){var e=t.domain,r=void 0===e?F.url.DOMAIN:e,n=t.bucketName,a=t.bucketPrefix,i=t.studyInstanceUID,o=t.seriesInstanceUID;if(n&&a&&i&&o)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(i,"/series/").concat(o,"/metadata.json")}function Ft(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function _t(t,e){let r;return(n,a)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=Ft(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>a(t.transaction(e,n).objectStore(e))))}let Dt;function Nt(){return Dt||(Dt=_t("keyval-store","keyval")),Dt}function Ut(t,e=Nt()){return e("readonly",(e=>Ft(e.get(t))))}function Mt(t){return Mt="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},Mt(t)}function Rt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Rt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Mt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(Mt(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 Bt(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Gt(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)?Gt(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 Gt(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 Ct(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function o(t){Ct(i,n,a,o,c,"next",t)}function c(t){Ct(i,n,a,o,c,"throw",t)}o(void 0)}))}}function zt(t){var e,r,n,a=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);a--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new Wt(e.call(t));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Wt(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return Wt=function(t){this.s=t,this.n=t.next},Wt.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new Wt(t)}var Ht;function Yt(){return Jt.apply(this,arguments)}function Jt(){return(Jt=qt(Rt().mark((function t(){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,Ht){t.next=5;break}return t.next=4,Ut(j);case 4:Ht=t.sent;case 5:if(Ht){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:Ht=t.sent;case 9:return t.abrupt("return",Ht);case 12:t.prev=12,t.t0=t.catch(0),console.warn("Error getting directoryhandle: ".concat(t.t0.message));case 15:case"end":return t.stop()}}),t,null,[[0,12]])})))).apply(this,arguments)}function Vt(t,e){return Kt.apply(this,arguments)}function Kt(){return Kt=qt(Rt().mark((function t(e,r){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),Kt.apply(this,arguments)}function $t(t,e){return Qt.apply(this,arguments)}function Qt(){return Qt=qt(Rt().mark((function t(e,r){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),Qt.apply(this,arguments)}function Zt(t,e){return Xt.apply(this,arguments)}function Xt(){return Xt=qt(Rt().mark((function t(e,r){var n,a,i,o,c,u=arguments;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:a=r.split("/"),i=e,t.prev=5,o=0;case 7:if(!(o<a.length-1)){t.next=14;break}return t.next=10,i.getDirectoryHandle(a[o],{create:!0});case 10:i=t.sent;case 11:o++,t.next=7;break;case 14:if(c=a.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",Vt(i,c));case 19:return t.abrupt("return",$t(i,c).catch(qt(Rt().mark((function t(){var o,c,u;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!a.includes(I.Partial)){t.next=23;break}t.prev=2,a.splice(a.findIndex((function(t){return t===I.Partial})),1),i=e,o=0;case 6:if(!(o<a.length-1)){t.next=13;break}return t.next=9,i.getDirectoryHandle(a[o],{create:!0});case 9:i=t.sent;case 10:o++,t.next=6;break;case 13:return c=a.at(-1).split("_")[0]+".tar",t.next=16,$t(i,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),Xt.apply(this,arguments)}function te(t,e,r){return ee.apply(this,arguments)}function ee(){return ee=qt(Rt().mark((function t(e,r,n){var a,i,o,c,u,s,f,l=arguments;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,i=r.split("/"),o=e,c=0;case 5:if(!(c<i.length-1)){t.next=12;break}return t.next=8,o.getDirectoryHandle(i[c],{create:!0});case 8:o=t.sent;case 9:c++,t.next=5;break;case 12:return u=i.at(-1),t.next=15,o.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!a){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),ee.apply(this,arguments)}function re(){return ne.apply(this,arguments)}function ne(){return ne=qt(Rt().mark((function t(){var e;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=qt(Rt().mark((function t(r){var n,a,i,o,c,u;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!1,a=!1,t.prev=2,o=Rt().mark((function t(){var n,a,i;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Bt(u.value,2),a=n[0],"directory"!==(i=n[1]).kind){t.next=9;break}if(a.toLowerCase()!==I.Partial){t.next=7;break}return t.next=5,r.removeEntry(a,{recursive:!0}).catch((function(t){return console.warn("Failed to remove ".concat(a,":"),t)}));case 5:t.next=9;break;case 7:return t.next=9,e(i);case 9:case"end":return t.stop()}}),t)})),c=zt(r.entries());case 5:return t.next=7,c.next();case 7:if(!(n=!(u=t.sent).done)){t.next=12;break}return t.delegateYield(o(),"t0",9);case 9:n=!1,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(2),a=!0,i=t.t1;case 18:if(t.prev=18,t.prev=19,!n||null==c.return){t.next=23;break}return t.next=23,c.return();case 23:if(t.prev=23,!a){t.next=26;break}throw i;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})));return function(e){return t.apply(this,arguments)}}(),t.prev=1,t.next=4,e(Ht);case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),console.warn("Error clearing partial files: ".concat(t.t0.message));case 9:case"end":return t.stop()}}),t,null,[[1,6]])}))),ne.apply(this,arguments)}function ae(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=Bt(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),a=n[0],i=(n[1],n[2]);return"".concat(r,"/").concat(a,"/").concat(i)}function ie(t){return"".concat(ae(t),"/").concat(t.split("series/")[1])}function oe(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(ae(t),"/").concat(I.Partial,"/").concat(r).concat(n,".dcm")}function ce(t){return"".concat(ae(t),"/metadata.json")}function ue(t){return ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ue(t)}function se(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */se=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ue(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ue(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 fe(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function le(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return he(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)?he(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 he(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 de(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,pe(n.key),n)}}function pe(t){var e=function(t,e){if("object"!=ue(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ue(e)?e:e+""}var ye=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=pe(r="metadataPromises"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"addDeidMetadata",value:function(t,e){var r,n=t.cod,a=le((null===(r=e.match(/studies\/(.*?)\/metadata/))||void 0===r?void 0:r[1].split("/"))||[],3),i=a[0],o=(a[1],a[2]);if(n&&i&&o)for(var c in n.instances){var u=n.instances[c];u.metadata.DeidStudyInstanceUID={Value:[i]},u.metadata.DeidSeriesInstanceUID={Value:[o]},u.metadata.DeidSopInstanceUID={Value:[c]}}else console.warn("Missing required metadata properties: cod, studyUID, or seriesUID")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=se().mark((function t(e,r){var n,a,i,o,c,u=this;return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=It(e)){t.next=3;break}throw new E("Error creating metadata json url");case 3:if(!(a=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,a;case 7:case 21:return t.abrupt("return",t.sent);case 8:return t.next=10,Yt();case 10:return i=t.sent,o=ce(n),t.next=14,Zt(i,o,{isJson:!0});case 14:if(!(c=t.sent)){t.next=17;break}return t.abrupt("return",c);case 17:return t.prev=17,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new E("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return u.addDeidMetadata(t,n),te(i,o,t,!0).then((function(){return t}))})),t.next=21,this.metadataPromises[n];case 24:throw t.prev=24,t.t0=t.catch(17),console.error(t.t0),t.t0;case 28:case"end":return t.stop()}}),t,this,[[17,24]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){fe(i,r,a,o,c,"next",t)}function c(t){fe(i,r,a,o,c,"throw",t)}o(void 0)}))},function(t,e){return a.apply(this,arguments)})}],e&&de(t.prototype,e),r&&de(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();const ve=ye;function me(t){return me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},me(t)}function ge(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ge=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==me(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(me(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 be(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var we={partial:function(t,e){return(r=ge().mark((function r(){var n,a,i,o,c,u;return ge().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.offsets,i=t.headers,o=t.directoryHandle,null!=a&&a.startByte&&null!=a&&a.endByte&&(i.Range="bytes=".concat(a.startByte,"-").concat(a.endByte-1)),c=oe(n,a),!o){r.next=10;break}return r.next=6,Zt(o,c,{offsets:a,isJson:!1});case 6:if(!(u=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(u),offsets:a}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:a}),o&&te(o,c,t)})).catch((function(t){throw new E("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,a){var i=r.apply(t,e);function o(t){be(i,n,a,o,c,"next",t)}function c(t){be(i,n,a,o,c,"throw",t)}o(void 0)}))})();var r}};const xe=we;function Ee(t){return Ee="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},Ee(t)}function Pe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Pe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Ee(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(Ee(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 Se(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 Oe(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Se(Object(r),!0).forEach((function(e){Le(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Se(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Le(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ee(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Ee(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ee(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ke(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var Ae={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(t){t>0&&(this.maxFetchSize=t)},decreaseFetchedSize:function(t){t>0&&t<=this.fetchedSize&&(this.fetchedSize-=t)},stream:function(t,e){var r,n=this;return(r=Pe().mark((function r(){var a,i,o,c,u,s,f,l,h,d,p,y,v,m,g,b,w,x,P;return Pe().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=t.url,i=t.headers,o=t.useSharedArrayBuffer,c=t.directoryHandle,u=new AbortController,s=null,f=null,r.prev=4,h=ie(a),!c){r.next=13;break}return r.next=9,Zt(c,h,{isJson:!1});case 9:if(!(d=r.sent)){r.next=13;break}return e({url:a,position:d.byteLength,fileArraybuffer:new Uint8Array(d)}),r.abrupt("return");case 13:return r.next=15,fetch(a,{headers:Oe({},i),signal:u.signal});case 15:if((p=r.sent).ok){r.next=18;break}throw new E("HTTP error! status: ".concat(p.status));case 18:if(y=null===(l=p.body)||void 0===l?void 0:l.getReader()){r.next=21;break}throw new E("Failed to get reader from response body");case 21:return m=!1,g=parseInt(p.headers.get("Content-Length")||"0",10),r.next=25,y.read();case 25:if(b=r.sent,m=b.done,b.value){r.next=29;break}throw new E("The fetched chunks does not have value");case 29:if(m){r.next=58;break}if(w=b.value.length,!(n.fetchedSize+w>n.maxFetchSize)){r.next=34;break}throw u.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 34:n.fetchedSize+=w,o?(s=new SharedArrayBuffer(g),f=new Uint8Array(s)):f=new Uint8Array(g),f.set(b.value),e({url:a,position:w,fileArraybuffer:f});case 38:if(m){r.next=57;break}return r.next=41,y.read();case 41:if(!(v=r.sent).done){r.next=45;break}return m=!0,r.abrupt("continue",38);case 45:if(x=v.value,!(n.fetchedSize+x.length>n.maxFetchSize)){r.next=51;break}throw s=null,f=null,u.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 51:n.fetchedSize+=x.length,f.set(x,w),w+=x.length,e({isAppending:!0,url:a,position:w,chunk:o?void 0:x}),r.next=38;break;case 57:c&&te(c,h,f.slice().buffer);case 58:r.next=65;break;case 60:throw r.prev=60,r.t0=r.catch(4),P=new E("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 65:return r.prev=65,s=null,f=null,u.abort(),r.finish(65);case 70:case"end":return r.stop()}}),r,null,[[4,60,65,70]])})),function(){var t=this,e=arguments;return new Promise((function(n,a){var i=r.apply(t,e);function o(t){ke(i,n,a,o,c,"next",t)}function c(t){ke(i,n,a,o,c,"throw",t)}o(void 0)}))})()}};const Te=Ae;function je(t){return je="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},je(t)}function Ie(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Fe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fe(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_e=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==je(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(je(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 De(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Ne(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function o(t){De(i,n,a,o,c,"next",t)}function c(t){De(i,n,a,o,c,"throw",t)}o(void 0)}))}}function Ue(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Re(n.key),n)}}function Me(t,e,r){return(e=Re(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Re(t){var e=function(t,e){if("object"!=je(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=je(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==je(e)?e:e+""}var Be=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),Me(this,"filePromises",{}),Me(this,"options",{maxWorkerFetchSize:1/0,domain:F.url.DOMAIN,enableLocalCache:!1}),Me(this,"fileManager",void 0),Me(this,"metadataManager",void 0),Me(this,"seriesUidFileUrls",{}),Me(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Me(this,"getOptions",(function(){return e.options}));var a=n.maxWorkerFetchSize,i=n.domain,o=n.disableWorker,u=n.enableLocalCache;this.options.maxWorkerFetchSize=a||this.options.maxWorkerFetchSize,this.options.domain=i||this.options.domain,this.options.enableLocalCache=!!u;var s=F.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=F.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Lt({fileStreamingScriptName:s}),this.metadataManager=new ve,o&&bt().setDataRetrieverMode(c.REQUEST),function(t,e){var n=t.fileStreamingScriptName,a=t.filePartialScriptName,i=bt();i.getDataRetrieverMode()===c.REQUEST?(i.register(n,Te),i.register(a,xe)):(i.register(n,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:n})})),i.register(a,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:a})}))),i.executeTask(n,"setMaxFetchSize",e)}({fileStreamingScriptName:s,filePartialScriptName:f},this.options.maxWorkerFetchSize)},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(f=Ne(_e().mark((function t(e){var r,n,a,c,f,l,h,d,p,y,v,m,g,b,w,x,P,S,O,L,k,A,T,j=this,I=arguments;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=I.length>1&&void 0!==I[1]?I[1]:{},a=(n=I.length>2&&void 0!==I[2]?I[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,f=n.fetchType,l=void 0===f?F.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new E("Url not provided");case 5:if(!(h=Tt(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new E("Metadata not found for ".concat(e));case 13:x=jt(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),P=x.url,S=x.startByte,O=x.endByte,L=x.thumbnailUrl,k=x.isMultiframe,t.t0=d,t.next=t.t0===o.THUMBNAIL?17:t.t0===o.FRAME?21:t.t0===o.SERIES_METADATA||t.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(L){t.next=19;break}throw new E("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,L),t.abrupt("return",this.fetchFile(L,r,{useSharedArrayBuffer:c}));case 21:if(P){t.next=23;break}throw new E("Url not found for frame");case 23:return A=P,l===i.BYTES_OPTIMIZED&&(A="".concat(P,"?bytes=").concat(S,"-").concat(O)),this.addFileUrl(m,u.FILE,P),t.abrupt("return",this.fetchFile(A,r,{offsets:{startByte:S,endByte:O},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new E("File Arraybuffer is not found");if(k)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}else r+=8;return t.slice(r,r+n)})));case 27:return t.abrupt("return",this.parseMetadata(w,d,g));case 28:throw new E("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),T=new E("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(T),T;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return f.apply(this,arguments)})},{key:"fetchFile",value:(a=Ne(_e().mark((function t(e,r){var n,a,o,c,u,s,f,l,h,d,p,y,v,m,g,b,w,x=this,S=arguments;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(n=S.length>2&&void 0!==S[2]?S[2]:{}).offsets,o=n.useSharedArrayBuffer,c=void 0!==o&&o,u=n.fetchType,s=void 0===u?F.Enums.FetchType.API_OPTIMIZED:u,f=s===i.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.enableLocalCache,!t.t0){t.next=10;break}return t.next=9,Yt();case 9:t.t0=t.sent;case 10:return h=t.t0,d=this.getOptions(),p=d.maxWorkerFetchSize,y=bt(),v=F.dataRetrieval,m=v.FILE_STREAMING_WORKER_NAME,g=v.FILE_PARTIAL_WORKER_NAME,b=v.THRESHOLD,this.filePromises[e]?w=this.filePromises[e]:(w=new Promise((function(t,n){if(x.fileManager.getTotalSize()+b>p)throw new E("CodDicomWebServer.ts: Maximum size(".concat(p,") for fetching files reached"));var i=F.Enums.FetchType;if(s===i.API_OPTIMIZED){var o=function(t){if(t instanceof P)throw n(t.error),t.error;var r=t.data,a=r.url,i=r.position,c=r.fileArraybuffer;a===e&&c&&(x.fileManager.set(a,{data:c,position:i}),y.removeEventListener(m,"message",o))};y.addEventListener(m,"message",o),y.executeTask(m,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){y.removeEventListener(m,"message",o),delete x.filePromises[e]}))}else if(s===i.BYTES_OPTIMIZED&&a){var u=a.startByte,f=a.endByte,l=e.split("?bytes=")[0],d=function(r){if(r instanceof P)throw n(r.error),r.error;var a=r.data,i=a.url,o=a.fileArraybuffer,c=a.offsets;i===l&&c.startByte===u&&c.endByte===f&&(x.fileManager.set(e,{data:o,position:o.length}),y.removeEventListener(g,"message",d),t())};y.addEventListener(g,"message",d),y.executeTask(g,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){y.removeEventListener(g,"message",d),delete x.filePromises[e]}))}else n(new E("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]=w),t.abrupt("return",new Promise((function(t,r){var n=!1,i=function(i){if(i instanceof P)throw r(i.message),i.error;var o=i.data,c=o.url,u=o.position,s=o.chunk;if(o.isAppending&&(s?x.fileManager.append(c,s,u):x.fileManager.setPosition(c,u)),!n&&c===e&&a&&u>a.endByte)try{var f=x.fileManager.get(c,a);n=!0,t(null==f?void 0:f.buffer)}catch(t){r(t)}};a&&!f&&y.addEventListener(m,"message",i),w.then((function(){if(!n)if(x.fileManager.getPosition(e)){var i=x.fileManager.get(e,f?void 0:a);n=!0,t(null==i?void 0:i.buffer)}else r(new E("File - ".concat(e," not found")))})).catch((function(t){r(t)})).then((function(){y.removeEventListener(m,"message",i)}))})));case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"downloadSeriesFile",value:function(t){var e,r=null===(e=Array.from(this.seriesUidFileUrls[t]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===e?void 0:e.url;if(r){var n=this.fileManager.get(r);return function(t,e){try{var r=new Blob([e],{type:"application/x-tar"}),n=URL.createObjectURL(r),a=document.createElement("a");return a.href=n,a.download=t,a.click(),URL.revokeObjectURL(n),!0}catch(e){return console.warn("Error downloading file - ".concat(t,": ")+e.message),!1}}(r.split("/").at(-1),n)}return!1}},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===o.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=Ie(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&&Ue(t.prototype,e),n&&Ue(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,a,f}();const Ge=Be,Ce={FetchType:i,CodDicomWebServer:Be,clearPartialFiles:re}})(),n})()));
|
|
20
|
+
const G=Symbol("Comlink.proxy"),C=Symbol("Comlink.endpoint"),q=Symbol("Comlink.releaseProxy"),z=Symbol("Comlink.finalizer"),W=Symbol("Comlink.thrown"),H=t=>"object"==typeof t&&null!==t||"function"==typeof t,Y=new Map([["proxy",{canHandle:t=>H(t)&&t[G],serialize(t){const{port1:e,port2:r}=new MessageChannel;return J(t,e),[r,[r]]},deserialize:t=>(t.start(),K(t))}],["throw",{canHandle:t=>H(t)&&W in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function J(t,e=globalThis,r=["*"]){e.addEventListener("message",(function n(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:i,type:o,path:c}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(at);let s;try{const e=c.slice(0,-1).reduce(((t,e)=>t[e]),t),r=c.reduce(((t,e)=>t[e]),t);switch(o){case"GET":s=r;break;case"SET":e[c.slice(-1)[0]]=at(a.data.value),s=!0;break;case"APPLY":s=r.apply(e,u);break;case"CONSTRUCT":s=function(t){return Object.assign(t,{[G]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:e,port2:r}=new MessageChannel;J(t,r),s=function(t,e){return rt.set(t,e),t}(e,[e])}break;case"RELEASE":s=void 0;break;default:return}}catch(t){s={value:t,[W]:0}}Promise.resolve(s).catch((t=>({value:t,[W]:0}))).then((r=>{const[a,c]=nt(r);e.postMessage(Object.assign(Object.assign({},a),{id:i}),c),"RELEASE"===o&&(e.removeEventListener("message",n),V(e),z in t&&"function"==typeof t[z]&&t[z]())})).catch((t=>{const[r,n]=nt({value:new TypeError("Unserializable return value"),[W]:0});e.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),e.start&&e.start()}function V(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function K(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),tt(t,r,[],e)}function $(t){if(t)throw new Error("Proxy has been released and is not useable")}function Q(t){return it(t,new Map,{type:"RELEASE"}).then((()=>{V(t)}))}const Z=new WeakMap,X="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Z.get(t)||0)-1;Z.set(t,e),0===e&&Q(t)}));function tt(t,e,r=[],n=function(){}){let a=!1;const i=new Proxy(n,{get(n,o){if($(a),o===q)return()=>{!function(t){X&&X.unregister(t)}(i),Q(t),e.clear(),a=!0};if("then"===o){if(0===r.length)return{then:()=>i};const n=it(t,e,{type:"GET",path:r.map((t=>t.toString()))}).then(at);return n.then.bind(n)}return tt(t,e,[...r,o])},set(n,i,o){$(a);const[c,u]=nt(o);return it(t,e,{type:"SET",path:[...r,i].map((t=>t.toString())),value:c},u).then(at)},apply(n,i,o){$(a);const c=r[r.length-1];if(c===C)return it(t,e,{type:"ENDPOINT"}).then(at);if("bind"===c)return tt(t,e,r.slice(0,-1));const[u,s]=et(o);return it(t,e,{type:"APPLY",path:r.map((t=>t.toString())),argumentList:u},s).then(at)},construct(n,i){$(a);const[o,c]=et(i);return it(t,e,{type:"CONSTRUCT",path:r.map((t=>t.toString())),argumentList:o},c).then(at)}});return function(t,e){const r=(Z.get(e)||0)+1;Z.set(e,r),X&&X.register(t,e,t)}(i,t),i}function et(t){const e=t.map(nt);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const rt=new WeakMap;function nt(t){for(const[e,r]of Y)if(r.canHandle(t)){const[n,a]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},a]}return[{type:"RAW",value:t},rt.get(t)||[]]}function at(t){switch(t.type){case"HANDLER":return Y.get(t.name).deserialize(t.value);case"RAW":return t.value}}function it(t,e,r,n){return new Promise((a=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(i,a),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)}))}function ot(t){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ot(t)}function ct(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ct=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ot(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ot(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 ut(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function st(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ft(n.key),n)}}function ft(t){var e=function(t,e){if("object"!=ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ot(e)?e:e+""}const lt=function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,n={},(r=ft(r="workerRegistry"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"register",value:function(t,e){try{var r=e();if(!r)throw new E("WorkerFn of worker ".concat(t," is not creating a worker"));this.workerRegistry[t]={instance:K(r),nativeWorker:r}}catch(t){console.warn(t)}}},{key:"executeTask",value:(n=ct().mark((function t(e,r,n){var a,i;return ct().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null===(a=this.workerRegistry[e])||void 0===a?void 0:a.instance){t.next=3;break}throw new E("Worker ".concat(e," not registered"));case 3:return t.prev=3,t.next=6,i[r](n);case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(e,'":'),t.t0),new E('Task "'.concat(r,'" failed: ').concat(t.t0.message));case 13:case"end":return t.stop()}}),t,this,[[3,9]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){ut(i,r,a,o,c,"next",t)}function c(t){ut(i,r,a,o,c,"throw",t)}o(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&&st(t.prototype,e),r&&st(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */dt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ht(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ht(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 pt(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mt(n.key),n)}}function vt(t,e,r){return(e=mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mt(t){var e=function(t,e){if("object"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ht(e)?e:e+""}var gt=new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),vt(this,"dataRetriever",void 0),vt(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new B,this.dataRetrieverMode=c.REQUEST):(this.dataRetriever=new lt,this.dataRetrieverMode=c.WORKER)},e=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(t){var e=vt(vt({},c.WORKER,lt),c.REQUEST,B);if(!(t in e))throw new E("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new e[t],this.dataRetrieverMode=t}},{key:"register",value:function(t,e){this.dataRetriever.register(t,e)}},{key:"executeTask",value:(n=dt().mark((function t(e,r,n){return dt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.dataRetriever.executeTask(e,r,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){pt(i,r,a,o,c,"next",t)}function c(t){pt(i,r,a,o,c,"throw",t)}o(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&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}());function bt(){return gt}function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}function xt(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Et(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Et(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function St(t,e,r){return(e=Ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ot(t){var e=function(t,e){if("object"!=wt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==wt(e)?e:e+""}const Lt=function(){return t=function t(e){var r=e.fileStreamingScriptName;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),St(this,"files",{}),St(this,"fileStreamingScriptName",void 0),this.fileStreamingScriptName=r},(e=[{key:"set",value:function(t,e){this.files[t]=e}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e)}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(t,e){var r=xt(e,2),n=r[0],a=r[1].position;return n.includes("?bytes=")?t:t+a}),0)}},{key:"remove",value:function(t){var e=this.getPosition(t);delete this.files[t],t.includes("?bytes=")||bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",e)}},{key:"purge",value:function(){var t=this.getTotalSize();this.files={},bt().executeTask(this.fileStreamingScriptName,"decreaseFetchedSize",t)}}])&&Pt(t.prototype,e),r&&Pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,a,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return At(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?At(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function At(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Tt(t,e){if(t.includes(F.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],a=n.split("/studies")[0],i=a.split("/"),c=i[0],u=i.slice(1).join("/"),s=n.split(a+"/")[1].split("/"),f=s[1],l=s[3],h="",d=1;switch(!0){case s.includes("thumbnail"):r=o.THUMBNAIL;break;case s.includes("metadata"):s.includes("instances")?(h=s[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case s.includes("frames"):h=s[5],d=+s[7],r=o.FRAME;break;default:throw new E("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:u,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function jt(t,e,r,n){var a,i;if(!t||null===(a=t.cod)||void 0===a||!a.instances)throw new E("Invalid seriesMetadata provided.");if(null==r)throw new E("Frame index is required.");var o,c=n.domain,u=n.bucketName,s=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;o="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(i=Object.entries(t.cod.instances).find((function(t){var r=kt(t,2),n=r[0];r[1];return n===e})))||void 0===i?void 0:i[1];if(!l)return{thumbnailUrl:o};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var a=t,i=F.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(i){a=t.split(i)[0]+i}var o=a.split("studies/")[1];return a="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),a}(p||y,c,u,s),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,x=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],x=!0);var P=v.start_byte,S=v.end_byte;return{url:g,startByte:void 0!==h?P+h:P,endByte:void 0!==d?P+d:S,thumbnailUrl:o,isMultiframe:x}}function It(t){var e=t.domain,r=void 0===e?F.url.DOMAIN:e,n=t.bucketName,a=t.bucketPrefix,i=t.studyInstanceUID,o=t.seriesInstanceUID;if(n&&a&&i&&o)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(i,"/series/").concat(o,"/metadata.json")}function Ft(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function _t(t,e){let r;return(n,a)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=Ft(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>a(t.transaction(e,n).objectStore(e))))}let Dt;function Nt(){return Dt||(Dt=_t("keyval-store","keyval")),Dt}function Ut(t,e=Nt()){return e("readonly",(e=>Ft(e.get(t))))}function Mt(t){return Mt="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},Mt(t)}function Rt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Rt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Mt(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(Mt(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 Bt(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Gt(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)?Gt(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 Gt(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 Ct(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function qt(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function o(t){Ct(i,n,a,o,c,"next",t)}function c(t){Ct(i,n,a,o,c,"throw",t)}o(void 0)}))}}function zt(t){var e,r,n,a=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);a--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new Wt(e.call(t));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Wt(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return Wt=function(t){this.s=t,this.n=t.next},Wt.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new Wt(t)}var Ht;function Yt(){return Jt.apply(this,arguments)}function Jt(){return(Jt=qt(Rt().mark((function t(){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,Ht){t.next=5;break}return t.next=4,Ut(j);case 4:Ht=t.sent;case 5:if(Ht){t.next=9;break}return t.next=8,navigator.storage.getDirectory();case 8:Ht=t.sent;case 9:return t.abrupt("return",Ht);case 12:t.prev=12,t.t0=t.catch(0),console.warn("Error getting directoryhandle: ".concat(t.t0.message));case 15:case"end":return t.stop()}}),t,null,[[0,12]])})))).apply(this,arguments)}function Vt(t,e){return Kt.apply(this,arguments)}function Kt(){return Kt=qt(Rt().mark((function t(e,r){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),Kt.apply(this,arguments)}function $t(t,e){return Qt.apply(this,arguments)}function Qt(){return Qt=qt(Rt().mark((function t(e,r){return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),Qt.apply(this,arguments)}function Zt(t,e){return Xt.apply(this,arguments)}function Xt(){return Xt=qt(Rt().mark((function t(e,r){var n,a,i,o,c,u=arguments;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:a=r.split("/"),i=e,t.prev=5,o=0;case 7:if(!(o<a.length-1)){t.next=14;break}return t.next=10,i.getDirectoryHandle(a[o],{create:!0});case 10:i=t.sent;case 11:o++,t.next=7;break;case 14:if(c=a.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",Vt(i,c));case 19:return t.abrupt("return",$t(i,c).catch(qt(Rt().mark((function t(){var o,c,u;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!a.includes(I.Partial)){t.next=23;break}t.prev=2,a.splice(a.findIndex((function(t){return t===I.Partial})),1),i=e,o=0;case 6:if(!(o<a.length-1)){t.next=13;break}return t.next=9,i.getDirectoryHandle(a[o],{create:!0});case 9:i=t.sent;case 10:o++,t.next=6;break;case 13:return c=a.at(-1).split("_")[0]+".tar",t.next=16,$t(i,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),Xt.apply(this,arguments)}function te(t,e,r){return ee.apply(this,arguments)}function ee(){return ee=qt(Rt().mark((function t(e,r,n){var a,i,o,c,u,s,f,l=arguments;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,i=r.split("/"),o=e,c=0;case 5:if(!(c<i.length-1)){t.next=12;break}return t.next=8,o.getDirectoryHandle(i[c],{create:!0});case 8:o=t.sent;case 9:c++,t.next=5;break;case 12:return u=i.at(-1),t.next=15,o.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!a){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),ee.apply(this,arguments)}function re(){return ne.apply(this,arguments)}function ne(){return ne=qt(Rt().mark((function t(){var e;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=qt(Rt().mark((function t(r){var n,a,i,o,c,u;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!1,a=!1,t.prev=2,o=Rt().mark((function t(){var n,a,i;return Rt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Bt(u.value,2),a=n[0],"directory"!==(i=n[1]).kind){t.next=9;break}if(a.toLowerCase()!==I.Partial){t.next=7;break}return t.next=5,r.removeEntry(a,{recursive:!0}).catch((function(t){return console.warn("Failed to remove ".concat(a,":"),t)}));case 5:t.next=9;break;case 7:return t.next=9,e(i);case 9:case"end":return t.stop()}}),t)})),c=zt(r.entries());case 5:return t.next=7,c.next();case 7:if(!(n=!(u=t.sent).done)){t.next=12;break}return t.delegateYield(o(),"t0",9);case 9:n=!1,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(2),a=!0,i=t.t1;case 18:if(t.prev=18,t.prev=19,!n||null==c.return){t.next=23;break}return t.next=23,c.return();case 23:if(t.prev=23,!a){t.next=26;break}throw i;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})));return function(e){return t.apply(this,arguments)}}(),t.prev=1,t.next=4,e(Ht);case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),console.warn("Error clearing partial files: ".concat(t.t0.message));case 9:case"end":return t.stop()}}),t,null,[[1,6]])}))),ne.apply(this,arguments)}function ae(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=Bt(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),a=n[0],i=(n[1],n[2]);return"".concat(r,"/").concat(a,"/").concat(i)}function ie(t){return"".concat(ae(t),"/").concat(t.split("series/")[1])}function oe(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(ae(t),"/").concat(I.Partial,"/").concat(r).concat(n,".dcm")}function ce(t){return"".concat(ae(t),"/metadata.json")}function ue(t){return ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ue(t)}function se(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */se=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==ue(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(ue(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 fe(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function le(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return he(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)?he(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 he(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 de(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,pe(n.key),n)}}function pe(t){var e=function(t,e){if("object"!=ue(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==ue(e)?e:e+""}var ye=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=pe(r="metadataPromises"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},e=[{key:"addDeidMetadata",value:function(t,e){var r,n=t.cod,a=le((null===(r=e.match(/studies\/(.*?)\/metadata/))||void 0===r?void 0:r[1].split("/"))||[],3),i=a[0],o=(a[1],a[2]);if(n&&i&&o)for(var c in n.instances){var u=n.instances[c];u.metadata.DeidStudyInstanceUID={Value:[i]},u.metadata.DeidSeriesInstanceUID={Value:[o]},u.metadata.DeidSopInstanceUID={Value:[c]}}else console.warn("Missing required metadata properties: cod, studyUID, or seriesUID")}},{key:"getMetadataFromCache",value:function(t){return this.metadataPromises[t]}},{key:"getMetadata",value:(n=se().mark((function t(e,r){var n,a,i,o,c,u=this;return se().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=It(e)){t.next=3;break}throw new E("Error creating metadata json url");case 3:if(!(a=this.getMetadataFromCache(n))){t.next=8;break}return t.next=7,a;case 7:case 21:return t.abrupt("return",t.sent);case 8:return t.next=10,Yt();case 10:return i=t.sent,o=ce(n),t.next=14,Zt(i,o,{isJson:!0});case 14:if(!(c=t.sent)){t.next=17;break}return t.abrupt("return",c);case 17:return t.prev=17,this.metadataPromises[n]=fetch(n,{headers:r}).then((function(t){if(!t.ok)throw new E("Failed to fetch metadata: ".concat(t.statusText));return t.json()})).then((function(t){return u.addDeidMetadata(t,n),te(i,o,t,!0).then((function(){return t}))})),t.next=21,this.metadataPromises[n];case 24:throw t.prev=24,t.t0=t.catch(17),console.error(t.t0),t.t0;case 28:case"end":return t.stop()}}),t,this,[[17,24]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,a){var i=n.apply(t,e);function o(t){fe(i,r,a,o,c,"next",t)}function c(t){fe(i,r,a,o,c,"throw",t)}o(void 0)}))},function(t,e){return a.apply(this,arguments)})}],e&&de(t.prototype,e),r&&de(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,a}();const ve=ye;function me(t){return me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},me(t)}function ge(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ge=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==me(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(me(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 be(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var we={partial:function(t,e){return(r=ge().mark((function r(){var n,a,i,o,c,u;return ge().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,a=t.offsets,i=t.headers,o=t.directoryHandle,null!=a&&a.startByte&&null!=a&&a.endByte&&(i.Range="bytes=".concat(a.startByte,"-").concat(a.endByte-1)),c=oe(n,a),!o){r.next=10;break}return r.next=6,Zt(o,c,{offsets:a,isJson:!1});case 6:if(!(u=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(u),offsets:a}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:a}),o&&te(o,c,t)})).catch((function(t){throw new E("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,a){var i=r.apply(t,e);function o(t){be(i,n,a,o,c,"next",t)}function c(t){be(i,n,a,o,c,"throw",t)}o(void 0)}))})();var r}};const xe=we;function Ee(t){return Ee="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},Ee(t)}function Pe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Pe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Ee(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(Ee(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 Se(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 Oe(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Se(Object(r),!0).forEach((function(e){Le(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Se(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Le(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ee(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=Ee(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==Ee(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ke(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}var Ae={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(t){t>0&&(this.maxFetchSize=t)},decreaseFetchedSize:function(t){t>0&&t<=this.fetchedSize&&(this.fetchedSize-=t)},stream:function(t,e){var r,n=this;return(r=Pe().mark((function r(){var a,i,o,c,u,s,f,l,h,d,p,y,v,m,g,b,w,x,P;return Pe().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=t.url,i=t.headers,o=t.useSharedArrayBuffer,c=t.directoryHandle,u=new AbortController,s=null,f=null,r.prev=4,h=ie(a),!c){r.next=13;break}return r.next=9,Zt(c,h,{isJson:!1});case 9:if(!(d=r.sent)){r.next=13;break}return e({url:a,position:d.byteLength,fileArraybuffer:new Uint8Array(d)}),r.abrupt("return");case 13:return r.next=15,fetch(a,{headers:Oe({},i),signal:u.signal});case 15:if((p=r.sent).ok){r.next=18;break}throw new E("HTTP error! status: ".concat(p.status));case 18:if(y=null===(l=p.body)||void 0===l?void 0:l.getReader()){r.next=21;break}throw new E("Failed to get reader from response body");case 21:return m=!1,g=parseInt(p.headers.get("Content-Length")||"0",10),r.next=25,y.read();case 25:if(b=r.sent,m=b.done,b.value){r.next=29;break}throw new E("The fetched chunks does not have value");case 29:if(m){r.next=58;break}if(w=b.value.length,!(n.fetchedSize+w>n.maxFetchSize)){r.next=34;break}throw u.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 34:n.fetchedSize+=w,o?(s=new SharedArrayBuffer(g),f=new Uint8Array(s)):f=new Uint8Array(g),f.set(b.value),e({url:a,position:w,fileArraybuffer:f});case 38:if(m){r.next=57;break}return r.next=41,y.read();case 41:if(!(v=r.sent).done){r.next=45;break}return m=!0,r.abrupt("continue",38);case 45:if(x=v.value,!(n.fetchedSize+x.length>n.maxFetchSize)){r.next=51;break}throw s=null,f=null,u.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 51:n.fetchedSize+=x.length,f.set(x,w),w+=x.length,e({isAppending:!0,url:a,position:w,chunk:o?void 0:x}),r.next=38;break;case 57:c&&te(c,h,f.slice().buffer);case 58:r.next=65;break;case 60:throw r.prev=60,r.t0=r.catch(4),P=new E("fileStreaming.ts: "+r.t0.message||0),console.error(P.message,r.t0),P;case 65:return r.prev=65,s=null,f=null,u.abort(),r.finish(65);case 70:case"end":return r.stop()}}),r,null,[[4,60,65,70]])})),function(){var t=this,e=arguments;return new Promise((function(n,a){var i=r.apply(t,e);function o(t){ke(i,n,a,o,c,"next",t)}function c(t){ke(i,n,a,o,c,"throw",t)}o(void 0)}))})()}};const Te=Ae;function je(t){return je="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},je(t)}function Ie(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,i,o,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.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&&(o=r.return(),Object(o)!==o))return}finally{if(s)throw a}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Fe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Fe(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_e=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.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 i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),c=new j(n||[]);return a(o,"_invoke",{value:L(t,r,c)}),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,o,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,o)&&(w=E);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,i,o,c){var u=l(t[a],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==je(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,o,c)}),(function(t){r("throw",t,o,c)})):e.resolve(f).then((function(t){s.value=t,o(s)}),(function(t){return r("throw",t,o,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,a){r(t,n,e,a)}))}return i=i?i.then(a,a):a()}})}function L(e,r,n){var a=h;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===y){if("throw"===i)throw o;return{value:t,done:!0}}for(n.method=i,n.arg=o;;){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 i=l(a,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=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 i.next=i}}throw new TypeError(je(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,i){void 0===i&&(i=Promise);var o=new O(f(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(P),s(P,u,"Generator"),s(P,o,(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,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return c.type="throw",c.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],c=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.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 i=a;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;T(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 De(t,e,r,n,a,i,o){try{var c=t[i](o),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,a)}function Ne(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function o(t){De(i,n,a,o,c,"next",t)}function c(t){De(i,n,a,o,c,"throw",t)}o(void 0)}))}}function Ue(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Re(n.key),n)}}function Me(t,e,r){return(e=Re(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Re(t){var e=function(t,e){if("object"!=je(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=je(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==je(e)?e:e+""}var Be=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),Me(this,"filePromises",{}),Me(this,"options",{maxWorkerFetchSize:1/0,domain:F.url.DOMAIN,enableLocalCache:!1}),Me(this,"fileManager",void 0),Me(this,"metadataManager",void 0),Me(this,"seriesUidFileUrls",{}),Me(this,"setOptions",(function(t){Object.keys(t).forEach((function(r){void 0!==t[r]&&(e.options[r]=t[r])}))})),Me(this,"getOptions",(function(){return e.options}));var a=n.maxWorkerFetchSize,i=n.domain,o=n.disableWorker,u=n.enableLocalCache;this.options.maxWorkerFetchSize=a||this.options.maxWorkerFetchSize,this.options.domain=i||this.options.domain,this.options.enableLocalCache=!!u;var s=F.dataRetrieval.FILE_STREAMING_WORKER_NAME,f=F.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Lt({fileStreamingScriptName:s}),this.metadataManager=new ve,o&&bt().setDataRetrieverMode(c.REQUEST),function(t,e){var n=t.fileStreamingScriptName,a=t.filePartialScriptName,i=bt();i.getDataRetrieverMode()===c.REQUEST?(i.register(n,Te),i.register(a,xe)):(i.register(n,(function(){return new Worker(new URL(r.p+r.u(846),r.b),{name:n})})),i.register(a,(function(){return new Worker(new URL(r.p+r.u(563),r.b),{name:a})}))),i.executeTask(n,"setMaxFetchSize",e)}({fileStreamingScriptName:s,filePartialScriptName:f},this.options.maxWorkerFetchSize)},e=[{key:"addFileUrl",value:function(t,e,r){this.seriesUidFileUrls[t]?this.seriesUidFileUrls[t].add({type:e,url:r}):this.seriesUidFileUrls[t]=new Set([{type:e,url:r}])}},{key:"fetchCod",value:(f=Ne(_e().mark((function t(e){var r,n,a,c,f,l,h,d,p,y,v,m,g,b,w,x,P,S,O,L,k,A,T,j=this,I=arguments;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=I.length>1&&void 0!==I[1]?I[1]:{},a=(n=I.length>2&&void 0!==I[2]?I[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,f=n.fetchType,l=void 0===f?F.Enums.FetchType.API_OPTIMIZED:f,t.prev=2,e){t.next=5;break}throw new E("Url not provided");case 5:if(!(h=Tt(e,this.options.domain))){t.next=31;break}return d=h.type,p=h.bucketName,y=h.bucketPrefix,v=h.studyInstanceUID,m=h.seriesInstanceUID,g=h.sopInstanceUID,b=h.frameNumber,t.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:p,bucketPrefix:y,studyInstanceUID:v,seriesInstanceUID:m},r);case 10:if(w=t.sent){t.next=13;break}throw new E("Metadata not found for ".concat(e));case 13:x=jt(w,g,b-1,{domain:this.options.domain,bucketName:p,bucketPrefix:y}),P=x.url,S=x.startByte,O=x.endByte,L=x.thumbnailUrl,k=x.isMultiframe,t.t0=d,t.next=t.t0===o.THUMBNAIL?17:t.t0===o.FRAME?21:t.t0===o.SERIES_METADATA||t.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(L){t.next=19;break}throw new E("Thumbnail not found for ".concat(e));case 19:return this.addFileUrl(m,u.THUMBNAIL,L),t.abrupt("return",this.fetchFile(L,r,{useSharedArrayBuffer:c}));case 21:if(P){t.next=23;break}throw new E("Url not found for frame");case 23:return A=P,l===i.BYTES_OPTIMIZED&&(A="".concat(P,"?bytes=").concat(S,"-").concat(O)),this.addFileUrl(m,u.FILE,P),t.abrupt("return",this.fetchFile(A,r,{offsets:{startByte:S,endByte:O},useSharedArrayBuffer:c,fetchType:l}).then((function(t){if(null==t||!t.byteLength)throw new E("File Arraybuffer is not found");if(k)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 E("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),T=new E("CodDicomWebServer.ts: ".concat(t.t1.message||"An error occured when fetching the COD")),console.error(T),T;case 39:case"end":return t.stop()}}),t,this,[[2,34]])}))),function(t){return f.apply(this,arguments)})},{key:"fetchFile",value:(a=Ne(_e().mark((function t(e,r){var n,a,o,c,u,s,f,l,h,d,p,y,v,m,g,b,w,x=this,S=arguments;return _e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=(n=S.length>2&&void 0!==S[2]?S[2]:{}).offsets,o=n.useSharedArrayBuffer,c=void 0!==o&&o,u=n.fetchType,s=void 0===u?F.Enums.FetchType.API_OPTIMIZED:u,f=s===i.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.enableLocalCache,!t.t0){t.next=10;break}return t.next=9,Yt();case 9:t.t0=t.sent;case 10:return h=t.t0,d=this.getOptions(),p=d.maxWorkerFetchSize,y=bt(),v=F.dataRetrieval,m=v.FILE_STREAMING_WORKER_NAME,g=v.FILE_PARTIAL_WORKER_NAME,b=v.THRESHOLD,this.filePromises[e]?w=this.filePromises[e]:(w=new Promise((function(t,n){if(x.fileManager.getTotalSize()+b>p)throw new E("CodDicomWebServer.ts: Maximum size(".concat(p,") for fetching files reached"));var i=F.Enums.FetchType;if(s===i.API_OPTIMIZED){var o=function(t){if(t instanceof P)throw n(t.error),t.error;var r=t.data,a=r.url,i=r.position,c=r.fileArraybuffer;a===e&&c&&(x.fileManager.set(a,{data:c,position:i}),y.removeEventListener(m,"message",o))};y.addEventListener(m,"message",o),y.executeTask(m,"stream",{url:e,headers:r,useSharedArrayBuffer:c,directoryHandle:h}).then((function(){t()})).catch((function(t){n(t)})).then((function(){y.removeEventListener(m,"message",o),delete x.filePromises[e]}))}else if(s===i.BYTES_OPTIMIZED&&a){var u=a.startByte,f=a.endByte,l=e.split("?bytes=")[0],d=function(r){if(r instanceof P)throw n(r.error),r.error;var a=r.data,i=a.url,o=a.fileArraybuffer,c=a.offsets;i===l&&c.startByte===u&&c.endByte===f&&(x.fileManager.set(e,{data:o,position:o.length}),y.removeEventListener(g,"message",d),t())};y.addEventListener(g,"message",d),y.executeTask(g,"partial",{url:l,offsets:{startByte:u,endByte:f},headers:r,directoryHandle:h}).catch((function(t){n(t)})).then((function(){y.removeEventListener(g,"message",d),delete x.filePromises[e]}))}else n(new E("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[e]=w),t.abrupt("return",new Promise((function(t,r){var n=!1,i=function(i){if(i instanceof P)throw r(i.message),i.error;var o=i.data,c=o.url,u=o.position,s=o.chunk;if(o.isAppending&&(s?x.fileManager.append(c,s,u):x.fileManager.setPosition(c,u)),!n&&c===e&&a&&u>a.endByte)try{var f=x.fileManager.get(c,a);n=!0,t(null==f?void 0:f.buffer)}catch(t){r(t)}};a&&!f&&y.addEventListener(m,"message",i),w.then((function(){if(!n)if(x.fileManager.getPosition(e)){var i=x.fileManager.get(e,f?void 0:a);n=!0,t(null==i?void 0:i.buffer)}else r(new E("File - ".concat(e," not found")))})).catch((function(t){r(t)})).then((function(){y.removeEventListener(m,"message",i)}))})));case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"downloadSeriesFile",value:function(t){var e,r=null===(e=Array.from(this.seriesUidFileUrls[t]).find((function(t){var e=t.url;return t.type===u.FILE&&e.endsWith(".tar")})))||void 0===e?void 0:e.url;if(r){var n=this.fileManager.get(r);return function(t,e){try{var r=new Blob([e],{type:"application/x-tar"}),n=URL.createObjectURL(r),a=document.createElement("a");return a.href=n,a.download=t,a.click(),URL.revokeObjectURL(n),!0}catch(e){return console.warn("Error downloading file - ".concat(t,": ")+e.message),!1}}(r.split("/").at(-1),n)}return!1}},{key:"delete",value:function(t){var e=this,r=this.seriesUidFileUrls[t];r&&r.forEach((function(t){var r=t.url;e.fileManager.remove(r)})),delete this.seriesUidFileUrls[t]}},{key:"deleteAll",value:function(){var t=this;Object.values(this.seriesUidFileUrls).forEach((function(e){e.forEach((function(e){var r=e.url;t.fileManager.remove(r)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(t,e,r){var n;return e===o.INSTANCE_METADATA?null===(n=Object.entries(t.cod.instances).find((function(t){var e=Ie(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&&Ue(t.prototype,e),n&&Ue(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,a,f}();const Ge=Be,Ce={FetchType:i,CodDicomWebServer:Be,clearPartialFiles:re}})(),n})()));
|
|
21
21
|
//# sourceMappingURL=main.js.map
|