var fn=Object.defineProperty;var gn=(nt,m,t)=>m in nt?fn(nt,m,{enumerable:!0,configurable:!0,writable:!0,value:t}):nt[m]=t;var he=(nt,m,t)=>(gn(nt,typeof m!="symbol"?m+"":m,t),t);(function(){"use strict";var nt;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 u=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(m,s,u.get?u:{enumerable:!0,get:function(){return i[s]}})}})}),Object.freeze(m)}function dispatchCallback(m,t){m&&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)}function product(...m){return m.reduce((t,i)=>t.flatMap(s=>i.map(u=>[s,u])))}function calculateReflectOffset(m,t){return Math.abs((m+t)%(2*t)-t)}function get_bounding_box(m,t){t&&(m=m.map(a=>a|0));const[i,s,u,d]=m;return{xmin:i,ymin:s,xmax:u,ymax:d}}var sharp={},ONNX_NODE=Object.freeze({__proto__:null,default:sharp});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(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(s){var u=Object.getOwnPropertyDescriptor(m,s);Object.defineProperty(i,s,u.get?u:{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 u=backendsSortedByPriority.indexOf(m);u!==-1&&backendsSortedByPriority.splice(u,1);for(let d=0;d{const t=m.length===0?backendsSortedByPriority:m,i=[];for(const s of t){const u=backends[s];if(u){if(u.initialized)return u.backend;if(u.aborted)continue;const d=!!u.initPromise;try{return d||(u.initPromise=u.backend.init()),await u.initPromise,u.initialized=!0,u.backend}catch(a){d||i.push({name:s,err:a}),u.aborted=!0}finally{delete u.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$2=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(f.height=n.height,i.width!==void 0&&i.width!==n.width)throw new Error("Image input config width doesn't match ImageBitmap width");f.width=n.width}else f.height=n.height,f.width=n.width;c(lt.bufferToTensor(o.data,f))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(h!==void 0)return lt.bufferToTensor(h,f);throw new Error("Input data provided is not supported - aborted tensor creation")}toImageData(t){var i,s;const u=document.createElement("canvas").getContext("2d");let d;if(u!=null){const a=this.dims[3],h=this.dims[2],f=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*a;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!==a)throw new Error("Image output config width doesn't match tensor width");if(t.format!==void 0&&f===4&&t.format!=="RGBA"||f===3&&t.format!=="RGB"&&t.format!=="BGR")throw new Error("Tensor format doesn't match input tensor dims")}const r=4;let o=0,p=1,g=2,_=3,b=0,y=e,w=e*2,T=-1;c==="RGBA"?(b=0,y=e,w=e*2,T=e*3):c==="RGB"?(b=0,y=e,w=e*2):c==="RBG"&&(b=0,w=e,y=e*2),d=u.createImageData(a,h);for(let S=0;S"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(const c of this.outputNames)u[c]=null;const h=await this.handler.run(t,u,d),f={};for(const c in h)Object.hasOwnProperty.call(h,c)&&(f[c]=new Tensor$1(h[c].type,h[c].data,h[c].dims));return f}static async create(t,i,s,u){let d,a={};if(typeof t=="string"){if(d=t,typeof i=="object"&&i!==null)a=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)a=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)a=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 u=="object"&&u!==null)a=u;else if(typeof u<"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 f=(a.executionProviders||[]).map(n=>typeof n=="string"?n:n.name),l=await(await resolveBackend(f)).createSessionHandler(d,a);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$2,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,u=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){function a(){return V.buffer!=Z&&Me(V.buffer),le}function h(){return V.buffer!=Z&&Me(V.buffer),Ae}function f(){return V.buffer!=Z&&Me(V.buffer),xe}function c(){return V.buffer!=Z&&Me(V.buffer),se}function l(){return V.buffer!=Z&&Me(V.buffer),we}var n,e,r;d=d||{},n||(n=d!==void 0?d:{}),n.ready=new Promise(function(v,O){e=v,r=O});var o,p,g,_,b,y,w=Object.assign({},n),T="./this.program",S=(v,O)=>{throw O},A=typeof window=="object",P=typeof importScripts=="function",x=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",M=n.ENVIRONMENT_IS_PTHREAD||!1,N="";function z(v){return n.locateFile?n.locateFile(v,N):N+v}if(x){let v;N=P?i(908).dirname(N)+"/":"//",y=()=>{b||(_=i(1384),b=i(908))},o=function(O,I){return y(),O=b.normalize(O),_.readFileSync(O,I?void 0:"utf8")},g=O=>((O=o(O,!0)).buffer||(O=new Uint8Array(O)),O),p=(O,I,F)=>{y(),O=b.normalize(O),_.readFile(O,function(B,q){B?F(B):I(q.buffer)})},1{if(qe())throw process.exitCode=O,I;I instanceof Ze||R("exiting due to exception: "+I),process.exit(O)},n.inspect=function(){return"[Emscripten Module object]"};try{v=i(9925)}catch(O){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),O}i.g.Worker=v.Worker}else(A||P)&&(P?N=self.location.href:typeof document<"u"&&document.currentScript&&(N=document.currentScript.src),s&&(N=s),N=N.indexOf("blob:")!==0?N.substr(0,N.replace(/[?#].*/,"").lastIndexOf("/")+1):"",x||(o=v=>{var O=new XMLHttpRequest;return O.open("GET",v,!1),O.send(null),O.responseText},P&&(g=v=>{var O=new XMLHttpRequest;return O.open("GET",v,!1),O.responseType="arraybuffer",O.send(null),new Uint8Array(O.response)}),p=(v,O,I)=>{var F=new XMLHttpRequest;F.open("GET",v,!0),F.responseType="arraybuffer",F.onload=()=>{F.status==200||F.status==0&&F.response?O(F.response):I()},F.onerror=I,F.send(null)}));x&&typeof performance>"u"&&(i.g.performance=i(6953).performance);var $=console.log.bind(console),C=console.warn.bind(console);x&&(y(),$=v=>_.writeSync(1,v+` `),C=v=>_.writeSync(2,v+` `));var G,D=n.print||$,R=n.printErr||C;Object.assign(n,w),w=null,n.thisProgram&&(T=n.thisProgram),n.quit&&(S=n.quit),n.wasmBinary&&(G=n.wasmBinary);var Y=n.noExitRuntime||!1;typeof WebAssembly!="object"&&ge("no native wasm support detected");var V,J,Z,le,Ae,xe,se,we,be=!1,ke=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Le(v,O,I){var F=(O>>>=0)+I;for(I=O;v[I]&&!(I>=F);)++I;if(16(B=(240&B)==224?(15&B)<<12|q<<6|Q:(7&B)<<18|q<<12|Q<<6|63&v[O++])?F+=String.fromCharCode(B):(B-=65536,F+=String.fromCharCode(55296|B>>10,56320|1023&B))}}else F+=String.fromCharCode(B)}return F}function ve(v,O){return(v>>>=0)?Le(h(),v,O):""}function $e(v,O,I,F){if(!(0>>=0;F=I+F-1;for(var q=0;q=Q&&(Q=65536+((1023&Q)<<10)|1023&v.charCodeAt(++q)),127>=Q){if(I>=F)break;O[I++>>>0]=Q}else{if(2047>=Q){if(I+1>=F)break;O[I++>>>0]=192|Q>>6}else{if(65535>=Q){if(I+2>=F)break;O[I++>>>0]=224|Q>>12}else{if(I+3>=F)break;O[I++>>>0]=240|Q>>18,O[I++>>>0]=128|Q>>12&63}O[I++>>>0]=128|Q>>6&63}O[I++>>>0]=128|63&Q}}return O[I>>>0]=0,I-B}function Fe(v){for(var O=0,I=0;I=F?O++:2047>=F?O+=2:55296<=F&&57343>=F?(O+=4,++I):O+=3}return O}function Me(v){Z=v,n.HEAP8=le=new Int8Array(v),n.HEAP16=new Int16Array(v),n.HEAP32=xe=new Int32Array(v),n.HEAPU8=Ae=new Uint8Array(v),n.HEAPU16=new Uint16Array(v),n.HEAPU32=se=new Uint32Array(v),n.HEAPF32=new Float32Array(v),n.HEAPF64=we=new Float64Array(v)}M&&(Z=n.buffer);var Pe=n.INITIAL_MEMORY||16777216;if(M)V=n.wasmMemory,Z=n.buffer;else if(n.wasmMemory)V=n.wasmMemory;else if(!((V=new WebAssembly.Memory({initial:Pe/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw R("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");V&&(Z=V.buffer),Pe=Z.byteLength,Me(Z);var Be,Ge=[],Ve=[],Xe=[],Qe=[];function qe(){return Y||!1}function Ue(){var v=n.preRun.shift();Ge.unshift(v)}var Ee,ze=0,Ye=null;function ge(v){throw M?postMessage({cmd:"onAbort",arg:v}):n.onAbort&&n.onAbort(v),R(v="Aborted("+v+")"),be=!0,v=new WebAssembly.RuntimeError(v+". Build with -sASSERTIONS for more info."),r(v),v}function pt(){return Ee.startsWith("data:application/octet-stream;base64,")}function ut(){var v=Ee;try{if(v==Ee&&G)return new Uint8Array(G);if(g)return g(v);throw"both async and sync fetching of the wasm failed"}catch(O){ge(O)}}Ee="ort-wasm-threaded.wasm",pt()||(Ee=z(Ee));var Et={};function Ze(v){this.name="ExitStatus",this.message="Program terminated with exit("+v+")",this.status=v}function ct(v){(v=re.Vb[v])||ge(),re.mc(v)}function dt(v){var O=re.Cc();if(!O)return 6;re.ac.push(O),re.Vb[v.Ub]=O,O.Ub=v.Ub;var I={cmd:"run",start_routine:v.Ic,arg:v.zc,pthread_ptr:v.Ub};return O.$b=()=>{I.time=performance.now(),O.postMessage(I,v.Nc)},O.loaded&&(O.$b(),delete O.$b),0}function Re(v){if(M)return ee(1,1,v);qe()||(re.oc(),n.onExit&&n.onExit(v),be=!0),S(v,new Ze(v))}function it(v,O){if(!O&&M)throw It(v),"unwind";qe()||M||(Wt(),rt(Xe),qt(0),Nt[1].length&&Lt(1,10),Nt[2].length&&Lt(2,10),re.oc()),Re(v)}var re={Yb:[],ac:[],qc:[],Vb:{},fc:function(){M&&re.Ec()},Pc:function(){},Ec:function(){re.receiveObjectTransfer=re.Gc,re.threadInitTLS=re.pc,re.setExitStatus=re.nc,Y=!1},nc:function(){},oc:function(){for(var v of Object.values(re.Vb))re.mc(v);for(v of re.Yb)v.terminate();re.Yb=[]},mc:function(v){var O=v.Ub;delete re.Vb[O],re.Yb.push(v),re.ac.splice(re.ac.indexOf(v),1),v.Ub=0,Rt(O)},Gc:function(){},pc:function(){re.qc.forEach(v=>v())},Fc:function(v,O){v.onmessage=I=>{var F=(I=I.data).cmd;if(v.Ub&&(re.Bc=v.Ub),I.targetThread&&I.targetThread!=Dt()){var B=re.Vb[I.Qc];B?B.postMessage(I,I.transferList):R('Internal error! Worker sent a message "'+F+'" to target pthread '+I.targetThread+", but that thread no longer exists!")}else F==="processProxyingQueue"?L(I.queue):F==="spawnThread"?dt(I):F==="cleanupThread"?ct(I.thread):F==="killThread"?(I=I.thread,F=re.Vb[I],delete re.Vb[I],F.terminate(),Rt(I),re.ac.splice(re.ac.indexOf(F),1),F.Ub=0):F==="cancelThread"?re.Vb[I.thread].postMessage({cmd:"cancel"}):F==="loaded"?(v.loaded=!0,O&&O(v),v.$b&&(v.$b(),delete v.$b)):F==="print"?D("Thread "+I.threadId+": "+I.text):F==="printErr"?R("Thread "+I.threadId+": "+I.text):F==="alert"?alert("Thread "+I.threadId+": "+I.text):I.target==="setimmediate"?v.postMessage(I):F==="onAbort"?n.onAbort&&n.onAbort(I.arg):F&&R("worker sent an unknown command "+F);re.Bc=void 0},v.onerror=I=>{throw R("worker sent an error! "+I.filename+":"+I.lineno+": "+I.message),I},x&&(v.on("message",function(I){v.onmessage({data:I})}),v.on("error",function(I){v.onerror(I)}),v.on("detachedExit",function(){})),v.postMessage({cmd:"load",urlOrBlob:n.mainScriptUrlOrBlob||s,wasmMemory:V,wasmModule:J})},yc:function(){var v=z("ort-wasm-threaded.worker.js");re.Yb.push(new Worker(v))},Cc:function(){return re.Yb.length==0&&(re.yc(),re.Fc(re.Yb[0])),re.Yb.pop()}};function rt(v){for(;0>2>>>0];v=f()[v+48>>2>>>0],Qt(O,O-v),ce(O)};var Je=[];function Te(v){var O=Je[v];return O||(v>=Je.length&&(Je.length=v+1),Je[v]=O=Be.get(v)),O}n.invokeEntryPoint=function(v,O){v=Te(v)(O),qe()?re.nc(v):Kt(v)};var ot,ft,st=[],ae=0,ie=0;function oe(v){this.Zb=v,this.Sb=v-24,this.xc=function(O){c()[this.Sb+4>>2>>>0]=O},this.bc=function(){return c()[this.Sb+4>>2>>>0]},this.wc=function(O){c()[this.Sb+8>>2>>>0]=O},this.Dc=function(){return c()[this.Sb+8>>2>>>0]},this.rc=function(){f()[this.Sb>>2>>>0]=0},this.hc=function(O){O=O?1:0,a()[this.Sb+12>>0>>>0]=O},this.uc=function(){return a()[this.Sb+12>>0>>>0]!=0},this.ic=function(O){O=O?1:0,a()[this.Sb+13>>0>>>0]=O},this.kc=function(){return a()[this.Sb+13>>0>>>0]!=0},this.fc=function(O,I){this.cc(0),this.xc(O),this.wc(I),this.rc(),this.hc(!1),this.ic(!1)},this.sc=function(){Atomics.add(f(),this.Sb>>2,1)},this.Hc=function(){return Atomics.sub(f(),this.Sb>>2,1)===1},this.cc=function(O){c()[this.Sb+16>>2>>>0]=O},this.tc=function(){return c()[this.Sb+16>>2>>>0]},this.vc=function(){if(Zt(this.bc()))return c()[this.Zb>>2>>>0];var O=this.tc();return O!==0?O:this.Zb}}function gt(v){return Vt(new oe(v).Sb)}function at(v,O,I,F){return M?ee(3,1,v,O,I,F):mt(v,O,I,F)}function mt(v,O,I,F){if(typeof SharedArrayBuffer>"u")return R("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var B=[];return M&&B.length===0?at(v,O,I,F):(v={Ic:I,Ub:v,zc:F,Nc:B},M?(v.Oc="spawnThread",postMessage(v,B),0):dt(v))}function _t(v,O,I){return M?ee(4,1,v,O,I):0}function bt(v,O){if(M)return ee(5,1,v,O)}function yt(v,O){if(M)return ee(6,1,v,O)}function wt(v,O,I){if(M)return ee(7,1,v,O,I)}function Tt(v,O,I){return M?ee(8,1,v,O,I):0}function xt(v,O){if(M)return ee(9,1,v,O)}function vt(v,O,I){if(M)return ee(10,1,v,O,I)}function St(v,O,I,F){if(M)return ee(11,1,v,O,I,F)}function At(v,O,I,F){if(M)return ee(12,1,v,O,I,F)}function Pt(v,O,I,F){if(M)return ee(13,1,v,O,I,F)}function Ot(v){if(M)return ee(14,1,v)}function E(v,O){if(M)return ee(15,1,v,O)}function k(v,O,I){if(M)return ee(16,1,v,O,I)}function L(v){Atomics.store(f(),v>>2,1),Dt()&&Yt(v),Atomics.compareExchange(f(),v>>2,1,0)}function j(v){return c()[v>>>2]+4294967296*f()[v+4>>>2]}function U(v,O,I,F,B,q){return M?ee(17,1,v,O,I,F,B,q):-52}function X(v,O,I,F,B,q){if(M)return ee(18,1,v,O,I,F,B,q)}function K(v){var O=Fe(v)+1,I=$t(O);return I&&$e(v,a(),I,O),I}function te(v,O,I){function F(me){return(me=me.toTimeString().match(/\(([A-Za-z ]+)\)$/))?me[1]:"GMT"}if(M)return ee(19,1,v,O,I);var B=new Date().getFullYear(),q=new Date(B,0,1),Q=new Date(B,6,1);B=q.getTimezoneOffset();var ne=Q.getTimezoneOffset(),fe=Math.max(B,ne);f()[v>>2>>>0]=60*fe,f()[O>>2>>>0]=+(B!=ne),v=F(q),O=F(Q),v=K(v),O=K(O),ne>2>>>0]=v,c()[I+4>>2>>>0]=O):(c()[I>>2>>>0]=O,c()[I+4>>2>>>0]=v)}function ee(v,O){var I=arguments.length-2,F=arguments;return Mt(()=>{for(var B=zt(8*I),q=B>>3,Q=0;Q>>0]=ne}return Xt(v,I,B,O)})}n.executeNotifiedProxyingQueue=L,ft=x?()=>{var v=process.hrtime();return 1e3*v[0]+v[1]/1e6}:M?()=>performance.now()-n.__performance_now_clock_drift:()=>performance.now();var ue,Se=[],Ne={};function Ce(){if(!ue){var v,O={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:T||"./this.program"};for(v in Ne)Ne[v]===void 0?delete O[v]:O[v]=Ne[v];var I=[];for(v in O)I.push(v+"="+O[v]);ue=I}return ue}function W(v,O){if(M)return ee(20,1,v,O);var I=0;return Ce().forEach(function(F,B){var q=O+I;for(B=c()[v+4*B>>2>>>0]=q,q=0;q>0>>>0]=F.charCodeAt(q);a()[B>>0>>>0]=0,I+=F.length+1}),0}function _e(v,O){if(M)return ee(21,1,v,O);var I=Ce();c()[v>>2>>>0]=I.length;var F=0;return I.forEach(function(B){F+=B.length+1}),c()[O>>2>>>0]=F,0}function Oe(v){return M?ee(22,1,v):52}function We(v,O,I,F){return M?ee(23,1,v,O,I,F):52}function et(v,O,I,F,B){return M?ee(24,1,v,O,I,F,B):70}var Nt=[null,[],[]];function Lt(v,O){var I=Nt[v];O===0||O===10?((v===1?D:R)(Le(I,0)),I.length=0):I.push(O)}function jt(v,O,I,F){if(M)return ee(25,1,v,O,I,F);for(var B=0,q=0;q>2>>>0],ne=c()[O+4>>2>>>0];O+=8;for(var fe=0;fe>>0]);B+=ne}return c()[F>>2>>>0]=B,0}var je=0;function kt(v){return v%4==0&&(v%100!=0||v%400==0)}var Bt=[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(v,O,I,F){function B(H,ye,Ie){for(H=typeof H=="number"?H.toString():H||"";H.lengthht?-1:0tt-H.getDate())){H.setDate(H.getDate()+ye);break}ye-=tt-H.getDate()+1,H.setDate(1),11>Ie?H.setMonth(Ie+1):(H.setMonth(0),H.setFullYear(H.getFullYear()+1))}return Ie=new Date(H.getFullYear()+1,0,4),ye=ne(new Date(H.getFullYear(),0,4)),Ie=ne(Ie),0>=Q(ye,H)?0>=Q(Ie,H)?H.getFullYear()+1:H.getFullYear():H.getFullYear()-1}var me=f()[F+40>>2>>>0];for(var De in F={Lc:f()[F>>2>>>0],Kc:f()[F+4>>2>>>0],dc:f()[F+8>>2>>>0],jc:f()[F+12>>2>>>0],ec:f()[F+16>>2>>>0],Xb:f()[F+20>>2>>>0],Tb:f()[F+24>>2>>>0],Wb:f()[F+28>>2>>>0],Rc:f()[F+32>>2>>>0],Jc:f()[F+36>>2>>>0],Mc:me?ve(me):""},I=ve(I),me={"%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"})I=I.replace(new RegExp(De,"g"),me[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 me={"%a":function(H){return Ke[H.Tb].substring(0,3)},"%A":function(H){return Ke[H.Tb]},"%b":function(H){return He[H.ec].substring(0,3)},"%B":function(H){return He[H.ec]},"%C":function(H){return q((H.Xb+1900)/100|0,2)},"%d":function(H){return q(H.jc,2)},"%e":function(H){return B(H.jc,2," ")},"%g":function(H){return fe(H).toString().substring(2)},"%G":function(H){return fe(H)},"%H":function(H){return q(H.dc,2)},"%I":function(H){return(H=H.dc)==0?H=12:12H.dc?"AM":"PM"},"%S":function(H){return q(H.Lc,2)},"%t":function(){return" "},"%u":function(H){return H.Tb||7},"%U":function(H){return q(Math.floor((H.Wb+7-H.Tb)/7),2)},"%V":function(H){var ye=Math.floor((H.Wb+7-(H.Tb+6)%7)/7);if(2>=(H.Tb+371-H.Wb-2)%7&&ye++,ye)ye==53&&((Ie=(H.Tb+371-H.Wb)%7)==4||Ie==3&&kt(H.Xb)||(ye=1));else{ye=52;var Ie=(H.Tb+7-H.Wb-1)%7;(Ie==4||Ie==5&&kt(H.Xb%400-1))&&ye++}return q(ye,2)},"%w":function(H){return H.Tb},"%W":function(H){return q(Math.floor((H.Wb+7-(H.Tb+6)%7)/7),2)},"%y":function(H){return(H.Xb+1900).toString().substring(2)},"%Y":function(H){return H.Xb+1900},"%z":function(H){var ye=0<=(H=H.Jc);return H=Math.abs(H)/60,(ye?"+":"-")+("0000"+(H/60*100+H%60)).slice(-4)},"%Z":function(H){return H.Mc},"%%":function(){return"%"}},I=I.replace(/%%/g,"\0\0"),me)I.includes(De)&&(I=I.replace(new RegExp(De,"g"),me[De](F)));return De=function(H){var ye=Array(Fe(H)+1);return $e(H,ye,0,ye.length),ye}(I=I.replace(/\0\0/g,"%")),De.length>O?0:(function(H,ye){a().set(H,ye>>>0)}(De,v),De.length-1)}re.fc();var hn=[null,Re,It,at,_t,bt,yt,wt,Tt,xt,vt,St,At,Pt,Ot,E,k,U,X,te,W,_e,Oe,We,et,jt],pn={b:function(v){return $t(v+24)+24},n:function(v){return(v=new oe(v)).uc()||(v.hc(!0),ae--),v.ic(!1),st.push(v),v.sc(),v.vc()},ma:function(v){throw R("Unexpected exception thrown, this is not properly supported - aborting"),be=!0,v},x:function(){pe(0);var v=st.pop();if(v.Hc()&&!v.kc()){var O=v.Dc();O&&Te(O)(v.Zb),gt(v.Zb)}ie=0},e:function(){var v=ie;if(!v)return je=0;var O=new oe(v);O.cc(v);var I=O.bc();if(!I)return je=0,v;for(var F=Array.prototype.slice.call(arguments),B=0;BL(F));else if(M)postMessage({targetThread:v,cmd:"processProxyingQueue",queue:F});else{if(!(v=re.Vb[v]))return;v.postMessage({cmd:"processProxyingQueue",queue:F})}return 1},Ea:function(){return-1},Pa:function(v,O){v=new Date(1e3*j(v)),f()[O>>2>>>0]=v.getUTCSeconds(),f()[O+4>>2>>>0]=v.getUTCMinutes(),f()[O+8>>2>>>0]=v.getUTCHours(),f()[O+12>>2>>>0]=v.getUTCDate(),f()[O+16>>2>>>0]=v.getUTCMonth(),f()[O+20>>2>>>0]=v.getUTCFullYear()-1900,f()[O+24>>2>>>0]=v.getUTCDay(),v=(v.getTime()-Date.UTC(v.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,f()[O+28>>2>>>0]=v},Qa:function(v,O){v=new Date(1e3*j(v)),f()[O>>2>>>0]=v.getSeconds(),f()[O+4>>2>>>0]=v.getMinutes(),f()[O+8>>2>>>0]=v.getHours(),f()[O+12>>2>>>0]=v.getDate(),f()[O+16>>2>>>0]=v.getMonth(),f()[O+20>>2>>>0]=v.getFullYear()-1900,f()[O+24>>2>>>0]=v.getDay();var I=new Date(v.getFullYear(),0,1),F=(v.getTime()-I.getTime())/864e5|0;f()[O+28>>2>>>0]=F,f()[O+36>>2>>>0]=-60*v.getTimezoneOffset(),F=new Date(v.getFullYear(),6,1).getTimezoneOffset(),v=0|(F!=(I=I.getTimezoneOffset())&&v.getTimezoneOffset()==Math.min(I,F)),f()[O+32>>2>>>0]=v},Ra:function(v){var O=new Date(f()[v+20>>2>>>0]+1900,f()[v+16>>2>>>0],f()[v+12>>2>>>0],f()[v+8>>2>>>0],f()[v+4>>2>>>0],f()[v>>2>>>0],0),I=f()[v+32>>2>>>0],F=O.getTimezoneOffset(),B=new Date(O.getFullYear(),0,1),q=new Date(O.getFullYear(),6,1).getTimezoneOffset(),Q=B.getTimezoneOffset(),ne=Math.min(Q,q);return 0>I?f()[v+32>>2>>>0]=+(q!=Q&&ne==F):0>2>>>0]=O.getDay(),I=(O.getTime()-B.getTime())/864e5|0,f()[v+28>>2>>>0]=I,f()[v>>2>>>0]=O.getSeconds(),f()[v+4>>2>>>0]=O.getMinutes(),f()[v+8>>2>>>0]=O.getHours(),f()[v+12>>2>>>0]=O.getDate(),f()[v+16>>2>>>0]=O.getMonth(),O.getTime()/1e3|0},Aa:U,Ba:X,Sa:function v(O,I,F){v.Ac||(v.Ac=!0,te(O,I,F))},y:function(){ge("")},U:function(){if(!x&&!P){var v="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";ot||(ot={}),ot[v]||(ot[v]=1,x&&(v="warning: "+v),R(v))}},ra:function(){return 4294901760},B:ft,Ia:function(v,O,I){h().copyWithin(v>>>0,O>>>0,O+I>>>0)},F:function(){return x?i(3993).cpus().length:navigator.hardwareConcurrency},Da:function(v,O,I){Se.length=O,I>>=3;for(var F=0;F>>0];return(0>v?Et[-v-1]:hn[v]).apply(null,Se)},qa:function(v){var O=h().length;if((v>>>=0)<=O||4294901760=I;I*=2){var F=O*(1+.2/I);F=Math.min(F,v+100663296);var B=Math;F=Math.max(v,F),B=B.min.call(B,4294901760,F+(65536-F%65536)%65536);e:{try{V.grow(B-Z.byteLength+65535>>>16),Me(V.buffer);var q=1;break e}catch{}q=void 0}if(q)return!0}return!1},Na:function(){throw"unwind"},Ga:W,Ha:_e,J:it,I:Oe,S:We,ga:et,R:jt,d:function(){return je},na:function v(O,I){v.lc||(v.lc=function(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var B=new Uint8Array(1);return()=>(crypto.getRandomValues(B),B[0])}if(x)try{var q=i(Object(function(){var Q=new Error("Cannot find module 'crypto'");throw Q.code="MODULE_NOT_FOUND",Q}()));return()=>q.randomBytes(1)[0]}catch{}return()=>ge("randomDevice")}());for(var F=0;F>0>>>0]=v.lc();return 0},ia:function(v,O,I){var F=de();try{return Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},ja:function(v,O,I){var F=de();try{return Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},K:function(v){var O=de();try{return Te(v)()}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},f:function(v,O){var I=de();try{return Te(v)(O)}catch(F){if(ce(I),F!==F+0)throw F;pe(1,0)}},P:function(v,O,I){var F=de();try{return Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},Q:function(v,O,I){var F=de();try{return Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},k:function(v,O,I){var F=de();try{return Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},p:function(v,O,I,F){var B=de();try{return Te(v)(O,I,F)}catch(q){if(ce(B),q!==q+0)throw q;pe(1,0)}},q:function(v,O,I,F,B){var q=de();try{return Te(v)(O,I,F,B)}catch(Q){if(ce(q),Q!==Q+0)throw Q;pe(1,0)}},N:function(v,O,I,F,B,q){var Q=de();try{return Te(v)(O,I,F,B,q)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},s:function(v,O,I,F,B,q){var Q=de();try{return Te(v)(O,I,F,B,q)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},w:function(v,O,I,F,B,q,Q){var ne=de();try{return Te(v)(O,I,F,B,q,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},L:function(v,O,I,F,B,q,Q,ne){var fe=de();try{return Te(v)(O,I,F,B,q,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},E:function(v,O,I,F,B,q,Q,ne,fe,me,De,Ke){var He=de();try{return Te(v)(O,I,F,B,q,Q,ne,fe,me,De,Ke)}catch(H){if(ce(He),H!==H+0)throw H;pe(1,0)}},aa:function(v,O,I,F,B,q,Q,ne){var fe=de();try{return ln(v,O,I,F,B,q,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},_:function(v,O,I,F,B,q,Q){var ne=de();try{return en(v,O,I,F,B,q,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},Z:function(v,O,I,F,B){var q=de();try{return un(v,O,I,F,B)}catch(Q){if(ce(q),Q!==Q+0)throw Q;pe(1,0)}},ca:function(v,O,I,F){var B=de();try{return sn(v,O,I,F)}catch(q){if(ce(B),q!==q+0)throw q;pe(1,0)}},$:function(v){var O=de();try{return Jt(v)}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},ba:function(v,O){var I=de();try{return an(v,O)}catch(F){if(ce(I),F!==F+0)throw F;pe(1,0)}},Y:function(v,O,I){var F=de();try{return tn(v,O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},g:function(v){var O=de();try{Te(v)()}catch(I){if(ce(O),I!==I+0)throw I;pe(1,0)}},r:function(v,O){var I=de();try{Te(v)(O)}catch(F){if(ce(I),F!==F+0)throw F;pe(1,0)}},i:function(v,O,I){var F=de();try{Te(v)(O,I)}catch(B){if(ce(F),B!==B+0)throw B;pe(1,0)}},ha:function(v,O,I,F){var B=de();try{Te(v)(O,I,F)}catch(q){if(ce(B),q!==q+0)throw q;pe(1,0)}},m:function(v,O,I,F){var B=de();try{Te(v)(O,I,F)}catch(q){if(ce(B),q!==q+0)throw q;pe(1,0)}},v:function(v,O,I,F,B){var q=de();try{Te(v)(O,I,F,B)}catch(Q){if(ce(q),Q!==Q+0)throw Q;pe(1,0)}},u:function(v,O,I,F,B,q){var Q=de();try{Te(v)(O,I,F,B,q)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},O:function(v,O,I,F,B,q,Q){var ne=de();try{Te(v)(O,I,F,B,q,Q)}catch(fe){if(ce(ne),fe!==fe+0)throw fe;pe(1,0)}},A:function(v,O,I,F,B,q,Q,ne){var fe=de();try{Te(v)(O,I,F,B,q,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},ka:function(v,O,I,F,B,q,Q,ne,fe){var me=de();try{Te(v)(O,I,F,B,q,Q,ne,fe)}catch(De){if(ce(me),De!==De+0)throw De;pe(1,0)}},C:function(v,O,I,F,B,q,Q,ne,fe,me,De){var Ke=de();try{Te(v)(O,I,F,B,q,Q,ne,fe,me,De)}catch(He){if(ce(Ke),He!==He+0)throw He;pe(1,0)}},D:function(v,O,I,F,B,q,Q,ne,fe,me,De,Ke,He,H,ye,Ie){var tt=de();try{Te(v)(O,I,F,B,q,Q,ne,fe,me,De,Ke,He,H,ye,Ie)}catch(ht){if(ce(tt),ht!==ht+0)throw ht;pe(1,0)}},fa:function(v,O,I,F,B,q,Q,ne){var fe=de();try{nn(v,O,I,F,B,q,Q,ne)}catch(me){if(ce(fe),me!==me+0)throw me;pe(1,0)}},da:function(v,O,I,F,B,q,Q,ne,fe,me,De,Ke){var He=de();try{on(v,O,I,F,B,q,Q,ne,fe,me,De,Ke)}catch(H){if(ce(He),H!==H+0)throw H;pe(1,0)}},ea:function(v,O,I,F,B,q){var Q=de();try{rn(v,O,I,F,B,q)}catch(ne){if(ce(Q),ne!==ne+0)throw ne;pe(1,0)}},o:function(v){return v},a:V||n.wasmMemory,G:function(v){je=v},la:Gt,z:function(v,O,I,F){return Gt(v,O,I,F)}};(function(){function v(B,q){n.asm=B.exports,re.qc.push(n.asm.sb),Be=n.asm.ub,Ve.unshift(n.asm.Va),J=q,M||(ze--,n.monitorRunDependencies&&n.monitorRunDependencies(ze),ze==0&&Ye&&(B=Ye,Ye=null,B()))}function O(B){v(B.instance,B.module)}function I(B){return function(){if(!G&&(A||P)){if(typeof fetch=="function"&&!Ee.startsWith("file://"))return fetch(Ee,{credentials:"same-origin"}).then(function(q){if(!q.ok)throw"failed to load wasm binary file at '"+Ee+"'";return q.arrayBuffer()}).catch(function(){return ut()});if(p)return new Promise(function(q,Q){p(Ee,function(ne){q(new Uint8Array(ne))},Q)})}return Promise.resolve().then(function(){return ut()})}().then(function(q){return WebAssembly.instantiate(q,F)}).then(function(q){return q}).then(B,function(q){R("failed to asynchronously prepare wasm: "+q),ge(q)})}var F={a:pn};if(M||(ze++,n.monitorRunDependencies&&n.monitorRunDependencies(ze)),n.instantiateWasm)try{return n.instantiateWasm(F,v)}catch(B){return R("Module.instantiateWasm callback failed with error: "+B),!1}(G||typeof WebAssembly.instantiateStreaming!="function"||pt()||Ee.startsWith("file://")||x||typeof fetch!="function"?I(O):fetch(Ee,{credentials:"same-origin"}).then(function(B){return WebAssembly.instantiateStreaming(B,F).then(O,function(q){return R("wasm streaming compile failed: "+q),R("falling back to ArrayBuffer instantiation"),I(O)})})).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)},pe=n._setThrew=function(){return(pe=n._setThrew=n.asm.Bb).apply(null,arguments)},Qt=n._emscripten_stack_set_limits=function(){return(Qt=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)},Zt=n.___cxa_is_pointer_type=function(){return(Zt=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)},on=n.dynCall_viiijjjii=function(){return(on=n.dynCall_viiijjjii=n.asm.Nb).apply(null,arguments)},sn=n.dynCall_iij=function(){return(sn=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)},ln=n.dynCall_iiiiiij=function(){return(ln=n.dynCall_iiiiiij=n.asm.Qb).apply(null,arguments)},un=n.dynCall_iiij=function(){return(un=n.dynCall_iiij=n.asm.Rb).apply(null,arguments)};function cn(){function v(){if(!Ct&&(Ct=!0,n.calledRun=!0,!be)&&(M||rt(Ve),e(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),!M)){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;){var O=n.postRun.shift();Qe.unshift(O)}rt(Qe)}}if(!(0{var s,u=(s=(s=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(d){var a,h,f;d=d||{},a||(a=d!==void 0?d:{}),a.ready=new Promise(function(E,k){h=E,f=k});var c,l,n,e,r,o,p=Object.assign({},a),g="./this.program",_=(E,k)=>{throw k},b=typeof window=="object",y=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T="";w?(T=y?i(908).dirname(T)+"/":"//",o=()=>{r||(e=i(1384),r=i(908))},c=function(E,k){return o(),E=r.normalize(E),e.readFileSync(E,k?void 0:"utf8")},n=E=>((E=c(E,!0)).buffer||(E=new Uint8Array(E)),E),l=(E,k,L)=>{o(),E=r.normalize(E),e.readFile(E,function(j,U){j?L(j):k(U.buffer)})},1{if(x||0{var k=new XMLHttpRequest;return k.open("GET",E,!1),k.send(null),k.responseText},y&&(n=E=>{var k=new XMLHttpRequest;return k.open("GET",E,!1),k.responseType="arraybuffer",k.send(null),new Uint8Array(k.response)}),l=(E,k,L)=>{var j=new XMLHttpRequest;j.open("GET",E,!0),j.responseType="arraybuffer",j.onload=()=>{j.status==200||j.status==0&&j.response?k(j.response):L()},j.onerror=L,j.send(null)});var S,A=a.print||console.log.bind(console),P=a.printErr||console.warn.bind(console);Object.assign(a,p),p=null,a.thisProgram&&(g=a.thisProgram),a.quit&&(_=a.quit),a.wasmBinary&&(S=a.wasmBinary);var x=a.noExitRuntime||!1;typeof WebAssembly!="object"&&Me("no native wasm support detected");var M,N,z,$,C,G,D=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Y(E,k,L){var j=(k>>>=0)+L;for(L=k;E[L]&&!(L>=j);)++L;if(16(U=(240&U)==224?(15&U)<<12|X<<6|K:(7&U)<<18|X<<12|K<<6|63&E[k++])?j+=String.fromCharCode(U):(U-=65536,j+=String.fromCharCode(55296|U>>10,56320|1023&U))}}else j+=String.fromCharCode(U)}return j}function V(E,k){return(E>>>=0)?Y($,E,k):""}function J(E,k,L,j){if(!(0>>=0;j=L+j-1;for(var X=0;X=K&&(K=65536+((1023&K)<<10)|1023&E.charCodeAt(++X)),127>=K){if(L>=j)break;k[L++>>>0]=K}else{if(2047>=K){if(L+1>=j)break;k[L++>>>0]=192|K>>6}else{if(65535>=K){if(L+2>=j)break;k[L++>>>0]=224|K>>12}else{if(L+3>=j)break;k[L++>>>0]=240|K>>18,k[L++>>>0]=128|K>>12&63}k[L++>>>0]=128|K>>6&63}k[L++>>>0]=128|63&K}}return k[L>>>0]=0,L-U}function Z(E){for(var k=0,L=0;L=j?k++:2047>=j?k+=2:55296<=j&&57343>=j?(k+=4,++L):k+=3}return k}function le(){var E=M.buffer;N=E,a.HEAP8=z=new Int8Array(E),a.HEAP16=new Int16Array(E),a.HEAP32=C=new Int32Array(E),a.HEAPU8=$=new Uint8Array(E),a.HEAPU16=new Uint16Array(E),a.HEAPU32=G=new Uint32Array(E),a.HEAPF32=new Float32Array(E),a.HEAPF64=new Float64Array(E)}var Ae,xe=[],se=[],we=[],be=[],ke=0;function Le(){var E=a.preRun.shift();xe.unshift(E)}var ve,$e=0,Fe=null;function Me(E){throw a.onAbort&&a.onAbort(E),P(E="Aborted("+E+")"),D=!0,E=new WebAssembly.RuntimeError(E+". Build with -sASSERTIONS for more info."),f(E),E}function Pe(){return ve.startsWith("data:application/octet-stream;base64,")}if(ve="ort-wasm.wasm",!Pe()){var Be=ve;ve=a.locateFile?a.locateFile(Be,T):T+Be}function Ge(){var E=ve;try{if(E==ve&&S)return new Uint8Array(S);if(n)return n(E);throw"both async and sync fetching of the wasm failed"}catch(k){Me(k)}}function Ve(E){this.name="ExitStatus",this.message="Program terminated with exit("+E+")",this.status=E}function Xe(E){for(;0>2>>>0]=k},this.Eb=function(){return G[this.zb+4>>2>>>0]},this.Sb=function(k){G[this.zb+8>>2>>>0]=k},this.Wb=function(){return G[this.zb+8>>2>>>0]},this.Tb=function(){C[this.zb>>2>>>0]=0},this.Ib=function(k){z[this.zb+12>>0>>>0]=k?1:0},this.Pb=function(){return z[this.zb+12>>0>>>0]!=0},this.Jb=function(k){z[this.zb+13>>0>>>0]=k?1:0},this.Lb=function(){return z[this.zb+13>>0>>>0]!=0},this.Rb=function(k,L){this.Fb(0),this.Ub(k),this.Sb(L),this.Tb(),this.Ib(!1),this.Jb(!1)},this.Nb=function(){C[this.zb>>2>>>0]+=1},this.Xb=function(){var k=C[this.zb>>2>>>0];return C[this.zb>>2>>>0]=k-1,k===1},this.Fb=function(k){G[this.zb+16>>2>>>0]=k},this.Ob=function(){return G[this.zb+16>>2>>>0]},this.Qb=function(){if(mt(this.Eb()))return G[this.Db>>2>>>0];var k=this.Ob();return k!==0?k:this.Db}}function ze(E){return ot(new Ee(E).zb)}var Ye=[];function ge(E){var k=Ye[E];return k||(E>=Ye.length&&(Ye.length=E+1),Ye[E]=k=Ae.get(E)),k}function pt(E){var k=Z(E)+1,L=Te(k);return L&&J(E,z,L,k),L}var ut={};function Et(){if(!Ze){var E,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",_:g||"./this.program"};for(E in ut)ut[E]===void 0?delete k[E]:k[E]=ut[E];var L=[];for(E in k)L.push(E+"="+k[E]);Ze=L}return Ze}var Ze,ct=[null,[],[]];function dt(E,k){var L=ct[E];k===0||k===10?((E===1?A:P)(Y(L,0)),L.length=0):L.push(k)}var Re=0;function it(E){return E%4==0&&(E%100!=0||E%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 Mt(E,k,L,j){function U(W,_e,Oe){for(W=typeof W=="number"?W.toString():W||"";W.length<_e;)W=Oe[0]+W;return W}function X(W,_e){return U(W,_e,"0")}function K(W,_e){function Oe(et){return 0>et?-1:0We-W.getDate())){W.setDate(W.getDate()+_e);break}_e-=We-W.getDate()+1,W.setDate(1),11>Oe?W.setMonth(Oe+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Oe=new Date(W.getFullYear()+1,0,4),_e=te(new Date(W.getFullYear(),0,4)),Oe=te(Oe),0>=K(_e,W)?0>=K(Oe,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}var ue=C[j+40>>2>>>0];for(var Se in j={$b:C[j>>2>>>0],Zb:C[j+4>>2>>>0],Gb:C[j+8>>2>>>0],Kb:C[j+12>>2>>>0],Hb:C[j+16>>2>>>0],Cb:C[j+20>>2>>>0],Ab:C[j+24>>2>>>0],Bb:C[j+28>>2>>>0],bc:C[j+32>>2>>>0],Yb:C[j+36>>2>>>0],ac:ue?V(ue):""},L=V(L),ue={"%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"})L=L.replace(new RegExp(Se,"g"),ue[Se]);var Ne="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ce="January February March April May June July August September October November December".split(" ");for(Se in ue={"%a":function(W){return Ne[W.Ab].substring(0,3)},"%A":function(W){return Ne[W.Ab]},"%b":function(W){return Ce[W.Hb].substring(0,3)},"%B":function(W){return Ce[W.Hb]},"%C":function(W){return X((W.Cb+1900)/100|0,2)},"%d":function(W){return X(W.Kb,2)},"%e":function(W){return U(W.Kb,2," ")},"%g":function(W){return ee(W).toString().substring(2)},"%G":function(W){return ee(W)},"%H":function(W){return X(W.Gb,2)},"%I":function(W){return(W=W.Gb)==0?W=12:12W.Gb?"AM":"PM"},"%S":function(W){return X(W.$b,2)},"%t":function(){return" "},"%u":function(W){return W.Ab||7},"%U":function(W){return X(Math.floor((W.Bb+7-W.Ab)/7),2)},"%V":function(W){var _e=Math.floor((W.Bb+7-(W.Ab+6)%7)/7);if(2>=(W.Ab+371-W.Bb-2)%7&&_e++,_e)_e==53&&((Oe=(W.Ab+371-W.Bb)%7)==4||Oe==3&&it(W.Cb)||(_e=1));else{_e=52;var Oe=(W.Ab+7-W.Bb-1)%7;(Oe==4||Oe==5&&it(W.Cb%400-1))&&_e++}return X(_e,2)},"%w":function(W){return W.Ab},"%W":function(W){return X(Math.floor((W.Bb+7-(W.Ab+6)%7)/7),2)},"%y":function(W){return(W.Cb+1900).toString().substring(2)},"%Y":function(W){return W.Cb+1900},"%z":function(W){var _e=0<=(W=W.Yb);return W=Math.abs(W)/60,(_e?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":function(W){return W.ac},"%%":function(){return"%"}},L=L.replace(/%%/g,"\0\0"),ue)L.includes(Se)&&(L=L.replace(new RegExp(Se,"g"),ue[Se](j)));return Se=function(W){var _e=Array(Z(W)+1);return J(W,_e,0,_e.length),_e}(L=L.replace(/\0\0/g,"%")),Se.length>k?0:(z.set(Se,E>>>0),Se.length-1)}var It={a:function(E){return Te(E+24)+24},m:function(E){return(E=new Ee(E)).Pb()||(E.Ib(!0),qe--),E.Jb(!1),Qe.push(E),E.Nb(),E.Qb()},ia:function(E){throw P("Unexpected exception thrown, this is not properly supported - aborting"),D=!0,E},w:function(){ae(0);var E=Qe.pop();if(E.Xb()&&!E.Lb()){var k=E.Wb();k&&ge(k)(E.Db),ze(E.Db)}Ue=0},d:function(){var E=Ue;if(!E)return Re=0;var k=new Ee(E);k.Fb(E);var L=k.Eb();if(!L)return Re=0,E;for(var j=Array.prototype.slice.call(arguments),U=0;U>>2]+4294967296*C[E+4>>>2])),C[k>>2>>>0]=E.getUTCSeconds(),C[k+4>>2>>>0]=E.getUTCMinutes(),C[k+8>>2>>>0]=E.getUTCHours(),C[k+12>>2>>>0]=E.getUTCDate(),C[k+16>>2>>>0]=E.getUTCMonth(),C[k+20>>2>>>0]=E.getUTCFullYear()-1900,C[k+24>>2>>>0]=E.getUTCDay(),C[k+28>>2>>>0]=(E.getTime()-Date.UTC(E.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Ea:function(E,k){E=new Date(1e3*(G[E>>>2]+4294967296*C[E+4>>>2])),C[k>>2>>>0]=E.getSeconds(),C[k+4>>2>>>0]=E.getMinutes(),C[k+8>>2>>>0]=E.getHours(),C[k+12>>2>>>0]=E.getDate(),C[k+16>>2>>>0]=E.getMonth(),C[k+20>>2>>>0]=E.getFullYear()-1900,C[k+24>>2>>>0]=E.getDay();var L=new Date(E.getFullYear(),0,1);C[k+28>>2>>>0]=(E.getTime()-L.getTime())/864e5|0,C[k+36>>2>>>0]=-60*E.getTimezoneOffset();var j=new Date(E.getFullYear(),6,1).getTimezoneOffset();L=L.getTimezoneOffset(),C[k+32>>2>>>0]=0|(j!=L&&E.getTimezoneOffset()==Math.min(L,j))},Fa:function(E){var k=new Date(C[E+20>>2>>>0]+1900,C[E+16>>2>>>0],C[E+12>>2>>>0],C[E+8>>2>>>0],C[E+4>>2>>>0],C[E>>2>>>0],0),L=C[E+32>>2>>>0],j=k.getTimezoneOffset(),U=new Date(k.getFullYear(),0,1),X=new Date(k.getFullYear(),6,1).getTimezoneOffset(),K=U.getTimezoneOffset(),te=Math.min(K,X);return 0>L?C[E+32>>2>>>0]=+(X!=K&&te==j):0>2>>>0]=k.getDay(),C[E+28>>2>>>0]=(k.getTime()-U.getTime())/864e5|0,C[E>>2>>>0]=k.getSeconds(),C[E+4>>2>>>0]=k.getMinutes(),C[E+8>>2>>>0]=k.getHours(),C[E+12>>2>>>0]=k.getDate(),C[E+16>>2>>>0]=k.getMonth(),k.getTime()/1e3|0},sa:function(){return-52},ta:function(){},Ga:function E(k,L,j){E.Vb||(E.Vb=!0,function(U,X,K){function te(Ce){return(Ce=Ce.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ce[1]:"GMT"}var ee=new Date().getFullYear(),ue=new Date(ee,0,1),Se=new Date(ee,6,1);ee=ue.getTimezoneOffset();var Ne=Se.getTimezoneOffset();C[U>>2>>>0]=60*Math.max(ee,Ne),C[X>>2>>>0]=+(ee!=Ne),U=te(ue),X=te(Se),U=pt(U),X=pt(X),Ne>2>>>0]=U,G[K+4>>2>>>0]=X):(G[K>>2>>>0]=X,G[K+4>>2>>>0]=U)}(k,L,j))},B:function(){Me("")},ma:function(){return 4294901760},I:w?()=>{var E=process.hrtime();return 1e3*E[0]+E[1]/1e6}:()=>performance.now(),xa:function(E,k,L){$.copyWithin(E>>>0,k>>>0,k+L>>>0)},G:function(E){var k=$.length;if(4294901760<(E>>>=0))return!1;for(var L=1;4>=L;L*=2){var j=k*(1+.2/L);j=Math.min(j,E+100663296);var U=Math;j=Math.max(E,j),U=U.min.call(U,4294901760,j+(65536-j%65536)%65536);e:{try{M.grow(U-N.byteLength+65535>>>16),le();var X=1;break e}catch{}X=void 0}if(X)return!0}return!1},va:function(E,k){var L=0;return Et().forEach(function(j,U){var X=k+L;for(U=G[E+4*U>>2>>>0]=X,X=0;X>0>>>0]=j.charCodeAt(X);z[U>>0>>>0]=0,L+=j.length+1}),0},wa:function(E,k){var L=Et();G[E>>2>>>0]=L.length;var j=0;return L.forEach(function(U){j+=U.length+1}),G[k>>2>>>0]=j,0},ba:function(E){x||0>2>>>0],te=G[k+4>>2>>>0];k+=8;for(var ee=0;ee>>0]);U+=te}return G[j>>2>>>0]=U,0},c:function(){return Re},ja:function E(k,L){E.Mb||(E.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 X=i(Object(function(){var K=new Error("Cannot find module 'crypto'");throw K.code="MODULE_NOT_FOUND",K}()));return()=>X.randomBytes(1)[0]}catch{}return()=>Me("randomDevice")}());for(var j=0;j>0>>>0]=E.Mb();return 0},ea:function(E,k,L){var j=ie();try{return ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},fa:function(E,k,L){var j=ie();try{return ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},J:function(E){var k=ie();try{return ge(E)()}catch(L){if(oe(k),L!==L+0)throw L;ae(1,0)}},e:function(E,k){var L=ie();try{return ge(E)(k)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},N:function(E,k,L){var j=ie();try{return ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},O:function(E,k,L){var j=ie();try{return ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},j:function(E,k,L){var j=ie();try{return ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},o:function(E,k,L,j){var U=ie();try{return ge(E)(k,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},p:function(E,k,L,j,U){var X=ie();try{return ge(E)(k,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},M:function(E,k,L,j,U,X){var K=ie();try{return ge(E)(k,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},r:function(E,k,L,j,U,X){var K=ie();try{return ge(E)(k,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},v:function(E,k,L,j,U,X,K){var te=ie();try{return ge(E)(k,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},K:function(E,k,L,j,U,X,K,te){var ee=ie();try{return ge(E)(k,L,j,U,X,K,te)}catch(ue){if(oe(ee),ue!==ue+0)throw ue;ae(1,0)}},D:function(E,k,L,j,U,X,K,te,ee,ue,Se,Ne){var Ce=ie();try{return ge(E)(k,L,j,U,X,K,te,ee,ue,Se,Ne)}catch(W){if(oe(Ce),W!==W+0)throw W;ae(1,0)}},X:function(E,k,L,j,U,X,K,te){var ee=ie();try{return At(E,k,L,j,U,X,K,te)}catch(ue){if(oe(ee),ue!==ue+0)throw ue;ae(1,0)}},V:function(E,k,L,j,U,X,K){var te=ie();try{return bt(E,k,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},U:function(E,k,L,j,U){var X=ie();try{return Pt(E,k,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},Z:function(E,k,L,j){var U=ie();try{return vt(E,k,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},W:function(E){var k=ie();try{return _t(E)}catch(L){if(oe(k),L!==L+0)throw L;ae(1,0)}},Y:function(E,k){var L=ie();try{return St(E,k)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},T:function(E,k,L){var j=ie();try{return yt(E,k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},f:function(E){var k=ie();try{ge(E)()}catch(L){if(oe(k),L!==L+0)throw L;ae(1,0)}},q:function(E,k){var L=ie();try{ge(E)(k)}catch(j){if(oe(L),j!==j+0)throw j;ae(1,0)}},h:function(E,k,L){var j=ie();try{ge(E)(k,L)}catch(U){if(oe(j),U!==U+0)throw U;ae(1,0)}},da:function(E,k,L,j){var U=ie();try{ge(E)(k,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},l:function(E,k,L,j){var U=ie();try{ge(E)(k,L,j)}catch(X){if(oe(U),X!==X+0)throw X;ae(1,0)}},t:function(E,k,L,j,U){var X=ie();try{ge(E)(k,L,j,U)}catch(K){if(oe(X),K!==K+0)throw K;ae(1,0)}},u:function(E,k,L,j,U,X){var K=ie();try{ge(E)(k,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},x:function(E,k,L,j,U,X,K){var te=ie();try{ge(E)(k,L,j,U,X,K)}catch(ee){if(oe(te),ee!==ee+0)throw ee;ae(1,0)}},z:function(E,k,L,j,U,X,K,te){var ee=ie();try{ge(E)(k,L,j,U,X,K,te)}catch(ue){if(oe(ee),ue!==ue+0)throw ue;ae(1,0)}},ga:function(E,k,L,j,U,X,K,te,ee){var ue=ie();try{ge(E)(k,L,j,U,X,K,te,ee)}catch(Se){if(oe(ue),Se!==Se+0)throw Se;ae(1,0)}},A:function(E,k,L,j,U,X,K,te,ee,ue,Se){var Ne=ie();try{ge(E)(k,L,j,U,X,K,te,ee,ue,Se)}catch(Ce){if(oe(Ne),Ce!==Ce+0)throw Ce;ae(1,0)}},C:function(E,k,L,j,U,X,K,te,ee,ue,Se,Ne,Ce,W,_e,Oe){var We=ie();try{ge(E)(k,L,j,U,X,K,te,ee,ue,Se,Ne,Ce,W,_e,Oe)}catch(et){if(oe(We),et!==et+0)throw et;ae(1,0)}},aa:function(E,k,L,j,U,X,K,te){var ee=ie();try{wt(E,k,L,j,U,X,K,te)}catch(ue){if(oe(ee),ue!==ue+0)throw ue;ae(1,0)}},_:function(E,k,L,j,U,X,K,te,ee,ue,Se,Ne){var Ce=ie();try{xt(E,k,L,j,U,X,K,te,ee,ue,Se,Ne)}catch(W){if(oe(Ce),W!==W+0)throw W;ae(1,0)}},$:function(E,k,L,j,U,X){var K=ie();try{Tt(E,k,L,j,U,X)}catch(te){if(oe(K),te!==te+0)throw te;ae(1,0)}},n:function(E){return E},F:function(E){Re=E},ha:Mt,y:function(E,k,L,j){return Mt(E,k,L,j)}};(function(){function E(U){a.asm=U.exports,M=a.asm.Ka,le(),Ae=a.asm.ib,se.unshift(a.asm.La),$e--,a.monitorRunDependencies&&a.monitorRunDependencies($e),$e==0&&Fe&&(U=Fe,Fe=null,U())}function k(U){E(U.instance)}function L(U){return function(){if(!S&&(b||y)){if(typeof fetch=="function"&&!ve.startsWith("file://"))return fetch(ve,{credentials:"same-origin"}).then(function(X){if(!X.ok)throw"failed to load wasm binary file at '"+ve+"'";return X.arrayBuffer()}).catch(function(){return Ge()});if(l)return new Promise(function(X,K){l(ve,function(te){X(new Uint8Array(te))},K)})}return Promise.resolve().then(function(){return Ge()})}().then(function(X){return WebAssembly.instantiate(X,j)}).then(function(X){return X}).then(U,function(X){P("failed to asynchronously prepare wasm: "+X),Me(X)})}var j={a:It};if($e++,a.monitorRunDependencies&&a.monitorRunDependencies($e),a.instantiateWasm)try{return a.instantiateWasm(j,E)}catch(U){return P("Module.instantiateWasm callback failed with error: "+U),!1}(S||typeof WebAssembly.instantiateStreaming!="function"||Pe()||ve.startsWith("file://")||w||typeof fetch!="function"?L(k):fetch(ve,{credentials:"same-origin"}).then(function(U){return WebAssembly.instantiateStreaming(U,j).then(k,function(X){return P("wasm streaming compile failed: "+X),P("falling back to ArrayBuffer instantiation"),L(k)})})).catch(f)})(),a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.La).apply(null,arguments)},a._OrtInit=function(){return(a._OrtInit=a.asm.Ma).apply(null,arguments)},a._OrtCreateSessionOptions=function(){return(a._OrtCreateSessionOptions=a.asm.Na).apply(null,arguments)},a._OrtAppendExecutionProvider=function(){return(a._OrtAppendExecutionProvider=a.asm.Oa).apply(null,arguments)},a._OrtAddSessionConfigEntry=function(){return(a._OrtAddSessionConfigEntry=a.asm.Pa).apply(null,arguments)},a._OrtReleaseSessionOptions=function(){return(a._OrtReleaseSessionOptions=a.asm.Qa).apply(null,arguments)},a._OrtCreateSession=function(){return(a._OrtCreateSession=a.asm.Ra).apply(null,arguments)},a._OrtReleaseSession=function(){return(a._OrtReleaseSession=a.asm.Sa).apply(null,arguments)},a._OrtGetInputCount=function(){return(a._OrtGetInputCount=a.asm.Ta).apply(null,arguments)},a._OrtGetOutputCount=function(){return(a._OrtGetOutputCount=a.asm.Ua).apply(null,arguments)},a._OrtGetInputName=function(){return(a._OrtGetInputName=a.asm.Va).apply(null,arguments)},a._OrtGetOutputName=function(){return(a._OrtGetOutputName=a.asm.Wa).apply(null,arguments)},a._OrtFree=function(){return(a._OrtFree=a.asm.Xa).apply(null,arguments)},a._OrtCreateTensor=function(){return(a._OrtCreateTensor=a.asm.Ya).apply(null,arguments)},a._OrtGetTensorData=function(){return(a._OrtGetTensorData=a.asm.Za).apply(null,arguments)},a._OrtReleaseTensor=function(){return(a._OrtReleaseTensor=a.asm._a).apply(null,arguments)},a._OrtCreateRunOptions=function(){return(a._OrtCreateRunOptions=a.asm.$a).apply(null,arguments)},a._OrtAddRunConfigEntry=function(){return(a._OrtAddRunConfigEntry=a.asm.ab).apply(null,arguments)},a._OrtReleaseRunOptions=function(){return(a._OrtReleaseRunOptions=a.asm.bb).apply(null,arguments)},a._OrtRun=function(){return(a._OrtRun=a.asm.cb).apply(null,arguments)},a._OrtEndProfiling=function(){return(a._OrtEndProfiling=a.asm.db).apply(null,arguments)};var Je,Te=a._malloc=function(){return(Te=a._malloc=a.asm.eb).apply(null,arguments)},ot=a._free=function(){return(ot=a._free=a.asm.fb).apply(null,arguments)},ft=a._fflush=function(){return(ft=a._fflush=a.asm.gb).apply(null,arguments)},st=a.___funcs_on_exit=function(){return(st=a.___funcs_on_exit=a.asm.hb).apply(null,arguments)},ae=a._setThrew=function(){return(ae=a._setThrew=a.asm.jb).apply(null,arguments)},ie=a.stackSave=function(){return(ie=a.stackSave=a.asm.kb).apply(null,arguments)},oe=a.stackRestore=function(){return(oe=a.stackRestore=a.asm.lb).apply(null,arguments)},gt=a.stackAlloc=function(){return(gt=a.stackAlloc=a.asm.mb).apply(null,arguments)},at=a.___cxa_can_catch=function(){return(at=a.___cxa_can_catch=a.asm.nb).apply(null,arguments)},mt=a.___cxa_is_pointer_type=function(){return(mt=a.___cxa_is_pointer_type=a.asm.ob).apply(null,arguments)},_t=a.dynCall_j=function(){return(_t=a.dynCall_j=a.asm.pb).apply(null,arguments)},bt=a.dynCall_iiiiij=function(){return(bt=a.dynCall_iiiiij=a.asm.qb).apply(null,arguments)},yt=a.dynCall_jii=function(){return(yt=a.dynCall_jii=a.asm.rb).apply(null,arguments)},wt=a.dynCall_viiiiij=function(){return(wt=a.dynCall_viiiiij=a.asm.sb).apply(null,arguments)},Tt=a.dynCall_vjji=function(){return(Tt=a.dynCall_vjji=a.asm.tb).apply(null,arguments)},xt=a.dynCall_viiijjjii=function(){return(xt=a.dynCall_viiijjjii=a.asm.ub).apply(null,arguments)},vt=a.dynCall_iij=function(){return(vt=a.dynCall_iij=a.asm.vb).apply(null,arguments)},St=a.dynCall_ji=function(){return(St=a.dynCall_ji=a.asm.wb).apply(null,arguments)},At=a.dynCall_iiiiiij=function(){return(At=a.dynCall_iiiiiij=a.asm.xb).apply(null,arguments)},Pt=a.dynCall_iiij=function(){return(Pt=a.dynCall_iiij=a.asm.yb).apply(null,arguments)};function Ot(){function E(){if(!Je&&(Je=!0,a.calledRun=!0,!D)){if(Xe(se),h(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;){var k=a.postRun.shift();be.unshift(k)}Xe(be)}}if(!(0<$e)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Le();Xe(xe),0<$e||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),E()},1)):E())}}if(a.UTF8ToString=V,a.stringToUTF8=function(E,k,L){return J(E,$,k,L)},a.lengthBytesUTF8=Z,a.stackSave=ie,a.stackRestore=oe,a.stackAlloc=gt,Fe=function E(){Je||Ot(),Je||(Fe=E)},a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0{m.exports=function(t,i){for(var s=new Array(arguments.length-1),u=0,d=2,a=!0;d{var i=t;i.length=function(h){var f=h.length;if(!f)return 0;for(var c=0;--f%4>1&&h.charAt(f)==="=";)++c;return Math.ceil(3*h.length)/4-c};for(var s=new Array(64),u=new Array(123),d=0;d<64;)u[s[d]=d<26?d+65:d<52?d+71:d<62?d-4:d-59|43]=d++;i.encode=function(h,f,c){for(var l,n=null,e=[],r=0,o=0;f>2],l=(3&p)<<4,o=1;break;case 1:e[r++]=s[l|p>>4],l=(15&p)<<2,o=2;break;case 2:e[r++]=s[l|p>>6],e[r++]=s[63&p],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 a="invalid encoding";i.decode=function(h,f,c){for(var l,n=c,e=0,r=0;r1)break;if((o=u[o])===void 0)throw Error(a);switch(e){case 0:l=o,e=1;break;case 1:f[c++]=l<<2|(48&o)>>4,l=o,e=2;break;case 2:f[c++]=(15&l)<<4|(60&o)>>2,l=o,e=3;break;case 3:f[c++]=(3&l)<<6|o,e=0}}if(e===1)throw Error(a);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,u){return(this._listeners[i]||(this._listeners[i]=[])).push({fn:s,ctx:u||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 u=this._listeners[i],d=0;d{function t(a){return typeof Float32Array<"u"?function(){var h=new Float32Array([-0]),f=new Uint8Array(h.buffer),c=f[3]===128;function l(o,p,g){h[0]=o,p[g]=f[0],p[g+1]=f[1],p[g+2]=f[2],p[g+3]=f[3]}function n(o,p,g){h[0]=o,p[g]=f[3],p[g+1]=f[2],p[g+2]=f[1],p[g+3]=f[0]}function e(o,p){return f[0]=o[p],f[1]=o[p+1],f[2]=o[p+2],f[3]=o[p+3],h[0]}function r(o,p){return f[3]=o[p],f[2]=o[p+1],f[1]=o[p+2],f[0]=o[p+3],h[0]}a.writeFloatLE=c?l:n,a.writeFloatBE=c?n:l,a.readFloatLE=c?e:r,a.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 f(c,l,n){var e=c(l,n),r=2*(e>>31)+1,o=e>>>23&255,p=8388607&e;return o===255?p?NaN:r*(1/0):o===0?1401298464324817e-60*r*p:r*Math.pow(2,o-150)*(p+8388608)}a.writeFloatLE=h.bind(null,i),a.writeFloatBE=h.bind(null,s),a.readFloatLE=f.bind(null,u),a.readFloatBE=f.bind(null,d)}(),typeof Float64Array<"u"?function(){var h=new Float64Array([-0]),f=new Uint8Array(h.buffer),c=f[7]===128;function l(o,p,g){h[0]=o,p[g]=f[0],p[g+1]=f[1],p[g+2]=f[2],p[g+3]=f[3],p[g+4]=f[4],p[g+5]=f[5],p[g+6]=f[6],p[g+7]=f[7]}function n(o,p,g){h[0]=o,p[g]=f[7],p[g+1]=f[6],p[g+2]=f[5],p[g+3]=f[4],p[g+4]=f[3],p[g+5]=f[2],p[g+6]=f[1],p[g+7]=f[0]}function e(o,p){return f[0]=o[p],f[1]=o[p+1],f[2]=o[p+2],f[3]=o[p+3],f[4]=o[p+4],f[5]=o[p+5],f[6]=o[p+6],f[7]=o[p+7],h[0]}function r(o,p){return f[7]=o[p],f[6]=o[p+1],f[5]=o[p+2],f[4]=o[p+3],f[3]=o[p+4],f[2]=o[p+5],f[1]=o[p+6],f[0]=o[p+7],h[0]}a.writeDoubleLE=c?l:n,a.writeDoubleBE=c?n:l,a.readDoubleLE=c?e:r,a.readDoubleBE=c?r:e}():function(){function h(c,l,n,e,r,o){var p=e<0?1:0;if(p&&(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((p<<31|2146435072)>>>0,r,o+n);else{var g;if(e<22250738585072014e-324)c((g=e/5e-324)>>>0,r,o+l),c((p<<31|g/4294967296)>>>0,r,o+n);else{var _=Math.floor(Math.log(e)/Math.LN2);_===1024&&(_=1023),c(4503599627370496*(g=e*Math.pow(2,-_))>>>0,r,o+l),c((p<<31|_+1023<<20|1048576*g&1048575)>>>0,r,o+n)}}}function f(c,l,n,e,r){var o=c(e,r+l),p=c(e,r+n),g=2*(p>>31)+1,_=p>>>20&2047,b=4294967296*(1048575&p)+o;return _===2047?b?NaN:g*(1/0):_===0?5e-324*g*b:g*Math.pow(2,_-1075)*(b+4503599627370496)}a.writeDoubleLE=h.bind(null,i,0,4),a.writeDoubleBE=h.bind(null,s,4,0),a.readDoubleLE=f.bind(null,u,0,4),a.readDoubleBE=f.bind(null,d,4,0)}(),a}function i(a,h,f){h[f]=255&a,h[f+1]=a>>>8&255,h[f+2]=a>>>16&255,h[f+3]=a>>>24}function s(a,h,f){h[f]=a>>>24,h[f+1]=a>>>16&255,h[f+2]=a>>>8&255,h[f+3]=255&a}function u(a,h){return(a[h]|a[h+1]<<8|a[h+2]<<16|a[h+3]<<24)>>>0}function d(a,h){return(a[h]<<24|a[h+1]<<16|a[h+2]<<8|a[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 u=s||8192,d=u>>>1,a=null,h=u;return function(f){if(f<1||f>d)return t(f);h+f>u&&(a=t(u),h=0);var c=i.call(a,h,h+=f);return 7&h&&(h=1+(7|h)),c}}},4997:(m,t)=>{var i=t;i.length=function(s){for(var u=0,d=0,a=0;a191&&a<224?f[c++]=(31&a)<<6|63&s[u++]:a>239&&a<365?(a=((7&a)<<18|(63&s[u++])<<12|(63&s[u++])<<6|63&s[u++])-65536,f[c++]=55296+(a>>10),f[c++]=56320+(1023&a)):f[c++]=(15&a)<<12|(63&s[u++])<<6|63&s[u++],c>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,f)),c=0);return h?(c&&h.push(String.fromCharCode.apply(String,f.slice(0,c))),h.join("")):String.fromCharCode.apply(String,f.slice(0,c))},i.write=function(s,u,d){for(var a,h,f=d,c=0;c>6|192,u[d++]=63&a|128):(64512&a)==55296&&(64512&(h=s.charCodeAt(c+1)))==56320?(a=65536+((1023&a)<<10)+(1023&h),++c,u[d++]=a>>18|240,u[d++]=a>>12&63|128,u[d++]=a>>6&63|128,u[d++]=63&a|128):(u[d++]=a>>12|224,u[d++]=a>>6&63|128,u[d++]=63&a|128);return d-f}},3442:(m,t)=>{t.__esModule=!0;var i=function(){function s(u){if(!u)throw new TypeError("Invalid argument; `value` has no value.");this.value=s.EMPTY,u&&s.isGuid(u)&&(this.value=u)}return s.isGuid=function(u){var d=u.toString();return u&&(u 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(u){return new s(u)},s.raw=function(){return[s.gen(2),s.gen(1),s.gen(1),s.gen(1),s.gen(3)].join("-")},s.gen=function(u){for(var d="",a=0;a{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,M,N){this.low=0|x,this.high=0|M,this.unsigned=!!N}function s(x){return(x&&x.__isLong__)===!0}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=s;var u={},d={};function a(x,M){var N,z,$;return M?($=0<=(x>>>=0)&&x<256)&&(z=d[x])?z:(N=f(x,(0|x)<0?-1:0,!0),$&&(d[x]=N),N):($=-128<=(x|=0)&&x<128)&&(z=u[x])?z:(N=f(x,x<0?-1:0,!1),$&&(u[x]=N),N)}function h(x,M){if(isNaN(x))return M?_:g;if(M){if(x<0)return _;if(x>=r)return S}else{if(x<=-o)return A;if(x+1>=o)return T}return x<0?h(-x,M).neg():f(x%e|0,x/e|0,M)}function f(x,M,N){return new i(x,M,N)}i.fromInt=a,i.fromNumber=h,i.fromBits=f;var c=Math.pow;function l(x,M,N){if(x.length===0)throw Error("empty string");if(x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return g;if(typeof M=="number"?(N=M,M=!1):M=!!M,(N=N||10)<2||360)throw Error("interior hyphen");if(z===0)return l(x.substring(1),M,N).neg();for(var $=h(c(N,8)),C=g,G=0;G>>0:this.low},P.toNumber=function(){return this.unsigned?(this.high>>>0)*e+(this.low>>>0):this.high*e+(this.low>>>0)},P.toString=function(x){if((x=x||10)<2||36>>0).toString(x);if((C=D).isZero())return R+G;for(;R.length<6;)R="0"+R;G=""+R+G}},P.getHighBits=function(){return this.high},P.getHighBitsUnsigned=function(){return this.high>>>0},P.getLowBits=function(){return this.low},P.getLowBitsUnsigned=function(){return this.low>>>0},P.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,M=31;M>0&&!(x&1<=0},P.isOdd=function(){return(1&this.low)==1},P.isEven=function(){return(1&this.low)==0},P.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},P.eq=P.equals,P.notEquals=function(x){return!this.eq(x)},P.neq=P.notEquals,P.ne=P.notEquals,P.lessThan=function(x){return this.comp(x)<0},P.lt=P.lessThan,P.lessThanOrEqual=function(x){return this.comp(x)<=0},P.lte=P.lessThanOrEqual,P.le=P.lessThanOrEqual,P.greaterThan=function(x){return this.comp(x)>0},P.gt=P.greaterThan,P.greaterThanOrEqual=function(x){return this.comp(x)>=0},P.gte=P.greaterThanOrEqual,P.ge=P.greaterThanOrEqual,P.compare=function(x){if(s(x)||(x=n(x)),this.eq(x))return 0;var M=this.isNegative(),N=x.isNegative();return M&&!N?-1:!M&&N?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},P.comp=P.compare,P.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(b)},P.neg=P.negate,P.add=function(x){s(x)||(x=n(x));var M=this.high>>>16,N=65535&this.high,z=this.low>>>16,$=65535&this.low,C=x.high>>>16,G=65535&x.high,D=x.low>>>16,R=0,Y=0,V=0,J=0;return V+=(J+=$+(65535&x.low))>>>16,Y+=(V+=z+D)>>>16,R+=(Y+=N+G)>>>16,R+=M+C,f((V&=65535)<<16|(J&=65535),(R&=65535)<<16|(Y&=65535),this.unsigned)},P.subtract=function(x){return s(x)||(x=n(x)),this.add(x.neg())},P.sub=P.subtract,P.multiply=function(x){if(this.isZero())return g;if(s(x)||(x=n(x)),t)return f(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(p)&&x.lt(p))return h(this.toNumber()*x.toNumber(),this.unsigned);var M=this.high>>>16,N=65535&this.high,z=this.low>>>16,$=65535&this.low,C=x.high>>>16,G=65535&x.high,D=x.low>>>16,R=65535&x.low,Y=0,V=0,J=0,Z=0;return J+=(Z+=$*R)>>>16,V+=(J+=z*R)>>>16,J&=65535,V+=(J+=$*D)>>>16,Y+=(V+=N*R)>>>16,V&=65535,Y+=(V+=z*D)>>>16,V&=65535,Y+=(V+=$*G)>>>16,Y+=M*R+N*D+z*G+$*C,f((J&=65535)<<16|(Z&=65535),(Y&=65535)<<16|(V&=65535),this.unsigned)},P.mul=P.multiply,P.divide=function(x){if(s(x)||(x=n(x)),x.isZero())throw Error("division by zero");var M,N,z;if(t)return this.unsigned||this.high!==-2147483648||x.low!==-1||x.high!==-1?f((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?_:g;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return _;if(x.gt(this.shru(1)))return y;z=_}else{if(this.eq(A))return x.eq(b)||x.eq(w)?A:x.eq(A)?b:(M=this.shr(1).div(x).shl(1)).eq(g)?x.isNegative()?b:w:(N=this.sub(x.mul(M)),z=M.add(N.div(x)));if(x.eq(A))return this.unsigned?_: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();z=g}for(N=this;N.gte(x);){M=Math.max(1,Math.floor(N.toNumber()/x.toNumber()));for(var $=Math.ceil(Math.log(M)/Math.LN2),C=$<=48?1:c(2,$-48),G=h(M),D=G.mul(x);D.isNegative()||D.gt(N);)D=(G=h(M-=C,this.unsigned)).mul(x);G.isZero()&&(G=b),z=z.add(G),N=N.sub(D)}return z},P.div=P.divide,P.modulo=function(x){return s(x)||(x=n(x)),t?f((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))},P.mod=P.modulo,P.rem=P.modulo,P.not=function(){return f(~this.low,~this.high,this.unsigned)},P.and=function(x){return s(x)||(x=n(x)),f(this.low&x.low,this.high&x.high,this.unsigned)},P.or=function(x){return s(x)||(x=n(x)),f(this.low|x.low,this.high|x.high,this.unsigned)},P.xor=function(x){return s(x)||(x=n(x)),f(this.low^x.low,this.high^x.high,this.unsigned)},P.shiftLeft=function(x){return s(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?f(this.low<>>32-x,this.unsigned):f(0,this.low<>>x|this.high<<32-x,this.high>>x,this.unsigned):f(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},P.shr=P.shiftRight,P.shiftRightUnsigned=function(x){if(s(x)&&(x=x.toInt()),(x&=63)==0)return this;var M=this.high;return x<32?f(this.low>>>x|M<<32-x,M>>>x,this.unsigned):f(x===32?M:M>>>x-32,0,this.unsigned)},P.shru=P.shiftRightUnsigned,P.shr_u=P.shiftRightUnsigned,P.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},P.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},P.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},P.toBytesLE=function(){var x=this.high,M=this.low;return[255&M,M>>>8&255,M>>>16&255,M>>>24,255&x,x>>>8&255,x>>>16&255,x>>>24]},P.toBytesBE=function(){var x=this.high,M=this.low;return[x>>>24,x>>>16&255,x>>>8&255,255&x,M>>>24,M>>>16&255,M>>>8&255,255&M]},i.fromBytes=function(x,M,N){return N?i.fromBytesLE(x,M):i.fromBytesBE(x,M)},i.fromBytesLE=function(x,M){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,M)},i.fromBytesBE=function(x,M){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],M)}},1446:(m,t,i)=>{var s,u,d,a=i(2100),h=a.Reader,f=a.Writer,c=a.util,l=a.roots.default||(a.roots.default={});l.onnx=((d={}).Version=(s={},(u=Object.create(s))[s[0]="_START_VERSION"]=0,u[s[1]="IR_VERSION_2017_10_10"]=1,u[s[2]="IR_VERSION_2017_10_30"]=2,u[s[3]="IR_VERSION_2017_11_3"]=3,u[s[4]="IR_VERSION_2019_1_22"]=4,u[s[5]="IR_VERSION"]=5,u),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:p.name=e.string();break;case 21:p.refAttrName=e.string();break;case 13:p.docString=e.string();break;case 20:p.type=e.int32();break;case 2:p.f=e.float();break;case 3:p.i=e.int64();break;case 4:p.s=e.bytes();break;case 5:p.t=l.onnx.TensorProto.decode(e,e.uint32());break;case 6:p.g=l.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(p.floats&&p.floats.length||(p.floats=[]),(7&g)==2)for(var _=e.uint32()+e.pos;e.pos<_;)p.floats.push(e.float());else p.floats.push(e.float());break;case 8:if(p.ints&&p.ints.length||(p.ints=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.ints.push(e.int64());else p.ints.push(e.int64());break;case 9:p.strings&&p.strings.length||(p.strings=[]),p.strings.push(e.bytes());break;case 10:p.tensors&&p.tensors.length||(p.tensors=[]),p.tensors.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 11:p.graphs&&p.graphs.length||(p.graphs=[]),p.graphs.push(l.onnx.GraphProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},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.refAttrName!=null&&e.hasOwnProperty("refAttrName")&&!c.isString(e.refAttrName))return"refAttrName: string expected";if(e.docString!=null&&e.hasOwnProperty("docString")&&!c.isString(e.docString))return"docString: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:}if(e.f!=null&&e.hasOwnProperty("f")&&typeof e.f!="number")return"f: number expected";if(e.i!=null&&e.hasOwnProperty("i")&&!(c.isInteger(e.i)||e.i&&c.isInteger(e.i.low)&&c.isInteger(e.i.high)))return"i: integer|Long expected";if(e.s!=null&&e.hasOwnProperty("s")&&!(e.s&&typeof e.s.length=="number"||c.isString(e.s)))return"s: buffer expected";if(e.t!=null&&e.hasOwnProperty("t")&&(o=l.onnx.TensorProto.verify(e.t)))return"t."+o;if(e.g!=null&&e.hasOwnProperty("g")&&(o=l.onnx.GraphProto.verify(e.g)))return"g."+o;if(e.floats!=null&&e.hasOwnProperty("floats")){if(!Array.isArray(e.floats))return"floats: array expected";for(var r=0;r>>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:p.name=e.string();break;case 2:p.type=l.onnx.TypeProto.decode(e,e.uint32());break;case 3:p.docString=e.string();break;default:e.skipType(7&g)}}return p},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,a.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:p.input&&p.input.length||(p.input=[]),p.input.push(e.string());break;case 2:p.output&&p.output.length||(p.output=[]),p.output.push(e.string());break;case 3:p.name=e.string();break;case 4:p.opType=e.string();break;case 7:p.domain=e.string();break;case 5:p.attribute&&p.attribute.length||(p.attribute=[]),p.attribute.push(l.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:p.docString=e.string();break;default:e.skipType(7&g)}}return p},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:p.irVersion=e.int64();break;case 8:p.opsetImport&&p.opsetImport.length||(p.opsetImport=[]),p.opsetImport.push(l.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:p.producerName=e.string();break;case 3:p.producerVersion=e.string();break;case 4:p.domain=e.string();break;case 5:p.modelVersion=e.int64();break;case 6:p.docString=e.string();break;case 7:p.graph=l.onnx.GraphProto.decode(e,e.uint32());break;case 14:p.metadataProps&&p.metadataProps.length||(p.metadataProps=[]),p.metadataProps.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},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:p.key=e.string();break;case 2:p.value=e.string();break;default:e.skipType(7&g)}}return p},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,a.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:p.tensorName=e.string();break;case 2:p.quantParameterTensorNames&&p.quantParameterTensorNames.length||(p.quantParameterTensorNames=[]),p.quantParameterTensorNames.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},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:p.node&&p.node.length||(p.node=[]),p.node.push(l.onnx.NodeProto.decode(e,e.uint32()));break;case 2:p.name=e.string();break;case 5:p.initializer&&p.initializer.length||(p.initializer=[]),p.initializer.push(l.onnx.TensorProto.decode(e,e.uint32()));break;case 10:p.docString=e.string();break;case 11:p.input&&p.input.length||(p.input=[]),p.input.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:p.output&&p.output.length||(p.output=[]),p.output.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:p.valueInfo&&p.valueInfo.length||(p.valueInfo=[]),p.valueInfo.push(l.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:p.quantizationAnnotation&&p.quantizationAnnotation.length||(p.quantizationAnnotation=[]),p.quantizationAnnotation.push(l.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&g)}}return p},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(p.dims&&p.dims.length||(p.dims=[]),(7&g)==2)for(var _=e.uint32()+e.pos;e.pos<_;)p.dims.push(e.int64());else p.dims.push(e.int64());break;case 2:p.dataType=e.int32();break;case 3:p.segment=l.onnx.TensorProto.Segment.decode(e,e.uint32());break;case 4:if(p.floatData&&p.floatData.length||(p.floatData=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.floatData.push(e.float());else p.floatData.push(e.float());break;case 5:if(p.int32Data&&p.int32Data.length||(p.int32Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.int32Data.push(e.int32());else p.int32Data.push(e.int32());break;case 6:p.stringData&&p.stringData.length||(p.stringData=[]),p.stringData.push(e.bytes());break;case 7:if(p.int64Data&&p.int64Data.length||(p.int64Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.int64Data.push(e.int64());else p.int64Data.push(e.int64());break;case 8:p.name=e.string();break;case 12:p.docString=e.string();break;case 9:p.rawData=e.bytes();break;case 13:p.externalData&&p.externalData.length||(p.externalData=[]),p.externalData.push(l.onnx.StringStringEntryProto.decode(e,e.uint32()));break;case 14:p.dataLocation=e.int32();break;case 10:if(p.doubleData&&p.doubleData.length||(p.doubleData=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.doubleData.push(e.double());else p.doubleData.push(e.double());break;case 11:if(p.uint64Data&&p.uint64Data.length||(p.uint64Data=[]),(7&g)==2)for(_=e.uint32()+e.pos;e.pos<_;)p.uint64Data.push(e.uint64());else p.uint64Data.push(e.uint64());break;default:e.skipType(7&g)}}return p},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.dims!=null&&e.hasOwnProperty("dims")){if(!Array.isArray(e.dims))return"dims: array expected";for(var r=0;r>>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 p=0;p>>0,e.dims[p].high>>>0).toNumber():e.dims[p]}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=[],p=0;p>>0,e.int64Data[p].high>>>0).toNumber():e.int64Data[p];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=[],p=0;p>>0,e.uint64Data[p].high>>>0).toNumber(!0):e.uint64Data[p];if(e.docString!=null&&e.hasOwnProperty("docString")&&(o.docString=e.docString),e.externalData&&e.externalData.length)for(o.externalData=[],p=0;p>>3){case 1:g.begin=r.int64();break;case 2:g.end=r.int64();break;default:r.skipType(7&_)}}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 p={};if(o.defaults){if(c.Long){var g=new c.Long(0,0,!1);p.begin=o.longs===String?g.toString():o.longs===Number?g.toNumber():g}else p.begin=o.longs===String?"0":0;c.Long?(g=new c.Long(0,0,!1),p.end=o.longs===String?g.toString():o.longs===Number?g.toNumber():g):p.end=o.longs===String?"0":0}return r.begin!=null&&r.hasOwnProperty("begin")&&(typeof r.begin=="number"?p.begin=o.longs===String?String(r.begin):r.begin:p.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"?p.end=o.longs===String?String(r.end):r.end:p.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),p},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.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?(p.dim&&p.dim.length||(p.dim=[]),p.dim.push(l.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&g)}return p},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:_.dimValue=o.int64();break;case 2:_.dimParam=o.string();break;case 3:_.denotation=o.string();break;default:o.skipType(7&b)}}return _},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 p={};if(o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(p.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(p.value===1)return"value: multiple values";if(p.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 p=new l.onnx.TensorShapeProto.Dimension;return o.dimValue!=null&&(c.Long?(p.dimValue=c.Long.fromValue(o.dimValue)).unsigned=!1:typeof o.dimValue=="string"?p.dimValue=parseInt(o.dimValue,10):typeof o.dimValue=="number"?p.dimValue=o.dimValue:typeof o.dimValue=="object"&&(p.dimValue=new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber())),o.dimParam!=null&&(p.dimParam=String(o.dimParam)),o.denotation!=null&&(p.denotation=String(o.denotation)),p},e.toObject=function(o,p){p||(p={});var g={};return p.defaults&&(g.denotation=""),o.dimValue!=null&&o.hasOwnProperty("dimValue")&&(typeof o.dimValue=="number"?g.dimValue=p.longs===String?String(o.dimValue):o.dimValue:g.dimValue=p.longs===String?c.Long.prototype.toString.call(o.dimValue):p.longs===Number?new c.LongBits(o.dimValue.low>>>0,o.dimValue.high>>>0).toNumber():o.dimValue,p.oneofs&&(g.value="dimValue")),o.dimParam!=null&&o.hasOwnProperty("dimParam")&&(g.dimParam=o.dimParam,p.oneofs&&(g.value="dimParam")),o.denotation!=null&&o.hasOwnProperty("denotation")&&(g.denotation=o.denotation),g},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),n}(),d.TypeProto=function(){function n(r){if(r)for(var o=Object.keys(r),p=0;p>>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&_)}}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 p={};return o.defaults&&(p.denotation=""),r.tensorType!=null&&r.hasOwnProperty("tensorType")&&(p.tensorType=l.onnx.TypeProto.Tensor.toObject(r.tensorType,o),o.oneofs&&(p.value="tensorType")),r.denotation!=null&&r.hasOwnProperty("denotation")&&(p.denotation=r.denotation),p},n.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},n.Tensor=function(){function r(o){if(o)for(var p=Object.keys(o),g=0;g>>3){case 1:_.elemType=o.int32();break;case 2:_.shape=l.onnx.TensorShapeProto.decode(o,o.uint32());break;default:o.skipType(7&b)}}return _},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 p=l.onnx.TensorShapeProto.verify(o.shape);if(p)return"shape."+p}return null},r.fromObject=function(o){if(o instanceof l.onnx.TypeProto.Tensor)return o;var p=new l.onnx.TypeProto.Tensor;if(o.elemType!=null&&(p.elemType=0|o.elemType),o.shape!=null){if(typeof o.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");p.shape=l.onnx.TensorShapeProto.fromObject(o.shape)}return p},r.toObject=function(o,p){p||(p={});var g={};return p.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,p)),g},r.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},r}(),n}(),d.OperatorSetIdProto=function(){function n(e){if(e)for(var r=Object.keys(e),o=0;o>>3){case 1:p.domain=e.string();break;case 2:p.version=e.int64();break;default:e.skipType(7&g)}}return p},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 p=new c.Long(0,0,!1);o.version=r.longs===String?p.toString():r.longs===Number?p.toNumber():p}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,a.util.toJSONOptions)},n}(),d),m.exports=l},2100:(m,t,i)=>{m.exports=i(9482)},9482:(m,t,i)=>{var s=t;function u(){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=u,u()},1408:(m,t,i)=>{m.exports=f;var s,u=i(9693),d=u.LongBits,a=u.utf8;function h(p,g){return RangeError("index out of range: "+p.pos+" + "+(g||1)+" > "+p.len)}function f(p){this.buf=p,this.pos=0,this.len=p.length}var c,l=typeof Uint8Array<"u"?function(p){if(p instanceof Uint8Array||Array.isArray(p))return new f(p);throw Error("illegal buffer")}:function(p){if(Array.isArray(p))return new f(p);throw Error("illegal buffer")},n=function(){return u.Buffer?function(p){return(f.create=function(g){return u.Buffer.isBuffer(g)?new s(g):l(g)})(p)}:l};function e(){var p=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(p.lo=(p.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return p}return p.lo=(p.lo|(127&this.buf[this.pos++])<<7*g)>>>0,p}for(;g<4;++g)if(p.lo=(p.lo|(127&this.buf[this.pos])<<7*g)>>>0,this.buf[this.pos++]<128)return p;if(p.lo=(p.lo|(127&this.buf[this.pos])<<28)>>>0,p.hi=(p.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return p;if(g=0,this.len-this.pos>4){for(;g<5;++g)if(p.hi=(p.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return p}else for(;g<5;++g){if(this.pos>=this.len)throw h(this);if(p.hi=(p.hi|(127&this.buf[this.pos])<<7*g+3)>>>0,this.buf[this.pos++]<128)return p}throw Error("invalid varint encoding")}function r(p,g){return(p[g-4]|p[g-3]<<8|p[g-2]<<16|p[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))}f.create=n(),f.prototype._slice=u.Array.prototype.subarray||u.Array.prototype.slice,f.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}),f.prototype.int32=function(){return 0|this.uint32()},f.prototype.sint32=function(){var p=this.uint32();return p>>>1^-(1&p)|0},f.prototype.bool=function(){return this.uint32()!==0},f.prototype.fixed32=function(){if(this.pos+4>this.len)throw h(this,4);return r(this.buf,this.pos+=4)},f.prototype.sfixed32=function(){if(this.pos+4>this.len)throw h(this,4);return 0|r(this.buf,this.pos+=4)},f.prototype.float=function(){if(this.pos+4>this.len)throw h(this,4);var p=u.float.readFloatLE(this.buf,this.pos);return this.pos+=4,p},f.prototype.double=function(){if(this.pos+8>this.len)throw h(this,4);var p=u.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,p},f.prototype.bytes=function(){var p=this.uint32(),g=this.pos,_=this.pos+p;if(_>this.len)throw h(this,p);return this.pos+=p,Array.isArray(this.buf)?this.buf.slice(g,_):g===_?new this.buf.constructor(0):this._slice.call(this.buf,g,_)},f.prototype.string=function(){var p=this.bytes();return a.read(p,0,p.length)},f.prototype.skip=function(p){if(typeof p=="number"){if(this.pos+p>this.len)throw h(this,p);this.pos+=p}else do if(this.pos>=this.len)throw h(this);while(128&this.buf[this.pos++]);return this},f.prototype.skipType=function(p){switch(p){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(p=7&this.uint32())!=4;)this.skipType(p);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+p+" at offset "+this.pos)}return this},f._configure=function(p){s=p,f.create=n(),s._configure();var g=u.Long?"toLong":"toNumber";u.merge(f.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 u=i(9693);function d(a){s.call(this,a)}d._configure=function(){u.Buffer&&(d.prototype._slice=u.Buffer.prototype.slice)},d.prototype.string=function(){var a=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+a,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+a,this.len))},d._configure()},5054:m=>{m.exports={}},5994:(m,t,i)=>{t.Service=i(7948)},7948:(m,t,i)=>{m.exports=u;var s=i(9693);function u(d,a,h){if(typeof d!="function")throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=d,this.requestDelimited=!!a,this.responseDelimited=!!h}(u.prototype=Object.create(s.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function d(a,h,f,c,l){if(!c)throw TypeError("request must be specified");var n=this;if(!l)return s.asPromise(d,n,a,h,f,c);if(n.rpcImpl)try{return n.rpcImpl(a,h[n.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(e,r){if(e)return n.emit("error",e,a),l(e);if(r!==null){if(!(r instanceof f))try{r=f[n.responseDelimited?"decodeDelimited":"decode"](r)}catch(o){return n.emit("error",o,a),l(o)}return n.emit("data",r,a),l(null,r)}n.end(!0)})}catch(e){return n.emit("error",e,a),void setTimeout(function(){l(e)},0)}else setTimeout(function(){l(Error("already ended"))},0)},u.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=u;var s=i(9693);function u(f,c){this.lo=f>>>0,this.hi=c>>>0}var d=u.zero=new u(0,0);d.toNumber=function(){return 0},d.zzEncode=d.zzDecode=function(){return this},d.length=function(){return 1};var a=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(f){if(f===0)return d;var c=f<0;c&&(f=-f);var l=f>>>0,n=(f-l)/4294967296>>>0;return c&&(n=~n>>>0,l=~l>>>0,++l>4294967295&&(l=0,++n>4294967295&&(n=0))),new u(l,n)},u.from=function(f){if(typeof f=="number")return u.fromNumber(f);if(s.isString(f)){if(!s.Long)return u.fromNumber(parseInt(f,10));f=s.Long.fromString(f)}return f.low||f.high?new u(f.low>>>0,f.high>>>0):d},u.prototype.toNumber=function(f){if(!f&&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},u.prototype.toLong=function(f){return s.Long?new s.Long(0|this.lo,0|this.hi,!!f):{low:0|this.lo,high:0|this.hi,unsigned:!!f}};var h=String.prototype.charCodeAt;u.fromHash=function(f){return f===a?d:new u((h.call(f,0)|h.call(f,1)<<8|h.call(f,2)<<16|h.call(f,3)<<24)>>>0,(h.call(f,4)|h.call(f,5)<<8|h.call(f,6)<<16|h.call(f,7)<<24)>>>0)},u.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)},u.prototype.zzEncode=function(){var f=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^f)>>>0,this.lo=(this.lo<<1^f)>>>0,this},u.prototype.zzDecode=function(){var f=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^f)>>>0,this.hi=(this.hi>>>1^f)>>>0,this},u.prototype.length=function(){var f=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,l=this.hi>>>24;return l===0?c===0?f<16384?f<128?1:2:f<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 u(a,h,f){for(var c=Object.keys(h),l=0;l0)},s.Buffer=function(){try{var a=s.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(a){return typeof a=="number"?s.Buffer?s._Buffer_allocUnsafe(a):new s.Array(a):s.Buffer?s._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},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(a){return a?s.LongBits.from(a).toHash():s.LongBits.zeroHash},s.longFromHash=function(a,h){var f=s.LongBits.fromHash(a);return s.Long?s.Long.fromBits(f.lo,f.hi,h):f.toNumber(!!h)},s.merge=u,s.lcFirst=function(a){return a.charAt(0).toLowerCase()+a.substring(1)},s.newError=d,s.ProtocolError=d("ProtocolError"),s.oneOfGetter=function(a){for(var h={},f=0;f-1;--l)if(h[c[l]]===1&&this[c[l]]!==void 0&&this[c[l]]!==null)return c[l]}},s.oneOfSetter=function(a){return function(h){for(var f=0;f{m.exports=n;var s,u=i(9693),d=u.LongBits,a=u.base64,h=u.utf8;function f(b,y,w){this.fn=b,this.len=y,this.next=void 0,this.val=w}function c(){}function l(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function n(){this.len=0,this.head=new f(c,0,0),this.tail=this.head,this.states=null}var e=function(){return u.Buffer?function(){return(n.create=function(){return new s})()}:function(){return new n}};function r(b,y,w){y[w]=255&b}function o(b,y){this.len=b,this.next=void 0,this.val=y}function p(b,y,w){for(;b.hi;)y[w++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)y[w++]=127&b.lo|128,b.lo=b.lo>>>7;y[w++]=b.lo}function g(b,y,w){y[w]=255&b,y[w+1]=b>>>8&255,y[w+2]=b>>>16&255,y[w+3]=b>>>24}n.create=e(),n.alloc=function(b){return new u.Array(b)},u.Array!==Array&&(n.alloc=u.pool(n.alloc,u.Array.prototype.subarray)),n.prototype._push=function(b,y,w){return this.tail=this.tail.next=new f(b,y,w),this.len+=y,this},o.prototype=Object.create(f.prototype),o.prototype.fn=function(b,y,w){for(;b>127;)y[w++]=127&b|128,b>>>=7;y[w]=b},n.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new o((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},n.prototype.int32=function(b){return b<0?this._push(p,10,d.fromNumber(b)):this.uint32(b)},n.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},n.prototype.uint64=function(b){var y=d.from(b);return this._push(p,y.length(),y)},n.prototype.int64=n.prototype.uint64,n.prototype.sint64=function(b){var y=d.from(b).zzEncode();return this._push(p,y.length(),y)},n.prototype.bool=function(b){return this._push(r,1,b?1:0)},n.prototype.fixed32=function(b){return this._push(g,4,b>>>0)},n.prototype.sfixed32=n.prototype.fixed32,n.prototype.fixed64=function(b){var y=d.from(b);return this._push(g,4,y.lo)._push(g,4,y.hi)},n.prototype.sfixed64=n.prototype.fixed64,n.prototype.float=function(b){return this._push(u.float.writeFloatLE,4,b)},n.prototype.double=function(b){return this._push(u.float.writeDoubleLE,8,b)};var _=u.Array.prototype.set?function(b,y,w){y.set(b,w)}:function(b,y,w){for(var T=0;T>>0;if(!y)return this._push(r,1,0);if(u.isString(b)){var w=n.alloc(y=a.length(b));a.decode(b,w,0),b=w}return this.uint32(y)._push(_,y,b)},n.prototype.string=function(b){var y=h.length(b);return y?this.uint32(y)._push(h.write,y,b):this._push(r,1,0)},n.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new f(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 f(c,0,0),this.len=0),this},n.prototype.ldelim=function(){var b=this.head,y=this.tail,w=this.len;return this.reset().uint32(w),w&&(this.tail.next=b.next,this.tail=y,this.len+=w),this},n.prototype.finish=function(){for(var b=this.head.next,y=this.constructor.alloc(this.len),w=0;b;)b.fn(b.val,y,w),w+=b.len,b=b.next;return y},n._configure=function(b){s=b,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 u=i(9693);function d(){s.call(this)}function a(h,f,c){h.length<40?u.utf8.write(h,f,c):f.utf8Write?f.utf8Write(h,c):f.write(h,c)}d._configure=function(){d.alloc=u._Buffer_allocUnsafe,d.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&u.Buffer.prototype.set.name==="set"?function(h,f,c){f.set(h,c)}:function(h,f,c){if(h.copy)h.copy(f,c,0,h.length);else for(var l=0;l>>0;return this.uint32(f),f&&this._push(d.writeBytesBuffer,f,h),this},d.prototype.string=function(h){var f=u.Buffer.byteLength(h);return this.uint32(f),f&&this._push(a,f,h),this},d._configure()},7714:(m,t,i)=>{t.R=void 0;const s=i(6919),u=i(7448);t.R=new class{async init(){}async createSessionHandler(d,a){const h=new s.Session(a);return await h.loadModel(d),new u.OnnxjsSessionHandler(h)}}},4200:(m,t,i)=>{t.c8=t.rX=void 0;const s=i(1670),u=i(5381),d=i(2157),a=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,u.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,f){const c=new a.OnnxruntimeWebAssemblySessionHandler;return await c.loadModel(h,f),Promise.resolve(c)}}},6018:function(m,t,i){var s=this&&this.__createBinding||(Object.create?function(a,h,f,c){c===void 0&&(c=f);var l=Object.getOwnPropertyDescriptor(h,f);l&&!("get"in l?!h.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return h[f]}}),Object.defineProperty(a,c,l)}:function(a,h,f,c){c===void 0&&(c=f),a[c]=h[f]}),u=this&&this.__exportStar||function(a,h){for(var f in a)f==="default"||Object.prototype.hasOwnProperty.call(h,f)||s(h,a,f)};Object.defineProperty(t,"__esModule",{value:!0}),u(i(1670),t);const d=i(1670);{const a=i(7714).R;(0,d.registerBackend)("webgl",a,-10)}{const a=i(4200).c8;(0,d.registerBackend)("cpu",a,10),(0,d.registerBackend)("wasm",a,10),(0,d.registerBackend)("xnnpack",a,9)}},246:(m,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createAttributeWithCacheKey=void 0;class i{constructor(u){Object.assign(this,u)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(u=>`${this[u]}`).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),u=i(9395),d=i(9162),a=i(2517);var h=u.onnxruntime.experimental.fbs;class f{constructor(l){if(this._attributes=new Map,l!=null){for(const n of l)n instanceof s.onnx.AttributeProto?this._attributes.set(n.name,[f.getValue(n),f.getType(n)]):n instanceof h.Attribute&&this._attributes.set(n.name(),[f.getValue(n),f.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,a.decodeUtf8String)(r)}return n===s.onnx.AttributeProto.AttributeType.STRINGS&&l instanceof s.onnx.AttributeProto?e.map(a.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),u=new Map;async function d(a){const h=t.backend;if(h[a]!==void 0&&function(f){const c=f;return"initialize"in c&&typeof c.initialize=="function"&&"createSessionHandler"in c&&typeof c.createSessionHandler=="function"&&"dispose"in c&&typeof c.dispose=="function"}(h[a])){const f=h[a];let c=f.initialize();if(typeof c=="object"&&"then"in c&&(c=await c),c)return u.set(a,f),f}}t.backend={webgl:new s.WebGLBackend},t.resolveBackend=async function a(h){if(!h)return a(["webgl"]);{const f=typeof h=="string"?[h]:h;for(const c of f){const l=u.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),u=i(6231),d=i(6416),a=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,a.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),u.Logger.setWithEnv(s.env),u.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 u.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),u=i(8520),d=i(5060),a=i(7859),h=i(9390);class f extends u.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 u.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 u.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 p=` void setOutput(vec4 val) { ${(0,d.getGlsl)(this.context.glContext.version).output} = val; } `;return r.floatTextureSetRGBA=new u.GlslLibRoutine(p),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 p=` void setOutput(float val) { ${(0,d.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0); } `;return r.floatTextureSetR=new u.GlslLibRoutine(p),r}getOutputScalarCoords(){return new u.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 u.GlslLibRoutine(r)):e[1]===1?(r=` int getOutputCoords() { return 2 * int(TexCoords.x * ${e[0]}.0); } `,new u.GlslLibRoutine(r)):(r=` int getOutputCoords() { ivec2 resTexRC = ivec2(TexCoords.xy * vec2(${e[0]}, ${e[1]})); return 2 * (resTexRC.y * ${e[0]} + resTexRC.x); } `,new u.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 u.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 u.GlslLibRoutine(e)}getOutputPacked3DCoords(l,n){const e=[n[0],n[1]],r=Math.ceil(l[2]/2),o=r*Math.ceil(l[1]/2),p=` 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 u.GlslLibRoutine(p)}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 p=o,g="",_="b, r, c";for(let y=2;y=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[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 u.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 _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[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 u.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 _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2","d3"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[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 u.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 _=r-3;_>=0;--_)o[_]=o[_+1]*l[_+1];const p=["r","c","d","d2","d3","d4"],g=o.map((_,b)=>`int ${p[b]} = index / ${_}; ${b===o.length-1?`int ${p[b+1]} = index - ${p[b]} * ${_}`:`index -= ${p[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 u.GlslLibRoutine(e)}getCommonUtilFuncs(){const l={};let n="uvFromFlat";l[n]=new u.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 u.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 u.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 u.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 u.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],p=(0,h.generateShaderFuncNameFromInputSamplerName)(e);o.isPacked?l[p]=this.getPackedSamplerFromInput(p,e,o):l[p]=this.getUnpackedSamplerFromInput(p,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,p=e.unpackedShape,g=r,_=(0,h.generateShaderFuncNameFromInputSamplerName)(g),b=o.length,y=p.length,w=s.BroadcastUtil.getBroadcastDims(o,p),T=(0,h.getCoordsDataType)(y),S=y-b;let A;const P=(0,h.getGlChannels)();A=b===0?"":y<2&&w.length>=1?"coords = 0;":w.map(C=>`coords.${P[C+S]} = 0;`).join(` `);let x="";x=y<2&&b>0?"coords":o.map((C,G)=>`coords.${P[G+S]}`).join(", ");let M="return outputValue;";const N=s.ShapeUtil.size(o)===1,z=s.ShapeUtil.size(p)===1;if(b!==1||N||z){if(N&&!z)M=y===1?` return vec4(outputValue.x, outputValue.x, 0., 0.); `:` return vec4(outputValue.x); `;else if(w.length){const C=b-2,G=b-1;w.indexOf(C)>-1&&w.indexOf(G)>-1?M="return vec4(outputValue.x);":w.indexOf(C)>-1?M="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":w.indexOf(G)>-1&&(M="return vec4(outputValue.xx, outputValue.zz);")}}else M=` return vec4(outputValue.xy, outputValue.xy); `;const $=` vec4 ${l}() { ${T} coords = getOutputCoords(); int lastDim = coords.${P[y-1]}; coords.${P[y-1]} = coords.${P[y-2]}; coords.${P[y-2]} = lastDim; ${A} vec4 outputValue = ${_}(${x}); ${M} } `;return new u.GlslLibRoutine($,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(l,n,e,r){const o=[e.width,e.height],p=[n.width,n.height],g=n.unpackedShape.length,_=e.unpackedShape.length,b=n.unpackedShape,y=e.unpackedShape,w=(0,h.generateShaderFuncNameFromInputSamplerName)(r);if(g===_&&s.ArrayUtil.arraysEqual(p,o)){const z=` float ${l}() { return sampleTexture(${r}, TexCoords); } `;return new u.GlslLibRoutine(z,["coordinates.sampleTexture"])}const T=(0,h.getCoordsDataType)(_),S=s.BroadcastUtil.getBroadcastDims(b,y),A=_-g;let P;const x=(0,h.getGlChannels)();P=g===0?"":_<2&&S.length>=1?"coords = 0;":S.map(z=>`coords.${x[z+A]} = 0;`).join(` `);let M="";M=_<2&&g>0?"coords":n.unpackedShape.map((z,$)=>`coords.${x[$+A]}`).join(", ");const N=` float ${l}() { ${T} coords = getOutputCoords(); ${P} return ${w}(${M}); } `;return new u.GlslLibRoutine(N,["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 u.GlslLibRoutine(e)}getPackedSampler1D(l,n,e){const r=[e.width,e.height],o=[r[1],r[0]],p=(0,d.getGlsl)(this.context.glContext.version),g=`vec4 ${l}(int index) { vec2 uv = packedUVfrom1D( ${o[0]}, ${o[1]}, index); return ${p.texture2D}(${n}, uv); }`;return new u.GlslLibRoutine(g,["coordinates.packedUVfrom1D"])}getPackedSampler2D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],p=(0,d.getGlsl)(this.context.glContext.version),g=o[0],_=o[1];if(o!=null&&s.ArrayUtil.arraysEqual(r,o)){const T=`vec4 ${l}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${_}.0, ${g}.0); return ${p.texture2D}(${n}, uv); }`;return new u.GlslLibRoutine(T)}const b=o,y=Math.ceil(r[1]/2),w=`vec4 ${l}(int row, int col) { vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${y}, row, col); return ${p.texture2D}(${n}, uv); }`;return new u.GlslLibRoutine(w,["coordinates.packedUVfrom2D"])}getPackedSampler3D(l,n,e){const r=e.unpackedShape,o=[e.width,e.height],p=[o[0],o[1]],g=(0,d.getGlsl)(this.context.glContext.version);if(r[0]===1){const T=r.slice(1),S=[1,2],A=(0,h.squeezeInputShape)(r,T),P=["b","row","col"],x=JSON.parse(JSON.stringify(e));x.unpackedShape=A;const M=this.getPackedSamplerFromInput(l,n,x),N=`${M.routineBody} vec4 ${l}(int b, int row, int col) { return ${l}(${(0,h.getSqueezedParams)(P,S)}); } `;return new u.GlslLibRoutine(N,M.dependencies)}const _=p[0],b=p[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 u.GlslLibRoutine(w,["coordinates.packedUVfrom3D"])}getPackedSamplerND(l,n,e){const r=e.unpackedShape,o=r.length,p=[e.width,e.height],g=(0,d.getGlsl)(this.context.glContext.version),_=[p[0],p[1]],b=_[1],y=_[0],w=Math.ceil(r[o-1]/2);let T=w*Math.ceil(r[o-2]/2),S="int b, int row, int col",A=`b * ${T} + (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 p=`_${n}`;l[p]=new u.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!1),[`shapeUtils.indicesToOffset${p}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),p+="_T",l[p]=new u.GlslLibRoutine(this.getValueFromSingle(n,o,r.width,r.height,!0),[`shapeUtils.indicesToOffset${p}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),l}getValueFromSingle(l,n,e,r,o){let p=`_${l}`;return o&&(p+="_T"),` float ${p}(int m[${n}]) { int offset = indicesToOffset${p}(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 p=`_${l}_Pack`;return o&&(p+="_T"),` vec4 ${p}(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=f},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,u,d,a){this.glContext=s,this.programInfo=u,this.inputTextureLayouts=d,this.outputTextureLayout=a}},t.GlslLib=class{constructor(s){this.context=s}},t.GlslLibRoutine=class{constructor(s,u){this.routineBody=s,this.dependencies=u}},t.GlslLibRoutineNode=class{constructor(s,u,d){this.name=s,this.dependencies=d||[],u&&(this.routineBody=u)}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 u=new Set,d=new Set,a=new Array;return this.createOrderedNodes(s,u,d,a),a}static createOrderedNodes(s,u,d,a){for(let h=0;h0)for(let f=0;f{Object.defineProperty(t,"__esModule",{value:!0}),t.EncodingGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}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 a=u.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))); ${a} rgba = rgba / 255.0; // values need to be normalized to [0,1] return rgba; } `)}}decodeUint8(){const a=u.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] ${a} 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 a=new ArrayBuffer(4),h=new Uint32Array(a),f=new Uint8Array(a);if(h[0]=3735928559,f[0]===239)return!0;if(f[0]===222)return!1;throw new Error("unknown endianness")}}t.EncodingGlslLib=u},9894:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragColorGlslLib=void 0;const s=i(8520),u=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,u.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 u={};let d;for(;(d=i.exec(s))!==null;){const a=d[3].split(",").map(h=>{const f=h.trim().split(" ");return f&&f.length===2?{type:f[0],name:f[1]}:null}).filter(h=>h!==null);u[d[2]]={params:a,body:d[4]}}for(const a in u){const h="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",a),f=new RegExp(h,"gm");for(;(d=f.exec(s))!==null;){const c=d[1],l=d[2],n=d[3].split(","),e=c?`${c} ${l};`:"";let r=u[a].body,o="";u[a].params.forEach((g,_)=>{g&&(o+=`${g.type} ${g.name} = ${n[_]}; `)}),r=`${o} ${r}`,r=r.replace("return",`${l} = `);const p=` ${e} { ${r} } `;s=s.replace(d[0],p)}}return s.replace(i,"")}},8879:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlslPreprocessor=void 0;const s=i(8520),u=i(2848),d=i(5483),a=i(5060);t.GlslPreprocessor=class{constructor(h,f,c,l){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new s.GlslContext(h,f,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 p=e+"."+o;let g;n[p]?(g=n[p],g.routineBody=r[o].routineBody):(g=new s.GlslLibRoutineNode(p,r[o].routineBody),n[p]=g);const _=r[o].dependencies;if(_)for(let b=0;b<_.length;++b)if(n[_[b]])g.addDependency(n[_[b]]);else{const y=new s.GlslLibRoutineNode(_[b]);n[_[b]]=y,g.addDependency(y)}}}}preprocess(){const h=this.context.programInfo;let f=h.shaderSource;return this.context.programInfo.hasMain||(f=`${f} ${(0,a.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),f=(0,u.replaceInlines)(f),`${(0,a.getFragShaderPreamble)(this.context.glContext.version)} ${this.getUniforms(h.inputNames,h.variables)} ${this.getImports(f)} ${f}`}getImports(h){const f=this.selectGlslLibRoutinesToBeIncluded(h);if(f.length===0)return"";let c="";for(let l=0;l{const l=c.split(".")[1];h.indexOf(l)!==-1&&f.push(this.glslLibRoutineDependencyGraph[c])}),s.TopologicalSortGlslRoutines.returnOrderedNodes(f)}getUniforms(h,f){const c=[];if(h)for(const l of h)c.push(`uniform sampler2D ${l};`);if(f)for(const l of f)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),u=i(7341),d=i(9894),a=i(2655),h=i(3891);t.glslRegistry={encoding:u.EncodingGlslLib,fragcolor:d.FragColorGlslLib,vec:h.VecGlslLib,shapeUtils:a.ShapeUtilsGlslLib,coordinates:s.CoordsGlslLib}},2655:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShapeUtilsGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}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 a=this.context.outputTextureLayout.shape.length,h={};return this.context.programInfo.inputNames.forEach((f,c)=>{const l=this.context.inputTextureLayouts[c].unpackedShape;if(l.length<=a){const n=l.length,e=a-n,r=`bcastIndices_${f}`;let o="";for(let g=0;g{const l=this.context.inputTextureLayouts[c].shape;if(!(l.length<2||l.length>a)){const n=l.length,e=a-n,r=`bcastMatmulIndices_${f}`;let o="";for(let g=0;g{const c=this.context.inputTextureLayouts[f].shape,l=this.context.inputTextureLayouts[f].strides,n=c.length;let e=`indicesToOffset_${h}`;a[e]=new s.GlslLibRoutine(u.indexToOffsetSingle(e,n,l)),e=`indicesToOffset_${h}_T`,a[e]=new s.GlslLibRoutine(u.indexToOffsetSingle(e,n,l.slice().reverse()))}),a}static indexToOffsetSingle(a,h,f){let c="";for(let l=h-1;l>=0;--l)c+=` offset += indices[${l}] * ${f[l]}; `;return` int ${a}(int indices[${h}]) { int offset = 0; ${c} return offset; } `}offsetToIndices(){const a={};return this.context.programInfo.inputNames.forEach((h,f)=>{const c=this.context.inputTextureLayouts[f].shape,l=this.context.inputTextureLayouts[f].strides,n=c.length;let e=`offsetToIndices_${h}`;a[e]=new s.GlslLibRoutine(u.offsetToIndicesSingle(e,n,l)),e=`offsetToIndices_${h}_T`,a[e]=new s.GlslLibRoutine(u.offsetToIndicesSingle(e,n,l.slice().reverse()))}),a}static offsetToIndicesSingle(a,h,f){const c=[];for(let l=0;l{const c=this.context.inputTextureLayouts[f].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; } } `;a[n]=new s.GlslLibRoutine(r)}),a}}t.ShapeUtilsGlslLib=u},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 u(d){return d===1?i:s}t.getGlsl=u,t.getVertexShaderSource=function(d){const a=u(d);return`${a.version} precision highp float; ${a.attribute} vec3 position; ${a.attribute} vec2 textureCoord; ${a.varyingVertex} vec2 TexCoords; void main() { gl_Position = vec4(position, 1.0); TexCoords = textureCoord; }`},t.getFragShaderPreamble=function(d){const a=u(d);return`${a.version} precision highp float; precision highp int; precision highp sampler2D; ${a.varyingFrag} vec2 TexCoords; ${a.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,a){return` void main() { int indices[${a}]; toVec(TexCoords, indices); vec4 result = vec4(process(indices)); ${u(d).output} = result; } `}},3891:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VecGlslLib=void 0;const s=i(8520);class u extends s.GlslLib{constructor(a){super(a)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const a=this.context.outputTextureLayout.shape.length,h={add:"+=",sub:"-=",mul:"*=",div:"/="},f={};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),u=i(9162),d=i(2517),a=i(2403),h=i(7019),f=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=T.map(P=>`${P.unpackedShape.join(",")};${P.width}x${P.height}`).join("_");let A=w.name;return w.cacheHint&&(A+="["+w.cacheHint+"]"),A+=":"+S,A})(e,o);let g=this.session.programManager.getArtifact(p);const _=g?g.programInfo:typeof e.get=="function"?e.get():e,b=(0,l.createTextureLayoutFromTextureType)(this.session.layoutStrategy,_.output.dims,_.output.textureType),y=this.createTextureData(b,_.output.type);return g||(g=this.session.programManager.build(_,o,y),this.session.programManager.setArtifact(p,g)),this.runProgram(g,o,y),y}run(e,r){return this.executeProgram(e,r).tensor}runProgram(e,r,o){for(let p=0;pthis.readTexture(_),async b=>this.readTextureAsync(_),void 0,g),texture:o});return this.setTextureData(_.tensor.dataId,_,e.isPacked),_}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,f.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,f.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,a.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(V,J,Z,le){le===void 0&&(le=Z);var Ae=Object.getOwnPropertyDescriptor(J,Z);Ae&&!("get"in Ae?!J.__esModule:Ae.writable||Ae.configurable)||(Ae={enumerable:!0,get:function(){return J[Z]}}),Object.defineProperty(V,le,Ae)}:function(V,J,Z,le){le===void 0&&(le=Z),V[le]=J[Z]}),u=this&&this.__setModuleDefault||(Object.create?function(V,J){Object.defineProperty(V,"default",{enumerable:!0,value:J})}:function(V,J){V.default=J}),d=this&&this.__importStar||function(V){if(V&&V.__esModule)return V;var J={};if(V!=null)for(var Z in V)Z!=="default"&&Object.prototype.hasOwnProperty.call(V,Z)&&s(J,V,Z);return u(J,V),J};Object.defineProperty(t,"__esModule",{value:!0}),t.WEBGL_OP_RESOLVE_RULES=void 0;const a=i(2898),h=d(i(7839)),f=i(4196),c=i(2069),l=i(8138),n=i(9663),e=i(5193),r=i(7992),o=i(1253),p=i(4776),g=i(6572),_=i(3346),b=i(5623),y=i(2870),w=i(2143),T=i(4939),S=i(718),A=i(2268),P=i(8117),x=i(2278),M=i(5524),N=i(5975),z=i(3933),$=i(6558),C=i(5723),G=i(3738),D=d(i(4909)),R=i(8428),Y=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+",a.batchNormalization,a.parseBatchNormalizationAttributes],["Cast","","6+",f.cast,f.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",p.gemm,p.parseGemmAttributesV7],["Gemm","","11+",p.gemm,p.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+",_.instanceNormalization,_.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",D.leakyRelu,D.parseLeakyReluAttributes],["Less","","7+",h.less],["Log","","6+",D.log],["MatMul","","1+",b.matMul,b.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+",T.reduceLogSum,T.parseReduceAttributes],["ReduceMax","","1+",T.reduceMax,T.parseReduceAttributes],["ReduceMean","","1+",T.reduceMean,T.parseReduceAttributes],["ReduceMin","","1+",T.reduceMin,T.parseReduceAttributes],["ReduceProd","","1+",T.reduceProd,T.parseReduceAttributes],["ReduceSum","","1-12",T.reduceSum,T.parseReduceAttributes],["ReduceSumSquare","","1+",T.reduceLogSumSquare,T.parseReduceAttributes],["Relu","","6+",D.relu],["Reshape","","5+",S.reshape],["Resize","","10",A.resize,A.parseResizeAttributesV10],["Resize","","11+",A.resize,A.parseResizeAttributesV11],["Shape","","1+",P.shape],["Sigmoid","","6+",D.sigmoid],["Sin","","7+",D.sin],["Slice","","10+",x.sliceV10],["Slice","","1-9",x.slice,x.parseSliceAttributes],["Softmax","","1-12",M.softmax,M.parseSoftmaxAttributes],["Softmax","","13+",M.softmaxV13,M.parseSoftmaxAttributesV13],["Split","","2-12",N.split,N.parseSplitAttributes],["Sqrt","","6+",D.sqrt],["Squeeze","","1-12",z.squeeze,z.parseSqueezeAttributes],["Squeeze","","13+",z.squeezeV13],["Sub","","7+",h.sub],["Sum","","6+",$.sum],["Tan","","7+",D.tan],["Tanh","","6+",D.tanh],["Tile","","6+",C.tile],["Transpose","","1+",G.transpose,G.parseTransposeAttributes],["Upsample","","7-8",Y.upsample,Y.parseUpsampleAttributesV7],["Upsample","","9",Y.upsample,Y.parseUpsampleAttributesV9],["Unsqueeze","","1-12",R.unsqueeze,R.parseUnsqueezeAttributes],["Unsqueeze","","13+",R.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),u=i(5060),d=i(2039),a={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)=>(f(l),[c.run(Object.assign(Object.assign({},a),{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,u.getGlsl)(c.session.backend.glContext.version),r=l[0].dims.length,[o,p]=c.calculateTextureWidthAndHeight(l[1].dims,d.TextureType.unpacked),g=` float process(int[${r}] indices) { vec2 position = offsetToCoords(indices[1], ${o}, ${p}); 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({},a),{output:{dims:l[0].dims,type:l[0].type,textureType:d.TextureType.unpacked},shaderSource:g})},f=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),u=i(8520),d=i(5060),a=i(2039);function h(){const T="add_";return{body:` float ${T}(float a, float b) { return a + b; } vec4 ${T}(vec4 v1, vec4 v2) { return v1 + v2; } `,name:T,type:u.FunctionType.ValueBased}}function f(){const T="div_";return{body:` float ${T}(float a, float b) { return a / b; } vec4 ${T}(vec4 v1, vec4 v2) { return v1 / v2; } `,name:T,type:u.FunctionType.ValueBased}}function c(){const T="mul_";return{body:` float ${T}(float a, float b) { return a * b; } vec4 ${T}(vec4 v1, vec4 v2) { return v1 * v2; } `,name:T,type:u.FunctionType.ValueBased}}function l(){const T="sub_";return{body:` float ${T}(float a, float b) { return a - b; } vec4 ${T}(vec4 v1, vec4 v2) { return v1 - v2; } `,name:T,type:u.FunctionType.ValueBased}}function n(){const T="equal_";return{body:` float ${T}(float a, float b) { return float(a == b); } vec4 ${T}(vec4 v1, vec4 v2) { return vec4(equal(v1, v2)); } `,name:T,type:u.FunctionType.ValueBased}}function e(){const T="greater_";return{body:` float ${T}(float a, float b) { return float(a > b); } vec4 ${T}(vec4 v1, vec4 v2) { return vec4( v1.r > v2.r , v1.g > v2.g, v1.b > v2.b, v1.a > v2.a ); } `,name:T,type:u.FunctionType.ValueBased}}function r(){const T="less_";return{body:` float ${T}(float a, float b) { return float(a < b); } vec4 ${T}(vec4 v1, vec4 v2) { return vec4( v1.r < v2.r , v1.g < v2.g, v1.b < v2.b, v1.a < v2.a ); } `,name:T,type:u.FunctionType.ValueBased}}function o(){const T="and_";return{body:` float ${T}(float a, float b) { return float( bool(a) && bool(b) ); } vec4 ${T}(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:T,type:u.FunctionType.ValueBased}}function p(){const T="or_";return{body:` float ${T}(float a, float b) { return float( bool(a) || bool(b) ); } vec4 ${T}(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:T,type:u.FunctionType.ValueBased}}function g(){const T="xor_";return{body:` float ${T}(float a, float b) { return float( bool(a) ^^ bool(b) ); } vec4 ${T}(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:T,type:u.FunctionType.ValueBased}}function _(){return function(T){const S=`${T}_`;return{body:` float ${S}(float a, float b) { return ${T}(a, b); } vec4 ${S}(vec4 v1, vec4 v2) { return ${T}(v1, v2); } `,name:S,type:u.FunctionType.ValueBased}}("pow")}function b(){const T="prelu_";return{body:` float ${T}(float a, float b) { return a < 0.0 ? a * b: a; } vec4 ${T}(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:T,type:u.FunctionType.ValueBased}}t.glslAdd=h,t.glslDiv=f,t.glslMul=c,t.glslSub=l,t.glslEqual=n,t.glslGreater=e,t.glslLess=r,t.glslAnd=o,t.glslOr=p,t.glslXor=g,t.glslPow=_,t.glslPRelu=b;const y=(T,S,A,P=S[0].type,x)=>{const M=T.session.pack?a.TextureType.packed:a.TextureType.unpacked;return{name:A.name,inputNames:["A","B"],inputTypes:[M,M],cacheHint:x,get:()=>w(T,S,A,P)}},w=(T,S,A,P=S[0].type)=>{const x=T.session.pack?a.TextureType.packed:a.TextureType.unpacked,M=!s.ShapeUtil.areEqual(S[0].dims,S[1].dims);let N=S[0].dims;const z=T.session.pack;if(M){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");N=G;const D=N.length,R=S[0].dims.length!==0?S[0].dims.length:1,Y=S[1].dims.length!==0?S[1].dims.length:1,V=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;",Z=(0,d.getGlsl)(T.session.backend.glContext.version),le=z?` ${A.body} void main() { vec4 a = getAAtOutCoords(); vec4 b = getBAtOutCoords(); vec4 result = ${A.name}(a, b); ${Z.output} = result; }`:` ${A.body} float process(int indices[${D}]) { int aindices[${R}]; int bindices[${Y}]; ${V} ${J} return ${A.name}(_A(aindices), _B(bindices)); }`;return{name:A.name,inputNames:["A","B"],inputTypes:[x,x],output:{dims:N,type:P,textureType:x},shaderSource:le,hasMain:z}}const $=(0,d.getGlsl)(T.session.backend.glContext.version),C=` ${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:P,textureType:x},shaderSource:C,hasMain:!0}};t.add=(T,S)=>[T.run(y(T,S,h()),S)],t.and=(T,S)=>[T.run(y(T,S,o(),"bool"),S)],t.div=(T,S)=>[T.run(y(T,S,f()),S)],t.equal=(T,S)=>[T.run(y(T,S,n(),"bool"),S)],t.greater=(T,S)=>[T.run(y(T,S,e(),"bool"),S)],t.less=(T,S)=>[T.run(y(T,S,r(),"bool"),S)],t.mul=(T,S)=>[T.run(y(T,S,c()),S)],t.or=(T,S)=>[T.run(y(T,S,p(),"bool"),S)],t.pow=(T,S)=>[T.run(y(T,S,_()),S)],t.pRelu=(T,S)=>[T.run(y(T,S,b()),S)],t.sub=(T,S)=>[T.run(y(T,S,l()),S)],t.xor=(T,S)=>[T.run(y(T,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,a,h)=>(u(a),[d.cast(a[0],h)]),t.parseCastAttributes=d=>s.ProtoUtil.tensorDataTypeFromProto(d.attributes.getInt("to"));const u=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),u=i(2039),d=i(9390),a=i(2827);t.createPackedConcatProgramInfoLoader=(f,c,l)=>{const n=(e=c.length,r=l.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:e},(o,p)=>`X${p}`),inputTypes:Array(e).fill(u.TextureType.packed),cacheHint:r});var e,r;return Object.assign(Object.assign({},n),{get:()=>((o,p,g,_)=>{const b=g[0].dims.slice();if(_>=b.length||_<-1*b.length)throw new Error("axis specified for concat doesn't match input dimensionality");_<0&&(_=b.length+_);const y=b.slice(0);for(let V=1;VV.dims),x=(0,d.getGlChannels)(w),M=new Array(P.length-1);M[0]=P[0][_];for(let V=1;V= ${M[V-1]}) { return getChannel( getX${V}(${h(x,N,J)}), vec2(${h(z,N,J)})); }`}const G=M.length,D=M[M.length-1];C+=` return getChannel( getX${G}(${h(x,N,D)}), vec2(${h(z,N,D)}));`;const R=(0,s.getGlsl)(o.session.backend.glContext.version),Y=` ${A} float getValue(${x.map(V=>"int "+V)}) { ${C} } 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(${T}), 0., 0., 0.); ${T[w-1]} = ${T[w-1]} + 1; if (${T[w-1]} < ${y[w-1]}) { result.g = getValue(${T}); } ${T[w-2]} = ${T[w-2]} + 1; if (${T[w-2]} < ${y[w-2]}) { result.a = getValue(${T}); } ${T[w-1]} = ${T[w-1]} - 1; if (${T[w-2]} < ${y[w-2]} && ${T[w-1]} < ${y[w-1]}) { result.b = getValue(${T}); } ${R.output} = result; } `;return Object.assign(Object.assign({},p),{output:{dims:y,type:g[0].type,textureType:u.TextureType.packed},shaderSource:Y,hasMain:!0})})(f,n,c,l.axis)})};const h=(f,c,l)=>{const n=f.indexOf(c);return f.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),u=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(a(e,r,o),r)]);const a=(e,r,o)=>{const p=(g=r.length,_=o.cacheKey,{name:"Concat",inputNames:Array.from({length:g},(b,y)=>`X${y}`),inputTypes:Array(g).fill(u.TextureType.unpacked),cacheHint:_});var g,_;return Object.assign(Object.assign({},p),{get:()=>((b,y,w,T)=>{const S=w[0].dims.slice();if(T>=S.length||T<-1*S.length)throw new Error("axis specified for concat doesn't match input dimensionality");T<0&&(T=S.length+T);const A=S.slice(0);for(let $=1;$`int getTextureWhereDataResides(int index) { ${e.map((r,o)=>`if(index<${r}) {return ${o};} `).join("")} }`,f=e=>h(e),c=(e,r)=>{const o=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${r}]) {`];for(let p=0;p{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 p of e){if(p.type!==r)throw new Error("input tensors should be one type");if(p.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),u=i(5060),d=i(2039),a=i(8138),h=i(2823);t.createUnpackedGroupedConvProgramInfoLoader=(f,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,p,g,_)=>{const b=p.length>2?"value += getBias(output_channel);":"",y=p[0].dims.slice(),w=p[1].dims.slice(),T=w[0]/_.group;s.Logger.verbose("GroupedConv",`autpPad:${_.autoPad}, dilations:${_.dilations}, group:${_.group}, kernelShape:${_.kernelShape}, pads:${_.pads}, strides:${_.strides}`);const S=(0,a.calculateOutputShape)(y,w,_.dilations,_.pads,_.strides),A=(0,u.getGlsl)(o.session.backend.glContext.version),{activationFunction:P,applyActivation:x}=(0,h.getActivationSnippet)(_),M=` const ivec2 strides = ivec2(${_.strides[0]}, ${_.strides[1]}); const ivec2 pads = ivec2(${_.pads[0]}, ${_.pads[1]}); ${P} 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 / ${T}; 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 * ${_.dilations[0]}; if (xHeight < 0 || xHeight >= ${y[2]}) { continue; } for (int wWidth = 0; wWidth < ${w[3]}; wWidth++) { int xWidth = xRCCorner.y + wWidth * ${_.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; } } } ${b} ${x} ${A.output} = vec4(value, .0, .0, .0); } `;return Object.assign(Object.assign({},g),{output:{dims:S,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:M,hasMain:!0})})(f,c,n,l)})}},1386:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.conv2DPacked=t.conv2DPackedPointwise=void 0;const s=i(8138),u=i(8555),d=i(708);t.conv2DPackedPointwise=(a,h,f)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,f.dilations,f.pads,f.strides),e=a.reshapePacked(h[0],[c[1],c[2]*c[3]]),r=a.reshapePacked(h[1],[l[0],l[1]]),o=h.length>2?[r,e,h[2]]:[r,e],p=a.run((0,d.createPackedMatmulProgramInfoLoader)(a,o,f),o);return a.reshapePacked(p,n)},t.conv2DPacked=(a,h,f)=>{const c=h[0].dims,l=h[1].dims,n=(0,s.calculateOutputShape)(c,l,f.dilations,f.pads,f.strides),e=a.run((0,u.createPackedIm2ColProgramInfoLoader)(a,h[0],h[1],n,f),[h[0]]),r=a.reshapePacked(h[1],[l[0],l[1]*l[2]*l[3]]),o=h.length===3?[r,e,h[2]]:[r,e],p=a.run((0,d.createPackedMatmulProgramInfoLoader)(a,o,f),o);return a.reshapePacked(p,n)}},9663:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvTransposeAttributes=t.convTranspose=void 0;const s=i(246),u=i(5060),d=i(2039),a=i(2823),h=(r,o,p,g,_,b)=>(r-1)*o+p+(g-1)*_+1-b,f=(r,o,p,g,_)=>{const b=Math.floor(r/2);o==="SAME_UPPER"?(p[g]=b,p[_]=r-b):o==="SAME_LOWER"&&(p[g]=r-b,p[_]=b)};t.convTranspose=(r,o,p)=>(e(o,p),c(r,o,p));const c=(r,o,p)=>{const g=n(p,o);return[l(r,o,g)]},l=(r,o,p)=>r.run(((g,_,b)=>{const y=(w=_.length>2,T=b.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:T});var w,T;return Object.assign(Object.assign({},y),{get:()=>((S,A,P,x)=>{const M=A.length>2?"getB(output_channel)":"0.0",N=A[0].dims,z=A[1].dims,$=z[1],C=z[0]/x.group,G=[A[0].dims[0],A[1].dims[1]*x.group,...x.outputShape],D=(0,u.getGlsl)(S.session.backend.glContext.version),{activationFunction:R,applyActivation:Y}=(0,a.getActivationSnippet)(x),V=` const ivec2 strides = ivec2(${x.strides[0]}, ${x.strides[1]}); const ivec2 pads = ivec2(${x.pads[0]}, ${x.pads[1]}); ${R} 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 = ${M}; for (int inChannelOffset = 0; inChannelOffset < ${C}; inChannelOffset++) { int input_channel = group_id * ${C} + inChannelOffset; for (int wWOff = 0; wWOff < ${z[2]}; wWOff++) { for (int wHOff = 0; wHOff < ${z[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 < ${N[2]} && wLocIn.y >= 0 && wLocIn.y < ${N[3]} ) { float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x); float wVal = getW(input_channel, wOutChannel, wHOff, wWOff); value += xVal * wVal; } } } } ${Y} ${D.output} = vec4(value, .0, .0, .0); } `;return Object.assign(Object.assign({},P),{output:{dims:G,type:A[0].type,textureType:d.TextureType.unpacked},shaderSource:V,hasMain:!0})})(g,_,y,b)})})(r,o,p),o),n=(r,o)=>{const p=r.kernelShape.slice();if(r.kernelShape.length===0)for(let y=2;y{const N=y.length-2,z=M.length===0;for(let $=0;${const o=r.attributes,p=(0,a.parseInternalActivationAttributes)(o),g=o.getString("auto_pad","NOTSET"),_=o.getInts("dilations",[1,1]),b=o.getInt("group",1),y=o.getInts("kernel_shape",[]),w=o.getInts("output_padding",[0,0]),T=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:_,group:b,kernelShape:y,outputPadding:w,outputShape:T,pads:S,strides:A},p))};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 p=r[1].dims[1]*o.group;if(r.length===3&&(r[2].dims.length!==1||r[2].dims[0]!==p))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),u=i(2517),d=i(4770),a=i(1386),h=i(9828),f=i(2823),c=i(3248),l=i(5623);t.calculateOutputShape=(g,_,b,y,w)=>{const T=g[0],S=g.slice(2),A=S.length,P=_[0],x=_.slice(2).map((N,z)=>N+(N-1)*(b[z]-1)),M=S.map((N,z)=>N+y[z]+y[z+A]).map((N,z)=>Math.floor((N-x[z]+w[z])/w[z]));return[T,P].concat(...M)},t.conv=(g,_,b)=>(p(_,b),n(g,_,b));const n=(g,_,b)=>{const y=o(b,_),w=g.session.pack,T=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[g.run((0,d.createUnpackedGroupedConvProgramInfoLoader)(g,_,y),_)]:T&&w?[e(g,_,y)]:w&&_[0].dims.length===4&&_[0].dims[0]===1&&!T?[(0,a.conv2DPacked)(g,_,y)]:[r(g,_,y)]},e=(g,_,b)=>{const y=_[0].dims,w=_[1].dims,T=(0,t.calculateOutputShape)(y,w,b.dilations,b.pads,b.strides),S=g.reshapeUnpacked(_[0],[y[1],y[2]*y[3]]),A=g.reshapeUnpacked(_[1],[w[0],w[1]]),P=_.length>2?[A,S,_[2]]:[A,S],x=g.run((0,l.createMatmulProgramInfoLoader)(P,b),P);return g.reshapeUnpacked(x,T)},r=(g,_,b)=>{const y=_[0].dims,w=_[1].dims,T=(0,t.calculateOutputShape)(y,w,b.dilations,b.pads,b.strides),S=g.run((0,c.createIm2ColProgramInfoLoader)(g,_[0],_[1],T,b),[_[0]]),A=_.length===3?[S,_[1],_[2]]:[S,_[1]];return g.run((0,h.createDotProductProgramInfoLoader)(g,_,T,b),A)},o=(g,_)=>{const b=g.kernelShape.slice();if(g.kernelShape.length===0)for(let T=2;T<_[1].dims.length;++T)b.push(_[1].dims[T]);const y=g.pads.slice();u.PoolConvUtil.adjustPadsBasedOnAutoPad(_[0].dims,g.strides,g.dilations,b,y,g.autoPad);const w=Object.assign({},g);return Object.assign(w,{kernelShape:b,pads:y,cacheKey:g.cacheKey}),w};t.parseConvAttributes=g=>{const _=g.attributes,b=(0,f.parseInternalActivationAttributes)(_),y=_.getString("auto_pad","NOTSET"),w=_.getInts("dilations",[1,1]),T=_.getInt("group",1),S=_.getInts("kernel_shape",[]),A=_.getInts("pads",[0,0,0,0]),P=_.getInts("strides",[1,1]);return(0,s.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:w,group:T,kernelShape:S,pads:A,strides:P},b))};const p=(g,_)=>{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]*_.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 b=g[0].dims.length-2;if(_.dilations.length!==b)throw new Error(`dilations should be ${b}D`);if(_.strides.length!==b)throw new Error(`strides should be ${b}D`);if(_.pads.length!==2*b)throw new Error(`pads should be ${2*b}D`);if(_.kernelShape.length!==0&&_.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,a,h)=>{u(a);const f=h.blocksize,c=f*f,l=h.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],n=h.mode==="DCR"?[a[0].dims[0],f,f,a[0].dims[1]/c,a[0].dims[2],a[0].dims[3]]:[a[0].dims[0],a[0].dims[1]/c,f,f,a[0].dims[2],a[0].dims[3]],e=d.reshapeUnpacked(a[0],n),r={perm:l,cacheKey:`${l}`},[o]=(0,s.transpose)(d,[e],r),p=[a[0].dims[0],a[0].dims[1]/c,a[0].dims[2]*f,a[0].dims[3]*f];return[d.reshapeUnpacked(o,p)]},t.parseDepthToSpaceAttributes=d=>{const a=d.attributes.getInt("blocksize");if(a<1)throw new Error(`blocksize must be >= 1, but got : ${a} 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:a}};const u=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),u=i(5060),d=i(2039),a=i(2823),h=i(3248);t.createDotProductProgramInfoLoader=(f,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,p,g,_)=>{const b=p[0].dims,y=p[1].dims,w=[y[0],Math.ceil(b[1]*y[2]*y[3]/4)],T=(0,h.calculateIm2ColDims)(b,y,g),[S,A]=r.calculateTextureWidthAndHeight(w,d.TextureType.packedLastDimension),P=s.ShapeUtil.computeStrides(T),[x,M]=r.calculateTextureWidthAndHeight(T,d.TextureType.packedLastDimension),N=g.length,z=p.length<3?"0.0":"_B(b)",$=Math.ceil(b[1]*y[2]*y[3]/4),{activationFunction:C,applyActivation:G}=(0,a.getActivationSnippet)(_),D=(0,u.getGlsl)(r.session.backend.glContext.version),R=` ${C} float process(int indices[${N}]) { 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] * ${P[0]} + im2col[1] * ${P[1]} + im2col[2] * ${P[2]}; int kernelOffset = indices[1] * ${w[1]}; float value = ${z}; for (int i = 0; i < ${$}; ++i) { vec2 im2colCoords = offsetToCoords(im2colOffset, ${x}, ${M}); 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:p[0].type,textureType:d.TextureType.unpacked},shaderSource:R})})(f,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,a,h)=>{u(a,h);const f=s.ShapeUtil.flattenShape(a[0].dims,h);return[d.reshapeUnpacked(a[0],f)]},t.parseFlattenAttributes=d=>d.attributes.getInt("axis",1);const u=(d,a)=>{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(a<-h||a>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),u=i(4909);t.getActivationSnippet=function(d){let a;switch(d.activation){case"Relu":a=(0,u.glslRelu)();break;case"Sigmoid":a=(0,u.glslSigmoid)();break;case"Clip":a=(0,u.glslClip)(d.clipMin,d.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const h=a.name;return{activationFunction:a.body,applyActivation:`value = ${h}_(value);`}},t.parseInternalActivationAttributes=d=>{const a=d.getString("activation","");if(a==="Clip"){const[h,f]=d.getFloats("activation_params",[s.MIN_CLIP,s.MAX_CLIP]);return{activation:a,clipMax:f,clipMin:h,activationCacheKey:`${a}:${h},${f}`}}return{activation:a,activationCacheKey:a}}},1253:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseGatherAttributes=t.gather=void 0;const s=i(246),u=i(782),d=i(2517),a=i(2039);t.gather=(l,n,e)=>(c(n,e.axis),[l.run(f(l,n,e),n)]),t.parseGatherAttributes=l=>(0,s.createAttributeWithCacheKey)({axis:l.attributes.getInt("axis",0)});const h={name:"Gather",inputNames:["A","B"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},f=(l,n,e)=>{const r=Object.assign(Object.assign({},h),{cacheHint:e.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((o,p,g,_)=>{const b=g[0].dims.slice(),y=g[1].dims.slice(),w=new Array(b.length+y.length-1);_=d.ShapeUtil.normalizeAxis(_,b.length);const T=[];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(u.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),u=i(2517),d=i(2039);t.gemm=(l,n,e)=>(c(n,e),[l.run(h(n,e),n)]);const a=(l,n)=>{const e=l.attributes.getInt("transA",0)!==0,r=l.attributes.getInt("transB",0)!==0,o=l.attributes.getFloat("alpha",1),p=l.attributes.getFloat("beta",1);return(0,s.createAttributeWithCacheKey)({transA:e,transB:r,alpha:o,beta:p,isOptionalC:n})};t.parseGemmAttributesV7=l=>a(l,!1),t.parseGemmAttributesV11=l=>a(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:()=>f(e,l,n)})},f=(l,n,e)=>{const r=n[0].dims.slice(),o=n[1].dims.slice(),[p,g]=u.GemmUtil.getShapeOfGemmResult(r,e.transA,o,e.transB,n.length===3?n[2].dims:void 0),_=[p,g];if(!_)throw new Error("Can't use gemm on the given tensors");let b=r[r.length-1],y="";e.transA&&(b=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=_.length,T=` 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<${b}; ++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:_,type:n[0].type,textureType:d.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:e.alpha},{name:"beta",type:"float",data:e.beta}],shaderSource:T})},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),u=i(2039),d=i(2827);t.createPackedIm2ColProgramInfoLoader=(a,h,f,c,l)=>{const n=(e=l.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[u.TextureType.packed],cacheHint:e});var e;return Object.assign(Object.assign({},n),{get:()=>((r,o,p,g,_,b)=>{const y=p.dims,w=g.dims,T=_.length,S=[w[1]*w[2]*w[3],_[2]*_[3]],A=w[2]*w[3],P=(0,d.unpackFromChannel)(),x=(0,s.getGlsl)(r.session.backend.glContext.version);let M="";for(let z=0;z<=1;z++)for(let $=0;$<=1;$++)M+=` blockIndex = rc.x + ${$}; pos = rc.y + ${z}; if(blockIndex < ${S[1]} && pos < ${S[0]}) { offsetY = int(blockIndex / (${_[T-1]})) * ${b.strides[0]} - ${b.pads[0]}; d0 = offsetY + ${b.dilations[0]} * (imod(pos, ${A}) / ${w[2]}); if(d0 < ${y[2]} && d0 >= 0) { offsetX = imod(blockIndex, ${_[T-1]}) * ${b.strides[1]} - ${b.pads[1]}; d1 = offsetX + ${b.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*z+$}] = getChannel( getA(0, ch, int(innerDims.x), int(innerDims.y)), innerDims); } } } `;const N=` ${P} void main() { ivec2 rc = getOutputCoords(); vec4 result = vec4(0.0); int blockIndex, pos, offsetY, d0, offsetX, d1, ch; vec2 innerDims; ${M} ${x.output} = result; } `;return Object.assign(Object.assign({},o),{output:{dims:S,type:p.type,textureType:u.TextureType.packed},shaderSource:N,hasMain:!0})})(a,n,h,f,c,l)})}},3248:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.calculateIm2ColDims=t.createIm2ColProgramInfoLoader=void 0;const s=i(2039);t.createIm2ColProgramInfoLoader=(u,d,a,h,f)=>{const c=(l=f.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[s.TextureType.unpacked],cacheHint:l});var l;return Object.assign(Object.assign({},c),{get:()=>((n,e,r,o,p,g)=>{const _=r.dims,b=o.dims,y=p.length,w=(0,t.calculateIm2ColDims)(_,b,p,4),T=` const int XC = ${_[1]}; const int XH = ${_[2]}; const int XW = ${_[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[${_.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:T})})(0,c,d,a,h,f)})},t.calculateIm2ColDims=(u,d,a,h=4)=>[a[0],a[2],a[3],Math.ceil(u[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),u=i(2039);t.imageScaler=(c,l,n)=>(f(l),[c.run(a(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:[u.TextureType.unpacked]},a=(c,l,n)=>{const e=Object.assign(Object.assign({},d),{cacheHint:n.cacheKey});return Object.assign(Object.assign({},e),{get:()=>((r,o,p,g)=>{const _=p[0].dims.slice(),b=_.length,y=` ${h(g.bias.length)} float process(int indices[${b}]) { return _X(indices) * scale + getBias(bias, indices[1]); }`;return Object.assign(Object.assign({},o),{output:{dims:_,type:p[0].type,textureType:u.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),u=i(2039);t.instanceNormalization=(l,n,e)=>{c(n);const r=l.run(a(n[0]),n);return[l.run(f(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:[u.TextureType.unpacked]},a=l=>Object.assign(Object.assign({},d),{get:()=>((n,e)=>{const r=e.dims.slice(),o=r[1],p=r[2]*r[3],g=[r[0],o],_=` 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(${p}); 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(${p}); return v; }`;return Object.assign(Object.assign({},n),{output:{dims:g,type:e.type,textureType:u.TextureType.packedLastDimension},shaderSource:_})})(d,l)}),h={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[u.TextureType.unpacked,u.TextureType.packedLastDimension,u.TextureType.unpacked,u.TextureType.unpacked]},f=(l,n,e,r)=>{const o=Object.assign(Object.assign({},h),{cacheHint:`${e}`});return Object.assign(Object.assign({},o),{get:()=>((p,g,_,b,y)=>{const w=(0,s.getGlsl)(p.session.backend.glContext.version),[T,S]=p.calculateTextureWidthAndHeight(y,u.TextureType.packedLastDimension),[A,P]=[T/4,S],x=` vec4 get_MeanAndVariance(int[2] mv) { int offset = indicesToOffset_MeanAndVariance(mv); vec2 coords = offsetToCoords(offset, ${A}, ${P}); 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:_.dims,type:_.type,textureType:u.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],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),u=i(5060),d=i(2039),a=i(9390),h=i(2823),f=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:()=>((p,g,_,b)=>{const y=_.length>2,w=y?"value += getBiasForMatmul();":"",T=_[0].dims,S=_[1].dims,A=s.BroadcastUtil.calcShape(T,S,!0),P=!s.ShapeUtil.areEqual(_[0].dims,_[1].dims);if(!A)throw new Error("Can't use matmul on the given tensors");const x=T[T.length-1],M=Math.ceil(x/2),N=T.length,z=S.length,$=(0,u.getGlsl)(p.session.backend.glContext.version),C=(0,a.getCoordsDataType)(A.length),G=A.length,D=(0,a.getGlChannels)(),{activationFunction:R,applyActivation:Y}=(0,h.getActivationSnippet)(b),V=y?`${(0,f.getBiasForMatmul)(C,D,_[2].dims,A,!0)}`:"",J=P?`${function(xe,se,we,be){let ke=[],Le=[];const ve=we[0].dims,$e=we[1].dims,Fe=ve.length,Me=$e.length,Pe=be.length,Be=Pe-Fe,Ge=Pe-Me;ke=ve.map((Ee,ze)=>`coords.${se[ze+Be]}`),ke[Fe-1]="i*2",ke.join(", "),Le=$e.map((Ee,ze)=>`coords.${se[ze+Ge]}`),Le[Me-2]="i*2",Le.join(", ");const Ve=s.BroadcastUtil.getBroadcastDims(ve,be),Xe=s.BroadcastUtil.getBroadcastDims($e,be),Qe=Ve.map(Ee=>`coords.${se[Ee+Be]} = 0;`).join(` `),qe=Xe.map(Ee=>`coords.${se[Ee+Ge]} = 0;`).join(` `),Ue=`int lastDim = coords.${se[Pe-1]}; coords.${se[Pe-1]} = coords.${se[Pe-2]}; coords.${se[Pe-2]} = lastDim;`;return` vec4 getAAtOutCoordsMatmul(int i) { ${xe} coords = getOutputCoords(); ${Ue} ${Qe} vec4 outputValue = getA(${ke}); return outputValue; } vec4 getBAtOutCoordsMatmul(int i) { ${xe} coords = getOutputCoords(); ${Ue} ${qe} vec4 outputValue = getB(${Le}); return outputValue; }`}(C,D,_,A)}`:"",Z=P?"getAAtOutCoordsMatmul(i)":`getA(${function(xe,se){let we="";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),u=i(2039),d=i(9390),a=i(2823),h=i(708);function f(n,e){const r=(o=n.length>2,p=e.activationCacheKey,{name:"MatMul",inputNames:o?["A","B","Bias"]:["A","B"],inputTypes:o?[u.TextureType.unpacked,u.TextureType.unpacked,u.TextureType.unpacked]:[u.TextureType.unpacked,u.TextureType.unpacked],cacheHint:p});var o,p;return Object.assign(Object.assign({},r),{get:()=>function(g,_,b){const y=_[0].dims,w=_[1].dims,T=s.BroadcastUtil.calcShape(y,w,!0);if(!T)throw new Error("Can't use matmul on the given tensors");const S=(0,d.getCoordsDataType)(T.length),A=(0,d.getGlChannels)(),{activationFunction:P,applyActivation:x}=(0,a.getActivationSnippet)(b),M=_.length>2,N=M?"value += getBiasForMatmul();":"",z=M?`${l(S,A,_[2].dims,T,!1)}`:"",$=T.length,C=y.length,G=w.length,D=` ${P} ${z} float process(int indices[${$}]) { int a[${C}]; int b[${G}]; bcastMatmulIndices_A(indices, a); bcastMatmulIndices_B(indices, b); float value; for (int k=0; k<${y[y.length-1]}; ++k) { a[${C-1}] = k; b[${G-2}] = k; value += _A(a) * _B(b); } ${N} ${x} return value; }`;return Object.assign(Object.assign({},g),{output:{dims:T,type:_[0].type,textureType:u.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(f(e,r),e)]),t.parseMatMulAttributes=n=>(0,a.parseInternalActivationAttributes)(n.attributes),t.createMatmulProgramInfoLoader=f;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,p){let g="";const _=r.length,b=o.length,y=b-_;g=b<2&&_>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 T="vec4(outputValue.xx, outputValue.yy)";return s.ShapeUtil.size(r)===1&&(T="vec4(outputValue.x)"),p?` vec4 getBiasForMatmul() { ${n} coords = getOutputCoords(); ${w} vec4 outputValue = getBias(${g}); return ${T}; }`:` 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),u=i(2039),d=i(9390),a=i(2827),h={name:"pack",inputNames:["A"],inputTypes:[u.TextureType.unpackedReversed]};t.createPackProgramInfoLoader=(f,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,p=n.dims.length,g=(0,d.getCoordsDataType)(p),_=(0,a.getChannels)("rc",p),b=(y=p,w=_,T=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 >= ${T}; `);var y,w,T,S;let A;A=o===0?[1,1]:o===1?[r[0],1]:[r[p-1],r[p-2]];const P=function(N,z,$){if(N===0)return"false";if(N===1)return`rc > ${z[0]}`;let C="";for(let G=N-2;G= ${z[G-N+2]}`,G= ${N[0]} ? 0. : getA(rc + 1), 0, 0`;let C="";if($>2)for(let G=0;G<$-2;++G)C+=`${z[G]},`;return`getA(${C}r, c), rEdge ? 0. : getA(${C}rp1, c), cEdge ? 0. : getA(${C}r, cp1), rEdge || cEdge ? 0. : getA(${C}rp1, cp1)`}(r,_),M=` void main() { ${g} rc = getOutputCoords(); if(${P}) { ${e.output} = vec4(0); } else { ${b} ${e.output} = vec4(${x}); } } `;return Object.assign(Object.assign({},h),{hasMain:!0,output:{dims:n.dims,type:n.type,textureType:u.TextureType.packed},shaderSource:M})})(f,c)})},2827:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unpackFromChannel=t.getChannels=t.getVecChannels=void 0;const s=i(9390);function u(d,a){return(0,s.getGlChannels)(a).map(h=>`${d}.${h}`)}t.getVecChannels=u,t.getChannels=function(d,a){return a===1?[d]:u(d,a)},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),u=i(2517),d=i(5060),a=i(2039),h={name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.padV2=(g,_,b)=>(l(_),[g.run(Object.assign(Object.assign({},h),{cacheHint:b.cacheKey,get:()=>c(g,_[0],b)}),_)]),t.parsePadAttributesV2=g=>{const _=g.attributes.getString("mode","constant"),b=g.attributes.getFloat("value",0),y=g.attributes.getInts("pads");return(0,s.createAttributeWithCacheKey)({mode:_,value:b,pads:y})},t.padV11=(g,_,b)=>{n(_);const y=f(g,_,b);return(0,t.padV2)(g,[_[0]],y)},t.parsePadAttributesV11=g=>g.attributes.getString("mode","constant");const f=(g,_,b)=>{if(!g.session.isInitializer(_[1].dataId)||_.length>=3&&!g.session.isInitializer(_[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(_[1].integerData),w=_.length>=3?_[2].floatData[0]:0;return(0,s.createAttributeWithCacheKey)({mode:b,pads:y,value:w})},c=(g,_,b)=>{const y=u.ShapeUtil.padShape(_.dims.slice(),b.pads),w=y.length,T=` ${e(g,_,b)} float process(int[${w}] indices) { return padA(indices); }`;return{name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked],output:{dims:y,type:_.type,textureType:a.TextureType.unpacked},shaderSource:T}},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,T]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),S=u.ShapeUtil.computeStrides(_.dims);switch(b.mode){case"constant":return r(y,_.dims,S,w,T,b.pads,b.value);case"reflect":return o(y,_.dims,S,w,T,b.pads);case"edge":return p(y,_.dims,S,w,T,b.pads);default:throw new Error("Invalid mode")}},r=(g,_,b,y,w,T,S)=>{const A=_.length;let P="";for(let x=A-1;x>=0;--x)P+=` k = m[${x}] - ${T[x]}; if (k < 0) return constant; if (k >= ${_[x]}) return constant; offset += k * ${b[x]}; `;return` float padA(int m[${A}]) { const float constant = float(${S}); int offset = 0; int k = 0; ${P} vec2 coords = offsetToCoords(offset, ${y}, ${w}); float value = getColorAsFloat(${g.texture2D}(A, coords)); return value; } `},o=(g,_,b,y,w,T)=>{const S=_.length;let A="";for(let P=S-1;P>=0;--P)A+=` k = m[${P}] - ${T[P]}; if (k < 0) { k = -k; } { const int _2n_1 = ${2*(_[P]-1)}; k = int( mod( float(k), float(_2n_1) ) ) ; if(k >= ${_[P]}) { k = _2n_1 - k; } } offset += k * ${b[P]}; `;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; } `},p=(g,_,b,y,w,T)=>{const S=_.length;let A="";for(let P=S-1;P>=0;--P)A+=` k = m[${P}] - ${T[P]}; if (k < 0) k = 0; if (k >= ${_[P]}) k = ${_[P]-1}; offset += k * ${b[P]}; `;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),u=i(2517),d=i(2039);t.averagePool=(p,g,_)=>{n(g);const b={name:"AveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:_.cacheKey};return[p.run(Object.assign(Object.assign({},b),{get:()=>a(g,b,!1,_)}),g)]},t.parseAveragePoolAttributes=p=>{const g=p.attributes.getString("auto_pad","NOTSET"),_=p.attributes.getInt("ceil_mode",0),b=p.attributes.getInt("count_include_pad",0)!==0,y=p.attributes.getInts("kernel_shape"),w=p.attributes.getInts("strides",[]),T=p.attributes.getInts("pads",[]);if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:_,countIncludePad:b,kernelShape:y,strides:w,pads:T})};const a=(p,g,_,b)=>{const[y,w]=f(p,b,_),T=u.ShapeUtil.size(y.kernelShape);let S="";y.countIncludePad?S+=`value /= float(${T});`:S+=`value /= float(${T} - pad);`;const A=` ${e(p[0].dims,y,"value += _X(x);",S,"0.0")} `;return Object.assign(Object.assign({},g),{output:{dims:w,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:A})};t.globalAveragePool=(p,g,_)=>{n(g);const b={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:`${_.countIncludePad}`};return[p.run(Object.assign(Object.assign({},b),{get:()=>a(g,b,!0,_)}),g)]},t.parseGlobalAveragePoolAttributes=p=>{const g=p.attributes.getInt("count_include_pad",0)!==0;return(0,s.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:g,kernelShape:[],strides:[],pads:[]})},t.maxPool=(p,g,_)=>{n(g);const b={name:"MaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked],cacheHint:_.cacheKey};return[p.run(Object.assign(Object.assign({},b),{get:()=>h(g,b,!1,_)}),g)]},t.parseMaxPoolAttributes=p=>{const g=p.attributes.getString("auto_pad","NOTSET"),_=p.attributes.getInt("ceil_mode",0),b=p.attributes.getInts("kernel_shape"),y=p.attributes.getInts("strides",[]),w=p.attributes.getInts("pads",[]),T=p.attributes.getInt("storage_order",0),S=p.attributes.getInts("dilations",[]);if(T!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,s.createAttributeWithCacheKey)({autoPad:g,ceilMode:_,countIncludePad:!1,kernelShape:b,strides:y,pads:w,storageOrder:T,dilations:S})};const h=(p,g,_,b)=>{const[y,w]=f(p,b,_),T=` ${e(p[0].dims,y,` value = max(_X(x), value); `,"","-1e5")} `;return Object.assign(Object.assign({},g),{output:{dims:w,type:p[0].type,textureType:d.TextureType.unpacked},shaderSource:T})},f=(p,g,_)=>{const b=p[0].dims.slice(),y=Object.hasOwnProperty.call(g,"dilations"),w=g.kernelShape.slice(),T=g.strides.slice(),S=y?g.dilations.slice():[],A=g.pads.slice();u.PoolConvUtil.adjustPoolAttributes(_,b,w,T,S,A);const P=u.PoolConvUtil.computePoolOutputShape(_,b,T,S,w,A,g.autoPad),x=Object.assign({},g);return y?Object.assign(x,{kernelShape:w,strides:T,pads:A,dilations:S,cacheKey:g.cacheKey}):Object.assign(x,{kernelShape:w,strides:T,pads:A,cacheKey:g.cacheKey}),[x,P]},c={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},l={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.globalMaxPool=(p,g)=>(n(g),[p.run(Object.assign(Object.assign({},l),{get:()=>h(g,l,!0,c)}),g)]);const n=p=>{if(!p||p.length!==1)throw new Error("Pool ops requires 1 input.");if(p[0].type!=="float32"&&p[0].type!=="float64")throw new Error("Invalid input type.")},e=(p,g,_,b,y)=>{const w=p.length;if(g.kernelShape.length<=2){const T=g.kernelShape[g.kernelShape.length-1],S=g.strides[g.strides.length-1],A=g.pads[g.pads.length/2-1],P=g.pads[g.pads.length-1],x=p[w-1];let M="",N="",z="";if(M=A+P!==0?` for (int i = 0; i < ${T}; i++) { x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; if (x[${w} - 1] < 0 || x[${w} - 1] >= ${x}) { pad++; continue; } ${_} }`:` for (int i = 0; i < ${T}; i++) { x[${w} - 1] = indices[${w} - 1] * ${S} - ${A} + i; ${_} }`,g.kernelShape.length===2){const $=g.kernelShape[g.kernelShape.length-2],C=g.strides[g.strides.length-2],G=g.pads[g.pads.length/2-2],D=g.pads[g.pads.length-2],R=p[w-2];N=G+D!==0?` for (int j = 0; j < ${$}; j++) { x[${w} - 2] = indices[${w} - 2] * ${C} - ${G} + j; if (x[${w} - 2] < 0 || x[${w} - 2] >= ${R}) { pad+= ${T}; continue; } `:` for (int j = 0; j < ${$}; j++) { x[${w} - 2] = indices[${w} - 2] * ${C} - ${G} + j; `,z=` } `}return` float process(int indices[${w}]) { int x[${w}]; copyVec(indices, x); float value = ${y}; int pad = 0; ${N} ${M} ${z} ${b} return value; } `}{const T=u.ShapeUtil.size(g.kernelShape),S=u.ShapeUtil.computeStrides(g.kernelShape),A=S.length,P=g.pads.length,x=o(A),M=r(p,"inputDims"),N=r(g.pads,"pads"),z=r(S,"kernelStrides"),$=r(g.strides,"strides");let C="";return C=g.pads.reduce((G,D)=>G+D)?` if (x[j] >= inputDims[j] || x[j] < 0) { pad++; isPad = true; break; } } if (!isPad) { ${_} }`:` } ${_} `,` ${x} float process(int indices[${w}]) { int x[${w}]; copyVec(indices, x); int offset[${A}]; int pads[${P}]; int inputDims[${w}]; int kernelStrides[${A}]; int strides[${A}]; ${N} ${M} ${$} ${z} float value = ${y}; int pad = 0; bool isPad = false; for (int i = 0; i < ${T}; 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]; ${C} } ${b} return value; } `}},r=(p,g)=>{let _="";for(let b=0;b` void offsetToIndices(int offset, int[${p}] strides, out int[${p}] indices) { if (${p} == 0) { return; } for (int i = 0; i < ${p} - 1; ++i) { indices[i] = offset / strides[i]; offset -= indices[i] * strides[i]; } indices[${p} - 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),u=i(782),d=i(2517),a=i(2039),h=(l,n,e,r,o)=>{c(n);const p={name:r,inputNames:["A"],inputTypes:[a.TextureType.unpacked]};return[l.run(Object.assign(Object.assign({},p),{cacheHint:e.cacheKey,get:()=>f(l,n,e,r,o,p)}),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 f=(l,n,e,r,o,p)=>{const g=[],_=n[0].dims.length||1,b=[],y=d.ShapeUtil.normalizeAxes(e.axes,n[0].dims.length),w=o(n,y);let T=w[1];for(let A=0;A=0||y.length===0?(e.keepDims&&g.push(1),T=` for(int j${A} = 0; j${A} < ${n[0].dims[A]}; j${A}++) { inputIdx[${A}] = j${A}; ${T} }`):(b.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[${_}]; // addressing input data ${b.join(` `)} ${w[0]} // init ops for reduce max/min ${T} ${w[2]} // final computation for reduce mean return value; }`;return Object.assign(Object.assign({},p),{output:{dims:g,type:n[0].type,textureType:a.TextureType.unpacked},shaderSource:S})},c=l=>{if(!l||l.length!==1)throw new Error("Reduce op requires 1 input.");if(u.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 p=1;for(let g=0;g=0||o.length===0)&&(p*=r[0].dims[g]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${p}.;`]}),t.reduceMax=(l,n,e)=>h(l,n,e,"ReduceMax",(r,o)=>{const p=[];for(let g=0;g=0||o.length===0)&&p.push(`inputIdx[${g}] = 0;`);return[`${p.join(` `)} value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),t.reduceMin=(l,n,e)=>h(l,n,e,"ReduceMin",(r,o)=>{const p=[];for(let g=0;g=0||o.length===0)&&p.push(`inputIdx[${g}] = 0;`);return[`${p.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),u=i(5060),d=i(2039),a=i(2827);t.createPackedReshape3DProgramInfoLoader=(h,f,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 p=e.dims,g=o;let _="";for(let w=0;w<4;w++){let T="";switch(w){case 0:T="outputCoords = rc;";break;case 1:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:T="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}_+=` ${T} ${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 b=(0,u.getGlsl)(n.session.backend.glContext.version),y=` ${function(w){const T=s.ShapeUtil.computeStrides(w),S=["b","r","c"],A="index";return` ivec3 inputCoordsFromReshapedOutCoords(int index) { ${T.map((P,x)=>`int ${S[x]} = ${A} / ${P}; ${x===T.length-1?`int ${S[x+1]} = ${A} - ${S[x]} * ${P}`:`index -= ${S[x]} * ${P}`};`).join("")} return ivec3(b, r, c); } `}(p)} ${function(w){const T=s.ShapeUtil.computeStrides(w);return` int getFlattenedIndex(ivec3 coords) { // reverse y, z order return coords.x * ${T[0]} + coords.z * ${T[1]} + coords.y; } `}(g)} ${(0,a.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,f,l,c)})},t.processDims3D=function(h){if(h.length===0)return[1,1,1];let f=1;for(let c=0;c1?h[h.length-2]:1,h[h.length-1]]},t.isReshapeCheap=function(h,f){let c=!1;return c=h.length===0||f.length===0||(h.length<2||f.length<2?h[h.length-1]===f[f.length-1]:h[h.length-1]===f[f.length-1]&&h[h.length-2]===f[f.length-2]),c}},718:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=void 0;const s=i(2517);t.reshape=(u,d)=>{const a=s.ShapeUtil.calculateReshapedDims(d[0].dims,d[1].integerData);return u.session.pack?[u.reshapePacked(d[0],a)]:[u.reshapeUnpacked(d[0],a)]}},2268:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseResizeAttributesV11=t.parseResizeAttributesV10=t.resize=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827),h=i(9793),f={name:"Resize",inputNames:["A"],inputTypes:[u.TextureType.packed]};t.resize=(r,o,p)=>((0,h.validateInputs)(o,p),[r.run(Object.assign(Object.assign({},f),{cacheHint:p.cacheKey,get:()=>c(r,o,p)}),o)]),t.parseResizeAttributesV10=r=>(0,h.parseUpsampleAttributes)(r,10),t.parseResizeAttributesV11=r=>(0,h.parseUpsampleAttributes)(r,11);const c=(r,o,p)=>{const g=(0,s.getGlsl)(r.session.backend.glContext.version),[_,b]=l(o,p);if(_.every(C=>C===1)&&p.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},f),{output:{dims:b,type:o[0].type,textureType:u.TextureType.packed},hasMain:!0,shaderSource:`void main() { vec4 v = ${g.texture2D}(X, TexCoords); ${g.output} = v; }`});const y=b.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const w=b[y-2],T=b[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],P=S[y-1],x=_[y-2],M=_[y-1];let N="";if(p.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${p.mode}'`);switch(p.coordinateTransformMode){case"asymmetric":N=` vec4 getSourceFracIndex(ivec4 coords) { return vec4(coords) / scaleWHWH; } `;break;case"half_pixel":N=` vec4 getSourceFracIndex(ivec4 coords) { return (vec4(coords) + 0.5) / scaleWHWH - 0.5; } `;break;case"pytorch_half_pixel":N=` vec4 getSourceFracIndex(ivec4 coords) { vec4 fcoords = vec4(coords); return vec4( ${T}.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, ${T}.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":N=` vec4 getSourceFracIndex(ivec4 coords) { vec4 resized = vec4(${T}.0 - 1.0, ${w}.0 - 1.0, ${T}.0 - 1.0, ${w}.0 - 1.0); vec4 original = vec4(${P}.0 - 1.0, ${A}.0 - 1.0, ${P}.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: '${p.coordinateTransformMode}'`)}const z=(0,d.getCoordsDataType)(y),$=` const vec2 inputWH = vec2(${A}.0, ${P}.0); const vec4 scaleWHWH = vec4(float(${x}), float(${M}), float(${x}), float(${M})); ${(0,a.unpackFromChannel)()} ${N} float getAValue(int x10, int r, int c, int d) { return getChannel(getA(x10, r, c, d), vec2(c, d)); } void main() { ${z} 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 < ${T-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({},f),{output:{dims:b,type:o[0].type,textureType:u.TextureType.packed},hasMain:!0,shaderSource:$})},l=(r,o)=>{const p=r[0].dims;let g,_=o.scales;if(_.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.");_=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),_=e(g,p,o.mode,o.isResize)}}else if(r[o.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=g||p.map((y,w)=>Math.floor(y*_[w]));return[_,b]},n=(r,o,p)=>{const g=Array.from(r.floatData);return(0,h.scalesValidation)(g,o,p),g},e=(r,o,p,g)=>{const _=o.length,b=new Array(_);for(let y=0,w=_;y{Object.defineProperty(t,"__esModule",{value:!0}),t.shape=void 0;const s=i(9162);t.shape=(d,a)=>(u(a),[new s.Tensor([a[0].dims.length],"int32",void 0,void 0,new Int32Array(a[0].dims))]);const u=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),u=i(782),d=i(2517),a=i(2039),h={name:"Slice",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.slice=(e,r,o)=>(c(r),[e.run(Object.assign(Object.assign({},h),{cacheHint:o.cacheKey,get:()=>f(e,r[0],o)}),r)]),t.parseSliceAttributes=e=>{const r=e.attributes.getInts("starts"),o=e.attributes.getInts("ends"),p=e.attributes.getInts("axes",[]);return(0,s.createAttributeWithCacheKey)({starts:r,ends:o,axes:p})};const f=(e,r,o)=>{const p=o.axes.length===0?r.dims.slice(0).map((S,A)=>A):o.axes,g=d.ShapeUtil.normalizeAxes(p,r.dims.length),_=o.starts.map((S,A)=>S>r.dims[g[A]]-1?r.dims[g[A]]:d.ShapeUtil.normalizeAxis(S,r.dims[g[A]])),b=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]}] += ${_[S]};`);const T=` float process(int outputIdx[${y.length}]) { ${w.join(` `)} return _A(outputIdx); }`;return Object.assign(Object.assign({},h),{output:{dims:y,type:r.type,textureType:a.TextureType.unpacked},shaderSource:T})},c=e=>{if(!e||e.length!==1)throw new Error("Slice requires 1 input.");if(u.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:()=>f(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(_=>_!==1))throw new Error("currently non-1 steps is not supported for Slice");const o=Array.from(r[1].integerData),p=Array.from(r[2].integerData),g=r.length>=4?Array.from(r[3].integerData):[];return{starts:o,ends:p,axes:g,cacheKey:`${g};${o};${p}`}},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),u=i(2517),d=i(5060),a=i(2039),h=i(3738),f={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[a.TextureType.unpacked]},c={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},l={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked,a.TextureType.unpacked]};t.softmax=(g,_,b)=>{p(_);const y=_[0].dims.slice(),w=u.ShapeUtil.normalizeAxis(b.axis,y.length),T=u.ShapeUtil.sizeToDimension(y,w),S=u.ShapeUtil.sizeFromDimension(y,w);return n(g,_,b,T,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)=>{p(_);const y=_[0].dims.slice(),w=u.ShapeUtil.normalizeAxis(b.axis,y.length),T=y.length,S=w!==T-1,A=[];let P,x=[],M=[];S&&(x=Array.from({length:T}).map((C,G)=>G),x[w]=T-1,x[T-1]=w,x.map(C=>A.push(y[C])),P=(0,s.createAttributeWithCacheKey)({perm:x}),M=(0,h.transpose)(g,_,P));const N=S?u.ShapeUtil.sizeToDimension(A,T-1):u.ShapeUtil.sizeToDimension(y,T-1),z=S?u.ShapeUtil.sizeFromDimension(A,T-1):u.ShapeUtil.sizeFromDimension(y,T-1),$=n(g,S?M:_,b,N,z);return S?(0,h.transpose)(g,$,P):$};const n=(g,_,b,y,w)=>{const T=e(g,_[0],y,w,[y]),S=g.run(Object.assign(Object.assign({},f),{cacheHint:b.cacheKey,get:()=>T}),_),A=r(g,_[0],y,w,T.output.dims,[y]),P=g.run(Object.assign(Object.assign({},c),{cacheHint:b.cacheKey,get:()=>A}),[_[0],S]),x=o(g,_[0],y,w,T.output.dims,A.output.dims);return[g.run(Object.assign(Object.assign({},l),{cacheHint:b.cacheKey,get:()=>x}),[_[0],S,P])]},e=(g,_,b,y,w)=>{const[T,S]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),A=w.length;if(b<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]!==b)throw new Error("Shape of the output should be equal to logical row count");const P=(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(${P.texture2D}(A, offsetToCoords(logical_row_start_offset, ${T}, ${S} ))); for(int i=1; i<${y}; ++i) { float current = getColorAsFloat(${P.texture2D}(A, offsetToCoords(logical_row_start_offset + i, ${T}, ${S}))); if(current > max) max = current; } return max; }`;return Object.assign(Object.assign({},f),{output:{dims:w,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},r=(g,_,b,y,w,T)=>{const[S,A]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),P=T.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1)throw new Error("Dimensionality of the output should be 1");if(T[0]!==b)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]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` float process(int[${P}] 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:T,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},o=(g,_,b,y,w,T)=>{const[S,A]=g.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),P=_.dims.length;if(b<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||T.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(w[0]!==b||T[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const x=` float process(int[${P}] 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:_.dims,type:_.type,textureType:a.TextureType.unpacked},shaderSource:x})},p=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),u=i(2517),d=i(2039),a={name:"Split",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.split=(l,n,e)=>{c(n);const r=u.ShapeUtil.normalizeAxis(e.axis,n[0].dims.length),o=h(l,n,r,e),p=[];for(let g=0;gf(l,n[0],e,r,g)}),n));return p},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]=u.SplitUtil.splitShape(n[0].dims,e,r.split,r.numOutputs);return o.length},f=(l,n,e,r,o)=>{const[p,g]=u.SplitUtil.splitShape(n.dims,r,e.split,e.numOutputs),_=g[o],b=p[o],y=` float process(int indices[${b.length}]) { indices[${r}] += ${_}; return _A(indices); } `;return Object.assign(Object.assign({},a),{cacheHint:`${e.cacheKey}:${o}`,output:{dims:b,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=(a,h,f)=>{u(h);const c=s.ShapeUtil.squeezeShape(h[0].dims,f);return[a.reshapeUnpacked(h[0],c)]},t.squeezeV13=(a,h)=>(d(h),(0,t.squeeze)(a,[h[0]],Array.from(h[1].integerData))),t.parseSqueezeAttributes=a=>a.attributes.getInts("axes");const u=a=>{if(!a||a.length!==1)throw new Error("Squeeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},d=a=>{if(!a||a.length!==2)throw new Error("Squeeze requires 2 inputs.");if(a[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),u=i(2039);t.sum=(h,f)=>{a(f);const c={name:"Sum",inputNames:f.map((l,n)=>`X${n}`),inputTypes:new Array(f.length).fill(u.TextureType.unpacked)};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,f,c)}),f)]};const d=(h,f,c)=>{const l=(0,s.getGlsl)(h.session.backend.glContext.version),n=f[0].dims.slice(),e=` void main() { vec4 result = ${f.map((r,o)=>`${l.texture2D}(X${o},TexCoords)`).join(" + ")}; ${l.output} = result; } `;return Object.assign(Object.assign({},c),{output:{dims:n,type:f[0].type,textureType:u.TextureType.unpacked},hasMain:!0,shaderSource:e})},a=h=>{if(!h||h.length===0)throw new Error("Sum requires inputs.");const f=h[0].dims.length;for(let c=1;c{Object.defineProperty(t,"__esModule",{value:!0}),t.tile=void 0;const s=i(782),u=i(2039);t.tile=(h,f)=>{a(f);const c={name:"Tile",inputNames:["A"],inputTypes:[u.TextureType.unpacked]};return[h.run(Object.assign(Object.assign({},c),{get:()=>d(h,f,c)}),f)]};const d=(h,f,c)=>{const l=f[0].dims.slice(),n=new Array(l.length),e=[];for(let p=0;p{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),u=i(2517),d=i(2039),a={name:"Transpose",inputNames:["A"],inputTypes:[d.TextureType.unpacked]};t.transpose=(e,r,o)=>(n(r),[e.run(Object.assign(Object.assign({},a),{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 p=r.dims;o=f(p,o);const g=c(p,o),_=p.length,b=` ${l("perm",o,_)} float process(int indices[${_}]) { int a[${_}]; perm(a, indices); return _A(a); }`;return Object.assign(Object.assign({},a),{output:{dims:g,type:r.type,textureType:d.TextureType.unpacked},shaderSource:b})},f=(e,r)=>(r&&r.length!==e.length&&(r=[...e.keys()].reverse()),r),c=(e,r)=>(r=f(e,r),u.ShapeUtil.sortBasedOnPerm(e,r)),l=(e,r,o)=>{const p=[];p.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),u=i(2039);t.encodeAsUint8=(d,a)=>{const h=a.shape,f=(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 = ${f.texture2D}(X,TexCoords).r; ${f.output} = encodeAsUint8(value); }`,l={name:"Uint8Encode",inputTypes:[u.TextureType.unpacked],inputNames:["X"],output:{dims:h,type:a.tensor.type,textureType:u.TextureType.downloadUint8AsFloat},shaderSource:c,hasMain:!0};return d.executeProgram(l,[a.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),u=i(2517),d=i(8520),a=i(5060),h=i(2039);function f(){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 R="elu";return{body:` const float alpha = float(${D}); float ${R}_(float a) { return a >= 0.0 ? a: (exp(a) - 1.0) * alpha; } vec4 ${R}_(vec4 v) { return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w)); } `,name:R,type:d.FunctionType.ValueBased}}function p(){return $("exp")}function g(){return $("floor")}function _(D,R){const Y="clip";return{body:` const float min = float(${D}); const float max = float(${R}); float ${Y}_(float a) { return clamp(a, min, max); } vec4 ${Y}_(vec4 v) { return clamp(v, min, max); } `,name:Y,type:d.FunctionType.ValueBased}}function b(){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 R="leakyRelu";return{body:` const float alpha = float(${D}); float ${R}_(float a) { return a < 0.0 ? a * alpha : a; } vec4 ${R}_(vec4 v) { return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w)); } `,name:R,type:d.FunctionType.ValueBased}}function w(){return $("log")}function T(){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 P(){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 M(){return $("sqrt")}function N(){return $("tan")}function z(){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=f,t.glslAcos=c,t.glslAsin=l,t.glslAtan=n,t.glslCeil=e,t.glslCos=r,t.glslElu=o,t.glslExp=p,t.glslFloor=g,t.glslClip=_,t.glslIdentity=b,t.glslLeakyRelu=y,t.glslLog=w,t.glslNeg=T,t.glslNot=S,t.glslSin=A,t.glslRelu=P,t.glslSigmoid=x,t.glslSqrt=M,t.glslTan=N,t.glslTanh=z;const C=(D,R,Y,V)=>{const J=D.session.pack?h.TextureType.packed:h.TextureType.unpacked,Z={name:Y.name,inputTypes:[J],inputNames:["A"],cacheHint:V};return Object.assign(Object.assign({},Z),{get:()=>((le,Ae,xe,se)=>{const we=le.session.pack?h.TextureType.packed:h.TextureType.unpacked,be=(0,a.getGlsl)(le.session.backend.glContext.version);return Object.assign(Object.assign({},Ae),{output:{dims:xe.dims,type:xe.type,textureType:we},shaderSource:` ${se.body} void main() { vec4 v = ${be.texture2D}(A, TexCoords); v = ${se.name}_(v); ${be.output} = v; } `,hasMain:!0})})(D,Z,R,Y)})};t.abs=(D,R)=>[D.run(C(D,R[0],f()),R)],t.acos=(D,R)=>[D.run(C(D,R[0],c()),R)],t.asin=(D,R)=>[D.run(C(D,R[0],l()),R)],t.atan=(D,R)=>[D.run(C(D,R[0],n()),R)],t.clip=(D,R,Y)=>[D.run(C(D,R[0],_(Y.min,Y.max),Y.cacheKey),R)],t.parseClipAttributes=D=>(0,s.createAttributeWithCacheKey)({min:D.attributes.getFloat("min",u.MIN_CLIP),max:D.attributes.getFloat("max",u.MAX_CLIP)}),t.clipV11=(D,R)=>{const Y=G(D,R);return(0,t.clip)(D,[R[0]],Y)};const G=(D,R)=>{if(R.length>=3&&(!D.session.isInitializer(R[1].dataId)||!D.session.isInitializer(R[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const Y=R.length>=3?R[1].numberData[0]:u.MIN_CLIP,V=R.length>=3?R[2].numberData[0]:u.MAX_CLIP;return(0,s.createAttributeWithCacheKey)({min:Y,max:V})};t.ceil=(D,R)=>[D.run(C(D,R[0],e()),R)],t.cos=(D,R)=>[D.run(C(D,R[0],r()),R)],t.elu=(D,R,Y)=>[D.run(C(D,R[0],o(Y.alpha),Y.cacheKey),R)],t.parseEluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",1)}),t.exp=(D,R)=>[D.run(C(D,R[0],p()),R)],t.floor=(D,R)=>[D.run(C(D,R[0],g()),R)],t.identity=(D,R)=>[D.run(C(D,R[0],b()),R)],t.leakyRelu=(D,R,Y)=>[D.run(C(D,R[0],y(Y.alpha),Y.cacheKey),R)],t.parseLeakyReluAttributes=D=>(0,s.createAttributeWithCacheKey)({alpha:D.attributes.getFloat("alpha",.01)}),t.log=(D,R)=>[D.run(C(D,R[0],w()),R)],t.neg=(D,R)=>[D.run(C(D,R[0],T()),R)],t.not=(D,R)=>[D.run(C(D,R[0],S()),R)],t.relu=(D,R)=>[D.run(C(D,R[0],P()),R)],t.sigmoid=(D,R)=>[D.run(C(D,R[0],x()),R)],t.sin=(D,R)=>[D.run(C(D,R[0],A()),R)],t.sqrt=(D,R)=>[D.run(C(D,R[0],M()),R)],t.tan=(D,R)=>[D.run(C(D,R[0],N()),R)],t.tanh=(D,R)=>[D.run(C(D,R[0],z()),R)]},5611:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackProgramInfoLoader=t.createUnpackProgramInfo=void 0;const s=i(5060),u=i(2039),d=i(9390),a=i(2827),h={name:"unpack",inputNames:["A"],inputTypes:[u.TextureType.packed]};t.createUnpackProgramInfo=(f,c)=>{const l=c.dims.length,n=(0,a.getChannels)("rc",l),e=n.slice(-2),r=(0,d.getCoordsDataType)(l),o=(0,a.unpackFromChannel)(),p=c.dims.length===0?"":function(b,y){if(b===1)return"rc";let w="";for(let T=0;TObject.assign(Object.assign({},h),{get:()=>(0,t.createUnpackProgramInfo)(f,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=(a,h,f)=>{u(h);const c=s.ShapeUtil.unsqueezeShape(h[0].dims,f);return[a.reshapeUnpacked(h[0],c)]},t.unsqueezeV13=(a,h)=>(d(h),(0,t.unsqueeze)(a,[h[0]],Array.from(h[1].integerData))),t.parseUnsqueezeAttributes=a=>a.attributes.getInts("axes");const u=a=>{if(!a||a.length!==1)throw new Error("Unsqueeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},d=a=>{if(!a||a.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(a[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),u=i(5060),d=i(2039),a={name:"Upsample",inputNames:["X"],inputTypes:[d.TextureType.unpacked]};t.upsample=(f,c,l)=>((0,t.validateInputs)(c,l),[f.run(Object.assign(Object.assign({},a),{cacheHint:l.cacheKey,get:()=>h(f,c,l)}),c)]),t.parseUpsampleAttributesV7=f=>(0,t.parseUpsampleAttributes)(f,7),t.parseUpsampleAttributesV9=f=>(0,t.parseUpsampleAttributes)(f,9),t.parseUpsampleAttributes=(f,c)=>{const l=c>=10,n=f.attributes.getString("mode","nearest");if(n!=="nearest"&&n!=="linear"&&(c<11||n!=="cubic"))throw new Error(`unrecognized mode: ${n}`);let e=[];c<9&&(e=f.attributes.getFloats("scales"),(0,t.scalesValidation)(e,n,l));const r=f.attributes.getFloat("extrapolation_value",0),o=c>10?f.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 p=o==="tf_crop_and_resize",g=p,_=n==="nearest"&&c>=11?f.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(_)===-1)throw new Error(`nearest_mode '${_}' is not supported`);const b=f.attributes.getFloat("cubic_coeff_a",-.75),y=f.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"&&_==="floor";let T=0,S=0,A=0;return c>10?f.inputs.length>2?(T=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:p,nearestMode:_,cubicCoefficientA:b,excludeOutside:y,useNearest2xOptimization:w,roiInputIdx:T,scalesInputIdx:S,sizesInputIdx:A})};const h=(f,c,l)=>{const n=(0,u.getGlsl)(f.session.backend.glContext.version),[e,r]=f.calculateTextureWidthAndHeight(c[0].dims,d.TextureType.unpacked),o=c[0].dims.map((A,P)=>Math.floor(A*l.scales[P])),[p,g]=f.calculateTextureWidthAndHeight(o,d.TextureType.unpacked),_=o.length,b=new Array(_),y=new Array(_);let w=` int output_pitches[${_}]; int input_pitches[${_}]; `;for(let A=_-1;A>=0;A--)b[A]=A===_-1?1:b[A+1]*o[A+1],y[A]=A===_-1?1:y[A+1]*c[0].dims[A+1],w+=` output_pitches[${A}] = ${b[A]}; input_pitches[${A}] = ${y[A]}; `;const T=` float getInputFloat(int index) { vec2 coords = offsetToCoords(index, ${e}, ${r}); float value = getColorAsFloat(${n.texture2D}(X, coords)); return value; } `,S=l.mode==="nearest"?` ${T} float process(int indices[${_}]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${g}); ${w} int d, m; for (int dim = 0; dim < ${_}; ++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); }`:_===4?` ${T} float process(int indices[4]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${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]); }`:` ${T} float process(int indices[2]) { int input_index = 0; int output_index = coordsToOffset(TexCoords, ${p}, ${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({},a),{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=(f,c)=>{if(!f||c.opset<9&&f.length!==1||c.opset>=9&&c.opset<11&&f.length!==2||c.opset>=11&&f.length<2)throw new Error("invalid inputs.");if(c.scales.length>0&&f[0].dims.length!==c.scales.length)throw new Error("Invalid input shape.");if(f[0].type==="string")throw new Error("Invalid input tensor types.")},t.scalesValidation=(f,c,l)=>{if(l){for(const n of f)if(n<=0)throw new Error("Scale value should be greater than 0.")}else for(const n of f)if(n<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(c!=="linear"&&c!=="cubic"||f.length===2||f.length===4&&f[0]===1&&f[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),u=i(6231),d=i(8879),a=i(5060);t.ProgramManager=class{constructor(h,f,c){this.profiler=h,this.glContext=f,this.textureLayoutStrategy=c,this.repo=new Map,this.attributesBound=!1}getArtifact(h){return this.repo.get(h)}setArtifact(h,f){this.repo.set(h,f)}run(h,f,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:[],f)}catch(o){throw u.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,f,c){return this.profiler.event("backend","ProgramManager.build",()=>{const l=new d.GlslPreprocessor(this.glContext,h,f,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){u.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const l=(0,a.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(l,this.glContext.gl.VERTEX_SHADER)}s.env.debug&&u.Logger.verbose("ProrgramManager",`FragShader: ${h} `);const f=this.glContext.compileShader(h,this.glContext.gl.FRAGMENT_SHADER),c=this.glContext.createProgram(this.vertexShader,f);return this.glContext.deleteShader(f),c}bindOutput(h){const f=h.width,c=h.height;u.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${f}/${c}, shape=${h.shape}, type=${h.tensor.type}`),this.glContext.attachFramebuffer(h.texture,f,c)}bindAttributes(h){const f=h.position,c=h.textureCoord;this.glContext.setVertexAttributes(f,c),this.attributesBound=!0}bindUniforms(h,f,c){var l;const n=this.glContext.gl;let e=0;for(const{name:r,type:o,location:p,arrayLength:g}of h){const _=(l=f.find(b=>b.name===r))===null||l===void 0?void 0:l.data;if(o!=="sampler2D"&&!_)throw new Error(`variable '${r}' does not have data defined in program info`);switch(o){case"sampler2D":this.bindTexture(c[e],p,e),e++;break;case"float":g?n.uniform1fv(p,_):n.uniform1f(p,_);break;case"int":g?n.uniform1iv(p,_):n.uniform1i(p,_);break;default:throw new Error(`Uniform not implemented: ${o}`)}}}bindTexture(h,f,c){this.glContext.bindTextureToUniform(h.texture,c,f)}getAttribLocations(h){return{position:this.getAttribLocation(h,"position"),textureCoord:this.getAttribLocation(h,"textureCoord")}}getUniformLocations(h,f,c){const l=[];if(f)for(const n of f)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,f){const c=this.glContext.gl.getUniformLocation(h,f);if(c===null)throw new Error(`Uniform ${f} not found.`);return c}getAttribLocation(h,f){return this.glContext.gl.getAttribLocation(h,f)}}},6416:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLSessionHandler=void 0;const s=i(6231),u=i(1047),d=i(8316),a=i(1640),h=i(1958),f=i(7859),c=i(5702);t.WebGLSessionHandler=class{constructor(l,n){this.backend=l,this.context=n,this.layoutStrategy=new f.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,u.resolveOperator)(l,n,a.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(u,d=1){if(d===1)this.internalFormat=u.R32F,this.format=u.RED,this.textureType=u.FLOAT,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA32F,this.format=u.RGBA,this.textureType=u.FLOAT,this.channelSize=d}}encode(u,d){let a,h;return u.constructor!==Float32Array&&(s.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),h=new Float32Array(u)),d*this.channelSize>u.length?(s.Logger.warning("Encoder","Source data too small. Allocating larger array"),h=u,a=this.allocate(d*this.channelSize),h.forEach((f,c)=>a[c]=f)):(h=u,a=h),a}allocate(u){return new Float32Array(4*u)}decode(u,d){return this.channelSize===1?u.filter((a,h)=>h%4==0).subarray(0,d):u.subarray(0,d)}},t.RGBAFloatDataEncoder=class{constructor(u,d=1,a){if(d!==1&&d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA,this.format=u.RGBA,this.channelSize=d,this.textureType=a||u.FLOAT}encode(u,d){let a=u;return this.channelSize===1&&(s.Logger.verbose("Encoder","Exploding into a larger array"),a=this.allocate(d),u.forEach((h,f)=>a[4*f]=h)),a}allocate(u){return new Float32Array(4*u)}decode(u,d){return this.channelSize===1?u.filter((a,h)=>h%4==0).subarray(0,d):u.subarray(0,d)}},t.Uint8DataEncoder=class{constructor(u,d=1){if(this.channelSize=4,d===1)this.internalFormat=u.ALPHA,this.format=u.ALPHA,this.textureType=u.UNSIGNED_BYTE,this.channelSize=d;else{if(d!==4)throw new Error(`Invalid number of channels: ${d}`);this.internalFormat=u.RGBA,this.format=u.RGBA,this.textureType=u.UNSIGNED_BYTE,this.channelSize=d}}encode(u,d){return new Uint8Array(u.buffer,u.byteOffset,u.byteLength)}allocate(u){return new Uint8Array(u*this.channelSize)}decode(u,d){if(u instanceof Uint8Array)return u.subarray(0,d);throw new Error(`Invalid array type: ${u.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),u=i(2517);function d(l,n){const e=[],r=[],o=n!=null&&Array.isArray(n)&&n.length===0,p=n==null||o?null:a(n,l).sort();let g=0;for(let _=0;__)&&l[_]===1&&(e.push(l[_]),r.push(_)),p[g]<=_&&g++}l[_]!==1&&(e.push(l[_]),r.push(_))}return{newShape:e,keptDims:r}}function a(l,n){const e=n.length;return l=l==null?n.map((r,o)=>o):[].concat(l),(0,u.assert)(l.every(r=>r>=-e&&r`All values in axis param must be in range [-${e}, ${e}) but got axis ${l}`),(0,u.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 f(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(!(p>e||g>e))return[p,g];s.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${l}, breakAxis:${n.breakAxis}`)}const r=l.reduce((p,g)=>p*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((b,y)=>b*y),_=n.breakAxis<=0?1:l.slice(0,n.breakAxis).reduce((b,y)=>b*y);if(!(g>r||_>r))return[g,_];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,_)=>_>=o.length-2?o[_]%2==0?o[_]:o[_]+1:o[_]),o.length===1&&(o=[2,o[0]])),o.length!==2&&(o=d(o).newShape);const p=f(o);return o.length<=1&&p<=r?[1,p]: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(p/4).map(g=>2*g):c(p)}},t.squeezeShape=d,t.parseAxisParam=a,t.isInt=h,t.sizeFromShape=f,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 f(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),u=i(2039);t.createTextureLayoutFromTextureType=(d,a,h)=>{const f=h===u.TextureType.unpacked||h===u.TextureType.unpackedReversed?1:4,c=h===u.TextureType.packed,l=h===u.TextureType.unpackedReversed||h===u.TextureType.packed,n=h===u.TextureType.packedLastDimension?a.length-1:void 0,e=h===u.TextureType.packedLastDimension?a.map((r,o)=>o===a.length-1?4*r:r):void 0;return(0,t.createTextureLayoutFromShape)(d,a,f,e,{isPacked:c,reverseWH:l,breakAxis:n})},t.calculateTextureWidthAndHeight=(d,a,h)=>{const f=(0,t.createTextureLayoutFromTextureType)(d,a,h);return[f.width,f.height]},t.createTextureLayoutFromShape=(d,a,h=1,f,c)=>{const l=!(!c||!c.isPacked),[n,e]=d.computeTextureWH(l&&f||a,c),r=a.length;let o=a.slice(0);if(r===0&&(o=[1]),h===1)f=a;else if(l){if(h!==4)throw new Error("a packed texture must be 4-channel");f=a,r>0&&(o[r-1]=Math.ceil(o[r-1]/2)),r>1&&(o[r-2]=Math.ceil(o[r-2]/2))}else if(!f)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:f,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(u,d,a,h){this.glContext=u,this.layoutStrategy=d,this.profiler=a,this.config=h,this.pendingRead=new Map,h.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(u,d,a,h){const f=this.toEncoderType(u),c=this.glContext.getEncoder(f,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 p=this.idleTextures.get(e);if(p&&p.length>0){const g=p.pop();return r.push(g),h===1&&this.glContext.updateTexture(g,l,n,c,this.toTextureData(u,a)),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(u,a));return this.config.reuseTextures&&(r.push(o),this.textureLookup.set(o,e)),o}readTexture(u,d,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const h=u.shape.reduce((c,l)=>c*l)*a,f=this.glContext.readTexture(u.texture,u.width,u.height,h,this.toEncoderType(d),a);return this.toTensorData(d,f)})}async readTextureAsync(u,d,a){const h=u.tensor.dataId;if(a||(a=1),this.pendingRead.has(h)){const f=this.pendingRead.get(h);return new Promise(c=>f==null?void 0:f.push(c))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(h,[]);const f=u.shape.reduce((e,r)=>e*r)*a;await this.glContext.createAndWaitForFence();const c=this.glContext.readTexture(u.texture,u.width,u.height,f,this.toEncoderType(d),a),l=this.toTensorData(d,c),n=this.pendingRead.get(h);return this.pendingRead.delete(h),n==null||n.forEach(e=>e(l)),l})}readUint8TextureAsFloat(u){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const d=u.shape.reduce((h,f)=>h*f),a=this.glContext.readTexture(u.texture,u.width,u.height,4*d,"byte",4);return new Float32Array(a.buffer,a.byteOffset,d)})}releaseTexture(u,d){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(u.texture),a)){d&&this.textureLookup.delete(a);const h=this.inUseTextures.get(a);if(h){const f=h.indexOf(u.texture);if(f!==-1){h.splice(f,1);let c=this.idleTextures.get(a);c||(c=[],this.idleTextures.set(a,c)),c.push(u.texture)}}}a&&!d||(s.Logger.verbose("TextureManager",`Deleting texture of size ${u.width}x${u.height}`),this.glContext.deleteTexture(u.texture))}toTensorData(u,d){switch(u){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 ${u} is not supported`)}}toTextureData(u,d){if(d)return d instanceof Float32Array?d:new Float32Array(d)}toEncoderType(u){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(u){const d=u.length;return u.slice(0,d-1).concat(u[d-1]/4)},t.repeatedTry=async function(u,d=h=>0,a){return new Promise((h,f)=>{let c=0;const l=()=>{if(u())return void h();c++;const n=d(c);a!=null&&c>=a?f():setTimeout(l,n)};l()})},t.generateShaderFuncNameFromInputSamplerName=function(u){return(0,s.assert)(u!==void 0&&u.length!==0,()=>"empty string found for sampler name"),"get"+u.charAt(0).toUpperCase()+u.slice(1)},t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(u){return(0,s.assert)(u!==void 0&&u.length!==0,()=>"empty string found for sampler name"),"get"+u.charAt(0).toUpperCase()+u.slice(1)+"AtOutCoords"},t.squeezeInputShape=function(u,d){let a=JSON.parse(JSON.stringify(u));return a=d,a},t.getSqueezedParams=function(u,d){return d.map(a=>u[a]).join(", ")},t.getCoordsDataType=function(u){if(u<=1)return"int";if(u===2)return"ivec2";if(u===3)return"ivec3";if(u===4)return"ivec4";if(u===5)return"ivec5";if(u===6)return"ivec6";throw Error(`GPU for rank ${u} is not yet supported`)},t.getGlChannels=function(u=6){return["x","y","z","w","u","v"].slice(0,u)}},7305:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createNewWebGLContext=t.createWebGLContext=void 0;const s=i(6231),u=i(1713),d={};function a(h){const f=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=f.getContext("webgl2",l),c))try{return new u.WebGLContext(c,2)}catch(n){s.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${n}`)}if((!h||h==="webgl")&&(c=f.getContext("webgl",l)||f.getContext("experimental-webgl",l),c))try{return new u.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(f){let c;f&&f!=="webgl2"||!("webgl2"in d)?f&&f!=="webgl"||!("webgl"in d)||(c=d.webgl):c=d.webgl2,c=c||a(f),f=f||c.version===1?"webgl":"webgl2";const l=c.gl;return d[f]=c,l.isContextLost()?(delete d[f],h(f)):(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=a},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]}),u=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 u(n,l),n};Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLContext=t.linearSearchLastTrue=void 0;const a=i(1670),h=d(i(7769)),f=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,f.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 u{constructor(a,h){this.op=a,this.node=h}}t.ExecutionPlan=class{constructor(d,a,h){this.graph=d,this.profiler=h,this.initialize(a)}initialize(d){this.profiler.event("session","ExecutionPlan.initialize",()=>{const a=this.graph.getNodes();if(a.length!==d.length)throw new Error("The size of nodes and OPs do not match.");this._ops=d.map((h,f)=>new u(h,a[f])),this.reset(),this._starter=[],this._ops.forEach((h,f)=>{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(f)})})}reset(){this._values=this.graph.getValues().map(d=>d.tensor)}async execute(d,a){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const h=d.createInferenceHandler(),f=this.graph.getInputIndices();if(a.length!==f.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${a.length} expected: ${f.length}`);a.forEach((o,p)=>{const g=f[p];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: ${p.node}`);const _=g;s.Logger.verbose("ExecPlan",`Runing op:${p.node.name} (${_.map((w,T)=>`'${p.node.inputs[T]}': ${w.type}[${w.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",p.node.name,async()=>p.op.impl(h,_,p.op.context));if(b.length!==p.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((w,T)=>{const S=p.node.outputs[T];if(this._values[S])throw new Error(`output [${S}] already has value: op:${p.node.name}`);this._values[S]=w});const y=new Set;b.forEach((w,T)=>{const S=p.node.outputs[T];for(const A of l[S].to){const P=n[A];let x=!0;for(const M of P.inputs)if(!this._values[M]){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),u=i(7778),d=i(9395),a=i(9162),h=i(2517);var f=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 u.Attribute(r.attribute)):r instanceof f.Node&&(this.name=o??r.name(),this.opType=r.opType(),this.attributes=new u.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 f.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 p=new Map;if(!r.input)throw new Error("missing information in graph: input");const g=[];for(const _ of r.input){if(o.has(_.name))throw new Error(`duplicated input name: ${_.name}`);const b=this._allData.push(new c(_))-1;o.set(_.name,b),g.push(_.name)}if(!r.initializer)throw new Error("missing information in graph: initializer");for(const _ of r.initializer){let b=o.get(_.name);if(b===void 0){const y=new c;y.type={shape:{dims:h.ProtoUtil.tensorDimsFromProto(_.dims)},tensorType:h.ProtoUtil.tensorDataTypeFromProto(_.dataType)},b=this._allData.push(y)-1,o.set(_.name,b)}this._allData[b]._from=-1,this._allData[b].tensor=a.Tensor.fromProto(_)}for(let _=0;_{this._allData[g]._to.forEach(_=>{r.add(_)})});const o=Array.from(r),p=new Array(this._nodes.length).fill("white");for(;o.length>0;){const g=o.pop();p[g]==="gray"?p[g]="black":(o.push(g),p[g]="gray",this._nodes[g].outputs.forEach(_=>{const b=this._allData[_];if(b.tensor!==void 0)throw new Error("node outputs should not be initialized");if(b._from!==g)throw new Error("from property of the Value object doesn't match index of Node being processed");b._to.forEach(y=>{if(p[y]==="gray")throw new Error("model graph is cyclic");p[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(p=>{const g=this._allData[p]._to.indexOf(o+r);g!==-1&&(this._allData[p]._to[g]=o)}),this._nodes[o].outputs.forEach(p=>{this._allData[p]._from&&this._allData[p]._from===o+r&&(this._allData[p]._from=o)})):(r++,this._nodes[o].outputs.forEach(p=>{this._allData[p]._from=-2}),this._nodes.splice(o,1),o--);r=0;for(let o=0;o0){let p=-1;this._allData[o].from!==void 0&&this._allData[o].from!==-1?(p=this._nodes[this._allData[o].from].outputs.indexOf(o+r),p!==-1&&(this._nodes[this._allData[o].from].outputs[p]=o)):(p=this._allInputIndices.indexOf(o+r),p!==-1&&(this._allInputIndices[p]=o)),this._allData[o].to.forEach(g=>{p=this._nodes[g].inputs.indexOf(o+r),p!==-1&&(this._nodes[g].inputs[p]=o)}),this._allData[o].to.length===0&&(p=this._allOutputIndices.indexOf(o+r),p!==-1&&(this._allOutputIndices[p]=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 p=o.inputs[0],g=o.outputs[0],_=this._allData[g].to,b=this._allData[p].to.indexOf(r);if(b===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[p].to.splice(b,1),this._allData[g]._to=[];const y=this._allOutputIndices.indexOf(g);if(y!==-1&&(this._allOutputIndices[y]=p),_&&_.length>0)for(const w of _){const T=this._nodes[w].inputs.indexOf(g);if(T===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[w].inputs[T]=p,this._allData[p].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 p=this._nodes[o[0]];if(p.opType==="Clip")if(p.inputs.length===1)try{r.attributes.set("activation_params","floats",[p.attributes.getFloat("min"),p.attributes.getFloat("max")])}catch{r.attributes.set("activation_params","floats",[h.MIN_CLIP,h.MAX_CLIP])}else{if(!(p.inputs.length>=3&&this._allData[p.inputs[1]].tensor!==void 0&&this._allData[p.inputs[2]].tensor!==void 0))continue;r.attributes.set("activation_params","floats",[this._allData[p.inputs[1]].tensor.floatData[0],this._allData[p.inputs[2]].tensor.floatData[0]])}r.attributes.set("activation","string",p.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}`)}}}},u={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let d={"":u};function a(l,n,e,r){if(n===void 0)return o=l,{verbose:a.verbose.bind(null,o),info:a.info.bind(null,o),warning:a.warning.bind(null,o),error:a.error.bind(null,o),fatal:a.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(),_(y)},async y=>{o&&await o.end(),b(y)})});if(!p&&o){const _=o.end();if(_&&typeof _.then=="function")return new Promise((b,y)=>{_.then(()=>{b(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 f(l,n,r,o=>this.endSync(o))}{const r=e.beginTimer();return new f(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),u=i(1446),d=i(7070),a=i(9395),h=i(2517);var f=a.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=u.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=f.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,u){if(u.endsWith("+")){const d=Number.parseInt(u.substring(0,u.length-1),10);return!isNaN(d)&&d<=s}if(u.split("-").length===2){const d=u.split("-"),a=Number.parseInt(d[0],10),h=Number.parseInt(d[1],10);return!isNaN(a)&&!isNaN(h)&&a<=s&&s<=h}return Number.parseInt(u,10)===s}Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOperator=void 0,t.resolveOperator=function(s,u,d){for(const a of d){const h=a[0],f=a[1],c=a[2],l=a[3],n=a[4];if(s.opType===h){for(const e of u)if((e.domain===f||e.domain==="ai.onnx"&&f==="")&&i(e.version,c))return{opImpl:l,opInit:n}}}throw new TypeError(`cannot resolve operator '${s.opType}' with opsets: ${u.map(a=>`${a.domain||"ai.onnx"} v${a.version}`).join(", ")}`)}},9395:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onnxruntime=void 0;const s=i(5686);var u,d;u=t.onnxruntime||(t.onnxruntime={}),function(a){(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"})(a.AttributeType||(a.AttributeType={}))}((d=u.experimental||(u.experimental={})).fbs||(d.fbs={})),function(a){(function(h){(function(f){(function(c){c[c.UNKNOWN=0]="UNKNOWN",c[c.VALUE=1]="VALUE",c[c.PARAM=2]="PARAM"})(f.DimensionValueType||(f.DimensionValueType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(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"})(f.TensorDataType||(f.TensorDataType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(function(c){c[c.Primitive=0]="Primitive",c[c.Fused=1]="Fused"})(f.NodeType||(f.NodeType={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){(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"})(f.TypeInfoValue||(f.TypeInfoValue={}))})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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)}}f.Shape=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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)}}f.Dimension=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.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,a.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)}}f.DimensionValue=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.experimental.fbs.TensorDataType.UNDEFINED}shape(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.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,a.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)}}f.TensorTypeAndShape=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.experimental.fbs.TensorDataType.UNDEFINED}valueType(n){let e=this.bb.__offset(this.bb_pos,6);return e?(n||new a.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,a.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)}}f.MapType=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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)}}f.SequenceType=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(h.fbs||(h.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(f,c){return this.bb_pos=f,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(f,c,l,n){return f.prep(4,12),f.writeInt32(n),f.writeInt32(l),f.writeInt32(c),f.offset()}}})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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)}}f.NodeEdge=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.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 a.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,a.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,p,g,_,b,y,w,T,S,A,P){return c.startNode(n),c.addName(n,e),c.addDocString(n,r),c.addDomain(n,o),c.addSinceVersion(n,p),c.addIndex(n,g),c.addOpType(n,_),c.addType(n,b),c.addExecutionProviderType(n,y),c.addInputs(n,w),c.addOutputs(n,T),c.addAttributes(n,S),c.addInputArgCounts(n,A),c.addImplicitInputs(n,P),c.endNode(n)}}f.Node=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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)}}f.ValueInfo=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.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,a.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)}}f.TypeInfo=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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)}}f.OperatorSetId=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.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,a.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,p,g,_){return c.startTensor(n),c.addName(n,e),c.addDocString(n,r),c.addDims(n,o),c.addDataType(n,p),c.addRawData(n,g),c.addStringData(n,_),c.endTensor(n)}}f.Tensor=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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)}}f.SparseTensor=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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):a.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 a.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 a.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 a.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 a.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,a.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,p,g,_,b,y,w,T,S,A,P){return c.startAttribute(n),c.addName(n,e),c.addDocString(n,r),c.addType(n,o),c.addF(n,p),c.addI(n,g),c.addS(n,_),c.addT(n,b),c.addG(n,y),c.addFloats(n,w),c.addInts(n,T),c.addStrings(n,S),c.addTensors(n,A),c.addGraphs(n,P),c.endAttribute(n)}}f.Attribute=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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 a.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 a.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 a.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,p,g,_,b,y){return c.startGraph(n),c.addInitializers(n,e),c.addNodeArgs(n,r),c.addNodes(n,o),c.addMaxNodeIndex(n,p),c.addNodeEdges(n,g),c.addInputs(n,_),c.addOutputs(n,b),c.addSparseInitializers(n,y),c.endGraph(n)}}f.Graph=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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,p,g,_,b,y,w){return c.startModel(n),c.addIrVersion(n,e),c.addOpsetImport(n,r),c.addProducerName(n,o),c.addProducerVersion(n,p),c.addDomain(n,g),c.addModelVersion(n,_),c.addDocString(n,b),c.addGraph(n,y),c.addGraphDocString(n,w),c.endModel(n)}}f.Model=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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)}}f.KernelCreateInfos=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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)}}f.SubGraphSessionState=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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)}}f.SessionState=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(a){(function(h){(function(f){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 a.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 a.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)}}f.InferenceSession=c})(h.fbs||(h.fbs={}))})(a.experimental||(a.experimental={}))}(t.onnxruntime||(t.onnxruntime={}))},7448:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxjsSessionHandler=void 0;const s=i(1670),u=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,a,h){const f=new Map;for(const n in d)if(Object.hasOwnProperty.call(d,n)){const e=d[n];f.set(n,new u.Tensor(e.dims,e.type,void 0,void 0,e.data))}const c=await this.session.run(f),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),u=i(1296),d=i(7091),a=i(1036),h=i(6231),f=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 f.Model,typeof c=="string"){const r=c.endsWith(".ort");if(typeof fetch>"u"){const o=await(0,u.promisify)(s.readFile)(c);this.initialize(o,r)}else{const o=await fetch(c),p=await o.arrayBuffer();this.initialize(new Uint8Array(p),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 a.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 P=="string")))throw new TypeError("cache should be a string array");A&&(this.cache=new Array(S))}else{if(w!==void 0){const P=e(_);if(!(w instanceof P))throw new TypeError(`cache should be type ${P.name}`)}if(A){const P=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}`)}}(_));this.cache=function(x,M){return new(e(M))(x)}(P,_)}}}static fromProto(g){if(!g)throw new Error("cannot construct Value from an empty tensor");const _=f.ProtoUtil.tensorDataTypeFromProto(g.dataType),b=f.ProtoUtil.tensorDimsFromProto(g.dims),y=new l(b,_);if(_==="string")g.stringData.forEach((w,T)=>{y.data[T]=(0,f.decodeUtf8String)(w)});else if(g.rawData&&typeof g.rawData.byteLength=="number"&&g.rawData.byteLength>0){const w=y.data,T=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 P=0;P0){const w=y.data,T=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 P=0;P1&&M>1)return;A[S-P]=Math.max(x,M)}return A}static index(_,b){const y=new Array(b.length);return c.fillIndex(_,b,y),y}static fillIndex(_,b,y){const w=_.length-b.length;for(let T=0;T=0;Y--)x[Y]=z%S[Y],z=Math.floor(z/S[Y]);G||(c.fillIndex(x,_.dims,M),$=_.get(M)),D||(c.fillIndex(x,b.dims,N),C=b.get(N)),P.set(x,y($,C))}}return P}}static isValidBroadcast(_,b){const y=_.length,w=b.length;if(y>w)return!1;for(let T=1;T<=y;T++)if(_[y-T]!==1&&_[y-T]!==b[w-T])return!1;return!0}static getBroadcastDims(_,b){const y=_.length,w=[];for(let T=0;T1&&A===1&&w.unshift(S)}return w}}t.BroadcastUtil=c,t.arrayCopyHelper=function(g,_,b,y,w){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;Td.default.isLong(b)?b.toNumber():b)}static tensorValueTypeFromProto(_){return{tensorType:l.tensorDataTypeFromProto(_.elemType),shape:{dims:l.tensorDimsFromProto(_.shape.dim.map(b=>b.dimValue))}}}static tensorDimsFromORTFormat(_){const b=[];for(let y=0;y<_.dimsLength();y++)b.push(n.longToNumber(_.dims(y)));return b}static tensorAttributesFromORTFormat(_){const b=[];for(let y=0;y<_.attributesLength();y++)b.push(_.attributes(y));return b}}t.ProtoUtil=l;class n{static longToNumber(_,b){return d.default.isLong(_)?_.toNumber():_ instanceof u.flatbuffers.Long?d.default.fromValue({low:_.low,high:_.high,unsigned:b!=null&&b}).toNumber():_}static isLong(_){return d.default.isLong(_)||_ instanceof u.flatbuffers.Long}}t.LongUtil=n;class e{static size(_){return e.getSizeFromDimensionRange(_,0,_.length)}static sizeFromDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeFromDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,b,_.length)}static sizeToDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeToDimension as Tensor has ${_.length} dimensions.`);return e.getSizeFromDimensionRange(_,0,b)}static getSizeFromDimensionRange(_,b,y){let w=1;for(let T=b;T=0;--w)y[w]=y[w+1]*_[w+1];return y}static transpose(_){return _.slice().reverse()}static indicesToOffset(_,b,y){y===void 0&&(y=_.length);let w=0;for(let T=0;T=b)throw new Error("unsupported axis for this operation.");return _<0?_+b:_}static normalizeAxes(_,b){return _.map(y=>this.normalizeAxis(y,b))}static incrementIndex(_,b,y){if(b.length===0||_.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=b.length;else if(y<=0||y>b.length)throw new Error("Incorrect axis to increment on");for(let w=y-1;w>=0&&(_[w]++,!(_[w]=_.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");w[P]=_[P]}else w[P]=b[P];S*=w[P]}}const A=e.size(_);if(T!==-1){if(A%S!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${_}] Output shape: [${b}]`);w[T]=A/S}else if(S!==A)throw new Error("reshapedDims and originalDims don't have matching sizes");return w}static sortBasedOnPerm(_,b){return b?b.map(y=>_[y]):_.slice().reverse()}static padShape(_,b){const y=_.length;return _.map((w,T)=>w+b[T]+b[T+y])}static areEqual(_,b){return _.length===b.length&&_.every((y,w)=>y===b[w])}static validateDimsAndCalcSize(_){if(_.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const y of _){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`);b*=y}return b}static flattenShape(_,b){b<0&&(b+=_.length);const y=_.reduce((T,S)=>T*S,1),w=_.slice(b).reduce((T,S)=>T*S,1);return[y/w,w]}static squeezeShape(_,b){const y=new Array;b=e.normalizeAxes(b,_.length);for(let w=0;w<_.length;w++){const T=b.indexOf(w)>=0;if(T&&_[w]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&_[w]>1||b.length>0&&!T)&&y.push(_[w])}return y}static unsqueezeShape(_,b){const y=new Array(_.length+b.length);y.fill(0);for(let T=0;T=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 T=0;T=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;T=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let S=0;S=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=g.length)throw new Error("targetIndex out of bounds");if(y+w>_.length)throw new Error("source indices to be copied are outside bounds");if(b+w>g.length)throw new Error("target array is too small to hold result");for(let T=0;Tb.push(C));const A=o.calcReduceShape(S,b,!0),P=e.size(A),x=new h.Tensor(A,_.type),M=e.computeStrides(A),N=e.computeStrides(S),z=new Array(S.length);for(let $=0;$=b.length)return S(_[T]);const x=b[w],M=x>=y.length?1:e.size(y.slice(x+1));for(let N=0;NT!==0)}}t.ReduceUtil=o;class p{static adjustPoolAttributes(_,b,y,w,T,S){if(!_&&y.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(_)for(let A=0;A=y.length?y.push(b[A+2]):y[A]=b[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,T,S){if(S){if(T.length!==2*(_.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(b.length!==_.length-2)throw new Error("length of strides should be the length of data dimensions");if(w.length!==_.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let A=0;A<_.length-2;A++)p.adjustPadAndReturnShape(_[A+2],b[A],y[A],w[A],T,A,A+_.length-2,S)}}static computePoolOutputShape(_,b,y,w,T,S,A){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const P=[b[0],b[1]];return p.computeShapeHelper(_,b,P,y,w,T,S,A),P}static computeConvOutputShape(_,b,y,w,T,S,A){if(_.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const P=[_[0],b[0]];return p.computeShapeHelper(!1,_,P,y,w,T,S,A),P}static computeShapeHelper(_,b,y,w,T,S,A,P){if(_)for(let x=0;x{Object.defineProperty(t,"__esModule",{value:!0}),t.iterateExtraOptions=void 0,t.iterateExtraOptions=(i,s,u,d)=>{if(typeof i=="object"&&i!==null){if(u.has(i))throw new Error("Circular reference in options");u.add(i)}Object.entries(i).forEach(([a,h])=>{const f=s?s+a:a;if(typeof h=="object")(0,t.iterateExtraOptions)(h,f+".",u,d);else if(typeof h=="string"||typeof h=="number")d(f,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);d(f,h?"1":"0")}})}},2157:function(m,t,i){var s,u=this&&this.__createBinding||(Object.create?function(M,N,z,$){$===void 0&&($=z);var C=Object.getOwnPropertyDescriptor(N,z);C&&!("get"in C?!N.__esModule:C.writable||C.configurable)||(C={enumerable:!0,get:function(){return N[z]}}),Object.defineProperty(M,$,C)}:function(M,N,z,$){$===void 0&&($=z),M[$]=N[z]}),d=this&&this.__setModuleDefault||(Object.create?function(M,N){Object.defineProperty(M,"default",{enumerable:!0,value:N})}:function(M,N){M.default=N}),a=this&&this.__importStar||function(M){if(M&&M.__esModule)return M;var N={};if(M!=null)for(var z in M)z!=="default"&&Object.prototype.hasOwnProperty.call(M,z)&&u(N,M,z);return d(N,M),N};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),f=a(i(349)),c=i(6361),l=()=>!!h.env.wasm.proxy&&typeof document<"u";let n,e,r,o=!1,p=!1,g=!1;const _=[],b=[],y=[],w=[],T=[],S=[],A=()=>{if(o||!p||g||!n)throw new Error("worker not ready")},P=M=>{switch(M.data.type){case"init-wasm":o=!1,M.data.err?(g=!0,e[1](M.data.err)):(p=!0,e[0]());break;case"init-ort":M.data.err?r[1](M.data.err):r[0]();break;case"create_allocate":M.data.err?_.shift()[1](M.data.err):_.shift()[0](M.data.out);break;case"create_finalize":M.data.err?b.shift()[1](M.data.err):b.shift()[0](M.data.out);break;case"create":M.data.err?y.shift()[1](M.data.err):y.shift()[0](M.data.out);break;case"release":M.data.err?w.shift()[1](M.data.err):w.shift()[0]();break;case"run":M.data.err?T.shift()[1](M.data.err):T.shift()[0](M.data.out);break;case"end-profiling":M.data.err?S.shift()[1](M.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(p)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((M,N)=>{n==null||n.terminate(),n=i(9710).Z(),n.onmessage=P,e=[M,N];const z={type:"init-wasm",in:h.env.wasm};n.postMessage(z)})}return(0,c.initializeWebAssembly)(h.env.wasm)},t.initOrt=async(M,N)=>{if(l())return A(),new Promise((z,$)=>{r=[z,$];const C={type:"init-ort",in:{numThreads:M,loggingLevel:N}};n.postMessage(C)});f.initOrt(M,N)},t.createSessionAllocate=async M=>l()?(A(),new Promise((N,z)=>{_.push([N,z]);const $={type:"create_allocate",in:{model:M}};n.postMessage($,[M.buffer])})):f.createSessionAllocate(M),t.createSessionFinalize=async(M,N)=>l()?(A(),new Promise((z,$)=>{b.push([z,$]);const C={type:"create_finalize",in:{modeldata:M,options:N}};n.postMessage(C)})):f.createSessionFinalize(M,N),t.createSession=async(M,N)=>l()?(A(),new Promise((z,$)=>{y.push([z,$]);const C={type:"create",in:{model:M,options:N}};n.postMessage(C,[M.buffer])})):f.createSession(M,N),t.releaseSession=async M=>{if(l())return A(),new Promise((N,z)=>{w.push([N,z]);const $={type:"release",in:M};n.postMessage($)});f.releaseSession(M)},t.run=async(M,N,z,$,C)=>l()?(A(),new Promise((G,D)=>{T.push([G,D]);const R={type:"run",in:{sessionId:M,inputIndices:N,inputs:z,outputIndices:$,options:C}};n.postMessage(R,f.extractTransferableBuffers(z))})):f.run(M,N,z,$,C),t.endProfiling=async M=>{if(l())return A(),new Promise((N,z)=>{S.push([N,z]);const $={type:"end-profiling",in:M};n.postMessage($)});f.endProfiling(M)}},586:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const s=i(7967),u=i(4983),d=i(6361);t.setRunOptions=a=>{const h=(0,d.getInstance)();let f=0;const c=[],l=a||{};try{if((a==null?void 0:a.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof a.logSeverityLevel!="number"||!Number.isInteger(a.logSeverityLevel)||a.logSeverityLevel<0||a.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${a.logSeverityLevel}`);if((a==null?void 0:a.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof a.logVerbosityLevel!="number"||!Number.isInteger(a.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${a.logVerbosityLevel}`);(a==null?void 0:a.terminate)===void 0&&(l.terminate=!1);let n=0;if((a==null?void 0:a.tag)!==void 0&&(n=(0,u.allocWasmString)(a.tag,c)),f=h._OrtCreateRunOptions(l.logSeverityLevel,l.logVerbosityLevel,!!l.terminate,n),f===0)throw new Error("Can't create run options");return(a==null?void 0:a.extra)!==void 0&&(0,s.iterateExtraOptions)(a.extra,"",new WeakSet,(e,r)=>{const o=(0,u.allocWasmString)(e,c),p=(0,u.allocWasmString)(r,c);if(h._OrtAddRunConfigEntry(f,o,p)!==0)throw new Error(`Can't set a run config entry: ${e} - ${r}`)}),[f,c]}catch(n){throw f!==0&&h._OrtReleaseRunOptions(f),c.forEach(h._free),n}}},2306:(m,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxruntimeWebAssemblySessionHandler=void 0;const s=i(2806),u=i(1670),d=i(2850),a=i(2157);let h;t.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(f){const c=await fetch(f),l=await c.arrayBuffer();return(0,a.createSessionAllocate)(new Uint8Array(l))}async loadModel(f,c){if(h||(await(0,a.initOrt)(u.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}`)}})(u.env.logLevel)),h=!0),typeof f=="string")if(typeof fetch>"u"){const l=await(0,d.promisify)(s.readFile)(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(l,c)}else{const l=await this.createSessionAllocate(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSessionFinalize)(l,c)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(f,c)}async dispose(){return(0,a.releaseSession)(this.sessionId)}async run(f,c,l){const n=[],e=[];Object.entries(f).forEach(g=>{const _=g[0],b=g[1],y=this.inputNames.indexOf(_);if(y===-1)throw new Error(`invalid input '${_}'`);n.push(b),e.push(y)});const r=[];Object.entries(c).forEach(g=>{const _=g[0],b=this.outputNames.indexOf(_);if(b===-1)throw new Error(`invalid output '${_}'`);r.push(b)});const o=await(0,a.run)(this.sessionId,e,n.map(g=>[g.type,g.dims,g.data]),r,l),p={};for(let g=0;g{Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const s=i(7967),u=i(4983),d=i(6361);t.setSessionOptions=a=>{const h=(0,d.getInstance)();let f=0;const c=[],l=a||{};(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{(a==null?void 0:a.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);(a==null?void 0:a.enableCpuMemArena)===void 0&&(l.enableCpuMemArena=!0),(a==null?void 0:a.enableMemPattern)===void 0&&(l.enableMemPattern=!0),(a==null?void 0:a.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((a==null?void 0:a.logId)!==void 0&&(r=(0,u.allocWasmString)(a.logId,c)),(a==null?void 0:a.logSeverityLevel)===void 0)l.logSeverityLevel=2;else if(typeof a.logSeverityLevel!="number"||!Number.isInteger(a.logSeverityLevel)||a.logSeverityLevel<0||a.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${a.logSeverityLevel}`);if((a==null?void 0:a.logVerbosityLevel)===void 0)l.logVerbosityLevel=0;else if(typeof a.logVerbosityLevel!="number"||!Number.isInteger(a.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${a.logVerbosityLevel}`);if((a==null?void 0:a.enableProfiling)===void 0&&(l.enableProfiling=!1),f=h._OrtCreateSessionOptions(n,!!l.enableCpuMemArena,!!l.enableMemPattern,e,!!l.enableProfiling,0,r,l.logSeverityLevel,l.logVerbosityLevel),f===0)throw new Error("Can't create session options");return a!=null&&a.executionProviders&&((o,p,g)=>{for(const _ of p){let b=typeof _=="string"?_:_.name;switch(b){case"xnnpack":b="XNNPACK";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${b}`)}const y=(0,u.allocWasmString)(b,g);if((0,d.getInstance)()._OrtAppendExecutionProvider(o,y)!==0)throw new Error(`Can't append execution provider: ${b}`)}})(f,a.executionProviders,c),(a==null?void 0:a.extra)!==void 0&&(0,s.iterateExtraOptions)(a.extra,"",new WeakSet,(o,p)=>{const g=(0,u.allocWasmString)(o,c),_=(0,u.allocWasmString)(p,c);if(h._OrtAddSessionConfigEntry(f,g,_)!==0)throw new Error(`Can't set a session config entry: ${o} - ${p}`)}),[f,c]}catch(n){throw f!==0&&h._OrtReleaseSessionOptions(f),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=(u,d)=>{const a=(0,s.getInstance)(),h=a.lengthBytesUTF8(u)+1,f=a._malloc(h);return a.stringToUTF8(u,f,h),d.push(f),f}},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),u=i(4919),d=i(4983),a=i(6361);t.initOrt=(n,e)=>{const r=(0,a.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,a.getInstance)(),r=e._malloc(n.byteLength);return e.HEAPU8.set(n,r),[r,n.byteLength]},t.createSessionFinalize=(n,e)=>{const r=(0,a.getInstance)();let o=0,p=0,g=[];try{if([p,g]=(0,u.setSessionOptions)(e),o=r._OrtCreateSession(n[0],n[1],p),o===0)throw new Error("Can't create a session")}finally{r._free(n[0]),r._OrtReleaseSessionOptions(p),g.forEach(r._free)}const _=r._OrtGetInputCount(o),b=r._OrtGetOutputCount(o),y=[],w=[],T=[],S=[];for(let A=0;A<_;A++){const P=r._OrtGetInputName(o,A);if(P===0)throw new Error("Can't get an input name");w.push(P),y.push(r.UTF8ToString(P))}for(let A=0;A{const r=(0,t.createSessionAllocate)(n);return(0,t.createSessionFinalize)(r,e)},t.releaseSession=n=>{const e=(0,a.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],p=r[1],g=r[2];p.forEach(e._OrtFree),g.forEach(e._OrtFree),e._OrtReleaseSession(o),h.delete(n)};const f=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,p)=>{const g=(0,a.getInstance)(),_=h.get(n);if(!_)throw new Error("invalid session id");const b=_[0],y=_[1],w=_[2],T=e.length,S=o.length;let A=0,P=[];const x=[],M=[];try{[A,P]=(0,s.setRunOptions)(p);for(let D=0;Dg.HEAP32[xe++]=we);const se=g._OrtCreateTensor(f(R),J,Z,Ae,Y.length);if(se===0)throw new Error("Can't create a tensor");x.push(se)}finally{g.stackRestore(le)}}const N=g.stackSave(),z=g.stackAlloc(4*T),$=g.stackAlloc(4*T),C=g.stackAlloc(4*S),G=g.stackAlloc(4*S);try{let D=z/4,R=$/4,Y=C/4,V=G/4;for(let le=0;lePe*Be);if(we=c(Le),we==="string"){const Pe=[];let Be=be/4;for(let Ge=0;Ge{const e=(0,a.getInstance)(),r=h.get(n);if(!r)throw new Error("invalid session id");const o=r[0],p=e._OrtEndProfiling(o);if(p===0)throw new Error("Can't get an profile file name");e._OrtFree(p)},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(p,g,_,b){b===void 0&&(b=_);var y=Object.getOwnPropertyDescriptor(g,_);y&&!("get"in y?!g.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return g[_]}}),Object.defineProperty(p,b,y)}:function(p,g,_,b){b===void 0&&(b=_),p[b]=g[_]}),u=this&&this.__setModuleDefault||(Object.create?function(p,g){Object.defineProperty(p,"default",{enumerable:!0,value:g})}:function(p,g){p.default=g}),d=this&&this.__importStar||function(p){if(p&&p.__esModule)return p;var g={};if(p!=null)for(var _ in p)_!=="default"&&Object.prototype.hasOwnProperty.call(p,_)&&s(g,p,_);return u(g,p),g},a=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const h=d(i(6449)),f=a(i(932)),c=i(3474);let l,n=!1,e=!1,r=!1;const o=(p,g)=>g?p?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":p?"ort-wasm-simd.wasm":"ort-wasm.wasm";t.initializeWebAssembly=async p=>{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=p.initTimeout,_=p.numThreads,b=p.simd,y=_>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=b&&(()=>{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}})(),T=typeof p.wasmPaths=="string"?p.wasmPaths:void 0,S=o(!1,y),A=o(w,y),P=typeof p.wasmPaths=="object"?p.wasmPaths[A]:void 0;let x=!1;const M=[];if(g>0&&M.push(new Promise(N=>{setTimeout(()=>{x=!0,N()},g)})),M.push(new Promise((N,z)=>{const $=y?c:f.default,C={locateFile:(G,D)=>y&&G.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([i(4154)],{type:"text/javascript"})):G===S?P??(T??D)+A:D+G};if(y)if(typeof Blob>"u")C.mainScriptUrlOrBlob=h.join("/","ort-wasm-threaded.js");else{const G=`var ortWasmThreaded=(function(){var _scriptDir;return ${$.toString()}})();`;C.mainScriptUrlOrBlob=new Blob([G],{type:"text/javascript"})}$(C).then(G=>{e=!1,n=!0,l=G,N()},G=>{e=!1,r=!0,z(G)})})),await Promise.race(M),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 p;!n||e||r||(e=!0,(p=l.PThread)===null||p===void 0||p.terminateAllThreads(),l=void 0,e=!1,n=!1,r=!0)}},9710:(m,t,i)=>{i.d(t,{Z:()=>d});var s=i(477),u=i.n(s);function d(){return u()('/*!\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,u){var d=self||window;try{try{var a;try{a=new d.Blob([t])}catch{(a=new(d.BlobBuilder||d.WebKitBlobBuilder||d.MozBlobBuilder||d.MSBlobBuilder)).append(t),a=a.getBlob()}var h=d.URL||d.webkitURL,f=h.createObjectURL(a),c=new d[i](f,s);return h.revokeObjectURL(f),c}catch{return new d[i]("data:application/javascript,".concat(encodeURIComponent(t)),s)}}catch{if(!u)throw Error("Inline worker is not supported");return new d[i](u,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(u,d){this.low=0|u,this.high=0|d},s.Long.create=function(u,d){return u==0&&d==0?s.Long.ZERO:new s.Long(u,d)},s.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},s.Long.prototype.equals=function(u){return this.low==u.low&&this.high==u.high},s.Long.ZERO=new s.Long(0,0),s.Builder=function(u){if(u)d=u;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(u){this.force_defaults=u},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(u,d){u>this.minalign&&(this.minalign=u);for(var a=1+~(this.bb.capacity()-this.space+d)&u-1;this.space=0&&this.vtable[d]==0;d--);for(var a=d+1;d>=0;d--)this.addInt16(this.vtable[d]!=0?u-this.vtable[d]:0);this.addInt16(u-this.object_start);var h=(a+2)*s.SIZEOF_SHORT;this.addInt16(h);var f=0,c=this.space;e:for(d=0;d=0;c--)this.writeInt8(f.charCodeAt(c))}this.prep(this.minalign,s.SIZEOF_INT+h),this.addOffset(u),h&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},s.Builder.prototype.finishSizePrefixed=function(u,d){this.finish(u,d,!0)},s.Builder.prototype.requiredField=function(u,d){var a=this.bb.capacity()-u,h=a-this.bb.readInt32(a);if(this.bb.readInt16(h+d)==0)throw new Error("FlatBuffers: field "+d+" must be set")},s.Builder.prototype.startVector=function(u,d,a){this.notNested(),this.vector_num_elems=d,this.prep(s.SIZEOF_INT,u*d),this.prep(a,u*d)},s.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},s.Builder.prototype.createString=function(u){if(u instanceof Uint8Array)var d=u;else{d=[];for(var a=0;a=56320?f:(f<<10)+u.charCodeAt(a++)+-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),a=0;for(var c=this.space,l=this.bb.bytes();a>24},s.ByteBuffer.prototype.readUint8=function(u){return this.bytes_[u]},s.ByteBuffer.prototype.readInt16=function(u){return this.readUint16(u)<<16>>16},s.ByteBuffer.prototype.readUint16=function(u){return this.bytes_[u]|this.bytes_[u+1]<<8},s.ByteBuffer.prototype.readInt32=function(u){return this.bytes_[u]|this.bytes_[u+1]<<8|this.bytes_[u+2]<<16|this.bytes_[u+3]<<24},s.ByteBuffer.prototype.readUint32=function(u){return this.readInt32(u)>>>0},s.ByteBuffer.prototype.readInt64=function(u){return new s.Long(this.readInt32(u),this.readInt32(u+4))},s.ByteBuffer.prototype.readUint64=function(u){return new s.Long(this.readUint32(u),this.readUint32(u+4))},s.ByteBuffer.prototype.readFloat32=function(u){return s.int32[0]=this.readInt32(u),s.float32[0]},s.ByteBuffer.prototype.readFloat64=function(u){return s.int32[s.isLittleEndian?0:1]=this.readInt32(u),s.int32[s.isLittleEndian?1:0]=this.readInt32(u+4),s.float64[0]},s.ByteBuffer.prototype.writeInt8=function(u,d){this.bytes_[u]=d},s.ByteBuffer.prototype.writeUint8=function(u,d){this.bytes_[u]=d},s.ByteBuffer.prototype.writeInt16=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8},s.ByteBuffer.prototype.writeUint16=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8},s.ByteBuffer.prototype.writeInt32=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8,this.bytes_[u+2]=d>>16,this.bytes_[u+3]=d>>24},s.ByteBuffer.prototype.writeUint32=function(u,d){this.bytes_[u]=d,this.bytes_[u+1]=d>>8,this.bytes_[u+2]=d>>16,this.bytes_[u+3]=d>>24},s.ByteBuffer.prototype.writeInt64=function(u,d){this.writeInt32(u,d.low),this.writeInt32(u+4,d.high)},s.ByteBuffer.prototype.writeUint64=function(u,d){this.writeUint32(u,d.low),this.writeUint32(u+4,d.high)},s.ByteBuffer.prototype.writeFloat32=function(u,d){s.float32[0]=d,this.writeInt32(u,s.int32[0])},s.ByteBuffer.prototype.writeFloat64=function(u,d){s.float64[0]=d,this.writeInt32(u,s.int32[s.isLittleEndian?0:1]),this.writeInt32(u+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(u){return u+this.readInt32(u)},s.ByteBuffer.prototype.__vector=function(u){return u+this.readInt32(u)+s.SIZEOF_INT},s.ByteBuffer.prototype.__vector_len=function(u){return this.readInt32(u+this.readInt32(u))},s.ByteBuffer.prototype.__has_identifier=function(u){if(u.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=sharp??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.10.1",WEB_CACHE_AVAILABLE=typeof self<"u"&&"caches"in self,FS_AVAILABLE=!isEmpty(sharp),PATH_AVAILABLE=!isEmpty(sharp),RUNNING_LOCALLY=FS_AVAILABLE&&PATH_AVAILABLE,__dirname=RUNNING_LOCALLY?sharp.dirname(sharp.dirname(sharp.fileURLToPath(self.location.href))):"./",DEFAULT_CACHE_DIR=RUNNING_LOCALLY?sharp.join(__dirname,"/.cache/"):null,DEFAULT_LOCAL_MODEL_PATH="/models/",localModelPath=RUNNING_LOCALLY?sharp.join(__dirname,DEFAULT_LOCAL_MODEL_PATH):DEFAULT_LOCAL_MODEL_PATH;onnx_env.wasm.wasmPaths=RUNNING_LOCALLY?sharp.join(__dirname,"/dist/"):`https://cdn.jsdelivr.net/npm/@xenova/transformers@${VERSION}/dist/`;const env$1={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,useCustomCache:!1,customCache:null};function isEmpty(m){return Object.keys(m).length===0}var define_process_env_default={};globalThis.ReadableStream||(globalThis.ReadableStream=sharp.ReadableStream);class FileResponse{constructor(t){he(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=sharp.existsSync(t),this.exists){this.status=200,this.statusText="OK";let i=sharp.statSync(t);this.headers.set("content-length",i.size.toString()),this.updateContentType();let s=this;this.body=new ReadableStream({start(u){s.arrayBuffer().then(d=>{u.enqueue(new Uint8Array(d)),u.close()})}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const t=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("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=new Headers(this.headers),t}async arrayBuffer(){return(await sharp.promises.readFile(this.filePath)).buffer}async blob(){const t=await sharp.promises.readFile(this.filePath);return new Blob([t],{type:this.headers.get("content-type")})}async text(){return await sharp.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}}function isValidHttpUrl(m,t=null){let i;try{i=new URL(m)}catch{return!1}return t&&!t.includes(i.hostname)?!1:i.protocol==="http:"||i.protocol==="https:"}async function getFile(m){var t;if(env$1.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 i=!!(define_process_env_default!=null&&define_process_env_default.TESTING_REMOTELY),s=env$1.version,u=new Headers;if(u.set("User-Agent",`transformers.js/${s}; is_ci/${i};`),isValidHttpUrl(m,["huggingface.co","hf.co"])){const a=(define_process_env_default==null?void 0:define_process_env_default.HF_TOKEN)??(define_process_env_default==null?void 0:define_process_env_default.HF_ACCESS_TOKEN);a&&u.set("Authorization",`Bearer ${a}`)}return fetch(m,{headers:u})}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=sharp.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 u=sharp.join(this.path,t);try{await sharp.promises.mkdir(sharp.dirname(u),{recursive:!0}),await sharp.promises.writeFile(u,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 u;if(!u&&env$1.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{u=await caches.open("transformers-cache")}catch(_){console.warn("An error occurred while opening the browser cache:",_)}}if(!u&&env$1.useFSCache&&(u=new FileCache(s.cache_dir??env$1.cacheDir)),!u&&env$1.useCustomCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");const d=s.revision??"main";let a=pathJoin(m,t),h=pathJoin(env$1.localModelPath,a),f=pathJoin(env$1.remoteHost,env$1.remotePathTemplate.replaceAll("{model}",m).replaceAll("{revision}",d),t),c=d==="main"?a:pathJoin(m,d,t),l,n=u instanceof FileCache?c:f,e=!1,r;u&&(r=await tryCache(u,h,n));const o=r!==void 0;if(r===void 0){if(isValidHttpUrl(a)){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${a}.`)}else try{r=await getFile(h),l=h}catch(b){console.warn(`Unable to load from local path "${h}": "${b}"`)}if(r===void 0||r.status===404){if(s.local_files_only||!env$1.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(f),r.status!==200)return handleError(r.status,f,i);l=n}e=u&&typeof Response<"u"&&r instanceof Response&&r.status===200}dispatchCallback(s.progress_callback,{status:"download",name:m,file:t});const p={status:"progress",name:m,file:t};let g;return s.progress_callback?o&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent)?(g=new Uint8Array(await r.arrayBuffer()),dispatchCallback(s.progress_callback,{...p,progress:100,loaded:g.length,total:g.length})):g=await readResponse(r,_=>{dispatchCallback(s.progress_callback,{...p,..._})}):g=new Uint8Array(await r.arrayBuffer()),e&&l&&await u.match(l)===void 0&&await u.put(l,new Response(g,{headers:r.headers})).catch(_=>{console.warn(`Unable to add response to browser cache: ${_}.`)}),dispatchCallback(s.progress_callback,{status:"done",name:m,file:t}),g}async function getModelJSON(m,t,i=!0,s={}){let u=await getModelFile(m,t,i,s);if(u===null)return{};let a=new TextDecoder("utf-8").decode(u);return JSON.parse(a)}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"),u=new Uint8Array(s),d=0;const a=m.body.getReader();async function h(){const{done:f,value:c}=await a.read();if(f)return;let l=d+c.length;if(l>s){s=l;let e=new Uint8Array(s);e.set(u),u=e}u.set(c,d),d=l;const n=d/s*100;return t({progress:n,loaded:d,total:s}),h()}return await h(),u}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],[u,d],a="bilinear",h=!1){const f=d/s,c=u/i,l=new m.constructor(u*d*t),n=i*s,e=u*d;for(let r=0;r=0;--h)u[h]=f,s[h]=t[i[h]],f*=s[h];const d=i.map((h,f)=>u[i.indexOf(f)]),a=new m.constructor(m.length);for(let h=0;h=0;--c)f+=l%t[c]*d[c],l=Math.floor(l/t[c]);a[f]=m[h]}return[a,s]}function softmax(m){const t=max(m)[0],i=m.map(d=>Math.exp(d-t)),s=i.reduce((d,a)=>d+a,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 isPowerOfTwo(m){return m>0&&(m&m-1)===0}class P2FFT{constructor(t){if(this.size=t|0,this.size<=1||!isPowerOfTwo(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=t<<1,this.table=new Float64Array(this.size*2);for(let s=0;ss;s<<=1)++i;this._width=i%2===0?i-1:i,this._bitrev=new Int32Array(1<>>u&3)<>>1);for(let u=0;u>>1]=t[u];return s}toComplexArray(t,i){const s=i||this.createComplexArray();for(let u=0;u>>1],s[u+1]=0;return s}completeSpectrum(t){const i=this._csize,s=i>>>1;for(let u=2;u>=2;a>=2;a>>=2){h=u/a<<1;const n=h>>>2;for(f=0;f>>1,a>>>1)}else for(f=0,c=0;f>>1,a>>>1,s)}for(a>>=2;a>=2;a>>=2){h=u/a<<1;const n=h>>>2;for(f=0;f>1;++l){const n=(l+1-t)**2/2,e=Math.sqrt(f**2+c**2)**n,r=n*Math.atan2(c,f),o=2*l;d[o]=e*Math.cos(r),d[o+1]=e*Math.sin(r),a[o]=d[o],a[o+1]=-d[o+1]}this._slicedChirpBuffer=d.subarray(i,s),this._f=new P2FFT(u>>1),this._f.transform(this._chirpBuffer,a)}_transform(t,i,s){const u=this._buffer1,d=this._buffer2,a=this._outBuffer1,h=this._outBuffer2,f=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(s)for(let n=0;n>1,o=i[r];u[n]=o*c[n],u[e]=o*c[e]}else for(let n=0;n=m.length&&(f=2*(m.length-1)-f),s[a++]=m[f]}s.sort(),i[d]=s[u]}return i}function round(m,t){const i=Math.pow(10,t);return Math.round(m*i)/i}const DataTypeMap=new Map([["bool",Uint8Array],["float32",Float32Array],["float64",Float64Array],["string",Array],["int8",Int8Array],["uint8",Uint8Array],["int16",Int16Array],["uint16",Uint16Array],["int32",Int32Array],["uint32",Uint32Array],["int64",BigInt64Array]]),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 u=Number(s);if(Number.isInteger(u))return i._getitem(u)}return i[s]},set:(i,s,u)=>i[s]=u})}*[Symbol.iterator](){const[t,...i]=this.dims;if(i.length>0){const s=i.reduce((u,d)=>u*d);for(let u=0;u0){const u=s.reduce((d,a)=>d*a);return this._subarray(t,u,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[f])];s.push(l),i.push(l[1]-l[0])}else throw new Error(`Invalid slice: ${c}`)}let u=s.map(([f,c])=>c-f),d=u.reduce((f,c)=>f*c),a=new this.data.constructor(d);const h=this.stride();for(let f=0;f=0;--l){const e=u[l];c+=(n%e+s[l][0])*h[l],n=Math.floor(n/e)}a[f]=this.data[c]}return new Tensor(this.type,a,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 a=this.data.reduce((h,f)=>h+f**t,0)**(1/t);return new Tensor(this.type,[a],[])}i=safeIndex(i,this.dims.length);const u=this.dims.slice();u[i]=1;const d=new this.data.constructor(this.data.length/this.dims[i]);for(let a=0;a=0;--f){const n=this.dims[f];if(f!==i){const e=c%n;h+=e*l,l*=u[f]}c=Math.floor(c/n)}d[h]+=this.data[a]**t}if(t!==1)for(let a=0;a=0;--a){const c=this.dims[a];if(a!==i){const l=h%c;d+=l*f,f*=this.dims[a]}h=Math.floor(h/c)}this.data[u]/=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),u=this.dims.slice(t,i+1),d=this.dims.slice(i+1);return this.dims=[...s,u.reduce((a,h)=>a*h,1),...d],this}flatten(t=0,i=-1){return this.clone().flatten_(t,i)}view(...t){let i=-1;for(let s=0;sa!==i?u*d:u,1);t[i]=this.data.length/s}return new Tensor(this.type,this.data,t)}neg_(){for(let t=0;td*a);if(i!==s)throw Error(`cannot reshape array of size ${i} into shape (${t})`);let u=m;for(let d=t.length-1;d>=0;d--)u=u.reduce((a,h)=>{let f=a[a.length-1];return f.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((a,h)=>a+h.dims[t],0);const s=i.reduce((a,h)=>a*h,1),u=new m[0].data.constructor(s),d=m[0].type;if(t===0){let a=0;for(let h of m)u.set(h.data,a),a+=h.data.length}else{let a=0;for(let h=0;h=0;--n){const o=f.dims[n];let p=e%o;n===t&&(p+=a),l+=p*r,r*=i[n],e=Math.floor(e/o)}u[l]=f.data[c]}a+=f.dims[t]}}return new Tensor(d,u,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 u=mean(m,t,s),d=m.dims.slice();d[t]=1;const a=new m.data.constructor(m.data.length/m.dims[t]);for(let f=0;f=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)}a[c]+=(m.data[f]-u.data[c])**2}for(let f=0;fa+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 u=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=f%l;a+=n*c,c*=s[h]}f=Math.floor(f/l)}u[a]+=m.data[d]}if(m.dims[t]!==1)for(let d=0;d0||h>0;)switch(f.push(a-1),c.push(h-1),d[a][h].item()){case 0:--a,--h;break;case 1:--a;break;case 2:--h;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${h}]. Please file a bug report.`)}return f.reverse(),c.reverse(),[f,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}function ones(m){const t=m.reduce((i,s)=>i*s,1);return new Tensor("int64",new BigInt64Array(t).fill(1n),m)}function ones_like(m){return ones(m.dims)}class PriorityQueue{constructor(t=(i,s)=>i>s){this._heap=[],this._comparator=t}get size(){return this._heap.length}isEmpty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(const i of t)this._heap.push(i),this._siftUp();return this.size}pop(){const t=this.peek(),i=this.size-1;return i>0&&this._swap(0,i),this._heap.pop(),this._siftDown(),t}replace(t){const i=this.peek();return this._heap[0]=t,this._siftDown(),i}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,i){return this._comparator(this._heap[t],this._heap[i])}_swap(t,i){const s=this._heap[t];this._heap[t]=this._heap[i],this._heap[i]=s}_siftUp(){let t=this.size-1;for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_siftDown(){let t=0;for(;this._left(t)[]),this.endNodes=Array.from({length:this.len+1},()=>[]);const u=new TokenLatticeNode(this.bosTokenId,0,0,0,0),d=new TokenLatticeNode(this.eosTokenId,1,this.len,0,0);this.nodes.push(u.clone()),this.nodes.push(d.clone()),this.beginNodes[this.len].push(d),this.endNodes[0].push(u)}insert(t,i,s,u){const d=this.nodes.length,a=new TokenLatticeNode(u,d,t,i,s);this.beginNodes[t].push(a),this.endNodes[t+i].push(a),this.nodes.push(a)}viterbi(){const t=this.len;let i=0;for(;i<=t;){if(this.beginNodes[i].length==0)return[];for(let h of this.beginNodes[i]){h.prev=null;let f=0,c=null;for(let l of this.endNodes[i]){const n=l.backtraceScore+h.score;(c===null||n>f)&&(c=l.clone(),f=n)}if(c!==null)h.prev=c,h.backtraceScore=f;else return[]}++i}const s=[],d=this.beginNodes[t][0].prev;if(d===null)return[];let a=d.clone();for(;a.prev!==null;)s.push(a.clone()),a=a.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,u,d){this.tokenId=t,this.nodeId=i,this.pos=s,this.length=u,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}}async function loadTokenizer(m,t){return await Promise.all([getModelJSON(m,"tokenizer.json",!0,t),getModelJSON(m,"tokenizer_config.json",!0,t)])}function regexSplit(m,t){const i=[];let s=0;for(const u of m.matchAll(t)){const d=u[0];s0&&i.push(d),s=u.index+d.length}return 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=objectToMap(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,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 u=[...s];if(u.length>this.max_input_chars_per_word){i.push(this.unk_token);continue}let d=!1,a=0,h=[];for(;a0&&(l=this.config.continuing_subword_prefix+l),this.tokens_to_ids.has(l)){c=l;break}--f}if(c===null){d=!0;break}h.push(c),a=f}d?i.push(this.unk_token):i.push(...h)}return i}}class Unigram extends TokenizerModel{constructor(t,i){super(t);const s=t.vocab.length;this.vocab=new Array(s),this.scores=new Array(s);for(let u=0;u[u,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 u=0;for(;u{const m=[...Array.from({length:94},(u,d)=>d+33),...Array.from({length:12},(u,d)=>d+161),...Array.from({length:82},(u,d)=>d+174)];let t=m.slice(),i=0;for(let u=0;u<256;++u)m.includes(u)||(m.push(u),t.push(256+i),i+=1);let s=t.map(u=>String.fromCharCode(u));return Object.fromEntries(m.map((u,d)=>[u,s[d]]))})(),UNICODE_TO_BYTES=reverseDictionary(BYTES_TO_UNICODE);class BPE extends TokenizerModel{constructor(t){super(t),this.BPE_SPLIT_TOKEN=" ",this.tokens_to_ids=objectToMap(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=new Map(t.merges.map((i,s)=>[i,s])),this.merges=t.merges.map(i=>i.split(this.BPE_SPLIT_TOKEN)),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.cache=new Map}bpe(t){if(t.length===0)return[];const i=this.cache.get(t);if(i!==void 0)return i;const s=Array.from(t);this.end_of_word_suffix&&(s[s.length-1]+=this.end_of_word_suffix);let u=[];if(s.length>1){const d=new PriorityQueue((f,c)=>f.score`<0x${a.toString(16).toUpperCase().padStart(2,"0")}>`)):i.push(this.unk_token)}return i}}class LegacyTokenizerModel extends TokenizerModel{constructor(t,i){super(t),this.tokens_to_ids=objectToMap(i.target_lang?t.vocab[i.target_lang]:t.vocab),this.bos_token=i.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=i.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=i.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=i.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(const[s,u]of this.tokens_to_ids)this.vocab[u]=s}encode(t){return t}}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"NFKC":return new NFKC(t);case"NFKD":return new NFKD(t);case"Strip":return new StripNormalizer(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 NFKC extends Normalizer{normalize(t){return t=t.normalize("NFKC"),t}}class NFKD extends Normalizer{normalize(t){return t=t.normalize("NFKD"),t}}class StripNormalizer extends Normalizer{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}}class StripAccents extends Normalizer{normalize(t){return t=remove_accents(t),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);case"Replace":return new ReplacePreTokenizer(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=new RegExp("'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.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(s=>Array.from(this.text_encoder.encode(s),u=>this.byte_encoder[u]).join(""))}}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)||[]:regexSplit(t,this.pattern)}}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);case"BertProcessing":return new BertProcessing(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 BertProcessing 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 RobertaProcessing extends BertProcessing{}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,u=[];for(let d of s)"SpecialToken"in d?u.push(d.SpecialToken.id):"Sequence"in d&&(d.Sequence.id==="A"?u=mergeArrays(u,t):d.Sequence.id==="B"&&(u=mergeArrays(u,i)));return u}}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);case"CTC":return new CTCDecoder(t);case"BPEDecoder":return new BPEDecoder(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{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 u of t){let d=null;if(u.length===6&&u.startsWith("<0x")&&u.endsWith(">")){let a=parseInt(u.slice(3,5),16);isNaN(a)||(d=a)}if(d!==null)s.push(d);else{if(s.length>0){let a=this.text_decoder.decode(Uint8Array.from(s));i.push(a),s=[]}i.push(u)}}if(s.length>0){let u=this.text_decoder.decode(Uint8Array.from(s));i.push(u),s=[]}return i}}class FuseDecoder extends Decoder{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 u of t)this.added_tokens.includes(u)?(s.length>0&&(i.push(this.convert_tokens_to_string(s)),s=[]),i.push(u)):s.push(u);return s.length>0&&i.push(this.convert_tokens_to_string(s)),i}}class CTCDecoder extends Decoder{constructor(t){super(t),this.pad_token=this.config.pad_token,this.word_delimiter_token=this.config.word_delimiter_token,this.cleanup=this.config.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let i=[t[0]];for(let d=1;dd!==this.pad_token).join("");return this.cleanup&&(u=clean_up_tokenization(u).replaceAll(this.word_delimiter_token," ").trim()),u}decode_chain(t){return[this.convert_tokens_to_string(t)]}}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 BPEDecoder extends Decoder{constructor(t){super(t),this.suffix=this.config.suffix}decode_chain(t){return t.map((i,s)=>i.replaceAll(this.suffix,s===t.length-1?"":" "))}}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 u=s.replaceAll(" ",this.strRep);this.addPrefixSpace&&!u.startsWith(this.replacement)&&(u=this.strRep+u),i.push(u)}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;ss.normalize("NFKC")).join("~"):t=t.normalize("NFKC"),t}}class PreTokenizerSequence extends PreTokenizer{constructor(t){super(),this.tokenizers=t.pretokenizers.map(i=>PreTokenizer.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 ReplacePreTokenizer extends PreTokenizer{constructor(t){super(),this.config=t,this.pattern=createPattern(this.config.pattern),this.content=this.config.content}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content)]}}class PreTrainedTokenizer extends Callable{constructor(t,i){super(),this.normalizer=Normalizer.fromConfig(t.normalizer),this.pre_tokenizer=PreTokenizer.fromConfig(t.pre_tokenizer),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 u=s.id,d=s.content;this.added_tokens.push(d),this.model.tokens_to_ids.set(d,u),this.model.vocab[u]=d,s.special&&(this.special_tokens.push(d),this.all_special_ids.push(u))}this.special_tokens.push(...i.additional_special_tokens??[]),this.special_tokens=[...new Set(this.special_tokens)],this.decoder.added_tokens=this.added_tokens,this.added_tokens_regex=this.added_tokens.length>0?new RegExp("("+this.added_tokens.map(escapeRegExp).join("|")+")"):null,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.unk_token=this.getToken(i,"unk_token"),this.unk_token_id=this.model.tokens_to_ids.get(this.unk_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.do_lowercase_and_remove_accent=i.do_lowercase_and_remove_accent??!1,this.padding_side="right"}getToken(t,...i){for(let s of i){let u=t[s];if(u)if(typeof u=="object"){if(u.__type==="AddedToken")return u.content;throw Error(`Unknown token: ${u}`)}else return u}return null}static async from_pretrained(t,{progress_callback:i=null,config:s=null,cache_dir:u=null,local_files_only:d=!1,revision:a="main"}={}){let h=await loadTokenizer(t,{progress_callback:i,config:s,cache_dir:u,local_files_only:d,revision:a});return new this(...h)}prepare_model_inputs(t){return t}_call(t,{text_pair:i=null,add_special_tokens:s=!0,padding:u=!1,truncation:d=null,max_length:a=null,return_tensor:h=!0}={}){let f;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");f=t.map((e,r)=>this.encode(e,i[r],{add_special_tokens:s}))}else f=t.map(e=>this.encode(e,null,{add_special_tokens:s}))}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).");f=[this.encode(t,i,{add_special_tokens:s})]}let c=max(f.map(e=>e.length))[0];a===null&&(a=c),a=Math.min(a,this.model_max_length);let l=[];if(u||d)for(let e=0;ea)d&&(f[e]=f[e].slice(0,a)),l.push(new Array(f[e].length).fill(1));else if(u){let r=a-f[e].length;this.padding_side==="right"?(l.push(new Array(f[e].length).fill(1).concat(new Array(r).fill(0))),f[e].push(...new Array(r).fill(this.pad_token_id))):(l.push(new Array(r).fill(0).concat(new Array(f[e].length).fill(1))),f[e].unshift(...new Array(r).fill(this.pad_token_id)))}else l.push(new Array(f[e].length).fill(1));else l=f.map(e=>new Array(e.length).fill(1));if(h){if(!(u&&d)&&f.some(r=>r.length!==f[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 e=[f.length,f[0].length];f=new Tensor("int64",BigInt64Array.from(f.flat().map(BigInt)),e),l=new Tensor("int64",BigInt64Array.from(l.flat().map(BigInt)),e)}else Array.isArray(t)||(f=f[0],l=l[0]);let n={input_ids:f,attention_mask:l};return n=this.prepare_model_inputs(n),n}_encode_text(t){return t===null?null:(this.added_tokens_regex?t.split(this.added_tokens_regex).filter(u=>u):[t]).map(u=>{if(this.added_tokens.includes(u))return u;{this.remove_space===!0&&(u=u.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(u=lowercase_and_remove_accent(u)),this.normalizer!==null&&(u=this.normalizer(u));let d=this.pre_tokenizer!==null?this.pre_tokenizer(u):[u];return this.model(d)}}).flat()}encode(t,i=null,{add_special_tokens:s=!0}={}){let u=this._encode_text(t),d=this._encode_text(i),a=this.post_processor!==null&&s?this.post_processor(u,d):mergeArrays(u??[],d??[]);return this.model.convert_tokens_to_ids(a)}batch_decode(t,i={}){return t instanceof Tensor&&(t=t.tolist()),t.map(s=>this.decode(s,i))}decode(t,i={}){if(t instanceof Tensor&&(t=prepareTensorForDecode(t)),!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 u=this.model.convert_ids_to_tokens(t);i&&(u=u.filter(a=>!this.special_tokens.includes(a)));let d=this.decoder(u);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 DebertaTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DebertaV2Tokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class HerbertTokenizer extends PreTrainedTokenizer{prepare_model_inputs(t){return add_token_types(t)}}class DistilBertTokenizer extends PreTrainedTokenizer{}class CamembertTokenizer extends PreTrainedTokenizer{}class XLMTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),console.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}prepare_model_inputs(t){return add_token_types(t)}}class T5Tokenizer extends PreTrainedTokenizer{}class GPT2Tokenizer extends PreTrainedTokenizer{}class BartTokenizer extends PreTrainedTokenizer{}class MBartTokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}class MBart50Tokenizer extends MBartTokenizer{}class RobertaTokenizer extends PreTrainedTokenizer{}class BloomTokenizer extends PreTrainedTokenizer{constructor(t,i){var d,a;const s=".,!?…。,、।۔،",u=(a=(d=t.pre_tokenizer)==null?void 0:d.pretokenizers[0])==null?void 0:a.pattern;u&&u.Regex===` ?[^(\\s|[${s}])]+`&&(u.Regex=` ?[^\\s${s}]+`),super(t,i)}}class LlamaTokenizer extends PreTrainedTokenizer{}class CodeLlamaTokenizer extends PreTrainedTokenizer{}class XLMRobertaTokenizer extends PreTrainedTokenizer{}class MPNetTokenizer extends PreTrainedTokenizer{}class FalconTokenizer extends PreTrainedTokenizer{}class GPTNeoXTokenizer extends PreTrainedTokenizer{}function _build_translation_inputs(m,t,i,s){if(!("language_codes"in m)||!Array.isArray(m.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in m)||!(m.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in m)||typeof m.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");const u=s.src_lang,d=s.tgt_lang;if(!m.language_codes.includes(d))throw new Error(`Target language code "${d}" is not valid. Must be one of: {${m.language_codes.join(", ")}}`);if(u!==void 0){if(!m.language_codes.includes(u))throw new Error(`Source language code "${u}" is not valid. Must be one of: {${m.language_codes.join(", ")}}`);for(let a of m.post_processor.config.single)if("SpecialToken"in a&&m.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=m.lang_to_token(u);break}}return s.forced_bos_token_id=m.model.convert_tokens_to_ids([m.lang_to_token(d)])[0],m._call(t,i)}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)),this.lang_to_token=s=>s}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}class M2M100Tokenizer extends PreTrainedTokenizer{constructor(t,i){super(t,i),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s.slice(2,-2)),this.lang_to_token=s=>`__${s}__`}_build_translation_inputs(t,i,s){return _build_translation_inputs(this,t,i,s)}}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:u=null,force_full_sequences:d=!0}={}){if(u===null)throw Error("Must specify time_precision");let a=null;const h=i==="word";function f(){return{language:a,timestamp:[null,null],text:""}}const c=[];let l=f(),n=0;const e=this.model.convert_tokens_to_ids(["<|notimestamps|>"])[0]+1;let r=[],o=[],p=!1,g=null;const _=new Set(this.all_special_ids);for(let w of t){const T=w.tokens,S=h?w.token_timestamps:null;let A=null,P=e;if("stride"in w){const[N,z,$]=w.stride;if(n-=z,g=N-$,z&&(P=z/u+e),$)for(let C=T.length-1;C>=0;--C){const G=T[C];if(G>=e){if(A!==null&&(G-e)*u=e){const $=(z-e)*u+n,C=round($,2);if(A!==null&&z>=A)p=!0;else if(p||r.length>0&&z0?(r.push(x),h&&o.push(M)):r.every(N=>N.length===0)&&(l=f(),r=[],x=[],o=[],M=[])}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,T]=this.findLongestCommonSequence(r,o),S=this.decode(w);l.text=S,h&&(l.words=this.collateWordTimestamps(w,T,a)),c.push(l)}let b=Object.create(null);const y=c.map(w=>w.text).join("");if(i||s){for(let w=0;w0;let h=a?[]:null,f=a?i[0]:null;for(let c=1;cC===N[G]).length,$=z/w+T;z>1&&$>n&&(n=$,e=[S,A,x,M])}const[o,p,g,_]=e,b=Math.floor((p+o)/2),y=Math.floor((_+g)/2);d.push(...s.slice(0,b)),s=l.slice(y),u=s.length,a&&(h.push(...f.slice(0,b)),f=i[c].slice(y))}return d.push(...s),a?(h.push(...f),[d,h]):[d,[]]}collateWordTimestamps(t,i,s){let[u,d,a]=this.combineTokensIntoWords(t,s),h=[];for(let f=0;f=u){let h=(a-u)*s;h=round(h,2),d.push(`<|${h}|>`),d.push([])}else d[d.length-1].push(a);return d=d.map(a=>typeof a=="string"?a:super.decode(a,i)),d.join("")}splitTokensOnUnicode(t){const i=this.decode(t,{decode_with_timestamps:!0}),s="�";let u=[],d=[],a=[],h=[],f=[],c=0;for(let l=0;l=this.model.tokens_to_ids.get("<|endoftext|>"),o=l.startsWith(" "),p=l.trim(),g=f.test(p);if(r||o||g||d.length===0)d.push(l),a.push(n),h.push(e);else{const _=d.length-1;d[_]+=l,a[_].push(...n),h[_].push(...e)}}return[d,a,h]}mergePunctuations(t,i,s,u,d){let a=structuredClone(t),h=structuredClone(i),f=structuredClone(s),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(" ")&&u.includes(a[c].trim())?(a[l]=a[c]+a[l],h[l]=mergeArrays(h[c],h[l]),f[l]=mergeArrays(f[c],f[l]),a[c]="",h[c]=[],f[c]=[]):l=c,--c;for(c=0,l=1;ln),h.filter(n=>n.length>0),f.filter(n=>n.length>0)]}get_decoder_prompt_ids({language:t=null,task:i=null,no_timestamps:s=!0}={}){let u=[];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 f=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(f)}`)}let a=this.model.tokens_to_ids.get(`<|${d}|>`);if(a===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.`);u.push(a)}else u.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.`);u.push(d)}else u.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.');u.push(d)}return u.map((d,a)=>[a+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[u,d]=s;return this.supported_language_codes.includes(u)||console.warn(`Unsupported language code "${u}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),mergeArrays([u],super._encode_text(d))}}}class Wav2Vec2CTCTokenizer extends PreTrainedTokenizer{}class BlenderbotTokenizer extends PreTrainedTokenizer{}class BlenderbotSmallTokenizer extends PreTrainedTokenizer{}class SpeechT5Tokenizer extends PreTrainedTokenizer{}class NougatTokenizer extends PreTrainedTokenizer{}class AutoTokenizer{static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main"}={}){let[f,c]=await loadTokenizer(t,{quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,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(f,c)}}he(AutoTokenizer,"TOKENIZER_CLASS_MAPPING",{T5Tokenizer,DistilBertTokenizer,CamembertTokenizer,DebertaTokenizer,DebertaV2Tokenizer,BertTokenizer,HerbertTokenizer,XLMTokenizer,MobileBertTokenizer,SqueezeBertTokenizer,AlbertTokenizer,GPT2Tokenizer,BartTokenizer,MBartTokenizer,MBart50Tokenizer,RobertaTokenizer,WhisperTokenizer,CodeGenTokenizer,CLIPTokenizer,MarianTokenizer,BloomTokenizer,NllbTokenizer,M2M100Tokenizer,LlamaTokenizer,CodeLlamaTokenizer,XLMRobertaTokenizer,MPNetTokenizer,FalconTokenizer,GPTNeoXTokenizer,Wav2Vec2CTCTokenizer,BlenderbotTokenizer,BlenderbotSmallTokenizer,SpeechT5Tokenizer,NougatTokenizer,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:u=null,local_files_only:d=!1,revision:a="main"}={}){let h=s??await loadConfig(t,{progress_callback:i,config:s,cache_dir:u,local_files_only:d,revision:a});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(u=>u(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),u=s.length>=1&&s[s.length-1]>=this.timestamp_begin,d=s.length<2||s[s.length-2]>=this.timestamp_begin;if(u&&(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 a=log_softmax(i.data),h=Math.log(a.subarray(this.timestamp_begin).map(Math.exp).reduce((c,l)=>c+l)),f=max(a.subarray(0,this.timestamp_begin))[0];return h>f&&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&&(u=u.map(d=>d/this.generation_config.temperature)),u}randomSelect(t){let i=t.reduce((u,d)=>u+d,0),s=Math.random()*i;for(let u=0;u1)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 u=this.getLogits(t,i),d=getTopItems(u,s),a=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},()=>{const h=this.randomSelect(a);return[d[h][0],Math.log(a[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 u=this.getLogits(t,i),d=getTopItems(u,s),a=softmax(d.map(h=>h[1]));return Array.from({length:this.generation_config.num_beams},(h,f)=>[d[f][0],Math.log(a[f])])}}const{InferenceSession,Tensor:ONNXTensor,env}=ONNX,MODEL_TYPES={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4},MODEL_TYPE_MAPPING=new Map,MODEL_NAME_TO_CLASS_MAPPING=new Map,MODEL_CLASS_TO_NAME_MAPPING=new Map;async function constructSession(m,t,i){let s=`onnx/${t}${i.quantized?"_quantized":""}.onnx`,u=await getModelFile(m,s,!0,i);try{return await InferenceSession.create(u,{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(u,{executionProviders:["wasm"]})}}function validateInputs(m,t){const i=Object.create(null),s=[];for(const a of m.inputNames){const h=t[a];if(!(h instanceof Tensor)){s.push(a);continue}i[a]=env.wasm.proxy?h.clone():h}if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);const u=Object.keys(t).length,d=m.inputNames.length;if(u>d){let a=Object.keys(t).filter(h=>!m.inputNames.includes(h));console.warn(`WARNING: Too many inputs were provided (${u} > ${d}). The following inputs will be ignored: "${a.join(", ")}".`)}return i}async function sessionRun(m,t){const i=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 u=t.indexOf(i)!==-1,d=s===null||!s.includes(i);if(u&&d){let a=BigInt64Array.from(t.data.map(h=>h!=i));return new Tensor("int64",a,t.dims)}else return ones_like(t)}function preparePositionIds(m,t,i){if(!m.inputNames.includes("position_ids"))return;const s=new BigInt64Array(t.attention_mask.data.length);for(let u=0;u0&&d.push(new NoRepeatNGramLogitsProcessor(i.no_repeat_ngram_size)),i.bad_words_ids!==null&&d.push(new NoBadWordsLogitsProcessor(i.bad_words_ids,i.eos_token_id)),i.min_length!==null&&i.eos_token_id!==null&&i.min_length>0&&d.push(new MinLengthLogitsProcessor(i.min_length,i.eos_token_id)),i.min_new_tokens!==null&&i.eos_token_id!==null&&i.min_new_tokens>0&&d.push(new MinNewTokensLengthLogitsProcessor(s,i.min_new_tokens,i.eos_token_id)),i.forced_bos_token_id!==null&&d.push(new ForcedBOSTokenLogitsProcessor(i.forced_bos_token_id)),i.forced_eos_token_id!==null&&d.push(new ForcedEOSTokenLogitsProcessor(i.max_length,i.forced_eos_token_id)),i.begin_suppress_tokens!==null){let a=s>1||i.forced_bos_token_id===null?s:s+1;i.forced_decoder_ids!==null&&(a+=i.forced_decoder_ids[i.forced_decoder_ids.length-1][0]),d.push(new SuppressTokensAtBeginLogitsProcessor(i.begin_suppress_tokens,a))}return i.forced_decoder_ids!==null&&d.push(new ForceTokensLogitsProcessor(i.forced_decoder_ids)),u!==null&&d.extend(u),d}_get_generation_config(i){let s=new GenerationConfig(this.config);return"generation_config"in this&&Object.assign(s,this.generation_config),i!==null&&Object.assign(s,i),s}async generate(i,s=null,u=null,{inputs_attention_mask:d=null}={}){if(!this.can_generate){let _=`The current model class (${MODEL_CLASS_TO_NAME_MAPPING.get(this.constructor)}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;const b=this.config.model_type,y=MODEL_WITH_LM_HEAD_MAPPING_NAMES.get(b)??MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES.get(b)??MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.get(b)??MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES.get(b);throw y&&(_+=` Please use the following class instead: '${y[0]}'`),Error(_)}if(!(i instanceof Tensor)&&!isTypedArray(i)&&!Array.isArray(i))throw Error(`\`inputs\` must be a Tensor, TypedArray, or Array, but is "${i.constructor.name}".`);let a;if(this.config.is_encoder_decoder)a=0;else if(a=i instanceof Tensor?i.dims.at(-1):i.length,a===0)throw Error("Must supply a non-empty array of input token ids.");s=this._get_generation_config(s),u=u??new LogitsProcessorList,u=this._get_logits_processor(s,a,u);let h=s.eos_token_id;h!==null&&!Array.isArray(h)&&(h=[h]);let f=1;const c=f+(s.max_new_tokens??1/0),l=Number.isInteger(s.max_length)&&(s.max_new_tokens??null)===null;let n=Sampler.getSampler(s),e=this.getStartBeams(i,s,f,d);for(;e.some(g=>!g.done)&&f=s.max_length){_.done=!0,g.push(_);continue}let b=await this.runBeam(_);s.output_attentions&&this.addAttentionsToBeam(_,b),s.output_scores;let y=b.logits.slice(null,-1,null);u(_.output_token_ids,y);let w=n(y);for(let[T,S]of w){let A={..._};this.updateBeam(A,T),A.score+=S,h&&h.includes(T)&&(A.done=!0),g.push(A)}}++f,g=this.groupBeams(g).map(_=>_.sort((b,y)=>y.score-b.score).slice(0,s.num_beams)),e=g.flat(),s.callback_function&&s.callback_function(e)}const r=this.groupBeams(e),o=g=>r.map(_=>s.num_return_sequences>1?_.slice(0,s.num_return_sequences).map(b=>b[g]):[_[0][g]]).flat(),p=o("output_token_ids");if(s.return_dict_in_generate){const g=o("decoder_attentions"),_=o("cross_attentions");return{sequences:p,decoder_attentions:g,cross_attentions:_}}else return p}addAttentionsToBeam(i,s){if(this.config.is_encoder_decoder){if(!s.cross_attentions||s.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`.");i.cross_attentions||(i.cross_attentions=[]),i.cross_attentions.push(s.cross_attentions)}if(!s.decoder_attentions||s.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`.");i.decoder_attentions||(i.decoder_attentions=[]),i.decoder_attentions.push(s.decoder_attentions)}groupBeams(i){const s=Object.create(null);for(const u of i)s[u.id]===void 0?s[u.id]=[u]:s[u.id].push(u);return Object.values(s)}getPastKeyValues(i,s){const u=Object.create(null);for(const d in i)if(d.startsWith("present")){let a=d.replace("present","past_key_values");s&&d.includes("encoder")?u[a]=s[a]:u[a]=i[d]}return u}getAttentions(i){const s=Object.create(null);for(const u of["cross_attentions","decoder_attentions"]){const d=[];for(const a in i)if(a.startsWith(u)){const h=a.split(".").pop();d[h]=i[a]}s[u]=d}return s}addPastKeyValues(i,s){if(s)Object.assign(i,s);else if(this.config.is_encoder_decoder&&(this.add_encoder_pkv??!0)){let d=[1,this.num_encoder_heads,0,this.encoder_dim_kv],a=[1,this.num_decoder_heads,0,this.decoder_dim_kv];for(let h=0;h{let n=Array.from({length:this.config.decoder_layers},(_,b)=>cat(l.map(y=>y[b]),2)),e=stack(s.map(([_,b])=>u?n[_].slice(null,b,null,[0,u]):n[_].slice(null,b)));e=e.transpose(1,0,2,3);let[r,o]=std_mean(e,-2,0,!0),p=e.clone();for(let _=0;_e[b+1]-e[b]),p=mergeArrays([1],o).map(_=>!!_),g=[];for(let _=0;_=e&&(Array.from(A.data).filter(x=>x>=s).length>0||_>=n))break}const b=cat(o),{waveform:y}=await sessionRun(a.session,{spectrogram:b});return{spectrogram:b,waveform:y}}}class SpeechT5HifiGan extends PreTrainedModel{constructor(){super(...arguments);he(this,"main_input_name","spectrogram")}}class TrOCRPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_encoder_layers=this.num_decoder_layers=this.config.decoder_layers,this.num_encoder_heads=this.num_decoder_heads=this.config.decoder_attention_heads,this.encoder_dim_kv=this.decoder_dim_kv=this.config.d_model/this.num_decoder_heads}}class TrOCRForCausalLM extends TrOCRPreTrainedModel{}class MistralPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_key_value_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class MistralModel extends MistralPreTrainedModel{}class MistralForCausalLM extends MistralPreTrainedModel{}class FalconPreTrainedModel extends PreTrainedModel{constructor(t,i,s){super(t,i),this.generation_config=s,this.config.pad_token_id=this.config.eos_token_id,this.num_heads=this.config.num_attention_heads,this.num_layers=this.config.num_hidden_layers,this.dim_kv=this.config.hidden_size/this.config.num_attention_heads}}class FalconModel extends FalconPreTrainedModel{}class FalconForCausalLM extends FalconPreTrainedModel{}class ClapPreTrainedModel extends PreTrainedModel{}class ClapModel extends ClapPreTrainedModel{}class ClapTextModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(t,i={}){return i.model_file_name??(i.model_file_name="text_model"),super.from_pretrained(t,i)}}class ClapAudioModelWithProjection extends ClapPreTrainedModel{static async from_pretrained(t,i={}){return i.model_file_name??(i.model_file_name="audio_model"),super.from_pretrained(t,i)}}class PretrainedMixin{static async from_pretrained(t,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main",model_file_name:f=null}={}){let c={quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,revision:h,model_file_name:f};if(u=await AutoConfig.from_pretrained(t,c),c.config||(c.config=u),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);for(let l of this.MODEL_CLASS_MAPPINGS){const n=l.get(u.model_type);if(n)return await n[1].from_pretrained(t,c)}if(this.BASE_IF_FAIL)return console.warn(`Unknown model class "${u.model_type}", attempting to construct from base class.`),await PreTrainedModel.from_pretrained(t,c);throw Error(`Unsupported model type: ${u.model_type}`)}}he(PretrainedMixin,"MODEL_CLASS_MAPPINGS",null),he(PretrainedMixin,"BASE_IF_FAIL",!1);const MODEL_MAPPING_NAMES_ENCODER_ONLY=new Map([["bert",["BertModel",BertModel]],["camembert",["CamembertModel",CamembertModel]],["deberta",["DebertaModel",DebertaModel]],["deberta-v2",["DebertaV2Model",DebertaV2Model]],["mpnet",["MPNetModel",MPNetModel]],["albert",["AlbertModel",AlbertModel]],["distilbert",["DistilBertModel",DistilBertModel]],["roberta",["RobertaModel",RobertaModel]],["xlm",["XLMModel",XLMModel]],["xlm-roberta",["XLMRobertaModel",XLMRobertaModel]],["clap",["ClapModel",ClapModel]],["clip",["CLIPModel",CLIPModel]],["mobilebert",["MobileBertModel",MobileBertModel]],["squeezebert",["SqueezeBertModel",SqueezeBertModel]],["wav2vec2",["Wav2Vec2Model",Wav2Vec2Model]],["wavlm",["WavLMModel",WavLMModel]],["audio-spectrogram-transformer",["ASTModel",ASTModel]],["detr",["DetrModel",DetrModel]],["vit",["ViTModel",ViTModel]],["mobilevit",["MobileViTModel",MobileViTModel]],["owlvit",["OwlViTModel",OwlViTModel]],["beit",["BeitModel",BeitModel]],["deit",["DeiTModel",DeiTModel]],["convnext",["ConvNextModel",ConvNextModel]],["convnextv2",["ConvNextV2Model",ConvNextV2Model]],["resnet",["ResNetModel",ResNetModel]],["swin",["SwinModel",SwinModel]],["swin2sr",["Swin2SRModel",Swin2SRModel]],["donut-swin",["DonutSwinModel",DonutSwinModel]],["yolos",["YolosModel",YolosModel]],["dpt",["DPTModel",DPTModel]],["glpn",["GLPNModel",GLPNModel]],["hifigan",["SpeechT5HifiGan",SpeechT5HifiGan]],["sam",["SamModel",SamModel]]]),MODEL_MAPPING_NAMES_ENCODER_DECODER=new Map([["t5",["T5Model",T5Model]],["longt5",["LongT5Model",LongT5Model]],["mt5",["MT5Model",MT5Model]],["bart",["BartModel",BartModel]],["mbart",["MBartModel",MBartModel]],["marian",["MarianModel",MarianModel]],["whisper",["WhisperModel",WhisperModel]],["m2m_100",["M2M100Model",M2M100Model]],["blenderbot",["BlenderbotModel",BlenderbotModel]],["blenderbot-small",["BlenderbotSmallModel",BlenderbotSmallModel]]]),MODEL_MAPPING_NAMES_DECODER_ONLY=new Map([["bloom",["BloomModel",BloomModel]],["gpt2",["GPT2Model",GPT2Model]],["gptj",["GPTJModel",GPTJModel]],["gpt_bigcode",["GPTBigCodeModel",GPTBigCodeModel]],["gpt_neo",["GPTNeoModel",GPTNeoModel]],["gpt_neox",["GPTNeoXModel",GPTNeoXModel]],["codegen",["CodeGenModel",CodeGenModel]],["llama",["LlamaModel",LlamaModel]],["mpt",["MptModel",MptModel]],["opt",["OPTModel",OPTModel]],["mistral",["MistralModel",MistralModel]],["falcon",["FalconModel",FalconModel]]]),MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForSpeechToText",SpeechT5ForSpeechToText]],["whisper",["WhisperForConditionalGeneration",WhisperForConditionalGeneration]]]),MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES=new Map([["speecht5",["SpeechT5ForTextToSpeech",SpeechT5ForTextToSpeech]]]),MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForSequenceClassification",BertForSequenceClassification]],["camembert",["CamembertForSequenceClassification",CamembertForSequenceClassification]],["deberta",["DebertaForSequenceClassification",DebertaForSequenceClassification]],["deberta-v2",["DebertaV2ForSequenceClassification",DebertaV2ForSequenceClassification]],["mpnet",["MPNetForSequenceClassification",MPNetForSequenceClassification]],["albert",["AlbertForSequenceClassification",AlbertForSequenceClassification]],["distilbert",["DistilBertForSequenceClassification",DistilBertForSequenceClassification]],["roberta",["RobertaForSequenceClassification",RobertaForSequenceClassification]],["xlm",["XLMForSequenceClassification",XLMForSequenceClassification]],["xlm-roberta",["XLMRobertaForSequenceClassification",XLMRobertaForSequenceClassification]],["bart",["BartForSequenceClassification",BartForSequenceClassification]],["mbart",["MBartForSequenceClassification",MBartForSequenceClassification]],["mobilebert",["MobileBertForSequenceClassification",MobileBertForSequenceClassification]],["squeezebert",["SqueezeBertForSequenceClassification",SqueezeBertForSequenceClassification]]]),MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES=new Map([["bert",["BertForTokenClassification",BertForTokenClassification]],["camembert",["CamembertForTokenClassification",CamembertForTokenClassification]],["deberta",["DebertaForTokenClassification",DebertaForTokenClassification]],["deberta-v2",["DebertaV2ForTokenClassification",DebertaV2ForTokenClassification]],["mpnet",["MPNetForTokenClassification",MPNetForTokenClassification]],["distilbert",["DistilBertForTokenClassification",DistilBertForTokenClassification]],["roberta",["RobertaForTokenClassification",RobertaForTokenClassification]],["xlm",["XLMForTokenClassification",XLMForTokenClassification]],["xlm-roberta",["XLMRobertaForTokenClassification",XLMRobertaForTokenClassification]]]),MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES=new Map([["t5",["T5ForConditionalGeneration",T5ForConditionalGeneration]],["longt5",["LongT5ForConditionalGeneration",LongT5ForConditionalGeneration]],["mt5",["MT5ForConditionalGeneration",MT5ForConditionalGeneration]],["bart",["BartForConditionalGeneration",BartForConditionalGeneration]],["mbart",["MBartForConditionalGeneration",MBartForConditionalGeneration]],["marian",["MarianMTModel",MarianMTModel]],["m2m_100",["M2M100ForConditionalGeneration",M2M100ForConditionalGeneration]],["blenderbot",["BlenderbotForConditionalGeneration",BlenderbotForConditionalGeneration]],["blenderbot-small",["BlenderbotSmallForConditionalGeneration",BlenderbotSmallForConditionalGeneration]]]),MODEL_WITH_LM_HEAD_MAPPING_NAMES=new Map([["bloom",["BloomForCausalLM",BloomForCausalLM]],["gpt2",["GPT2LMHeadModel",GPT2LMHeadModel]],["gptj",["GPTJForCausalLM",GPTJForCausalLM]],["gpt_bigcode",["GPTBigCodeForCausalLM",GPTBigCodeForCausalLM]],["gpt_neo",["GPTNeoForCausalLM",GPTNeoForCausalLM]],["gpt_neox",["GPTNeoXForCausalLM",GPTNeoXForCausalLM]],["codegen",["CodeGenForCausalLM",CodeGenForCausalLM]],["llama",["LlamaForCausalLM",LlamaForCausalLM]],["mpt",["MptForCausalLM",MptForCausalLM]],["opt",["OPTForCausalLM",OPTForCausalLM]],["mbart",["MBartForCausalLM",MBartForCausalLM]],["mistral",["MistralForCausalLM",MistralForCausalLM]],["falcon",["FalconForCausalLM",FalconForCausalLM]],["trocr",["TrOCRForCausalLM",TrOCRForCausalLM]]]),MODEL_FOR_MASKED_LM_MAPPING_NAMES=new Map([["bert",["BertForMaskedLM",BertForMaskedLM]],["camembert",["CamembertForMaskedLM",CamembertForMaskedLM]],["deberta",["DebertaForMaskedLM",DebertaForMaskedLM]],["deberta-v2",["DebertaV2ForMaskedLM",DebertaV2ForMaskedLM]],["mpnet",["MPNetForMaskedLM",MPNetForMaskedLM]],["albert",["AlbertForMaskedLM",AlbertForMaskedLM]],["distilbert",["DistilBertForMaskedLM",DistilBertForMaskedLM]],["roberta",["RobertaForMaskedLM",RobertaForMaskedLM]],["xlm",["XLMWithLMHeadModel",XLMWithLMHeadModel]],["xlm-roberta",["XLMRobertaForMaskedLM",XLMRobertaForMaskedLM]],["mobilebert",["MobileBertForMaskedLM",MobileBertForMaskedLM]],["squeezebert",["SqueezeBertForMaskedLM",SqueezeBertForMaskedLM]]]),MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES=new Map([["bert",["BertForQuestionAnswering",BertForQuestionAnswering]],["camembert",["CamembertForQuestionAnswering",CamembertForQuestionAnswering]],["deberta",["DebertaForQuestionAnswering",DebertaForQuestionAnswering]],["deberta-v2",["DebertaV2ForQuestionAnswering",DebertaV2ForQuestionAnswering]],["mpnet",["MPNetForQuestionAnswering",MPNetForQuestionAnswering]],["albert",["AlbertForQuestionAnswering",AlbertForQuestionAnswering]],["distilbert",["DistilBertForQuestionAnswering",DistilBertForQuestionAnswering]],["roberta",["RobertaForQuestionAnswering",RobertaForQuestionAnswering]],["xlm",["XLMForQuestionAnswering",XLMForQuestionAnswering]],["xlm-roberta",["XLMRobertaForQuestionAnswering",XLMRobertaForQuestionAnswering]],["mobilebert",["MobileBertForQuestionAnswering",MobileBertForQuestionAnswering]],["squeezebert",["SqueezeBertForQuestionAnswering",SqueezeBertForQuestionAnswering]]]),MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES=new Map([["vision-encoder-decoder",["VisionEncoderDecoderModel",VisionEncoderDecoderModel]]]),MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES=new Map([["vit",["ViTForImageClassification",ViTForImageClassification]],["mobilevit",["MobileViTForImageClassification",MobileViTForImageClassification]],["beit",["BeitForImageClassification",BeitForImageClassification]],["deit",["DeiTForImageClassification",DeiTForImageClassification]],["convnext",["ConvNextForImageClassification",ConvNextForImageClassification]],["convnextv2",["ConvNextV2ForImageClassification",ConvNextV2ForImageClassification]],["resnet",["ResNetForImageClassification",ResNetForImageClassification]],["swin",["SwinForImageClassification",SwinForImageClassification]]]),MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES=new Map([["detr",["DetrForObjectDetection",DetrForObjectDetection]],["yolos",["YolosForObjectDetection",YolosForObjectDetection]]]),MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES=new Map([["owlvit",["OwlViTForObjectDetection",OwlViTForObjectDetection]]]),MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES=new Map([["detr",["DetrForSegmentation",DetrForSegmentation]]]),MODEL_FOR_MASK_GENERATION_MAPPING_NAMES=new Map([["sam",["SamModel",SamModel]]]),MODEL_FOR_CTC_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForCTC",Wav2Vec2ForCTC]],["wavlm",["WavLMForCTC",WavLMForCTC]]]),MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES=new Map([["wav2vec2",["Wav2Vec2ForSequenceClassification",Wav2Vec2ForSequenceClassification]],["wavlm",["WavLMForSequenceClassification",WavLMForSequenceClassification]],["audio-spectrogram-transformer",["ASTForAudioClassification",ASTForAudioClassification]]]),MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES=new Map([["swin2sr",["Swin2SRForImageSuperResolution",Swin2SRForImageSuperResolution]]]),MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES=new Map([["dpt",["DPTForDepthEstimation",DPTForDepthEstimation]],["glpn",["GLPNForDepthEstimation",GLPNForDepthEstimation]]]),MODEL_CLASS_TYPE_MAPPING=[[MODEL_MAPPING_NAMES_ENCODER_ONLY,MODEL_TYPES.EncoderOnly],[MODEL_MAPPING_NAMES_ENCODER_DECODER,MODEL_TYPES.EncoderDecoder],[MODEL_MAPPING_NAMES_DECODER_ONLY,MODEL_TYPES.DecoderOnly],[MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Seq2Seq],[MODEL_WITH_LM_HEAD_MAPPING_NAMES,MODEL_TYPES.DecoderOnly],[MODEL_FOR_MASKED_LM_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,MODEL_TYPES.Vision2Seq],[MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_MASK_GENERATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_CTC_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,MODEL_TYPES.EncoderOnly],[MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES,MODEL_TYPES.Seq2Seq]];for(const[m,t]of MODEL_CLASS_TYPE_MAPPING)for(const[i,s]of m.values())MODEL_TYPE_MAPPING.set(i,t),MODEL_CLASS_TO_NAME_MAPPING.set(s,i),MODEL_NAME_TO_CLASS_MAPPING.set(i,s);const CUSTOM_MAPPING=[["CLIPTextModelWithProjection",CLIPTextModelWithProjection,MODEL_TYPES.EncoderOnly],["CLIPVisionModelWithProjection",CLIPVisionModelWithProjection,MODEL_TYPES.EncoderOnly],["ClapTextModelWithProjection",ClapTextModelWithProjection,MODEL_TYPES.EncoderOnly],["ClapAudioModelWithProjection",ClapAudioModelWithProjection,MODEL_TYPES.EncoderOnly]];for(const[m,t,i]of CUSTOM_MAPPING)MODEL_TYPE_MAPPING.set(m,i),MODEL_CLASS_TO_NAME_MAPPING.set(t,m),MODEL_NAME_TO_CLASS_MAPPING.set(m,t);class AutoModel extends PretrainedMixin{}he(AutoModel,"MODEL_CLASS_MAPPINGS",[MODEL_MAPPING_NAMES_ENCODER_ONLY,MODEL_MAPPING_NAMES_ENCODER_DECODER,MODEL_MAPPING_NAMES_DECODER_ONLY]),he(AutoModel,"BASE_IF_FAIL",!0);class AutoModelForSequenceClassification extends PretrainedMixin{}he(AutoModelForSequenceClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForTokenClassification extends PretrainedMixin{}he(AutoModelForTokenClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForSeq2SeqLM extends PretrainedMixin{}he(AutoModelForSeq2SeqLM,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]);class AutoModelForSpeechSeq2Seq extends PretrainedMixin{}he(AutoModelForSpeechSeq2Seq,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]);class AutoModelForTextToSpectrogram extends PretrainedMixin{}he(AutoModelForTextToSpectrogram,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]);class AutoModelForCausalLM extends PretrainedMixin{}he(AutoModelForCausalLM,"MODEL_CLASS_MAPPINGS",[MODEL_WITH_LM_HEAD_MAPPING_NAMES]);class AutoModelForMaskedLM extends PretrainedMixin{}he(AutoModelForMaskedLM,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_MASKED_LM_MAPPING_NAMES]);class AutoModelForQuestionAnswering extends PretrainedMixin{}he(AutoModelForQuestionAnswering,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]);class AutoModelForVision2Seq extends PretrainedMixin{}he(AutoModelForVision2Seq,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]);class AutoModelForImageClassification extends PretrainedMixin{}he(AutoModelForImageClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForImageSegmentation extends PretrainedMixin{}he(AutoModelForImageSegmentation,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]);class AutoModelForObjectDetection extends PretrainedMixin{}he(AutoModelForObjectDetection,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]);class AutoModelForZeroShotObjectDetection extends PretrainedMixin{}he(AutoModelForZeroShotObjectDetection,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]);class AutoModelForCTC extends PretrainedMixin{}he(AutoModelForCTC,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_CTC_MAPPING_NAMES]);class AutoModelForAudioClassification extends PretrainedMixin{}he(AutoModelForAudioClassification,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]);class AutoModelForDocumentQuestionAnswering extends PretrainedMixin{}he(AutoModelForDocumentQuestionAnswering,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]);class AutoModelForImageToImage extends PretrainedMixin{}he(AutoModelForImageToImage,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]);class AutoModelForDepthEstimation extends PretrainedMixin{}he(AutoModelForDepthEstimation,"MODEL_CLASS_MAPPINGS",[MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]);class Seq2SeqLMOutput extends ModelOutput{constructor({logits:t,past_key_values:i,encoder_outputs:s,decoder_attentions:u=null,cross_attentions:d=null}){super(),this.logits=t,this.past_key_values=i,this.encoder_outputs=s,this.decoder_attentions=u,this.cross_attentions=d}}class SequenceClassifierOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class TokenClassifierOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class MaskedLMOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}class QuestionAnsweringModelOutput extends ModelOutput{constructor({start_logits:t,end_logits:i}){super(),this.start_logits=t,this.end_logits=i}}class CausalLMOutput extends ModelOutput{constructor({logits:t}){super(),this.logits=t}}const BROWSER_ENV=typeof self<"u",WEBWORKER_ENV=BROWSER_ENV&&self.constructor.name==="DedicatedWorkerGlobalScope";let createCanvasFunction,ImageDataClass,loadImageFunction;if(BROWSER_ENV)createCanvasFunction=(m,t)=>{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(sharp)loadImageFunction=async m=>{const i=(await m.metadata()).channels;let{data:s,info:u}=await m.raw().toBuffer({resolveWithObject:!0});const d=new RawImage(new Uint8ClampedArray(s),u.width,u.height,u.channels);return i!==void 0&&i!==u.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"},CONTENT_TYPE_MAP=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]);class RawImage{constructor(t,i,s,u){this.data=t,this.width=i,this.height=s,this.channels=u}get size(){return[this.width,this.height]}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 i=await getFile(t);if(i.status!==200)throw new Error(`Unable to read image from "${t}" (${i.status} ${i.statusText})`);let s=await i.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=sharp(await t.arrayBuffer());return await loadImageFunction(i)}}static fromTensor(t,i="CHW"){if(i==="CHW")t=t.transpose(1,2,0);else if(i!=="HWC")throw new Error(`Unsupported channel format: ${i}`);return new RawImage(t.data,t.dims[1],t.dims[0],t.dims[2])}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?f=s:l=-s,u>=0?c=u:n=-u,h.drawImage(a,f,c,t,i,l,n,t,i),new RawImage(h.getImageData(0,0,t,i).data,t,i,4).convert(d)}else{let d=this.toSharp();if(s>=0&&u>=0)d=d.extract({left:Math.floor(s),top:Math.floor(u),width:t,height:i});else if(s<=0&&u<=0){let a=Math.floor(-u),h=Math.floor(-s);d=d.extend({top:a,left:h,right:t-this.width-h,bottom:i-this.height-a})}else{let a=[0,0],h=0;u<0?(a[0]=Math.floor(-u),a[1]=i-this.height-a[0]):h=Math.floor(u);let f=[0,0],c=0;s<0?(f[0]=Math.floor(-s),f[1]=t-this.width-f[0]):c=Math.floor(s),d=d.extend({top:a[0],bottom:a[1],left:f[0],right:f[1]}).extract({left:c,top:h,width:t,height:i})}return await loadImageFunction(d)}}async toBlob(t="image/png",i=1){if(!BROWSER_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:t,quality:i})}toCanvas(){if(!BROWSER_ENV)throw new Error("toCanvas() is only supported in browser environments.");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,u=null){return this.data=t,this.width=i,this.height=s,u!==null&&(this.channels=u),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}async save(t){if(BROWSER_ENV){if(WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");const i=t.split(".").pop().toLowerCase(),s=CONTENT_TYPE_MAP.get(i)??"image/png",u=await this.toBlob(s),d=URL.createObjectURL(u),a=document.createElement("a");a.href=d,a.download=t,a.click(),a.remove()}else{if(env$1.useFS)return await this.toSharp().toFile(t);throw new Error("Unable to save the image because filesystem is disabled in this environment.")}}toSharp(){if(BROWSER_ENV)throw new Error("toSharp() is only supported in server-side environments.");return sharp(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}}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/guides/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 u=await s.decodeAudioData(i);let d;if(u.numberOfChannels===2){const a=Math.sqrt(2),h=u.getChannelData(0),f=u.getChannelData(1);d=new Float32Array(h.length);for(let c=0;c2595*Math.log10(1+m/700),kaldi:m=>1127*Math.log(1+m/700),slaney:(m,t=1e3,i=15,s=27/Math.log(6.4))=>m>=t?i+Math.log(m/t)*s:3*m/200};function hertz_to_mel(m,t="htk"){const i=HERTZ_TO_MEL_MAPPING[t];if(!i)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof m=="number"?i(m):m.map(s=>i(s))}const MEL_TO_HERTZ_MAPPING={htk:m=>700*(10**(m/2595)-1),kaldi:m=>700*(Math.exp(m/1127)-1),slaney:(m,t=1e3,i=15,s=Math.log(6.4)/27)=>m>=i?t*Math.exp(s*(m-i)):200*m/3};function mel_to_hertz(m,t="htk"){const i=MEL_TO_HERTZ_MAPPING[t];if(!i)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof m=="number"?i(m):m.map(s=>i(s))}function _create_triangular_filter_bank(m,t){const i=Float64Array.from({length:t.length-1},(a,h)=>t[h+1]-t[h]),s=Array.from({length:m.length},()=>new Array(t.length));for(let a=0;anew Array(m.length));for(let a=0;am+s*d)}function mel_filter_bank(m,t,i,s,u,d=null,a="htk",h=!1){if(d!==null&&d!=="slaney")throw new Error('norm must be one of null or "slaney"');const f=hertz_to_mel(i,a),c=hertz_to_mel(s,a),l=linspace(f,c,t+2);let n=mel_to_hertz(l,a),e;if(h){const o=u/(m*2);e=hertz_to_mel(Float64Array.from({length:m},(p,g)=>g*o),a),n=l}else e=linspace(0,Math.floor(u/2),m);const r=_create_triangular_filter_bank(e,n);if(d!==null&&d==="slaney")for(let o=0;ou)throw Error(`frame_length (${i}) may not be larger than fft_length (${u})`);if(w!==i)throw new Error(`Length of the window (${w}) must equal frame_length (${i})`);if(s<=0)throw new Error("hop_length must be greater than zero");if(a){if(h!=="reflect")throw new Error(`pad_mode="${h}" not implemented yet.`);const D=Math.floor((u-1)/2)+1;m=padReflect(m,D,D)}const T=Math.floor(1+Math.floor((m.length-i)/s)),S=f?Math.floor(u/2)+1:u;let A=T,P=T;_!==null&&(_>T?b&&(P=_):P=A=_);const x=new FFT(u),M=new Float64Array(u),N=new Float64Array(x.outputBufferSize),z=new Array(A);for(let D=0;D=1;--V)M[V]-=c*M[V-1];M[0]*=1-c}for(let V=0;Vs)throw new Error(`Length of the window (${m}) may not be larger than frame_length (${s})`);return a}function center_to_corners_format([m,t,i,s]){return[m-i/2,t-s/2,m+i/2,t+s/2]}function post_process_object_detection(m,t=.5,i=null,s=!1){const u=m.logits,d=m.pred_boxes,[a,h,f]=u.dims;if(i!==null&&i.length!==a)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;lt&&_.push(y)}else{let y=max(g.data)[1];if(y===f-1)continue;_.push(y),b=softmax(g.data)}for(const y of _){let w=o[p].data;w=center_to_corners_format(w),n!==null&&(w=w.map((T,S)=>T*n[(S+1)%2])),e.boxes.push(w),e.classes.push(y),e.scores.push(b[y])}}c.push(e)}return c}function validate_audio_inputs(m,t){var i;if(!(m instanceof Float32Array||m instanceof Float64Array))throw new Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${((i=m==null?void 0:m.constructor)==null?void 0:i.name)??typeof m} instead.If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}class FeatureExtractor extends Callable{constructor(t){super(),this.config=t}}class ImageFeatureExtractor extends FeatureExtractor{constructor(t){super(t),this.image_mean=this.config.image_mean,this.image_std=this.config.image_std,this.resample=this.config.resample??2,this.do_rescale=this.config.do_rescale??!0,this.rescale_factor=this.config.rescale_factor??1/255,this.do_normalize=this.config.do_normalize,this.do_resize=this.config.do_resize,this.do_thumbnail=this.config.do_thumbnail,this.size=this.config.size,this.size_divisor=this.config.size_divisor,this.do_center_crop=this.config.do_center_crop,this.crop_size=this.config.crop_size,this.do_convert_rgb=this.config.do_convert_rgb??!0,this.do_crop_margin=this.config.do_crop_margin,this.pad_size=this.config.pad_size,this.do_pad=this.config.do_pad,this.do_pad&&!this.pad_size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size)}async thumbnail(t,i,s=2){const u=t.height,d=t.width,a=i.height,h=i.width;let f=Math.min(u,a),c=Math.min(d,h);return f===u&&c===d?t:(u>d?c=Math.floor(d*f/u):d>u&&(f=Math.floor(u*c/d)),await t.resize(c,f,{resample:s}))}async crop_margin(t,i=200){const s=t.clone().grayscale(),u=min(s.data)[0],a=max(s.data)[0]-u;if(a===0)return t;const h=i/255;let f=s.width,c=s.height,l=0,n=0;for(let e=0;ethis.preprocess(d)));return s.forEach(d=>d.pixel_values.dims=[1,...d.pixel_values.dims]),{pixel_values:cat(s.map(d=>d.pixel_values)),original_sizes:s.map(d=>d.original_size),reshaped_input_sizes:s.map(d=>d.reshaped_input_size)}}}class DPTFeatureExtractor extends ImageFeatureExtractor{}class GLPNFeatureExtractor extends ImageFeatureExtractor{}class CLIPFeatureExtractor extends ImageFeatureExtractor{}class ConvNextFeatureExtractor extends ImageFeatureExtractor{}class ConvNextImageProcessor extends ConvNextFeatureExtractor{}class ViTFeatureExtractor extends ImageFeatureExtractor{}class MobileViTFeatureExtractor extends ImageFeatureExtractor{}class OwlViTFeatureExtractor extends ImageFeatureExtractor{post_process_object_detection(...t){return post_process_object_detection(...t)}}class DeiTFeatureExtractor extends ImageFeatureExtractor{}class BeitFeatureExtractor extends ImageFeatureExtractor{}class DonutFeatureExtractor extends ImageFeatureExtractor{pad_image(t,i,s,u={}){const[d,a,h]=i;let f=this.image_mean;Array.isArray(this.image_mean)||(f=new Array(h).fill(f)),this.image_std,Array.isArray(this.image_std)||new Array(h).fill(f);const c=f.map((l,n)=>-l/this.image_std[n]);return super.pad_image(t,i,s,{center:!0,constant_values:c,...u})}}class NougatImageProcessor extends DonutFeatureExtractor{}class DetrFeatureExtractor extends ImageFeatureExtractor{async _call(t){const i=await super._call(t),s=[i.pixel_values.dims[0],64,64],u=new Tensor("int64",new BigInt64Array(s.reduce((d,a)=>d*a)).fill(1n),s);return{...i,pixel_mask:u}}post_process_object_detection(...t){return post_process_object_detection(...t)}remove_low_and_no_objects(t,i,s,u){let d=[],a=[],h=[];for(let f=0;fs&&(d.push(l),a.push(r),h.push(n))}return[d,a,h]}check_segment_validity(t,i,s,u=.5,d=.8){let a=[],h=0,f=0;for(let l=0;l=u&&++f;let c=h>0&&f>0;return c&&(c=h/f>d),[c,a]}compute_segments(t,i,s,u,d,a=null,h=null){let[f,c]=h??t[0].dims,l=new Tensor("int32",new Int32Array(f*c),[f,c]),n=[];if(h!==null)for(let p=0;pr[_]&&(e[_]=p,r[_]=t[p].data[_])}let o=0;for(let p=0;pBigInt(Math.round(f)))),a);return{pixel_values:s,original_sizes:u,reshaped_input_sizes:d,input_points:h}}post_process_masks(t,i,s,{mask_threshold:u=0,binarize:d=!0,pad_size:a=null}={}){let h=[];a=a??this.pad_size;let f=[a.height,a.width];for(let c=0;cb>u),_.dims)),_.dims=[1,..._.dims],r.push(_)}let o=cat(r);h.push(o)}return h}}class Swin2SRImageProcessor extends ImageFeatureExtractor{pad_image(t,i,s,u={}){const[d,a,h]=i;return super.pad_image(t,i,{width:d+(s-d%s)%s,height:a+(s-a%s)%s},{mode:"symmetric",center:!1,constant_values:-1,...u})}}class WhisperFeatureExtractor extends FeatureExtractor{constructor(t){var i;super(t),(i=this.config).mel_filters??(i.mel_filters=mel_filter_bank(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney")),this.window=window_function(this.config.n_fft,"hann")}_extract_fbank_features(t){const{data:i,dims:s}=spectrogram(t,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10",max_num_frames:this.config.nb_max_frames}),u=max(i)[0];for(let d=0;dthis.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`."),i=t.slice(0,this.config.n_samples)):(i=new Float32Array(this.config.n_samples),i.set(t));const{data:s,dims:u}=this._extract_fbank_features(i);return{input_features:new Tensor("float32",s,[1,...u])}}}class Wav2Vec2FeatureExtractor extends FeatureExtractor{_zero_mean_unit_var_norm(t){const s=t.reduce((d,a)=>d+a,0)/t.length,u=t.reduce((d,a)=>d+(a-s)**2,0)/t.length;return t.map(d=>(d-s)/Math.sqrt(u+1e-7))}async _call(t){validate_audio_inputs(t,"Wav2Vec2FeatureExtractor"),t instanceof Float64Array&&(t=new Float32Array(t));let i=t;this.config.do_normalize&&(i=this._zero_mean_unit_var_norm(i));const s=[1,i.length];return{input_values:new Tensor("float32",i,s),attention_mask:new Tensor("int64",new BigInt64Array(i.length).fill(1n),s)}}}class ASTFeatureExtractor extends FeatureExtractor{constructor(t){super(t);const i=this.config.sampling_rate,s=mel_filter_bank(256,this.config.num_mel_bins,20,Math.floor(i/2),i,null,"kaldi",!0);for(let u=0;u0)if(s==="rand_trunc"){a=!0;const f=Math.floor(Math.random()*(h+1));t=t.subarray(f,f+i),d=this._extract_fbank_features(t,this.mel_filters_slaney,this.config.nb_max_samples),d.dims=[1,...d.dims]}else throw new Error(`Truncation strategy "${s}" not implemented`);else{if(h<0){let f=new Float64Array(i);if(f.set(t),u==="repeat")for(let c=t.length;cRawImage.read(t))),m}class Pipeline extends Callable{constructor({task:t,model:i,tokenizer:s=null,processor:u=null}){super(),this.task=t,this.model=i,this.tokenizer=s,this.processor=u}async dispose(){await this.model.dispose()}async _call(t,...i){let s=this.tokenizer(t,{padding:!0,truncation:!0}),u=await this.model(s);return[s,u]}}class TextClassificationPipeline extends Pipeline{async _call(t,{topk:i=1}={}){let s=this.model.config.problem_type==="multi_label_classification"?f=>f.sigmoid().data:f=>softmax(f.data),[u,d]=await super._call(t),a=this.model.config.id2label,h=[];for(let f of d.logits){let c=s(f),n=getTopItems(c,i).map(function(e){return{label:a[e[0]],score:e[1]}});i===1?h.push(...n):h.push(n)}return Array.isArray(t)||i===1?h:h[0]}}class TokenClassificationPipeline extends Pipeline{async _call(t,{ignore_labels:i=["O"]}={}){let s=Array.isArray(t);s||(t=[t]);let u=this.tokenizer,[d,a]=await super._call(t),h=a.logits,f=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=[...f];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)?a:a[0]}}class Text2TextGenerationPipeline extends Pipeline{constructor(){super(...arguments);he(this,"_key","generated_text")}async _call(i,s={}){Array.isArray(i)||(i=[i]),this.model.config.prefix&&(i=i.map(c=>this.model.config.prefix+c));let u=this.model.config.task_specific_params;u&&u[this.task]&&u[this.task].prefix&&(i=i.map(c=>u[this.task].prefix+c));let d={padding:!0,truncation:!0},a;this instanceof TranslationPipeline&&"_build_translation_inputs"in this.tokenizer?a=this.tokenizer._build_translation_inputs(i,d,s).input_ids:a=this.tokenizer(i,d).input_ids;let h=await this.model.generate(a,s),f=this.tokenizer.batch_decode(h,{skip_special_tokens:!0});return this._key!==null&&(f=f.map(c=>this._key===null?c:{[this._key]:c})),f}}class SummarizationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);he(this,"_key","summary_text")}}class TranslationPipeline extends Text2TextGenerationPipeline{constructor(){super(...arguments);he(this,"_key","translation_text")}}class TextGenerationPipeline extends Pipeline{async _call(t,i={}){let s=typeof t=="string"||t instanceof String;s&&(t=[t]);const u=i.add_special_tokens??!1;this.tokenizer.padding_side="left";let d=this.tokenizer(t,{add_special_tokens:u,padding:!0,truncation:!0}),a=d.input_ids,h=d.attention_mask,f=await this.model.generate(a,i,null,{inputs_attention_mask:h});const c=this.tokenizer.batch_decode(f,{skip_special_tokens:!0}),l=Array.from({length:t.length},n=>[]);for(let n=0;n[i.toLowerCase(),s])),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.label2id.not_entailment,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:u=!1}={}){let d=Array.isArray(t);d||(t=[t]),Array.isArray(i)||(i=[i]);let a=i.map(c=>s.replace("{}",c)),h=u||i.length===1,f=[];for(let c of t){let l=[];for(let r of a){let o=this.tokenizer(c,{text_pair:r,padding:!0,truncation:!0}),p=await this.model(o);h?l.push([p.logits.data[this.contradiction_id],p.logits.data[this.entailment_id]]):l.push(p.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]);f.push({sequence:c,labels:e.map(r=>i[r[1]]),scores:e.map(r=>r[0])})}return d?f:f[0]}}class FeatureExtractionPipeline extends Pipeline{async _call(t,{pooling:i="none",normalize:s=!1}={}){let[u,d]=await super._call(t),a=d.last_hidden_state??d.logits;if(i!=="none")if(i==="mean")a=mean_pooling(a,u.attention_mask);else throw Error(`Pooling method '${i}' not supported.`);return s&&(a=a.normalize(2,-1)),a}}class AudioClassificationPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,{topk:i=5}={}){let s=!Array.isArray(t);s&&(t=[t]);const u=this.model.config.id2label,d=this.processor.feature_extractor.config.sampling_rate;let a=[];for(let h of t){h=await this._preprocess(h,d);const f=await this.processor(h),l=(await this.model(f)).logits[0];let e=getTopItems(softmax(l.data),i).map(function(r){return{label:u[r[0]],score:r[1]}});i===1?a.push(...e):a.push(e)}return!s||i===1?a:a[0]}}class ZeroShotAudioClassificationPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,i,{hypothesis_template:s="This is a sound of {}."}={}){const u=!Array.isArray(t);u&&(t=[t]);const d=i.map(c=>s.replace("{}",c)),a=this.tokenizer(d,{padding:!0,truncation:!0}),h=this.processor.feature_extractor.config.sampling_rate,f=[];for(let c of t){c=await this._preprocess(c,h);const l=await this.processor(c),n=await this.model({...a,...l}),e=softmax(n.logits_per_audio.data);f.push([...e].map((r,o)=>({score:r,label:i[o]})))}return u?f[0]:f}}class AutomaticSpeechRecognitionPipeline extends Pipeline{constructor(t){super(t)}async _preprocess(t,i){return isString(t)&&(t=await read_audio(t,i)),t}async _call(t,i={}){switch(this.model.config.model_type){case"whisper":return this._call_whisper(t,i);case"wav2vec2":return this._call_wav2vec2(t,i);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(t,i={}){i.language&&console.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),i.task&&console.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let s=!Array.isArray(t);s&&(t=[t]);const u=this.processor.feature_extractor.config.sampling_rate;let d=[];for(let a of t){a=await this._preprocess(a,u);const h=await this.processor(a),c=(await this.model(h)).logits[0],l=[];for(let e of c)l.push(max(e.data)[1]);const n=this.tokenizer.decode(l);d.push({text:n})}return s?d[0]:d}async _call_whisper(t,i={}){let s=i.return_timestamps??!1,u=i.chunk_length_s??0,d=i.stride_length_s??null,a=i.chunk_callback??null,h=i.force_full_sequences??!1;s==="word"&&(i.return_token_timestamps=!0);let f=pop(i,"language",null),c=pop(i,"task",null);if(f||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 p=this.tokenizer.get_decoder_prompt_ids({language:f,task:c,no_timestamps:!s});p.length>0&&(i.forced_decoder_ids=p)}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,r=this.processor.feature_extractor.config.hop_length;let o=[];for(let p of t){p=await this._preprocess(p,n);let g=[];if(u>0){if(d===null)d=u/6;else if(u<=d)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");const y=n*u,w=n*d,T=y-2*w;let S=0;for(;S=p.length;g.push({stride:[A.length,x?0:w,M?0:w],input_features:P.input_features,is_last:M}),S+=T}}else g=[{stride:[p.length,0,0],input_features:(await this.processor(p)).input_features,is_last:!0}];for(let y of g){i.num_frames=Math.floor(y.stride[0]/r);let w=await this.model.generate(y.input_features,i);s==="word"?(y.tokens=w.sequences[0],y.token_timestamps=w.token_timestamps.tolist()[0].map(T=>round(T,2))):y.tokens=w[0],y.stride=y.stride.map(T=>T/n),a!==null&&a(y)}let[_,b]=this.tokenizer._decode_asr(g,{time_precision:e,return_timestamps:s,force_full_sequences:h});o.push({text:_,...b})}return l?o[0]:o}}class ImageToTextPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:u}=await this.processor(t),d=[];for(let a of u){a.dims=[1,...a.dims];let h=await this.model.generate(a,i),f=this.tokenizer.batch_decode(h,{skip_special_tokens:!0}).map(c=>({generated_text:c.trim()}));d.push(f)}return s?d:d[0]}}class ImageClassificationPipeline extends Pipeline{constructor(t){super(t)}async _call(t,{topk:i=1}={}){let s=Array.isArray(t);t=await prepareImages(t);let{pixel_values:u}=await this.processor(t),d=await this.model({pixel_values:u}),a=this.model.config.id2label,h=[];for(let f of d.logits){let l=getTopItems(softmax(f.data),i).map(function(n){return{label:a[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){super(t),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:u=.8,label_ids_to_fuse:d=null,target_sizes:a=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(p=>[p.height,p.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[p,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=p;break}let o=[];if(h==="panoptic"||h==="instance"){let p=r(e,i,s,u,d,a??c)[0],g=p.segmentation,_=this.model.config.id2label;for(let b of p.segments_info){let y=new Uint8ClampedArray(g.data.length);for(let T=0;Ts.replace("{}",l)),a=this.tokenizer(d,{padding:!0,truncation:!0}),{pixel_values:h}=await this.processor(t),f=await this.model({...a,pixel_values:h}),c=[];for(let l of f.logits_per_image){let n=softmax(l.data);c.push([...n].map((e,r)=>({score:e,label:i[r]})))}return u?c:c[0]}}class ObjectDetectionPipeline extends Pipeline{constructor(t){super(t)}async _call(t,{threshold:i=.9,percentage:s=!1}={}){let u=Array.isArray(t);if(u&&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(e=>[e.height,e.width]),{pixel_values:a,pixel_mask:h}=await this.processor(t),f=await this.model({pixel_values:a,pixel_mask:h}),c=this.processor.feature_extractor.post_process_object_detection(f,i,d),l=this.model.config.id2label;const n=c.map(e=>e.boxes.map((r,o)=>({score:e.scores[o],label:l[e.classes[o]],box:get_bounding_box(r,!s)})));return u?n:n[0]}}class ZeroShotObjectDetectionPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i,{threshold:s=.1,topk:u=null,percentage:d=!1}={}){const a=Array.isArray(t);t=await prepareImages(t);const h=this.tokenizer(i,{padding:!0,truncation:!0}),f=await this.processor(t),c=[];for(let l=0;l({score:p.scores[b],label:i[p.classes[b]],box:get_bounding_box(_,!d)})).sort((_,b)=>b.score-_.score);u!==null&&(g=g.slice(0,u)),c.push(g)}return a?c:c[0]}}class DocumentQuestionAnsweringPipeline extends Pipeline{constructor(t){super(t)}async _call(t,i,s={}){t=(await prepareImages(t))[0];const{pixel_values:u}=await this.processor(t),d=`${i}`,a=this.tokenizer(d,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,h=await this.model.generate(u,{...s,decoder_input_ids:a,max_length:this.model.config.decoder.max_position_embeddings}),c=this.tokenizer.batch_decode(h)[0].match(/(.*?)<\/s_answer>/);let l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}}class TextToAudioPipeline extends Pipeline{constructor(i){super(i);he(this,"DEFAULT_VOCODER_ID","Xenova/speecht5_hifigan");this.vocoder=i.vocoder??null}async _call(i,{speaker_embeddings:s=null}={}){if(this.vocoder||(console.log("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await AutoModel.from_pretrained(this.DEFAULT_VOCODER_ID,{quantized:!1})),(typeof s=="string"||s instanceof URL)&&(s=new Float32Array(await(await fetch(s)).arrayBuffer())),s instanceof Float32Array)s=new Tensor("float32",s,[1,s.length]);else if(!(s instanceof Tensor))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");const{input_ids:u}=this.tokenizer(i,{padding:!0,truncation:!0}),{waveform:d}=await this.model.generate_speech(u,s,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return{audio:d.data,sampling_rate:a}}}class ImageToImagePipeline extends Pipeline{async _call(t){t=await prepareImages(t);let i=await this.processor(t),s=await this.model(i),u=[];for(let d of s.reconstruction){const a=d.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");u.push(RawImage.fromTensor(a))}return u.length>1?u:u[0]}}class DepthEstimationPipeline extends Pipeline{async _call(t){t=await prepareImages(t);const i=await this.processor(t),{predicted_depth:s}=await this.model(i),u=[];for(let d=0;d1?u:u[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"},"audio-classification":{pipeline:AudioClassificationPipeline,model:AutoModelForAudioClassification,processor:AutoProcessor,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:AutoTokenizer,pipeline:ZeroShotAudioClassificationPipeline,model:AutoModel,processor:AutoProcessor,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:AutoTokenizer,pipeline:AutomaticSpeechRecognitionPipeline,model:[AutoModelForSpeechSeq2Seq,AutoModelForCTC],processor:AutoProcessor,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:AutoTokenizer,pipeline:TextToAudioPipeline,model:[AutoModelForTextToSpectrogram],processor:AutoProcessor,default:{model:"Xenova/speecht5_tts"},type:"text"},"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"},"zero-shot-object-detection":{tokenizer:AutoTokenizer,pipeline:ZeroShotObjectDetectionPipeline,model:AutoModelForZeroShotObjectDetection,processor:AutoProcessor,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:AutoTokenizer,pipeline:DocumentQuestionAnsweringPipeline,model:AutoModelForDocumentQuestionAnswering,processor:AutoProcessor,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:ImageToImagePipeline,model:AutoModelForImageToImage,processor:AutoProcessor,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:DepthEstimationPipeline,model:AutoModelForDepthEstimation,processor:AutoProcessor,default:{model:"Xenova/dpt-large"},type:"image"},"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","text-to-speech":"text-to-audio",embeddings:"feature-extraction"};async function pipeline(m,t=null,{quantized:i=!0,progress_callback:s=null,config:u=null,cache_dir:d=null,local_files_only:a=!1,revision:h="main"}={}){m=TASK_ALIASES[m]??m;let f=SUPPORTED_TASKS[m.split("_",1)[0]];if(!f)throw Error(`Unsupported pipeline: ${m}. Must be one of [${Object.keys(SUPPORTED_TASKS)}]`);t||(t=f.default.model,console.log(`No model specified. Using default model: "${t}".`));let c={quantized:i,progress_callback:s,config:u,cache_dir:d,local_files_only:a,revision:h};const l=new Map([["tokenizer",f.tokenizer],["model",f.model],["processor",f.processor]]);let n=await loadItems(l,t,c);n.task=m,dispatchCallback(s,{status:"ready",task:m,model:t});let e=f.pipeline;return new e(n)}async function loadItems(m,t,i){const s=Object.create(null),u=[];for(let[d,a]of m.entries()){if(!a)continue;let h;Array.isArray(a)?h=new Promise(async(f,c)=>{let l;for(let n of a)try{f(await n.from_pretrained(t,i));return}catch(e){l=e}c(l)}):h=a.from_pretrained(t,i),s[d]=h,u.push(h)}await Promise.all(u);for(let[d,a]of Object.entries(s))s[d]=await a;return s}self.addEventListener("message",async m=>{let t=await MyTranslationPipeline.getInstance(s=>{self.postMessage(s)}),i=await t(m.data.text,{tgt_lang:m.data.tgt_lang,src_lang:m.data.src_lang,callback_function:s=>{self.postMessage({status:"update",output:t.tokenizer.decode(s[0].output_token_ids,{skip_special_tokens:!0})})}});self.postMessage({status:"complete",output:i})});class MyTranslationPipeline{static async getInstance(t=null){return this.instance===null&&(this.instance=pipeline(this.task,this.model,{progress_callback:t})),this.instance}}he(MyTranslationPipeline,"task","translation"),he(MyTranslationPipeline,"model","Xenova/nllb-200-distilled-600M"),he(MyTranslationPipeline,"instance",null)})();