onnxruntime-web
Version:
A Javascript library for running ONNX models on browsers
8 lines • 72.8 kB
JavaScript
/*!
* ONNX Runtime Web v1.24.3
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
var Jt=Object.defineProperty;var Za=Object.getOwnPropertyDescriptor;var Qa=Object.getOwnPropertyNames;var Ka=Object.prototype.hasOwnProperty;var qt=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var N=(n,t)=>()=>(n&&(t=n(n=0)),t);var it=(n,t)=>{for(var a in t)Jt(n,a,{get:t[a],enumerable:!0})},es=(n,t,a,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qa(t))!Ka.call(n,o)&&o!==a&&Jt(n,o,{get:()=>t[o],enumerable:!(u=Za(t,o))||u.enumerable});return n};var Xt=n=>es(Jt({},"__esModule",{value:!0}),n);var ut,Be,Je,ts,dr,Zt=N(()=>{"use strict";ut=new Map,Be=[],Je=(n,t,a)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let u=ut.get(n);if(u===void 0)ut.set(n,{backend:t,priority:a});else{if(u.priority>a)return;if(u.priority===a&&u.backend!==t)throw new Error(`cannot register backend "${n}" using priority ${a}`)}if(a>=0){let o=Be.indexOf(n);o!==-1&&Be.splice(o,1);for(let d=0;d<Be.length;d++)if(ut.get(Be[d]).priority<=a){Be.splice(d,0,n);return}Be.push(n)}return}throw new TypeError("not a valid backend")},ts=async n=>{let t=ut.get(n);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let a=!!t.initPromise;try{return a||(t.initPromise=t.backend.init(n)),await t.initPromise,t.initialized=!0,t.backend}catch(u){return a||(t.error=`${u}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},dr=async n=>{let t=n.executionProviders||[],a=t.map(m=>typeof m=="string"?m:m.name),u=a.length===0?Be:a,o,d=[],c=new Set;for(let m of u){let h=await ts(m);typeof h=="string"?d.push({name:m,err:h}):(o||(o=h),o===h&&c.add(m))}if(!o)throw new Error(`no available backend found. ERR: ${d.map(m=>`[${m.name}] ${m.err}`).join(", ")}`);for(let{name:m,err:h}of d)a.includes(m)&&console.warn(`removing requested execution provider "${m}" from session options because it is not available: ${h}`);let l=t.filter(m=>c.has(typeof m=="string"?m:m.name));return[o,new Proxy(n,{get:(m,h)=>h==="executionProviders"?l:Reflect.get(m,h)})]}});var pr=N(()=>{"use strict";Zt()});var mr,hr=N(()=>{"use strict";mr="1.24.3"});var wr,J,Qt=N(()=>{"use strict";hr();wr="warning",J={wasm:{},webgl:{},webgpu:{},versions:{common:mr},set logLevel(n){if(n!==void 0){if(typeof n!="string"||["verbose","info","warning","error","fatal"].indexOf(n)===-1)throw new Error(`Unsupported logging level: ${n}`);wr=n}},get logLevel(){return wr}};Object.defineProperty(J,"logLevel",{enumerable:!0})});var Y,br=N(()=>{"use strict";Qt();Y=J});var yr,gr,Er=N(()=>{"use strict";yr=(n,t)=>{let a=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);a.width=n.dims[3],a.height=n.dims[2];let u=a.getContext("2d");if(u!=null){let o,d;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=n.dims[2],d=n.dims[3]):(o=n.dims[3],d=n.dims[2]);let c=t?.format!==void 0?t.format:"RGB",l=t?.norm,m,h;l===void 0||l.mean===void 0?m=[255,255,255,255]:typeof l.mean=="number"?m=[l.mean,l.mean,l.mean,l.mean]:(m=[l.mean[0],l.mean[1],l.mean[2],0],l.mean[3]!==void 0&&(m[3]=l.mean[3])),l===void 0||l.bias===void 0?h=[0,0,0,0]:typeof l.bias=="number"?h=[l.bias,l.bias,l.bias,l.bias]:(h=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(h[3]=l.bias[3]));let g=d*o,b=0,y=g,T=g*2,I=-1;c==="RGBA"?(b=0,y=g,T=g*2,I=g*3):c==="RGB"?(b=0,y=g,T=g*2):c==="RBG"&&(b=0,T=g,y=g*2);for(let U=0;U<d;U++)for(let z=0;z<o;z++){let v=(n.data[b++]-h[0])*m[0],O=(n.data[y++]-h[1])*m[1],F=(n.data[T++]-h[2])*m[2],D=I===-1?255:(n.data[I++]-h[3])*m[3];u.fillStyle="rgba("+v+","+O+","+F+","+D+")",u.fillRect(z,U,1,1)}if("toDataURL"in a)return a.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},gr=(n,t)=>{let a=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),u;if(a!=null){let o,d,c;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(o=n.dims[2],d=n.dims[1],c=n.dims[3]):(o=n.dims[3],d=n.dims[2],c=n.dims[1]);let l=t!==void 0&&t.format!==void 0?t.format:"RGB",m=t?.norm,h,g;m===void 0||m.mean===void 0?h=[255,255,255,255]:typeof m.mean=="number"?h=[m.mean,m.mean,m.mean,m.mean]:(h=[m.mean[0],m.mean[1],m.mean[2],255],m.mean[3]!==void 0&&(h[3]=m.mean[3])),m===void 0||m.bias===void 0?g=[0,0,0,0]:typeof m.bias=="number"?g=[m.bias,m.bias,m.bias,m.bias]:(g=[m.bias[0],m.bias[1],m.bias[2],0],m.bias[3]!==void 0&&(g[3]=m.bias[3]));let b=d*o;if(t!==void 0&&(t.format!==void 0&&c===4&&t.format!=="RGBA"||c===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let y=4,T=0,I=1,U=2,z=3,v=0,O=b,F=b*2,D=-1;l==="RGBA"?(v=0,O=b,F=b*2,D=b*3):l==="RGB"?(v=0,O=b,F=b*2):l==="RBG"&&(v=0,F=b,O=b*2),u=a.createImageData(o,d);for(let k=0;k<d*o;T+=y,I+=y,U+=y,z+=y,k++)u.data[T]=(n.data[v++]-g[0])*h[0],u.data[I]=(n.data[O++]-g[1])*h[1],u.data[U]=(n.data[F++]-g[2])*h[2],u.data[z]=D===-1?255:(n.data[D++]-g[3])*h[3]}else throw new Error("Can not access image data");return u}});var Kt,Tr,Sr,vr,Or,Ar,Ir=N(()=>{"use strict";ft();Kt=(n,t)=>{if(n===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:a,width:u}=t,o=t.norm??{mean:255,bias:0},d,c;typeof o.mean=="number"?d=[o.mean,o.mean,o.mean,o.mean]:d=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?c=[o.bias,o.bias,o.bias,o.bias]:c=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let l=t.format!==void 0?t.format:"RGBA",m=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",h=a*u,g=m==="RGBA"?new Float32Array(h*4):new Float32Array(h*3),b=4,y=0,T=1,I=2,U=3,z=0,v=h,O=h*2,F=-1;l==="RGB"&&(b=3,y=0,T=1,I=2,U=-1),m==="RGBA"?F=h*3:m==="RBG"?(z=0,O=h,v=h*2):m==="BGR"&&(O=0,v=h,z=h*2);for(let k=0;k<h;k++,y+=b,I+=b,T+=b,U+=b)g[z++]=(n[y]+c[0])/d[0],g[v++]=(n[T]+c[1])/d[1],g[O++]=(n[I]+c[2])/d[2],F!==-1&&U!==-1&&(g[F++]=(n[U]+c[3])/d[3]);return m==="RGBA"?new Z("float32",g,[1,4,a,u]):new Z("float32",g,[1,3,a,u])},Tr=async(n,t)=>{let a=typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement,u=typeof ImageData<"u"&&n instanceof ImageData,o=typeof ImageBitmap<"u"&&n instanceof ImageBitmap,d=typeof n=="string",c,l=t??{},m=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},h=g=>typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement||g instanceof OffscreenCanvas?g.getContext("2d"):null;if(a){let g=m();g.width=n.width,g.height=n.height;let b=h(g);if(b!=null){let y=n.height,T=n.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(y=t.resizedHeight,T=t.resizedWidth),t!==void 0){if(l=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");l.tensorFormat="RGBA",l.height=y,l.width=T}else l.tensorFormat="RGBA",l.height=y,l.width=T;b.drawImage(n,0,0),c=b.getImageData(0,0,T,y).data}else throw new Error("Can not access image data")}else if(u){let g,b;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(g=t.resizedHeight,b=t.resizedWidth):(g=n.height,b=n.width),t!==void 0&&(l=t),l.format="RGBA",l.height=g,l.width=b,t!==void 0){let y=m();y.width=b,y.height=g;let T=h(y);if(T!=null)T.putImageData(n,0,0),c=T.getImageData(0,0,b,g).data;else throw new Error("Can not access image data")}else c=n.data}else if(o){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let g=m();g.width=n.width,g.height=n.height;let b=h(g);if(b!=null){let y=n.height,T=n.width;return b.drawImage(n,0,0,T,y),c=b.getImageData(0,0,T,y).data,l.height=y,l.width=T,Kt(c,l)}else throw new Error("Can not access image data")}else{if(d)return new Promise((g,b)=>{let y=m(),T=h(y);if(!n||!T)return b();let I=new Image;I.crossOrigin="Anonymous",I.src=n,I.onload=()=>{y.width=I.width,y.height=I.height,T.drawImage(I,0,0,y.width,y.height);let U=T.getImageData(0,0,y.width,y.height);l.height=y.height,l.width=y.width,g(Kt(U.data,l))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(c!==void 0)return Kt(c,l);throw new Error("Input data provided is not supported - aborted tensor creation")},Sr=(n,t)=>{let{width:a,height:u,download:o,dispose:d}=t,c=[1,u,a,4];return new Z({location:"texture",type:"float32",texture:n,dims:c,download:o,dispose:d})},vr=(n,t)=>{let{dataType:a,dims:u,download:o,dispose:d}=t;return new Z({location:"gpu-buffer",type:a??"float32",gpuBuffer:n,dims:u,download:o,dispose:d})},Or=(n,t)=>{let{dataType:a,dims:u,download:o,dispose:d}=t;return new Z({location:"ml-tensor",type:a??"float32",mlTensor:n,dims:u,download:o,dispose:d})},Ar=(n,t,a)=>new Z({location:"cpu-pinned",type:n,data:t,dims:a??[t.length]})});var Le,qe,Br,Lr,Pr=N(()=>{"use strict";Le=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),qe=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Br=!1,Lr=()=>{if(!Br){Br=!0;let n=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,a=globalThis.Float16Array,u=typeof a<"u"&&a.from;n&&(Le.set("int64",BigInt64Array),qe.set(BigInt64Array,"int64")),t&&(Le.set("uint64",BigUint64Array),qe.set(BigUint64Array,"uint64")),u?(Le.set("float16",a),qe.set(a,"float16")):Le.set("float16",Uint16Array)}}});var Dr,_r,Ur=N(()=>{"use strict";ft();Dr=n=>{let t=1;for(let a=0;a<n.length;a++){let u=n[a];if(typeof u!="number"||!Number.isSafeInteger(u))throw new TypeError(`dims[${a}] must be an integer, got: ${u}`);if(u<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${u}`);t*=u}return t},_r=(n,t)=>{switch(n.location){case"cpu":return new Z(n.type,n.data,t);case"cpu-pinned":return new Z({location:"cpu-pinned",data:n.data,type:n.type,dims:t});case"texture":return new Z({location:"texture",texture:n.texture,type:n.type,dims:t});case"gpu-buffer":return new Z({location:"gpu-buffer",gpuBuffer:n.gpuBuffer,type:n.type,dims:t});case"ml-tensor":return new Z({location:"ml-tensor",mlTensor:n.mlTensor,type:n.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${n.location} is not supported`)}}});var Z,ft=N(()=>{"use strict";Er();Ir();Pr();Ur();Z=class{constructor(t,a,u){Lr();let o,d;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,o=t.type,d=t.dims,t.location){case"cpu-pinned":{let l=Le.get(o);if(!l)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(t.data instanceof l))throw new TypeError(`buffer should be of type ${l.name}`);this.cpuData=t.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint64"&&o!=="int8"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let l,m;if(typeof t=="string")if(o=t,m=u,t==="string"){if(!Array.isArray(a))throw new TypeError("A string tensor's data must be a string array.");l=a}else{let h=Le.get(t);if(h===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(a)){if(t==="float16"&&h===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${h.name} as data.`);t==="uint64"||t==="int64"?l=h.from(a,BigInt):l=h.from(a)}else if(a instanceof h)l=a;else if(a instanceof Uint8ClampedArray)if(t==="uint8")l=Uint8Array.from(a);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&a instanceof Uint16Array&&h!==Uint16Array)l=new globalThis.Float16Array(a.buffer,a.byteOffset,a.length);else throw new TypeError(`A ${o} tensor's data must be type of ${h}`)}else if(m=a,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let h=typeof t[0];if(h==="string")o="string",l=t;else if(h==="boolean")o="bool",l=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${h}.`)}else if(t instanceof Uint8ClampedArray)o="uint8",l=Uint8Array.from(t);else{let h=qe.get(t.constructor);if(h===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);o=h,l=t}if(m===void 0)m=[l.length];else if(!Array.isArray(m))throw new TypeError("A tensor's dims must be a number array");d=m,this.cpuData=l,this.dataLocation="cpu"}let c=Dr(d);if(this.cpuData&&c!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(c/2)===this.cpuData.length))throw new Error(`Tensor's size(${c}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=d,this.size=c}static async fromImage(t,a){return Tr(t,a)}static fromTexture(t,a){return Sr(t,a)}static fromGpuBuffer(t,a){return vr(t,a)}static fromMLTensor(t,a){return Or(t,a)}static fromPinnedBuffer(t,a,u){return Ar(t,a,u)}toDataURL(t){return yr(this,t)}toImageData(t){return gr(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}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{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 a=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=a,t&&this.disposer&&(this.disposer(),this.disposer=void 0),a}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.mlTensorData=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 _r(this,t)}}});var de,en=N(()=>{"use strict";ft();de=Z});var xr,Mr,Pe,De,_e,Ue,tn=N(()=>{"use strict";Qt();xr=(n,t)=>{(typeof J.trace>"u"?!J.wasm.trace:!J.trace)||console.timeStamp(`${n}::ORT::${t}`)},Mr=(n,t)=>{let a=new Error().stack?.split(/\r\n|\r|\n/g)||[],u=!1;for(let o=0;o<a.length;o++){if(u&&!a[o].includes("TRACE_FUNC")){let d=`FUNC_${n}::${a[o].trim().split(" ")[1]}`;t&&(d+=`::${t}`),xr("CPU",d);return}a[o].includes("TRACE_FUNC")&&(u=!0)}},Pe=n=>{(typeof J.trace>"u"?!J.wasm.trace:!J.trace)||Mr("BEGIN",n)},De=n=>{(typeof J.trace>"u"?!J.wasm.trace:!J.trace)||Mr("END",n)},_e=n=>{(typeof J.trace>"u"?!J.wasm.trace:!J.trace)||console.time(`ORT::${n}`)},Ue=n=>{(typeof J.trace>"u"?!J.wasm.trace:!J.trace)||console.timeEnd(`ORT::${n}`)}});var ct,Cr=N(()=>{"use strict";Zt();en();tn();ct=class n{constructor(t){this.handler=t}async run(t,a,u){Pe(),_e("InferenceSession.run");let o={},d={};if(typeof t!="object"||t===null||t instanceof de||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let c=!0;if(typeof a=="object"){if(a===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(a instanceof de)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(a)){if(a.length===0)throw new TypeError("'fetches' cannot be an empty array.");c=!1;for(let h of a){if(typeof h!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(h)===-1)throw new RangeError(`'fetches' contains invalid output name: ${h}.`);o[h]=null}if(typeof u=="object"&&u!==null)d=u;else if(typeof u<"u")throw new TypeError("'options' must be an object.")}else{let h=!1,g=Object.getOwnPropertyNames(a);for(let b of this.outputNames)if(g.indexOf(b)!==-1){let y=a[b];(y===null||y instanceof de)&&(h=!0,c=!1,o[b]=y)}if(h){if(typeof u=="object"&&u!==null)d=u;else if(typeof u<"u")throw new TypeError("'options' must be an object.")}else d=a}}else if(typeof a<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let h of this.inputNames)if(typeof t[h]>"u")throw new Error(`input '${h}' is missing in 'feeds'.`);if(c)for(let h of this.outputNames)o[h]=null;let l=await this.handler.run(t,o,d),m={};for(let h in l)if(Object.hasOwnProperty.call(l,h)){let g=l[h];g instanceof de?m[h]=g:m[h]=new de(g.type,g.data,g.dims)}return Ue("InferenceSession.run"),De(),m}async release(){return this.handler.dispose()}static async create(t,a,u,o){Pe(),_e("InferenceSession.create");let d,c={};if(typeof t=="string"){if(d=t,typeof a=="object"&&a!==null)c=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(d=t,typeof a=="object"&&a!==null)c=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let g=t,b=0,y=t.byteLength;if(typeof a=="object"&&a!==null)c=a;else if(typeof a=="number"){if(b=a,!Number.isSafeInteger(b))throw new RangeError("'byteOffset' must be an integer.");if(b<0||b>=g.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${g.byteLength}).`);if(y=t.byteLength-b,typeof u=="number"){if(y=u,!Number.isSafeInteger(y))throw new RangeError("'byteLength' must be an integer.");if(y<=0||b+y>g.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${g.byteLength-b}].`);if(typeof o=="object"&&o!==null)c=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof u<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof a<"u")throw new TypeError("'options' must be an object.");d=new Uint8Array(g,b,y)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[l,m]=await dr(c),h=await l.createInferenceSessionHandler(d,m);return Ue("InferenceSession.create"),De(),new n(h)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}});var ns,Rr=N(()=>{"use strict";Cr();ns=ct});var Fr=N(()=>{"use strict"});var Nr=N(()=>{"use strict"});var kr=N(()=>{"use strict"});var Wr=N(()=>{"use strict"});var nn={};it(nn,{InferenceSession:()=>ns,TRACE:()=>xr,TRACE_EVENT_BEGIN:()=>_e,TRACE_EVENT_END:()=>Ue,TRACE_FUNC_BEGIN:()=>Pe,TRACE_FUNC_END:()=>De,Tensor:()=>de,env:()=>Y,registerBackend:()=>Je});var Te=N(()=>{"use strict";pr();br();Rr();en();Fr();Nr();tn();kr();Wr()});var lt=N(()=>{"use strict"});var Hr={};it(Hr,{default:()=>rs});var $r,zr,rs,jr=N(()=>{"use strict";rn();xe();dt();$r="ort-wasm-proxy-worker",zr=globalThis.self?.name===$r;zr&&(self.onmessage=n=>{let{type:t,in:a}=n.data;try{switch(t){case"init-wasm":pt(a.wasm).then(()=>{mt(a).then(()=>{postMessage({type:t})},u=>{postMessage({type:t,err:u})})},u=>{postMessage({type:t,err:u})});break;case"init-ep":{let{epName:u,env:o}=a;ht(o,u).then(()=>{postMessage({type:t})},d=>{postMessage({type:t,err:d})});break}case"copy-from":{let{buffer:u}=a,o=Xe(u);postMessage({type:t,out:o});break}case"create":{let{model:u,options:o}=a;wt(u,o).then(d=>{postMessage({type:t,out:d})},d=>{postMessage({type:t,err:d})});break}case"release":bt(a),postMessage({type:t});break;case"run":{let{sessionId:u,inputIndices:o,inputs:d,outputIndices:c,options:l}=a;yt(u,o,d,c,new Array(c.length).fill(null),l).then(m=>{m.some(h=>h[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:m},Et([...d,...m]))},m=>{postMessage({type:t,err:m})});break}case"end-profiling":gt(a),postMessage({type:t});break;default:}}catch(u){postMessage({type:t,err:u})}});rs=zr?null:n=>new Worker(n??oe,{type:"module",name:$r})});var Yr={};it(Yr,{default:()=>os});async function Vr(n={}){var t=n,a=!!globalThis.window,u=!!globalThis.WorkerGlobalScope,o=u&&self.name?.startsWith("em-pthread");t.mountExternalData=(e,r)=>{e.startsWith("./")&&(e=e.substring(2)),(t.Sb||(t.Sb=new Map)).set(e,r)},t.unmountExternalData=()=>{delete t.Sb},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,kc:!0}).buffer.constructor;var d,c,l=(e,r)=>{throw r},m=import.meta.url,h="";if(a||u){try{h=new URL(".",m).href}catch{}u&&(c=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),d=async e=>{if(k(e))return new Promise((i,s)=>{var f=new XMLHttpRequest;f.open("GET",e,!0),f.responseType="arraybuffer",f.onload=()=>{f.status==200||f.status==0&&f.response?i(f.response):s(f.status)},f.onerror=s,f.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw Error(r.status+" : "+r.url)}}var g,b,y,T,I,U,z=console.log.bind(console),v=console.error.bind(console),O=z,F=v,D=!1,k=e=>e.startsWith("file://");function w(){ge.buffer!=j.buffer&&ee()}if(o){let e=function(r){try{var i=r.data,s=i.Qb;if(s==="load"){let f=[];self.onmessage=p=>f.push(p),U=()=>{postMessage({Qb:"loaded"});for(let p of f)e(p);self.onmessage=e};for(let p of i.$b)t[p]&&!t[p].proxy||(t[p]=(...E)=>{postMessage({Qb:"callHandler",Zb:p,args:E})},p=="print"&&(O=t[p]),p=="printErr"&&(F=t[p]));ge=i.ec,ee(),b=i.fc,Ut(),st()}else if(s==="run"){(function(f){var p=(w(),W)[f+52>>>2>>>0];f=(w(),W)[f+56>>>2>>>0],sr(p,p-f),P(p)})(i.Pb),zt(i.Pb,0,0,1,0,0),wn(),Ft(i.Pb),Q||=!0;try{Ao(i.cc,i.Ub)}catch(f){if(f!="unwind")throw f}}else i.target!=="setimmediate"&&(s==="checkMailbox"?Q&&nt():s&&(F(`worker: received unknown command ${s}`),F(i)))}catch(f){throw tr(),f}};var vs=e,Q=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var j,ne,pe,B,W,re,me,A,K,He=!1;function ee(){var e=ge.buffer;t.HEAP8=j=new Int8Array(e),pe=new Int16Array(e),t.HEAPU8=ne=new Uint8Array(e),new Uint16Array(e),t.HEAP32=B=new Int32Array(e),t.HEAPU32=W=new Uint32Array(e),re=new Float32Array(e),me=new Float64Array(e),A=new BigInt64Array(e),new BigUint64Array(e)}function he(){He=!0,o?U():Ee.Ua()}function H(e){throw F(e="Aborted("+e+")"),D=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),I?.(e),e}function q(){return{a:{S:fa,f:Io,w:Bo,e:Lo,j:Po,g:Do,T:_o,b:Uo,G:xo,ua:vn,k:Mo,K:In,Ka:Bn,qa:Ln,sa:Pn,La:Dn,Ia:_n,Ba:Un,Ha:xn,Z:Mn,ra:Cn,oa:Rn,Ja:Fn,pa:Nn,Qa:Co,Ea:Ro,ma:No,va:ko,ja:Wo,U:Go,Da:Ft,Na:$o,ya:zo,za:Ho,Aa:jo,wa:$n,xa:zn,ka:Hn,Sa:Yo,Pa:Xo,W:Zo,V:Qo,Oa:Jo,F:Ko,Ma:ea,na:ta,u:Vo,H:na,R:ot,la:oa,da:ra,Ta:aa,Fa:Yn,Ga:Jn,ta:ye,L:qn,Y:Xn,Ca:Zn,X:Qn,$:Va,M:ka,aa:ja,N:Na,v:Pa,c:pa,m:la,n:ca,r:va,ea:Ca,x:Ia,o:ha,O:Ra,D:Wa,I:Ma,ba:Ha,ca:za,Q:Da,P:xa,fa:_a,z:Ba,E:Fa,d:ma,q:wa,i:da,_:Ya,l:ya,p:ga,s:ba,t:Ea,y:Oa,ga:La,B:Ga,J:Aa,C:$a,ha:Sa,ia:Ta,A:Ua,h:ia,a:ge,Ra:V}}}async function Ut(){function e(s,f){return Ee=s.exports,Ee=function(){var p=Ee,E=M=>()=>M()>>>0,S=M=>R=>M(R)>>>0;return(p=Object.assign({},p)).tb=E(p.tb),p.vb=S(p.vb),p.Jb=S(p.Jb),p.Kb=E(p.Kb),p.Ob=S(p.Ob),p}(),mn.push(Ee.wb),s=Ee,t._OrtInit=s.Va,t._OrtGetLastError=s.Wa,t._OrtCreateSessionOptions=s.Xa,t._OrtAppendExecutionProvider=s.Ya,t._OrtAddFreeDimensionOverride=s.Za,t._OrtAddSessionConfigEntry=s._a,t._OrtReleaseSessionOptions=s.$a,t._OrtCreateSession=s.ab,t._OrtReleaseSession=s.bb,t._OrtGetInputOutputCount=s.cb,t._OrtGetInputOutputMetadata=s.db,t._OrtFree=s.eb,t._OrtCreateTensor=s.fb,t._OrtGetTensorData=s.gb,t._OrtReleaseTensor=s.hb,t._OrtCreateRunOptions=s.ib,t._OrtAddRunConfigEntry=s.jb,t._OrtReleaseRunOptions=s.kb,t._OrtCreateBinding=s.lb,t._OrtBindInput=s.mb,t._OrtBindOutput=s.nb,t._OrtClearBoundOutputs=s.ob,t._OrtReleaseBinding=s.pb,t._OrtRunWithBinding=s.qb,t._OrtRun=s.rb,t._OrtEndProfiling=s.sb,at=s.tb,Kn=t._free=s.ub,er=t._malloc=s.vb,zt=s.yb,tr=s.zb,nr=s.Ab,rr=s.Bb,Ht=s.Cb,or=s.Db,ar=s.Eb,x=s.Fb,Ye=s.Gb,sr=s.Hb,P=s.Ib,jt=s.Jb,_=s.Kb,ir=s.Lb,Vt=s.Mb,ur=s.Nb,fr=s.Ob,cr=s.xb,b=f,Ee}var r,i=q();return t.instantiateWasm?new Promise(s=>{t.instantiateWasm(i,(f,p)=>{s(e(f,p))})}):o?e(new WebAssembly.Instance(b,q()),b):(K??=t.locateFile?t.locateFile?t.locateFile("ort-wasm-simd-threaded.wasm",h):h+"ort-wasm-simd-threaded.wasm":new URL("ort-wasm-simd-threaded.wasm",import.meta.url).href,r=await async function(s){var f=K;if(!g&&!k(f))try{var p=fetch(f,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(p,s)}catch(E){F(`wasm streaming compile failed: ${E}`),F("falling back to ArrayBuffer instantiation")}return async function(E,S){try{var M=await async function(R){if(!g)try{var X=await d(R);return new Uint8Array(X)}catch{}if(R==K&&g)R=new Uint8Array(g);else{if(!c)throw"both async and sync fetching of the wasm failed";R=c(R)}return R}(E);return await WebAssembly.instantiate(M,S)}catch(R){F(`failed to asynchronously prepare wasm: ${R}`),H(R)}}(f,s)}(i),e(r.instance,r.module))}class Se{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var ve=e=>{e.terminate(),e.onmessage=()=>{}},je=[],Re=0,te=null,ue=e=>{ce.length==0&&(yn(),bn(ce[0]));var r=ce.pop();if(!r)return 6;Fe.push(r),Oe[e.Pb]=r,r.Pb=e.Pb;var i={Qb:"run",cc:e.bc,Ub:e.Ub,Pb:e.Pb};return r.postMessage(i,e.Yb),0},se=0,L=(e,r,...i)=>{var s,f=16*i.length,p=_(),E=jt(f),S=E>>>3;for(s of i)typeof s=="bigint"?((w(),A)[S++>>>0]=1n,(w(),A)[S++>>>0]=s):((w(),A)[S++>>>0]=0n,(w(),me)[S++>>>0]=s);return e=nr(e,0,f,E,r),P(p),e};function V(e){if(o)return L(0,1,e);if(y=e,!(0<se)){for(var r of Fe)ve(r);for(r of ce)ve(r);ce=[],Fe=[],Oe={},D=!0}l(0,new Se(e))}function fe(e){if(o)return L(1,0,e);ye(e)}var ye=e=>{if(y=e,o)throw fe(e),"unwind";V(e)},ce=[],Fe=[],mn=[],Oe={},hn=e=>{var r=e.Pb;delete Oe[r],ce.push(e),Fe.splice(Fe.indexOf(e),1),e.Pb=0,rr(r)};function wn(){mn.forEach(e=>e())}var bn=e=>new Promise(r=>{e.onmessage=f=>{var p=f.data;if(f=p.Qb,p.Tb&&p.Tb!=at()){var E=Oe[p.Tb];E?E.postMessage(p,p.Yb):F(`Internal error! Worker sent a message "${f}" to target pthread ${p.Tb}, but that thread no longer exists!`)}else f==="checkMailbox"?nt():f==="spawnThread"?ue(p):f==="cleanupThread"?Rt(()=>{hn(Oe[p.dc])}):f==="loaded"?(e.loaded=!0,r(e)):p.target==="setimmediate"?e.postMessage(p):f==="uncaughtException"?e.onerror(p.error):f==="callHandler"?t[p.Zb](...p.args):f&&F(`worker sent an unknown command ${f}`)},e.onerror=f=>{throw F(`worker sent an error! ${f.filename}:${f.lineno}: ${f.message}`),f};var i,s=[];for(i of[])t.propertyIsEnumerable(i)&&s.push(i);e.postMessage({Qb:"load",$b:s,ec:ge,fc:b})});function yn(){var e=new Worker((()=>{let r=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new r("ort.wasm.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});ce.push(e)}var ge,gn=[],C=e=>{var r=gn[e];return r||(gn[e]=r=cr.get(e)),r},Ao=(e,r)=>{se=0,e=C(e)(r),0<se?y=e:Ht(e)},et=[],tt=0;function Io(e){var r=new xt(e>>>=0);return(w(),j)[r.Rb+12>>>0]==0&&(En(r,!0),tt--),Tn(r,!1),et.push(r),fr(e)}var Ne=0,Bo=()=>{x(0,0);var e=et.pop();ir(e.Vb),Ne=0};function En(e,r){r=r?1:0,(w(),j)[e.Rb+12>>>0]=r}function Tn(e,r){r=r?1:0,(w(),j)[e.Rb+13>>>0]=r}class xt{constructor(r){this.Vb=r,this.Rb=r-24}}var Mt=e=>{var r=Ne;if(!r)return Ye(0),0;var i=new xt(r);(w(),W)[i.Rb+16>>>2>>>0]=r;var s=(w(),W)[i.Rb+4>>>2>>>0];if(!s)return Ye(0),r;for(var f of e){if(f===0||f===s)break;if(ur(f,s,i.Rb+16))return Ye(f),r}return Ye(s),r};function Lo(){return Mt([])}function Po(e){return Mt([e>>>0])}function Do(e,r,i,s){return Mt([e>>>0,r>>>0,i>>>0,s>>>0])}var _o=()=>{var e=et.pop();e||H("no exception to throw");var r=e.Vb;throw(w(),j)[e.Rb+13>>>0]==0&&(et.push(e),Tn(e,!0),En(e,!1),tt++),Vt(r),Ne=r};function Uo(e,r,i){var s=new xt(e>>>=0);throw r>>>=0,i>>>=0,(w(),W)[s.Rb+16>>>2>>>0]=0,(w(),W)[s.Rb+4>>>2>>>0]=r,(w(),W)[s.Rb+8>>>2>>>0]=i,Vt(e),tt++,Ne=e}var xo=()=>tt;function Sn(e,r,i,s){return o?L(2,1,e,r,i,s):vn(e,r,i,s)}function vn(e,r,i,s){if(e>>>=0,r>>>=0,i>>>=0,s>>>=0,!globalThis.SharedArrayBuffer)return 6;var f=[];return o&&f.length===0?Sn(e,r,i,s):(e={bc:i,Pb:e,Ub:s,Yb:f},o?(e.Qb="spawnThread",postMessage(e,f),0):ue(e))}function Mo(e){throw Ne||=e>>>0,Ne}var On=globalThis.TextDecoder&&new TextDecoder,An=(e,r=0,i,s)=>{var f=r>>>=0;if(i=f+i,s)s=i;else{for(;e[f]&&!(f>=i);)++f;s=f}if(16<s-r&&e.buffer&&On)return On.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,s):e.slice(r,s));for(f="";r<s;)if(128&(i=e[r++])){var p=63&e[r++];if((224&i)==192)f+=String.fromCharCode((31&i)<<6|p);else{var E=63&e[r++];65536>(i=(240&i)==224?(15&i)<<12|p<<6|E:(7&i)<<18|p<<12|E<<6|63&e[r++])?f+=String.fromCharCode(i):(i-=65536,f+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else f+=String.fromCharCode(i);return f},Ct=(e,r,i)=>(e>>>=0)?An((w(),ne),e,r,i):"";function In(e,r,i){return o?L(3,1,e,r,i):0}function Bn(e,r){if(o)return L(4,1,e,r)}function Ln(e,r){if(o)return L(5,1,e,r)}function Pn(e,r,i){if(o)return L(6,1,e,r,i)}function Dn(e,r,i){return o?L(7,1,e,r,i):0}function _n(e,r){if(o)return L(8,1,e,r)}function Un(e,r,i){if(o)return L(9,1,e,r,i)}function xn(e,r,i,s){if(o)return L(10,1,e,r,i,s)}function Mn(e,r,i,s){if(o)return L(11,1,e,r,i,s)}function Cn(e,r,i,s){if(o)return L(12,1,e,r,i,s)}function Rn(e){if(o)return L(13,1,e)}function Fn(e,r){if(o)return L(14,1,e,r)}function Nn(e,r,i){if(o)return L(15,1,e,r,i)}var Co=()=>H("");function Ro(e){zt(e>>>0,!u,1,!a,131072,!1),wn()}var Rt=e=>{if(!D)try{if(e(),!(0<se))try{o?at()&&Ht(y):ye(y)}catch(r){r instanceof Se||r=="unwind"||l(0,r)}}catch(r){r instanceof Se||r=="unwind"||l(0,r)}},Fo=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Ft(e){e>>>=0,Fo||(Atomics.waitAsync((w(),B),e>>>2,e).value.then(nt),e+=128,Atomics.store((w(),B),e>>>2,1))}var nt=()=>Rt(()=>{var e=at();e&&(Ft(e),ar())});function No(e,r){(e>>>=0)==r>>>0?setTimeout(nt):o?postMessage({Tb:e,Qb:"checkMailbox"}):(e=Oe[e])&&e.postMessage({Qb:"checkMailbox"})}var Nt=[];function ko(e,r,i,s,f){for(r>>>=0,f>>>=0,Nt.length=0,i=f>>>3,s=f+s>>>3;i<s;){var p;p=(w(),A)[i++>>>0]?(w(),A)[i++>>>0]:(w(),me)[i++>>>0],Nt.push(p)}return(r?lr[r]:ua[e])(...Nt)}var Wo=()=>{se=0};function Go(e){e>>>=0,o?postMessage({Qb:"cleanupThread",dc:e}):hn(Oe[e])}function $o(e){}function zo(e,r){e=-9007199254740992>e||9007199254740992<e?NaN:Number(e),r>>>=0,e=new Date(1e3*e),(w(),B)[r>>>2>>>0]=e.getUTCSeconds(),(w(),B)[r+4>>>2>>>0]=e.getUTCMinutes(),(w(),B)[r+8>>>2>>>0]=e.getUTCHours(),(w(),B)[r+12>>>2>>>0]=e.getUTCDate(),(w(),B)[r+16>>>2>>>0]=e.getUTCMonth(),(w(),B)[r+20>>>2>>>0]=e.getUTCFullYear()-1900,(w(),B)[r+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(w(),B)[r+28>>>2>>>0]=e}var kn=e=>e%4==0&&(e%100!=0||e%400==0),Wn=[0,31,60,91,121,152,182,213,244,274,305,335],Gn=[0,31,59,90,120,151,181,212,243,273,304,334];function Ho(e,r){e=-9007199254740992>e||9007199254740992<e?NaN:Number(e),r>>>=0,e=new Date(1e3*e),(w(),B)[r>>>2>>>0]=e.getSeconds(),(w(),B)[r+4>>>2>>>0]=e.getMinutes(),(w(),B)[r+8>>>2>>>0]=e.getHours(),(w(),B)[r+12>>>2>>>0]=e.getDate(),(w(),B)[r+16>>>2>>>0]=e.getMonth(),(w(),B)[r+20>>>2>>>0]=e.getFullYear()-1900,(w(),B)[r+24>>>2>>>0]=e.getDay();var i=(kn(e.getFullYear())?Wn:Gn)[e.getMonth()]+e.getDate()-1|0;(w(),B)[r+28>>>2>>>0]=i,(w(),B)[r+36>>>2>>>0]=-60*e.getTimezoneOffset(),i=new Date(e.getFullYear(),6,1).getTimezoneOffset();var s=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(i!=s&&e.getTimezoneOffset()==Math.min(s,i)),(w(),B)[r+32>>>2>>>0]=e}function jo(e){e>>>=0;var r=new Date((w(),B)[e+20>>>2>>>0]+1900,(w(),B)[e+16>>>2>>>0],(w(),B)[e+12>>>2>>>0],(w(),B)[e+8>>>2>>>0],(w(),B)[e+4>>>2>>>0],(w(),B)[e>>>2>>>0],0),i=(w(),B)[e+32>>>2>>>0],s=r.getTimezoneOffset(),f=new Date(r.getFullYear(),6,1).getTimezoneOffset(),p=new Date(r.getFullYear(),0,1).getTimezoneOffset(),E=Math.min(p,f);return 0>i?(w(),B)[e+32>>>2>>>0]=+(f!=p&&E==s):0<i!=(E==s)&&(f=Math.max(p,f),r.setTime(r.getTime()+6e4*((0<i?E:f)-s))),(w(),B)[e+24>>>2>>>0]=r.getDay(),i=(kn(r.getFullYear())?Wn:Gn)[r.getMonth()]+r.getDate()-1|0,(w(),B)[e+28>>>2>>>0]=i,(w(),B)[e>>>2>>>0]=r.getSeconds(),(w(),B)[e+4>>>2>>>0]=r.getMinutes(),(w(),B)[e+8>>>2>>>0]=r.getHours(),(w(),B)[e+12>>>2>>>0]=r.getDate(),(w(),B)[e+16>>>2>>>0]=r.getMonth(),(w(),B)[e+20>>>2>>>0]=r.getYear(),e=r.getTime(),BigInt(isNaN(e)?-1:e/1e3)}function $n(e,r,i,s,f,p,E){return o?L(16,1,e,r,i,s,f,p,E):-52}function zn(e,r,i,s,f,p){if(o)return L(17,1,e,r,i,s,f,p)}var Ve={},Vo=()=>performance.timeOrigin+performance.now();function Hn(e,r){if(o)return L(18,1,e,r);if(Ve[e]&&(clearTimeout(Ve[e].id),delete Ve[e]),!r)return 0;var i=setTimeout(()=>{delete Ve[e],Rt(()=>or(e,performance.timeOrigin+performance.now()))},r);return Ve[e]={id:i,lc:r},0}var Ae=(e,r,i)=>{var s=(w(),ne);if(r>>>=0,0<i){var f=r;i=r+i-1;for(var p=0;p<e.length;++p){var E=e.codePointAt(p);if(127>=E){if(r>=i)break;s[r++>>>0]=E}else if(2047>=E){if(r+1>=i)break;s[r++>>>0]=192|E>>6,s[r++>>>0]=128|63&E}else if(65535>=E){if(r+2>=i)break;s[r++>>>0]=224|E>>12,s[r++>>>0]=128|E>>6&63,s[r++>>>0]=128|63&E}else{if(r+3>=i)break;s[r++>>>0]=240|E>>18,s[r++>>>0]=128|E>>12&63,s[r++>>>0]=128|E>>6&63,s[r++>>>0]=128|63&E,p++}}s[r>>>0]=0,e=r-f}else e=0;return e};function Yo(e,r,i,s){e>>>=0,r>>>=0,i>>>=0,s>>>=0;var f=new Date().getFullYear(),p=new Date(f,0,1).getTimezoneOffset();f=new Date(f,6,1).getTimezoneOffset();var E=Math.max(p,f);(w(),W)[e>>>2>>>0]=60*E,(w(),B)[r>>>2>>>0]=+(p!=f),e=(r=S=>{var M=Math.abs(S);return`UTC${0<=S?"-":"+"}${String(Math.floor(M/60)).padStart(2,"0")}${String(M%60).padStart(2,"0")}`})(p),r=r(f),f<p?(Ae(e,i,17),Ae(r,s,17)):(Ae(e,s,17),Ae(r,i,17))}var Jo=()=>Date.now(),qo=1;function Xo(e,r,i){if(i>>>=0,!(0<=e&&3>=e))return 28;if(e===0)e=Date.now();else{if(!qo)return 52;e=performance.timeOrigin+performance.now()}return e=Math.round(1e6*e),(w(),A)[i>>>3>>>0]=BigInt(e),0}var kt=[];function Zo(e,r,i){e>>>=0,r>>>=0,i>>>=0,kt.length=0;for(var s;s=(w(),ne)[r++>>>0];){var f=s!=105;i+=(f&=s!=112)&&i%8?4:0,kt.push(s==112?(w(),W)[i>>>2>>>0]:s==106?(w(),A)[i>>>3>>>0]:s==105?(w(),B)[i>>>2>>>0]:(w(),me)[i>>>3>>>0]),i+=f?8:4}return lr[e](...kt)}var Qo=()=>{};function Ko(e,r){return F(Ct(e>>>0,r>>>0))}var ea=()=>{throw se+=1,"unwind"};function ta(){return 4294901760}var na=()=>navigator.hardwareConcurrency,Ie={},Wt=e=>{for(var r=0,i=0;i<e.length;++i){var s=e.charCodeAt(i);127>=s?r++:2047>=s?r+=2:55296<=s&&57343>=s?(r+=4,++i):r+=3}return r},rt=e=>{var r;return(r=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(e))?+r[1]:(r=/:(\d+):\d+(?:\)|$)/.exec(e))?2147483648|+r[1]:0},jn=e=>{for(var r of e)(e=rt(r))&&(Ie[e]=r)};function ra(){var e=Error().stack.toString().split(`
`);return e[0]=="Error"&&e.shift(),jn(e),Ie.Wb=rt(e[3]),Ie.ac=e,Ie.Wb}function ot(e){if(!(e=Ie[e>>>0]))return 0;var r;if(r=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(e))e=r[1];else if(r=/^\s+at (.*) \(.*\)$/.exec(e))e=r[1];else{if(!(r=/^(.+?)@/.exec(e)))return 0;e=r[1]}Kn(ot.Xb??0),r=Wt(e)+1;var i=er(r);return i&&Ae(e,i,r),ot.Xb=i,ot.Xb}function oa(e){e>>>=0;var r=(w(),ne).length;if(e<=r||4294901760<e)return!1;for(var i=1;4>=i;i*=2){var s=r*(1+.2/i);s=Math.min(s,e+100663296);e:{s=(Math.min(4294901760,65536*Math.ceil(Math.max(e,s)/65536))-ge.buffer.byteLength+65535)/65536|0;try{ge.grow(s),ee();var f=1;break e}catch{}f=void 0}if(f)return!0}return!1}function aa(e,r,i){if(e>>>=0,r>>>=0,Ie.Wb==e)var s=Ie.ac;else(s=Error().stack.toString().split(`
`))[0]=="Error"&&s.shift(),jn(s);for(var f=3;s[f]&&rt(s[f])!=e;)++f;for(e=0;e<i&&s[e+f];++e)(w(),B)[r+4*e>>>2>>>0]=rt(s[e+f]);return e}var Gt,$t={},Vn=()=>{if(!Gt){var e,r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(e in $t)$t[e]===void 0?delete r[e]:r[e]=$t[e];var i=[];for(e in r)i.push(`${e}=${r[e]}`);Gt=i}return Gt};function Yn(e,r){if(o)return L(19,1,e,r);e>>>=0,r>>>=0;var i,s=0,f=0;for(i of Vn()){var p=r+s;(w(),W)[e+f>>>2>>>0]=p,s+=Ae(i,p,1/0)+1,f+=4}return 0}function Jn(e,r){if(o)return L(20,1,e,r);e>>>=0,r>>>=0;var i=Vn();for(var s of((w(),W)[e>>>2>>>0]=i.length,e=0,i))e+=Wt(s)+1;return(w(),W)[r>>>2>>>0]=e,0}function qn(e){return o?L(21,1,e):52}function Xn(e,r,i,s){return o?L(22,1,e,r,i,s):52}function Zn(e,r,i,s){return o?L(23,1,e,r,i,s):70}var sa=[null,[],[]];function Qn(e,r,i,s){if(o)return L(24,1,e,r,i,s);r>>>=0,i>>>=0,s>>>=0;for(var f=0,p=0;p<i;p++){var E=(w(),W)[r>>>2>>>0],S=(w(),W)[r+4>>>2>>>0];r+=8;for(var M=0;M<S;M++){var R=e,X=(w(),ne)[E+M>>>0],le=sa[R];X===0||X===10?((R===1?O:F)(An(le)),le.length=0):le.push(X)}f+=S}return(w(),W)[s>>>2>>>0]=f,0}function ia(e){return e>>>0}o||function(){for(var e=t.numThreads-1;e--;)yn();je.push(async()=>{var r=async function(){if(!o)return Promise.all(ce.map(bn))}();Re++,await r,--Re==0&&te&&(r=te,te=null,r())})}(),o||(ge=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),ee()),t.wasmBinary&&(g=t.wasmBinary),t.stackSave=()=>_(),t.stackRestore=e=>P(e),t.stackAlloc=e=>jt(e),t.setValue=function(e,r,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":case"i8":(w(),j)[e>>>0]=r;break;case"i16":(w(),pe)[e>>>1>>>0]=r;break;case"i32":(w(),B)[e>>>2>>>0]=r;break;case"i64":(w(),A)[e>>>3>>>0]=BigInt(r);break;case"float":(w(),re)[e>>>2>>>0]=r;break;case"double":(w(),me)[e>>>3>>>0]=r;break;case"*":(w(),W)[e>>>2>>>0]=r;break;default:H(`invalid type for setValue: ${i}`)}},t.getValue=function(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":case"i8":return(w(),j)[e>>>0];case"i16":return(w(),pe)[e>>>1>>>0];case"i32":return(w(),B)[e>>>2>>>0];case"i64":return(w(),A)[e>>>3>>>0];case"float":return(w(),re)[e>>>2>>>0];case"double":return(w(),me)[e>>>3>>>0];case"*":return(w(),W)[e>>>2>>>0];default:H(`invalid type for getValue: ${r}`)}},t.UTF8ToString=Ct,t.stringToUTF8=Ae,t.lengthBytesUTF8=Wt;var at,Kn,er,zt,tr,nr,rr,Ht,or,ar,x,Ye,sr,P,jt,_,ir,Vt,ur,fr,cr,Ee,ua=[V,fe,Sn,In,Bn,Ln,Pn,Dn,_n,Un,xn,Mn,Cn,Rn,Fn,Nn,$n,zn,Hn,Yn,Jn,qn,Xn,Zn,Qn],lr={887900:(e,r,i,s,f)=>{if(t===void 0||!t.Sb)return 1;if((e=Ct(Number(e>>>0))).startsWith("./")&&(e=e.substring(2)),!(e=t.Sb.get(e)))return 2;if(r=Number(r>>>0),i=Number(i>>>0),s=Number(s>>>0),r+i>e.byteLength)return 3;try{let p=e.subarray(r,r+i);switch(f){case 0:(w(),ne).set(p,s>>>0);break;case 1:t.hc?t.hc(s,p):t.jc(s,p);break;default:return 4}return 0}catch{return 4}},888724:()=>typeof wasmOffsetConverter<"u"};function fa(){return typeof wasmOffsetConverter<"u"}function ca(e,r,i,s){var f=_();try{return C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function la(e,r,i){var s=_();try{return C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;x(1,0)}}function da(e,r,i){var s=_();try{C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;x(1,0)}}function pa(e,r){var i=_();try{return C(e)(r)}catch(s){if(P(i),s!==s+0)throw s;x(1,0)}}function ma(e){var r=_();try{C(e)()}catch(i){if(P(r),i!==i+0)throw i;x(1,0)}}function ha(e,r,i,s,f,p,E){var S=_();try{return C(e)(r,i,s,f,p,E)}catch(M){if(P(S),M!==M+0)throw M;x(1,0)}}function wa(e,r){var i=_();try{C(e)(r)}catch(s){if(P(i),s!==s+0)throw s;x(1,0)}}function ba(e,r,i,s,f,p){var E=_();try{C(e)(r,i,s,f,p)}catch(S){if(P(E),S!==S+0)throw S;x(1,0)}}function ya(e,r,i,s){var f=_();try{C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function ga(e,r,i,s,f){var p=_();try{C(e)(r,i,s,f)}catch(E){if(P(p),E!==E+0)throw E;x(1,0)}}function Ea(e,r,i,s,f,p,E){var S=_();try{C(e)(r,i,s,f,p,E)}catch(M){if(P(S),M!==M+0)throw M;x(1,0)}}function Ta(e,r,i,s,f,p,E){var S=_();try{C(e)(r,i,s,f,p,E)}catch(M){if(P(S),M!==M+0)throw M;x(1,0)}}function Sa(e,r,i,s,f,p,E,S){var M=_();try{C(e)(r,i,s,f,p,E,S)}catch(R){if(P(M),R!==R+0)throw R;x(1,0)}}function va(e,r,i,s,f){var p=_();try{return C(e)(r,i,s,f)}catch(E){if(P(p),E!==E+0)throw E;x(1,0)}}function Oa(e,r,i,s,f,p,E,S){var M=_();try{C(e)(r,i,s,f,p,E,S)}catch(R){if(P(M),R!==R+0)throw R;x(1,0)}}function Aa(e,r,i,s,f,p,E,S,M,R,X,le){var we=_();try{C(e)(r,i,s,f,p,E,S,M,R,X,le)}catch(be){if(P(we),be!==be+0)throw be;x(1,0)}}function Ia(e,r,i,s,f,p){var E=_();try{return C(e)(r,i,s,f,p)}catch(S){if(P(E),S!==S+0)throw S;x(1,0)}}function Ba(e,r,i){var s=_();try{return C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;return x(1,0),0n}}function La(e,r,i,s,f,p,E,S,M){var R=_();try{C(e)(r,i,s,f,p,E,S,M)}catch(X){if(P(R),X!==X+0)throw X;x(1,0)}}function Pa(e){var r=_();try{return C(e)()}catch(i){if(P(r),i!==i+0)throw i;x(1,0)}}function Da(e,r,i){var s=_();try{return C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;x(1,0)}}function _a(e,r){var i=_();try{return C(e)(r)}catch(s){if(P(i),s!==s+0)throw s;return x(1,0),0n}}function Ua(e,r,i,s,f){var p=_();try{C(e)(r,i,s,f)}catch(E){if(P(p),E!==E+0)throw E;x(1,0)}}function xa(e){var r=_();try{return C(e)()}catch(i){if(P(r),i!==i+0)throw i;return x(1,0),0n}}function Ma(e,r,i,s,f,p){var E=_();try{return C(e)(r,i,s,f,p)}catch(S){if(P(E),S!==S+0)throw S;x(1,0)}}function Ca(e,r,i,s,f,p){var E=_();try{return C(e)(r,i,s,f,p)}catch(S){if(P(E),S!==S+0)throw S;x(1,0)}}function Ra(e,r,i,s,f,p,E,S){var M=_();try{return C(e)(r,i,s,f,p,E,S)}catch(R){if(P(M),R!==R+0)throw R;x(1,0)}}function Fa(e,r,i,s,f){var p=_();try{return C(e)(r,i,s,f)}catch(E){if(P(p),E!==E+0)throw E;return x(1,0),0n}}function Na(e,r,i,s){var f=_();try{return C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function ka(e,r,i,s){var f=_();try{return C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function Wa(e,r,i,s,f,p,E,S,M,R,X,le){var we=_();try{return C(e)(r,i,s,f,p,E,S,M,R,X,le)}catch(be){if(P(we),be!==be+0)throw be;x(1,0)}}function Ga(e,r,i,s,f,p,E,S,M,R,X){var le=_();try{C(e)(r,i,s,f,p,E,S,M,R,X)}catch(we){if(P(le),we!==we+0)throw we;x(1,0)}}function $a(e,r,i,s,f,p,E,S,M,R,X,le,we,be,Ja,qa){var Xa=_();try{C(e)(r,i,s,f,p,E,S,M,R,X,le,we,be,Ja,qa)}catch(Yt){if(P(Xa),Yt!==Yt+0)throw Yt;x(1,0)}}function za(e,r,i,s){var f=_();try{return C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function Ha(e,r,i,s,f){var p=_();try{return C(e)(r,i,s,f)}catch(E){if(P(p),E!==E+0)throw E;x(1,0)}}function ja(e,r,i){var s=_();try{return C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;x(1,0)}}function Va(e,r,i){var s=_();try{return C(e)(r,i)}catch(f){if(P(s),f!==f+0)throw f;x(1,0)}}function Ya(e,r,i,s){var f=_();try{C(e)(r,i,s)}catch(p){if(P(f),p!==p+0)throw p;x(1,0)}}function st(){if(0<Re)te=st;else if(o)T?.(t),he();else{for(var e=je;0<e.length;)e.shift()(t);0<Re?te=st:(t.calledRun=!0,D||(he(),T?.(t)))}}return o||(Ee=await Ut(),st()),t.PTR_SIZE=4,He?t:new Promise((e,r)=>{T=e,I=r})}var os,as,Jr=N(()=>{"use strict";os=Vr,as=globalThis.self?.name?.startsWith("em-pthread");as&&Vr()});var Zr,an,ss,oe,Qr,on,is,us,Kr,fs,qr,eo,Xr,to,dt=N(()=>{"use strict";lt();Zr=typeof location>"u"?void 0:location.origin,an=import.meta.url>"file:"&&import.meta.url<"file;",ss=()=>{if(!!1){if(an){let n=URL;return new URL(new n("ort.wasm.bundle.min.mjs",import.meta.url).href,Zr).href}return import.meta.url}},oe=ss(),Qr=()=>{if(oe&&!oe.startsWith("blob:"))return oe.substring(0,oe.lastIndexOf("/")+1)},on=(n,t)=>{try{let a=t??oe;return(a?new URL(n,a):new URL(n)).origin===Zr}catch{return!1}},is=(n,t)=>{let a=t??oe;try{return(a?new URL(n,a):new URL(n)).href}catch{return}},us=(n,t)=>`${t??"./"}${n}`,Kr=async n=>{let a=await(await fetch(n,{credentials:"same-origin"})).blob();return URL.createObjectURL(a)},fs=async n=>(await import(/*webpackIgnore:true*/ /*@vite-ignore*/n)).default,qr=(jr(),Xt(Hr)).default,eo=async()=>{if(!oe)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(on(oe))return[void 0,qr()];let n=await Kr(oe);return[n,qr(n)]},Xr=(Jr(),Xt(Yr)).default,to=async(n,t,a,u)=>{let o=Xr&&!(n||t);if(o)if(oe)o=on(oe)||u&&!a;else if(u&&!a)o=!0;else throw new Error("cannot determine the script source URL.");if(o)return[void 0,Xr];{let d="ort-wasm-simd-threaded.mjs",c=n??is(d,t),l=!!1&&a&&c&&!on(c,t),m=l?await Kr(c):c??us(d,t);return[l?m:void 0,await fs(m)]}}});var sn,un,Tt,no,cs,ls,ds,pt,$,xe=N(()=>{"use strict";dt();un=!1,Tt=!1,no=!1,cs=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},ls=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},ds=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},pt=async n=>{if(un)return Promise.resolve();if(Tt)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(no)throw new Error("previous call to 'initializeWebAssembly()' failed.");Tt=!0;let t=n.initTimeout,a=n.numThreads;if(n.simd!==!1){if(n.simd==="relaxed"){if(!ds())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!ls())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let u=cs();a>1&&!u&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+a+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),n.numThreads=a=1);let o=n.wasmPaths,d=typeof o=="string"?o:void 0,c=o?.mjs,l=c?.href??c,m=o?.wasm,h=m?.href??m,g=n.wasmBinary,[b,y]=await to(l,d,a>1,!!g||!!h),T=!1,I=[];if(t>0&&I.push(new Promise(U=>{setTimeout(()=>{T=!0,U()},t)})),I.push(new Promise((U,z)=>{let v={numThreads:a};if(g)v.wasmBinary=g,v.locateFile=O=>O;else if(h||d)v.locateFile=O=>h??d+O;else if(l&&l.indexOf("blob:")!==0)v.locateFile=O=>new URL(O,l).href;else if(b){let O=Qr();O&&(v.locateFile=F=>O+F)}y(v).then(O=>{Tt=!1,un=!0,sn=O,U(),b&&URL.revokeObjectURL(b)},O=>{Tt=!1,no=!0,z(O)})})),await Promise.race(I),T)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},$=()=>{if(un&&sn)return sn;throw new Error("WebAssembly is not initialized yet.")}});var ae,Ze,G,St=N(()=>{"use strict";xe();ae=(n,t)=>{let a=$(),u=a.lengthBytesUTF8(n)+1,o=a._malloc(u);return a.stringToUTF8(n,o,u),t.push(o),o},Ze=(n,t,a,u)=>{if(typeof n=="object"&&n!==null){if(a.has(n))throw new Error("Circular reference in options");a.add(n)}Object.entries(n).forEach(([o,d])=>{let c=t?t+o:o;if(typeof d=="object")Ze(d,c+".",a,u);else if(typeof d=="string"||typeof d=="number")u(c,d.toString());else if(typeof d=="boolean")u(c,d?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof d}`)})},G=n=>{let t=$(),a=t.stackSave();try{let u=t.PTR_SIZE,o=t.stackAlloc(2*u);t._OrtGetLastError(o,o+u);let d=Number(t.getValue(o,u===4?"i32":"i64")),c=t.getValue(o+u,"*"),l=c?t.UTF8ToString(c):"";throw new Error(`${n} ERROR_CODE: ${d}, ERROR_MESSAGE: ${l}`)}finally{t.stackRestore(a)}}});var ro,oo=N(()=>{"use strict";xe();St();ro=n=>{let t=$(),a=0,u=[],o=n||{};try{if(n?.logSeverityLevel===void 0)o.logSeverityLevel=2;else if(typeof n.logSeverityLevel!="number"||!Number.isInteger(n.logSeverityLevel)||n.logSeverityLevel<0||n.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${n.logSeverityLevel}`);if(n?.logVerbosityLevel===void 0)o.logVerbosityLevel=0;else if(typeof n.logVerbosityLevel!="number"||!Number.isInteger(n.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${n.logVerbosityLevel}`);n?.terminate===void 0&&(o.terminate=!1);let d=0;return n?.tag!==void 0&&(d=ae(n.tag,u)),a=t._OrtCreateRunOptions(o.logSeverityLevel,o.logVerbosityLevel,!!o.terminate,d),a===0&&G("Can't create run options."),n?.extra!==void 0&&Ze(n.extra,"",new WeakSet,(c,l)=>{let m=ae(c,u),h=ae(l,u);t._OrtAddRunConfigEntry(a,m,h)!==0&&G(`Can't set a run config entry: ${c} -