onnxruntime-web
Version:
A Javascript library for running ONNX models on browsers
6 lines • 718 kB
JavaScript
/*!
* ONNX Runtime Web v1.20.0-dev.20240924-cfa45df6b5
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
"use strict";var ort=(()=>{var ib=Object.create;var bn=Object.defineProperty;var ab=Object.getOwnPropertyDescriptor;var sb=Object.getOwnPropertyNames;var ub=Object.getPrototypeOf,lb=Object.prototype.hasOwnProperty;var Jo=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var S=(r,e)=>()=>(r&&(e=r(r=0)),e);var Be=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),wr=(r,e)=>{for(var n in e)bn(r,n,{get:e[n],enumerable:!0})},ja=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of sb(e))!lb.call(r,o)&&o!==n&&bn(r,o,{get:()=>e[o],enumerable:!(t=ab(e,o))||t.enumerable});return r};var vr=(r,e,n)=>(n=r!=null?ib(ub(r)):{},ja(e||!r||!r.__esModule?bn(n,"default",{value:r,enumerable:!0}):n,r)),Nr=r=>ja(bn({},"__esModule",{value:!0}),r);var yn,Yt,Rt,cb,xn,wn=S(()=>{"use strict";yn=new Map,Yt=[],Rt=(r,e,n)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let t=yn.get(r);if(t===void 0)yn.set(r,{backend:e,priority:n});else{if(t.priority>n)return;if(t.priority===n&&t.backend!==e)throw new Error(`cannot register backend "${r}" using priority ${n}`)}if(n>=0){let o=Yt.indexOf(r);o!==-1&&Yt.splice(o,1);for(let i=0;i<Yt.length;i++)if(yn.get(Yt[i]).priority<=n){Yt.splice(i,0,r);return}Yt.push(r)}return}throw new TypeError("not a valid backend")},cb=async r=>{let e=yn.get(r);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let n=!!e.initPromise;try{return n||(e.initPromise=e.backend.init(r)),await e.initPromise,e.initialized=!0,e.backend}catch(t){return n||(e.error=`${t}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},xn=async r=>{let e=r.executionProviders||[],n=e.map(u=>typeof u=="string"?u:u.name),t=n.length===0?Yt:n,o,i=[],s=new Set;for(let u of t){let l=await cb(u);typeof l=="string"?i.push({name:u,err:l}):(o||(o=l),o===l&&s.add(u))}if(!o)throw new Error(`no available backend found. ERR: ${i.map(u=>`[${u.name}] ${u.err}`).join(", ")}`);for(let{name:u,err:l}of i)n.includes(u)&&console.warn(`removing requested execution provider "${u}" from session options because it is not available: ${l}`);let a=e.filter(u=>s.has(typeof u=="string"?u:u.name));return[o,new Proxy(r,{get:(u,l)=>l==="executionProviders"?a:Reflect.get(u,l)})]}});var Xa=S(()=>{"use strict";wn()});var Za,Ja=S(()=>{"use strict";Za="1.20.0-dev.20240912-ae39c40e5b"});var Ya,ot,Yo=S(()=>{"use strict";Ja();Ya="warning",ot={wasm:{},webgl:{},webgpu:{},versions:{common:Za},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}`);Ya=r}},get logLevel(){return Ya}};Object.defineProperty(ot,"logLevel",{enumerable:!0})});var q,Qa=S(()=>{"use strict";Yo();q=ot});var es,ts,rs=S(()=>{"use strict";es=(r,e)=>{let n=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);n.width=r.dims[3],n.height=r.dims[2];let t=n.getContext("2d");if(t!=null){let o,i;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[3]):(o=r.dims[3],i=r.dims[2]);let s=e?.format!==void 0?e.format:"RGB",a=e?.norm,u,l;a===void 0||a.mean===void 0?u=[255,255,255,255]:typeof a.mean=="number"?u=[a.mean,a.mean,a.mean,a.mean]:(u=[a.mean[0],a.mean[1],a.mean[2],0],a.mean[3]!==void 0&&(u[3]=a.mean[3])),a===void 0||a.bias===void 0?l=[0,0,0,0]:typeof a.bias=="number"?l=[a.bias,a.bias,a.bias,a.bias]:(l=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(l[3]=a.bias[3]));let c=i*o,f=0,d=c,m=c*2,p=-1;s==="RGBA"?(f=0,d=c,m=c*2,p=c*3):s==="RGB"?(f=0,d=c,m=c*2):s==="RBG"&&(f=0,m=c,d=c*2);for(let h=0;h<i;h++)for(let b=0;b<o;b++){let y=(r.data[f++]-l[0])*u[0],g=(r.data[d++]-l[1])*u[1],x=(r.data[m++]-l[2])*u[2],v=p===-1?255:(r.data[p++]-l[3])*u[3];t.fillStyle="rgba("+y+","+g+","+x+","+v+")",t.fillRect(b,h,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")},ts=(r,e)=>{let n=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),t;if(n!=null){let o,i,s;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(o=r.dims[2],i=r.dims[1],s=r.dims[3]):(o=r.dims[3],i=r.dims[2],s=r.dims[1]);let a=e!==void 0&&e.format!==void 0?e.format:"RGB",u=e?.norm,l,c;u===void 0||u.mean===void 0?l=[255,255,255,255]:typeof u.mean=="number"?l=[u.mean,u.mean,u.mean,u.mean]:(l=[u.mean[0],u.mean[1],u.mean[2],255],u.mean[3]!==void 0&&(l[3]=u.mean[3])),u===void 0||u.bias===void 0?c=[0,0,0,0]:typeof u.bias=="number"?c=[u.bias,u.bias,u.bias,u.bias]:(c=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(c[3]=u.bias[3]));let f=i*o;if(e!==void 0&&(e.format!==void 0&&s===4&&e.format!=="RGBA"||s===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let d=4,m=0,p=1,h=2,b=3,y=0,g=f,x=f*2,v=-1;a==="RGBA"?(y=0,g=f,x=f*2,v=f*3):a==="RGB"?(y=0,g=f,x=f*2):a==="RBG"&&(y=0,x=f,g=f*2),t=n.createImageData(o,i);for(let _=0;_<i*o;m+=d,p+=d,h+=d,b+=d,_++)t.data[m]=(r.data[y++]-c[0])*l[0],t.data[p]=(r.data[g++]-c[1])*l[1],t.data[h]=(r.data[x++]-c[2])*l[2],t.data[b]=v===-1?255:(r.data[v++]-c[3])*l[3]}else throw new Error("Can not access image data");return t}});var Qo,ns,os,is,as,ss=S(()=>{"use strict";vn();Qo=(r,e)=>{if(r===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:n,width:t}=e,o=e.norm??{mean:255,bias:0},i,s;typeof o.mean=="number"?i=[o.mean,o.mean,o.mean,o.mean]:i=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?s=[o.bias,o.bias,o.bias,o.bias]:s=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];let a=e.format!==void 0?e.format:"RGBA",u=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",l=n*t,c=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),f=4,d=0,m=1,p=2,h=3,b=0,y=l,g=l*2,x=-1;a==="RGB"&&(f=3,d=0,m=1,p=2,h=-1),u==="RGBA"?x=l*3:u==="RBG"?(b=0,g=l,y=l*2):u==="BGR"&&(g=0,y=l,b=l*2);for(let _=0;_<l;_++,d+=f,p+=f,m+=f,h+=f)c[b++]=(r[d]+s[0])/i[0],c[y++]=(r[m]+s[1])/i[1],c[g++]=(r[p]+s[2])/i[2],x!==-1&&h!==-1&&(c[x++]=(r[h]+s[3])/i[3]);return u==="RGBA"?new qe("float32",c,[1,4,n,t]):new qe("float32",c,[1,3,n,t])},ns=async(r,e)=>{let n=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,t=typeof ImageData<"u"&&r instanceof ImageData,o=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,i=typeof r=="string",s,a=e??{},u=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},l=c=>c instanceof HTMLCanvasElement||c instanceof OffscreenCanvas?c.getContext("2d"):null;if(n){let c=u();c.width=r.width,c.height=r.height;let f=l(c);if(f!=null){let d=r.height,m=r.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(d=e.resizedHeight,m=e.resizedWidth),e!==void 0){if(a=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=d,a.width=m}else a.tensorFormat="RGBA",a.height=d,a.width=m;f.drawImage(r,0,0),s=f.getImageData(0,0,m,d).data}else throw new Error("Can not access image data")}else if(t){let c,f;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(c=e.resizedHeight,f=e.resizedWidth):(c=r.height,f=r.width),e!==void 0&&(a=e),a.format="RGBA",a.height=c,a.width=f,e!==void 0){let d=u();d.width=f,d.height=c;let m=l(d);if(m!=null)m.putImageData(r,0,0),s=m.getImageData(0,0,f,c).data;else throw new Error("Can not access image data")}else s=r.data}else if(o){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let c=u();c.width=r.width,c.height=r.height;let f=l(c);if(f!=null){let d=r.height,m=r.width;return f.drawImage(r,0,0,m,d),s=f.getImageData(0,0,m,d).data,a.height=d,a.width=m,Qo(s,a)}else throw new Error("Can not access image data")}else{if(i)return new Promise((c,f)=>{let d=u(),m=l(d);if(!r||!m)return f();let p=new Image;p.crossOrigin="Anonymous",p.src=r,p.onload=()=>{d.width=p.width,d.height=p.height,m.drawImage(p,0,0,d.width,d.height);let h=m.getImageData(0,0,d.width,d.height);a.height=d.height,a.width=d.width,c(Qo(h.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Qo(s,a);throw new Error("Input data provided is not supported - aborted tensor creation")},os=(r,e)=>{let{width:n,height:t,download:o,dispose:i}=e,s=[1,t,n,4];return new qe({location:"texture",type:"float32",texture:r,dims:s,download:o,dispose:i})},is=(r,e)=>{let{dataType:n,dims:t,download:o,dispose:i}=e;return new qe({location:"gpu-buffer",type:n??"float32",gpuBuffer:r,dims:t,download:o,dispose:i})},as=(r,e,n)=>new qe({location:"cpu-pinned",type:r,data:e,dims:n??[e.length]})});var Qt,Vr,us,ls,cs=S(()=>{"use strict";Qt=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Vr=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),us=!1,ls=()=>{if(!us){us=!0;let r=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;r&&(Qt.set("int64",BigInt64Array),Vr.set(BigInt64Array,"int64")),e&&(Qt.set("uint64",BigUint64Array),Vr.set(BigUint64Array,"uint64")),n?(Qt.set("float16",Float16Array),Vr.set(Float16Array,"float16")):Qt.set("float16",Uint16Array)}}});var fs,ds,ps=S(()=>{"use strict";vn();fs=r=>{let e=1;for(let n=0;n<r.length;n++){let t=r[n];if(typeof t!="number"||!Number.isSafeInteger(t))throw new TypeError(`dims[${n}] must be an integer, got: ${t}`);if(t<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${t}`);e*=t}return e},ds=(r,e)=>{switch(r.location){case"cpu":return new qe(r.type,r.data,e);case"cpu-pinned":return new qe({location:"cpu-pinned",data:r.data,type:r.type,dims:e});case"texture":return new qe({location:"texture",texture:r.texture,type:r.type,dims:e});case"gpu-buffer":return new qe({location:"gpu-buffer",gpuBuffer:r.gpuBuffer,type:r.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${r.location} is not supported`)}}});var qe,vn=S(()=>{"use strict";rs();ss();cs();ps();qe=class{constructor(e,n,t){ls();let o,i;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,o=e.type,i=e.dims,e.location){case"cpu-pinned":{let a=Qt.get(o);if(!a)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(e.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=e.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.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=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,u;if(typeof e=="string")if(o=e,u=t,e==="string"){if(!Array.isArray(n))throw new TypeError("A string tensor's data must be a string array.");a=n}else{let l=Qt.get(e);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&l===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${l.name} as data.`);e==="uint64"||e==="int64"?a=l.from(n,BigInt):a=l.from(n)}else if(n instanceof l)a=n;else if(n instanceof Uint8ClampedArray)if(e==="uint8")a=Uint8Array.from(n);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else throw new TypeError(`A ${o} tensor's data must be type of ${l}`)}else if(u=n,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof e[0];if(l==="string")o="string",a=e;else if(l==="boolean")o="bool",a=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(e instanceof Uint8ClampedArray)o="uint8",a=Uint8Array.from(e);else{let l=Vr.get(e.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);o=l,a=e}if(u===void 0)u=[a.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");i=u,this.cpuData=a,this.dataLocation="cpu"}let s=fs(i);if(this.cpuData&&s!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(s/2)===this.cpuData.length))throw new Error(`Tensor's size(${s}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=i,this.size=s}static async fromImage(e,n){return ns(e,n)}static fromTexture(e,n){return os(e,n)}static fromGpuBuffer(e,n){return is(e,n)}static fromPinnedBuffer(e,n,t){return as(e,n,t)}toDataURL(e){return es(this,e)}toImageData(e){return ts(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}async getData(e){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let n=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=n,e&&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(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return ds(this,e)}}});var ze,Tn=S(()=>{"use strict";vn();ze=qe});var Fr,ms,Je,Ke,ei=S(()=>{"use strict";Yo();Fr=(r,e)=>{(typeof ot.trace>"u"?!ot.wasm.trace:!ot.trace)||console.timeStamp(`${r}::ORT::${e}`)},ms=(r,e)=>{let n=new Error().stack?.split(/\r\n|\r|\n/g)||[],t=!1;for(let o=0;o<n.length;o++){if(t&&!n[o].includes("TRACE_FUNC")){let i=`FUNC_${r}::${n[o].trim().split(" ")[1]}`;e&&(i+=`::${e}`),Fr("CPU",i);return}n[o].includes("TRACE_FUNC")&&(t=!0)}},Je=r=>{(typeof ot.trace>"u"?!ot.wasm.trace:!ot.trace)||ms("BEGIN",r)},Ke=r=>{(typeof ot.trace>"u"?!ot.wasm.trace:!ot.trace)||ms("END",r)}});var _n,hs=S(()=>{"use strict";wn();Tn();ei();_n=class r{constructor(e){this.handler=e}async run(e,n,t){Je();let o={},i={};if(typeof e!="object"||e===null||e instanceof ze||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let s=!0;if(typeof n=="object"){if(n===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(n instanceof ze)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.");s=!1;for(let l of n){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);o[l]=null}if(typeof t=="object"&&t!==null)i=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,c=Object.getOwnPropertyNames(n);for(let f of this.outputNames)if(c.indexOf(f)!==-1){let d=n[f];(d===null||d instanceof ze)&&(l=!0,s=!1,o[f]=d)}if(l){if(typeof t=="object"&&t!==null)i=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else i=n}}else if(typeof n<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of this.inputNames)if(typeof e[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(s)for(let l of this.outputNames)o[l]=null;let a=await this.handler.run(e,o,i),u={};for(let l in a)if(Object.hasOwnProperty.call(a,l)){let c=a[l];c instanceof ze?u[l]=c:u[l]=new ze(c.type,c.data,c.dims)}return Ke(),u}async release(){return this.handler.dispose()}static async create(e,n,t,o){Je();let i,s={};if(typeof e=="string"){if(i=e,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,typeof n=="object"&&n!==null)s=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let c=e,f=0,d=e.byteLength;if(typeof n=="object"&&n!==null)s=n;else if(typeof n=="number"){if(f=n,!Number.isSafeInteger(f))throw new RangeError("'byteOffset' must be an integer.");if(f<0||f>=c.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${c.byteLength}).`);if(d=e.byteLength-f,typeof t=="number"){if(d=t,!Number.isSafeInteger(d))throw new RangeError("'byteLength' must be an integer.");if(d<=0||f+d>c.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${c.byteLength-f}].`);if(typeof o=="object"&&o!==null)s=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof t<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof n<"u")throw new TypeError("'options' must be an object.");i=new Uint8Array(c,f,d)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[a,u]=await xn(s),l=await a.createInferenceSessionHandler(i,u);return Ke(),new r(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var gs,bs=S(()=>{"use strict";hs();gs=_n});var ys=S(()=>{"use strict"});var xs=S(()=>{"use strict"});var ws=S(()=>{"use strict"});var vs=S(()=>{"use strict"});var fb,In,Ts=S(()=>{"use strict";wn();Tn();fb="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",In=class r{constructor(e,n,t){this.handler=e,this.hasOptimizerModel=n,this.hasEvalModel=t}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(e,n){let t=e.evalModel||"",o=e.optimizerModel||"",i=n||{},[s,a]=await xn(i);if(s.createTrainingSessionHandler){let u=await s.createTrainingSessionHandler(e.checkpointState,e.trainModel,t,o,a);return new r(u,!!e.optimizerModel,!!e.evalModel)}else throw new Error(fb)}typeNarrowingForRunStep(e,n,t,o,i){let s={},a={};if(typeof t!="object"||t===null||t instanceof ze||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let u=!0;if(typeof o=="object"){if(o===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(o instanceof ze)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(o)){if(o.length===0)throw new TypeError("'fetches' cannot be an empty array.");u=!1;for(let l of o){if(typeof l!="string")throw new TypeError("'fetches' must be a string array or an object.");if(n.indexOf(l)===-1)throw new RangeError(`'fetches' contains invalid output name: ${l}.`);s[l]=null}if(typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else{let l=!1,c=Object.getOwnPropertyNames(o);for(let f of n)if(c.indexOf(f)!==-1){let d=o[f];(d===null||d instanceof ze)&&(l=!0,u=!1,s[f]=d)}if(l){if(typeof i=="object"&&i!==null)a=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else a=o}}else if(typeof o<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let l of e)if(typeof t[l]>"u")throw new Error(`input '${l}' is missing in 'feeds'.`);if(u)for(let l of n)s[l]=null;return[s,a]}convertHandlerReturnTypeToMapOfTensors(e){let n={};for(let t in e)if(Object.hasOwnProperty.call(e,t)){let o=e[t];o instanceof ze?n[t]=o:n[t]=new ze(o.type,o.data,o.dims)}return n}async lazyResetGrad(){await this.handler.lazyResetGrad()}async runTrainStep(e,n,t){let[o,i]=this.typeNarrowingForRunStep(this.trainingInputNames,this.trainingOutputNames,e,n,t),s=await this.handler.runTrainStep(e,o,i);return this.convertHandlerReturnTypeToMapOfTensors(s)}async runOptimizerStep(e){if(this.hasOptimizerModel)await this.handler.runOptimizerStep(e||{});else throw new Error("This TrainingSession has no OptimizerModel loaded.")}async runEvalStep(e,n,t){if(this.hasEvalModel){let[o,i]=this.typeNarrowingForRunStep(this.evalInputNames,this.evalOutputNames,e,n,t),s=await this.handler.runEvalStep(e,o,i);return this.convertHandlerReturnTypeToMapOfTensors(s)}else throw new Error("This TrainingSession has no EvalModel loaded.")}async getParametersSize(e=!0){return this.handler.getParametersSize(e)}async loadParametersBuffer(e,n=!0){let t=await this.getParametersSize(n);if(e.length!==4*t)throw new Error("Size of the buffer passed into loadParametersBuffer must match the number of parameters in the model. Please use getParametersSize method to check.");return this.handler.loadParametersBuffer(e,n)}async getContiguousParameters(e=!0){return this.handler.getContiguousParameters(e)}async release(){return this.handler.dispose()}}});var _s,Is=S(()=>{"use strict";Ts();_s=In});var ti={};wr(ti,{InferenceSession:()=>gs,TRACE:()=>Fr,TRACE_FUNC_BEGIN:()=>Je,TRACE_FUNC_END:()=>Ke,Tensor:()=>ze,TrainingSession:()=>_s,env:()=>q,registerBackend:()=>Rt});var Ue=S(()=>{"use strict";Xa();Qa();bs();Tn();ys();xs();ei();ws();vs();Is()});function Ut(r,e,n,t){if(e===void 0)return pb(r);if(n===void 0)Sn(r,e,1);else if(typeof n=="number"&&t===void 0)Sn(r,e,n);else if(typeof n=="string"&&t===void 0)Sn(r,n,1,e);else if(typeof n=="string"&&typeof t=="number")Sn(r,n,t,e);else throw new TypeError("input is valid")}function pb(r){return{verbose:Ut.verbose.bind(null,r),info:Ut.info.bind(null,r),warning:Ut.warning.bind(null,r),error:Ut.error.bind(null,r),fatal:Ut.fatal.bind(null,r)}}function Sn(r,e,n,t){let o=Gr[t||""]||Gr[""];$s[r]<$s[o.minimalSeverity]||(o.logDateTime&&(e=`${new Date().toISOString()}|${e}`),o.logSourceLocation,db[o.provider].log(r,e,t))}var ri,ni,$s,db,As,Gr,ge,An,Pn,On,$n,ut=S(()=>{"use strict";ri=class{log(e,n,t){}},ni=class{log(e,n,t){console.log(`${this.color(e)} ${t?"\x1B[35m"+t+"\x1B[0m ":""}${n}`)}color(e){switch(e){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${e}`)}}},$s={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},db={none:new ri,console:new ni},As={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},Gr={"":As};(u=>{function r(l,c){u("verbose",l,c)}u.verbose=r;function e(l,c){u("info",l,c)}u.info=e;function n(l,c){u("warning",l,c)}u.warning=n;function t(l,c){u("error",l,c)}u.error=t;function o(l,c){u("fatal",l,c)}u.fatal=o;function i(l){Gr={},s("",l||{})}u.reset=i;function s(l,c){if(l==="*")i(c);else{let f=Gr[l]||As;Gr[l]={provider:c.provider||f.provider,minimalSeverity:c.minimalSeverity||f.minimalSeverity,logDateTime:c.logDateTime===void 0?f.logDateTime:c.logDateTime,logSourceLocation:c.logSourceLocation===void 0?f.logSourceLocation:c.logSourceLocation}}}u.set=s;function a(l){let c={};l.logLevel&&(c.minimalSeverity=l.logLevel),s("",c)}u.setWithEnv=a})(Ut||={});ge=Ut,An=class{constructor(e,n,t,o,i,s){this.category=e;this.name=n;this.startTime=t;this.endCallback=o;this.timer=i;this.ctx=s}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}},Pn=class{constructor(e,n,t,o){this.category=e;this.name=n;this.startTime=t;this.endTime=o}},On=class{constructor(e,n,t){this._started=!1;this._flushPointer=0;this._started=!1,this._maxNumberEvents=e===void 0?1e4:e,this._flushBatchSize=n===void 0?10:n,this._flushIntervalInMilliseconds=t===void 0?5e3:t}static create(e){return e===void 0?new this:new this(e.maxNumberEvents,e.flushBatchSize,e.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=$n(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(e,n,t,o){let i=this._started?this.begin(e,n,o):void 0,s=!1,a=t();if(a&&typeof a.then=="function")return s=!0,new Promise((u,l)=>{a.then(async c=>{i&&await i.end(),u(c)},async c=>{i&&await i.end(),l(c)})});if(!s&&i){let u=i.end();if(u&&typeof u.then=="function")return new Promise((l,c)=>{u.then(()=>{l(a)},f=>{c(f)})})}return a}begin(e,n,t){if(!this._started)throw new Error("profiler is not started yet");if(t===void 0){let o=$n();return this.flush(o),new An(e,n,o,i=>this.endSync(i))}else{let o=t.beginTimer();return new An(e,n,0,async i=>this.end(i),o,t)}}async end(e){let n=await e.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Pn(e.category,e.name,e.startTime,n)),this.flush(n))}endSync(e){let n=$n();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new Pn(e.category,e.name,e.startTime,n)),this.flush(n))}logOneEvent(e){ge.verbose(`Profiler.${e.category}`,`${(e.endTime-e.startTime).toFixed(2)}ms on event '${e.name}' at ${e.endTime.toFixed(2)}`)}flush(e){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(let n=this._flushPointer;this._flushPointer<n+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=$n()}}get started(){return this._started}},$n=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Ps(r,e,n){for(let t of n){let o=t[0],i=t[1],s=t[2],a=t[3],u=t[4];if(r.opType===o){for(let l of e)if((l.domain===i||l.domain==="ai.onnx"&&i==="")&&mb(l.version,s))return{opImpl:a,opInit:u}}}throw new TypeError(`cannot resolve operator '${r.opType}' with opsets: ${e.map(t=>`${t.domain||"ai.onnx"} v${t.version}`).join(", ")}`)}function mb(r,e){if(e.endsWith("+")){let n=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(n)&&n<=r}else if(e.split("-").length===2){let n=e.split("-"),t=Number.parseInt(n[0],10),o=Number.parseInt(n[1],10);return!isNaN(t)&&!isNaN(o)&&t<=r&&r<=o}else return Number.parseInt(e,10)===r}var Os=S(()=>{"use strict"});var Es=Be(oi=>{"use strict";oi.__esModule=!0;var hb=function(){function r(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=r.EMPTY,e&&r.isGuid(e)&&(this.value=e)}return r.isGuid=function(e){var n=e.toString();return e&&(e instanceof r||r.validator.test(n))},r.create=function(){return new r([r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-"))},r.createEmpty=function(){return new r("emptyguid")},r.parse=function(e){return new r(e)},r.raw=function(){return[r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-")},r.gen=function(e){for(var n="",t=0;t<e;t++)n+=((1+Math.random())*65536|0).toString(16).substring(1);return n},r.prototype.equals=function(e){return r.isGuid(e)&&this.value===e.toString()},r.prototype.isEmpty=function(){return this.value===r.EMPTY},r.prototype.toString=function(){return this.value},r.prototype.toJSON=function(){return{value:this.value}},r.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),r.EMPTY="00000000-0000-0000-0000-000000000000",r}();oi.Guid=hb});function Te(r,e,n){this.low=r|0,this.high=e|0,this.unsigned=!!n}function We(r){return(r&&r.__isLong__)===!0}function Cs(r){var e=Math.clz32(r&-r);return r?31-e:e}function er(r,e){var n,t,o;return e?(r>>>=0,(o=0<=r&&r<256)&&(t=Ds[r],t)?t:(n=pe(r,0,!0),o&&(Ds[r]=n),n)):(r|=0,(o=-128<=r&&r<128)&&(t=ks[r],t)?t:(n=pe(r,r<0?-1:0,!1),o&&(ks[r]=n),n))}function ct(r,e){if(isNaN(r))return e?Nt:xt;if(e){if(r<0)return Nt;if(r>=Rs)return Fs}else{if(r<=-Ls)return Ye;if(r+1>=Ls)return Vs}return r<0?ct(-r,e).neg():pe(r%_r|0,r/_r|0,e)}function pe(r,e,n){return new Te(r,e,n)}function ai(r,e,n){if(r.length===0)throw Error("empty string");if(typeof e=="number"?(n=e,e=!1):e=!!e,r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return e?Nt:xt;if(n=n||10,n<2||36<n)throw RangeError("radix");var t;if((t=r.indexOf("-"))>0)throw Error("interior hyphen");if(t===0)return ai(r.substring(1),e,n).neg();for(var o=ct(En(n,8)),i=xt,s=0;s<r.length;s+=8){var a=Math.min(8,r.length-s),u=parseInt(r.substring(s,s+a),n);if(a<8){var l=ct(En(n,a));i=i.mul(l).add(ct(u))}else i=i.mul(o),i=i.add(ct(u))}return i.unsigned=e,i}function wt(r,e){return typeof r=="number"?ct(r,e):typeof r=="string"?ai(r,e):pe(r.low,r.high,typeof e=="boolean"?e:r.unsigned)}var lt,ks,Ds,En,Bs,gb,_r,Rs,Ls,zs,xt,Nt,Tr,Ns,ii,Vs,Fs,Ye,L,Vt,si=S(()=>{lt=null;try{lt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}Te.prototype.__isLong__;Object.defineProperty(Te.prototype,"__isLong__",{value:!0});Te.isLong=We;ks={},Ds={};Te.fromInt=er;Te.fromNumber=ct;Te.fromBits=pe;En=Math.pow;Te.fromString=ai;Te.fromValue=wt;Bs=65536,gb=1<<24,_r=Bs*Bs,Rs=_r*_r,Ls=Rs/2,zs=er(gb),xt=er(0);Te.ZERO=xt;Nt=er(0,!0);Te.UZERO=Nt;Tr=er(1);Te.ONE=Tr;Ns=er(1,!0);Te.UONE=Ns;ii=er(-1);Te.NEG_ONE=ii;Vs=pe(-1,2147483647,!1);Te.MAX_VALUE=Vs;Fs=pe(-1,-1,!0);Te.MAX_UNSIGNED_VALUE=Fs;Ye=pe(0,-2147483648,!1);Te.MIN_VALUE=Ye;L=Te.prototype;L.toInt=function(){return this.unsigned?this.low>>>0:this.low};L.toNumber=function(){return this.unsigned?(this.high>>>0)*_r+(this.low>>>0):this.high*_r+(this.low>>>0)};L.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ye)){var n=ct(e),t=this.div(n),o=t.mul(n).sub(this);return t.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=ct(En(e,6),this.unsigned),s=this,a="";;){var u=s.div(i),l=s.sub(u.mul(i)).toInt()>>>0,c=l.toString(e);if(s=u,s.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};L.getHighBits=function(){return this.high};L.getHighBitsUnsigned=function(){return this.high>>>0};L.getLowBits=function(){return this.low};L.getLowBitsUnsigned=function(){return this.low>>>0};L.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ye)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};L.isZero=function(){return this.high===0&&this.low===0};L.eqz=L.isZero;L.isNegative=function(){return!this.unsigned&&this.high<0};L.isPositive=function(){return this.unsigned||this.high>=0};L.isOdd=function(){return(this.low&1)===1};L.isEven=function(){return(this.low&1)===0};L.equals=function(e){return We(e)||(e=wt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};L.eq=L.equals;L.notEquals=function(e){return!this.eq(e)};L.neq=L.notEquals;L.ne=L.notEquals;L.lessThan=function(e){return this.comp(e)<0};L.lt=L.lessThan;L.lessThanOrEqual=function(e){return this.comp(e)<=0};L.lte=L.lessThanOrEqual;L.le=L.lessThanOrEqual;L.greaterThan=function(e){return this.comp(e)>0};L.gt=L.greaterThan;L.greaterThanOrEqual=function(e){return this.comp(e)>=0};L.gte=L.greaterThanOrEqual;L.ge=L.greaterThanOrEqual;L.compare=function(e){if(We(e)||(e=wt(e)),this.eq(e))return 0;var n=this.isNegative(),t=e.isNegative();return n&&!t?-1:!n&&t?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};L.comp=L.compare;L.negate=function(){return!this.unsigned&&this.eq(Ye)?Ye:this.not().add(Tr)};L.neg=L.negate;L.add=function(e){We(e)||(e=wt(e));var n=this.high>>>16,t=this.high&65535,o=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,u=e.low>>>16,l=e.low&65535,c=0,f=0,d=0,m=0;return m+=i+l,d+=m>>>16,m&=65535,d+=o+u,f+=d>>>16,d&=65535,f+=t+a,c+=f>>>16,f&=65535,c+=n+s,c&=65535,pe(d<<16|m,c<<16|f,this.unsigned)};L.subtract=function(e){return We(e)||(e=wt(e)),this.add(e.neg())};L.sub=L.subtract;L.multiply=function(e){if(this.isZero())return this;if(We(e)||(e=wt(e)),lt){var n=lt.mul(this.low,this.high,e.low,e.high);return pe(n,lt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Nt:xt;if(this.eq(Ye))return e.isOdd()?Ye:xt;if(e.eq(Ye))return this.isOdd()?Ye:xt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(zs)&&e.lt(zs))return ct(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,o=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,u=e.high&65535,l=e.low>>>16,c=e.low&65535,f=0,d=0,m=0,p=0;return p+=s*c,m+=p>>>16,p&=65535,m+=i*c,d+=m>>>16,m&=65535,m+=s*l,d+=m>>>16,m&=65535,d+=o*c,f+=d>>>16,d&=65535,d+=i*l,f+=d>>>16,d&=65535,d+=s*u,f+=d>>>16,d&=65535,f+=t*c+o*l+i*u+s*a,f&=65535,pe(m<<16|p,f<<16|d,this.unsigned)};L.mul=L.multiply;L.divide=function(e){if(We(e)||(e=wt(e)),e.isZero())throw Error("division by zero");if(lt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?lt.div_u:lt.div_s)(this.low,this.high,e.low,e.high);return pe(n,lt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Nt:xt;var t,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Nt;if(e.gt(this.shru(1)))return Ns;i=Nt}else{if(this.eq(Ye)){if(e.eq(Tr)||e.eq(ii))return Ye;if(e.eq(Ye))return Tr;var s=this.shr(1);return t=s.div(e).shl(1),t.eq(xt)?e.isNegative()?Tr:ii:(o=this.sub(e.mul(t)),i=t.add(o.div(e)),i)}else if(e.eq(Ye))return this.unsigned?Nt:xt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=xt}for(o=this;o.gte(e);){t=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),u=a<=48?1:En(2,a-48),l=ct(t),c=l.mul(e);c.isNegative()||c.gt(o);)t-=u,l=ct(t,this.unsigned),c=l.mul(e);l.isZero()&&(l=Tr),i=i.add(l),o=o.sub(c)}return i};L.div=L.divide;L.modulo=function(e){if(We(e)||(e=wt(e)),lt){var n=(this.unsigned?lt.rem_u:lt.rem_s)(this.low,this.high,e.low,e.high);return pe(n,lt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};L.mod=L.modulo;L.rem=L.modulo;L.not=function(){return pe(~this.low,~this.high,this.unsigned)};L.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};L.clz=L.countLeadingZeros;L.countTrailingZeros=function(){return this.low?Cs(this.low):Cs(this.high)+32};L.ctz=L.countTrailingZeros;L.and=function(e){return We(e)||(e=wt(e)),pe(this.low&e.low,this.high&e.high,this.unsigned)};L.or=function(e){return We(e)||(e=wt(e)),pe(this.low|e.low,this.high|e.high,this.unsigned)};L.xor=function(e){return We(e)||(e=wt(e)),pe(this.low^e.low,this.high^e.high,this.unsigned)};L.shiftLeft=function(e){return We(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?pe(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):pe(0,this.low<<e-32,this.unsigned)};L.shl=L.shiftLeft;L.shiftRight=function(e){return We(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?pe(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):pe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};L.shr=L.shiftRight;L.shiftRightUnsigned=function(e){return We(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?pe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?pe(this.high,0,this.unsigned):pe(this.high>>>e-32,0,this.unsigned)};L.shru=L.shiftRightUnsigned;L.shr_u=L.shiftRightUnsigned;L.rotateLeft=function(e){var n;return We(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?pe(this.high,this.low,this.unsigned):e<32?(n=32-e,pe(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,pe(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))};L.rotl=L.rotateLeft;L.rotateRight=function(e){var n;return We(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?pe(this.high,this.low,this.unsigned):e<32?(n=32-e,pe(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,pe(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))};L.rotr=L.rotateRight;L.toSigned=function(){return this.unsigned?pe(this.low,this.high,!1):this};L.toUnsigned=function(){return this.unsigned?this:pe(this.low,this.high,!0)};L.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};L.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};L.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};Te.fromBytes=function(e,n,t){return t?Te.fromBytesLE(e,n):Te.fromBytesBE(e,n)};Te.fromBytesLE=function(e,n){return new Te(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};Te.fromBytesBE=function(e,n){return new Te(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};Vt=Te});var $,Cn=S(()=>{$={};$.Offset;$.Table;$.SIZEOF_SHORT=2;$.SIZEOF_INT=4;$.FILE_IDENTIFIER_LENGTH=4;$.SIZE_PREFIX_LENGTH=4;$.Encoding={UTF8_BYTES:1,UTF16_STRING:2};$.int32=new Int32Array(2);$.float32=new Float32Array($.int32.buffer);$.float64=new Float64Array($.int32.buffer);$.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;$.Long=function(r,e){this.low=r|0,this.high=e|0};$.Long.create=function(r,e){return r==0&&e==0?$.Long.ZERO:new $.Long(r,e)};$.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296};$.Long.prototype.equals=function(r){return this.low==r.low&&this.high==r.high};$.Long.ZERO=new $.Long(0,0);$.Builder=function(r){if(r)var e=r;else var e=1024;this.bb=$.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};$.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};$.Builder.prototype.forceDefaults=function(r){this.force_defaults=r};$.Builder.prototype.dataBuffer=function(){return this.bb};$.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())};$.Builder.prototype.prep=function(r,e){r>this.minalign&&(this.minalign=r);for(var n=~(this.bb.capacity()-this.space+e)+1&r-1;this.space<n+r+e;){var t=this.bb.capacity();this.bb=$.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(n)};$.Builder.prototype.pad=function(r){for(var e=0;e<r;e++)this.bb.writeInt8(--this.space,0)};$.Builder.prototype.writeInt8=function(r){this.bb.writeInt8(this.space-=1,r)};$.Builder.prototype.writeInt16=function(r){this.bb.writeInt16(this.space-=2,r)};$.Builder.prototype.writeInt32=function(r){this.bb.writeInt32(this.space-=4,r)};$.Builder.prototype.writeInt64=function(r){this.bb.writeInt64(this.space-=8,r)};$.Builder.prototype.writeFloat32=function(r){this.bb.writeFloat32(this.space-=4,r)};$.Builder.prototype.writeFloat64=function(r){this.bb.writeFloat64(this.space-=8,r)};$.Builder.prototype.addInt8=function(r){this.prep(1,0),this.writeInt8(r)};$.Builder.prototype.addInt16=function(r){this.prep(2,0),this.writeInt16(r)};$.Builder.prototype.addInt32=function(r){this.prep(4,0),this.writeInt32(r)};$.Builder.prototype.addInt64=function(r){this.prep(8,0),this.writeInt64(r)};$.Builder.prototype.addFloat32=function(r){this.prep(4,0),this.writeFloat32(r)};$.Builder.prototype.addFloat64=function(r){this.prep(8,0),this.writeFloat64(r)};$.Builder.prototype.addFieldInt8=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(r))};$.Builder.prototype.addFieldInt16=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(r))};$.Builder.prototype.addFieldInt32=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(r))};$.Builder.prototype.addFieldInt64=function(r,e,n){(this.force_defaults||!e.equals(n))&&(this.addInt64(e),this.slot(r))};$.Builder.prototype.addFieldFloat32=function(r,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(r))};$.Builder.prototype.addFieldFloat64=function(r,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(r))};$.Builder.prototype.addFieldOffset=function(r,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(r))};$.Builder.prototype.addFieldStruct=function(r,e,n){e!=n&&(this.nested(e),this.slot(r))};$.Builder.prototype.nested=function(r){if(r!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")};$.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")};$.Builder.prototype.slot=function(r){this.vtable[r]=this.offset()};$.Builder.prototype.offset=function(){return this.bb.capacity()-this.space};$.Builder.growByteBuffer=function(r){var e=r.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var n=e<<1,t=$.ByteBuffer.allocate(n);return t.setPosition(n-e),t.bytes().set(r.bytes(),n-e),t};$.Builder.prototype.addOffset=function(r){this.prep($.SIZEOF_INT,0),this.writeInt32(this.offset()-r+$.SIZEOF_INT)};$.Builder.prototype.startObject=function(r){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=r;for(var e=0;e<r;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()};$.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var r=this.offset(),e=this.vtable_in_use-1;e>=0&&this.vtable[e]==0;e--);for(var n=e+1;e>=0;e--)this.addInt16(this.vtable[e]!=0?r-this.vtable[e]:0);var t=2;this.addInt16(r-this.object_start);var o=(n+t)*$.SIZEOF_SHORT;this.addInt16(o);var i=0,s=this.space;e:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(o==this.bb.readInt16(a)){for(var u=$.SIZEOF_SHORT;u<o;u+=$.SIZEOF_SHORT)if(this.bb.readInt16(s+u)!=this.bb.readInt16(a+u))continue e;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-r,this.bb.writeInt32(this.space,i-r)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-r,this.offset()-r)),this.isNested=!1,r};$.Builder.prototype.finish=function(r,e,n){var t=n?$.SIZE_PREFIX_LENGTH:0;if(e){var o=e;if(this.prep(this.minalign,$.SIZEOF_INT+$.FILE_IDENTIFIER_LENGTH+t),o.length!=$.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+$.FILE_IDENTIFIER_LENGTH);for(var i=$.FILE_IDENTIFIER_LENGTH-1;i>=0;i--)this.writeInt8(o.charCodeAt(i))}this.prep(this.minalign,$.SIZEOF_INT+t),this.addOffset(r),t&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)};$.Builder.prototype.finishSizePrefixed=function(r,e){this.finish(r,e,!0)};$.Builder.prototype.requiredField=function(r,e){var n=this.bb.capacity()-r,t=n-this.bb.readInt32(n),o=this.bb.readInt16(t+e)!=0;if(!o)throw new Error("FlatBuffers: field "+e+" must be set")};$.Builder.prototype.startVector=function(r,e,n){this.notNested(),this.vector_num_elems=e,this.prep($.SIZEOF_INT,r*e),this.prep(n,r*e)};$.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()};$.Builder.prototype.createString=function(r){if(r instanceof Uint8Array)var e=r;else for(var e=[],n=0;n<r.length;){var t,o=r.charCodeAt(n++);if(o<55296||o>=56320)t=o;else{var i=r.charCodeAt(n++);t=(o<<10)+i+(65536-56623104-56320)}t<128?e.push(t):(t<2048?e.push(t>>6&31|192):(t<65536?e.push(t>>12&15|224):e.push(t>>18&7|240,t>>12&63|128),e.push(t>>6&63|128)),e.push(t&63|128))}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(var n=0,s=this.space,a=this.bb.bytes();n<e.length;n++)a[s++]=e[n];return this.endVector()};$.Builder.prototype.createLong=function(r,e){return $.Long.create(r,e)};$.ByteBuffer=function(r){this.bytes_=r,this.position_=0};$.ByteBuffer.allocate=function(r){return new $.ByteBuffer(new Uint8Array(r))};$.ByteBuffer.prototype.clear=function(){this.position_=0};$.ByteBuffer.prototype.bytes=function(){return this.bytes_};$.ByteBuffer.prototype.position=function(){return this.position_};$.ByteBuffer.prototype.setPosition=function(r){this.position_=r};$.ByteBuffer.prototype.capacity=function(){return this.bytes_.length};$.ByteBuffer.prototype.readInt8=function(r){return this.readUint8(r)<<24>>24};$.ByteBuffer.prototype.readUint8=function(r){return this.bytes_[r]};$.ByteBuffer.prototype.readInt16=function(r){return this.readUint16(r)<<16>>16};$.ByteBuffer.prototype.readUint16=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8};$.ByteBuffer.prototype.readInt32=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8|this.bytes_[r+2]<<16|this.bytes_[r+3]<<24};$.ByteBuffer.prototype.readUint32=function(r){return this.readInt32(r)>>>0};$.ByteBuffer.prototype.readInt64=function(r){return new $.Long(this.readInt32(r),this.readInt32(r+4))};$.ByteBuffer.prototype.readUint64=function(r){return new $.Long(this.readUint32(r),this.readUint32(r+4))};$.ByteBuffer.prototype.readFloat32=function(r){return $.int32[0]=this.readInt32(r),$.float32[0]};$.ByteBuffer.prototype.readFloat64=function(r){return $.int32[$.isLittleEndian?0:1]=this.readInt32(r),$.int32[$.isLittleEndian?1:0]=this.readInt32(r+4),$.float64[0]};$.ByteBuffer.prototype.writeInt8=function(r,e){this.bytes_[r]=e};$.ByteBuffer.prototype.writeUint8=function(r,e){this.bytes_[r]=e};$.ByteBuffer.prototype.writeInt16=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8};$.ByteBuffer.prototype.writeUint16=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8};$.ByteBuffer.prototype.writeInt32=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8,this.bytes_[r+2]=e>>16,this.bytes_[r+3]=e>>24};$.ByteBuffer.prototype.writeUint32=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8,this.bytes_[r+2]=e>>16,this.bytes_[r+3]=e>>24};$.ByteBuffer.prototype.writeInt64=function(r,e){this.writeInt32(r,e.low),this.writeInt32(r+4,e.high)};$.ByteBuffer.prototype.writeUint64=function(r,e){this.writeUint32(r,e.low),this.writeUint32(r+4,e.high)};$.ByteBuffer.prototype.writeFloat32=function(r,e){$.float32[0]=e,this.writeInt32(r,$.int32[0])};$.ByteBuffer.prototype.writeFloat64=function(r,e){$.float64[0]=e,this.writeInt32(r,$.int32[$.isLittleEndian?0:1]),this.writeInt32(r+4,$.int32[$.isLittleEndian?1:0])};$.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+$.SIZEOF_INT+$.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var r="",e=0;e<$.FILE_IDENTIFIER_LENGTH;e++)r+=String.fromCharCode(this.readInt8(this.position_+$.SIZEOF_INT+e));return r};$.ByteBuffer.prototype.__offset=function(r,e){var n=r-this.readInt32(r);return e<this.readInt16(n)?this.readInt16(n+e):0};$.ByteBuffer.prototype.__union=function(r,e){return r.bb_pos=e+this.readInt32(e),r.bb=this,r};$.ByteBuffer.prototype.__string=function(r,e)