UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

6 lines 1.06 MB
/*! * ONNX Runtime Web v1.17.3 * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ "use strict";var ort=(()=>{var s0=Object.create;var Yo=Object.defineProperty;var u0=Object.getOwnPropertyDescriptor;var l0=Object.getOwnPropertyNames;var d0=Object.getPrototypeOf,c0=Object.prototype.hasOwnProperty;var k=(r,e)=>()=>(r&&(e=r(r=0)),e);var ot=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Vr=(r,e)=>{for(var n in e)Yo(r,n,{get:e[n],enumerable:!0})},Xu=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l0(e))!c0.call(r,o)&&o!==n&&Yo(r,o,{get:()=>e[o],enumerable:!(t=u0(e,o))||t.enumerable});return r};var In=(r,e,n)=>(n=r!=null?s0(d0(r)):{},Xu(e||!r||!r.__esModule?Yo(n,"default",{value:r,enumerable:!0}):n,r)),kr=r=>Xu(Yo({},"__esModule",{value:!0}),r);var Xo,rn,Dr,f0,Zo,Jo=k(()=>{"use strict";Xo=new Map,rn=[],Dr=(r,e,n)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let t=Xo.get(r);if(t===void 0)Xo.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=rn.indexOf(r);o!==-1&&rn.splice(o,1);for(let i=0;i<rn.length;i++)if(Xo.get(rn[i]).priority<=n){rn.splice(i,0,r);return}rn.push(r)}return}throw new TypeError("not a valid backend")},f0=async r=>{let e=Xo.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}}},Zo=async r=>{let e=r.executionProviders||[],n=e.map(u=>typeof u=="string"?u:u.name),t=n.length===0?rn:n,o,i=[],s=new Set;for(let u of t){let l=await f0(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 Zu=k(()=>{"use strict";Jo()});var Ju,Qu=k(()=>{"use strict";Ju="1.17.3"});var el,Ht,ka=k(()=>{"use strict";Qu();el="warning",Ht={wasm:{},webgl:{},webgpu:{},versions:{common:Ju},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}`);el=r}},get logLevel(){return el}};Object.defineProperty(Ht,"logLevel",{enumerable:!0})});var fe,tl=k(()=>{"use strict";ka();fe=Ht});var rl,nl,ol=k(()=>{"use strict";rl=(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 d=i*o,f=0,p=d,g=d*2,b=-1;s==="RGBA"?(f=0,p=d,g=d*2,b=d*3):s==="RGB"?(f=0,p=d,g=d*2):s==="RBG"&&(f=0,g=d,p=d*2);for(let y=0;y<i;y++)for(let _=0;_<o;_++){let T=(r.data[f++]-l[0])*u[0],v=(r.data[p++]-l[1])*u[1],I=(r.data[g++]-l[2])*u[2],C=b===-1?255:(r.data[b++]-l[3])*u[3];t.fillStyle="rgba("+T+","+v+","+I+","+C+")",t.fillRect(_,y,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")},nl=(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,d;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?d=[0,0,0,0]:typeof u.bias=="number"?d=[u.bias,u.bias,u.bias,u.bias]:(d=[u.bias[0],u.bias[1],u.bias[2],0],u.bias[3]!==void 0&&(d[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 p=4,g=0,b=1,y=2,_=3,T=0,v=f,I=f*2,C=-1;a==="RGBA"?(T=0,v=f,I=f*2,C=f*3):a==="RGB"?(T=0,v=f,I=f*2):a==="RBG"&&(T=0,I=f,v=f*2),t=n.createImageData(o,i);for(let P=0;P<i*o;g+=p,b+=p,y+=p,_+=p,P++)t.data[g]=(r.data[T++]-d[0])*l[0],t.data[b]=(r.data[v++]-d[1])*l[1],t.data[y]=(r.data[I++]-d[2])*l[2],t.data[_]=C===-1?255:(r.data[C++]-d[3])*l[3]}else throw new Error("Can not access image data");return t}});var Da,il,al,sl,ul,ll=k(()=>{"use strict";Qo();Da=(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,d=u==="RGBA"?new Float32Array(l*4):new Float32Array(l*3),f=4,p=0,g=1,b=2,y=3,_=0,T=l,v=l*2,I=-1;a==="RGB"&&(f=3,p=0,g=1,b=2,y=-1),u==="RGBA"?I=l*3:u==="RBG"?(_=0,v=l,T=l*2):u==="BGR"&&(v=0,T=l,_=l*2);for(let P=0;P<l;P++,p+=f,b+=f,g+=f,y+=f)d[_++]=(r[p]+s[0])/i[0],d[T++]=(r[g]+s[1])/i[1],d[v++]=(r[b]+s[2])/i[2],I!==-1&&y!==-1&&(d[I++]=(r[y]+s[3])/i[3]);return u==="RGBA"?new Rt("float32",d,[1,4,n,t]):new Rt("float32",d,[1,3,n,t])},il=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=d=>d instanceof HTMLCanvasElement||d instanceof OffscreenCanvas?d.getContext("2d"):null;if(n){let d=u();d.width=r.width,d.height=r.height;let f=l(d);if(f!=null){let p=r.height,g=r.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(p=e.resizedHeight,g=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=p,a.width=g}else a.tensorFormat="RGBA",a.height=p,a.width=g;f.drawImage(r,0,0),s=f.getImageData(0,0,g,p).data}else throw new Error("Can not access image data")}else if(t){let d,f;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(d=e.resizedHeight,f=e.resizedWidth):(d=r.height,f=r.width),e!==void 0&&(a=e),a.format="RGBA",a.height=d,a.width=f,e!==void 0){let p=u();p.width=f,p.height=d;let g=l(p);if(g!=null)g.putImageData(r,0,0),s=g.getImageData(0,0,f,d).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 d=u();d.width=r.width,d.height=r.height;let f=l(d);if(f!=null){let p=r.height,g=r.width;return f.drawImage(r,0,0,g,p),s=f.getImageData(0,0,g,p).data,a.height=p,a.width=g,Da(s,a)}else throw new Error("Can not access image data")}else{if(i)return new Promise((d,f)=>{let p=u(),g=l(p);if(!r||!g)return f();let b=new Image;b.crossOrigin="Anonymous",b.src=r,b.onload=()=>{p.width=b.width,p.height=b.height,g.drawImage(b,0,0,p.width,p.height);let y=g.getImageData(0,0,p.width,p.height);a.height=p.height,a.width=p.width,d(Da(y.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(s!==void 0)return Da(s,a);throw new Error("Input data provided is not supported - aborted tensor creation")},al=(r,e)=>{let{width:n,height:t,download:o,dispose:i}=e,s=[1,t,n,4];return new Rt({location:"texture",type:"float32",texture:r,dims:s,download:o,dispose:i})},sl=(r,e)=>{let{dataType:n,dims:t,download:o,dispose:i}=e;return new Rt({location:"gpu-buffer",type:n??"float32",gpuBuffer:r,dims:t,download:o,dispose:i})},ul=(r,e,n)=>new Rt({location:"cpu-pinned",type:r,data:e,dims:n??[e.length]})});var nn,ao,dl,cl,fl=k(()=>{"use strict";nn=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),ao=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),dl=!1,cl=()=>{if(!dl){dl=!0;let r=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,n=typeof Float16Array<"u"&&Float16Array.from;r&&(nn.set("int64",BigInt64Array),ao.set(BigInt64Array,"int64")),e&&(nn.set("uint64",BigUint64Array),ao.set(BigUint64Array,"uint64")),n?(nn.set("float16",Float16Array),ao.set(Float16Array,"float16")):nn.set("float16",Uint16Array)}}});var pl,hl,ml=k(()=>{"use strict";Qo();pl=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},hl=(r,e)=>{switch(r.location){case"cpu":return new Rt(r.type,r.data,e);case"cpu-pinned":return new Rt({location:"cpu-pinned",data:r.data,type:r.type,dims:e});case"texture":return new Rt({location:"texture",texture:r.texture,type:r.type,dims:e});case"gpu-buffer":return new Rt({location:"gpu-buffer",gpuBuffer:r.gpuBuffer,type:r.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${r.location} is not supported`)}}});var Rt,Qo=k(()=>{"use strict";ol();ll();fl();ml();Rt=class{constructor(e,n,t){cl();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=nn.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")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=nn.get(e);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(n)){if(e==="float16"&&l===Uint16Array)throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");e==="uint64"||e==="int64"?a=l.from(n,BigInt):a=l.from(n)}else if(n instanceof l)a=n;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{let l=ao.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=pl(i);if(this.cpuData&&s!==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 il(e,n)}static fromTexture(e,n){return al(e,n)}static fromGpuBuffer(e,n){return sl(e,n)}static fromPinnedBuffer(e,n,t){return ul(e,n,t)}toDataURL(e){return rl(this,e)}toImageData(e){return nl(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 hl(this,e)}}});var wt,ei=k(()=>{"use strict";Qo();wt=Rt});var so,gl,Nt,zt,Ba=k(()=>{"use strict";ka();so=(r,e)=>{(typeof Ht.trace>"u"?!Ht.wasm.trace:!Ht.trace)||console.timeStamp(`${r}::ORT::${e}`)},gl=(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}`),so("CPU",i);return}n[o].includes("TRACE_FUNC")&&(t=!0)}},Nt=r=>{(typeof Ht.trace>"u"?!Ht.wasm.trace:!Ht.trace)||gl("BEGIN",r)},zt=r=>{(typeof Ht.trace>"u"?!Ht.wasm.trace:!Ht.trace)||gl("END",r)}});var ti,bl=k(()=>{"use strict";Jo();ei();Ba();ti=class r{constructor(e){this.handler=e}async run(e,n,t){Nt();let o={},i={};if(typeof e!="object"||e===null||e instanceof wt||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 wt)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,d=Object.getOwnPropertyNames(n);for(let f of this.outputNames)if(d.indexOf(f)!==-1){let p=n[f];(p===null||p instanceof wt)&&(l=!0,s=!1,o[f]=p)}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 d=a[l];d instanceof wt?u[l]=d:u[l]=new wt(d.type,d.data,d.dims)}return zt(),u}async release(){return this.handler.dispose()}static async create(e,n,t,o){Nt();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 d=e,f=0,p=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>=d.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${d.byteLength}).`);if(p=e.byteLength-f,typeof t=="number"){if(p=t,!Number.isSafeInteger(p))throw new RangeError("'byteLength' must be an integer.");if(p<=0||f+p>d.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${d.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(d,f,p)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[a,u]=await Zo(s),l=await a.createInferenceSessionHandler(i,u);return zt(),new r(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}});var yl,vl=k(()=>{"use strict";bl();yl=ti});var wl=k(()=>{"use strict"});var xl=k(()=>{"use strict"});var _l=k(()=>{"use strict"});var $l=k(()=>{"use strict"});var p0,ri,Tl=k(()=>{"use strict";Jo();ei();p0="Training backend could not be resolved. Make sure you're using the correct configuration & WebAssembly files.",ri=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 Zo(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(p0)}typeNarrowingForRunStep(e,n,t,o,i){let s={},a={};if(typeof t!="object"||t===null||t instanceof wt||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 wt)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,d=Object.getOwnPropertyNames(o);for(let f of n)if(d.indexOf(f)!==-1){let p=o[f];(p===null||p instanceof wt)&&(l=!0,u=!1,s[f]=p)}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 wt?n[t]=o:n[t]=new wt(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 Sl,Il=k(()=>{"use strict";Tl();Sl=ri});var Ra={};Vr(Ra,{InferenceSession:()=>yl,TRACE:()=>so,TRACE_FUNC_BEGIN:()=>Nt,TRACE_FUNC_END:()=>zt,Tensor:()=>wt,TrainingSession:()=>Sl,env:()=>fe,registerBackend:()=>Dr});var Et=k(()=>{"use strict";Zu();tl();vl();ei();wl();xl();Ba();_l();$l();Il()});function Fr(r,e,n,t){if(e===void 0)return m0(r);if(n===void 0)ni(r,e,1);else if(typeof n=="number"&&t===void 0)ni(r,e,n);else if(typeof n=="string"&&t===void 0)ni(r,n,1,e);else if(typeof n=="string"&&typeof t=="number")ni(r,n,t,e);else throw new TypeError("input is valid")}function m0(r){return{verbose:Fr.verbose.bind(null,r),info:Fr.info.bind(null,r),warning:Fr.warning.bind(null,r),error:Fr.error.bind(null,r),fatal:Fr.fatal.bind(null,r)}}function ni(r,e,n,t){let o=uo[t||""]||uo[""];El[r]<El[o.minimalSeverity]||(o.logDateTime&&(e=`${new Date().toISOString()}|${e}`),o.logSourceLocation,h0[o.provider].log(r,e,t))}var za,Ma,El,h0,Ol,uo,Ye,ii,ai,si,oi,jt=k(()=>{"use strict";za=class{log(e,n,t){}},Ma=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}`)}}},El={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},h0={none:new za,console:new Ma},Ol={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1},uo={"":Ol};(u=>{function r(l,d){u("verbose",l,d)}u.verbose=r;function e(l,d){u("info",l,d)}u.info=e;function n(l,d){u("warning",l,d)}u.warning=n;function t(l,d){u("error",l,d)}u.error=t;function o(l,d){u("fatal",l,d)}u.fatal=o;function i(l){uo={},s("",l||{})}u.reset=i;function s(l,d){if(l==="*")i(d);else{let f=uo[l]||Ol;uo[l]={provider:d.provider||f.provider,minimalSeverity:d.minimalSeverity||f.minimalSeverity,logDateTime:d.logDateTime===void 0?f.logDateTime:d.logDateTime,logSourceLocation:d.logSourceLocation===void 0?f.logSourceLocation:d.logSourceLocation}}}u.set=s;function a(l){let d={};l.logLevel&&(d.minimalSeverity=l.logLevel),s("",d)}u.setWithEnv=a})(Fr||={});Ye=Fr,ii=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)}},ai=class{constructor(e,n,t,o){this.category=e;this.name=n;this.startTime=t;this.endTime=o}},si=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=oi(),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 d=>{i&&await i.end(),u(d)},async d=>{i&&await i.end(),l(d)})});if(!s&&i){let u=i.end();if(u&&typeof u.then=="function")return new Promise((l,d)=>{u.then(()=>{l(a)},f=>{d(f)})})}return a}begin(e,n,t){if(!this._started)throw new Error("profiler is not started yet");if(t===void 0){let o=oi();return this.flush(o),new ii(e,n,o,i=>this.endSync(i))}else{let o=t.beginTimer();return new ii(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 ai(e.category,e.name,e.startTime,n)),this.flush(n))}endSync(e){let n=oi();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new ai(e.category,e.name,e.startTime,n)),this.flush(n))}logOneEvent(e){Ye.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=oi()}}get started(){return this._started}},oi=typeof performance<"u"&&performance.now?()=>performance.now():Date.now});function Cl(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==="")&&g0(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 g0(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 Pl=k(()=>{"use strict"});var kl=ot(La=>{"use strict";La.__esModule=!0;var b0=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}();La.Guid=b0});function it(r,e,n){this.low=r|0,this.high=e|0,this.unsigned=!!n}function Ot(r){return(r&&r.__isLong__)===!0}function Dl(r){var e=Math.clz32(r&-r);return r?31-e:e}function on(r,e){var n,t,o;return e?(r>>>=0,(o=0<=r&&r<256)&&(t=Rl[r],t)?t:(n=qe(r,0,!0),o&&(Rl[r]=n),n)):(r|=0,(o=-128<=r&&r<128)&&(t=Bl[r],t)?t:(n=qe(r,r<0?-1:0,!1),o&&(Bl[r]=n),n))}function Yt(r,e){if(isNaN(r))return e?Br:ir;if(e){if(r<0)return Br;if(r>=Nl)return Vl}else{if(r<=-Ml)return Gt;if(r+1>=Ml)return Ul}return r<0?Yt(-r,e).neg():qe(r%En|0,r/En|0,e)}function qe(r,e,n){return new it(r,e,n)}function Ga(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?Br:ir;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 Ga(r.substring(1),e,n).neg();for(var o=Yt(ui(n,8)),i=ir,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=Yt(ui(n,a));i=i.mul(l).add(Yt(u))}else i=i.mul(o),i=i.add(Yt(u))}return i.unsigned=e,i}function ar(r,e){return typeof r=="number"?Yt(r,e):typeof r=="string"?Ga(r,e):qe(r.low,r.high,typeof e=="boolean"?e:r.unsigned)}var Kt,Bl,Rl,ui,zl,y0,En,Nl,Ml,Ll,ir,Br,An,Gl,Na,Ul,Vl,Gt,Y,Rr,Ua=k(()=>{Kt=null;try{Kt=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{}it.prototype.__isLong__;Object.defineProperty(it.prototype,"__isLong__",{value:!0});it.isLong=Ot;Bl={},Rl={};it.fromInt=on;it.fromNumber=Yt;it.fromBits=qe;ui=Math.pow;it.fromString=Ga;it.fromValue=ar;zl=65536,y0=1<<24,En=zl*zl,Nl=En*En,Ml=Nl/2,Ll=on(y0),ir=on(0);it.ZERO=ir;Br=on(0,!0);it.UZERO=Br;An=on(1);it.ONE=An;Gl=on(1,!0);it.UONE=Gl;Na=on(-1);it.NEG_ONE=Na;Ul=qe(-1,2147483647,!1);it.MAX_VALUE=Ul;Vl=qe(-1,-1,!0);it.MAX_UNSIGNED_VALUE=Vl;Gt=qe(0,-2147483648,!1);it.MIN_VALUE=Gt;Y=it.prototype;Y.toInt=function(){return this.unsigned?this.low>>>0:this.low};Y.toNumber=function(){return this.unsigned?(this.high>>>0)*En+(this.low>>>0):this.high*En+(this.low>>>0)};Y.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(Gt)){var n=Yt(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=Yt(ui(e,6),this.unsigned),s=this,a="";;){var u=s.div(i),l=s.sub(u.mul(i)).toInt()>>>0,d=l.toString(e);if(s=u,s.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};Y.getHighBits=function(){return this.high};Y.getHighBitsUnsigned=function(){return this.high>>>0};Y.getLowBits=function(){return this.low};Y.getLowBitsUnsigned=function(){return this.low>>>0};Y.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Gt)?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};Y.isZero=function(){return this.high===0&&this.low===0};Y.eqz=Y.isZero;Y.isNegative=function(){return!this.unsigned&&this.high<0};Y.isPositive=function(){return this.unsigned||this.high>=0};Y.isOdd=function(){return(this.low&1)===1};Y.isEven=function(){return(this.low&1)===0};Y.equals=function(e){return Ot(e)||(e=ar(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};Y.eq=Y.equals;Y.notEquals=function(e){return!this.eq(e)};Y.neq=Y.notEquals;Y.ne=Y.notEquals;Y.lessThan=function(e){return this.comp(e)<0};Y.lt=Y.lessThan;Y.lessThanOrEqual=function(e){return this.comp(e)<=0};Y.lte=Y.lessThanOrEqual;Y.le=Y.lessThanOrEqual;Y.greaterThan=function(e){return this.comp(e)>0};Y.gt=Y.greaterThan;Y.greaterThanOrEqual=function(e){return this.comp(e)>=0};Y.gte=Y.greaterThanOrEqual;Y.ge=Y.greaterThanOrEqual;Y.compare=function(e){if(Ot(e)||(e=ar(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};Y.comp=Y.compare;Y.negate=function(){return!this.unsigned&&this.eq(Gt)?Gt:this.not().add(An)};Y.neg=Y.negate;Y.add=function(e){Ot(e)||(e=ar(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,d=0,f=0,p=0,g=0;return g+=i+l,p+=g>>>16,g&=65535,p+=o+u,f+=p>>>16,p&=65535,f+=t+a,d+=f>>>16,f&=65535,d+=n+s,d&=65535,qe(p<<16|g,d<<16|f,this.unsigned)};Y.subtract=function(e){return Ot(e)||(e=ar(e)),this.add(e.neg())};Y.sub=Y.subtract;Y.multiply=function(e){if(this.isZero())return this;if(Ot(e)||(e=ar(e)),Kt){var n=Kt.mul(this.low,this.high,e.low,e.high);return qe(n,Kt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Br:ir;if(this.eq(Gt))return e.isOdd()?Gt:ir;if(e.eq(Gt))return this.isOdd()?Gt:ir;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(Ll)&&e.lt(Ll))return Yt(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,d=e.low&65535,f=0,p=0,g=0,b=0;return b+=s*d,g+=b>>>16,b&=65535,g+=i*d,p+=g>>>16,g&=65535,g+=s*l,p+=g>>>16,g&=65535,p+=o*d,f+=p>>>16,p&=65535,p+=i*l,f+=p>>>16,p&=65535,p+=s*u,f+=p>>>16,p&=65535,f+=t*d+o*l+i*u+s*a,f&=65535,qe(g<<16|b,f<<16|p,this.unsigned)};Y.mul=Y.multiply;Y.divide=function(e){if(Ot(e)||(e=ar(e)),e.isZero())throw Error("division by zero");if(Kt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?Kt.div_u:Kt.div_s)(this.low,this.high,e.low,e.high);return qe(n,Kt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Br:ir;var t,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Br;if(e.gt(this.shru(1)))return Gl;i=Br}else{if(this.eq(Gt)){if(e.eq(An)||e.eq(Na))return Gt;if(e.eq(Gt))return An;var s=this.shr(1);return t=s.div(e).shl(1),t.eq(ir)?e.isNegative()?An:Na:(o=this.sub(e.mul(t)),i=t.add(o.div(e)),i)}else if(e.eq(Gt))return this.unsigned?Br:ir;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=ir}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:ui(2,a-48),l=Yt(t),d=l.mul(e);d.isNegative()||d.gt(o);)t-=u,l=Yt(t,this.unsigned),d=l.mul(e);l.isZero()&&(l=An),i=i.add(l),o=o.sub(d)}return i};Y.div=Y.divide;Y.modulo=function(e){if(Ot(e)||(e=ar(e)),Kt){var n=(this.unsigned?Kt.rem_u:Kt.rem_s)(this.low,this.high,e.low,e.high);return qe(n,Kt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};Y.mod=Y.modulo;Y.rem=Y.modulo;Y.not=function(){return qe(~this.low,~this.high,this.unsigned)};Y.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};Y.clz=Y.countLeadingZeros;Y.countTrailingZeros=function(){return this.low?Dl(this.low):Dl(this.high)+32};Y.ctz=Y.countTrailingZeros;Y.and=function(e){return Ot(e)||(e=ar(e)),qe(this.low&e.low,this.high&e.high,this.unsigned)};Y.or=function(e){return Ot(e)||(e=ar(e)),qe(this.low|e.low,this.high|e.high,this.unsigned)};Y.xor=function(e){return Ot(e)||(e=ar(e)),qe(this.low^e.low,this.high^e.high,this.unsigned)};Y.shiftLeft=function(e){return Ot(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?qe(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):qe(0,this.low<<e-32,this.unsigned)};Y.shl=Y.shiftLeft;Y.shiftRight=function(e){return Ot(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?qe(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):qe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};Y.shr=Y.shiftRight;Y.shiftRightUnsigned=function(e){return Ot(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?qe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?qe(this.high,0,this.unsigned):qe(this.high>>>e-32,0,this.unsigned)};Y.shru=Y.shiftRightUnsigned;Y.shr_u=Y.shiftRightUnsigned;Y.rotateLeft=function(e){var n;return Ot(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?qe(this.high,this.low,this.unsigned):e<32?(n=32-e,qe(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,qe(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))};Y.rotl=Y.rotateLeft;Y.rotateRight=function(e){var n;return Ot(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?qe(this.high,this.low,this.unsigned):e<32?(n=32-e,qe(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,qe(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))};Y.rotr=Y.rotateRight;Y.toSigned=function(){return this.unsigned?qe(this.low,this.high,!1):this};Y.toUnsigned=function(){return this.unsigned?this:qe(this.low,this.high,!0)};Y.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};Y.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]};Y.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]};it.fromBytes=function(e,n,t){return t?it.fromBytesLE(e,n):it.fromBytesBE(e,n)};it.fromBytesLE=function(e,n){return new it(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};it.fromBytesBE=function(e,n){return new it(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};Rr=it});var D,li=k(()=>{D={};D.Offset;D.Table;D.SIZEOF_SHORT=2;D.SIZEOF_INT=4;D.FILE_IDENTIFIER_LENGTH=4;D.SIZE_PREFIX_LENGTH=4;D.Encoding={UTF8_BYTES:1,UTF16_STRING:2};D.int32=new Int32Array(2);D.float32=new Float32Array(D.int32.buffer);D.float64=new Float64Array(D.int32.buffer);D.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;D.Long=function(r,e){this.low=r|0,this.high=e|0};D.Long.create=function(r,e){return r==0&&e==0?D.Long.ZERO:new D.Long(r,e)};D.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296};D.Long.prototype.equals=function(r){return this.low==r.low&&this.high==r.high};D.Long.ZERO=new D.Long(0,0);D.Builder=function(r){if(r)var e=r;else var e=1024;this.bb=D.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};D.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};D.Builder.prototype.forceDefaults=function(r){this.force_defaults=r};D.Builder.prototype.dataBuffer=function(){return this.bb};D.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())};D.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=D.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(n)};D.Builder.prototype.pad=function(r){for(var e=0;e<r;e++)this.bb.writeInt8(--this.space,0)};D.Builder.prototype.writeInt8=function(r){this.bb.writeInt8(this.space-=1,r)};D.Builder.prototype.writeInt16=function(r){this.bb.writeInt16(this.space-=2,r)};D.Builder.prototype.writeInt32=function(r){this.bb.writeInt32(this.space-=4,r)};D.Builder.prototype.writeInt64=function(r){this.bb.writeInt64(this.space-=8,r)};D.Builder.prototype.writeFloat32=function(r){this.bb.writeFloat32(this.space-=4,r)};D.Builder.prototype.writeFloat64=function(r){this.bb.writeFloat64(this.space-=8,r)};D.Builder.prototype.addInt8=function(r){this.prep(1,0),this.writeInt8(r)};D.Builder.prototype.addInt16=function(r){this.prep(2,0),this.writeInt16(r)};D.Builder.prototype.addInt32=function(r){this.prep(4,0),this.writeInt32(r)};D.Builder.prototype.addInt64=function(r){this.prep(8,0),this.writeInt64(r)};D.Builder.prototype.addFloat32=function(r){this.prep(4,0),this.writeFloat32(r)};D.Builder.prototype.addFloat64=function(r){this.prep(8,0),this.writeFloat64(r)};D.Builder.prototype.addFieldInt8=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(r))};D.Builder.prototype.addFieldInt16=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(r))};D.Builder.prototype.addFieldInt32=function(r,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(r))};D.Builder.prototype.addFieldInt64=function(r,e,n){(this.force_defaults||!e.equals(n))&&(this.addInt64(e),this.slot(r))};D.Builder.prototype.addFieldFloat32=function(r,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(r))};D.Builder.prototype.addFieldFloat64=function(r,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(r))};D.Builder.prototype.addFieldOffset=function(r,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(r))};D.Builder.prototype.addFieldStruct=function(r,e,n){e!=n&&(this.nested(e),this.slot(r))};D.Builder.prototype.nested=function(r){if(r!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")};D.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")};D.Builder.prototype.slot=function(r){this.vtable[r]=this.offset()};D.Builder.prototype.offset=function(){return this.bb.capacity()-this.space};D.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=D.ByteBuffer.allocate(n);return t.setPosition(n-e),t.bytes().set(r.bytes(),n-e),t};D.Builder.prototype.addOffset=function(r){this.prep(D.SIZEOF_INT,0),this.writeInt32(this.offset()-r+D.SIZEOF_INT)};D.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()};D.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)*D.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=D.SIZEOF_SHORT;u<o;u+=D.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};D.Builder.prototype.finish=function(r,e,n){var t=n?D.SIZE_PREFIX_LENGTH:0;if(e){var o=e;if(this.prep(this.minalign,D.SIZEOF_INT+D.FILE_IDENTIFIER_LENGTH+t),o.length!=D.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+D.FILE_IDENTIFIER_LENGTH);for(var i=D.FILE_IDENTIFIER_LENGTH-1;i>=0;i--)this.writeInt8(o.charCodeAt(i))}this.prep(this.minalign,D.SIZEOF_INT+t),this.addOffset(r),t&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)};D.Builder.prototype.finishSizePrefixed=function(r,e){this.finish(r,e,!0)};D.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")};D.Builder.prototype.startVector=function(r,e,n){this.notNested(),this.vector_num_elems=e,this.prep(D.SIZEOF_INT,r*e),this.prep(n,r*e)};D.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()};D.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()};D.Builder.prototype.createLong=function(r,e){return D.Long.create(r,e)};D.ByteBuffer=function(r){this.bytes_=r,this.position_=0};D.ByteBuffer.allocate=function(r){return new D.ByteBuffer(new Uint8Array(r))};D.ByteBuffer.prototype.clear=function(){this.position_=0};D.ByteBuffer.prototype.bytes=function(){return this.bytes_};D.ByteBuffer.prototype.position=function(){return this.position_};D.ByteBuffer.prototype.setPosition=function(r){this.position_=r};D.ByteBuffer.prototype.capacity=function(){return this.bytes_.length};D.ByteBuffer.prototype.readInt8=function(r){return this.readUint8(r)<<24>>24};D.ByteBuffer.prototype.readUint8=function(r){return this.bytes_[r]};D.ByteBuffer.prototype.readInt16=function(r){return this.readUint16(r)<<16>>16};D.ByteBuffer.prototype.readUint16=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8};D.ByteBuffer.prototype.readInt32=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8|this.bytes_[r+2]<<16|this.bytes_[r+3]<<24};D.ByteBuffer.prototype.readUint32=function(r){return this.readInt32(r)>>>0};D.ByteBuffer.prototype.readInt64=function(r){return new D.Long(this.readInt32(r),this.readInt32(r+4))};D.ByteBuffer.prototype.readUint64=function(r){return new D.Long(this.readUint32(r),this.readUint32(r+4))};D.ByteBuffer.prototype.readFloat32=function(r){return D.int32[0]=this.readInt32(r),D.float32[0]};D.ByteBuffer.prototype.readFloat64=function(r){return D.int32[D.isLittleEndian?0:1]=this.readInt32(r),D.int32[D.isLittleEndian?1:0]=this.readInt32(r+4),D.float64[0]};D.ByteBuffer.prototype.writeInt8=function(r,e){this.bytes_[r]=e};D.ByteBuffer.prototype.writeUint8=function(r,e){this.bytes_[r]=e};D.ByteBuffer.prototype.writeInt16=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8};D.ByteBuffer.prototype.writeUint16=function(r,e){this.bytes_[r]=e,this.bytes_[r+1]=e>>8};D.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};D.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};D.ByteBuffer.prototype.writeInt64=function(r,e){this.writeInt32(r,e.low),this.writeInt32(r+4,e.high)};D.ByteBuffer.prototype.writeUint64=function(r,e){this.writeUint32(r,e.low),this.writeUint32(r+4,e.high)};D.ByteBuffer.prototype.writeFloat32=function(r,e){D.float32[0]=e,this.writeInt32(r,D.int32[0])};D.ByteBuffer.prototype.writeFloat64=function(r,e){D.float64[0]=e,this.writeInt32(r,D.int32[D.isLittleEndian?0:1]),this.writeInt32(r+4,D.int32[D.isLittleEndian?1:0])};D.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+D.SIZEOF_INT+D.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var r="",e=0;e<D.FILE_IDENTIFIER_LENGTH;e++)r+=String.fromCharCode(this.readInt8(this.position_+D.SIZEOF_INT+e));return r};D.ByteBuffer.prototype.__offset=function(r,e){var n=r-this.readInt32(r);return e<this.readInt16(n)?this.readInt16(n+e):0};D.ByteBuffer.prototype.__union=function(r,e){return r.bb_pos=e+this.readInt32(e),r.bb=this,r};D.ByteBuffer.prototype.__string=function(r,e){r+=this.readInt32(r);var n=this.readInt32(r),t="",o=0;if(r+=D.SIZEOF_INT,e===D.Encoding.UTF8_BYTES)return this.bytes_.subarray(r,r+n);for(;o<n;){var i,s=this.readUint8(r+o++);if(s<192)i=s;else{var a=this.readUint8(r+o++);if(s<224)i=(s&31)<<6|a&63;else{var u=this.readUint8(r+o++);if(s<240)i=(s&15)<<12|(a&63)<<6|u&63;else{var l=this.readUint8(r+o++);i=(s&7)<<18|(a&63)<<12|(u&63)<<6|l&63}}}i<65536?t+=String.fromCharCode(i):(i-=65536,t+=String.fromCharCode((i>>10)+55296,(i&1024-1)+56320))}return t};D.ByteBuffer.prototype.__indirect=function(r){return r+this.readInt32(r)};D.ByteBuffer.prototype.__vector=function(r){return r+this.readInt32(r)+D.SIZEOF_INT};D.ByteBuffer.proto