UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

9 lines 145 kB
/*! * ONNX Runtime Web v1.17.3 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ "use strict";var ort=(()=>{var nr=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var Pa=Object.getOwnPropertyNames;var Ra=Object.prototype.hasOwnProperty;var H=(r,t)=>()=>(r&&(t=r(r=0)),t);var ot=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),it=(r,t)=>{for(var n in t)nr(r,n,{get:t[n],enumerable:!0})},Da=(r,t,n,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Pa(t))!Ra.call(r,i)&&i!==n&&nr(r,i,{get:()=>t[i],enumerable:!(f=xa(t,i))||f.enumerable});return r};var Ve=r=>Da(nr({},"__esModule",{value:!0}),r);var Ut,Xe,st,Ua,Ft,It=H(()=>{"use strict";Ut=new Map,Xe=[],st=(r,t,n)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let f=Ut.get(r);if(f===void 0)Ut.set(r,{backend:t,priority:n});else{if(f.priority>n)return;if(f.priority===n&&f.backend!==t)throw new Error(`cannot register backend "${r}" using priority ${n}`)}if(n>=0){let i=Xe.indexOf(r);i!==-1&&Xe.splice(i,1);for(let m=0;m<Xe.length;m++)if(Ut.get(Xe[m]).priority<=n){Xe.splice(m,0,r);return}Xe.push(r)}return}throw new TypeError("not a valid backend")},Ua=async r=>{let t=Ut.get(r);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(r)),await t.initPromise,t.initialized=!0,t.backend}catch(f){return n||(t.error=`${f}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},Ft=async r=>{let t=r.executionProviders||[],n=t.map(h=>typeof h=="string"?h:h.name),f=n.length===0?Xe:n,i,m=[],d=new Set;for(let h of f){let g=await Ua(h);typeof g=="string"?m.push({name:h,err:g}):(i||(i=g),i===g&&d.add(h))}if(!i)throw new Error(`no available backend found. ERR: ${m.map(h=>`[${h.name}] ${h.err}`).join(", ")}`);for(let{name:h,err:g}of m)n.includes(h)&&console.warn(`removing requested execution provider "${h}" from session options because it is not available: ${g}`);let s=t.filter(h=>d.has(typeof h=="string"?h:h.name));return[i,new Proxy(r,{get:(h,g)=>g==="executionProviders"?s:Reflect.get(h,g)})]}});var en=H(()=>{"use strict";It()});var tn,rn=H(()=>{"use strict";tn="1.17.3"});var nn,ve,ar=H(()=>{"use strict";rn();nn="warning",ve={wasm:{},webgl:{},webgpu:{},versions:{common:tn},set logLevel(r){if(r!==void 0){if(typeof r!="string"||["verbose","info","warning","error","fatal"].indexOf(r)===-1)throw new Error(`Unsupported logging level: ${r}`);nn=r}},get logLevel(){return nn}};Object.defineProperty(ve,"logLevel",{enumerable:!0})});var G,an=H(()=>{"use strict";ar();G=ve});var on,sn,un=H(()=>{"use strict";on=(r,t)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=r.dims[3],n.height=r.dims[2];let f=n.getContext("2d");if(f!=null){let i,m;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(i=r.dims[2],m=r.dims[3]):(i=r.dims[3],m=r.dims[2]);let d=t?.format!==void 0?t.format:"RGB",s=t?.norm,h,g;s===void 0||s.mean===void 0?h=[255,255,255,255]:typeof s.mean=="number"?h=[s.mean,s.mean,s.mean,s.mean]:(h=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(h[3]=s.mean[3])),s===void 0||s.bias===void 0?g=[0,0,0,0]:typeof s.bias=="number"?g=[s.bias,s.bias,s.bias,s.bias]:(g=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(g[3]=s.bias[3]));let O=m*i,E=0,v=O,C=O*2,x=-1;d==="RGBA"?(E=0,v=O,C=O*2,x=O*3):d==="RGB"?(E=0,v=O,C=O*2):d==="RBG"&&(E=0,C=O,v=O*2);for(let P=0;P<m;P++)for(let T=0;T<i;T++){let B=(r.data[E++]-g[0])*h[0],k=(r.data[v++]-g[1])*h[1],N=(r.data[C++]-g[2])*h[2],V=x===-1?255:(r.data[x++]-g[3])*h[3];f.fillStyle="rgba("+B+","+k+","+N+","+V+")",f.fillRect(T,P,1,1)}if("toDataURL"in n)return n.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},sn=(r,t)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),f;if(n!=null){let i,m,d;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(i=r.dims[2],m=r.dims[1],d=r.dims[3]):(i=r.dims[3],m=r.dims[2],d=r.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:"RGB",h=t?.norm,g,O;h===void 0||h.mean===void 0?g=[255,255,255,255]:typeof h.mean=="number"?g=[h.mean,h.mean,h.mean,h.mean]:(g=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(g[3]=h.mean[3])),h===void 0||h.bias===void 0?O=[0,0,0,0]:typeof h.bias=="number"?O=[h.bias,h.bias,h.bias,h.bias]:(O=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(O[3]=h.bias[3]));let E=m*i;if(t!==void 0&&(t.format!==void 0&&d===4&&t.format!=="RGBA"||d===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let v=4,C=0,x=1,P=2,T=3,B=0,k=E,N=E*2,V=-1;s==="RGBA"?(B=0,k=E,N=E*2,V=E*3):s==="RGB"?(B=0,k=E,N=E*2):s==="RBG"&&(B=0,N=E,k=E*2),f=n.createImageData(i,m);for(let Y=0;Y<m*i;C+=v,x+=v,P+=v,T+=v,Y++)f.data[C]=(r.data[B++]-O[0])*g[0],f.data[x]=(r.data[k++]-O[1])*g[1],f.data[P]=(r.data[N++]-O[2])*g[2],f.data[T]=V===-1?255:(r.data[V++]-O[3])*g[3]}else throw new Error("Can not access image data");return f}});var or,fn,ln,cn,dn,pn=H(()=>{"use strict";Bt();or=(r,t)=>{if(r===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:f}=t,i=t.norm??{mean:255,bias:0},m,d;typeof i.mean=="number"?m=[i.mean,i.mean,i.mean,i.mean]:m=[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],typeof i.bias=="number"?d=[i.bias,i.bias,i.bias,i.bias]:d=[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format!==void 0?t.format:"RGBA",h=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",g=n*f,O=h==="RGBA"?new Float32Array(g*4):new Float32Array(g*3),E=4,v=0,C=1,x=2,P=3,T=0,B=g,k=g*2,N=-1;s==="RGB"&&(E=3,v=0,C=1,x=2,P=-1),h==="RGBA"?N=g*3:h==="RBG"?(T=0,k=g,B=g*2):h==="BGR"&&(k=0,B=g,T=g*2);for(let Y=0;Y<g;Y++,v+=E,x+=E,C+=E,P+=E)O[T++]=(r[v]+d[0])/m[0],O[B++]=(r[C]+d[1])/m[1],O[k++]=(r[x]+d[2])/m[2],N!==-1&&P!==-1&&(O[N++]=(r[P]+d[3])/m[3]);return h==="RGBA"?new ge("float32",O,[1,4,n,f]):new ge("float32",O,[1,3,n,f])},fn=async(r,t)=>{let n=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,f=typeof ImageData<"u"&&r instanceof ImageData,i=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,m=typeof r=="string",d,s=t??{},h=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},g=O=>O instanceof HTMLCanvasElement||O instanceof OffscreenCanvas?O.getContext("2d"):null;if(n){let O=h();O.width=r.width,O.height=r.height;let E=g(O);if(E!=null){let v=r.height,C=r.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(v=t.resizedHeight,C=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=v,s.width=C}else s.tensorFormat="RGBA",s.height=v,s.width=C;E.drawImage(r,0,0),d=E.getImageData(0,0,C,v).data}else throw new Error("Can not access image data")}else if(f){let O,E;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(O=t.resizedHeight,E=t.resizedWidth):(O=r.height,E=r.width),t!==void 0&&(s=t),s.format="RGBA",s.height=O,s.width=E,t!==void 0){let v=h();v.width=E,v.height=O;let C=g(v);if(C!=null)C.putImageData(r,0,0),d=C.getImageData(0,0,E,O).data;else throw new Error("Can not access image data")}else d=r.data}else if(i){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let O=h();O.width=r.width,O.height=r.height;let E=g(O);if(E!=null){let v=r.height,C=r.width;return E.drawImage(r,0,0,C,v),d=E.getImageData(0,0,C,v).data,s.height=v,s.width=C,or(d,s)}else throw new Error("Can not access image data")}else{if(m)return new Promise((O,E)=>{let v=h(),C=g(v);if(!r||!C)return E();let x=new Image;x.crossOrigin="Anonymous",x.src=r,x.onload=()=>{v.width=x.width,v.height=x.height,C.drawImage(x,0,0,v.width,v.height);let P=C.getImageData(0,0,v.width,v.height);s.height=v.height,s.width=v.width,O(or(P.data,s))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(d!==void 0)return or(d,s);throw new Error("Input data provided is not supported - aborted tensor creation")},ln=(r,t)=>{let{width:n,height:f,download:i,dispose:m}=t,d=[1,f,n,4];return new ge({location:"texture",type:"float32",texture:r,dims:d,download:i,dispose:m})},cn=(r,t)=>{let{dataType:n,dims:f,download:i,dispose:m}=t;return new ge({location:"gpu-buffer",type:n??"float32",gpuBuffer:r,dims:f,download:i,dispose:m})},dn=(r,t,n)=>new ge({location:"cpu-pinned",type:r,data:t,dims:n??[t.length]})});var Je,vt,mn,hn,gn=H(()=>{"use strict";Je=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),vt=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),mn=!1,hn=()=>{if(!mn){mn=!0;let r=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;r&&(Je.set("int64",BigInt64Array),vt.set(BigInt64Array,"int64")),t&&(Je.set("uint64",BigUint64Array),vt.set(BigUint64Array,"uint64")),n?(Je.set("float16",Float16Array),vt.set(Float16Array,"float16")):Je.set("float16",Uint16Array)}}});var yn,wn,bn=H(()=>{"use strict";Bt();yn=r=>{let t=1;for(let n=0;n<r.length;n++){let f=r[n];if(typeof f!="number"||!Number.isSafeInteger(f))throw new TypeError(`dims[${n}] must be an integer, got: ${f}`);if(f<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${f}`);t*=f}return t},wn=(r,t)=>{switch(r.location){case"cpu":return new ge(r.type,r.data,t);case"cpu-pinned":return new ge({location:"cpu-pinned",data:r.data,type:r.type,dims:t});case"texture":return new ge({location:"texture",texture:r.texture,type:r.type,dims:t});case"gpu-buffer":return new ge({location:"gpu-buffer",gpuBuffer:r.gpuBuffer,type:r.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${r.location} is not supported`)}}});var ge,Bt=H(()=>{"use strict";un();pn();gn();bn();ge=class{constructor(t,n,f){hn();let i,m;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,i=t.type,m=t.dims,t.location){case"cpu-pinned":{let s=Je.get(i);if(!s)throw new TypeError(`unsupported type "${i}" to create tensor from pinned buffer`);if(!(t.data instanceof s))throw new TypeError(`buffer should be of type ${s.name}`);this.cpuData=t.data;break}case"texture":{if(i!=="float32")throw new TypeError(`unsupported type "${i}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(i!=="float32"&&i!=="float16"&&i!=="int32"&&i!=="int64"&&i!=="uint32"&&i!=="uint8"&&i!=="bool")throw new TypeError(`unsupported type "${i}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let s,h;if(typeof t=="string")if(i=t,h=f,t==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");s=n}else{let g=Je.get(t);if(g===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(n)){if(t==="float16"&&g===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");t==="uint64"||t==="int64"?s=g.from(n,BigInt):s=g.from(n)}else if(n instanceof g)s=n;else throw new TypeError(`A ${i} tensor's data must be type of ${g}`)}else if(h=n,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let g=typeof t[0];if(g==="string")i="string",s=t;else if(g==="boolean")i="bool",s=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${g}.`)}else{let g=vt.get(t.constructor);if(g===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);i=g,s=t}if(h===void 0)h=[s.length];else if(!Array.isArray(h))throw new TypeError("A tensor's dims must be a number array");m=h,this.cpuData=s,this.dataLocation="cpu"}let d=yn(m);if(this.cpuData&&d!==this.cpuData.length)throw new Error(`Tensor's size(${d}) does not match data length(${this.cpuData.length}).`);this.type=i,this.dims=m,this.size=d}static async fromImage(t,n){return fn(t,n)}static fromTexture(t,n){return ln(t,n)}static fromGpuBuffer(t,n){return cn(t,n)}static fromPinnedBuffer(t,n,f){return dn(t,n,f)}toDataURL(t){return on(this,t)}toImageData(t){return sn(this,t)}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(t){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 n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,t&&this.disposer&&(this.disposer(),this.disposer=void 0),n}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(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return wn(this,t)}}});var ce,Lt=H(()=>{"use strict";Bt();ce=ge});var ir,vn,He,$e,sr=H(()=>{"use strict";ar();ir=(r,t)=>{(typeof ve.trace>"u"?!ve.wasm.trace:!ve.trace)||console.timeStamp(`${r}::ORT::${t}`)},vn=(r,t)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],f=!1;for(let i=0;i<n.length;i++){if(f&&!n[i].includes("TRACE_FUNC")){let m=`FUNC_${r}::${n[i].trim().split(" ")[1]}`;t&&(m+=`::${t}`),ir("CPU",m);return}n[i].includes("TRACE_FUNC")&&(f=!0)}},He=r=>{(typeof ve.trace>"u"?!ve.wasm.trace:!ve.trace)||vn("BEGIN",r)},$e=r=>{(typeof ve.trace>"u"?!ve.wasm.trace:!ve.trace)||vn("END",r)}});var kt,On=H(()=>{"use strict";It();Lt();sr();kt=class r{constructor(t){this.handler=t}async run(t,n,f){He();let i={},m={};if(typeof t!="object"||t===null||t instanceof ce||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let d=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof ce)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(n)){if(n.length===0)throw new TypeError("'fetches' cannot be an empty array.");d=!1;for(let g of n){if(typeof g!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(g)===-1)throw new RangeError(`'fetches' contains invalid output name: ${g}.`);i[g]=null}if(typeof f=="object"&&f!==null)m=f;else if(typeof f<"u")throw new TypeError("'options' must be an object.")}else{let g=!1,O=Object.getOwnPropertyNames(n);for(let E of this.outputNames)if(O.indexOf(E)!==-1){let v=n[E];(v===null||v instanceof ce)&&(g=!0,d=!1,i[E]=v)}if(g){if(typeof f=="object"&&f!==null)m=f;else if(typeof f<"u")throw new TypeError("'options' must be an object.")}else m=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let g of this.inputNames)if(typeof t[g]>"u")throw new Error(`input '${g}' is missing in 'feeds'.`);if(d)for(let g of this.outputNames)i[g]=null;let s=await this.handler.run(t,i,m),h={};for(let g in s)if(Object.hasOwnProperty.call(s,g)){let O=s[g];O instanceof ce?h[g]=O:h[g]=new ce(O.type,O.data,O.dims)}return $e(),h}async release(){return this.handler.dispose()}static async create(t,n,f,i){He();let m,d={};if(typeof t=="string"){if(m=t,typeof n=="object"&&n!==null)d=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(m=t,typeof n=="object"&&n!==null)d=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){let O=t,E=0,v=t.byteLength;if(typeof n=="object"&&n!==null)d=n;else if(typeof n=="number"){if(E=n,!Number.isSafeInteger(E))throw new RangeError("'byteOffset' must be an integer.");if(E<0||E>=O.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${O.byteLength}).`);if(v=t.byteLength-E,typeof f=="number"){if(v=f,!Number.isSafeInteger(v))throw new RangeError("'byteLength' must be an integer.");if(v<=0||E+v>O.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${O.byteLength-E}].`);if(typeof i=="object"&&i!==null)d=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(typeof f<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");m=new Uint8Array(O,E,v)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[s,h]=await Ft(d),g=await s.createInferenceSessionHandler(m,h);return $e(),new r(g)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var En,_n=H(()=>{"use strict";On();En=kt});var An=H(()=>{"use strict"});var Tn=H(()=>{"use strict"});var Sn=H(()=>{"use strict"});var Mn=H(()=>{"use strict"});var Fa,Nt,Cn=H(()=>{"use strict";It();Lt();Fa="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",Nt=class r{constructor(t,n,f){this.handler=t,this.hasOptimizerModel=n,this.hasEvalModel=f}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 f=t.evalModel||"",i=t.optimizerModel||"",m=n||{},[d,s]=await Ft(m);if(d.createTrainingSessionHandler){let h=await d.createTrainingSessionHandler(t.checkpointState,t.trainModel,f,i,s);return new r(h,!!t.optimizerModel,!!t.evalModel)}else throw new Error(Fa)}typeNarrowingForRunStep(t,n,f,i,m){let d={},s={};if(typeof f!="object"||f===null||f instanceof ce||Array.isArray(f))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let h=!0;if(typeof i=="object"){if(i===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(i instanceof ce)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(i)){if(i.length===0)throw new TypeError("'fetches' cannot be an empty array.");h=!1;for(let g of i){if(typeof g!="string")throw new TypeError("'fetches' must be a string array or an object.");if(n.indexOf(g)===-1)throw new RangeError(`'fetches' contains invalid output name: ${g}.`);d[g]=null}if(typeof m=="object"&&m!==null)s=m;else if(typeof m<"u")throw new TypeError("'options' must be an object.")}else{let g=!1,O=Object.getOwnPropertyNames(i);for(let E of n)if(O.indexOf(E)!==-1){let v=i[E];(v===null||v instanceof ce)&&(g=!0,h=!1,d[E]=v)}if(g){if(typeof m=="object"&&m!==null)s=m;else if(typeof m<"u")throw new TypeError("'options' must be an object.")}else s=i}}else if(typeof i<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let g of t)if(typeof f[g]>"u")throw new Error(`input '${g}' is missing in 'feeds'.`);if(h)for(let g of n)d[g]=null;return[d,s]}convertHandlerReturnTypeToMapOfTensors(t){let n={};for(let f in t)if(Object.hasOwnProperty.call(t,f)){let i=t[f];i instanceof ce?n[f]=i:n[f]=new ce(i.type,i.data,i.dims)}return n}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(t,n,f){let[i,m]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,t,n,f),d=await this.handler.runTrainStep(t,i,m);return this.convertHandlerReturnTypeToMapOfTensors(d)}async runOptimizerStep(t){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(t||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(t,n,f){if(this.hasEvalModel){let[i,m]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,t,n,f),d=await this.handler.runEvalStep(t,i,m);return this.convertHandlerReturnTypeToMapOfTensors(d)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(t=!0){return this.handler.getParametersSize(t)}async loadParametersBuffer(t,n=!0){let f=await this.getParametersSize(n);if(t.length!==4*f)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(t,n)}async getContiguousParameters(t=!0){return this.handler.getContiguousParameters(t)}async release(){return this.handler.dispose()}}});var xn,Pn=H(()=>{"use strict";Cn();xn=Nt});var ur={};it(ur,{InferenceSession:()=>En,TRACE:()=>ir,TRACE_FUNC_BEGIN:()=>He,TRACE_FUNC_END:()=>$e,Tensor:()=>ce,TrainingSession:()=>xn,env:()=>G,registerBackend:()=>st});var Qe=H(()=>{"use strict";en();an();_n();Lt();An();Tn();sr();Sn();Mn();Pn()});var fr={};it(fr,{createReadStream:()=>Dn,readFile:()=>Ia,readFileSync:()=>Ba});var Ia,Ba,Dn,lr=H(()=>{Ia=void 0,Ba=void 0,Dn=void 0});var cr={};it(cr,{join:()=>La});var La,dr=H(()=>{La=void 0});var In=ot((Fn,pr)=>{"use strict";var Un=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(t={}){var n=t,f,i;n.ready=new Promise((o,l)=>{f=o,i=l});var m=Object.assign({},n),d="./this.program",s=typeof window=="object",h=typeof importScripts=="function",g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",O="",E,v,C;if(g){var x=(lr(),Ve(fr)),P=(dr(),Ve(cr));O=h?P.dirname(O)+"/":__dirname+"/",E=(o,l)=>(o=Me(o)?new URL(o):P.normalize(o),x.readFileSync(o,l?void 0:"utf8")),C=o=>(o=E(o,!0),o.buffer||(o=new Uint8Array(o)),o),v=(o,l,c,b=!0)=>{o=Me(o)?new URL(o):P.normalize(o),x.readFile(o,b?void 0:"utf8",(S,D)=>{S?c(S):l(b?D.buffer:D)})},!n.thisProgram&&1<process.argv.length&&(d=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),n.inspect=()=>"[Emscripten Module object]"}else(s||h)&&(h?O=self.location.href:typeof document<"u"&&document.currentScript&&(O=document.currentScript.src),r&&(O=r),O.indexOf("blob:")!==0?O=O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1):O="",E=o=>{var l=new XMLHttpRequest;return l.open("GET",o,!1),l.send(null),l.responseText},h&&(C=o=>{var l=new XMLHttpRequest;return l.open("GET",o,!1),l.responseType="arraybuffer",l.send(null),new Uint8Array(l.response)}),v=(o,l,c)=>{var b=new XMLHttpRequest;b.open("GET",o,!0),b.responseType="arraybuffer",b.onload=()=>{b.status==200||b.status==0&&b.response?l(b.response):c()},b.onerror=c,b.send(null)});var T=console.log.bind(console),B=console.error.bind(console);Object.assign(n,m),m=null,typeof WebAssembly!="object"&&L("no native wasm support detected");var k,N=!1,V,Y,R,X,Fe;function Ne(){var o=k.buffer;n.HEAP8=V=new Int8Array(o),n.HEAP16=new Int16Array(o),n.HEAPU8=Y=new Uint8Array(o),n.HEAPU16=new Uint16Array(o),n.HEAP32=R=new Int32Array(o),n.HEAPU32=X=new Uint32Array(o),n.HEAPF32=new Float32Array(o),n.HEAPF64=Fe=new Float64Array(o)}var me=[],ie=[],re=[],Se=0,Ee=null,se=null;function L(o){throw o="Aborted("+o+")",B(o),N=!0,o=new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info."),i(o),o}var _e=o=>o.startsWith("data:application/octet-stream;base64,"),Me=o=>o.startsWith("file://"),de;if(de="ort-wasm.wasm",!_e(de)){var Ce=de;de=n.locateFile?n.locateFile(Ce,O):O+Ce}function J(o){if(C)return C(o);throw"both async and sync fetching of the wasm failed"}function ye(o){if(s||h){if(typeof fetch=="function"&&!Me(o))return fetch(o,{credentials:"same-origin"}).then(l=>{if(!l.ok)throw"failed to load wasm binary file at '"+o+"'";return l.arrayBuffer()}).catch(()=>J(o));if(v)return new Promise((l,c)=>{v(o,b=>l(new Uint8Array(b)),c)})}return Promise.resolve().then(()=>J(o))}function Ge(o,l,c){return ye(o).then(b=>WebAssembly.instantiate(b,l)).then(b=>b).then(c,b=>{B(`failed to asynchronously prepare wasm: ${b}`),L(b)})}function xe(o,l){var c=de;return typeof WebAssembly.instantiateStreaming!="function"||_e(c)||Me(c)||g||typeof fetch!="function"?Ge(c,o,l):fetch(c,{credentials:"same-origin"}).then(b=>WebAssembly.instantiateStreaming(b,o).then(l,function(S){return B(`wasm streaming compile failed: ${S}`),B("falling back to ArrayBuffer instantiation"),Ge(c,o,l)}))}var Ae,Te={920016:(o,l,c,b)=>{if(typeof n>"u"||!n.za)return 1;if(o=Q(o>>>0),o.startsWith("./")&&(o=o.substring(2)),o=n.za.get(o),!o)return 2;if(l>>>=0,c>>>=0,l+c>o.byteLength)return 3;try{return Y.set(o.subarray(l,l+c),b>>>0>>>0),0}catch{return 4}}};function je(o){this.xa=o-24,this.Ha=function(l){X[this.xa+4>>>2>>>0]=l},this.Ga=function(l){X[this.xa+8>>>2>>>0]=l},this.Aa=function(l,c){this.Fa(),this.Ha(l),this.Ga(c)},this.Fa=function(){X[this.xa+16>>>2>>>0]=0}}var we=0,Pe=0,Ie=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ae=(o,l,c)=>{l>>>=0;var b=l+c;for(c=l;o[c]&&!(c>=b);)++c;if(16<c-l&&o.buffer&&Ie)return Ie.decode(o.subarray(l,c));for(b="";l<c;){var S=o[l++];if(S&128){var D=o[l++]&63;if((S&224)==192)b+=String.fromCharCode((S&31)<<6|D);else{var W=o[l++]&63;S=(S&240)==224?(S&15)<<12|D<<6|W:(S&7)<<18|D<<12|W<<6|o[l++]&63,65536>S?b+=String.fromCharCode(S):(S-=65536,b+=String.fromCharCode(55296|S>>10,56320|S&1023))}}else b+=String.fromCharCode(S)}return b},Q=(o,l)=>(o>>>=0)?ae(Y,o,l):"",pe=o=>{for(var l=0,c=0;c<o.length;++c){var b=o.charCodeAt(c);127>=b?l++:2047>=b?l+=2:55296<=b&&57343>=b?(l+=4,++c):l+=3}return l},Be=(o,l,c,b)=>{if(c>>>=0,!(0<b))return 0;var S=c;b=c+b-1;for(var D=0;D<o.length;++D){var W=o.charCodeAt(D);if(55296<=W&&57343>=W){var oe=o.charCodeAt(++D);W=65536+((W&1023)<<10)|oe&1023}if(127>=W){if(c>=b)break;l[c++>>>0]=W}else{if(2047>=W){if(c+1>=b)break;l[c++>>>0]=192|W>>6}else{if(65535>=W){if(c+2>=b)break;l[c++>>>0]=224|W>>12}else{if(c+3>=b)break;l[c++>>>0]=240|W>>18,l[c++>>>0]=128|W>>12&63}l[c++>>>0]=128|W>>6&63}l[c++>>>0]=128|W&63}}return l[c>>>0]=0,c-S},Re=o=>o%4===0&&(o%100!==0||o%400===0),dt=[0,31,60,91,121,152,182,213,244,274,305,335],At=[0,31,59,90,120,151,181,212,243,273,304,334],Le=o=>{var l=pe(o)+1,c=St(l);return c&&Be(o,Y,c,l),c},Ke=[],We={},et=()=>{if(!tt){var o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"},l;for(l in We)We[l]===void 0?delete o[l]:o[l]=We[l];var c=[];for(l in o)c.push(`${l}=${o[l]}`);tt=c}return tt},tt,ze=[null,[],[]],pt=[31,29,31,30,31,30,31,31,30,31,30,31],mt=[31,28,31,30,31,30,31,31,30,31,30,31];function rt(o){var l=Array(pe(o)+1);return Be(o,l,0,l.length),l}function Tt(o,l,c,b){function S(y,$,q){for(y=typeof y=="number"?y.toString():y||"";y.length<$;)y=q[0]+y;return y}function D(y,$){return S(y,$,"0")}function W(y,$){function q(bt){return 0>bt?-1:0<bt?1:0}var De;return(De=q(y.getFullYear()-$.getFullYear()))===0&&(De=q(y.getMonth()-$.getMonth()))===0&&(De=q(y.getDate()-$.getDate())),De}function oe(y){switch(y.getDay()){case 0:return new Date(y.getFullYear()-1,11,29);case 1:return y;case 2:return new Date(y.getFullYear(),0,3);case 3:return new Date(y.getFullYear(),0,2);case 4:return new Date(y.getFullYear(),0,1);case 5:return new Date(y.getFullYear()-1,11,31);case 6:return new Date(y.getFullYear()-1,11,30)}}function he(y){var $=y.ta;for(y=new Date(new Date(y.ua+1900,0,1).getTime());0<$;){var q=y.getMonth(),De=(Re(y.getFullYear())?pt:mt)[q];if($>De-y.getDate())$-=De-y.getDate()+1,y.setDate(1),11>q?y.setMonth(q+1):(y.setMonth(0),y.setFullYear(y.getFullYear()+1));else{y.setDate(y.getDate()+$);break}}return q=new Date(y.getFullYear()+1,0,4),$=oe(new Date(y.getFullYear(),0,4)),q=oe(q),0>=W($,y)?0>=W(q,y)?y.getFullYear()+1:y.getFullYear():y.getFullYear()-1}o>>>=0,l>>>=0,c>>>=0,b>>>=0;var fe=X[b+40>>>2>>>0];b={Da:R[b>>>2>>>0],Ca:R[b+4>>>2>>>0],va:R[b+8>>>2>>>0],ya:R[b+12>>>2>>>0],wa:R[b+16>>>2>>>0],ua:R[b+20>>>2>>>0],oa:R[b+24>>>2>>>0],ta:R[b+28>>>2>>>0],Ia:R[b+32>>>2>>>0],Ba:R[b+36>>>2>>>0],Ea:fe?Q(fe):""},c=Q(c),fe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var le in fe)c=c.replace(new RegExp(le,"g"),fe[le]);var yt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),wt="January February March April May June July August September October November December".split(" ");fe={"%a":y=>yt[y.oa].substring(0,3),"%A":y=>yt[y.oa],"%b":y=>wt[y.wa].substring(0,3),"%B":y=>wt[y.wa],"%C":y=>D((y.ua+1900)/100|0,2),"%d":y=>D(y.ya,2),"%e":y=>S(y.ya,2," "),"%g":y=>he(y).toString().substring(2),"%G":y=>he(y),"%H":y=>D(y.va,2),"%I":y=>(y=y.va,y==0?y=12:12<y&&(y-=12),D(y,2)),"%j":y=>{for(var $=0,q=0;q<=y.wa-1;$+=(Re(y.ua+1900)?pt:mt)[q++]);return D(y.ya+$,3)},"%m":y=>D(y.wa+1,2),"%M":y=>D(y.Ca,2),"%n":()=>` `,"%p":y=>0<=y.va&&12>y.va?"AM":"PM","%S":y=>D(y.Da,2),"%t":()=>" ","%u":y=>y.oa||7,"%U":y=>D(Math.floor((y.ta+7-y.oa)/7),2),"%V":y=>{var $=Math.floor((y.ta+7-(y.oa+6)%7)/7);if(2>=(y.oa+371-y.ta-2)%7&&$++,$)$==53&&(q=(y.oa+371-y.ta)%7,q==4||q==3&&Re(y.ua)||($=1));else{$=52;var q=(y.oa+7-y.ta-1)%7;(q==4||q==5&&Re(y.ua%400-1))&&$++}return D($,2)},"%w":y=>y.oa,"%W":y=>D(Math.floor((y.ta+7-(y.oa+6)%7)/7),2),"%y":y=>(y.ua+1900).toString().substring(2),"%Y":y=>y.ua+1900,"%z":y=>{y=y.Ba;var $=0<=y;return y=Math.abs(y)/60,($?"+":"-")+("0000"+(y/60*100+y%60)).slice(-4)},"%Z":y=>y.Ea,"%%":()=>"%"},c=c.replace(/%%/g,"\0\0");for(le in fe)c.includes(le)&&(c=c.replace(new RegExp(le,"g"),fe[le](b)));return c=c.replace(/\0\0/g,"%"),le=rt(c),le.length>l?0:(V.set(le,o>>>0),le.length-1)}var z={a:function(o,l,c){throw o>>>=0,new je(o).Aa(l>>>0,c>>>0),we=o,Pe++,we},e:function(){return 0},H:function(){},x:function(){},z:function(){},J:function(){return 0},F:function(){},A:function(){},E:function(){},g:function(){},y:function(){},v:function(){},G:function(){},w:function(){},k:()=>1,n:function(o,l,c){o=l+2097152>>>0<4194305-!!o?(o>>>0)+4294967296*l:NaN,c>>>=0,o=new Date(1e3*o),R[c>>>2>>>0]=o.getUTCSeconds(),R[c+4>>>2>>>0]=o.getUTCMinutes(),R[c+8>>>2>>>0]=o.getUTCHours(),R[c+12>>>2>>>0]=o.getUTCDate(),R[c+16>>>2>>>0]=o.getUTCMonth(),R[c+20>>>2>>>0]=o.getUTCFullYear()-1900,R[c+24>>>2>>>0]=o.getUTCDay(),R[c+28>>>2>>>0]=(o.getTime()-Date.UTC(o.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(o,l,c){o=l+2097152>>>0<4194305-!!o?(o>>>0)+4294967296*l:NaN,c>>>=0,o=new Date(1e3*o),R[c>>>2>>>0]=o.getSeconds(),R[c+4>>>2>>>0]=o.getMinutes(),R[c+8>>>2>>>0]=o.getHours(),R[c+12>>>2>>>0]=o.getDate(),R[c+16>>>2>>>0]=o.getMonth(),R[c+20>>>2>>>0]=o.getFullYear()-1900,R[c+24>>>2>>>0]=o.getDay(),R[c+28>>>2>>>0]=(Re(o.getFullYear())?dt:At)[o.getMonth()]+o.getDate()-1|0,R[c+36>>>2>>>0]=-(60*o.getTimezoneOffset()),l=new Date(o.getFullYear(),6,1).getTimezoneOffset();var b=new Date(o.getFullYear(),0,1).getTimezoneOffset();R[c+32>>>2>>>0]=(l!=b&&o.getTimezoneOffset()==Math.min(b,l))|0},p:function(o){o>>>=0;var l=new Date(R[o+20>>>2>>>0]+1900,R[o+16>>>2>>>0],R[o+12>>>2>>>0],R[o+8>>>2>>>0],R[o+4>>>2>>>0],R[o>>>2>>>0],0),c=R[o+32>>>2>>>0],b=l.getTimezoneOffset(),S=new Date(l.getFullYear(),6,1).getTimezoneOffset(),D=new Date(l.getFullYear(),0,1).getTimezoneOffset(),W=Math.min(D,S);return 0>c?R[o+32>>>2>>>0]=+(S!=D&&W==b):0<c!=(W==b)&&(S=Math.max(D,S),l.setTime(l.getTime()+6e4*((0<c?W:S)-b))),R[o+24>>>2>>>0]=l.getDay(),R[o+28>>>2>>>0]=(Re(l.getFullYear())?dt:At)[l.getMonth()]+l.getDate()-1|0,R[o>>>2>>>0]=l.getSeconds(),R[o+4>>>2>>>0]=l.getMinutes(),R[o+8>>>2>>>0]=l.getHours(),R[o+12>>>2>>>0]=l.getDate(),R[o+16>>>2>>>0]=l.getMonth(),R[o+20>>>2>>>0]=l.getYear(),o=l.getTime(),isNaN(o)?(R[nt()>>>2>>>0]=61,o=-1):o/=1e3,ht((Ae=o,1<=+Math.abs(Ae)?0<Ae?+Math.floor(Ae/4294967296)>>>0:~~+Math.ceil((Ae-+(~~Ae>>>0))/4294967296)>>>0:0)),o>>>0},l:function(){return-52},m:function(){},t:function(o,l,c){function b(he){return(he=he.toTimeString().match(/\(([A-Za-z ]+)\)$/))?he[1]:"GMT"}c>>>=0;var S=new Date().getFullYear(),D=new Date(S,0,1),W=new Date(S,6,1);S=D.getTimezoneOffset();var oe=W.getTimezoneOffset();X[o>>>0>>>2>>>0]=60*Math.max(S,oe),R[l>>>0>>>2>>>0]=+(S!=oe),o=b(D),l=b(W),o=Le(o),l=Le(l),oe<S?(X[c>>>2>>>0]=o,X[c+4>>>2>>>0]=l):(X[c>>>2>>>0]=l,X[c+4>>>2>>>0]=o)},d:()=>{L("")},B:function(o,l,c){o>>>=0,l>>>=0,c>>>=0,Ke.length=0;for(var b;b=Y[l++>>>0];){var S=b!=105;S&=b!=112,c+=S&&c%8?4:0,Ke.push(b==112?X[c>>>2>>>0]:b==105?R[c>>>2>>>0]:Fe[c>>>3>>>0]),c+=S?8:4}return Te[o].apply(null,Ke)},h:()=>Date.now(),u:function(){return 4294901760},b:()=>performance.now(),I:function(o,l,c){return l>>>=0,Y.copyWithin(o>>>0>>>0,l>>>0,l+(c>>>0)>>>0)},s:function(o){o>>>=0;var l=Y.length;if(4294901760<o)return!1;for(var c=1;4>=c;c*=2){var b=l*(1+.2/c);b=Math.min(b,o+100663296);var S=Math;b=Math.max(o,b);e:{S=(S.min.call(S,4294901760,b+(65536-b%65536)%65536)-k.buffer.byteLength+65535)/65536;try{k.grow(S),Ne();var D=1;break e}catch{}D=void 0}if(D)return!0}return!1},C:function(o,l){o>>>=0,l>>>=0;var c=0;return et().forEach((b,S)=>{var D=l+c;for(S=X[o+4*S>>>2>>>0]=D,D=0;D<b.length;++D)V[S++>>>0>>>0]=b.charCodeAt(D);V[S>>>0>>>0]=0,c+=b.length+1}),0},D:function(o,l){o>>>=0,l>>>=0;var c=et();X[o>>>2>>>0]=c.length;var b=0;return c.forEach(S=>b+=S.length+1),X[l>>>2>>>0]=b,0},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(o,l,c,b){l>>>=0,c>>>=0,b>>>=0;for(var S=0,D=0;D<c;D++){var W=X[l>>>2>>>0],oe=X[l+4>>>2>>>0];l+=8;for(var he=0;he<oe;he++){var fe=Y[W+he>>>0],le=ze[o];fe===0||fe===10?((o===1?T:B)(ae(le,0)),le.length=0):le.push(fe)}S+=oe}return X[b>>>2>>>0]=S,0},r:Tt,c:function(o,l,c,b){return Tt(o>>>0,l>>>0,c>>>0,b>>>0)}},I=function(){function o(c){return I=c.exports,I=Ct(),k=I.K,Ne(),ie.unshift(I.L),Se--,Se==0&&(Ee!==null&&(clearInterval(Ee),Ee=null),se&&(c=se,se=null,c())),I}var l={a:z};if(Se++,n.instantiateWasm)try{return n.instantiateWasm(l,o)}catch(c){B(`Module.instantiateWasm callback failed with error: ${c}`),i(c)}return xe(l,function(c){o(c.instance)}).catch(i),{}}();n._OrtInit=(o,l)=>(n._OrtInit=I.M)(o,l),n._OrtGetLastError=(o,l)=>(n._OrtGetLastError=I.N)(o,l),n._OrtCreateSessionOptions=(o,l,c,b,S,D,W,oe,he,fe)=>(n._OrtCreateSessionOptions=I.O)(o,l,c,b,S,D,W,oe,he,fe),n._OrtAppendExecutionProvider=(o,l)=>(n._OrtAppendExecutionProvider=I.P)(o,l),n._OrtAddFreeDimensionOverride=(o,l,c)=>(n._OrtAddFreeDimensionOverride=I.Q)(o,l,c),n._OrtAddSessionConfigEntry=(o,l,c)=>(n._OrtAddSessionConfigEntry=I.R)(o,l,c),n._OrtReleaseSessionOptions=o=>(n._OrtReleaseSessionOptions=I.S)(o),n._OrtCreateSession=(o,l,c)=>(n._OrtCreateSession=I.T)(o,l,c),n._OrtReleaseSession=o=>(n._OrtReleaseSession=I.U)(o),n._OrtGetInputOutputCount=(o,l,c)=>(n._OrtGetInputOutputCount=I.V)(o,l,c),n._OrtGetInputName=(o,l)=>(n._OrtGetInputName=I.W)(o,l),n._OrtGetOutputName=(o,l)=>(n._OrtGetOutputName=I.X)(o,l),n._OrtFree=o=>(n._OrtFree=I.Y)(o),n._OrtCreateTensor=(o,l,c,b,S,D)=>(n._OrtCreateTensor=I.Z)(o,l,c,b,S,D),n._OrtGetTensorData=(o,l,c,b,S)=>(n._OrtGetTensorData=I._)(o,l,c,b,S),n._OrtReleaseTensor=o=>(n._OrtReleaseTensor=I.$)(o),n._OrtCreateRunOptions=(o,l,c,b)=>(n._OrtCreateRunOptions=I.aa)(o,l,c,b),n._OrtAddRunConfigEntry=(o,l,c)=>(n._OrtAddRunConfigEntry=I.ba)(o,l,c),n._OrtReleaseRunOptions=o=>(n._OrtReleaseRunOptions=I.ca)(o),n._OrtCreateBinding=o=>(n._OrtCreateBinding=I.da)(o),n._OrtBindInput=(o,l,c)=>(n._OrtBindInput=I.ea)(o,l,c),n._OrtBindOutput=(o,l,c,b)=>(n._OrtBindOutput=I.fa)(o,l,c,b),n._OrtClearBoundOutputs=o=>(n._OrtClearBoundOutputs=I.ga)(o),n._OrtReleaseBinding=o=>(n._OrtReleaseBinding=I.ha)(o),n._OrtRunWithBinding=(o,l,c,b,S)=>(n._OrtRunWithBinding=I.ia)(o,l,c,b,S),n._OrtRun=(o,l,c,b,S,D,W,oe)=>(n._OrtRun=I.ja)(o,l,c,b,S,D,W,oe),n._OrtEndProfiling=o=>(n._OrtEndProfiling=I.ka)(o);var nt=()=>(nt=I.la)(),St=n._malloc=o=>(St=n._malloc=I.ma)(o);n._free=o=>(n._free=I.na)(o);var ht=o=>(ht=I.pa)(o),Mt=()=>(Mt=I.qa)(),F=o=>(F=I.ra)(o),Ye=o=>(Ye=I.sa)(o);function Ct(){var o=I;o=Object.assign({},o);var l=b=>()=>b()>>>0,c=b=>S=>b(S)>>>0;return o.la=l(o.la),o.ma=c(o.ma),o.qa=l(o.qa),o.sa=c(o.sa),o}n.stackAlloc=Ye,n.stackSave=Mt,n.stackRestore=F,n.UTF8ToString=Q,n.stringToUTF8=(o,l,c)=>Be(o,Y,l,c),n.lengthBytesUTF8=pe;var ke;se=function o(){ke||gt(),ke||(se=o)};function gt(){if(!(0<Se)){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;){var o=n.preRun.shift();me.unshift(o)}for(;0<me.length;)me.shift()(n);if(!(0<Se||ke||(ke=!0,n.calledRun=!0,N))){for(;0<ie.length;)ie.shift()(n);for(f(n);0<re.length;)re.shift()(n)}}}return gt(),t.ready}})();typeof Fn=="object"&&typeof pr=="object"?pr.exports=Un:typeof define=="function"&&define.amd&&define([],()=>Un)});var Bn=ot(()=>{});var Ln=ot(()=>{});var kn={};it(kn,{cpus:()=>ka});var ka,Nn=H(()=>{ka=void 0});var $n=ot((Hn,mr)=>{"use strict";var Wn=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(t={}){function n(){return re.buffer!=L.buffer&&J(),L}function f(){return re.buffer!=L.buffer&&J(),_e}function i(){return re.buffer!=L.buffer&&J(),Me}function m(){return re.buffer!=L.buffer&&J(),de}function d(){return re.buffer!=L.buffer&&J(),Ce}var s=t,h,g;s.ready=new Promise((e,a)=>{h=e,g=a});var O=Object.assign({},s),E="./this.program",v=(e,a)=>{throw a},C=typeof window=="object",x=typeof importScripts=="function",P=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T=s.ENVIRONMENT_IS_PTHREAD||!1,B="";function k(e){return s.locateFile?s.locateFile(e,B):B+e}var N,V,Y;if(P){var R=(lr(),Ve(fr)),X=(dr(),Ve(cr));B=x?X.dirname(B)+"/":__dirname+"/",N=(a,u)=>(a=Q(a)?new URL(a):X.normalize(a),R.readFileSync(a,u?void 0:"utf8")),Y=a=>(a=N(a,!0),a.buffer||(a=new Uint8Array(a)),a),V=(a,u,p,_=!0)=>{a=Q(a)?new URL(a):X.normalize(a),R.readFile(a,_?void 0:"utf8",(A,M)=>{A?p(A):u(_?M.buffer:M)})},!s.thisProgram&&1<process.argv.length&&(E=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),v=(a,u)=>{throw process.exitCode=a,u},s.inspect=()=>"[Emscripten Module object]";let e;try{e=Bn()}catch(a){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),a}global.Worker=e.Worker}else(C||x)&&(x?B=self.location.href:typeof document<"u"&&document.currentScript&&(B=document.currentScript.src),typeof r<"u"&&r&&(B=r),B.indexOf("blob:")!==0?B=B.substr(0,B.replace(/[?#].*/,"").lastIndexOf("/")+1):B="",P||(N=e=>{var a=new XMLHttpRequest;return a.open("GET",e,!1),a.send(null),a.responseText},x&&(Y=e=>{var a=new XMLHttpRequest;return a.open("GET",e,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),V=(e,a,u)=>{var p=new XMLHttpRequest;p.open("GET",e,!0),p.responseType="arraybuffer",p.onload=()=>{p.status==200||p.status==0&&p.response?a(p.response):u()},p.onerror=u,p.send(null)}));P&&typeof performance>"u"&&(global.performance=Ln().performance);var Fe=console.log.bind(console),Ne=console.error.bind(console);P&&(Fe=(...e)=>R.writeSync(1,e.join(" ")+` `),Ne=(...e)=>R.writeSync(2,e.join(" ")+` `));var me=Fe,ie=Ne;Object.assign(s,O),O=null,typeof WebAssembly!="object"&&Ie("no native wasm support detected");var re,Se,Ee=!1,se,L,_e,Me,de,Ce;function J(){var e=re.buffer;s.HEAP8=L=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAPU8=_e=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAP32=Me=new Int32Array(e),s.HEAPU32=de=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=Ce=new Float64Array(e)}var ye=16777216;if(T)re=s.wasmMemory;else if(s.wasmMemory)re=s.wasmMemory;else if(re=new WebAssembly.Memory({initial:ye/65536,maximum:65536,shared:!0}),!(re.buffer instanceof SharedArrayBuffer))throw ie("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),P&&ie("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");J(),ye=re.buffer.byteLength;var Ge=[],xe=[],Ae=[],Te=0,je=null,we=null;function Pe(){if(Te--,Te==0&&(je!==null&&(clearInterval(je),je=null),we)){var e=we;we=null,e()}}function Ie(e){throw e="Aborted("+e+")",ie(e),Ee=!0,se=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),g(e),e}var ae=e=>e.startsWith("data:application/octet-stream;base64,"),Q=e=>e.startsWith("file://"),pe;pe="ort-wasm-threaded.wasm",ae(pe)||(pe=k(pe));function Be(e){if(Y)return Y(e);throw"both async and sync fetching of the wasm failed"}function Re(e){if(C||x){if(typeof fetch=="function"&&!Q(e))return fetch(e,{credentials:"same-origin"}).then(a=>{if(!a.ok)throw"failed to load wasm binary file at '"+e+"'";return a.arrayBuffer()}).catch(()=>Be(e));if(V)return new Promise((a,u)=>{V(e,p=>a(new Uint8Array(p)),u)})}return Promise.resolve().then(()=>Be(e))}function dt(e,a,u){return Re(e).then(p=>WebAssembly.instantiate(p,a)).then(p=>p).then(u,p=>{ie(`failed to asynchronously prepare wasm: ${p}`),Ie(p)})}function At(e,a){var u=pe;return typeof WebAssembly.instantiateStreaming!="function"||ae(u)||Q(u)||P||typeof fetch!="function"?dt(u,e,a):fetch(u,{credentials:"same-origin"}).then(p=>WebAssembly.instantiateStreaming(p,e).then(a,function(_){return ie(`wasm streaming compile failed: ${_}`),ie("falling back to ArrayBuffer instantiation"),dt(u,e,a)}))}var Le,Ke={921388:(e,a,u,p)=>{if(typeof s>"u"||!s.cb)return 1;if(e=rt(e>>>0),e.startsWith("./")&&(e=e.substring(2)),e=s.cb.get(e),!e)return 2;if(a>>>=0,u>>>=0,p>>>=0,a+u>e.byteLength)return 3;try{return f().set(e.subarray(a,a+u),p>>>0),0}catch{return 4}}};function We(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var et=e=>{e.terminate(),e.onmessage=()=>{}},tt=e=>{F.Pa.length==0&&(ht(),F.Ya(F.Pa[0]));var a=F.Pa.pop();if(!a)return 6;F.Qa.push(a),F.Ma[e.Oa]=a,a.Oa=e.Oa;var u={cmd:"run",start_routine:e.kb,arg:e.hb,pthread_ptr:e.Oa};return P&&a.unref(),a.postMessage(u,e.qb),0},ze=0,pt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,mt=(e,a,u)=>{a>>>=0;var p=a+u;for(u=a;e[u]&&!(u>=p);)++u;if(16<u-a&&e.buffer&&pt)return pt.decode(e.buffer instanceof SharedArrayBuffer?e.slice(a,u):e.subarray(a,u));for(p="";a<u;){var _=e[a++];if(_&128){var A=e[a++]&63;if((_&224)==192)p+=String.fromCharCode((_&31)<<6|A);else{var M=e[a++]&63;_=(_&240)==224?(_&15)<<12|A<<6|M:(_&7)<<18|A<<12|M<<6|e[a++]&63,65536>_?p+=String.fromCharCode(_):(_-=65536,p+=String.fromCharCode(55296|_>>10,56320|_&1023))}}else p+=String.fromCharCode(_)}return p},rt=(e,a)=>(e>>>=0)?mt(f(),e,a):"",Tt=e=>{var a=tr();return e=e(),Rt(a),e};function z(e,a){var u=arguments.length-2,p=arguments;return Tt(()=>{for(var _=rr(8*u),A=_>>>3,M=0;M<u;M++){var ee=p[2+M];d()[A+M>>>0]=ee}return Yr(e,u,_,a)})}function I(e){if(T)return z(0,1,e);se=e,0<ze||(F.lb(),s.onExit?.(e),Ee=!0),v(e,new We(e))}var nt=e=>{if(se=e,T)throw Ct(e),"unwind";I(e)};function St(){for(var e=s.numThreads;e--;)ht();Ge.unshift(()=>{Te++,Mt(()=>Pe())})}function ht(){var e=k("ort-wasm-threaded.worker.js");e=new Worker(e),F.Pa.push(e)}function Mt(e){T?e():Promise.all(F.Pa.map(F.Ya)).then(e)}var F={Pa:[],Qa:[],bb:[],Ma:{},Wa(){T?(F.receiveObjectTransfer=F.jb,F.threadInitTLS=F.ab,F.setExitStatus=F.$a):St()},$a:e=>se=e,tb:["$terminateWorker"],lb:()=>{for(var e of F.Qa)et(e);for(e of F.Pa)et(e);F.Pa=[],F.Qa=[],F.Ma=[]},Za:e=>{var a=e.Oa;delete F.Ma[a],F.Pa.push(e),F.Qa.splice(F.Qa.indexOf(e),1),e.Oa=0,Kt(a)},jb(){},ab(){F.bb.forEach(e=>e())},Ya:e=>new Promise(a=>{e.onmessage=A=>{A=A.data;var M=A.cmd;if(A.targetThread&&A.targetThread!=Pt()){var ee=F.Ma[A.targetThread];ee?ee.postMessage(A,A.transferList):ie(`Internal error! Worker sent a message "${M}" to target pthread ${A.targetThread}, but that thread no longer exists!`)}else M==="checkMailbox"?xt():M==="spawnThread"?tt(A):M==="cleanupThread"?F.Za(F.Ma[A.thread]):M==="killThread"?(A=A.thread,M=F.Ma[A],delete F.Ma[A],et(M),Kt(A),F.Qa.splice(F.Qa.indexOf(M),1),M.Oa=0):M==="cancelThread"?F.Ma[A.thread].postMessage({cmd:"cancel"}):M==="loaded"?(e.loaded=!0,P&&!e.Oa&&e.unref(),a(e)):M==="alert"?alert(`Thread ${A.threadId}: ${A.text}`):A.target==="setimmediate"?e.postMessage(A):M==="callHandler"?s[A.handler](...A.args):M&&ie(`worker sent an unknown command ${M}`)},e.onerror=A=>{throw ie(`worker sent an error! ${A.filename}:${A.lineno}: ${A.message}`),A},P&&(e.on("message",A=>e.onmessage({data:A})),e.on("error",A=>e.onerror(A)));var u=[],p=["onExit"],_;for(_ of p)s.hasOwnProperty(_)&&u.push(_);e.postMessage({cmd:"load",handlers:u,urlOrBlob:s.mainScriptUrlOrBlob||r,wasmMemory:re,wasmModule:Se})})};s.PThread=F;var Ye=e=>{for(;0<e.length;)e.shift()(s)};s.establishStackSpace=()=>{var e=Pt(),a=m()[e+52>>>2>>>0];e=m()[e+56>>>2>>>0],Xr(a,a-e),Rt(a)};function Ct(e){if(T)return z(1,0,e);nt(e)}var ke=[],gt;s.invokeEntryPoint=(e,a)=>{var u=ke[e];u||(e>=ke.length&&(ke.length=e+1),ke[e]=u=gt.get(e)),e=u(a),0<ze?F.$a(e):er(e)};function o(e){this.Va=e-24,this.gb=function(a){m()[this.Va+4>>>2>>>0]=a},this.fb=function(a){m()[this.Va+8>>>2>>>0]=a},this.Wa=function(a,u){this.eb(),this.gb(a),this.fb(u)},this.eb=function(){m()[this.Va+16>>>2>>>0]=0}}var l=0,c=0;function b(e,a,u,p){return T?z(2,1,e,a,u,p):S(e,a,u,p)}function S(e,a,u,p){if(e>>>=0,a>>>=0,u>>>=0,p>>>=0,typeof SharedArrayBuffer>"u")return ie("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var _=[];return T&&_.length===0?b(e,a,u,p):(e={kb:u,Oa:e,hb:p,qb:_},T?(e.sb="spawnThread",postMessage(e,_),0):tt(e))}function D(e,a,u){return T?z(3,1,e,a,u):0}function W(e,a){if(T)return z(4,1,e,a)}var oe=e=>{for(var a=0,u=0;u<e.length;++u){var p=e.charCodeAt(u);127>=p?a++:2047>=p?a+=2:55296<=p&&57343>=p?(a+=4,++u):a+=3}return a},he=(e,a,u,p)=>{if(u>>>=0,!(0<p))return 0;var _=u;p=u+p-1;for(var A=0;A<e.length;++A){var M=e.charCodeAt(A);if(55296<=M&&57343>=M){var ee=e.charCodeAt(++A);M=65536+((M&1023)<<10)|ee&1023}if(127>=M){if(u>=p)break;a[u++>>>0]=M}else{if(2047>=M){if(u+1>=p)break;a[u++>>>0]=192|M>>6}else{if(65535>=M){if(u+2>=p)break;a[u++>>>0]=224|M>>12}else{if(u+3>=p)break;a[u++>>>0]=240|M>>18,a[u++>>>0]=128|M>>12&63}a[u++>>>0]=128|M>>6&63}a[u++>>>0]=128|M&63}}return a[u>>>0]=0,u-_},fe=(e,a,u)=>he(e,f(),a,u);function le(e,a){if(T)return z(5,1,e,a)}function yt(e,a,u){if(T)return z(6,1,e,a,u)}function wt(e,a,u){return T?z(7,1,e,a,u):0}function y(e,a){if(T)return z(8,1,e,a)}function $(e,a,u){if(T)return z(9,1,e,a,u)}function q(e,a,u,p){if(T)return z(10,1,e,a,u,p)}function De(e,a,u,p){if(T)return z(11,1,e,a,u,p)}function bt(e,a,u,p){if(T)return z(12,1,e,a,u,p)}function Tr(e){if(T)return z(13,1,e)}function Sr(e,a){if(T)return z(14,1,e,a)}function Mr(e,a,u){if(T)return z(15,1,e,a,u)}function Vt(e){e>>>=0,typeof Atomics.rb=="function"&&(Atomics.rb(i(),e>>>2,e).value.then(xt),e+=128,Atomics.store(i(),e>>>2,1))}s.__emscripten_thread_mailbox_await=Vt;var xt=()=>{var e=Pt();if(e&&(Vt(e),e=qr,!Ee))try{if(e(),!(0<ze))try{T?er(se):nt(se)}catch(a){a instanceof We||a=="unwind"||v(1,a)}}catch(a){a instanceof We||a=="unwind"||v(1,a)}};s.checkMailbox=xt;var Xt=[],at=e=>e%4===0&&(e%100!==0||e%400===0),Cr=[0,31,60,91,121,152,182,213,244,274,305,335],xr=[0,31,59,90,120,151,181,212,243,273,304,334];function Pr(e,a,u,p,_,A,M,ee){return T?z(16,1,e,a,u,p,_,A,M,ee):-52}function Rr(e,a,u,p,_,A,M){if(T)return z(17,1,e,a,u,p,_,A,M)}var Dr=e=>{var a=oe(e)+1,u=jr(a);return u&&fe(e,u,a),u},Jt=[],Qt={},Ur=()=>{if(!Zt){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:E||"./this.program"},a;for(a in Qt)Qt[a]===void 0?delete e[a]:e[a]=Qt[a];var u=[];for(a in e)u.push(`${a}=${e[a]}`);Zt=u}return Zt},Zt;function Fr(e,a){if(T)return z(18,1,e,a);e>>>=0,a>>>=0;var u=0;return Ur().forEach((p,_)=>{var A=a+u;for(_=m()[e+4*_>>>2>>>0]=A,A=0;A<p.length;++A)n()[_++>>>0>>>0]=p.charCodeAt(A);n()[_>>>0>>>0]=0,u+=p.length+1}),0}function Ir(e,a){if(T)return z(19,1,e,a);e>>>=0,a>>>=0;var u=Ur();m()[e>>>2>>>0]=u.length;var p=0;