diff --git "a/worker-d0344f04.js" "b/worker-d0344f04.js" deleted file mode 100644--- "a/worker-d0344f04.js" +++ /dev/null @@ -1,1790 +0,0 @@ -var pn=Object.defineProperty;var gn=(nt,m,t)=>m in nt?pn(nt,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):nt[m]=t;var Ee=(nt,m,t)=>(gn(nt,typeof m!="symbol"?m+"":m,t),t);(function(){var nt;"use strict";function _mergeNamespaces(m,t){return t.forEach(function(i){i&&typeof i!="string"&&!Array.isArray(i)&&Object.keys(i).forEach(function(s){if(s!=="default"&&!(s in m)){var a=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(m,s,a.get?a:{enumerable:!0,get:function(){return i[s]}})}})}),Object.freeze(m)}function dispatchCallback(m,t){m!==null&&m(t)}function reverseDictionary(m){return Object.fromEntries(Object.entries(m).map(([t,i])=>[i,t]))}function escapeRegExp(m){return m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Callable=class{constructor(){let m=function(...t){return m._call(...t)};return Object.setPrototypeOf(m,new.target.prototype)}_call(...m){throw Error("Must implement _call method in subclass")}};function isString(m){return typeof m=="string"||m instanceof String}function isTypedArray(m){var t,i,s;return((s=(i=(t=m==null?void 0:m.prototype)==null?void 0:t.__proto__)==null?void 0:i.constructor)==null?void 0:s.name)==="TypedArray"}function isIntegralNumber(m){return Number.isInteger(m)||typeof m=="bigint"}function exists(m){return m!=null}function calculateDimensions(m){const t=[];let i=m;for(;Array.isArray(i);)t.push(i.length),i=i[0];return t}function pop(m,t,i=void 0){const s=m[t];if(s!==void 0)return delete m[t],s;if(i===void 0)throw Error(`Key ${t} does not exist in object.`);return i}function mergeArrays(...m){return Array.prototype.concat.apply([],m)}var fs={},ONNX_NODE=Object.freeze({__proto__:null,default:fs});function getDefaultExportFromCjs(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function getAugmentedNamespace(m){if(m.__esModule)return m;var t=m.default;if(typeof t=="function"){var i=function s(){if(this instanceof s){var a=[null];a.push.apply(a,arguments);var d=Function.bind.apply(t,a);return new d}return t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(s){var a=Object.getOwnPropertyDescriptor(m,s);Object.defineProperty(i,s,a.get?a:{enumerable:!0,get:function(){return m[s]}})}),i}var ortWeb_min$1={exports:{}};const backends={},backendsSortedByPriority=[],registerBackend=(m,t,i)=>{if(t&&typeof t.init=="function"&&typeof t.createSessionHandler=="function"){const s=backends[m];if(s===void 0)backends[m]={backend:t,priority:i};else{if(s.priority>i)return;if(s.priority===i&&s.backend!==t)throw new Error(`cannot register backend "${m}" using priority ${i}`)}if(i>=0){const a=backendsSortedByPriority.indexOf(m);a!==-1&&backendsSortedByPriority.splice(a,1);for(let d=0;d{const t=m.length===0?backendsSortedByPriority:m,i=[];for(const s of t){const a=backends[s];if(a){if(a.initialized)return a.backend;if(a.aborted)continue;const d=!!a.initPromise;try{return d||(a.initPromise=a.backend.init()),await a.initPromise,a.initialized=!0,a.backend}catch(u){d||i.push({name:s,err:u}),a.aborted=!0}finally{delete a.initPromise}}}throw new Error(`no available backend found. ERR: ${i.map(s=>`[${s.name}] ${s.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);this.logLevelInternal=t}}get logLevel(){return this.logLevelInternal}}const env$1=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function",NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);isBigInt64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64",BigInt64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array,"int64")),isBigUint64ArrayAvailable&&(NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64",BigUint64Array),NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array,"uint64"));const calculateSize=m=>{let t=1;for(let i=0;i{const n=document.createElement("canvas"),e=n.getContext("2d");if(!t||!e)return l();const r=new Image;r.crossOrigin="Anonymous",r.src=t,r.onload=()=>{n.width=r.width,n.height=r.height,e.drawImage(r,0,0,n.width,n.height);const o=e.getImageData(0,0,n.width,n.height);if(i!==void 0){if(i.height!==void 0&&i.height!==n.height)throw new Error("Image input config height doesn't match ImageBitmap height");if(p.height=n.height,i.width!==void 0&&i.width!==n.width)throw new Error("Image input config width doesn't match ImageBitmap width");p.width=n.width}else p.height=n.height,p.width=n.width;c(ut.bufferToTensor(o.data,p))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(h!==void 0)return ut.bufferToTensor(h,p);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(t){var i,s;const a=document.createElement("canvas").getContext("2d");let d;if(a!=null){const u=this.dims[3],h=this.dims[2],p=this.dims[1],c=t!==void 0&&t.format!==void 0?t.format:"RGB",l=t!==void 0&&((i=t.norm)===null||i===void 0?void 0:i.mean)!==void 0?t.norm.mean:255,n=t!==void 0&&((s=t.norm)===null||s===void 0?void 0:s.bias)!==void 0?t.norm.bias:0,e=h*u;if(t!==void 0){if(t.height!==void 0&&t.height!==h)throw new Error("Image output config height doesn't match tensor height");if(t.width!==void 0&&t.width!==u)throw new Error("Image output config width doesn't match tensor width");if(t.format!==void 0&&p===4&&t.format!=="RGBA"||p===3&&t.format!=="RGB"&&t.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const r=4;let o=0,f=1,g=2,b=3,_=0,y=e,w=e*2,v=-1;c==="RGBA"?(_=0,y=e,w=e*2,v=e*3):c==="RGB"?(_=0,y=e,w=e*2):c==="RBG"&&(_=0,w=e,y=e*2),d=a.createImageData(u,h);for(let S=0;S"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(u)for(const c of this.outputNames)a[c]=null;const h=await this.handler.run(t,a,d),p={};for(const c in h)Object.hasOwnProperty.call(h,c)&&(p[c]=new Tensor$1(h[c].type,h[c].data,h[c].dims));return p}static async create(t,i,s,a){let d,u={};if(typeof t=="string"){if(d=t,typeof i=="object"&&i!==null)u=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(d=t,typeof i=="object"&&i!==null)u=i;else if(typeof i<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){const n=t;let e=0,r=t.byteLength;if(typeof i=="object"&&i!==null)u=i;else if(typeof i=="number"){if(e=i,!Number.isSafeInteger(e))throw new RangeError("'byteOffset' must be an integer.");if(e<0||e>=n.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${n.byteLength}).`);if(r=t.byteLength-e,typeof s=="number"){if(r=s,!Number.isSafeInteger(r))throw new RangeError("'byteLength' must be an integer.");if(r<=0||e+r>n.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${n.byteLength-e}].`);if(typeof a=="object"&&a!==null)u=a;else if(typeof a<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof i<"u")throw new TypeError("'options' must be an object.");d=new Uint8Array(n,e,r)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const p=(u.executionProviders||[]).map(n=>typeof n=="string"?n:n.name),l=await(await resolveBackend(p)).createSessionHandler(d,u);return new dn(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const InferenceSession$1=InferenceSession$2;var lib=Object.freeze({__proto__:null,InferenceSession:InferenceSession$1,Tensor:Tensor$1,env:env$1,registerBackend}),require$$0=getAugmentedNamespace(lib);/*! -* ONNX Runtime Web v1.14.0 -* Copyright (c) Microsoft Corporation. All rights reserved. -* Licensed under the MIT License. -*/(function(module,exports){(function(m,t){module.exports=t(require$$0)})(self,__WEBPACK_EXTERNAL_MODULE__1670__=>(()=>{var __webpack_modules__={3474:(m,t,i)=>{var s,a=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){function u(){return X.buffer!=ee&&Ie(X.buffer),ue}function h(){return X.buffer!=ee&&Ie(X.buffer),Se}function p(){return X.buffer!=ee&&Ie(X.buffer),ve}function c(){return X.buffer!=ee&&Ie(X.buffer),se}function l(){return X.buffer!=ee&&Ie(X.buffer),ye}var n,e,r;d=d||{},n||(n=d!==void 0?d:{}),n.ready=new Promise(function(T,k){e=T,r=k});var o,f,g,b,_,y,w=Object.assign({},n),v="./this.program",S=(T,k)=>{throw k},A=typeof window=="object",I=typeof importScripts=="function",x=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",E=n.ENVIRONMENT_IS_PTHREAD||!1,F="";function R(T){return n.locateFile?n.locateFile(T,F):F+T}if(x){let T;F=I?i(908).dirname(F)+"/":"//",y=()=>{_||(b=i(1384),_=i(908))},o=function(k,P){return y(),k=_.normalize(k),b.readFileSync(k,P?void 0:"utf8")},g=k=>((k=o(k,!0)).buffer||(k=new Uint8Array(k)),k),f=(k,P,C)=>{y(),k=_.normalize(k),b.readFile(k,function(j,V){j?C(j):P(V.buffer)})},1{if(qe())throw process.exitCode=k,P;P instanceof Qe||z("exiting due to exception: "+P),process.exit(k)},n.inspect=function(){return"[Emscripten Module object]"};try{T=i(9925)}catch(k){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),k}i.g.Worker=T.Worker}else(A||I)&&(I?F=self.location.href:typeof document<"u"&&document.currentScript&&(F=document.currentScript.src),s&&(F=s),F=F.indexOf("blob:")!==0?F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1):"",x||(o=T=>{var k=new XMLHttpRequest;return k.open("GET",T,!1),k.send(null),k.responseText},I&&(g=T=>{var k=new XMLHttpRequest;return k.open("GET",T,!1),k.responseType="arraybuffer",k.send(null),new Uint8Array(k.response)}),f=(T,k,P)=>{var C=new XMLHttpRequest;C.open("GET",T,!0),C.responseType="arraybuffer",C.onload=()=>{C.status==200||C.status==0&&C.response?k(C.response):P()},C.onerror=P,C.send(null)}));x&&typeof performance>"u"&&(i.g.performance=i(6953).performance);var $=console.log.bind(console),L=console.warn.bind(console);x&&(y(),$=T=>b.writeSync(1,T+` -`),L=T=>b.writeSync(2,T+` -`));var G,D=n.print||$,z=n.printErr||L;Object.assign(n,w),w=null,n.thisProgram&&(v=n.thisProgram),n.quit&&(S=n.quit),n.wasmBinary&&(G=n.wasmBinary);var Z=n.noExitRuntime||!1;typeof WebAssembly!="object"&&pe("no native wasm support detected");var X,J,ee,ue,Se,ve,se,ye,be=!1,Pe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ne(T,k,P){var C=(k>>>=0)+P;for(P=k;T[P]&&!(P>=C);)++P;if(16(j=(240&j)==224?(15&j)<<12|V<<6|K:(7&j)<<18|V<<12|K<<6|63&T[k++])?C+=String.fromCharCode(j):(j-=65536,C+=String.fromCharCode(55296|j>>10,56320|1023&j))}}else C+=String.fromCharCode(j)}return C}function xe(T,k){return(T>>>=0)?Ne(h(),T,k):""}function Fe(T,k,P,C){if(!(0>>=0;C=P+C-1;for(var V=0;V=K&&(K=65536+((1023&K)<<10)|1023&T.charCodeAt(++V)),127>=K){if(P>=C)break;k[P++>>>0]=K}else{if(2047>=K){if(P+1>=C)break;k[P++>>>0]=192|K>>6}else{if(65535>=K){if(P+2>=C)break;k[P++>>>0]=224|K>>12}else{if(P+3>=C)break;k[P++>>>0]=240|K>>18,k[P++>>>0]=128|K>>12&63}k[P++>>>0]=128|K>>6&63}k[P++>>>0]=128|63&K}}return k[P>>>0]=0,P-j}function Ce(T){for(var k=0,P=0;P=C?k++:2047>=C?k+=2:55296<=C&&57343>=C?(k+=4,++P):k+=3}return k}function Ie(T){ee=T,n.HEAP8=ue=new Int8Array(T),n.HEAP16=new Int16Array(T),n.HEAP32=ve=new Int32Array(T),n.HEAPU8=Se=new Uint8Array(T),n.HEAPU16=new Uint16Array(T),n.HEAPU32=se=new Uint32Array(T),n.HEAPF32=new Float32Array(T),n.HEAPF64=ye=new Float64Array(T)}E&&(ee=n.buffer);var Ae=n.INITIAL_MEMORY||16777216;if(E)X=n.wasmMemory,ee=n.buffer;else if(n.wasmMemory)X=n.wasmMemory;else if(!((X=new WebAssembly.Memory({initial:Ae/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw z("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),x&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");X&&(ee=X.buffer),Ae=ee.byteLength,Ie(ee);var je,Ge=[],Ve=[],Xe=[],Ze=[];function qe(){return Z||!1}function Ue(){var T=n.preRun.shift();Ge.unshift(T)}var Oe,ze=0,Ye=null;function pe(T){throw E?postMessage({cmd:"onAbort",arg:T}):n.onAbort&&n.onAbort(T),z(T="Aborted("+T+")"),be=!0,T=new WebAssembly.RuntimeError(T+". Build with -sASSERTIONS for more info."),r(T),T}function ft(){return Oe.startsWith("data:application/octet-stream;base64,")}function lt(){var T=Oe;try{if(T==Oe&&G)return new Uint8Array(G);if(g)return g(T);throw"both async and sync fetching of the wasm failed"}catch(k){pe(k)}}Oe="ort-wasm-threaded.wasm",ft()||(Oe=R(Oe));var Ot={};function Qe(T){this.name="ExitStatus",this.message="Program terminated with exit("+T+")",this.status=T}function ct(T){(T=re.Vb[T])||pe(),re.mc(T)}function dt(T){var k=re.Cc();if(!k)return 6;re.ac.push(k),re.Vb[T.Ub]=k,k.Ub=T.Ub;var P={cmd:"run",start_routine:T.Ic,arg:T.zc,pthread_ptr:T.Ub};return k.$b=()=>{P.time=performance.now(),k.postMessage(P,T.Nc)},k.loaded&&(k.$b(),delete k.$b),0}function Re(T){if(E)return Q(1,1,T);qe()||(re.oc(),n.onExit&&n.onExit(T),be=!0),S(T,new Qe(T))}function it(T,k){if(!k&&E)throw Pt(T),"unwind";qe()||E||(Wt(),rt(Xe),qt(0),Lt[1].length&&Nt(1,10),Lt[2].length&&Nt(2,10),re.oc()),Re(T)}var re={Yb:[],ac:[],qc:[],Vb:{},fc:function(){E&&re.Ec()},Pc:function(){},Ec:function(){re.receiveObjectTransfer=re.Gc,re.threadInitTLS=re.pc,re.setExitStatus=re.nc,Z=!1},nc:function(){},oc:function(){for(var T of Object.values(re.Vb))re.mc(T);for(T of re.Yb)T.terminate();re.Yb=[]},mc:function(T){var k=T.Ub;delete re.Vb[k],re.Yb.push(T),re.ac.splice(re.ac.indexOf(T),1),T.Ub=0,Rt(k)},Gc:function(){},pc:function(){re.qc.forEach(T=>T())},Fc:function(T,k){T.onmessage=P=>{var C=(P=P.data).cmd;if(T.Ub&&(re.Bc=T.Ub),P.targetThread&&P.targetThread!=Dt()){var j=re.Vb[P.Qc];j?j.postMessage(P,P.transferList):z('Internal error! Worker sent a message "'+C+'" to target pthread '+P.targetThread+", but that thread no longer exists!")}else C==="processProxyingQueue"?N(P.queue):C==="spawnThread"?dt(P):C==="cleanupThread"?ct(P.thread):C==="killThread"?(P=P.thread,C=re.Vb[P],delete re.Vb[P],C.terminate(),Rt(P),re.ac.splice(re.ac.indexOf(C),1),C.Ub=0):C==="cancelThread"?re.Vb[P.thread].postMessage({cmd:"cancel"}):C==="loaded"?(T.loaded=!0,k&&k(T),T.$b&&(T.$b(),delete T.$b)):C==="print"?D("Thread "+P.threadId+": "+P.text):C==="printErr"?z("Thread "+P.threadId+": "+P.text):C==="alert"?alert("Thread "+P.threadId+": "+P.text):P.target==="setimmediate"?T.postMessage(P):C==="onAbort"?n.onAbort&&n.onAbort(P.arg):C&&z("worker sent an unknown command "+C);re.Bc=void 0},T.onerror=P=>{throw z("worker sent an error! "+P.filename+":"+P.lineno+": "+P.message),P},x&&(T.on("message",function(P){T.onmessage({data:P})}),T.on("error",function(P){T.onerror(P)}),T.on("detachedExit",function(){})),T.postMessage({cmd:"load",urlOrBlob:n.mainScriptUrlOrBlob||s,wasmMemory:X,wasmModule:J})},yc:function(){var T=R("ort-wasm-threaded.worker.js");re.Yb.push(new Worker(T))},Cc:function(){return re.Yb.length==0&&(re.yc(),re.Fc(re.Yb[0])),re.Yb.pop()}};function rt(T){for(;0>2>>>0];T=p()[T+48>>2>>>0],Zt(k,k-T),ce(k)};var Je=[];function we(T){var k=Je[T];return k||(T>=Je.length&&(Je.length=T+1),Je[T]=k=je.get(T)),k}n.invokeEntryPoint=function(T,k){T=we(T)(k),qe()?re.nc(T):Kt(T)};var st,pt,ot=[],ae=0,ie=0;function oe(T){this.Zb=T,this.Sb=T-24,this.xc=function(k){c()[this.Sb+4>>2>>>0]=k},this.bc=function(){return c()[this.Sb+4>>2>>>0]},this.wc=function(k){c()[this.Sb+8>>2>>>0]=k},this.Dc=function(){return c()[this.Sb+8>>2>>>0]},this.rc=function(){p()[this.Sb>>2>>>0]=0},this.hc=function(k){k=k?1:0,u()[this.Sb+12>>0>>>0]=k},this.uc=function(){return u()[this.Sb+12>>0>>>0]!=0},this.ic=function(k){k=k?1:0,u()[this.Sb+13>>0>>>0]=k},this.kc=function(){return u()[this.Sb+13>>0>>>0]!=0},this.fc=function(k,P){this.cc(0),this.xc(k),this.wc(P),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(p(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(p(),this.Sb>>2,1)===1},this.cc=function(k){c()[this.Sb+16>>2>>>0]=k},this.tc=function(){return c()[this.Sb+16>>2>>>0]},this.vc=function(){if(Qt(this.bc()))return c()[this.Zb>>2>>>0];var k=this.tc();return k!==0?k:this.Zb}}function gt(T){return Vt(new oe(T).Sb)}function at(T,k,P,C){return E?Q(3,1,T,k,P,C):mt(T,k,P,C)}function mt(T,k,P,C){if(typeof SharedArrayBuffer>"u")return z("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var j=[];return E&&j.length===0?at(T,k,P,C):(T={Ic:P,Ub:T,zc:C,Nc:j},E?(T.Oc="spawnThread",postMessage(T,j),0):dt(T))}function bt(T,k,P){return E?Q(4,1,T,k,P):0}function _t(T,k){if(E)return Q(5,1,T,k)}function yt(T,k){if(E)return Q(6,1,T,k)}function wt(T,k,P){if(E)return Q(7,1,T,k,P)}function vt(T,k,P){return E?Q(8,1,T,k,P):0}function xt(T,k){if(E)return Q(9,1,T,k)}function Tt(T,k,P){if(E)return Q(10,1,T,k,P)}function St(T,k,P,C){if(E)return Q(11,1,T,k,P,C)}function At(T,k,P,C){if(E)return Q(12,1,T,k,P,C)}function It(T,k,P,C){if(E)return Q(13,1,T,k,P,C)}function kt(T){if(E)return Q(14,1,T)}function O(T,k){if(E)return Q(15,1,T,k)}function M(T,k,P){if(E)return Q(16,1,T,k,P)}function N(T){Atomics.store(p(),T>>2,1),Dt()&&Yt(T),Atomics.compareExchange(p(),T>>2,1,0)}function B(T){return c()[T>>>2]+4294967296*p()[T+4>>>2]}function U(T,k,P,C,j,V){return E?Q(17,1,T,k,P,C,j,V):-52}function H(T,k,P,C,j,V){if(E)return Q(18,1,T,k,P,C,j,V)}function Y(T){var k=Ce(T)+1,P=$t(k);return P&&Fe(T,u(),P,k),P}function te(T,k,P){function C(ge){return(ge=ge.toTimeString().match(/\(([A-Za-z ]+)\)$/))?ge[1]:"GMT"}if(E)return Q(19,1,T,k,P);var j=new Date().getFullYear(),V=new Date(j,0,1),K=new Date(j,6,1);j=V.getTimezoneOffset();var ne=K.getTimezoneOffset(),fe=Math.max(j,ne);p()[T>>2>>>0]=60*fe,p()[k>>2>>>0]=+(j!=ne),T=C(V),k=C(K),T=Y(T),k=Y(k),ne>2>>>0]=T,c()[P+4>>2>>>0]=k):(c()[P>>2>>>0]=k,c()[P+4>>2>>>0]=T)}function Q(T,k){var P=arguments.length-2,C=arguments;return Et(()=>{for(var j=zt(8*P),V=j>>3,K=0;K>>0]=ne}return Xt(T,P,j,k)})}n.executeNotifiedProxyingQueue=N,pt=x?()=>{var T=process.hrtime();return 1e3*T[0]+T[1]/1e6}:E?()=>performance.now()-n.__performance_now_clock_drift:()=>performance.now();var le,Te=[],$e={};function Le(){if(!le){var T,k={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:v||"./this.program"};for(T in $e)$e[T]===void 0?delete k[T]:k[T]=$e[T];var P=[];for(T in k)P.push(T+"="+k[T]);le=P}return le}function q(T,k){if(E)return Q(20,1,T,k);var P=0;return Le().forEach(function(C,j){var V=k+P;for(j=c()[T+4*j>>2>>>0]=V,V=0;V>0>>>0]=C.charCodeAt(V);u()[j>>0>>>0]=0,P+=C.length+1}),0}function me(T,k){if(E)return Q(21,1,T,k);var P=Le();c()[T>>2>>>0]=P.length;var C=0;return P.forEach(function(j){C+=j.length+1}),c()[k>>2>>>0]=C,0}function ke(T){return E?Q(22,1,T):52}function We(T,k,P,C){return E?Q(23,1,T,k,P,C):52}function et(T,k,P,C,j){return E?Q(24,1,T,k,P,C,j):70}var Lt=[null,[],[]];function Nt(T,k){var P=Lt[T];k===0||k===10?((T===1?D:z)(Ne(P,0)),P.length=0):P.push(k)}function Bt(T,k,P,C){if(E)return Q(25,1,T,k,P,C);for(var j=0,V=0;V>2>>>0],ne=c()[k+4>>2>>>0];k+=8;for(var fe=0;fe>>0]);j+=ne}return c()[C>>2>>>0]=j,0}var Be=0;function Mt(T){return T%4==0&&(T%100!=0||T%400==0)}var jt=[31,29,31,30,31,30,31,31,30,31,30,31],Ut=[31,28,31,30,31,30,31,31,30,31,30,31];function Gt(T,k,P,C){function j(W,_e,Me){for(W=typeof W=="number"?W.toString():W||"";W.length<_e;)W=Me[0]+W;return W}function V(W,_e){return j(W,_e,"0")}function K(W,_e){function Me(ht){return 0>ht?-1:0tt-W.getDate())){W.setDate(W.getDate()+_e);break}_e-=tt-W.getDate()+1,W.setDate(1),11>Me?W.setMonth(Me+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Me=new Date(W.getFullYear()+1,0,4),_e=ne(new Date(W.getFullYear(),0,4)),Me=ne(Me),0>=K(_e,W)?0>=K(Me,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}var ge=p()[C+40>>2>>>0];for(var De in C={Lc:p()[C>>2>>>0],Kc:p()[C+4>>2>>>0],dc:p()[C+8>>2>>>0],jc:p()[C+12>>2>>>0],ec:p()[C+16>>2>>>0],Xb:p()[C+20>>2>>>0],Tb:p()[C+24>>2>>>0],Wb:p()[C+28>>2>>>0],Rc:p()[C+32>>2>>>0],Jc:p()[C+36>>2>>>0],Mc:ge?xe(ge):""},P=xe(P),ge={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})P=P.replace(new RegExp(De,"g"),ge[De]);var Ke="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),He="January February March April May June July August September October November December".split(" ");for(De in ge={"%a":function(W){return Ke[W.Tb].substring(0,3)},"%A":function(W){return Ke[W.Tb]},"%b":function(W){return He[W.ec].substring(0,3)},"%B":function(W){return He[W.ec]},"%C":function(W){return V((W.Xb+1900)/100|0,2)},"%d":function(W){return V(W.jc,2)},"%e":function(W){return j(W.jc,2," ")},"%g":function(W){return fe(W).toString().substring(2)},"%G":function(W){return fe(W)},"%H":function(W){return V(W.dc,2)},"%I":function(W){return(W=W.dc)==0?W=12:12W.dc?"AM":"PM"},"%S":function(W){return V(W.Lc,2)},"%t":function(){return" "},"%u":function(W){return W.Tb||7},"%U":function(W){return V(Math.floor((W.Wb+7-W.Tb)/7),2)},"%V":function(W){var _e=Math.floor((W.Wb+7-(W.Tb+6)%7)/7);if(2>=(W.Tb+371-W.Wb-2)%7&&_e++,_e)_e==53&&((Me=(W.Tb+371-W.Wb)%7)==4||Me==3&&Mt(W.Xb)||(_e=1));else{_e=52;var Me=(W.Tb+7-W.Wb-1)%7;(Me==4||Me==5&&Mt(W.Xb%400-1))&&_e++}return V(_e,2)},"%w":function(W){return W.Tb},"%W":function(W){return V(Math.floor((W.Wb+7-(W.Tb+6)%7)/7),2)},"%y":function(W){return(W.Xb+1900).toString().substring(2)},"%Y":function(W){return W.Xb+1900},"%z":function(W){var _e=0<=(W=W.Jc);return W=Math.abs(W)/60,(_e?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":function(W){return W.Mc},"%%":function(){return"%"}},P=P.replace(/%%/g,"\0\0"),ge)P.includes(De)&&(P=P.replace(new RegExp(De,"g"),ge[De](C)));return De=function(W){var _e=Array(Ce(W)+1);return Fe(W,_e,0,_e.length),_e}(P=P.replace(/\0\0/g,"%")),De.length>k?0:(function(W,_e){u().set(W,_e>>>0)}(De,T),De.length-1)}re.fc();var hn=[null,Re,Pt,at,bt,_t,yt,wt,vt,xt,Tt,St,At,It,kt,O,M,U,H,te,q,me,ke,We,et,Bt],fn={b:function(T){return $t(T+24)+24},n:function(T){return(T=new oe(T)).uc()||(T.hc(!0),ae--),T.ic(!1),ot.push(T),T.sc(),T.vc()},ma:function(T){throw z("Unexpected exception thrown, this is not properly supported - aborting"),be=!0,T},x:function(){he(0);var T=ot.pop();if(T.Hc()&&!T.kc()){var k=T.Dc();k&&we(k)(T.Zb),gt(T.Zb)}ie=0},e:function(){var T=ie;if(!T)return Be=0;var k=new oe(T);k.cc(T);var P=k.bc();if(!P)return Be=0,T;for(var C=Array.prototype.slice.call(arguments),j=0;jN(C));else if(E)postMessage({targetThread:T,cmd:"processProxyingQueue",queue:C});else{if(!(T=re.Vb[T]))return;T.postMessage({cmd:"processProxyingQueue",queue:C})}return 1},Ea:function(){return-1},Pa:function(T,k){T=new Date(1e3*B(T)),p()[k>>2>>>0]=T.getUTCSeconds(),p()[k+4>>2>>>0]=T.getUTCMinutes(),p()[k+8>>2>>>0]=T.getUTCHours(),p()[k+12>>2>>>0]=T.getUTCDate(),p()[k+16>>2>>>0]=T.getUTCMonth(),p()[k+20>>2>>>0]=T.getUTCFullYear()-1900,p()[k+24>>2>>>0]=T.getUTCDay(),T=(T.getTime()-Date.UTC(T.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,p()[k+28>>2>>>0]=T},Qa:function(T,k){T=new Date(1e3*B(T)),p()[k>>2>>>0]=T.getSeconds(),p()[k+4>>2>>>0]=T.getMinutes(),p()[k+8>>2>>>0]=T.getHours(),p()[k+12>>2>>>0]=T.getDate(),p()[k+16>>2>>>0]=T.getMonth(),p()[k+20>>2>>>0]=T.getFullYear()-1900,p()[k+24>>2>>>0]=T.getDay();var P=new Date(T.getFullYear(),0,1),C=(T.getTime()-P.getTime())/864e5|0;p()[k+28>>2>>>0]=C,p()[k+36>>2>>>0]=-60*T.getTimezoneOffset(),C=new Date(T.getFullYear(),6,1).getTimezoneOffset(),T=0|(C!=(P=P.getTimezoneOffset())&&T.getTimezoneOffset()==Math.min(P,C)),p()[k+32>>2>>>0]=T},Ra:function(T){var k=new Date(p()[T+20>>2>>>0]+1900,p()[T+16>>2>>>0],p()[T+12>>2>>>0],p()[T+8>>2>>>0],p()[T+4>>2>>>0],p()[T>>2>>>0],0),P=p()[T+32>>2>>>0],C=k.getTimezoneOffset(),j=new Date(k.getFullYear(),0,1),V=new Date(k.getFullYear(),6,1).getTimezoneOffset(),K=j.getTimezoneOffset(),ne=Math.min(K,V);return 0>P?p()[T+32>>2>>>0]=+(V!=K&&ne==C):0>2>>>0]=k.getDay(),P=(k.getTime()-j.getTime())/864e5|0,p()[T+28>>2>>>0]=P,p()[T>>2>>>0]=k.getSeconds(),p()[T+4>>2>>>0]=k.getMinutes(),p()[T+8>>2>>>0]=k.getHours(),p()[T+12>>2>>>0]=k.getDate(),p()[T+16>>2>>>0]=k.getMonth(),k.getTime()/1e3|0},Aa:U,Ba:H,Sa:function T(k,P,C){T.Ac||(T.Ac=!0,te(k,P,C))},y:function(){pe("")},U:function(){if(!x&&!I){var T="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";st||(st={}),st[T]||(st[T]=1,x&&(T="warning: "+T),z(T))}},ra:function(){return 4294901760},B:pt,Ia:function(T,k,P){h().copyWithin(T>>>0,k>>>0,k+P>>>0)},F:function(){return x?i(3993).cpus().length:navigator.hardwareConcurrency},Da:function(T,k,P){Te.length=k,P>>=3;for(var C=0;C>>0];return(0>T?Ot[-T-1]:hn[T]).apply(null,Te)},qa:function(T){var k=h().length;if((T>>>=0)<=k||4294901760=P;P*=2){var C=k*(1+.2/P);C=Math.min(C,T+100663296);var j=Math;C=Math.max(T,C),j=j.min.call(j,4294901760,C+(65536-C%65536)%65536);e:{try{X.grow(j-ee.byteLength+65535>>>16),Ie(X.buffer);var V=1;break e}catch{}V=void 0}if(V)return!0}return!1},Na:function(){throw"unwind"},Ga:q,Ha:me,J:it,I:ke,S:We,ga:et,R:Bt,d:function(){return Be},na:function T(k,P){T.lc||(T.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var j=new Uint8Array(1);return()=>(crypto.getRandomValues(j),j[0])}if(x)try{var V=i(Object(function(){var K=new Error("Cannot find module 'crypto'");throw K.code="MODULE_NOT_FOUND",K}()));return()=>V.randomBytes(1)[0]}catch{}return()=>pe("randomDevice")}());for(var C=0;C>0>>>0]=T.lc();return 0},ia:function(T,k,P){var C=de();try{return we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},ja:function(T,k,P){var C=de();try{return we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},K:function(T){var k=de();try{return we(T)()}catch(P){if(ce(k),P!==P+0)throw P;he(1,0)}},f:function(T,k){var P=de();try{return we(T)(k)}catch(C){if(ce(P),C!==C+0)throw C;he(1,0)}},P:function(T,k,P){var C=de();try{return we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},Q:function(T,k,P){var C=de();try{return we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},k:function(T,k,P){var C=de();try{return we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},p:function(T,k,P,C){var j=de();try{return we(T)(k,P,C)}catch(V){if(ce(j),V!==V+0)throw V;he(1,0)}},q:function(T,k,P,C,j){var V=de();try{return we(T)(k,P,C,j)}catch(K){if(ce(V),K!==K+0)throw K;he(1,0)}},N:function(T,k,P,C,j,V){var K=de();try{return we(T)(k,P,C,j,V)}catch(ne){if(ce(K),ne!==ne+0)throw ne;he(1,0)}},s:function(T,k,P,C,j,V){var K=de();try{return we(T)(k,P,C,j,V)}catch(ne){if(ce(K),ne!==ne+0)throw ne;he(1,0)}},w:function(T,k,P,C,j,V,K){var ne=de();try{return we(T)(k,P,C,j,V,K)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;he(1,0)}},L:function(T,k,P,C,j,V,K,ne){var fe=de();try{return we(T)(k,P,C,j,V,K,ne)}catch(ge){if(ce(fe),ge!==ge+0)throw ge;he(1,0)}},E:function(T,k,P,C,j,V,K,ne,fe,ge,De,Ke){var He=de();try{return we(T)(k,P,C,j,V,K,ne,fe,ge,De,Ke)}catch(W){if(ce(He),W!==W+0)throw W;he(1,0)}},aa:function(T,k,P,C,j,V,K,ne){var fe=de();try{return un(T,k,P,C,j,V,K,ne)}catch(ge){if(ce(fe),ge!==ge+0)throw ge;he(1,0)}},_:function(T,k,P,C,j,V,K){var ne=de();try{return en(T,k,P,C,j,V,K)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;he(1,0)}},Z:function(T,k,P,C,j){var V=de();try{return ln(T,k,P,C,j)}catch(K){if(ce(V),K!==K+0)throw K;he(1,0)}},ca:function(T,k,P,C){var j=de();try{return on(T,k,P,C)}catch(V){if(ce(j),V!==V+0)throw V;he(1,0)}},$:function(T){var k=de();try{return Jt(T)}catch(P){if(ce(k),P!==P+0)throw P;he(1,0)}},ba:function(T,k){var P=de();try{return an(T,k)}catch(C){if(ce(P),C!==C+0)throw C;he(1,0)}},Y:function(T,k,P){var C=de();try{return tn(T,k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},g:function(T){var k=de();try{we(T)()}catch(P){if(ce(k),P!==P+0)throw P;he(1,0)}},r:function(T,k){var P=de();try{we(T)(k)}catch(C){if(ce(P),C!==C+0)throw C;he(1,0)}},i:function(T,k,P){var C=de();try{we(T)(k,P)}catch(j){if(ce(C),j!==j+0)throw j;he(1,0)}},ha:function(T,k,P,C){var j=de();try{we(T)(k,P,C)}catch(V){if(ce(j),V!==V+0)throw V;he(1,0)}},m:function(T,k,P,C){var j=de();try{we(T)(k,P,C)}catch(V){if(ce(j),V!==V+0)throw V;he(1,0)}},v:function(T,k,P,C,j){var V=de();try{we(T)(k,P,C,j)}catch(K){if(ce(V),K!==K+0)throw K;he(1,0)}},u:function(T,k,P,C,j,V){var K=de();try{we(T)(k,P,C,j,V)}catch(ne){if(ce(K),ne!==ne+0)throw ne;he(1,0)}},O:function(T,k,P,C,j,V,K){var ne=de();try{we(T)(k,P,C,j,V,K)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;he(1,0)}},A:function(T,k,P,C,j,V,K,ne){var fe=de();try{we(T)(k,P,C,j,V,K,ne)}catch(ge){if(ce(fe),ge!==ge+0)throw ge;he(1,0)}},ka:function(T,k,P,C,j,V,K,ne,fe){var ge=de();try{we(T)(k,P,C,j,V,K,ne,fe)}catch(De){if(ce(ge),De!==De+0)throw De;he(1,0)}},C:function(T,k,P,C,j,V,K,ne,fe,ge,De){var Ke=de();try{we(T)(k,P,C,j,V,K,ne,fe,ge,De)}catch(He){if(ce(Ke),He!==He+0)throw He;he(1,0)}},D:function(T,k,P,C,j,V,K,ne,fe,ge,De,Ke,He,W,_e,Me){var tt=de();try{we(T)(k,P,C,j,V,K,ne,fe,ge,De,Ke,He,W,_e,Me)}catch(ht){if(ce(tt),ht!==ht+0)throw ht;he(1,0)}},fa:function(T,k,P,C,j,V,K,ne){var fe=de();try{nn(T,k,P,C,j,V,K,ne)}catch(ge){if(ce(fe),ge!==ge+0)throw ge;he(1,0)}},da:function(T,k,P,C,j,V,K,ne,fe,ge,De,Ke){var He=de();try{sn(T,k,P,C,j,V,K,ne,fe,ge,De,Ke)}catch(W){if(ce(He),W!==W+0)throw W;he(1,0)}},ea:function(T,k,P,C,j,V){var K=de();try{rn(T,k,P,C,j,V)}catch(ne){if(ce(K),ne!==ne+0)throw ne;he(1,0)}},o:function(T){return T},a:X||n.wasmMemory,G:function(T){Be=T},la:Gt,z:function(T,k,P,C){return Gt(T,k,P,C)}};(function(){function T(j,V){n.asm=j.exports,re.qc.push(n.asm.sb),je=n.asm.ub,Ve.unshift(n.asm.Va),J=V,E||(ze--,n.monitorRunDependencies&&n.monitorRunDependencies(ze),ze==0&&Ye&&(j=Ye,Ye=null,j()))}function k(j){T(j.instance,j.module)}function P(j){return function(){if(!G&&(A||I)){if(typeof fetch=="function"&&!Oe.startsWith("file://"))return fetch(Oe,{credentials:"same-origin"}).then(function(V){if(!V.ok)throw"failed to load wasm binary file at '"+Oe+"'";return V.arrayBuffer()}).catch(function(){return lt()});if(f)return new Promise(function(V,K){f(Oe,function(ne){V(new Uint8Array(ne))},K)})}return Promise.resolve().then(function(){return lt()})}().then(function(V){return WebAssembly.instantiate(V,C)}).then(function(V){return V}).then(j,function(V){z("failed to asynchronously prepare wasm: "+V),pe(V)})}var C={a:fn};if(E||(ze++,n.monitorRunDependencies&&n.monitorRunDependencies(ze)),n.instantiateWasm)try{return n.instantiateWasm(C,T)}catch(j){return z("Module.instantiateWasm callback failed with error: "+j),!1}(G||typeof WebAssembly.instantiateStreaming!="function"||ft()||Oe.startsWith("file://")||x||typeof fetch!="function"?P(k):fetch(Oe,{credentials:"same-origin"}).then(function(j){return WebAssembly.instantiateStreaming(j,C).then(k,function(V){return z("wasm streaming compile failed: "+V),z("falling back to ArrayBuffer instantiation"),P(k)})})).catch(r)})(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.Va).apply(null,arguments)},n._OrtInit=function(){return(n._OrtInit=n.asm.Wa).apply(null,arguments)},n._OrtCreateSessionOptions=function(){return(n._OrtCreateSessionOptions=n.asm.Xa).apply(null,arguments)},n._OrtAppendExecutionProvider=function(){return(n._OrtAppendExecutionProvider=n.asm.Ya).apply(null,arguments)},n._OrtAddSessionConfigEntry=function(){return(n._OrtAddSessionConfigEntry=n.asm.Za).apply(null,arguments)},n._OrtReleaseSessionOptions=function(){return(n._OrtReleaseSessionOptions=n.asm._a).apply(null,arguments)},n._OrtCreateSession=function(){return(n._OrtCreateSession=n.asm.$a).apply(null,arguments)},n._OrtReleaseSession=function(){return(n._OrtReleaseSession=n.asm.ab).apply(null,arguments)},n._OrtGetInputCount=function(){return(n._OrtGetInputCount=n.asm.bb).apply(null,arguments)},n._OrtGetOutputCount=function(){return(n._OrtGetOutputCount=n.asm.cb).apply(null,arguments)},n._OrtGetInputName=function(){return(n._OrtGetInputName=n.asm.db).apply(null,arguments)},n._OrtGetOutputName=function(){return(n._OrtGetOutputName=n.asm.eb).apply(null,arguments)},n._OrtFree=function(){return(n._OrtFree=n.asm.fb).apply(null,arguments)},n._OrtCreateTensor=function(){return(n._OrtCreateTensor=n.asm.gb).apply(null,arguments)},n._OrtGetTensorData=function(){return(n._OrtGetTensorData=n.asm.hb).apply(null,arguments)},n._OrtReleaseTensor=function(){return(n._OrtReleaseTensor=n.asm.ib).apply(null,arguments)},n._OrtCreateRunOptions=function(){return(n._OrtCreateRunOptions=n.asm.jb).apply(null,arguments)},n._OrtAddRunConfigEntry=function(){return(n._OrtAddRunConfigEntry=n.asm.kb).apply(null,arguments)},n._OrtReleaseRunOptions=function(){return(n._OrtReleaseRunOptions=n.asm.lb).apply(null,arguments)},n._OrtRun=function(){return(n._OrtRun=n.asm.mb).apply(null,arguments)},n._OrtEndProfiling=function(){return(n._OrtEndProfiling=n.asm.nb).apply(null,arguments)};var Dt=n._pthread_self=function(){return(Dt=n._pthread_self=n.asm.ob).apply(null,arguments)},$t=n._malloc=function(){return($t=n._malloc=n.asm.pb).apply(null,arguments)},Vt=n._free=function(){return(Vt=n._free=n.asm.qb).apply(null,arguments)},qt=n._fflush=function(){return(qt=n._fflush=n.asm.rb).apply(null,arguments)};n.__emscripten_tls_init=function(){return(n.__emscripten_tls_init=n.asm.sb).apply(null,arguments)};var Wt=n.___funcs_on_exit=function(){return(Wt=n.___funcs_on_exit=n.asm.tb).apply(null,arguments)},Ht=n.__emscripten_thread_init=function(){return(Ht=n.__emscripten_thread_init=n.asm.vb).apply(null,arguments)};n.__emscripten_thread_crashed=function(){return(n.__emscripten_thread_crashed=n.asm.wb).apply(null,arguments)};var Ct,Xt=n._emscripten_run_in_main_runtime_thread_js=function(){return(Xt=n._emscripten_run_in_main_runtime_thread_js=n.asm.xb).apply(null,arguments)},Yt=n.__emscripten_proxy_execute_task_queue=function(){return(Yt=n.__emscripten_proxy_execute_task_queue=n.asm.yb).apply(null,arguments)},Rt=n.__emscripten_thread_free_data=function(){return(Rt=n.__emscripten_thread_free_data=n.asm.zb).apply(null,arguments)},Kt=n.__emscripten_thread_exit=function(){return(Kt=n.__emscripten_thread_exit=n.asm.Ab).apply(null,arguments)},he=n._setThrew=function(){return(he=n._setThrew=n.asm.Bb).apply(null,arguments)},Zt=n._emscripten_stack_set_limits=function(){return(Zt=n._emscripten_stack_set_limits=n.asm.Cb).apply(null,arguments)},de=n.stackSave=function(){return(de=n.stackSave=n.asm.Db).apply(null,arguments)},ce=n.stackRestore=function(){return(ce=n.stackRestore=n.asm.Eb).apply(null,arguments)},zt=n.stackAlloc=function(){return(zt=n.stackAlloc=n.asm.Fb).apply(null,arguments)},Ft=n.___cxa_can_catch=function(){return(Ft=n.___cxa_can_catch=n.asm.Gb).apply(null,arguments)},Qt=n.___cxa_is_pointer_type=function(){return(Qt=n.___cxa_is_pointer_type=n.asm.Hb).apply(null,arguments)},Jt=n.dynCall_j=function(){return(Jt=n.dynCall_j=n.asm.Ib).apply(null,arguments)},en=n.dynCall_iiiiij=function(){return(en=n.dynCall_iiiiij=n.asm.Jb).apply(null,arguments)},tn=n.dynCall_jii=function(){return(tn=n.dynCall_jii=n.asm.Kb).apply(null,arguments)},nn=n.dynCall_viiiiij=function(){return(nn=n.dynCall_viiiiij=n.asm.Lb).apply(null,arguments)},rn=n.dynCall_vjji=function(){return(rn=n.dynCall_vjji=n.asm.Mb).apply(null,arguments)},sn=n.dynCall_viiijjjii=function(){return(sn=n.dynCall_viiijjjii=n.asm.Nb).apply(null,arguments)},on=n.dynCall_iij=function(){return(on=n.dynCall_iij=n.asm.Ob).apply(null,arguments)},an=n.dynCall_ji=function(){return(an=n.dynCall_ji=n.asm.Pb).apply(null,arguments)},un=n.dynCall_iiiiiij=function(){return(un=n.dynCall_iiiiiij=n.asm.Qb).apply(null,arguments)},ln=n.dynCall_iiij=function(){return(ln=n.dynCall_iiij=n.asm.Rb).apply(null,arguments)};function cn(){function T(){if(!Ct&&(Ct=!0,n.calledRun=!0,!be)&&(E||rt(Ve),e(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),!E)){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;){var k=n.postRun.shift();Ze.unshift(k)}rt(Ze)}}if(!(0{var s,a=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){var u,h,p;d=d||{},u||(u=d!==void 0?d:{}),u.ready=new Promise(function(O,M){h=O,p=M});var c,l,n,e,r,o,f=Object.assign({},u),g="./this.program",b=(O,M)=>{throw M},_=typeof window=="object",y=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v="";w?(v=y?i(908).dirname(v)+"/":"//",o=()=>{r||(e=i(1384),r=i(908))},c=function(O,M){return o(),O=r.normalize(O),e.readFileSync(O,M?void 0:"utf8")},n=O=>((O=c(O,!0)).buffer||(O=new Uint8Array(O)),O),l=(O,M,N)=>{o(),O=r.normalize(O),e.readFile(O,function(B,U){B?N(B):M(U.buffer)})},1{if(x||0{var M=new XMLHttpRequest;return M.open("GET",O,!1),M.send(null),M.responseText},y&&(n=O=>{var M=new XMLHttpRequest;return M.open("GET",O,!1),M.responseType="arraybuffer",M.send(null),new Uint8Array(M.response)}),l=(O,M,N)=>{var B=new XMLHttpRequest;B.open("GET",O,!0),B.responseType="arraybuffer",B.onload=()=>{B.status==200||B.status==0&&B.response?M(B.response):N()},B.onerror=N,B.send(null)});var S,A=u.print||console.log.bind(console),I=u.printErr||console.warn.bind(console);Object.assign(u,f),f=null,u.thisProgram&&(g=u.thisProgram),u.quit&&(b=u.quit),u.wasmBinary&&(S=u.wasmBinary);var x=u.noExitRuntime||!1;typeof WebAssembly!="object"&&Ie("no native wasm support detected");var E,F,R,$,L,G,D=!1,z=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Z(O,M,N){var B=(M>>>=0)+N;for(N=M;O[N]&&!(N>=B);)++N;if(16(U=(240&U)==224?(15&U)<<12|H<<6|Y:(7&U)<<18|H<<12|Y<<6|63&O[M++])?B+=String.fromCharCode(U):(U-=65536,B+=String.fromCharCode(55296|U>>10,56320|1023&U))}}else B+=String.fromCharCode(U)}return B}function X(O,M){return(O>>>=0)?Z($,O,M):""}function J(O,M,N,B){if(!(0>>=0;B=N+B-1;for(var H=0;H=Y&&(Y=65536+((1023&Y)<<10)|1023&O.charCodeAt(++H)),127>=Y){if(N>=B)break;M[N++>>>0]=Y}else{if(2047>=Y){if(N+1>=B)break;M[N++>>>0]=192|Y>>6}else{if(65535>=Y){if(N+2>=B)break;M[N++>>>0]=224|Y>>12}else{if(N+3>=B)break;M[N++>>>0]=240|Y>>18,M[N++>>>0]=128|Y>>12&63}M[N++>>>0]=128|Y>>6&63}M[N++>>>0]=128|63&Y}}return M[N>>>0]=0,N-U}function ee(O){for(var M=0,N=0;N=B?M++:2047>=B?M+=2:55296<=B&&57343>=B?(M+=4,++N):M+=3}return M}function ue(){var O=E.buffer;F=O,u.HEAP8=R=new Int8Array(O),u.HEAP16=new Int16Array(O),u.HEAP32=L=new Int32Array(O),u.HEAPU8=$=new Uint8Array(O),u.HEAPU16=new Uint16Array(O),u.HEAPU32=G=new Uint32Array(O),u.HEAPF32=new Float32Array(O),u.HEAPF64=new Float64Array(O)}var Se,ve=[],se=[],ye=[],be=[],Pe=0;function Ne(){var O=u.preRun.shift();ve.unshift(O)}var xe,Fe=0,Ce=null;function Ie(O){throw u.onAbort&&u.onAbort(O),I(O="Aborted("+O+")"),D=!0,O=new WebAssembly.RuntimeError(O+". Build with -sASSERTIONS for more info."),p(O),O}function Ae(){return xe.startsWith("data:application/octet-stream;base64,")}if(xe="ort-wasm.wasm",!Ae()){var je=xe;xe=u.locateFile?u.locateFile(je,v):v+je}function Ge(){var O=xe;try{if(O==xe&&S)return new Uint8Array(S);if(n)return n(O);throw"both async and sync fetching of the wasm failed"}catch(M){Ie(M)}}function Ve(O){this.name="ExitStatus",this.message="Program terminated with exit("+O+")",this.status=O}function Xe(O){for(;0>2>>>0]=M},this.Eb=function(){return G[this.zb+4>>2>>>0]},this.Sb=function(M){G[this.zb+8>>2>>>0]=M},this.Wb=function(){return G[this.zb+8>>2>>>0]},this.Tb=function(){L[this.zb>>2>>>0]=0},this.Ib=function(M){R[this.zb+12>>0>>>0]=M?1:0},this.Pb=function(){return R[this.zb+12>>0>>>0]!=0},this.Jb=function(M){R[this.zb+13>>0>>>0]=M?1:0},this.Lb=function(){return R[this.zb+13>>0>>>0]!=0},this.Rb=function(M,N){this.Fb(0),this.Ub(M),this.Sb(N),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){L[this.zb>>2>>>0]+=1},this.Xb=function(){var M=L[this.zb>>2>>>0];return L[this.zb>>2>>>0]=M-1,M===1},this.Fb=function(M){G[this.zb+16>>2>>>0]=M},this.Ob=function(){return G[this.zb+16>>2>>>0]},this.Qb=function(){if(mt(this.Eb()))return G[this.Db>>2>>>0];var M=this.Ob();return M!==0?M:this.Db}}function ze(O){return st(new Oe(O).zb)}var Ye=[];function pe(O){var M=Ye[O];return M||(O>=Ye.length&&(Ye.length=O+1),Ye[O]=M=Se.get(O)),M}function ft(O){var M=ee(O)+1,N=we(M);return N&&J(O,R,N,M),N}var lt={};function Ot(){if(!Qe){var O,M={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(O in lt)lt[O]===void 0?delete M[O]:M[O]=lt[O];var N=[];for(O in M)N.push(O+"="+M[O]);Qe=N}return Qe}var Qe,ct=[null,[],[]];function dt(O,M){var N=ct[O];M===0||M===10?((O===1?A:I)(Z(N,0)),N.length=0):N.push(M)}var Re=0;function it(O){return O%4==0&&(O%100!=0||O%400==0)}var re=[31,29,31,30,31,30,31,31,30,31,30,31],rt=[31,28,31,30,31,30,31,31,30,31,30,31];function Et(O,M,N,B){function U(q,me,ke){for(q=typeof q=="number"?q.toString():q||"";q.lengthet?-1:0We-q.getDate())){q.setDate(q.getDate()+me);break}me-=We-q.getDate()+1,q.setDate(1),11>ke?q.setMonth(ke+1):(q.setMonth(0),q.setFullYear(q.getFullYear()+1))}return ke=new Date(q.getFullYear()+1,0,4),me=te(new Date(q.getFullYear(),0,4)),ke=te(ke),0>=Y(me,q)?0>=Y(ke,q)?q.getFullYear()+1:q.getFullYear():q.getFullYear()-1}var le=L[B+40>>2>>>0];for(var Te in B={$b:L[B>>2>>>0],Zb:L[B+4>>2>>>0],Gb:L[B+8>>2>>>0],Kb:L[B+12>>2>>>0],Hb:L[B+16>>2>>>0],Cb:L[B+20>>2>>>0],Ab:L[B+24>>2>>>0],Bb:L[B+28>>2>>>0],bc:L[B+32>>2>>>0],Yb:L[B+36>>2>>>0],ac:le?X(le):""},N=X(N),le={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})N=N.replace(new RegExp(Te,"g"),le[Te]);var $e="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Le="January February March April May June July August September October November December".split(" ");for(Te in le={"%a":function(q){return $e[q.Ab].substring(0,3)},"%A":function(q){return $e[q.Ab]},"%b":function(q){return Le[q.Hb].substring(0,3)},"%B":function(q){return Le[q.Hb]},"%C":function(q){return H((q.Cb+1900)/100|0,2)},"%d":function(q){return H(q.Kb,2)},"%e":function(q){return U(q.Kb,2," ")},"%g":function(q){return Q(q).toString().substring(2)},"%G":function(q){return Q(q)},"%H":function(q){return H(q.Gb,2)},"%I":function(q){return(q=q.Gb)==0?q=12:12q.Gb?"AM":"PM"},"%S":function(q){return H(q.$b,2)},"%t":function(){return" "},"%u":function(q){return q.Ab||7},"%U":function(q){return H(Math.floor((q.Bb+7-q.Ab)/7),2)},"%V":function(q){var me=Math.floor((q.Bb+7-(q.Ab+6)%7)/7);if(2>=(q.Ab+371-q.Bb-2)%7&&me++,me)me==53&&((ke=(q.Ab+371-q.Bb)%7)==4||ke==3&&it(q.Cb)||(me=1));else{me=52;var ke=(q.Ab+7-q.Bb-1)%7;(ke==4||ke==5&&it(q.Cb%400-1))&&me++}return H(me,2)},"%w":function(q){return q.Ab},"%W":function(q){return H(Math.floor((q.Bb+7-(q.Ab+6)%7)/7),2)},"%y":function(q){return(q.Cb+1900).toString().substring(2)},"%Y":function(q){return q.Cb+1900},"%z":function(q){var me=0<=(q=q.Yb);return q=Math.abs(q)/60,(me?"+":"-")+("0000"+(q/60*100+q%60)).slice(-4)},"%Z":function(q){return q.ac},"%%":function(){return"%"}},N=N.replace(/%%/g,"\0\0"),le)N.includes(Te)&&(N=N.replace(new RegExp(Te,"g"),le[Te](B)));return Te=function(q){var me=Array(ee(q)+1);return J(q,me,0,me.length),me}(N=N.replace(/\0\0/g,"%")),Te.length>M?0:(R.set(Te,O>>>0),Te.length-1)}var Pt={a:function(O){return we(O+24)+24},m:function(O){return(O=new Oe(O)).Pb()||(O.Ib(!0),qe--),O.Jb(!1),Ze.push(O),O.Nb(),O.Qb()},ia:function(O){throw I("Unexpected exception thrown, this is not properly supported - aborting"),D=!0,O},w:function(){ae(0);var O=Ze.pop();if(O.Xb()&&!O.Lb()){var M=O.Wb();M&&pe(M)(O.Db),ze(O.Db)}Ue=0},d:function(){var O=Ue;if(!O)return Re=0;var M=new Oe(O);M.Fb(O);var N=M.Eb();if(!N)return Re=0,O;for(var B=Array.prototype.slice.call(arguments),U=0;U>>2]+4294967296*L[O+4>>>2])),L[M>>2>>>0]=O.getUTCSeconds(),L[M+4>>2>>>0]=O.getUTCMinutes(),L[M+8>>2>>>0]=O.getUTCHours(),L[M+12>>2>>>0]=O.getUTCDate(),L[M+16>>2>>>0]=O.getUTCMonth(),L[M+20>>2>>>0]=O.getUTCFullYear()-1900,L[M+24>>2>>>0]=O.getUTCDay(),L[M+28>>2>>>0]=(O.getTime()-Date.UTC(O.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(O,M){O=new Date(1e3*(G[O>>>2]+4294967296*L[O+4>>>2])),L[M>>2>>>0]=O.getSeconds(),L[M+4>>2>>>0]=O.getMinutes(),L[M+8>>2>>>0]=O.getHours(),L[M+12>>2>>>0]=O.getDate(),L[M+16>>2>>>0]=O.getMonth(),L[M+20>>2>>>0]=O.getFullYear()-1900,L[M+24>>2>>>0]=O.getDay();var N=new Date(O.getFullYear(),0,1);L[M+28>>2>>>0]=(O.getTime()-N.getTime())/864e5|0,L[M+36>>2>>>0]=-60*O.getTimezoneOffset();var B=new Date(O.getFullYear(),6,1).getTimezoneOffset();N=N.getTimezoneOffset(),L[M+32>>2>>>0]=0|(B!=N&&O.getTimezoneOffset()==Math.min(N,B))},Fa:function(O){var M=new Date(L[O+20>>2>>>0]+1900,L[O+16>>2>>>0],L[O+12>>2>>>0],L[O+8>>2>>>0],L[O+4>>2>>>0],L[O>>2>>>0],0),N=L[O+32>>2>>>0],B=M.getTimezoneOffset(),U=new Date(M.getFullYear(),0,1),H=new Date(M.getFullYear(),6,1).getTimezoneOffset(),Y=U.getTimezoneOffset(),te=Math.min(Y,H);return 0>N?L[O+32>>2>>>0]=+(H!=Y&&te==B):0>2>>>0]=M.getDay(),L[O+28>>2>>>0]=(M.getTime()-U.getTime())/864e5|0,L[O>>2>>>0]=M.getSeconds(),L[O+4>>2>>>0]=M.getMinutes(),L[O+8>>2>>>0]=M.getHours(),L[O+12>>2>>>0]=M.getDate(),L[O+16>>2>>>0]=M.getMonth(),M.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function O(M,N,B){O.Vb||(O.Vb=!0,function(U,H,Y){function te(Le){return(Le=Le.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Le[1]:"GMT"}var Q=new Date().getFullYear(),le=new Date(Q,0,1),Te=new Date(Q,6,1);Q=le.getTimezoneOffset();var $e=Te.getTimezoneOffset();L[U>>2>>>0]=60*Math.max(Q,$e),L[H>>2>>>0]=+(Q!=$e),U=te(le),H=te(Te),U=ft(U),H=ft(H),$e>2>>>0]=U,G[Y+4>>2>>>0]=H):(G[Y>>2>>>0]=H,G[Y+4>>2>>>0]=U)}(M,N,B))},B:function(){Ie("")},ma:function(){return 4294901760},I:w?()=>{var O=process.hrtime();return 1e3*O[0]+O[1]/1e6}:()=>performance.now(),xa:function(O,M,N){$.copyWithin(O>>>0,M>>>0,M+N>>>0)},G:function(O){var M=$.length;if(4294901760<(O>>>=0))return!1;for(var N=1;4>=N;N*=2){var B=M*(1+.2/N);B=Math.min(B,O+100663296);var U=Math;B=Math.max(O,B),U=U.min.call(U,4294901760,B+(65536-B%65536)%65536);e:{try{E.grow(U-F.byteLength+65535>>>16),ue();var H=1;break e}catch{}H=void 0}if(H)return!0}return!1},va:function(O,M){var N=0;return Ot().forEach(function(B,U){var H=M+N;for(U=G[O+4*U>>2>>>0]=H,H=0;H>0>>>0]=B.charCodeAt(H);R[U>>0>>>0]=0,N+=B.length+1}),0},wa:function(O,M){var N=Ot();G[O>>2>>>0]=N.length;var B=0;return N.forEach(function(U){B+=U.length+1}),G[M>>2>>>0]=B,0},ba:function(O){x||0>2>>>0],te=G[M+4>>2>>>0];M+=8;for(var Q=0;Q>>0]);U+=te}return G[B>>2>>>0]=U,0},c:function(){return Re},ja:function O(M,N){O.Mb||(O.Mb=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var U=new Uint8Array(1);return()=>(crypto.getRandomValues(U),U[0])}if(w)try{var H=i(Object(function(){var Y=new Error("Cannot find module 'crypto'");throw Y.code="MODULE_NOT_FOUND",Y}()));return()=>H.randomBytes(1)[0]}catch{}return()=>Ie("randomDevice")}());for(var B=0;B>0>>>0]=O.Mb();return 0},ea:function(O,M,N){var B=ie();try{return pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},fa:function(O,M,N){var B=ie();try{return pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},J:function(O){var M=ie();try{return pe(O)()}catch(N){if(oe(M),N!==N+0)throw N;ae(1,0)}},e:function(O,M){var N=ie();try{return pe(O)(M)}catch(B){if(oe(N),B!==B+0)throw B;ae(1,0)}},N:function(O,M,N){var B=ie();try{return pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},O:function(O,M,N){var B=ie();try{return pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},j:function(O,M,N){var B=ie();try{return pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},o:function(O,M,N,B){var U=ie();try{return pe(O)(M,N,B)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},p:function(O,M,N,B,U){var H=ie();try{return pe(O)(M,N,B,U)}catch(Y){if(oe(H),Y!==Y+0)throw Y;ae(1,0)}},M:function(O,M,N,B,U,H){var Y=ie();try{return pe(O)(M,N,B,U,H)}catch(te){if(oe(Y),te!==te+0)throw te;ae(1,0)}},r:function(O,M,N,B,U,H){var Y=ie();try{return pe(O)(M,N,B,U,H)}catch(te){if(oe(Y),te!==te+0)throw te;ae(1,0)}},v:function(O,M,N,B,U,H,Y){var te=ie();try{return pe(O)(M,N,B,U,H,Y)}catch(Q){if(oe(te),Q!==Q+0)throw Q;ae(1,0)}},K:function(O,M,N,B,U,H,Y,te){var Q=ie();try{return pe(O)(M,N,B,U,H,Y,te)}catch(le){if(oe(Q),le!==le+0)throw le;ae(1,0)}},D:function(O,M,N,B,U,H,Y,te,Q,le,Te,$e){var Le=ie();try{return pe(O)(M,N,B,U,H,Y,te,Q,le,Te,$e)}catch(q){if(oe(Le),q!==q+0)throw q;ae(1,0)}},X:function(O,M,N,B,U,H,Y,te){var Q=ie();try{return At(O,M,N,B,U,H,Y,te)}catch(le){if(oe(Q),le!==le+0)throw le;ae(1,0)}},V:function(O,M,N,B,U,H,Y){var te=ie();try{return _t(O,M,N,B,U,H,Y)}catch(Q){if(oe(te),Q!==Q+0)throw Q;ae(1,0)}},U:function(O,M,N,B,U){var H=ie();try{return It(O,M,N,B,U)}catch(Y){if(oe(H),Y!==Y+0)throw Y;ae(1,0)}},Z:function(O,M,N,B){var U=ie();try{return Tt(O,M,N,B)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},W:function(O){var M=ie();try{return bt(O)}catch(N){if(oe(M),N!==N+0)throw N;ae(1,0)}},Y:function(O,M){var N=ie();try{return St(O,M)}catch(B){if(oe(N),B!==B+0)throw B;ae(1,0)}},T:function(O,M,N){var B=ie();try{return yt(O,M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},f:function(O){var M=ie();try{pe(O)()}catch(N){if(oe(M),N!==N+0)throw N;ae(1,0)}},q:function(O,M){var N=ie();try{pe(O)(M)}catch(B){if(oe(N),B!==B+0)throw B;ae(1,0)}},h:function(O,M,N){var B=ie();try{pe(O)(M,N)}catch(U){if(oe(B),U!==U+0)throw U;ae(1,0)}},da:function(O,M,N,B){var U=ie();try{pe(O)(M,N,B)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},l:function(O,M,N,B){var U=ie();try{pe(O)(M,N,B)}catch(H){if(oe(U),H!==H+0)throw H;ae(1,0)}},t:function(O,M,N,B,U){var H=ie();try{pe(O)(M,N,B,U)}catch(Y){if(oe(H),Y!==Y+0)throw Y;ae(1,0)}},u:function(O,M,N,B,U,H){var Y=ie();try{pe(O)(M,N,B,U,H)}catch(te){if(oe(Y),te!==te+0)throw te;ae(1,0)}},x:function(O,M,N,B,U,H,Y){var te=ie();try{pe(O)(M,N,B,U,H,Y)}catch(Q){if(oe(te),Q!==Q+0)throw Q;ae(1,0)}},z:function(O,M,N,B,U,H,Y,te){var Q=ie();try{pe(O)(M,N,B,U,H,Y,te)}catch(le){if(oe(Q),le!==le+0)throw le;ae(1,0)}},ga:function(O,M,N,B,U,H,Y,te,Q){var le=ie();try{pe(O)(M,N,B,U,H,Y,te,Q)}catch(Te){if(oe(le),Te!==Te+0)throw Te;ae(1,0)}},A:function(O,M,N,B,U,H,Y,te,Q,le,Te){var $e=ie();try{pe(O)(M,N,B,U,H,Y,te,Q,le,Te)}catch(Le){if(oe($e),Le!==Le+0)throw Le;ae(1,0)}},C:function(O,M,N,B,U,H,Y,te,Q,le,Te,$e,Le,q,me,ke){var We=ie();try{pe(O)(M,N,B,U,H,Y,te,Q,le,Te,$e,Le,q,me,ke)}catch(et){if(oe(We),et!==et+0)throw et;ae(1,0)}},aa:function(O,M,N,B,U,H,Y,te){var Q=ie();try{wt(O,M,N,B,U,H,Y,te)}catch(le){if(oe(Q),le!==le+0)throw le;ae(1,0)}},_:function(O,M,N,B,U,H,Y,te,Q,le,Te,$e){var Le=ie();try{xt(O,M,N,B,U,H,Y,te,Q,le,Te,$e)}catch(q){if(oe(Le),q!==q+0)throw q;ae(1,0)}},$:function(O,M,N,B,U,H){var Y=ie();try{vt(O,M,N,B,U,H)}catch(te){if(oe(Y),te!==te+0)throw te;ae(1,0)}},n:function(O){return O},F:function(O){Re=O},ha:Et,y:function(O,M,N,B){return Et(O,M,N,B)}};(function(){function O(U){u.asm=U.exports,E=u.asm.Ka,ue(),Se=u.asm.ib,se.unshift(u.asm.La),Fe--,u.monitorRunDependencies&&u.monitorRunDependencies(Fe),Fe==0&&Ce&&(U=Ce,Ce=null,U())}function M(U){O(U.instance)}function N(U){return function(){if(!S&&(_||y)){if(typeof fetch=="function"&&!xe.startsWith("file://"))return fetch(xe,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+xe+"'";return H.arrayBuffer()}).catch(function(){return Ge()});if(l)return new Promise(function(H,Y){l(xe,function(te){H(new Uint8Array(te))},Y)})}return Promise.resolve().then(function(){return Ge()})}().then(function(H){return WebAssembly.instantiate(H,B)}).then(function(H){return H}).then(U,function(H){I("failed to asynchronously prepare wasm: "+H),Ie(H)})}var B={a:Pt};if(Fe++,u.monitorRunDependencies&&u.monitorRunDependencies(Fe),u.instantiateWasm)try{return u.instantiateWasm(B,O)}catch(U){return I("Module.instantiateWasm callback failed with error: "+U),!1}(S||typeof WebAssembly.instantiateStreaming!="function"||Ae()||xe.startsWith("file://")||w||typeof fetch!="function"?N(M):fetch(xe,{credentials:"same-origin"}).then(function(U){return WebAssembly.instantiateStreaming(U,B).then(M,function(H){return I("wasm streaming compile failed: "+H),I("falling back to ArrayBuffer instantiation"),N(M)})})).catch(p)})(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.La).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Ma).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Na).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Oa).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Pa).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm.Qa).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.Ra).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.Sa).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.Ta).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.Ua).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.Va).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.Wa).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.Xa).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.Ya).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.Za).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm._a).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.$a).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.ab).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.bb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.cb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.db).apply(null,arguments)};var Je,we=u._malloc=function(){return(we=u._malloc=u.asm.eb).apply(null,arguments)},st=u._free=function(){return(st=u._free=u.asm.fb).apply(null,arguments)},pt=u._fflush=function(){return(pt=u._fflush=u.asm.gb).apply(null,arguments)},ot=u.___funcs_on_exit=function(){return(ot=u.___funcs_on_exit=u.asm.hb).apply(null,arguments)},ae=u._setThrew=function(){return(ae=u._setThrew=u.asm.jb).apply(null,arguments)},ie=u.stackSave=function(){return(ie=u.stackSave=u.asm.kb).apply(null,arguments)},oe=u.stackRestore=function(){return(oe=u.stackRestore=u.asm.lb).apply(null,arguments)},gt=u.stackAlloc=function(){return(gt=u.stackAlloc=u.asm.mb).apply(null,arguments)},at=u.___cxa_can_catch=function(){return(at=u.___cxa_can_catch=u.asm.nb).apply(null,arguments)},mt=u.___cxa_is_pointer_type=function(){return(mt=u.___cxa_is_pointer_type=u.asm.ob).apply(null,arguments)},bt=u.dynCall_j=function(){return(bt=u.dynCall_j=u.asm.pb).apply(null,arguments)},_t=u.dynCall_iiiiij=function(){return(_t=u.dynCall_iiiiij=u.asm.qb).apply(null,arguments)},yt=u.dynCall_jii=function(){return(yt=u.dynCall_jii=u.asm.rb).apply(null,arguments)},wt=u.dynCall_viiiiij=function(){return(wt=u.dynCall_viiiiij=u.asm.sb).apply(null,arguments)},vt=u.dynCall_vjji=function(){return(vt=u.dynCall_vjji=u.asm.tb).apply(null,arguments)},xt=u.dynCall_viiijjjii=function(){return(xt=u.dynCall_viiijjjii=u.asm.ub).apply(null,arguments)},Tt=u.dynCall_iij=function(){return(Tt=u.dynCall_iij=u.asm.vb).apply(null,arguments)},St=u.dynCall_ji=function(){return(St=u.dynCall_ji=u.asm.wb).apply(null,arguments)},At=u.dynCall_iiiiiij=function(){return(At=u.dynCall_iiiiiij=u.asm.xb).apply(null,arguments)},It=u.dynCall_iiij=function(){return(It=u.dynCall_iiij=u.asm.yb).apply(null,arguments)};function kt(){function O(){if(!Je&&(Je=!0,u.calledRun=!0,!D)){if(Xe(se),h(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;){var M=u.postRun.shift();be.unshift(M)}Xe(be)}}if(!(0{m.exports=function(t,i){for(var s=new Array(arguments.length-1),a=0,d=2,u=!0;d{var i=t;i.length=function(h){var p=h.length;if(!p)return 0;for(var c=0;--p%4>1&&h.charAt(p)==="=";)++c;return Math.ceil(3*h.length)/4-c};for(var s=new Array(64),a=new Array(123),d=0;d<64;)a[s[d]=d<26?d+65:d<52?d+71:d<62?d-4:d-59|43]=d++;i.encode=function(h,p,c){for(var l,n=null,e=[],r=0,o=0;p>2],l=(3&f)<<4,o=1;break;case 1:e[r++]=s[l|f>>4],l=(15&f)<<2,o=2;break;case 2:e[r++]=s[l|f>>6],e[r++]=s[63&f],o=0}r>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,e)),r=0)}return o&&(e[r++]=s[l],e[r++]=61,o===1&&(e[r++]=61)),n?(r&&n.push(String.fromCharCode.apply(String,e.slice(0,r))),n.join("")):String.fromCharCode.apply(String,e.slice(0,r))};var u="invalid encoding";i.decode=function(h,p,c){for(var l,n=c,e=0,r=0;r1)break;if((o=a[o])===void 0)throw Error(u);switch(e){case 0:l=o,e=1;break;case 1:p[c++]=l<<2|(48&o)>>4,l=o,e=2;break;case 2:p[c++]=(15&l)<<4|(60&o)>>2,l=o,e=3;break;case 3:p[c++]=(3&l)<<6|o,e=0}}if(e===1)throw Error(u);return c-n},i.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9211:m=>{function t(){this._listeners={}}m.exports=t,t.prototype.on=function(i,s,a){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:s,ctx:a||this}),this},t.prototype.off=function(i,s){if(i===void 0)this._listeners={};else if(s===void 0)this._listeners[i]=[];else for(var a=this._listeners[i],d=0;d{function t(u){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),p=new Uint8Array(h.buffer),c=p[3]===128;function l(o,f,g){h[0]=o,f[g]=p[0],f[g+1]=p[1],f[g+2]=p[2],f[g+3]=p[3]}function n(o,f,g){h[0]=o,f[g]=p[3],f[g+1]=p[2],f[g+2]=p[1],f[g+3]=p[0]}function e(o,f){return p[0]=o[f],p[1]=o[f+1],p[2]=o[f+2],p[3]=o[f+3],h[0]}function r(o,f){return p[3]=o[f],p[2]=o[f+1],p[1]=o[f+2],p[0]=o[f+3],h[0]}u.writeFloatLE=c?l:n,u.writeFloatBE=c?n:l,u.readFloatLE=c?e:r,u.readFloatBE=c?r:e}():function(){function h(c,l,n,e){var r=l<0?1:0;if(r&&(l=-l),l===0)c(1/l>0?0:2147483648,n,e);else if(isNaN(l))c(2143289344,n,e);else if(l>34028234663852886e22)c((r<<31|2139095040)>>>0,n,e);else if(l<11754943508222875e-54)c((r<<31|Math.round(l/1401298464324817e-60))>>>0,n,e);else{var o=Math.floor(Math.log(l)/Math.LN2);c((r<<31|o+127<<23|8388607&Math.round(l*Math.pow(2,-o)*8388608))>>>0,n,e)}}function p(c,l,n){var e=c(l,n),r=2*(e>>31)+1,o=e>>>23&255,f=8388607&e;return o===255?f?NaN:r*(1/0):o===0?1401298464324817e-60*r*f:r*Math.pow(2,o-150)*(f+8388608)}u.writeFloatLE=h.bind(null,i),u.writeFloatBE=h.bind(null,s),u.readFloatLE=p.bind(null,a),u.readFloatBE=p.bind(null,d)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),p=new Uint8Array(h.buffer),c=p[7]===128;function l(o,f,g){h[0]=o,f[g]=p[0],f[g+1]=p[1],f[g+2]=p[2],f[g+3]=p[3],f[g+4]=p[4],f[g+5]=p[5],f[g+6]=p[6],f[g+7]=p[7]}function n(o,f,g){h[0]=o,f[g]=p[7],f[g+1]=p[6],f[g+2]=p[5],f[g+3]=p[4],f[g+4]=p[3],f[g+5]=p[2],f[g+6]=p[1],f[g+7]=p[0]}function e(o,f){return p[0]=o[f],p[1]=o[f+1],p[2]=o[f+2],p[3]=o[f+3],p[4]=o[f+4],p[5]=o[f+5],p[6]=o[f+6],p[7]=o[f+7],h[0]}function r(o,f){return p[7]=o[f],p[6]=o[f+1],p[5]=o[f+2],p[4]=o[f+3],p[3]=o[f+4],p[2]=o[f+5],p[1]=o[f+6],p[0]=o[f+7],h[0]}u.writeDoubleLE=c?l:n,u.writeDoubleBE=c?n:l,u.readDoubleLE=c?e:r,u.readDoubleBE=c?r:e}():function(){function h(c,l,n,e,r,o){var f=e<0?1:0;if(f&&(e=-e),e===0)c(0,r,o+l),c(1/e>0?0:2147483648,r,o+n);else if(isNaN(e))c(0,r,o+l),c(2146959360,r,o+n);else if(e>17976931348623157e292)c(0,r,o+l),c((f<<31|2146435072)>>>0,r,o+n);else{var g;if(e<22250738585072014e-324)c((g=e/5e-324)>>>0,r,o+l),c((f<<31|g/4294967296)>>>0,r,o+n);else{var b=Math.floor(Math.log(e)/Math.LN2);b===1024&&(b=1023),c(4503599627370496*(g=e*Math.pow(2,-b))>>>0,r,o+l),c((f<<31|b+1023<<20|1048576*g&1048575)>>>0,r,o+n)}}}function p(c,l,n,e,r){var o=c(e,r+l),f=c(e,r+n),g=2*(f>>31)+1,b=f>>>20&2047,_=4294967296*(1048575&f)+o;return b===2047?_?NaN:g*(1/0):b===0?5e-324*g*_:g*Math.pow(2,b-1075)*(_+4503599627370496)}u.writeDoubleLE=h.bind(null,i,0,4),u.writeDoubleBE=h.bind(null,s,4,0),u.readDoubleLE=p.bind(null,a,0,4),u.readDoubleBE=p.bind(null,d,4,0)}(),u}function i(u,h,p){h[p]=255&u,h[p+1]=u>>>8&255,h[p+2]=u>>>16&255,h[p+3]=u>>>24}function s(u,h,p){h[p]=u>>>24,h[p+1]=u>>>16&255,h[p+2]=u>>>8&255,h[p+3]=255&u}function a(u,h){return(u[h]|u[h+1]<<8|u[h+2]<<16|u[h+3]<<24)>>>0}function d(u,h){return(u[h]<<24|u[h+1]<<16|u[h+2]<<8|u[h+3])>>>0}m.exports=t(t)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(m){}return null}module.exports=inquire},6662:m=>{m.exports=function(t,i,s){var a=s||8192,d=a>>>1,u=null,h=a;return function(p){if(p<1||p>d)return t(p);h+p>a&&(u=t(a),h=0);var c=i.call(u,h,h+=p);return 7&h&&(h=1+(7|h)),c}}},4997:(m,t)=>{var i=t;i.length=function(s){for(var a=0,d=0,u=0;u191&&u<224?p[c++]=(31&u)<<6|63&s[a++]:u>239&&u<365?(u=((7&u)<<18|(63&s[a++])<<12|(63&s[a++])<<6|63&s[a++])-65536,p[c++]=55296+(u>>10),p[c++]=56320+(1023&u)):p[c++]=(15&u)<<12|(63&s[a++])<<6|63&s[a++],c>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,p)),c=0);return h?(c&&h.push(String.fromCharCode.apply(String,p.slice(0,c))),h.join("")):String.fromCharCode.apply(String,p.slice(0,c))},i.write=function(s,a,d){for(var u,h,p=d,c=0;c>6|192,a[d++]=63&u|128):(64512&u)==55296&&(64512&(h=s.charCodeAt(c+1)))==56320?(u=65536+((1023&u)<<10)+(1023&h),++c,a[d++]=u>>18|240,a[d++]=u>>12&63|128,a[d++]=u>>6&63|128,a[d++]=63&u|128):(a[d++]=u>>12|224,a[d++]=u>>6&63|128,a[d++]=63&u|128);return d-p}},3442:(m,t)=>{t.__esModule=!0;var i=function(){function s(a){if(!a)throw new TypeError("Invalid argument; `value` has no value.");this.value=s.EMPTY,a&&s.isGuid(a)&&(this.value=a)}return s.isGuid=function(a){var d=a.toString();return a&&(a instanceof s||s.validator.test(d))},s.create=function(){return new s([s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-"))},s.createEmpty=function(){return new s("emptyguid")},s.parse=function(a){return new s(a)},s.raw=function(){return[s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-")},s.gen=function(a){for(var d="",u=0;u{m.exports=i;var t=null;try{t=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{}function i(x,E,F){this.low=0|x,this.high=0|E,this.unsigned=!!F}function s(x){return(x&&x.__isLong__)===!0}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=s;var a={},d={};function u(x,E){var F,R,$;return E?($=0<=(x>>>=0)&&x<256)&&(R=d[x])?R:(F=p(x,(0|x)<0?-1:0,!0),$&&(d[x]=F),F):($=-128<=(x|=0)&&x<128)&&(R=a[x])?R:(F=p(x,x<0?-1:0,!1),$&&(a[x]=F),F)}function h(x,E){if(isNaN(x))return E?b:g;if(E){if(x<0)return b;if(x>=r)return S}else{if(x<=-o)return A;if(x+1>=o)return v}return x<0?h(-x,E).neg():p(x%e|0,x/e|0,E)}function p(x,E,F){return new i(x,E,F)}i.fromInt=u,i.fromNumber=h,i.fromBits=p;var c=Math.pow;function l(x,E,F){if(x.length===0)throw Error("empty string");if(x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return g;if(typeof E=="number"?(F=E,E=!1):E=!!E,(F=F||10)<2||360)throw Error("interior hyphen");if(R===0)return l(x.substring(1),E,F).neg();for(var $=h(c(F,8)),L=g,G=0;G>>0:this.low},I.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},I.toString=function(x){if((x=x||10)<2||36>>0).toString(x);if((L=D).isZero())return z+G;for(;z.length<6;)z="0"+z;G=""+z+G}},I.getHighBits=function(){return this.high},I.getHighBitsUnsigned=function(){return this.high>>>0},I.getLowBits=function(){return this.low},I.getLowBitsUnsigned=function(){return this.low>>>0},I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,E=31;E>0&&!(x&1<=0},I.isOdd=function(){return(1&this.low)==1},I.isEven=function(){return(1&this.low)==0},I.equals=function(x){return s(x)||(x=n(x)),(this.unsigned===x.unsigned||this.high>>>31!=1||x.high>>>31!=1)&&this.high===x.high&&this.low===x.low},I.eq=I.equals,I.notEquals=function(x){return!this.eq(x)},I.neq=I.notEquals,I.ne=I.notEquals,I.lessThan=function(x){return this.comp(x)<0},I.lt=I.lessThan,I.lessThanOrEqual=function(x){return this.comp(x)<=0},I.lte=I.lessThanOrEqual,I.le=I.lessThanOrEqual,I.greaterThan=function(x){return this.comp(x)>0},I.gt=I.greaterThan,I.greaterThanOrEqual=function(x){return this.comp(x)>=0},I.gte=I.greaterThanOrEqual,I.ge=I.greaterThanOrEqual,I.compare=function(x){if(s(x)||(x=n(x)),this.eq(x))return 0;var E=this.isNegative(),F=x.isNegative();return E&&!F?-1:!E&&F?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},I.comp=I.compare,I.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(_)},I.neg=I.negate,I.add=function(x){s(x)||(x=n(x));var E=this.high>>>16,F=65535&this.high,R=this.low>>>16,$=65535&this.low,L=x.high>>>16,G=65535&x.high,D=x.low>>>16,z=0,Z=0,X=0,J=0;return X+=(J+=$+(65535&x.low))>>>16,Z+=(X+=R+D)>>>16,z+=(Z+=F+G)>>>16,z+=E+L,p((X&=65535)<<16|(J&=65535),(z&=65535)<<16|(Z&=65535),this.unsigned)},I.subtract=function(x){return s(x)||(x=n(x)),this.add(x.neg())},I.sub=I.subtract,I.multiply=function(x){if(this.isZero())return g;if(s(x)||(x=n(x)),t)return p(t.mul(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned);if(x.isZero())return g;if(this.eq(A))return x.isOdd()?A:g;if(x.eq(A))return this.isOdd()?A:g;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(f)&&x.lt(f))return h(this.toNumber()*x.toNumber(),this.unsigned);var E=this.high>>>16,F=65535&this.high,R=this.low>>>16,$=65535&this.low,L=x.high>>>16,G=65535&x.high,D=x.low>>>16,z=65535&x.low,Z=0,X=0,J=0,ee=0;return J+=(ee+=$*z)>>>16,X+=(J+=R*z)>>>16,J&=65535,X+=(J+=$*D)>>>16,Z+=(X+=F*z)>>>16,X&=65535,Z+=(X+=R*D)>>>16,X&=65535,Z+=(X+=$*G)>>>16,Z+=E*z+F*D+R*G+$*L,p((J&=65535)<<16|(ee&=65535),(Z&=65535)<<16|(X&=65535),this.unsigned)},I.mul=I.multiply,I.divide=function(x){if(s(x)||(x=n(x)),x.isZero())throw Error("division by zero");var E,F,R;if(t)return this.unsigned||this.high!==-2147483648||x.low!==-1||x.high!==-1?p((this.unsigned?t.div_u:t.div_s)(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:g;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return b;if(x.gt(this.shru(1)))return y;R=b}else{if(this.eq(A))return x.eq(_)||x.eq(w)?A:x.eq(A)?_:(E=this.shr(1).div(x).shl(1)).eq(g)?x.isNegative()?_:w:(F=this.sub(x.mul(E)),R=E.add(F.div(x)));if(x.eq(A))return this.unsigned?b:g;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();R=g}for(F=this;F.gte(x);){E=Math.max(1,Math.floor(F.toNumber()/x.toNumber()));for(var $=Math.ceil(Math.log(E)/Math.LN2),L=$<=48?1:c(2,$-48),G=h(E),D=G.mul(x);D.isNegative()||D.gt(F);)D=(G=h(E-=L,this.unsigned)).mul(x);G.isZero()&&(G=_),R=R.add(G),F=F.sub(D)}return R},I.div=I.divide,I.modulo=function(x){return s(x)||(x=n(x)),t?p((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,x.low,x.high),t.get_high(),this.unsigned):this.sub(this.div(x).mul(x))},I.mod=I.modulo,I.rem=I.modulo,I.not=function(){return p(~this.low,~this.high,this.unsigned)},I.and=function(x){return s(x)||(x=n(x)),p(this.low&x.low,this.high&x.high,this.unsigned)},I.or=function(x){return s(x)||(x=n(x)),p(this.low|x.low,this.high|x.high,this.unsigned)},I.xor=function(x){return s(x)||(x=n(x)),p(this.low^x.low,this.high^x.high,this.unsigned)},I.shiftLeft=function(x){return s(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?p(this.low<>>32-x,this.unsigned):p(0,this.low<>>x|this.high<<32-x,this.high>>x,this.unsigned):p(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},I.shr=I.shiftRight,I.shiftRightUnsigned=function(x){if(s(x)&&(x=x.toInt()),(x&=63)==0)return this;var E=this.high;return x<32?p(this.low>>>x|E<<32-x,E>>>x,this.unsigned):p(x===32?E:E>>>x-32,0,this.unsigned)},I.shru=I.shiftRightUnsigned,I.shr_u=I.shiftRightUnsigned,I.toSigned=function(){return this.unsigned?p(this.low,this.high,!1):this},I.toUnsigned=function(){return this.unsigned?this:p(this.low,this.high,!0)},I.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},I.toBytesLE=function(){var x=this.high,E=this.low;return[255&E,E>>>8&255,E>>>16&255,E>>>24,255&x,x>>>8&255,x>>>16&255,x>>>24]},I.toBytesBE=function(){var x=this.high,E=this.low;return[x>>>24,x>>>16&255,x>>>8&255,255&x,E>>>24,E>>>16&255,E>>>8&255,255&E]},i.fromBytes=function(x,E,F){return F?i.fromBytesLE(x,E):i.fromBytesBE(x,E)},i.fromBytesLE=function(x,E){return new i(x[0]|x[1]<<8|x[2]<<16|x[3]<<24,x[4]|x[5]<<8|x[6]<<16|x[7]<<24,E)},i.fromBytesBE=function(x,E){return new i(x[4]<<24|x[5]<<16|x[6]<<8|x[7],x[0]<<24|x[1]<<16|x[2]<<8|x[3],E)}},1446:(m,t,i)=>{var s,a,d,u=i(2100),h=u.Reader,p=u.Writer,c=u.util,l=u.roots.default||(u.roots.default={});l.onnx=((d={}).Version=(s={},(a=Object.create(s))[s[0]="_START_VERSION"]=0,a[s[1]="IR_VERSION_2017_10_10"]=1,a[s[2]="IR_VERSION_2017_10_30"]=2,a[s[3]="IR_VERSION_2017_11_3"]=3,a[s[4]="IR_VERSION_2019_1_22"]=4,a[s[5]="IR_VERSION"]=5,a),d.AttributeProto=function(){function n(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:f.name=e.string();break;case 21:f.refAttrName=e.string();break;case 13:f.docString=e.string();break;case 20:f.type=e.int32();break;case 2:f.f=e.float();break;case 3:f.i=e.int64();break;case 4:f.s=e.bytes();break;case 5:f.t=l.onnx.TensorProto.decode(e,e.uint32());break;case 6:f.g=l.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(f.floats&&f.floats.length||(f.floats=[]),(7&g)==2)for(var b=e.uint32()+e.pos;e.pos>>0,e.i.high>>>0).toNumber())),e.s!=null&&(typeof e.s=="string"?c.base64.decode(e.s,r.s=c.newBuffer(c.base64.length(e.s)),0):e.s.length&&(r.s=e.s)),e.t!=null){if(typeof e.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");r.t=l.onnx.TensorProto.fromObject(e.t)}if(e.g!=null){if(typeof e.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");r.g=l.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");r.floats=[];for(var o=0;o>>0,e.ints[o].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(r.strings=[],o=0;o>>0,e.i.high>>>0).toNumber():e.i),e.s!=null&&e.hasOwnProperty("s")&&(o.s=r.bytes===String?c.base64.encode(e.s,0,e.s.length):r.bytes===Array?Array.prototype.slice.call(e.s):e.s),e.t!=null&&e.hasOwnProperty("t")&&(o.t=l.onnx.TensorProto.toObject(e.t,r)),e.g!=null&&e.hasOwnProperty("g")&&(o.g=l.onnx.GraphProto.toObject(e.g,r)),e.floats&&e.floats.length){o.floats=[];for(var g=0;g>>0,e.ints[g].high>>>0).toNumber():e.ints[g];if(e.strings&&e.strings.length)for(o.strings=[],g=0;g>>3){case 1:f.name=e.string();break;case 2:f.type=l.onnx.TypeProto.decode(e,e.uint32());break;case 3:f.docString=e.string();break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.name!=null&&e.hasOwnProperty("name")&&!c.isString(e.name))return"name: string expected";if(e.type!=null&&e.hasOwnProperty("type")){var r=l.onnx.TypeProto.verify(e.type);if(r)return"type."+r}return e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString)?"docString: string expected":null},n.fromObject=function(e){if(e instanceof l.onnx.ValueInfoProto)return e;var r=new l.onnx.ValueInfoProto;if(e.name!=null&&(r.name=String(e.name)),e.type!=null){if(typeof e.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");r.type=l.onnx.TypeProto.fromObject(e.type)}return e.docString!=null&&(r.docString=String(e.docString)),r},n.toObject=function(e,r){r||(r={});var o={};return r.defaults&&(o.name="",o.type=null,o.docString=""),e.name!=null&&e.hasOwnProperty("name")&&(o.name=e.name),e.type!=null&&e.hasOwnProperty("type")&&(o.type=l.onnx.TypeProto.toObject(e.type,r)),e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},n}(),d.NodeProto=function(){function n(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:f.input&&f.input.length||(f.input=[]),f.input.push(e.string());break;case 2:f.output&&f.output.length||(f.output=[]),f.output.push(e.string());break;case 3:f.name=e.string();break;case 4:f.opType=e.string();break;case 7:f.domain=e.string();break;case 5:f.attribute&&f.attribute.length||(f.attribute=[]),f.attribute.push(l.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:f.docString=e.string();break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.input!=null&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var r=0;r>>3){case 1:f.irVersion=e.int64();break;case 8:f.opsetImport&&f.opsetImport.length||(f.opsetImport=[]),f.opsetImport.push(l.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:f.producerName=e.string();break;case 3:f.producerVersion=e.string();break;case 4:f.domain=e.string();break;case 5:f.modelVersion=e.int64();break;case 6:f.docString=e.string();break;case 7:f.graph=l.onnx.GraphProto.decode(e,e.uint32());break;case 14:f.metadataProps&&f.metadataProps.length||(f.metadataProps=[]),f.metadataProps.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.irVersion!=null&&e.hasOwnProperty("irVersion")&&!(c.isInteger(e.irVersion)||e.irVersion&&c.isInteger(e.irVersion.low)&&c.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(e.opsetImport!=null&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var r=0;r>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");r.opsetImport=[];for(var o=0;o>>0,e.modelVersion.high>>>0).toNumber())),e.docString!=null&&(r.docString=String(e.docString)),e.graph!=null){if(typeof e.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");r.graph=l.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(r.metadataProps=[],o=0;o>>0,e.irVersion.high>>>0).toNumber():e.irVersion),e.producerName!=null&&e.hasOwnProperty("producerName")&&(o.producerName=e.producerName),e.producerVersion!=null&&e.hasOwnProperty("producerVersion")&&(o.producerVersion=e.producerVersion),e.domain!=null&&e.hasOwnProperty("domain")&&(o.domain=e.domain),e.modelVersion!=null&&e.hasOwnProperty("modelVersion")&&(typeof e.modelVersion=="number"?o.modelVersion=r.longs===String?String(e.modelVersion):e.modelVersion:o.modelVersion=r.longs===String?c.Long.prototype.toString.call(e.modelVersion):r.longs===Number?new c.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),e.graph!=null&&e.hasOwnProperty("graph")&&(o.graph=l.onnx.GraphProto.toObject(e.graph,r)),e.opsetImport&&e.opsetImport.length){o.opsetImport=[];for(var g=0;g>>3){case 1:f.key=e.string();break;case 2:f.value=e.string();break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){return typeof e!="object"||e===null?"object expected":e.key!=null&&e.hasOwnProperty("key")&&!c.isString(e.key)?"key: string expected":e.value!=null&&e.hasOwnProperty("value")&&!c.isString(e.value)?"value: string expected":null},n.fromObject=function(e){if(e instanceof l.onnx.StringStringEntryProto)return e;var r=new l.onnx.StringStringEntryProto;return e.key!=null&&(r.key=String(e.key)),e.value!=null&&(r.value=String(e.value)),r},n.toObject=function(e,r){r||(r={});var o={};return r.defaults&&(o.key="",o.value=""),e.key!=null&&e.hasOwnProperty("key")&&(o.key=e.key),e.value!=null&&e.hasOwnProperty("value")&&(o.value=e.value),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},n}(),d.TensorAnnotation=function(){function n(e){if(this.quantParameterTensorNames=[],e)for(var r=Object.keys(e),o=0;o>>3){case 1:f.tensorName=e.string();break;case 2:f.quantParameterTensorNames&&f.quantParameterTensorNames.length||(f.quantParameterTensorNames=[]),f.quantParameterTensorNames.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.tensorName!=null&&e.hasOwnProperty("tensorName")&&!c.isString(e.tensorName))return"tensorName: string expected";if(e.quantParameterTensorNames!=null&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var r=0;r>>3){case 1:f.node&&f.node.length||(f.node=[]),f.node.push(l.onnx.NodeProto.decode(e,e.uint32()));break;case 2:f.name=e.string();break;case 5:f.initializer&&f.initializer.length||(f.initializer=[]),f.initializer.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 10:f.docString=e.string();break;case 11:f.input&&f.input.length||(f.input=[]),f.input.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:f.output&&f.output.length||(f.output=[]),f.output.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:f.valueInfo&&f.valueInfo.length||(f.valueInfo=[]),f.valueInfo.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:f.quantizationAnnotation&&f.quantizationAnnotation.length||(f.quantizationAnnotation=[]),f.quantizationAnnotation.push(l.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.node!=null&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var r=0;r>>3){case 1:if(f.dims&&f.dims.length||(f.dims=[]),(7&g)==2)for(var b=e.uint32()+e.pos;e.pos>>0,e.dims[o].high>>>0).toNumber())}if(e.dataType!=null&&(r.dataType=0|e.dataType),e.segment!=null){if(typeof e.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");r.segment=l.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(r.floatData=[],o=0;o>>0,e.int64Data[o].high>>>0).toNumber())}if(e.name!=null&&(r.name=String(e.name)),e.docString!=null&&(r.docString=String(e.docString)),e.rawData!=null&&(typeof e.rawData=="string"?c.base64.decode(e.rawData,r.rawData=c.newBuffer(c.base64.length(e.rawData)),0):e.rawData.length&&(r.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(r.externalData=[],o=0;o>>0,e.uint64Data[o].high>>>0).toNumber(!0))}return r},n.toObject=function(e,r){r||(r={});var o={};if((r.arrays||r.defaults)&&(o.dims=[],o.floatData=[],o.int32Data=[],o.stringData=[],o.int64Data=[],o.doubleData=[],o.uint64Data=[],o.externalData=[]),r.defaults&&(o.dataType=0,o.segment=null,o.name="",r.bytes===String?o.rawData="":(o.rawData=[],r.bytes!==Array&&(o.rawData=c.newBuffer(o.rawData))),o.docString="",o.dataLocation=r.enums===String?"DEFAULT":0),e.dims&&e.dims.length){o.dims=[];for(var f=0;f>>0,e.dims[f].high>>>0).toNumber():e.dims[f]}if(e.dataType!=null&&e.hasOwnProperty("dataType")&&(o.dataType=e.dataType),e.segment!=null&&e.hasOwnProperty("segment")&&(o.segment=l.onnx.TensorProto.Segment.toObject(e.segment,r)),e.floatData&&e.floatData.length)for(o.floatData=[],f=0;f>>0,e.int64Data[f].high>>>0).toNumber():e.int64Data[f];if(e.name!=null&&e.hasOwnProperty("name")&&(o.name=e.name),e.rawData!=null&&e.hasOwnProperty("rawData")&&(o.rawData=r.bytes===String?c.base64.encode(e.rawData,0,e.rawData.length):r.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(o.doubleData=[],f=0;f>>0,e.uint64Data[f].high>>>0).toNumber(!0):e.uint64Data[f];if(e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),e.externalData&&e.externalData.length)for(o.externalData=[],f=0;f>>3){case 1:g.begin=r.int64();break;case 2:g.end=r.int64();break;default:r.skipType(7&b)}}return g},e.decodeDelimited=function(r){return r instanceof h||(r=new h(r)),this.decode(r,r.uint32())},e.verify=function(r){return typeof r!="object"||r===null?"object expected":r.begin!=null&&r.hasOwnProperty("begin")&&!(c.isInteger(r.begin)||r.begin&&c.isInteger(r.begin.low)&&c.isInteger(r.begin.high))?"begin: integer|Long expected":r.end!=null&&r.hasOwnProperty("end")&&!(c.isInteger(r.end)||r.end&&c.isInteger(r.end.low)&&c.isInteger(r.end.high))?"end: integer|Long expected":null},e.fromObject=function(r){if(r instanceof l.onnx.TensorProto.Segment)return r;var o=new l.onnx.TensorProto.Segment;return r.begin!=null&&(c.Long?(o.begin=c.Long.fromValue(r.begin)).unsigned=!1:typeof r.begin=="string"?o.begin=parseInt(r.begin,10):typeof r.begin=="number"?o.begin=r.begin:typeof r.begin=="object"&&(o.begin=new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber())),r.end!=null&&(c.Long?(o.end=c.Long.fromValue(r.end)).unsigned=!1:typeof r.end=="string"?o.end=parseInt(r.end,10):typeof r.end=="number"?o.end=r.end:typeof r.end=="object"&&(o.end=new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber())),o},e.toObject=function(r,o){o||(o={});var f={};if(o.defaults){if(c.Long){var g=new c.Long(0,0,!1);f.begin=o.longs===String?g.toString():o.longs===Number?g.toNumber():g}else f.begin=o.longs===String?"0":0;c.Long?(g=new c.Long(0,0,!1),f.end=o.longs===String?g.toString():o.longs===Number?g.toNumber():g):f.end=o.longs===String?"0":0}return r.begin!=null&&r.hasOwnProperty("begin")&&(typeof r.begin=="number"?f.begin=o.longs===String?String(r.begin):r.begin:f.begin=o.longs===String?c.Long.prototype.toString.call(r.begin):o.longs===Number?new c.LongBits(r.begin.low>>>0,r.begin.high>>>0).toNumber():r.begin),r.end!=null&&r.hasOwnProperty("end")&&(typeof r.end=="number"?f.end=o.longs===String?String(r.end):r.end:f.end=o.longs===String?c.Long.prototype.toString.call(r.end):o.longs===Number?new c.LongBits(r.end.low>>>0,r.end.high>>>0).toNumber():r.end),f},e.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},e}(),n.DataLocation=function(){var e={},r=Object.create(e);return r[e[0]="DEFAULT"]=0,r[e[1]="EXTERNAL"]=1,r}(),n}(),d.TensorShapeProto=function(){function n(e){if(this.dim=[],e)for(var r=Object.keys(e),o=0;o>>3==1?(f.dim&&f.dim.length||(f.dim=[]),f.dim.push(l.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&g)}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.dim!=null&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var r=0;r>>3){case 1:b.dimValue=o.int64();break;case 2:b.dimParam=o.string();break;case 3:b.denotation=o.string();break;default:o.skipType(7&_)}}return b},e.decodeDelimited=function(o){return o instanceof h||(o=new h(o)),this.decode(o,o.uint32())},e.verify=function(o){if(typeof o!="object"||o===null)return"object expected";var f={};if(o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(f.value=1,!(c.isInteger(o.dimValue)||o.dimValue&&c.isInteger(o.dimValue.low)&&c.isInteger(o.dimValue.high))))return"dimValue: integer|Long expected";if(o.dimParam!=null&&o.hasOwnProperty("dimParam")){if(f.value===1)return"value: multiple values";if(f.value=1,!c.isString(o.dimParam))return"dimParam: string expected"}return o.denotation!=null&&o.hasOwnProperty("denotation")&&!c.isString(o.denotation)?"denotation: string expected":null},e.fromObject=function(o){if(o instanceof l.onnx.TensorShapeProto.Dimension)return o;var f=new l.onnx.TensorShapeProto.Dimension;return o.dimValue!=null&&(c.Long?(f.dimValue=c.Long.fromValue(o.dimValue)).unsigned=!1:typeof o.dimValue=="string"?f.dimValue=parseInt(o.dimValue,10):typeof o.dimValue=="number"?f.dimValue=o.dimValue:typeof o.dimValue=="object"&&(f.dimValue=new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber())),o.dimParam!=null&&(f.dimParam=String(o.dimParam)),o.denotation!=null&&(f.denotation=String(o.denotation)),f},e.toObject=function(o,f){f||(f={});var g={};return f.defaults&&(g.denotation=""),o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(typeof o.dimValue=="number"?g.dimValue=f.longs===String?String(o.dimValue):o.dimValue:g.dimValue=f.longs===String?c.Long.prototype.toString.call(o.dimValue):f.longs===Number?new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber():o.dimValue,f.oneofs&&(g.value="dimValue")),o.dimParam!=null&&o.hasOwnProperty("dimParam")&&(g.dimParam=o.dimParam,f.oneofs&&(g.value="dimParam")),o.denotation!=null&&o.hasOwnProperty("denotation")&&(g.denotation=o.denotation),g},e.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},e}(),n}(),d.TypeProto=function(){function n(r){if(r)for(var o=Object.keys(r),f=0;f>>3){case 1:g.tensorType=l.onnx.TypeProto.Tensor.decode(r,r.uint32());break;case 6:g.denotation=r.string();break;default:r.skipType(7&b)}}return g},n.decodeDelimited=function(r){return r instanceof h||(r=new h(r)),this.decode(r,r.uint32())},n.verify=function(r){if(typeof r!="object"||r===null)return"object expected";if(r.tensorType!=null&&r.hasOwnProperty("tensorType")){var o=l.onnx.TypeProto.Tensor.verify(r.tensorType);if(o)return"tensorType."+o}return r.denotation!=null&&r.hasOwnProperty("denotation")&&!c.isString(r.denotation)?"denotation: string expected":null},n.fromObject=function(r){if(r instanceof l.onnx.TypeProto)return r;var o=new l.onnx.TypeProto;if(r.tensorType!=null){if(typeof r.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");o.tensorType=l.onnx.TypeProto.Tensor.fromObject(r.tensorType)}return r.denotation!=null&&(o.denotation=String(r.denotation)),o},n.toObject=function(r,o){o||(o={});var f={};return o.defaults&&(f.denotation=""),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&(f.tensorType=l.onnx.TypeProto.Tensor.toObject(r.tensorType,o),o.oneofs&&(f.value="tensorType")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(f.denotation=r.denotation),f},n.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},n.Tensor=function(){function r(o){if(o)for(var f=Object.keys(o),g=0;g>>3){case 1:b.elemType=o.int32();break;case 2:b.shape=l.onnx.TensorShapeProto.decode(o,o.uint32());break;default:o.skipType(7&_)}}return b},r.decodeDelimited=function(o){return o instanceof h||(o=new h(o)),this.decode(o,o.uint32())},r.verify=function(o){if(typeof o!="object"||o===null)return"object expected";if(o.elemType!=null&&o.hasOwnProperty("elemType")&&!c.isInteger(o.elemType))return"elemType: integer expected";if(o.shape!=null&&o.hasOwnProperty("shape")){var f=l.onnx.TensorShapeProto.verify(o.shape);if(f)return"shape."+f}return null},r.fromObject=function(o){if(o instanceof l.onnx.TypeProto.Tensor)return o;var f=new l.onnx.TypeProto.Tensor;if(o.elemType!=null&&(f.elemType=0|o.elemType),o.shape!=null){if(typeof o.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");f.shape=l.onnx.TensorShapeProto.fromObject(o.shape)}return f},r.toObject=function(o,f){f||(f={});var g={};return f.defaults&&(g.elemType=0,g.shape=null),o.elemType!=null&&o.hasOwnProperty("elemType")&&(g.elemType=o.elemType),o.shape!=null&&o.hasOwnProperty("shape")&&(g.shape=l.onnx.TensorShapeProto.toObject(o.shape,f)),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},r}(),n}(),d.OperatorSetIdProto=function(){function n(e){if(e)for(var r=Object.keys(e),o=0;o>>3){case 1:f.domain=e.string();break;case 2:f.version=e.int64();break;default:e.skipType(7&g)}}return f},n.decodeDelimited=function(e){return e instanceof h||(e=new h(e)),this.decode(e,e.uint32())},n.verify=function(e){return typeof e!="object"||e===null?"object expected":e.domain!=null&&e.hasOwnProperty("domain")&&!c.isString(e.domain)?"domain: string expected":e.version!=null&&e.hasOwnProperty("version")&&!(c.isInteger(e.version)||e.version&&c.isInteger(e.version.low)&&c.isInteger(e.version.high))?"version: integer|Long expected":null},n.fromObject=function(e){if(e instanceof l.onnx.OperatorSetIdProto)return e;var r=new l.onnx.OperatorSetIdProto;return e.domain!=null&&(r.domain=String(e.domain)),e.version!=null&&(c.Long?(r.version=c.Long.fromValue(e.version)).unsigned=!1:typeof e.version=="string"?r.version=parseInt(e.version,10):typeof e.version=="number"?r.version=e.version:typeof e.version=="object"&&(r.version=new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),r},n.toObject=function(e,r){r||(r={});var o={};if(r.defaults)if(o.domain="",c.Long){var f=new c.Long(0,0,!1);o.version=r.longs===String?f.toString():r.longs===Number?f.toNumber():f}else o.version=r.longs===String?"0":0;return e.domain!=null&&e.hasOwnProperty("domain")&&(o.domain=e.domain),e.version!=null&&e.hasOwnProperty("version")&&(typeof e.version=="number"?o.version=r.longs===String?String(e.version):e.version:o.version=r.longs===String?c.Long.prototype.toString.call(e.version):r.longs===Number?new c.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),o},n.prototype.toJSON=function(){return this.constructor.toObject(this,u.util.toJSONOptions)},n}(),d),m.exports=l},2100:(m,t,i)=>{m.exports=i(9482)},9482:(m,t,i)=>{var s=t;function a(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=i(1173),s.BufferWriter=i(3155),s.Reader=i(1408),s.BufferReader=i(593),s.util=i(9693),s.rpc=i(5994),s.roots=i(5054),s.configure=a,a()},1408:(m,t,i)=>{m.exports=p;var s,a=i(9693),d=a.LongBits,u=a.utf8;function h(f,g){return RangeError("index out of range: "+f.pos+" + "+(g||1)+" > "+f.len)}function p(f){this.buf=f,this.pos=0,this.len=f.length}var c,l=typeof Uint8Array<"u"?function(f){if(f instanceof Uint8Array||Array.isArray(f))return new p(f);throw Error("illegal buffer")}:function(f){if(Array.isArray(f))return new p(f);throw Error("illegal buffer")},n=function(){return a.Buffer?function(f){return(p.create=function(g){return a.Buffer.isBuffer(g)?new s(g):l(g)})(f)}:l};function e(){var f=new d(0,0),g=0;if(!(this.len-this.pos>4)){for(;g<3;++g){if(this.pos>=this.len)throw h(this);if(f.lo=(f.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return f}return f.lo=(f.lo|(127&this.buf[this.pos++])<<7*g)>>>0,f}for(;g<4;++g)if(f.lo=(f.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return f;if(f.lo=(f.lo|(127&this.buf[this.pos])<<28)>>>0,f.hi=(f.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return f;if(g=0,this.len-this.pos>4){for(;g<5;++g)if(f.hi=(f.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return f}else for(;g<5;++g){if(this.pos>=this.len)throw h(this);if(f.hi=(f.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return f}throw Error("invalid varint encoding")}function r(f,g){return(f[g-4]|f[g-3]<<8|f[g-2]<<16|f[g-1]<<24)>>>0}function o(){if(this.pos+8>this.len)throw h(this,8);return new d(r(this.buf,this.pos+=4),r(this.buf,this.pos+=4))}p.create=n(),p.prototype._slice=a.Array.prototype.subarray||a.Array.prototype.slice,p.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return c;if((this.pos+=5)>this.len)throw this.pos=this.len,h(this,10);return c}),p.prototype.int32=function(){return 0|this.uint32()},p.prototype.sint32=function(){var f=this.uint32();return f>>>1^-(1&f)|0},p.prototype.bool=function(){return this.uint32()!==0},p.prototype.fixed32=function(){if(this.pos+4>this.len)throw h(this,4);return r(this.buf,this.pos+=4)},p.prototype.sfixed32=function(){if(this.pos+4>this.len)throw h(this,4);return 0|r(this.buf,this.pos+=4)},p.prototype.float=function(){if(this.pos+4>this.len)throw h(this,4);var f=a.float.readFloatLE(this.buf,this.pos);return this.pos+=4,f},p.prototype.double=function(){if(this.pos+8>this.len)throw h(this,4);var f=a.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,f},p.prototype.bytes=function(){var f=this.uint32(),g=this.pos,b=this.pos+f;if(b>this.len)throw h(this,f);return this.pos+=f,Array.isArray(this.buf)?this.buf.slice(g,b):g===b?new this.buf.constructor(0):this._slice.call(this.buf,g,b)},p.prototype.string=function(){var f=this.bytes();return u.read(f,0,f.length)},p.prototype.skip=function(f){if(typeof f=="number"){if(this.pos+f>this.len)throw h(this,f);this.pos+=f}else do if(this.pos>=this.len)throw h(this);while(128&this.buf[this.pos++]);return this},p.prototype.skipType=function(f){switch(f){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(f=7&this.uint32())!=4;)this.skipType(f);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+f+" at offset "+this.pos)}return this},p._configure=function(f){s=f,p.create=n(),s._configure();var g=a.Long?"toLong":"toNumber";a.merge(p.prototype,{int64:function(){return e.call(this)[g](!1)},uint64:function(){return e.call(this)[g](!0)},sint64:function(){return e.call(this).zzDecode()[g](!1)},fixed64:function(){return o.call(this)[g](!0)},sfixed64:function(){return o.call(this)[g](!1)}})}},593:(m,t,i)=>{m.exports=d;var s=i(1408);(d.prototype=Object.create(s.prototype)).constructor=d;var a=i(9693);function d(u){s.call(this,u)}d._configure=function(){a.Buffer&&(d.prototype._slice=a.Buffer.prototype.slice)},d.prototype.string=function(){var u=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+u,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+u,this.len))},d._configure()},5054:m=>{m.exports={}},5994:(m,t,i)=>{t.Service=i(7948)},7948:(m,t,i)=>{m.exports=a;var s=i(9693);function a(d,u,h){if(typeof d!="function")throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=d,this.requestDelimited=!!u,this.responseDelimited=!!h}(a.prototype=Object.create(s.EventEmitter.prototype)).constructor=a,a.prototype.rpcCall=function d(u,h,p,c,l){if(!c)throw TypeError("request must be specified");var n=this;if(!l)return s.asPromise(d,n,u,h,p,c);if(n.rpcImpl)try{return n.rpcImpl(u,h[n.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(e,r){if(e)return n.emit("error",e,u),l(e);if(r!==null){if(!(r instanceof p))try{r=p[n.responseDelimited?"decodeDelimited":"decode"](r)}catch(o){return n.emit("error",o,u),l(o)}return n.emit("data",r,u),l(null,r)}n.end(!0)})}catch(e){return n.emit("error",e,u),void setTimeout(function(){l(e)},0)}else setTimeout(function(){l(Error("already ended"))},0)},a.prototype.end=function(d){return this.rpcImpl&&(d||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(m,t,i)=>{m.exports=a;var s=i(9693);function a(p,c){this.lo=p>>>0,this.hi=c>>>0}var d=a.zero=new a(0,0);d.toNumber=function(){return 0},d.zzEncode=d.zzDecode=function(){return this},d.length=function(){return 1};var u=a.zeroHash="\0\0\0\0\0\0\0\0";a.fromNumber=function(p){if(p===0)return d;var c=p<0;c&&(p=-p);var l=p>>>0,n=(p-l)/4294967296>>>0;return c&&(n=~n>>>0,l=~l>>>0,++l>4294967295&&(l=0,++n>4294967295&&(n=0))),new a(l,n)},a.from=function(p){if(typeof p=="number")return a.fromNumber(p);if(s.isString(p)){if(!s.Long)return a.fromNumber(parseInt(p,10));p=s.Long.fromString(p)}return p.low||p.high?new a(p.low>>>0,p.high>>>0):d},a.prototype.toNumber=function(p){if(!p&&this.hi>>>31){var c=1+~this.lo>>>0,l=~this.hi>>>0;return c||(l=l+1>>>0),-(c+4294967296*l)}return this.lo+4294967296*this.hi},a.prototype.toLong=function(p){return s.Long?new s.Long(0|this.lo,0|this.hi,!!p):{low:0|this.lo,high:0|this.hi,unsigned:!!p}};var h=String.prototype.charCodeAt;a.fromHash=function(p){return p===u?d:new a((h.call(p,0)|h.call(p,1)<<8|h.call(p,2)<<16|h.call(p,3)<<24)>>>0,(h.call(p,4)|h.call(p,5)<<8|h.call(p,6)<<16|h.call(p,7)<<24)>>>0)},a.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},a.prototype.zzEncode=function(){var p=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^p)>>>0,this.lo=(this.lo<<1^p)>>>0,this},a.prototype.zzDecode=function(){var p=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^p)>>>0,this.hi=(this.hi>>>1^p)>>>0,this},a.prototype.length=function(){var p=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,l=this.hi>>>24;return l===0?c===0?p<16384?p<128?1:2:p<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:l<128?9:10}},9693:function(m,t,i){var s=t;function a(u,h,p){for(var c=Object.keys(h),l=0;l0)},s.Buffer=function(){try{var u=s.inquire("buffer").Buffer;return u.prototype.utf8Write?u:null}catch{return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(u){return typeof u=="number"?s.Buffer?s._Buffer_allocUnsafe(u):new s.Array(u):s.Buffer?s._Buffer_from(u):typeof Uint8Array>"u"?u:new Uint8Array(u)},s.Array=typeof Uint8Array<"u"?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(u){return u?s.LongBits.from(u).toHash():s.LongBits.zeroHash},s.longFromHash=function(u,h){var p=s.LongBits.fromHash(u);return s.Long?s.Long.fromBits(p.lo,p.hi,h):p.toNumber(!!h)},s.merge=a,s.lcFirst=function(u){return u.charAt(0).toLowerCase()+u.substring(1)},s.newError=d,s.ProtocolError=d("ProtocolError"),s.oneOfGetter=function(u){for(var h={},p=0;p-1;--l)if(h[c[l]]===1&&this[c[l]]!==void 0&&this[c[l]]!==null)return c[l]}},s.oneOfSetter=function(u){return function(h){for(var p=0;p{m.exports=n;var s,a=i(9693),d=a.LongBits,u=a.base64,h=a.utf8;function p(_,y,w){this.fn=_,this.len=y,this.next=void 0,this.val=w}function c(){}function l(_){this.head=_.head,this.tail=_.tail,this.len=_.len,this.next=_.states}function n(){this.len=0,this.head=new p(c,0,0),this.tail=this.head,this.states=null}var e=function(){return a.Buffer?function(){return(n.create=function(){return new s})()}:function(){return new n}};function r(_,y,w){y[w]=255&_}function o(_,y){this.len=_,this.next=void 0,this.val=y}function f(_,y,w){for(;_.hi;)y[w++]=127&_.lo|128,_.lo=(_.lo>>>7|_.hi<<25)>>>0,_.hi>>>=7;for(;_.lo>127;)y[w++]=127&_.lo|128,_.lo=_.lo>>>7;y[w++]=_.lo}function g(_,y,w){y[w]=255&_,y[w+1]=_>>>8&255,y[w+2]=_>>>16&255,y[w+3]=_>>>24}n.create=e(),n.alloc=function(_){return new a.Array(_)},a.Array!==Array&&(n.alloc=a.pool(n.alloc,a.Array.prototype.subarray)),n.prototype._push=function(_,y,w){return this.tail=this.tail.next=new p(_,y,w),this.len+=y,this},o.prototype=Object.create(p.prototype),o.prototype.fn=function(_,y,w){for(;_>127;)y[w++]=127&_|128,_>>>=7;y[w]=_},n.prototype.uint32=function(_){return this.len+=(this.tail=this.tail.next=new o((_>>>=0)<128?1:_<16384?2:_<2097152?3:_<268435456?4:5,_)).len,this},n.prototype.int32=function(_){return _<0?this._push(f,10,d.fromNumber(_)):this.uint32(_)},n.prototype.sint32=function(_){return this.uint32((_<<1^_>>31)>>>0)},n.prototype.uint64=function(_){var y=d.from(_);return this._push(f,y.length(),y)},n.prototype.int64=n.prototype.uint64,n.prototype.sint64=function(_){var y=d.from(_).zzEncode();return this._push(f,y.length(),y)},n.prototype.bool=function(_){return this._push(r,1,_?1:0)},n.prototype.fixed32=function(_){return this._push(g,4,_>>>0)},n.prototype.sfixed32=n.prototype.fixed32,n.prototype.fixed64=function(_){var y=d.from(_);return this._push(g,4,y.lo)._push(g,4,y.hi)},n.prototype.sfixed64=n.prototype.fixed64,n.prototype.float=function(_){return this._push(a.float.writeFloatLE,4,_)},n.prototype.double=function(_){return this._push(a.float.writeDoubleLE,8,_)};var b=a.Array.prototype.set?function(_,y,w){y.set(_,w)}:function(_,y,w){for(var v=0;v<_.length;++v)y[w+v]=_[v]};n.prototype.bytes=function(_){var y=_.length>>>0;if(!y)return this._push(r,1,0);if(a.isString(_)){var w=n.alloc(y=u.length(_));u.decode(_,w,0),_=w}return this.uint32(y)._push(b,y,_)},n.prototype.string=function(_){var y=h.length(_);return y?this.uint32(y)._push(h.write,y,_):this._push(r,1,0)},n.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new p(c,0,0),this.len=0,this},n.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new p(c,0,0),this.len=0),this},n.prototype.ldelim=function(){var _=this.head,y=this.tail,w=this.len;return this.reset().uint32(w),w&&(this.tail.next=_.next,this.tail=y,this.len+=w),this},n.prototype.finish=function(){for(var _=this.head.next,y=this.constructor.alloc(this.len),w=0;_;)_.fn(_.val,y,w),w+=_.len,_=_.next;return y},n._configure=function(_){s=_,n.create=e(),s._configure()}},3155:(m,t,i)=>{m.exports=d;var s=i(1173);(d.prototype=Object.create(s.prototype)).constructor=d;var a=i(9693);function d(){s.call(this)}function u(h,p,c){h.length<40?a.utf8.write(h,p,c):p.utf8Write?p.utf8Write(h,c):p.write(h,c)}d._configure=function(){d.alloc=a._Buffer_allocUnsafe,d.writeBytesBuffer=a.Buffer&&a.Buffer.prototype instanceof Uint8Array&&a.Buffer.prototype.set.name==="set"?function(h,p,c){p.set(h,c)}:function(h,p,c){if(h.copy)h.copy(p,c,0,h.length);else for(var l=0;l>>0;return this.uint32(p),p&&this._push(d.writeBytesBuffer,p,h),this},d.prototype.string=function(h){var p=a.Buffer.byteLength(h);return this.uint32(p),p&&this._push(u,p,h),this},d._configure()},7714:(m,t,i)=>{t.R=void 0;const s=i(6919),a=i(7448);t.R=new class{async init(){}async createSessionHandler(d,u){const h=new s.Session(u);return await h.loadModel(d),new a.OnnxjsSessionHandler(h)}}},4200:(m,t,i)=>{t.c8=t.rX=void 0;const s=i(1670),a=i(5381),d=i(2157),u=i(2306);t.rX=()=>{if((typeof s.env.wasm.initTimeout!="number"||s.env.wasm.initTimeout<0)&&(s.env.wasm.initTimeout=0),typeof s.env.wasm.simd!="boolean"&&(s.env.wasm.simd=!0),typeof s.env.wasm.proxy!="boolean"&&(s.env.wasm.proxy=!1),typeof s.env.wasm.numThreads!="number"||!Number.isInteger(s.env.wasm.numThreads)||s.env.wasm.numThreads<=0){const h=typeof navigator>"u"?(0,a.cpus)().length:navigator.hardwareConcurrency;s.env.wasm.numThreads=Math.min(4,Math.ceil((h||1)/2))}},t.c8=new class{async init(){(0,t.rX)(),await(0,d.initWasm)()}async createSessionHandler(h,p){const c=new u.OnnxruntimeWebAssemblySessionHandler;return await c.loadModel(h,p),Promise.resolve(c)}}},6018:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(u,h,p,c){c===void 0&&(c=p);var l=Object.getOwnPropertyDescriptor(h,p);l&&!("get"in l?!h.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return h[p]}}),Object.defineProperty(u,c,l)}:function(u,h,p,c){c===void 0&&(c=p),u[c]=h[p]}),a=this&&this.__exportStar||function(u,h){for(var p in u)p==="default"||Object.prototype.hasOwnProperty.call(h,p)||s(h,u,p)};Object.defineProperty(t,"__esModule",{value:!0}),a(i(1670),t);const d=i(1670);{const u=i(7714).R;(0,d.registerBackend)("webgl",u,-10)}{const u=i(4200).c8;(0,d.registerBackend)("cpu",u,10),(0,d.registerBackend)("wasm",u,10),(0,d.registerBackend)("xnnpack",u,9)}},246:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createAttributeWithCacheKey=void 0;class i{constructor(a){Object.assign(this,a)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(a=>`${this[a]}`).join(";")),this._cacheKey}}t.createAttributeWithCacheKey=s=>new i(s)},7778:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Attribute=void 0;const s=i(1446),a=i(9395),d=i(9162),u=i(2517);var h=a.onnxruntime.experimental.fbs;class p{constructor(l){if(this._attributes=new Map,l!=null){for(const n of l)n instanceof s.onnx.AttributeProto?this._attributes.set(n.name,[p.getValue(n),p.getType(n)]):n instanceof h.Attribute&&this._attributes.set(n.name(),[p.getValue(n),p.getType(n)]);if(this._attributes.sized.Tensor.fromProto(r));if(l instanceof h.Attribute)return e.map(r=>d.Tensor.fromOrtTensor(r))}if(n===s.onnx.AttributeProto.AttributeType.STRING&&l instanceof s.onnx.AttributeProto){const r=e;return(0,u.decodeUtf8String)(r)}return n===s.onnx.AttributeProto.AttributeType.STRINGS&&l instanceof s.onnx.AttributeProto?e.map(u.decodeUtf8String):e}static getValueNoCheck(l){return l instanceof s.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(l):this.getValueNoCheckFromOrtFormat(l)}static getValueNoCheckFromOnnxFormat(l){switch(l.type){case s.onnx.AttributeProto.AttributeType.FLOAT:return l.f;case s.onnx.AttributeProto.AttributeType.INT:return l.i;case s.onnx.AttributeProto.AttributeType.STRING:return l.s;case s.onnx.AttributeProto.AttributeType.TENSOR:return l.t;case s.onnx.AttributeProto.AttributeType.GRAPH:return l.g;case s.onnx.AttributeProto.AttributeType.FLOATS:return l.floats;case s.onnx.AttributeProto.AttributeType.INTS:return l.ints;case s.onnx.AttributeProto.AttributeType.STRINGS:return l.strings;case s.onnx.AttributeProto.AttributeType.TENSORS:return l.tensors;case s.onnx.AttributeProto.AttributeType.GRAPHS:return l.graphs;default:throw new Error(`unsupported attribute type: ${s.onnx.AttributeProto.AttributeType[l.type]}`)}}static getValueNoCheckFromOrtFormat(l){switch(l.type()){case h.AttributeType.FLOAT:return l.f();case h.AttributeType.INT:return l.i();case h.AttributeType.STRING:return l.s();case h.AttributeType.TENSOR:return l.t();case h.AttributeType.GRAPH:return l.g();case h.AttributeType.FLOATS:return l.floatsArray();case h.AttributeType.INTS:{const n=[];for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveBackend=t.backend=void 0;const s=i(5038),a=new Map;async function d(u){const h=t.backend;if(h[u]!==void 0&&function(p){const c=p;return"initialize"in c&&typeof c.initialize=="function"&&"createSessionHandler"in c&&typeof c.createSessionHandler=="function"&&"dispose"in c&&typeof c.dispose=="function"}(h[u])){const p=h[u];let c=p.initialize();if(typeof c=="object"&&"then"in c&&(c=await c),c)return a.set(u,p),p}}t.backend={webgl:new s.WebGLBackend},t.resolveBackend=async function u(h){if(!h)return u(["webgl"]);{const p=typeof h=="string"?[h]:h;for(const c of p){const l=a.get(c);if(l)return l;const n=await d(c);if(n)return n}}throw new Error("no available backend to use")}},5038:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLBackend=void 0;const s=i(1670),a=i(6231),d=i(6416),u=i(7305);t.WebGLBackend=class{get contextId(){return s.env.webgl.contextId}set contextId(h){s.env.webgl.contextId=h}get matmulMaxBatchSize(){return s.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(h){s.env.webgl.matmulMaxBatchSize=h}get textureCacheMode(){return s.env.webgl.textureCacheMode}set textureCacheMode(h){s.env.webgl.textureCacheMode=h}get pack(){return s.env.webgl.pack}set pack(h){s.env.webgl.pack=h}get async(){return s.env.webgl.async}set async(h){s.env.webgl.async=h}initialize(){try{return this.glContext=(0,u.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),a.Logger.setWithEnv(s.env),a.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(h){return a.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${h}`),!1}}createSessionHandler(h){return new d.WebGLSessionHandler(this,h)}dispose(){this.glContext.dispose()}}},5107:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsGlslLib=void 0;const s=i(2517),a=i(8520),d=i(5060),u=i(7859),h=i(9390);class p extends a.GlslLib{constructor(l){super(l)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new a.GlslLibRoutine(` - vec2 offsetToCoords(int offset, int width, int height) { - int t = offset / width; - int s = offset - t*width; - vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height); - return coords; - } - `)}}coordsToOffset(){return{coordsToOffset:new a.GlslLibRoutine(` - int coordsToOffset(vec2 coords, int width, int height) { - float s = coords.s * float(width); - float t = coords.t * float(height); - int offset = int(t) * width + int(s); - return offset; - } - `)}}getOutputSamplingSnippet(){const l=this.context.outputTextureLayout;return l.isPacked?this.getPackedOutputSamplingSnippet(l):this.getUnpackedOutputSamplingSnippet(l)}getPackedOutputSamplingSnippet(l){const n=l.unpackedShape,e=[l.width,l.height],r={},o="getOutputCoords";switch(n.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputPacked1DCoords(n,e);break;case 2:r[o]=this.getOutputPacked2DCoords(n,e);break;case 3:r[o]=this.getOutputPacked3DCoords(n,e);break;default:r[o]=this.getOutputPackedNDCoords(n,e)}const f=` - void setOutput(vec4 val) { - ${(0,d.getGlsl)(this.context.glContext.version).output} = val; - } - `;return r.floatTextureSetRGBA=new a.GlslLibRoutine(f),r}getUnpackedOutputSamplingSnippet(l){const n=l.unpackedShape,e=[l.width,l.height],r={},o="getOutputCoords";switch(n.length){case 0:r[o]=this.getOutputScalarCoords();break;case 1:r[o]=this.getOutputUnpacked1DCoords(n,e);break;case 2:r[o]=this.getOutputUnpacked2DCoords(n,e);break;case 3:r[o]=this.getOutputUnpacked3DCoords(n,e);break;case 4:r[o]=this.getOutputUnpacked4DCoords(n,e);break;case 5:r[o]=this.getOutputUnpacked5DCoords(n,e);break;case 6:r[o]=this.getOutputUnpacked6DCoords(n,e);break;default:throw new Error(`Unsupported output dimensionality: ${n.length}`)}const f=` - void setOutput(float val) { - ${(0,d.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); - } - `;return r.floatTextureSetR=new a.GlslLibRoutine(f),r}getOutputScalarCoords(){return new a.GlslLibRoutine(` - int getOutputCoords() { - return 0; - } - `)}getOutputPacked1DCoords(l,n){const e=n;let r="";return e[0]===1?(r=` - int getOutputCoords() { - return 2 * int(TexCoords.y * ${e[1]}.0); - } - `,new a.GlslLibRoutine(r)):e[1]===1?(r=` - int getOutputCoords() { - return 2 * int(TexCoords.x * ${e[0]}.0); - } - `,new a.GlslLibRoutine(r)):(r=` - int getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${e[0]}, ${e[1]})); - return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); - } - `,new a.GlslLibRoutine(r))}getOutputPacked2DCoords(l,n){let e="";if(s.ArrayUtil.arraysEqual(l,n))return e=` - ivec2 getOutputCoords() { - return 2 * ivec2(TexCoords.xy * vec2(${n[0]}, ${n[1]})); - } - `,new a.GlslLibRoutine(e);const r=n,o=Math.ceil(l[1]/2);return e=` - ivec2 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${r[0]}, ${r[1]})); - - int index = resTexRC.y * ${r[0]} + resTexRC.x; - - // reverse r and c order for packed texture - int r = imod(index, ${o}) * 2; - int c = 2 * (index / ${o}); - - return ivec2(r, c); - } - `,new a.GlslLibRoutine(e)}getOutputPacked3DCoords(l,n){const e=[n[0],n[1]],r=Math.ceil(l[2]/2),o=r*Math.ceil(l[1]/2),f=` - ivec3 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${e[0]}, ${e[1]})); - int index = resTexRC.y * ${e[0]} + resTexRC.x; - - int b = index / ${o}; - index -= b * ${o}; - - // reverse r and c order for packed texture - int r = imod(index, ${r}) * 2; - int c = 2 * (index / ${r}); - - return ivec3(b, r, c); - } - `;return new a.GlslLibRoutine(f)}getOutputPackedNDCoords(l,n){const e=[n[0],n[1]],r=Math.ceil(l[l.length-1]/2),o=r*Math.ceil(l[l.length-2]/2);let f=o,g="",b="b, r, c";for(let y=2;y=0;--b)o[b]=o[b+1]*l[b+1];const f=["r","c","d"],g=o.map((b,_)=>`int ${f[_]} = index / ${b}; ${_===o.length-1?`int ${f[_+1]} = index - ${f[_]} * ${b}`:`index -= ${f[_]} * ${b}`};`).join("");return e=` - ivec3 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${n[0]}, ${n[1]})); - int index = resTexRC.y * ${n[0]} + resTexRC.x; - ${g} - return ivec3(r, c, d); - } - `,new a.GlslLibRoutine(e)}getOutputUnpacked4DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let b=r-3;b>=0;--b)o[b]=o[b+1]*l[b+1];const f=["r","c","d","d2"],g=o.map((b,_)=>`int ${f[_]} = index / ${b}; ${_===o.length-1?`int ${f[_+1]} = index - ${f[_]} * ${b}`:`index -= ${f[_]} * ${b}`};`).join("");return e=` - ivec4 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${n[0]}, ${n[1]})); - int index = resTexRC.y * ${n[0]} + resTexRC.x; - ${g} - return ivec4(r, c, d, d2); - } - `,new a.GlslLibRoutine(e)}getOutputUnpacked5DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let b=r-3;b>=0;--b)o[b]=o[b+1]*l[b+1];const f=["r","c","d","d2","d3"],g=o.map((b,_)=>`int ${f[_]} = index / ${b}; ${_===o.length-1?`int ${f[_+1]} = index - ${f[_]} * ${b}`:`index -= ${f[_]} * ${b}`};`).join("");return e=` - ivec5 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${n[0]}, ${n[1]})); - int index = resTexRC.y * ${n[0]} + resTexRC.x; - ${g} - return ivec5(r, c, d, d2, d3); - } - `,new a.GlslLibRoutine(e)}getOutputUnpacked6DCoords(l,n){let e="";const r=l.length;let o=null;r<2&&(o=[]),o=new Array(r-1),o[r-2]=l[r-1];for(let b=r-3;b>=0;--b)o[b]=o[b+1]*l[b+1];const f=["r","c","d","d2","d3","d4"],g=o.map((b,_)=>`int ${f[_]} = index / ${b}; ${_===o.length-1?`int ${f[_+1]} = index - ${f[_]} * ${b}`:`index -= ${f[_]} * ${b}`};`).join("");return e=` - ivec6 getOutputCoords() { - ivec2 resTexRC = ivec2(TexCoords.xy * - vec2(${n[0]}, ${n[1]})); - int index = resTexRC.y * ${n[0]} + resTexRC.x; - ${g} - return ivec6(r, c, d, d2, d3, d4); - } - `,new a.GlslLibRoutine(e)}getCommonUtilFuncs(){const l={};let n="uvFromFlat";l[n]=new a.GlslLibRoutine(` - vec2 uvFromFlat(int texNumR, int texNumC, int index) { - int texC = index / texNumR; - int texR = index - texC * texNumR; - // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to - // v. - return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC); - } - `),n="packedUVfrom1D",l[n]=new a.GlslLibRoutine(` - vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { - int texelIndex = index / 2; - int texR = texelIndex / texNumC; - int texC = texelIndex - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); - } - `),n="packedUVfrom2D",l[n]=new a.GlslLibRoutine(` - vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) { - int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); - int texR = texelIndex / texNumC; - int texC = texelIndex - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); - } - `),n="packedUVfrom3D",l[n]=new a.GlslLibRoutine(` - vec2 packedUVfrom3D(int texNumR, int texNumC, - int texelsInBatch, int texelsInLogicalRow, int b, - int row, int col) { - int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2); - int texR = index / texNumC; - int texC = index - texR * texNumC; - return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); - } - `),n="sampleTexture";const e=(0,d.getGlsl)(this.context.glContext.version);return l[n]=new a.GlslLibRoutine(` - float sampleTexture(sampler2D textureSampler, vec2 uv) { - return ${e.texture2D}(textureSampler, uv).r; - }`),l}getInputsSamplingSnippets(){const l={},n=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((e,r)=>{const o=this.context.inputTextureLayouts[r],f=(0,h.generateShaderFuncNameFromInputSamplerName)(e);o.isPacked?l[f]=this.getPackedSamplerFromInput(f,e,o):l[f]=this.getUnpackedSamplerFromInput(f,e,o);const g=(0,h.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(e);o.unpackedShape.length<=n.unpackedShape.length&&(o.isPacked?l[g]=this.getPackedSamplerAtOutputCoords(g,o,n,e):l[g]=this.getUnpackedSamplerAtOutputCoords(g,o,n,e))}),l}getPackedSamplerAtOutputCoords(l,n,e,r){const o=n.unpackedShape,f=e.unpackedShape,g=r,b=(0,h.generateShaderFuncNameFromInputSamplerName)(g),_=o.length,y=f.length,w=s.BroadcastUtil.getBroadcastDims(o,f),v=(0,h.getCoordsDataType)(y),S=y-_;let A;const I=(0,h.getGlChannels)();A=_===0?"":y<2&&w.length>=1?"coords = 0;":w.map(L=>`coords.${I[L+S]} = 0;`).join(` -`);let x="";x=y<2&&_>0?"coords":o.map((L,G)=>`coords.${I[G+S]}`).join(", ");let E="return outputValue;";const F=s.ShapeUtil.size(o)===1,R=s.ShapeUtil.size(f)===1;if(_!==1||F||R){if(F&&!R)E=y===1?` - return vec4(outputValue.x, outputValue.x, 0., 0.); - `:` - return vec4(outputValue.x); - `;else if(w.length){const L=_-2,G=_-1;w.indexOf(L)>-1&&w.indexOf(G)>-1?E="return vec4(outputValue.x);":w.indexOf(L)>-1?E="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":w.indexOf(G)>-1&&(E="return vec4(outputValue.xx, outputValue.zz);")}}else E=` - return vec4(outputValue.xy, outputValue.xy); - `;const $=` - vec4 ${l}() { - ${v} coords = getOutputCoords(); - - int lastDim = coords.${I[y-1]}; - coords.${I[y-1]} = coords.${I[y-2]}; - coords.${I[y-2]} = lastDim; - - ${A} - vec4 outputValue = ${b}(${x}); - ${E} - } - `;return new a.GlslLibRoutine($,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(l,n,e,r){const o=[e.width,e.height],f=[n.width,n.height],g=n.unpackedShape.length,b=e.unpackedShape.length,_=n.unpackedShape,y=e.unpackedShape,w=(0,h.generateShaderFuncNameFromInputSamplerName)(r);if(g===b&&s.ArrayUtil.arraysEqual(f,o)){const R=` - float ${l}() { - return sampleTexture(${r}, TexCoords); - } - `;return new a.GlslLibRoutine(R,["coordinates.sampleTexture"])}const v=(0,h.getCoordsDataType)(b),S=s.BroadcastUtil.getBroadcastDims(_,y),A=b-g;let I;const x=(0,h.getGlChannels)();I=g===0?"":b<2&&S.length>=1?"coords = 0;":S.map(R=>`coords.${x[R+A]} = 0;`).join(` -`);let E="";E=b<2&&g>0?"coords":n.unpackedShape.map((R,$)=>`coords.${x[$+A]}`).join(", ");const F=` - float ${l}() { - ${v} coords = getOutputCoords(); - ${I} - return ${w}(${E}); - } - `;return new a.GlslLibRoutine(F,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(l,n,e){switch(e.unpackedShape.length){case 0:return this.getPackedSamplerScalar(l,n);case 1:return this.getPackedSampler1D(l,n,e);case 2:return this.getPackedSampler2D(l,n,e);case 3:return this.getPackedSampler3D(l,n,e);default:return this.getPackedSamplerND(l,n,e)}}getUnpackedSamplerFromInput(l,n,e){const r=e.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(l,n,e);case 1:return this.getUnpackedSampler1D(l,n,e);case 2:return this.getUnpackedSampler2D(l,n,e);case 3:return this.getUnpackedSampler3D(l,n,e);case 4:return this.getUnpackedSampler4D(l,n,e);case 5:return this.getUnpackedSampler5D(l,n,e);case 6:return this.getUnpackedSampler6D(l,n,e);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(l,n){const e=` - vec4 ${l}() { - return ${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${n}, halfCR); - } - `;return new a.GlslLibRoutine(e)}getPackedSampler1D(l,n,e){const r=[e.width,e.height],o=[r[1],r[0]],f=(0,d.getGlsl)(this.context.glContext.version),g=`vec4 ${l}(int index) { - vec2 uv = packedUVfrom1D( - ${o[0]}, ${o[1]}, index); - return ${f.texture2D}(${n}, uv); - }`;return new a.GlslLibRoutine(g,["coordinates.packedUVfrom1D"])}getPackedSampler2D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],f=(0,d.getGlsl)(this.context.glContext.version),g=o[0],b=o[1];if(o!=null&&s.ArrayUtil.arraysEqual(r,o)){const v=`vec4 ${l}(int row, int col) { - vec2 uv = (vec2(col, row) + halfCR) / vec2(${b}.0, ${g}.0); - return ${f.texture2D}(${n}, uv); - }`;return new a.GlslLibRoutine(v)}const _=o,y=Math.ceil(r[1]/2),w=`vec4 ${l}(int row, int col) { - vec2 uv = packedUVfrom2D(${_[1]}, ${_[0]}, ${y}, row, col); - return ${f.texture2D}(${n}, uv); - }`;return new a.GlslLibRoutine(w,["coordinates.packedUVfrom2D"])}getPackedSampler3D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],f=[o[0],o[1]],g=(0,d.getGlsl)(this.context.glContext.version);if(r[0]===1){const v=r.slice(1),S=[1,2],A=(0,h.squeezeInputShape)(r,v),I=["b","row","col"],x=JSON.parse(JSON.stringify(e));x.unpackedShape=A;const E=this.getPackedSamplerFromInput(l,n,x),F=`${E.routineBody} - vec4 ${l}(int b, int row, int col) { - return ${l}(${(0,h.getSqueezedParams)(I,S)}); - } `;return new a.GlslLibRoutine(F,E.dependencies)}const b=f[0],_=f[1],y=Math.ceil(r[2]/2),w=`vec4 ${l}(int b, int row, int col) { - vec2 uv = packedUVfrom3D( - ${_}, ${b}, ${y*Math.ceil(r[1]/2)}, ${y}, b, row, col); - return ${g.texture2D}(${n}, uv);}`;return new a.GlslLibRoutine(w,["coordinates.packedUVfrom3D"])}getPackedSamplerND(l,n,e){const r=e.unpackedShape,o=r.length,f=[e.width,e.height],g=(0,d.getGlsl)(this.context.glContext.version),b=[f[0],f[1]],_=b[1],y=b[0],w=Math.ceil(r[o-1]/2);let v=w*Math.ceil(r[o-2]/2),S="int b, int row, int col",A=`b * ${v} + (row / 2) * ${w} + (col / 2)`;for(let x=2;x{const r=this.context.inputTextureLayouts[e],o=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length;let f=`_${n}`;l[f]=new a.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!1),[`shapeUtils.indicesToOffset${f}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),f+="_T",l[f]=new a.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!0),[`shapeUtils.indicesToOffset${f}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),l}getValueFromSingle(l,n,e,r,o){let f=`_${l}`;return o&&(f+="_T"),` - float ${f}(int m[${n}]) { - int offset = indicesToOffset${f}(m); - vec2 coords = offsetToCoords(offset, ${e}, ${r}); - float value = getColorAsFloat(${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${l}, coords)); - return value; - } - `}getPackedValueFrom(l,n,e,r,o){let f=`_${l}_Pack`;return o&&(f+="_T"),` - vec4 ${f}(int m[${n}]) { - int offset = indicesToOffset_${l}(m); - vec2 coords = offsetToCoords(offset, ${e}, ${r}); - return ${(0,d.getGlsl)(this.context.glContext.version).texture2D}(${l}, coords); - } - `}}t.CoordsGlslLib=p},8520:(m,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.TopologicalSortGlslRoutines=t.GlslLibRoutineNode=t.GlslLibRoutine=t.GlslLib=t.GlslContext=t.FunctionType=void 0,(i=t.FunctionType||(t.FunctionType={}))[i.ValueBased=0]="ValueBased",i[i.Positional=1]="Positional",t.GlslContext=class{constructor(s,a,d,u){this.glContext=s,this.programInfo=a,this.inputTextureLayouts=d,this.outputTextureLayout=u}},t.GlslLib=class{constructor(s){this.context=s}},t.GlslLibRoutine=class{constructor(s,a){this.routineBody=s,this.dependencies=a}},t.GlslLibRoutineNode=class{constructor(s,a,d){this.name=s,this.dependencies=d||[],a&&(this.routineBody=a)}addDependency(s){s&&this.dependencies.push(s)}},t.TopologicalSortGlslRoutines=class{static returnOrderedNodes(s){if(!s||s.length===0)return[];if(s.length===1)return s;const a=new Set,d=new Set,u=new Array;return this.createOrderedNodes(s,a,d,u),u}static createOrderedNodes(s,a,d,u){for(let h=0;h0)for(let p=0;p{Object.defineProperty(t,"__esModule",{value:!0}),t.EncodingGlslLib=void 0;const s=i(8520);class a extends s.GlslLib{constructor(u){super(u)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new s.GlslLibRoutine(`highp vec4 encode(highp float f) { - return vec4(f, 0.0, 0.0, 0.0); - } - `)}}decodeFloat32(){return{decode:new s.GlslLibRoutine(`highp float decode(highp vec4 rgba) { - return rgba.r; - } - `)}}encodeUint8(){const u=a.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new s.GlslLibRoutine(` - highp vec4 encode(highp float f) { - highp float F = abs(f); - highp float Sign = step(0.0,-f); - highp float Exponent = floor(log2(F)); - highp float Mantissa = (exp2(- Exponent) * F); - Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa)); - highp vec4 rgba; - rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0)); - rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0); - rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0))); - rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0))); - ${u} - rgba = rgba / 255.0; // values need to be normalized to [0,1] - return rgba; - } - `)}}decodeUint8(){const u=a.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new s.GlslLibRoutine(` - highp float decode(highp vec4 rgba) { - rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255] - ${u} - highp float Sign = 1.0 - step(128.0,rgba[0])*2.0; - highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0; - highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000); - highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 )); - return Result; - } - `)}}static isLittleEndian(){const u=new ArrayBuffer(4),h=new Uint32Array(u),p=new Uint8Array(u);if(h[0]=3735928559,p[0]===239)return!0;if(p[0]===222)return!1;throw new Error("unknown endianness")}}t.EncodingGlslLib=a},9894:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragColorGlslLib=void 0;const s=i(8520),a=i(5060);class d extends s.GlslLib{constructor(h){super(h)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const h=(0,a.getGlsl)(this.context.glContext.version);return{setFragColor:new s.GlslLibRoutine(` - void setFragColor(float value) { - ${h.output} = encode(value); - } - `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new s.GlslLibRoutine(` - float getColorAsFloat(vec4 color) { - return decode(color); - } - `,["encoding.decode"])}}}t.FragColorGlslLib=d},2848:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.replaceInlines=void 0;const i=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;t.replaceInlines=function(s){const a={};let d;for(;(d=i.exec(s))!==null;){const u=d[3].split(",").map(h=>{const p=h.trim().split(" ");return p&&p.length===2?{type:p[0],name:p[1]}:null}).filter(h=>h!==null);a[d[2]]={params:u,body:d[4]}}for(const u in a){const h="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",u),p=new RegExp(h,"gm");for(;(d=p.exec(s))!==null;){const c=d[1],l=d[2],n=d[3].split(","),e=c?`${c} ${l};`:"";let r=a[u].body,o="";a[u].params.forEach((g,b)=>{g&&(o+=`${g.type} ${g.name} = ${n[b]}; -`)}),r=`${o} - ${r}`,r=r.replace("return",`${l} = `);const f=` - ${e} - { - ${r} - } - `;s=s.replace(d[0],f)}}return s.replace(i,"")}},8879:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlslPreprocessor=void 0;const s=i(8520),a=i(2848),d=i(5483),u=i(5060);t.GlslPreprocessor=class{constructor(h,p,c,l){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new s.GlslContext(h,p,c,l),Object.keys(d.glslRegistry).forEach(e=>{const r=new d.glslRegistry[e](this.context);this.libs[e]=r});const n=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const r=this.libs[e].getFunctions();for(const o in r){const f=e+"."+o;let g;n[f]?(g=n[f],g.routineBody=r[o].routineBody):(g=new s.GlslLibRoutineNode(f,r[o].routineBody),n[f]=g);const b=r[o].dependencies;if(b)for(let _=0;_{const l=c.split(".")[1];h.indexOf(l)!==-1&&p.push(this.glslLibRoutineDependencyGraph[c])}),s.TopologicalSortGlslRoutines.returnOrderedNodes(p)}getUniforms(h,p){const c=[];if(h)for(const l of h)c.push(`uniform sampler2D ${l};`);if(p)for(const l of p)c.push(`uniform ${l.type} ${l.name}${l.arrayLength?`[${l.arrayLength}]`:""};`);return c.join(` -`)}}},5483:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.glslRegistry=void 0;const s=i(5107),a=i(7341),d=i(9894),u=i(2655),h=i(3891);t.glslRegistry={encoding:a.EncodingGlslLib,fragcolor:d.FragColorGlslLib,vec:h.VecGlslLib,shapeUtils:u.ShapeUtilsGlslLib,coordinates:s.CoordsGlslLib}},2655:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShapeUtilsGlslLib=void 0;const s=i(8520);class a extends s.GlslLib{constructor(u){super(u)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const u=this.context.outputTextureLayout.shape.length,h={};return this.context.programInfo.inputNames.forEach((p,c)=>{const l=this.context.inputTextureLayouts[c].unpackedShape;if(l.length<=u){const n=l.length,e=u-n,r=`bcastIndices_${p}`;let o="";for(let g=0;g{const l=this.context.inputTextureLayouts[c].shape;if(!(l.length<2||l.length>u)){const n=l.length,e=u-n,r=`bcastMatmulIndices_${p}`;let o="";for(let g=0;g{const c=this.context.inputTextureLayouts[p].shape,l=this.context.inputTextureLayouts[p].strides,n=c.length;let e=`indicesToOffset_${h}`;u[e]=new s.GlslLibRoutine(a.indexToOffsetSingle(e,n,l)),e=`indicesToOffset_${h}_T`,u[e]=new s.GlslLibRoutine(a.indexToOffsetSingle(e,n,l.slice().reverse()))}),u}static indexToOffsetSingle(u,h,p){let c="";for(let l=h-1;l>=0;--l)c+=` - offset += indices[${l}] * ${p[l]}; - `;return` - int ${u}(int indices[${h}]) { - int offset = 0; - ${c} - return offset; - } - `}offsetToIndices(){const u={};return this.context.programInfo.inputNames.forEach((h,p)=>{const c=this.context.inputTextureLayouts[p].shape,l=this.context.inputTextureLayouts[p].strides,n=c.length;let e=`offsetToIndices_${h}`;u[e]=new s.GlslLibRoutine(a.offsetToIndicesSingle(e,n,l)),e=`offsetToIndices_${h}_T`,u[e]=new s.GlslLibRoutine(a.offsetToIndicesSingle(e,n,l.slice().reverse()))}),u}static offsetToIndicesSingle(u,h,p){const c=[];for(let l=0;l{const c=this.context.inputTextureLayouts[p].shape,l=c.length,n=`incrementIndices_${h}`;let e="";for(let o=0;o= 0; --i) { - if(i > axis) continue; - indices[i] += 1; - if(indices[i] < shape[i]) { - break; - } - indices[i] = 0; - } - } - `;u[n]=new s.GlslLibRoutine(r)}),u}}t.ShapeUtilsGlslLib=a},5060:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultFragShaderMain=t.getFragShaderPreamble=t.getVertexShaderSource=t.getGlsl=void 0;const i={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},s={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function a(d){return d===1?i:s}t.getGlsl=a,t.getVertexShaderSource=function(d){const u=a(d);return`${u.version} - precision highp float; - ${u.attribute} vec3 position; - ${u.attribute} vec2 textureCoord; - - ${u.varyingVertex} vec2 TexCoords; - - void main() - { - gl_Position = vec4(position, 1.0); - TexCoords = textureCoord; - }`},t.getFragShaderPreamble=function(d){const u=a(d);return`${u.version} - precision highp float; - precision highp int; - precision highp sampler2D; - ${u.varyingFrag} vec2 TexCoords; - ${u.outputDeclaration} - const vec2 halfCR = vec2(0.5, 0.5); - - // Custom vector types to handle higher dimenalities. - struct ivec5 - { - int x; - int y; - int z; - int w; - int u; - }; - - struct ivec6 - { - int x; - int y; - int z; - int w; - int u; - int v; - }; - - int imod(int x, int y) { - return x - y * (x / y); - } - - `},t.getDefaultFragShaderMain=function(d,u){return` - void main() { - int indices[${u}]; - toVec(TexCoords, indices); - vec4 result = vec4(process(indices)); - ${a(d).output} = result; - } - `}},3891:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VecGlslLib=void 0;const s=i(8520);class a extends s.GlslLib{constructor(u){super(u)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const u=this.context.outputTextureLayout.shape.length,h={add:"+=",sub:"-=",mul:"*=",div:"/="},p={};for(const c in h){const l=`${c}Vec`;let n="";for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLInferenceHandler=void 0;const s=i(6231),a=i(9162),d=i(2517),u=i(2403),h=i(7019),p=i(8710),c=i(5611),l=i(4057),n=i(2039);t.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,r){return(0,l.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,r)}executeProgram(e,r){if(r.length{const S=v.map(I=>`${I.unpackedShape.join(",")};${I.width}x${I.height}`).join("_");let A=w.name;return w.cacheHint&&(A+="["+w.cacheHint+"]"),A+=":"+S,A})(e,o);let g=this.session.programManager.getArtifact(f);const b=g?g.programInfo:typeof e.get=="function"?e.get():e,_=(0,l.createTextureLayoutFromTextureType)(this.session.layoutStrategy,b.output.dims,b.output.textureType),y=this.createTextureData(_,b.output.type);return g||(g=this.session.programManager.build(b,o,y),this.session.programManager.setArtifact(f,g)),this.runProgram(g,o,y),y}run(e,r){return this.executeProgram(e,r).tensor}runProgram(e,r,o){for(let f=0;fthis.readTexture(b),async _=>this.readTextureAsync(b),void 0,g),texture:o});return this.setTextureData(b.tensor.dataId,b,e.isPacked),b}getTextureData(e,r=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,r):r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,o=!1){this.session.isInitializer(e)?this.session.setTextureData(e,r,o):(o?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,r)}isTextureLayoutCached(e,r=!1){return!!this.getTextureData(e.dataId,r)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.session.textureManager.releaseTexture(e)),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,p.encodeAsUint8)(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,p.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,u.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,c.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},1640:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(X,J,ee,ue){ue===void 0&&(ue=ee);var Se=Object.getOwnPropertyDescriptor(J,ee);Se&&!("get"in Se?!J.__esModule:Se.writable||Se.configurable)||(Se={enumerable:!0,get:function(){return J[ee]}}),Object.defineProperty(X,ue,Se)}:function(X,J,ee,ue){ue===void 0&&(ue=ee),X[ue]=J[ee]}),a=this&&this.__setModuleDefault||(Object.create?function(X,J){Object.defineProperty(X,"default",{enumerable:!0,value:J})}:function(X,J){X.default=J}),d=this&&this.__importStar||function(X){if(X&&X.__esModule)return X;var J={};if(X!=null)for(var ee in X)ee!=="default"&&Object.prototype.hasOwnProperty.call(X,ee)&&s(J,X,ee);return a(J,X),J};Object.defineProperty(t,"__esModule",{value:!0}),t.WEBGL_OP_RESOLVE_RULES=void 0;const u=i(2898),h=d(i(7839)),p=i(4196),c=i(2069),l=i(8138),n=i(9663),e=i(5193),r=i(7992),o=i(1253),f=i(4776),g=i(6572),b=i(3346),_=i(5623),y=i(2870),w=i(2143),v=i(4939),S=i(718),A=i(2268),I=i(8117),x=i(2278),E=i(5524),F=i(5975),R=i(3933),$=i(6558),L=i(5723),G=i(3738),D=d(i(4909)),z=i(8428),Z=i(9793);t.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",D.abs],["Acos","","7+",D.acos],["Add","","7+",h.add],["And","","7+",h.and],["Asin","","7+",D.asin],["Atan","","7+",D.atan],["AveragePool","","7+",w.averagePool,w.parseAveragePoolAttributes],["BatchNormalization","","7+",u.batchNormalization,u.parseBatchNormalizationAttributes],["Cast","","6+",p.cast,p.parseCastAttributes],["Ceil","","6+",D.ceil],["Clip","","6-10",D.clip,D.parseClipAttributes],["Clip","","11+",D.clipV11],["Concat","","4+",c.concat,c.parseConcatAttributes],["Conv","","1+",l.conv,l.parseConvAttributes],["ConvTranspose","","1+",n.convTranspose,n.parseConvTransposeAttributes],["Cos","","7+",D.cos],["Div","","7+",h.div],["Dropout","","7+",D.identity],["DepthToSpace","","1+",e.depthToSpace,e.parseDepthToSpaceAttributes],["Equal","","7+",h.equal],["Elu","","6+",D.elu,D.parseEluAttributes],["Exp","","6+",D.exp],["Flatten","","1+",r.flatten,r.parseFlattenAttributes],["Floor","","6+",D.floor],["FusedConv","com.microsoft","1+",l.conv,l.parseConvAttributes],["Gather","","1+",o.gather,o.parseGatherAttributes],["Gemm","","7-10",f.gemm,f.parseGemmAttributesV7],["Gemm","","11+",f.gemm,f.parseGemmAttributesV11],["GlobalAveragePool","","1+",w.globalAveragePool,w.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",w.globalMaxPool],["Greater","","7+",h.greater],["Identity","","1+",D.identity],["ImageScaler","","1+",g.imageScaler,g.parseImageScalerAttributes],["InstanceNormalization","","6+",b.instanceNormalization,b.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",D.leakyRelu,D.parseLeakyReluAttributes],["Less","","7+",h.less],["Log","","6+",D.log],["MatMul","","1+",_.matMul,_.parseMatMulAttributes],["MaxPool","","1+",w.maxPool,w.parseMaxPoolAttributes],["Mul","","7+",h.mul],["Neg","","6+",D.neg],["Not","","1+",D.not],["Or","","7+",h.or],["Pad","","2-10",y.padV2,y.parsePadAttributesV2],["Pad","","11+",y.padV11,y.parsePadAttributesV11],["Pow","","7+",h.pow],["PRelu","","7+",h.pRelu],["ReduceLogSum","","1+",v.reduceLogSum,v.parseReduceAttributes],["ReduceMax","","1+",v.reduceMax,v.parseReduceAttributes],["ReduceMean","","1+",v.reduceMean,v.parseReduceAttributes],["ReduceMin","","1+",v.reduceMin,v.parseReduceAttributes],["ReduceProd","","1+",v.reduceProd,v.parseReduceAttributes],["ReduceSum","","1-12",v.reduceSum,v.parseReduceAttributes],["ReduceSumSquare","","1+",v.reduceLogSumSquare,v.parseReduceAttributes],["Relu","","6+",D.relu],["Reshape","","5+",S.reshape],["Resize","","10",A.resize,A.parseResizeAttributesV10],["Resize","","11+",A.resize,A.parseResizeAttributesV11],["Shape","","1+",I.shape],["Sigmoid","","6+",D.sigmoid],["Sin","","7+",D.sin],["Slice","","10+",x.sliceV10],["Slice","","1-9",x.slice,x.parseSliceAttributes],["Softmax","","1-12",E.softmax,E.parseSoftmaxAttributes],["Softmax","","13+",E.softmaxV13,E.parseSoftmaxAttributesV13],["Split","","2-12",F.split,F.parseSplitAttributes],["Sqrt","","6+",D.sqrt],["Squeeze","","1-12",R.squeeze,R.parseSqueezeAttributes],["Squeeze","","13+",R.squeezeV13],["Sub","","7+",h.sub],["Sum","","6+",$.sum],["Tan","","7+",D.tan],["Tanh","","6+",D.tanh],["Tile","","6+",L.tile],["Transpose","","1+",G.transpose,G.parseTransposeAttributes],["Upsample","","7-8",Z.upsample,Z.parseUpsampleAttributesV7],["Upsample","","9",Z.upsample,Z.parseUpsampleAttributesV9],["Unsqueeze","","1-12",z.unsqueeze,z.parseUnsqueezeAttributes],["Unsqueeze","","13+",z.unsqueezeV13],["Xor","","7+",h.xor]]},2898:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseBatchNormalizationAttributes=t.batchNormalization=void 0;const s=i(246),a=i(5060),d=i(2039),u={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]};t.batchNormalization=(c,l,n)=>(p(l),[c.run(Object.assign(Object.assign({},u),{cacheHint:n.cacheKey,get:()=>h(c,l,n)}),l)]),t.parseBatchNormalizationAttributes=c=>{const l=c.attributes.getFloat("epsilon",1e-5),n=c.attributes.getFloat("momentum",.9),e=c.attributes.getInt("spatial",1);return(0,s.createAttributeWithCacheKey)({epsilon:l,momentum:n,spatial:e})};const h=(c,l,n)=>{const e=(0,a.getGlsl)(c.session.backend.glContext.version),r=l[0].dims.length,[o,f]=c.calculateTextureWidthAndHeight(l[1].dims,d.TextureType.unpacked),g=` - float process(int[${r}] indices) { - vec2 position = offsetToCoords(indices[1], ${o}, ${f}); - float scale = getColorAsFloat(${e.texture2D}(Scale, position)); - float mean = getColorAsFloat(${e.texture2D}(Mean, position)); - float variance = getColorAsFloat(${e.texture2D}(Variance, position)); - float b = getColorAsFloat(${e.texture2D}(B, position)); - - return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b; - }`;return Object.assign(Object.assign({},u),{output:{dims:l[0].dims,type:l[0].type,textureType:d.TextureType.unpacked},shaderSource:g})},p=c=>{if(!c||c.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const l=c[0],n=c[1],e=c[2],r=c[3],o=c[4];if(l.dims.length<3||n.dims.length!==1||e.dims.length!==1||r.dims.length!==1||o.dims.length!==1)throw new Error("invalid input shape.");if(n.dims[0]!==l.dims[1]||e.dims[0]!==l.dims[1]||r.dims[0]!==l.dims[1]||o.dims[0]!==l.dims[1])throw new Error("invalid input shape.");if(l.type!=="float32"&&l.type!=="float64"||n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||o.type!=="float32"&&o.type!=="float64")throw new Error("invalid input tensor types.")}},7839:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xor=t.sub=t.pRelu=t.pow=t.or=t.mul=t.less=t.greater=t.equal=t.div=t.and=t.add=t.glslPRelu=t.glslPow=t.glslXor=t.glslOr=t.glslAnd=t.glslLess=t.glslGreater=t.glslEqual=t.glslSub=t.glslMul=t.glslDiv=t.glslAdd=void 0;const s=i(2517),a=i(8520),d=i(5060),u=i(2039);function h(){const v="add_";return{body:` - float ${v}(float a, float b) { - return a + b; - } - vec4 ${v}(vec4 v1, vec4 v2) { - return v1 + v2; - } - `,name:v,type:a.FunctionType.ValueBased}}function p(){const v="div_";return{body:` - float ${v}(float a, float b) { - return a / b; - } - vec4 ${v}(vec4 v1, vec4 v2) { - return v1 / v2; - } - `,name:v,type:a.FunctionType.ValueBased}}function c(){const v="mul_";return{body:` - float ${v}(float a, float b) { - return a * b; - } - vec4 ${v}(vec4 v1, vec4 v2) { - return v1 * v2; - } - `,name:v,type:a.FunctionType.ValueBased}}function l(){const v="sub_";return{body:` - float ${v}(float a, float b) { - return a - b; - } - vec4 ${v}(vec4 v1, vec4 v2) { - return v1 - v2; - } - `,name:v,type:a.FunctionType.ValueBased}}function n(){const v="equal_";return{body:` - float ${v}(float a, float b) { - return float(a == b); - } - vec4 ${v}(vec4 v1, vec4 v2) { - return vec4(equal(v1, v2)); - } - `,name:v,type:a.FunctionType.ValueBased}}function e(){const v="greater_";return{body:` - float ${v}(float a, float b) { - return float(a > b); - } - vec4 ${v}(vec4 v1, vec4 v2) { - return vec4( v1.r > v2.r , - v1.g > v2.g, - v1.b > v2.b, - v1.a > v2.a ); - } - `,name:v,type:a.FunctionType.ValueBased}}function r(){const v="less_";return{body:` - float ${v}(float a, float b) { - return float(a < b); - } - vec4 ${v}(vec4 v1, vec4 v2) { - return vec4( v1.r < v2.r , - v1.g < v2.g, - v1.b < v2.b, - v1.a < v2.a ); - } - `,name:v,type:a.FunctionType.ValueBased}}function o(){const v="and_";return{body:` - float ${v}(float a, float b) { - return float( bool(a) && bool(b) ); - } - vec4 ${v}(vec4 v1, vec4 v2) { - bvec4 b1 = bvec4(v1); - bvec4 b2 = bvec4(v2); - return vec4( b1.r && b2.r , - b1.g && b2.g, - b1.b && b2.b, - b1.a && b2.a ); - } - `,name:v,type:a.FunctionType.ValueBased}}function f(){const v="or_";return{body:` - float ${v}(float a, float b) { - return float( bool(a) || bool(b) ); - } - vec4 ${v}(vec4 v1, vec4 v2) { - bvec4 b1 = bvec4(v1); - bvec4 b2 = bvec4(v2); - return vec4( b1.r || b2.r , - b1.g || b2.g, - b1.b || b2.b, - b1.a || b2.a ); - } - `,name:v,type:a.FunctionType.ValueBased}}function g(){const v="xor_";return{body:` - float ${v}(float a, float b) { - return float( bool(a) ^^ bool(b) ); - } - vec4 ${v}(vec4 v1, vec4 v2) { - bvec4 b1 = bvec4(v1); - bvec4 b2 = bvec4(v2); - return vec4( b1.r ^^ b2.r , - b1.g ^^ b2.g, - b1.b ^^ b2.b, - b1.a ^^ b2.a ); - } - `,name:v,type:a.FunctionType.ValueBased}}function b(){return function(v){const S=`${v}_`;return{body:` - float ${S}(float a, float b) { - return ${v}(a, b); - } - vec4 ${S}(vec4 v1, vec4 v2) { - return ${v}(v1, v2); - } - `,name:S,type:a.FunctionType.ValueBased}}("pow")}function _(){const v="prelu_";return{body:` - float ${v}(float a, float b) { - return a < 0.0 ? a * b: a; - } - vec4 ${v}(vec4 v1, vec4 v2) { - return vec4( - v1.r < 0.0 ? v1.r * v2.r: v1.r, - v1.g < 0.0 ? v1.g * v2.g: v1.g, - v1.b < 0.0 ? v1.b * v2.b: v1.b, - v1.a < 0.0 ? v1.a * v2.a: v1.a - ); - } - `,name:v,type:a.FunctionType.ValueBased}}t.glslAdd=h,t.glslDiv=p,t.glslMul=c,t.glslSub=l,t.glslEqual=n,t.glslGreater=e,t.glslLess=r,t.glslAnd=o,t.glslOr=f,t.glslXor=g,t.glslPow=b,t.glslPRelu=_;const y=(v,S,A,I=S[0].type,x)=>{const E=v.session.pack?u.TextureType.packed:u.TextureType.unpacked;return{name:A.name,inputNames:["A","B"],inputTypes:[E,E],cacheHint:x,get:()=>w(v,S,A,I)}},w=(v,S,A,I=S[0].type)=>{const x=v.session.pack?u.TextureType.packed:u.TextureType.unpacked,E=!s.ShapeUtil.areEqual(S[0].dims,S[1].dims);let F=S[0].dims;const R=v.session.pack;if(E){const G=s.BroadcastUtil.calcShape(S[0].dims,S[1].dims,!1);if(!G)throw new Error("Can't perform binary op on the given tensors");F=G;const D=F.length,z=S[0].dims.length!==0?S[0].dims.length:1,Z=S[1].dims.length!==0?S[1].dims.length:1,X=S[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",J=S[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",ee=(0,d.getGlsl)(v.session.backend.glContext.version),ue=R?` - ${A.body} - void main() { - vec4 a = getAAtOutCoords(); - vec4 b = getBAtOutCoords(); - vec4 result = ${A.name}(a, b); - ${ee.output} = result; - }`:` - ${A.body} - float process(int indices[${D}]) { - int aindices[${z}]; - int bindices[${Z}]; - ${X} - ${J} - return ${A.name}(_A(aindices), _B(bindices)); - }`;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:F,type:I,textureType:x},shaderSource:ue,hasMain:R}}const $=(0,d.getGlsl)(v.session.backend.glContext.version),L=` - ${A.body} - void main() { - vec4 v1 = ${$.texture2D}(A, TexCoords); - vec4 v2 = ${$.texture2D}(B, TexCoords); - vec4 result = ${A.name}(v1, v2); - ${$.output} = result; - } - `;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:S[0].dims,type:I,textureType:x},shaderSource:L,hasMain:!0}};t.add=(v,S)=>[v.run(y(v,S,h()),S)],t.and=(v,S)=>[v.run(y(v,S,o(),"bool"),S)],t.div=(v,S)=>[v.run(y(v,S,p()),S)],t.equal=(v,S)=>[v.run(y(v,S,n(),"bool"),S)],t.greater=(v,S)=>[v.run(y(v,S,e(),"bool"),S)],t.less=(v,S)=>[v.run(y(v,S,r(),"bool"),S)],t.mul=(v,S)=>[v.run(y(v,S,c()),S)],t.or=(v,S)=>[v.run(y(v,S,f(),"bool"),S)],t.pow=(v,S)=>[v.run(y(v,S,b()),S)],t.pRelu=(v,S)=>[v.run(y(v,S,_()),S)],t.sub=(v,S)=>[v.run(y(v,S,l()),S)],t.xor=(v,S)=>[v.run(y(v,S,g(),"bool"),S)]},4196:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseCastAttributes=t.cast=void 0;const s=i(2517);t.cast=(d,u,h)=>(a(u),[d.cast(u[0],h)]),t.parseCastAttributes=d=>s.ProtoUtil.tensorDataTypeFromProto(d.attributes.getInt("to"));const a=d=>{if(!d||d.length!==1)throw new Error("Cast requires 1 input.");if(d[0].type==="string")throw new Error("Invalid input type.")}},1163:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedConcatProgramInfoLoader=void 0;const s=i(5060),a=i(2039),d=i(9390),u=i(2827);t.createPackedConcatProgramInfoLoader=(p,c,l)=>{const n=(e=c.length,r=l.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(o,f)=>`X${f}`),inputTypes:Array(e).fill(a.TextureType.packed),cacheHint:r});var e,r;return Object.assign(Object.assign({},n),{get:()=>((o,f,g,b)=>{const _=g[0].dims.slice();if(b>=_.length||b<-1*_.length)throw new Error("axis specified for concat doesn't match input dimensionality");b<0&&(b=_.length+b);const y=_.slice(0);for(let X=1;XX.dims),x=(0,d.getGlChannels)(w),E=new Array(I.length-1);E[0]=I[0][b];for(let X=1;X= ${E[X-1]}) { - return getChannel( - getX${X}(${h(x,F,J)}), - vec2(${h(R,F,J)})); - }`}const G=E.length,D=E[E.length-1];L+=` - return getChannel( - getX${G}(${h(x,F,D)}), - vec2(${h(R,F,D)}));`;const z=(0,s.getGlsl)(o.session.backend.glContext.version),Z=` - ${A} - float getValue(${x.map(X=>"int "+X)}) { - ${L} - } - - void main() { - ${S} coords = getOutputCoords(); - int lastDim = coords.${x[w-1]}; - coords.${x[w-1]} = coords.${x[w-2]}; - coords.${x[w-2]} = lastDim; - - vec4 result = vec4(getValue(${v}), 0., 0., 0.); - - ${v[w-1]} = ${v[w-1]} + 1; - if (${v[w-1]} < ${y[w-1]}) { - result.g = getValue(${v}); - } - - ${v[w-2]} = ${v[w-2]} + 1; - if (${v[w-2]} < ${y[w-2]}) { - result.a = getValue(${v}); - } - - ${v[w-1]} = ${v[w-1]} - 1; - if (${v[w-2]} < ${y[w-2]} && - ${v[w-1]} < ${y[w-1]}) { - result.b = getValue(${v}); - } - ${z.output} = result; - } - `;return Object.assign(Object.assign({},f),{output:{dims:y,type:g[0].type,textureType:a.TextureType.packed},shaderSource:Z,hasMain:!0})})(p,n,c,l.axis)})};const h=(p,c,l)=>{const n=p.indexOf(c);return p.map((e,r)=>r===n?`${e} - ${l}`:e).join()}},2069:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConcatAttributes=t.concat=void 0;const s=i(246),a=i(2039),d=i(1163);t.concat=(e,r,o)=>(n(r),e.session.pack&&r[0].dims.length>1?[e.run((0,d.createPackedConcatProgramInfoLoader)(e,r,o),r)]:[e.run(u(e,r,o),r)]);const u=(e,r,o)=>{const f=(g=r.length,b=o.cacheKey,{name:"Concat",inputNames:Array.from({length:g},(_,y)=>`X${y}`),inputTypes:Array(g).fill(a.TextureType.unpacked),cacheHint:b});var g,b;return Object.assign(Object.assign({},f),{get:()=>((_,y,w,v)=>{const S=w[0].dims.slice();if(v>=S.length||v<-1*S.length)throw new Error("axis specified for concat doesn't match input dimensionality");v<0&&(v=S.length+v);const A=S.slice(0);for(let $=1;$`int getTextureWhereDataResides(int index) { - ${e.map((r,o)=>`if(index<${r}) {return ${o};} -`).join("")} - }`,p=e=>h(e),c=(e,r)=>{const o=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let f=0;f{const r=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let o=0;o(0,s.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const n=e=>{if(!e||e.length<1)throw new Error("too few inputs");const r=e[0].type,o=e[0].dims.length;if(r==="string")throw new Error("string tensor is not supported yet");for(const f of e){if(f.type!==r)throw new Error("input tensors should be one type");if(f.dims.length!==o)throw new Error("input tensors should have the same shape")}}},4770:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackedGroupedConvProgramInfoLoader=void 0;const s=i(6231),a=i(5060),d=i(2039),u=i(8138),h=i(2823);t.createUnpackedGroupedConvProgramInfoLoader=(p,c,l)=>{const n=(e=c.length>2,r=l.cacheKey,{name:"GroupedConv",inputNames:e?["X","W","Bias"]:["X","W"],inputTypes:e?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],cacheHint:r});var e,r;return Object.assign(Object.assign({},n),{get:()=>((o,f,g,b)=>{const _=f.length>2?"value += getBias(output_channel);":"",y=f[0].dims.slice(),w=f[1].dims.slice(),v=w[0]/b.group;s.Logger.verbose("GroupedConv",`autpPad:${b.autoPad}, dilations:${b.dilations}, group:${b.group}, kernelShape:${b.kernelShape}, pads:${b.pads}, strides:${b.strides}`);const S=(0,u.calculateOutputShape)(y,w,b.dilations,b.pads,b.strides),A=(0,a.getGlsl)(o.session.backend.glContext.version),{activationFunction:I,applyActivation:x}=(0,h.getActivationSnippet)(b),E=` - const ivec2 strides = ivec2(${b.strides[0]}, ${b.strides[1]}); - const ivec2 pads = ivec2(${b.pads[0]}, ${b.pads[1]}); - ${I} - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - int output_channel = coords.y; - ivec2 xRCCorner = coords.zw * strides - pads; - int group_id = output_channel / ${v}; - - float value = 0.0; - for (int wInChannel = 0; wInChannel < ${w[1]}; wInChannel++) { - int input_channel = group_id * ${w[1]} + wInChannel; - for (int wHeight = 0; wHeight < ${w[2]}; wHeight++) { - int xHeight = xRCCorner.x + wHeight * ${b.dilations[0]}; - - if (xHeight < 0 || xHeight >= ${y[2]}) { - continue; - } - - for (int wWidth = 0; wWidth < ${w[3]}; wWidth++) { - int xWidth = xRCCorner.y + wWidth * ${b.dilations[1]}; - if (xWidth < 0 || xWidth >= ${y[3]}) { - continue; - } - - float xVal = getX(batch, input_channel, xWidth, xHeight); - float wVal = getW(output_channel, wInChannel, wWidth, wHeight); - value += xVal*wVal; - } - } - } - ${_} - ${x} - ${A.output} = vec4(value, .0, .0, .0); - } -`;return Object.assign(Object.assign({},g),{output:{dims:S,type:f[0].type,textureType:d.TextureType.unpacked},shaderSource:E,hasMain:!0})})(p,c,n,l)})}},1386:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.conv2DPacked=t.conv2DPackedPointwise=void 0;const s=i(8138),a=i(8555),d=i(708);t.conv2DPackedPointwise=(u,h,p)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,p.dilations,p.pads,p.strides),e=u.reshapePacked(h[0],[c[1],c[2]*c[3]]),r=u.reshapePacked(h[1],[l[0],l[1]]),o=h.length>2?[r,e,h[2]]:[r,e],f=u.run((0,d.createPackedMatmulProgramInfoLoader)(u,o,p),o);return u.reshapePacked(f,n)},t.conv2DPacked=(u,h,p)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,p.dilations,p.pads,p.strides),e=u.run((0,a.createPackedIm2ColProgramInfoLoader)(u,h[0],h[1],n,p),[h[0]]),r=u.reshapePacked(h[1],[l[0],l[1]*l[2]*l[3]]),o=h.length===3?[r,e,h[2]]:[r,e],f=u.run((0,d.createPackedMatmulProgramInfoLoader)(u,o,p),o);return u.reshapePacked(f,n)}},9663:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvTransposeAttributes=t.convTranspose=void 0;const s=i(246),a=i(5060),d=i(2039),u=i(2823),h=(r,o,f,g,b,_)=>(r-1)*o+f+(g-1)*b+1-_,p=(r,o,f,g,b)=>{const _=Math.floor(r/2);o==="SAME_UPPER"?(f[g]=_,f[b]=r-_):o==="SAME_LOWER"&&(f[g]=r-_,f[b]=_)};t.convTranspose=(r,o,f)=>(e(o,f),c(r,o,f));const c=(r,o,f)=>{const g=n(f,o);return[l(r,o,g)]},l=(r,o,f)=>r.run(((g,b,_)=>{const y=(w=b.length>2,v=_.cacheKey,{name:"ConvTranspose",inputNames:w?["X","W","B"]:["X","W"],inputTypes:w?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],cacheHint:v});var w,v;return Object.assign(Object.assign({},y),{get:()=>((S,A,I,x)=>{const E=A.length>2?"getB(output_channel)":"0.0",F=A[0].dims,R=A[1].dims,$=R[1],L=R[0]/x.group,G=[A[0].dims[0],A[1].dims[1]*x.group,...x.outputShape],D=(0,a.getGlsl)(S.session.backend.glContext.version),{activationFunction:z,applyActivation:Z}=(0,u.getActivationSnippet)(x),X=` - const ivec2 strides = ivec2(${x.strides[0]}, ${x.strides[1]}); - const ivec2 pads = ivec2(${x.pads[0]}, ${x.pads[1]}); - ${z} - void main() { - ivec4 coords = getOutputCoords(); - int batch = coords.x; - int output_channel = coords.y; - - ivec2 loc = coords.zw + pads; - - int group_id = output_channel / ${$}; - int wOutChannel = output_channel - group_id * ${$}; - - float value = ${E}; - for (int inChannelOffset = 0; inChannelOffset < ${L}; inChannelOffset++) { - int input_channel = group_id * ${L} + inChannelOffset; - for (int wWOff = 0; wWOff < ${R[2]}; wWOff++) { - for (int wHOff = 0; wHOff < ${R[3]}; wHOff++) { - ivec2 wOff = ivec2(wWOff * ${x.dilations[0]}, wHOff * ${x.dilations[1]}); - ivec2 wLoc = loc - wOff; - ivec2 wLocIn = wLoc / strides; - if ( - wLocIn * strides == wLoc && - wLocIn.x >= 0 && wLocIn.x < ${F[2]} && - wLocIn.y >= 0 && wLocIn.y < ${F[3]} - ) { - float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); - float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); - value += xVal * wVal; - } - } - } - } - ${Z} - ${D.output} = vec4(value, .0, .0, .0); - } -`;return Object.assign(Object.assign({},I),{output:{dims:G,type:A[0].type,textureType:d.TextureType.unpacked},shaderSource:X,hasMain:!0})})(g,b,y,_)})})(r,o,f),o),n=(r,o)=>{const f=r.kernelShape.slice();if(r.kernelShape.length===0)for(let y=2;y{const F=y.length-2,R=E.length===0;for(let $=0;${const o=r.attributes,f=(0,u.parseInternalActivationAttributes)(o),g=o.getString("auto_pad","NOTSET"),b=o.getInts("dilations",[1,1]),_=o.getInt("group",1),y=o.getInts("kernel_shape",[]),w=o.getInts("output_padding",[0,0]),v=o.getInts("output_shape",[]),S=o.getInts("pads",[0,0,0,0]),A=o.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:g,dilations:b,group:_,kernelShape:y,outputPadding:w,outputShape:v,pads:S,strides:A},f))};const e=(r,o)=>{if(!r||r.length!==2&&r.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(r[0].dims.length!==4||r[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(r[0].dims[1]!==r[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const f=r[1].dims[1]*o.group;if(r.length===3&&(r[2].dims.length!==1||r[2].dims[0]!==f))throw new Error("invalid bias");const g=r[0].dims.length-2;if(o.dilations.length!==g)throw new Error(`dilations should be ${g}D`);if(o.strides.length!==g)throw new Error(`strides should be ${g}D`);if(o.pads.length!==2*g)throw new Error(`pads should be ${2*g}D`);if(o.outputPadding.length!==g)throw new Error(`output_padding should be ${g}D`);if(o.kernelShape.length!==0&&o.kernelShape.length!==r[1].dims.length-2)throw new Error("invalid kernel shape");if(o.outputShape.length!==0&&o.outputShape.length!==r[0].dims.length-2)throw new Error("invalid output shape");if(r[0].type!=="float32"||r[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(r.length===3&&r[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},8138:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvAttributes=t.conv=t.calculateOutputShape=void 0;const s=i(246),a=i(2517),d=i(4770),u=i(1386),h=i(9828),p=i(2823),c=i(3248),l=i(5623);t.calculateOutputShape=(g,b,_,y,w)=>{const v=g[0],S=g.slice(2),A=S.length,I=b[0],x=b.slice(2).map((F,R)=>F+(F-1)*(_[R]-1)),E=S.map((F,R)=>F+y[R]+y[R+A]).map((F,R)=>Math.floor((F-x[R]+w[R])/w[R]));return[v,I].concat(...E)},t.conv=(g,b,_)=>(f(b,_),n(g,b,_));const n=(g,b,_)=>{const y=o(_,b),w=g.session.pack,v=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[g.run((0,d.createUnpackedGroupedConvProgramInfoLoader)(g,b,y),b)]:v&&w?[e(g,b,y)]:w&&b[0].dims.length===4&&b[0].dims[0]===1&&!v?[(0,u.conv2DPacked)(g,b,y)]:[r(g,b,y)]},e=(g,b,_)=>{const y=b[0].dims,w=b[1].dims,v=(0,t.calculateOutputShape)(y,w,_.dilations,_.pads,_.strides),S=g.reshapeUnpacked(b[0],[y[1],y[2]*y[3]]),A=g.reshapeUnpacked(b[1],[w[0],w[1]]),I=b.length>2?[A,S,b[2]]:[A,S],x=g.run((0,l.createMatmulProgramInfoLoader)(I,_),I);return g.reshapeUnpacked(x,v)},r=(g,b,_)=>{const y=b[0].dims,w=b[1].dims,v=(0,t.calculateOutputShape)(y,w,_.dilations,_.pads,_.strides),S=g.run((0,c.createIm2ColProgramInfoLoader)(g,b[0],b[1],v,_),[b[0]]),A=b.length===3?[S,b[1],b[2]]:[S,b[1]];return g.run((0,h.createDotProductProgramInfoLoader)(g,b,v,_),A)},o=(g,b)=>{const _=g.kernelShape.slice();if(g.kernelShape.length===0)for(let v=2;v{const b=g.attributes,_=(0,p.parseInternalActivationAttributes)(b),y=b.getString("auto_pad","NOTSET"),w=b.getInts("dilations",[1,1]),v=b.getInt("group",1),S=b.getInts("kernel_shape",[]),A=b.getInts("pads",[0,0,0,0]),I=b.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:w,group:v,kernelShape:S,pads:A,strides:I},_))};const f=(g,b)=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(g[0].dims.length!==4||g[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(g[0].dims[1]!==g[1].dims[1]*b.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(g.length===3&&(g[2].dims.length!==1||g[1].dims[0]!==g[2].dims[0]))throw new Error("invalid bias");const _=g[0].dims.length-2;if(b.dilations.length!==_)throw new Error(`dilations should be ${_}D`);if(b.strides.length!==_)throw new Error(`strides should be ${_}D`);if(b.pads.length!==2*_)throw new Error(`pads should be ${2*_}D`);if(b.kernelShape.length!==0&&b.kernelShape.length!==g[1].dims.length-2)throw new Error("invalid kernel shape");if(g[0].type!=="float32"||g[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(g.length===3&&g[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},5193:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDepthToSpaceAttributes=t.depthToSpace=void 0;const s=i(3738);t.depthToSpace=(d,u,h)=>{a(u);const p=h.blocksize,c=p*p,l=h.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],n=h.mode==="DCR"?[u[0].dims[0],p,p,u[0].dims[1]/c,u[0].dims[2],u[0].dims[3]]:[u[0].dims[0],u[0].dims[1]/c,p,p,u[0].dims[2],u[0].dims[3]],e=d.reshapeUnpacked(u[0],n),r={perm:l,cacheKey:`${l}`},[o]=(0,s.transpose)(d,[e],r),f=[u[0].dims[0],u[0].dims[1]/c,u[0].dims[2]*p,u[0].dims[3]*p];return[d.reshapeUnpacked(o,f)]},t.parseDepthToSpaceAttributes=d=>{const u=d.attributes.getInt("blocksize");if(u<1)throw new Error(`blocksize must be >= 1, but got : ${u} for DepthToSpace`);const h=d.attributes.getString("mode","DCR");if(h!=="DCR"&&h!=="CRD")throw new Error(`unrecognized mode: ${h} for DepthToSpace`);return{mode:h,blocksize:u}};const a=d=>{if(d.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${d.length}`);if(d[0].type==="string"||d[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},9828:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createDotProductProgramInfoLoader=void 0;const s=i(2517),a=i(5060),d=i(2039),u=i(2823),h=i(3248);t.createDotProductProgramInfoLoader=(p,c,l,n)=>{const e=((r,o)=>({name:"ConvDotProduct",inputNames:r?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:r?[d.TextureType.unpacked,d.TextureType.packedLastDimension,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.packedLastDimension],cacheKey:o.activationCacheKey}))(c.length>2,n);return Object.assign(Object.assign({},e),{get:()=>((r,o,f,g,b)=>{const _=f[0].dims,y=f[1].dims,w=[y[0],Math.ceil(_[1]*y[2]*y[3]/4)],v=(0,h.calculateIm2ColDims)(_,y,g),[S,A]=r.calculateTextureWidthAndHeight(w,d.TextureType.packedLastDimension),I=s.ShapeUtil.computeStrides(v),[x,E]=r.calculateTextureWidthAndHeight(v,d.TextureType.packedLastDimension),F=g.length,R=f.length<3?"0.0":"_B(b)",$=Math.ceil(_[1]*y[2]*y[3]/4),{activationFunction:L,applyActivation:G}=(0,u.getActivationSnippet)(b),D=(0,a.getGlsl)(r.session.backend.glContext.version),z=` -${L} -float process(int indices[${F}]) { - int b[1]; - b[0] = indices[1]; - int im2col[4]; - im2col[0] = indices[0]; - im2col[1] = indices[2]; - im2col[2] = indices[3]; - int im2colOffset = im2col[0] * ${I[0]} + im2col[1] * ${I[1]} + im2col[2] * ${I[2]}; - int kernelOffset = indices[1] * ${w[1]}; - float value = ${R}; - for (int i = 0; i < ${$}; ++i) { - vec2 im2colCoords = offsetToCoords(im2colOffset, ${x}, ${E}); - vec2 kernelCoords = offsetToCoords(kernelOffset, ${S}, ${A}); - value += dot(${D.texture2D}(Im2Col, im2colCoords), ${D.texture2D}(K, kernelCoords)); - ++im2colOffset; - ++kernelOffset; - } - ${G} - return value; -}`;return Object.assign(Object.assign({},o),{output:{dims:g,type:f[0].type,textureType:d.TextureType.unpacked},shaderSource:z})})(p,e,c,l,n)})}},7992:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseFlattenAttributes=t.flatten=void 0;const s=i(2517);t.flatten=(d,u,h)=>{a(u,h);const p=s.ShapeUtil.flattenShape(u[0].dims,h);return[d.reshapeUnpacked(u[0],p)]},t.parseFlattenAttributes=d=>d.attributes.getInt("axis",1);const a=(d,u)=>{if(!d||d.length!==1)throw new Error("Flatten requires 1 input.");const h=d[0].dims.length;if(h===0)throw new Error("scalar tensor is not supported.");if(u<-h||u>h)throw new Error("Invalid axis");if(d[0].type==="string")throw new Error("string tensor is not supported.")}},2823:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseInternalActivationAttributes=t.getActivationSnippet=void 0;const s=i(2517),a=i(4909);t.getActivationSnippet=function(d){let u;switch(d.activation){case"Relu":u=(0,a.glslRelu)();break;case"Sigmoid":u=(0,a.glslSigmoid)();break;case"Clip":u=(0,a.glslClip)(d.clipMin,d.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const h=u.name;return{activationFunction:u.body,applyActivation:`value = ${h}_(value);`}},t.parseInternalActivationAttributes=d=>{const u=d.getString("activation","");if(u==="Clip"){const[h,p]=d.getFloats("activation_params",[s.MIN_CLIP,s.MAX_CLIP]);return{activation:u,clipMax:p,clipMin:h,activationCacheKey:`${u}:${h},${p}`}}return{activation:u,activationCacheKey:u}}},1253:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGatherAttributes=t.gather=void 0;const s=i(246),a=i(782),d=i(2517),u=i(2039);t.gather=(l,n,e)=>(c(n,e.axis),[l.run(p(l,n,e),n)]),t.parseGatherAttributes=l=>(0,s.createAttributeWithCacheKey)({axis:l.attributes.getInt("axis",0)});const h={name:"Gather",inputNames:["A","B"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked]},p=(l,n,e)=>{const r=Object.assign(Object.assign({},h),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((o,f,g,b)=>{const _=g[0].dims.slice(),y=g[1].dims.slice(),w=new Array(_.length+y.length-1);b=d.ShapeUtil.normalizeAxis(b,_.length);const v=[];for(let A=0;A{if(!l||l.length!==2)throw new Error("Gather requires 2 inputs.");const e=l[0].dims.length;if(e<1)throw new Error("Invalid input shape.");if(n<-e||n>e-1)throw new Error("Invalid axis.");if(a.NUMBER_TYPES.indexOf(l[0].type)===-1)throw new Error("Invaid input type.");if(l[1].type!=="int32"&&l[1].type!=="int16")throw new Error("Invaid input type.")}},4776:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGemmAttributesV11=t.parseGemmAttributesV7=t.gemm=void 0;const s=i(246),a=i(2517),d=i(2039);t.gemm=(l,n,e)=>(c(n,e),[l.run(h(n,e),n)]);const u=(l,n)=>{const e=l.attributes.getInt("transA",0)!==0,r=l.attributes.getInt("transB",0)!==0,o=l.attributes.getFloat("alpha",1),f=l.attributes.getFloat("beta",1);return(0,s.createAttributeWithCacheKey)({transA:e,transB:r,alpha:o,beta:f,isOptionalC:n})};t.parseGemmAttributesV7=l=>u(l,!1),t.parseGemmAttributesV11=l=>u(l,!0);const h=(l,n)=>{const e={name:"Gemm",inputNames:l.length===3?["A","B","C"]:["A","B"],inputTypes:l.length===3?[d.TextureType.unpacked,d.TextureType.unpacked,d.TextureType.unpacked]:[d.TextureType.unpacked,d.TextureType.unpacked],key:n.cacheKey};return Object.assign(Object.assign({},e),{get:()=>p(e,l,n)})},p=(l,n,e)=>{const r=n[0].dims.slice(),o=n[1].dims.slice(),[f,g]=a.GemmUtil.getShapeOfGemmResult(r,e.transA,o,e.transB,n.length===3?n[2].dims:void 0),b=[f,g];if(!b)throw new Error("Can't use gemm on the given tensors");let _=r[r.length-1],y="";e.transA&&(_=r[0]),e.transA&&e.transB?y="value += _A_T(a) * _B_T(b);":e.transA&&!e.transB?y="value += _A_T(a) * _B(b);":!e.transA&&e.transB?y="value += _A(a) * _B_T(b);":e.transA||e.transB||(y="value += _A(a) * _B(b);");const w=b.length,v=` - float process(int indices[${w}]) { - int a[${w}]; - int b[${w}]; - ${n.length===3?`int c[${n[2].dims.length}];`:""} - - copyVec(indices, a); - copyVec(indices, b); - ${n.length===3?"bcastIndices_C(indices, c);":""} - - float value = 0.0; - for (int k=0; k<${_}; ++k) { - a[${w-1}] = k; - b[${w-2}] = k; - ${y} - } - - value = value * alpha; - ${n.length===3?"value += beta * _C(c);":""} - return value; - }`;return Object.assign(Object.assign({},l),{output:{dims:b,type:n[0].type,textureType:d.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:v})},c=(l,n)=>{if(!l)throw new Error("Input is missing");if(n.isOptionalC&&(l.length<2||l.length>3))throw new Error("Invaid input shape.");if(!n.isOptionalC&&l.length!==3)throw new Error("Gemm requires 3 inputs");if(l.length===3&&l[2].dims.length!==1&&l[2].dims.length!==2)throw new Error("Invalid input shape of C");if(l[0].type!=="float32"&&l[0].type!=="float64"||l[1].type!=="float32"&&l[1].type!=="float64"||l.length===3&&l[2].type!=="float32"&&l[2].type!=="float64")throw new Error("Invalid input type.");if(l[0].type!==l[1].type||l.length===3&&l[0].type!==l[2].type)throw new Error("Input types are mismatched")}},8555:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedIm2ColProgramInfoLoader=void 0;const s=i(5060),a=i(2039),d=i(2827);t.createPackedIm2ColProgramInfoLoader=(u,h,p,c,l)=>{const n=(e=l.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[a.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},n),{get:()=>((r,o,f,g,b,_)=>{const y=f.dims,w=g.dims,v=b.length,S=[w[1]*w[2]*w[3],b[2]*b[3]],A=w[2]*w[3],I=(0,d.unpackFromChannel)(),x=(0,s.getGlsl)(r.session.backend.glContext.version);let E="";for(let R=0;R<=1;R++)for(let $=0;$<=1;$++)E+=` - blockIndex = rc.x + ${$}; - pos = rc.y + ${R}; - - if(blockIndex < ${S[1]} && pos < ${S[0]}) { - offsetY = int(blockIndex / (${b[v-1]})) * ${_.strides[0]} - - ${_.pads[0]}; - d0 = offsetY + ${_.dilations[0]} * (imod(pos, ${A}) / ${w[2]}); - - if(d0 < ${y[2]} && d0 >= 0) { - offsetX = imod(blockIndex, ${b[v-1]}) * ${_.strides[1]} - - ${_.pads[1]}; - d1 = offsetX + ${_.dilations[1]} * imod(imod(pos, ${A}), ${w[2]}); - - if(d1 < ${y[3]} && d1 >= 0) { - - ch = int(float(pos)/ ${A}.); - innerDims = vec2(d0, d1); - result[${2*R+$}] = getChannel( - getA(0, ch, int(innerDims.x), - int(innerDims.y)), innerDims); - } - } - } - - `;const F=` - ${I} - - void main() { - ivec2 rc = getOutputCoords(); - vec4 result = vec4(0.0); - int blockIndex, pos, offsetY, d0, offsetX, d1, ch; - vec2 innerDims; - ${E} - ${x.output} = result; - } - `;return Object.assign(Object.assign({},o),{output:{dims:S,type:f.type,textureType:a.TextureType.packed},shaderSource:F,hasMain:!0})})(u,n,h,p,c,l)})}},3248:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculateIm2ColDims=t.createIm2ColProgramInfoLoader=void 0;const s=i(2039);t.createIm2ColProgramInfoLoader=(a,d,u,h,p)=>{const c=(l=p.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[s.TextureType.unpacked],cacheHint:l});var l;return Object.assign(Object.assign({},c),{get:()=>((n,e,r,o,f,g)=>{const b=r.dims,_=o.dims,y=f.length,w=(0,t.calculateIm2ColDims)(b,_,f,4),v=` - const int XC = ${b[1]}; - const int XH = ${b[2]}; - const int XW = ${b[3]}; - const int KH = ${g.kernelShape[0]}; - const int KW = ${g.kernelShape[1]}; - const int dilationH = ${g.dilations[0]}; - const int dilationW = ${g.dilations[1]}; - const int strideH = ${g.strides[0]}; - const int strideW = ${g.strides[1]}; - const int padH = ${g.pads[0]}; - const int padW = ${g.pads[1]}; - const int KHKW = KH*KW; - const int XCKHKW = XC * KHKW; - const int outputChannels = 4; - vec4 process(int indices[${y}]) { - int b = indices[0]; // batch size - int oh = indices[1] * strideH - padH; //output height - int ow = indices[2] * strideW - padW; //output width - int p = indices[3] * outputChannels; //patch - vec4 value = vec4(0.0); - for(int i=0; i < outputChannels; ++i) { - if(p < XCKHKW) { - int patchC = p / KHKW; - int patchH = (p - patchC*KHKW) / KW; - int patchW = (p - patchC*KHKW) - patchH * KW; - int xh2 = oh + patchH * dilationH; - int xw2 = ow + patchW * dilationW; - int x[${b.length}]; - x[0] = b; - x[1] = patchC; - x[2] = xh2; - x[3] = xw2; - if(xh2 >= 0 && - xh2 < XH && - xw2 >= 0 && - xw2 < XW) { - value[i] = _X(x); - } - } - ++p; - } - return value; - } - `;return Object.assign(Object.assign({},e),{output:{dims:w,type:r.type,textureType:s.TextureType.packedLastDimension},shaderSource:v})})(0,c,d,u,h,p)})},t.calculateIm2ColDims=(a,d,u,h=4)=>[u[0],u[2],u[3],Math.ceil(a[1]*d[2]*d[3]/h)]},6572:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseImageScalerAttributes=t.imageScaler=void 0;const s=i(246),a=i(2039);t.imageScaler=(c,l,n)=>(p(l),[c.run(u(c,l,n),l)]),t.parseImageScalerAttributes=c=>{const l=c.attributes.getFloat("scale"),n=c.attributes.getFloats("bias");return(0,s.createAttributeWithCacheKey)({scale:l,bias:n})};const d={name:"ImageScaler",inputNames:["X"],inputTypes:[a.TextureType.unpacked]},u=(c,l,n)=>{const e=Object.assign(Object.assign({},d),{cacheHint:n.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((r,o,f,g)=>{const b=f[0].dims.slice(),_=b.length,y=` - ${h(g.bias.length)} - float process(int indices[${_}]) { - return _X(indices) * scale + getBias(bias, indices[1]); - }`;return Object.assign(Object.assign({},o),{output:{dims:b,type:f[0].type,textureType:a.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:g.bias.length,data:g.bias},{name:"scale",type:"float",data:g.scale}],shaderSource:y})})(0,e,l,n)})},h=c=>{const l=[`float getBias(float bias[${c}], int channel) {`];for(let n=0;n{if(!c||c.length!==1)throw new Error("ImageScaler requires 1 input.");if(c[0].dims.length!==4)throw new Error("Invalid input shape.");if(c[0].type!=="float32"&&c[0].type!=="float64")throw new Error("Invalid input type.")}},3346:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseInstanceNormalizationAttributes=t.instanceNormalization=void 0;const s=i(5060),a=i(2039);t.instanceNormalization=(l,n,e)=>{c(n);const r=l.run(u(n[0]),n);return[l.run(p(l,n[0],e,r.dims),[n[0],r,n[1],n[2]])]},t.parseInstanceNormalizationAttributes=l=>l.attributes.getFloat("epsilon",1e-5);const d={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[a.TextureType.unpacked]},u=l=>Object.assign(Object.assign({},d),{get:()=>((n,e)=>{const r=e.dims.slice(),o=r[1],f=r[2]*r[3],g=[r[0],o],b=` - vec4 process(int[2] indices) { - vec4 v = vec4(0.0); - int a[4]; - a[0] = indices[0]; - a[1] = indices[1]; - float temp = 0.0; - for(int a2=0; a2<${r[2]}; a2++) { - a[2] = a2; - for(int a3=0; a3<${r[3]}; a3++) { - a[3] = a3; - float x = _X(a); - temp += x; - } - } - float mean = temp / float(${f}); - temp = 0.0; - for(int a2=0; a2<${r[2]}; a2++) { - a[2] = a2; - for(int a3=0; a3<${r[3]}; a3++) { - a[3] = a3; - float x = _X(a); - temp += (x - mean) * (x - mean); - } - } - v.r = mean; - v.g = temp / float(${f}); - - return v; - }`;return Object.assign(Object.assign({},n),{output:{dims:g,type:e.type,textureType:a.TextureType.packedLastDimension},shaderSource:b})})(d,l)}),h={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[a.TextureType.unpacked,a.TextureType.packedLastDimension,a.TextureType.unpacked,a.TextureType.unpacked]},p=(l,n,e,r)=>{const o=Object.assign(Object.assign({},h),{cacheHint:`${e}`});return Object.assign(Object.assign({},o),{get:()=>((f,g,b,_,y)=>{const w=(0,s.getGlsl)(f.session.backend.glContext.version),[v,S]=f.calculateTextureWidthAndHeight(y,a.TextureType.packedLastDimension),[A,I]=[v/4,S],x=` - vec4 get_MeanAndVariance(int[2] mv) { - int offset = indicesToOffset_MeanAndVariance(mv); - vec2 coords = offsetToCoords(offset, ${A}, ${I}); - return ${w.texture2D}(MeanAndVariance, coords); - } - - float process(int[4] indices) { - int mv[2]; - mv[0] = indices[0]; - mv[1] = indices[1]; - vec4 mean_and_variance = get_MeanAndVariance(mv); - float mean = mean_and_variance.r; - float variance = mean_and_variance.g; - - int sb[1]; - sb[0] = indices[1]; - float scale = _Scale(sb); - float b = _B(sb); - - return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b; - }`;return Object.assign(Object.assign({},g),{output:{dims:b.dims,type:b.type,textureType:a.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:_}],shaderSource:x})})(l,o,n,e,r)})},c=l=>{if(!l||l.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const n=l[0],e=l[1],r=l[2];if(n.dims.length<3||e.dims.length!==1||r.dims.length!==1)throw new Error("Invalid input shape.");if(e.dims[0]!==n.dims[1]||r.dims[0]!==n.dims[1])throw new Error("Input shapes are mismatched.");if(n.type!=="float32"&&n.type!=="float64"||e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64")throw new Error("Invalid input type.");if(l[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},708:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedMatmulProgramInfoLoader=void 0;const s=i(2517),a=i(5060),d=i(2039),u=i(9390),h=i(2823),p=i(5623);t.createPackedMatmulProgramInfoLoader=(c,l,n)=>{const e=(r=l.length>2,o=n.activationCacheKey,{name:"MatMul (packed)",inputNames:r?["A","B","Bias"]:["A","B"],inputTypes:r?[d.TextureType.packed,d.TextureType.packed,d.TextureType.packed]:[d.TextureType.packed,d.TextureType.packed],cacheHint:o});var r,o;return Object.assign(Object.assign({},e),{get:()=>((f,g,b,_)=>{const y=b.length>2,w=y?"value += getBiasForMatmul();":"",v=b[0].dims,S=b[1].dims,A=s.BroadcastUtil.calcShape(v,S,!0),I=!s.ShapeUtil.areEqual(b[0].dims,b[1].dims);if(!A)throw new Error("Can't use matmul on the given tensors");const x=v[v.length-1],E=Math.ceil(x/2),F=v.length,R=S.length,$=(0,a.getGlsl)(f.session.backend.glContext.version),L=(0,u.getCoordsDataType)(A.length),G=A.length,D=(0,u.getGlChannels)(),{activationFunction:z,applyActivation:Z}=(0,h.getActivationSnippet)(_),X=y?`${(0,p.getBiasForMatmul)(L,D,b[2].dims,A,!0)}`:"",J=I?`${function(ve,se,ye,be){let Pe=[],Ne=[];const xe=ye[0].dims,Fe=ye[1].dims,Ce=xe.length,Ie=Fe.length,Ae=be.length,je=Ae-Ce,Ge=Ae-Ie;Pe=xe.map((Oe,ze)=>`coords.${se[ze+je]}`),Pe[Ce-1]="i*2",Pe.join(", "),Ne=Fe.map((Oe,ze)=>`coords.${se[ze+Ge]}`),Ne[Ie-2]="i*2",Ne.join(", ");const Ve=s.BroadcastUtil.getBroadcastDims(xe,be),Xe=s.BroadcastUtil.getBroadcastDims(Fe,be),Ze=Ve.map(Oe=>`coords.${se[Oe+je]} = 0;`).join(` -`),qe=Xe.map(Oe=>`coords.${se[Oe+Ge]} = 0;`).join(` -`),Ue=`int lastDim = coords.${se[Ae-1]}; - coords.${se[Ae-1]} = coords.${se[Ae-2]}; - coords.${se[Ae-2]} = lastDim;`;return` -vec4 getAAtOutCoordsMatmul(int i) { - ${ve} coords = getOutputCoords(); - ${Ue} - ${Ze} - vec4 outputValue = getA(${Pe}); - return outputValue; -} - -vec4 getBAtOutCoordsMatmul(int i) { - ${ve} coords = getOutputCoords(); - ${Ue} - ${qe} - vec4 outputValue = getB(${Ne}); - return outputValue; -}`}(L,D,b,A)}`:"",ee=I?"getAAtOutCoordsMatmul(i)":`getA(${function(ve,se){let ye="";for(let be=0;be{Object.defineProperty(t,"__esModule",{value:!0}),t.getBiasForMatmul=t.createMatmulProgramInfoLoader=t.parseMatMulAttributes=t.matMul=void 0;const s=i(2517),a=i(2039),d=i(9390),u=i(2823),h=i(708);function p(n,e){const r=(o=n.length>2,f=e.activationCacheKey,{name:"MatMul",inputNames:o?["A","B","Bias"]:["A","B"],inputTypes:o?[a.TextureType.unpacked,a.TextureType.unpacked,a.TextureType.unpacked]:[a.TextureType.unpacked,a.TextureType.unpacked],cacheHint:f});var o,f;return Object.assign(Object.assign({},r),{get:()=>function(g,b,_){const y=b[0].dims,w=b[1].dims,v=s.BroadcastUtil.calcShape(y,w,!0);if(!v)throw new Error("Can't use matmul on the given tensors");const S=(0,d.getCoordsDataType)(v.length),A=(0,d.getGlChannels)(),{activationFunction:I,applyActivation:x}=(0,u.getActivationSnippet)(_),E=b.length>2,F=E?"value += getBiasForMatmul();":"",R=E?`${l(S,A,b[2].dims,v,!1)}`:"",$=v.length,L=y.length,G=w.length,D=` - ${I} - ${R} - float process(int indices[${$}]) { - int a[${L}]; - int b[${G}]; - bcastMatmulIndices_A(indices, a); - bcastMatmulIndices_B(indices, b); - - float value; - for (int k=0; k<${y[y.length-1]}; ++k) { - a[${L-1}] = k; - b[${G-2}] = k; - value += _A(a) * _B(b); - } - ${F} - ${x} - return value; - }`;return Object.assign(Object.assign({},g),{output:{dims:v,type:b[0].type,textureType:a.TextureType.unpacked},shaderSource:D})}(r,n,e)})}t.matMul=(n,e,r)=>(c(e),n.session.pack?[n.run((0,h.createPackedMatmulProgramInfoLoader)(n,e,r),e)]:[n.run(p(e,r),e)]),t.parseMatMulAttributes=n=>(0,u.parseInternalActivationAttributes)(n.attributes),t.createMatmulProgramInfoLoader=p;const c=n=>{if(!n||n.length!==2)throw new Error("MatMul requires 2 inputs.");if(n[0].dims[n[0].dims.length-1]!==n[1].dims[n[1].dims.length-2])throw new Error("shared dimension does not match.");if(n[0].type!=="float32"&&n[0].type!=="float64"||n[1].type!=="float32"&&n[1].type!=="float64")throw new Error("inputs should be float type");if(n[0].type!==n[1].type)throw new Error("inputs types should match")};function l(n,e,r,o,f){let g="";const b=r.length,_=o.length,y=_-b;g=_<2&&b>0?"coords":r.map((S,A)=>`coords.${e[A+y]}`).join(", ");const w=s.BroadcastUtil.getBroadcastDims(r,o).map(S=>`coords.${e[S+y]} = 0;`).join(` -`);let v="vec4(outputValue.xx, outputValue.yy)";return s.ShapeUtil.size(r)===1&&(v="vec4(outputValue.x)"),f?` -vec4 getBiasForMatmul() { - ${n} coords = getOutputCoords(); - ${w} - vec4 outputValue = getBias(${g}); - return ${v}; -}`:` -float getBiasForMatmul() { - ${n} coords = getOutputCoords(); - ${w} - return getBias(coords.x); -}`}t.getBiasForMatmul=l},2403:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPackProgramInfoLoader=void 0;const s=i(5060),a=i(2039),d=i(9390),u=i(2827),h={name:"pack",inputNames:["A"],inputTypes:[a.TextureType.unpackedReversed]};t.createPackProgramInfoLoader=(p,c)=>Object.assign(Object.assign({},h),{get:()=>((l,n)=>{const e=(0,s.getGlsl)(l.session.backend.glContext.version),r=n.dims,o=r.length,f=n.dims.length,g=(0,d.getCoordsDataType)(f),b=(0,u.getChannels)("rc",f),_=(y=f,w=b,v=r[r.length-2],S=r[r.length-1],y===0||y===1?"":` - int r = ${w[y-2]}; - int c = ${w[y-1]}; - int rp1 = ${w[y-2]} + 1; - int cp1 = ${w[y-1]} + 1; - bool rEdge = rp1 >= ${S}; - bool cEdge = cp1 >= ${v}; - `);var y,w,v,S;let A;A=o===0?[1,1]:o===1?[r[0],1]:[r[f-1],r[f-2]];const I=function(F,R,$){if(F===0)return"false";if(F===1)return`rc > ${R[0]}`;let L="";for(let G=F-2;G= ${R[G-F+2]}`,G= ${F[0]} ? 0. : getA(rc + 1), - 0, 0`;let L="";if($>2)for(let G=0;G<$-2;++G)L+=`${R[G]},`;return`getA(${L}r, c), - rEdge ? 0. : getA(${L}rp1, c), - cEdge ? 0. : getA(${L}r, cp1), - rEdge || cEdge ? 0. : getA(${L}rp1, cp1)`}(r,b),E=` - void main() { - ${g} rc = getOutputCoords(); - - if(${I}) { - ${e.output} = vec4(0); - } else { - ${_} - - ${e.output} = vec4(${x}); - } - } - `;return Object.assign(Object.assign({},h),{hasMain:!0,output:{dims:n.dims,type:n.type,textureType:a.TextureType.packed},shaderSource:E})})(p,c)})},2827:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unpackFromChannel=t.getChannels=t.getVecChannels=void 0;const s=i(9390);function a(d,u){return(0,s.getGlChannels)(u).map(h=>`${d}.${h}`)}t.getVecChannels=a,t.getChannels=function(d,u){return u===1?[d]:a(d,u)},t.unpackFromChannel=function(){return` - float getChannel(vec4 frag, int dim) { - int modCoord = imod(dim, 2); - return modCoord == 0 ? frag.r : frag.g; - } - - float getChannel(vec4 frag, vec2 innerDims) { - vec2 modCoord = mod(innerDims, 2.); - return modCoord.x == 0. ? - (modCoord.y == 0. ? frag.r : frag.g) : - (modCoord.y == 0. ? frag.b : frag.a); - } - `}},2870:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parsePadAttributesV11=t.padV11=t.parsePadAttributesV2=t.padV2=void 0;const s=i(246),a=i(2517),d=i(5060),u=i(2039),h={name:"Pad",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};t.padV2=(g,b,_)=>(l(b),[g.run(Object.assign(Object.assign({},h),{cacheHint:_.cacheKey,get:()=>c(g,b[0],_)}),b)]),t.parsePadAttributesV2=g=>{const b=g.attributes.getString("mode","constant"),_=g.attributes.getFloat("value",0),y=g.attributes.getInts("pads");return(0,s.createAttributeWithCacheKey)({mode:b,value:_,pads:y})},t.padV11=(g,b,_)=>{n(b);const y=p(g,b,_);return(0,t.padV2)(g,[b[0]],y)},t.parsePadAttributesV11=g=>g.attributes.getString("mode","constant");const p=(g,b,_)=>{if(!g.session.isInitializer(b[1].dataId)||b.length>=3&&!g.session.isInitializer(b[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(b[1].integerData),w=b.length>=3?b[2].floatData[0]:0;return(0,s.createAttributeWithCacheKey)({mode:_,pads:y,value:w})},c=(g,b,_)=>{const y=a.ShapeUtil.padShape(b.dims.slice(),_.pads),w=y.length,v=` - ${e(g,b,_)} - float process(int[${w}] indices) { - return padA(indices); - }`;return{name:"Pad",inputNames:["A"],inputTypes:[u.TextureType.unpacked],output:{dims:y,type:b.type,textureType:u.TextureType.unpacked},shaderSource:v}},l=g=>{if(!g||g.length!==1)throw new Error("Pad requires 1 input");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type.")},n=g=>{if(!g||g.length!==2&&g.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(g[1].type!=="int32")throw new Error("Invalid input type.");if(g.length>=3&&g[2].type==="string")throw new Error("Invalid input type.")},e=(g,b,_)=>{const y=(0,d.getGlsl)(g.session.backend.glContext.version),[w,v]=g.calculateTextureWidthAndHeight(b.dims,u.TextureType.unpacked),S=a.ShapeUtil.computeStrides(b.dims);switch(_.mode){case"constant":return r(y,b.dims,S,w,v,_.pads,_.value);case"reflect":return o(y,b.dims,S,w,v,_.pads);case"edge":return f(y,b.dims,S,w,v,_.pads);default:throw new Error("Invalid mode")}},r=(g,b,_,y,w,v,S)=>{const A=b.length;let I="";for(let x=A-1;x>=0;--x)I+=` - k = m[${x}] - ${v[x]}; - if (k < 0) return constant; - if (k >= ${b[x]}) return constant; - offset += k * ${_[x]}; - `;return` - float padA(int m[${A}]) { - const float constant = float(${S}); - int offset = 0; - int k = 0; - ${I} - vec2 coords = offsetToCoords(offset, ${y}, ${w}); - float value = getColorAsFloat(${g.texture2D}(A, coords)); - return value; - } - `},o=(g,b,_,y,w,v)=>{const S=b.length;let A="";for(let I=S-1;I>=0;--I)A+=` - k = m[${I}] - ${v[I]}; - if (k < 0) { k = -k; } - { - const int _2n_1 = ${2*(b[I]-1)}; - k = int( mod( float(k), float(_2n_1) ) ) ; - if(k >= ${b[I]}) { k = _2n_1 - k; } - } - offset += k * ${_[I]}; - `;return` - float padA(int m[${S}]) { - int offset = 0; - int k = 0; - ${A} - vec2 coords = offsetToCoords(offset, ${y}, ${w}); - float value = getColorAsFloat(${g.texture2D}(A, coords)); - return value; - } - `},f=(g,b,_,y,w,v)=>{const S=b.length;let A="";for(let I=S-1;I>=0;--I)A+=` - k = m[${I}] - ${v[I]}; - if (k < 0) k = 0; - if (k >= ${b[I]}) k = ${b[I]-1}; - offset += k * ${_[I]}; - `;return` - float padA(int m[${S}]) { - int offset = 0; - int k = 0; - ${A} - vec2 coords = offsetToCoords(offset, ${y}, ${w}); - float value = getColorAsFloat(${g.texture2D}(A, coords)); - return value; - } - `}},2143:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.globalMaxPool=t.parseMaxPoolAttributes=t.maxPool=t.parseGlobalAveragePoolAttributes=t.globalAveragePool=t.parseAveragePoolAttributes=t.averagePool=void 0;const s=i(246),a=i(2517),d=i(2039);t.averagePool=(f,g,b)=>{n(g);const _={name:"AveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:b.cacheKey};return[f.run(Object.assign(Object.assign({},_),{get:()=>u(g,_,!1,b)}),g)]},t.parseAveragePoolAttributes=f=>{const g=f.attributes.getString("auto_pad","NOTSET"),b=f.attributes.getInt("ceil_mode",0),_=f.attributes.getInt("count_include_pad",0)!==0,y=f.attributes.getInts("kernel_shape"),w=f.attributes.getInts("strides",[]),v=f.attributes.getInts("pads",[]);if(b!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:b,countIncludePad:_,kernelShape:y,strides:w,pads:v})};const u=(f,g,b,_)=>{const[y,w]=p(f,_,b),v=a.ShapeUtil.size(y.kernelShape);let S="";y.countIncludePad?S+=`value /= float(${v});`:S+=`value /= float(${v} - pad);`;const A=` - ${e(f[0].dims,y,"value += _X(x);",S,"0.0")} - `;return Object.assign(Object.assign({},g),{output:{dims:w,type:f[0].type,textureType:d.TextureType.unpacked},shaderSource:A})};t.globalAveragePool=(f,g,b)=>{n(g);const _={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:`${b.countIncludePad}`};return[f.run(Object.assign(Object.assign({},_),{get:()=>u(g,_,!0,b)}),g)]},t.parseGlobalAveragePoolAttributes=f=>{const g=f.attributes.getInt("count_include_pad",0)!==0;return(0,s.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:g,kernelShape:[],strides:[],pads:[]})},t.maxPool=(f,g,b)=>{n(g);const _={name:"MaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:b.cacheKey};return[f.run(Object.assign(Object.assign({},_),{get:()=>h(g,_,!1,b)}),g)]},t.parseMaxPoolAttributes=f=>{const g=f.attributes.getString("auto_pad","NOTSET"),b=f.attributes.getInt("ceil_mode",0),_=f.attributes.getInts("kernel_shape"),y=f.attributes.getInts("strides",[]),w=f.attributes.getInts("pads",[]),v=f.attributes.getInt("storage_order",0),S=f.attributes.getInts("dilations",[]);if(v!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(b!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:b,countIncludePad:!1,kernelShape:_,strides:y,pads:w,storageOrder:v,dilations:S})};const h=(f,g,b,_)=>{const[y,w]=p(f,_,b),v=` - ${e(f[0].dims,y,` - value = max(_X(x), value); - `,"","-1e5")} - `;return Object.assign(Object.assign({},g),{output:{dims:w,type:f[0].type,textureType:d.TextureType.unpacked},shaderSource:v})},p=(f,g,b)=>{const _=f[0].dims.slice(),y=Object.hasOwnProperty.call(g,"dilations"),w=g.kernelShape.slice(),v=g.strides.slice(),S=y?g.dilations.slice():[],A=g.pads.slice();a.PoolConvUtil.adjustPoolAttributes(b,_,w,v,S,A);const I=a.PoolConvUtil.computePoolOutputShape(b,_,v,S,w,A,g.autoPad),x=Object.assign({},g);return y?Object.assign(x,{kernelShape:w,strides:v,pads:A,dilations:S,cacheKey:g.cacheKey}):Object.assign(x,{kernelShape:w,strides:v,pads:A,cacheKey:g.cacheKey}),[x,I]},c={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},l={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.globalMaxPool=(f,g)=>(n(g),[f.run(Object.assign(Object.assign({},l),{get:()=>h(g,l,!0,c)}),g)]);const n=f=>{if(!f||f.length!==1)throw new Error("Pool ops requires 1 input.");if(f[0].type!=="float32"&&f[0].type!=="float64")throw new Error("Invalid input type.")},e=(f,g,b,_,y)=>{const w=f.length;if(g.kernelShape.length<=2){const v=g.kernelShape[g.kernelShape.length-1],S=g.strides[g.strides.length-1],A=g.pads[g.pads.length/2-1],I=g.pads[g.pads.length-1],x=f[w-1];let E="",F="",R="";if(E=A+I!==0?` - for (int i = 0; i < ${v}; i++) { - x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; - if (x[${w} - 1] < 0 || x[${w} - 1] >= ${x}) { - pad++; - continue; - } - ${b} - }`:` - for (int i = 0; i < ${v}; i++) { - x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; - ${b} - }`,g.kernelShape.length===2){const $=g.kernelShape[g.kernelShape.length-2],L=g.strides[g.strides.length-2],G=g.pads[g.pads.length/2-2],D=g.pads[g.pads.length-2],z=f[w-2];F=G+D!==0?` - for (int j = 0; j < ${$}; j++) { - x[${w} - 2] = indices[${w} - 2] * ${L} - ${G} + j; - if (x[${w} - 2] < 0 || x[${w} - 2] >= ${z}) { - pad+= ${v}; - continue; - } - `:` - for (int j = 0; j < ${$}; j++) { - x[${w} - 2] = indices[${w} - 2] * ${L} - ${G} + j; - `,R=` - } - `}return` - float process(int indices[${w}]) { - int x[${w}]; - copyVec(indices, x); - - float value = ${y}; - int pad = 0; - ${F} - ${E} - ${R} - ${_} - return value; - } - `}{const v=a.ShapeUtil.size(g.kernelShape),S=a.ShapeUtil.computeStrides(g.kernelShape),A=S.length,I=g.pads.length,x=o(A),E=r(f,"inputDims"),F=r(g.pads,"pads"),R=r(S,"kernelStrides"),$=r(g.strides,"strides");let L="";return L=g.pads.reduce((G,D)=>G+D)?` - if (x[j] >= inputDims[j] || x[j] < 0) { - pad++; - isPad = true; - break; - } - } - if (!isPad) { - ${b} - }`:` - } - ${b} - `,` - ${x} - float process(int indices[${w}]) { - int x[${w}]; - copyVec(indices, x); - int offset[${A}]; - int pads[${I}]; - int inputDims[${w}]; - int kernelStrides[${A}]; - int strides[${A}]; - ${F} - ${E} - ${$} - ${R} - - float value = ${y}; - int pad = 0; - bool isPad = false; - for (int i = 0; i < ${v}; i++) { - offsetToIndices(i, kernelStrides, offset); - isPad = false; - for (int j = ${w} - ${A}; j < ${w}; j++) { - x[j] = indices[j] * strides[j - ${w} + ${A}] - + offset[j - ${w} + ${A}] - pads[j - 2]; - ${L} - } - ${_} - - return value; - } - `}},r=(f,g)=>{let b="";for(let _=0;_` - void offsetToIndices(int offset, int[${f}] strides, out int[${f}] indices) { - if (${f} == 0) { - return; - } - for (int i = 0; i < ${f} - 1; ++i) { - indices[i] = offset / strides[i]; - offset -= indices[i] * strides[i]; - } - indices[${f} - 1] = offset; - }`},4939:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reduceLogSumSquare=t.reduceLogSum=t.reduceProd=t.reduceMin=t.reduceMax=t.reduceMean=t.reduceSum=t.parseReduceAttributes=void 0;const s=i(246),a=i(782),d=i(2517),u=i(2039),h=(l,n,e,r,o)=>{c(n);const f={name:r,inputNames:["A"],inputTypes:[u.TextureType.unpacked]};return[l.run(Object.assign(Object.assign({},f),{cacheHint:e.cacheKey,get:()=>p(l,n,e,r,o,f)}),n)]};t.parseReduceAttributes=l=>{const n=l.attributes.getInts("axes",[]),e=l.attributes.getInt("keepdims",1)===1;return(0,s.createAttributeWithCacheKey)({axes:n,keepDims:e})};const p=(l,n,e,r,o,f)=>{const g=[],b=n[0].dims.length||1,_=[],y=d.ShapeUtil.normalizeAxes(e.axes,n[0].dims.length),w=o(n,y);let v=w[1];for(let A=0;A=0||y.length===0?(e.keepDims&&g.push(1),v=` - for(int j${A} = 0; j${A} < ${n[0].dims[A]}; j${A}++) { - inputIdx[${A}] = j${A}; - ${v} - }`):(_.push(`inputIdx[${A}] = outputIdx[${g.length}];`),g.push(n[0].dims[A]));const S=` - float process(int outputIdx[${g.length||1}]) { - float value; // final result - int inputIdx[${b}]; // addressing input data - ${_.join(` -`)} - ${w[0]} // init ops for reduce max/min - ${v} - ${w[2]} // final computation for reduce mean - return value; - }`;return Object.assign(Object.assign({},f),{output:{dims:g,type:n[0].type,textureType:u.TextureType.unpacked},shaderSource:S})},c=l=>{if(!l||l.length!==1)throw new Error("Reduce op requires 1 input.");if(a.NUMBER_TYPES.indexOf(l[0].type)===-1)throw new Error("Invalid input type.")};t.reduceSum=(l,n,e)=>h(l,n,e,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),t.reduceMean=(l,n,e)=>h(l,n,e,"ReduceMean",(r,o)=>{let f=1;for(let g=0;g=0||o.length===0)&&(f*=r[0].dims[g]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${f}.;`]}),t.reduceMax=(l,n,e)=>h(l,n,e,"ReduceMax",(r,o)=>{const f=[];for(let g=0;g=0||o.length===0)&&f.push(`inputIdx[${g}] = 0;`);return[`${f.join(` -`)} -value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),t.reduceMin=(l,n,e)=>h(l,n,e,"ReduceMin",(r,o)=>{const f=[];for(let g=0;g=0||o.length===0)&&f.push(`inputIdx[${g}] = 0;`);return[`${f.join(` -`)} -value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),t.reduceProd=(l,n,e)=>h(l,n,e,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),t.reduceLogSum=(l,n,e)=>h(l,n,e,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),t.reduceLogSumSquare=(l,n,e)=>h(l,n,e,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7019:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isReshapeCheap=t.processDims3D=t.createPackedReshape3DProgramInfoLoader=void 0;const s=i(2517),a=i(5060),d=i(2039),u=i(2827);t.createPackedReshape3DProgramInfoLoader=(h,p,c)=>{const l=(n=>({name:"Reshape (packed)",inputTypes:[d.TextureType.packed],inputNames:["A"],cacheHint:`${n}`}))(c);return Object.assign(Object.assign({},l),{get:()=>((n,e,r,o)=>{const f=e.dims,g=o;let b="";for(let w=0;w<4;w++){let v="";switch(w){case 0:v="outputCoords = rc;";break;case 1:v="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:v="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:v="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}b+=` - ${v} - ${w>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""} - int flattenedIndex = getFlattenedIndex(outputCoords); - - ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex); - vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z)); - - result[${w}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims); - - ${w>0?"}":""} - `}const _=(0,a.getGlsl)(n.session.backend.glContext.version),y=` - ${function(w){const v=s.ShapeUtil.computeStrides(w),S=["b","r","c"],A="index";return` - ivec3 inputCoordsFromReshapedOutCoords(int index) { - ${v.map((I,x)=>`int ${S[x]} = ${A} / ${I}; ${x===v.length-1?`int ${S[x+1]} = ${A} - ${S[x]} * ${I}`:`index -= ${S[x]} * ${I}`};`).join("")} - return ivec3(b, r, c); - } - `}(f)} - ${function(w){const v=s.ShapeUtil.computeStrides(w);return` - int getFlattenedIndex(ivec3 coords) { - // reverse y, z order - return coords.x * ${v[0]} + coords.z * ${v[1]} + coords.y; - } -`}(g)} - ${(0,u.unpackFromChannel)()} - - void main() { - ivec3 rc = getOutputCoords(); - - vec4 result = vec4(0.0); - - ivec3 outputCoords; - int rows = ${g[2]}; - int cols = ${g[1]}; - - ${b} - ${_.output} = result; - } - `;return Object.assign(Object.assign({},r),{output:{dims:g,type:e.type,textureType:d.TextureType.packed},shaderSource:y,hasMain:!0})})(h,p,l,c)})},t.processDims3D=function(h){if(h.length===0)return[1,1,1];let p=1;for(let c=0;c1?h[h.length-2]:1,h[h.length-1]]},t.isReshapeCheap=function(h,p){let c=!1;return c=h.length===0||p.length===0||(h.length<2||p.length<2?h[h.length-1]===p[p.length-1]:h[h.length-1]===p[p.length-1]&&h[h.length-2]===p[p.length-2]),c}},718:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=void 0;const s=i(2517);t.reshape=(a,d)=>{const u=s.ShapeUtil.calculateReshapedDims(d[0].dims,d[1].integerData);return a.session.pack?[a.reshapePacked(d[0],u)]:[a.reshapeUnpacked(d[0],u)]}},2268:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseResizeAttributesV11=t.parseResizeAttributesV10=t.resize=void 0;const s=i(5060),a=i(2039),d=i(9390),u=i(2827),h=i(9793),p={name:"Resize",inputNames:["A"],inputTypes:[a.TextureType.packed]};t.resize=(r,o,f)=>((0,h.validateInputs)(o,f),[r.run(Object.assign(Object.assign({},p),{cacheHint:f.cacheKey,get:()=>c(r,o,f)}),o)]),t.parseResizeAttributesV10=r=>(0,h.parseUpsampleAttributes)(r,10),t.parseResizeAttributesV11=r=>(0,h.parseUpsampleAttributes)(r,11);const c=(r,o,f)=>{const g=(0,s.getGlsl)(r.session.backend.glContext.version),[b,_]=l(o,f);if(b.every(L=>L===1)&&f.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},p),{output:{dims:_,type:o[0].type,textureType:a.TextureType.packed},hasMain:!0,shaderSource:`void main() { - vec4 v = ${g.texture2D}(X, TexCoords); - ${g.output} = v; - }`});const y=_.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const w=_[y-2],v=_[y-1],S=o[0].dims;if(y!==S.length)throw new Error(`output dimension should match input ${S.length}, but got ${y}`);const A=S[y-2],I=S[y-1],x=b[y-2],E=b[y-1];let F="";if(f.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${f.mode}'`);switch(f.coordinateTransformMode){case"asymmetric":F=` - vec4 getSourceFracIndex(ivec4 coords) { - return vec4(coords) / scaleWHWH; - } - `;break;case"half_pixel":F=` - vec4 getSourceFracIndex(ivec4 coords) { - return (vec4(coords) + 0.5) / scaleWHWH - 0.5; - } - `;break;case"pytorch_half_pixel":F=` - vec4 getSourceFracIndex(ivec4 coords) { - vec4 fcoords = vec4(coords); - return vec4( - ${v}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, - ${w}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, - ${v}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, - ${w}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 - ); - } - `;break;case"align_corners":F=` - vec4 getSourceFracIndex(ivec4 coords) { - vec4 resized = vec4(${v}.0 - 1.0, ${w}.0 - 1.0, ${v}.0 - 1.0, - ${w}.0 - 1.0); - vec4 original = vec4(${I}.0 - 1.0, ${A}.0 - 1.0, ${I}.0 - 1.0, - ${A}.0 - 1.0); - vec4 new_scale = original / resized; - return vec4(coords) * new_scale; - } - `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${f.coordinateTransformMode}'`)}const R=(0,d.getCoordsDataType)(y),$=` - const vec2 inputWH = vec2(${A}.0, ${I}.0); - const vec4 scaleWHWH = vec4(float(${x}), float(${E}), float(${x}), float(${E})); - ${(0,u.unpackFromChannel)()} - ${F} - float getAValue(int x10, int r, int c, int d) { - return getChannel(getA(x10, r, c, d), vec2(c, d)); - } - void main() { - ${R} rc = getOutputCoords(); - - int batch = rc[0]; - int depth = rc[1]; - - // retrieve the 4 coordinates that is used in the 4 packed output values. - ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1); - - // calculate the source index in fraction - vec4 sourceFrac = getSourceFracIndex(coords); - - // get the lower and upper bound of the 4 values that will be packed into one texel. - ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy))); - ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw))); - ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy))); - ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw))); - - bool hasNextRow = rc.w < ${w-1}; - bool hasNextCol = rc.z < ${v-1}; - - // pack x00, x01, x10, x11's top-left corner into one vec4 structure - vec4 topLeft = vec4( - getAValue(batch, depth, x00.x, x00.y), - hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0, - hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0, - (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0); - - // pack x00, x01, x10, x11's top-right corner into one vec4 structure - vec4 topRight = vec4( - getAValue(batch, depth, x00.x, x00.w), - hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0, - hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0, - (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0); - - // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure - vec4 bottomLeft = vec4( - getAValue(batch, depth, x00.z, x00.y), - hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0, - hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0, - (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0); - - // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure - vec4 bottomRight = vec4( - getAValue(batch, depth, x00.z, x00.w), - hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0, - hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0, - (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0); - - // calculate the interpolation fraction on u and v direction - vec4 frac = vec4(sourceFrac) - floor(sourceFrac); - vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0)); - - vec4 top = mix(topLeft, topRight, clampFrac.ywyw); - vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw); - vec4 newValue = mix(top, bottom, clampFrac.xxzz); - - ${g.output} = vec4(newValue); - } - `;return Object.assign(Object.assign({},p),{output:{dims:_,type:o[0].type,textureType:a.TextureType.packed},hasMain:!0,shaderSource:$})},l=(r,o)=>{const f=r[0].dims;let g,b=o.scales;if(b.length===0){const y=r[o.scalesInputIdx];if(y&&y.size!==0){if(r[o.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");b=n(y,o.mode,o.isResize)}else{const w=r[o.sizesInputIdx];if(!w||w.size===0)throw new Error("Either scales or sizes MUST be provided as input.");g=Array.from(w.integerData),b=e(g,f,o.mode,o.isResize)}}else if(r[o.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const _=g||f.map((y,w)=>Math.floor(y*b[w]));return[b,_]},n=(r,o,f)=>{const g=Array.from(r.floatData);return(0,h.scalesValidation)(g,o,f),g},e=(r,o,f,g)=>{const b=o.length,_=new Array(b);for(let y=0,w=b;y{Object.defineProperty(t,"__esModule",{value:!0}),t.shape=void 0;const s=i(9162);t.shape=(d,u)=>(a(u),[new s.Tensor([u[0].dims.length],"int32",void 0,void 0,new Int32Array(u[0].dims))]);const a=d=>{if(!d||d.length!==1)throw new Error("Shape requires 1 input.")}},2278:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sliceV10=t.parseSliceAttributes=t.slice=void 0;const s=i(246),a=i(782),d=i(2517),u=i(2039),h={name:"Slice",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};t.slice=(e,r,o)=>(c(r),[e.run(Object.assign(Object.assign({},h),{cacheHint:o.cacheKey,get:()=>p(e,r[0],o)}),r)]),t.parseSliceAttributes=e=>{const r=e.attributes.getInts("starts"),o=e.attributes.getInts("ends"),f=e.attributes.getInts("axes",[]);return(0,s.createAttributeWithCacheKey)({starts:r,ends:o,axes:f})};const p=(e,r,o)=>{const f=o.axes.length===0?r.dims.slice(0).map((S,A)=>A):o.axes,g=d.ShapeUtil.normalizeAxes(f,r.dims.length),b=o.starts.map((S,A)=>S>r.dims[g[A]]-1?r.dims[g[A]]:d.ShapeUtil.normalizeAxis(S,r.dims[g[A]])),_=o.ends.map((S,A)=>S>r.dims[g[A]]-1?r.dims[g[A]]:d.ShapeUtil.normalizeAxis(S,r.dims[g[A]])),y=r.dims.slice(),w=[];for(let S=0;S0&&w.push(`outputIdx[${g[S]}] += ${b[S]};`);const v=` - float process(int outputIdx[${y.length}]) { - ${w.join(` - `)} - return _A(outputIdx); - }`;return Object.assign(Object.assign({},h),{output:{dims:y,type:r.type,textureType:u.TextureType.unpacked},shaderSource:v})},c=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(a.NUMBER_TYPES.indexOf(e[0].type)===-1)throw new Error("Invalid input type.")};t.sliceV10=(e,r)=>{n(r);const o=l(e,r);return[e.run(Object.assign(Object.assign({},h),{cacheHint:o.cacheKey,get:()=>p(e,r[0],o)}),[r[0]])]};const l=(e,r)=>{if(!e.session.isInitializer(r[1].dataId)||!e.session.isInitializer(r[2].dataId)||r.length>=4&&!e.session.isInitializer(r[3].dataId)||r.length>=5&&!e.session.isInitializer(r[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(r.length>=5&&r[4].integerData.some(b=>b!==1))throw new Error("currently non-1 steps is not supported for Slice");const o=Array.from(r[1].integerData),f=Array.from(r[2].integerData),g=r.length>=4?Array.from(r[3].integerData):[];return{starts:o,ends:f,axes:g,cacheKey:`${g};${o};${f}`}},n=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if(e[1].type!=="int32"||e[1].dims.length!==1)throw new Error("Invalid input type.");if(e[2].type!=="int32"||e[2].dims.length!==1)throw new Error("Invalid input type.");if(e.length>=4&&(e[3].type!=="int32"||e[3].dims.length!==1))throw new Error("Invalid input type.");if(e.length>=5&&(e[4].type!=="int32"||e[4].dims.length!==1))throw new Error("Invalid input type.")}},5524:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.softmaxV13=t.parseSoftmaxAttributesV13=t.parseSoftmaxAttributes=t.softmax=void 0;const s=i(246),a=i(2517),d=i(5060),u=i(2039),h=i(3738),p={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[u.TextureType.unpacked]},c={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked]},l={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[u.TextureType.unpacked,u.TextureType.unpacked,u.TextureType.unpacked]};t.softmax=(g,b,_)=>{f(b);const y=b[0].dims.slice(),w=a.ShapeUtil.normalizeAxis(_.axis,y.length),v=a.ShapeUtil.sizeToDimension(y,w),S=a.ShapeUtil.sizeFromDimension(y,w);return n(g,b,_,v,S)},t.parseSoftmaxAttributes=g=>(0,s.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",1)}),t.parseSoftmaxAttributesV13=g=>(0,s.createAttributeWithCacheKey)({axis:g.attributes.getInt("axis",-1)}),t.softmaxV13=(g,b,_)=>{f(b);const y=b[0].dims.slice(),w=a.ShapeUtil.normalizeAxis(_.axis,y.length),v=y.length,S=w!==v-1,A=[];let I,x=[],E=[];S&&(x=Array.from({length:v}).map((L,G)=>G),x[w]=v-1,x[v-1]=w,x.map(L=>A.push(y[L])),I=(0,s.createAttributeWithCacheKey)({perm:x}),E=(0,h.transpose)(g,b,I));const F=S?a.ShapeUtil.sizeToDimension(A,v-1):a.ShapeUtil.sizeToDimension(y,v-1),R=S?a.ShapeUtil.sizeFromDimension(A,v-1):a.ShapeUtil.sizeFromDimension(y,v-1),$=n(g,S?E:b,_,F,R);return S?(0,h.transpose)(g,$,I):$};const n=(g,b,_,y,w)=>{const v=e(g,b[0],y,w,[y]),S=g.run(Object.assign(Object.assign({},p),{cacheHint:_.cacheKey,get:()=>v}),b),A=r(g,b[0],y,w,v.output.dims,[y]),I=g.run(Object.assign(Object.assign({},c),{cacheHint:_.cacheKey,get:()=>A}),[b[0],S]),x=o(g,b[0],y,w,v.output.dims,A.output.dims);return[g.run(Object.assign(Object.assign({},l),{cacheHint:_.cacheKey,get:()=>x}),[b[0],S,I])]},e=(g,b,_,y,w)=>{const[v,S]=g.calculateTextureWidthAndHeight(b.dims,u.TextureType.unpacked),A=w.length;if(_<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1)throw new Error("Dimensionality of the output should be 1");if(w[0]!==_)throw new Error("Shape of the output should be equal to logical row count");const I=(0,d.getGlsl)(g.session.backend.glContext.version),x=` - float process(int[${A}] indices) { - int logical_row_start_offset = indices[0] * ${y}; - - float max = getColorAsFloat(${I.texture2D}(A, offsetToCoords(logical_row_start_offset, ${v}, - ${S} ))); - for(int i=1; i<${y}; ++i) - { - float current = getColorAsFloat(${I.texture2D}(A, offsetToCoords(logical_row_start_offset + i, - ${v}, ${S}))); - if(current > max) - max = current; - } - - return max; - }`;return Object.assign(Object.assign({},p),{output:{dims:w,type:b.type,textureType:u.TextureType.unpacked},shaderSource:x})},r=(g,b,_,y,w,v)=>{const[S,A]=g.calculateTextureWidthAndHeight(b.dims,u.TextureType.unpacked),I=v.length;if(_<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1)throw new Error("Dimensionality of the output should be 1");if(v[0]!==_)throw new Error("Shape of the output should be equal to logical row count");if(w.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(w[0]!==_)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` - float process(int[${I}] indices) { - int logical_row_start_offset = indices[0] * ${y}; - - float norm_factor = 0.0; - float max = _Max(indices); - for(int i=0; i<${y}; ++i) - { - norm_factor += exp(getColorAsFloat(${(0,d.getGlsl)(g.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i, - ${S}, ${A}))) - max); - } - - return norm_factor; - }`;return Object.assign(Object.assign({},c),{output:{dims:v,type:b.type,textureType:u.TextureType.unpacked},shaderSource:x})},o=(g,b,_,y,w,v)=>{const[S,A]=g.calculateTextureWidthAndHeight(b.dims,u.TextureType.unpacked),I=b.dims.length;if(_<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(w.length!==1||v.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(w[0]!==_||v[0]!==_)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` - float process(int[${I}] indices) { - - // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords) - int offset = coordsToOffset(TexCoords, ${S}, ${A}); - - //determine the logical row for this index - int logical_row_index[1]; - logical_row_index[0] = offset / ${y}; - - float norm_factor = _Norm(logical_row_index); - - // avoid possible division by 0 - // if norm_facor is 0, all elements are zero - // if so, return 0 - if(norm_factor == 0.0) - return 0.0; - - return exp(_A(indices) - _Max(logical_row_index)) / norm_factor; - }`;return Object.assign(Object.assign({},l),{output:{dims:b.dims,type:b.type,textureType:u.TextureType.unpacked},shaderSource:x})},f=g=>{if(!g||g.length!==1)throw new Error("Softmax requires 1 input.");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type")}},5975:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseSplitAttributes=t.split=void 0;const s=i(246),a=i(2517),d=i(2039),u={name:"Split",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.split=(l,n,e)=>{c(n);const r=a.ShapeUtil.normalizeAxis(e.axis,n[0].dims.length),o=h(l,n,r,e),f=[];for(let g=0;gp(l,n[0],e,r,g)}),n));return f},t.parseSplitAttributes=l=>{const n=l.attributes.getInt("axis",0),e=l.attributes.getInts("split",[]),r=l.outputs.length;return(0,s.createAttributeWithCacheKey)({axis:n,split:e,numOutputs:r})};const h=(l,n,e,r)=>{const[,o]=a.SplitUtil.splitShape(n[0].dims,e,r.split,r.numOutputs);return o.length},p=(l,n,e,r,o)=>{const[f,g]=a.SplitUtil.splitShape(n.dims,r,e.split,e.numOutputs),b=g[o],_=f[o],y=` - float process(int indices[${_.length}]) { - indices[${r}] += ${b}; - return _A(indices); - } - `;return Object.assign(Object.assign({},u),{cacheHint:`${e.cacheKey}:${o}`,output:{dims:_,type:n.type,textureType:d.TextureType.unpacked},shaderSource:y})},c=l=>{if(!l||l.length!==1)throw new Error("Split requires one input.");if(l[0].type!=="int8"&&l[0].type!=="uint8"&&l[0].type!=="int16"&&l[0].type!=="uint16"&&l[0].type!=="int32"&&l[0].type!=="uint32"&&l[0].type!=="float32"&&l[0].type!=="float64"&&l[0].type!=="bool")throw new Error("Invalid input type.")}},3933:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseSqueezeAttributes=t.squeezeV13=t.squeeze=void 0;const s=i(2517);t.squeeze=(u,h,p)=>{a(h);const c=s.ShapeUtil.squeezeShape(h[0].dims,p);return[u.reshapeUnpacked(h[0],c)]},t.squeezeV13=(u,h)=>(d(h),(0,t.squeeze)(u,[h[0]],Array.from(h[1].integerData))),t.parseSqueezeAttributes=u=>u.attributes.getInts("axes");const a=u=>{if(!u||u.length!==1)throw new Error("Squeeze requires 1 input.");if(u[0].type==="string")throw new Error("invalid input tensor types.")},d=u=>{if(!u||u.length!==2)throw new Error("Squeeze requires 2 inputs.");if(u[1].type!=="int32")throw new Error("Invalid input type.")}},6558:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sum=void 0;const s=i(5060),a=i(2039);t.sum=(h,p)=>{u(p);const c={name:"Sum",inputNames:p.map((l,n)=>`X${n}`),inputTypes:new Array(p.length).fill(a.TextureType.unpacked)};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,p,c)}),p)]};const d=(h,p,c)=>{const l=(0,s.getGlsl)(h.session.backend.glContext.version),n=p[0].dims.slice(),e=` - void main() { - vec4 result = ${p.map((r,o)=>`${l.texture2D}(X${o},TexCoords)`).join(" + ")}; - ${l.output} = result; - } - `;return Object.assign(Object.assign({},c),{output:{dims:n,type:p[0].type,textureType:a.TextureType.unpacked},hasMain:!0,shaderSource:e})},u=h=>{if(!h||h.length===0)throw new Error("Sum requires inputs.");const p=h[0].dims.length;for(let c=1;c{Object.defineProperty(t,"__esModule",{value:!0}),t.tile=void 0;const s=i(782),a=i(2039);t.tile=(h,p)=>{u(p);const c={name:"Tile",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,p,c)}),p)]};const d=(h,p,c)=>{const l=p[0].dims.slice(),n=new Array(l.length),e=[];for(let f=0;f{if(!h||h.length!==2)throw new Error("Tile requires 2 input.");if(h[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(h[1].dims[0]!==h[0].dims.length)throw new Error("Invalid input shape.");if(s.NUMBER_TYPES.indexOf(h[0].type)===-1)throw new Error("Invalid input type.");if(h[1].type!=="int32"&&h[1].type!=="int16")throw new Error("Invalid repeat type.")}},3738:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseTransposeAttributes=t.transpose=void 0;const s=i(246),a=i(2517),d=i(2039),u={name:"Transpose",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.transpose=(e,r,o)=>(n(r),[e.run(Object.assign(Object.assign({},u),{cacheHint:o.cacheKey,get:()=>h(e,r[0],o.perm)}),r)]),t.parseTransposeAttributes=e=>(0,s.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const h=(e,r,o)=>{const f=r.dims;o=p(f,o);const g=c(f,o),b=f.length,_=` - ${l("perm",o,b)} - float process(int indices[${b}]) { - int a[${b}]; - perm(a, indices); - return _A(a); - }`;return Object.assign(Object.assign({},u),{output:{dims:g,type:r.type,textureType:d.TextureType.unpacked},shaderSource:_})},p=(e,r)=>(r&&r.length!==e.length&&(r=[...e.keys()].reverse()),r),c=(e,r)=>(r=p(e,r),a.ShapeUtil.sortBasedOnPerm(e,r)),l=(e,r,o)=>{const f=[];f.push(`void ${e}(out int a[${o}], int src[${o}]) {`);for(let g=0;g{if(!e||e.length!==1)throw new Error("Transpose requires 1 input.");if(e[0].type!=="float32"&&e[0].type!=="float64")throw new Error("input should be float tensor")}},8710:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeAsUint8=void 0;const s=i(5060),a=i(2039);t.encodeAsUint8=(d,u)=>{const h=u.shape,p=(0,s.getGlsl)(d.session.backend.glContext.version),c=` - const float FLOAT_MAX = 1.70141184e38; - const float FLOAT_MIN = 1.17549435e-38; - - bool isNaN(float val) { - return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true; - } - - highp vec4 encodeAsUint8(highp float v) { - if (isNaN(v)) { - return vec4(255, 255, 255, 255); - } - - highp float av = abs(v); - - if(av < FLOAT_MIN) { - return vec4(0.0, 0.0, 0.0, 0.0); - } else if(v > FLOAT_MAX) { - return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; - } else if(v < -FLOAT_MAX) { - return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; - } - - highp vec4 c = vec4(0,0,0,0); - - highp float e = floor(log2(av)); - highp float m = exp2(fract(log2(av))) - 1.0; - - c[2] = floor(128.0 * m); - m -= c[2] / 128.0; - c[1] = floor(32768.0 * m); - m -= c[1] / 32768.0; - c[0] = floor(8388608.0 * m); - - highp float ebias = e + 127.0; - c[3] = floor(ebias / 2.0); - ebias -= c[3] * 2.0; - c[2] += floor(ebias) * 128.0; - - c[3] += 128.0 * step(0.0, -v); - - return c / 255.0; - } - - void main() { - float value = ${p.texture2D}(X,TexCoords).r; - ${p.output} = encodeAsUint8(value); - }`,l={name:"Uint8Encode",inputTypes:[a.TextureType.unpacked],inputNames:["X"],output:{dims:h,type:u.tensor.type,textureType:a.TextureType.downloadUint8AsFloat},shaderSource:c,hasMain:!0};return d.executeProgram(l,[u.tensor])}},4909:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tanh=t.tan=t.sqrt=t.sin=t.sigmoid=t.relu=t.not=t.neg=t.log=t.parseLeakyReluAttributes=t.leakyRelu=t.identity=t.floor=t.exp=t.parseEluAttributes=t.elu=t.cos=t.ceil=t.clipV11=t.parseClipAttributes=t.clip=t.atan=t.asin=t.acos=t.abs=t.glslTanh=t.glslTan=t.glslSqrt=t.glslSigmoid=t.glslRelu=t.glslSin=t.glslNot=t.glslNeg=t.glslLog=t.glslLeakyRelu=t.glslIdentity=t.glslClip=t.glslFloor=t.glslExp=t.glslElu=t.glslCos=t.glslCeil=t.glslAtan=t.glslAsin=t.glslAcos=t.glslAbs=void 0;const s=i(246),a=i(2517),d=i(8520),u=i(5060),h=i(2039);function p(){return $("abs")}function c(){return $("acos")}function l(){return $("asin")}function n(){return $("atan")}function e(){return $("ceil")}function r(){return $("cos")}function o(D){const z="elu";return{body:` - const float alpha = float(${D}); - - float ${z}_(float a) { - return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; - } - vec4 ${z}_(vec4 v) { - return vec4(${z}_(v.x), ${z}_(v.y), ${z}_(v.z), ${z}_(v.w)); - } - `,name:z,type:d.FunctionType.ValueBased}}function f(){return $("exp")}function g(){return $("floor")}function b(D,z){const Z="clip";return{body:` - const float min = float(${D}); - const float max = float(${z}); - - float ${Z}_(float a) { - return clamp(a, min, max); - } - vec4 ${Z}_(vec4 v) { - return clamp(v, min, max); - } - `,name:Z,type:d.FunctionType.ValueBased}}function _(){const D="indentity";return{body:` - float ${D}_(float a) { - return a; - } - vec4 ${D}_(vec4 v) { - return v; - } - `,name:D,type:d.FunctionType.ValueBased}}function y(D){const z="leakyRelu";return{body:` - const float alpha = float(${D}); - - float ${z}_(float a) { - return a < 0.0 ? a * alpha : a; - } - vec4 ${z}_(vec4 v) { - return vec4(${z}_(v.x), ${z}_(v.y), ${z}_(v.z), ${z}_(v.w)); - } - `,name:z,type:d.FunctionType.ValueBased}}function w(){return $("log")}function v(){const D="neg";return{body:` - float ${D}_(float a) { - return -a; - } - vec4 ${D}_(vec4 v) { - return -v; - } - `,name:D,type:d.FunctionType.ValueBased}}function S(){const D="not";return{body:` - float ${D}_(float a) { - return float( ! bool(a) ); - } - bool ${D}_(bool a) { - return !a; - } - vec4 ${D}_(vec4 v) { - return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w)); - } - bvec4 ${D}_(bvec4 v) { - return bvec4(!v.x, !v.y, !v.z, !v.w); - } - `,name:D,type:d.FunctionType.ValueBased}}function A(){return $("sin")}function I(){const D="relu";return{body:` - float ${D}_(float a) { - return max( a, 0.0 ); - } - vec4 ${D}_(vec4 v) { - return max( v, 0.0 ); - } - `,name:D,type:d.FunctionType.ValueBased}}function x(){const D="sigmoid";return{body:` - float ${D}_(float a) { - return 1.0 / (1.0 + exp(-a)); - } - vec4 ${D}_(vec4 v) { - return 1.0 / (1.0 + exp(-v)); - } - `,name:D,type:d.FunctionType.ValueBased}}function E(){return $("sqrt")}function F(){return $("tan")}function R(){const D="tanh";return{body:` - float ${D}_(float a) { - a = clamp(a, -10., 10.); - a = exp(2.*a); - return (a - 1.) / (a + 1.); - } - vec4 ${D}_(vec4 v) { - v = clamp(v, -10., 10.); - v = exp(2.*v); - return (v - 1.) / (v + 1.); - } - `,name:D,type:d.FunctionType.ValueBased}}function $(D){return{body:` - float ${D}_(float a) { - return ${D}(a); - } - vec4 ${D}_(vec4 v) { - return ${D}(v); - } - `,name:D,type:d.FunctionType.ValueBased}}t.glslAbs=p,t.glslAcos=c,t.glslAsin=l,t.glslAtan=n,t.glslCeil=e,t.glslCos=r,t.glslElu=o,t.glslExp=f,t.glslFloor=g,t.glslClip=b,t.glslIdentity=_,t.glslLeakyRelu=y,t.glslLog=w,t.glslNeg=v,t.glslNot=S,t.glslSin=A,t.glslRelu=I,t.glslSigmoid=x,t.glslSqrt=E,t.glslTan=F,t.glslTanh=R;const L=(D,z,Z,X)=>{const J=D.session.pack?h.TextureType.packed:h.TextureType.unpacked,ee={name:Z.name,inputTypes:[J],inputNames:["A"],cacheHint:X};return Object.assign(Object.assign({},ee),{get:()=>((ue,Se,ve,se)=>{const ye=ue.session.pack?h.TextureType.packed:h.TextureType.unpacked,be=(0,u.getGlsl)(ue.session.backend.glContext.version);return Object.assign(Object.assign({},Se),{output:{dims:ve.dims,type:ve.type,textureType:ye},shaderSource:` - ${se.body} - void main() { - vec4 v = ${be.texture2D}(A, TexCoords); - v = ${se.name}_(v); - ${be.output} = v; - } - `,hasMain:!0})})(D,ee,z,Z)})};t.abs=(D,z)=>[D.run(L(D,z[0],p()),z)],t.acos=(D,z)=>[D.run(L(D,z[0],c()),z)],t.asin=(D,z)=>[D.run(L(D,z[0],l()),z)],t.atan=(D,z)=>[D.run(L(D,z[0],n()),z)],t.clip=(D,z,Z)=>[D.run(L(D,z[0],b(Z.min,Z.max),Z.cacheKey),z)],t.parseClipAttributes=D=>(0,s.createAttributeWithCacheKey)({min:D.attributes.getFloat("min",a.MIN_CLIP),max:D.attributes.getFloat("max",a.MAX_CLIP)}),t.clipV11=(D,z)=>{const Z=G(D,z);return(0,t.clip)(D,[z[0]],Z)};const G=(D,z)=>{if(z.length>=3&&(!D.session.isInitializer(z[1].dataId)||!D.session.isInitializer(z[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const Z=z.length>=3?z[1].numberData[0]:a.MIN_CLIP,X=z.length>=3?z[2].numberData[0]:a.MAX_CLIP;return(0,s.createAttributeWithCacheKey)({min:Z,max:X})};t.ceil=(D,z)=>[D.run(L(D,z[0],e()),z)],t.cos=(D,z)=>[D.run(L(D,z[0],r()),z)],t.elu=(D,z,Z)=>[D.run(L(D,z[0],o(Z.alpha),Z.cacheKey),z)],t.parseEluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",1)}),t.exp=(D,z)=>[D.run(L(D,z[0],f()),z)],t.floor=(D,z)=>[D.run(L(D,z[0],g()),z)],t.identity=(D,z)=>[D.run(L(D,z[0],_()),z)],t.leakyRelu=(D,z,Z)=>[D.run(L(D,z[0],y(Z.alpha),Z.cacheKey),z)],t.parseLeakyReluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",.01)}),t.log=(D,z)=>[D.run(L(D,z[0],w()),z)],t.neg=(D,z)=>[D.run(L(D,z[0],v()),z)],t.not=(D,z)=>[D.run(L(D,z[0],S()),z)],t.relu=(D,z)=>[D.run(L(D,z[0],I()),z)],t.sigmoid=(D,z)=>[D.run(L(D,z[0],x()),z)],t.sin=(D,z)=>[D.run(L(D,z[0],A()),z)],t.sqrt=(D,z)=>[D.run(L(D,z[0],E()),z)],t.tan=(D,z)=>[D.run(L(D,z[0],F()),z)],t.tanh=(D,z)=>[D.run(L(D,z[0],R()),z)]},5611:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackProgramInfoLoader=t.createUnpackProgramInfo=void 0;const s=i(5060),a=i(2039),d=i(9390),u=i(2827),h={name:"unpack",inputNames:["A"],inputTypes:[a.TextureType.packed]};t.createUnpackProgramInfo=(p,c)=>{const l=c.dims.length,n=(0,u.getChannels)("rc",l),e=n.slice(-2),r=(0,d.getCoordsDataType)(l),o=(0,u.unpackFromChannel)(),f=c.dims.length===0?"":function(_,y){if(_===1)return"rc";let w="";for(let v=0;v<_;v++)w+=y[v],v<_-1&&(w+=",");return w}(l,n),g=l<=1?"rc":`vec2(${e.join(",")})`,b=` - ${o} - void main() { - ${r} rc = getOutputCoords(); - - // Sample the texture with the coords to get the rgba channel value. - vec4 packedInput = getA(${f}); - - ${(0,s.getGlsl)(p.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${g}), 0, 0, 0); - } - `;return Object.assign(Object.assign({},h),{hasMain:!0,output:{dims:c.dims,type:c.type,textureType:a.TextureType.unpacked},shaderSource:b})},t.createUnpackProgramInfoLoader=(p,c)=>Object.assign(Object.assign({},h),{get:()=>(0,t.createUnpackProgramInfo)(p,c)})},8428:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnsqueezeAttributes=t.unsqueezeV13=t.unsqueeze=void 0;const s=i(2517);t.unsqueeze=(u,h,p)=>{a(h);const c=s.ShapeUtil.unsqueezeShape(h[0].dims,p);return[u.reshapeUnpacked(h[0],c)]},t.unsqueezeV13=(u,h)=>(d(h),(0,t.unsqueeze)(u,[h[0]],Array.from(h[1].integerData))),t.parseUnsqueezeAttributes=u=>u.attributes.getInts("axes");const a=u=>{if(!u||u.length!==1)throw new Error("Unsqueeze requires 1 input.");if(u[0].type==="string")throw new Error("invalid input tensor types.")},d=u=>{if(!u||u.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(u[1].type!=="int32")throw new Error("Invalid input type.")}},9793:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scalesValidation=t.validateInputs=t.parseUpsampleAttributes=t.parseUpsampleAttributesV9=t.parseUpsampleAttributesV7=t.upsample=void 0;const s=i(246),a=i(5060),d=i(2039),u={name:"Upsample",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.upsample=(p,c,l)=>((0,t.validateInputs)(c,l),[p.run(Object.assign(Object.assign({},u),{cacheHint:l.cacheKey,get:()=>h(p,c,l)}),c)]),t.parseUpsampleAttributesV7=p=>(0,t.parseUpsampleAttributes)(p,7),t.parseUpsampleAttributesV9=p=>(0,t.parseUpsampleAttributes)(p,9),t.parseUpsampleAttributes=(p,c)=>{const l=c>=10,n=p.attributes.getString("mode","nearest");if(n!=="nearest"&&n!=="linear"&&(c<11||n!=="cubic"))throw new Error(`unrecognized mode: ${n}`);let e=[];c<9&&(e=p.attributes.getFloats("scales"),(0,t.scalesValidation)(e,n,l));const r=p.attributes.getFloat("extrapolation_value",0),o=c>10?p.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(o)===-1)throw new Error(`coordinate_transform_mode '${o}' is not supported`);const f=o==="tf_crop_and_resize",g=f,b=n==="nearest"&&c>=11?p.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(b)===-1)throw new Error(`nearest_mode '${b}' is not supported`);const _=p.attributes.getFloat("cubic_coeff_a",-.75),y=p.attributes.getInt("exclude_outside",0)!==0;if(y&&n!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const w=c<11||n==="nearest"&&o==="asymmetric"&&b==="floor";let v=0,S=0,A=0;return c>10?p.inputs.length>2?(v=1,S=2,A=3):(S=1,A=2):c===9&&(S=1),(0,s.createAttributeWithCacheKey)({opset:c,isResize:l,mode:n,scales:e,extrapolationValue:r,coordinateTransformMode:o,useExtrapolation:g,needRoiInput:f,nearestMode:b,cubicCoefficientA:_,excludeOutside:y,useNearest2xOptimization:w,roiInputIdx:v,scalesInputIdx:S,sizesInputIdx:A})};const h=(p,c,l)=>{const n=(0,a.getGlsl)(p.session.backend.glContext.version),[e,r]=p.calculateTextureWidthAndHeight(c[0].dims,d.TextureType.unpacked),o=c[0].dims.map((A,I)=>Math.floor(A*l.scales[I])),[f,g]=p.calculateTextureWidthAndHeight(o,d.TextureType.unpacked),b=o.length,_=new Array(b),y=new Array(b);let w=` - int output_pitches[${b}]; - int input_pitches[${b}]; - `;for(let A=b-1;A>=0;A--)_[A]=A===b-1?1:_[A+1]*o[A+1],y[A]=A===b-1?1:y[A+1]*c[0].dims[A+1],w+=` - output_pitches[${A}] = ${_[A]}; - input_pitches[${A}] = ${y[A]}; - `;const v=` - float getInputFloat(int index) { - vec2 coords = offsetToCoords(index, ${e}, ${r}); - float value = getColorAsFloat(${n.texture2D}(X, coords)); - return value; - } - `,S=l.mode==="nearest"?` - ${v} - float process(int indices[${b}]) { - int input_index = 0; - int output_index = coordsToOffset(TexCoords, ${f}, ${g}); - - ${w} - - int d, m; - for (int dim = 0; dim < ${b}; ++dim) { - d = output_index / output_pitches[dim]; - m = output_index - d * output_pitches[dim]; - output_index = m; - - if (scales[dim] != 1 && d > 0) { - int d2 = d / scales[dim]; - m = d - d2 * scales[dim]; - d = d2; - } - input_index += input_pitches[dim] * d; - } - - return getInputFloat(input_index); - }`:b===4?` - ${v} - float process(int indices[4]) { - int input_index = 0; - int output_index = coordsToOffset(TexCoords, ${f}, ${g}); - - ${w} - - int m; - int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3; - index_of_dim0 = output_index / output_pitches[0]; - m = output_index - index_of_dim0 * output_pitches[0]; - index_of_dim1 = m / output_pitches[1]; - m = m - index_of_dim1 * output_pitches[1]; - index_of_dim2 = m / output_pitches[2]; - m = m - index_of_dim2 * output_pitches[2]; - index_of_dim3 = m; - - int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset; - index_of_input_dim2 = index_of_dim2 / scales[2]; - y_offset = index_of_dim2 - index_of_input_dim2 * scales[2]; - index_of_input_dim3 = index_of_dim3 / scales[3]; - x_offset = index_of_dim3 - index_of_input_dim3 * scales[3]; - - input_index = index_of_dim0 * input_pitches[0] + - index_of_dim1 * input_pitches[1] + - index_of_input_dim2 * input_pitches[2] + - index_of_input_dim3; - - float x00 = getInputFloat(input_index); - float x10, x01, x11; - - bool end_of_dim2 = false; - if (index_of_input_dim2 == (${c[0].dims[2]} - 1)) { - // It's the end in dimension 2 - x01 = x00; - end_of_dim2 = true; - } else { - x01 = getInputFloat(input_index + input_pitches[2]); - } - - if (index_of_input_dim3 == (input_pitches[2] - 1)) { - // It's the end in dimension 3 - x10 = x00; - x11 = x01; - } - else { - x10 = getInputFloat(input_index + 1); - x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1); - } - - float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]); - float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]); - return y0 + float(x_offset) * (y1 - y0) / float(scales[3]); - }`:` - ${v} - float process(int indices[2]) { - int input_index = 0; - int output_index = coordsToOffset(TexCoords, ${f}, ${g}); - - ${w} - - int m; - int index_of_dim0, index_of_dim1; - index_of_dim0 = output_index / output_pitches[0]; - m = output_index - index_of_dim0 * output_pitches[0]; - index_of_dim1 = m; - - int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset; - index_of_input_dim0 = index_of_dim0 / scales[0]; - y_offset = index_of_dim0 - index_of_input_dim0 * scales[0]; - index_of_input_dim1 = index_of_dim1 / scales[1]; - x_offset = index_of_dim1 - index_of_input_dim1 * scales[1]; - - input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1; - - float x00 = getInputFloat(input_index); - float x10, x01, x11; - - bool end_of_dim0 = false; - if (index_of_input_dim0 == (${c[0].dims[0]} - 1)) { - // It's the end in dimension 0 - x01 = x00; - end_of_dim0 = true; - } else { - x01 = getInputFloat(input_index + input_pitches[0]); - } - - if (index_of_input_dim1 == (input_pitches[0] - 1)) { - // It's the end in dimension 1 - x10 = x00; - x11 = x01; - } - else { - x10 = getInputFloat(input_index + 1); - x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1); - } - - float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]); - float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]); - return y0 + float(x_offset) * (y1 - y0) / float(scales[1]); - }`;return Object.assign(Object.assign({},u),{output:{dims:o,type:c[0].type,textureType:d.TextureType.unpacked},shaderSource:S,variables:[{name:"scales",type:"int",arrayLength:l.scales.length,data:l.scales.map(A=>Math.ceil(A))}]})};t.validateInputs=(p,c)=>{if(!p||c.opset<9&&p.length!==1||c.opset>=9&&c.opset<11&&p.length!==2||c.opset>=11&&p.length<2)throw new Error("invalid inputs.");if(c.scales.length>0&&p[0].dims.length!==c.scales.length)throw new Error("Invalid input shape.");if(p[0].type==="string")throw new Error("Invalid input tensor types.")},t.scalesValidation=(p,c,l)=>{if(l){for(const n of p)if(n<=0)throw new Error("Scale value should be greater than 0.")}else for(const n of p)if(n<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(c!=="linear"&&c!=="cubic"||p.length===2||p.length===4&&p[0]===1&&p[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${l?"Resize":"Upsample"} opeartor.`)}},1958:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProgramManager=void 0;const s=i(1670),a=i(6231),d=i(8879),u=i(5060);t.ProgramManager=class{constructor(h,p,c){this.profiler=h,this.glContext=p,this.textureLayoutStrategy=c,this.repo=new Map,this.attributesBound=!1}getArtifact(h){return this.repo.get(h)}setArtifact(h,p){this.repo.set(h,p)}run(h,p,c){var l;this.profiler.event("op",`ProgramManager.run ${(l=h.programInfo.name)!==null&&l!==void 0?l:"unknown kernel"}`,()=>{var n;const e=this.glContext.gl,r=h.program;e.useProgram(r);try{this.bindOutput(c),this.attributesBound||this.bindAttributes(h.attribLocations),this.bindUniforms(h.uniformLocations,(n=h.programInfo.variables)!==null&&n!==void 0?n:[],p)}catch(o){throw a.Logger.error("ProgramManager",h.programInfo.shaderSource),o}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(h=>this.glContext.deleteProgram(h.program))}build(h,p,c){return this.profiler.event("backend","ProgramManager.build",()=>{const l=new d.GlslPreprocessor(this.glContext,h,p,c),n=l.preprocess(),e=this.compile(n);return{programInfo:h,program:e,uniformLocations:this.getUniformLocations(e,l.context.programInfo.inputNames,l.context.programInfo.variables),attribLocations:this.getAttribLocations(e)}})}compile(h){if(!this.vertexShader){a.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const l=(0,u.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(l,this.glContext.gl.VERTEX_SHADER)}s.env.debug&&a.Logger.verbose("ProrgramManager",`FragShader: -${h} -`);const p=this.glContext.compileShader(h,this.glContext.gl.FRAGMENT_SHADER),c=this.glContext.createProgram(this.vertexShader,p);return this.glContext.deleteShader(p),c}bindOutput(h){const p=h.width,c=h.height;a.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${p}/${c}, shape=${h.shape}, type=${h.tensor.type}`),this.glContext.attachFramebuffer(h.texture,p,c)}bindAttributes(h){const p=h.position,c=h.textureCoord;this.glContext.setVertexAttributes(p,c),this.attributesBound=!0}bindUniforms(h,p,c){var l;const n=this.glContext.gl;let e=0;for(const{name:r,type:o,location:f,arrayLength:g}of h){const b=(l=p.find(_=>_.name===r))===null||l===void 0?void 0:l.data;if(o!=="sampler2D"&&!b)throw new Error(`variable '${r}' does not have data defined in program info`);switch(o){case"sampler2D":this.bindTexture(c[e],f,e),e++;break;case"float":g?n.uniform1fv(f,b):n.uniform1f(f,b);break;case"int":g?n.uniform1iv(f,b):n.uniform1i(f,b);break;default:throw new Error(`Uniform not implemented: ${o}`)}}}bindTexture(h,p,c){this.glContext.bindTextureToUniform(h.texture,c,p)}getAttribLocations(h){return{position:this.getAttribLocation(h,"position"),textureCoord:this.getAttribLocation(h,"textureCoord")}}getUniformLocations(h,p,c){const l=[];if(p)for(const n of p)l.push({name:n,type:"sampler2D",location:this.getUniformLocation(h,n)});if(c)for(const n of c)l.push(Object.assign(Object.assign({},n),{location:this.getUniformLocation(h,n.name)}));return l}getUniformLocation(h,p){const c=this.glContext.gl.getUniformLocation(h,p);if(c===null)throw new Error(`Uniform ${p} not found.`);return c}getAttribLocation(h,p){return this.glContext.gl.getAttribLocation(h,p)}}},6416:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLSessionHandler=void 0;const s=i(6231),a=i(1047),d=i(8316),u=i(1640),h=i(1958),p=i(7859),c=i(5702);t.WebGLSessionHandler=class{constructor(l,n){this.backend=l,this.context=n,this.layoutStrategy=new p.PreferLogicalStrategy(l.glContext.maxTextureSize),this.programManager=new h.ProgramManager(this.context.profiler,l.glContext,this.layoutStrategy),this.textureManager=new c.TextureManager(l.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:l.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=l.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new d.WebGLInferenceHandler(this)}onGraphInitialized(l){const n=l.getValues().filter(e=>e.from===-1&&e.tensor).map(e=>e.tensor.dataId);this.initializers=new Set(n)}isInitializer(l){return!!this.initializers&&this.initializers.has(l)}addInitializer(l){this.initializers.add(l)}getTextureData(l,n){return n?this.packedTextureDataCache.get(l):this.unpackedTextureDataCache.get(l)}setTextureData(l,n,e=!1){s.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),e?this.packedTextureDataCache.set(l,n):this.unpackedTextureDataCache.set(l,n)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(l=>this.textureManager.releaseTexture(l,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(l=>this.textureManager.releaseTexture(l,!0)),this.unpackedTextureDataCache=new Map}resolve(l,n,e){const r=(0,a.resolveOperator)(l,n,u.WEBGL_OP_RESOLVE_RULES);return{impl:r.opImpl,context:r.opInit?r.opInit(l,e):l}}}},7769:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Uint8DataEncoder=t.RGBAFloatDataEncoder=t.RedFloat32DataEncoder=void 0;const s=i(6231);t.RedFloat32DataEncoder=class{constructor(a,d=1){if(d===1)this.internalFormat=a.R32F,this.format=a.RED,this.textureType=a.FLOAT,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=a.RGBA32F,this.format=a.RGBA,this.textureType=a.FLOAT,this.channelSize=d}}encode(a,d){let u,h;return a.constructor!==Float32Array&&(s.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),h=new Float32Array(a)),d*this.channelSize>a.length?(s.Logger.warning("Encoder","Source data too small. Allocating larger array"),h=a,u=this.allocate(d*this.channelSize),h.forEach((p,c)=>u[c]=p)):(h=a,u=h),u}allocate(a){return new Float32Array(4*a)}decode(a,d){return this.channelSize===1?a.filter((u,h)=>h%4==0).subarray(0,d):a.subarray(0,d)}},t.RGBAFloatDataEncoder=class{constructor(a,d=1,u){if(d!==1&&d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=a.RGBA,this.format=a.RGBA,this.channelSize=d,this.textureType=u||a.FLOAT}encode(a,d){let u=a;return this.channelSize===1&&(s.Logger.verbose("Encoder","Exploding into a larger array"),u=this.allocate(d),a.forEach((h,p)=>u[4*p]=h)),u}allocate(a){return new Float32Array(4*a)}decode(a,d){return this.channelSize===1?a.filter((u,h)=>h%4==0).subarray(0,d):a.subarray(0,d)}},t.Uint8DataEncoder=class{constructor(a,d=1){if(this.channelSize=4,d===1)this.internalFormat=a.ALPHA,this.format=a.ALPHA,this.textureType=a.UNSIGNED_BYTE,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=a.RGBA,this.format=a.RGBA,this.textureType=a.UNSIGNED_BYTE,this.channelSize=d}}encode(a,d){return new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}allocate(a){return new Uint8Array(a*this.channelSize)}decode(a,d){if(a instanceof Uint8Array)return a.subarray(0,d);throw new Error(`Invalid array type: ${a.constructor}`)}}},7859:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getBatchDim=t.sizeToSquarishShape=t.getRowsCols=t.sizeFromShape=t.isInt=t.parseAxisParam=t.squeezeShape=t.PreferLogicalStrategy=t.AlwaysKeepOriginalSizeStrategy=void 0;const s=i(6231),a=i(2517);function d(l,n){const e=[],r=[],o=n!=null&&Array.isArray(n)&&n.length===0,f=n==null||o?null:u(n,l).sort();let g=0;for(let b=0;bb)&&l[b]===1&&(e.push(l[b]),r.push(b)),f[g]<=b&&g++}l[b]!==1&&(e.push(l[b]),r.push(b))}return{newShape:e,keptDims:r}}function u(l,n){const e=n.length;return l=l==null?n.map((r,o)=>o):[].concat(l),(0,a.assert)(l.every(r=>r>=-e&&r`All values in axis param must be in range [-${e}, ${e}) but got axis ${l}`),(0,a.assert)(l.every(h),()=>`All values in axis param must be integers but got axis ${l}`),l.map(r=>r<0?e+r:r)}function h(l){return l%1==0}function p(l){if(l.length===0)return 1;let n=l[0];for(let e=1;e=l.length?1:l.slice(n.breakAxis).reduce((b,_)=>b*_),g=n.breakAxis<=0?1:l.slice(0,n.breakAxis).reduce((b,_)=>b*_);if(!(f>e||g>e))return[f,g];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${l}, breakAxis:${n.breakAxis}`)}const r=l.reduce((f,g)=>f*g);let o=Math.floor(Math.sqrt(r));for(;o=e||r%o!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${l}`);return[o,r/o]}},t.PreferLogicalStrategy=class{constructor(l){this.maxTextureSize=l}computeTextureWH(l,n){const e=this.computeTexture(l,n);return n&&n.isPacked&&(e[0]/=2,e[1]/=2),n&&n.reverseWH?[e[1],e[0]]:e}computeTexture(l,n){const e=n&&n.isPacked;if(l.length===0)return e?[2,2]:[1,1];let r=this.maxTextureSize;if(n&&n.breakAxis!==void 0){const g=n.breakAxis>=l.length?1:l.slice(n.breakAxis).reduce((_,y)=>_*y),b=n.breakAxis<=0?1:l.slice(0,n.breakAxis).reduce((_,y)=>_*y);if(!(g>r||b>r))return[g,b];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${l}, breakAxis:${n.breakAxis}`)}let o=l.slice(0);e&&(r*=2,o=o.map((g,b)=>b>=o.length-2?o[b]%2==0?o[b]:o[b]+1:o[b]),o.length===1&&(o=[2,o[0]])),o.length!==2&&(o=d(o).newShape);const f=p(o);return o.length<=1&&f<=r?[1,f]:o.length===2&&o[0]<=r&&o[1]<=r?o:o.length===3&&o[0]*o[1]<=r&&o[2]<=r?[o[0]*o[1],o[2]]:o.length===3&&o[0]<=r&&o[1]*o[2]<=r?[o[0],o[1]*o[2]]:o.length===4&&o[0]*o[1]*o[2]<=r&&o[3]<=r?[o[0]*o[1]*o[2],o[3]]:o.length===4&&o[0]<=r&&o[1]*o[2]*o[3]<=r?[o[0],o[1]*o[2]*o[3]]:e?c(f/4).map(g=>2*g):c(f)}},t.squeezeShape=d,t.parseAxisParam=u,t.isInt=h,t.sizeFromShape=p,t.getRowsCols=function(l){if(l.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[l.length>1?l[l.length-2]:1,l[l.length-1]]},t.sizeToSquarishShape=c,t.getBatchDim=function(l,n=2){return p(l.slice(0,l.length-n))}},4057:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createTextureLayoutFromShape=t.calculateTextureWidthAndHeight=t.createTextureLayoutFromTextureType=void 0;const s=i(2517),a=i(2039);t.createTextureLayoutFromTextureType=(d,u,h)=>{const p=h===a.TextureType.unpacked||h===a.TextureType.unpackedReversed?1:4,c=h===a.TextureType.packed,l=h===a.TextureType.unpackedReversed||h===a.TextureType.packed,n=h===a.TextureType.packedLastDimension?u.length-1:void 0,e=h===a.TextureType.packedLastDimension?u.map((r,o)=>o===u.length-1?4*r:r):void 0;return(0,t.createTextureLayoutFromShape)(d,u,p,e,{isPacked:c,reverseWH:l,breakAxis:n})},t.calculateTextureWidthAndHeight=(d,u,h)=>{const p=(0,t.createTextureLayoutFromTextureType)(d,u,h);return[p.width,p.height]},t.createTextureLayoutFromShape=(d,u,h=1,p,c)=>{const l=!(!c||!c.isPacked),[n,e]=d.computeTextureWH(l&&p||u,c),r=u.length;let o=u.slice(0);if(r===0&&(o=[1]),h===1)p=u;else if(l){if(h!==4)throw new Error("a packed texture must be 4-channel");p=u,r>0&&(o[r-1]=Math.ceil(o[r-1]/2)),r>1&&(o[r-2]=Math.ceil(o[r-2]/2))}else if(!p)throw new Error("Unpacked shape is needed when using channels > 1");return{width:n,height:e,channels:h,isPacked:l,shape:o,strides:s.ShapeUtil.computeStrides(o),unpackedShape:p,reversedWH:c&&c.reverseWH}}},5702:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextureManager=void 0;const s=i(6231);t.TextureManager=class{constructor(a,d,u,h){this.glContext=a,this.layoutStrategy=d,this.profiler=u,this.config=h,this.pendingRead=new Map,h.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(a,d,u,h){const p=this.toEncoderType(a),c=this.glContext.getEncoder(p,d.channels||1,h);if(d.isPacked&&h===1)throw new Error("not implemented");const l=d.width,n=d.height;let e,r;if(this.config.reuseTextures){e=`${l}x${n}_${c.format}_${c.internalFormat}_${c.textureType}`,r=this.inUseTextures.get(e),r||(r=[],this.inUseTextures.set(e,r));const f=this.idleTextures.get(e);if(f&&f.length>0){const g=f.pop();return r.push(g),h===1&&this.glContext.updateTexture(g,l,n,c,this.toTextureData(a,u)),g}}s.Logger.verbose("TextureManager",`Creating new texture of size ${d.width}x${d.height}`);const o=this.glContext.allocateTexture(l,n,c,this.toTextureData(a,u));return this.config.reuseTextures&&(r.push(o),this.textureLookup.set(o,e)),o}readTexture(a,d,u){return u||(u=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const h=a.shape.reduce((c,l)=>c*l)*u,p=this.glContext.readTexture(a.texture,a.width,a.height,h,this.toEncoderType(d),u);return this.toTensorData(d,p)})}async readTextureAsync(a,d,u){const h=a.tensor.dataId;if(u||(u=1),this.pendingRead.has(h)){const p=this.pendingRead.get(h);return new Promise(c=>p==null?void 0:p.push(c))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(h,[]);const p=a.shape.reduce((e,r)=>e*r)*u;await this.glContext.createAndWaitForFence();const c=this.glContext.readTexture(a.texture,a.width,a.height,p,this.toEncoderType(d),u),l=this.toTensorData(d,c),n=this.pendingRead.get(h);return this.pendingRead.delete(h),n==null||n.forEach(e=>e(l)),l})}readUint8TextureAsFloat(a){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const d=a.shape.reduce((h,p)=>h*p),u=this.glContext.readTexture(a.texture,a.width,a.height,4*d,"byte",4);return new Float32Array(u.buffer,u.byteOffset,d)})}releaseTexture(a,d){let u;if(this.config.reuseTextures&&(u=this.textureLookup.get(a.texture),u)){d&&this.textureLookup.delete(u);const h=this.inUseTextures.get(u);if(h){const p=h.indexOf(a.texture);if(p!==-1){h.splice(p,1);let c=this.idleTextures.get(u);c||(c=[],this.idleTextures.set(u,c)),c.push(a.texture)}}}u&&!d||(s.Logger.verbose("TextureManager",`Deleting texture of size ${a.width}x${a.height}`),this.glContext.deleteTexture(a.texture))}toTensorData(a,d){switch(a){case"int16":return d instanceof Int16Array?d:Int16Array.from(d);case"int32":return d instanceof Int32Array?d:Int32Array.from(d);case"int8":return d instanceof Int8Array?d:Int8Array.from(d);case"uint16":return d instanceof Uint16Array?d:Uint16Array.from(d);case"uint32":return d instanceof Uint32Array?d:Uint32Array.from(d);case"uint8":case"bool":return d instanceof Uint8Array?d:Uint8Array.from(d);case"float32":return d instanceof Float32Array?d:Float32Array.from(d);case"float64":return d instanceof Float64Array?d:Float64Array.from(d);default:throw new Error(`TensorData type ${a} is not supported`)}}toTextureData(a,d){if(d)return d instanceof Float32Array?d:new Float32Array(d)}toEncoderType(a){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},2039:(m,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.TextureType=void 0,(i=t.TextureType||(t.TextureType={}))[i.unpacked=0]="unpacked",i[i.unpackedReversed=1]="unpackedReversed",i[i.packed=2]="packed",i[i.downloadUint8AsFloat=3]="downloadUint8AsFloat",i[i.packedLastDimension=4]="packedLastDimension"},9390:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGlChannels=t.getCoordsDataType=t.getSqueezedParams=t.squeezeInputShape=t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=t.generateShaderFuncNameFromInputSamplerName=t.repeatedTry=t.getPackedShape=void 0;const s=i(2517);t.getPackedShape=function(a){const d=a.length;return a.slice(0,d-1).concat(a[d-1]/4)},t.repeatedTry=async function(a,d=h=>0,u){return new Promise((h,p)=>{let c=0;const l=()=>{if(a())return void h();c++;const n=d(c);u!=null&&c>=u?p():setTimeout(l,n)};l()})},t.generateShaderFuncNameFromInputSamplerName=function(a){return(0,s.assert)(a!==void 0&&a.length!==0,()=>"empty string found for sampler name"),"get"+a.charAt(0).toUpperCase()+a.slice(1)},t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(a){return(0,s.assert)(a!==void 0&&a.length!==0,()=>"empty string found for sampler name"),"get"+a.charAt(0).toUpperCase()+a.slice(1)+"AtOutCoords"},t.squeezeInputShape=function(a,d){let u=JSON.parse(JSON.stringify(a));return u=d,u},t.getSqueezedParams=function(a,d){return d.map(u=>a[u]).join(", ")},t.getCoordsDataType=function(a){if(a<=1)return"int";if(a===2)return"ivec2";if(a===3)return"ivec3";if(a===4)return"ivec4";if(a===5)return"ivec5";if(a===6)return"ivec6";throw Error(`GPU for rank ${a} is not yet supported`)},t.getGlChannels=function(a=6){return["x","y","z","w","u","v"].slice(0,a)}},7305:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createNewWebGLContext=t.createWebGLContext=void 0;const s=i(6231),a=i(1713),d={};function u(h){const p=function(){if(typeof document>"u"){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}const n=document.createElement("canvas");return n.width=1,n.height=1,n}();let c;const l={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!h||h==="webgl2")&&(c=p.getContext("webgl2",l),c))try{return new a.WebGLContext(c,2)}catch(n){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!h||h==="webgl")&&(c=p.getContext("webgl",l)||p.getContext("experimental-webgl",l),c))try{return new a.WebGLContext(c,1)}catch(n){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${n}`)}throw new Error("WebGL is not supported")}t.createWebGLContext=function h(p){let c;p&&p!=="webgl2"||!("webgl2"in d)?p&&p!=="webgl"||!("webgl"in d)||(c=d.webgl):c=d.webgl2,c=c||u(p),p=p||c.version===1?"webgl":"webgl2";const l=c.gl;return d[p]=c,l.isContextLost()?(delete d[p],h(p)):(l.disable(l.DEPTH_TEST),l.disable(l.STENCIL_TEST),l.disable(l.BLEND),l.disable(l.DITHER),l.disable(l.POLYGON_OFFSET_FILL),l.disable(l.SAMPLE_COVERAGE),l.enable(l.SCISSOR_TEST),l.enable(l.CULL_FACE),l.cullFace(l.BACK),c)},t.createNewWebGLContext=u},1713:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(l,n,e,r){r===void 0&&(r=e);var o=Object.getOwnPropertyDescriptor(n,e);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[e]}}),Object.defineProperty(l,r,o)}:function(l,n,e,r){r===void 0&&(r=e),l[r]=n[e]}),a=this&&this.__setModuleDefault||(Object.create?function(l,n){Object.defineProperty(l,"default",{enumerable:!0,value:n})}:function(l,n){l.default=n}),d=this&&this.__importStar||function(l){if(l&&l.__esModule)return l;var n={};if(l!=null)for(var e in l)e!=="default"&&Object.prototype.hasOwnProperty.call(l,e)&&s(n,l,e);return a(n,l),n};Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLContext=t.linearSearchLastTrue=void 0;const u=i(1670),h=d(i(7769)),p=i(9390);function c(l){let n=0;for(;nthis.isTimerResultAvailable(l)),this.getTimerResult(l)}async createAndWaitForFence(){const l=this.createFence(this.gl);return this.pollFence(l)}createFence(l){let n;const e=l,r=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return l.flush(),n=r===null?()=>!0:()=>{const o=e.clientWaitSync(r,0,0);return o===e.ALREADY_SIGNALED||o===e.CONDITION_SATISFIED},{query:r,isFencePassed:n}}async pollFence(l){return new Promise(n=>{this.addItemToPoll(()=>l.isFencePassed(),()=>n())})}pollItems(){const l=c(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=l;++n){const{resolveFn:e}=this.itemsToPoll[n];e()}this.itemsToPoll=this.itemsToPoll.slice(l+1)}async addItemToPoll(l,n){this.itemsToPoll.push({isDoneFn:l,resolveFn:n}),this.itemsToPoll.length>1||await(0,p.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},1036:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExecutionPlan=void 0;const s=i(6231);class a{constructor(u,h){this.op=u,this.node=h}}t.ExecutionPlan=class{constructor(d,u,h){this.graph=d,this.profiler=h,this.initialize(u)}initialize(d){this.profiler.event("session","ExecutionPlan.initialize",()=>{const u=this.graph.getNodes();if(u.length!==d.length)throw new Error("The size of nodes and OPs do not match.");this._ops=d.map((h,p)=>new a(h,u[p])),this.reset(),this._starter=[],this._ops.forEach((h,p)=>{let c=!0;for(const l of h.node.inputs)if(!this._values[l]&&this.graph.getInputIndices().indexOf(l)===-1){c=!1;break}c&&this._starter.push(p)})})}reset(){this._values=this.graph.getValues().map(d=>d.tensor)}async execute(d,u){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const h=d.createInferenceHandler(),p=this.graph.getInputIndices();if(u.length!==p.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${u.length} expected: ${p.length}`);u.forEach((o,f)=>{const g=p[f];this._values[g]=o});const c=this._starter.slice(0),l=this.graph.getValues(),n=this.graph.getNodes();let e=0;for(;ethis._values[w]);if(g.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${f.node}`);const b=g;s.Logger.verbose("ExecPlan",`Runing op:${f.node.name} (${b.map((w,v)=>`'${f.node.inputs[v]}': ${w.type}[${w.dims.join(",")}]`).join(", ")})`);const _=await this.profiler.event("node",f.node.name,async()=>f.op.impl(h,b,f.op.context));if(_.length!==f.node.outputs.length)throw new Error("the size of output does not match model definition.");_.forEach((w,v)=>{const S=f.node.outputs[v];if(this._values[S])throw new Error(`output [${S}] already has value: op:${f.node.name}`);this._values[S]=w});const y=new Set;_.forEach((w,v)=>{const S=f.node.outputs[v];for(const A of l[S].to){const I=n[A];let x=!0;for(const E of I.inputs)if(!this._values[E]){x=!1;break}x&&y.add(A)}}),c.push(...y)}const r=[];for(let o=0;o{Object.defineProperty(t,"__esModule",{value:!0}),t.Graph=void 0;const s=i(1446),a=i(7778),d=i(9395),u=i(9162),h=i(2517);var p=d.onnxruntime.experimental.fbs;t.Graph={from:(e,r)=>new n(e,r)};class c{constructor(r){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,r&&(this.type=h.ProtoUtil.tensorValueTypeFromProto(r.type.tensorType))}get from(){return this._from}get to(){return this._to}}class l{constructor(r,o){r instanceof s.onnx.NodeProto?(this.name=r.name,this.opType=r.opType,this.attributes=new a.Attribute(r.attribute)):r instanceof p.Node&&(this.name=o??r.name(),this.opType=r.opType(),this.attributes=new a.Attribute(h.ProtoUtil.tensorAttributesFromORTFormat(r))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class n{constructor(r,o){if(!r)throw new TypeError("graph is empty");this.buildGraph(r),this.transformGraph(o),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(r){if(r instanceof s.onnx.GraphProto)this.buildGraphFromOnnxFormat(r);else{if(!(r instanceof p.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(r)}}buildGraphFromOnnxFormat(r){const o=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const f=new Map;if(!r.input)throw new Error("missing information in graph: input");const g=[];for(const b of r.input){if(o.has(b.name))throw new Error(`duplicated input name: ${b.name}`);const _=this._allData.push(new c(b))-1;o.set(b.name,_),g.push(b.name)}if(!r.initializer)throw new Error("missing information in graph: initializer");for(const b of r.initializer){let _=o.get(b.name);if(_===void 0){const y=new c;y.type={shape:{dims:h.ProtoUtil.tensorDimsFromProto(b.dims)},tensorType:h.ProtoUtil.tensorDataTypeFromProto(b.dataType)},_=this._allData.push(y)-1,o.set(b.name,_)}this._allData[_]._from=-1,this._allData[_].tensor=u.Tensor.fromProto(b)}for(let b=0;b{this._allData[g]._to.forEach(b=>{r.add(b)})});const o=Array.from(r),f=new Array(this._nodes.length).fill("white");for(;o.length>0;){const g=o.pop();f[g]==="gray"?f[g]="black":(o.push(g),f[g]="gray",this._nodes[g].outputs.forEach(b=>{const _=this._allData[b];if(_.tensor!==void 0)throw new Error("node outputs should not be initialized");if(_._from!==g)throw new Error("from property of the Value object doesn't match index of Node being processed");_._to.forEach(y=>{if(f[y]==="gray")throw new Error("model graph is cyclic");f[y]==="white"&&o.push(y)})}))}}transformGraph(r){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),r&&r.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let r=0;for(let o=0;o0&&(this._nodes[o].inputs.forEach(f=>{const g=this._allData[f]._to.indexOf(o+r);g!==-1&&(this._allData[f]._to[g]=o)}),this._nodes[o].outputs.forEach(f=>{this._allData[f]._from&&this._allData[f]._from===o+r&&(this._allData[f]._from=o)})):(r++,this._nodes[o].outputs.forEach(f=>{this._allData[f]._from=-2}),this._nodes.splice(o,1),o--);r=0;for(let o=0;o0){let f=-1;this._allData[o].from!==void 0&&this._allData[o].from!==-1?(f=this._nodes[this._allData[o].from].outputs.indexOf(o+r),f!==-1&&(this._nodes[this._allData[o].from].outputs[f]=o)):(f=this._allInputIndices.indexOf(o+r),f!==-1&&(this._allInputIndices[f]=o)),this._allData[o].to.forEach(g=>{f=this._nodes[g].inputs.indexOf(o+r),f!==-1&&(this._nodes[g].inputs[f]=o)}),this._allData[o].to.length===0&&(f=this._allOutputIndices.indexOf(o+r),f!==-1&&(this._allOutputIndices[f]=o))}}else r++,this._allData.splice(o,1),o--}deleteNode(r){const o=this._nodes[r];if(o.outputs.length>1){for(let w=1;w0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}o.executeNode=!1;const f=o.inputs[0],g=o.outputs[0],b=this._allData[g].to,_=this._allData[f].to.indexOf(r);if(_===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[f].to.splice(_,1),this._allData[g]._to=[];const y=this._allOutputIndices.indexOf(g);if(y!==-1&&(this._allOutputIndices[y]=f),b&&b.length>0)for(const w of b){const v=this._nodes[w].inputs.indexOf(g);if(v===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[w].inputs[v]=f,this._allData[f].to.push(w)}}removeAllDropoutNodes(){let r=0;for(const o of this._nodes){if(o.opType==="Dropout"){if(o.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(o.outputs.length!==1&&o.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(o.outputs.length===2&&this._allData[o.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(r)}r++}}removeAllIdentityNodes(){let r=0;for(const o of this._nodes)o.opType==="Identity"&&this.deleteNode(r),r++}isActivation(r){switch(r.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const r of this._nodes)if(r.opType==="Conv"){const o=this._allData[r.outputs[0]]._to;if(o.length===1&&this.isActivation(this._nodes[o[0]])){const f=this._nodes[o[0]];if(f.opType==="Clip")if(f.inputs.length===1)try{r.attributes.set("activation_params","floats",[f.attributes.getFloat("min"),f.attributes.getFloat("max")])}catch{r.attributes.set("activation_params","floats",[h.MIN_CLIP,h.MAX_CLIP])}else{if(!(f.inputs.length>=3&&this._allData[f.inputs[1]].tensor!==void 0&&this._allData[f.inputs[2]].tensor!==void 0))continue;r.attributes.set("activation_params","floats",[this._allData[f.inputs[1]].tensor.floatData[0],this._allData[f.inputs[2]].tensor.floatData[0]])}r.attributes.set("activation","string",f.opType),this.deleteNode(o[0])}}}}},6231:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.now=t.Profiler=t.Logger=void 0;const i={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},s={none:new class{log(l,n,e){}},console:new class{log(l,n,e){console.log(`${this.color(l)} ${e?"\x1B[35m"+e+"\x1B[0m ":""}${n}`)}color(l){switch(l){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: ${l}`)}}}},a={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let d={"":a};function u(l,n,e,r){if(n===void 0)return o=l,{verbose:u.verbose.bind(null,o),info:u.info.bind(null,o),warning:u.warning.bind(null,o),error:u.error.bind(null,o),fatal:u.fatal.bind(null,o)};if(e===void 0)h(l,n);else if(typeof e=="number"&&r===void 0)h(l,n);else if(typeof e=="string"&&r===void 0)h(l,e,0,n);else{if(typeof e!="string"||typeof r!="number")throw new TypeError("input is valid");h(l,e,0,n)}var o}function h(l,n,e,r){const o=d[r||""]||d[""];i[l]{g.then(async y=>{o&&await o.end(),b(y)},async y=>{o&&await o.end(),_(y)})});if(!f&&o){const b=o.end();if(b&&typeof b.then=="function")return new Promise((_,y)=>{b.then(()=>{_(g)},w=>{y(w)})})}return g}begin(l,n,e){if(!this._started)throw new Error("profiler is not started yet");if(e===void 0){const r=(0,t.now)();return this.flush(r),new p(l,n,r,o=>this.endSync(o))}{const r=e.beginTimer();return new p(l,n,0,async o=>this.end(o),r,e)}}async end(l){const n=await l.checkTimer();this._timingEvents.length=this._flushBatchSize||l-this._flushTime>=this._flushIntervalInMilliseconds){for(const n=this._flushPointer;this._flushPointerperformance.now():Date.now},2644:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(5686),a=i(1446),d=i(7070),u=i(9395),h=i(2517);var p=u.onnxruntime.experimental.fbs;t.Model=class{constructor(){}load(c,l,n){if(!n)try{return void this.loadFromOnnxFormat(c,l)}catch(e){if(n!==void 0)throw e}this.loadFromOrtFormat(c,l)}loadFromOnnxFormat(c,l){const n=a.onnx.ModelProto.decode(c);if(h.LongUtil.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map(e=>({domain:e.domain,version:h.LongUtil.longToNumber(e.version)})),this._graph=d.Graph.from(n.graph,l)}loadFromOrtFormat(c,l){const n=new s.flatbuffers.ByteBuffer(c),e=p.InferenceSession.getRootAsInferenceSession(n).model();if(h.LongUtil.longToNumber(e.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.FLOAT_TYPES=t.INT_TYPES=t.NUMBER_TYPES=void 0,t.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],t.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],t.FLOAT_TYPES=["float32","float64"]},1047:(m,t)=>{function i(s,a){if(a.endsWith("+")){const d=Number.parseInt(a.substring(0,a.length-1),10);return!isNaN(d)&&d<=s}if(a.split("-").length===2){const d=a.split("-"),u=Number.parseInt(d[0],10),h=Number.parseInt(d[1],10);return!isNaN(u)&&!isNaN(h)&&u<=s&&s<=h}return Number.parseInt(a,10)===s}Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOperator=void 0,t.resolveOperator=function(s,a,d){for(const u of d){const h=u[0],p=u[1],c=u[2],l=u[3],n=u[4];if(s.opType===h){for(const e of a)if((e.domain===p||e.domain==="ai.onnx"&&p==="")&&i(e.version,c))return{opImpl:l,opInit:n}}}throw new TypeError(`cannot resolve operator '${s.opType}' with opsets: ${a.map(u=>`${u.domain||"ai.onnx"} v${u.version}`).join(", ")}`)}},9395:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onnxruntime=void 0;const s=i(5686);var a,d;a=t.onnxruntime||(t.onnxruntime={}),function(u){(function(h){h[h.UNDEFINED=0]="UNDEFINED",h[h.FLOAT=1]="FLOAT",h[h.INT=2]="INT",h[h.STRING=3]="STRING",h[h.TENSOR=4]="TENSOR",h[h.GRAPH=5]="GRAPH",h[h.FLOATS=6]="FLOATS",h[h.INTS=7]="INTS",h[h.STRINGS=8]="STRINGS",h[h.TENSORS=9]="TENSORS",h[h.GRAPHS=10]="GRAPHS",h[h.SPARSE_TENSOR=11]="SPARSE_TENSOR",h[h.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(u.AttributeType||(u.AttributeType={}))}((d=a.experimental||(a.experimental={})).fbs||(d.fbs={})),function(u){(function(h){(function(p){(function(c){c[c.UNKNOWN=0]="UNKNOWN",c[c.VALUE=1]="VALUE",c[c.PARAM=2]="PARAM"})(p.DimensionValueType||(p.DimensionValueType={}))})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){(function(c){c[c.UNDEFINED=0]="UNDEFINED",c[c.FLOAT=1]="FLOAT",c[c.UINT8=2]="UINT8",c[c.INT8=3]="INT8",c[c.UINT16=4]="UINT16",c[c.INT16=5]="INT16",c[c.INT32=6]="INT32",c[c.INT64=7]="INT64",c[c.STRING=8]="STRING",c[c.BOOL=9]="BOOL",c[c.FLOAT16=10]="FLOAT16",c[c.DOUBLE=11]="DOUBLE",c[c.UINT32=12]="UINT32",c[c.UINT64=13]="UINT64",c[c.COMPLEX64=14]="COMPLEX64",c[c.COMPLEX128=15]="COMPLEX128",c[c.BFLOAT16=16]="BFLOAT16"})(p.TensorDataType||(p.TensorDataType={}))})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){(function(c){c[c.Primitive=0]="Primitive",c[c.Fused=1]="Fused"})(p.NodeType||(p.NodeType={}))})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){(function(c){c[c.NONE=0]="NONE",c[c.tensor_type=1]="tensor_type",c[c.sequence_type=2]="sequence_type",c[c.map_type=3]="map_type"})(p.TypeInfoValue||(p.TypeInfoValue={}))})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsShape(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsShape(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}dim(n,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new u.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}dimLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}static startShape(n){n.startObject(1)}static addDim(n,e){n.addFieldOffset(0,e,0)}static createDimVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startDimVector(n,e){n.startVector(4,e,4)}static endShape(n){return n.endObject()}static createShape(n,e){return c.startShape(n),c.addDim(n,e),c.endShape(n)}}p.Shape=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsDimension(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimension(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}value(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new u.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}denotation(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}static startDimension(n){n.startObject(2)}static addValue(n,e){n.addFieldOffset(0,e,0)}static addDenotation(n,e){n.addFieldOffset(1,e,0)}static endDimension(n){return n.endObject()}static createDimension(n,e,r){return c.startDimension(n),c.addValue(n,e),c.addDenotation(n,r),c.endDimension(n)}}p.Dimension=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsDimensionValue(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsDimensionValue(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}dimType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt8(this.bb_pos+n):u.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}dimParam(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}static startDimensionValue(n){n.startObject(3)}static addDimType(n,e){n.addFieldInt8(0,e,u.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(n,e){n.addFieldInt64(1,e,n.createLong(0,0))}static addDimParam(n,e){n.addFieldOffset(2,e,0)}static endDimensionValue(n){return n.endObject()}static createDimensionValue(n,e,r,o){return c.startDimensionValue(n),c.addDimType(n,e),c.addDimValue(n,r),c.addDimParam(n,o),c.endDimensionValue(n)}}p.DimensionValue=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTensorTypeAndShape(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensorTypeAndShape(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}elemType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):u.experimental.fbs.TensorDataType.UNDEFINED}shape(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new u.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startTensorTypeAndShape(n){n.startObject(2)}static addElemType(n,e){n.addFieldInt32(0,e,u.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(n,e){n.addFieldOffset(1,e,0)}static endTensorTypeAndShape(n){return n.endObject()}static createTensorTypeAndShape(n,e,r){return c.startTensorTypeAndShape(n),c.addElemType(n,e),c.addShape(n,r),c.endTensorTypeAndShape(n)}}p.TensorTypeAndShape=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsMapType(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsMapType(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}keyType(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt32(this.bb_pos+n):u.experimental.fbs.TensorDataType.UNDEFINED}valueType(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new u.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startMapType(n){n.startObject(2)}static addKeyType(n,e){n.addFieldInt32(0,e,u.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(n,e){n.addFieldOffset(1,e,0)}static endMapType(n){return n.endObject()}static createMapType(n,e,r){return c.startMapType(n),c.addKeyType(n,e),c.addValueType(n,r),c.endMapType(n)}}p.MapType=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSequenceType(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSequenceType(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}elemType(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new u.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSequenceType(n){n.startObject(1)}static addElemType(n,e){n.addFieldOffset(0,e,0)}static endSequenceType(n){return n.endObject()}static createSequenceType(n,e){return c.startSequenceType(n),c.addElemType(n,e),c.endSequenceType(n)}}p.SequenceType=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(h.fbs||(h.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(p,c){return this.bb_pos=p,this.bb=c,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(p,c,l,n){return p.prep(4,12),p.writeInt32(n),p.writeInt32(l),p.writeInt32(c),p.offset()}}})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsNodeEdge(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNodeEdge(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}nodeIndex(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readUint32(this.bb_pos+n):0}inputEdges(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*n,this.bb):null}inputEdgesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}outputEdges(n,e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new u.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*n,this.bb):null}outputEdgesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNodeEdge(n){n.startObject(3)}static addNodeIndex(n,e){n.addFieldInt32(0,e,0)}static addInputEdges(n,e){n.addFieldOffset(1,e,0)}static startInputEdgesVector(n,e){n.startVector(12,e,4)}static addOutputEdges(n,e){n.addFieldOffset(2,e,0)}static startOutputEdgesVector(n,e){n.startVector(12,e,4)}static endNodeEdge(n){return n.endObject()}static createNodeEdge(n,e,r,o){return c.startNodeEdge(n),c.addNodeIndex(n,e),c.addInputEdges(n,r),c.addOutputEdges(n,o),c.endNodeEdge(n)}}p.NodeEdge=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsNode(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsNode(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}domain(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}sinceVersion(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):0}index(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readUint32(this.bb_pos+n):0}opType(n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,n):null}type(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.readInt32(this.bb_pos+n):u.experimental.fbs.NodeType.Primitive}executionProviderType(n){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,n):null}inputs(n,e){let r=this.bb.__offset(this.bb_pos,20);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,e){let r=this.bb.__offset(this.bb_pos,22);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}attributes(n,e){let r=this.bb.__offset(this.bb_pos,24);return r?(e||new u.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}attributesLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCounts(n){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*n):0}inputArgCountsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}inputArgCountsArray(){let n=this.bb.__offset(this.bb_pos,26);return n?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}implicitInputs(n,e){let r=this.bb.__offset(this.bb_pos,28);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}implicitInputsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startNode(n){n.startObject(13)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addDomain(n,e){n.addFieldOffset(2,e,0)}static addSinceVersion(n,e){n.addFieldInt32(3,e,0)}static addIndex(n,e){n.addFieldInt32(4,e,0)}static addOpType(n,e){n.addFieldOffset(5,e,0)}static addType(n,e){n.addFieldInt32(6,e,u.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(n,e){n.addFieldOffset(7,e,0)}static addInputs(n,e){n.addFieldOffset(8,e,0)}static createInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInputsVector(n,e){n.startVector(4,e,4)}static addOutputs(n,e){n.addFieldOffset(9,e,0)}static createOutputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOutputsVector(n,e){n.startVector(4,e,4)}static addAttributes(n,e){n.addFieldOffset(10,e,0)}static createAttributesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startAttributesVector(n,e){n.startVector(4,e,4)}static addInputArgCounts(n,e){n.addFieldOffset(11,e,0)}static createInputArgCountsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addInt32(e[r]);return n.endVector()}static startInputArgCountsVector(n,e){n.startVector(4,e,4)}static addImplicitInputs(n,e){n.addFieldOffset(12,e,0)}static createImplicitInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startImplicitInputsVector(n,e){n.startVector(4,e,4)}static endNode(n){return n.endObject()}static createNode(n,e,r,o,f,g,b,_,y,w,v,S,A,I){return c.startNode(n),c.addName(n,e),c.addDocString(n,r),c.addDomain(n,o),c.addSinceVersion(n,f),c.addIndex(n,g),c.addOpType(n,b),c.addType(n,_),c.addExecutionProviderType(n,y),c.addInputs(n,w),c.addOutputs(n,v),c.addAttributes(n,S),c.addInputArgCounts(n,A),c.addImplicitInputs(n,I),c.endNode(n)}}p.Node=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsValueInfo(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsValueInfo(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}type(n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new u.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startValueInfo(n){n.startObject(3)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addType(n,e){n.addFieldOffset(2,e,0)}static endValueInfo(n){return n.endObject()}static createValueInfo(n,e,r,o){return c.startValueInfo(n),c.addName(n,e),c.addDocString(n,r),c.addType(n,o),c.endValueInfo(n)}}p.ValueInfo=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTypeInfo(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTypeInfo(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}denotation(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}valueType(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readUint8(this.bb_pos+n):u.experimental.fbs.TypeInfoValue.NONE}value(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(n,this.bb_pos+e):null}static startTypeInfo(n){n.startObject(3)}static addDenotation(n,e){n.addFieldOffset(0,e,0)}static addValueType(n,e){n.addFieldInt8(1,e,u.experimental.fbs.TypeInfoValue.NONE)}static addValue(n,e){n.addFieldOffset(2,e,0)}static endTypeInfo(n){return n.endObject()}static createTypeInfo(n,e,r,o){return c.startTypeInfo(n),c.addDenotation(n,e),c.addValueType(n,r),c.addValue(n,o),c.endTypeInfo(n)}}p.TypeInfo=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsOperatorSetId(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsOperatorSetId(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}domain(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}version(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}static startOperatorSetId(n){n.startObject(2)}static addDomain(n,e){n.addFieldOffset(0,e,0)}static addVersion(n,e){n.addFieldInt64(1,e,n.createLong(0,0))}static endOperatorSetId(n){return n.endObject()}static createOperatorSetId(n,e,r){return c.startOperatorSetId(n),c.addDomain(n,e),c.addVersion(n,r),c.endOperatorSetId(n)}}p.OperatorSetId=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsTensor(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsTensor(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}dims(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}dataType(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt32(this.bb_pos+n):u.experimental.fbs.TensorDataType.UNDEFINED}rawData(n){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+n):0}rawDataLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}rawDataArray(){let n=this.bb.__offset(this.bb_pos,12);return n?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}stringData(n,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}stringDataLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}static startTensor(n){n.startObject(6)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addDims(n,e){n.addFieldOffset(2,e,0)}static createDimsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startDimsVector(n,e){n.startVector(8,e,8)}static addDataType(n,e){n.addFieldInt32(3,e,u.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(n,e){n.addFieldOffset(4,e,0)}static createRawDataVector(n,e){n.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)n.addInt8(e[r]);return n.endVector()}static startRawDataVector(n,e){n.startVector(1,e,1)}static addStringData(n,e){n.addFieldOffset(5,e,0)}static createStringDataVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startStringDataVector(n,e){n.startVector(4,e,4)}static endTensor(n){return n.endObject()}static createTensor(n,e,r,o,f,g,b){return c.startTensor(n),c.addName(n,e),c.addDocString(n,r),c.addDims(n,o),c.addDataType(n,f),c.addRawData(n,g),c.addStringData(n,b),c.endTensor(n)}}p.Tensor=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSparseTensor(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSparseTensor(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}values(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}indices(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dims(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}dimsLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSparseTensor(n){n.startObject(3)}static addValues(n,e){n.addFieldOffset(0,e,0)}static addIndices(n,e){n.addFieldOffset(1,e,0)}static addDims(n,e){n.addFieldOffset(2,e,0)}static createDimsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startDimsVector(n,e){n.startVector(8,e,8)}static endSparseTensor(n){return n.endObject()}static createSparseTensor(n,e,r,o){return c.startSparseTensor(n),c.addValues(n,e),c.addIndices(n,r),c.addDims(n,o),c.endSparseTensor(n)}}p.SparseTensor=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsAttribute(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsAttribute(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}name(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}docString(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,n):null}type(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.readInt32(this.bb_pos+n):u.experimental.fbs.AttributeType.UNDEFINED}f(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readFloat32(this.bb_pos+n):0}i(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}s(n){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,n):null}t(n){let e=this.bb.__offset(this.bb_pos,16);return e?(n||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}g(n){let e=this.bb.__offset(this.bb_pos,18);return e?(n||new u.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}floats(n){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*n):0}floatsLength(){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__vector_len(this.bb_pos+n):0}floatsArray(){let n=this.bb.__offset(this.bb_pos,20);return n?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}ints(n){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}intsLength(){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__vector_len(this.bb_pos+n):0}strings(n,e){let r=this.bb.__offset(this.bb_pos,24);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}stringsLength(){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__vector_len(this.bb_pos+n):0}tensors(n,e){let r=this.bb.__offset(this.bb_pos,26);return r?(e||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}tensorsLength(){let n=this.bb.__offset(this.bb_pos,26);return n?this.bb.__vector_len(this.bb_pos+n):0}graphs(n,e){let r=this.bb.__offset(this.bb_pos,28);return r?(e||new u.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}graphsLength(){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__vector_len(this.bb_pos+n):0}static startAttribute(n){n.startObject(13)}static addName(n,e){n.addFieldOffset(0,e,0)}static addDocString(n,e){n.addFieldOffset(1,e,0)}static addType(n,e){n.addFieldInt32(2,e,u.experimental.fbs.AttributeType.UNDEFINED)}static addF(n,e){n.addFieldFloat32(3,e,0)}static addI(n,e){n.addFieldInt64(4,e,n.createLong(0,0))}static addS(n,e){n.addFieldOffset(5,e,0)}static addT(n,e){n.addFieldOffset(6,e,0)}static addG(n,e){n.addFieldOffset(7,e,0)}static addFloats(n,e){n.addFieldOffset(8,e,0)}static createFloatsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addFloat32(e[r]);return n.endVector()}static startFloatsVector(n,e){n.startVector(4,e,4)}static addInts(n,e){n.addFieldOffset(9,e,0)}static createIntsVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startIntsVector(n,e){n.startVector(8,e,8)}static addStrings(n,e){n.addFieldOffset(10,e,0)}static createStringsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startStringsVector(n,e){n.startVector(4,e,4)}static addTensors(n,e){n.addFieldOffset(11,e,0)}static createTensorsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startTensorsVector(n,e){n.startVector(4,e,4)}static addGraphs(n,e){n.addFieldOffset(12,e,0)}static createGraphsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startGraphsVector(n,e){n.startVector(4,e,4)}static endAttribute(n){return n.endObject()}static createAttribute(n,e,r,o,f,g,b,_,y,w,v,S,A,I){return c.startAttribute(n),c.addName(n,e),c.addDocString(n,r),c.addType(n,o),c.addF(n,f),c.addI(n,g),c.addS(n,b),c.addT(n,_),c.addG(n,y),c.addFloats(n,w),c.addInts(n,v),c.addStrings(n,S),c.addTensors(n,A),c.addGraphs(n,I),c.endAttribute(n)}}p.Attribute=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsGraph(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsGraph(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}initializers(n,e){let r=this.bb.__offset(this.bb_pos,4);return r?(e||new u.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}initializersLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeArgs(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodeArgsLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}nodes(n,e){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new u.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodesLength(){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__vector_len(this.bb_pos+n):0}maxNodeIndex(){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readUint32(this.bb_pos+n):0}nodeEdges(n,e){let r=this.bb.__offset(this.bb_pos,12);return r?(e||new u.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}nodeEdgesLength(){let n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__vector_len(this.bb_pos+n):0}inputs(n,e){let r=this.bb.__offset(this.bb_pos,14);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}inputsLength(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__vector_len(this.bb_pos+n):0}outputs(n,e){let r=this.bb.__offset(this.bb_pos,16);return r?this.bb.__string(this.bb.__vector(this.bb_pos+r)+4*n,e):null}outputsLength(){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__vector_len(this.bb_pos+n):0}sparseInitializers(n,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new u.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}sparseInitializersLength(){let n=this.bb.__offset(this.bb_pos,18);return n?this.bb.__vector_len(this.bb_pos+n):0}static startGraph(n){n.startObject(8)}static addInitializers(n,e){n.addFieldOffset(0,e,0)}static createInitializersVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInitializersVector(n,e){n.startVector(4,e,4)}static addNodeArgs(n,e){n.addFieldOffset(1,e,0)}static createNodeArgsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodeArgsVector(n,e){n.startVector(4,e,4)}static addNodes(n,e){n.addFieldOffset(2,e,0)}static createNodesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodesVector(n,e){n.startVector(4,e,4)}static addMaxNodeIndex(n,e){n.addFieldInt32(3,e,0)}static addNodeEdges(n,e){n.addFieldOffset(4,e,0)}static createNodeEdgesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startNodeEdgesVector(n,e){n.startVector(4,e,4)}static addInputs(n,e){n.addFieldOffset(5,e,0)}static createInputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startInputsVector(n,e){n.startVector(4,e,4)}static addOutputs(n,e){n.addFieldOffset(6,e,0)}static createOutputsVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOutputsVector(n,e){n.startVector(4,e,4)}static addSparseInitializers(n,e){n.addFieldOffset(7,e,0)}static createSparseInitializersVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startSparseInitializersVector(n,e){n.startVector(4,e,4)}static endGraph(n){return n.endObject()}static createGraph(n,e,r,o,f,g,b,_,y){return c.startGraph(n),c.addInitializers(n,e),c.addNodeArgs(n,r),c.addNodes(n,o),c.addMaxNodeIndex(n,f),c.addNodeEdges(n,g),c.addInputs(n,b),c.addOutputs(n,_),c.addSparseInitializers(n,y),c.endGraph(n)}}p.Graph=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsModel(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsModel(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}irVersion(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}opsetImport(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}opsetImportLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}producerName(n){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,n):null}producerVersion(n){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,n):null}domain(n){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,n):null}modelVersion(){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.readInt64(this.bb_pos+n):this.bb.createLong(0,0)}docString(n){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__string(this.bb_pos+e,n):null}graph(n){let e=this.bb.__offset(this.bb_pos,18);return e?(n||new u.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}graphDocString(n){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__string(this.bb_pos+e,n):null}static startModel(n){n.startObject(9)}static addIrVersion(n,e){n.addFieldInt64(0,e,n.createLong(0,0))}static addOpsetImport(n,e){n.addFieldOffset(1,e,0)}static createOpsetImportVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startOpsetImportVector(n,e){n.startVector(4,e,4)}static addProducerName(n,e){n.addFieldOffset(2,e,0)}static addProducerVersion(n,e){n.addFieldOffset(3,e,0)}static addDomain(n,e){n.addFieldOffset(4,e,0)}static addModelVersion(n,e){n.addFieldInt64(5,e,n.createLong(0,0))}static addDocString(n,e){n.addFieldOffset(6,e,0)}static addGraph(n,e){n.addFieldOffset(7,e,0)}static addGraphDocString(n,e){n.addFieldOffset(8,e,0)}static endModel(n){return n.endObject()}static createModel(n,e,r,o,f,g,b,_,y,w){return c.startModel(n),c.addIrVersion(n,e),c.addOpsetImport(n,r),c.addProducerName(n,o),c.addProducerVersion(n,f),c.addDomain(n,g),c.addModelVersion(n,b),c.addDocString(n,_),c.addGraph(n,y),c.addGraphDocString(n,w),c.endModel(n)}}p.Model=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsKernelCreateInfos(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsKernelCreateInfos(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}nodeIndices(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*n):0}nodeIndicesLength(){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__vector_len(this.bb_pos+n):0}nodeIndicesArray(){let n=this.bb.__offset(this.bb_pos,4);return n?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+n),this.bb.__vector_len(this.bb_pos+n)):null}kernelDefHashes(n){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*n):this.bb.createLong(0,0)}kernelDefHashesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startKernelCreateInfos(n){n.startObject(2)}static addNodeIndices(n,e){n.addFieldOffset(0,e,0)}static createNodeIndicesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addInt32(e[r]);return n.endVector()}static startNodeIndicesVector(n,e){n.startVector(4,e,4)}static addKernelDefHashes(n,e){n.addFieldOffset(1,e,0)}static createKernelDefHashesVector(n,e){n.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)n.addInt64(e[r]);return n.endVector()}static startKernelDefHashesVector(n,e){n.startVector(8,e,8)}static endKernelCreateInfos(n){return n.endObject()}static createKernelCreateInfos(n,e,r){return c.startKernelCreateInfos(n),c.addNodeIndices(n,e),c.addKernelDefHashes(n,r),c.endKernelCreateInfos(n)}}p.KernelCreateInfos=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSubGraphSessionState(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSubGraphSessionState(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}graphId(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}sessionState(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new u.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startSubGraphSessionState(n){n.startObject(2)}static addGraphId(n,e){n.addFieldOffset(0,e,0)}static addSessionState(n,e){n.addFieldOffset(1,e,0)}static endSubGraphSessionState(n){let e=n.endObject();return n.requiredField(e,4),e}static createSubGraphSessionState(n,e,r){return c.startSubGraphSessionState(n),c.addGraphId(n,e),c.addSessionState(n,r),c.endSubGraphSessionState(n)}}p.SubGraphSessionState=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsSessionState(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsSessionState(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}kernels(n){let e=this.bb.__offset(this.bb_pos,4);return e?(n||new u.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}subGraphSessionStates(n,e){let r=this.bb.__offset(this.bb_pos,6);return r?(e||new u.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*n),this.bb):null}subGraphSessionStatesLength(){let n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__vector_len(this.bb_pos+n):0}static startSessionState(n){n.startObject(2)}static addKernels(n,e){n.addFieldOffset(0,e,0)}static addSubGraphSessionStates(n,e){n.addFieldOffset(1,e,0)}static createSubGraphSessionStatesVector(n,e){n.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)n.addOffset(e[r]);return n.endVector()}static startSubGraphSessionStatesVector(n,e){n.startVector(4,e,4)}static endSessionState(n){return n.endObject()}static createSessionState(n,e,r){return c.startSessionState(n),c.addKernels(n,e),c.addSubGraphSessionStates(n,r),c.endSessionState(n)}}p.SessionState=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(u){(function(h){(function(p){class c{constructor(){this.bb=null,this.bb_pos=0}__init(n,e){return this.bb_pos=n,this.bb=e,this}static getRootAsInferenceSession(n,e){return(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static getSizePrefixedRootAsInferenceSession(n,e){return n.setPosition(n.position()+s.flatbuffers.SIZE_PREFIX_LENGTH),(e||new c).__init(n.readInt32(n.position())+n.position(),n)}static bufferHasIdentifier(n){return n.__has_identifier("ORTM")}ortVersion(n){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,n):null}model(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new u.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}sessionState(n){let e=this.bb.__offset(this.bb_pos,8);return e?(n||new u.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startInferenceSession(n){n.startObject(3)}static addOrtVersion(n,e){n.addFieldOffset(0,e,0)}static addModel(n,e){n.addFieldOffset(1,e,0)}static addSessionState(n,e){n.addFieldOffset(2,e,0)}static endInferenceSession(n){return n.endObject()}static finishInferenceSessionBuffer(n,e){n.finish(e,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(n,e){n.finish(e,"ORTM",!0)}static createInferenceSession(n,e,r,o){return c.startInferenceSession(n),c.addOrtVersion(n,e),c.addModel(n,r),c.addSessionState(n,o),c.endInferenceSession(n)}}p.InferenceSession=c})(h.fbs||(h.fbs={}))})(u.experimental||(u.experimental={}))}(t.onnxruntime||(t.onnxruntime={}))},7448:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxjsSessionHandler=void 0;const s=i(1670),a=i(9162);t.OnnxjsSessionHandler=class{constructor(d){this.session=d,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(d,u,h){const p=new Map;for(const n in d)if(Object.hasOwnProperty.call(d,n)){const e=d[n];p.set(n,new a.Tensor(e.dims,e.type,void 0,void 0,e.data))}const c=await this.session.run(p),l={};return c.forEach((n,e)=>{l[e]=new s.Tensor(n.type,n.data,n.dims)}),l}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6919:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Session=void 0;const s=i(7067),a=i(1296),d=i(7091),u=i(1036),h=i(6231),p=i(2644);t.Session=class{constructor(c={}){this._initialized=!1,this.backendHint=c.backendHint,this.profiler=h.Profiler.create(c.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(c,l,n){await this.profiler.event("session","Session.loadModel",async()=>{const e=await(0,d.resolveBackend)(this.backendHint);if(this.sessionHandler=e.createSessionHandler(this.context),this._model=new p.Model,typeof c=="string"){const r=c.endsWith(".ort");if(typeof fetch>"u"){const o=await(0,a.promisify)(s.readFile)(c);this.initialize(o,r)}else{const o=await fetch(c),f=await o.arrayBuffer();this.initialize(new Uint8Array(f),r)}}else if(ArrayBuffer.isView(c))this.initialize(c);else{const r=new Uint8Array(c,l||0,n||c.byteLength);this.initialize(r)}})}initialize(c,l){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(c,n,l),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new u.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(c){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const l=this.normalizeAndValidateInputs(c),n=await this._executionPlan.execute(this.sessionHandler,l);return this.createOutput(n)})}normalizeAndValidateInputs(c){const l=this._model.graph.getInputNames();if(Array.isArray(c)){if(c.length!==l.length)throw new Error(`incorrect input array length: expected ${l.length} but got ${c.length}`)}else{if(c.size!==l.length)throw new Error(`incorrect input map size: expected ${l.length} but got ${c.size}`);const n=new Array(c.size);let e=0;for(let r=0;rtypeof I=="string")))throw new TypeError("cache should be a string array");A&&(this.cache=new Array(S))}else{if(w!==void 0){const I=e(b);if(!(w instanceof I))throw new TypeError(`cache should be type ${I.name}`)}if(A){const I=new ArrayBuffer(S*function(x){switch(x){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${x}`)}}(b));this.cache=function(x,E){return new(e(E))(x)}(I,b)}}}static fromProto(g){if(!g)throw new Error("cannot construct Value from an empty tensor");const b=p.ProtoUtil.tensorDataTypeFromProto(g.dataType),_=p.ProtoUtil.tensorDimsFromProto(g.dims),y=new l(_,b);if(b==="string")g.stringData.forEach((w,v)=>{y.data[v]=(0,p.decodeUtf8String)(w)});else if(g.rawData&&typeof g.rawData.byteLength=="number"&&g.rawData.byteLength>0){const w=y.data,v=new DataView(g.rawData.buffer,g.rawData.byteOffset,g.rawData.byteLength),S=n(g.dataType),A=g.rawData.byteLength/S;if(g.rawData.byteLength%S!=0)throw new Error("invalid buffer length");if(w.length!==A)throw new Error("buffer length mismatch");for(let I=0;I0){const w=y.data,v=new DataView(g.rawDataArray().buffer,g.rawDataArray().byteOffset,g.rawDataLength()),S=n(g.dataType()),A=g.rawDataLength()/S;if(g.rawDataLength()%S!=0)throw new Error("invalid buffer length");if(w.length!==A)throw new Error("buffer length mismatch");for(let I=0;I1&&E>1)return;A[S-I]=Math.max(x,E)}return A}static index(b,_){const y=new Array(_.length);return c.fillIndex(b,_,y),y}static fillIndex(b,_,y){const w=b.length-_.length;for(let v=0;v<_.length;v++)y[v]=b[w+v]%_[v]}static calc(b,_,y,w,v){const S=c.calcShape(b.dims,_.dims);if(S){if(w&&!e.areEqual(S,b.dims))return;const A=e.size(S),I=w?b:new h.Tensor(S,v||b.type);if(S.length===0)I.set([],y(b.get([]),_.get([])));else{const x=new Array(S.length),E=new Array(b.dims.length),F=new Array(_.dims.length);let R,$=0,L=0,G=!1,D=!1;b.dims.length===0&&($=b.get([]),G=!0),_.dims.length===0&&(L=_.get([]),D=!0);for(let z=0;z=0;Z--)x[Z]=R%S[Z],R=Math.floor(R/S[Z]);G||(c.fillIndex(x,b.dims,E),$=b.get(E)),D||(c.fillIndex(x,_.dims,F),L=_.get(F)),I.set(x,y($,L))}}return I}}static isValidBroadcast(b,_){const y=b.length,w=_.length;if(y>w)return!1;for(let v=1;v<=y;v++)if(b[y-v]!==1&&b[y-v]!==_[w-v])return!1;return!0}static getBroadcastDims(b,_){const y=b.length,w=[];for(let v=0;v1&&A===1&&w.unshift(S)}return w}}t.BroadcastUtil=c,t.arrayCopyHelper=function(g,b,_,y,w){if(y<0||y>=b.length)throw new Error("sourceIndex out of bounds");if(_<0||_>=g.length)throw new Error("targetIndex out of bounds");if(y+w>b.length)throw new Error("source indices to be copied are outside bounds");if(_+w>g.length)throw new Error("target array is too small to hold result");for(let v=0;vd.default.isLong(_)?_.toNumber():_)}static tensorValueTypeFromProto(b){return{tensorType:l.tensorDataTypeFromProto(b.elemType),shape:{dims:l.tensorDimsFromProto(b.shape.dim.map(_=>_.dimValue))}}}static tensorDimsFromORTFormat(b){const _=[];for(let y=0;yb.length)throw new Error(`invalid dimension of ${_} for sizeFromDimension as Tensor has ${b.length} dimensions.`);return e.getSizeFromDimensionRange(b,_,b.length)}static sizeToDimension(b,_){if(_<0||_>b.length)throw new Error(`invalid dimension of ${_} for sizeToDimension as Tensor has ${b.length} dimensions.`);return e.getSizeFromDimensionRange(b,0,_)}static getSizeFromDimensionRange(b,_,y){let w=1;for(let v=_;v=0;--w)y[w]=y[w+1]*b[w+1];return y}static transpose(b){return b.slice().reverse()}static indicesToOffset(b,_,y){y===void 0&&(y=b.length);let w=0;for(let v=0;v=_)throw new Error("unsupported axis for this operation.");return b<0?b+_:b}static normalizeAxes(b,_){return b.map(y=>this.normalizeAxis(y,_))}static incrementIndex(b,_,y){if(_.length===0||b.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=_.length;else if(y<=0||y>_.length)throw new Error("Incorrect axis to increment on");for(let w=y-1;w>=0&&(b[w]++,!(b[w]<_[w]));--w)b[w]=0}static calculateReshapedDims(b,_){if(_.length===0){if(b.length===0||e.size(b)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const y=_.length,w=new Array(y);let v=-1,S=1;for(let I=0;I=b.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");w[I]=b[I]}else w[I]=_[I];S*=w[I]}}const A=e.size(b);if(v!==-1){if(A%S!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${b}] Output shape: [${_}]`);w[v]=A/S}else if(S!==A)throw new Error("reshapedDims and originalDims don't have matching sizes");return w}static sortBasedOnPerm(b,_){return _?_.map(y=>b[y]):b.slice().reverse()}static padShape(b,_){const y=b.length;return b.map((w,v)=>w+_[v]+_[v+y])}static areEqual(b,_){return b.length===_.length&&b.every((y,w)=>y===_[w])}static validateDimsAndCalcSize(b){if(b.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let _=1;for(const y of b){if(!Number.isInteger(y))throw new TypeError(`Invalid shape: ${y} is not an integer`);if(y<0||y>2147483647)throw new TypeError(`Invalid shape: length ${y} is not allowed`);_*=y}return _}static flattenShape(b,_){_<0&&(_+=b.length);const y=b.reduce((v,S)=>v*S,1),w=b.slice(_).reduce((v,S)=>v*S,1);return[y/w,w]}static squeezeShape(b,_){const y=new Array;_=e.normalizeAxes(_,b.length);for(let w=0;w=0;if(v&&b[w]!==1)throw new Error("squeeze an axis of size different than 1");(_.length===0&&b[w]>1||_.length>0&&!v)&&y.push(b[w])}return y}static unsqueezeShape(b,_){const y=new Array(b.length+_.length);y.fill(0);for(let v=0;v<_.length;v++){const S=e.normalizeAxis(_[v],y.length);if(S>=y.length)throw new Error("'axes' has an out of range axis");if(y[S]!==0)throw new Error("'axes' has a duplicate axis");y[S]=1}let w=0;for(let v=0;v=b.length)throw new Error("sourceIndex out of bounds");if(_<0||_>=g.length)throw new Error("targetIndex out of bounds");if(y+w>b.length)throw new Error("source indices to be copied are outside bounds");if(_+w>g.length)throw new Error("target array is too small to hold result");for(let v=0;v=b.length)throw new Error("sourceIndex out of bounds");if(_<0||_>=g.length)throw new Error("targetIndex out of bounds");if(y+w>b.length)throw new Error("source indices to be copied are outside bounds");if(_+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=b.length)throw new Error("sourceIndex out of bounds");if(_<0||_>=g.length)throw new Error("targetIndex out of bounds");if(y+w>b.length)throw new Error("source indices to be copied are outside bounds");if(_+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=b.length)throw new Error("sourceIndex out of bounds");if(_<0||_>=g.length)throw new Error("targetIndex out of bounds");if(y+w>b.length)throw new Error("source indices to be copied are outside bounds");if(_+w>g.length)throw new Error("target array is too small to hold result");for(let v=0;v_.push(L));const A=o.calcReduceShape(S,_,!0),I=e.size(A),x=new h.Tensor(A,b.type),E=e.computeStrides(A),F=e.computeStrides(S),R=new Array(S.length);for(let $=0;$=_.length)return S(b[v]);const x=_[w],E=x>=y.length?1:e.size(y.slice(x+1));for(let F=0;Fv!==0)}}t.ReduceUtil=o;class f{static adjustPoolAttributes(b,_,y,w,v,S){if(!b&&y.length!==_.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(b)for(let A=0;A<_.length-2;A++)A>=y.length?y.push(_[A+2]):y[A]=_[A+2];for(let A=0;A=y[A]||S[A+y.length]>=y[A])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(b,_,y,w,v,S){if(S){if(v.length!==2*(b.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(_.length!==b.length-2)throw new Error("length of strides should be the length of data dimensions");if(w.length!==b.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let A=0;A{Object.defineProperty(t,"__esModule",{value:!0}),t.iterateExtraOptions=void 0,t.iterateExtraOptions=(i,s,a,d)=>{if(typeof i=="object"&&i!==null){if(a.has(i))throw new Error("Circular reference in options");a.add(i)}Object.entries(i).forEach(([u,h])=>{const p=s?s+u:u;if(typeof h=="object")(0,t.iterateExtraOptions)(h,p+".",a,d);else if(typeof h=="string"||typeof h=="number")d(p,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);d(p,h?"1":"0")}})}},2157:function(m,t,i){var s,a=this&&this.__createBinding||(Object.create?function(E,F,R,$){$===void 0&&($=R);var L=Object.getOwnPropertyDescriptor(F,R);L&&!("get"in L?!F.__esModule:L.writable||L.configurable)||(L={enumerable:!0,get:function(){return F[R]}}),Object.defineProperty(E,$,L)}:function(E,F,R,$){$===void 0&&($=R),E[$]=F[R]}),d=this&&this.__setModuleDefault||(Object.create?function(E,F){Object.defineProperty(E,"default",{enumerable:!0,value:F})}:function(E,F){E.default=F}),u=this&&this.__importStar||function(E){if(E&&E.__esModule)return E;var F={};if(E!=null)for(var R in E)R!=="default"&&Object.prototype.hasOwnProperty.call(E,R)&&a(F,E,R);return d(F,E),F};Object.defineProperty(t,"__esModule",{value:!0}),t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=t.initWasm=void 0;const h=i(1670),p=u(i(349)),c=i(6361),l=()=>!!h.env.wasm.proxy&&typeof document<"u";let n,e,r,o=!1,f=!1,g=!1;const b=[],_=[],y=[],w=[],v=[],S=[],A=()=>{if(o||!f||g||!n)throw new Error("worker not ready")},I=E=>{switch(E.data.type){case"init-wasm":o=!1,E.data.err?(g=!0,e[1](E.data.err)):(f=!0,e[0]());break;case"init-ort":E.data.err?r[1](E.data.err):r[0]();break;case"create_allocate":E.data.err?b.shift()[1](E.data.err):b.shift()[0](E.data.out);break;case"create_finalize":E.data.err?_.shift()[1](E.data.err):_.shift()[0](E.data.out);break;case"create":E.data.err?y.shift()[1](E.data.err):y.shift()[0](E.data.out);break;case"release":E.data.err?w.shift()[1](E.data.err):w.shift()[0]();break;case"run":E.data.err?v.shift()[1](E.data.err):v.shift()[0](E.data.out);break;case"end-profiling":E.data.err?S.shift()[1](E.data.err):S.shift()[0]()}},x=typeof document<"u"?(s=document==null?void 0:document.currentScript)===null||s===void 0?void 0:s.src:void 0;t.initWasm=async()=>{if(l()){if(f)return;if(o)throw new Error("multiple calls to 'initWasm()' detected.");if(g)throw new Error("previous call to 'initWasm()' failed.");return o=!0,h.env.wasm.wasmPaths===void 0&&x&&x.indexOf("blob:")!==0&&(h.env.wasm.wasmPaths=x.substr(0,+x.lastIndexOf("/")+1)),new Promise((E,F)=>{n==null||n.terminate(),n=i(9710).Z(),n.onmessage=I,e=[E,F];const R={type:"init-wasm",in:h.env.wasm};n.postMessage(R)})}return(0,c.initializeWebAssembly)(h.env.wasm)},t.initOrt=async(E,F)=>{if(l())return A(),new Promise((R,$)=>{r=[R,$];const L={type:"init-ort",in:{numThreads:E,loggingLevel:F}};n.postMessage(L)});p.initOrt(E,F)},t.createSessionAllocate=async E=>l()?(A(),new Promise((F,R)=>{b.push([F,R]);const $={type:"create_allocate",in:{model:E}};n.postMessage($,[E.buffer])})):p.createSessionAllocate(E),t.createSessionFinalize=async(E,F)=>l()?(A(),new Promise((R,$)=>{_.push([R,$]);const L={type:"create_finalize",in:{modeldata:E,options:F}};n.postMessage(L)})):p.createSessionFinalize(E,F),t.createSession=async(E,F)=>l()?(A(),new Promise((R,$)=>{y.push([R,$]);const L={type:"create",in:{model:E,options:F}};n.postMessage(L,[E.buffer])})):p.createSession(E,F),t.releaseSession=async E=>{if(l())return A(),new Promise((F,R)=>{w.push([F,R]);const $={type:"release",in:E};n.postMessage($)});p.releaseSession(E)},t.run=async(E,F,R,$,L)=>l()?(A(),new Promise((G,D)=>{v.push([G,D]);const z={type:"run",in:{sessionId:E,inputIndices:F,inputs:R,outputIndices:$,options:L}};n.postMessage(z,p.extractTransferableBuffers(R))})):p.run(E,F,R,$,L),t.endProfiling=async E=>{if(l())return A(),new Promise((F,R)=>{S.push([F,R]);const $={type:"end-profiling",in:E};n.postMessage($)});p.endProfiling(E)}},586:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const s=i(7967),a=i(4983),d=i(6361);t.setRunOptions=u=>{const h=(0,d.getInstance)();let p=0;const c=[],l=u||{};try{if((u==null?void 0:u.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof u.logSeverityLevel!="number"||!Number.isInteger(u.logSeverityLevel)||u.logSeverityLevel<0||u.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${u.logSeverityLevel}`);if((u==null?void 0:u.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof u.logVerbosityLevel!="number"||!Number.isInteger(u.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${u.logVerbosityLevel}`);(u==null?void 0:u.terminate)===void 0&&(l.terminate=!1);let n=0;if((u==null?void 0:u.tag)!==void 0&&(n=(0,a.allocWasmString)(u.tag,c)),p=h._OrtCreateRunOptions(l.logSeverityLevel,l.logVerbosityLevel,!!l.terminate,n),p===0)throw new Error("Can't create run options");return(u==null?void 0:u.extra)!==void 0&&(0,s.iterateExtraOptions)(u.extra,"",new WeakSet,(e,r)=>{const o=(0,a.allocWasmString)(e,c),f=(0,a.allocWasmString)(r,c);if(h._OrtAddRunConfigEntry(p,o,f)!==0)throw new Error(`Can't set a run config entry: ${e} - ${r}`)}),[p,c]}catch(n){throw p!==0&&h._OrtReleaseRunOptions(p),c.forEach(h._free),n}}},2306:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxruntimeWebAssemblySessionHandler=void 0;const s=i(2806),a=i(1670),d=i(2850),u=i(2157);let h;t.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(p){const c=await fetch(p),l=await c.arrayBuffer();return(0,u.createSessionAllocate)(new Uint8Array(l))}async loadModel(p,c){if(h||(await(0,u.initOrt)(a.env.wasm.numThreads,(l=>{switch(l){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${l}`)}})(a.env.logLevel)),h=!0),typeof p=="string")if(typeof fetch>"u"){const l=await(0,d.promisify)(s.readFile)(p);[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSession)(l,c)}else{const l=await this.createSessionAllocate(p);[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSessionFinalize)(l,c)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,u.createSession)(p,c)}async dispose(){return(0,u.releaseSession)(this.sessionId)}async run(p,c,l){const n=[],e=[];Object.entries(p).forEach(g=>{const b=g[0],_=g[1],y=this.inputNames.indexOf(b);if(y===-1)throw new Error(`invalid input '${b}'`);n.push(_),e.push(y)});const r=[];Object.entries(c).forEach(g=>{const b=g[0],_=this.outputNames.indexOf(b);if(_===-1)throw new Error(`invalid output '${b}'`);r.push(_)});const o=await(0,u.run)(this.sessionId,e,n.map(g=>[g.type,g.dims,g.data]),r,l),f={};for(let g=0;g{Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const s=i(7967),a=i(4983),d=i(6361);t.setSessionOptions=u=>{const h=(0,d.getInstance)();let p=0;const c=[],l=u||{};(n=>{n.extra||(n.extra={}),n.extra.session||(n.extra.session={});const e=n.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(l);try{(u==null?void 0:u.graphOptimizationLevel)===void 0&&(l.graphOptimizationLevel="all");const n=(o=>{switch(o){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${o}`)}})(l.graphOptimizationLevel);(u==null?void 0:u.enableCpuMemArena)===void 0&&(l.enableCpuMemArena=!0),(u==null?void 0:u.enableMemPattern)===void 0&&(l.enableMemPattern=!0),(u==null?void 0:u.executionMode)===void 0&&(l.executionMode="sequential");const e=(o=>{switch(o){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${o}`)}})(l.executionMode);let r=0;if((u==null?void 0:u.logId)!==void 0&&(r=(0,a.allocWasmString)(u.logId,c)),(u==null?void 0:u.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof u.logSeverityLevel!="number"||!Number.isInteger(u.logSeverityLevel)||u.logSeverityLevel<0||u.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${u.logSeverityLevel}`);if((u==null?void 0:u.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof u.logVerbosityLevel!="number"||!Number.isInteger(u.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${u.logVerbosityLevel}`);if((u==null?void 0:u.enableProfiling)===void 0&&(l.enableProfiling=!1),p=h._OrtCreateSessionOptions(n,!!l.enableCpuMemArena,!!l.enableMemPattern,e,!!l.enableProfiling,0,r,l.logSeverityLevel,l.logVerbosityLevel),p===0)throw new Error("Can't create session options");return u!=null&&u.executionProviders&&((o,f,g)=>{for(const b of f){let _=typeof b=="string"?b:b.name;switch(_){case"xnnpack":_="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${_}`)}const y=(0,a.allocWasmString)(_,g);if((0,d.getInstance)()._OrtAppendExecutionProvider(o,y)!==0)throw new Error(`Can't append execution provider: ${_}`)}})(p,u.executionProviders,c),(u==null?void 0:u.extra)!==void 0&&(0,s.iterateExtraOptions)(u.extra,"",new WeakSet,(o,f)=>{const g=(0,a.allocWasmString)(o,c),b=(0,a.allocWasmString)(f,c);if(h._OrtAddSessionConfigEntry(p,g,b)!==0)throw new Error(`Can't set a session config entry: ${o} - ${f}`)}),[p,c]}catch(n){throw p!==0&&h._OrtReleaseSessionOptions(p),c.forEach(h._free),n}}},4983:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.allocWasmString=void 0;const s=i(6361);t.allocWasmString=(a,d)=>{const u=(0,s.getInstance)(),h=u.lengthBytesUTF8(a)+1,p=u._malloc(h);return u.stringToUTF8(a,p,h),d.push(p),p}},349:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=void 0;const s=i(586),a=i(4919),d=i(4983),u=i(6361);t.initOrt=(n,e)=>{const r=(0,u.getInstance)()._OrtInit(n,e);if(r!==0)throw new Error(`Can't initialize onnxruntime. error code = ${r}`)};const h=new Map;t.createSessionAllocate=n=>{const e=(0,u.getInstance)(),r=e._malloc(n.byteLength);return e.HEAPU8.set(n,r),[r,n.byteLength]},t.createSessionFinalize=(n,e)=>{const r=(0,u.getInstance)();let o=0,f=0,g=[];try{if([f,g]=(0,a.setSessionOptions)(e),o=r._OrtCreateSession(n[0],n[1],f),o===0)throw new Error("Can't create a session")}finally{r._free(n[0]),r._OrtReleaseSessionOptions(f),g.forEach(r._free)}const b=r._OrtGetInputCount(o),_=r._OrtGetOutputCount(o),y=[],w=[],v=[],S=[];for(let A=0;A{const r=(0,t.createSessionAllocate)(n);return(0,t.createSessionFinalize)(r,e)},t.releaseSession=n=>{const e=(0,u.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],f=r[1],g=r[2];f.forEach(e._OrtFree),g.forEach(e._OrtFree),e._OrtReleaseSession(o),h.delete(n)};const p=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${n}`)}},c=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${n}`)}},l=n=>{switch(n){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}};t.run=(n,e,r,o,f)=>{const g=(0,u.getInstance)(),b=h.get(n);if(!b)throw new Error("invalid session id");const _=b[0],y=b[1],w=b[2],v=e.length,S=o.length;let A=0,I=[];const x=[],E=[];try{[A,I]=(0,s.setRunOptions)(f);for(let D=0;Dg.HEAP32[ve++]=ye);const se=g._OrtCreateTensor(p(z),J,ee,Se,Z.length);if(se===0)throw new Error("Can't create a tensor");x.push(se)}finally{g.stackRestore(ue)}}const F=g.stackSave(),R=g.stackAlloc(4*v),$=g.stackAlloc(4*v),L=g.stackAlloc(4*S),G=g.stackAlloc(4*S);try{let D=R/4,z=$/4,Z=L/4,X=G/4;for(let ue=0;ueAe*je);if(ye=c(Ne),ye==="string"){const Ae=[];let je=be/4;for(let Ge=0;Ge{const e=(0,u.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],f=e._OrtEndProfiling(o);if(f===0)throw new Error("Can't get an profile file name");e._OrtFree(f)},t.extractTransferableBuffers=n=>{const e=[];for(const r of n){const o=r[2];!Array.isArray(o)&&o.buffer&&e.push(o.buffer)}return e}},6361:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(f,g,b,_){_===void 0&&(_=b);var y=Object.getOwnPropertyDescriptor(g,b);y&&!("get"in y?!g.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return g[b]}}),Object.defineProperty(f,_,y)}:function(f,g,b,_){_===void 0&&(_=b),f[_]=g[b]}),a=this&&this.__setModuleDefault||(Object.create?function(f,g){Object.defineProperty(f,"default",{enumerable:!0,value:g})}:function(f,g){f.default=g}),d=this&&this.__importStar||function(f){if(f&&f.__esModule)return f;var g={};if(f!=null)for(var b in f)b!=="default"&&Object.prototype.hasOwnProperty.call(f,b)&&s(g,f,b);return a(g,f),g},u=this&&this.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const h=d(i(6449)),p=u(i(932)),c=i(3474);let l,n=!1,e=!1,r=!1;const o=(f,g)=>g?f?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":f?"ort-wasm-simd.wasm":"ort-wasm.wasm";t.initializeWebAssembly=async f=>{if(n)return Promise.resolve();if(e)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(r)throw new Error("previous call to 'initializeWebAssembly()' failed.");e=!0;const g=f.initTimeout,b=f.numThreads,_=f.simd,y=b>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),w=_&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),v=typeof f.wasmPaths=="string"?f.wasmPaths:void 0,S=o(!1,y),A=o(w,y),I=typeof f.wasmPaths=="object"?f.wasmPaths[A]:void 0;let x=!1;const E=[];if(g>0&&E.push(new Promise(F=>{setTimeout(()=>{x=!0,F()},g)})),E.push(new Promise((F,R)=>{const $=y?c:p.default,L={locateFile:(G,D)=>y&&G.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([i(4154)],{type:"text/javascript"})):G===S?I??(v??D)+A:D+G};if(y)if(typeof Blob>"u")L.mainScriptUrlOrBlob=h.join("/","ort-wasm-threaded.js");else{const G=`var ortWasmThreaded=(function(){var _scriptDir;return ${$.toString()}})();`;L.mainScriptUrlOrBlob=new Blob([G],{type:"text/javascript"})}$(L).then(G=>{e=!1,n=!0,l=G,F()},G=>{e=!1,r=!0,R(G)})})),await Promise.race(E),x)throw new Error(`WebAssembly backend initializing failed due to timeout: ${g}ms`)},t.getInstance=()=>{if(n&&l)return l;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var f;!n||e||r||(e=!0,(f=l.PThread)===null||f===void 0||f.terminateAllThreads(),l=void 0,e=!1,n=!1,r=!0)}},9710:(m,t,i)=>{i.d(t,{Z:()=>d});var s=i(477),a=i.n(s);function d(){return a()('/*!\n* ONNX Runtime Web v1.14.0\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var t={474:(t,e,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){function e(){return j.buffer!=D&&N(j.buffer),P}function r(){return j.buffer!=D&&N(j.buffer),U}function a(){return j.buffer!=D&&N(j.buffer),F}function i(){return j.buffer!=D&&N(j.buffer),I}function o(){return j.buffer!=D&&N(j.buffer),W}var u,c,s;t=t||{},u||(u=void 0!==t?t:{}),u.ready=new Promise((function(t,e){c=t,s=e}));var l,f,p,h,d,y,b=Object.assign({},u),m="./this.program",g=(t,e)=>{throw e},v="object"==typeof window,w="function"==typeof importScripts,_="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,O=u.ENVIRONMENT_IS_PTHREAD||!1,A="";function S(t){return u.locateFile?u.locateFile(t,A):A+t}if(_){let e;A=w?n(908).dirname(A)+"/":"//",y=()=>{d||(h=n(384),d=n(908))},l=function(t,e){return y(),t=d.normalize(t),h.readFileSync(t,e?void 0:"utf8")},p=t=>((t=l(t,!0)).buffer||(t=new Uint8Array(t)),t),f=(t,e,n)=>{y(),t=d.normalize(t),h.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(Q())throw process.exitCode=t,e;e instanceof ct||x("exiting due to exception: "+e),process.exit(t)},u.inspect=function(){return"[Emscripten Module object]"};try{e=n(925)}catch(t){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),t}n.g.Worker=e.Worker}else(v||w)&&(w?A=self.location.href:"undefined"!=typeof document&&document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),A=0!==A.indexOf("blob:")?A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):"",_||(l=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},w&&(p=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),f=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)}));_&&"undefined"==typeof performance&&(n.g.performance=n(953).performance);var T=console.log.bind(console),E=console.warn.bind(console);_&&(y(),T=t=>h.writeSync(1,t+"\\n"),E=t=>h.writeSync(2,t+"\\n"));var M,C=u.print||T,x=u.printErr||E;Object.assign(u,b),b=null,u.thisProgram&&(m=u.thisProgram),u.quit&&(g=u.quit),u.wasmBinary&&(M=u.wasmBinary);var R=u.noExitRuntime||!1;"object"!=typeof WebAssembly&&at("no native wasm support detected");var j,k,D,P,U,F,I,W,H=!1,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function Y(t,e){return(t>>>=0)?z(r(),t,e):""}function B(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function G(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function N(t){D=t,u.HEAP8=P=new Int8Array(t),u.HEAP16=new Int16Array(t),u.HEAP32=F=new Int32Array(t),u.HEAPU8=U=new Uint8Array(t),u.HEAPU16=new Uint16Array(t),u.HEAPU32=I=new Uint32Array(t),u.HEAPF32=new Float32Array(t),u.HEAPF64=W=new Float64Array(t)}O&&(D=u.buffer);var V=u.INITIAL_MEMORY||16777216;if(O)j=u.wasmMemory,D=u.buffer;else if(u.wasmMemory)j=u.wasmMemory;else if(!((j=new WebAssembly.Memory({initial:V/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw x("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),_&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");j&&(D=j.buffer),V=D.byteLength,N(D);var $,q=[],X=[],J=[],Z=[];function Q(){return R||!1}function K(){var t=u.preRun.shift();q.unshift(t)}var tt,et=0,nt=null,rt=null;function at(t){throw O?postMessage({cmd:"onAbort",arg:t}):u.onAbort&&u.onAbort(t),x(t="Aborted("+t+")"),H=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),s(t),t}function it(){return tt.startsWith("data:application/octet-stream;base64,")}function ot(){var t=tt;try{if(t==tt&&M)return new Uint8Array(M);if(p)return p(t);throw"both async and sync fetching of the wasm failed"}catch(t){at(t)}}tt="ort-wasm-threaded.wasm",it()||(tt=S(tt));var ut={};function ct(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function st(t){(t=ht.Vb[t])||at(),ht.mc(t)}function lt(t){var e=ht.Cc();if(!e)return 6;ht.ac.push(e),ht.Vb[t.Ub]=e,e.Ub=t.Ub;var n={cmd:"run",start_routine:t.Ic,arg:t.zc,pthread_ptr:t.Ub};return e.$b=()=>{n.time=performance.now(),e.postMessage(n,t.Nc)},e.loaded&&(e.$b(),delete e.$b),0}function ft(t){if(O)return $t(1,1,t);Q()||(ht.oc(),u.onExit&&u.onExit(t),H=!0),g(t,new ct(t))}function pt(t,e){if(!e&&O)throw bt(t),"unwind";Q()||O||(me(),dt(J),be(0),re[1].length&&ae(1,10),re[2].length&&ae(2,10),ht.oc()),ft(t)}var ht={Yb:[],ac:[],qc:[],Vb:{},fc:function(){O&&ht.Ec()},Pc:function(){},Ec:function(){ht.receiveObjectTransfer=ht.Gc,ht.threadInitTLS=ht.pc,ht.setExitStatus=ht.nc,R=!1},nc:function(){},oc:function(){for(var t of Object.values(ht.Vb))ht.mc(t);for(t of ht.Yb)t.terminate();ht.Yb=[]},mc:function(t){var e=t.Ub;delete ht.Vb[e],ht.Yb.push(t),ht.ac.splice(ht.ac.indexOf(t),1),t.Ub=0,Oe(e)},Gc:function(){},pc:function(){ht.qc.forEach((t=>t()))},Fc:function(t,e){t.onmessage=n=>{var r=(n=n.data).cmd;if(t.Ub&&(ht.Bc=t.Ub),n.targetThread&&n.targetThread!=he()){var a=ht.Vb[n.Qc];a?a.postMessage(n,n.transferList):x(\'Internal error! Worker sent a message "\'+r+\'" to target pthread \'+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?zt(n.queue):"spawnThread"===r?lt(n):"cleanupThread"===r?st(n.thread):"killThread"===r?(n=n.thread,r=ht.Vb[n],delete ht.Vb[n],r.terminate(),Oe(n),ht.ac.splice(ht.ac.indexOf(r),1),r.Ub=0):"cancelThread"===r?ht.Vb[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(t.loaded=!0,e&&e(t),t.$b&&(t.$b(),delete t.$b)):"print"===r?C("Thread "+n.threadId+": "+n.text):"printErr"===r?x("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?t.postMessage(n):"onAbort"===r?u.onAbort&&u.onAbort(n.arg):r&&x("worker sent an unknown command "+r);ht.Bc=void 0},t.onerror=t=>{throw x("worker sent an error! "+t.filename+":"+t.lineno+": "+t.message),t},_&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){}))),t.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||_scriptDir,wasmMemory:j,wasmModule:k})},yc:function(){var t=S("ort-wasm-threaded.worker.js");ht.Yb.push(new Worker(t))},Cc:function(){return 0==ht.Yb.length&&(ht.yc(),ht.Fc(ht.Yb[0])),ht.Yb.pop()}};function dt(t){for(;0>2>>>0];t=a()[t+48>>2>>>0],Te(e,e-t),Me(e)};var mt=[];function gt(t){var e=mt[t];return e||(t>=mt.length&&(mt.length=t+1),mt[t]=e=$.get(t)),e}u.invokeEntryPoint=function(t,e){t=gt(t)(e),Q()?ht.nc(t):Ae(t)};var vt,wt,_t=[],Ot=0,At=0;function St(t){this.Zb=t,this.Sb=t-24,this.xc=function(t){i()[this.Sb+4>>2>>>0]=t},this.bc=function(){return i()[this.Sb+4>>2>>>0]},this.wc=function(t){i()[this.Sb+8>>2>>>0]=t},this.Dc=function(){return i()[this.Sb+8>>2>>>0]},this.rc=function(){a()[this.Sb>>2>>>0]=0},this.hc=function(t){t=t?1:0,e()[this.Sb+12>>0>>>0]=t},this.uc=function(){return 0!=e()[this.Sb+12>>0>>>0]},this.ic=function(t){t=t?1:0,e()[this.Sb+13>>0>>>0]=t},this.kc=function(){return 0!=e()[this.Sb+13>>0>>>0]},this.fc=function(t,e){this.cc(0),this.xc(t),this.wc(e),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(a(),this.Sb>>2,1)},this.Hc=function(){return 1===Atomics.sub(a(),this.Sb>>2,1)},this.cc=function(t){i()[this.Sb+16>>2>>>0]=t},this.tc=function(){return i()[this.Sb+16>>2>>>0]},this.vc=function(){if(Re(this.bc()))return i()[this.Zb>>2>>>0];var t=this.tc();return 0!==t?t:this.Zb}}function Tt(t){return ye(new St(t).Sb)}function Et(t,e,n,r){return O?$t(3,1,t,e,n,r):Mt(t,e,n,r)}function Mt(t,e,n,r){if("undefined"==typeof SharedArrayBuffer)return x("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return O&&0===a.length?Et(t,e,n,r):(t={Ic:n,Ub:t,zc:r,Nc:a},O?(t.Oc="spawnThread",postMessage(t,a),0):lt(t))}function Ct(t,e,n){return O?$t(4,1,t,e,n):0}function xt(t,e){if(O)return $t(5,1,t,e)}function Rt(t,e){if(O)return $t(6,1,t,e)}function jt(t,e,n){if(O)return $t(7,1,t,e,n)}function kt(t,e,n){return O?$t(8,1,t,e,n):0}function Dt(t,e){if(O)return $t(9,1,t,e)}function Pt(t,e,n){if(O)return $t(10,1,t,e,n)}function Ut(t,e,n,r){if(O)return $t(11,1,t,e,n,r)}function Ft(t,e,n,r){if(O)return $t(12,1,t,e,n,r)}function It(t,e,n,r){if(O)return $t(13,1,t,e,n,r)}function Wt(t){if(O)return $t(14,1,t)}function Ht(t,e){if(O)return $t(15,1,t,e)}function Lt(t,e,n){if(O)return $t(16,1,t,e,n)}function zt(t){Atomics.store(a(),t>>2,1),he()&&_e(t),Atomics.compareExchange(a(),t>>2,1,0)}function Yt(t){return i()[t>>>2]+4294967296*a()[t+4>>>2]}function Bt(t,e,n,r,a,i){return O?$t(17,1,t,e,n,r,a,i):-52}function Gt(t,e,n,r,a,i){if(O)return $t(18,1,t,e,n,r,a,i)}function Nt(t){var n=G(t)+1,r=de(n);return r&&B(t,e(),r,n),r}function Vt(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}if(O)return $t(19,1,t,e,n);var o=(new Date).getFullYear(),u=new Date(o,0,1),c=new Date(o,6,1);o=u.getTimezoneOffset();var s=c.getTimezoneOffset(),l=Math.max(o,s);a()[t>>2>>>0]=60*l,a()[e>>2>>>0]=Number(o!=s),t=r(u),e=r(c),t=Nt(t),e=Nt(e),s>2>>>0]=t,i()[n+4>>2>>>0]=e):(i()[n>>2>>>0]=e,i()[n+4>>2>>>0]=t)}function $t(t,e){var n=arguments.length-2,r=arguments;return yt((()=>{for(var a=Ce(8*n),i=a>>3,u=0;u>>0]=c}return we(t,n,a,e)}))}u.executeNotifiedProxyingQueue=zt,wt=_?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:O?()=>performance.now()-u.__performance_now_clock_drift:()=>performance.now();var qt,Xt=[],Jt={};function Zt(){if(!qt){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"};for(t in Jt)void 0===Jt[t]?delete e[t]:e[t]=Jt[t];var n=[];for(t in e)n.push(t+"="+e[t]);qt=n}return qt}function Qt(t,n){if(O)return $t(20,1,t,n);var r=0;return Zt().forEach((function(a,o){var u=n+r;for(o=i()[t+4*o>>2>>>0]=u,u=0;u>0>>>0]=a.charCodeAt(u);e()[o>>0>>>0]=0,r+=a.length+1})),0}function Kt(t,e){if(O)return $t(21,1,t,e);var n=Zt();i()[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),i()[e>>2>>>0]=r,0}function te(t){return O?$t(22,1,t):52}function ee(t,e,n,r){return O?$t(23,1,t,e,n,r):52}function ne(t,e,n,r,a){return O?$t(24,1,t,e,n,r,a):70}var re=[null,[],[]];function ae(t,e){var n=re[t];0===e||10===e?((1===t?C:x)(z(n,0)),n.length=0):n.push(e)}function ie(t,e,n,a){if(O)return $t(25,1,t,e,n,a);for(var o=0,u=0;u>2>>>0],s=i()[e+4>>2>>>0];e+=8;for(var l=0;l>>0]);o+=s}return i()[a>>2>>>0]=o,0}var oe=0;function ue(t){return 0==t%4&&(0!=t%100||0==t%400)}var ce=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function le(t,n,r,i){function o(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=s(new Date(t.getFullYear(),0,4)),n=s(n),0>=c(e,t)?0>=c(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var f=a()[i+40>>2>>>0];for(var p in i={Lc:a()[i>>2>>>0],Kc:a()[i+4>>2>>>0],dc:a()[i+8>>2>>>0],jc:a()[i+12>>2>>>0],ec:a()[i+16>>2>>>0],Xb:a()[i+20>>2>>>0],Tb:a()[i+24>>2>>>0],Wb:a()[i+28>>2>>>0],Rc:a()[i+32>>2>>>0],Jc:a()[i+36>>2>>>0],Mc:f?Y(f):""},r=Y(r),f={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(p,"g"),f[p]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(p in f={"%a":function(t){return h[t.Tb].substring(0,3)},"%A":function(t){return h[t.Tb]},"%b":function(t){return d[t.ec].substring(0,3)},"%B":function(t){return d[t.ec]},"%C":function(t){return u((t.Xb+1900)/100|0,2)},"%d":function(t){return u(t.jc,2)},"%e":function(t){return o(t.jc,2," ")},"%g":function(t){return l(t).toString().substring(2)},"%G":function(t){return l(t)},"%H":function(t){return u(t.dc,2)},"%I":function(t){return 0==(t=t.dc)?t=12:12t.dc?"AM":"PM"},"%S":function(t){return u(t.Lc,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Tb||7},"%U":function(t){return u(Math.floor((t.Wb+7-t.Tb)/7),2)},"%V":function(t){var e=Math.floor((t.Wb+7-(t.Tb+6)%7)/7);if(2>=(t.Tb+371-t.Wb-2)%7&&e++,e)53==e&&(4==(n=(t.Tb+371-t.Wb)%7)||3==n&&ue(t.Xb)||(e=1));else{e=52;var n=(t.Tb+7-t.Wb-1)%7;(4==n||5==n&&ue(t.Xb%400-1))&&e++}return u(e,2)},"%w":function(t){return t.Tb},"%W":function(t){return u(Math.floor((t.Wb+7-(t.Tb+6)%7)/7),2)},"%y":function(t){return(t.Xb+1900).toString().substring(2)},"%Y":function(t){return t.Xb+1900},"%z":function(t){var e=0<=(t=t.Jc);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.Mc},"%%":function(){return"%"}},r=r.replace(/%%/g,"\\0\\0"),f)r.includes(p)&&(r=r.replace(new RegExp(p,"g"),f[p](i)));return p=function(t){var e=Array(G(t)+1);return B(t,e,0,e.length),e}(r=r.replace(/\\0\\0/g,"%")),p.length>n?0:(function(t,n){e().set(t,n>>>0)}(p,t),p.length-1)}ht.fc();var fe=[null,ft,bt,Et,Ct,xt,Rt,jt,kt,Dt,Pt,Ut,Ft,It,Wt,Ht,Lt,Bt,Gt,Vt,Qt,Kt,te,ee,ne,ie],pe={b:function(t){return de(t+24)+24},n:function(t){return(t=new St(t)).uc()||(t.hc(!0),Ot--),t.ic(!1),_t.push(t),t.sc(),t.vc()},ma:function(t){throw x("Unexpected exception thrown, this is not properly supported - aborting"),H=!0,t},x:function(){Se(0);var t=_t.pop();if(t.Hc()&&!t.kc()){var e=t.Dc();e&>(e)(t.Zb),Tt(t.Zb)}At=0},e:function(){var t=At;if(!t)return oe=0;var e=new St(t);e.cc(t);var n=e.bc();if(!n)return oe=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;azt(r)));else if(O)postMessage({targetThread:t,cmd:"processProxyingQueue",queue:r});else{if(!(t=ht.Vb[t]))return;t.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},Ea:function(){return-1},Pa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getUTCSeconds(),a()[e+4>>2>>>0]=t.getUTCMinutes(),a()[e+8>>2>>>0]=t.getUTCHours(),a()[e+12>>2>>>0]=t.getUTCDate(),a()[e+16>>2>>>0]=t.getUTCMonth(),a()[e+20>>2>>>0]=t.getUTCFullYear()-1900,a()[e+24>>2>>>0]=t.getUTCDay(),t=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[e+28>>2>>>0]=t},Qa:function(t,e){t=new Date(1e3*Yt(t)),a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getFullYear()-1900,a()[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1),r=(t.getTime()-n.getTime())/864e5|0;a()[e+28>>2>>>0]=r,a()[e+36>>2>>>0]=-60*t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset(),t=0|(r!=(n=n.getTimezoneOffset())&&t.getTimezoneOffset()==Math.min(n,r)),a()[e+32>>2>>>0]=t},Ra:function(t){var e=new Date(a()[t+20>>2>>>0]+1900,a()[t+16>>2>>>0],a()[t+12>>2>>>0],a()[t+8>>2>>>0],a()[t+4>>2>>>0],a()[t>>2>>>0],0),n=a()[t+32>>2>>>0],r=e.getTimezoneOffset(),i=new Date(e.getFullYear(),0,1),o=new Date(e.getFullYear(),6,1).getTimezoneOffset(),u=i.getTimezoneOffset(),c=Math.min(u,o);return 0>n?a()[t+32>>2>>>0]=Number(o!=u&&c==r):0>2>>>0]=e.getDay(),n=(e.getTime()-i.getTime())/864e5|0,a()[t+28>>2>>>0]=n,a()[t>>2>>>0]=e.getSeconds(),a()[t+4>>2>>>0]=e.getMinutes(),a()[t+8>>2>>>0]=e.getHours(),a()[t+12>>2>>>0]=e.getDate(),a()[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},Aa:Bt,Ba:Gt,Sa:function t(e,n,r){t.Ac||(t.Ac=!0,Vt(e,n,r))},y:function(){at("")},U:function(){if(!_&&!w){var t="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";vt||(vt={}),vt[t]||(vt[t]=1,_&&(t="warning: "+t),x(t))}},ra:function(){return 4294901760},B:wt,Ia:function(t,e,n){r().copyWithin(t>>>0,e>>>0,e+n>>>0)},F:function(){return _?n(993).cpus().length:navigator.hardwareConcurrency},Da:function(t,e,n){Xt.length=e,n>>=3;for(var r=0;r>>0];return(0>t?ut[-t-1]:fe[t]).apply(null,Xt)},qa:function(t){var e=r().length;if((t>>>=0)<=e||4294901760=n;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var i=Math;a=Math.max(t,a),i=i.min.call(i,4294901760,a+(65536-a%65536)%65536);t:{try{j.grow(i-D.byteLength+65535>>>16),N(j.buffer);var o=1;break t}catch(t){}o=void 0}if(o)return!0}return!1},Na:function(){throw"unwind"},Ga:Qt,Ha:Kt,J:pt,I:te,S:ee,ga:ne,R:ie,d:function(){return oe},na:function t(r,a){t.lc||(t.lc=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(_)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>at("randomDevice")}());for(var i=0;i>0>>>0]=t.lc();return 0},ia:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ja:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},K:function(t){var e=Ee();try{return gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},f:function(t,e){var n=Ee();try{return gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},P:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},Q:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},k:function(t,e,n){var r=Ee();try{return gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},p:function(t,e,n,r){var a=Ee();try{return gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},q:function(t,e,n,r,a){var i=Ee();try{return gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},N:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},s:function(t,e,n,r,a,i){var o=Ee();try{return gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},w:function(t,e,n,r,a,i,o){var u=Ee();try{return gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},L:function(t,e,n,r,a,i,o,u){var c=Ee();try{return gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},E:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{return gt(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=Ee();try{return He(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},_:function(t,e,n,r,a,i,o){var u=Ee();try{return ke(t,e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},Z:function(t,e,n,r,a){var i=Ee();try{return Le(t,e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},ca:function(t,e,n,r){var a=Ee();try{return Ie(t,e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},$:function(t){var e=Ee();try{return je(t)}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},ba:function(t,e){var n=Ee();try{return We(t,e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},Y:function(t,e,n){var r=Ee();try{return De(t,e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},g:function(t){var e=Ee();try{gt(t)()}catch(t){if(Me(e),t!==t+0)throw t;Se(1,0)}},r:function(t,e){var n=Ee();try{gt(t)(e)}catch(t){if(Me(n),t!==t+0)throw t;Se(1,0)}},i:function(t,e,n){var r=Ee();try{gt(t)(e,n)}catch(t){if(Me(r),t!==t+0)throw t;Se(1,0)}},ha:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},m:function(t,e,n,r){var a=Ee();try{gt(t)(e,n,r)}catch(t){if(Me(a),t!==t+0)throw t;Se(1,0)}},v:function(t,e,n,r,a){var i=Ee();try{gt(t)(e,n,r,a)}catch(t){if(Me(i),t!==t+0)throw t;Se(1,0)}},u:function(t,e,n,r,a,i){var o=Ee();try{gt(t)(e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},O:function(t,e,n,r,a,i,o){var u=Ee();try{gt(t)(e,n,r,a,i,o)}catch(t){if(Me(u),t!==t+0)throw t;Se(1,0)}},A:function(t,e,n,r,a,i,o,u){var c=Ee();try{gt(t)(e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},ka:function(t,e,n,r,a,i,o,u,c){var s=Ee();try{gt(t)(e,n,r,a,i,o,u,c)}catch(t){if(Me(s),t!==t+0)throw t;Se(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l){var f=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(Me(f),t!==t+0)throw t;Se(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=Ee();try{gt(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(Me(b),t!==t+0)throw t;Se(1,0)}},fa:function(t,e,n,r,a,i,o,u){var c=Ee();try{Pe(t,e,n,r,a,i,o,u)}catch(t){if(Me(c),t!==t+0)throw t;Se(1,0)}},da:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=Ee();try{Fe(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(Me(p),t!==t+0)throw t;Se(1,0)}},ea:function(t,e,n,r,a,i){var o=Ee();try{Ue(t,e,n,r,a,i)}catch(t){if(Me(o),t!==t+0)throw t;Se(1,0)}},o:function(t){return t},a:j||u.wasmMemory,G:function(t){oe=t},la:le,z:function(t,e,n,r){return le(t,e,n,r)}};!function(){function t(t,e){u.asm=t.exports,ht.qc.push(u.asm.sb),$=u.asm.ub,X.unshift(u.asm.Va),k=e,O||(et--,u.monitorRunDependencies&&u.monitorRunDependencies(et),0==et&&(null!==nt&&(clearInterval(nt),nt=null),rt&&(t=rt,rt=null,t())))}function e(e){t(e.instance,e.module)}function n(t){return function(){if(!M&&(v||w)){if("function"==typeof fetch&&!tt.startsWith("file://"))return fetch(tt,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+tt+"\'";return t.arrayBuffer()})).catch((function(){return ot()}));if(f)return new Promise((function(t,e){f(tt,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return ot()}))}().then((function(t){return WebAssembly.instantiate(t,r)})).then((function(t){return t})).then(t,(function(t){x("failed to asynchronously prepare wasm: "+t),at(t)}))}var r={a:pe};if(O||(et++,u.monitorRunDependencies&&u.monitorRunDependencies(et)),u.instantiateWasm)try{return u.instantiateWasm(r,t)}catch(t){return x("Module.instantiateWasm callback failed with error: "+t),!1}(M||"function"!=typeof WebAssembly.instantiateStreaming||it()||tt.startsWith("file://")||_||"function"!=typeof fetch?n(e):fetch(tt,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(e,(function(t){return x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation"),n(e)}))}))).catch(s)}(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.Va).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.Wa).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.Xa).apply(null,arguments)},u._OrtAppendExecutionProvider=function(){return(u._OrtAppendExecutionProvider=u.asm.Ya).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.Za).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm._a).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.$a).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.ab).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.bb).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.cb).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.db).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.eb).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.fb).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.gb).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.hb).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm.ib).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.jb).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.kb).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.lb).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.mb).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.nb).apply(null,arguments)};var he=u._pthread_self=function(){return(he=u._pthread_self=u.asm.ob).apply(null,arguments)},de=u._malloc=function(){return(de=u._malloc=u.asm.pb).apply(null,arguments)},ye=u._free=function(){return(ye=u._free=u.asm.qb).apply(null,arguments)},be=u._fflush=function(){return(be=u._fflush=u.asm.rb).apply(null,arguments)};u.__emscripten_tls_init=function(){return(u.__emscripten_tls_init=u.asm.sb).apply(null,arguments)};var me=u.___funcs_on_exit=function(){return(me=u.___funcs_on_exit=u.asm.tb).apply(null,arguments)},ge=u.__emscripten_thread_init=function(){return(ge=u.__emscripten_thread_init=u.asm.vb).apply(null,arguments)};u.__emscripten_thread_crashed=function(){return(u.__emscripten_thread_crashed=u.asm.wb).apply(null,arguments)};var ve,we=u._emscripten_run_in_main_runtime_thread_js=function(){return(we=u._emscripten_run_in_main_runtime_thread_js=u.asm.xb).apply(null,arguments)},_e=u.__emscripten_proxy_execute_task_queue=function(){return(_e=u.__emscripten_proxy_execute_task_queue=u.asm.yb).apply(null,arguments)},Oe=u.__emscripten_thread_free_data=function(){return(Oe=u.__emscripten_thread_free_data=u.asm.zb).apply(null,arguments)},Ae=u.__emscripten_thread_exit=function(){return(Ae=u.__emscripten_thread_exit=u.asm.Ab).apply(null,arguments)},Se=u._setThrew=function(){return(Se=u._setThrew=u.asm.Bb).apply(null,arguments)},Te=u._emscripten_stack_set_limits=function(){return(Te=u._emscripten_stack_set_limits=u.asm.Cb).apply(null,arguments)},Ee=u.stackSave=function(){return(Ee=u.stackSave=u.asm.Db).apply(null,arguments)},Me=u.stackRestore=function(){return(Me=u.stackRestore=u.asm.Eb).apply(null,arguments)},Ce=u.stackAlloc=function(){return(Ce=u.stackAlloc=u.asm.Fb).apply(null,arguments)},xe=u.___cxa_can_catch=function(){return(xe=u.___cxa_can_catch=u.asm.Gb).apply(null,arguments)},Re=u.___cxa_is_pointer_type=function(){return(Re=u.___cxa_is_pointer_type=u.asm.Hb).apply(null,arguments)},je=u.dynCall_j=function(){return(je=u.dynCall_j=u.asm.Ib).apply(null,arguments)},ke=u.dynCall_iiiiij=function(){return(ke=u.dynCall_iiiiij=u.asm.Jb).apply(null,arguments)},De=u.dynCall_jii=function(){return(De=u.dynCall_jii=u.asm.Kb).apply(null,arguments)},Pe=u.dynCall_viiiiij=function(){return(Pe=u.dynCall_viiiiij=u.asm.Lb).apply(null,arguments)},Ue=u.dynCall_vjji=function(){return(Ue=u.dynCall_vjji=u.asm.Mb).apply(null,arguments)},Fe=u.dynCall_viiijjjii=function(){return(Fe=u.dynCall_viiijjjii=u.asm.Nb).apply(null,arguments)},Ie=u.dynCall_iij=function(){return(Ie=u.dynCall_iij=u.asm.Ob).apply(null,arguments)},We=u.dynCall_ji=function(){return(We=u.dynCall_ji=u.asm.Pb).apply(null,arguments)},He=u.dynCall_iiiiiij=function(){return(He=u.dynCall_iiiiiij=u.asm.Qb).apply(null,arguments)},Le=u.dynCall_iiij=function(){return(Le=u.dynCall_iiij=u.asm.Rb).apply(null,arguments)};function ze(){function t(){if(!ve&&(ve=!0,u.calledRun=!0,!H)&&(O||dt(X),c(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),!O)){if(u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;){var t=u.postRun.shift();Z.unshift(t)}dt(Z)}}if(!(0{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(t){var e,r,a;t=t||{},e||(e=void 0!==t?t:{}),e.ready=new Promise((function(t,e){r=t,a=e}));var i,o,u,c,s,l,f=Object.assign({},e),p="./this.program",h=(t,e)=>{throw e},d="object"==typeof window,y="function"==typeof importScripts,b="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,m="";b?(m=y?n(908).dirname(m)+"/":"//",l=()=>{s||(c=n(384),s=n(908))},i=function(t,e){return l(),t=s.normalize(t),c.readFileSync(t,e?void 0:"utf8")},u=t=>((t=i(t,!0)).buffer||(t=new Uint8Array(t)),t),o=(t,e,n)=>{l(),t=s.normalize(t),c.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1{if(_||0{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},y&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),o=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var g,v=e.print||console.log.bind(console),w=e.printErr||console.warn.bind(console);Object.assign(e,f),f=null,e.thisProgram&&(p=e.thisProgram),e.quit&&(h=e.quit),e.wasmBinary&&(g=e.wasmBinary);var _=e.noExitRuntime||!1;"object"!=typeof WebAssembly&&V("no native wasm support detected");var O,A,S,T,E,M,C=!1,x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function R(t,e,n){var r=(e>>>=0)+n;for(n=e;t[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&t[e++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function j(t,e){return(t>>>=0)?R(T,t,e):""}function k(t,e,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),127>=o){if(n>=r)break;e[n++>>>0]=o}else{if(2047>=o){if(n+1>=r)break;e[n++>>>0]=192|o>>6}else{if(65535>=o){if(n+2>=r)break;e[n++>>>0]=224|o>>12}else{if(n+3>=r)break;e[n++>>>0]=240|o>>18,e[n++>>>0]=128|o>>12&63}e[n++>>>0]=128|o>>6&63}e[n++>>>0]=128|63&o}}return e[n>>>0]=0,n-a}function D(t){for(var e=0,n=0;n=r?e++:2047>=r?e+=2:55296<=r&&57343>=r?(e+=4,++n):e+=3}return e}function P(){var t=O.buffer;A=t,e.HEAP8=S=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=E=new Int32Array(t),e.HEAPU8=T=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=M=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var U,F=[],I=[],W=[],H=[],L=0;function z(){var t=e.preRun.shift();F.unshift(t)}var Y,B=0,G=null,N=null;function V(t){throw e.onAbort&&e.onAbort(t),w(t="Aborted("+t+")"),C=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),a(t),t}function $(){return Y.startsWith("data:application/octet-stream;base64,")}if(Y="ort-wasm.wasm",!$()){var q=Y;Y=e.locateFile?e.locateFile(q,m):m+q}function X(){var t=Y;try{if(t==Y&&g)return new Uint8Array(g);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){V(t)}}function J(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Z(t){for(;0>2>>>0]=t},this.Eb=function(){return M[this.zb+4>>2>>>0]},this.Sb=function(t){M[this.zb+8>>2>>>0]=t},this.Wb=function(){return M[this.zb+8>>2>>>0]},this.Tb=function(){E[this.zb>>2>>>0]=0},this.Ib=function(t){S[this.zb+12>>0>>>0]=t?1:0},this.Pb=function(){return 0!=S[this.zb+12>>0>>>0]},this.Jb=function(t){S[this.zb+13>>0>>>0]=t?1:0},this.Lb=function(){return 0!=S[this.zb+13>>0>>>0]},this.Rb=function(t,e){this.Fb(0),this.Ub(t),this.Sb(e),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){E[this.zb>>2>>>0]+=1},this.Xb=function(){var t=E[this.zb>>2>>>0];return E[this.zb>>2>>>0]=t-1,1===t},this.Fb=function(t){M[this.zb+16>>2>>>0]=t},this.Ob=function(){return M[this.zb+16>>2>>>0]},this.Qb=function(){if(Mt(this.Eb()))return M[this.Db>>2>>>0];var t=this.Ob();return 0!==t?t:this.Db}}function nt(t){return vt(new et(t).zb)}var rt=[];function at(t){var e=rt[t];return e||(t>=rt.length&&(rt.length=t+1),rt[t]=e=U.get(t)),e}function it(t){var e=D(t)+1,n=gt(e);return n&&k(t,S,n,e),n}var ot={};function ut(){if(!ct){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(t in ot)void 0===ot[t]?delete e[t]:e[t]=ot[t];var n=[];for(t in e)n.push(t+"="+e[t]);ct=n}return ct}var ct,st=[null,[],[]];function lt(t,e){var n=st[t];0===e||10===e?((1===t?v:w)(R(n,0)),n.length=0):n.push(e)}var ft=0;function pt(t){return 0==t%4&&(0!=t%100||0==t%400)}var ht=[31,29,31,30,31,30,31,31,30,31,30,31],dt=[31,28,31,30,31,30,31,31,30,31,30,31];function yt(t,e,n,r){function a(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.lengtht?-1:0r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return n=new Date(t.getFullYear()+1,0,4),e=u(new Date(t.getFullYear(),0,4)),n=u(n),0>=o(e,t)?0>=o(n,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var s=E[r+40>>2>>>0];for(var l in r={$b:E[r>>2>>>0],Zb:E[r+4>>2>>>0],Gb:E[r+8>>2>>>0],Kb:E[r+12>>2>>>0],Hb:E[r+16>>2>>>0],Cb:E[r+20>>2>>>0],Ab:E[r+24>>2>>>0],Bb:E[r+28>>2>>>0],bc:E[r+32>>2>>>0],Yb:E[r+36>>2>>>0],ac:s?j(s):""},n=j(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(l,"g"),s[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(l in s={"%a":function(t){return f[t.Ab].substring(0,3)},"%A":function(t){return f[t.Ab]},"%b":function(t){return p[t.Hb].substring(0,3)},"%B":function(t){return p[t.Hb]},"%C":function(t){return i((t.Cb+1900)/100|0,2)},"%d":function(t){return i(t.Kb,2)},"%e":function(t){return a(t.Kb,2," ")},"%g":function(t){return c(t).toString().substring(2)},"%G":function(t){return c(t)},"%H":function(t){return i(t.Gb,2)},"%I":function(t){return 0==(t=t.Gb)?t=12:12t.Gb?"AM":"PM"},"%S":function(t){return i(t.$b,2)},"%t":function(){return"\\t"},"%u":function(t){return t.Ab||7},"%U":function(t){return i(Math.floor((t.Bb+7-t.Ab)/7),2)},"%V":function(t){var e=Math.floor((t.Bb+7-(t.Ab+6)%7)/7);if(2>=(t.Ab+371-t.Bb-2)%7&&e++,e)53==e&&(4==(n=(t.Ab+371-t.Bb)%7)||3==n&&pt(t.Cb)||(e=1));else{e=52;var n=(t.Ab+7-t.Bb-1)%7;(4==n||5==n&&pt(t.Cb%400-1))&&e++}return i(e,2)},"%w":function(t){return t.Ab},"%W":function(t){return i(Math.floor((t.Bb+7-(t.Ab+6)%7)/7),2)},"%y":function(t){return(t.Cb+1900).toString().substring(2)},"%Y":function(t){return t.Cb+1900},"%z":function(t){var e=0<=(t=t.Yb);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.ac},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),s)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),s[l](r)));return l=function(t){var e=Array(D(t)+1);return k(t,e,0,e.length),e}(n=n.replace(/\\0\\0/g,"%")),l.length>e?0:(S.set(l,t>>>0),l.length-1)}var bt={a:function(t){return gt(t+24)+24},m:function(t){return(t=new et(t)).Pb()||(t.Ib(!0),K--),t.Jb(!1),Q.push(t),t.Nb(),t.Qb()},ia:function(t){throw w("Unexpected exception thrown, this is not properly supported - aborting"),C=!0,t},w:function(){Ot(0);var t=Q.pop();if(t.Xb()&&!t.Lb()){var e=t.Wb();e&&at(e)(t.Db),nt(t.Db)}tt=0},d:function(){var t=tt;if(!t)return ft=0;var e=new et(t);e.Fb(t);var n=e.Eb();if(!n)return ft=0,t;for(var r=Array.prototype.slice.call(arguments),a=0;a>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getUTCSeconds(),E[e+4>>2>>>0]=t.getUTCMinutes(),E[e+8>>2>>>0]=t.getUTCHours(),E[e+12>>2>>>0]=t.getUTCDate(),E[e+16>>2>>>0]=t.getUTCMonth(),E[e+20>>2>>>0]=t.getUTCFullYear()-1900,E[e+24>>2>>>0]=t.getUTCDay(),E[e+28>>2>>>0]=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(t,e){t=new Date(1e3*(M[t>>>2]+4294967296*E[t+4>>>2])),E[e>>2>>>0]=t.getSeconds(),E[e+4>>2>>>0]=t.getMinutes(),E[e+8>>2>>>0]=t.getHours(),E[e+12>>2>>>0]=t.getDate(),E[e+16>>2>>>0]=t.getMonth(),E[e+20>>2>>>0]=t.getFullYear()-1900,E[e+24>>2>>>0]=t.getDay();var n=new Date(t.getFullYear(),0,1);E[e+28>>2>>>0]=(t.getTime()-n.getTime())/864e5|0,E[e+36>>2>>>0]=-60*t.getTimezoneOffset();var r=new Date(t.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),E[e+32>>2>>>0]=0|(r!=n&&t.getTimezoneOffset()==Math.min(n,r))},Fa:function(t){var e=new Date(E[t+20>>2>>>0]+1900,E[t+16>>2>>>0],E[t+12>>2>>>0],E[t+8>>2>>>0],E[t+4>>2>>>0],E[t>>2>>>0],0),n=E[t+32>>2>>>0],r=e.getTimezoneOffset(),a=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear(),6,1).getTimezoneOffset(),o=a.getTimezoneOffset(),u=Math.min(o,i);return 0>n?E[t+32>>2>>>0]=Number(i!=o&&u==r):0>2>>>0]=e.getDay(),E[t+28>>2>>>0]=(e.getTime()-a.getTime())/864e5|0,E[t>>2>>>0]=e.getSeconds(),E[t+4>>2>>>0]=e.getMinutes(),E[t+8>>2>>>0]=e.getHours(),E[t+12>>2>>>0]=e.getDate(),E[t+16>>2>>>0]=e.getMonth(),e.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function t(e,n,r){t.Vb||(t.Vb=!0,function(t,e,n){function r(t){return(t=t.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?t[1]:"GMT"}var a=(new Date).getFullYear(),i=new Date(a,0,1),o=new Date(a,6,1);a=i.getTimezoneOffset();var u=o.getTimezoneOffset();E[t>>2>>>0]=60*Math.max(a,u),E[e>>2>>>0]=Number(a!=u),t=r(i),e=r(o),t=it(t),e=it(e),u>2>>>0]=t,M[n+4>>2>>>0]=e):(M[n>>2>>>0]=e,M[n+4>>2>>>0]=t)}(e,n,r))},B:function(){V("")},ma:function(){return 4294901760},I:b?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now(),xa:function(t,e,n){T.copyWithin(t>>>0,e>>>0,e+n>>>0)},G:function(t){var e=T.length;if(4294901760<(t>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296);var a=Math;r=Math.max(t,r),a=a.min.call(a,4294901760,r+(65536-r%65536)%65536);t:{try{O.grow(a-A.byteLength+65535>>>16),P();var i=1;break t}catch(t){}i=void 0}if(i)return!0}return!1},va:function(t,e){var n=0;return ut().forEach((function(r,a){var i=e+n;for(a=M[t+4*a>>2>>>0]=i,i=0;i>0>>>0]=r.charCodeAt(i);S[a>>0>>>0]=0,n+=r.length+1})),0},wa:function(t,e){var n=ut();M[t>>2>>>0]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),M[e>>2>>>0]=r,0},ba:function(t){_||0>2>>>0],u=M[e+4>>2>>>0];e+=8;for(var c=0;c>>0]);a+=u}return M[r>>2>>>0]=a,0},c:function(){return ft},ja:function t(e,r){t.Mb||(t.Mb=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return()=>(crypto.getRandomValues(t),t[0])}if(b)try{var e=n(Object(function(){var t=new Error("Cannot find module \'crypto\'");throw t.code="MODULE_NOT_FOUND",t}()));return()=>e.randomBytes(1)[0]}catch(t){}return()=>V("randomDevice")}());for(var a=0;a>0>>>0]=t.Mb();return 0},ea:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},fa:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},J:function(t){var e=At();try{return at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},e:function(t,e){var n=At();try{return at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},N:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},O:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},j:function(t,e,n){var r=At();try{return at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},o:function(t,e,n,r){var a=At();try{return at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},p:function(t,e,n,r,a){var i=At();try{return at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},M:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},r:function(t,e,n,r,a,i){var o=At();try{return at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},v:function(t,e,n,r,a,i,o){var u=At();try{return at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},K:function(t,e,n,r,a,i,o,u){var c=At();try{return at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},D:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{return at(t)(e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},X:function(t,e,n,r,a,i,o,u){var c=At();try{return Ft(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},V:function(t,e,n,r,a,i,o){var u=At();try{return xt(t,e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},U:function(t,e,n,r,a){var i=At();try{return It(t,e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},Z:function(t,e,n,r){var a=At();try{return Pt(t,e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},W:function(t){var e=At();try{return Ct(t)}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},Y:function(t,e){var n=At();try{return Ut(t,e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},T:function(t,e,n){var r=At();try{return Rt(t,e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},f:function(t){var e=At();try{at(t)()}catch(t){if(St(e),t!==t+0)throw t;Ot(1,0)}},q:function(t,e){var n=At();try{at(t)(e)}catch(t){if(St(n),t!==t+0)throw t;Ot(1,0)}},h:function(t,e,n){var r=At();try{at(t)(e,n)}catch(t){if(St(r),t!==t+0)throw t;Ot(1,0)}},da:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},l:function(t,e,n,r){var a=At();try{at(t)(e,n,r)}catch(t){if(St(a),t!==t+0)throw t;Ot(1,0)}},t:function(t,e,n,r,a){var i=At();try{at(t)(e,n,r,a)}catch(t){if(St(i),t!==t+0)throw t;Ot(1,0)}},u:function(t,e,n,r,a,i){var o=At();try{at(t)(e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},x:function(t,e,n,r,a,i,o){var u=At();try{at(t)(e,n,r,a,i,o)}catch(t){if(St(u),t!==t+0)throw t;Ot(1,0)}},z:function(t,e,n,r,a,i,o,u){var c=At();try{at(t)(e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},ga:function(t,e,n,r,a,i,o,u,c){var s=At();try{at(t)(e,n,r,a,i,o,u,c)}catch(t){if(St(s),t!==t+0)throw t;Ot(1,0)}},A:function(t,e,n,r,a,i,o,u,c,s,l){var f=At();try{at(t)(e,n,r,a,i,o,u,c,s,l)}catch(t){if(St(f),t!==t+0)throw t;Ot(1,0)}},C:function(t,e,n,r,a,i,o,u,c,s,l,f,p,h,d,y){var b=At();try{at(t)(e,n,r,a,i,o,u,c,s,l,f,p,h,d,y)}catch(t){if(St(b),t!==t+0)throw t;Ot(1,0)}},aa:function(t,e,n,r,a,i,o,u){var c=At();try{jt(t,e,n,r,a,i,o,u)}catch(t){if(St(c),t!==t+0)throw t;Ot(1,0)}},_:function(t,e,n,r,a,i,o,u,c,s,l,f){var p=At();try{Dt(t,e,n,r,a,i,o,u,c,s,l,f)}catch(t){if(St(p),t!==t+0)throw t;Ot(1,0)}},$:function(t,e,n,r,a,i){var o=At();try{kt(t,e,n,r,a,i)}catch(t){if(St(o),t!==t+0)throw t;Ot(1,0)}},n:function(t){return t},F:function(t){ft=t},ha:yt,y:function(t,e,n,r){return yt(t,e,n,r)}};!function(){function t(t){e.asm=t.exports,O=e.asm.Ka,P(),U=e.asm.ib,I.unshift(e.asm.La),B--,e.monitorRunDependencies&&e.monitorRunDependencies(B),0==B&&(null!==G&&(clearInterval(G),G=null),N&&(t=N,N=null,t()))}function n(e){t(e.instance)}function r(t){return function(){if(!g&&(d||y)){if("function"==typeof fetch&&!Y.startsWith("file://"))return fetch(Y,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at \'"+Y+"\'";return t.arrayBuffer()})).catch((function(){return X()}));if(o)return new Promise((function(t,e){o(Y,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return X()}))}().then((function(t){return WebAssembly.instantiate(t,i)})).then((function(t){return t})).then(t,(function(t){w("failed to asynchronously prepare wasm: "+t),V(t)}))}var i={a:bt};if(B++,e.monitorRunDependencies&&e.monitorRunDependencies(B),e.instantiateWasm)try{return e.instantiateWasm(i,t)}catch(t){return w("Module.instantiateWasm callback failed with error: "+t),!1}(g||"function"!=typeof WebAssembly.instantiateStreaming||$()||Y.startsWith("file://")||b||"function"!=typeof fetch?r(n):fetch(Y,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(n,(function(t){return w("wasm streaming compile failed: "+t),w("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.La).apply(null,arguments)},e._OrtInit=function(){return(e._OrtInit=e.asm.Ma).apply(null,arguments)},e._OrtCreateSessionOptions=function(){return(e._OrtCreateSessionOptions=e.asm.Na).apply(null,arguments)},e._OrtAppendExecutionProvider=function(){return(e._OrtAppendExecutionProvider=e.asm.Oa).apply(null,arguments)},e._OrtAddSessionConfigEntry=function(){return(e._OrtAddSessionConfigEntry=e.asm.Pa).apply(null,arguments)},e._OrtReleaseSessionOptions=function(){return(e._OrtReleaseSessionOptions=e.asm.Qa).apply(null,arguments)},e._OrtCreateSession=function(){return(e._OrtCreateSession=e.asm.Ra).apply(null,arguments)},e._OrtReleaseSession=function(){return(e._OrtReleaseSession=e.asm.Sa).apply(null,arguments)},e._OrtGetInputCount=function(){return(e._OrtGetInputCount=e.asm.Ta).apply(null,arguments)},e._OrtGetOutputCount=function(){return(e._OrtGetOutputCount=e.asm.Ua).apply(null,arguments)},e._OrtGetInputName=function(){return(e._OrtGetInputName=e.asm.Va).apply(null,arguments)},e._OrtGetOutputName=function(){return(e._OrtGetOutputName=e.asm.Wa).apply(null,arguments)},e._OrtFree=function(){return(e._OrtFree=e.asm.Xa).apply(null,arguments)},e._OrtCreateTensor=function(){return(e._OrtCreateTensor=e.asm.Ya).apply(null,arguments)},e._OrtGetTensorData=function(){return(e._OrtGetTensorData=e.asm.Za).apply(null,arguments)},e._OrtReleaseTensor=function(){return(e._OrtReleaseTensor=e.asm._a).apply(null,arguments)},e._OrtCreateRunOptions=function(){return(e._OrtCreateRunOptions=e.asm.$a).apply(null,arguments)},e._OrtAddRunConfigEntry=function(){return(e._OrtAddRunConfigEntry=e.asm.ab).apply(null,arguments)},e._OrtReleaseRunOptions=function(){return(e._OrtReleaseRunOptions=e.asm.bb).apply(null,arguments)},e._OrtRun=function(){return(e._OrtRun=e.asm.cb).apply(null,arguments)},e._OrtEndProfiling=function(){return(e._OrtEndProfiling=e.asm.db).apply(null,arguments)};var mt,gt=e._malloc=function(){return(gt=e._malloc=e.asm.eb).apply(null,arguments)},vt=e._free=function(){return(vt=e._free=e.asm.fb).apply(null,arguments)},wt=e._fflush=function(){return(wt=e._fflush=e.asm.gb).apply(null,arguments)},_t=e.___funcs_on_exit=function(){return(_t=e.___funcs_on_exit=e.asm.hb).apply(null,arguments)},Ot=e._setThrew=function(){return(Ot=e._setThrew=e.asm.jb).apply(null,arguments)},At=e.stackSave=function(){return(At=e.stackSave=e.asm.kb).apply(null,arguments)},St=e.stackRestore=function(){return(St=e.stackRestore=e.asm.lb).apply(null,arguments)},Tt=e.stackAlloc=function(){return(Tt=e.stackAlloc=e.asm.mb).apply(null,arguments)},Et=e.___cxa_can_catch=function(){return(Et=e.___cxa_can_catch=e.asm.nb).apply(null,arguments)},Mt=e.___cxa_is_pointer_type=function(){return(Mt=e.___cxa_is_pointer_type=e.asm.ob).apply(null,arguments)},Ct=e.dynCall_j=function(){return(Ct=e.dynCall_j=e.asm.pb).apply(null,arguments)},xt=e.dynCall_iiiiij=function(){return(xt=e.dynCall_iiiiij=e.asm.qb).apply(null,arguments)},Rt=e.dynCall_jii=function(){return(Rt=e.dynCall_jii=e.asm.rb).apply(null,arguments)},jt=e.dynCall_viiiiij=function(){return(jt=e.dynCall_viiiiij=e.asm.sb).apply(null,arguments)},kt=e.dynCall_vjji=function(){return(kt=e.dynCall_vjji=e.asm.tb).apply(null,arguments)},Dt=e.dynCall_viiijjjii=function(){return(Dt=e.dynCall_viiijjjii=e.asm.ub).apply(null,arguments)},Pt=e.dynCall_iij=function(){return(Pt=e.dynCall_iij=e.asm.vb).apply(null,arguments)},Ut=e.dynCall_ji=function(){return(Ut=e.dynCall_ji=e.asm.wb).apply(null,arguments)},Ft=e.dynCall_iiiiiij=function(){return(Ft=e.dynCall_iiiiiij=e.asm.xb).apply(null,arguments)},It=e.dynCall_iiij=function(){return(It=e.dynCall_iiij=e.asm.yb).apply(null,arguments)};function Wt(){function t(){if(!mt&&(mt=!0,e.calledRun=!0,!C)){if(Z(I),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var t=e.postRun.shift();H.unshift(t)}Z(H)}}if(!(0{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iterateExtraOptions=void 0,e.iterateExtraOptions=(t,n,r,a)=>{if("object"==typeof t&&null!==t){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach((([t,i])=>{const o=n?n+t:t;if("object"==typeof i)(0,e.iterateExtraOptions)(i,o+".",r,a);else if("string"==typeof i||"number"==typeof i)a(o,i.toString());else{if("boolean"!=typeof i)throw new Error("Can\'t handle extra config type: "+typeof i);a(o,i?"1":"0")}}))}},586:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setRunOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};try{if(void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);void 0===(null==t?void 0:t.terminate)&&(u.terminate=!1);let i=0;if(void 0!==(null==t?void 0:t.tag)&&(i=(0,a.allocWasmString)(t.tag,o)),n=e._OrtCreateRunOptions(u.logSeverityLevel,u.logVerbosityLevel,!!u.terminate,i),0===n)throw new Error("Can\'t create run options");return void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddRunConfigEntry(n,i,u))throw new Error(`Can\'t set a run config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseRunOptions(n),o.forEach(e._free),t}}},919:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const r=n(967),a=n(983),i=n(361);e.setSessionOptions=t=>{const e=(0,i.getInstance)();let n=0;const o=[],u=t||{};(t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});const e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1")})(u);try{void 0===(null==t?void 0:t.graphOptimizationLevel)&&(u.graphOptimizationLevel="all");const c=(t=>{switch(t){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${t}`)}})(u.graphOptimizationLevel);void 0===(null==t?void 0:t.enableCpuMemArena)&&(u.enableCpuMemArena=!0),void 0===(null==t?void 0:t.enableMemPattern)&&(u.enableMemPattern=!0),void 0===(null==t?void 0:t.executionMode)&&(u.executionMode="sequential");const s=(t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}})(u.executionMode);let l=0;if(void 0!==(null==t?void 0:t.logId)&&(l=(0,a.allocWasmString)(t.logId,o)),void 0===(null==t?void 0:t.logSeverityLevel))u.logSeverityLevel=2;else if("number"!=typeof t.logSeverityLevel||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${t.logSeverityLevel}`);if(void 0===(null==t?void 0:t.logVerbosityLevel))u.logVerbosityLevel=0;else if("number"!=typeof t.logVerbosityLevel||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);if(void 0===(null==t?void 0:t.enableProfiling)&&(u.enableProfiling=!1),n=e._OrtCreateSessionOptions(c,!!u.enableCpuMemArena,!!u.enableMemPattern,s,!!u.enableProfiling,0,l,u.logSeverityLevel,u.logVerbosityLevel),0===n)throw new Error("Can\'t create session options");return(null==t?void 0:t.executionProviders)&&((t,e,n)=>{for(const r of e){let e="string"==typeof r?r:r.name;switch(e){case"xnnpack":e="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${e}`)}const o=(0,a.allocWasmString)(e,n);if(0!==(0,i.getInstance)()._OrtAppendExecutionProvider(t,o))throw new Error(`Can\'t append execution provider: ${e}`)}})(n,t.executionProviders,o),void 0!==(null==t?void 0:t.extra)&&(0,r.iterateExtraOptions)(t.extra,"",new WeakSet,((t,r)=>{const i=(0,a.allocWasmString)(t,o),u=(0,a.allocWasmString)(r,o);if(0!==e._OrtAddSessionConfigEntry(n,i,u))throw new Error(`Can\'t set a session config entry: ${t} - ${r}`)})),[n,o]}catch(t){throw 0!==n&&e._OrtReleaseSessionOptions(n),o.forEach(e._free),t}}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.allocWasmString=void 0;const r=n(361);e.allocWasmString=(t,e)=>{const n=(0,r.getInstance)(),a=n.lengthBytesUTF8(t)+1,i=n._malloc(a);return n.stringToUTF8(t,i,a),e.push(i),i}},349:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initOrt=void 0;const r=n(586),a=n(919),i=n(983),o=n(361);e.initOrt=(t,e)=>{const n=(0,o.getInstance)()._OrtInit(t,e);if(0!==n)throw new Error(`Can\'t initialize onnxruntime. error code = ${n}`)};const u=new Map;e.createSessionAllocate=t=>{const e=(0,o.getInstance)(),n=e._malloc(t.byteLength);return e.HEAPU8.set(t,n),[n,t.byteLength]},e.createSessionFinalize=(t,e)=>{const n=(0,o.getInstance)();let r=0,i=0,c=[];try{if([i,c]=(0,a.setSessionOptions)(e),r=n._OrtCreateSession(t[0],t[1],i),0===r)throw new Error("Can\'t create a session")}finally{n._free(t[0]),n._OrtReleaseSessionOptions(i),c.forEach(n._free)}const s=n._OrtGetInputCount(r),l=n._OrtGetOutputCount(r),f=[],p=[],h=[],d=[];for(let t=0;t{const r=(0,e.createSessionAllocate)(t);return(0,e.createSessionFinalize)(r,n)},e.releaseSession=t=>{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],i=n[2];a.forEach(e._OrtFree),i.forEach(e._OrtFree),e._OrtReleaseSession(r),u.delete(t)};const c=t=>{switch(t){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${t}`)}},s=t=>{switch(t){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${t}`)}},l=t=>{switch(t){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}};e.run=(t,e,n,a,f)=>{const p=(0,o.getInstance)(),h=u.get(t);if(!h)throw new Error("invalid session id");const d=h[0],y=h[1],b=h[2],m=e.length,g=a.length;let v=0,w=[];const _=[],O=[];try{[v,w]=(0,r.setRunOptions)(f);for(let t=0;tp.HEAP32[t++]=e));const n=p._OrtCreateTensor(c(e),o,u,l,r.length);if(0===n)throw new Error("Can\'t create a tensor");_.push(n)}finally{p.stackRestore(s)}}const t=p.stackSave(),o=p.stackAlloc(4*m),u=p.stackAlloc(4*m),h=p.stackAlloc(4*g),A=p.stackAlloc(4*g);try{let n=o/4,r=u/4,i=h/4,c=A/4;for(let t=0;tt*e));if(a=s(o),"string"===a){const t=[];let e=i/4;for(let n=0;n{const e=(0,o.getInstance)(),n=u.get(t);if(!n)throw new Error("invalid session id");const r=n[0],a=e._OrtEndProfiling(r);if(0===a)throw new Error("Can\'t get an profile file name");e._OrtFree(a)},e.extractTransferableBuffers=t=>{const e=[];for(const n of t){const t=n[2];!Array.isArray(t)&&t.buffer&&e.push(t.buffer)}return e}},361:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(e,n);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,a)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return a(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const u=i(n(449)),c=o(n(932)),s=n(474);let l,f=!1,p=!1,h=!1;const d=(t,e)=>e?t?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":t?"ort-wasm-simd.wasm":"ort-wasm.wasm";e.initializeWebAssembly=async t=>{if(f)return Promise.resolve();if(p)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(h)throw new Error("previous call to \'initializeWebAssembly()\' failed.");p=!0;const e=t.initTimeout,r=t.numThreads,a=t.simd,i=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(t){return!1}})(),o=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(t){return!1}})(),y="string"==typeof t.wasmPaths?t.wasmPaths:void 0,b=d(!1,i),m=d(o,i),g="object"==typeof t.wasmPaths?t.wasmPaths[m]:void 0;let v=!1;const w=[];if(e>0&&w.push(new Promise((t=>{setTimeout((()=>{v=!0,t()}),e)}))),w.push(new Promise(((t,e)=>{const r=i?s:c.default,a={locateFile:(t,e)=>i&&t.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(154)],{type:"text/javascript"})):t===b?null!=g?g:(null!=y?y:e)+m:e+t};if(i)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=u.join("/","ort-wasm-threaded.js");else{const t=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([t],{type:"text/javascript"})}r(a).then((e=>{p=!1,f=!0,l=e,t()}),(t=>{p=!1,h=!0,e(t)}))}))),await Promise.race(w),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},e.getInstance=()=>{if(f&&l)return l;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var t;!f||p||h||(p=!0,null===(t=l.PThread)||void 0===t||t.terminateAllThreads(),l=void 0,p=!1,f=!1,h=!0)}},154:t=>{"use strict";t.exports=\'"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\\n\'},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t=n(349),e=n(361);self.onmessage=n=>{switch(n.data.type){case"init-wasm":(0,e.initializeWebAssembly)(n.data.in).then((()=>postMessage({type:"init-wasm"})),(t=>postMessage({type:"init-wasm",err:t})));break;case"init-ort":try{const{numThreads:e,loggingLevel:r}=n.data.in;(0,t.initOrt)(e,r),postMessage({type:"init-ort"})}catch(t){postMessage({type:"init-ort",err:t})}break;case"create_allocate":try{const{model:e}=n.data.in,r=(0,t.createSessionAllocate)(e);postMessage({type:"create_allocate",out:r})}catch(t){postMessage({type:"create_allocate",err:t})}break;case"create_finalize":try{const{modeldata:e,options:r}=n.data.in,a=(0,t.createSessionFinalize)(e,r);postMessage({type:"create_finalize",out:a})}catch(t){postMessage({type:"create_finalize",err:t})}break;case"create":try{const{model:e,options:r}=n.data.in,a=(0,t.createSession)(e,r);postMessage({type:"create",out:a})}catch(t){postMessage({type:"create",err:t})}break;case"release":try{const e=n.data.in;(0,t.releaseSession)(e),postMessage({type:"release"})}catch(t){postMessage({type:"release",err:t})}break;case"run":try{const{sessionId:e,inputIndices:r,inputs:a,outputIndices:i,options:o}=n.data.in,u=(0,t.run)(e,r,a,i,o);postMessage({type:"run",out:u},(0,t.extractTransferableBuffers)(u))}catch(t){postMessage({type:"run",err:t})}break;case"end-profiling":try{const e=n.data.in;(0,t.endProfiling)(e),postMessage({type:"end-profiling"})}catch(t){postMessage({type:"end-profiling",err:t})}}}})()})();\n',"Worker",void 0,void 0)}},477:m=>{m.exports=function(t,i,s,a){var d=self||window;try{try{var u;try{u=new d.Blob([t])}catch{(u=new(d.BlobBuilder||d.WebKitBlobBuilder||d.MozBlobBuilder||d.MSBlobBuilder)).append(t),u=u.getBlob()}var h=d.URL||d.webkitURL,p=h.createObjectURL(u),c=new d[i](p,s);return h.revokeObjectURL(p),c}catch{return new d[i]("data:application/javascript,".concat(encodeURIComponent(t)),s)}}catch{if(!a)throw Error("Inline worker is not supported");return new d[i](a,s)}}},4154:m=>{m.exports=`"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}}; -`},1670:m=>{m.exports=__WEBPACK_EXTERNAL_MODULE__1670__},7067:()=>{},1296:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(m,t,i)=>{i.r(t),i.d(t,{flatbuffers:()=>s});var s={};s.Offset,s.Table,s.SIZEOF_SHORT=2,s.SIZEOF_INT=4,s.FILE_IDENTIFIER_LENGTH=4,s.SIZE_PREFIX_LENGTH=4,s.Encoding={UTF8_BYTES:1,UTF16_STRING:2},s.int32=new Int32Array(2),s.float32=new Float32Array(s.int32.buffer),s.float64=new Float64Array(s.int32.buffer),s.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,s.Long=function(a,d){this.low=0|a,this.high=0|d},s.Long.create=function(a,d){return a==0&&d==0?s.Long.ZERO:new s.Long(a,d)},s.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},s.Long.prototype.equals=function(a){return this.low==a.low&&this.high==a.high},s.Long.ZERO=new s.Long(0,0),s.Builder=function(a){if(a)d=a;else var d=1024;this.bb=s.ByteBuffer.allocate(d),this.space=d,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},s.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},s.Builder.prototype.forceDefaults=function(a){this.force_defaults=a},s.Builder.prototype.dataBuffer=function(){return this.bb},s.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},s.Builder.prototype.prep=function(a,d){a>this.minalign&&(this.minalign=a);for(var u=1+~(this.bb.capacity()-this.space+d)&a-1;this.space=0&&this.vtable[d]==0;d--);for(var u=d+1;d>=0;d--)this.addInt16(this.vtable[d]!=0?a-this.vtable[d]:0);this.addInt16(a-this.object_start);var h=(u+2)*s.SIZEOF_SHORT;this.addInt16(h);var p=0,c=this.space;e:for(d=0;d=0;c--)this.writeInt8(p.charCodeAt(c))}this.prep(this.minalign,s.SIZEOF_INT+h),this.addOffset(a),h&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},s.Builder.prototype.finishSizePrefixed=function(a,d){this.finish(a,d,!0)},s.Builder.prototype.requiredField=function(a,d){var u=this.bb.capacity()-a,h=u-this.bb.readInt32(u);if(this.bb.readInt16(h+d)==0)throw new Error("FlatBuffers: field "+d+" must be set")},s.Builder.prototype.startVector=function(a,d,u){this.notNested(),this.vector_num_elems=d,this.prep(s.SIZEOF_INT,a*d),this.prep(u,a*d)},s.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},s.Builder.prototype.createString=function(a){if(a instanceof Uint8Array)var d=a;else{d=[];for(var u=0;u=56320?p:(p<<10)+a.charCodeAt(u++)+-56613888)<128?d.push(h):(h<2048?d.push(h>>6&31|192):(h<65536?d.push(h>>12&15|224):d.push(h>>18&7|240,h>>12&63|128),d.push(h>>6&63|128)),d.push(63&h|128))}}this.addInt8(0),this.startVector(1,d.length,1),this.bb.setPosition(this.space-=d.length),u=0;for(var c=this.space,l=this.bb.bytes();u>24},s.ByteBuffer.prototype.readUint8=function(a){return this.bytes_[a]},s.ByteBuffer.prototype.readInt16=function(a){return this.readUint16(a)<<16>>16},s.ByteBuffer.prototype.readUint16=function(a){return this.bytes_[a]|this.bytes_[a+1]<<8},s.ByteBuffer.prototype.readInt32=function(a){return this.bytes_[a]|this.bytes_[a+1]<<8|this.bytes_[a+2]<<16|this.bytes_[a+3]<<24},s.ByteBuffer.prototype.readUint32=function(a){return this.readInt32(a)>>>0},s.ByteBuffer.prototype.readInt64=function(a){return new s.Long(this.readInt32(a),this.readInt32(a+4))},s.ByteBuffer.prototype.readUint64=function(a){return new s.Long(this.readUint32(a),this.readUint32(a+4))},s.ByteBuffer.prototype.readFloat32=function(a){return s.int32[0]=this.readInt32(a),s.float32[0]},s.ByteBuffer.prototype.readFloat64=function(a){return s.int32[s.isLittleEndian?0:1]=this.readInt32(a),s.int32[s.isLittleEndian?1:0]=this.readInt32(a+4),s.float64[0]},s.ByteBuffer.prototype.writeInt8=function(a,d){this.bytes_[a]=d},s.ByteBuffer.prototype.writeUint8=function(a,d){this.bytes_[a]=d},s.ByteBuffer.prototype.writeInt16=function(a,d){this.bytes_[a]=d,this.bytes_[a+1]=d>>8},s.ByteBuffer.prototype.writeUint16=function(a,d){this.bytes_[a]=d,this.bytes_[a+1]=d>>8},s.ByteBuffer.prototype.writeInt32=function(a,d){this.bytes_[a]=d,this.bytes_[a+1]=d>>8,this.bytes_[a+2]=d>>16,this.bytes_[a+3]=d>>24},s.ByteBuffer.prototype.writeUint32=function(a,d){this.bytes_[a]=d,this.bytes_[a+1]=d>>8,this.bytes_[a+2]=d>>16,this.bytes_[a+3]=d>>24},s.ByteBuffer.prototype.writeInt64=function(a,d){this.writeInt32(a,d.low),this.writeInt32(a+4,d.high)},s.ByteBuffer.prototype.writeUint64=function(a,d){this.writeUint32(a,d.low),this.writeUint32(a+4,d.high)},s.ByteBuffer.prototype.writeFloat32=function(a,d){s.float32[0]=d,this.writeInt32(a,s.int32[0])},s.ByteBuffer.prototype.writeFloat64=function(a,d){s.float64[0]=d,this.writeInt32(a,s.int32[s.isLittleEndian?0:1]),this.writeInt32(a+4,s.int32[s.isLittleEndian?1:0])},s.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&c)))}return h},s.ByteBuffer.prototype.__indirect=function(a){return a+this.readInt32(a)},s.ByteBuffer.prototype.__vector=function(a){return a+this.readInt32(a)+s.SIZEOF_INT},s.ByteBuffer.prototype.__vector_len=function(a){return this.readInt32(a+this.readInt32(a))},s.ByteBuffer.prototype.__has_identifier=function(a){if(a.length!=s.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+s.FILE_IDENTIFIER_LENGTH);for(var d=0;d{var t=m&&m.__esModule?()=>m.default:()=>m;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(m,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(m,i)&&Object.defineProperty(m,i,{enumerable:!0,get:t[i]})},__webpack_require__.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),__webpack_require__.o=(m,t)=>Object.prototype.hasOwnProperty.call(m,t),__webpack_require__.r=m=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(m,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6018);return __webpack_exports__})())})(ortWeb_min$1);var ortWeb_minExports=ortWeb_min$1.exports,ortWeb_min=getDefaultExportFromCjs(ortWeb_minExports),ONNX_WEB=_mergeNamespaces({__proto__:null,default:ortWeb_min},[ortWeb_minExports]);let ONNX;const executionProviders=["wasm"];typeof process<"u"&&((nt=process==null?void 0:process.release)==null?void 0:nt.name)==="node"?(ONNX=fs??ONNX_NODE,executionProviders.unshift("cpu")):(ONNX=ortWeb_min??ONNX_WEB,typeof navigator<"u"&&/iP(hone|od|ad).+16_4.+AppleWebKit/.test(navigator.userAgent)&&(ONNX.env.wasm.simd=!1));const{env:onnx_env}=ONNX,VERSION="2.4.0",WEB_CACHE_AVAILABLE=typeof self<"u"&&"caches"in self,FS_AVAILABLE=!isEmpty(fs),PATH_AVAILABLE=!isEmpty(fs),RUNNING_LOCALLY=FS_AVAILABLE&&PATH_AVAILABLE,__dirname=RUNNING_LOCALLY?fs.dirname(fs.dirname(fs.fileURLToPath(self.location.href))):"./",DEFAULT_CACHE_DIR=RUNNING_LOCALLY?fs.join(__dirname,"/.cache/"):null,DEFAULT_LOCAL_MODEL_PATH="/models/",localModelPath=RUNNING_LOCALLY?fs.join(__dirname,DEFAULT_LOCAL_MODEL_PATH):DEFAULT_LOCAL_MODEL_PATH;onnx_env.wasm.wasmPaths=RUNNING_LOCALLY?fs.join(__dirname,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${VERSION}/dist/`;const env={backends:{onnx:onnx_env,tfjs:{}},__dirname,version:VERSION,allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!0,localModelPath,useFS:FS_AVAILABLE,useBrowserCache:WEB_CACHE_AVAILABLE,useFSCache:FS_AVAILABLE,cacheDir:DEFAULT_CACHE_DIR};function isEmpty(m){return Object.keys(m).length===0}globalThis.ReadableStream||(globalThis.ReadableStream=fs.ReadableStream);class Headers extends Object{constructor(...t){super(),Object.assign(this,t)}get(t){return this[t]}clone(){return new Headers(this)}}class FileResponse{constructor(t){Ee(this,"_CONTENT_TYPE_MAP",{txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"});if(this.filePath=t,this.headers=new Headers,this.exists=fs.existsSync(t),this.exists){this.status=200,this.statusText="OK";let i=fs.statSync(t);this.headers["content-length"]=i.size,this.updateContentType();let s=this;this.body=new ReadableStream({start(a){s.arrayBuffer().then(d=>{a.enqueue(new Uint8Array(d)),a.close()})}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const t=this.filePath.toString().split(".").pop().toLowerCase();this.headers["content-type"]=this._CONTENT_TYPE_MAP[t]??"application/octet-stream"}clone(){let t=new FileResponse(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=this.headers.clone(),t}async arrayBuffer(){return(await fs.promises.readFile(this.filePath)).buffer}async blob(){const t=await fs.promises.readFile(this.filePath);return new Blob([t],{type:this.headers["content-type"]})}async text(){return await fs.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function isValidHttpUrl(m){let t;try{t=new URL(m)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}async function getFile(m){var t,i;if(env.useFS&&!isValidHttpUrl(m))return new FileResponse(m);if(typeof process<"u"&&((t=process==null?void 0:process.release)==null?void 0:t.name)==="node"){const s=!!((i=process.env)!=null&&i.TESTING_REMOTELY),a=env.version;return fetch(m,{headers:{"User-Agent":`transformers.js/${a}; is_ci/${s};`}})}else return fetch(m)}const ERROR_MAPPING={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"};function handleError(m,t,i){if(!i)return null;const s=ERROR_MAPPING[m]??`Error (${m}) occurred while trying to load file`;throw Error(`${s}: "${t}".`)}class FileCache{constructor(t){this.path=t}async match(t){let i=fs.join(this.path,t),s=new FileResponse(i);if(s.exists)return s}async put(t,i){const s=Buffer.from(await i.arrayBuffer());let a=fs.join(this.path,t);try{await fs.promises.mkdir(fs.dirname(a),{recursive:!0}),await fs.promises.writeFile(a,s)}catch(d){console.warn("An error occurred while writing the file to cache:",d)}}}async function tryCache(m,...t){for(let i of t)try{let s=await m.match(i);if(s)return s}catch{continue}}async function getModelFile(m,t,i=!0,s={}){dispatchCallback(s.progress_callback,{status:"initiate",name:m,file:t});let a;if(!a&&env.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{a=await caches.open("transformers-cache")}catch(f){console.warn("An error occurred while opening the browser cache:",f)}}!a&&env.useFSCache&&(a=new FileCache(s.cache_dir??env.cacheDir));const d=s.revision??"main";let u=pathJoin(m,t),h=pathJoin(env.localModelPath,u),p=pathJoin(env.remoteHost,env.remotePathTemplate.replaceAll("{model}",m).replaceAll("{revision}",d),t),c=d==="main"?u:pathJoin(m,d,t),l,n=a instanceof FileCache?c:p,e,r;if(a&&(r=await tryCache(a,h,n)),r===void 0){if(isValidHttpUrl(u)){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${u}.`)}else try{r=await getFile(h),l=h}catch(g){console.warn(`Unable to load from local path "${h}": "${g}"`)}if(r===void 0||r.status===404){if(s.local_files_only||!env.allowRemoteModels){if(i)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${h}".`);return null}if(r=await getFile(p),r.status!==200)return handleError(r.status,p,i);l=n}a&&r instanceof Response&&r.status===200&&(e=r.clone())}dispatchCallback(s.progress_callback,{status:"download",name:m,file:t});const o=await readResponse(r,f=>{dispatchCallback(s.progress_callback,{status:"progress",...f,name:m,file:t})});return e&&l&&await a.match(l)===void 0&&await a.put(l,e).catch(f=>{console.warn(`Unable to add response to browser cache: ${f}.`)}),dispatchCallback(s.progress_callback,{status:"done",name:m,file:t}),o}async function getModelJSON(m,t,i=!0,s={}){let a=await getModelFile(m,t,i,s);if(a===null)return{};let u=new TextDecoder("utf-8").decode(a);return JSON.parse(u)}async function readResponse(m,t){const i=m.headers.get("Content-Length");i===null&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let s=parseInt(i??"0"),a=new Uint8Array(s),d=0;const u=m.body.getReader();async function h(){const{done:p,value:c}=await u.read();if(p)return;let l=d+c.length;if(l>s){s=l;let e=new Uint8Array(s);e.set(a),a=e}a.set(c,d),d=l;const n=d/s*100;return t({progress:n,loaded:d,total:s}),h()}return await h(),a}function pathJoin(...m){return m=m.map((t,i)=>(i&&(t=t.replace(new RegExp("^/"),"")),i!==m.length-1&&(t=t.replace(new RegExp("/$"),"")),t)),m.join("/")}function interpolate_data(m,[t,i,s],[a,d],u="bilinear",h=!1){const p=d/s,c=a/i,l=new m.constructor(a*d*t),n=i*s,e=a*d;for(let r=0;r=0;--h)a[h]=p,s[h]=t[i[h]],p*=s[h];const d=i.map((h,p)=>a[i.indexOf(p)]),u=new m.constructor(m.length);for(let h=0;h=0;--c)p+=l%t[c]*d[c],l=Math.floor(l/t[c]);u[p]=m[h]}return[u,s]}function softmax(m){const t=max(m)[0],i=m.map(d=>Math.exp(d-t)),s=i.reduce((d,u)=>d+u,0);return i.map(d=>d/s)}function log_softmax(m){return softmax(m).map(s=>Math.log(s))}function getTopItems(m,t=0){return m=Array.from(m).map((i,s)=>[s,i]).sort((i,s)=>s[1]-i[1]),t>0&&(m=m.slice(0,t)),m}function min(m){if(m.length===0)throw Error("Array must not be empty");let t=m[0],i=0;for(let s=1;st&&(t=m[s],i=s);return[t,i]}function rfftfreq(m,t=1){if(!Number.isInteger(m))throw new TypeError(`n should be an integer, but ${m} given.`);const i=1/(m*t),s=Math.floor(m/2)+1,a=new Array(s);for(let d=0;ds;s<<=1)++i;this._width=i%2===0?i-1:i,this._bitrev=new Int32Array(1<>>a&3)<>>1);for(let a=0;a>>1]=t[a];return s}toComplexArray(t,i){const s=i||this.createComplexArray();for(let a=0;a>>1],s[a+1]=0;return s}completeSpectrum(t){const i=this._csize,s=i>>>1;for(let a=2;a>=2;u>=2;u>>=2){h=a/u<<1;let n=h>>>2;for(p=0;p>>1,u>>>1)}else for(p=0,c=0;p>>1,u>>>1,s)}for(u>>=2;u>=2;u>>=2){h=a/u<<1;const n=h>>>1,e=n>>>1,r=e>>>1;for(p=0;p=m.length&&(p=2*(m.length-1)-p),s[u++]=m[p]}s.sort(),i[d]=s[a]}return i}function round(m,t){const i=Math.pow(10,t);return Math.round(m*i)/i}const ONNXTensor$1=ONNX.Tensor;class Tensor extends ONNXTensor$1{constructor(...t){return t[0]instanceof ONNX.Tensor?super(t[0].type,t[0].data,t[0].dims):super(...t),new Proxy(this,{get:(i,s)=>{if(typeof s=="string"){let a=Number(s);if(Number.isInteger(a))return i._getitem(a)}return i[s]},set:(i,s,a)=>i[s]=a})}*[Symbol.iterator](){const[t,...i]=this.dims;if(i.length>0){const s=i.reduce((a,d)=>a*d);for(let a=0;a0){const a=s.reduce((d,u)=>d*u);return this._subarray(t,a,s)}else return new Tensor(this.type,[this.data[t]],s)}indexOf(t){for(let i=0;ic[1])throw new Error(`Invalid slice: ${c}`);let l=[Math.max(c[0],0),Math.min(c[1],this.dims[p])];s.push(l),i.push(l[1]-l[0])}else throw new Error(`Invalid slice: ${c}`)}let a=s.map(([p,c])=>c-p),d=a.reduce((p,c)=>p*c),u=new this.data.constructor(d);const h=this.stride();for(let p=0;p=0;--l){const e=a[l];c+=(n%e+s[l][0])*h[l],n=Math.floor(n/e)}u[p]=this.data[c]}return new Tensor(this.type,u,i)}transpose(...t){return transpose(this,t)}sum(t=null,i=!1){return this.norm(1,t,i)}norm(t="fro",i=null,s=!1){if(t==="fro")t=2;else if(typeof t=="string")throw Error(`Unsupported norm: ${t}`);if(i===null){let u=this.data.reduce((h,p)=>h+p**t,0)**(1/t);return new Tensor(this.type,[u],[])}i=safeIndex(i,this.dims.length);const a=this.dims.slice();a[i]=1;const d=new this.data.constructor(this.data.length/this.dims[i]);for(let u=0;u=0;--p){const n=this.dims[p];if(p!==i){const e=c%n;h+=e*l,l*=a[p]}c=Math.floor(c/n)}d[h]+=this.data[u]**t}if(t!==1)for(let u=0;u=0;--u){const c=this.dims[u];if(u!==i){const l=h%c;d+=l*p,p*=this.dims[u]}h=Math.floor(h/c)}this.data[a]/=s.data[d]}return this}normalize(t=2,i=1){return this.clone().normalize_(t,i)}stride(){return dimsToStride(this.dims)}squeeze(t=null){return new Tensor(this.type,this.data,calc_squeeze_dims(this.dims,t))}squeeze_(t=null){return this.dims=calc_squeeze_dims(this.dims,t),this}unsqueeze(t=null){return new Tensor(this.type,this.data,calc_unsqueeze_dims(this.dims,t))}unsqueeze_(t=null){return this.dims=calc_unsqueeze_dims(this.dims,t),this}flatten_(t=0,i=-1){i=(i+this.dims.length)%this.dims.length;let s=this.dims.slice(0,t),a=this.dims.slice(t,i+1),d=this.dims.slice(i+1);return this.dims=[...s,a.reduce((u,h)=>u*h,1),...d],this}flatten(t=0,i=-1){return this.clone().flatten_(t,i)}view(...t){let i=-1;for(let s=0;su!==i?a*d:a,1);t[i]=this.data.length/s}return new Tensor(this.type,this.data,t)}neg_(){for(let t=0;td*u);if(i!==s)throw Error(`cannot reshape array of size ${i} into shape (${t})`);let a=m;for(let d=t.length-1;d>=0;d--)a=a.reduce((u,h)=>{let p=u[u.length-1];return p.lengthi!==1):typeof t=="number"?m[t]===1&&m.splice(t,1):Array.isArray(t)&&(m=m.filter((i,s)=>i!==1||!t.includes(s))),m}function calc_unsqueeze_dims(m,t){return t=safeIndex(t,m.length+1),m=m.slice(),m.splice(t,0,1),m}function safeIndex(m,t,i=null){if(m<-t||m>=t)throw new Error(`IndexError: index ${m} is out of bounds for dimension${i===null?"":" "+i} with size ${t}`);return m<0&&(m=(m%t+t)%t),m}function cat(m,t=0){t=safeIndex(t,m[0].dims.length);const i=m[0].dims.slice();i[t]=m.reduce((u,h)=>u+h.dims[t],0);const s=i.reduce((u,h)=>u*h,1),a=new m[0].data.constructor(s),d=m[0].type;if(t===0){let u=0;for(let h of m)a.set(h.data,u),u+=h.data.length}else{let u=0;for(let h=0;h=0;--n){const o=p.dims[n];let f=e%o;n===t&&(f+=u),l+=f*r,r*=i[n],e=Math.floor(e/o)}a[l]=p.data[c]}u+=p.dims[t]}}return new Tensor(d,a,i)}function stack(m,t=0){return cat(m.map(i=>i.unsqueeze(t)),t)}function std_mean(m,t=null,i=1,s=!1){if(t===null){const c=m.data.reduce((r,o)=>r+o,0)/m.data.length,l=Math.sqrt(m.data.reduce((r,o)=>r+(o-c)**2,0)/(m.data.length-i)),n=new Tensor(m.type,[c],[]);return[new Tensor(m.type,[l],[]),n]}t=safeIndex(t,m.dims.length);const a=mean(m,t,s),d=m.dims.slice();d[t]=1;const u=new m.data.constructor(m.data.length/m.dims[t]);for(let p=0;p=0;--l){const r=m.dims[l];if(l!==t){const o=n%r;c+=o*e,e*=d[l]}n=Math.floor(n/r)}u[c]+=(m.data[p]-a.data[c])**2}for(let p=0;pu+h,0);return new Tensor(m.type,[d/m.data.length],[])}t=safeIndex(t,m.dims.length);const s=m.dims.slice();s[t]=1;const a=new m.data.constructor(m.data.length/m.dims[t]);for(let d=0;d=0;--h){const l=m.dims[h];if(h!==t){const n=p%l;u+=n*c,c*=s[h]}p=Math.floor(p/l)}a[u]+=m.data[d]}if(m.dims[t]!==1)for(let d=0;d0||h>0;)switch(p.push(u-1),c.push(h-1),d[u][h].item()){case 0:--u,--h;break;case 1:--u;break;case 2:--h;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${u}, ${h}]. Please file a bug report.`)}return p.reverse(),c.reverse(),[p,c]}function dimsToStride(m){const t=new Array(m.length);for(let i=m.length-1,s=1;i>=0;--i)t[i]=s,s*=m[i];return t}async function loadTokenizer(m,t){return await Promise.all([getModelJSON(m,"tokenizer.json",!0,t),getModelJSON(m,"tokenizer_config.json",!0,t)])}function createPattern(m,t=!0){return m.Regex?new RegExp(t?m.Regex:`(${m.Regex})`,"gu"):m.String?m.String:(console.warn("Unknown pattern type:",m),null)}function clean_up_tokenization(m){return m.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n\'t/g,"n't").replace(/ \'m/g,"'m").replace(/ \'s/g,"'s").replace(/ \'ve/g,"'ve").replace(/ \'re/g,"'re")}function fuse(m,t){let i=[],s=0;for(;sthis.tokens_to_ids.get(s)??this.unk_token_id);return this.fuse_unk&&(i=fuse(i,this.unk_token_id)),i}convert_ids_to_tokens(t){return t.map(i=>this.vocab[i]??this.unk_token)}}class WordPieceTokenizer extends TokenizerModel{constructor(t){super(t),this.tokens_to_ids=t.vocab,this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[i,s]of this.tokens_to_ids)this.vocab[s]=i}encode(t){let i=[];for(let s of t){let a=[...s],d=!1,u=0,h=[];for(;u0&&(l=this.config.continuing_subword_prefix+l),this.tokens_to_ids.has(l)){c=l;break}--p}if(c===null){d=!0;break}h.push(c),u=p}d?i.push(this.unk_token):i.push(...h)}return i}}class Unigram extends TokenizerModel{constructor(t,i){super(t),this.vocab=new Array(t.vocab.size),this.scores=new Array(t.vocab.size);let s=0;t.vocab.forEach((a,d)=>{this.vocab[s]=d,this.scores[s]=a,++s}),this.unk_token_id=t.unk_id,this.unk_token=this.vocab[t.unk_id],this.tokens_to_ids=new Map(this.vocab.map((a,d)=>[a,d])),this.bosToken=" ",this.bosTokenId=this.tokens_to_ids.get(this.bosToken),this.eosToken=i.eos_token,this.eosTokenId=this.tokens_to_ids.get(this.eosToken),this.unkToken=this.vocab[this.unk_token_id],this.minScore=min(this.scores)[0],this.unkScore=this.minScore-10,this.scores[this.unk_token_id]=this.unkScore,this.trie=new CharTrie,this.trie.extend(this.vocab),this.fuse_unk=!0}populateNodes(t){const i=t.sentence,s=i.length;let a=0;for(;a{const m=[...Array.from({length:"~".charCodeAt(0)-"!".charCodeAt(0)+1},(a,d)=>d+"!".charCodeAt(0)),...Array.from({length:"¬".charCodeAt(0)-"¡".charCodeAt(0)+1},(a,d)=>d+"¡".charCodeAt(0)),...Array.from({length:"ÿ".charCodeAt(0)-"®".charCodeAt(0)+1},(a,d)=>d+"®".charCodeAt(0))];let t=m.slice(),i=0;for(let a=0;a<256;++a)m.includes(a)||(m.push(a),t.push(256+i),i+=1);let s=t.map(a=>String.fromCharCode(a));return Object.fromEntries(m.map((a,d)=>[a,s[d]]))})(),UNICODE_TO_BYTES=reverseDictionary(BYTES_TO_UNICODE);class BPE extends TokenizerModel{constructor(t){super(t),this.tokens_to_ids=t.vocab,this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[i,s]of this.tokens_to_ids)this.vocab[s]=i;this.bpe_ranks=Object.fromEntries(t.merges.map((i,s)=>[i,s])),this.merges=t.merges.map(i=>i.split(/\s+/)),this.end_of_word_suffix=t.end_of_word_suffix,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.cache=Object.create(null),this.fuse_unk??(this.fuse_unk=this.config.fuse_unk)}get_pairs(t){let i=new Set,s=t[0];for(let a=1;a{let r=this.bpe_ranks[n]??1/0,o=this.bpe_ranks[e]??1/0;return r<=o?n:e});if(!(d in this.bpe_ranks))break;let[u,h]=d.split(/\s+/g),p=[],c=0,l=-1;for(;c`<0x${u.toString(16).toUpperCase().padStart(2,"0")}>`)):i.push(this.unk_token)}return i}}class Normalizer extends Callable{constructor(t){super(),this.config=t}static fromConfig(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new BertNormalizer(t);case"Precompiled":return new Precompiled(t);case"Sequence":return new NormalizerSequence(t);case"Replace":return new Replace(t);case"NFC":return new NFC(t);case"NFKD":return new NFKD(t);case"StripAccents":return new StripAccents(t);case"Lowercase":return new Lowercase(t);case"Prepend":return new Prepend(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}normalize(t){throw Error("normalize should be implemented in subclass.")}_call(t){return this.normalize(t)}}class Replace extends Normalizer{normalize(t){let i=createPattern(this.config.pattern);return i===null||(t=t.replaceAll(i,this.config.content)),t}}class NFC extends Normalizer{normalize(t){return t=t.normalize("NFC"),t}}class NFKD extends Normalizer{normalize(t){return t=t.normalize("NFKD"),t}}class StripAccents extends Normalizer{normalize(t){return t=t.replace(/[\u0300-\u036f]/g,""),t}}class Lowercase extends Normalizer{normalize(t){return t=t.toLowerCase(),t}}class Prepend extends Normalizer{normalize(t){return t=this.config.prepend+t,t}}class NormalizerSequence extends Normalizer{constructor(t){super(t),this.normalizers=t.normalizers.map(i=>Normalizer.fromConfig(i))}normalize(t){return this.normalizers.reduce((i,s)=>s.normalize(i),t)}}class BertNormalizer extends Normalizer{_tokenize_chinese_chars(t){let i=[];for(let s=0;s=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103}stripAccents(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}normalize(t){return this.config.handle_chinese_chars&&(t=this._tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.stripAccents(t))):this.config.strip_accents&&(t=this.stripAccents(t)),t}}class PreTokenizer extends Callable{static fromConfig(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new BertPreTokenizer(t);case"Sequence":return new PreTokenizerSequence(t);case"WhitespaceSplit":return new WhitespaceSplit(t);case"Metaspace":return new MetaspacePreTokenizer(t);case"ByteLevel":return new ByteLevelPreTokenizer(t);case"Split":return new SplitPreTokenizer(t);case"Punctuation":return new PunctuationPreTokenizer(t);case"Digits":return new DigitsPreTokenizer(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}pre_tokenize_text(t){throw Error("pre_tokenize_text should be implemented in subclass.")}pre_tokenize(t){let i=[];return Array.isArray(t)?i=t.map(s=>this.pre_tokenize_text(s)):i=this.pre_tokenize_text(t),i.flat()}_call(t){return this.pre_tokenize(t)}}class BertPreTokenizer extends PreTokenizer{constructor(t){super(),this.pattern=new RegExp(`[^\\s${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]`,"gu")}pre_tokenize_text(t){return t.trim().match(this.pattern)||[]}}class ByteLevelPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space,this.trim_offsets=this.config.trim_offsets,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=BYTES_TO_UNICODE,this.text_encoder=new TextEncoder}pre_tokenize_text(t){return(this.use_regex?t.match(this.pattern)||[]:[t]).map(s=>(this.add_prefix_space&&!s.startsWith(" ")&&(s=" "+s),s=Array.from(this.text_encoder.encode(s),a=>this.byte_encoder[a]).join(""),s))}}class SplitPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=createPattern(this.config.pattern,this.config.invert)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:t.split(this.pattern).filter(i=>i)}}class PunctuationPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${PUNCTUATION_REGEX}]+|[${PUNCTUATION_REGEX}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}}class DigitsPreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t;const i=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(i,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}}class PostProcessor extends Callable{constructor(t){super(),this.config=t}static fromConfig(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new TemplateProcessing(t);case"ByteLevel":return new ByteLevelPostProcessor(t);case"RobertaProcessing":return new RobertaProcessing(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}post_process(t,...i){throw Error("post_process should be implemented in subclass.")}_call(t,...i){return this.post_process(t,...i)}}class RobertaProcessing extends PostProcessor{constructor(t){super(t),this.cls=t.cls[0],this.sep=t.sep[0]}post_process(t,i=null){return t=mergeArrays([this.cls],t,[this.sep]),i!==null&&(t=mergeArrays(t,[this.sep],i,[this.sep])),t}}class TemplateProcessing extends PostProcessor{constructor(t){super(t),this.single=t.single,this.pair=t.pair}post_process(t,i=null){let s=i===null?this.single:this.pair,a=[];for(let d of s)"SpecialToken"in d?a.push(d.SpecialToken.id):"Sequence"in d&&(d.Sequence.id==="A"?a=mergeArrays(a,t):d.Sequence.id==="B"&&(a=mergeArrays(a,i)));return a}}class ByteLevelPostProcessor extends PostProcessor{post_process(t){return t}}class Decoder extends Callable{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=t.trim_offsets}static fromConfig(t){switch(t.type){case"WordPiece":return new WordPieceDecoder(t);case"Metaspace":return new MetaspaceDecoder(t);case"ByteLevel":return new ByteLevelDecoder(t);case"Replace":return new ReplaceDecoder(t);case"ByteFallback":return new ByteFallback(t);case"Fuse":return new FuseDecoder(t);case"Strip":return new StripDecoder(t);case"Sequence":return new DecoderSequence(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}decode_chain(t){throw Error("`decode_chain` should be implemented in subclass.")}}class ReplaceDecoder extends Decoder{constructor(t){super(t)}decode_chain(t){let i=createPattern(this.config.pattern);return i===null?t:t.map(s=>s.replaceAll(i,this.config.content))}}class ByteFallback extends Decoder{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let i=[],s=[];for(let a of t){let d=null;if(a.length===6&&a.startsWith("<0x")&&a.endsWith(">")){let u=parseInt(a.slice(3,5),16);isNaN(u)||(d=u)}if(d!==null)s.push(d);else{if(s.length>0){let u=this.text_decoder.decode(Uint8Array.from(s));i.push(u),s=[]}i.push(a)}}if(s.length>0){let a=this.text_decoder.decode(Uint8Array.from(s));i.push(a),s=[]}return i}}class FuseDecoder extends Decoder{constructor(t){super(t)}decode_chain(t){return[t.join("")]}}class StripDecoder extends Decoder{constructor(t){super(t),this.content=this.config.content,this.start=this.config.start,this.stop=this.config.stop}decode_chain(t){return t.map(i=>{let s=0;for(let d=0;d(s!==0&&(i.startsWith(this.config.prefix)?i=i.replace(this.config.prefix,""):i=" "+i),this.cleanup&&(i=clean_up_tokenization(i)),i))}}class ByteLevelDecoder extends Decoder{constructor(t){super(t),this.byte_decoder=UNICODE_TO_BYTES,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let i=t.join(""),s=new Uint8Array([...i].map(d=>this.byte_decoder[d]));return this.text_decoder.decode(s)}decode_chain(t){let i=[],s=[];for(let a of t)this.added_tokens.includes(a)?(s.length>0&&(i.push(this.convert_tokens_to_string(s)),s=[]),i.push(a)):s.push(a);return s.length>0&&i.push(this.convert_tokens_to_string(s)),i}}class DecoderSequence extends Decoder{constructor(t){super(t),this.decoders=t.decoders.map(i=>Decoder.fromConfig(i))}decode_chain(t){return this.decoders.reduce((i,s)=>s.decode_chain(i),t)}}class MetaspacePreTokenizer extends PreTokenizer{constructor(t){super(),this.addPrefixSpace=t.add_prefix_space,this.replacement=t.replacement,this.strRep=t.str_rep||this.replacement}pre_tokenize(t){typeof t=="string"&&(t=t.trimStart().split(/\s+/));const i=[];for(let s of t){let a=s.replaceAll(" ",this.strRep);this.addPrefixSpace&&!a.startsWith(this.replacement)&&(a=this.strRep+a),i.push(a)}return i}}class MetaspaceDecoder extends Decoder{constructor(t){super(t),this.addPrefixSpace=t.add_prefix_space,this.replacement=t.replacement}decode_chain(t){let i=[];for(let s=0;sPreTokenizer.fromConfig(i))}pre_tokenize_text(t){return typeof t=="string"&&(t=[t]),this.tokenizers.reduce((i,s)=>s.pre_tokenize(i),t)}}class WhitespaceSplit extends PreTokenizer{constructor(t){super()}pre_tokenize_text(t){return whitespace_split(t)}}class PreTrainedTokenizer extends Callable{constructor(t,i){super(),this.normalizer=Normalizer.fromConfig(t.normalizer),this.pre_tokenizer=PreTokenizer.fromConfig(t.pre_tokenizer),t.model.vocab&&(Array.isArray(t.model.vocab)||(t.model.vocab=Object.entries(t.model.vocab)),t.model.vocab=new Map(t.model.vocab)),this.model=TokenizerModel.fromConfig(t.model,i),this.post_processor=PostProcessor.fromConfig(t.post_processor),this.decoder=Decoder.fromConfig(t.decoder),this.decoder.end_of_word_suffix=this.model.end_of_word_suffix,this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];for(let s of t.added_tokens){let a=s.id,d=s.content;this.added_tokens.push(d),this.model.tokens_to_ids.set(d,a),this.model.vocab[a]=d,s.special&&(this.special_tokens.push(d),this.all_special_ids.push(a))}this.decoder.added_tokens=this.added_tokens,this.added_tokens_regex=new RegExp("("+this.added_tokens.map(escapeRegExp).join("|")+")"),this.mask_token=this.getToken(i,"mask_token"),this.mask_token_id=this.model.tokens_to_ids.get(this.mask_token),this.pad_token=this.getToken(i,"pad_token","eos_token"),this.pad_token_id=this.model.tokens_to_ids.get(this.pad_token),this.sep_token=this.getToken(i,"sep_token"),this.sep_token_id=this.model.tokens_to_ids.get(this.sep_token),this.model_max_length=i.model_max_length,this.remove_space=i.remove_space,this.clean_up_tokenization_spaces=i.clean_up_tokenization_spaces??!0,this.padding_side="right"}getToken(t,...i){for(let s of i){let a=t[s];if(a)if(typeof a=="object"){if(a.__type==="AddedToken")return a.content;throw Error(`Unknown token: ${a}`)}else return a}return null}static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:a=null,local_files_only:d=!1,revision:u="main"}={}){let h=await loadTokenizer(t,{progress_callback:i,config:s,cache_dir:a,local_files_only:d,revision:u});return new this(...h)}prepare_model_inputs(t){return t}_call(t,{text_pair:i=null,padding:s=!1,truncation:a=null,max_length:d=null,return_tensor:u=!0}={}){let h;if(Array.isArray(t)){if(t.length===0)throw Error("text array must be non-empty");if(i!==null){if(Array.isArray(i)){if(t.length!==i.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");h=t.map((n,e)=>this.encode(n,i[e]))}else h=t.map(n=>this.encode(n))}else{if(t===null)throw Error("text may not be null");if(Array.isArray(i))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");h=[this.encode(t,i)]}let p=max(h.map(n=>n.length))[0];d===null&&(d=p),d=Math.min(d,this.model_max_length);let c=[];if(s||a)for(let n=0;nd)a&&(h[n]=h[n].slice(0,d)),c.push(new Array(h[n].length).fill(1));else if(s){let e=d-h[n].length;this.padding_side==="right"?(c.push(new Array(h[n].length).fill(1).concat(new Array(e).fill(0))),h[n].push(...new Array(e).fill(this.pad_token_id))):(c.push(new Array(e).fill(0).concat(new Array(h[n].length).fill(1))),h[n].unshift(...new Array(e).fill(this.pad_token_id)))}else c.push(new Array(h[n].length).fill(1));else c=h.map(n=>new Array(n.length).fill(1));if(u){if(!(s&&a)&&h.some(e=>e.length!==h[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");let n=[h.length,h[0].length];h=new Tensor("int64",BigInt64Array.from(h.flat().map(BigInt)),n),c=new Tensor("int64",BigInt64Array.from(c.flat().map(BigInt)),n)}else Array.isArray(t)||(h=h[0],c=c[0]);let l={input_ids:h,attention_mask:c};return l=this.prepare_model_inputs(l),l}_encode_text(t){return t===null?null:t.split(this.added_tokens_regex).filter(a=>a).map(a=>{if(this.added_tokens.includes(a))return a;{this.remove_space===!0&&(a=a.trim().split(/\s+/).join(" ")),this.normalizer!==null&&(a=this.normalizer(a));let d=this.pre_tokenizer!==null?this.pre_tokenizer(a):[a];return this.model(d)}}).flat()}encode(t,i=null){let s=this._encode_text(t),a=this._encode_text(i),d=this.post_processor!==null?this.post_processor(s,a):mergeArrays(s??[],a??[]);return this.model.convert_tokens_to_ids(d)}batch_decode(t,i={}){return t.map(s=>this.decode(s,i))}decode(t,i={}){if(!Array.isArray(t)||t.length===0||!isIntegralNumber(t[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(t,i)}decode_single(t,{skip_special_tokens:i=!1,clean_up_tokenization_spaces:s=null}){let a=this.model.convert_ids_to_tokens(t);i&&(a=a.filter(u=>!this.special_tokens.includes(u)));let d=this.decoder(a);return this.decoder.end_of_word_suffix&&(d=d.replaceAll(this.decoder.end_of_word_suffix," "),i&&(d=d.trim())),(s??this.clean_up_tokenization_spaces)&&(d=clean_up_tokenization(d)),d}}function add_token_types(m){if(m.input_ids instanceof Tensor)m.token_type_ids=new Tensor("int64",new BigInt64Array(m.input_ids.data.length),m.input_ids.dims);else if(Array.isArray(m.input_ids))Array.isArray(m.input_ids[0])?m.token_type_ids=m.input_ids.map(t=>new Array(t.length).fill(0)):m.token_type_ids=new Array(m.input_ids.length).fill(0);else throw new Error("Input ids must be a Tensor or an Array");return m}class BertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class AlbertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class MobileBertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class SqueezeBertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DistilBertTokenizer extends PreTrainedTokenizer{}class T5Tokenizer extends PreTrainedTokenizer{}class GPT2Tokenizer extends PreTrainedTokenizer{}class BartTokenizer extends PreTrainedTokenizer{}class RobertaTokenizer extends PreTrainedTokenizer{}class BloomTokenizer extends PreTrainedTokenizer{}class LlamaTokenizer extends PreTrainedTokenizer{}class XLMRobertaTokenizer extends PreTrainedTokenizer{}class MPNetTokenizer extends PreTrainedTokenizer{}class FalconTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class GPTNeoXTokenizer extends PreTrainedTokenizer{}class NllbTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s))}_build_translation_inputs(t,i,s){if(!this.language_codes.includes(s.tgt_lang))throw new Error(`Target language code "${s.tgt_lang}" is not valid. Must be one of: {${this.language_codes.join(", ")}}`);if(s.src_lang!==void 0){if(!this.language_codes.includes(s.src_lang))throw new Error(`Source language code "${s.src_lang}" is not valid. Must be one of: {${this.language_codes.join(", ")}}`);for(let a of this.post_processor.config.single)if("SpecialToken"in a&&this.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=s.src_lang;break}}return s.forced_bos_token_id=this.model.convert_tokens_to_ids([s.tgt_lang])[0],this._call(t,i)}}const WHISPER_LANGUAGES=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],WHISPER_LANGUAGE_MAPPING=new Map(WHISPER_LANGUAGES),WHISPER_TO_LANGUAGE_CODE_MAPPING=new Map([...WHISPER_LANGUAGES.map(([m,t])=>[t,m]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);class WhisperTokenizer extends PreTrainedTokenizer{_decode_asr(t,{return_timestamps:i=!1,return_language:s=!1,time_precision:a=null,force_full_sequences:d=!0}={}){if(a===null)throw Error("Must specify time_precision");let u=null;const h=i==="word";function p(){return{language:u,timestamp:[null,null],text:""}}const c=[];let l=p(),n=0;const e=this.model.convert_tokens_to_ids(["<|notimestamps|>"])[0]+1;let r=[],o=[],f=!1,g=null;const b=new Set(this.all_special_ids);for(let w of t){const v=w.tokens,S=h?w.token_timestamps:null;let A=null,I=e;if("stride"in w){const[F,R,$]=w.stride;if(n-=R,g=F-$,R&&(I=R/a+e),$)for(let L=v.length-1;L>=0;--L){const G=v[L];if(G>=e){if(A!==null&&(G-e)*a=e){const $=(R-e)*a+n,L=round($,2);if(A!==null&&R>=A)f=!0;else if(f||r.length>0&&R0?(r.push(x),h&&o.push(E)):r.every(F=>F.length===0)&&(l=p(),r=[],x=[],o=[],E=[])}if(r.length>0){if(d&&i)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");const[w,v]=this.findLongestCommonSequence(r,o),S=this.decode(w);l.text=S,h&&(l.words=this.collateWordTimestamps(w,v,u)),c.push(l)}let _=Object.create(null);const y=c.map(w=>w.text).join("");if(i||s){for(let w=0;w0;let h=u?[]:null,p=u?i[0]:null;for(let c=1;cL===F[G]).length,$=R/w+v;R>1&&$>n&&(n=$,e=[S,A,x,E])}const[o,f,g,b]=e,_=Math.floor((f+o)/2),y=Math.floor((b+g)/2);d.push(...s.slice(0,_)),s=l.slice(y),a=s.length,u&&(h.push(...p.slice(0,_)),p=i[c].slice(y))}return d.push(...s),u?(h.push(...p),[d,h]):[d,[]]}collateWordTimestamps(t,i,s){let[a,d,u]=this.combineTokensIntoWords(t,s),h=[];for(let p=0;p=a){let h=(u-a)*s;h=round(h,2),d.push(`<|${h}|>`),d.push([])}else d[d.length-1].push(u);return d=d.map(u=>typeof u=="string"?u:super.decode(u,i)),d.join("")}splitTokensOnUnicode(t){const i=this.decode(t,{decode_with_timestamps:!0}),s="�";let a=[],d=[],u=[],h=[],p=[],c=0;for(let l=0;l=this.model.tokens_to_ids.get("<|endoftext|>"),o=l.startsWith(" "),f=l.trim(),g=p.test(f);if(r||o||g||d.length===0)d.push(l),u.push(n),h.push(e);else{const b=d.length-1;d[b]+=l,u[b].push(...n),h[b].push(...e)}}return[d,u,h]}mergePunctuations(t,i,s,a,d){let u=structuredClone(t),h=structuredClone(i),p=structuredClone(s),c=u.length-2,l=u.length-1;for(;c>=0;)u[c].startsWith(" ")&&a.includes(u[c].trim())?(u[l]=u[c]+u[l],h[l]=mergeArrays(h[c],h[l]),p[l]=mergeArrays(p[c],p[l]),u[c]="",h[c]=[],p[c]=[]):l=c,--c;for(c=0,l=1;ln),h.filter(n=>n.length>0),p.filter(n=>n.length>0)]}get_decoder_prompt_ids({language:t=null,task:i=null,no_timestamps:s=!0}={}){let a=[];if(t){t=t.toLowerCase();let d=WHISPER_TO_LANGUAGE_CODE_MAPPING.get(t);if(d===void 0)if(WHISPER_LANGUAGE_MAPPING.has(t))d=t;else{const p=t.length===2?WHISPER_LANGUAGE_MAPPING.keys():WHISPER_LANGUAGE_MAPPING.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(p)}`)}let u=this.model.tokens_to_ids.get(`<|${d}|>`);if(u===void 0)throw new Error(`Unable to find language "${d}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);a.push(u)}else a.push(null);if(i){if(i=i.toLowerCase(),i!=="transcribe"&&i!=="translate")throw new Error(`Task "${i}" is not supported. Must be one of: ["transcribe", "translate"]`);let d=this.model.tokens_to_ids.get(`<|${i}|>`);if(d===void 0)throw new Error(`Unable to find task "${i}" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.`);a.push(d)}else a.push(null);if(s){let d=this.model.tokens_to_ids.get("<|notimestamps|>");if(d===void 0)throw new Error('Unable to find "<|notimestamps|>" in model vocabulary. Please report this issue at https://github.com/xenova/transformers.js/issues/new/choose.');a.push(d)}return a.map((d,u)=>[u+1,d]).filter(d=>d[1]!==null)}}class CodeGenTokenizer extends PreTrainedTokenizer{}class CLIPTokenizer extends PreTrainedTokenizer{}class MarianTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=this.model.vocab.filter(s=>this.languageRegex.test(s)),console.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(t){if(t===null)return null;let[i,...s]=t.trim().split(this.languageRegex);if(s.length===0)return super._encode_text(i);if(s.length===2){let[a,d]=s;return this.supported_language_codes.includes(a)||console.warn(`Unsupported language code "${a}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),mergeArrays([a],super._encode_text(d))}}}class CharTrie{constructor(){this.root=CharTrieNode.default()}extend(t){for(let i of t)this.push(i)}push(t){let i=this.root;for(let s of t){let a=i.children.get(s);a===void 0&&(a=CharTrieNode.default(),i.children.set(s,a)),i=a}i.isLeaf=!0}*commonPrefixSearch(t){let i=this.root,s="";for(let a=0;ap)&&(c=l.clone(),p=n)}if(c!==null)h.prev=c,h.backtraceScore=p;else return[]}++i}const s=[],d=this.beginNodes[t][0].prev;if(d===null)return[];let u=d.clone();for(;u.prev!==null;)s.push(u.clone()),u=u.clone().prev.clone();return s.reverse(),s}piece(t){return this.sentence.slice(t.pos,t.pos+t.length)}tokens(){return this.viterbi().map(i=>this.piece(i))}tokenIds(){return this.viterbi().map(i=>i.tokenId)}}class TokenLatticeNode{constructor(t,i,s,a,d){this.tokenId=t,this.nodeId=i,this.pos=s,this.length=a,this.score=d,this.prev=null,this.backtraceScore=0}clone(){const t=new TokenLatticeNode(this.tokenId,this.nodeId,this.pos,this.length,this.score);return t.prev=this.prev,t.backtraceScore=this.backtraceScore,t}}class AutoTokenizer{static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:a=null,cache_dir:d=null,local_files_only:u=!1,revision:h="main"}={}){let[p,c]=await loadTokenizer(t,{quantized:i,progress_callback:s,config:a,cache_dir:d,local_files_only:u,revision:h}),l=c.tokenizer_class.replace(/Fast$/,""),n=this.TOKENIZER_CLASS_MAPPING[l];return n||(console.warn(`Unknown tokenizer class "${l}", attempting to construct from base class.`),n=PreTrainedTokenizer),new n(p,c)}}Ee(AutoTokenizer,"TOKENIZER_CLASS_MAPPING",{T5Tokenizer,DistilBertTokenizer,BertTokenizer,MobileBertTokenizer,SqueezeBertTokenizer,AlbertTokenizer,GPT2Tokenizer,BartTokenizer,RobertaTokenizer,WhisperTokenizer,CodeGenTokenizer,CLIPTokenizer,MarianTokenizer,BloomTokenizer,NllbTokenizer,LlamaTokenizer,XLMRobertaTokenizer,MPNetTokenizer,FalconTokenizer,GPTNeoXTokenizer,PreTrainedTokenizer});async function loadConfig(m,t){return await getModelJSON(m,"config.json",!0,t)}class PretrainedConfig{constructor(t){this.model_type=null,this.is_encoder_decoder=!1,Object.assign(this,t)}static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:a=null,local_files_only:d=!1,revision:u="main"}={}){let h=s??await loadConfig(t,{progress_callback:i,config:s,cache_dir:a,local_files_only:d,revision:u});return new this(h)}}class AutoConfig{static async from_pretrained(...t){return PretrainedConfig.from_pretrained(...t)}}class LogitsProcessorList extends Callable{constructor(){super(),this.processors=[]}push(t){this.processors.push(t)}extend(t){this.processors.push(...t)}_call(t,i){for(let s of i)this.processors.forEach(a=>a(t,s))}[Symbol.iterator](){return this.processors.values()}}class LogitsProcessor extends Callable{_call(t,i){throw Error("`_call` should be implemented in a subclass")}}class ForceTokensLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.force_token_map=Object.fromEntries(t??[])}_call(t,i){let s=this.force_token_map[t.length];return exists(s)&&(i.data.fill(-1/0),i.data[s]=0),i}}class ForcedBOSTokenLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.bos_token_id=t}_call(t,i){return t.length===1&&(i.data.fill(-1/0),i.data[this.bos_token_id]=0),i}}class ForcedEOSTokenLogitsProcessor extends LogitsProcessor{constructor(t,i){super(),this.max_length=t,this.forced_eos_token_id=i}_call(t,i){}}class SuppressTokensAtBeginLogitsProcessor extends LogitsProcessor{constructor(t,i){super(),this.begin_suppress_tokens=t,this.begin_index=i}_call(t,i){if(t.length===this.begin_index)for(let s of this.begin_suppress_tokens)i.data[s]=-1/0;return i}}class WhisperTimeStampLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.eos_token_id=t.eos_token_id,this.no_timestamps_token_id=t.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=(t.forced_decoder_ids||[]).length+2,t.forced_decoder_ids.slice(-1)[0][1]===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=t.max_initial_timestamp_index}_call(t,i){if(i.data[this.no_timestamps_token_id]=-1/0,t.length===this.begin_index-1)return i.data.fill(-1/0),i.data[this.timestamp_begin]=0,i;const s=t.slice(this.begin_index),a=s.length>=1&&s[s.length-1]>=this.timestamp_begin,d=s.length<2||s[s.length-2]>=this.timestamp_begin;if(a&&(d?i.data.subarray(this.timestamp_begin).fill(-1/0):i.data.subarray(0,this.eos_token_id).fill(-1/0)),t.length===this.begin_index&&this.max_initial_timestamp_index!==null){const c=this.timestamp_begin+this.max_initial_timestamp_index;i.data.subarray(c+1).fill(-1/0)}const u=log_softmax(i.data),h=Math.log(u.subarray(this.timestamp_begin).map(Math.exp).reduce((c,l)=>c+l)),p=max(u.subarray(0,this.timestamp_begin))[0];return h>p&&i.data.subarray(0,this.timestamp_begin).fill(-1/0),i}}class NoRepeatNGramLogitsProcessor extends LogitsProcessor{constructor(t){super(),this.no_repeat_ngram_size=t}getNgrams(t){const i=t.length,s=[];for(let d=0;d0&&(a=a.map(d=>d/this.generation_config.temperature)),a}randomSelect(t){let i=t.reduce((a,d)=>a+d,0),s=Math.random()*i;for(let a=0;a1)return new BeamSearchSampler(t);if(t.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${t.num_return_sequences}.`);return new GreedySampler(t)}}class GreedySampler extends Sampler{sample(t,i=-1){let s=this.getLogits(t,i);return[[max(s)[1],0]]}}class MultinomialSampler extends Sampler{sample(t,i=-1){let s=t.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const a=this.getLogits(t,i),d=getTopItems(a,s),u=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},()=>{const h=this.randomSelect(u);return[d[h][0],Math.log(u[h])]})}}class BeamSearchSampler extends Sampler{sample(t,i=-1){let s=t.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));const a=this.getLogits(t,i),d=getTopItems(a,s),u=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},(h,p)=>[d[p][0],Math.log(u[p])])}}const{InferenceSession,Tensor:ONNXTensor}=ONNX;class ModelType{}class EncoderOnlyModelType extends ModelType{}class EncoderDecoderModelType extends ModelType{}class Seq2SeqModelType extends EncoderDecoderModelType{}class DecoderOnlyModelType extends ModelType{}const MODEL_TYPE_MAPPING=new Map,MODEL_CLASS_MAPPING=new Map;async function forward(m,t){return MODEL_TYPE_MAPPING.get(m.constructor.name)===DecoderOnlyModelType?await decoderForward(m,t):await encoderForward(m,t)}async function constructSession(m,t,i){let s=`onnx/${t}${i.quantized?"_quantized":""}.onnx`,a=await getModelFile(m,s,!0,i);try{return await InferenceSession.create(a,{executionProviders})}catch(d){if(executionProviders.length===1&&executionProviders[0]==="wasm")throw d;return console.warn(d),console.warn("Something went wrong during model construction (most likely a missing operation). Using `wasm` as a fallback. "),await InferenceSession.create(a,{executionProviders:["wasm"]})}}async function validateInputs(m,t){const i={},s=[];for(let u of m.inputNames)t[u]===void 0?s.push(u):i[u]=t[u];if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);const a=Object.keys(t).length,d=m.inputNames.length;if(a>d){let u=Object.keys(t).filter(h=>!m.inputNames.includes(h));console.warn(`WARNING: Too many inputs were provided (${a} > ${d}). The following inputs will be ignored: "${u.join(", ")}".`)}return i}async function sessionRun(m,t){const i=await validateInputs(m,t);try{let s=await m.run(i);return s=replaceTensors(s),s}catch(s){throw console.error(`An error occurred during model execution: "${s}".`),console.error("Inputs given to model:",i),s}}function replaceTensors(m){for(let t in m)m[t]instanceof ONNXTensor?m[t]=new Tensor(m[t]):typeof m[t]=="object"&&replaceTensors(m[t]);return m}function toI64Tensor(m){if(m instanceof Tensor)return m;if(m.length===0)throw Error("items must be non-empty");if(Array.isArray(m[0])){if(m.some(t=>t.length!==m[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new Tensor("int64",BigInt64Array.from(m.flat().map(t=>BigInt(t))),[m.length,m[0].length])}else return new Tensor("int64",BigInt64Array.from(m.map(t=>BigInt(t))),[1,m.length])}function prepareAttentionMask(m,t){let i=m.config.pad_token_id??null,s=m.config.eos_token_id??null;isIntegralNumber(s)&&(s=[s]);let a=t.indexOf(i)!==-1,d=s===null||!s.includes(i);if(a&&d){let u=BigInt64Array.from(t.data.map(h=>h!=i));return new Tensor("int64",u,t.dims)}else return new Tensor("int64",new BigInt64Array(t.data.length).fill(1n),t.dims)}function boolTensor(m){return new Tensor("bool",[m],[1])}async function seq2seqForward(m,t,{add_decoder_pkv:i=!0}={}){let{encoder_outputs:s,past_key_values:a}=t;s||(s=(await encoderForward(m,t)).last_hidden_state);let d={input_ids:t.decoder_input_ids,encoder_hidden_states:s,use_cache_branch:boolTensor(!!a)};m.decoder_merged_session.inputNames.includes("encoder_attention_mask")&&(d.encoder_attention_mask=t.attention_mask),m.addPastKeyValues(d,a,i);const u=await sessionRun(m.decoder_merged_session,d);let h=u.logits;a=m.getPastKeyValues(u,a);const p=m.getAttentions(u);return new Seq2SeqLMOutput({logits:h,past_key_values:a,encoder_outputs:s,...p})}function seq2seqStartBeams(m,t,i,s=!0){let a=[],d=0,u=m.config.decoder_start_token_id;Array.isArray(u)||(u=[u]);for(let h of t){h.dims=[1,...h.dims];let p={inputs:h,encoder_outputs:null,prev_model_outputs:null,output_token_ids:u,done:!1,score:0,id:d++};s&&(p.attention_mask=prepareAttentionMask(m,h)),a.push(p)}return a}async function seq2seqRunBeam(m,t,{input_name:i="input_ids"}={}){var d;let s={[i]:t.inputs,decoder_input_ids:toI64Tensor(t.output_token_ids.slice(-1)),encoder_outputs:t.encoder_outputs,past_key_values:(d=t.prev_model_outputs)==null?void 0:d.past_key_values};t.attention_mask&&(s.attention_mask=t.attention_mask);let a=await m.forward(s);return t.prev_model_outputs=a,t.encoder_outputs=a.encoder_outputs,a}async function encoderForward(m,t){let i={};for(let s of m.session.inputNames)i[s]=t[s];return await sessionRun(m.session,i)}async function decoderForward(m,t){let{input_ids:i,past_key_values:s,attention_mask:a}=t,d={input_ids:i,attention_mask:a??prepareAttentionMask(m,i),use_cache_branch:boolTensor(s!==null)};m.addPastKeyValues(d,s);let u=await sessionRun(m.session,d),h=u.logits;return s=m.getPastKeyValues(u,s),{logits:h,past_key_values:s}}function decoderStartBeams(m,t,i,s){let a=[],d=0;for(let u of t){let h=u.tolist().map(Number);u.dims=[1,...u.dims];let p;s?(p=s[d],p.dims=[1,...p.dims]):p=prepareAttentionMask(m,u);let c={input:u,model_input_ids:u,attention_mask:p,prev_model_outputs:null,output_token_ids:h,num_output_tokens:i,done:!1,score:0,id:d++};a.push(c)}return a}async function decoderRunBeam(m,t){var d;let i=new BigInt64Array(t.output_token_ids.length).fill(1n),s={input_ids:t.model_input_ids,attention_mask:new Tensor("int64",i,[1,i.length]),past_key_values:(d=t.prev_model_outputs)==null?void 0:d.past_key_values},a=await m.forward(s);return t.prev_model_outputs=a,a}function decoderUpdatebeam(m,t){m.output_token_ids=[...m.output_token_ids,t],m.model_input_ids=new Tensor("int64",[BigInt(t)],[1,1])}class PreTrainedModel extends Callable{constructor(t,i){super(),this.config=t,this.session=i}async dispose(){let t=[];for(let i of Object.keys(this)){let s=this[i];s instanceof InferenceSession&&t.push(s.handler.dispose())}return await Promise.all(t)}static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:a=null,cache_dir:d=null,local_files_only:u=!1,revision:h="main"}={}){let p={quantized:i,progress_callback:s,config:a,cache_dir:d,local_files_only:u,revision:h},c=MODEL_TYPE_MAPPING.get(this.name),l;if(c===DecoderOnlyModelType)l=await Promise.all([AutoConfig.from_pretrained(t,p),constructSession(t,"decoder_model_merged",p)]);else if(c===Seq2SeqModelType)l=await Promise.all([AutoConfig.from_pretrained(t,p),constructSession(t,"encoder_model",p),constructSession(t,"decoder_model_merged",p),getModelJSON(t,"generation_config.json",!1,p)]);else if(c===EncoderDecoderModelType)l=await Promise.all([AutoConfig.from_pretrained(t,p),constructSession(t,"encoder_model",p),constructSession(t,"decoder_model_merged",p)]);else if(c===EncoderOnlyModelType)l=await Promise.all([AutoConfig.from_pretrained(t,p),constructSession(t,"model",p)]);else throw console.warn("Malformed class definition.",this),Error(`Unable to load model: ${t}. Please report this bug at https://github.com/xenova/transformers.js/issues/new/choose.`);return new this(...l)}async _call(t){return await this.forward(t)}async forward(t){return await forward(this,t)}_get_logits_processor(t,i,s=null){const a=new LogitsProcessorList;if(t.repetition_penalty!==null&&t.repetition_penalty!==1&&a.push(new RepetitionPenaltyLogitsProcessor(t.repetition_penalty)),t.no_repeat_ngram_size!==null&&t.no_repeat_ngram_size>0&&a.push(new NoRepeatNGramLogitsProcessor(t.no_repeat_ngram_size)),t.forced_bos_token_id!==null&&a.push(new ForcedBOSTokenLogitsProcessor(t.forced_bos_token_id)),t.forced_eos_token_id!==null&&a.push(new ForcedEOSTokenLogitsProcessor(t.max_length,t.forced_eos_token_id)),t.begin_suppress_tokens!==null){let d=i>1||t.forced_bos_token_id===null?i:i+1;t.forced_decoder_ids!==null&&(d+=t.forced_decoder_ids[t.forced_decoder_ids.length-1][0]),a.push(new SuppressTokensAtBeginLogitsProcessor(t.begin_suppress_tokens,d))}return t.forced_decoder_ids!==null&&a.push(new ForceTokensLogitsProcessor(t.forced_decoder_ids)),s!==null&&a.extend(s),a}_get_generation_config(t){let i=new GenerationConfig;return"generation_config"in this&&Object.assign(i,this.generation_config),t!==null&&Object.assign(i,t),i}async generate(t,i=null,s=null,{inputs_attention_mask:a=null}={}){if(!(t instanceof Tensor)&&!isTypedArray(t)&&!Array.isArray(t))throw Error(`\`inputs\` must be a Tensor, TypedArray, or Array, but is "${t.constructor.name}".`);let d;if(this.config.is_encoder_decoder)d=0;else if(d=t instanceof Tensor?t.dims[0]:t.length,d===0)throw Error("Must supply a non-empty array of input token ids.");i=this._get_generation_config(i),s=s??new LogitsProcessorList,s=this._get_logits_processor(i,d,s);let u=1;const h=u+(i.max_new_tokens??1/0),p=Number.isInteger(i.max_length)&&(i.max_new_tokens??null)===null;let c=Sampler.getSampler(i),l=this.getStartBeams(t,u,a);for(;l.some(o=>!o.done)&&u=i.max_length){f.done=!0,o.push(f);continue}let g=await this.runBeam(f);i.output_attentions&&this.addAttentionsToBeam(f,g),i.output_scores;let b=g.logits.slice(null,-1,null);s(f.output_token_ids,b);let _=c(b);for(let[y,w]of _){let v={...f};this.updateBeam(v,y),v.score+=w,y===this.config.eos_token_id&&(v.done=!0),o.push(v)}}++u,o=this.groupBeams(o).map(f=>f.sort((g,b)=>b.score-g.score).slice(0,i.num_beams)),l=o.flat(),i.callback_function&&i.callback_function(l)}const n=this.groupBeams(l),e=o=>n.map(f=>i.num_return_sequences>1?f.slice(0,i.num_return_sequences).map(g=>g[o]):[f[0][o]]).flat(),r=e("output_token_ids");if(i.return_dict_in_generate){const o=e("decoder_attentions"),f=e("cross_attentions");return{sequences:r,decoder_attentions:o,cross_attentions:f}}else return r}addAttentionsToBeam(t,i){if(this.config.is_encoder_decoder){if(!i.cross_attentions||i.cross_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce cross-attentions. This is most likely because the model was not exported with `output_attentions=True`.");t.cross_attentions||(t.cross_attentions=[]),t.cross_attentions.push(i.cross_attentions)}if(!i.decoder_attentions||i.decoder_attentions.length===0)throw Error("`output_attentions` is true, but the model did not produce decoder-attentions. This is most likely because the model was not exported with `output_attentions=True`.");t.decoder_attentions||(t.decoder_attentions=[]),t.decoder_attentions.push(i.decoder_attentions)}groupBeams(t){const i=Object.create(null);for(const s of t)i[s.id]===void 0?i[s.id]=[s]:i[s.id].push(s);return Object.values(i)}getPastKeyValues(t,i){const s=Object.create(null);for(const a in t)if(a.startsWith("present")){let d=a.replace("present","past_key_values");i&&a.includes("encoder")?s[d]=i[d]:s[d]=t[a]}return s}getAttentions(t){const i=Object.create(null);for(const s of["cross_attentions","decoder_attentions"]){const a=[];for(const d in t)if(d.startsWith(s)){const u=d.split(".").pop();a[u]=t[d]}i[s]=a}return i}addPastKeyValues(t,i,s=!1){if(i)Object.assign(t,i);else if(s){let a=[1,this.num_encoder_heads,0,this.encoder_dim_kv];for(let u=0;u{let c=Array.from({length:this.config.decoder_layers},(f,g)=>cat(p.map(b=>b[g]),2)),l=stack(i.map(([f,g])=>c[f].slice(null,g)));l=l.transpose(1,0,2,3);let[n,e]=std_mean(l,-2,0,!0),r=l.clone();for(let f=0;fl[g+1]-l[g]),r=mergeArrays([1],e).map(f=>!!f),o=[];for(let f=0;f{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(m,t)},loadImageFunction=self.createImageBitmap,ImageDataClass=self.ImageData;else if(fs)loadImageFunction=async m=>{const i=(await m.metadata()).channels;let{data:s,info:a}=await m.raw().toBuffer({resolveWithObject:!0});const d=new RawImage(new Uint8ClampedArray(s),a.width,a.height,a.channels);return i!==void 0&&i!==a.channels&&d.convert(i),d};else throw new Error("Unable to load image processing library.");const RESAMPLING_MAPPING={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"};class RawImage{constructor(t,i,s,a){this._update(t,i,s,a)}static async read(t){if(t instanceof RawImage)return t;if(isString(t)||t instanceof URL)return await this.fromURL(t);throw new Error(`Unsupported input type: ${typeof t}`)}static async fromURL(t){let s=await(await getFile(t)).blob();return this.fromBlob(s)}static async fromBlob(t){if(BROWSER_ENV){let i=await loadImageFunction(t);const s=createCanvasFunction(i.width,i.height).getContext("2d");return s.drawImage(i,0,0),new this(s.getImageData(0,0,i.width,i.height).data,i.width,i.height,4)}else{let i=fs(await t.arrayBuffer());return await loadImageFunction(i)}}grayscale(){if(this.channels===1)return this;let t=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let i=0,s=0;i=0?p=s:l=-s,a>=0?c=a:n=-a,h.drawImage(u,p,c,t,i,l,n,t,i),new RawImage(h.getImageData(0,0,t,i).data,t,i,4).convert(d)}else{let d=fs(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}});if(s>=0&&a>=0)d=d.extract({left:Math.floor(s),top:Math.floor(a),width:t,height:i});else if(s<=0&&a<=0){let u=Math.floor(-a),h=Math.floor(-s);d=d.extend({top:u,left:h,right:t-this.width-h,bottom:i-this.height-u})}else{let u=[0,0],h=0;a<0?(u[0]=Math.floor(-a),u[1]=i-this.height-u[0]):h=Math.floor(a);let p=[0,0],c=0;s<0?(p[0]=Math.floor(-s),p[1]=t-this.width-p[0]):c=Math.floor(s),d=d.extend({top:u[0],bottom:u[1],left:p[0],right:p[1]}).extract({left:c,top:h,width:t,height:i})}return await loadImageFunction(d)}}toCanvas(){let t=this.clone().rgba(),i=createCanvasFunction(t.width,t.height),s=new ImageDataClass(t.data,t.width,t.height);return i.getContext("2d").putImageData(s,0,0),i}_update(t,i,s,a=null){return this.data=t,this.width=i,this.height=s,a!==null&&(this.channels=a),this}clone(){return new RawImage(this.data.slice(),this.width,this.height,this.channels)}convert(t){if(this.channels===t)return this;switch(t){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}save(t,i="image/png"){if(!env.useFS)throw new Error("Unable to save the image because filesystem is disabled in this environment.");const a=this.toCanvas().toBuffer(i);fs.writeFileSync(t,a)}}async function read_audio(m,t){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/tutorials/node-audio-processing.");const i=await(await getFile(m)).arrayBuffer(),s=new AudioContext({sampleRate:t});typeof t>"u"&&console.warn(`No sampling rate provided, using default of ${s.sampleRate}Hz.`);const a=await s.decodeAudioData(i);let d;if(a.numberOfChannels===2){const u=Math.sqrt(2);let h=a.getChannelData(0),p=a.getChannelData(1);d=new Float32Array(h.length);for(let c=0;c=o?e[_]=r*Math.exp(f*(y-o)):e[_]=l+n*y,g[_]=d.map(w=>e[_]-w)}const b=e.slice(1).map((_,y)=>1/(_-e[y]));for(let _=0;_this.preprocess(a)));return i.forEach(a=>a.pixel_values.dims=[1,...a.pixel_values.dims]),{pixel_values:cat(i.map(a=>a.pixel_values)),original_sizes:i.map(a=>a.original_size),reshaped_input_sizes:i.map(a=>a.reshaped_input_size)}}}class ViTFeatureExtractor extends ImageFeatureExtractor{}class MobileViTFeatureExtractor extends ImageFeatureExtractor{}class DetrFeatureExtractor extends ImageFeatureExtractor{async _call(t){let i=await super._call(t),s=[i.pixel_values.dims[0],64,64];return i.pixel_mask=new Tensor("int64",new BigInt64Array(s.reduce((a,d)=>a*d)).fill(1n),s),i}center_to_corners_format([t,i,s,a]){return[t-s/2,i-a/2,t+s/2,i+a/2]}post_process_object_detection(t,i=.5,s=null){const a=t.logits,d=t.pred_boxes,[u,h,p]=a.dims;if(s!==null&&s.length!==u)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let l=0;li){let w=o[f].data;w=this.center_to_corners_format(w),n!==null&&(w=w.map((v,S)=>v*n[(S+1)%2])),e.boxes.push(w),e.classes.push(b),e.scores.push(y)}}c.push(e)}return c}remove_low_and_no_objects(t,i,s,a){let d=[],u=[],h=[];for(let p=0;ps&&(d.push(l),u.push(r),h.push(n))}return[d,u,h]}check_segment_validity(t,i,s,a=.5,d=.8){let u=[],h=0,p=0;for(let l=0;l=a&&++p;let c=h>0&&p>0;return c&&(c=h/p>d),[c,u]}compute_segments(t,i,s,a,d,u=null,h=null){let[p,c]=h??t[0].dims,l=new Tensor("int32",new Int32Array(p*c),[p,c]),n=[];if(h!==null)for(let f=0;fr[b]&&(e[b]=f,r[b]=t[f].data[b])}let o=0;for(let f=0;fBigInt(Math.round(p)))),u);return{pixel_values:s,original_sizes:a,reshaped_input_sizes:d,input_points:h}}post_process_masks(t,i,s,{mask_threshold:a=0,binarize:d=!0,pad_size:u=null}={}){let h=[];u=u??this.pad_size;let p=[u.height,u.width];for(let c=0;c_>a),b.dims)),b.dims=[1,...b.dims],r.push(b)}let o=cat(r);h.push(o)}return h}}class WhisperFeatureExtractor extends FeatureExtractor{constructor(t){var i;super(t),(i=this.config).mel_filters??(i.mel_filters=getMelFilters(this.config.sampling_rate,this.config.n_fft,this.config.feature_size))}calcOffset(t,i){return Math.abs((t+i)%(2*i)-i)}padReflect(t,i,s){const a=new Float32Array(t.length+i+s),d=t.length-1;for(let u=0;u>1;++v){const S=(v+1-s)**2/2,A=Math.sqrt(b**2+_**2)**S,I=S*Math.atan2(_,b);let x=2*v;c[x]=A*Math.cos(I),c[x+1]=A*Math.sin(I),l[x]=c[x],l[x+1]=-c[x+1]}const y=c.subarray(a,d),w=new FFT(u>>1);w.transform(r,l);for(let v=0;v>1,F=S[E]*i[E];n[I]=F*y[I],n[x]=F*y[x]}w.transform(o,n);for(let I=0;Ia?u-a:0,c=u>1,c=new Float32Array(h*p);for(let b=0;bthis.config.n_samples&&console.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`.");let i=t.slice(0,this.config.n_samples),s=this._extract_fbank_features(i);return{input_features:new Tensor("float32",s.data,[1,...s.dims])}}}class Processor extends Callable{constructor(t){super(),this.feature_extractor=t}async _call(t){return await this.feature_extractor(t)}}class SamProcessor extends Processor{async _call(t,i){return await this.feature_extractor(t,i)}post_process_masks(...t){return this.feature_extractor.post_process_masks(...t)}}class WhisperProcessor extends Processor{async _call(t){return await this.feature_extractor(t)}}class AutoProcessor{static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:a=null,local_files_only:d=!1,revision:u="main"}={}){let h=s??await getModelJSON(t,"preprocessor_config.json",!0,{progress_callback:i,config:s,cache_dir:a,local_files_only:d,revision:u}),p=h.feature_extractor_type??h.image_processor_type,c=this.FEATURE_EXTRACTOR_CLASS_MAPPING[p];if(!c)if(h.size!==void 0)console.warn("Feature extractor type not specified, assuming ImageFeatureExtractor due to size parameter in config."),c=ImageFeatureExtractor;else throw new Error(`Unknown Feature Extractor type: ${h.feature_extractor_type}`);let l=this.PROCESSOR_CLASS_MAPPING[h.processor_class]??Processor,n=new c(h);return new l(n)}}Ee(AutoProcessor,"FEATURE_EXTRACTOR_CLASS_MAPPING",{WhisperFeatureExtractor,ViTFeatureExtractor,MobileViTFeatureExtractor,DetrFeatureExtractor,SamImageProcessor}),Ee(AutoProcessor,"PROCESSOR_CLASS_MAPPING",{WhisperProcessor,SamProcessor});async function prepareImages(m){return Array.isArray(m)||(m=[m]),m=await Promise.all(m.map(t=>RawImage.read(t))),m}class Pipeline extends Callable{constructor(t,i,s){super(),this.task=t,this.tokenizer=i,this.model=s}async dispose(){await this.model.dispose()}async _call(t){let i=this.tokenizer(t,{padding:!0,truncation:!0}),s=await this.model(i);return[i,s]}}class TextClassificationPipeline extends Pipeline{async _call(t,{topk:i=1}={}){let[s,a]=await super._call(t),d=this.model.config.id2label,u=[];for(let h of a.logits){let c=getTopItems(softmax(h.data),i).map(function(l){return{label:d[l[0]],score:l[1]}});i===1?u.push(...c):u.push(c)}return Array.isArray(t)||i===1?u:u[0]}}class TokenClassificationPipeline extends Pipeline{async _call(t,{ignore_labels:i=["O"]}={}){let s=Array.isArray(t);s||(t=[t]);let a=this.tokenizer,[d,u]=await super._call(t),h=u.logits,p=this.model.config.id2label,c=[];for(let l=0;l[r,o]).filter(r=>r[1]>c),n=Array.from(softmax(d.end_logits[h].data)).map((r,o)=>[r,o]).filter(r=>r[1]>c),e=product(l,n).filter(r=>r[0][1]<=r[1][1]).map(r=>[r[0][1],r[1][1],r[0][0]*r[1][0]]).sort((r,o)=>o[2]-r[2]);for(let r=0;r{let o=[...p];return o[c]=r[0],{score:r[1],token:r[0],token_str:d.model.vocab[r[0]],sequence:d.decode(o,{skip_special_tokens:!0})}}))}return Array.isArray(t)?u:u[0]}}class Text2TextGenerationPipeline extends Pipeline{constructor(){super(...arguments);Ee(this,"_key",null)}async _call(i,s={}){Array.isArray(i)||(i=[i]),this.model.config.prefix&&(i=i.map(c=>this.model.config.prefix+c));let a=this.model.config.task_specific_params;a&&a[this.task]&&a[this.task].prefix&&(i=i.map(c=>a[this.task].prefix+c));let d={padding:!0,truncation:!0},u;this instanceof TranslationPipeline&&"_build_translation_inputs"in this.tokenizer?u=this.tokenizer._build_translation_inputs(i,d,s).input_ids:u=this.tokenizer(i,d).input_ids;let h=await this.model.generate(u,s),p=this.tokenizer.batch_decode(h,{skip_special_tokens:!0});return this._key!==null&&(p=p.map(c=>this._key===null?c:{[this._key]:c})),p}}class SummarizationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);Ee(this,"_key","summary_text")}}class TranslationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);Ee(this,"_key","translation_text")}}class TextGenerationPipeline extends Pipeline{async _call(t,i={}){let s=typeof t=="string"||t instanceof String;s&&(t=[t]),this.tokenizer.padding_side="left";let a=this.tokenizer(t,{padding:!0,truncation:!0}),d=a.input_ids,u=a.attention_mask,h=await this.model.generate(d,i,null,{inputs_attention_mask:u});const p=this.tokenizer.batch_decode(h,{skip_special_tokens:!0}),c=Array.from({length:t.length},l=>[]);for(let l=0;l[a.toLowerCase(),d])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(console.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction,this.contradiction_id===void 0&&(console.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(t,i,{hypothesis_template:s="This example is {}.",multi_label:a=!1}={}){let d=Array.isArray(t);d||(t=[t]),Array.isArray(i)||(i=[i]);let u=i.map(c=>s.replace("{}",c)),h=a||i.length===1,p=[];for(let c of t){let l=[];for(let r of u){let o=this.tokenizer(c,{text_pair:r}),f=await this.model(o);h?l.push([f.logits.data[this.contradiction_id],f.logits.data[this.entailment_id]]):l.push(f.logits.data[this.entailment_id])}let n;h?n=l.map(r=>softmax(r)[1]):n=softmax(l);let e=n.map((r,o)=>[r,o]).sort((r,o)=>o[0]-r[0]);p.push({sequence:c,labels:e.map(r=>i[r[1]]),scores:e.map(r=>r[0])})}return d?p:p[0]}}class FeatureExtractionPipeline extends Pipeline{async _call(t,{pooling:i="none",normalize:s=!1}={}){let[a,d]=await super._call(t),u=d.last_hidden_state??d.logits;if(i!=="none")if(i==="mean")u=mean_pooling(u,a.attention_mask);else throw Error(`Pooling method '${i}' not supported.`);return s&&(u=u.normalize(2,-1)),u}}class AutomaticSpeechRecognitionPipeline extends Pipeline{constructor(t,i,s,a){super(t,i,s),this.processor=a}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,i={}){let s=i.return_timestamps??!1,a=i.chunk_length_s??0,d=i.stride_length_s??null,u=i.chunk_callback??null,h=i.force_full_sequences??!1;s==="word"&&(i.return_token_timestamps=!0);let p=pop(i,"language",null),c=pop(i,"task",null);if(p||c||s){if(i.forced_decoder_ids)throw new Error("Cannot specify `language`/`task`/`return_timestamps` and `forced_decoder_ids` at the same time.");let o=this.tokenizer.get_decoder_prompt_ids({language:p,task:c,no_timestamps:!s});o.length>0&&(i.forced_decoder_ids=o)}let l=!Array.isArray(t);l&&(t=[t]);const n=this.processor.feature_extractor.config.sampling_rate,e=this.processor.feature_extractor.config.chunk_length/this.model.config.max_source_positions;let r=[];for(let o of t){o=await this._preprocess(o,n);let f=[];if(a>0){if(d===null)d=a/6;else if(a<=d)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");const _=n*a,y=n*d,w=_-2*y;let v=0;for(;v=o.length;f.push({stride:[S.length,I?0:y,x?0:y],input_features:A.input_features,is_last:x}),v+=w}}else f=[{stride:[o.length,0,0],input_features:(await this.processor(o)).input_features,is_last:!0}];for(let _ of f){let y=await this.model.generate(_.input_features,i);s==="word"?(_.tokens=y.sequences[0],_.token_timestamps=y.token_timestamps.tolist()[0].map(w=>round(w,2))):_.tokens=y[0],_.stride=_.stride.map(w=>w/n),u!==null&&u(_)}let[g,b]=this.tokenizer._decode_asr(f,{time_precision:e,return_timestamps:s,force_full_sequences:h});r.push({text:g,...b})}return l?r[0]:r}}class ImageToTextPipeline extends Pipeline{constructor(t,i,s,a){super(t,i,s),this.processor=a}async _call(t,i={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:a}=await this.processor(t),d=[];for(let u of a){u.dims=[1,...u.dims];let h=await this.model.generate(u,i),p=this.tokenizer.batch_decode(h,{skip_special_tokens:!0}).map(c=>({generated_text:c.trim()}));d.push(p)}return s?d:d[0]}}class ImageClassificationPipeline extends Pipeline{constructor(t,i,s){super(t,null,i),this.processor=s}async _call(t,{topk:i=1}={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:a}=await this.processor(t),d=await this.model({pixel_values:a}),u=this.model.config.id2label,h=[];for(let p of d.logits){let l=getTopItems(softmax(p.data),i).map(function(n){return{label:u[n[0]],score:n[1]}});i===1?h.push(...l):h.push(l)}return s||i===1?h:h[0]}}class ImageSegmentationPipeline extends Pipeline{constructor(t,i,s){super(t,null,i),this.processor=s,this.subtasks_mapping={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"}}async _call(t,{threshold:i=.5,mask_threshold:s=.5,overlap_mask_area_threshold:a=.8,label_ids_to_fuse:d=null,target_sizes:u=null,subtask:h=null}={}){if(Array.isArray(t)&&t.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");t=await prepareImages(t);let c=t.map(f=>[f.height,f.width]),{pixel_values:l,pixel_mask:n}=await this.processor(t),e=await this.model({pixel_values:l,pixel_mask:n}),r=null;if(h!==null)r=this.subtasks_mapping[h];else for(let[f,g]of Object.entries(this.subtasks_mapping))if(g in this.processor.feature_extractor){r=this.processor.feature_extractor[g].bind(this.processor.feature_extractor),h=f;break}let o=[];if(h==="panoptic"||h==="instance"){let f=r(e,i,s,a,d,u??c)[0],g=f.segmentation,b=this.model.config.id2label;for(let _ of f.segments_info){let y=new Uint8ClampedArray(g.data.length);for(let v=0;vs.replace("{}",l)),u=this.tokenizer(d,{padding:!0,truncation:!0}),{pixel_values:h}=await this.processor(t),p=await this.model({...u,pixel_values:h}),c=[];for(let l of p.logits_per_image){let n=softmax(l.data);c.push([...n].map((e,r)=>({score:e,label:i[r]})))}return a?c:c[0]}}class ObjectDetectionPipeline extends Pipeline{constructor(t,i,s){super(t,null,i),this.processor=s}async _call(t,{threshold:i=.9,percentage:s=!1}={}){let a=Array.isArray(t);if(a&&t.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");t=await prepareImages(t);let d=s?null:t.map(n=>[n.height,n.width]),{pixel_values:u,pixel_mask:h}=await this.processor(t),p=await this.model({pixel_values:u,pixel_mask:h}),c=this.processor.feature_extractor.post_process_object_detection(p,i,d),l=this.model.config.id2label;return c.forEach(n=>n.labels=n.classes.map(e=>l[e])),a?c:c[0]}}const SUPPORTED_TASKS={"text-classification":{tokenizer:AutoTokenizer,pipeline:TextClassificationPipeline,model:AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:AutoTokenizer,pipeline:TokenClassificationPipeline,model:AutoModelForTokenClassification,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:AutoTokenizer,pipeline:QuestionAnsweringPipeline,model:AutoModelForQuestionAnswering,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:AutoTokenizer,pipeline:FillMaskPipeline,model:AutoModelForMaskedLM,default:{model:"Xenova/bert-base-uncased"},type:"text"},summarization:{tokenizer:AutoTokenizer,pipeline:SummarizationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:AutoTokenizer,pipeline:TranslationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:AutoTokenizer,pipeline:Text2TextGenerationPipeline,model:AutoModelForSeq2SeqLM,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:AutoTokenizer,pipeline:TextGenerationPipeline,model:AutoModelForCausalLM,default:{model:"Xenova/gpt2"},type:"text"},"zero-shot-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotClassificationPipeline,model:AutoModelForSequenceClassification,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"automatic-speech-recognition":{tokenizer:AutoTokenizer,pipeline:AutomaticSpeechRecognitionPipeline,model:AutoModelForSeq2SeqLM,processor:AutoProcessor,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"image-to-text":{tokenizer:AutoTokenizer,pipeline:ImageToTextPipeline,model:AutoModelForVision2Seq,processor:AutoProcessor,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:ImageClassificationPipeline,model:AutoModelForImageClassification,processor:AutoProcessor,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:ImageSegmentationPipeline,model:AutoModelForImageSegmentation,processor:AutoProcessor,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"zero-shot-image-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotImageClassificationPipeline,model:AutoModel,processor:AutoProcessor,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:ObjectDetectionPipeline,model:AutoModelForObjectDetection,processor:AutoProcessor,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"feature-extraction":{tokenizer:AutoTokenizer,pipeline:FeatureExtractionPipeline,model:AutoModel,default:{model:"Xenova/all-MiniLM-L6-v2"},type:"text"}},TASK_ALIASES={"sentiment-analysis":"text-classification",ner:"token-classification",vqa:"visual-question-answering",asr:"automatic-speech-recognition",embeddings:"feature-extraction"};async function pipeline(m,t=null,{quantized:i=!0,progress_callback:s=null,config:a=null,cache_dir:d=null,local_files_only:u=!1,revision:h="main"}={}){m=TASK_ALIASES[m]??m;let p=SUPPORTED_TASKS[m.split("_",1)[0]];if(!p)throw Error(`Unsupported pipeline: ${m}. Must be one of [${Object.keys(SUPPORTED_TASKS)}]`);t||(t=p.default.model,console.log(`No model specified. Using default model: "${t}".`));let c=p.tokenizer,l=p.model,n=p.pipeline,e=p.processor,r=[],o={quantized:i,progress_callback:s,config:a,cache_dir:d,local_files_only:u,revision:h};c&&r.push(c.from_pretrained(t,o)),l&&r.push(l.from_pretrained(t,o)),e&&r.push(e.from_pretrained(t,o));let f=await Promise.all(r);return dispatchCallback(s,{status:"ready",task:m,model:t}),new n(m,...f)}function product(...m){return m.reduce((t,i)=>t.flatMap(s=>i.map(a=>[s,a])))}const chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function encode$3(m){let t="";for(let i=0;i>2],t+=chars[(m[i]&3)<<4|m[i+1]>>4],t+=chars[(m[i+1]&15)<<2|m[i+2]>>6],t+=chars[m[i+2]&63];return m.length%3===2?t=t.substring(0,t.length-1)+"=":m.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function decode$3(m){let t=new Uint8Array(256);for(let a=0;a>4,s[d++]=(h&15)<<4|p>>2,s[d++]=(p&3)<<6|c&63}return s}function changeBitDepth(m,t,i,s){if(["32f","64"].indexOf(t)>-1&&["32f","64"].indexOf(s)>-1){i.set(m);return}validateBitDepth_(t),validateBitDepth_(s);let a=getBitDepthFunction_(t,s),d={oldMin:Math.pow(2,parseInt(t,10))/2,newMin:Math.pow(2,parseInt(s,10))/2,oldMax:Math.pow(2,parseInt(t,10))/2-1,newMax:Math.pow(2,parseInt(s,10))/2-1};sign8Bit_(t,m,!0);for(let u=0,h=m.length;u0?m=parseInt(m/t.oldMax*t.newMax,10):m=parseInt(m/t.oldMin*t.newMin,10),m}function floatToInt_(m,t){return parseInt(m>0?m*t.newMax:m*t.newMin,10)}function intToFloat_(m,t){return m>0?m/t.oldMax:m/t.oldMin}function getBitDepthFunction_(m,t){let i=function(s){return s};return m!=t&&(["32f","64"].includes(m)?i=floatToInt_:["32f","64"].includes(t)?i=intToFloat_:i=intToInt_),i}function validateBitDepth_(m){if(m!="32f"&&m!="64"&&(parseInt(m,10)<"8"||parseInt(m,10)>"53"))throw new Error("Invalid bit depth.")}function sign8Bit_(m,t,i){if(m=="8"){let s=i?-128:128;for(let a=0,d=t.length;a>4,h=u<<4^d;i.push(decodeSample_(h,t)),i.push(decodeSample_(u,t))}return i}function sign_(m){return m>32768?m-65536:m}function encodeSample_(m,t){let i=m-t.predicted,s=0;i>=0?s=0:(s=8,i=-i);let a=STEP_TABLE[t.index],d=a>>3;return i>a&&(s|=4,i-=a,d+=a),a>>=1,i>a&&(s|=2,i-=a,d+=a),a>>=1,i>a&&(s|=1,d+=a),updateEncoder_(s,d,t),s}function updateEncoder_(m,t,i){m&8?i.predicted-=t:i.predicted+=t,i.predicted<-32768?i.predicted=-32768:i.predicted>32767&&(i.predicted=32767),i.index+=INDEX_TABLE[m&7],i.index<0?i.index=0:i.index>88&&(i.index=88)}function decodeSample_(m,t){let i=0;return m&4&&(i+=t.step),m&2&&(i+=t.step>>1),m&1&&(i+=t.step>>2),i+=t.step>>3,m&8&&(i=-i),t.predicted+=i,t.predicted>32767?t.predicted=32767:t.predicted<-32767&&(t.predicted=-32767),updateDecoder_(m,t),t.predicted}function updateDecoder_(m,t){t.index+=INDEX_TABLE[m],t.index<0?t.index=0:t.index>88&&(t.index=88),t.step=STEP_TABLE[t.index]}function blockHead_(m,t){encodeSample_(m,t);let i=[];return i.push(m&255),i.push(m>>8&255),i.push(t.index),i.push(0),i}const LOG_TABLE=[1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];function encodeSample$1(m){let t;m=m==-32768?-32767:m;let i=~m>>8&128;if(i||(m=m*-1),m>32635&&(m=32635),m>=256){let s=LOG_TABLE[m>>8&127],a=m>>s+3&15;t=s<<4|a}else t=m>>4;return t^(i^85)}function decodeSample$1(m){let t=0;m^=85,m&128&&(m&=-129,t=-1);let i=((m&240)>>4)+4,s=0;return i!=4?s=1<>8&128,t!=0&&(m=-m),m=m+BIAS,m>CLIP&&(m=CLIP),i=encodeTable[m>>7&255],s=m>>i+3&15,a=~(t|i<<4|s),a}function decodeSample(m){let t,i,s,a;return m=~m,t=m&128,i=m>>4&7,s=m&15,a=decodeTable[i]+(s<=0&&p<=127)s+=String.fromCharCode(p);else{let c=0;p>=194&&p<=223?c=1:p>=224&&p<=239?(c=2,m[a]===224&&(d=160),m[a]===237&&(u=159)):p>=240&&p<=244?(c=3,m[a]===240&&(d=144),m[a]===244&&(u=143)):h=!0,p=p&(1<<8-c-1)-1;for(let l=0;lu)&&(h=!0),p=p<<6|m[a]&63,a++;h?s+=String.fromCharCode(65533):p<=65535?s+=String.fromCharCode(p):(p-=65536,s+=String.fromCharCode((p>>10&1023)+55296,(p&1023)+56320))}}return s}function pack$1(m,t,i=0){let s=0,a=m.length;for(;s>6*u)+h,i++;u>0;)t[i]=128|d>>6*(u-1)&63,i++,u--}s++}return i}class IntParser{constructor(t,i=!1){this.bits=t,this.offset=Math.ceil(t/8),this.max=Math.pow(2,t)-1,this.min=0,this.unpack=this.unpack_,i&&(this.max=Math.pow(2,t)/2-1,this.min=-this.max-1,this.unpack=this.unpackSigned_)}pack(t,i,s=0){i=this.clamp_(Math.round(i));for(let a=0,d=this.offset;athis.max?this.max:tthis.max&&(t-=this.max*2+2),t}}class FloatParser{constructor(t,i){this.offset=Math.ceil((t+i)/8),this.ebits=t,this.fbits=i,this.bias=(1<this.biasP2-this.ebitsFbits*2&&(i=i<0?-1/0:1/0);let a=((i=+i)||1/i)<0||i<0?1:0;i=Math.abs(i);let d=Math.min(Math.floor(Math.log(i)/Math.LN2),1023),u=roundToEven(i/Math.pow(2,d)*Math.pow(2,this.fbits));return i!==i?(u=Math.pow(2,this.fbits-1),d=(1<=Math.pow(2,1-this.bias)?(u/Math.pow(2,this.fbits)>=2&&(d=d+1,u=1),d>this.bias?(d=(1<=0;p--){let c=t[p+i].toString(2);d+="00000000".substring(c.length)+c}let u=d.charAt(0)=="1"?-1:1;d=d.substring(1);let h=parseInt(d.substring(0,this.ebits),2);return d=d.substring(this.ebits),h==s?parseInt(d,2)!==0?NaN:u*(1/0):(h===0?(h+=1,a=parseInt(d,2)):a=parseInt("1"+d,2),u*a*this.fbias*Math.pow(2,h-this.bias))}packFloatBits_(t,i,s,a,d){let u=[];u.push(s);for(let n=this.ebits;n>0;n-=1)u[n]=a%2?1:0,a=Math.floor(a/2);let h=u.length;for(let n=this.fbits;n>0;n-=1)u[h+n]=d%2?1:0,d=Math.floor(d/2);let p=u.join(""),c=this.offset+i-1,l=i;for(;c>=i;)t[c]=parseInt(p.substring(0,8),2),p=p.substring(8),c--,l++;return l}}function roundToEven(m){let t=Math.floor(m),i=m-t;return i<.5?t:i>.5||t%2?t+1:t}function unpackString(m,t=0,i=m.length){return unpack$1(m,t,i)}function packString(m){let t=[];return pack$1(m,t),t}function packStringTo(m,t,i=0){return pack$1(m,t,i)}function packArrayTo(m,t,i,s=0){t=t||{};let a=getParser_(t.bits,t.fp,t.signed),d=Math.ceil(t.bits/8),u=0,h=s;for(let p=m.length;u16&&(this.fmt.cbSize=this.readUInt16_(t),this.fmt.chunkSize>18&&(this.fmt.validBitsPerSample=this.readUInt16_(t),this.fmt.chunkSize>20&&(this.fmt.dwChannelMask=this.readUInt32(t),this.fmt.subformat=[this.readUInt32(t),this.readUInt32(t),this.readUInt32(t),this.readUInt32(t)])))}readFactChunk_(t){let i=this.findChunk("fact");i&&(this.head=i.chunkData.start,this.fact.chunkId=i.chunkId,this.fact.chunkSize=i.chunkSize,this.fact.dwSampleLength=this.readUInt32(t))}readCueChunk_(t){let i=this.findChunk("cue ");if(i){this.head=i.chunkData.start,this.cue.chunkId=i.chunkId,this.cue.chunkSize=i.chunkSize,this.cue.dwCuePoints=this.readUInt32(t);for(let s=0;s-1&&this.readLISTadtlSubChunks_(s,t):i=="INFO"&&this.readLISTINFOSubChunks_(s,t)}readLISTadtlSubChunks_(t,i){this.head=i.chunkData.start;let s={chunkId:i.chunkId,chunkSize:i.chunkSize,dwName:this.readUInt32(t)};i.chunkId=="ltxt"?(s.dwSampleLength=this.readUInt32(t),s.dwPurposeID=this.readUInt32(t),s.dwCountry=this.readUInt16_(t),s.dwLanguage=this.readUInt16_(t),s.dwDialect=this.readUInt16_(t),s.dwCodePage=this.readUInt16_(t),s.value=""):s.value=this.readZSTR_(t,this.head),this.LIST[this.LIST.length-1].subChunks.push(s)}readLISTINFOSubChunks_(t,i){this.head=i.chunkData.start,this.LIST[this.LIST.length-1].subChunks.push({chunkId:i.chunkId,chunkSize:i.chunkSize,value:this.readZSTR_(t,this.head)})}readJunkChunk_(t){let i=this.findChunk("junk");i&&(this.junk={chunkId:i.chunkId,chunkSize:i.chunkSize,chunkData:[].slice.call(t.slice(i.chunkData.start,i.chunkData.end))})}read_PMXChunk_(t){let i=this.findChunk("_PMX");i&&(this.head=i.chunkData.start,this._PMX.chunkId=i.chunkId,this._PMX.chunkSize=i.chunkSize,this._PMX.value=unpackString(t,this.head,this.head+this._PMX.chunkSize))}readZSTR_(t,i=0){for(let s=i;s16&&(t=t.concat(pack(this.fmt.cbSize,this.uInt16))),this.fmt.chunkSize>18&&(t=t.concat(pack(this.fmt.validBitsPerSample,this.uInt16))),this.fmt.chunkSize>20&&(t=t.concat(pack(this.fmt.dwChannelMask,this.uInt32))),this.fmt.chunkSize>24&&(t=t.concat(pack(this.fmt.subformat[0],this.uInt32),pack(this.fmt.subformat[1],this.uInt32),pack(this.fmt.subformat[2],this.uInt32),pack(this.fmt.subformat[3],this.uInt32))),t}getLISTBytes_(){let t=[];for(let i=0;i-1){let s=writeString(t.value,t.value.length);i=i.concat(packString(t.chunkId),pack(s.length+4+1,this.uInt32),pack(t.dwName,this.uInt32),s),i.push(0)}else t.chunkId=="ltxt"&&(i=i.concat(this.getLtxtChunkBytes_(t)));return i}getLtxtChunkBytes_(t){return[].concat(packString(t.chunkId),pack(t.value.length+20,this.uInt32),pack(t.dwName,this.uInt32),pack(t.dwSampleLength,this.uInt32),pack(t.dwPurposeID,this.uInt32),pack(t.dwCountry,this.uInt16),pack(t.dwLanguage,this.uInt16),pack(t.dwDialect,this.uInt16),pack(t.dwCodePage,this.uInt16),writeString(t.value,t.value.length))}get_PMXBytes_(){let t=[];if(this._PMX.chunkId){let i=packString(this._PMX.value);this._PMX.chunkSize=i.length,t=t.concat(packString(this._PMX.chunkId),pack(this._PMX.chunkSize,this.uInt32),i)}return this.enforceByteLen_(t),t}getJunkBytes_(){let t=[];return this.junk.chunkId?t.concat(packString(this.junk.chunkId),pack(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):(this.enforceByteLen_(t),t)}enforceByteLen_(t){t.length%2&&t.push(0)}}function interleave(m){let t=[];if(m.length>0)if(m[0].constructor!==Number){t=new Float64Array(m[0].length*m.length);for(let i=0,s=m[0].length,a=0;i65535)}function validateSampleRate(m,t,i){let s=m*(t/8)*i;return!(i<1||s>4294967295)}class WaveFileCreator extends WaveFileParser{constructor(){super(),this.bitDepth="0",this.dataType={bits:0,be:!1},this.WAV_AUDIO_FORMATS={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3}}fromScratch(t,i,s,a,d){d=d||{},this.clearHeaders(),this.newWavFile_(t,i,s,a,d)}fromBuffer(t,i=!0){super.fromBuffer(t,i),this.bitDepthFromFmt_(),this.updateDataType_()}toBuffer(){return this.validateWavHeader_(),super.toBuffer()}getSamples(t=!1,i=Float64Array){let s=new i(this.data.samples.length/(this.dataType.bits/8));return unpackArrayTo(this.data.samples,this.dataType,s,0,this.data.samples.length),!t&&this.fmt.numChannels>1?deInterleave(s,this.fmt.numChannels,i):s}getSample(t){if(t=t*(this.dataType.bits/8),t+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");return unpack(this.data.samples.slice(t,t+this.dataType.bits/8),this.dataType)}setSample(t,i){if(t=t*(this.dataType.bits/8),t+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");packTo(i,this.dataType,this.data.samples,t)}getiXML(){return this.iXML.value}setiXML(t){if(typeof t!="string")throw new TypeError("iXML value must be a string.");this.iXML.value=t,this.iXML.chunkId="iXML"}get_PMX(){return this._PMX.value}set_PMX(t){if(typeof t!="string")throw new TypeError("_PMX value must be a string.");this._PMX.value=t,this._PMX.chunkId="_PMX"}newWavFile_(t,i,s,a,d){d.container||(d.container="RIFF"),this.container=d.container,this.bitDepth=s,a=interleave(a),this.updateDataType_();let u=this.dataType.bits/8;this.data.samples=new Uint8Array(a.length*u),packArrayTo(a,this.dataType,this.data.samples,0),this.makeWavHeader_(s,t,i,u,this.data.samples.length,d),this.data.chunkId="data",this.data.chunkSize=this.data.samples.length,this.validateWavHeader_()}makeWavHeader_(t,i,s,a,d,u){t=="4"?this.createADPCMHeader_(t,i,s,a,d,u):t=="8a"||t=="8m"?this.createALawMulawHeader_(t,i,s,a,d,u):Object.keys(this.WAV_AUDIO_FORMATS).indexOf(t)==-1||i>2?this.createExtensibleHeader_(t,i,s,a,d,u):this.createPCMHeader_(t,i,s,a,d,u)}createPCMHeader_(t,i,s,a,d,u){this.container=u.container,this.chunkSize=36+d,this.format="WAVE",this.bitDepth=t,this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.WAV_AUDIO_FORMATS[t]||65534,numChannels:i,sampleRate:s,byteRate:i*a*s,blockAlign:i*a,bitsPerSample:parseInt(t,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}}createADPCMHeader_(t,i,s,a,d,u){this.createPCMHeader_(t,i,s,a,d,u),this.chunkSize=40+d,this.fmt.chunkSize=20,this.fmt.byteRate=4055,this.fmt.blockAlign=256,this.fmt.bitsPerSample=4,this.fmt.cbSize=2,this.fmt.validBitsPerSample=505,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:d*2}}createExtensibleHeader_(t,i,s,a,d,u){this.createPCMHeader_(t,i,s,a,d,u),this.chunkSize=36+24+d,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(t,10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(t,10),this.fmt.dwChannelMask=dwChannelMask_(i),this.fmt.subformat=[1,1048576,2852126848,1905997824]}createALawMulawHeader_(t,i,s,a,d,u){this.createPCMHeader_(t,i,s,a,d,u),this.chunkSize=40+d,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:d}}bitDepthFromFmt_(){this.fmt.audioFormat===3&&this.fmt.bitsPerSample===32?this.bitDepth="32f":this.fmt.audioFormat===6?this.bitDepth="8a":this.fmt.audioFormat===7?this.bitDepth="8m":this.bitDepth=this.fmt.bitsPerSample.toString()}validateBitDepth_(){if(!this.WAV_AUDIO_FORMATS[this.bitDepth]){if(parseInt(this.bitDepth,10)>8&&parseInt(this.bitDepth,10)<54)return!0;throw new Error("Invalid bit depth.")}return!0}updateDataType_(){this.dataType={bits:(parseInt(this.bitDepth,10)-1|7)+1,fp:this.bitDepth=="32f"||this.bitDepth=="64",signed:this.bitDepth!="8",be:this.container=="RIFX"},["4","8a","8m"].indexOf(this.bitDepth)>-1&&(this.dataType.bits=8,this.dataType.signed=!1)}validateWavHeader_(){if(this.validateBitDepth_(),!validateNumChannels(this.fmt.numChannels,this.fmt.bitsPerSample))throw new Error("Invalid number of channels.");if(!validateSampleRate(this.fmt.numChannels,this.fmt.bitsPerSample,this.fmt.sampleRate))throw new Error("Invalid sample rate.")}}function dwChannelMask_(m){let t=0;return m===1?t=4:m===2?t=3:m===4?t=51:m===6?t=63:m===8&&(t=1599),t}class WaveFileTagEditor extends WaveFileCreator{getTag(t){let i=this.getTagIndex_(t);return i.TAG!==null?this.LIST[i.LIST].subChunks[i.TAG].value:null}setTag(t,i){t=fixRIFFTag_(t);let s=this.getTagIndex_(t);s.TAG!==null?(this.LIST[s.LIST].subChunks[s.TAG].chunkSize=i.length+1,this.LIST[s.LIST].subChunks[s.TAG].value=i):s.LIST!==null?this.LIST[s.LIST].subChunks.push({chunkId:t,chunkSize:i.length+1,value:i}):(this.LIST.push({chunkId:"LIST",chunkSize:8+i.length+1,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:t,chunkSize:i.length+1,value:i}))}deleteTag(t){let i=this.getTagIndex_(t);return i.TAG!==null?(this.LIST[i.LIST].subChunks.splice(i.TAG,1),!0):!1}listTags(){let t=this.getLISTIndex("INFO"),i={};if(t!==null)for(let s=0,a=this.LIST[t].subChunks.length;si.dwSampleOffset&&!s?(this.setCuePoint_(i,a+1),this.setCuePoint_(t[a],a+2),s=!0):this.setCuePoint_(t[a],s?a+2:a+1);s||this.setCuePoint_(i,this.cue.points.length+1)}clearLISTadtl_(){for(let t=0,i=this.LIST.length;tt){let p=new h(s.LPForder||DEFAULT_LPF_ORDER[s.LPFType],i,t/2);upsample_(m,d,u,p)}else{let p=new h(s.LPForder||DEFAULT_LPF_ORDER[s.LPFType],t,i/2);downsample_(m,d,u,p)}}else resample_(m,d,u);return d}function resample_(m,t,i){for(let s=0,a=t.length;s=0;a--)t[a]=s.filter(t[a])}function downsample_(m,t,i,s){for(let a=0,d=m.length;a=0;a--)m[a]=s.filter(m[a]);resample_(m,t,i)}class WaveFileConverter extends WaveFileCueEditor{toRIFF(){let t=new Float64Array(outputSize_(this.data.samples.length,this.dataType.bits/8));unpackArrayTo(this.data.samples,this.dataType,t,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,t,{container:"RIFF"})}toRIFX(){let t=new Float64Array(outputSize_(this.data.samples.length,this.dataType.bits/8));unpackArrayTo(this.data.samples,this.dataType,t,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,t,{container:"RIFX"})}toIMAADPCM(){if(this.fmt.sampleRate!==8e3)throw new Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(this.fmt.numChannels!==1)throw new Error("Only mono files can be compressed as IMA-ADPCM.");{this.assure16Bit_();let t=new Int16Array(outputSize_(this.data.samples.length,2));unpackArrayTo(this.data.samples,this.dataType,t,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"4",encode$2(t),{container:this.correctContainer_()})}}fromIMAADPCM(t="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",decode$2(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()}),t!="16"&&this.toBitDepth(t)}toALaw(){this.assure16Bit_();let t=new Int16Array(outputSize_(this.data.samples.length,2));unpackArrayTo(this.data.samples,this.dataType,t,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8a",encode$1(t),{container:this.correctContainer_()})}fromALaw(t="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",decode$1(this.data.samples),{container:this.correctContainer_()}),t!="16"&&this.toBitDepth(t)}toMuLaw(){this.assure16Bit_();let t=new Int16Array(outputSize_(this.data.samples.length,2));unpackArrayTo(this.data.samples,this.dataType,t,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8m",encode(t),{container:this.correctContainer_()})}fromMuLaw(t="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",decode(this.data.samples),{container:this.correctContainer_()}),t!="16"&&this.toBitDepth(t)}toBitDepth(t,i=!0){let s=t,a=this.bitDepth;i||(t!="32f"&&(s=this.dataType.bits.toString()),a=""+this.dataType.bits),this.assureUncompressed_();let d=this.getSamples(!0),u=new Float64Array(d.length);changeBitDepth(d,a,u,s),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,t,u,{container:this.correctContainer_()})}toSampleRate(t,i){this.validateResample_(t);let s=this.getSamples(),a=[];if(s.constructor===Float64Array)a=resample(s,this.fmt.sampleRate,t,i);else for(let d=0;d-1)throw new Error("wavefile can't change the sample rate of compressed files.")}else throw new Error("Invalid sample rate.")}assure16Bit_(){this.assureUncompressed_(),this.bitDepth!="16"&&this.toBitDepth("16")}assureUncompressed_(){this.bitDepth=="8a"?this.fromALaw():this.bitDepth=="8m"?this.fromMuLaw():this.bitDepth=="4"&&this.fromIMAADPCM()}correctContainer_(){return this.container=="RF64"?"RIFF":this.container}fromExisting_(t,i,s,a,d){let u=new WaveFileCueEditor;Object.assign(this.fmt,u.fmt),Object.assign(this.fact,u.fact),Object.assign(this.ds64,u.ds64),Object.assign(this.data,u.data),this.newWavFile_(t,i,s,a,d)}}function outputSize_(m,t){let i=m/t;return i%2&&i++,i}class WaveFile extends WaveFileConverter{constructor(t){super(),t&&this.fromBuffer(t)}fromBase64(t){this.fromBuffer(decode$3(t))}toBase64(){return encode$3(this.toBuffer())}toDataURI(){return"data:audio/wav;base64,"+this.toBase64()}fromDataURI(t){this.fromBase64(t.replace("data:audio/wav;base64,",""))}}(async()=>{let m=await pipeline("automatic-speech-recognition","Xenova/whisper-tiny.en");class t{static async getInstance(s=null){return this.instance===null&&(this.instance=pipeline(this.task,this.model,{progress_callback:s})),this.instance}}Ee(t,"task","translation"),Ee(t,"model","Xenova/nllb-200-distilled-600M"),Ee(t,"instance",null),self.addEventListener("message",async i=>{let s=await t.getInstance(d=>{self.postMessage(d)});if(i.data.type!=="text"){let d=i.data.text,h=await(await fetch(d)).arrayBuffer(),p=new WaveFile(new Uint8Array(h));p.toBitDepth("32f"),p.toSampleRate(16e3);let c=p.getSamples();Array.isArray(c)&&(c=c[0]);let l=performance.now(),n=await m(c),e=performance.now();console.log(`Execution duration: ${(e-l)/1e3} seconds`),console.log(n)}let a=await s(i.data.text,{tgt_lang:i.data.tgt_lang,src_lang:i.data.src_lang,callback_function:d=>{self.postMessage({status:"update",output:s.tokenizer.decode(d[0].output_token_ids,{skip_special_tokens:!0})})}});self.postMessage({status:"complete",output:a})})})()})();