dicomweb-proxy
Version:
A proxy to translate between dicomweb and dimse
2 lines • 537 kB
JavaScript
/*! For license information please see ort.min.js.LICENSE.txt */
var vd=Object.create,En=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,_d=Object.getOwnPropertyNames,Od=Object.getPrototypeOf,Id=Object.prototype.hasOwnProperty,L=(e,t)=>()=>(e&&(t=e(e=0)),t),me=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Pr=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})},Ha=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of _d(t))!Id.call(e,o)&&o!==n&&En(e,o,{get:()=>t[o],enumerable:!(r=wd(t,o))||r.enumerable});return e},Er=(e,t,n)=>(n=null!=e?vd(Od(e)):{},Ha(!t&&e&&e.__esModule?n:En(n,"default",{value:e,enumerable:!0}),e)),rr=e=>Ha(En({},"__esModule",{value:!0}),e),Dn,nr,or,Ln,Fn=L((()=>{"use strict";Dn=new Map,nr=[],or=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createInferenceSessionHandler)throw new TypeError("not a valid backend");{let r=Dn.get(e);if(void 0===r)Dn.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=nr.indexOf(e);-1!==t&&nr.splice(t,1);for(let t=0;t<nr.length;t++)if(Dn.get(nr[t]).priority<=n)return void nr.splice(t,0,e);nr.push(e)}}},Ln=async e=>{let t=0===e.length?nr:e,n=[];for(let e of t){let t=Dn.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(o){r||n.push({name:e,err:o}),t.aborted=!0}finally{delete t.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`)}})),qa=L((()=>{"use strict";Fn()})),ja,Ya=L((()=>{"use strict";ja="1.17.1"})),Xa,ir,Ho=L((()=>{"use strict";Ya(),Xa="warning",ir={wasm:{},webgl:{},webgpu:{},versions:{common:ja},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}`);Xa=e}},get logLevel(){return Xa}},Object.defineProperty(ir,"logLevel",{enumerable:!0})})),Z,Ka=L((()=>{"use strict";Ho(),Z=ir})),Ja,Za,Qa=L((()=>{"use strict";Ja=(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 o,i;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],i=e.dims[3]):(o=e.dims[3],i=e.dims[2]);let a,s,u=void 0!==t?.format?t.format:"RGB",l=t?.norm;void 0===l||void 0===l.mean?a=[255,255,255,255]:"number"==typeof l.mean?a=[l.mean,l.mean,l.mean,l.mean]:(a=[l.mean[0],l.mean[1],l.mean[2],0],void 0!==l.mean[3]&&(a[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 c=i*o,p=0,d=c,f=2*c,h=-1;"RGBA"===u?(p=0,d=c,f=2*c,h=3*c):"RGB"===u?(p=0,d=c,f=2*c):"RBG"===u&&(p=0,f=c,d=2*c);for(let t=0;t<i;t++)for(let n=0;n<o;n++){let o=(e.data[p++]-s[0])*a[0],i=(e.data[d++]-s[1])*a[1],u=(e.data[f++]-s[2])*a[2],l=-1===h?255:(e.data[h++]-s[3])*a[3];r.fillStyle="rgba("+o+","+i+","+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")},Za=(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 o,i,a;void 0!==t?.tensorLayout&&"NHWC"===t.tensorLayout?(o=e.dims[2],i=e.dims[1],a=e.dims[3]):(o=e.dims[3],i=e.dims[2],a=e.dims[1]);let s,u,l=void 0!==t&&void 0!==t.format?t.format:"RGB",c=t?.norm;void 0===c||void 0===c.mean?s=[255,255,255,255]:"number"==typeof c.mean?s=[c.mean,c.mean,c.mean,c.mean]:(s=[c.mean[0],c.mean[1],c.mean[2],255],void 0!==c.mean[3]&&(s[3]=c.mean[3])),void 0===c||void 0===c.bias?u=[0,0,0,0]:"number"==typeof c.bias?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],void 0!==c.bias[3]&&(u[3]=c.bias[3]));let p=i*o;if(void 0!==t&&(void 0!==t.format&&4===a&&"RGBA"!==t.format||3===a&&"RGB"!==t.format&&"BGR"!==t.format))throw new Error("Tensor format doesn't match input tensor dims");let d=4,f=0,h=1,g=2,m=3,b=0,y=p,w=2*p,_=-1;"RGBA"===l?(b=0,y=p,w=2*p,_=3*p):"RGB"===l?(b=0,y=p,w=2*p):"RBG"===l&&(b=0,w=p,y=2*p),n=r.createImageData(o,i);for(let t=0;t<i*o;f+=d,h+=d,g+=d,m+=d,t++)n.data[f]=(e.data[b++]-u[0])*s[0],n.data[h]=(e.data[y++]-u[1])*s[1],n.data[g]=(e.data[w++]-u[2])*s[2],n.data[m]=-1===_?255:(e.data[_++]-u[3])*s[3]}return n}})),qo,es,ts,rs,ns,os=L((()=>{"use strict";$n(),qo=(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:o,width:i}=t,a=t.norm??{mean:255,bias:0};n="number"==typeof a.mean?[a.mean,a.mean,a.mean,a.mean]:[a.mean[0],a.mean[1],a.mean[2],a.mean[3]??255],r="number"==typeof a.bias?[a.bias,a.bias,a.bias,a.bias]:[a.bias[0],a.bias[1],a.bias[2],a.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=o*i,c="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l),p=4,d=0,f=1,h=2,g=3,m=0,b=l,y=2*l,w=-1;"RGB"===s&&(p=3,d=0,f=1,h=2,g=-1),"RGBA"===u?w=3*l:"RBG"===u?(m=0,y=l,b=2*l):"BGR"===u&&(y=0,b=l,m=2*l);for(let t=0;t<l;t++,d+=p,h+=p,f+=p,g+=p)c[m++]=(e[d]+r[0])/n[0],c[b++]=(e[f]+r[1])/n[1],c[y++]=(e[h]+r[2])/n[2],-1!==w&&-1!==g&&(c[w++]=(e[g]+r[3])/n[3]);return new Ye("float32",c,"RGBA"===u?[1,4,o,i]:[1,3,o,i])},es=async(e,t)=>{let n,r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,o=typeof ImageData<"u"&&e instanceof ImageData,i=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,a="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 o=l(r);if(null==o)throw new Error("Can not access image data");{let r=e.height,i=e.width;if(void 0!==t&&void 0!==t.resizedHeight&&void 0!==t.resizedWidth&&(r=t.resizedHeight,i=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=i}else s.tensorFormat="RGBA",s.height=r,s.width=i;o.drawImage(e,0,0),n=o.getImageData(0,0,i,r).data}}else{if(!o){if(i){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 o=l(r);if(null!=o){let t=e.height,r=e.width;return o.drawImage(e,0,0,r,t),n=o.getImageData(0,0,r,t).data,s.height=t,s.width=r,qo(n,s)}throw new Error("Can not access image data")}if(a)return new Promise(((t,n)=>{let r=u(),o=l(r);if(!e||!o)return n();let i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>{r.width=i.width,r.height=i.height,o.drawImage(i,0,0,r.width,r.height);let e=o.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(qo(e.data,s))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{let r,o;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(r=t.resizedHeight,o=t.resizedWidth):(r=e.height,o=e.width),void 0!==t&&(s=t),s.format="RGBA",s.height=r,s.width=o,void 0!==t){let t=u();t.width=o,t.height=r;let i=l(t);if(null==i)throw new Error("Can not access image data");i.putImageData(e,0,0),n=i.getImageData(0,0,o,r).data}else n=e.data}}if(void 0!==n)return qo(n,s);throw new Error("Input data provided is not supported - aborted tensor creation")},ts=(e,t)=>{let{width:n,height:r,download:o,dispose:i}=t;return new Ye({location:"texture",type:"float32",texture:e,dims:[1,r,n,4],download:o,dispose:i})},rs=(e,t)=>{let{dataType:n,dims:r,download:o,dispose:i}=t;return new Ye({location:"gpu-buffer",type:n??"float32",gpuBuffer:e,dims:r,download:o,dispose:i})},ns=(e,t,n)=>new Ye({location:"cpu-pinned",type:e,data:t,dims:n??[t.length]})})),Qr,Cn,is,as,ss=L((()=>{"use strict";Qr=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),Cn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),is=!1,as=()=>{if(!is){is=!0;let e=typeof BigInt64Array<"u"&&"function"==typeof BigInt64Array.from,t=typeof BigUint64Array<"u"&&"function"==typeof BigUint64Array.from;e&&(Qr.set("int64",BigInt64Array),Cn.set(BigInt64Array,"int64")),t&&(Qr.set("uint64",BigUint64Array),Cn.set(BigUint64Array,"uint64"))}}})),us,ls,fs=L((()=>{"use strict";$n(),us=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},ls=(e,t)=>{switch(e.location){case"cpu":return new Ye(e.type,e.data,t);case"cpu-pinned":return new Ye({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new Ye({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new Ye({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}})),Ye,$n=L((()=>{"use strict";Qa(),os(),ss(),fs(),Ye=class{constructor(e,t,n){let r,o;if(as(),"object"==typeof e&&"location"in e)switch(this.dataLocation=e.location,r=e.type,o=e.dims,e.location){case"cpu-pinned":{let t=Qr.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 i,a;if("string"==typeof e)if(r=e,a=n,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");i=t}else{let n=Qr.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.");i="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}`);i=t}}else if(a=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",i=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);r="bool",i=Uint8Array.from(e)}}else{let t=Cn.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,i=e}if(void 0===a)a=[i.length];else if(!Array.isArray(a))throw new TypeError("A tensor's dims must be a number array");o=a,this.cpuData=i,this.dataLocation="cpu"}let i=us(o);if(this.cpuData&&i!==this.cpuData.length)throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=o,this.size=i}static async fromImage(e,t){return es(e,t)}static fromTexture(e,t){return ts(e,t)}static fromGpuBuffer(e,t){return rs(e,t)}static fromPinnedBuffer(e,t,n){return ns(e,t,n)}toDataURL(e){return Ja(this,e)}toImageData(e){return Za(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 ls(this,e)}}})),Re,kn=L((()=>{"use strict";$n(),Re=Ye})),cs,ps,ar,sr,jo=L((()=>{"use strict";Ho(),cs=(e,t)=>{ir.wasm.trace&&console.timeStamp(`${e}::ORT::${t}`)},ps=(e,t)=>{let n=(new Error).stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let o=0;o<n.length;o++){if(r&&!n[o].includes("TRACE_FUNC")){let r=`FUNC_${e}::${n[o].trim().split(" ")[1]}`;return t&&(r+=`::${t}`),void cs("CPU",r)}n[o].includes("TRACE_FUNC")&&(r=!0)}},ar=e=>{ir.wasm.trace&&ps("BEGIN",e)},sr=e=>{ir.wasm.trace&&ps("END",e)}})),Bn,ds=L((()=>{"use strict";Fn(),kn(),jo(),Bn=class e{constructor(e){this.handler=e}async run(e,t,n){ar();let r={},o={};if("object"!=typeof e||null===e||e instanceof Re||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if("object"==typeof t){if(null===t)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof Re)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.");i=!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)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,a=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(-1!==a.indexOf(n)){let o=t[n];(null===o||o instanceof Re)&&(e=!0,i=!1,r[n]=o)}if(e){if("object"==typeof n&&null!==n)o=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else o=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(i)for(let e of this.outputNames)r[e]=null;let a=await this.handler.run(e,r,o),s={};for(let e in a)if(Object.hasOwnProperty.call(a,e)){let t=a[e];s[e]=t instanceof Re?t:new Re(t.type,t.data,t.dims)}return sr(),s}async release(){return this.handler.dispose()}static async create(t,n,r,o){ar();let i,a={};if("string"==typeof t){if(i=t,"object"==typeof n&&null!==n)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(i=t,"object"==typeof n&&null!==n)a=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)a=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 o&&null!==o)a=o;else if(typeof o<"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.");i=new Uint8Array(e,s,u)}}let s=(a.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),u=await(await Ln(s)).createInferenceSessionHandler(i,a);return sr(),new e(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}})),Sd,hs=L((()=>{"use strict";ds(),Sd=Bn})),ms=L((()=>{})),Ad,Nn,bs=L((()=>{"use strict";Fn(),kn(),Ad="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Nn=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||"",o=t.optimizerModel||"",i=n||{},a=(i.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),s=await Ln(a);if(s.createTrainingSessionHandler){let n=await s.createTrainingSessionHandler(t.checkpointState,t.trainModel,r,o,i);return new e(n,!!t.optimizerModel,!!t.evalModel)}throw new Error(Ad)}typeNarrowingForRunStep(e,t,n,r,o){let i={},a={};if("object"!=typeof n||null===n||n instanceof Re||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 Re)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}.`);i[e]=null}if("object"==typeof o&&null!==o)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else{let e=!1,n=Object.getOwnPropertyNames(r);for(let o of t)if(-1!==n.indexOf(o)){let t=r[o];(null===t||t instanceof Re)&&(e=!0,s=!1,i[o]=t)}if(e){if("object"==typeof o&&null!==o)a=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else a=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)i[e]=null;return[i,a]}convertHandlerReturnTypeToMapOfTensors(e){let t={};for(let n in e)if(Object.hasOwnProperty.call(e,n)){let r=e[n];t[n]=r instanceof Re?r:new Re(r.type,r.data,r.dims)}return t}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,t,n){let[r,o]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,t,n),i=await this.handler.runTrainStep(e,r,o);return this.convertHandlerReturnTypeToMapOfTensors(i)}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,o]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,t,n),i=await this.handler.runEvalStep(e,r,o);return this.convertHandlerReturnTypeToMapOfTensors(i)}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()}}})),Pd,gs=L((()=>{"use strict";bs(),Pd=Nn})),Yo={};Pr(Yo,{InferenceSession:()=>Sd,TRACE:()=>cs,TRACE_FUNC_BEGIN:()=>ar,TRACE_FUNC_END:()=>sr,Tensor:()=>Re,TrainingSession:()=>Pd,env:()=>Z,registerBackend:()=>or});var vt=L((()=>{"use strict";qa(),Ka(),hs(),kn(),jo(),ms(),gs()}));function jt(e,t,n,r){if(void 0===t)return Dd(e);if(void 0===n)Rn(e,t,1);else if("number"==typeof n&&void 0===r)Rn(e,t,n);else if("string"==typeof n&&void 0===r)Rn(e,n,1,t);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");Rn(e,n,r,t)}}function Dd(e){return{verbose:jt.verbose.bind(null,e),info:jt.info.bind(null,e),warning:jt.warning.bind(null,e),error:jt.error.bind(null,e),fatal:jt.fatal.bind(null,e)}}function Rn(e,t,n,r){let o=en[r||""]||en[""];Ts[e]<Ts[o.minimalSeverity]||(o.logDateTime&&(t=`${(new Date).toISOString()}|${t}`),o.logSourceLocation,Ed[o.provider].log(e,t,r))}var Xo,Ko,Ts,Ed,xs,en,ce,Gn,Un,zn,Mn,ut=L((()=>{"use strict";Xo=class{log(e,t,n){}},Ko=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}`)}}},Ts={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},Ed={none:new Xo,console:new Ko},en={"":xs={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1}},(e=>{function t(e){en={},n("",e||{})}function n(e,n){if("*"===e)t(n);else{let t=en[e]||xs;en[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)}})(jt||={}),ce=jt,Gn=class{constructor(e,t,n,r,o,i){this.category=e,this.name=t,this.startTime=n,this.endCallback=r,this.timer=o,this.ctx=i}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)}},Un=class{constructor(e,t,n,r){this.category=e,this.name=t,this.startTime=n,this.endTime=r}},zn=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=Mn(),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 o=this._started?this.begin(e,t,r):void 0,i=!1,a=n();if(a&&"function"==typeof a.then)return i=!0,new Promise(((e,t)=>{a.then((async t=>{o&&await o.end(),e(t)}),(async e=>{o&&await o.end(),t(e)}))}));if(!i&&o){let e=o.end();if(e&&"function"==typeof e.then)return new Promise(((t,n)=>{e.then((()=>{t(a)}),(e=>{n(e)}))}))}return a}begin(e,t,n){if(!this._started)throw new Error("profiler is not started yet");if(void 0===n){let n=Mn();return this.flush(n),new Gn(e,t,n,(e=>this.endSync(e)))}{let r=n.beginTimer();return new Gn(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 Un(e.category,e.name,e.startTime,t)),this.flush(t))}endSync(e){let t=Mn();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Un(e.category,e.name,e.startTime,t)),this.flush(t))}logOneEvent(e){ce.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=Mn()}}get started(){return this._started}},Mn=typeof performance<"u"&&performance.now?()=>performance.now():Date.now}));function vs(e,t,n){for(let r of n){let n=r[0],o=r[1],i=r[2],a=r[3],s=r[4];if(e.opType===n)for(let e of t)if((e.domain===o||"ai.onnx"===e.domain&&""===o)&&Ld(e.version,i))return{opImpl:a,opInit:s}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${t.map((e=>`${e.domain||"ai.onnx"} v${e.version}`)).join(", ")}`)}function Ld(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),o=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(o)&&r<=e&&e<=o}return Number.parseInt(t,10)===e}var ws=L((()=>{})),_s=me((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 be(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function We(e){return!0===(e&&e.__isLong__)}function Os(e){var t=Math.clz32(e&-e);return e?31-t:t}function ur(e,t){var n,r,o;return t?(o=0<=(e>>>=0)&&e<256)&&(r=Ss[e])?r:(n=le(e,0,!0),o&&(Ss[e]=n),n):(o=-128<=(e|=0)&&e<128)&&(r=Is[e])?r:(n=le(e,e<0?-1:0,!1),o&&(Is[e]=n),n)}function ft(e,t){if(isNaN(e))return t?Ut:wt;if(t){if(e<0)return Ut;if(e>=Ds)return $s}else{if(e<=-Ps)return tt;if(e+1>=Ps)return Fs}return e<0?ft(-e,t).neg():le(e%Lr|0,e/Lr|0,t)}function le(e,t,n){return new be(e,t,n)}function Qo(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?Ut:wt;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 Qo(e.substring(1),t,n).neg();for(var o=ft(Vn(n,8)),i=wt,a=0;a<e.length;a+=8){var s=Math.min(8,e.length-a),u=parseInt(e.substring(a,a+s),n);if(s<8){var l=ft(Vn(n,s));i=i.mul(l).add(ft(u))}else i=(i=i.mul(o)).add(ft(u))}return i.unsigned=t,i}function _t(e,t){return"number"==typeof e?ft(e,t):"string"==typeof e?Qo(e,t):le(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}var lt,Is,Ss,Vn,As,$d,Lr,Ds,Ps,Es,wt,Ut,Dr,Ls,Zo,Fs,$s,tt,$,zt,ei=L((()=>{lt=null;try{lt=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{}be.prototype.__isLong__,Object.defineProperty(be.prototype,"__isLong__",{value:!0}),be.isLong=We,Is={},Ss={},be.fromInt=ur,be.fromNumber=ft,be.fromBits=le,Vn=Math.pow,be.fromString=Qo,be.fromValue=_t,Ps=(Ds=(Lr=(As=65536)*As)*Lr)/2,Es=ur($d=1<<24),wt=ur(0),be.ZERO=wt,Ut=ur(0,!0),be.UZERO=Ut,Dr=ur(1),be.ONE=Dr,Ls=ur(1,!0),be.UONE=Ls,Zo=ur(-1),be.NEG_ONE=Zo,Fs=le(-1,2147483647,!1),be.MAX_VALUE=Fs,$s=le(-1,-1,!0),be.MAX_UNSIGNED_VALUE=$s,tt=le(0,-2147483648,!1),be.MIN_VALUE=tt,($=be.prototype).toInt=function(){return this.unsigned?this.low>>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*Lr+(this.low>>>0):this.high*Lr+(this.low>>>0)},$.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(tt)){var t=ft(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 o=ft(Vn(e,6),this.unsigned),i=this,a="";;){var s=i.div(o),u=(i.sub(s.mul(o)).toInt()>>>0).toString(e);if((i=s).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tt)?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},$.isZero=function(){return 0===this.high&&0===this.low},$.eqz=$.isZero,$.isNegative=function(){return!this.unsigned&&this.high<0},$.isPositive=function(){return this.unsigned||this.high>=0},$.isOdd=function(){return!(1&~this.low)},$.isEven=function(){return!(1&this.low)},$.equals=function(e){return We(e)||(e=_t(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},$.eq=$.equals,$.notEquals=function(e){return!this.eq(e)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(e){return this.comp(e)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(e){return this.comp(e)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(e){return this.comp(e)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(e){return this.comp(e)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(e){if(We(e)||(e=_t(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},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(tt)?tt:this.not().add(Dr)},$.neg=$.negate,$.add=function(e){We(e)||(e=_t(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=e.high>>>16,a=65535&e.high,s=e.low>>>16,u=0,l=0,c=0,p=0;return c+=(p+=o+(65535&e.low))>>>16,l+=(c+=r+s)>>>16,u+=(l+=n+a)>>>16,u+=t+i,le((c&=65535)<<16|(p&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},$.subtract=function(e){return We(e)||(e=_t(e)),this.add(e.neg())},$.sub=$.subtract,$.multiply=function(e){if(this.isZero())return this;if(We(e)||(e=_t(e)),lt)return le(lt.mul(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Ut:wt;if(this.eq(tt))return e.isOdd()?tt:wt;if(e.eq(tt))return this.isOdd()?tt:wt;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(Es)&&e.lt(Es))return ft(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=e.high>>>16,a=65535&e.high,s=e.low>>>16,u=65535&e.low,l=0,c=0,p=0,d=0;return p+=(d+=o*u)>>>16,c+=(p+=r*u)>>>16,p&=65535,c+=(p+=o*s)>>>16,l+=(c+=n*u)>>>16,c&=65535,l+=(c+=r*s)>>>16,c&=65535,l+=(c+=o*a)>>>16,l+=t*u+n*s+r*a+o*i,le((p&=65535)<<16|(d&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},$.mul=$.multiply,$.divide=function(e){if(We(e)||(e=_t(e)),e.isZero())throw Error("division by zero");var t,n,r;if(lt)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?le((this.unsigned?lt.div_u:lt.div_s)(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Ut:wt;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Ut;if(e.gt(this.shru(1)))return Ls;r=Ut}else{if(this.eq(tt))return e.eq(Dr)||e.eq(Zo)?tt:e.eq(tt)?Dr:(t=this.shr(1).div(e).shl(1)).eq(wt)?e.isNegative()?Dr:Zo:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(tt))return this.unsigned?Ut:wt;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=wt}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:Vn(2,o-48),a=ft(t),s=a.mul(e);s.isNegative()||s.gt(n);)s=(a=ft(t-=i,this.unsigned)).mul(e);a.isZero()&&(a=Dr),r=r.add(a),n=n.sub(s)}return r},$.div=$.divide,$.modulo=function(e){return We(e)||(e=_t(e)),lt?le((this.unsigned?lt.rem_u:lt.rem_s)(this.low,this.high,e.low,e.high),lt.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return le(~this.low,~this.high,this.unsigned)},$.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},$.clz=$.countLeadingZeros,$.countTrailingZeros=function(){return this.low?Os(this.low):Os(this.high)+32},$.ctz=$.countTrailingZeros,$.and=function(e){return We(e)||(e=_t(e)),le(this.low&e.low,this.high&e.high,this.unsigned)},$.or=function(e){return We(e)||(e=_t(e)),le(this.low|e.low,this.high|e.high,this.unsigned)},$.xor=function(e){return We(e)||(e=_t(e)),le(this.low^e.low,this.high^e.high,this.unsigned)},$.shiftLeft=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):le(0,this.low<<e-32,this.unsigned)},$.shl=$.shiftLeft,$.shiftRight=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):le(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(e){return We(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?le(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):le(32===e?this.high:this.high>>>e-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.rotateLeft=function(e){var t;return We(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?le(this.high,this.low,this.unsigned):e<32?(t=32-e,le(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),le(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},$.rotl=$.rotateLeft,$.rotateRight=function(e){var t;return We(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?le(this.high,this.low,this.unsigned):e<32?(t=32-e,le(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),le(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},$.rotr=$.rotateRight,$.toSigned=function(){return this.unsigned?le(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:le(this.low,this.high,!0)},$.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},$.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]},$.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]},be.fromBytes=function(e,t,n){return n?be.fromBytesLE(e,t):be.fromBytesBE(e,t)},be.fromBytesLE=function(e,t){return new be(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},be.fromBytesBE=function(e,t){return new be(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},zt=be})),_,Wn=L((()=>{_={},_.Table,_.SIZEOF_SHORT=2,_.SIZEOF_INT=4,_.FILE_IDENTIFIER_LENGTH=4,_.SIZE_PREFIX_LENGTH=4,_.Encoding={UTF8_BYTES:1,UTF16_STRING:2},_.int32=new Int32Array(2),_.float32=new Float32Array(_.int32.buffer),_.float64=new Float64Array(_.int32.buffer),_.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],_.Long=function(e,t){this.low=0|e,this.high=0|t},_.Long.create=function(e,t){return 0==e&&0==t?_.Long.ZERO:new _.Long(e,t)},_.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},_.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},_.Long.ZERO=new _.Long(0,0),_.Builder=function(e){if(e)var t=e;else t=1024;this.bb=_.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},_.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},_.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},_.Builder.prototype.dataBuffer=function(){return this.bb},_.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},_.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=_.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(n)},_.Builder.prototype.pad=function(e){for(var t=0;t<e;t++)this.bb.writeInt8(--this.space,0)},_.Builder.prototype.writeInt8=function(e){this.bb.writeInt8(this.space-=1,e)},_.Builder.prototype.writeInt16=function(e){this.bb.writeInt16(this.space-=2,e)},_.Builder.prototype.writeInt32=function(e){this.bb.writeInt32(this.space-=4,e)},_.Builder.prototype.writeInt64=function(e){this.bb.writeInt64(this.space-=8,e)},_.Builder.prototype.writeFloat32=function(e){this.bb.writeFloat32(this.space-=4,e)},_.Builder.prototype.writeFloat64=function(e){this.bb.writeFloat64(this.space-=8,e)},_.Builder.prototype.addInt8=function(e){this.prep(1,0),this.writeInt8(e)},_.Builder.prototype.addInt16=function(e){this.prep(2,0),this.writeInt16(e)},_.Builder.prototype.addInt32=function(e){this.prep(4,0),this.writeInt32(e)},_.Builder.prototype.addInt64=function(e){this.prep(8,0),this.writeInt64(e)},_.Builder.prototype.addFloat32=function(e){this.prep(4,0),this.writeFloat32(e)},_.Builder.prototype.addFloat64=function(e){this.prep(8,0),this.writeFloat64(e)},_.Builder.prototype.addFieldInt8=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))},_.Builder.prototype.addFieldInt16=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))},_.Builder.prototype.addFieldInt32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))},_.Builder.prototype.addFieldInt64=function(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))},_.Builder.prototype.addFieldFloat32=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))},_.Builder.prototype.addFieldFloat64=function(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))},_.Builder.prototype.addFieldOffset=function(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))},_.Builder.prototype.addFieldStruct=function(e,t,n){t!=n&&(this.nested(t),this.slot(e))},_.Builder.prototype.nested=function(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},_.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},_.Builder.prototype.slot=function(e){this.vtable[e]=this.offset()},_.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},_.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=_.ByteBuffer.allocate(n);return r.setPosition(n-t),r.bytes().set(e.bytes(),n-t),r},_.Builder.prototype.addOffset=function(e){this.prep(_.SIZEOF_INT,0),this.writeInt32(this.offset()-e+_.SIZEOF_INT)},_.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()},_.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)*_.SIZEOF_SHORT;this.addInt16(r);var o=0,i=this.space;e:for(t=0;t<this.vtables.length;t++){var a=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(a)){for(var s=_.SIZEOF_SHORT;s<r;s+=_.SIZEOF_SHORT)if(this.bb.readInt16(i+s)!=this.bb.readInt16(a+s))continue e;o=this.vtables[t];break}}return o?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,o-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e},_.Builder.prototype.finish=function(e,t,n){var r=n?_.SIZE_PREFIX_LENGTH:0;if(t){var o=t;if(this.prep(this.minalign,_.SIZEOF_INT+_.FILE_IDENTIFIER_LENGTH+r),o.length!=_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+_.FILE_IDENTIFIER_LENGTH);for(var i=_.FILE_IDENTIFIER_LENGTH-1;i>=0;i--)this.writeInt8(o.charCodeAt(i))}this.prep(this.minalign,_.SIZEOF_INT+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},_.Builder.prototype.finishSizePrefixed=function(e,t){this.finish(e,t,!0)},_.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")},_.Builder.prototype.startVector=function(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(_.SIZEOF_INT,e*t),this.prep(n,e*t)},_.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},_.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var t=e;else{t=[];for(var n=0;n<e.length;){var r,o=e.charCodeAt(n++);if(o<55296||o>=56320)r=o;else r=(o<<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 i=this.space,a=this.bb.bytes();n<t.length;n++)a[i++]=t[n];return this.endVector()},_.Builder.prototype.createLong=function(e,t){return _.Long.create(e,t)},_.ByteBuffer=function(e){this.bytes_=e,this.position_=0},_.ByteBuffer.allocate=function(e){return new _.ByteBuffer(new Uint8Array(e))},_.ByteBuffer.prototype.clear=function(){this.position_=0},_.ByteBuffer.prototype.bytes=function(){return this.bytes_},_.ByteBuffer.prototype.position=function(){return this.position_},_.ByteBuffer.prototype.setPosition=function(e){this.position_=e},_.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},_.ByteBuffer.prototype.readInt8=function(e){return this.readUint8(e)<<24>>24},_.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},_.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},_.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},_.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},_.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},_.ByteBuffer.prototype.readInt64=function(e){return new _.Long(this.readInt32(e),this.readInt32(e+4))},_.ByteBuffer.prototype.readUint64=function(e){return new _.Long(this.readUint32(e),this.readUint32(e+4))},_.ByteBuffer.prototype.readFloat32=function(e){return _.int32[0]=this.readInt32(e),_.float32[0]},_.ByteBuffer.prototype.readFloat64=function(e){return _.int32[_.isLittleEndian?0:1]=this.readInt32(e),_.int32[_.isLittleEndian?1:0]=this.readInt32(e+4),_.float64[0]},_.ByteBuffer.prototype.writeInt8=function(e,t){this.bytes_[e]=t},_.ByteBuffer.prototype.writeUint8=function(e,t){this.bytes_[e]=t},_.ByteBuffer.prototype.writeInt16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},_.ByteBuffer.prototype.writeUint16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},_.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},_.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},_.ByteBuffer.prototype.writeInt64=function(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)},_.ByteBuffer.prototype.writeUint64=function(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)},_.ByteBuffer.prototype.writeFloat32=function(e,t){_.float32[0]=t,this.writeInt32(e,_.int32[0])},_.ByteBuffer.prototype.writeFloat64=function(e,t){_.float64[0]=t,this.writeInt32(e,_.int32[_.isLittleEndian?0:1]),this.writeInt32(e+4,_.int32[_.isLittleEndian?1:0])},_.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+_.SIZEOF_INT+_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var e="",t=0;t<_.FILE_IDENTIFIER_LENGTH;t++)e+=String.fromCharCode(this.readInt8(this.position_+_.SIZEOF_INT+t));return e},_.ByteBuffer.prototype.__offset=function(e,t){var n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0},_.ByteBuffer.prototype.__union=function(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e},_.ByteBuffer.prototype.__string=function(e,t){e+=this.readInt32(e);var n=this.readInt32(e),r="",o=0;if(e+=_.SIZEOF_INT,t===_.Encoding.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;o<n;){var i,a=this.readUint8(e+o++);if(a<192)i=a;else{var s=this.readUint8(e+o++);if(a<224)i=(31&a)<<6|63&s;else{var u=this.readUint8(e+o++);if(a<240)i=(15&a)<<12|(63&s)<<6|63&u;else i=(7&a)<<18|(63&s)<<12|(63&u)<<6|63&this.readUint8(e+o++)}}i<65536?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296+(i>>10),56320+(1023&i)))}return r},_.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},_.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+_.SIZEOF_INT},_.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},_.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=_.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+_.FILE_IDENTIFIER_LENGTH);for(var t=0;t<_.FILE_IDENTIFIER_LENGTH;t++)if(e.charCodeAt(t)!=this.readInt8(this.position_+_.SIZEOF_INT+t))return!1;return!0},_.ByteBuffer.prototype.createLong=function(e,t){return _.Long.create(e,t)}})),W,tn=L((()=>{"use strict";Wn(),(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||={})})(W||={}),(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||={})})(W||={}),(e=>{let t;(e=>{let t;(e=>{let t;var n;(n=t=e.TensorDataType||={})[n.UNDEFINED=0]="UNDEFINED",n[n.FLOAT=1]="FLOAT",n[