dicomweb-proxy
Version:
A proxy to translate between dicomweb and dimse
2 lines • 1.02 MB
JavaScript
/*! For license information please see ort.all.min.js.LICENSE.txt */
var Vy=Object.create,Ho=Object.defineProperty,Fy=Object.getOwnPropertyDescriptor,Uy=Object.getOwnPropertyNames,Gy=Object.getPrototypeOf,Wy=Object.prototype.hasOwnProperty,D=(e,t)=>()=>(e&&(t=e(e=0)),t),Je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zr=(e,t)=>{for(var n in t)Ho(e,n,{get:t[n],enumerable:!0})},Gu=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of Uy(t))!Wy.call(e,i)&&i!==n&&Ho(e,i,{get:()=>t[i],enumerable:!(r=Fy(t,i))||r.enumerable});return e},Tn=(e,t,n)=>(n=null!=e?Vy(Gy(e)):{},Gu(!t&&e&&e.__esModule?n:Ho(n,"default",{value:e,enumerable:!0}),e)),Nr=e=>Gu(Ho({},"__esModule",{value:!0}),e),qo,Jr,Lr,jo,Ko=D((()=>{"use strict";qo=new Map,Jr=[],Lr=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{let r=qo.get(e);if(void 0===r)qo.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=Jr.indexOf(e);-1!==t&&Jr.splice(t,1);for(let t=0;t<Jr.length;t++)if(qo.get(Jr[t]).priority<=n)return void Jr.splice(t,0,e);Jr.push(e)}}},jo=async e=>{let t=0===e.length?Jr:e,n=[];for(let e of t){let t=qo.get(e);if(t){if(t.initialized)return t.backend;if(t.aborted)continue;let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(i){r||n.push({name:e,err:i}),t.aborted=!0}finally{delete t.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`)}})),Wu=D((()=>{"use strict";Ko()})),Hu,qu=D((()=>{"use strict";Hu="1.17.1"})),ju,Qr,Aa=D((()=>{"use strict";qu(),ju="warning",Qr={wasm:{},webgl:{},webgpu:{},versions:{common:Hu},set logLevel(e){if(void 0!==e){if("string"!=typeof e||-1===["verbose","info","warning","error","fatal"].indexOf(e))throw new Error(`Unsupported logging level: ${e}`);ju=e}},get logLevel(){return ju}},Object.defineProperty(Qr,"logLevel",{enumerable:!0})})),ye,Ku=D((()=>{"use strict";Aa(),ye=Qr})),Yu,Xu,Zu=D((()=>{"use strict";Yu=(e,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext("2d");if(null!=r){let i,a;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o,s,u=void 0!==t?.format?t.format:"RGB",l=t?.norm;void 0===l||void 0===l.mean?o=[255,255,255,255]:"number"==typeof l.mean?o=[l.mean,l.mean,l.mean,l.mean]:(o=[l.mean[0],l.mean[1],l.mean[2],0],void 0!==l.mean[3]&&(o[3]=l.mean[3])),void 0===l||void 0===l.bias?s=[0,0,0,0]:"number"==typeof l.bias?s=[l.bias,l.bias,l.bias,l.bias]:(s=[l.bias[0],l.bias[1],l.bias[2],0],void 0!==l.bias[3]&&(s[3]=l.bias[3]));let d=a*i,p=0,c=d,h=2*d,f=-1;"RGBA"===u?(p=0,c=d,h=2*d,f=3*d):"RGB"===u?(p=0,c=d,h=2*d):"RBG"===u&&(p=0,h=d,c=2*d);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[p++]-s[0])*o[0],a=(e.data[c++]-s[1])*o[1],u=(e.data[h++]-s[2])*o[2],l=-1===f?255:(e.data[f++]-s[3])*o[3];r.fillStyle="rgba("+i+","+a+","+u+","+l+")",r.fillRect(n,t,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}throw new Error("Can not access image data")},Xu=(e,t)=>{let n,r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");if(null==r)throw new Error("Can not access image data");{let i,a,o;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s,u,l=void 0!==t&&void 0!==t.format?t.format:"RGB",d=t?.norm;void 0===d||void 0===d.mean?s=[255,255,255,255]:"number"==typeof d.mean?s=[d.mean,d.mean,d.mean,d.mean]:(s=[d.mean[0],d.mean[1],d.mean[2],255],void 0!==d.mean[3]&&(s[3]=d.mean[3])),void 0===d||void 0===d.bias?u=[0,0,0,0]:"number"==typeof d.bias?u=[d.bias,d.bias,d.bias,d.bias]:(u=[d.bias[0],d.bias[1],d.bias[2],0],void 0!==d.bias[3]&&(u[3]=d.bias[3]));let p=a*i;if(void 0!==t&&(void 0!==t.format&&4===o&&"RGBA"!==t.format||3===o&&"RGB"!==t.format&&"BGR"!==t.format))throw new Error("Tensor format doesn't match input tensor dims");let c=4,h=0,f=1,m=2,g=3,y=0,b=p,w=2*p,v=-1;"RGBA"===l?(y=0,b=p,w=2*p,v=3*p):"RGB"===l?(y=0,b=p,w=2*p):"RBG"===l&&(y=0,w=p,b=2*p),n=r.createImageData(i,a);for(let t=0;t<a*i;h+=c,f+=c,m+=c,g+=c,t++)n.data[h]=(e.data[y++]-u[0])*s[0],n.data[f]=(e.data[b++]-u[1])*s[1],n.data[m]=(e.data[w++]-u[2])*s[2],n.data[g]=-1===v?255:(e.data[v++]-u[3])*s[3]}return n}})),Oa,Ju,Qu,el,tl,rl=D((()=>{"use strict";Yo(),Oa=(e,t)=>{if(void 0===e)throw new Error("Image buffer must be defined");if(void 0===t.height||void 0===t.width)throw new Error("Image height and width must be defined");if("NHWC"===t.tensorLayout)throw new Error("NHWC Tensor layout is not supported yet");let n,r,{height:i,width:a}=t,o=t.norm??{mean:255,bias:0};n="number"==typeof o.mean?[o.mean,o.mean,o.mean,o.mean]:[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],r="number"==typeof o.bias?[o.bias,o.bias,o.bias,o.bias]:[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let s=void 0!==t.format?t.format:"RGBA",u=void 0!==t.tensorFormat&&void 0!==t.tensorFormat?t.tensorFormat:"RGB",l=i*a,d="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l),p=4,c=0,h=1,f=2,m=3,g=0,y=l,b=2*l,w=-1;"RGB"===s&&(p=3,c=0,h=1,f=2,m=-1),"RGBA"===u?w=3*l:"RBG"===u?(g=0,b=l,y=2*l):"BGR"===u&&(b=0,y=l,g=2*l);for(let t=0;t<l;t++,c+=p,f+=p,h+=p,m+=p)d[g++]=(e[c]+r[0])/n[0],d[y++]=(e[h]+r[1])/n[1],d[b++]=(e[f]+r[2])/n[2],-1!==w&&-1!==m&&(d[w++]=(e[m]+r[3])/n[3]);return new kt("float32",d,"RGBA"===u?[1,4,i,a]:[1,3,i,a])},Ju=async(e,t)=>{let n,r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,i=typeof ImageData<"u"&&e instanceof ImageData,a=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,o="string"==typeof e,s=t??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=e=>e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):null;if(r){let r=u();r.width=e.width,r.height=e.height;let i=l(r);if(null==i)throw new Error("Can not access image data");{let r=e.height,a=e.width;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(r=t.resizedHeight,a=t.resizedWidth),void 0!==t){if(s=t,void 0!==t.tensorFormat)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=r,s.width=a}else s.tensorFormat="RGBA",s.height=r,s.width=a;i.drawImage(e,0,0),n=i.getImageData(0,0,a,r).data}}else{if(!i){if(a){if(void 0===t)throw new Error("Please provide image config with format for Imagebitmap");let r=u();r.width=e.width,r.height=e.height;let i=l(r);if(null!=i){let t=e.height,r=e.width;return i.drawImage(e,0,0,r,t),n=i.getImageData(0,0,r,t).data,s.height=t,s.width=r,Oa(n,s)}throw new Error("Can not access image data")}if(o)return new Promise(((t,n)=>{let r=u(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin="Anonymous",a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(Oa(e.data,s))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,i;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(r=t.resizedHeight,i=t.resizedWidth):(r=e.height,i=e.width),void 0!==t&&(s=t),s.format="RGBA",s.height=r,s.width=i,void 0!==t){let t=u();t.width=i,t.height=r;let a=l(t);if(null==a)throw new Error("Can not access image data");a.putImageData(e,0,0),n=a.getImageData(0,0,i,r).data}else n=e.data}}if(void 0!==n)return Oa(n,s);throw new Error("Input data provided is not supported - aborted tensor creation")},Qu=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new kt({location:"texture",type:"float32",texture:e,dims:[1,r,n,4],download:i,dispose:a})},el=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new kt({location:"gpu-buffer",type:n??"float32",gpuBuffer:e,dims:r,download:i,dispose:a})},tl=(e,t,n)=>new kt({location:"cpu-pinned",type:e,data:t,dims:n??[t.length]})})),ro,Xo,nl,ol,il=D((()=>{"use strict";ro=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Xo=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),nl=!1,ol=()=>{if(!nl){nl=!0;let e=typeof BigInt64Array<"u"&&"function"==typeof BigInt64Array.from,t=typeof BigUint64Array<"u"&&"function"==typeof BigUint64Array.from;e&&(ro.set("int64",BigInt64Array),Xo.set(BigInt64Array,"int64")),t&&(ro.set("uint64",BigUint64Array),Xo.set(BigUint64Array,"uint64"))}}})),al,sl,ul=D((()=>{"use strict";Yo(),al=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if("number"!=typeof r||!Number.isSafeInteger(r))throw new TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},sl=(e,t)=>{switch(e.location){case"cpu":return new kt(e.type,e.data,t);case"cpu-pinned":return new kt({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new kt({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new kt({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}})),kt,Yo=D((()=>{"use strict";Zu(),rl(),il(),ul(),kt=class{constructor(e,t,n){let r,i;if(ol(),"object"==typeof e&&"location"in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case"cpu-pinned":{let t=ro.get(r);if(!t)throw new TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw new TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case"texture":if("float32"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case"gpu-buffer":if("float32"!==r&&"float16"!==r&&"int32"!==r&&"int64"!==r&&"uint32"!==r&&"bool"!==r)throw new TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if("string"==typeof e)if(r=e,o=n,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");a=t}else{let n=ro.get(e);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if("float16"===e)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");a="uint64"===e||"int64"===e?n.from(t,BigInt):n.from(t)}else{if(!(t instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);a=t}}else if(o=t,Array.isArray(e)){if(0===e.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");let t=typeof e[0];if("string"===t)r="string",a=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);r="bool",a=Uint8Array.from(e)}}else{let t=Xo.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(void 0===o)o=[a.length];else if(!Array.isArray(o))throw new TypeError("A tensor's dims must be a number array");i=o,this.cpuData=a,this.dataLocation="cpu"}let a=al(i);if(this.cpuData&&a!==this.cpuData.length)throw new Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return Ju(e,t)}static fromTexture(e,t){return Qu(e,t)}static fromGpuBuffer(e,t){return el(e,t)}static fromPinnedBuffer(e,t,n){return tl(e,t,n)}toDataURL(e){return Yu(this,e)}toImageData(e){return Xu(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if("none"===this.dataLocation)throw new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return sl(this,e)}}})),_t,Zo=D((()=>{"use strict";Yo(),_t=kt})),Jo,ll,Ut,Gt,Ea=D((()=>{"use strict";Aa(),Jo=(e,t)=>{Qr.wasm.trace&&console.timeStamp(`${e}::ORT::${t}`)},ll=(e,t)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes("TRACE_FUNC")){let r=`FUNC_${e}::${n[i].trim().split(" ")[1]}`;return t&&(r+=`::${t}`),void Jo("CPU",r)}n[i].includes("TRACE_FUNC")&&(r=!0)}},Ut=e=>{Qr.wasm.trace&&ll("BEGIN",e)},Gt=e=>{Qr.wasm.trace&&ll("END",e)}})),Qo,dl=D((()=>{"use strict";Ko(),Zo(),Ea(),Qo=class e{constructor(e){this.handler=e}async run(e,t,n){Ut();let r={},i={};if("object"!=typeof e||null===e||e instanceof _t||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if("object"==typeof t){if(null===t)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof _t)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(0===t.length)throw new TypeError("'fetches' cannot be an empty array.");a=!1;for(let e of t){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===this.outputNames.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(-1!==o.indexOf(n)){let i=t[n];(null===i||i instanceof _t)&&(e=!0,a=!1,r[n]=i)}if(e){if("object"==typeof n&&null!==n)i=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else i=t}}else if(typeof t<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of this.inputNames)if(typeof e[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];s[e]=t instanceof _t?t:new _t(t.type,t.data,t.dims)}return Gt(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Ut();let a,o={};if("string"==typeof t){if(a=t,"object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(a=t,"object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{if(!(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{let e=t,s=0,u=t.byteLength;if("object"==typeof n&&null!==n)o=n;else if("number"==typeof n){if(s=n,!Number.isSafeInteger(s))throw new RangeError("'byteOffset' must be an integer.");if(s<0||s>=e.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(u=t.byteLength-s,"number"==typeof r){if(u=r,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||s+u>e.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if("object"==typeof i&&null!==i)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof r<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");a=new Uint8Array(e,s,u)}}let s=(o.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),u=await(await jo(s)).createInferenceSessionHandler(a,o);return Gt(),new e(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}})),Hy,cl=D((()=>{"use strict";dl(),Hy=Qo})),fl=D((()=>{})),qy,ei,pl=D((()=>{"use strict";Ko(),Zo(),qy="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",ei=class e{constructor(e,t,n){this.handler=e,this.hasOptimizerModel=t,this.hasEvalModel=n}get trainingInputNames(){return this.handler.inputNames}get trainingOutputNames(){return this.handler.outputNames}get evalInputNames(){if(this.hasEvalModel)return this.handler.evalInputNames;throw new Error("This training session has no evalModel loaded.")}get evalOutputNames(){if(this.hasEvalModel)return this.handler.evalOutputNames;throw new Error("This training session has no evalModel loaded.")}static async create(t,n){let r=t.evalModel||"",i=t.optimizerModel||"",a=n||{},o=(a.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),s=await jo(o);if(s.createTrainingSessionHandler){let n=await s.createTrainingSessionHandler(t.checkpointState,t.trainModel,r,i,a);return new e(n,!!t.optimizerModel,!!t.evalModel)}throw new Error(qy)}typeNarrowingForRunStep(e,t,n,r,i){let a={},o={};if("object"!=typeof n||null===n||n instanceof _t||Array.isArray(n))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if("object"==typeof r){if(null===r)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof _t)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(0===r.length)throw new TypeError("'fetches' cannot be an empty array.");s=!1;for(let e of r){if("string"!=typeof e)throw new TypeError("'fetches' must be a string array or an object.");if(-1===t.indexOf(e))throw new RangeError(`'fetches' contains invalid output name: ${e}.`);a[e]=null}if("object"==typeof i&&null!==i)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,n=Object.getOwnPropertyNames(r);for(let i of t)if(-1!==n.indexOf(i)){let t=r[i];(null===t||t instanceof _t)&&(e=!0,s=!1,a[i]=t)}if(e){if("object"==typeof i&&null!==i)o=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else o=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let t of e)if(typeof n[t]>"u")throw new Error(`input '${t}' is missing in 'feeds'.`);if(s)for(let e of t)a[e]=null;return[a,o]}convertHandlerReturnTypeToMapOfTensors(e){let t={};for(let n in e)if(Object.hasOwnProperty.call(e,n)){let r=e[n];t[n]=r instanceof _t?r:new _t(r.type,r.data,r.dims)}return t}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,t,n){let[r,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,t,n),a=await this.handler.runTrainStep(e,r,i);return this.convertHandlerReturnTypeToMapOfTensors(a)}async runOptimizerStep(e){if(!this.hasOptimizerModel)throw new Error("This TrainingSession has no OptimizerModel loaded.");await this.handler.runOptimizerStep(e||{})}async runEvalStep(e,t,n){if(this.hasEvalModel){let[r,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,t,n),a=await this.handler.runEvalStep(e,r,i);return this.convertHandlerReturnTypeToMapOfTensors(a)}throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,t=!0){let n=await this.getParametersSize(t);if(e.length!==4*n)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(e,t)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}})),jy,hl=D((()=>{"use strict";pl(),jy=ei})),Ca={};Zr(Ca,{InferenceSession:()=>Hy,TRACE:()=>Jo,TRACE_FUNC_BEGIN:()=>Ut,TRACE_FUNC_END:()=>Gt,Tensor:()=>_t,TrainingSession:()=>jy,env:()=>ye,registerBackend:()=>Lr});var Et=D((()=>{"use strict";Wu(),Ku(),cl(),Zo(),Ea(),fl(),hl()}));function Mr(e,t,n,r){if(void 0===t)return Yy(e);if(void 0===n)ti(e,t,1);else if("number"==typeof n&&void 0===r)ti(e,t,n);else if("string"==typeof n&&void 0===r)ti(e,n,1,t);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");ti(e,n,r,t)}}function Yy(e){return{verbose:Mr.verbose.bind(null,e),info:Mr.info.bind(null,e),warning:Mr.warning.bind(null,e),error:Mr.error.bind(null,e),fatal:Mr.fatal.bind(null,e)}}function ti(e,t,n,r){let i=no[r||""]||no[""];gl[e]<gl[i.minimalSeverity]||(i.logDateTime&&(t=`${(new Date).toISOString()}|${t}`),i.logSourceLocation,Ky[i.provider].log(e,t,r))}var Pa,ka,gl,Ky,bl,no,qe,ni,oi,ii,ri,Ht=D((()=>{"use strict";Pa=class{log(e,t,n){}},ka=class{log(e,t,n){console.log(`${this.color(e)} ${n?"[35m"+n+"[0m ":""}${t}`)}color(e){switch(e){case"verbose":return"[34;40mv[0m";case"info":return"[32mi[0m";case"warning":return"[30;43mw[0m";case"error":return"[31;40me[0m";case"fatal":return"[101mf[0m";default:throw new Error(`unsupported severity: ${e}`)}}},gl={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Ky={none:new Pa,console:new ka},no={"":bl={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(e=>{function t(e){no={},n("",e||{})}function n(e,n){if("*"===e)t(n);else{let t=no[e]||bl;no[e]={provider:n.provider||t.provider,minimalSeverity:n.minimalSeverity||t.minimalSeverity,logDateTime:void 0===n.logDateTime?t.logDateTime:n.logDateTime,logSourceLocation:void 0===n.logSourceLocation?t.logSourceLocation:n.logSourceLocation}}}e.verbose=function(t,n){e("verbose",t,n)},e.info=function(t,n){e("info",t,n)},e.warning=function(t,n){e("warning",t,n)},e.error=function(t,n){e("error",t,n)},e.fatal=function(t,n){e("fatal",t,n)},e.reset=t,e.set=n,e.setWithEnv=function(e){let t={};e.logLevel&&(t.minimalSeverity=e.logLevel),n("",t)}})(Mr||={}),qe=Mr,ni=class{constructor(e,t,n,r,i,a){this.category=e,this.name=t,this.startTime=n,this.endCallback=r,this.timer=i,this.ctx=a}async end(){return this.endCallback(this)}async checkTimer(){if(void 0===this.ctx||void 0===this.timer)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},oi=class{constructor(e,t,n,r){this.category=e,this.name=t,this.startTime=n,this.endTime=r}},ii=class{constructor(e,t,n){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=void 0===e?1e4:e,this._flushBatchSize=void 0===t?10:t,this._flushIntervalInMilliseconds=void 0===n?5e3:n}static create(e){return void 0===e?new this:new this(e.maxNumberEvents,e.flushBatchSize,e.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=ri(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,t,n,r){let i=this._started?this.begin(e,t,r):void 0,a=!1,o=n();if(o&&"function"==typeof o.then)return a=!0,new Promise(((e,t)=>{o.then((async t=>{i&&await i.end(),e(t)}),(async e=>{i&&await i.end(),t(e)}))}));if(!a&&i){let e=i.end();if(e&&"function"==typeof e.then)return new Promise(((t,n)=>{e.then((()=>{t(o)}),(e=>{n(e)}))}))}return o}begin(e,t,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){let n=ri();return this.flush(n),new ni(e,t,n,(e=>this.endSync(e)))}{let r=n.beginTimer();return new ni(e,t,0,(async e=>this.end(e)),r,n)}}async end(e){let t=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new oi(e.category,e.name,e.startTime,t)),this.flush(t))}endSync(e){let t=ri();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new oi(e.category,e.name,e.startTime,t)),this.flush(t))}logOneEvent(e){qe.verbose(`Profiler.${e.category}`,`${(e.endTime-e.startTime).toFixed(2)}ms on event '${e.name}' at ${e.endTime.toFixed(2)}`)}flush(e){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(let e=this._flushPointer;this._flushPointer<e+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=ri()}}get started(){return this._started}},ri=typeof performance<"u"&&performance.now?()=>performance.now():Date.now}));function yl(e,t,n){for(let r of n){let n=r[0],i=r[1],a=r[2],o=r[3],s=r[4];if(e.opType===n)for(let e of t)if((e.domain===i||"ai.onnx"===e.domain&&""===i)&&Xy(e.version,a))return{opImpl:o,opInit:s}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${t.map((e=>`${e.domain||"ai.onnx"} v${e.version}`)).join(", ")}`)}function Xy(e,t){if(t.endsWith("+")){let n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=e}if(2===t.split("-").length){let n=t.split("-"),r=Number.parseInt(n[0],10),i=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(i)&&r<=e&&e<=i}return Number.parseInt(t,10)===e}var vl=D((()=>{})),wl=Je((e=>{"use strict";e.__esModule=!0;var t=function(){function e(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=e.EMPTY,t&&e.isGuid(t)&&(this.value=t)}return e.isGuid=function(t){var n=t.toString();return t&&(t instanceof e||e.validator.test(n))},e.create=function(){return new e([e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-"))},e.createEmpty=function(){return new e("emptyguid")},e.parse=function(t){return new e(t)},e.raw=function(){return[e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-")},e.gen=function(e){for(var t="",n=0;n<e;n++)t+=(65536*(1+Math.random())|0).toString(16).substring(1);return t},e.prototype.equals=function(t){return e.isGuid(t)&&this.value===t.toString()},e.prototype.isEmpty=function(){return this.value===e.EMPTY},e.prototype.toString=function(){return this.value},e.prototype.toJSON=function(){return{value:this.value}},e.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),e.EMPTY="00000000-0000-0000-0000-000000000000",e}();e.Guid=t}));function Qe(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Ct(e){return!0===(e&&e.__isLong__)}function xl(e){var t=Math.clz32(e&-e);return e?31-t:t}function en(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=_l[e])?r:(n=Ge(e,0,!0),i&&(_l[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=Tl[e])?r:(n=Ge(e,e<0?-1:0,!1),i&&(Tl[e]=n),n)}function jt(e,t){if(isNaN(e))return t?Or:nr;if(t){if(e<0)return Or;if(e>=Al)return Cl}else{if(e<=-Sl)return zt;if(e+1>=Sl)return El}return e<0?jt(-e,t).neg():Ge(e%$n|0,e/$n|0,t)}function Ge(e,t,n){return new Qe(e,t,n)}function Ra(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Or:nr;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Ra(e.substring(1),t,n).neg();for(var i=jt(ai(n,8)),a=nr,o=0;o<e.length;o+=8){var s=Math.min(8,e.length-o),u=parseInt(e.substring(o,o+s),n);if(s<8){var l=jt(ai(n,s));a=a.mul(l).add(jt(u))}else a=(a=a.mul(i)).add(jt(u))}return a.unsigned=t,a}function or(e,t){return"number"==typeof e?jt(e,t):"string"==typeof e?Ra(e,t):Ge(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}var qt,Tl,_l,ai,$l,Jy,$n,Al,Sl,Il,nr,Or,_n,Ol,Ba,El,Cl,zt,K,Er,za=D((()=>{qt=null;try{qt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}Qe.prototype.__isLong__,Object.defineProperty(Qe.prototype,"__isLong__",{value:!0}),Qe.isLong=Ct,Tl={},_l={},Qe.fromInt=en,Qe.fromNumber=jt,Qe.fromBits=Ge,ai=Math.pow,Qe.fromString=Ra,Qe.fromValue=or,Sl=(Al=($n=($l=65536)*$l)*$n)/2,Il=en(Jy=1<<24),nr=en(0),Qe.ZERO=nr,Or=en(0,!0),Qe.UZERO=Or,_n=en(1),Qe.ONE=_n,Ol=en(1,!0),Qe.UONE=Ol,Ba=en(-1),Qe.NEG_ONE=Ba,El=Ge(-1,2147483647,!1),Qe.MAX_VALUE=El,Cl=Ge(-1,-1,!0),Qe.MAX_UNSIGNED_VALUE=Cl,zt=Ge(0,-2147483648,!1),Qe.MIN_VALUE=zt,(K=Qe.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},K.toNumber=function(){return this.unsigned?(this.high>>>0)*$n+(this.low>>>0):this.high*$n+(this.low>>>0)},K.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(zt)){var t=jt(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=jt(ai(e,6),this.unsigned),a=this,o="";;){var s=a.div(i),u=(a.sub(s.mul(i)).toInt()>>>0).toString(e);if((a=s).isZero())return u+o;for(;u.length<6;)u="0"+u;o=""+u+o}},K.getHighBits=function(){return this.high},K.getHighBitsUnsigned=function(){return this.high>>>0},K.getLowBits=function(){return this.low},K.getLowBitsUnsigned=function(){return this.low>>>0},K.getNumBitsAbs=function(){if(this.isNegative())return this.eq(zt)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},K.isZero=function(){return 0===this.high&&0===this.low},K.eqz=K.isZero,K.isNegative=function(){return!this.unsigned&&this.high<0},K.isPositive=function(){return this.unsigned||this.high>=0},K.isOdd=function(){return!(1&~this.low)},K.isEven=function(){return!(1&this.low)},K.equals=function(e){return Ct(e)||(e=or(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},K.eq=K.equals,K.notEquals=function(e){return!this.eq(e)},K.neq=K.notEquals,K.ne=K.notEquals,K.lessThan=function(e){return this.comp(e)<0},K.lt=K.lessThan,K.lessThanOrEqual=function(e){return this.comp(e)<=0},K.lte=K.lessThanOrEqual,K.le=K.lessThanOrEqual,K.greaterThan=function(e){return this.comp(e)>0},K.gt=K.greaterThan,K.greaterThanOrEqual=function(e){return this.comp(e)>=0},K.gte=K.greaterThanOrEqual,K.ge=K.greaterThanOrEqual,K.compare=function(e){if(Ct(e)||(e=or(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},K.comp=K.compare,K.negate=function(){return!this.unsigned&&this.eq(zt)?zt:this.not().add(_n)},K.neg=K.negate,K.add=function(e){Ct(e)||(e=or(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,u=0,l=0,d=0,p=0;return d+=(p+=i+(65535&e.low))>>>16,l+=(d+=r+s)>>>16,u+=(l+=n+o)>>>16,u+=t+a,Ge((d&=65535)<<16|(p&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},K.subtract=function(e){return Ct(e)||(e=or(e)),this.add(e.neg())},K.sub=K.subtract,K.multiply=function(e){if(this.isZero())return this;if(Ct(e)||(e=or(e)),qt)return Ge(qt.mul(this.low,this.high,e.low,e.high),qt.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Or:nr;if(this.eq(zt))return e.isOdd()?zt:nr;if(e.eq(zt))return this.isOdd()?zt:nr;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Il)&&e.lt(Il))return jt(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,a=e.high>>>16,o=65535&e.high,s=e.low>>>16,u=65535&e.low,l=0,d=0,p=0,c=0;return p+=(c+=i*u)>>>16,d+=(p+=r*u)>>>16,p&=65535,d+=(p+=i*s)>>>16,l+=(d+=n*u)>>>16,d&=65535,l+=(d+=r*s)>>>16,d&=65535,l+=(d+=i*o)>>>16,l+=t*u+n*s+r*o+i*a,Ge((p&=65535)<<16|(c&=65535),(l&=65535)<<16|(d&=65535),this.unsigned)},K.mul=K.multiply,K.divide=function(e){if(Ct(e)||(e=or(e)),e.isZero())throw Error("division by zero");var t,n,r;if(qt)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Ge((this.unsigned?qt.div_u:qt.div_s)(this.low,this.high,e.low,e.high),qt.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Or:nr;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Or;if(e.gt(this.shru(1)))return Ol;r=Or}else{if(this.eq(zt))return e.eq(_n)||e.eq(Ba)?zt:e.eq(zt)?_n:(t=this.shr(1).div(e).shl(1)).eq(nr)?e.isNegative()?_n:Ba:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(zt))return this.unsigned?Or:nr;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=nr}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),a=i<=48?1:ai(2,i-48),o=jt(t),s=o.mul(e);s.isNegative()||s.gt(n);)s=(o=jt(t-=a,this.unsigned)).mul(e);o.isZero()&&(o=_n),r=r.add(o),n=n.sub(s)}return r},K.div=K.divide,K.modulo=function(e){return Ct(e)||(e=or(e)),qt?Ge((this.unsigned?qt.rem_u:qt.rem_s)(this.low,this.high,e.low,e.high),qt.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},K.mod=K.modulo,K.rem=K.modulo,K.not=function(){return Ge(~this.low,~this.high,this.unsigned)},K.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},K.clz=K.countLeadingZeros,K.countTrailingZeros=function(){return this.low?xl(this.low):xl(this.high)+32},K.ctz=K.countTrailingZeros,K.and=function(e){return Ct(e)||(e=or(e)),Ge(this.low&e.low,this.high&e.high,this.unsigned)},K.or=function(e){return Ct(e)||(e=or(e)),Ge(this.low|e.low,this.high|e.high,this.unsigned)},K.xor=function(e){return Ct(e)||(e=or(e)),Ge(this.low^e.low,this.high^e.high,this.unsigned)},K.shiftLeft=function(e){return Ct(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Ge(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Ge(0,this.low<<e-32,this.unsigned)},K.shl=K.shiftLeft,K.shiftRight=function(e){return Ct(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Ge(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Ge(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},K.shr=K.shiftRight,K.shiftRightUnsigned=function(e){return Ct(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Ge(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Ge(32===e?this.high:this.high>>>e-32,0,this.unsigned)},K.shru=K.shiftRightUnsigned,K.shr_u=K.shiftRightUnsigned,K.rotateLeft=function(e){var t;return Ct(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Ge(this.high,this.low,this.unsigned):e<32?(t=32-e,Ge(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),Ge(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},K.rotl=K.rotateLeft,K.rotateRight=function(e){var t;return Ct(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Ge(this.high,this.low,this.unsigned):e<32?(t=32-e,Ge(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),Ge(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},K.rotr=K.rotateRight,K.toSigned=function(){return this.unsigned?Ge(this.low,this.high,!1):this},K.toUnsigned=function(){return this.unsigned?this:Ge(this.low,this.high,!0)},K.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},K.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},K.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Qe.fromBytes=function(e,t,n){return n?Qe.fromBytesLE(e,t):Qe.fromBytesBE(e,t)},Qe.fromBytesLE=function(e,t){return new Qe(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Qe.fromBytesBE=function(e,t){return new Qe(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},Er=Qe})),k,si=D((()=>{k={},k.Table,k.SIZEOF_SHORT=2,k.SIZEOF_INT=4,k.FILE_IDENTIFIER_LENGTH=4,k.SIZE_PREFIX_LENGTH=4,k.Encoding={UTF8_BYTES:1,UTF16_STRING:2},k.int32=new Int32Array(2),k.float32=new Float32Array(k.int32.buffer),k.float64=new Float64Array(k.int32.buffer),k.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],k.Long=function(e,t){this.low=0|e,this.high=0|t},k.Long.create=function(e,t){return 0==e&&0==t?k.Long.ZERO:new k.Long(e,t)},k.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},k.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},k.Long.ZERO=new k.Long(0,0),k.Builder=function(e){if(e)var t=e;else t=1024;this.bb=k.ByteBuffer.allocate(t),this.space=t,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},k.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},k.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},k.Builder.prototype.dataBuffer=function(){return this.bb},k.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},k.Builder.prototype.prep=function(e,t){e>this.minalign&&(this.minalign=e);for(var n=1+~(this.bb.capacity()-this.space+t)&e-1;this.space<n+e+t;){var r=this.bb.capacity();this.bb=k.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(n)},k.Builder.prototype.pad=function(e){for(var t=0;t<e;t++)this.bb.writeInt8(--this.space,0)},k.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},k.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},k.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},k.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},k.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},k.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},k.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},k.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},k.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},k.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},k.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},k.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},k.Builder.prototype.addFieldInt8=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))},k.Builder.prototype.addFieldInt16=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))},k.Builder.prototype.addFieldInt32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))},k.Builder.prototype.addFieldInt64=function(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))},k.Builder.prototype.addFieldFloat32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))},k.Builder.prototype.addFieldFloat64=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))},k.Builder.prototype.addFieldOffset=function(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))},k.Builder.prototype.addFieldStruct=function(e,t,n){t!=n&&(this.nested(t),this.slot(e))},k.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},k.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},k.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},k.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},k.Builder.growByteBuffer=function(e){var t=e.capacity();if(3221225472&t)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=t<<1,r=k.ByteBuffer.allocate(n);return r.setPosition(n-t),r.bytes().set(e.bytes(),n-t),r},k.Builder.prototype.addOffset=function(e){this.prep(k.SIZEOF_INT,0),this.writeInt32(this.offset()-e+k.SIZEOF_INT)},k.Builder.prototype.startObject=function(e){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=e;for(var t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()},k.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var e=this.offset(),t=this.vtable_in_use-1;t>=0&&0==this.vtable[t];t--);for(var n=t+1;t>=0;t--)this.addInt16(0!=this.vtable[t]?e-this.vtable[t]:0);this.addInt16(e-this.object_start);var r=(n+2)*k.SIZEOF_SHORT;this.addInt16(r);var i=0,a=this.space;e:for(t=0;t<this.vtables.length;t++){var o=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(o)){for(var s=k.SIZEOF_SHORT;s<r;s+=k.SIZEOF_SHORT)if(this.bb.readInt16(a+s)!=this.bb.readInt16(o+s))continue e;i=this.vtables[t];break}}return i?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,i-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},k.Builder.prototype.finish=function(e,t,n){var r=n?k.SIZE_PREFIX_LENGTH:0;if(t){var i=t;if(this.prep(this.minalign,k.SIZEOF_INT+k.FILE_IDENTIFIER_LENGTH+r),i.length!=k.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+k.FILE_IDENTIFIER_LENGTH);for(var a=k.FILE_IDENTIFIER_LENGTH-1;a>=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,k.SIZEOF_INT+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},k.Builder.prototype.finishSizePrefixed=function(e,t){this.finish(e,t,!0)},k.Builder.prototype.requiredField=function(e,t){var n=this.bb.capacity()-e,r=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(r+t)))throw new Error("FlatBuffers: field "+t+" must be set")},k.Builder.prototype.startVector=function(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(k.SIZEOF_INT,e*t),this.prep(n,e*t)},k.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},k.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var t=e;else{t=[];for(var n=0;n<e.length;){var r,i=e.charCodeAt(n++);if(i<55296||i>=56320)r=i;else r=(i<<10)+e.charCodeAt(n++)+-56613888;r<128?t.push(r):(r<2048?t.push(r>>6&31|192):(r<65536?t.push(r>>12&15|224):t.push(r>>18&7|240,r>>12&63|128),t.push(r>>6&63|128)),t.push(63&r|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);n=0;for(var a=this.space,o=this.bb.bytes();n<t.length;n++)o[a++]=t[n];return this.endVector()},k.Builder.prototype.createLong=function(e,t){return k.Long.create(e,t)},k.ByteBuffer=function(e){this.bytes_=e,this.position_=0},k.ByteBuffer.allocate=function(e){return new k.ByteBuffer(new Uint8Array(e))},k.ByteBuffer.prototype.clear=function(){this.position_=0},k.ByteBuffer.prototype.bytes=function(){return this.bytes_},k.ByteBuffer.prototype.position=function(){return this.position_},k.ByteBuffer.prototype.setPosition=function(e){this.position_=e},k.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},k.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},k.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},k.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},k.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},k.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},k.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},k.ByteBuffer.prototype.readInt64=function(e){return new k.Long(this.readInt32(e),this.readInt32(e+4))},k.ByteBuffer.prototype.readUint64=function(e){return new k.Long(this.readUint32(e),this.readUint32(e+4))},k.ByteBuffer.prototype.readFloat32=function(e){return k.int32[0]=this.readInt32(e),k.float32[0]},k.ByteBuffer.prototype.readFloat64=function(e){return k.int32[k.isLittleEndian?0:1]=this.readInt32(e),k.int32[k.isLittleEndian?1:0]=this.readInt32(e+4),k.float64[0]},k.ByteBuffer.prototype.writeInt8=function(e,t){this.bytes_[e]=t},k.ByteBuffer.prototype.writeUint8=function(e,t){this.bytes_[e]=t},k.ByteBuffer.prototype.writeInt16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},k.ByteBuffer.prototype.writeUint16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},k.ByteBuffer.prototype.writeInt32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},k.ByteBuffer.prototype.writeUint32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},k.ByteBuffer.prototype.writeInt64=function(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)},k.ByteBuffer.prototype.writeUint64=function(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)},k.ByteBuffer.prototype.writeFloat32=function(e,t){k.float32[0]=t,this.writeInt32(e,k.int32[0])},k.ByteBuffer.prototype.writeFloat64=function(e,t){k.float64[0]=t,this.writeInt32(e,k.int32[k.isLittleEndian?0:1]),this.writeInt32(e+4,k.int32[k.isLittleEndian?1:0])},k.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+k.SIZEOF_INT+k.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",t=0;t<k.FILE_IDENTIFIER_LENGTH;t++)e+=String.fromCharCode(this.readInt8(this.position_+k.SIZEOF_INT+t));return e},k.ByteBuffer.prototype.__offset=function(e,t){var n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0},k.ByteBuffer.prototype.__union=function(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e},k.ByteBuffer.prototype.__string=function(e,t){e+=this.readInt32(e);var n=this.readInt32(e),r="",i=0;if(e+=k.SIZEOF_INT,t===k.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;i<n;){var a,o=this.readUint8(e+i++);if(o<192)a=o;else{var s=this.readUint8(e+i++);if(o<224)a=(31&o)<<6|63&s;else{var u=this.readUint8(e+i++);if(o<240)a=(15&o)<<12|(63&s)<<6|63&u;else a=(7&o)<<18|(63&s)<<12|(63&u)<<6|63&this.readUint8(e+i++)}}a<65536?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296+(a>>10),56320+(1023&a)))}return r},k.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},k.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+k.SIZEOF_INT},k.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},k.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=k.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+k.FILE_IDENTIFIER_LENGTH);for(var t=0;t<k.FILE_IDENTIFIER_LENGTH;t++)if(e.charCodeAt(t)!=this.readInt8(this.position_+k.SIZEOF_INT+t))return!1;return!0},k.ByteBuffer.prototype.createLong=function(e,t){return k.Long.create(e,t)}})),se,oo=D((()=>{"use strict";si(),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.AttributeType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]="FLOAT",n[n.INT=2]="INT",n[n.STRING=3]="STRING",n[n.TENSOR=4]="TENSOR",n[n.GRAPH=5]="GRAPH",n[n.FLOATS=6]="FLOATS",n[n.INTS=7]="INTS",n[n.STRINGS=8]="STRINGS",n[n.TENSORS=9]="TENSORS",n[n.GRAPHS=10]="GRAPHS",n[n.SPARSE_TENSOR=11]="SPARSE_TENSOR",n[n.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(t=e.fbs||={})})(t=e.experimental||={})})(se||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.DimensionValueType||={})[n.UNKNOWN=0]="UNKNOWN",n[n.VALUE=1]="VALUE",n[n.PARAM=2]="PARAM"})(t=e.fbs||={})})(t=e.experimental||={})})(se||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.TensorDataType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]=