|
- const p=function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))t(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&t(l)}).observe(document,{childList:!0,subtree:!0});function r(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerpolicy&&(i.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?i.credentials="include":o.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function t(o){if(o.ep)return;o.ep=!0;const i=r(o);fetch(o.href,i)}};p();var _scriptDir=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0,cv={},scriptDirectory="";function locateFile(n){return cv.locateFile?cv.locateFile(n,scriptDirectory):scriptDirectory+n}document.currentScript&&(scriptDirectory=document.currentScript.src);_scriptDir&&(scriptDirectory=_scriptDir);scriptDirectory.indexOf("blob:")!==0?scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1):scriptDirectory="";var read_=function(e){try{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText}catch(o){var t=tryParseAsDataURI(e);if(t)return intArrayToString(t);throw o}},readAsync=function(e,r,t){var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=function(){if(o.status==200||o.status==0&&o.response){r(o.response);return}var l=tryParseAsDataURI(e);if(l){r(l.buffer);return}t()},o.onerror=t,o.send(null)},out=cv.print||console.log.bind(console),err$1=cv.printErr||console.warn.bind(console);function dynamicAlloc(n){var e=HEAP32[DYNAMICTOP_PTR>>2],r=e+n+15&-16;return r>_emscripten_get_heap_size()&&abort(),HEAP32[DYNAMICTOP_PTR>>2]=r,e}function warnOnce(n){warnOnce.shown||(warnOnce.shown={}),warnOnce.shown[n]||(warnOnce.shown[n]=1,err$1(n))}var wasmBinary;cv.wasmBinary&&(wasmBinary=cv.wasmBinary);typeof WebAssembly!="object"&&err$1("no native wasm support detected");var wasmMemory,wasmTable=new WebAssembly.Table({initial:10498,maximum:10498+0,element:"anyfunc"}),ABORT=!1;function assert$1(n,e){n||abort("Assertion failed: "+e)}function getMemory(n){return runtimeInitialized?_malloc(n):dynamicAlloc(n)}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function UTF8ArrayToString(n,e,r){for(var t=e+r,o=e;n[o]&&!(o>=t);)++o;if(o-e>16&&n.subarray&&UTF8Decoder)return UTF8Decoder.decode(n.subarray(e,o));for(var i="";e<o;){var l=n[e++];if(!(l&128)){i+=String.fromCharCode(l);continue}var a=n[e++]&63;if((l&224)==192){i+=String.fromCharCode((l&31)<<6|a);continue}var s=n[e++]&63;if((l&240)==224?l=(l&15)<<12|a<<6|s:l=(l&7)<<18|a<<12|s<<6|n[e++]&63,l<65536)i+=String.fromCharCode(l);else{var u=l-65536;i+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return i}function UTF8ToString(n,e){return n?UTF8ArrayToString(HEAPU8,n,e):""}function stringToUTF8Array(n,e,r,t){if(!(t>0))return 0;for(var o=r,i=r+t-1,l=0;l<n.length;++l){var a=n.charCodeAt(l);if(a>=55296&&a<=57343){var s=n.charCodeAt(++l);a=65536+((a&1023)<<10)|s&1023}if(a<=127){if(r>=i)break;e[r++]=a}else if(a<=2047){if(r+1>=i)break;e[r++]=192|a>>6,e[r++]=128|a&63}else if(a<=65535){if(r+2>=i)break;e[r++]=224|a>>12,e[r++]=128|a>>6&63,e[r++]=128|a&63}else{if(r+3>=i)break;e[r++]=240|a>>18,e[r++]=128|a>>12&63,e[r++]=128|a>>6&63,e[r++]=128|a&63}}return e[r]=0,r-o}function stringToUTF8(n,e,r){return stringToUTF8Array(n,HEAPU8,e,r)}function lengthBytesUTF8(n){for(var e=0,r=0;r<n.length;++r){var t=n.charCodeAt(r);t>=55296&&t<=57343&&(t=65536+((t&1023)<<10)|n.charCodeAt(++r)&1023),t<=127?++e:t<=2047?e+=2:t<=65535?e+=3:e+=4}return e}typeof TextDecoder!="undefined"&&new TextDecoder("utf-16le");function writeArrayToMemory(n,e){HEAP8.set(n,e)}function writeAsciiToMemory(n,e,r){for(var t=0;t<n.length;++t)HEAP8[e++>>0]=n.charCodeAt(t);r||(HEAP8[e>>0]=0)}var PAGE_SIZE=16384,WASM_PAGE_SIZE=65536;function alignUp(n,e){return n%e>0&&(n+=e-n%e),n}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(n){buffer=n,cv.HEAP8=HEAP8=new Int8Array(n),cv.HEAP16=HEAP16=new Int16Array(n),cv.HEAP32=HEAP32=new Int32Array(n),cv.HEAPU8=HEAPU8=new Uint8Array(n),cv.HEAPU16=HEAPU16=new Uint16Array(n),cv.HEAPU32=HEAPU32=new Uint32Array(n),cv.HEAPF32=HEAPF32=new Float32Array(n),cv.HEAPF64=HEAPF64=new Float64Array(n)}var DYNAMIC_BASE=6627104,DYNAMICTOP_PTR=1384064,INITIAL_TOTAL_MEMORY=cv.TOTAL_MEMORY||134217728;cv.wasmMemory?wasmMemory=cv.wasmMemory:wasmMemory=new WebAssembly.Memory({initial:INITIAL_TOTAL_MEMORY/WASM_PAGE_SIZE,maximum:1073741824/WASM_PAGE_SIZE});wasmMemory&&(buffer=wasmMemory.buffer);INITIAL_TOTAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(n){for(;n.length>0;){var e=n.shift();if(typeof e=="function"){e();continue}var r=e.func;typeof r=="number"?e.arg===void 0?cv.dynCall_v(r):cv.dynCall_vi(r,e.arg):r(e.arg===void 0?null:e.arg)}}var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],runtimeInitialized=!1;function preRun(){if(cv.preRun)for(typeof cv.preRun=="function"&&(cv.preRun=[cv.preRun]);cv.preRun.length;)addOnPreRun(cv.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,!cv.noFSInit&&!FS.init.initialized&&FS.init(),callRuntimeCallbacks(__ATINIT__)}function preMain(){FS.ignorePermissions=!1,callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(cv.postRun)for(typeof cv.postRun=="function"&&(cv.postRun=[cv.postRun]);cv.postRun.length;)addOnPostRun(cv.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(n){__ATPRERUN__.unshift(n)}function addOnPostRun(n){__ATPOSTRUN__.unshift(n)}var Math_abs=Math.abs,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_min=Math.min,runDependencies=0,dependenciesFulfilled=null;function getUniqueRunDependency(n){return n}function addRunDependency(n){runDependencies++,cv.monitorRunDependencies&&cv.monitorRunDependencies(runDependencies)}function removeRunDependency(n){if(runDependencies--,cv.monitorRunDependencies&&cv.monitorRunDependencies(runDependencies),runDependencies==0&&dependenciesFulfilled){var e=dependenciesFulfilled;dependenciesFulfilled=null,e()}}cv.preloadedImages={};cv.preloadedAudios={};function abort(n){throw cv.onAbort&&cv.onAbort(n),n+="",out(n),err$1(n),ABORT=!0,"abort("+n+"). Build with -s ASSERTIONS=1 for more info."}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(n){return String.prototype.startsWith?n.startsWith(dataURIPrefix):n.indexOf(dataURIPrefix)===0}var wasmBinaryFile="opencv.wasm";isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));function getBinary(){try{if(wasmBinary)return new Uint8Array(wasmBinary);var n=tryParseAsDataURI(wasmBinaryFile);if(n)return n;throw"both async and sync fetching of the wasm failed"}catch(e){abort(e)}}function getBinaryPromise(){return!wasmBinary&&typeof fetch=="function"?fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(n){if(!n.ok)throw"failed to load wasm binary file at '"+wasmBinaryFile+"'";return n.arrayBuffer()}).catch(function(){return getBinary()}):new Promise(function(n,e){n(getBinary())})}function createWasm(){var n={env:asmLibraryArg,wasi_unstable:asmLibraryArg};function e(l,a){var s=l.exports;cv.asm=s,removeRunDependency()}addRunDependency();function r(l){e(l.instance)}function t(l){return getBinaryPromise().then(function(a){return WebAssembly.instantiate(a,n)}).then(l,function(a){err$1("failed to asynchronously prepare wasm: "+a),abort(a)})}function o(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch=="function")fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(l){var a=WebAssembly.instantiateStreaming(l,n);return a.then(r,function(s){err$1("wasm streaming compile failed: "+s),err$1("falling back to ArrayBuffer instantiation"),t(r)})});else return t(r)}if(cv.instantiateWasm)try{var i=cv.instantiateWasm(n,e);return i}catch(l){return err$1("cv.instantiateWasm callback failed with error: "+l),!1}return o(),{}}var tempDouble,tempI64;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function _emscripten_set_main_loop_timing(n,e){if(Browser.mainLoop.timingMode=n,Browser.mainLoop.timingValue=e,!Browser.mainLoop.func)return 1;if(n==0)Browser.mainLoop.scheduler=function(){var l=Math.max(0,Browser.mainLoop.tickStartTime+e-_emscripten_get_now())|0;setTimeout(Browser.mainLoop.runner,l)},Browser.mainLoop.method="timeout";else if(n==1)Browser.mainLoop.scheduler=function(){Browser.requestAnimationFrame(Browser.mainLoop.runner)},Browser.mainLoop.method="rAF";else if(n==2){if(typeof setImmediate=="undefined"){var r=[],t="setimmediate",o=function(i){(i.data===t||i.data.target===t)&&(i.stopPropagation(),r.shift()())};addEventListener("message",o,!0),setImmediate=function(l){r.push(l),postMessage(t,"*")}}Browser.mainLoop.scheduler=function(){setImmediate(Browser.mainLoop.runner)},Browser.mainLoop.method="immediate"}return 0}function _emscripten_get_now(){abort()}function _emscripten_set_main_loop(n,e,r,t,o){assert$1(!Browser.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Browser.mainLoop.func=n,Browser.mainLoop.arg=t;var i;typeof t!="undefined"?i=function(){cv.dynCall_vi(n,t)}:i=function(){cv.dynCall_v(n)};var l=Browser.mainLoop.currentlyRunningMainloop;if(Browser.mainLoop.runner=function(){if(!ABORT){if(Browser.mainLoop.queue.length>0){var s=Date.now(),u=Browser.mainLoop.queue.shift();if(u.func(u.arg),Browser.mainLoop.remainingBlockers){var c=Browser.mainLoop.remainingBlockers,f=c%1==0?c-1:Math.floor(c);u.counted?Browser.mainLoop.remainingBlockers=f:(f=f+.5,Browser.mainLoop.remainingBlockers=(8*c+f)/9)}if(console.log('main loop blocker "'+u.name+'" took '+(Date.now()-s)+" ms"),Browser.mainLoop.updateStatus(),l<Browser.mainLoop.currentlyRunningMainloop)return;setTimeout(Browser.mainLoop.runner,0);return}if(!(l<Browser.mainLoop.currentlyRunningMainloop)){if(Browser.mainLoop.currentFrameNumber=Browser.mainLoop.currentFrameNumber+1|0,Browser.mainLoop.timingMode==1&&Browser.mainLoop.timingValue>1&&Browser.mainLoop.currentFrameNumber%Browser.mainLoop.timingValue!=0){Browser.mainLoop.scheduler();return}else Browser.mainLoop.timingMode==0&&(Browser.mainLoop.tickStartTime=_emscripten_get_now());Browser.mainLoop.method==="timeout"&&cv.ctx&&(err$1("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"),Browser.mainLoop.method=""),Browser.mainLoop.runIter(i),!(l<Browser.mainLoop.currentlyRunningMainloop)&&(typeof SDL=="object"&&SDL.audio&&SDL.audio.queueNewAudioData&&SDL.audio.queueNewAudioData(),Browser.mainLoop.scheduler())}}},o||(e&&e>0?_emscripten_set_main_loop_timing(0,1e3/e):_emscripten_set_main_loop_timing(1,1),Browser.mainLoop.scheduler()),r)throw"SimulateInfiniteLoop"}var Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:function(){Browser.mainLoop.scheduler=null,Browser.mainLoop.currentlyRunningMainloop++},resume:function(){Browser.mainLoop.currentlyRunningMainloop++;var n=Browser.mainLoop.timingMode,e=Browser.mainLoop.timingValue,r=Browser.mainLoop.func;Browser.mainLoop.func=null,_emscripten_set_main_loop(r,0,!1,Browser.mainLoop.arg,!0),_emscripten_set_main_loop_timing(n,e),Browser.mainLoop.scheduler()},updateStatus:function(){if(cv.setStatus){var n=cv.statusMessage||"Please wait...",e=Browser.mainLoop.remainingBlockers,r=Browser.mainLoop.expectedBlockers;e?e<r?cv.setStatus(n+" ("+(r-e)+"/"+r+")"):cv.setStatus(n):cv.setStatus("")}},runIter:function(n){if(!ABORT){if(cv.preMainLoop){var e=cv.preMainLoop();if(e===!1)return}try{n()}catch(r){if(r instanceof ExitStatus)return;throw r&&typeof r=="object"&&r.stack&&err$1("exception thrown: "+[r,r.stack]),r}cv.postMainLoop&&cv.postMainLoop()}}},isFullscreen:!1,pointerLock:!1,moduleContextCreatedCallbacks:[],workers:[],init:function(){if(cv.preloadPlugins||(cv.preloadPlugins=[]),Browser.initted)return;Browser.initted=!0;try{new Blob,Browser.hasBlobConstructor=!0}catch{Browser.hasBlobConstructor=!1,console.log("warning: no blob constructor, cannot create blobs with mimetypes")}Browser.BlobBuilder=typeof MozBlobBuilder!="undefined"?MozBlobBuilder:typeof WebKitBlobBuilder!="undefined"?WebKitBlobBuilder:Browser.hasBlobConstructor?null:console.log("warning: no BlobBuilder"),Browser.URLObject=typeof window!="undefined"?window.URL?window.URL:window.webkitURL:void 0,!cv.noImageDecoding&&typeof Browser.URLObject=="undefined"&&(console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),cv.noImageDecoding=!0);var n={};n.canHandle=function(i){return!cv.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(i)},n.handle=function(i,l,a,s){var u=null;if(Browser.hasBlobConstructor)try{u=new Blob([i],{type:Browser.getMimetype(l)}),u.size!==i.length&&(u=new Blob([new Uint8Array(i).buffer],{type:Browser.getMimetype(l)}))}catch(m){warnOnce("Blob constructor present but fails: "+m+"; falling back to blob builder")}if(!u){var c=new Browser.BlobBuilder;c.append(new Uint8Array(i).buffer),u=c.getBlob()}var f=Browser.URLObject.createObjectURL(u),d=new Image;d.onload=function(){assert$1(d.complete,"Image "+l+" could not be decoded");var _=document.createElement("canvas");_.width=d.width,_.height=d.height;var S=_.getContext("2d");S.drawImage(d,0,0),cv.preloadedImages[l]=_,Browser.URLObject.revokeObjectURL(f),a&&a(i)},d.onerror=function(_){console.log("Image "+f+" could not be decoded"),s&&s()},d.src=f},cv.preloadPlugins.push(n);var e={};e.canHandle=function(i){return!cv.noAudioDecoding&&i.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},e.handle=function(i,l,a,s){var u=!1;function c(S){u||(u=!0,cv.preloadedAudios[l]=S,a&&a(i))}function f(){u||(u=!0,cv.preloadedAudios[l]=new Audio,s&&s())}if(Browser.hasBlobConstructor){try{var d=new Blob([i],{type:Browser.getMimetype(l)})}catch{return f()}var m=Browser.URLObject.createObjectURL(d),_=new Audio;_.addEventListener("canplaythrough",function(){c(_)},!1),_.onerror=function(E){if(u)return;console.log("warning: browser could not fully decode audio "+l+", trying slower base64 approach");function $(y){for(var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A="=",P="",C=0,L=0,B=0;B<y.length;B++)for(C=C<<8|y[B],L+=8;L>=6;){var V=C>>L-6&63;L-=6,P+=v[V]}return L==2?(P+=v[(C&3)<<4],P+=A+A):L==4&&(P+=v[(C&15)<<2],P+=A),P}_.src="data:audio/x-"+l.substr(-3)+";base64,"+$(i),c(_)},_.src=m,Browser.safeSetTimeout(function(){c(_)},1e4)}else return f()},cv.preloadPlugins.push(e);function r(){Browser.pointerLock=document.pointerLockElement===cv.canvas||document.mozPointerLockElement===cv.canvas||document.webkitPointerLockElement===cv.canvas||document.msPointerLockElement===cv.canvas}var t=cv.canvas;t&&(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock||t.msRequestPointerLock||function(){},t.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},t.exitPointerLock=t.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",r,!1),document.addEventListener("mozpointerlockchange",r,!1),document.addEventListener("webkitpointerlockchange",r,!1),document.addEventListener("mspointerlockchange",r,!1),cv.elementPointerLock&&t.addEventListener("click",function(o){!Browser.pointerLock&&cv.canvas.requestPointerLock&&(cv.canvas.requestPointerLock(),o.preventDefault())},!1))},createContext:function(n,e,r,t){if(e&&cv.ctx&&n==cv.canvas)return cv.ctx;var o,i;if(e){var l={antialias:!1,alpha:!1,majorVersion:1};if(t)for(var a in t)l[a]=t[a];typeof GL!="undefined"&&(i=GL.createContext(n,l),i&&(o=GL.getContext(i).GLctx))}else o=n.getContext("2d");return o?(r&&(e||assert$1(typeof GLctx=="undefined","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),cv.ctx=o,e&&GL.makeContextCurrent(i),cv.useWebGL=e,Browser.moduleContextCreatedCallbacks.forEach(function(s){s()}),Browser.init()),o):null},destroyContext:function(n,e,r){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen:function(n,e,r){Browser.lockPointer=n,Browser.resizeCanvas=e,Browser.vrDevice=r,typeof Browser.lockPointer=="undefined"&&(Browser.lockPointer=!0),typeof Browser.resizeCanvas=="undefined"&&(Browser.resizeCanvas=!1),typeof Browser.vrDevice=="undefined"&&(Browser.vrDevice=null);var t=cv.canvas;function o(){Browser.isFullscreen=!1;var l=t.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===l?(t.exitFullscreen=Browser.exitFullscreen,Browser.lockPointer&&t.requestPointerLock(),Browser.isFullscreen=!0,Browser.resizeCanvas?Browser.setFullscreenCanvasSize():Browser.updateCanvasDimensions(t)):(l.parentNode.insertBefore(t,l),l.parentNode.removeChild(l),Browser.resizeCanvas?Browser.setWindowedCanvasSize():Browser.updateCanvasDimensions(t)),cv.onFullScreen&&cv.onFullScreen(Browser.isFullscreen),cv.onFullscreen&&cv.onFullscreen(Browser.isFullscreen)}Browser.fullscreenHandlersInstalled||(Browser.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",o,!1),document.addEventListener("mozfullscreenchange",o,!1),document.addEventListener("webkitfullscreenchange",o,!1),document.addEventListener("MSFullscreenChange",o,!1));var i=document.createElement("div");t.parentNode.insertBefore(i,t),i.appendChild(t),i.requestFullscreen=i.requestFullscreen||i.mozRequestFullScreen||i.msRequestFullscreen||(i.webkitRequestFullscreen?function(){i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}:null)||(i.webkitRequestFullScreen?function(){i.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),r?i.requestFullscreen({vrDisplay:r}):i.requestFullscreen()},requestFullScreen:function(n,e,r){return err$1("Browser.requestFullScreen() is deprecated. Please call Browser.requestFullscreen instead."),Browser.requestFullScreen=function(t,o,i){return Browser.requestFullscreen(t,o,i)},Browser.requestFullscreen(n,e,r)},exitFullscreen:function(){if(!Browser.isFullscreen)return!1;var n=document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){};return n.apply(document,[]),!0},nextRAF:0,fakeRequestAnimationFrame:function(n){var e=Date.now();if(Browser.nextRAF===0)Browser.nextRAF=e+1e3/60;else for(;e+2>=Browser.nextRAF;)Browser.nextRAF+=1e3/60;var r=Math.max(Browser.nextRAF-e,0);setTimeout(n,r)},requestAnimationFrame:function(n){if(typeof requestAnimationFrame=="function"){requestAnimationFrame(n);return}var e=Browser.fakeRequestAnimationFrame;e(n)},safeCallback:function(n){return function(){if(!ABORT)return n.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){Browser.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(Browser.allowAsyncCallbacks=!0,Browser.queuedAsyncCallbacks.length>0){var n=Browser.queuedAsyncCallbacks;Browser.queuedAsyncCallbacks=[],n.forEach(function(e){e()})}},safeRequestAnimationFrame:function(n){return Browser.requestAnimationFrame(function(){ABORT||(Browser.allowAsyncCallbacks?n():Browser.queuedAsyncCallbacks.push(n))})},safeSetTimeout:function(n,e){return setTimeout(function(){ABORT||(Browser.allowAsyncCallbacks?n():Browser.queuedAsyncCallbacks.push(n))},e)},safeSetInterval:function(n,e){return setInterval(function(){ABORT||Browser.allowAsyncCallbacks&&n()},e)},getMimetype:function(n){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[n.substr(n.lastIndexOf(".")+1)]},getUserMedia:function(n){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(n)},getMovementX:function(n){return n.movementX||n.mozMovementX||n.webkitMovementX||0},getMovementY:function(n){return n.movementY||n.mozMovementY||n.webkitMovementY||0},getMouseWheelDelta:function(n){var e=0;switch(n.type){case"DOMMouseScroll":e=n.detail/3;break;case"mousewheel":e=n.wheelDelta/120;break;case"wheel":switch(e=n.deltaY,n.deltaMode){case 0:e/=100;break;case 1:e/=3;break;case 2:e*=80;break;default:throw"unrecognized mouse wheel delta mode: "+n.deltaMode}break;default:throw"unrecognized mouse wheel event: "+n.type}return e},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function(n){if(Browser.pointerLock)n.type!="mousemove"&&"mozMovementX"in n?Browser.mouseMovementX=Browser.mouseMovementY=0:(Browser.mouseMovementX=Browser.getMovementX(n),Browser.mouseMovementY=Browser.getMovementY(n)),typeof SDL!="undefined"?(Browser.mouseX=SDL.mouseX+Browser.mouseMovementX,Browser.mouseY=SDL.mouseY+Browser.mouseMovementY):(Browser.mouseX+=Browser.mouseMovementX,Browser.mouseY+=Browser.mouseMovementY);else{var e=cv.canvas.getBoundingClientRect(),r=cv.canvas.width,t=cv.canvas.height,o=typeof window.scrollX!="undefined"?window.scrollX:window.pageXOffset,i=typeof window.scrollY!="undefined"?window.scrollY:window.pageYOffset;if(n.type==="touchstart"||n.type==="touchend"||n.type==="touchmove"){var l=n.touch;if(l===void 0)return;var a=l.pageX-(o+e.left),s=l.pageY-(i+e.top);a=a*(r/e.width),s=s*(t/e.height);var u={x:a,y:s};if(n.type==="touchstart")Browser.lastTouches[l.identifier]=u,Browser.touches[l.identifier]=u;else if(n.type==="touchend"||n.type==="touchmove"){var c=Browser.touches[l.identifier];c||(c=u),Browser.lastTouches[l.identifier]=c,Browser.touches[l.identifier]=u}return}var f=n.pageX-(o+e.left),d=n.pageY-(i+e.top);f=f*(r/e.width),d=d*(t/e.height),Browser.mouseMovementX=f-Browser.mouseX,Browser.mouseMovementY=d-Browser.mouseY,Browser.mouseX=f,Browser.mouseY=d}},asyncLoad:function(n,e,r,t){var o=t?"":"al "+n;readAsync(n,function(i){assert$1(i,'Loading data file "'+n+'" failed (no arrayBuffer).'),e(new Uint8Array(i)),o&&removeRunDependency()},function(i){if(r)r();else throw'Loading data file "'+n+'" failed.'}),o&&addRunDependency()},resizeListeners:[],updateResizeListeners:function(){var n=cv.canvas;Browser.resizeListeners.forEach(function(e){e(n.width,n.height)})},setCanvasSize:function(n,e,r){var t=cv.canvas;Browser.updateCanvasDimensions(t,n,e),r||Browser.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize:function(){if(typeof SDL!="undefined"){var n=HEAPU32[SDL.screen>>2];n=n|8388608,HEAP32[SDL.screen>>2]=n}Browser.updateCanvasDimensions(cv.canvas),Browser.updateResizeListeners()},setWindowedCanvasSize:function(){if(typeof SDL!="undefined"){var n=HEAPU32[SDL.screen>>2];n=n&-8388609,HEAP32[SDL.screen>>2]=n}Browser.updateCanvasDimensions(cv.canvas),Browser.updateResizeListeners()},updateCanvasDimensions:function(n,e,r){e&&r?(n.widthNative=e,n.heightNative=r):(e=n.widthNative,r=n.heightNative);var t=e,o=r;if(cv.forcedAspectRatio&&cv.forcedAspectRatio>0&&(t/o<cv.forcedAspectRatio?t=Math.round(o*cv.forcedAspectRatio):o=Math.round(t/cv.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===n.parentNode&&typeof screen!="undefined"){var i=Math.min(screen.width/t,screen.height/o);t=Math.round(t*i),o=Math.round(o*i)}Browser.resizeCanvas?(n.width!=t&&(n.width=t),n.height!=o&&(n.height=o),typeof n.style!="undefined"&&(n.style.removeProperty("width"),n.style.removeProperty("height"))):(n.width!=e&&(n.width=e),n.height!=r&&(n.height=r),typeof n.style!="undefined"&&(t!=e||o!=r?(n.style.setProperty("width",t+"px","important"),n.style.setProperty("height",o+"px","important")):(n.style.removeProperty("width"),n.style.removeProperty("height"))))},wgetRequests:{},nextWgetRequestHandle:0,getNextWgetRequestHandle:function(){var n=Browser.nextWgetRequestHandle;return Browser.nextWgetRequestHandle++,n}};function demangle(n){var e=cv.___cxa_demangle||cv.__cxa_demangle;assert$1(e);try{var r=n;r.startsWith("__Z")&&(r=r.substr(1));var t=lengthBytesUTF8(r)+1,o=_malloc(t);stringToUTF8(r,o,t);var i=_malloc(4),l=e(o,0,0,i);if(HEAP32[i>>2]===0&&l)return UTF8ToString(l)}catch{}finally{o&&_free(o),i&&_free(i),l&&_free(l)}return n}function demangleAll(n){var e=/\b_Z[\w\d_]+/g;return n.replace(e,function(r){var t=demangle(r);return r===t?r:t+" ["+r+"]"})}function jsStackTrace(){var n=new Error;if(!n.stack){try{throw new Error(0)}catch(e){n=e}if(!n.stack)return"(no stack trace available)"}return n.stack.toString()}function stackTrace(){var n=jsStackTrace();return cv.extraStackTrace&&(n+=`
- `+cv.extraStackTrace()),demangleAll(n)}function ___cxa_allocate_exception(n){return _malloc(n)}function _atexit(n,e){}function ___cxa_atexit(){return _atexit.apply(null,arguments)}var ___exception_infos={};function ___cxa_throw(n,e,r){throw ___exception_infos[n]={ptr:n,adjusted:[n],type:e,destructor:r,refcount:0,caught:!1,rethrown:!1},"uncaught_exception"in __ZSt18uncaught_exceptionv?__ZSt18uncaught_exceptionv.uncaught_exceptions++:__ZSt18uncaught_exceptionv.uncaught_exceptions=1,n}function ___lock(){}function ___setErrNo(n){return cv.___errno_location&&(HEAP32[cv.___errno_location()>>2]=n),n}function ___map_file(n,e){return ___setErrNo(63),-1}var PATH={splitPath:function(n){var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(n).slice(1)},normalizeArray:function(n,e){for(var r=0,t=n.length-1;t>=0;t--){var o=n[t];o==="."?n.splice(t,1):o===".."?(n.splice(t,1),r++):r&&(n.splice(t,1),r--)}if(e)for(;r;r--)n.unshift("..");return n},normalize:function(n){var e=n.charAt(0)==="/",r=n.substr(-1)==="/";return n=PATH.normalizeArray(n.split("/").filter(function(t){return!!t}),!e).join("/"),!n&&!e&&(n="."),n&&r&&(n+="/"),(e?"/":"")+n},dirname:function(n){var e=PATH.splitPath(n),r=e[0],t=e[1];return!r&&!t?".":(t&&(t=t.substr(0,t.length-1)),r+t)},basename:function(n){if(n==="/")return"/";var e=n.lastIndexOf("/");return e===-1?n:n.substr(e+1)},extname:function(n){return PATH.splitPath(n)[3]},join:function(){var n=Array.prototype.slice.call(arguments,0);return PATH.normalize(n.join("/"))},join2:function(n,e){return PATH.normalize(n+"/"+e)}},PATH_FS={resolve:function(){for(var n="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var t=r>=0?arguments[r]:FS.cwd();if(typeof t!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";n=t+"/"+n,e=t.charAt(0)==="/"}return n=PATH.normalizeArray(n.split("/").filter(function(o){return!!o}),!e).join("/"),(e?"/":"")+n||"."},relative:function(n,e){n=PATH_FS.resolve(n).substr(1),e=PATH_FS.resolve(e).substr(1);function r(u){for(var c=0;c<u.length&&u[c]==="";c++);for(var f=u.length-1;f>=0&&u[f]==="";f--);return c>f?[]:u.slice(c,f-c+1)}for(var t=r(n.split("/")),o=r(e.split("/")),i=Math.min(t.length,o.length),l=i,a=0;a<i;a++)if(t[a]!==o[a]){l=a;break}for(var s=[],a=l;a<t.length;a++)s.push("..");return s=s.concat(o.slice(l)),s.join("/")}},TTY={ttys:[],init:function(){},shutdown:function(){},register:function(n,e){TTY.ttys[n]={input:[],output:[],ops:e},FS.registerDevice(n,TTY.stream_ops)},stream_ops:{open:function(n){var e=TTY.ttys[n.node.rdev];if(!e)throw new FS.ErrnoError(43);n.tty=e,n.seekable=!1},close:function(n){n.tty.ops.flush(n.tty)},flush:function(n){n.tty.ops.flush(n.tty)},read:function(n,e,r,t,o){if(!n.tty||!n.tty.ops.get_char)throw new FS.ErrnoError(60);for(var i=0,l=0;l<t;l++){var a;try{a=n.tty.ops.get_char(n.tty)}catch{throw new FS.ErrnoError(29)}if(a===void 0&&i===0)throw new FS.ErrnoError(6);if(a==null)break;i++,e[r+l]=a}return i&&(n.node.timestamp=Date.now()),i},write:function(n,e,r,t,o){if(!n.tty||!n.tty.ops.put_char)throw new FS.ErrnoError(60);try{for(var i=0;i<t;i++)n.tty.ops.put_char(n.tty,e[r+i])}catch{throw new FS.ErrnoError(29)}return t&&(n.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(n){if(!n.input.length){var e=null;if(typeof window!="undefined"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
- `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
- `)),!e)return null;n.input=intArrayFromString(e,!0)}return n.input.shift()},put_char:function(n,e){e===null||e===10?(out(UTF8ArrayToString(n.output,0)),n.output=[]):e!=0&&n.output.push(e)},flush:function(n){n.output&&n.output.length>0&&(out(UTF8ArrayToString(n.output,0)),n.output=[])}},default_tty1_ops:{put_char:function(n,e){e===null||e===10?(err$1(UTF8ArrayToString(n.output,0)),n.output=[]):e!=0&&n.output.push(e)},flush:function(n){n.output&&n.output.length>0&&(err$1(UTF8ArrayToString(n.output,0)),n.output=[])}}},MEMFS={ops_table:null,mount:function(n){return MEMFS.createNode(null,"/",16895,0)},createNode:function(n,e,r,t){if(FS.isBlkdev(r)||FS.isFIFO(r))throw new FS.ErrnoError(63);MEMFS.ops_table||(MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}});var o=FS.createNode(n,e,r,t);return FS.isDir(o.mode)?(o.node_ops=MEMFS.ops_table.dir.node,o.stream_ops=MEMFS.ops_table.dir.stream,o.contents={}):FS.isFile(o.mode)?(o.node_ops=MEMFS.ops_table.file.node,o.stream_ops=MEMFS.ops_table.file.stream,o.usedBytes=0,o.contents=null):FS.isLink(o.mode)?(o.node_ops=MEMFS.ops_table.link.node,o.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(o.mode)&&(o.node_ops=MEMFS.ops_table.chrdev.node,o.stream_ops=MEMFS.ops_table.chrdev.stream),o.timestamp=Date.now(),n&&(n.contents[e]=o),o},getFileDataAsRegularArray:function(n){if(n.contents&&n.contents.subarray){for(var e=[],r=0;r<n.usedBytes;++r)e.push(n.contents[r]);return e}return n.contents},getFileDataAsTypedArray:function(n){return n.contents?n.contents.subarray?n.contents.subarray(0,n.usedBytes):new Uint8Array(n.contents):new Uint8Array},expandFileStorage:function(n,e){var r=n.contents?n.contents.length:0;if(!(r>=e)){var t=1024*1024;e=Math.max(e,r*(r<t?2:1.125)|0),r!=0&&(e=Math.max(e,256));var o=n.contents;n.contents=new Uint8Array(e),n.usedBytes>0&&n.contents.set(o.subarray(0,n.usedBytes),0)}},resizeFileStorage:function(n,e){if(n.usedBytes!=e){if(e==0){n.contents=null,n.usedBytes=0;return}if(!n.contents||n.contents.subarray){var r=n.contents;n.contents=new Uint8Array(new ArrayBuffer(e)),r&&n.contents.set(r.subarray(0,Math.min(e,n.usedBytes))),n.usedBytes=e;return}if(n.contents||(n.contents=[]),n.contents.length>e)n.contents.length=e;else for(;n.contents.length<e;)n.contents.push(0);n.usedBytes=e}},node_ops:{getattr:function(n){var e={};return e.dev=FS.isChrdev(n.mode)?n.id:1,e.ino=n.id,e.mode=n.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=n.rdev,FS.isDir(n.mode)?e.size=4096:FS.isFile(n.mode)?e.size=n.usedBytes:FS.isLink(n.mode)?e.size=n.link.length:e.size=0,e.atime=new Date(n.timestamp),e.mtime=new Date(n.timestamp),e.ctime=new Date(n.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr:function(n,e){e.mode!==void 0&&(n.mode=e.mode),e.timestamp!==void 0&&(n.timestamp=e.timestamp),e.size!==void 0&&MEMFS.resizeFileStorage(n,e.size)},lookup:function(n,e){throw FS.genericErrors[44]},mknod:function(n,e,r,t){return MEMFS.createNode(n,e,r,t)},rename:function(n,e,r){if(FS.isDir(n.mode)){var t;try{t=FS.lookupNode(e,r)}catch{}if(t)for(var o in t.contents)throw new FS.ErrnoError(55)}delete n.parent.contents[n.name],n.name=r,e.contents[r]=n,n.parent=e},unlink:function(n,e){delete n.contents[e]},rmdir:function(n,e){var r=FS.lookupNode(n,e);for(var t in r.contents)throw new FS.ErrnoError(55);delete n.contents[e]},readdir:function(n){var e=[".",".."];for(var r in n.contents)!n.contents.hasOwnProperty(r)||e.push(r);return e},symlink:function(n,e,r){var t=MEMFS.createNode(n,e,41471,0);return t.link=r,t},readlink:function(n){if(!FS.isLink(n.mode))throw new FS.ErrnoError(28);return n.link}},stream_ops:{read:function(n,e,r,t,o){var i=n.node.contents;if(o>=n.node.usedBytes)return 0;var l=Math.min(n.node.usedBytes-o,t);if(l>8&&i.subarray)e.set(i.subarray(o,o+l),r);else for(var a=0;a<l;a++)e[r+a]=i[o+a];return l},write:function(n,e,r,t,o,i){if(i=!1,!t)return 0;var l=n.node;if(l.timestamp=Date.now(),e.subarray&&(!l.contents||l.contents.subarray)){if(i)return l.contents=e.subarray(r,r+t),l.usedBytes=t,t;if(l.usedBytes===0&&o===0)return l.contents=new Uint8Array(e.subarray(r,r+t)),l.usedBytes=t,t;if(o+t<=l.usedBytes)return l.contents.set(e.subarray(r,r+t),o),t}if(MEMFS.expandFileStorage(l,o+t),l.contents.subarray&&e.subarray)l.contents.set(e.subarray(r,r+t),o);else for(var a=0;a<t;a++)l.contents[o+a]=e[r+a];return l.usedBytes=Math.max(l.usedBytes,o+t),t},llseek:function(n,e,r){var t=e;if(r===1?t+=n.position:r===2&&FS.isFile(n.node.mode)&&(t+=n.node.usedBytes),t<0)throw new FS.ErrnoError(28);return t},allocate:function(n,e,r){MEMFS.expandFileStorage(n.node,e+r),n.node.usedBytes=Math.max(n.node.usedBytes,e+r)},mmap:function(n,e,r,t,o,i,l){if(!FS.isFile(n.node.mode))throw new FS.ErrnoError(43);var a,s,u=n.node.contents;if(!(l&2)&&(u.buffer===e||u.buffer===e.buffer))s=!1,a=u.byteOffset;else{(o>0||o+t<n.node.usedBytes)&&(u.subarray?u=u.subarray(o,o+t):u=Array.prototype.slice.call(u,o,o+t)),s=!0;var c=e.buffer==HEAP8.buffer;if(a=_malloc(t),!a)throw new FS.ErrnoError(48);(c?HEAP8:e).set(u,a)}return{ptr:a,allocated:s}},msync:function(n,e,r,t,o){if(!FS.isFile(n.node.mode))throw new FS.ErrnoError(43);return o&2||MEMFS.stream_ops.write(n,e,0,t,r,!1),0}}},IDBFS={dbs:{},indexedDB:function(){if(typeof indexedDB!="undefined")return indexedDB;var n=null;return typeof window=="object"&&(n=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),assert$1(n,"IDBFS used, but indexedDB not supported"),n},DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function(n){return MEMFS.mount.apply(null,arguments)},syncfs:function(n,e,r){IDBFS.getLocalSet(n,function(t,o){if(t)return r(t);IDBFS.getRemoteSet(n,function(i,l){if(i)return r(i);var a=e?l:o,s=e?o:l;IDBFS.reconcile(a,s,r)})})},getDB:function(n,e){var r=IDBFS.dbs[n];if(r)return e(null,r);var t;try{t=IDBFS.indexedDB().open(n,IDBFS.DB_VERSION)}catch(o){return e(o)}if(!t)return e("Unable to connect to IndexedDB");t.onupgradeneeded=function(o){var i=o.target.result,l=o.target.transaction,a;i.objectStoreNames.contains(IDBFS.DB_STORE_NAME)?a=l.objectStore(IDBFS.DB_STORE_NAME):a=i.createObjectStore(IDBFS.DB_STORE_NAME),a.indexNames.contains("timestamp")||a.createIndex("timestamp","timestamp",{unique:!1})},t.onsuccess=function(){r=t.result,IDBFS.dbs[n]=r,e(null,r)},t.onerror=function(o){e(this.error),o.preventDefault()}},getLocalSet:function(n,e){var r={};function t(s){return s!=="."&&s!==".."}function o(s){return function(u){return PATH.join2(s,u)}}for(var i=FS.readdir(n.mountpoint).filter(t).map(o(n.mountpoint));i.length;){var l=i.pop(),a;try{a=FS.stat(l)}catch(s){return e(s)}FS.isDir(a.mode)&&i.push.apply(i,FS.readdir(l).filter(t).map(o(l))),r[l]={timestamp:a.mtime}}return e(null,{type:"local",entries:r})},getRemoteSet:function(n,e){var r={};IDBFS.getDB(n.mountpoint,function(t,o){if(t)return e(t);try{var i=o.transaction([IDBFS.DB_STORE_NAME],"readonly");i.onerror=function(s){e(this.error),s.preventDefault()};var l=i.objectStore(IDBFS.DB_STORE_NAME),a=l.index("timestamp");a.openKeyCursor().onsuccess=function(s){var u=s.target.result;if(!u)return e(null,{type:"remote",db:o,entries:r});r[u.primaryKey]={timestamp:u.key},u.continue()}}catch(s){return e(s)}})},loadLocalEntry:function(n,e){var r,t;try{var o=FS.lookupPath(n);t=o.node,r=FS.stat(n)}catch(i){return e(i)}return FS.isDir(r.mode)?e(null,{timestamp:r.mtime,mode:r.mode}):FS.isFile(r.mode)?(t.contents=MEMFS.getFileDataAsTypedArray(t),e(null,{timestamp:r.mtime,mode:r.mode,contents:t.contents})):e(new Error("node type not supported"))},storeLocalEntry:function(n,e,r){try{if(FS.isDir(e.mode))FS.mkdir(n,e.mode);else if(FS.isFile(e.mode))FS.writeFile(n,e.contents,{canOwn:!0});else return r(new Error("node type not supported"));FS.chmod(n,e.mode),FS.utime(n,e.timestamp,e.timestamp)}catch(t){return r(t)}r(null)},removeLocalEntry:function(n,e){try{var r=FS.lookupPath(n),t=FS.stat(n);FS.isDir(t.mode)?FS.rmdir(n):FS.isFile(t.mode)&&FS.unlink(n)}catch(o){return e(o)}e(null)},loadRemoteEntry:function(n,e,r){var t=n.get(e);t.onsuccess=function(o){r(null,o.target.result)},t.onerror=function(o){r(this.error),o.preventDefault()}},storeRemoteEntry:function(n,e,r,t){var o=n.put(r,e);o.onsuccess=function(){t(null)},o.onerror=function(i){t(this.error),i.preventDefault()}},removeRemoteEntry:function(n,e,r){var t=n.delete(e);t.onsuccess=function(){r(null)},t.onerror=function(o){r(this.error),o.preventDefault()}},reconcile:function(n,e,r){var t=0,o=[];Object.keys(n.entries).forEach(function(f){var d=n.entries[f],m=e.entries[f];(!m||d.timestamp>m.timestamp)&&(o.push(f),t++)});var i=[];if(Object.keys(e.entries).forEach(function(f){e.entries[f];var d=n.entries[f];d||(i.push(f),t++)}),!t)return r(null);var l=!1,a=n.type==="remote"?n.db:e.db,s=a.transaction([IDBFS.DB_STORE_NAME],"readwrite"),u=s.objectStore(IDBFS.DB_STORE_NAME);function c(f){if(f&&!l)return l=!0,r(f)}s.onerror=function(f){c(this.error),f.preventDefault()},s.oncomplete=function(f){l||r(null)},o.sort().forEach(function(f){e.type==="local"?IDBFS.loadRemoteEntry(u,f,function(d,m){if(d)return c(d);IDBFS.storeLocalEntry(f,m,c)}):IDBFS.loadLocalEntry(f,function(d,m){if(d)return c(d);IDBFS.storeRemoteEntry(u,f,m,c)})}),i.sort().reverse().forEach(function(f){e.type==="local"?IDBFS.removeLocalEntry(f,c):IDBFS.removeRemoteEntry(u,f,c)})}},FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(n){if(!(n instanceof FS.ErrnoError))throw n+" : "+stackTrace();return ___setErrNo(n.errno)},lookupPath:function(n,e){if(n=PATH_FS.resolve(FS.cwd(),n),e=e||{},!n)return{path:"",node:null};var r={follow_mount:!0,recurse_count:0};for(var t in r)e[t]===void 0&&(e[t]=r[t]);if(e.recurse_count>8)throw new FS.ErrnoError(32);for(var o=PATH.normalizeArray(n.split("/").filter(function(d){return!!d}),!1),i=FS.root,l="/",a=0;a<o.length;a++){var s=a===o.length-1;if(s&&e.parent)break;if(i=FS.lookupNode(i,o[a]),l=PATH.join2(l,o[a]),FS.isMountpoint(i)&&(!s||s&&e.follow_mount)&&(i=i.mounted.root),!s||e.follow)for(var u=0;FS.isLink(i.mode);){var c=FS.readlink(l);l=PATH_FS.resolve(PATH.dirname(l),c);var f=FS.lookupPath(l,{recurse_count:e.recurse_count});if(i=f.node,u++>40)throw new FS.ErrnoError(32)}}return{path:l,node:i}},getPath:function(n){for(var e;;){if(FS.isRoot(n)){var r=n.mount.mountpoint;return e?r[r.length-1]!=="/"?r+"/"+e:r+e:r}e=e?n.name+"/"+e:n.name,n=n.parent}},hashName:function(n,e){for(var r=0,t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t)|0;return(n+r>>>0)%FS.nameTable.length},hashAddNode:function(n){var e=FS.hashName(n.parent.id,n.name);n.name_next=FS.nameTable[e],FS.nameTable[e]=n},hashRemoveNode:function(n){var e=FS.hashName(n.parent.id,n.name);if(FS.nameTable[e]===n)FS.nameTable[e]=n.name_next;else for(var r=FS.nameTable[e];r;){if(r.name_next===n){r.name_next=n.name_next;break}r=r.name_next}},lookupNode:function(n,e){var r=FS.mayLookup(n);if(r)throw new FS.ErrnoError(r,n);for(var t=FS.hashName(n.id,e),o=FS.nameTable[t];o;o=o.name_next){var i=o.name;if(o.parent.id===n.id&&i===e)return o}return FS.lookup(n,e)},createNode:function(n,e,r,t){if(!FS.FSNode){FS.FSNode=function(a,s,u,c){a||(a=this),this.parent=a,this.mount=a.mount,this.mounted=null,this.id=FS.nextInode++,this.name=s,this.mode=u,this.node_ops={},this.stream_ops={},this.rdev=c},FS.FSNode.prototype={};var o=365,i=146;Object.defineProperties(FS.FSNode.prototype,{read:{get:function(){return(this.mode&o)===o},set:function(a){a?this.mode|=o:this.mode&=~o}},write:{get:function(){return(this.mode&i)===i},set:function(a){a?this.mode|=i:this.mode&=~i}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}})}var l=new FS.FSNode(n,e,r,t);return FS.hashAddNode(l),l},destroyNode:function(n){FS.hashRemoveNode(n)},isRoot:function(n){return n===n.parent},isMountpoint:function(n){return!!n.mounted},isFile:function(n){return(n&61440)===32768},isDir:function(n){return(n&61440)===16384},isLink:function(n){return(n&61440)===40960},isChrdev:function(n){return(n&61440)===8192},isBlkdev:function(n){return(n&61440)===24576},isFIFO:function(n){return(n&61440)===4096},isSocket:function(n){return(n&49152)===49152},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(n){var e=FS.flagModes[n];if(typeof e=="undefined")throw new Error("Unknown file open mode: "+n);return e},flagsToPermissionString:function(n){var e=["r","w","rw"][n&3];return n&512&&(e+="w"),e},nodePermissions:function(n,e){return FS.ignorePermissions?0:e.indexOf("r")!==-1&&!(n.mode&292)||e.indexOf("w")!==-1&&!(n.mode&146)||e.indexOf("x")!==-1&&!(n.mode&73)?2:0},mayLookup:function(n){var e=FS.nodePermissions(n,"x");return e||(n.node_ops.lookup?0:2)},mayCreate:function(n,e){try{var r=FS.lookupNode(n,e);return 20}catch{}return FS.nodePermissions(n,"wx")},mayDelete:function(n,e,r){var t;try{t=FS.lookupNode(n,e)}catch(i){return i.errno}var o=FS.nodePermissions(n,"wx");if(o)return o;if(r){if(!FS.isDir(t.mode))return 54;if(FS.isRoot(t)||FS.getPath(t)===FS.cwd())return 10}else if(FS.isDir(t.mode))return 31;return 0},mayOpen:function(n,e){return n?FS.isLink(n.mode)?32:FS.isDir(n.mode)&&(FS.flagsToPermissionString(e)!=="r"||e&512)?31:FS.nodePermissions(n,FS.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd:function(n,e){n=n||0,e=e||FS.MAX_OPEN_FDS;for(var r=n;r<=e;r++)if(!FS.streams[r])return r;throw new FS.ErrnoError(33)},getStream:function(n){return FS.streams[n]},createStream:function(n,e,r){FS.FSStream||(FS.FSStream=function(){},FS.FSStream.prototype={},Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(l){this.node=l}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}));var t=new FS.FSStream;for(var o in n)t[o]=n[o];n=t;var i=FS.nextfd(e,r);return n.fd=i,FS.streams[i]=n,n},closeStream:function(n){FS.streams[n]=null},chrdev_stream_ops:{open:function(n){var e=FS.getDevice(n.node.rdev);n.stream_ops=e.stream_ops,n.stream_ops.open&&n.stream_ops.open(n)},llseek:function(){throw new FS.ErrnoError(70)}},major:function(n){return n>>8},minor:function(n){return n&255},makedev:function(n,e){return n<<8|e},registerDevice:function(n,e){FS.devices[n]={stream_ops:e}},getDevice:function(n){return FS.devices[n]},getMounts:function(n){for(var e=[],r=[n];r.length;){var t=r.pop();e.push(t),r.push.apply(r,t.mounts)}return e},syncfs:function(n,e){typeof n=="function"&&(e=n,n=!1),FS.syncFSRequests++,FS.syncFSRequests>1&&console.log("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var r=FS.getMounts(FS.root.mount),t=0;function o(l){return FS.syncFSRequests--,e(l)}function i(l){if(l)return i.errored?void 0:(i.errored=!0,o(l));++t>=r.length&&o(null)}r.forEach(function(l){if(!l.type.syncfs)return i(null);l.type.syncfs(l,n,i)})},mount:function(n,e,r){var t=r==="/",o=!r,i;if(t&&FS.root)throw new FS.ErrnoError(10);if(!t&&!o){var l=FS.lookupPath(r,{follow_mount:!1});if(r=l.path,i=l.node,FS.isMountpoint(i))throw new FS.ErrnoError(10);if(!FS.isDir(i.mode))throw new FS.ErrnoError(54)}var a={type:n,opts:e,mountpoint:r,mounts:[]},s=n.mount(a);return s.mount=a,a.root=s,t?FS.root=s:i&&(i.mounted=a,i.mount&&i.mount.mounts.push(a)),s},unmount:function(n){var e=FS.lookupPath(n,{follow_mount:!1});if(!FS.isMountpoint(e.node))throw new FS.ErrnoError(28);var r=e.node,t=r.mounted,o=FS.getMounts(t);Object.keys(FS.nameTable).forEach(function(l){for(var a=FS.nameTable[l];a;){var s=a.name_next;o.indexOf(a.mount)!==-1&&FS.destroyNode(a),a=s}}),r.mounted=null;var i=r.mount.mounts.indexOf(t);r.mount.mounts.splice(i,1)},lookup:function(n,e){return n.node_ops.lookup(n,e)},mknod:function(n,e,r){var t=FS.lookupPath(n,{parent:!0}),o=t.node,i=PATH.basename(n);if(!i||i==="."||i==="..")throw new FS.ErrnoError(28);var l=FS.mayCreate(o,i);if(l)throw new FS.ErrnoError(l);if(!o.node_ops.mknod)throw new FS.ErrnoError(63);return o.node_ops.mknod(o,i,e,r)},create:function(n,e){return e=e!==void 0?e:438,e&=4095,e|=32768,FS.mknod(n,e,0)},mkdir:function(n,e){return e=e!==void 0?e:511,e&=1023,e|=16384,FS.mknod(n,e,0)},mkdirTree:function(n,e){for(var r=n.split("/"),t="",o=0;o<r.length;++o)if(!!r[o]){t+="/"+r[o];try{FS.mkdir(t,e)}catch(i){if(i.errno!=20)throw i}}},mkdev:function(n,e,r){return typeof r=="undefined"&&(r=e,e=438),e|=8192,FS.mknod(n,e,r)},symlink:function(n,e){if(!PATH_FS.resolve(n))throw new FS.ErrnoError(44);var r=FS.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new FS.ErrnoError(44);var o=PATH.basename(e),i=FS.mayCreate(t,o);if(i)throw new FS.ErrnoError(i);if(!t.node_ops.symlink)throw new FS.ErrnoError(63);return t.node_ops.symlink(t,o,n)},rename:function(n,e){var r=PATH.dirname(n),t=PATH.dirname(e),o=PATH.basename(n),i=PATH.basename(e),l,a,s;try{l=FS.lookupPath(n,{parent:!0}),a=l.node,l=FS.lookupPath(e,{parent:!0}),s=l.node}catch{throw new FS.ErrnoError(10)}if(!a||!s)throw new FS.ErrnoError(44);if(a.mount!==s.mount)throw new FS.ErrnoError(75);var u=FS.lookupNode(a,o),c=PATH_FS.relative(n,t);if(c.charAt(0)!==".")throw new FS.ErrnoError(28);if(c=PATH_FS.relative(e,r),c.charAt(0)!==".")throw new FS.ErrnoError(55);var f;try{f=FS.lookupNode(s,i)}catch{}if(u!==f){var d=FS.isDir(u.mode),m=FS.mayDelete(a,o,d);if(m)throw new FS.ErrnoError(m);if(m=f?FS.mayDelete(s,i,d):FS.mayCreate(s,i),m)throw new FS.ErrnoError(m);if(!a.node_ops.rename)throw new FS.ErrnoError(63);if(FS.isMountpoint(u)||f&&FS.isMountpoint(f))throw new FS.ErrnoError(10);if(s!==a&&(m=FS.nodePermissions(a,"w"),m))throw new FS.ErrnoError(m);try{FS.trackingDelegate.willMovePath&&FS.trackingDelegate.willMovePath(n,e)}catch(_){console.log("FS.trackingDelegate['willMovePath']('"+n+"', '"+e+"') threw an exception: "+_.message)}FS.hashRemoveNode(u);try{a.node_ops.rename(u,s,i)}catch(_){throw _}finally{FS.hashAddNode(u)}try{FS.trackingDelegate.onMovePath&&FS.trackingDelegate.onMovePath(n,e)}catch(_){console.log("FS.trackingDelegate['onMovePath']('"+n+"', '"+e+"') threw an exception: "+_.message)}}},rmdir:function(n){var e=FS.lookupPath(n,{parent:!0}),r=e.node,t=PATH.basename(n),o=FS.lookupNode(r,t),i=FS.mayDelete(r,t,!0);if(i)throw new FS.ErrnoError(i);if(!r.node_ops.rmdir)throw new FS.ErrnoError(63);if(FS.isMountpoint(o))throw new FS.ErrnoError(10);try{FS.trackingDelegate.willDeletePath&&FS.trackingDelegate.willDeletePath(n)}catch(l){console.log("FS.trackingDelegate['willDeletePath']('"+n+"') threw an exception: "+l.message)}r.node_ops.rmdir(r,t),FS.destroyNode(o);try{FS.trackingDelegate.onDeletePath&&FS.trackingDelegate.onDeletePath(n)}catch(l){console.log("FS.trackingDelegate['onDeletePath']('"+n+"') threw an exception: "+l.message)}},readdir:function(n){var e=FS.lookupPath(n,{follow:!0}),r=e.node;if(!r.node_ops.readdir)throw new FS.ErrnoError(54);return r.node_ops.readdir(r)},unlink:function(n){var e=FS.lookupPath(n,{parent:!0}),r=e.node,t=PATH.basename(n),o=FS.lookupNode(r,t),i=FS.mayDelete(r,t,!1);if(i)throw new FS.ErrnoError(i);if(!r.node_ops.unlink)throw new FS.ErrnoError(63);if(FS.isMountpoint(o))throw new FS.ErrnoError(10);try{FS.trackingDelegate.willDeletePath&&FS.trackingDelegate.willDeletePath(n)}catch(l){console.log("FS.trackingDelegate['willDeletePath']('"+n+"') threw an exception: "+l.message)}r.node_ops.unlink(r,t),FS.destroyNode(o);try{FS.trackingDelegate.onDeletePath&&FS.trackingDelegate.onDeletePath(n)}catch(l){console.log("FS.trackingDelegate['onDeletePath']('"+n+"') threw an exception: "+l.message)}},readlink:function(n){var e=FS.lookupPath(n),r=e.node;if(!r)throw new FS.ErrnoError(44);if(!r.node_ops.readlink)throw new FS.ErrnoError(28);return PATH_FS.resolve(FS.getPath(r.parent),r.node_ops.readlink(r))},stat:function(n,e){var r=FS.lookupPath(n,{follow:!e}),t=r.node;if(!t)throw new FS.ErrnoError(44);if(!t.node_ops.getattr)throw new FS.ErrnoError(63);return t.node_ops.getattr(t)},lstat:function(n){return FS.stat(n,!0)},chmod:function(n,e,r){var t;if(typeof n=="string"){var o=FS.lookupPath(n,{follow:!r});t=o.node}else t=n;if(!t.node_ops.setattr)throw new FS.ErrnoError(63);t.node_ops.setattr(t,{mode:e&4095|t.mode&-4096,timestamp:Date.now()})},lchmod:function(n,e){FS.chmod(n,e,!0)},fchmod:function(n,e){var r=FS.getStream(n);if(!r)throw new FS.ErrnoError(8);FS.chmod(r.node,e)},chown:function(n,e,r,t){var o;if(typeof n=="string"){var i=FS.lookupPath(n,{follow:!t});o=i.node}else o=n;if(!o.node_ops.setattr)throw new FS.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(n,e,r){FS.chown(n,e,r,!0)},fchown:function(n,e,r){var t=FS.getStream(n);if(!t)throw new FS.ErrnoError(8);FS.chown(t.node,e,r)},truncate:function(n,e){if(e<0)throw new FS.ErrnoError(28);var r;if(typeof n=="string"){var t=FS.lookupPath(n,{follow:!0});r=t.node}else r=n;if(!r.node_ops.setattr)throw new FS.ErrnoError(63);if(FS.isDir(r.mode))throw new FS.ErrnoError(31);if(!FS.isFile(r.mode))throw new FS.ErrnoError(28);var o=FS.nodePermissions(r,"w");if(o)throw new FS.ErrnoError(o);r.node_ops.setattr(r,{size:e,timestamp:Date.now()})},ftruncate:function(n,e){var r=FS.getStream(n);if(!r)throw new FS.ErrnoError(8);if((r.flags&2097155)===0)throw new FS.ErrnoError(28);FS.truncate(r.node,e)},utime:function(n,e,r){var t=FS.lookupPath(n,{follow:!0}),o=t.node;o.node_ops.setattr(o,{timestamp:Math.max(e,r)})},open:function(n,e,r,t,o){if(n==="")throw new FS.ErrnoError(44);e=typeof e=="string"?FS.modeStringToFlags(e):e,r=typeof r=="undefined"?438:r,e&64?r=r&4095|32768:r=0;var i;if(typeof n=="object")i=n;else{n=PATH.normalize(n);try{var l=FS.lookupPath(n,{follow:!(e&131072)});i=l.node}catch{}}var a=!1;if(e&64)if(i){if(e&128)throw new FS.ErrnoError(20)}else i=FS.mknod(n,r,0),a=!0;if(!i)throw new FS.ErrnoError(44);if(FS.isChrdev(i.mode)&&(e&=-513),e&65536&&!FS.isDir(i.mode))throw new FS.ErrnoError(54);if(!a){var s=FS.mayOpen(i,e);if(s)throw new FS.ErrnoError(s)}e&512&&FS.truncate(i,0),e&=-641;var u=FS.createStream({node:i,path:FS.getPath(i),flags:e,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1},t,o);u.stream_ops.open&&u.stream_ops.open(u),cv.logReadFiles&&!(e&1)&&(FS.readFiles||(FS.readFiles={}),n in FS.readFiles||(FS.readFiles[n]=1,console.log("FS.trackingDelegate error on read file: "+n)));try{if(FS.trackingDelegate.onOpenFile){var c=0;(e&2097155)!==1&&(c|=FS.tracking.openFlags.READ),(e&2097155)!==0&&(c|=FS.tracking.openFlags.WRITE),FS.trackingDelegate.onOpenFile(n,c)}}catch(f){console.log("FS.trackingDelegate['onOpenFile']('"+n+"', flags) threw an exception: "+f.message)}return u},close:function(n){if(FS.isClosed(n))throw new FS.ErrnoError(8);n.getdents&&(n.getdents=null);try{n.stream_ops.close&&n.stream_ops.close(n)}catch(e){throw e}finally{FS.closeStream(n.fd)}n.fd=null},isClosed:function(n){return n.fd===null},llseek:function(n,e,r){if(FS.isClosed(n))throw new FS.ErrnoError(8);if(!n.seekable||!n.stream_ops.llseek)throw new FS.ErrnoError(70);if(r!=0&&r!=1&&r!=2)throw new FS.ErrnoError(28);return n.position=n.stream_ops.llseek(n,e,r),n.ungotten=[],n.position},read:function(n,e,r,t,o){if(t<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(n))throw new FS.ErrnoError(8);if((n.flags&2097155)===1)throw new FS.ErrnoError(8);if(FS.isDir(n.node.mode))throw new FS.ErrnoError(31);if(!n.stream_ops.read)throw new FS.ErrnoError(28);var i=typeof o!="undefined";if(!i)o=n.position;else if(!n.seekable)throw new FS.ErrnoError(70);var l=n.stream_ops.read(n,e,r,t,o);return i||(n.position+=l),l},write:function(n,e,r,t,o,i){if(t<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(n))throw new FS.ErrnoError(8);if((n.flags&2097155)===0)throw new FS.ErrnoError(8);if(FS.isDir(n.node.mode))throw new FS.ErrnoError(31);if(!n.stream_ops.write)throw new FS.ErrnoError(28);n.flags&1024&&FS.llseek(n,0,2);var l=typeof o!="undefined";if(!l)o=n.position;else if(!n.seekable)throw new FS.ErrnoError(70);var a=n.stream_ops.write(n,e,r,t,o,i);l||(n.position+=a);try{n.path&&FS.trackingDelegate.onWriteToFile&&FS.trackingDelegate.onWriteToFile(n.path)}catch(s){console.log("FS.trackingDelegate['onWriteToFile']('"+n.path+"') threw an exception: "+s.message)}return a},allocate:function(n,e,r){if(FS.isClosed(n))throw new FS.ErrnoError(8);if(e<0||r<=0)throw new FS.ErrnoError(28);if((n.flags&2097155)===0)throw new FS.ErrnoError(8);if(!FS.isFile(n.node.mode)&&!FS.isDir(n.node.mode))throw new FS.ErrnoError(43);if(!n.stream_ops.allocate)throw new FS.ErrnoError(138);n.stream_ops.allocate(n,e,r)},mmap:function(n,e,r,t,o,i,l){if((i&2)!==0&&(l&2)===0&&(n.flags&2097155)!==2)throw new FS.ErrnoError(2);if((n.flags&2097155)===1)throw new FS.ErrnoError(2);if(!n.stream_ops.mmap)throw new FS.ErrnoError(43);return n.stream_ops.mmap(n,e,r,t,o,i,l)},msync:function(n,e,r,t,o){return!n||!n.stream_ops.msync?0:n.stream_ops.msync(n,e,r,t,o)},munmap:function(n){return 0},ioctl:function(n,e,r){if(!n.stream_ops.ioctl)throw new FS.ErrnoError(59);return n.stream_ops.ioctl(n,e,r)},readFile:function(n,e){if(e=e||{},e.flags=e.flags||"r",e.encoding=e.encoding||"binary",e.encoding!=="utf8"&&e.encoding!=="binary")throw new Error('Invalid encoding type "'+e.encoding+'"');var r,t=FS.open(n,e.flags),o=FS.stat(n),i=o.size,l=new Uint8Array(i);return FS.read(t,l,0,i,0),e.encoding==="utf8"?r=UTF8ArrayToString(l,0):e.encoding==="binary"&&(r=l),FS.close(t),r},writeFile:function(n,e,r){r=r||{},r.flags=r.flags||"w";var t=FS.open(n,r.flags,r.mode);if(typeof e=="string"){var o=new Uint8Array(lengthBytesUTF8(e)+1),i=stringToUTF8Array(e,o,0,o.length);FS.write(t,o,0,i,void 0,r.canOwn)}else if(ArrayBuffer.isView(e))FS.write(t,e,0,e.byteLength,void 0,r.canOwn);else throw new Error("Unsupported data type");FS.close(t)},cwd:function(){return FS.currentPath},chdir:function(n){var e=FS.lookupPath(n,{follow:!0});if(e.node===null)throw new FS.ErrnoError(44);if(!FS.isDir(e.node.mode))throw new FS.ErrnoError(54);var r=FS.nodePermissions(e.node,"x");if(r)throw new FS.ErrnoError(r);FS.currentPath=e.path},createDefaultDirectories:function(){FS.mkdir("/tmp"),FS.mkdir("/home"),FS.mkdir("/home/web_user")},createDefaultDevices:function(){FS.mkdir("/dev"),FS.registerDevice(FS.makedev(1,3),{read:function(){return 0},write:function(r,t,o,i,l){return i}}),FS.mkdev("/dev/null",FS.makedev(1,3)),TTY.register(FS.makedev(5,0),TTY.default_tty_ops),TTY.register(FS.makedev(6,0),TTY.default_tty1_ops),FS.mkdev("/dev/tty",FS.makedev(5,0)),FS.mkdev("/dev/tty1",FS.makedev(6,0));var n;if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var e=new Uint8Array(1);n=function(){return crypto.getRandomValues(e),e[0]}}n||(n=function(){abort("random_device")}),FS.createDevice("/dev","random",n),FS.createDevice("/dev","urandom",n),FS.mkdir("/dev/shm"),FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){FS.mkdir("/proc"),FS.mkdir("/proc/self"),FS.mkdir("/proc/self/fd"),FS.mount({mount:function(){var n=FS.createNode("/proc/self","fd",16895,73);return n.node_ops={lookup:function(e,r){var t=+r,o=FS.getStream(t);if(!o)throw new FS.ErrnoError(8);var i={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return o.path}}};return i.parent=i,i}},n}},{},"/proc/self/fd")},createStandardStreams:function(){cv.stdin?FS.createDevice("/dev","stdin",cv.stdin):FS.symlink("/dev/tty","/dev/stdin"),cv.stdout?FS.createDevice("/dev","stdout",null,cv.stdout):FS.symlink("/dev/tty","/dev/stdout"),cv.stderr?FS.createDevice("/dev","stderr",null,cv.stderr):FS.symlink("/dev/tty1","/dev/stderr"),FS.open("/dev/stdin","r"),FS.open("/dev/stdout","w"),FS.open("/dev/stderr","w")},ensureErrnoError:function(){FS.ErrnoError||(FS.ErrnoError=function(e,r){this.node=r,this.setErrno=function(t){this.errno=t},this.setErrno(e),this.message="FS error"},FS.ErrnoError.prototype=new Error,FS.ErrnoError.prototype.constructor=FS.ErrnoError,[44].forEach(function(n){FS.genericErrors[n]=new FS.ErrnoError(n),FS.genericErrors[n].stack="<generic error, no stack>"}))},staticInit:function(){FS.ensureErrnoError(),FS.nameTable=new Array(4096),FS.mount(MEMFS,{},"/"),FS.createDefaultDirectories(),FS.createDefaultDevices(),FS.createSpecialDirectories(),FS.filesystems={MEMFS,IDBFS}},init:function(n,e,r){FS.init.initialized=!0,FS.ensureErrnoError(),cv.stdin=n||cv.stdin,cv.stdout=e||cv.stdout,cv.stderr=r||cv.stderr,FS.createStandardStreams()},quit:function(){FS.init.initialized=!1;var n=cv._fflush;n&&n(0);for(var e=0;e<FS.streams.length;e++){var r=FS.streams[e];!r||FS.close(r)}},getMode:function(n,e){var r=0;return n&&(r|=365),e&&(r|=146),r},joinPath:function(n,e){var r=PATH.join.apply(null,n);return e&&r[0]=="/"&&(r=r.substr(1)),r},absolutePath:function(n,e){return PATH_FS.resolve(e,n)},standardizePath:function(n){return PATH.normalize(n)},findObject:function(n,e){var r=FS.analyzePath(n,e);return r.exists?r.object:(___setErrNo(r.error),null)},analyzePath:function(n,e){try{var r=FS.lookupPath(n,{follow:!e});n=r.path}catch{}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var r=FS.lookupPath(n,{parent:!0});t.parentExists=!0,t.parentPath=r.path,t.parentObject=r.node,t.name=PATH.basename(n),r=FS.lookupPath(n,{follow:!e}),t.exists=!0,t.path=r.path,t.object=r.node,t.name=r.node.name,t.isRoot=r.path==="/"}catch(o){t.error=o.errno}return t},createFolder:function(n,e,r,t){var o=PATH.join2(typeof n=="string"?n:FS.getPath(n),e),i=FS.getMode(r,t);return FS.mkdir(o,i)},createPath:function(n,e,r,t){n=typeof n=="string"?n:FS.getPath(n);for(var o=e.split("/").reverse();o.length;){var i=o.pop();if(!!i){var l=PATH.join2(n,i);try{FS.mkdir(l)}catch{}n=l}}return l},createFile:function(n,e,r,t,o){var i=PATH.join2(typeof n=="string"?n:FS.getPath(n),e),l=FS.getMode(t,o);return FS.create(i,l)},createDataFile:function(n,e,r,t,o,i){var l=e?PATH.join2(typeof n=="string"?n:FS.getPath(n),e):n,a=FS.getMode(t,o),s=FS.create(l,a);if(r){if(typeof r=="string"){for(var u=new Array(r.length),c=0,f=r.length;c<f;++c)u[c]=r.charCodeAt(c);r=u}FS.chmod(s,a|146);var d=FS.open(s,"w");FS.write(d,r,0,r.length,0,i),FS.close(d),FS.chmod(s,a)}return s},createDevice:function(n,e,r,t){var o=PATH.join2(typeof n=="string"?n:FS.getPath(n),e),i=FS.getMode(!!r,!!t);FS.createDevice.major||(FS.createDevice.major=64);var l=FS.makedev(FS.createDevice.major++,0);return FS.registerDevice(l,{open:function(a){a.seekable=!1},close:function(a){t&&t.buffer&&t.buffer.length&&t(10)},read:function(a,s,u,c,f){for(var d=0,m=0;m<c;m++){var _;try{_=r()}catch{throw new FS.ErrnoError(29)}if(_===void 0&&d===0)throw new FS.ErrnoError(6);if(_==null)break;d++,s[u+m]=_}return d&&(a.node.timestamp=Date.now()),d},write:function(a,s,u,c,f){for(var d=0;d<c;d++)try{t(s[u+d])}catch{throw new FS.ErrnoError(29)}return c&&(a.node.timestamp=Date.now()),d}}),FS.mkdev(o,i,l)},createLink:function(n,e,r,t,o){var i=PATH.join2(typeof n=="string"?n:FS.getPath(n),e);return FS.symlink(r,i)},forceLoadFile:function(n){if(n.isDevice||n.isFolder||n.link||n.contents)return!0;var e=!0;if(typeof XMLHttpRequest!="undefined")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(read_)try{n.contents=intArrayFromString(read_(n.url),!0),n.usedBytes=n.contents.length}catch{e=!1}else throw new Error("Cannot load without read() or XMLHttpRequest.");return e||___setErrNo(29),e},createLazyFile:function(n,e,r,t,o){function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(d){if(!(d>this.length-1||d<0)){var m=d%this.chunkSize,_=d/this.chunkSize|0;return this.getter(_)[m]}},i.prototype.setDataGetter=function(d){this.getter=d},i.prototype.cacheLength=function(){var d=new XMLHttpRequest;if(d.open("HEAD",r,!1),d.send(null),!(d.status>=200&&d.status<300||d.status===304))throw new Error("Couldn't load "+r+". Status: "+d.status);var m=Number(d.getResponseHeader("Content-length")),_,S=(_=d.getResponseHeader("Accept-Ranges"))&&_==="bytes",E=(_=d.getResponseHeader("Content-Encoding"))&&_==="gzip",$=1024*1024;S||($=m);var y=function(A,P){if(A>P)throw new Error("invalid range ("+A+", "+P+") or no bytes requested!");if(P>m-1)throw new Error("only "+m+" bytes available! programmer error!");var C=new XMLHttpRequest;if(C.open("GET",r,!1),m!==$&&C.setRequestHeader("Range","bytes="+A+"-"+P),typeof Uint8Array!="undefined"&&(C.responseType="arraybuffer"),C.overrideMimeType&&C.overrideMimeType("text/plain; charset=x-user-defined"),C.send(null),!(C.status>=200&&C.status<300||C.status===304))throw new Error("Couldn't load "+r+". Status: "+C.status);return C.response!==void 0?new Uint8Array(C.response||[]):intArrayFromString(C.responseText||"",!0)},v=this;v.setDataGetter(function(A){var P=A*$,C=(A+1)*$-1;if(C=Math.min(C,m-1),typeof v.chunks[A]=="undefined"&&(v.chunks[A]=y(P,C)),typeof v.chunks[A]=="undefined")throw new Error("doXHR failed!");return v.chunks[A]}),(E||!m)&&($=m=1,m=this.getter(0).length,$=m,console.log("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=m,this._chunkSize=$,this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l,a}else var a={isDevice:!1,url:r};var s=FS.createFile(n,e,a,t,o);a.contents?s.contents=a.contents:a.url&&(s.contents=null,s.url=a.url),Object.defineProperties(s,{usedBytes:{get:function(){return this.contents.length}}});var u={},c=Object.keys(s.stream_ops);return c.forEach(function(f){var d=s.stream_ops[f];u[f]=function(){if(!FS.forceLoadFile(s))throw new FS.ErrnoError(29);return d.apply(null,arguments)}}),u.read=function(d,m,_,S,E){if(!FS.forceLoadFile(s))throw new FS.ErrnoError(29);var $=d.node.contents;if(E>=$.length)return 0;var y=Math.min($.length-E,S);if($.slice)for(var v=0;v<y;v++)m[_+v]=$[E+v];else for(var v=0;v<y;v++)m[_+v]=$.get(E+v);return y},s.stream_ops=u,s},createPreloadedFile:function(n,e,r,t,o,i,l,a,s,u){Browser.init();var c=e?PATH_FS.resolve(PATH.join2(n,e)):n;function f(d){function m(S){u&&u(),a||FS.createDataFile(n,e,S,t,o,s),i&&i(),removeRunDependency()}var _=!1;cv.preloadPlugins.forEach(function(S){_||S.canHandle(c)&&(S.handle(d,c,m,function(){l&&l(),removeRunDependency()}),_=!0)}),_||m(d)}addRunDependency(),typeof r=="string"?Browser.asyncLoad(r,function(d){f(d)},l):f(r)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:function(){return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(n,e,r){e=e||function(){},r=r||function(){};var t=FS.indexedDB();try{var o=t.open(FS.DB_NAME(),FS.DB_VERSION)}catch(i){return r(i)}o.onupgradeneeded=function(){console.log("creating db");var l=o.result;l.createObjectStore(FS.DB_STORE_NAME)},o.onsuccess=function(){var l=o.result,a=l.transaction([FS.DB_STORE_NAME],"readwrite"),s=a.objectStore(FS.DB_STORE_NAME),u=0,c=0,f=n.length;function d(){c==0?e():r()}n.forEach(function(m){var _=s.put(FS.analyzePath(m).object.contents,m);_.onsuccess=function(){u++,u+c==f&&d()},_.onerror=function(){c++,u+c==f&&d()}}),a.onerror=r},o.onerror=r},loadFilesFromDB:function(n,e,r){e=e||function(){},r=r||function(){};var t=FS.indexedDB();try{var o=t.open(FS.DB_NAME(),FS.DB_VERSION)}catch(i){return r(i)}o.onupgradeneeded=r,o.onsuccess=function(){var l=o.result;try{var a=l.transaction([FS.DB_STORE_NAME],"readonly")}catch(m){r(m);return}var s=a.objectStore(FS.DB_STORE_NAME),u=0,c=0,f=n.length;function d(){c==0?e():r()}n.forEach(function(m){var _=s.get(m);_.onsuccess=function(){FS.analyzePath(m).exists&&FS.unlink(m),FS.createDataFile(PATH.dirname(m),PATH.basename(m),_.result,!0,!0,!0),u++,u+c==f&&d()},_.onerror=function(){c++,u+c==f&&d()}}),a.onerror=r},o.onerror=r}},SYSCALLS={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:function(n,e){if(e[0]!=="/"){var r;if(n===-100)r=FS.cwd();else{var t=FS.getStream(n);if(!t)throw new FS.ErrnoError(8);r=t.path}e=PATH.join2(r,e)}return e},doStat:function(n,e,r){try{var t=n(e)}catch(o){if(o&&o.node&&PATH.normalize(e)!==PATH.normalize(FS.getPath(o.node)))return-54;throw o}return HEAP32[r>>2]=t.dev,HEAP32[r+4>>2]=0,HEAP32[r+8>>2]=t.ino,HEAP32[r+12>>2]=t.mode,HEAP32[r+16>>2]=t.nlink,HEAP32[r+20>>2]=t.uid,HEAP32[r+24>>2]=t.gid,HEAP32[r+28>>2]=t.rdev,HEAP32[r+32>>2]=0,tempI64=[t.size>>>0,(tempDouble=t.size,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+40>>2]=tempI64[0],HEAP32[r+44>>2]=tempI64[1],HEAP32[r+48>>2]=4096,HEAP32[r+52>>2]=t.blocks,HEAP32[r+56>>2]=t.atime.getTime()/1e3|0,HEAP32[r+60>>2]=0,HEAP32[r+64>>2]=t.mtime.getTime()/1e3|0,HEAP32[r+68>>2]=0,HEAP32[r+72>>2]=t.ctime.getTime()/1e3|0,HEAP32[r+76>>2]=0,tempI64=[t.ino>>>0,(tempDouble=t.ino,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+80>>2]=tempI64[0],HEAP32[r+84>>2]=tempI64[1],0},doMsync:function(n,e,r,t){var o=new Uint8Array(HEAPU8.subarray(n,n+r));FS.msync(e,o,0,r,t)},doMkdir:function(n,e){return n=PATH.normalize(n),n[n.length-1]==="/"&&(n=n.substr(0,n.length-1)),FS.mkdir(n,e,0),0},doMknod:function(n,e,r){switch(e&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return FS.mknod(n,e,r),0},doReadlink:function(n,e,r){if(r<=0)return-28;var t=FS.readlink(n),o=Math.min(r,lengthBytesUTF8(t)),i=HEAP8[e+o];return stringToUTF8(t,e,r+1),HEAP8[e+o]=i,o},doAccess:function(n,e){if(e&-8)return-28;var r,t=FS.lookupPath(n,{follow:!0});if(r=t.node,!r)return-44;var o="";return e&4&&(o+="r"),e&2&&(o+="w"),e&1&&(o+="x"),o&&FS.nodePermissions(r,o)?-2:0},doDup:function(n,e,r){var t=FS.getStream(r);return t&&FS.close(t),FS.open(n,e,0,r,r).fd},doReadv:function(n,e,r,t){for(var o=0,i=0;i<r;i++){var l=HEAP32[e+i*8>>2],a=HEAP32[e+(i*8+4)>>2],s=FS.read(n,HEAP8,l,a,t);if(s<0)return-1;if(o+=s,s<a)break}return o},doWritev:function(n,e,r,t){for(var o=0,i=0;i<r;i++){var l=HEAP32[e+i*8>>2],a=HEAP32[e+(i*8+4)>>2],s=FS.write(n,HEAP8,l,a,t);if(s<0)return-1;o+=s}return o},varargs:0,get:function(n){SYSCALLS.varargs+=4;var e=HEAP32[SYSCALLS.varargs-4>>2];return e},getStr:function(){var n=UTF8ToString(SYSCALLS.get());return n},getStreamFromFD:function(n){n===void 0&&(n=SYSCALLS.get());var e=FS.getStream(n);if(!e)throw new FS.ErrnoError(8);return e},get64:function(){var n=SYSCALLS.get();return SYSCALLS.get(),n},getZero:function(){SYSCALLS.get()}};function ___syscall221(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.getStreamFromFD(),t=SYSCALLS.get();switch(t){case 0:{var o=SYSCALLS.get();if(o<0)return-28;var i;return i=FS.open(r.path,r.flags,0,o),i.fd}case 1:case 2:return 0;case 3:return r.flags;case 4:{var o=SYSCALLS.get();return r.flags|=o,0}case 12:{var o=SYSCALLS.get(),l=0;return HEAP16[o+l>>1]=2,0}case 13:case 14:return 0;case 16:case 8:return-28;case 9:return ___setErrNo(28),-1;default:return-28}}catch(a){return(typeof FS=="undefined"||!(a instanceof FS.ErrnoError))&&abort(a),-a.errno}}function ___syscall3(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.getStreamFromFD(),t=SYSCALLS.get(),o=SYSCALLS.get();return FS.read(r,HEAP8,t,o)}catch(i){return(typeof FS=="undefined"||!(i instanceof FS.ErrnoError))&&abort(i),-i.errno}}function ___syscall4(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.getStreamFromFD(),t=SYSCALLS.get(),o=SYSCALLS.get();return FS.write(r,HEAP8,t,o)}catch(i){return(typeof FS=="undefined"||!(i instanceof FS.ErrnoError))&&abort(i),-i.errno}}function ___syscall5(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.getStr(),t=SYSCALLS.get(),o=SYSCALLS.get(),i=FS.open(r,t,o);return i.fd}catch(l){return(typeof FS=="undefined"||!(l instanceof FS.ErrnoError))&&abort(l),-l.errno}}function ___syscall54(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.getStreamFromFD(),t=SYSCALLS.get();switch(t){case 21509:case 21505:return r.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return r.tty?0:-59;case 21519:{if(!r.tty)return-59;var o=SYSCALLS.get();return HEAP32[o>>2]=0,0}case 21520:return r.tty?-28:-59;case 21531:{var o=SYSCALLS.get();return FS.ioctl(r,t,o)}case 21523:return r.tty?0:-59;case 21524:return r.tty?0:-59;default:abort("bad ioctl syscall "+t)}}catch(i){return(typeof FS=="undefined"||!(i instanceof FS.ErrnoError))&&abort(i),-i.errno}}function __emscripten_syscall_munmap(n,e){if(n===-1||e===0)return-28;var r=SYSCALLS.mappings[n];if(!r)return 0;if(e===r.len){var t=FS.getStream(r.fd);SYSCALLS.doMsync(n,t,e,r.flags),FS.munmap(t),SYSCALLS.mappings[n]=null,r.allocated&&_free(r.malloc)}return 0}function ___syscall91(n,e){SYSCALLS.varargs=e;try{var r=SYSCALLS.get(),t=SYSCALLS.get();return __emscripten_syscall_munmap(r,t)}catch(o){return(typeof FS=="undefined"||!(o instanceof FS.ErrnoError))&&abort(o),-o.errno}}function ___unlock(){}var tupleRegistrations={};function runDestructors(n){for(;n.length;){var e=n.pop(),r=n.pop();r(e)}}function simpleReadValueFromPointer(n){return this.fromWireType(HEAPU32[n>>2])}var awaitingDependencies={},registeredTypes={},typeDependencies={},char_0=48,char_9=57;function makeLegalFunctionName(n){if(n===void 0)return"_unknown";n=n.replace(/[^a-zA-Z0-9_]/g,"$");var e=n.charCodeAt(0);return e>=char_0&&e<=char_9?"_"+n:n}function createNamedFunction(n,e){return n=makeLegalFunctionName(n),new Function("body","return function "+n+`() {
- "use strict"; return body.apply(this, arguments);
- };
- `)(e)}function extendError(n,e){var r=createNamedFunction(e,function(t){this.name=e,this.message=t;var o=new Error(t).stack;o!==void 0&&(this.stack=this.toString()+`
- `+o.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},r}var InternalError=void 0;function throwInternalError(n){throw new InternalError(n)}function whenDependentTypesAreResolved(n,e,r){n.forEach(function(a){typeDependencies[a]=e});function t(a){var s=r(a);s.length!==n.length&&throwInternalError("Mismatched type converter count");for(var u=0;u<n.length;++u)registerType(n[u],s[u])}var o=new Array(e.length),i=[],l=0;e.forEach(function(a,s){registeredTypes.hasOwnProperty(a)?o[s]=registeredTypes[a]:(i.push(a),awaitingDependencies.hasOwnProperty(a)||(awaitingDependencies[a]=[]),awaitingDependencies[a].push(function(){o[s]=registeredTypes[a],++l,l===i.length&&t(o)}))}),i.length===0&&t(o)}function __embind_finalize_value_array(n){var e=tupleRegistrations[n];delete tupleRegistrations[n];var r=e.elements,t=r.length,o=r.map(function(a){return a.getterReturnType}).concat(r.map(function(a){return a.setterArgumentType})),i=e.rawConstructor,l=e.rawDestructor;whenDependentTypesAreResolved([n],o,function(a){return r.forEach(function(s,u){var c=a[u],f=s.getter,d=s.getterContext,m=a[u+t],_=s.setter,S=s.setterContext;s.read=function(E){return c.fromWireType(f(d,E))},s.write=function(E,$){var y=[];_(S,E,m.toWireType(y,$)),runDestructors(y)}}),[{name:e.name,fromWireType:function(s){for(var u=new Array(t),c=0;c<t;++c)u[c]=r[c].read(s);return l(s),u},toWireType:function(s,u){if(t!==u.length)throw new TypeError("Incorrect number of tuple elements for "+e.name+": expected="+t+", actual="+u.length);for(var c=i(),f=0;f<t;++f)r[f].write(c,u[f]);return s!==null&&s.push(l,c),c},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:l}]})}var structRegistrations={};function __embind_finalize_value_object(n){var e=structRegistrations[n];delete structRegistrations[n];var r=e.rawConstructor,t=e.rawDestructor,o=e.fields,i=o.map(function(l){return l.getterReturnType}).concat(o.map(function(l){return l.setterArgumentType}));whenDependentTypesAreResolved([n],i,function(l){var a={};return o.forEach(function(s,u){var c=s.fieldName,f=l[u],d=s.getter,m=s.getterContext,_=l[u+o.length],S=s.setter,E=s.setterContext;a[c]={read:function($){return f.fromWireType(d(m,$))},write:function($,y){var v=[];S(E,$,_.toWireType(v,y)),runDestructors(v)}}}),[{name:e.name,fromWireType:function(s){var u={};for(var c in a)u[c]=a[c].read(s);return t(s),u},toWireType:function(s,u){for(var c in a)if(!(c in u))throw new TypeError("Missing field");var f=r();for(c in a)a[c].write(f,u[c]);return s!==null&&s.push(t,f),f},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:t}]})}function getShiftFromSize(n){switch(n){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+n)}}function embind_init_charCodes(){for(var n=new Array(256),e=0;e<256;++e)n[e]=String.fromCharCode(e);embind_charCodes=n}var embind_charCodes=void 0;function readLatin1String(n){for(var e="",r=n;HEAPU8[r];)e+=embind_charCodes[HEAPU8[r++]];return e}var BindingError=void 0;function throwBindingError(n){throw new BindingError(n)}function registerType(n,e,r){if(r=r||{},!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");var t=e.name;if(n||throwBindingError('type "'+t+'" must have a positive integer typeid pointer'),registeredTypes.hasOwnProperty(n)){if(r.ignoreDuplicateRegistrations)return;throwBindingError("Cannot register type '"+t+"' twice")}if(registeredTypes[n]=e,delete typeDependencies[n],awaitingDependencies.hasOwnProperty(n)){var o=awaitingDependencies[n];delete awaitingDependencies[n],o.forEach(function(i){i()})}}function __embind_register_bool(n,e,r,t,o){var i=getShiftFromSize(r);e=readLatin1String(e),registerType(n,{name:e,fromWireType:function(l){return!!l},toWireType:function(l,a){return a?t:o},argPackAdvance:8,readValueFromPointer:function(l){var a;if(r===1)a=HEAP8;else if(r===2)a=HEAP16;else if(r===4)a=HEAP32;else throw new TypeError("Unknown boolean type size: "+e);return this.fromWireType(a[l>>i])},destructorFunction:null})}function ClassHandle_isAliasOf(n){if(!(this instanceof ClassHandle)||!(n instanceof ClassHandle))return!1;for(var e=this.$$.ptrType.registeredClass,r=this.$$.ptr,t=n.$$.ptrType.registeredClass,o=n.$$.ptr;e.baseClass;)r=e.upcast(r),e=e.baseClass;for(;t.baseClass;)o=t.upcast(o),t=t.baseClass;return e===t&&r===o}function shallowCopyInternalPointer(n){return{count:n.count,deleteScheduled:n.deleteScheduled,preservePointerOnDelete:n.preservePointerOnDelete,ptr:n.ptr,ptrType:n.ptrType,smartPtr:n.smartPtr,smartPtrType:n.smartPtrType}}function throwInstanceAlreadyDeleted(n){function e(r){return r.$$.ptrType.registeredClass.name}throwBindingError(e(n)+" instance already deleted")}var finalizationGroup=!1;function detachFinalizer(n){}function runDestructor(n){n.smartPtr?n.smartPtrType.rawDestructor(n.smartPtr):n.ptrType.registeredClass.rawDestructor(n.ptr)}function releaseClassHandle(n){n.count.value-=1;var e=n.count.value===0;e&&runDestructor(n)}function attachFinalizer(n){return typeof FinalizationGroup=="undefined"?(attachFinalizer=function(e){return e},n):(finalizationGroup=new FinalizationGroup(function(e){for(var r=e.next();!r.done;r=e.next()){var t=r.value;t.ptr?releaseClassHandle(t):console.warn("object already deleted: "+t.ptr)}}),attachFinalizer=function(e){return finalizationGroup.register(e,e.$$,e.$$),e},detachFinalizer=function(e){finalizationGroup.unregister(e.$$)},attachFinalizer(n))}function ClassHandle_clone(){if(this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var n=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));return n.$$.count.value+=1,n.$$.deleteScheduled=!1,n}function ClassHandle_delete(){this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&throwBindingError("Object already scheduled for deletion"),detachFinalizer(this),releaseClassHandle(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ClassHandle_isDeleted(){return!this.$$.ptr}var delayFunction=void 0,deletionQueue=[];function flushPendingDeletes(){for(;deletionQueue.length;){var n=deletionQueue.pop();n.$$.deleteScheduled=!1,n.delete()}}function ClassHandle_deleteLater(){return this.$$.ptr||throwInstanceAlreadyDeleted(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&throwBindingError("Object already scheduled for deletion"),deletionQueue.push(this),deletionQueue.length===1&&delayFunction&&delayFunction(flushPendingDeletes),this.$$.deleteScheduled=!0,this}function init_ClassHandle(){ClassHandle.prototype.isAliasOf=ClassHandle_isAliasOf,ClassHandle.prototype.clone=ClassHandle_clone,ClassHandle.prototype.delete=ClassHandle_delete,ClassHandle.prototype.isDeleted=ClassHandle_isDeleted,ClassHandle.prototype.deleteLater=ClassHandle_deleteLater}function ClassHandle(){}var registeredPointers={};function ensureOverloadTable(n,e,r){if(n[e].overloadTable===void 0){var t=n[e];n[e]=function(){return n[e].overloadTable.hasOwnProperty(arguments.length)||throwBindingError("Function '"+r+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+n[e].overloadTable+")!"),n[e].overloadTable[arguments.length].apply(this,arguments)},n[e].overloadTable=[],n[e].overloadTable[t.argCount]=t}}function exposePublicSymbol(n,e,r){cv.hasOwnProperty(n)?((r===void 0||cv[n].overloadTable!==void 0&&cv[n].overloadTable[r]!==void 0)&&throwBindingError("Cannot register public name '"+n+"' twice"),ensureOverloadTable(cv,n,n),cv.hasOwnProperty(r)&&throwBindingError("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!"),cv[n].overloadTable[r]=e):(cv[n]=e,r!==void 0&&(cv[n].numArguments=r))}function RegisteredClass(n,e,r,t,o,i,l,a){this.name=n,this.constructor=e,this.instancePrototype=r,this.rawDestructor=t,this.baseClass=o,this.getActualType=i,this.upcast=l,this.downcast=a,this.pureVirtualFunctions=[]}function upcastPointer(n,e,r){for(;e!==r;)e.upcast||throwBindingError("Expected null or instance of "+r.name+", got an instance of "+e.name),n=e.upcast(n),e=e.baseClass;return n}function constNoSmartPtrRawPointerToWireType(n,e){if(e===null)return this.isReference&&throwBindingError("null is not a valid "+this.name),0;e.$$||throwBindingError('Cannot pass "'+_embind_repr(e)+'" as a '+this.name),e.$$.ptr||throwBindingError("Cannot pass deleted object as a pointer of type "+this.name);var r=e.$$.ptrType.registeredClass,t=upcastPointer(e.$$.ptr,r,this.registeredClass);return t}function genericPointerToWireType(n,e){var r;if(e===null)return this.isReference&&throwBindingError("null is not a valid "+this.name),this.isSmartPointer?(r=this.rawConstructor(),n!==null&&n.push(this.rawDestructor,r),r):0;e.$$||throwBindingError('Cannot pass "'+_embind_repr(e)+'" as a '+this.name),e.$$.ptr||throwBindingError("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&e.$$.ptrType.isConst&&throwBindingError("Cannot convert argument of type "+(e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name)+" to parameter type "+this.name);var t=e.$$.ptrType.registeredClass;if(r=upcastPointer(e.$$.ptr,t,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&throwBindingError("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:throwBindingError("Cannot convert argument of type "+(e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var o=e.clone();r=this.rawShare(r,__emval_register(function(){o.delete()})),n!==null&&n.push(this.rawDestructor,r)}break;default:throwBindingError("Unsupporting sharing policy")}return r}function nonConstNoSmartPtrRawPointerToWireType(n,e){if(e===null)return this.isReference&&throwBindingError("null is not a valid "+this.name),0;e.$$||throwBindingError('Cannot pass "'+_embind_repr(e)+'" as a '+this.name),e.$$.ptr||throwBindingError("Cannot pass deleted object as a pointer of type "+this.name),e.$$.ptrType.isConst&&throwBindingError("Cannot convert argument of type "+e.$$.ptrType.name+" to parameter type "+this.name);var r=e.$$.ptrType.registeredClass,t=upcastPointer(e.$$.ptr,r,this.registeredClass);return t}function RegisteredPointer_getPointee(n){return this.rawGetPointee&&(n=this.rawGetPointee(n)),n}function RegisteredPointer_destructor(n){this.rawDestructor&&this.rawDestructor(n)}function RegisteredPointer_deleteObject(n){n!==null&&n.delete()}function downcastPointer(n,e,r){if(e===r)return n;if(r.baseClass===void 0)return null;var t=downcastPointer(n,e,r.baseClass);return t===null?null:r.downcast(t)}function getInheritedInstanceCount(){return Object.keys(registeredInstances).length}function getLiveInheritedInstances(){var n=[];for(var e in registeredInstances)registeredInstances.hasOwnProperty(e)&&n.push(registeredInstances[e]);return n}function setDelayFunction(n){delayFunction=n,deletionQueue.length&&delayFunction&&delayFunction(flushPendingDeletes)}function init_embind(){cv.getInheritedInstanceCount=getInheritedInstanceCount,cv.getLiveInheritedInstances=getLiveInheritedInstances,cv.flushPendingDeletes=flushPendingDeletes,cv.setDelayFunction=setDelayFunction}var registeredInstances={};function getBasestPointer(n,e){for(e===void 0&&throwBindingError("ptr should not be undefined");n.baseClass;)e=n.upcast(e),n=n.baseClass;return e}function getInheritedInstance(n,e){return e=getBasestPointer(n,e),registeredInstances[e]}function makeClassHandle(n,e){(!e.ptrType||!e.ptr)&&throwInternalError("makeClassHandle requires ptr and ptrType");var r=!!e.smartPtrType,t=!!e.smartPtr;return r!==t&&throwInternalError("Both smartPtrType and smartPtr must be specified"),e.count={value:1},attachFinalizer(Object.create(n,{$$:{value:e}}))}function RegisteredPointer_fromWireType(n){var e=this.getPointee(n);if(!e)return this.destructor(n),null;var r=getInheritedInstance(this.registeredClass,e);if(r!==void 0){if(r.$$.count.value===0)return r.$$.ptr=e,r.$$.smartPtr=n,r.clone();var t=r.clone();return this.destructor(n),t}function o(){return this.isSmartPointer?makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:n}):makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr:n})}var i=this.registeredClass.getActualType(e),l=registeredPointers[i];if(!l)return o.call(this);var a;this.isConst?a=l.constPointerType:a=l.pointerType;var s=downcastPointer(e,this.registeredClass,a.registeredClass);return s===null?o.call(this):this.isSmartPointer?makeClassHandle(a.registeredClass.instancePrototype,{ptrType:a,ptr:s,smartPtrType:this,smartPtr:n}):makeClassHandle(a.registeredClass.instancePrototype,{ptrType:a,ptr:s})}function init_RegisteredPointer(){RegisteredPointer.prototype.getPointee=RegisteredPointer_getPointee,RegisteredPointer.prototype.destructor=RegisteredPointer_destructor,RegisteredPointer.prototype.argPackAdvance=8,RegisteredPointer.prototype.readValueFromPointer=simpleReadValueFromPointer,RegisteredPointer.prototype.deleteObject=RegisteredPointer_deleteObject,RegisteredPointer.prototype.fromWireType=RegisteredPointer_fromWireType}function RegisteredPointer(n,e,r,t,o,i,l,a,s,u,c){this.name=n,this.registeredClass=e,this.isReference=r,this.isConst=t,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=l,this.rawGetPointee=a,this.rawConstructor=s,this.rawShare=u,this.rawDestructor=c,!o&&e.baseClass===void 0?t?(this.toWireType=constNoSmartPtrRawPointerToWireType,this.destructorFunction=null):(this.toWireType=nonConstNoSmartPtrRawPointerToWireType,this.destructorFunction=null):this.toWireType=genericPointerToWireType}function replacePublicSymbol(n,e,r){cv.hasOwnProperty(n)||throwInternalError("Replacing nonexistant public symbol"),cv[n].overloadTable!==void 0&&r!==void 0?cv[n].overloadTable[r]=e:(cv[n]=e,cv[n].argCount=r)}function embind__requireFunction(n,e){n=readLatin1String(n);function r(i){for(var l=[],a=1;a<n.length;++a)l.push("a"+a);var s="dynCall_"+n+"_"+e,u="return function "+s+"("+l.join(", ")+`) {
- `;return u+=" return dynCall(rawFunction"+(l.length?", ":"")+l.join(", ")+`);
- `,u+=`};
- `,new Function("dynCall","rawFunction",u)(i,e)}var t;if(cv["FUNCTION_TABLE_"+n]!==void 0)t=cv["FUNCTION_TABLE_"+n][e];else if(typeof FUNCTION_TABLE!="undefined")t=FUNCTION_TABLE[e];else{var o=cv["dynCall_"+n];o===void 0&&(o=cv["dynCall_"+n.replace(/f/g,"d")],o===void 0&&throwBindingError("No dynCall invoker for signature: "+n)),t=r(o)}return typeof t!="function"&&throwBindingError("unknown function pointer with signature "+n+": "+e),t}var UnboundTypeError=void 0;function getTypeName(n){var e=___getTypeName(n),r=readLatin1String(e);return _free(e),r}function throwUnboundTypeError(n,e){var r=[],t={};function o(i){if(!t[i]&&!registeredTypes[i]){if(typeDependencies[i]){typeDependencies[i].forEach(o);return}r.push(i),t[i]=!0}}throw e.forEach(o),new UnboundTypeError(n+": "+r.map(getTypeName).join([", "]))}function __embind_register_class(n,e,r,t,o,i,l,a,s,u,c,f,d){c=readLatin1String(c),i=embind__requireFunction(o,i),a&&(a=embind__requireFunction(l,a)),u&&(u=embind__requireFunction(s,u)),d=embind__requireFunction(f,d);var m=makeLegalFunctionName(c);exposePublicSymbol(m,function(){throwUnboundTypeError("Cannot construct "+c+" due to unbound types",[t])}),whenDependentTypesAreResolved([n,e,r],t?[t]:[],function(_){_=_[0];var S,E;t?(S=_.registeredClass,E=S.instancePrototype):E=ClassHandle.prototype;var $=createNamedFunction(m,function(){if(Object.getPrototypeOf(this)!==y)throw new BindingError("Use 'new' to construct "+c);if(v.constructor_body===void 0)throw new BindingError(c+" has no accessible constructor");var L=v.constructor_body[arguments.length];if(L===void 0)throw new BindingError("Tried to invoke ctor of "+c+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(v.constructor_body).toString()+") parameters instead!");return L.apply(this,arguments)}),y=Object.create(E,{constructor:{value:$}});$.prototype=y;var v=new RegisteredClass(c,$,y,d,S,i,a,u),A=new RegisteredPointer(c,v,!0,!1,!1),P=new RegisteredPointer(c+"*",v,!1,!1,!1),C=new RegisteredPointer(c+" const*",v,!1,!0,!1);return registeredPointers[n]={pointerType:P,constPointerType:C},replacePublicSymbol(m,$),[A,P,C]})}function new_(n,e){if(!(n instanceof Function))throw new TypeError("new_ called with constructor type "+typeof n+" which is not a function");var r=createNamedFunction(n.name||"unknownFunctionName",function(){});r.prototype=n.prototype;var t=new r,o=n.apply(t,e);return o instanceof Object?o:t}function craftInvokerFunction(n,e,r,t,o){var i=e.length;i<2&&throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var l=e[1]!==null&&r!==null,a=!1,s=1;s<e.length;++s)if(e[s]!==null&&e[s].destructorFunction===void 0){a=!0;break}for(var u=e[0].name!=="void",c="",f="",s=0;s<i-2;++s)c+=(s!==0?", ":"")+"arg"+s,f+=(s!==0?", ":"")+"arg"+s+"Wired";var d="return function "+makeLegalFunctionName(n)+"("+c+`) {
- if (arguments.length !== `+(i-2)+`) {
- throwBindingError('function `+n+" called with ' + arguments.length + ' arguments, expected "+(i-2)+` args!');
- }
- `;a&&(d+=`var destructors = [];
- `);var m=a?"destructors":"null",_=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],S=[throwBindingError,t,o,runDestructors,e[0],e[1]];l&&(d+="var thisWired = classParam.toWireType("+m+`, this);
- `);for(var s=0;s<i-2;++s)d+="var arg"+s+"Wired = argType"+s+".toWireType("+m+", arg"+s+"); // "+e[s+2].name+`
- `,_.push("argType"+s),S.push(e[s+2]);if(l&&(f="thisWired"+(f.length>0?", ":"")+f),d+=(u?"var rv = ":"")+"invoker(fn"+(f.length>0?", ":"")+f+`);
- `,a)d+=`runDestructors(destructors);
- `;else for(var s=l?1:2;s<e.length;++s){var E=s===1?"thisWired":"arg"+(s-2)+"Wired";e[s].destructorFunction!==null&&(d+=E+"_dtor("+E+"); // "+e[s].name+`
- `,_.push(E+"_dtor"),S.push(e[s].destructorFunction))}u&&(d+=`var ret = retType.fromWireType(rv);
- return ret;
- `),d+=`}
- `,_.push(d);var $=new_(Function,_).apply(null,S);return $}function heap32VectorToArray(n,e){for(var r=[],t=0;t<n;t++)r.push(HEAP32[(e>>2)+t]);return r}function __embind_register_class_class_function(n,e,r,t,o,i,l){var a=heap32VectorToArray(r,t);e=readLatin1String(e),i=embind__requireFunction(o,i),whenDependentTypesAreResolved([],[n],function(s){s=s[0];var u=s.name+"."+e;function c(){throwUnboundTypeError("Cannot call "+u+" due to unbound types",a)}var f=s.registeredClass.constructor;return f[e]===void 0?(c.argCount=r-1,f[e]=c):(ensureOverloadTable(f,e,u),f[e].overloadTable[r-1]=c),whenDependentTypesAreResolved([],a,function(d){var m=[d[0],null].concat(d.slice(1)),_=craftInvokerFunction(u,m,null,i,l);return f[e].overloadTable===void 0?(_.argCount=r-1,f[e]=_):f[e].overloadTable[r-1]=_,[]}),[]})}function __embind_register_class_constructor(n,e,r,t,o,i){var l=heap32VectorToArray(e,r);o=embind__requireFunction(t,o),whenDependentTypesAreResolved([],[n],function(a){a=a[0];var s="constructor "+a.name;if(a.registeredClass.constructor_body===void 0&&(a.registeredClass.constructor_body=[]),a.registeredClass.constructor_body[e-1]!==void 0)throw new BindingError("Cannot register multiple constructors with identical number of parameters ("+(e-1)+") for class '"+a.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return a.registeredClass.constructor_body[e-1]=function(){throwUnboundTypeError("Cannot construct "+a.name+" due to unbound types",l)},whenDependentTypesAreResolved([],l,function(u){return a.registeredClass.constructor_body[e-1]=function(){arguments.length!==e-1&&throwBindingError(s+" called with "+arguments.length+" arguments, expected "+(e-1));var f=[],d=new Array(e);d[0]=i;for(var m=1;m<e;++m)d[m]=u[m].toWireType(f,arguments[m-1]);var _=o.apply(null,d);return runDestructors(f),u[0].fromWireType(_)},[]}),[]})}function __embind_register_class_function(n,e,r,t,o,i,l,a){var s=heap32VectorToArray(r,t);e=readLatin1String(e),i=embind__requireFunction(o,i),whenDependentTypesAreResolved([],[n],function(u){u=u[0];var c=u.name+"."+e;a&&u.registeredClass.pureVirtualFunctions.push(e);function f(){throwUnboundTypeError("Cannot call "+c+" due to unbound types",s)}var d=u.registeredClass.instancePrototype,m=d[e];return m===void 0||m.overloadTable===void 0&&m.className!==u.name&&m.argCount===r-2?(f.argCount=r-2,f.className=u.name,d[e]=f):(ensureOverloadTable(d,e,c),d[e].overloadTable[r-2]=f),whenDependentTypesAreResolved([],s,function(_){var S=craftInvokerFunction(c,_,u,i,l);return d[e].overloadTable===void 0?(S.argCount=r-2,d[e]=S):d[e].overloadTable[r-2]=S,[]}),[]})}function validateThis(n,e,r){return n instanceof Object||throwBindingError(r+' with invalid "this": '+n),n instanceof e.registeredClass.constructor||throwBindingError(r+' incompatible with "this" of type '+n.constructor.name),n.$$.ptr||throwBindingError("cannot call emscripten binding method "+r+" on deleted object"),upcastPointer(n.$$.ptr,n.$$.ptrType.registeredClass,e.registeredClass)}function __embind_register_class_property(n,e,r,t,o,i,l,a,s,u){e=readLatin1String(e),o=embind__requireFunction(t,o),whenDependentTypesAreResolved([],[n],function(c){c=c[0];var f=c.name+"."+e,d={get:function(){throwUnboundTypeError("Cannot access "+f+" due to unbound types",[r,l])},enumerable:!0,configurable:!0};return s?d.set=function(){throwUnboundTypeError("Cannot access "+f+" due to unbound types",[r,l])}:d.set=function(m){throwBindingError(f+" is a read-only property")},Object.defineProperty(c.registeredClass.instancePrototype,e,d),whenDependentTypesAreResolved([],s?[r,l]:[r],function(m){var _=m[0],S={get:function(){var $=validateThis(this,c,f+" getter");return _.fromWireType(o(i,$))},enumerable:!0};if(s){s=embind__requireFunction(a,s);var E=m[1];S.set=function($){var y=validateThis(this,c,f+" setter"),v=[];s(u,y,E.toWireType(v,$)),runDestructors(v)}}return Object.defineProperty(c.registeredClass.instancePrototype,e,S),[]}),[]})}function __embind_register_constant(n,e,r){n=readLatin1String(n),whenDependentTypesAreResolved([],[e],function(t){return t=t[0],cv[n]=t.fromWireType(r),[]})}var emval_free_list=[],emval_handle_array=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function __emval_decref(n){n>4&&--emval_handle_array[n].refcount===0&&(emval_handle_array[n]=void 0,emval_free_list.push(n))}function count_emval_handles(){for(var n=0,e=5;e<emval_handle_array.length;++e)emval_handle_array[e]!==void 0&&++n;return n}function get_first_emval(){for(var n=5;n<emval_handle_array.length;++n)if(emval_handle_array[n]!==void 0)return emval_handle_array[n];return null}function init_emval(){cv.count_emval_handles=count_emval_handles,cv.get_first_emval=get_first_emval}function __emval_register(n){switch(n){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var e=emval_free_list.length?emval_free_list.pop():emval_handle_array.length;return emval_handle_array[e]={refcount:1,value:n},e}}}function __embind_register_emval(n,e){e=readLatin1String(e),registerType(n,{name:e,fromWireType:function(r){var t=emval_handle_array[r].value;return __emval_decref(r),t},toWireType:function(r,t){return __emval_register(t)},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:null})}function _embind_repr(n){if(n===null)return"null";var e=typeof n;return e==="object"||e==="array"||e==="function"?n.toString():""+n}function floatReadValueFromPointer(n,e){switch(e){case 2:return function(r){return this.fromWireType(HEAPF32[r>>2])};case 3:return function(r){return this.fromWireType(HEAPF64[r>>3])};default:throw new TypeError("Unknown float type: "+n)}}function __embind_register_float(n,e,r){var t=getShiftFromSize(r);e=readLatin1String(e),registerType(n,{name:e,fromWireType:function(o){return o},toWireType:function(o,i){if(typeof i!="number"&&typeof i!="boolean")throw new TypeError('Cannot convert "'+_embind_repr(i)+'" to '+this.name);return i},argPackAdvance:8,readValueFromPointer:floatReadValueFromPointer(e,t),destructorFunction:null})}function __embind_register_function(n,e,r,t,o,i){var l=heap32VectorToArray(e,r);n=readLatin1String(n),o=embind__requireFunction(t,o),exposePublicSymbol(n,function(){throwUnboundTypeError("Cannot call "+n+" due to unbound types",l)},e-1),whenDependentTypesAreResolved([],l,function(a){var s=[a[0],null].concat(a.slice(1));return replacePublicSymbol(n,craftInvokerFunction(n,s,null,o,i),e-1),[]})}function integerReadValueFromPointer(n,e,r){switch(e){case 0:return r?function(o){return HEAP8[o]}:function(o){return HEAPU8[o]};case 1:return r?function(o){return HEAP16[o>>1]}:function(o){return HEAPU16[o>>1]};case 2:return r?function(o){return HEAP32[o>>2]}:function(o){return HEAPU32[o>>2]};default:throw new TypeError("Unknown integer type: "+n)}}function __embind_register_integer(n,e,r,t,o){e=readLatin1String(e),o===-1&&(o=4294967295);var i=getShiftFromSize(r),l=function(u){return u};if(t===0){var a=32-8*r;l=function(u){return u<<a>>>a}}var s=e.indexOf("unsigned")!=-1;registerType(n,{name:e,fromWireType:l,toWireType:function(u,c){if(typeof c!="number"&&typeof c!="boolean")throw new TypeError('Cannot convert "'+_embind_repr(c)+'" to '+this.name);if(c<t||c>o)throw new TypeError('Passing a number "'+_embind_repr(c)+'" from JS side to C/C++ side to an argument of type "'+e+'", which is outside the valid range ['+t+", "+o+"]!");return s?c>>>0:c|0},argPackAdvance:8,readValueFromPointer:integerReadValueFromPointer(e,i,t!==0),destructorFunction:null})}function __embind_register_memory_view(n,e,r){var t=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=t[e];function i(l){l=l>>2;var a=HEAPU32,s=a[l],u=a[l+1];return new o(a.buffer,u,s)}r=readLatin1String(r),registerType(n,{name:r,fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})}function __embind_register_smart_ptr(n,e,r,t,o,i,l,a,s,u,c,f){r=readLatin1String(r),i=embind__requireFunction(o,i),a=embind__requireFunction(l,a),u=embind__requireFunction(s,u),f=embind__requireFunction(c,f),whenDependentTypesAreResolved([n],[e],function(d){d=d[0];var m=new RegisteredPointer(r,d.registeredClass,!1,!1,!0,d,t,i,a,u,f);return[m]})}function __embind_register_std_string(n,e){e=readLatin1String(e);var r=e==="std::string";registerType(n,{name:e,fromWireType:function(t){var o=HEAPU32[t>>2],i;if(r){var l=HEAPU8[t+4+o],a=0;l!=0&&(a=l,HEAPU8[t+4+o]=0);for(var s=t+4,u=0;u<=o;++u){var c=t+4+u;if(HEAPU8[c]==0){var f=UTF8ToString(s);i===void 0?i=f:(i+=String.fromCharCode(0),i+=f),s=c+1}}a!=0&&(HEAPU8[t+4+o]=a)}else{for(var d=new Array(o),u=0;u<o;++u)d[u]=String.fromCharCode(HEAPU8[t+4+u]);i=d.join("")}return _free(t),i},toWireType:function(t,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,l=typeof o=="string";l||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||throwBindingError("Cannot pass non-string to std::string"),r&&l?i=function(){return lengthBytesUTF8(o)}:i=function(){return o.length};var a=i(),s=_malloc(4+a+1);if(HEAPU32[s>>2]=a,r&&l)stringToUTF8(o,s+4,a+1);else if(l)for(var u=0;u<a;++u){var c=o.charCodeAt(u);c>255&&(_free(s),throwBindingError("String has UTF-16 code units that do not fit in 8 bits")),HEAPU8[s+4+u]=c}else for(var u=0;u<a;++u)HEAPU8[s+4+u]=o[u];return t!==null&&t.push(_free,s),s},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:function(t){_free(t)}})}function __embind_register_std_wstring(n,e,r){r=readLatin1String(r);var t,o;e===2?(t=function(){return HEAPU16},o=1):e===4&&(t=function(){return HEAPU32},o=2),registerType(n,{name:r,fromWireType:function(i){for(var l=t(),a=HEAPU32[i>>2],s=new Array(a),u=i+4>>o,c=0;c<a;++c)s[c]=String.fromCharCode(l[u+c]);return _free(i),s.join("")},toWireType:function(i,l){var a=l.length,s=_malloc(4+a*e),u=t();HEAPU32[s>>2]=a;for(var c=s+4>>o,f=0;f<a;++f)u[c+f]=l.charCodeAt(f);return i!==null&&i.push(_free,s),s},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:function(i){_free(i)}})}function __embind_register_value_array(n,e,r,t,o,i){tupleRegistrations[n]={name:readLatin1String(e),rawConstructor:embind__requireFunction(r,t),rawDestructor:embind__requireFunction(o,i),elements:[]}}function __embind_register_value_array_element(n,e,r,t,o,i,l,a,s){tupleRegistrations[n].elements.push({getterReturnType:e,getter:embind__requireFunction(r,t),getterContext:o,setterArgumentType:i,setter:embind__requireFunction(l,a),setterContext:s})}function __embind_register_value_object(n,e,r,t,o,i){structRegistrations[n]={name:readLatin1String(e),rawConstructor:embind__requireFunction(r,t),rawDestructor:embind__requireFunction(o,i),fields:[]}}function __embind_register_value_object_field(n,e,r,t,o,i,l,a,s,u){structRegistrations[n].fields.push({fieldName:readLatin1String(e),getterReturnType:r,getter:embind__requireFunction(t,o),getterContext:i,setterArgumentType:l,setter:embind__requireFunction(a,s),setterContext:u})}function __embind_register_void(n,e){e=readLatin1String(e),registerType(n,{isVoid:!0,name:e,argPackAdvance:0,fromWireType:function(){},toWireType:function(r,t){}})}function requireHandle(n){return n||throwBindingError("Cannot use deleted val. handle = "+n),emval_handle_array[n].value}function requireRegisteredType(n,e){var r=registeredTypes[n];return r===void 0&&throwBindingError(e+" has unknown type "+getTypeName(n)),r}function __emval_as(n,e,r){n=requireHandle(n),e=requireRegisteredType(e,"emval::as");var t=[],o=__emval_register(t);return HEAP32[r>>2]=o,e.toWireType(t,n)}var emval_symbols={};function getStringOrSymbol(n){var e=emval_symbols[n];return e===void 0?readLatin1String(n):e}var emval_methodCallers=[];function __emval_call_void_method(n,e,r,t){n=emval_methodCallers[n],e=requireHandle(e),r=getStringOrSymbol(r),n(e,r,null,t)}function __emval_addMethodCaller(n){var e=emval_methodCallers.length;return emval_methodCallers.push(n),e}function __emval_lookupTypes(n,e,r){for(var t=new Array(n),o=0;o<n;++o)t[o]=requireRegisteredType(HEAP32[(e>>2)+o],"parameter "+o);return t}function __emval_get_method_caller(n,e){for(var r=__emval_lookupTypes(n,e),t=r[0],o=t.name+"_$"+r.slice(1).map(function(m){return m.name}).join("_")+"$",i=["retType"],l=[t],a="",s=0;s<n-1;++s)a+=(s!==0?", ":"")+"arg"+s,i.push("argType"+s),l.push(r[1+s]);for(var u=makeLegalFunctionName("methodCaller_"+o),c="return function "+u+`(handle, name, destructors, args) {
- `,f=0,s=0;s<n-1;++s)c+=" var arg"+s+" = argType"+s+".readValueFromPointer(args"+(f?"+"+f:"")+`);
- `,f+=r[s+1].argPackAdvance;c+=" var rv = handle[name]("+a+`);
- `;for(var s=0;s<n-1;++s)r[s+1].deleteObject&&(c+=" argType"+s+".deleteObject(arg"+s+`);
- `);t.isVoid||(c+=` return retType.toWireType(destructors, rv);
- `),c+=`};
- `,i.push(c);var d=new_(Function,i).apply(null,l);return __emval_addMethodCaller(d)}function __emval_get_property(n,e){return n=requireHandle(n),e=requireHandle(e),__emval_register(n[e])}function __emval_incref(n){n>4&&(emval_handle_array[n].refcount+=1)}function __emval_new_array(){return __emval_register([])}function __emval_new_cstring(n){return __emval_register(getStringOrSymbol(n))}function __emval_run_destructors(n){var e=emval_handle_array[n].value;runDestructors(e),__emval_decref(n)}function __emval_set_property(n,e,r){n=requireHandle(n),e=requireHandle(e),r=requireHandle(r),n[e]=r}function __emval_take_value(n,e){n=requireRegisteredType(n,"_emval_take_value");var r=n.readValueFromPointer(e);return __emval_register(r)}function _abort(){abort()}function _emscripten_get_now_is_monotonic(){return typeof dateNow!="undefined"||typeof performance=="object"&&performance&&typeof performance.now=="function"}function _clock_gettime(n,e){var r;if(n===0)r=Date.now();else if(n===1&&_emscripten_get_now_is_monotonic())r=_emscripten_get_now();else return ___setErrNo(28),-1;return HEAP32[e>>2]=r/1e3|0,HEAP32[e+4>>2]=r%1e3*1e3*1e3|0,0}function _emscripten_get_heap_size(){return HEAP8.length}function _emscripten_get_sbrk_ptr(){return 1384064}function _emscripten_memcpy_big(n,e,r){HEAPU8.set(HEAPU8.subarray(e,e+r),n)}function emscripten_realloc_buffer(n){try{return wasmMemory.grow(n-buffer.byteLength+65535>>16),updateGlobalBufferAndViews(wasmMemory.buffer),1}catch{}}function _emscripten_resize_heap(n){var e=_emscripten_get_heap_size(),r=65536,t=2147483648-r;if(n>t)return!1;for(var o=16777216,i=Math.max(e,o);i<n;)i<=536870912?i=alignUp(2*i,r):i=Math.min(alignUp((3*i+2147483648)/4,r),t);if(i=Math.min(i,1073741824),i==e)return!1;var l=emscripten_realloc_buffer(i);return!!l}var ENV={};function _emscripten_get_environ(){if(!_emscripten_get_environ.strings){var n={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",_:"./this.program"};for(var e in ENV)n[e]=ENV[e];var r=[];for(var e in n)r.push(e+"="+n[e]);_emscripten_get_environ.strings=r}return _emscripten_get_environ.strings}function _environ_get(n,e){var r=_emscripten_get_environ(),t=0;return r.forEach(function(o,i){var l=e+t;HEAP32[n+i*4>>2]=l,writeAsciiToMemory(o,l),t+=o.length+1}),0}function _environ_sizes_get(n,e){var r=_emscripten_get_environ();HEAP32[n>>2]=r.length;var t=0;return r.forEach(function(o){t+=o.length+1}),HEAP32[e>>2]=t,0}function _fd_close(n){try{var e=SYSCALLS.getStreamFromFD(n);return FS.close(e),0}catch(r){return(typeof FS=="undefined"||!(r instanceof FS.ErrnoError))&&abort(r),r.errno}}function _fd_read(n,e,r,t){try{var o=SYSCALLS.getStreamFromFD(n),i=SYSCALLS.doReadv(o,e,r);return HEAP32[t>>2]=i,0}catch(l){return(typeof FS=="undefined"||!(l instanceof FS.ErrnoError))&&abort(l),l.errno}}function _fd_seek(n,e,r,t,o){try{var i=SYSCALLS.getStreamFromFD(n),l=4294967296,a=r*l+(e>>>0),s=9007199254740992;return a<=-s||a>=s?-61:(FS.llseek(i,a,t),tempI64=[i.position>>>0,(tempDouble=i.position,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[o>>2]=tempI64[0],HEAP32[o+4>>2]=tempI64[1],i.getdents&&a===0&&t===0&&(i.getdents=null),0)}catch(u){return(typeof FS=="undefined"||!(u instanceof FS.ErrnoError))&&abort(u),u.errno}}function _fd_write(n,e,r,t){try{var o=SYSCALLS.getStreamFromFD(n),i=SYSCALLS.doWritev(o,e,r);return HEAP32[t>>2]=i,0}catch(l){return(typeof FS=="undefined"||!(l instanceof FS.ErrnoError))&&abort(l),l.errno}}function _pthread_mutexattr_destroy(){}function _pthread_mutexattr_init(){}function _pthread_mutexattr_settype(){}function _round(n){return n=+n,n>=0?+Math_floor(n+.5):+Math_ceil(n-.5)}function _roundf(n){return n=+n,n>=0?+Math_floor(n+.5):+Math_ceil(n-.5)}function _setTempRet0(n){}function __isLeapYear(n){return n%4===0&&(n%100!==0||n%400===0)}function __arraySum(n,e){var r=0;return r}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31],__MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(n,e){for(var r=new Date(n.getTime());e>0;){var t=__isLeapYear(r.getFullYear()),o=r.getMonth(),i=(t?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[o];if(e>i-r.getDate())e-=i-r.getDate()+1,r.setDate(1),o<11?r.setMonth(o+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1));else return r.setDate(r.getDate()+e),r}return r}function _strftime(n,e,r,t){var o=HEAP32[t+40>>2],i={tm_sec:HEAP32[t>>2],tm_min:HEAP32[t+4>>2],tm_hour:HEAP32[t+8>>2],tm_mday:HEAP32[t+12>>2],tm_mon:HEAP32[t+16>>2],tm_year:HEAP32[t+20>>2],tm_wday:HEAP32[t+24>>2],tm_yday:HEAP32[t+28>>2],tm_isdst:HEAP32[t+32>>2],tm_gmtoff:HEAP32[t+36>>2],tm_zone:o?UTF8ToString(o):""},l=UTF8ToString(r),a={"%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"};for(var s in a)l=l.replace(new RegExp(s,"g"),a[s]);var u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"];function f(y,v,A){for(var P=typeof y=="number"?y.toString():y||"";P.length<v;)P=A[0]+P;return P}function d(y,v){return f(y,v,"0")}function m(y,v){function A(C){return C<0?-1:C>0?1:0}var P;return(P=A(y.getFullYear()-v.getFullYear()))===0&&(P=A(y.getMonth()-v.getMonth()))===0&&(P=A(y.getDate()-v.getDate())),P}function _(y){switch(y.getDay()){case 0:return new Date(y.getFullYear()-1,11,29);case 1:return y;case 2:return new Date(y.getFullYear(),0,3);case 3:return new Date(y.getFullYear(),0,2);case 4:return new Date(y.getFullYear(),0,1);case 5:return new Date(y.getFullYear()-1,11,31);case 6:return new Date(y.getFullYear()-1,11,30)}}function S(y){var v=__addDays(new Date(y.tm_year+1900,0,1),y.tm_yday),A=new Date(v.getFullYear(),0,4),P=new Date(v.getFullYear()+1,0,4),C=_(A),L=_(P);return m(C,v)<=0?m(L,v)<=0?v.getFullYear()+1:v.getFullYear():v.getFullYear()-1}var E={"%a":function(y){return u[y.tm_wday].substring(0,3)},"%A":function(y){return u[y.tm_wday]},"%b":function(y){return c[y.tm_mon].substring(0,3)},"%B":function(y){return c[y.tm_mon]},"%C":function(y){var v=y.tm_year+1900;return d(v/100|0,2)},"%d":function(y){return d(y.tm_mday,2)},"%e":function(y){return f(y.tm_mday,2," ")},"%g":function(y){return S(y).toString().substring(2)},"%G":function(y){return S(y)},"%H":function(y){return d(y.tm_hour,2)},"%I":function(y){var v=y.tm_hour;return v==0?v=12:v>12&&(v-=12),d(v,2)},"%j":function(y){return d(y.tm_mday+__arraySum(__isLeapYear(y.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,y.tm_mon-1),3)},"%m":function(y){return d(y.tm_mon+1,2)},"%M":function(y){return d(y.tm_min,2)},"%n":function(){return`
- `},"%p":function(y){return y.tm_hour>=0&&y.tm_hour<12?"AM":"PM"},"%S":function(y){return d(y.tm_sec,2)},"%t":function(){return" "},"%u":function(y){return y.tm_wday||7},"%U":function(y){var v=new Date(y.tm_year+1900,0,1),A=v.getDay()===0?v:__addDays(v,7-v.getDay()),P=new Date(y.tm_year+1900,y.tm_mon,y.tm_mday);if(m(A,P)<0){var C=__arraySum(__isLeapYear(P.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,P.getMonth()-1)-31,L=31-A.getDate(),B=L+C+P.getDate();return d(Math.ceil(B/7),2)}return m(A,v)===0?"01":"00"},"%V":function(y){var v=new Date(y.tm_year+1900,0,4),A=new Date(y.tm_year+1901,0,4),P=_(v),C=_(A),L=__addDays(new Date(y.tm_year+1900,0,1),y.tm_yday);if(m(L,P)<0)return"53";if(m(C,L)<=0)return"01";var B;return P.getFullYear()<y.tm_year+1900?B=y.tm_yday+32-P.getDate():B=y.tm_yday+1-P.getDate(),d(Math.ceil(B/7),2)},"%w":function(y){return y.tm_wday},"%W":function(y){var v=new Date(y.tm_year,0,1),A=v.getDay()===1?v:__addDays(v,v.getDay()===0?1:7-v.getDay()+1),P=new Date(y.tm_year+1900,y.tm_mon,y.tm_mday);if(m(A,P)<0){var C=__arraySum(__isLeapYear(P.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,P.getMonth()-1)-31,L=31-A.getDate(),B=L+C+P.getDate();return d(Math.ceil(B/7),2)}return m(A,v)===0?"01":"00"},"%y":function(y){return(y.tm_year+1900).toString().substring(2)},"%Y":function(y){return y.tm_year+1900},"%z":function(y){var v=y.tm_gmtoff,A=v>=0;return v=Math.abs(v)/60,v=v/60*100+v%60,(A?"+":"-")+String("0000"+v).slice(-4)},"%Z":function(y){return y.tm_zone},"%%":function(){return"%"}};for(var s in E)l.indexOf(s)>=0&&(l=l.replace(new RegExp(s,"g"),E[s](i)));var $=intArrayFromString(l,!1);return $.length>e?0:(writeArrayToMemory($,n),$.length-1)}function _strftime_l(n,e,r,t){return _strftime(n,e,r,t)}function _sysconf(n){switch(n){case 30:return PAGE_SIZE;case 85:var e=2*1024*1024*1024-65536;return e=1073741824,e/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return typeof navigator=="object"&&navigator.hardwareConcurrency||1}return ___setErrNo(28),-1}cv.requestFullScreen=function(e,r,t){err$1("cv.requestFullScreen is deprecated. Please call cv.requestFullscreen instead."),cv.requestFullScreen=cv.requestFullscreen,Browser.requestFullScreen(e,r,t)};cv.requestFullscreen=function(e,r,t){Browser.requestFullscreen(e,r,t)};cv.requestAnimationFrame=function(e){Browser.requestAnimationFrame(e)};cv.setCanvasSize=function(e,r,t){Browser.setCanvasSize(e,r,t)};cv.pauseMainLoop=function(){Browser.mainLoop.pause()};cv.resumeMainLoop=function(){Browser.mainLoop.resume()};cv.getUserMedia=function(){Browser.getUserMedia()};cv.createContext=function(e,r,t,o){return Browser.createContext(e,r,t,o)};typeof dateNow!="undefined"?_emscripten_get_now=dateNow:typeof performance=="object"&&performance&&typeof performance.now=="function"?_emscripten_get_now=function(){return performance.now()}:_emscripten_get_now=Date.now;FS.staticInit();cv.FS_createFolder=FS.createFolder;cv.FS_createPath=FS.createPath;cv.FS_createDataFile=FS.createDataFile;cv.FS_createPreloadedFile=FS.createPreloadedFile;cv.FS_createLazyFile=FS.createLazyFile;cv.FS_createLink=FS.createLink;cv.FS_createDevice=FS.createDevice;cv.FS_unlink=FS.unlink;InternalError=cv.InternalError=extendError(Error,"InternalError");embind_init_charCodes();BindingError=cv.BindingError=extendError(Error,"BindingError");init_ClassHandle();init_RegisteredPointer();init_embind();UnboundTypeError=cv.UnboundTypeError=extendError(Error,"UnboundTypeError");init_emval();function intArrayFromString(n,e,r){var t=r>0?r:lengthBytesUTF8(n)+1,o=new Array(t),i=stringToUTF8Array(n,o,0,o.length);return e&&(o.length=i),o}function intArrayToString(n){for(var e=[],r=0;r<n.length;r++){var t=n[r];t>255&&(t&=255),e.push(String.fromCharCode(t))}return e.join("")}var decodeBase64=typeof atob=="function"?atob:function(n){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="",t,o,i,l,a,s,u,c=0;n=n.replace(/[^A-Za-z0-9\+\/\=]/g,"");do l=e.indexOf(n.charAt(c++)),a=e.indexOf(n.charAt(c++)),s=e.indexOf(n.charAt(c++)),u=e.indexOf(n.charAt(c++)),t=l<<2|a>>4,o=(a&15)<<4|s>>2,i=(s&3)<<6|u,r=r+String.fromCharCode(t),s!==64&&(r=r+String.fromCharCode(o)),u!==64&&(r=r+String.fromCharCode(i));while(c<n.length);return r};function intArrayFromBase64(n){try{for(var e=decodeBase64(n),r=new Uint8Array(e.length),t=0;t<e.length;++t)r[t]=e.charCodeAt(t);return r}catch{throw new Error("Converting base64 string to bytes failed.")}}function tryParseAsDataURI(n){if(!!isDataURI(n))return intArrayFromBase64(n.slice(dataURIPrefix.length))}var asmLibraryArg={__cxa_allocate_exception:___cxa_allocate_exception,__cxa_atexit:___cxa_atexit,__cxa_throw:___cxa_throw,__lock:___lock,__map_file:___map_file,__syscall221:___syscall221,__syscall3:___syscall3,__syscall4:___syscall4,__syscall5:___syscall5,__syscall54:___syscall54,__syscall91:___syscall91,__unlock:___unlock,_embind_finalize_value_array:__embind_finalize_value_array,_embind_finalize_value_object:__embind_finalize_value_object,_embind_register_bool:__embind_register_bool,_embind_register_class:__embind_register_class,_embind_register_class_class_function:__embind_register_class_class_function,_embind_register_class_constructor:__embind_register_class_constructor,_embind_register_class_function:__embind_register_class_function,_embind_register_class_property:__embind_register_class_property,_embind_register_constant:__embind_register_constant,_embind_register_emval:__embind_register_emval,_embind_register_float:__embind_register_float,_embind_register_function:__embind_register_function,_embind_register_integer:__embind_register_integer,_embind_register_memory_view:__embind_register_memory_view,_embind_register_smart_ptr:__embind_register_smart_ptr,_embind_register_std_string:__embind_register_std_string,_embind_register_std_wstring:__embind_register_std_wstring,_embind_register_value_array:__embind_register_value_array,_embind_register_value_array_element:__embind_register_value_array_element,_embind_register_value_object:__embind_register_value_object,_embind_register_value_object_field:__embind_register_value_object_field,_embind_register_void:__embind_register_void,_emval_as:__emval_as,_emval_call_void_method:__emval_call_void_method,_emval_decref:__emval_decref,_emval_get_method_caller:__emval_get_method_caller,_emval_get_property:__emval_get_property,_emval_incref:__emval_incref,_emval_new_array:__emval_new_array,_emval_new_cstring:__emval_new_cstring,_emval_run_destructors:__emval_run_destructors,_emval_set_property:__emval_set_property,_emval_take_value:__emval_take_value,abort:_abort,clock_gettime:_clock_gettime,emscripten_get_sbrk_ptr:_emscripten_get_sbrk_ptr,emscripten_memcpy_big:_emscripten_memcpy_big,emscripten_resize_heap:_emscripten_resize_heap,environ_get:_environ_get,environ_sizes_get:_environ_sizes_get,fd_close:_fd_close,fd_read:_fd_read,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,pthread_mutexattr_destroy:_pthread_mutexattr_destroy,pthread_mutexattr_init:_pthread_mutexattr_init,pthread_mutexattr_settype:_pthread_mutexattr_settype,round:_round,roundf:_roundf,setTempRet0:_setTempRet0,strftime_l:_strftime_l,sysconf:_sysconf,table:wasmTable},asm=createWasm();cv.asm=asm;var ___wasm_call_ctors=cv.___wasm_call_ctors=function(){return cv.asm.__wasm_call_ctors.apply(null,arguments)},_malloc=cv._malloc=function(){return cv.asm.malloc.apply(null,arguments)},_free=cv._free=function(){return cv.asm.free.apply(null,arguments)};cv.___errno_location=function(){return cv.asm.__errno_location.apply(null,arguments)};cv._setThrew=function(){return cv.asm.setThrew.apply(null,arguments)};var __ZSt18uncaught_exceptionv=cv.__ZSt18uncaught_exceptionv=function(){return cv.asm._ZSt18uncaught_exceptionv.apply(null,arguments)};cv.___cxa_demangle=function(){return cv.asm.__cxa_demangle.apply(null,arguments)};var ___getTypeName=cv.___getTypeName=function(){return cv.asm.__getTypeName.apply(null,arguments)};cv.___embind_register_native_and_builtin_types=function(){return cv.asm.__embind_register_native_and_builtin_types.apply(null,arguments)};cv.stackSave=function(){return cv.asm.stackSave.apply(null,arguments)};cv.stackAlloc=function(){return cv.asm.stackAlloc.apply(null,arguments)};cv.stackRestore=function(){return cv.asm.stackRestore.apply(null,arguments)};cv.__growWasmMemory=function(){return cv.asm.__growWasmMemory.apply(null,arguments)};cv.dynCall_ii=function(){return cv.asm.dynCall_ii.apply(null,arguments)};cv.dynCall_vi=function(){return cv.asm.dynCall_vi.apply(null,arguments)};cv.dynCall_i=function(){return cv.asm.dynCall_i.apply(null,arguments)};cv.dynCall_iii=function(){return cv.asm.dynCall_iii.apply(null,arguments)};cv.dynCall_iiii=function(){return cv.asm.dynCall_iiii.apply(null,arguments)};cv.dynCall_iiiii=function(){return cv.asm.dynCall_iiiii.apply(null,arguments)};cv.dynCall_iiiiii=function(){return cv.asm.dynCall_iiiiii.apply(null,arguments)};cv.dynCall_iiiiiii=function(){return cv.asm.dynCall_iiiiiii.apply(null,arguments)};cv.dynCall_viii=function(){return cv.asm.dynCall_viii.apply(null,arguments)};cv.dynCall_viiii=function(){return cv.asm.dynCall_viiii.apply(null,arguments)};cv.dynCall_vii=function(){return cv.asm.dynCall_vii.apply(null,arguments)};cv.dynCall_viiidd=function(){return cv.asm.dynCall_viiidd.apply(null,arguments)};cv.dynCall_viiiidd=function(){return cv.asm.dynCall_viiiidd.apply(null,arguments)};cv.dynCall_viiid=function(){return cv.asm.dynCall_viiid.apply(null,arguments)};cv.dynCall_viiiid=function(){return cv.asm.dynCall_viiiid.apply(null,arguments)};cv.dynCall_viiiii=function(){return cv.asm.dynCall_viiiii.apply(null,arguments)};cv.dynCall_dii=function(){return cv.asm.dynCall_dii.apply(null,arguments)};cv.dynCall_diii=function(){return cv.asm.dynCall_diii.apply(null,arguments)};cv.dynCall_iiiid=function(){return cv.asm.dynCall_iiiid.apply(null,arguments)};cv.dynCall_fiii=function(){return cv.asm.dynCall_fiii.apply(null,arguments)};cv.dynCall_fiiii=function(){return cv.asm.dynCall_fiiii.apply(null,arguments)};cv.dynCall_fiiiii=function(){return cv.asm.dynCall_fiiiii.apply(null,arguments)};cv.dynCall_diiiii=function(){return cv.asm.dynCall_diiiii.apply(null,arguments)};cv.dynCall_diiii=function(){return cv.asm.dynCall_diiii.apply(null,arguments)};cv.dynCall_viid=function(){return cv.asm.dynCall_viid.apply(null,arguments)};cv.dynCall_fii=function(){return cv.asm.dynCall_fii.apply(null,arguments)};cv.dynCall_viif=function(){return cv.asm.dynCall_viif.apply(null,arguments)};cv.dynCall_iiiiiiiiii=function(){return cv.asm.dynCall_iiiiiiiiii.apply(null,arguments)};cv.dynCall_iiiiiiiii=function(){return cv.asm.dynCall_iiiiiiiii.apply(null,arguments)};cv.dynCall_iiiiiiii=function(){return cv.asm.dynCall_iiiiiiii.apply(null,arguments)};cv.dynCall_viiif=function(){return cv.asm.dynCall_viiif.apply(null,arguments)};cv.dynCall_iiiif=function(){return cv.asm.dynCall_iiiif.apply(null,arguments)};cv.dynCall_viiiddii=function(){return cv.asm.dynCall_viiiddii.apply(null,arguments)};cv.dynCall_viiddii=function(){return cv.asm.dynCall_viiddii.apply(null,arguments)};cv.dynCall_viiiddi=function(){return cv.asm.dynCall_viiiddi.apply(null,arguments)};cv.dynCall_viiddi=function(){return cv.asm.dynCall_viiddi.apply(null,arguments)};cv.dynCall_viidd=function(){return cv.asm.dynCall_viidd.apply(null,arguments)};cv.dynCall_viiiiddi=function(){return cv.asm.dynCall_viiiiddi.apply(null,arguments)};cv.dynCall_viiiiddddii=function(){return cv.asm.dynCall_viiiiddddii.apply(null,arguments)};cv.dynCall_viiiddddii=function(){return cv.asm.dynCall_viiiddddii.apply(null,arguments)};cv.dynCall_viiiiddddi=function(){return cv.asm.dynCall_viiiiddddi.apply(null,arguments)};cv.dynCall_viiiddddi=function(){return cv.asm.dynCall_viiiddddi.apply(null,arguments)};cv.dynCall_viiiidddd=function(){return cv.asm.dynCall_viiiidddd.apply(null,arguments)};cv.dynCall_viiidddd=function(){return cv.asm.dynCall_viiidddd.apply(null,arguments)};cv.dynCall_viiiiddd=function(){return cv.asm.dynCall_viiiiddd.apply(null,arguments)};cv.dynCall_viiiddd=function(){return cv.asm.dynCall_viiiddd.apply(null,arguments)};cv.dynCall_viiiddidddd=function(){return cv.asm.dynCall_viiiddidddd.apply(null,arguments)};cv.dynCall_viiddidddd=function(){return cv.asm.dynCall_viiddidddd.apply(null,arguments)};cv.dynCall_viiiddiddd=function(){return cv.asm.dynCall_viiiddiddd.apply(null,arguments)};cv.dynCall_viiddiddd=function(){return cv.asm.dynCall_viiddiddd.apply(null,arguments)};cv.dynCall_viiiddidd=function(){return cv.asm.dynCall_viiiddidd.apply(null,arguments)};cv.dynCall_viiddidd=function(){return cv.asm.dynCall_viiddidd.apply(null,arguments)};cv.dynCall_viiiddid=function(){return cv.asm.dynCall_viiiddid.apply(null,arguments)};cv.dynCall_viiddid=function(){return cv.asm.dynCall_viiddid.apply(null,arguments)};cv.dynCall_viiiiiddi=function(){return cv.asm.dynCall_viiiiiddi.apply(null,arguments)};cv.dynCall_viiiiidd=function(){return cv.asm.dynCall_viiiiidd.apply(null,arguments)};cv.dynCall_viiiiid=function(){return cv.asm.dynCall_viiiiid.apply(null,arguments)};cv.dynCall_viiiiiiddi=function(){return cv.asm.dynCall_viiiiiiddi.apply(null,arguments)};cv.dynCall_viiiiiidd=function(){return cv.asm.dynCall_viiiiiidd.apply(null,arguments)};cv.dynCall_viiiiiid=function(){return cv.asm.dynCall_viiiiiid.apply(null,arguments)};cv.dynCall_viiiiii=function(){return cv.asm.dynCall_viiiiii.apply(null,arguments)};cv.dynCall_viiiiiiiddi=function(){return cv.asm.dynCall_viiiiiiiddi.apply(null,arguments)};cv.dynCall_viiiiiiidd=function(){return cv.asm.dynCall_viiiiiiidd.apply(null,arguments)};cv.dynCall_viiiiiiid=function(){return cv.asm.dynCall_viiiiiiid.apply(null,arguments)};cv.dynCall_viiiiiii=function(){return cv.asm.dynCall_viiiiiii.apply(null,arguments)};cv.dynCall_viiidiiid=function(){return cv.asm.dynCall_viiidiiid.apply(null,arguments)};cv.dynCall_viidiiid=function(){return cv.asm.dynCall_viidiiid.apply(null,arguments)};cv.dynCall_viididdii=function(){return cv.asm.dynCall_viididdii.apply(null,arguments)};cv.dynCall_vididdii=function(){return cv.asm.dynCall_vididdii.apply(null,arguments)};cv.dynCall_viididdi=function(){return cv.asm.dynCall_viididdi.apply(null,arguments)};cv.dynCall_vididdi=function(){return cv.asm.dynCall_vididdi.apply(null,arguments)};cv.dynCall_viiidi=function(){return cv.asm.dynCall_viiidi.apply(null,arguments)};cv.dynCall_viidi=function(){return cv.asm.dynCall_viidi.apply(null,arguments)};cv.dynCall_viiiiiiii=function(){return cv.asm.dynCall_viiiiiiii.apply(null,arguments)};cv.dynCall_viiiidiiiidi=function(){return cv.asm.dynCall_viiiidiiiidi.apply(null,arguments)};cv.dynCall_viiidiiiidi=function(){return cv.asm.dynCall_viiidiiiidi.apply(null,arguments)};cv.dynCall_viiiiiiiiiiid=function(){return cv.asm.dynCall_viiiiiiiiiiid.apply(null,arguments)};cv.dynCall_viiiiiiiiiid=function(){return cv.asm.dynCall_viiiiiiiiiid.apply(null,arguments)};cv.dynCall_viiiiiiiiiii=function(){return cv.asm.dynCall_viiiiiiiiiii.apply(null,arguments)};cv.dynCall_viiiiiiiiii=function(){return cv.asm.dynCall_viiiiiiiiii.apply(null,arguments)};cv.dynCall_viiiiiiiii=function(){return cv.asm.dynCall_viiiiiiiii.apply(null,arguments)};cv.dynCall_diiiiiiiiiiiii=function(){return cv.asm.dynCall_diiiiiiiiiiiii.apply(null,arguments)};cv.dynCall_diiiiiiiiiiii=function(){return cv.asm.dynCall_diiiiiiiiiiii.apply(null,arguments)};cv.dynCall_diiiiiiiiiii=function(){return cv.asm.dynCall_diiiiiiiiiii.apply(null,arguments)};cv.dynCall_diiiiiiiiii=function(){return cv.asm.dynCall_diiiiiiiiii.apply(null,arguments)};cv.dynCall_di=function(){return cv.asm.dynCall_di.apply(null,arguments)};cv.dynCall_viiiiidi=function(){return cv.asm.dynCall_viiiiidi.apply(null,arguments)};cv.dynCall_viiiidi=function(){return cv.asm.dynCall_viiiidi.apply(null,arguments)};cv.dynCall_vidiii=function(){return cv.asm.dynCall_vidiii.apply(null,arguments)};cv.dynCall_vdiii=function(){return cv.asm.dynCall_vdiii.apply(null,arguments)};cv.dynCall_vidii=function(){return cv.asm.dynCall_vidii.apply(null,arguments)};cv.dynCall_vdii=function(){return cv.asm.dynCall_vdii.apply(null,arguments)};cv.dynCall_viiiiiifi=function(){return cv.asm.dynCall_viiiiiifi.apply(null,arguments)};cv.dynCall_viiiiifi=function(){return cv.asm.dynCall_viiiiifi.apply(null,arguments)};cv.dynCall_viiiiiif=function(){return cv.asm.dynCall_viiiiiif.apply(null,arguments)};cv.dynCall_viiiiif=function(){return cv.asm.dynCall_viiiiif.apply(null,arguments)};cv.dynCall_viiiiiiiiiiii=function(){return cv.asm.dynCall_viiiiiiiiiiii.apply(null,arguments)};cv.dynCall_viiiidddiiii=function(){return cv.asm.dynCall_viiiidddiiii.apply(null,arguments)};cv.dynCall_viiidddiiii=function(){return cv.asm.dynCall_viiidddiiii.apply(null,arguments)};cv.dynCall_viiiidddiii=function(){return cv.asm.dynCall_viiiidddiii.apply(null,arguments)};cv.dynCall_viiidddiii=function(){return cv.asm.dynCall_viiidddiii.apply(null,arguments)};cv.dynCall_viiiidddii=function(){return cv.asm.dynCall_viiiidddii.apply(null,arguments)};cv.dynCall_viiidddii=function(){return cv.asm.dynCall_viiidddii.apply(null,arguments)};cv.dynCall_viiiidddi=function(){return cv.asm.dynCall_viiiidddi.apply(null,arguments)};cv.dynCall_viiidddi=function(){return cv.asm.dynCall_viiidddi.apply(null,arguments)};cv.dynCall_iiiiiididi=function(){return cv.asm.dynCall_iiiiiididi.apply(null,arguments)};cv.dynCall_viiiiididi=function(){return cv.asm.dynCall_viiiiididi.apply(null,arguments)};cv.dynCall_iiiiiidid=function(){return cv.asm.dynCall_iiiiiidid.apply(null,arguments)};cv.dynCall_viiiiidid=function(){return cv.asm.dynCall_viiiiidid.apply(null,arguments)};cv.dynCall_iiiiiidi=function(){return cv.asm.dynCall_iiiiiidi.apply(null,arguments)};cv.dynCall_iiiiiid=function(){return cv.asm.dynCall_iiiiiid.apply(null,arguments)};cv.dynCall_viiiiiidi=function(){return cv.asm.dynCall_viiiiiidi.apply(null,arguments)};cv.dynCall_iiiiidiid=function(){return cv.asm.dynCall_iiiiidiid.apply(null,arguments)};cv.dynCall_viiiidiid=function(){return cv.asm.dynCall_viiiidiid.apply(null,arguments)};cv.dynCall_iiiiidii=function(){return cv.asm.dynCall_iiiiidii.apply(null,arguments)};cv.dynCall_viiiidii=function(){return cv.asm.dynCall_viiiidii.apply(null,arguments)};cv.dynCall_iiiiidi=function(){return cv.asm.dynCall_iiiiidi.apply(null,arguments)};cv.dynCall_iiiiid=function(){return cv.asm.dynCall_iiiiid.apply(null,arguments)};cv.dynCall_diiiiiiii=function(){return cv.asm.dynCall_diiiiiiii.apply(null,arguments)};cv.dynCall_diiiiiii=function(){return cv.asm.dynCall_diiiiiii.apply(null,arguments)};cv.dynCall_diiiiii=function(){return cv.asm.dynCall_diiiiii.apply(null,arguments)};cv.dynCall_viiididii=function(){return cv.asm.dynCall_viiididii.apply(null,arguments)};cv.dynCall_viididii=function(){return cv.asm.dynCall_viididii.apply(null,arguments)};cv.dynCall_viiididi=function(){return cv.asm.dynCall_viiididi.apply(null,arguments)};cv.dynCall_viididi=function(){return cv.asm.dynCall_viididi.apply(null,arguments)};cv.dynCall_iiidd=function(){return cv.asm.dynCall_iiidd.apply(null,arguments)};cv.dynCall_viiiiddiiid=function(){return cv.asm.dynCall_viiiiddiiid.apply(null,arguments)};cv.dynCall_viiiddiiid=function(){return cv.asm.dynCall_viiiddiiid.apply(null,arguments)};cv.dynCall_viiiiddiii=function(){return cv.asm.dynCall_viiiiddiii.apply(null,arguments)};cv.dynCall_viiiddiii=function(){return cv.asm.dynCall_viiiddiii.apply(null,arguments)};cv.dynCall_viiiiddii=function(){return cv.asm.dynCall_viiiiddii.apply(null,arguments)};cv.dynCall_viiiiddiiiid=function(){return cv.asm.dynCall_viiiiddiiiid.apply(null,arguments)};cv.dynCall_viiiddiiiid=function(){return cv.asm.dynCall_viiiddiiiid.apply(null,arguments)};cv.dynCall_viiiiddiiii=function(){return cv.asm.dynCall_viiiiddiiii.apply(null,arguments)};cv.dynCall_viiiddiiii=function(){return cv.asm.dynCall_viiiddiiii.apply(null,arguments)};cv.dynCall_diiiid=function(){return cv.asm.dynCall_diiiid.apply(null,arguments)};cv.dynCall_diiid=function(){return cv.asm.dynCall_diiid.apply(null,arguments)};cv.dynCall_viiddiii=function(){return cv.asm.dynCall_viiddiii.apply(null,arguments)};cv.dynCall_vidi=function(){return cv.asm.dynCall_vidi.apply(null,arguments)};cv.dynCall_viiiiiiiid=function(){return cv.asm.dynCall_viiiiiiiid.apply(null,arguments)};cv.dynCall_viiiiidiiii=function(){return cv.asm.dynCall_viiiiidiiii.apply(null,arguments)};cv.dynCall_viiiidiiii=function(){return cv.asm.dynCall_viiiidiiii.apply(null,arguments)};cv.dynCall_viiiiidiii=function(){return cv.asm.dynCall_viiiiidiii.apply(null,arguments)};cv.dynCall_viiiidiii=function(){return cv.asm.dynCall_viiiidiii.apply(null,arguments)};cv.dynCall_viiiiidii=function(){return cv.asm.dynCall_viiiiidii.apply(null,arguments)};cv.dynCall_viiiiiiidi=function(){return cv.asm.dynCall_viiiiiiidi.apply(null,arguments)};cv.dynCall_iiiiiiiiiifdii=function(){return cv.asm.dynCall_iiiiiiiiiifdii.apply(null,arguments)};cv.dynCall_iiiiiiiiifdii=function(){return cv.asm.dynCall_iiiiiiiiifdii.apply(null,arguments)};cv.dynCall_iiiiiiiiiifdi=function(){return cv.asm.dynCall_iiiiiiiiiifdi.apply(null,arguments)};cv.dynCall_iiiiiiiiifdi=function(){return cv.asm.dynCall_iiiiiiiiifdi.apply(null,arguments)};cv.dynCall_iiiiiiiiiifd=function(){return cv.asm.dynCall_iiiiiiiiiifd.apply(null,arguments)};cv.dynCall_iiiiiiiiifd=function(){return cv.asm.dynCall_iiiiiiiiifd.apply(null,arguments)};cv.dynCall_iiiiiiiiiif=function(){return cv.asm.dynCall_iiiiiiiiiif.apply(null,arguments)};cv.dynCall_iiiiiiiiif=function(){return cv.asm.dynCall_iiiiiiiiif.apply(null,arguments)};cv.dynCall_diiiddi=function(){return cv.asm.dynCall_diiiddi.apply(null,arguments)};cv.dynCall_diiddi=function(){return cv.asm.dynCall_diiddi.apply(null,arguments)};cv.dynCall_iiidiiiii=function(){return cv.asm.dynCall_iiidiiiii.apply(null,arguments)};cv.dynCall_viidiiiii=function(){return cv.asm.dynCall_viidiiiii.apply(null,arguments)};cv.dynCall_iiidiiii=function(){return cv.asm.dynCall_iiidiiii.apply(null,arguments)};cv.dynCall_viidiiii=function(){return cv.asm.dynCall_viidiiii.apply(null,arguments)};cv.dynCall_iiidiii=function(){return cv.asm.dynCall_iiidiii.apply(null,arguments)};cv.dynCall_viidiii=function(){return cv.asm.dynCall_viidiii.apply(null,arguments)};cv.dynCall_iiidii=function(){return cv.asm.dynCall_iiidii.apply(null,arguments)};cv.dynCall_viidii=function(){return cv.asm.dynCall_viidii.apply(null,arguments)};cv.dynCall_iiidi=function(){return cv.asm.dynCall_iiidi.apply(null,arguments)};cv.dynCall_iiid=function(){return cv.asm.dynCall_iiid.apply(null,arguments)};cv.dynCall_iiiiifiii=function(){return cv.asm.dynCall_iiiiifiii.apply(null,arguments)};cv.dynCall_viiiifiii=function(){return cv.asm.dynCall_viiiifiii.apply(null,arguments)};cv.dynCall_iiiiifii=function(){return cv.asm.dynCall_iiiiifii.apply(null,arguments)};cv.dynCall_viiiifii=function(){return cv.asm.dynCall_viiiifii.apply(null,arguments)};cv.dynCall_iiiiifi=function(){return cv.asm.dynCall_iiiiifi.apply(null,arguments)};cv.dynCall_viiiifi=function(){return cv.asm.dynCall_viiiifi.apply(null,arguments)};cv.dynCall_iiiiif=function(){return cv.asm.dynCall_iiiiif.apply(null,arguments)};cv.dynCall_viiiif=function(){return cv.asm.dynCall_viiiif.apply(null,arguments)};cv.dynCall_vid=function(){return cv.asm.dynCall_vid.apply(null,arguments)};cv.dynCall_iiiiffi=function(){return cv.asm.dynCall_iiiiffi.apply(null,arguments)};cv.dynCall_viiiffi=function(){return cv.asm.dynCall_viiiffi.apply(null,arguments)};cv.dynCall_iiiiff=function(){return cv.asm.dynCall_iiiiff.apply(null,arguments)};cv.dynCall_viiiff=function(){return cv.asm.dynCall_viiiff.apply(null,arguments)};cv.dynCall_iiiiiiffi=function(){return cv.asm.dynCall_iiiiiiffi.apply(null,arguments)};cv.dynCall_viiiiiffi=function(){return cv.asm.dynCall_viiiiiffi.apply(null,arguments)};cv.dynCall_iiiiiiff=function(){return cv.asm.dynCall_iiiiiiff.apply(null,arguments)};cv.dynCall_viiiiiff=function(){return cv.asm.dynCall_viiiiiff.apply(null,arguments)};cv.dynCall_iidi=function(){return cv.asm.dynCall_iidi.apply(null,arguments)};cv.dynCall_iid=function(){return cv.asm.dynCall_iid.apply(null,arguments)};cv.dynCall_iiifi=function(){return cv.asm.dynCall_iiifi.apply(null,arguments)};cv.dynCall_viifi=function(){return cv.asm.dynCall_viifi.apply(null,arguments)};cv.dynCall_iiif=function(){return cv.asm.dynCall_iiif.apply(null,arguments)};cv.dynCall_vif=function(){return cv.asm.dynCall_vif.apply(null,arguments)};cv.dynCall_viiidiiii=function(){return cv.asm.dynCall_viiidiiii.apply(null,arguments)};cv.dynCall_viiidiii=function(){return cv.asm.dynCall_viiidiii.apply(null,arguments)};cv.dynCall_viiidii=function(){return cv.asm.dynCall_viiidii.apply(null,arguments)};cv.dynCall_viiiiidiiiii=function(){return cv.asm.dynCall_viiiiidiiiii.apply(null,arguments)};cv.dynCall_viiiiiidiiiii=function(){return cv.asm.dynCall_viiiiiidiiiii.apply(null,arguments)};cv.dynCall_viiiiiidiiii=function(){return cv.asm.dynCall_viiiiiidiiii.apply(null,arguments)};cv.dynCall_viiiiiidiii=function(){return cv.asm.dynCall_viiiiiidiii.apply(null,arguments)};cv.dynCall_viiiiiidii=function(){return cv.asm.dynCall_viiiiiidii.apply(null,arguments)};cv.dynCall_viiiiifii=function(){return cv.asm.dynCall_viiiiifii.apply(null,arguments)};cv.dynCall_viiifii=function(){return cv.asm.dynCall_viiifii.apply(null,arguments)};cv.dynCall_viiifi=function(){return cv.asm.dynCall_viiifi.apply(null,arguments)};cv.dynCall_iiiddiid=function(){return cv.asm.dynCall_iiiddiid.apply(null,arguments)};cv.dynCall_viiddiid=function(){return cv.asm.dynCall_viiddiid.apply(null,arguments)};cv.dynCall_iiiddii=function(){return cv.asm.dynCall_iiiddii.apply(null,arguments)};cv.dynCall_iiiddi=function(){return cv.asm.dynCall_iiiddi.apply(null,arguments)};cv.dynCall_iiiddiiid=function(){return cv.asm.dynCall_iiiddiiid.apply(null,arguments)};cv.dynCall_viiddiiid=function(){return cv.asm.dynCall_viiddiiid.apply(null,arguments)};cv.dynCall_iiiiiiiididiii=function(){return cv.asm.dynCall_iiiiiiiididiii.apply(null,arguments)};cv.dynCall_iiiiiiiiiiiii=function(){return cv.asm.dynCall_iiiiiiiiiiiii.apply(null,arguments)};cv.dynCall_viiiidiiddi=function(){return cv.asm.dynCall_viiiidiiddi.apply(null,arguments)};cv.dynCall_viiiiidiiddi=function(){return cv.asm.dynCall_viiiiidiiddi.apply(null,arguments)};cv.dynCall_viiiidiidd=function(){return cv.asm.dynCall_viiiidiidd.apply(null,arguments)};cv.dynCall_viiiiidiidd=function(){return cv.asm.dynCall_viiiiidiidd.apply(null,arguments)};cv.dynCall_viiiiidiid=function(){return cv.asm.dynCall_viiiiidiid.apply(null,arguments)};cv.dynCall_iiiifiii=function(){return cv.asm.dynCall_iiiifiii.apply(null,arguments)};cv.dynCall_viiifiii=function(){return cv.asm.dynCall_viiifiii.apply(null,arguments)};cv.dynCall_iiiifii=function(){return cv.asm.dynCall_iiiifii.apply(null,arguments)};cv.dynCall_iiiifi=function(){return cv.asm.dynCall_iiiifi.apply(null,arguments)};cv.dynCall_iiiiiddiddi=function(){return cv.asm.dynCall_iiiiiddiddi.apply(null,arguments)};cv.dynCall_viiiiddiddi=function(){return cv.asm.dynCall_viiiiddiddi.apply(null,arguments)};cv.dynCall_iiiiiddidd=function(){return cv.asm.dynCall_iiiiiddidd.apply(null,arguments)};cv.dynCall_viiiiddidd=function(){return cv.asm.dynCall_viiiiddidd.apply(null,arguments)};cv.dynCall_iiiiiddid=function(){return cv.asm.dynCall_iiiiiddid.apply(null,arguments)};cv.dynCall_viiiiddid=function(){return cv.asm.dynCall_viiiiddid.apply(null,arguments)};cv.dynCall_iiiiiddi=function(){return cv.asm.dynCall_iiiiiddi.apply(null,arguments)};cv.dynCall_iiiiidd=function(){return cv.asm.dynCall_iiiiidd.apply(null,arguments)};cv.dynCall_iifff=function(){return cv.asm.dynCall_iifff.apply(null,arguments)};cv.dynCall_vifff=function(){return cv.asm.dynCall_vifff.apply(null,arguments)};cv.dynCall_iiff=function(){return cv.asm.dynCall_iiff.apply(null,arguments)};cv.dynCall_viff=function(){return cv.asm.dynCall_viff.apply(null,arguments)};cv.dynCall_iif=function(){return cv.asm.dynCall_iif.apply(null,arguments)};cv.dynCall_iiifiiiiiii=function(){return cv.asm.dynCall_iiifiiiiiii.apply(null,arguments)};cv.dynCall_viifiiiiiii=function(){return cv.asm.dynCall_viifiiiiiii.apply(null,arguments)};cv.dynCall_iiifiiiiii=function(){return cv.asm.dynCall_iiifiiiiii.apply(null,arguments)};cv.dynCall_viifiiiiii=function(){return cv.asm.dynCall_viifiiiiii.apply(null,arguments)};cv.dynCall_iiifiiiii=function(){return cv.asm.dynCall_iiifiiiii.apply(null,arguments)};cv.dynCall_viifiiiii=function(){return cv.asm.dynCall_viifiiiii.apply(null,arguments)};cv.dynCall_iiifiiii=function(){return cv.asm.dynCall_iiifiiii.apply(null,arguments)};cv.dynCall_viifiiii=function(){return cv.asm.dynCall_viifiiii.apply(null,arguments)};cv.dynCall_iiifiii=function(){return cv.asm.dynCall_iiifiii.apply(null,arguments)};cv.dynCall_viifiii=function(){return cv.asm.dynCall_viifiii.apply(null,arguments)};cv.dynCall_iiifii=function(){return cv.asm.dynCall_iiifii.apply(null,arguments)};cv.dynCall_viifii=function(){return cv.asm.dynCall_viifii.apply(null,arguments)};cv.dynCall_iiffff=function(){return cv.asm.dynCall_iiffff.apply(null,arguments)};cv.dynCall_viffff=function(){return cv.asm.dynCall_viffff.apply(null,arguments)};cv.dynCall_viifff=function(){return cv.asm.dynCall_viifff.apply(null,arguments)};cv.dynCall_iiifff=function(){return cv.asm.dynCall_iiifff.apply(null,arguments)};cv.dynCall_viijii=function(){return cv.asm.dynCall_viijii.apply(null,arguments)};cv.dynCall_ji=function(){return cv.asm.dynCall_ji.apply(null,arguments)};cv.dynCall_viiiiiiiiiiddi=function(){return cv.asm.dynCall_viiiiiiiiiiddi.apply(null,arguments)};cv.dynCall_v=function(){return cv.asm.dynCall_v.apply(null,arguments)};cv.dynCall_viiiiiiiiidd=function(){return cv.asm.dynCall_viiiiiiiiidd.apply(null,arguments)};cv.dynCall_fi=function(){return cv.asm.dynCall_fi.apply(null,arguments)};cv.dynCall_jiii=function(){return cv.asm.dynCall_jiii.apply(null,arguments)};cv.dynCall_vifi=function(){return cv.asm.dynCall_vifi.apply(null,arguments)};cv.dynCall_vij=function(){return cv.asm.dynCall_vij.apply(null,arguments)};cv.dynCall_iiiiiifiididiii=function(){return cv.asm.dynCall_iiiiiifiididiii.apply(null,arguments)};cv.dynCall_viiidiiddi=function(){return cv.asm.dynCall_viiidiiddi.apply(null,arguments)};cv.dynCall_jii=function(){return cv.asm.dynCall_jii.apply(null,arguments)};cv.dynCall_viji=function(){return cv.asm.dynCall_viji.apply(null,arguments)};cv.dynCall_jiji=function(){return cv.asm.dynCall_jiji.apply(null,arguments)};cv.dynCall_iidiiii=function(){return cv.asm.dynCall_iidiiii.apply(null,arguments)};cv.dynCall_iiiiij=function(){return cv.asm.dynCall_iiiiij.apply(null,arguments)};cv.dynCall_iiiiijj=function(){return cv.asm.dynCall_iiiiijj.apply(null,arguments)};cv.dynCall_iiiiiijj=function(){return cv.asm.dynCall_iiiiiijj.apply(null,arguments)};cv.asm=asm;cv.getMemory=getMemory;cv.addRunDependency=addRunDependency;cv.removeRunDependency=removeRunDependency;cv.FS_createFolder=FS.createFolder;cv.FS_createPath=FS.createPath;cv.FS_createDataFile=FS.createDataFile;cv.FS_createPreloadedFile=FS.createPreloadedFile;cv.FS_createLazyFile=FS.createLazyFile;cv.FS_createLink=FS.createLink;cv.FS_createDevice=FS.createDevice;cv.FS_unlink=FS.unlink;cv.calledRun=calledRun;var calledRun;cv.then=function(n){if(calledRun)n(cv);else{var e=cv.onRuntimeInitialized;cv.onRuntimeInitialized=function(){e&&e(),n(cv)}}return cv};function ExitStatus(n){this.name="ExitStatus",this.message="Program terminated with exit("+n+")",this.status=n}dependenciesFulfilled=function n(){calledRun||run$2(),calledRun||(dependenciesFulfilled=n)};function run$2(n){if(runDependencies>0||(preRun(),runDependencies>0))return;function e(){calledRun||(calledRun=!0,cv.calledRun=!0,!ABORT&&(initRuntime(),preMain(),cv.onRuntimeInitialized&&cv.onRuntimeInitialized(),postRun()))}cv.setStatus?(cv.setStatus("Running..."),setTimeout(function(){setTimeout(function(){cv.setStatus("")},1),e()},1)):e()}cv.run=run$2;if(cv.preInit)for(typeof cv.preInit=="function"&&(cv.preInit=[cv.preInit]);cv.preInit.length>0;)cv.preInit.pop()();run$2();typeof cv.FS=="undefined"&&typeof FS!="undefined"&&(cv.FS=FS);cv.imread=function(n){var e=null;typeof n=="string"?e=document.getElementById(n):e=n;var r=null,t=null;if(e instanceof HTMLImageElement)r=document.createElement("canvas"),r.width=e.width,r.height=e.height,t=r.getContext("2d"),t.drawImage(e,0,0,e.width,e.height);else if(e instanceof HTMLCanvasElement)r=e,t=r.getContext("2d");else throw new Error("Please input the valid canvas or img id.");var o=t.getImageData(0,0,r.width,r.height);return cv.matFromImageData(o)};cv.imshow=function(n,e){var r=null;if(typeof n=="string"?r=document.getElementById(n):r=n,!(r instanceof HTMLCanvasElement))throw new Error("Please input the valid canvas element or id.");if(!(e instanceof cv.Mat))throw new Error("Please input the valid cv.Mat instance.");var t=new cv.Mat,o=e.type()%8,i=o<=cv.CV_8S?1:o<=cv.CV_32S?1/256:255,l=o===cv.CV_8S||o===cv.CV_16S?128:0;switch(e.convertTo(t,cv.CV_8U,i,l),t.type()){case cv.CV_8UC1:cv.cvtColor(t,t,cv.COLOR_GRAY2RGBA);break;case cv.CV_8UC3:cv.cvtColor(t,t,cv.COLOR_RGB2RGBA);break;case cv.CV_8UC4:break;default:throw new Error("Bad number of channels (Source image must have 1, 3 or 4 channels)")}var a=new ImageData(new Uint8ClampedArray(t.data),t.cols,t.rows),s=r.getContext("2d");s.clearRect(0,0,r.width,r.height),r.width=a.width,r.height=a.height,s.putImageData(a,0,0),t.delete()};cv.VideoCapture=function(n){var e=null;if(typeof n=="string"?e=document.getElementById(n):e=n,!(e instanceof HTMLVideoElement))throw new Error("Please input the valid video element or id.");var r=document.createElement("canvas");r.width=e.width,r.height=e.height;var t=r.getContext("2d");this.video=e,this.read=function(o){if(!(o instanceof cv.Mat))throw new Error("Please input the valid cv.Mat instance.");if(o.type()!==cv.CV_8UC4)throw new Error("Bad type of input mat: the type should be cv.CV_8UC4.");if(o.cols!==e.width||o.rows!==e.height)throw new Error("Bad size of input mat: the size should be same as the video.");t.drawImage(e,0,0,e.width,e.height),o.data.set(t.getImageData(0,0,e.width,e.height).data)}};function Range(n,e){this.start=typeof n=="undefined"?0:n,this.end=typeof e=="undefined"?0:e}cv.Range=Range;function Point(n,e){this.x=typeof n=="undefined"?0:n,this.y=typeof e=="undefined"?0:e}cv.Point=Point;function Size(n,e){this.width=typeof n=="undefined"?0:n,this.height=typeof e=="undefined"?0:e}cv.Size=Size;function Rect(){switch(arguments.length){case 0:{this.x=0,this.y=0,this.width=0,this.height=0;break}case 1:{var n=arguments[0];this.x=n.x,this.y=n.y,this.width=n.width,this.height=n.height;break}case 2:{var e=arguments[0],r=arguments[1];this.x=e.x,this.y=e.y,this.width=r.width,this.height=r.height;break}case 4:{this.x=arguments[0],this.y=arguments[1],this.width=arguments[2],this.height=arguments[3];break}default:throw new Error("Invalid arguments")}}cv.Rect=Rect;function RotatedRect(){switch(arguments.length){case 0:{this.center={x:0,y:0},this.size={width:0,height:0},this.angle=0;break}case 3:{this.center=arguments[0],this.size=arguments[1],this.angle=arguments[2];break}default:throw new Error("Invalid arguments")}}RotatedRect.points=function(n){return cv.rotatedRectPoints(n)};RotatedRect.boundingRect=function(n){return cv.rotatedRectBoundingRect(n)};RotatedRect.boundingRect2f=function(n){return cv.rotatedRectBoundingRect2f(n)};cv.RotatedRect=RotatedRect;function Scalar(n,e,r,t){this.push(typeof n=="undefined"?0:n),this.push(typeof e=="undefined"?0:e),this.push(typeof r=="undefined"?0:r),this.push(typeof t=="undefined"?0:t)}Scalar.prototype=new Array;Scalar.all=function(n){return new Scalar(n,n,n,n)};cv.Scalar=Scalar;function MinMaxLoc(){switch(arguments.length){case 0:{this.minVal=0,this.maxVal=0,this.minLoc=new Point,this.maxLoc=new Point;break}case 4:{this.minVal=arguments[0],this.maxVal=arguments[1],this.minLoc=arguments[2],this.maxLoc=arguments[3];break}default:throw new Error("Invalid arguments")}}cv.MinMaxLoc=MinMaxLoc;function Circle(){switch(arguments.length){case 0:{this.center=new Point,this.radius=0;break}case 2:{this.center=arguments[0],this.radius=arguments[1];break}default:throw new Error("Invalid arguments")}}cv.Circle=Circle;function TermCriteria(){switch(arguments.length){case 0:{this.type=0,this.maxCount=0,this.epsilon=0;break}case 3:{this.type=arguments[0],this.maxCount=arguments[1],this.epsilon=arguments[2];break}default:throw new Error("Invalid arguments")}}cv.TermCriteria=TermCriteria;cv.matFromArray=function(n,e,r,t){var o=new cv.Mat(n,e,r);switch(r){case cv.CV_8U:case cv.CV_8UC1:case cv.CV_8UC2:case cv.CV_8UC3:case cv.CV_8UC4:{o.data.set(t);break}case cv.CV_8S:case cv.CV_8SC1:case cv.CV_8SC2:case cv.CV_8SC3:case cv.CV_8SC4:{o.data8S.set(t);break}case cv.CV_16U:case cv.CV_16UC1:case cv.CV_16UC2:case cv.CV_16UC3:case cv.CV_16UC4:{o.data16U.set(t);break}case cv.CV_16S:case cv.CV_16SC1:case cv.CV_16SC2:case cv.CV_16SC3:case cv.CV_16SC4:{o.data16S.set(t);break}case cv.CV_32S:case cv.CV_32SC1:case cv.CV_32SC2:case cv.CV_32SC3:case cv.CV_32SC4:{o.data32S.set(t);break}case cv.CV_32F:case cv.CV_32FC1:case cv.CV_32FC2:case cv.CV_32FC3:case cv.CV_32FC4:{o.data32F.set(t);break}case cv.CV_64F:case cv.CV_64FC1:case cv.CV_64FC2:case cv.CV_64FC3:case cv.CV_64FC4:{o.data64F.set(t);break}default:throw new Error("Type is unsupported")}return o};cv.matFromImageData=function(n){var e=new cv.Mat(n.height,n.width,cv.CV_8UC4);return e.data.set(n.data),e};cv.loadPromise=new Promise(n=>{cv.onRuntimeInitialized=n});cv.init=function(){return cv.loadPromise};var commonjsGlobal$1=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getAugmentedNamespace(n){if(n.__esModule)return n;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(r){var t=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,t.get?t:{enumerable:!0,get:function(){return n[r]}})}),e}function commonjsRequire$1(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var lib$1={};const backends={},backendsSortedByPriority=[],registerBackend=(n,e,r)=>{if(e&&typeof e.init=="function"&&typeof e.createSessionHandler=="function"){const t=backends[n];if(t===void 0)backends[n]={backend:e,priority:r};else{if(t.backend===e)return;throw new Error(`backend "${n}" is already registered`)}if(r>=0){for(let o=0;o<backendsSortedByPriority.length;o++)if(backends[backendsSortedByPriority[o]].priority<=r){backendsSortedByPriority.splice(o,0,n);return}backendsSortedByPriority.push(n)}return}throw new TypeError("not a valid backend")},resolveBackend=async n=>{const e=n.length===0?backendsSortedByPriority:n,r=[];for(const t of e){const o=backends[t];if(o){if(o.initialized)return o.backend;if(o.aborted)continue;const i=!!o.initPromise;try{return i||(o.initPromise=o.backend.init()),await o.initPromise,o.initialized=!0,o.backend}catch(l){i||r.push({name:t,err:l}),o.aborted=!0}finally{delete o.initPromise}}}throw new Error(`no available backend found. ERR: ${r.map(t=>`[${t.name}] ${t.err}`).join(", ")}`)};class EnvImpl{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);this.logLevelInternal=e}}get logLevel(){return this.logLevelInternal}}const env=new EnvImpl,isBigInt64ArrayAvailable=typeof BigInt64Array!="undefined"&&typeof BigInt64Array.from=="function",isBigUint64ArrayAvailable=typeof BigUint64Array!="undefined"&&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=n=>{let e=1;for(let r=0;r<n.length;r++){const t=n[r];if(typeof t!="number"||!Number.isSafeInteger(t))throw new TypeError(`dims[${r}] must be an integer, got: ${t}`);if(t<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${t}`);e*=t}return e};class Tensor$2{constructor(e,r,t){let o,i,l;if(typeof e=="string")if(o=e,l=t,e==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");i=r}else{const s=NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(e);if(s===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(r))i=s.from(r);else if(r instanceof s)i=r;else throw new TypeError(`A ${o} tensor's data must be type of ${s}`)}else if(l=r,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const s=typeof e[0];if(s==="string")o="string",i=e;else if(s==="boolean")o="bool",i=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${s}.`)}else{const s=NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(e.constructor);if(s===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);o=s,i=e}if(l===void 0)l=[i.length];else if(!Array.isArray(l))throw new TypeError("A tensor's dims must be a number array");const a=calculateSize(l);if(a!==i.length)throw new Error(`Tensor's size(${a}) does not match data length(${i.length}).`);this.dims=l,this.type=o,this.data=i,this.size=a}reshape(e){return new Tensor$2(this.type,this.data,e)}}const Tensor$1=Tensor$2;class InferenceSession$1{constructor(e){this.handler=e}async run(e,r,t){const o={};let i={};if(typeof e!="object"||e===null||e instanceof Tensor$1||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let l=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Tensor$1)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");l=!1;for(const u of r){if(typeof u!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(u)===-1)throw new RangeError(`'fetches' contains invalid output name: ${u}.`);o[u]=null}if(typeof t=="object"&&t!==null)i=t;else if(typeof t!="undefined")throw new TypeError("'options' must be an object.")}else{let u=!1;const c=Object.getOwnPropertyNames(r);for(const f of this.outputNames)if(c.indexOf(f)!==-1){const d=r[f];(d===null||d instanceof Tensor$1)&&(u=!0,l=!1,o[f]=d)}if(u){if(typeof t=="object"&&t!==null)i=t;else if(typeof t!="undefined")throw new TypeError("'options' must be an object.")}else i=r}}else if(typeof r!="undefined")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const u of this.inputNames)if(typeof e[u]=="undefined")throw new Error(`input '${u}' is missing in 'feeds'.`);if(l)for(const u of this.outputNames)o[u]=null;const a=await this.handler.run(e,o,i),s={};for(const u in a)Object.hasOwnProperty.call(a,u)&&(s[u]=new Tensor$1(a[u].type,a[u].data,a[u].dims));return s}static async create(e,r,t,o){let i,l={};if(typeof e=="string"){if(i=e,typeof r=="object"&&r!==null)l=r;else if(typeof r!="undefined")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(i=e,typeof r=="object"&&r!==null)l=r;else if(typeof r!="undefined")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer!="undefined"&&e instanceof SharedArrayBuffer){const f=e;let d=0,m=e.byteLength;if(typeof r=="object"&&r!==null)l=r;else if(typeof r=="number"){if(d=r,!Number.isSafeInteger(d))throw new RangeError("'byteOffset' must be an integer.");if(d<0||d>=f.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${f.byteLength}).`);if(m=e.byteLength-d,typeof t=="number"){if(m=t,!Number.isSafeInteger(m))throw new RangeError("'byteLength' must be an integer.");if(m<=0||d+m>f.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${f.byteLength-d}].`);if(typeof o=="object"&&o!==null)l=o;else if(typeof o!="undefined")throw new TypeError("'options' must be an object.")}else if(typeof t!="undefined")throw new TypeError("'byteLength' must be a number.")}else if(typeof r!="undefined")throw new TypeError("'options' must be an object.");i=new Uint8Array(f,d,m)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const s=(l.executionProviders||[]).map(f=>typeof f=="string"?f:f.name),c=await(await resolveBackend(s)).createSessionHandler(i,l);return new InferenceSession$1(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}const InferenceSession=InferenceSession$1;var lib=Object.freeze(Object.defineProperty({__proto__:null,registerBackend,env,InferenceSession,Tensor:Tensor$1},Symbol.toStringTag,{value:"Module"})),require$$0$1=getAugmentedNamespace(lib),backendOnnxjs={},session={},__viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$3$1=getAugmentedNamespace(__viteBrowserExternal$1),backend={},backendWebgl={},instrument={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.now=n.Profiler=n.Logger=void 0;class e{log(_,S,E){}}class r{log(_,S,E){console.log(`${this.color(_)} ${E?"\x1B[35m"+E+"\x1B[0m ":""}${S}`)}color(_){switch(_){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: ${_}`)}}}const t={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},o={none:new e,console:new r},i={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let l={[""]:i};function a(m,_,S,E){if(_===void 0)return s(m);if(S===void 0)u(m,_);else if(typeof S=="number"&&E===void 0)u(m,_);else if(typeof S=="string"&&E===void 0)u(m,S,1,_);else if(typeof S=="string"&&typeof E=="number")u(m,S,E,_);else throw new TypeError("input is valid")}function s(m){return{verbose:a.verbose.bind(null,m),info:a.info.bind(null,m),warning:a.warning.bind(null,m),error:a.error.bind(null,m),fatal:a.fatal.bind(null,m)}}function u(m,_,S,E){const $=l[E||""]||l[""];t[m]<t[$.minimalSeverity]||($.logDateTime&&(_=`${new Date().toISOString()}|${_}`),$.logSourceLocation,o[$.provider].log(m,_,E))}(function(m){function _(C,L){m("verbose",C,L)}m.verbose=_;function S(C,L){m("info",C,L)}m.info=S;function E(C,L){m("warning",C,L)}m.warning=E;function $(C,L){m("error",C,L)}m.error=$;function y(C,L){m("fatal",C,L)}m.fatal=y;function v(C){l={},A("",C||{})}m.reset=v;function A(C,L){if(C==="*")v(L);else{const B=l[C]||i;l[C]={provider:L.provider||B.provider,minimalSeverity:L.minimalSeverity||B.minimalSeverity,logDateTime:L.logDateTime===void 0?B.logDateTime:L.logDateTime,logSourceLocation:L.logSourceLocation===void 0?B.logSourceLocation:L.logSourceLocation}}}m.set=A;function P(C){const L={};C.logLevel&&(L.minimalSeverity=C.logLevel),A("",L)}m.setWithEnv=P})(a||(a={})),n.Logger=a;class c{constructor(_,S,E,$,y,v){this.category=_,this.name=S,this.startTime=E,this.endCallback=$,this.timer=y,this.ctx=v}end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}}class f{constructor(_,S,E,$){this.category=_,this.name=S,this.startTime=E,this.endTime=$}}class d{constructor(_,S,E){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=_===void 0?1e4:_,this._flushBatchSize=S===void 0?10:S,this._flushIntervalInMilliseconds=E===void 0?5e3:E}static create(_){return _===void 0?new this:new this(_.maxNumberEvents,_.flushBatchSize,_.flushIntervalInMilliseconds)}start(){this._started=!0,this._timingEvents=[],this._flushTime=n.now(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(_,S,E,$){const y=this._started?this.begin(_,S,$):void 0;let v=!1;const A=E();if(A&&typeof A.then=="function")return v=!0,new Promise((P,C)=>{A.then(async L=>{y&&await y.end(),P(L)},async L=>{y&&await y.end(),C(L)})});if(!v&&y){const P=y.end();if(P&&typeof P.then=="function")return new Promise((C,L)=>{P.then(()=>{C(A)},B=>{L(B)})})}return A}begin(_,S,E){if(!this._started)throw new Error("profiler is not started yet");if(E===void 0){const $=n.now();return this.flush($),new c(_,S,$,y=>this.endSync(y))}else{const $=E.beginTimer();return new c(_,S,0,async y=>this.end(y),$,E)}}async end(_){const S=await _.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new f(_.category,_.name,_.startTime,S)),this.flush(S))}endSync(_){const S=n.now();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new f(_.category,_.name,_.startTime,S)),this.flush(S))}logOneEvent(_){n.Logger.verbose(`Profiler.${_.category}`,`${(_.endTime-_.startTime).toFixed(2)}ms on event '${_.name}' at ${_.endTime.toFixed(2)}`)}flush(_){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||_-this._flushTime>=this._flushIntervalInMilliseconds){for(const S=this._flushPointer;this._flushPointer<S+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=n.now()}}get started(){return this._started}}n.Profiler=d,n.now=typeof performance!="undefined"&&performance.now?()=>performance.now():Date.now})(instrument);var sessionHandler$2={},opset={};Object.defineProperty(opset,"__esModule",{value:!0});opset.resolveOperator=void 0;function resolveOperator(n,e,r){for(const t of r){const o=t[0],i=t[1],l=t[2],a=t[3],s=t[4];if(n.opType===o){for(const u of e)if((u.domain===i||u.domain==="ai.onnx"&&i==="")&&matchSelector(u.version,l))return{opImpl:a,opInit:s}}}throw new TypeError(`cannot resolve operator '${n.opType}' with opsets: ${e.map(t=>`${t.domain||"ai.onnx"} v${t.version}`).join(", ")}`)}opset.resolveOperator=resolveOperator;function matchSelector(n,e){if(e.endsWith("+")){const r=Number.parseInt(e.substring(0,e.length-1),10);return!isNaN(r)&&r<=n}else if(e.split("-").length===2){const r=e.split("-"),t=Number.parseInt(r[0],10),o=Number.parseInt(r[1],10);return!isNaN(t)&&!isNaN(o)&&t<=n&&n<=o}else return Number.parseInt(e,10)===n}var inferenceHandler={},tensor={},guid={};guid.__esModule=!0;var Guid=function(){function n(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=n.EMPTY,e&&n.isGuid(e)&&(this.value=e)}return n.isGuid=function(e){var r=e.toString();return e&&(e instanceof n||n.validator.test(r))},n.create=function(){return new n([n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-"))},n.createEmpty=function(){return new n("emptyguid")},n.parse=function(e){return new n(e)},n.raw=function(){return[n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-")},n.gen=function(e){for(var r="",t=0;t<e;t++)r+=((1+Math.random())*65536|0).toString(16).substring(1);return r},n.prototype.equals=function(e){return n.isGuid(e)&&this.value===e.toString()},n.prototype.isEmpty=function(){return this.value===n.EMPTY},n.prototype.toString=function(){return this.value},n.prototype.toJSON=function(){return{value:this.value}},n.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),n.EMPTY="00000000-0000-0000-0000-000000000000",n}();guid.Guid=Guid;var long=Long,wasm$1=null;try{wasm$1=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 Long(n,e,r){this.low=n|0,this.high=e|0,this.unsigned=!!r}Long.prototype.__isLong__;Object.defineProperty(Long.prototype,"__isLong__",{value:!0});function isLong(n){return(n&&n.__isLong__)===!0}Long.isLong=isLong;var INT_CACHE={},UINT_CACHE={};function fromInt(n,e){var r,t,o;return e?(n>>>=0,(o=0<=n&&n<256)&&(t=UINT_CACHE[n],t)?t:(r=fromBits(n,(n|0)<0?-1:0,!0),o&&(UINT_CACHE[n]=r),r)):(n|=0,(o=-128<=n&&n<128)&&(t=INT_CACHE[n],t)?t:(r=fromBits(n,n<0?-1:0,!1),o&&(INT_CACHE[n]=r),r))}Long.fromInt=fromInt;function fromNumber(n,e){if(isNaN(n))return e?UZERO:ZERO;if(e){if(n<0)return UZERO;if(n>=TWO_PWR_64_DBL)return MAX_UNSIGNED_VALUE}else{if(n<=-TWO_PWR_63_DBL)return MIN_VALUE;if(n+1>=TWO_PWR_63_DBL)return MAX_VALUE}return n<0?fromNumber(-n,e).neg():fromBits(n%TWO_PWR_32_DBL|0,n/TWO_PWR_32_DBL|0,e)}Long.fromNumber=fromNumber;function fromBits(n,e,r){return new Long(n,e,r)}Long.fromBits=fromBits;var pow_dbl=Math.pow;function fromString(n,e,r){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return ZERO;if(typeof e=="number"?(r=e,e=!1):e=!!e,r=r||10,r<2||36<r)throw RangeError("radix");var t;if((t=n.indexOf("-"))>0)throw Error("interior hyphen");if(t===0)return fromString(n.substring(1),e,r).neg();for(var o=fromNumber(pow_dbl(r,8)),i=ZERO,l=0;l<n.length;l+=8){var a=Math.min(8,n.length-l),s=parseInt(n.substring(l,l+a),r);if(a<8){var u=fromNumber(pow_dbl(r,a));i=i.mul(u).add(fromNumber(s))}else i=i.mul(o),i=i.add(fromNumber(s))}return i.unsigned=e,i}Long.fromString=fromString;function fromValue(n,e){return typeof n=="number"?fromNumber(n,e):typeof n=="string"?fromString(n,e):fromBits(n.low,n.high,typeof e=="boolean"?e:n.unsigned)}Long.fromValue=fromValue;var TWO_PWR_16_DBL=1<<16,TWO_PWR_24_DBL=1<<24,TWO_PWR_32_DBL=TWO_PWR_16_DBL*TWO_PWR_16_DBL,TWO_PWR_64_DBL=TWO_PWR_32_DBL*TWO_PWR_32_DBL,TWO_PWR_63_DBL=TWO_PWR_64_DBL/2,TWO_PWR_24=fromInt(TWO_PWR_24_DBL),ZERO=fromInt(0);Long.ZERO=ZERO;var UZERO=fromInt(0,!0);Long.UZERO=UZERO;var ONE=fromInt(1);Long.ONE=ONE;var UONE=fromInt(1,!0);Long.UONE=UONE;var NEG_ONE=fromInt(-1);Long.NEG_ONE=NEG_ONE;var MAX_VALUE=fromBits(-1,2147483647,!1);Long.MAX_VALUE=MAX_VALUE;var MAX_UNSIGNED_VALUE=fromBits(-1,-1,!0);Long.MAX_UNSIGNED_VALUE=MAX_UNSIGNED_VALUE;var MIN_VALUE=fromBits(0,-2147483648,!1);Long.MIN_VALUE=MIN_VALUE;var LongPrototype=Long.prototype;LongPrototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};LongPrototype.toNumber=function(){return this.unsigned?(this.high>>>0)*TWO_PWR_32_DBL+(this.low>>>0):this.high*TWO_PWR_32_DBL+(this.low>>>0)};LongPrototype.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(MIN_VALUE)){var r=fromNumber(e),t=this.div(r),o=t.mul(r).sub(this);return t.toString(e)+o.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=fromNumber(pow_dbl(e,6),this.unsigned),l=this,a="";;){var s=l.div(i),u=l.sub(s.mul(i)).toInt()>>>0,c=u.toString(e);if(l=s,l.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};LongPrototype.getHighBits=function(){return this.high};LongPrototype.getHighBitsUnsigned=function(){return this.high>>>0};LongPrototype.getLowBits=function(){return this.low};LongPrototype.getLowBitsUnsigned=function(){return this.low>>>0};LongPrototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(MIN_VALUE)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&(e&1<<r)==0;r--);return this.high!=0?r+33:r+1};LongPrototype.isZero=function(){return this.high===0&&this.low===0};LongPrototype.eqz=LongPrototype.isZero;LongPrototype.isNegative=function(){return!this.unsigned&&this.high<0};LongPrototype.isPositive=function(){return this.unsigned||this.high>=0};LongPrototype.isOdd=function(){return(this.low&1)===1};LongPrototype.isEven=function(){return(this.low&1)===0};LongPrototype.equals=function(e){return isLong(e)||(e=fromValue(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};LongPrototype.eq=LongPrototype.equals;LongPrototype.notEquals=function(e){return!this.eq(e)};LongPrototype.neq=LongPrototype.notEquals;LongPrototype.ne=LongPrototype.notEquals;LongPrototype.lessThan=function(e){return this.comp(e)<0};LongPrototype.lt=LongPrototype.lessThan;LongPrototype.lessThanOrEqual=function(e){return this.comp(e)<=0};LongPrototype.lte=LongPrototype.lessThanOrEqual;LongPrototype.le=LongPrototype.lessThanOrEqual;LongPrototype.greaterThan=function(e){return this.comp(e)>0};LongPrototype.gt=LongPrototype.greaterThan;LongPrototype.greaterThanOrEqual=function(e){return this.comp(e)>=0};LongPrototype.gte=LongPrototype.greaterThanOrEqual;LongPrototype.ge=LongPrototype.greaterThanOrEqual;LongPrototype.compare=function(e){if(isLong(e)||(e=fromValue(e)),this.eq(e))return 0;var r=this.isNegative(),t=e.isNegative();return r&&!t?-1:!r&&t?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};LongPrototype.comp=LongPrototype.compare;LongPrototype.negate=function(){return!this.unsigned&&this.eq(MIN_VALUE)?MIN_VALUE:this.not().add(ONE)};LongPrototype.neg=LongPrototype.negate;LongPrototype.add=function(e){isLong(e)||(e=fromValue(e));var r=this.high>>>16,t=this.high&65535,o=this.low>>>16,i=this.low&65535,l=e.high>>>16,a=e.high&65535,s=e.low>>>16,u=e.low&65535,c=0,f=0,d=0,m=0;return m+=i+u,d+=m>>>16,m&=65535,d+=o+s,f+=d>>>16,d&=65535,f+=t+a,c+=f>>>16,f&=65535,c+=r+l,c&=65535,fromBits(d<<16|m,c<<16|f,this.unsigned)};LongPrototype.subtract=function(e){return isLong(e)||(e=fromValue(e)),this.add(e.neg())};LongPrototype.sub=LongPrototype.subtract;LongPrototype.multiply=function(e){if(this.isZero())return ZERO;if(isLong(e)||(e=fromValue(e)),wasm$1){var r=wasm$1.mul(this.low,this.high,e.low,e.high);return fromBits(r,wasm$1.get_high(),this.unsigned)}if(e.isZero())return ZERO;if(this.eq(MIN_VALUE))return e.isOdd()?MIN_VALUE:ZERO;if(e.eq(MIN_VALUE))return this.isOdd()?MIN_VALUE:ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(TWO_PWR_24)&&e.lt(TWO_PWR_24))return fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,o=this.high&65535,i=this.low>>>16,l=this.low&65535,a=e.high>>>16,s=e.high&65535,u=e.low>>>16,c=e.low&65535,f=0,d=0,m=0,_=0;return _+=l*c,m+=_>>>16,_&=65535,m+=i*c,d+=m>>>16,m&=65535,m+=l*u,d+=m>>>16,m&=65535,d+=o*c,f+=d>>>16,d&=65535,d+=i*u,f+=d>>>16,d&=65535,d+=l*s,f+=d>>>16,d&=65535,f+=t*c+o*u+i*s+l*a,f&=65535,fromBits(m<<16|_,f<<16|d,this.unsigned)};LongPrototype.mul=LongPrototype.multiply;LongPrototype.divide=function(e){if(isLong(e)||(e=fromValue(e)),e.isZero())throw Error("division by zero");if(wasm$1){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?wasm$1.div_u:wasm$1.div_s)(this.low,this.high,e.low,e.high);return fromBits(r,wasm$1.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?UZERO:ZERO;var t,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return UZERO;if(e.gt(this.shru(1)))return UONE;i=UZERO}else{if(this.eq(MIN_VALUE)){if(e.eq(ONE)||e.eq(NEG_ONE))return MIN_VALUE;if(e.eq(MIN_VALUE))return ONE;var l=this.shr(1);return t=l.div(e).shl(1),t.eq(ZERO)?e.isNegative()?ONE:NEG_ONE:(o=this.sub(e.mul(t)),i=t.add(o.div(e)),i)}else if(e.eq(MIN_VALUE))return this.unsigned?UZERO:ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=ZERO}for(o=this;o.gte(e);){t=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),s=a<=48?1:pow_dbl(2,a-48),u=fromNumber(t),c=u.mul(e);c.isNegative()||c.gt(o);)t-=s,u=fromNumber(t,this.unsigned),c=u.mul(e);u.isZero()&&(u=ONE),i=i.add(u),o=o.sub(c)}return i};LongPrototype.div=LongPrototype.divide;LongPrototype.modulo=function(e){if(isLong(e)||(e=fromValue(e)),wasm$1){var r=(this.unsigned?wasm$1.rem_u:wasm$1.rem_s)(this.low,this.high,e.low,e.high);return fromBits(r,wasm$1.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};LongPrototype.mod=LongPrototype.modulo;LongPrototype.rem=LongPrototype.modulo;LongPrototype.not=function(){return fromBits(~this.low,~this.high,this.unsigned)};LongPrototype.and=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low&e.low,this.high&e.high,this.unsigned)};LongPrototype.or=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low|e.low,this.high|e.high,this.unsigned)};LongPrototype.xor=function(e){return isLong(e)||(e=fromValue(e)),fromBits(this.low^e.low,this.high^e.high,this.unsigned)};LongPrototype.shiftLeft=function(e){return isLong(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):fromBits(0,this.low<<e-32,this.unsigned)};LongPrototype.shl=LongPrototype.shiftLeft;LongPrototype.shiftRight=function(e){return isLong(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};LongPrototype.shr=LongPrototype.shiftRight;LongPrototype.shiftRightUnsigned=function(e){if(isLong(e)&&(e=e.toInt()),e&=63,e===0)return this;var r=this.high;if(e<32){var t=this.low;return fromBits(t>>>e|r<<32-e,r>>>e,this.unsigned)}else return e===32?fromBits(r,0,this.unsigned):fromBits(r>>>e-32,0,this.unsigned)};LongPrototype.shru=LongPrototype.shiftRightUnsigned;LongPrototype.shr_u=LongPrototype.shiftRightUnsigned;LongPrototype.toSigned=function(){return this.unsigned?fromBits(this.low,this.high,!1):this};LongPrototype.toUnsigned=function(){return this.unsigned?this:fromBits(this.low,this.high,!0)};LongPrototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};LongPrototype.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};LongPrototype.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Long.fromBytes=function(e,r,t){return t?Long.fromBytesLE(e,r):Long.fromBytesBE(e,r)};Long.fromBytesLE=function(e,r){return new Long(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Long.fromBytesBE=function(e,r){return new Long(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var indexMinimal={},minimal$1={},aspromise=asPromise;function asPromise(n,e){for(var r=new Array(arguments.length-1),t=0,o=2,i=!0;o<arguments.length;)r[t++]=arguments[o++];return new Promise(function(a,s){r[t]=function(c){if(i)if(i=!1,c)s(c);else{for(var f=new Array(arguments.length-1),d=0;d<f.length;)f[d++]=arguments[d];a.apply(null,f)}};try{n.apply(e||null,r)}catch(u){i&&(i=!1,s(u))}})}var base64$1={};(function(n){var e=n;e.length=function(a){var s=a.length;if(!s)return 0;for(var u=0;--s%4>1&&a.charAt(s)==="=";)++u;return Math.ceil(a.length*3)/4-u};for(var r=new Array(64),t=new Array(123),o=0;o<64;)t[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;e.encode=function(a,s,u){for(var c=null,f=[],d=0,m=0,_;s<u;){var S=a[s++];switch(m){case 0:f[d++]=r[S>>2],_=(S&3)<<4,m=1;break;case 1:f[d++]=r[_|S>>4],_=(S&15)<<2,m=2;break;case 2:f[d++]=r[_|S>>6],f[d++]=r[S&63],m=0;break}d>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,f)),d=0)}return m&&(f[d++]=r[_],f[d++]=61,m===1&&(f[d++]=61)),c?(d&&c.push(String.fromCharCode.apply(String,f.slice(0,d))),c.join("")):String.fromCharCode.apply(String,f.slice(0,d))};var i="invalid encoding";e.decode=function(a,s,u){for(var c=u,f=0,d,m=0;m<a.length;){var _=a.charCodeAt(m++);if(_===61&&f>1)break;if((_=t[_])===void 0)throw Error(i);switch(f){case 0:d=_,f=1;break;case 1:s[u++]=d<<2|(_&48)>>4,d=_,f=2;break;case 2:s[u++]=(d&15)<<4|(_&60)>>2,d=_,f=3;break;case 3:s[u++]=(d&3)<<6|_,f=0;break}}if(f===1)throw Error(i);return u-c},e.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(e,r,t){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:r,ctx:t||this}),this};EventEmitter.prototype.off=function(e,r){if(e===void 0)this._listeners={};else if(r===void 0)this._listeners[e]=[];else for(var t=this._listeners[e],o=0;o<t.length;)t[o].fn===r?t.splice(o,1):++o;return this};EventEmitter.prototype.emit=function(e){var r=this._listeners[e];if(r){for(var t=[],o=1;o<arguments.length;)t.push(arguments[o++]);for(o=0;o<r.length;)r[o].fn.apply(r[o++].ctx,t)}return this};var float=factory(factory);function factory(n){return typeof Float32Array!="undefined"?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),t=r[3]===128;function o(s,u,c){e[0]=s,u[c]=r[0],u[c+1]=r[1],u[c+2]=r[2],u[c+3]=r[3]}function i(s,u,c){e[0]=s,u[c]=r[3],u[c+1]=r[2],u[c+2]=r[1],u[c+3]=r[0]}n.writeFloatLE=t?o:i,n.writeFloatBE=t?i:o;function l(s,u){return r[0]=s[u],r[1]=s[u+1],r[2]=s[u+2],r[3]=s[u+3],e[0]}function a(s,u){return r[3]=s[u],r[2]=s[u+1],r[1]=s[u+2],r[0]=s[u+3],e[0]}n.readFloatLE=t?l:a,n.readFloatBE=t?a:l}():function(){function e(t,o,i,l){var a=o<0?1:0;if(a&&(o=-o),o===0)t(1/o>0?0:2147483648,i,l);else if(isNaN(o))t(2143289344,i,l);else if(o>34028234663852886e22)t((a<<31|2139095040)>>>0,i,l);else if(o<11754943508222875e-54)t((a<<31|Math.round(o/1401298464324817e-60))>>>0,i,l);else{var s=Math.floor(Math.log(o)/Math.LN2),u=Math.round(o*Math.pow(2,-s)*8388608)&8388607;t((a<<31|s+127<<23|u)>>>0,i,l)}}n.writeFloatLE=e.bind(null,writeUintLE),n.writeFloatBE=e.bind(null,writeUintBE);function r(t,o,i){var l=t(o,i),a=(l>>31)*2+1,s=l>>>23&255,u=l&8388607;return s===255?u?NaN:a*(1/0):s===0?a*1401298464324817e-60*u:a*Math.pow(2,s-150)*(u+8388608)}n.readFloatLE=r.bind(null,readUintLE),n.readFloatBE=r.bind(null,readUintBE)}(),typeof Float64Array!="undefined"?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),t=r[7]===128;function o(s,u,c){e[0]=s,u[c]=r[0],u[c+1]=r[1],u[c+2]=r[2],u[c+3]=r[3],u[c+4]=r[4],u[c+5]=r[5],u[c+6]=r[6],u[c+7]=r[7]}function i(s,u,c){e[0]=s,u[c]=r[7],u[c+1]=r[6],u[c+2]=r[5],u[c+3]=r[4],u[c+4]=r[3],u[c+5]=r[2],u[c+6]=r[1],u[c+7]=r[0]}n.writeDoubleLE=t?o:i,n.writeDoubleBE=t?i:o;function l(s,u){return r[0]=s[u],r[1]=s[u+1],r[2]=s[u+2],r[3]=s[u+3],r[4]=s[u+4],r[5]=s[u+5],r[6]=s[u+6],r[7]=s[u+7],e[0]}function a(s,u){return r[7]=s[u],r[6]=s[u+1],r[5]=s[u+2],r[4]=s[u+3],r[3]=s[u+4],r[2]=s[u+5],r[1]=s[u+6],r[0]=s[u+7],e[0]}n.readDoubleLE=t?l:a,n.readDoubleBE=t?a:l}():function(){function e(t,o,i,l,a,s){var u=l<0?1:0;if(u&&(l=-l),l===0)t(0,a,s+o),t(1/l>0?0:2147483648,a,s+i);else if(isNaN(l))t(0,a,s+o),t(2146959360,a,s+i);else if(l>17976931348623157e292)t(0,a,s+o),t((u<<31|2146435072)>>>0,a,s+i);else{var c;if(l<22250738585072014e-324)c=l/5e-324,t(c>>>0,a,s+o),t((u<<31|c/4294967296)>>>0,a,s+i);else{var f=Math.floor(Math.log(l)/Math.LN2);f===1024&&(f=1023),c=l*Math.pow(2,-f),t(c*4503599627370496>>>0,a,s+o),t((u<<31|f+1023<<20|c*1048576&1048575)>>>0,a,s+i)}}}n.writeDoubleLE=e.bind(null,writeUintLE,0,4),n.writeDoubleBE=e.bind(null,writeUintBE,4,0);function r(t,o,i,l,a){var s=t(l,a+o),u=t(l,a+i),c=(u>>31)*2+1,f=u>>>20&2047,d=4294967296*(u&1048575)+s;return f===2047?d?NaN:c*(1/0):f===0?c*5e-324*d:c*Math.pow(2,f-1075)*(d+4503599627370496)}n.readDoubleLE=r.bind(null,readUintLE,0,4),n.readDoubleBE=r.bind(null,readUintBE,4,0)}(),n}function writeUintLE(n,e,r){e[r]=n&255,e[r+1]=n>>>8&255,e[r+2]=n>>>16&255,e[r+3]=n>>>24}function writeUintBE(n,e,r){e[r]=n>>>24,e[r+1]=n>>>16&255,e[r+2]=n>>>8&255,e[r+3]=n&255}function readUintLE(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0}function readUintBE(n,e){return(n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(n){}return null}var utf8$2={};(function(n){var e=n;e.length=function(t){for(var o=0,i=0,l=0;l<t.length;++l)i=t.charCodeAt(l),i<128?o+=1:i<2048?o+=2:(i&64512)===55296&&(t.charCodeAt(l+1)&64512)===56320?(++l,o+=4):o+=3;return o},e.read=function(t,o,i){var l=i-o;if(l<1)return"";for(var a=null,s=[],u=0,c;o<i;)c=t[o++],c<128?s[u++]=c:c>191&&c<224?s[u++]=(c&31)<<6|t[o++]&63:c>239&&c<365?(c=((c&7)<<18|(t[o++]&63)<<12|(t[o++]&63)<<6|t[o++]&63)-65536,s[u++]=55296+(c>>10),s[u++]=56320+(c&1023)):s[u++]=(c&15)<<12|(t[o++]&63)<<6|t[o++]&63,u>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,s)),u=0);return a?(u&&a.push(String.fromCharCode.apply(String,s.slice(0,u))),a.join("")):String.fromCharCode.apply(String,s.slice(0,u))},e.write=function(t,o,i){for(var l=i,a,s,u=0;u<t.length;++u)a=t.charCodeAt(u),a<128?o[i++]=a:a<2048?(o[i++]=a>>6|192,o[i++]=a&63|128):(a&64512)===55296&&((s=t.charCodeAt(u+1))&64512)===56320?(a=65536+((a&1023)<<10)+(s&1023),++u,o[i++]=a>>18|240,o[i++]=a>>12&63|128,o[i++]=a>>6&63|128,o[i++]=a&63|128):(o[i++]=a>>12|224,o[i++]=a>>6&63|128,o[i++]=a&63|128);return i-l}})(utf8$2);var pool_1$1=pool$1;function pool$1(n,e,r){var t=r||8192,o=t>>>1,i=null,l=t;return function(s){if(s<1||s>o)return n(s);l+s>t&&(i=n(t),l=0);var u=e.call(i,l,l+=s);return l&7&&(l=(l|7)+1),u}}var longbits=LongBits$2,util$6=minimal$1;function LongBits$2(n,e){this.lo=n>>>0,this.hi=e>>>0}var zero=LongBits$2.zero=new LongBits$2(0,0);zero.toNumber=function(){return 0};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};var zeroHash=LongBits$2.zeroHash="\0\0\0\0\0\0\0\0";LongBits$2.fromNumber=function n(e){if(e===0)return zero;var r=e<0;r&&(e=-e);var t=e>>>0,o=(e-t)/4294967296>>>0;return r&&(o=~o>>>0,t=~t>>>0,++t>4294967295&&(t=0,++o>4294967295&&(o=0))),new LongBits$2(t,o)};LongBits$2.from=function n(e){if(typeof e=="number")return LongBits$2.fromNumber(e);if(util$6.isString(e))if(util$6.Long)e=util$6.Long.fromString(e);else return LongBits$2.fromNumber(parseInt(e,10));return e.low||e.high?new LongBits$2(e.low>>>0,e.high>>>0):zero};LongBits$2.prototype.toNumber=function n(e){if(!e&&this.hi>>>31){var r=~this.lo+1>>>0,t=~this.hi>>>0;return r||(t=t+1>>>0),-(r+t*4294967296)}return this.lo+this.hi*4294967296};LongBits$2.prototype.toLong=function n(e){return util$6.Long?new util$6.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var charCodeAt=String.prototype.charCodeAt;LongBits$2.fromHash=function n(e){return e===zeroHash?zero:new LongBits$2((charCodeAt.call(e,0)|charCodeAt.call(e,1)<<8|charCodeAt.call(e,2)<<16|charCodeAt.call(e,3)<<24)>>>0,(charCodeAt.call(e,4)|charCodeAt.call(e,5)<<8|charCodeAt.call(e,6)<<16|charCodeAt.call(e,7)<<24)>>>0)};LongBits$2.prototype.toHash=function n(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};LongBits$2.prototype.zzEncode=function n(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};LongBits$2.prototype.zzDecode=function n(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};LongBits$2.prototype.length=function n(){var e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:t<128?9:10};(function(n){var e=n;e.asPromise=aspromise,e.base64=base64$1,e.EventEmitter=eventemitter,e.float=float,e.inquire=inquire_1,e.utf8=utf8$2,e.pool=pool_1$1,e.LongBits=longbits,e.isNode=Boolean(typeof commonjsGlobal$1!="undefined"&&commonjsGlobal$1&&commonjsGlobal$1.process&&commonjsGlobal$1.process.versions&&commonjsGlobal$1.process.versions.node),e.global=e.isNode&&commonjsGlobal$1||typeof window!="undefined"&&window||typeof self!="undefined"&&self||commonjsGlobal$1,e.emptyArray=Object.freeze?Object.freeze([]):[],e.emptyObject=Object.freeze?Object.freeze({}):{},e.isInteger=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i},e.isString=function(i){return typeof i=="string"||i instanceof String},e.isObject=function(i){return i&&typeof i=="object"},e.isset=e.isSet=function(i,l){var a=i[l];return a!=null&&i.hasOwnProperty(l)?typeof a!="object"||(Array.isArray(a)?a.length:Object.keys(a).length)>0:!1},e.Buffer=function(){try{var o=e.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),e._Buffer_from=null,e._Buffer_allocUnsafe=null,e.newBuffer=function(i){return typeof i=="number"?e.Buffer?e._Buffer_allocUnsafe(i):new e.Array(i):e.Buffer?e._Buffer_from(i):typeof Uint8Array=="undefined"?i:new Uint8Array(i)},e.Array=typeof Uint8Array!="undefined"?Uint8Array:Array,e.Long=e.global.dcodeIO&&e.global.dcodeIO.Long||e.global.Long||e.inquire("long"),e.key2Re=/^true|false|0|1$/,e.key32Re=/^-?(?:0|[1-9][0-9]*)$/,e.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,e.longToHash=function(i){return i?e.LongBits.from(i).toHash():e.LongBits.zeroHash},e.longFromHash=function(i,l){var a=e.LongBits.fromHash(i);return e.Long?e.Long.fromBits(a.lo,a.hi,l):a.toNumber(Boolean(l))};function r(o,i,l){for(var a=Object.keys(i),s=0;s<a.length;++s)(o[a[s]]===void 0||!l)&&(o[a[s]]=i[a[s]]);return o}e.merge=r,e.lcFirst=function(i){return i.charAt(0).toLowerCase()+i.substring(1)};function t(o){function i(l,a){if(!(this instanceof i))return new i(l,a);Object.defineProperty(this,"message",{get:function(){return l}}),Error.captureStackTrace?Error.captureStackTrace(this,i):Object.defineProperty(this,"stack",{value:new Error().stack||""}),a&&r(this,a)}return(i.prototype=Object.create(Error.prototype)).constructor=i,Object.defineProperty(i.prototype,"name",{get:function(){return o}}),i.prototype.toString=function(){return this.name+": "+this.message},i}e.newError=t,e.ProtocolError=t("ProtocolError"),e.oneOfGetter=function(i){for(var l={},a=0;a<i.length;++a)l[i[a]]=1;return function(){for(var s=Object.keys(this),u=s.length-1;u>-1;--u)if(l[s[u]]===1&&this[s[u]]!==void 0&&this[s[u]]!==null)return s[u]}},e.oneOfSetter=function(i){return function(l){for(var a=0;a<i.length;++a)i[a]!==l&&delete this[i[a]]}},e.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},e._configure=function(){var o=e.Buffer;if(!o){e._Buffer_from=e._Buffer_allocUnsafe=null;return}e._Buffer_from=o.from!==Uint8Array.from&&o.from||function(l,a){return new o(l,a)},e._Buffer_allocUnsafe=o.allocUnsafe||function(l){return new o(l)}}})(minimal$1);var writer=Writer$1,util$5=minimal$1,BufferWriter$1,LongBits$1=util$5.LongBits,base64=util$5.base64,utf8$1=util$5.utf8;function Op(n,e,r){this.fn=n,this.len=e,this.next=void 0,this.val=r}function noop(){}function State(n){this.head=n.head,this.tail=n.tail,this.len=n.len,this.next=n.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function n(){return util$5.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function n(e){return new util$5.Array(e)};util$5.Array!==Array&&(Writer$1.alloc=util$5.pool(Writer$1.alloc,util$5.Array.prototype.subarray));Writer$1.prototype._push=function n(e,r,t){return this.tail=this.tail.next=new Op(e,r,t),this.len+=r,this};function writeByte(n,e,r){e[r]=n&255}function writeVarint32(n,e,r){for(;n>127;)e[r++]=n&127|128,n>>>=7;e[r]=n}function VarintOp(n,e){this.len=n,this.next=void 0,this.val=e}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function n(e){return this.len+=(this.tail=this.tail.next=new VarintOp((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Writer$1.prototype.int32=function n(e){return e<0?this._push(writeVarint64,10,LongBits$1.fromNumber(e)):this.uint32(e)};Writer$1.prototype.sint32=function n(e){return this.uint32((e<<1^e>>31)>>>0)};function writeVarint64(n,e,r){for(;n.hi;)e[r++]=n.lo&127|128,n.lo=(n.lo>>>7|n.hi<<25)>>>0,n.hi>>>=7;for(;n.lo>127;)e[r++]=n.lo&127|128,n.lo=n.lo>>>7;e[r++]=n.lo}Writer$1.prototype.uint64=function n(e){var r=LongBits$1.from(e);return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function n(e){var r=LongBits$1.from(e).zzEncode();return this._push(writeVarint64,r.length(),r)};Writer$1.prototype.bool=function n(e){return this._push(writeByte,1,e?1:0)};function writeFixed32(n,e,r){e[r]=n&255,e[r+1]=n>>>8&255,e[r+2]=n>>>16&255,e[r+3]=n>>>24}Writer$1.prototype.fixed32=function n(e){return this._push(writeFixed32,4,e>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function n(e){var r=LongBits$1.from(e);return this._push(writeFixed32,4,r.lo)._push(writeFixed32,4,r.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function n(e){return this._push(util$5.float.writeFloatLE,4,e)};Writer$1.prototype.double=function n(e){return this._push(util$5.float.writeDoubleLE,8,e)};var writeBytes=util$5.Array.prototype.set?function n(e,r,t){r.set(e,t)}:function n(e,r,t){for(var o=0;o<e.length;++o)r[t+o]=e[o]};Writer$1.prototype.bytes=function n(e){var r=e.length>>>0;if(!r)return this._push(writeByte,1,0);if(util$5.isString(e)){var t=Writer$1.alloc(r=base64.length(e));base64.decode(e,t,0),e=t}return this.uint32(r)._push(writeBytes,r,e)};Writer$1.prototype.string=function n(e){var r=utf8$1.length(e);return r?this.uint32(r)._push(utf8$1.write,r,e):this._push(writeByte,1,0)};Writer$1.prototype.fork=function n(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function n(){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 Op(noop,0,0),this.len=0),this};Writer$1.prototype.ldelim=function n(){var e=this.head,r=this.tail,t=this.len;return this.reset().uint32(t),t&&(this.tail.next=e.next,this.tail=r,this.len+=t),this};Writer$1.prototype.finish=function n(){for(var e=this.head.next,r=this.constructor.alloc(this.len),t=0;e;)e.fn(e.val,r,t),t+=e.len,e=e.next;return r};Writer$1._configure=function(n){BufferWriter$1=n,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$4=minimal$1;function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$4._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$4.Buffer&&util$4.Buffer.prototype instanceof Uint8Array&&util$4.Buffer.prototype.set.name==="set"?function(e,r,t){r.set(e,t)}:function(e,r,t){if(e.copy)e.copy(r,t,0,e.length);else for(var o=0;o<e.length;)r[t++]=e[o++]}};BufferWriter.prototype.bytes=function n(e){util$4.isString(e)&&(e=util$4._Buffer_from(e,"base64"));var r=e.length>>>0;return this.uint32(r),r&&this._push(BufferWriter.writeBytesBuffer,r,e),this};function writeStringBuffer(n,e,r){n.length<40?util$4.utf8.write(n,e,r):e.utf8Write?e.utf8Write(n,r):e.write(n,r)}BufferWriter.prototype.string=function n(e){var r=util$4.Buffer.byteLength(e);return this.uint32(r),r&&this._push(writeStringBuffer,r,e),this};BufferWriter._configure();var reader=Reader$1,util$3=minimal$1,BufferReader$1,LongBits=util$3.LongBits,utf8=util$3.utf8;function indexOutOfRange(n,e){return RangeError("index out of range: "+n.pos+" + "+(e||1)+" > "+n.len)}function Reader$1(n){this.buf=n,this.pos=0,this.len=n.length}var create_array=typeof Uint8Array!="undefined"?function n(e){if(e instanceof Uint8Array||Array.isArray(e))return new Reader$1(e);throw Error("illegal buffer")}:function n(e){if(Array.isArray(e))return new Reader$1(e);throw Error("illegal buffer")},create=function n(){return util$3.Buffer?function(r){return(Reader$1.create=function(o){return util$3.Buffer.isBuffer(o)?new BufferReader$1(o):create_array(o)})(r)}:create_array};Reader$1.create=create();Reader$1.prototype._slice=util$3.Array.prototype.subarray||util$3.Array.prototype.slice;Reader$1.prototype.uint32=function n(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return e}}();Reader$1.prototype.int32=function n(){return this.uint32()|0};Reader$1.prototype.sint32=function n(){var e=this.uint32();return e>>>1^-(e&1)|0};function readLongVarint(){var n=new LongBits(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(n.lo=(n.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return n;if(n.lo=(n.lo|(this.buf[this.pos]&127)<<28)>>>0,n.hi=(n.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return n;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw indexOutOfRange(this);if(n.lo=(n.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return n}return n.lo=(n.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,n}if(this.len-this.pos>4){for(;e<5;++e)if(n.hi=(n.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return n}else for(;e<5;++e){if(this.pos>=this.len)throw indexOutOfRange(this);if(n.hi=(n.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return n}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function n(){return this.uint32()!==0};function readFixed32_end(n,e){return(n[e-4]|n[e-3]<<8|n[e-2]<<16|n[e-1]<<24)>>>0}Reader$1.prototype.fixed32=function n(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function n(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function n(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var e=util$3.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};Reader$1.prototype.double=function n(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var e=util$3.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};Reader$1.prototype.bytes=function n(){var e=this.uint32(),r=this.pos,t=this.pos+e;if(t>this.len)throw indexOutOfRange(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(r,t):r===t?new this.buf.constructor(0):this._slice.call(this.buf,r,t)};Reader$1.prototype.string=function n(){var e=this.bytes();return utf8.read(e,0,e.length)};Reader$1.prototype.skip=function n(e){if(typeof e=="number"){if(this.pos+e>this.len)throw indexOutOfRange(this,e);this.pos+=e}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(n){switch(n){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(n=this.uint32()&7)!==4;)this.skipType(n);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+n+" at offset "+this.pos)}return this};Reader$1._configure=function(n){BufferReader$1=n,Reader$1.create=create(),BufferReader$1._configure();var e=util$3.Long?"toLong":"toNumber";util$3.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[e](!1)},uint64:function(){return readLongVarint.call(this)[e](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[e](!1)},fixed64:function(){return readFixed64.call(this)[e](!0)},sfixed64:function(){return readFixed64.call(this)[e](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$2=minimal$1;function BufferReader(n){Reader.call(this,n)}BufferReader._configure=function(){util$2.Buffer&&(BufferReader.prototype._slice=util$2.Buffer.prototype.slice)};BufferReader.prototype.string=function n(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))};BufferReader._configure();var rpc={},service=Service,util$1=minimal$1;(Service.prototype=Object.create(util$1.EventEmitter.prototype)).constructor=Service;function Service(n,e,r){if(typeof n!="function")throw TypeError("rpcImpl must be a function");util$1.EventEmitter.call(this),this.rpcImpl=n,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}Service.prototype.rpcCall=function n(e,r,t,o,i){if(!o)throw TypeError("request must be specified");var l=this;if(!i)return util$1.asPromise(n,l,e,r,t,o);if(!l.rpcImpl){setTimeout(function(){i(Error("already ended"))},0);return}try{return l.rpcImpl(e,r[l.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(s,u){if(s)return l.emit("error",s,e),i(s);if(u===null){l.end(!0);return}if(!(u instanceof t))try{u=t[l.responseDelimited?"decodeDelimited":"decode"](u)}catch(c){return l.emit("error",c,e),i(c)}return l.emit("data",u,e),i(null,u)})}catch(a){l.emit("error",a,e),setTimeout(function(){i(a)},0);return}};Service.prototype.end=function n(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(n){var e=n;e.Service=service})(rpc);var roots={};(function(n){var e=n;e.build="minimal",e.Writer=writer,e.BufferWriter=writer_buffer,e.Reader=reader,e.BufferReader=reader_buffer,e.util=minimal$1,e.rpc=rpc,e.roots=roots,e.configure=r;function r(){e.util._configure(),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}r()})(indexMinimal);var minimal=indexMinimal,$protobuf=minimal,$Reader=$protobuf.Reader,$Writer=$protobuf.Writer,$util=$protobuf.util,$root=$protobuf.roots.default||($protobuf.roots.default={});$root.onnx=function(){var n={};return n.Version=function(){var e={},r=Object.create(e);return r[e[0]="_START_VERSION"]=0,r[e[1]="IR_VERSION_2017_10_10"]=1,r[e[2]="IR_VERSION_2017_10_30"]=2,r[e[3]="IR_VERSION_2017_11_3"]=3,r[e[4]="IR_VERSION_2019_1_22"]=4,r[e[5]="IR_VERSION"]=5,r}(),n.AttributeProto=function(){function e(r){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.name="",e.prototype.refAttrName="",e.prototype.docString="",e.prototype.type=0,e.prototype.f=0,e.prototype.i=$util.Long?$util.Long.fromBits(0,0,!1):0,e.prototype.s=$util.newBuffer([]),e.prototype.t=null,e.prototype.g=null,e.prototype.floats=$util.emptyArray,e.prototype.ints=$util.emptyArray,e.prototype.strings=$util.emptyArray,e.prototype.tensors=$util.emptyArray,e.prototype.graphs=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.name!=null&&t.hasOwnProperty("name")&&o.uint32(10).string(t.name),t.f!=null&&t.hasOwnProperty("f")&&o.uint32(21).float(t.f),t.i!=null&&t.hasOwnProperty("i")&&o.uint32(24).int64(t.i),t.s!=null&&t.hasOwnProperty("s")&&o.uint32(34).bytes(t.s),t.t!=null&&t.hasOwnProperty("t")&&$root.onnx.TensorProto.encode(t.t,o.uint32(42).fork()).ldelim(),t.g!=null&&t.hasOwnProperty("g")&&$root.onnx.GraphProto.encode(t.g,o.uint32(50).fork()).ldelim(),t.floats!=null&&t.floats.length){o.uint32(58).fork();for(var i=0;i<t.floats.length;++i)o.float(t.floats[i]);o.ldelim()}if(t.ints!=null&&t.ints.length){o.uint32(66).fork();for(var i=0;i<t.ints.length;++i)o.int64(t.ints[i]);o.ldelim()}if(t.strings!=null&&t.strings.length)for(var i=0;i<t.strings.length;++i)o.uint32(74).bytes(t.strings[i]);if(t.tensors!=null&&t.tensors.length)for(var i=0;i<t.tensors.length;++i)$root.onnx.TensorProto.encode(t.tensors[i],o.uint32(82).fork()).ldelim();if(t.graphs!=null&&t.graphs.length)for(var i=0;i<t.graphs.length;++i)$root.onnx.GraphProto.encode(t.graphs[i],o.uint32(90).fork()).ldelim();return t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(106).string(t.docString),t.type!=null&&t.hasOwnProperty("type")&&o.uint32(160).int32(t.type),t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&o.uint32(170).string(t.refAttrName),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.AttributeProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.name=t.string();break;case 21:l.refAttrName=t.string();break;case 13:l.docString=t.string();break;case 20:l.type=t.int32();break;case 2:l.f=t.float();break;case 3:l.i=t.int64();break;case 4:l.s=t.bytes();break;case 5:l.t=$root.onnx.TensorProto.decode(t,t.uint32());break;case 6:l.g=$root.onnx.GraphProto.decode(t,t.uint32());break;case 7:if(l.floats&&l.floats.length||(l.floats=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.floats.push(t.float());else l.floats.push(t.float());break;case 8:if(l.ints&&l.ints.length||(l.ints=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.ints.push(t.int64());else l.ints.push(t.int64());break;case 9:l.strings&&l.strings.length||(l.strings=[]),l.strings.push(t.bytes());break;case 10:l.tensors&&l.tensors.length||(l.tensors=[]),l.tensors.push($root.onnx.TensorProto.decode(t,t.uint32()));break;case 11:l.graphs&&l.graphs.length||(l.graphs=[]),l.graphs.push($root.onnx.GraphProto.decode(t,t.uint32()));break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!$util.isString(t.name))return"name: string expected";if(t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&!$util.isString(t.refAttrName))return"refAttrName: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString))return"docString: string expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.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:break}if(t.f!=null&&t.hasOwnProperty("f")&&typeof t.f!="number")return"f: number expected";if(t.i!=null&&t.hasOwnProperty("i")&&!$util.isInteger(t.i)&&!(t.i&&$util.isInteger(t.i.low)&&$util.isInteger(t.i.high)))return"i: integer|Long expected";if(t.s!=null&&t.hasOwnProperty("s")&&!(t.s&&typeof t.s.length=="number"||$util.isString(t.s)))return"s: buffer expected";if(t.t!=null&&t.hasOwnProperty("t")){var o=$root.onnx.TensorProto.verify(t.t);if(o)return"t."+o}if(t.g!=null&&t.hasOwnProperty("g")){var o=$root.onnx.GraphProto.verify(t.g);if(o)return"g."+o}if(t.floats!=null&&t.hasOwnProperty("floats")){if(!Array.isArray(t.floats))return"floats: array expected";for(var i=0;i<t.floats.length;++i)if(typeof t.floats[i]!="number")return"floats: number[] expected"}if(t.ints!=null&&t.hasOwnProperty("ints")){if(!Array.isArray(t.ints))return"ints: array expected";for(var i=0;i<t.ints.length;++i)if(!$util.isInteger(t.ints[i])&&!(t.ints[i]&&$util.isInteger(t.ints[i].low)&&$util.isInteger(t.ints[i].high)))return"ints: integer|Long[] expected"}if(t.strings!=null&&t.hasOwnProperty("strings")){if(!Array.isArray(t.strings))return"strings: array expected";for(var i=0;i<t.strings.length;++i)if(!(t.strings[i]&&typeof t.strings[i].length=="number"||$util.isString(t.strings[i])))return"strings: buffer[] expected"}if(t.tensors!=null&&t.hasOwnProperty("tensors")){if(!Array.isArray(t.tensors))return"tensors: array expected";for(var i=0;i<t.tensors.length;++i){var o=$root.onnx.TensorProto.verify(t.tensors[i]);if(o)return"tensors."+o}}if(t.graphs!=null&&t.hasOwnProperty("graphs")){if(!Array.isArray(t.graphs))return"graphs: array expected";for(var i=0;i<t.graphs.length;++i){var o=$root.onnx.GraphProto.verify(t.graphs[i]);if(o)return"graphs."+o}}return null},e.fromObject=function(t){if(t instanceof $root.onnx.AttributeProto)return t;var o=new $root.onnx.AttributeProto;switch(t.name!=null&&(o.name=String(t.name)),t.refAttrName!=null&&(o.refAttrName=String(t.refAttrName)),t.docString!=null&&(o.docString=String(t.docString)),t.type){case"UNDEFINED":case 0:o.type=0;break;case"FLOAT":case 1:o.type=1;break;case"INT":case 2:o.type=2;break;case"STRING":case 3:o.type=3;break;case"TENSOR":case 4:o.type=4;break;case"GRAPH":case 5:o.type=5;break;case"FLOATS":case 6:o.type=6;break;case"INTS":case 7:o.type=7;break;case"STRINGS":case 8:o.type=8;break;case"TENSORS":case 9:o.type=9;break;case"GRAPHS":case 10:o.type=10;break}if(t.f!=null&&(o.f=Number(t.f)),t.i!=null&&($util.Long?(o.i=$util.Long.fromValue(t.i)).unsigned=!1:typeof t.i=="string"?o.i=parseInt(t.i,10):typeof t.i=="number"?o.i=t.i:typeof t.i=="object"&&(o.i=new $util.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber())),t.s!=null&&(typeof t.s=="string"?$util.base64.decode(t.s,o.s=$util.newBuffer($util.base64.length(t.s)),0):t.s.length&&(o.s=t.s)),t.t!=null){if(typeof t.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");o.t=$root.onnx.TensorProto.fromObject(t.t)}if(t.g!=null){if(typeof t.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");o.g=$root.onnx.GraphProto.fromObject(t.g)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");o.floats=[];for(var i=0;i<t.floats.length;++i)o.floats[i]=Number(t.floats[i])}if(t.ints){if(!Array.isArray(t.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");o.ints=[];for(var i=0;i<t.ints.length;++i)$util.Long?(o.ints[i]=$util.Long.fromValue(t.ints[i])).unsigned=!1:typeof t.ints[i]=="string"?o.ints[i]=parseInt(t.ints[i],10):typeof t.ints[i]=="number"?o.ints[i]=t.ints[i]:typeof t.ints[i]=="object"&&(o.ints[i]=new $util.LongBits(t.ints[i].low>>>0,t.ints[i].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");o.strings=[];for(var i=0;i<t.strings.length;++i)typeof t.strings[i]=="string"?$util.base64.decode(t.strings[i],o.strings[i]=$util.newBuffer($util.base64.length(t.strings[i])),0):t.strings[i].length&&(o.strings[i]=t.strings[i])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");o.tensors=[];for(var i=0;i<t.tensors.length;++i){if(typeof t.tensors[i]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");o.tensors[i]=$root.onnx.TensorProto.fromObject(t.tensors[i])}}if(t.graphs){if(!Array.isArray(t.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");o.graphs=[];for(var i=0;i<t.graphs.length;++i){if(typeof t.graphs[i]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");o.graphs[i]=$root.onnx.GraphProto.fromObject(t.graphs[i])}}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.floats=[],i.ints=[],i.strings=[],i.tensors=[],i.graphs=[]),o.defaults){if(i.name="",i.f=0,$util.Long){var l=new $util.Long(0,0,!1);i.i=o.longs===String?l.toString():o.longs===Number?l.toNumber():l}else i.i=o.longs===String?"0":0;o.bytes===String?i.s="":(i.s=[],o.bytes!==Array&&(i.s=$util.newBuffer(i.s))),i.t=null,i.g=null,i.docString="",i.type=o.enums===String?"UNDEFINED":0,i.refAttrName=""}if(t.name!=null&&t.hasOwnProperty("name")&&(i.name=t.name),t.f!=null&&t.hasOwnProperty("f")&&(i.f=o.json&&!isFinite(t.f)?String(t.f):t.f),t.i!=null&&t.hasOwnProperty("i")&&(typeof t.i=="number"?i.i=o.longs===String?String(t.i):t.i:i.i=o.longs===String?$util.Long.prototype.toString.call(t.i):o.longs===Number?new $util.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber():t.i),t.s!=null&&t.hasOwnProperty("s")&&(i.s=o.bytes===String?$util.base64.encode(t.s,0,t.s.length):o.bytes===Array?Array.prototype.slice.call(t.s):t.s),t.t!=null&&t.hasOwnProperty("t")&&(i.t=$root.onnx.TensorProto.toObject(t.t,o)),t.g!=null&&t.hasOwnProperty("g")&&(i.g=$root.onnx.GraphProto.toObject(t.g,o)),t.floats&&t.floats.length){i.floats=[];for(var a=0;a<t.floats.length;++a)i.floats[a]=o.json&&!isFinite(t.floats[a])?String(t.floats[a]):t.floats[a]}if(t.ints&&t.ints.length){i.ints=[];for(var a=0;a<t.ints.length;++a)typeof t.ints[a]=="number"?i.ints[a]=o.longs===String?String(t.ints[a]):t.ints[a]:i.ints[a]=o.longs===String?$util.Long.prototype.toString.call(t.ints[a]):o.longs===Number?new $util.LongBits(t.ints[a].low>>>0,t.ints[a].high>>>0).toNumber():t.ints[a]}if(t.strings&&t.strings.length){i.strings=[];for(var a=0;a<t.strings.length;++a)i.strings[a]=o.bytes===String?$util.base64.encode(t.strings[a],0,t.strings[a].length):o.bytes===Array?Array.prototype.slice.call(t.strings[a]):t.strings[a]}if(t.tensors&&t.tensors.length){i.tensors=[];for(var a=0;a<t.tensors.length;++a)i.tensors[a]=$root.onnx.TensorProto.toObject(t.tensors[a],o)}if(t.graphs&&t.graphs.length){i.graphs=[];for(var a=0;a<t.graphs.length;++a)i.graphs[a]=$root.onnx.GraphProto.toObject(t.graphs[a],o)}return t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),t.type!=null&&t.hasOwnProperty("type")&&(i.type=o.enums===String?$root.onnx.AttributeProto.AttributeType[t.type]:t.type),t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&(i.refAttrName=t.refAttrName),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e.AttributeType=function(){var r={},t=Object.create(r);return t[r[0]="UNDEFINED"]=0,t[r[1]="FLOAT"]=1,t[r[2]="INT"]=2,t[r[3]="STRING"]=3,t[r[4]="TENSOR"]=4,t[r[5]="GRAPH"]=5,t[r[6]="FLOATS"]=6,t[r[7]="INTS"]=7,t[r[8]="STRINGS"]=8,t[r[9]="TENSORS"]=9,t[r[10]="GRAPHS"]=10,t}(),e}(),n.ValueInfoProto=function(){function e(r){if(r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.name="",e.prototype.type=null,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(t,o){return o||(o=$Writer.create()),t.name!=null&&t.hasOwnProperty("name")&&o.uint32(10).string(t.name),t.type!=null&&t.hasOwnProperty("type")&&$root.onnx.TypeProto.encode(t.type,o.uint32(18).fork()).ldelim(),t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(26).string(t.docString),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.ValueInfoProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.name=t.string();break;case 2:l.type=$root.onnx.TypeProto.decode(t,t.uint32());break;case 3:l.docString=t.string();break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!$util.isString(t.name))return"name: string expected";if(t.type!=null&&t.hasOwnProperty("type")){var o=$root.onnx.TypeProto.verify(t.type);if(o)return"type."+o}return t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString)?"docString: string expected":null},e.fromObject=function(t){if(t instanceof $root.onnx.ValueInfoProto)return t;var o=new $root.onnx.ValueInfoProto;if(t.name!=null&&(o.name=String(t.name)),t.type!=null){if(typeof t.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");o.type=$root.onnx.TypeProto.fromObject(t.type)}return t.docString!=null&&(o.docString=String(t.docString)),o},e.toObject=function(t,o){o||(o={});var i={};return o.defaults&&(i.name="",i.type=null,i.docString=""),t.name!=null&&t.hasOwnProperty("name")&&(i.name=t.name),t.type!=null&&t.hasOwnProperty("type")&&(i.type=$root.onnx.TypeProto.toObject(t.type,o)),t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.NodeProto=function(){function e(r){if(this.input=[],this.output=[],this.attribute=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.input=$util.emptyArray,e.prototype.output=$util.emptyArray,e.prototype.name="",e.prototype.opType="",e.prototype.domain="",e.prototype.attribute=$util.emptyArray,e.prototype.docString="",e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.input!=null&&t.input.length)for(var i=0;i<t.input.length;++i)o.uint32(10).string(t.input[i]);if(t.output!=null&&t.output.length)for(var i=0;i<t.output.length;++i)o.uint32(18).string(t.output[i]);if(t.name!=null&&t.hasOwnProperty("name")&&o.uint32(26).string(t.name),t.opType!=null&&t.hasOwnProperty("opType")&&o.uint32(34).string(t.opType),t.attribute!=null&&t.attribute.length)for(var i=0;i<t.attribute.length;++i)$root.onnx.AttributeProto.encode(t.attribute[i],o.uint32(42).fork()).ldelim();return t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(50).string(t.docString),t.domain!=null&&t.hasOwnProperty("domain")&&o.uint32(58).string(t.domain),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.NodeProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.input&&l.input.length||(l.input=[]),l.input.push(t.string());break;case 2:l.output&&l.output.length||(l.output=[]),l.output.push(t.string());break;case 3:l.name=t.string();break;case 4:l.opType=t.string();break;case 7:l.domain=t.string();break;case 5:l.attribute&&l.attribute.length||(l.attribute=[]),l.attribute.push($root.onnx.AttributeProto.decode(t,t.uint32()));break;case 6:l.docString=t.string();break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var o=0;o<t.input.length;++o)if(!$util.isString(t.input[o]))return"input: string[] expected"}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var o=0;o<t.output.length;++o)if(!$util.isString(t.output[o]))return"output: string[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!$util.isString(t.name))return"name: string expected";if(t.opType!=null&&t.hasOwnProperty("opType")&&!$util.isString(t.opType))return"opType: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!$util.isString(t.domain))return"domain: string expected";if(t.attribute!=null&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(var o=0;o<t.attribute.length;++o){var i=$root.onnx.AttributeProto.verify(t.attribute[o]);if(i)return"attribute."+i}}return t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString)?"docString: string expected":null},e.fromObject=function(t){if(t instanceof $root.onnx.NodeProto)return t;var o=new $root.onnx.NodeProto;if(t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.NodeProto.input: array expected");o.input=[];for(var i=0;i<t.input.length;++i)o.input[i]=String(t.input[i])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.NodeProto.output: array expected");o.output=[];for(var i=0;i<t.output.length;++i)o.output[i]=String(t.output[i])}if(t.name!=null&&(o.name=String(t.name)),t.opType!=null&&(o.opType=String(t.opType)),t.domain!=null&&(o.domain=String(t.domain)),t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");o.attribute=[];for(var i=0;i<t.attribute.length;++i){if(typeof t.attribute[i]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");o.attribute[i]=$root.onnx.AttributeProto.fromObject(t.attribute[i])}}return t.docString!=null&&(o.docString=String(t.docString)),o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.input=[],i.output=[],i.attribute=[]),o.defaults&&(i.name="",i.opType="",i.docString="",i.domain=""),t.input&&t.input.length){i.input=[];for(var l=0;l<t.input.length;++l)i.input[l]=t.input[l]}if(t.output&&t.output.length){i.output=[];for(var l=0;l<t.output.length;++l)i.output[l]=t.output[l]}if(t.name!=null&&t.hasOwnProperty("name")&&(i.name=t.name),t.opType!=null&&t.hasOwnProperty("opType")&&(i.opType=t.opType),t.attribute&&t.attribute.length){i.attribute=[];for(var l=0;l<t.attribute.length;++l)i.attribute[l]=$root.onnx.AttributeProto.toObject(t.attribute[l],o)}return t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),t.domain!=null&&t.hasOwnProperty("domain")&&(i.domain=t.domain),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.ModelProto=function(){function e(r){if(this.opsetImport=[],this.metadataProps=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.irVersion=$util.Long?$util.Long.fromBits(0,0,!1):0,e.prototype.opsetImport=$util.emptyArray,e.prototype.producerName="",e.prototype.producerVersion="",e.prototype.domain="",e.prototype.modelVersion=$util.Long?$util.Long.fromBits(0,0,!1):0,e.prototype.docString="",e.prototype.graph=null,e.prototype.metadataProps=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.irVersion!=null&&t.hasOwnProperty("irVersion")&&o.uint32(8).int64(t.irVersion),t.producerName!=null&&t.hasOwnProperty("producerName")&&o.uint32(18).string(t.producerName),t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&o.uint32(26).string(t.producerVersion),t.domain!=null&&t.hasOwnProperty("domain")&&o.uint32(34).string(t.domain),t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&o.uint32(40).int64(t.modelVersion),t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(50).string(t.docString),t.graph!=null&&t.hasOwnProperty("graph")&&$root.onnx.GraphProto.encode(t.graph,o.uint32(58).fork()).ldelim(),t.opsetImport!=null&&t.opsetImport.length)for(var i=0;i<t.opsetImport.length;++i)$root.onnx.OperatorSetIdProto.encode(t.opsetImport[i],o.uint32(66).fork()).ldelim();if(t.metadataProps!=null&&t.metadataProps.length)for(var i=0;i<t.metadataProps.length;++i)$root.onnx.StringStringEntryProto.encode(t.metadataProps[i],o.uint32(114).fork()).ldelim();return o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.ModelProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.irVersion=t.int64();break;case 8:l.opsetImport&&l.opsetImport.length||(l.opsetImport=[]),l.opsetImport.push($root.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 2:l.producerName=t.string();break;case 3:l.producerVersion=t.string();break;case 4:l.domain=t.string();break;case 5:l.modelVersion=t.int64();break;case 6:l.docString=t.string();break;case 7:l.graph=$root.onnx.GraphProto.decode(t,t.uint32());break;case 14:l.metadataProps&&l.metadataProps.length||(l.metadataProps=[]),l.metadataProps.push($root.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&!$util.isInteger(t.irVersion)&&!(t.irVersion&&$util.isInteger(t.irVersion.low)&&$util.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var o=0;o<t.opsetImport.length;++o){var i=$root.onnx.OperatorSetIdProto.verify(t.opsetImport[o]);if(i)return"opsetImport."+i}}if(t.producerName!=null&&t.hasOwnProperty("producerName")&&!$util.isString(t.producerName))return"producerName: string expected";if(t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&!$util.isString(t.producerVersion))return"producerVersion: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!$util.isString(t.domain))return"domain: string expected";if(t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&!$util.isInteger(t.modelVersion)&&!(t.modelVersion&&$util.isInteger(t.modelVersion.low)&&$util.isInteger(t.modelVersion.high)))return"modelVersion: integer|Long expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString))return"docString: string expected";if(t.graph!=null&&t.hasOwnProperty("graph")){var i=$root.onnx.GraphProto.verify(t.graph);if(i)return"graph."+i}if(t.metadataProps!=null&&t.hasOwnProperty("metadataProps")){if(!Array.isArray(t.metadataProps))return"metadataProps: array expected";for(var o=0;o<t.metadataProps.length;++o){var i=$root.onnx.StringStringEntryProto.verify(t.metadataProps[o]);if(i)return"metadataProps."+i}}return null},e.fromObject=function(t){if(t instanceof $root.onnx.ModelProto)return t;var o=new $root.onnx.ModelProto;if(t.irVersion!=null&&($util.Long?(o.irVersion=$util.Long.fromValue(t.irVersion)).unsigned=!1:typeof t.irVersion=="string"?o.irVersion=parseInt(t.irVersion,10):typeof t.irVersion=="number"?o.irVersion=t.irVersion:typeof t.irVersion=="object"&&(o.irVersion=new $util.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");o.opsetImport=[];for(var i=0;i<t.opsetImport.length;++i){if(typeof t.opsetImport[i]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");o.opsetImport[i]=$root.onnx.OperatorSetIdProto.fromObject(t.opsetImport[i])}}if(t.producerName!=null&&(o.producerName=String(t.producerName)),t.producerVersion!=null&&(o.producerVersion=String(t.producerVersion)),t.domain!=null&&(o.domain=String(t.domain)),t.modelVersion!=null&&($util.Long?(o.modelVersion=$util.Long.fromValue(t.modelVersion)).unsigned=!1:typeof t.modelVersion=="string"?o.modelVersion=parseInt(t.modelVersion,10):typeof t.modelVersion=="number"?o.modelVersion=t.modelVersion:typeof t.modelVersion=="object"&&(o.modelVersion=new $util.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber())),t.docString!=null&&(o.docString=String(t.docString)),t.graph!=null){if(typeof t.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");o.graph=$root.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");o.metadataProps=[];for(var i=0;i<t.metadataProps.length;++i){if(typeof t.metadataProps[i]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");o.metadataProps[i]=$root.onnx.StringStringEntryProto.fromObject(t.metadataProps[i])}}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.opsetImport=[],i.metadataProps=[]),o.defaults){if($util.Long){var l=new $util.Long(0,0,!1);i.irVersion=o.longs===String?l.toString():o.longs===Number?l.toNumber():l}else i.irVersion=o.longs===String?"0":0;if(i.producerName="",i.producerVersion="",i.domain="",$util.Long){var l=new $util.Long(0,0,!1);i.modelVersion=o.longs===String?l.toString():o.longs===Number?l.toNumber():l}else i.modelVersion=o.longs===String?"0":0;i.docString="",i.graph=null}if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&(typeof t.irVersion=="number"?i.irVersion=o.longs===String?String(t.irVersion):t.irVersion:i.irVersion=o.longs===String?$util.Long.prototype.toString.call(t.irVersion):o.longs===Number?new $util.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber():t.irVersion),t.producerName!=null&&t.hasOwnProperty("producerName")&&(i.producerName=t.producerName),t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&(i.producerVersion=t.producerVersion),t.domain!=null&&t.hasOwnProperty("domain")&&(i.domain=t.domain),t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&(typeof t.modelVersion=="number"?i.modelVersion=o.longs===String?String(t.modelVersion):t.modelVersion:i.modelVersion=o.longs===String?$util.Long.prototype.toString.call(t.modelVersion):o.longs===Number?new $util.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),t.graph!=null&&t.hasOwnProperty("graph")&&(i.graph=$root.onnx.GraphProto.toObject(t.graph,o)),t.opsetImport&&t.opsetImport.length){i.opsetImport=[];for(var a=0;a<t.opsetImport.length;++a)i.opsetImport[a]=$root.onnx.OperatorSetIdProto.toObject(t.opsetImport[a],o)}if(t.metadataProps&&t.metadataProps.length){i.metadataProps=[];for(var a=0;a<t.metadataProps.length;++a)i.metadataProps[a]=$root.onnx.StringStringEntryProto.toObject(t.metadataProps[a],o)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.StringStringEntryProto=function(){function e(r){if(r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.key="",e.prototype.value="",e.create=function(t){return new e(t)},e.encode=function(t,o){return o||(o=$Writer.create()),t.key!=null&&t.hasOwnProperty("key")&&o.uint32(10).string(t.key),t.value!=null&&t.hasOwnProperty("value")&&o.uint32(18).string(t.value),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.StringStringEntryProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.key=t.string();break;case 2:l.value=t.string();break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!$util.isString(t.key)?"key: string expected":t.value!=null&&t.hasOwnProperty("value")&&!$util.isString(t.value)?"value: string expected":null},e.fromObject=function(t){if(t instanceof $root.onnx.StringStringEntryProto)return t;var o=new $root.onnx.StringStringEntryProto;return t.key!=null&&(o.key=String(t.key)),t.value!=null&&(o.value=String(t.value)),o},e.toObject=function(t,o){o||(o={});var i={};return o.defaults&&(i.key="",i.value=""),t.key!=null&&t.hasOwnProperty("key")&&(i.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(i.value=t.value),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.TensorAnnotation=function(){function e(r){if(this.quantParameterTensorNames=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.tensorName="",e.prototype.quantParameterTensorNames=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.tensorName!=null&&t.hasOwnProperty("tensorName")&&o.uint32(10).string(t.tensorName),t.quantParameterTensorNames!=null&&t.quantParameterTensorNames.length)for(var i=0;i<t.quantParameterTensorNames.length;++i)$root.onnx.StringStringEntryProto.encode(t.quantParameterTensorNames[i],o.uint32(18).fork()).ldelim();return o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.TensorAnnotation;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.tensorName=t.string();break;case 2:l.quantParameterTensorNames&&l.quantParameterTensorNames.length||(l.quantParameterTensorNames=[]),l.quantParameterTensorNames.push($root.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.tensorName!=null&&t.hasOwnProperty("tensorName")&&!$util.isString(t.tensorName))return"tensorName: string expected";if(t.quantParameterTensorNames!=null&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var o=0;o<t.quantParameterTensorNames.length;++o){var i=$root.onnx.StringStringEntryProto.verify(t.quantParameterTensorNames[o]);if(i)return"quantParameterTensorNames."+i}}return null},e.fromObject=function(t){if(t instanceof $root.onnx.TensorAnnotation)return t;var o=new $root.onnx.TensorAnnotation;if(t.tensorName!=null&&(o.tensorName=String(t.tensorName)),t.quantParameterTensorNames){if(!Array.isArray(t.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");o.quantParameterTensorNames=[];for(var i=0;i<t.quantParameterTensorNames.length;++i){if(typeof t.quantParameterTensorNames[i]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");o.quantParameterTensorNames[i]=$root.onnx.StringStringEntryProto.fromObject(t.quantParameterTensorNames[i])}}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.quantParameterTensorNames=[]),o.defaults&&(i.tensorName=""),t.tensorName!=null&&t.hasOwnProperty("tensorName")&&(i.tensorName=t.tensorName),t.quantParameterTensorNames&&t.quantParameterTensorNames.length){i.quantParameterTensorNames=[];for(var l=0;l<t.quantParameterTensorNames.length;++l)i.quantParameterTensorNames[l]=$root.onnx.StringStringEntryProto.toObject(t.quantParameterTensorNames[l],o)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.GraphProto=function(){function e(r){if(this.node=[],this.initializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.node=$util.emptyArray,e.prototype.name="",e.prototype.initializer=$util.emptyArray,e.prototype.docString="",e.prototype.input=$util.emptyArray,e.prototype.output=$util.emptyArray,e.prototype.valueInfo=$util.emptyArray,e.prototype.quantizationAnnotation=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.node!=null&&t.node.length)for(var i=0;i<t.node.length;++i)$root.onnx.NodeProto.encode(t.node[i],o.uint32(10).fork()).ldelim();if(t.name!=null&&t.hasOwnProperty("name")&&o.uint32(18).string(t.name),t.initializer!=null&&t.initializer.length)for(var i=0;i<t.initializer.length;++i)$root.onnx.TensorProto.encode(t.initializer[i],o.uint32(42).fork()).ldelim();if(t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(82).string(t.docString),t.input!=null&&t.input.length)for(var i=0;i<t.input.length;++i)$root.onnx.ValueInfoProto.encode(t.input[i],o.uint32(90).fork()).ldelim();if(t.output!=null&&t.output.length)for(var i=0;i<t.output.length;++i)$root.onnx.ValueInfoProto.encode(t.output[i],o.uint32(98).fork()).ldelim();if(t.valueInfo!=null&&t.valueInfo.length)for(var i=0;i<t.valueInfo.length;++i)$root.onnx.ValueInfoProto.encode(t.valueInfo[i],o.uint32(106).fork()).ldelim();if(t.quantizationAnnotation!=null&&t.quantizationAnnotation.length)for(var i=0;i<t.quantizationAnnotation.length;++i)$root.onnx.TensorAnnotation.encode(t.quantizationAnnotation[i],o.uint32(114).fork()).ldelim();return o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.GraphProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.node&&l.node.length||(l.node=[]),l.node.push($root.onnx.NodeProto.decode(t,t.uint32()));break;case 2:l.name=t.string();break;case 5:l.initializer&&l.initializer.length||(l.initializer=[]),l.initializer.push($root.onnx.TensorProto.decode(t,t.uint32()));break;case 10:l.docString=t.string();break;case 11:l.input&&l.input.length||(l.input=[]),l.input.push($root.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 12:l.output&&l.output.length||(l.output=[]),l.output.push($root.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 13:l.valueInfo&&l.valueInfo.length||(l.valueInfo=[]),l.valueInfo.push($root.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 14:l.quantizationAnnotation&&l.quantizationAnnotation.length||(l.quantizationAnnotation=[]),l.quantizationAnnotation.push($root.onnx.TensorAnnotation.decode(t,t.uint32()));break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var o=0;o<t.node.length;++o){var i=$root.onnx.NodeProto.verify(t.node[o]);if(i)return"node."+i}}if(t.name!=null&&t.hasOwnProperty("name")&&!$util.isString(t.name))return"name: string expected";if(t.initializer!=null&&t.hasOwnProperty("initializer")){if(!Array.isArray(t.initializer))return"initializer: array expected";for(var o=0;o<t.initializer.length;++o){var i=$root.onnx.TensorProto.verify(t.initializer[o]);if(i)return"initializer."+i}}if(t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString))return"docString: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var o=0;o<t.input.length;++o){var i=$root.onnx.ValueInfoProto.verify(t.input[o]);if(i)return"input."+i}}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(var o=0;o<t.output.length;++o){var i=$root.onnx.ValueInfoProto.verify(t.output[o]);if(i)return"output."+i}}if(t.valueInfo!=null&&t.hasOwnProperty("valueInfo")){if(!Array.isArray(t.valueInfo))return"valueInfo: array expected";for(var o=0;o<t.valueInfo.length;++o){var i=$root.onnx.ValueInfoProto.verify(t.valueInfo[o]);if(i)return"valueInfo."+i}}if(t.quantizationAnnotation!=null&&t.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(t.quantizationAnnotation))return"quantizationAnnotation: array expected";for(var o=0;o<t.quantizationAnnotation.length;++o){var i=$root.onnx.TensorAnnotation.verify(t.quantizationAnnotation[o]);if(i)return"quantizationAnnotation."+i}}return null},e.fromObject=function(t){if(t instanceof $root.onnx.GraphProto)return t;var o=new $root.onnx.GraphProto;if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.GraphProto.node: array expected");o.node=[];for(var i=0;i<t.node.length;++i){if(typeof t.node[i]!="object")throw TypeError(".onnx.GraphProto.node: object expected");o.node[i]=$root.onnx.NodeProto.fromObject(t.node[i])}}if(t.name!=null&&(o.name=String(t.name)),t.initializer){if(!Array.isArray(t.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");o.initializer=[];for(var i=0;i<t.initializer.length;++i){if(typeof t.initializer[i]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");o.initializer[i]=$root.onnx.TensorProto.fromObject(t.initializer[i])}}if(t.docString!=null&&(o.docString=String(t.docString)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.GraphProto.input: array expected");o.input=[];for(var i=0;i<t.input.length;++i){if(typeof t.input[i]!="object")throw TypeError(".onnx.GraphProto.input: object expected");o.input[i]=$root.onnx.ValueInfoProto.fromObject(t.input[i])}}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.GraphProto.output: array expected");o.output=[];for(var i=0;i<t.output.length;++i){if(typeof t.output[i]!="object")throw TypeError(".onnx.GraphProto.output: object expected");o.output[i]=$root.onnx.ValueInfoProto.fromObject(t.output[i])}}if(t.valueInfo){if(!Array.isArray(t.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");o.valueInfo=[];for(var i=0;i<t.valueInfo.length;++i){if(typeof t.valueInfo[i]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");o.valueInfo[i]=$root.onnx.ValueInfoProto.fromObject(t.valueInfo[i])}}if(t.quantizationAnnotation){if(!Array.isArray(t.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");o.quantizationAnnotation=[];for(var i=0;i<t.quantizationAnnotation.length;++i){if(typeof t.quantizationAnnotation[i]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");o.quantizationAnnotation[i]=$root.onnx.TensorAnnotation.fromObject(t.quantizationAnnotation[i])}}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.node=[],i.initializer=[],i.input=[],i.output=[],i.valueInfo=[],i.quantizationAnnotation=[]),o.defaults&&(i.name="",i.docString=""),t.node&&t.node.length){i.node=[];for(var l=0;l<t.node.length;++l)i.node[l]=$root.onnx.NodeProto.toObject(t.node[l],o)}if(t.name!=null&&t.hasOwnProperty("name")&&(i.name=t.name),t.initializer&&t.initializer.length){i.initializer=[];for(var l=0;l<t.initializer.length;++l)i.initializer[l]=$root.onnx.TensorProto.toObject(t.initializer[l],o)}if(t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),t.input&&t.input.length){i.input=[];for(var l=0;l<t.input.length;++l)i.input[l]=$root.onnx.ValueInfoProto.toObject(t.input[l],o)}if(t.output&&t.output.length){i.output=[];for(var l=0;l<t.output.length;++l)i.output[l]=$root.onnx.ValueInfoProto.toObject(t.output[l],o)}if(t.valueInfo&&t.valueInfo.length){i.valueInfo=[];for(var l=0;l<t.valueInfo.length;++l)i.valueInfo[l]=$root.onnx.ValueInfoProto.toObject(t.valueInfo[l],o)}if(t.quantizationAnnotation&&t.quantizationAnnotation.length){i.quantizationAnnotation=[];for(var l=0;l<t.quantizationAnnotation.length;++l)i.quantizationAnnotation[l]=$root.onnx.TensorAnnotation.toObject(t.quantizationAnnotation[l],o)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n.TensorProto=function(){function e(r){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.dims=$util.emptyArray,e.prototype.dataType=0,e.prototype.segment=null,e.prototype.floatData=$util.emptyArray,e.prototype.int32Data=$util.emptyArray,e.prototype.stringData=$util.emptyArray,e.prototype.int64Data=$util.emptyArray,e.prototype.name="",e.prototype.docString="",e.prototype.rawData=$util.newBuffer([]),e.prototype.externalData=$util.emptyArray,e.prototype.dataLocation=0,e.prototype.doubleData=$util.emptyArray,e.prototype.uint64Data=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.dims!=null&&t.dims.length){o.uint32(10).fork();for(var i=0;i<t.dims.length;++i)o.int64(t.dims[i]);o.ldelim()}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&o.uint32(16).int32(t.dataType),t.segment!=null&&t.hasOwnProperty("segment")&&$root.onnx.TensorProto.Segment.encode(t.segment,o.uint32(26).fork()).ldelim(),t.floatData!=null&&t.floatData.length){o.uint32(34).fork();for(var i=0;i<t.floatData.length;++i)o.float(t.floatData[i]);o.ldelim()}if(t.int32Data!=null&&t.int32Data.length){o.uint32(42).fork();for(var i=0;i<t.int32Data.length;++i)o.int32(t.int32Data[i]);o.ldelim()}if(t.stringData!=null&&t.stringData.length)for(var i=0;i<t.stringData.length;++i)o.uint32(50).bytes(t.stringData[i]);if(t.int64Data!=null&&t.int64Data.length){o.uint32(58).fork();for(var i=0;i<t.int64Data.length;++i)o.int64(t.int64Data[i]);o.ldelim()}if(t.name!=null&&t.hasOwnProperty("name")&&o.uint32(66).string(t.name),t.rawData!=null&&t.hasOwnProperty("rawData")&&o.uint32(74).bytes(t.rawData),t.doubleData!=null&&t.doubleData.length){o.uint32(82).fork();for(var i=0;i<t.doubleData.length;++i)o.double(t.doubleData[i]);o.ldelim()}if(t.uint64Data!=null&&t.uint64Data.length){o.uint32(90).fork();for(var i=0;i<t.uint64Data.length;++i)o.uint64(t.uint64Data[i]);o.ldelim()}if(t.docString!=null&&t.hasOwnProperty("docString")&&o.uint32(98).string(t.docString),t.externalData!=null&&t.externalData.length)for(var i=0;i<t.externalData.length;++i)$root.onnx.StringStringEntryProto.encode(t.externalData[i],o.uint32(106).fork()).ldelim();return t.dataLocation!=null&&t.hasOwnProperty("dataLocation")&&o.uint32(112).int32(t.dataLocation),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.TensorProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:if(l.dims&&l.dims.length||(l.dims=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.dims.push(t.int64());else l.dims.push(t.int64());break;case 2:l.dataType=t.int32();break;case 3:l.segment=$root.onnx.TensorProto.Segment.decode(t,t.uint32());break;case 4:if(l.floatData&&l.floatData.length||(l.floatData=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.floatData.push(t.float());else l.floatData.push(t.float());break;case 5:if(l.int32Data&&l.int32Data.length||(l.int32Data=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.int32Data.push(t.int32());else l.int32Data.push(t.int32());break;case 6:l.stringData&&l.stringData.length||(l.stringData=[]),l.stringData.push(t.bytes());break;case 7:if(l.int64Data&&l.int64Data.length||(l.int64Data=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.int64Data.push(t.int64());else l.int64Data.push(t.int64());break;case 8:l.name=t.string();break;case 12:l.docString=t.string();break;case 9:l.rawData=t.bytes();break;case 13:l.externalData&&l.externalData.length||(l.externalData=[]),l.externalData.push($root.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 14:l.dataLocation=t.int32();break;case 10:if(l.doubleData&&l.doubleData.length||(l.doubleData=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.doubleData.push(t.double());else l.doubleData.push(t.double());break;case 11:if(l.uint64Data&&l.uint64Data.length||(l.uint64Data=[]),(a&7)===2)for(var s=t.uint32()+t.pos;t.pos<s;)l.uint64Data.push(t.uint64());else l.uint64Data.push(t.uint64());break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dims!=null&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var o=0;o<t.dims.length;++o)if(!$util.isInteger(t.dims[o])&&!(t.dims[o]&&$util.isInteger(t.dims[o].low)&&$util.isInteger(t.dims[o].high)))return"dims: integer|Long[] expected"}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&!$util.isInteger(t.dataType))return"dataType: integer expected";if(t.segment!=null&&t.hasOwnProperty("segment")){var i=$root.onnx.TensorProto.Segment.verify(t.segment);if(i)return"segment."+i}if(t.floatData!=null&&t.hasOwnProperty("floatData")){if(!Array.isArray(t.floatData))return"floatData: array expected";for(var o=0;o<t.floatData.length;++o)if(typeof t.floatData[o]!="number")return"floatData: number[] expected"}if(t.int32Data!=null&&t.hasOwnProperty("int32Data")){if(!Array.isArray(t.int32Data))return"int32Data: array expected";for(var o=0;o<t.int32Data.length;++o)if(!$util.isInteger(t.int32Data[o]))return"int32Data: integer[] expected"}if(t.stringData!=null&&t.hasOwnProperty("stringData")){if(!Array.isArray(t.stringData))return"stringData: array expected";for(var o=0;o<t.stringData.length;++o)if(!(t.stringData[o]&&typeof t.stringData[o].length=="number"||$util.isString(t.stringData[o])))return"stringData: buffer[] expected"}if(t.int64Data!=null&&t.hasOwnProperty("int64Data")){if(!Array.isArray(t.int64Data))return"int64Data: array expected";for(var o=0;o<t.int64Data.length;++o)if(!$util.isInteger(t.int64Data[o])&&!(t.int64Data[o]&&$util.isInteger(t.int64Data[o].low)&&$util.isInteger(t.int64Data[o].high)))return"int64Data: integer|Long[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!$util.isString(t.name))return"name: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!$util.isString(t.docString))return"docString: string expected";if(t.rawData!=null&&t.hasOwnProperty("rawData")&&!(t.rawData&&typeof t.rawData.length=="number"||$util.isString(t.rawData)))return"rawData: buffer expected";if(t.externalData!=null&&t.hasOwnProperty("externalData")){if(!Array.isArray(t.externalData))return"externalData: array expected";for(var o=0;o<t.externalData.length;++o){var i=$root.onnx.StringStringEntryProto.verify(t.externalData[o]);if(i)return"externalData."+i}}if(t.dataLocation!=null&&t.hasOwnProperty("dataLocation"))switch(t.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:break}if(t.doubleData!=null&&t.hasOwnProperty("doubleData")){if(!Array.isArray(t.doubleData))return"doubleData: array expected";for(var o=0;o<t.doubleData.length;++o)if(typeof t.doubleData[o]!="number")return"doubleData: number[] expected"}if(t.uint64Data!=null&&t.hasOwnProperty("uint64Data")){if(!Array.isArray(t.uint64Data))return"uint64Data: array expected";for(var o=0;o<t.uint64Data.length;++o)if(!$util.isInteger(t.uint64Data[o])&&!(t.uint64Data[o]&&$util.isInteger(t.uint64Data[o].low)&&$util.isInteger(t.uint64Data[o].high)))return"uint64Data: integer|Long[] expected"}return null},e.fromObject=function(t){if(t instanceof $root.onnx.TensorProto)return t;var o=new $root.onnx.TensorProto;if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.TensorProto.dims: array expected");o.dims=[];for(var i=0;i<t.dims.length;++i)$util.Long?(o.dims[i]=$util.Long.fromValue(t.dims[i])).unsigned=!1:typeof t.dims[i]=="string"?o.dims[i]=parseInt(t.dims[i],10):typeof t.dims[i]=="number"?o.dims[i]=t.dims[i]:typeof t.dims[i]=="object"&&(o.dims[i]=new $util.LongBits(t.dims[i].low>>>0,t.dims[i].high>>>0).toNumber())}if(t.dataType!=null&&(o.dataType=t.dataType|0),t.segment!=null){if(typeof t.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");o.segment=$root.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");o.floatData=[];for(var i=0;i<t.floatData.length;++i)o.floatData[i]=Number(t.floatData[i])}if(t.int32Data){if(!Array.isArray(t.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");o.int32Data=[];for(var i=0;i<t.int32Data.length;++i)o.int32Data[i]=t.int32Data[i]|0}if(t.stringData){if(!Array.isArray(t.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");o.stringData=[];for(var i=0;i<t.stringData.length;++i)typeof t.stringData[i]=="string"?$util.base64.decode(t.stringData[i],o.stringData[i]=$util.newBuffer($util.base64.length(t.stringData[i])),0):t.stringData[i].length&&(o.stringData[i]=t.stringData[i])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");o.int64Data=[];for(var i=0;i<t.int64Data.length;++i)$util.Long?(o.int64Data[i]=$util.Long.fromValue(t.int64Data[i])).unsigned=!1:typeof t.int64Data[i]=="string"?o.int64Data[i]=parseInt(t.int64Data[i],10):typeof t.int64Data[i]=="number"?o.int64Data[i]=t.int64Data[i]:typeof t.int64Data[i]=="object"&&(o.int64Data[i]=new $util.LongBits(t.int64Data[i].low>>>0,t.int64Data[i].high>>>0).toNumber())}if(t.name!=null&&(o.name=String(t.name)),t.docString!=null&&(o.docString=String(t.docString)),t.rawData!=null&&(typeof t.rawData=="string"?$util.base64.decode(t.rawData,o.rawData=$util.newBuffer($util.base64.length(t.rawData)),0):t.rawData.length&&(o.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");o.externalData=[];for(var i=0;i<t.externalData.length;++i){if(typeof t.externalData[i]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");o.externalData[i]=$root.onnx.StringStringEntryProto.fromObject(t.externalData[i])}}switch(t.dataLocation){case"DEFAULT":case 0:o.dataLocation=0;break;case"EXTERNAL":case 1:o.dataLocation=1;break}if(t.doubleData){if(!Array.isArray(t.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");o.doubleData=[];for(var i=0;i<t.doubleData.length;++i)o.doubleData[i]=Number(t.doubleData[i])}if(t.uint64Data){if(!Array.isArray(t.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");o.uint64Data=[];for(var i=0;i<t.uint64Data.length;++i)$util.Long?(o.uint64Data[i]=$util.Long.fromValue(t.uint64Data[i])).unsigned=!0:typeof t.uint64Data[i]=="string"?o.uint64Data[i]=parseInt(t.uint64Data[i],10):typeof t.uint64Data[i]=="number"?o.uint64Data[i]=t.uint64Data[i]:typeof t.uint64Data[i]=="object"&&(o.uint64Data[i]=new $util.LongBits(t.uint64Data[i].low>>>0,t.uint64Data[i].high>>>0).toNumber(!0))}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.dims=[],i.floatData=[],i.int32Data=[],i.stringData=[],i.int64Data=[],i.doubleData=[],i.uint64Data=[],i.externalData=[]),o.defaults&&(i.dataType=0,i.segment=null,i.name="",o.bytes===String?i.rawData="":(i.rawData=[],o.bytes!==Array&&(i.rawData=$util.newBuffer(i.rawData))),i.docString="",i.dataLocation=o.enums===String?"DEFAULT":0),t.dims&&t.dims.length){i.dims=[];for(var l=0;l<t.dims.length;++l)typeof t.dims[l]=="number"?i.dims[l]=o.longs===String?String(t.dims[l]):t.dims[l]:i.dims[l]=o.longs===String?$util.Long.prototype.toString.call(t.dims[l]):o.longs===Number?new $util.LongBits(t.dims[l].low>>>0,t.dims[l].high>>>0).toNumber():t.dims[l]}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&(i.dataType=t.dataType),t.segment!=null&&t.hasOwnProperty("segment")&&(i.segment=$root.onnx.TensorProto.Segment.toObject(t.segment,o)),t.floatData&&t.floatData.length){i.floatData=[];for(var l=0;l<t.floatData.length;++l)i.floatData[l]=o.json&&!isFinite(t.floatData[l])?String(t.floatData[l]):t.floatData[l]}if(t.int32Data&&t.int32Data.length){i.int32Data=[];for(var l=0;l<t.int32Data.length;++l)i.int32Data[l]=t.int32Data[l]}if(t.stringData&&t.stringData.length){i.stringData=[];for(var l=0;l<t.stringData.length;++l)i.stringData[l]=o.bytes===String?$util.base64.encode(t.stringData[l],0,t.stringData[l].length):o.bytes===Array?Array.prototype.slice.call(t.stringData[l]):t.stringData[l]}if(t.int64Data&&t.int64Data.length){i.int64Data=[];for(var l=0;l<t.int64Data.length;++l)typeof t.int64Data[l]=="number"?i.int64Data[l]=o.longs===String?String(t.int64Data[l]):t.int64Data[l]:i.int64Data[l]=o.longs===String?$util.Long.prototype.toString.call(t.int64Data[l]):o.longs===Number?new $util.LongBits(t.int64Data[l].low>>>0,t.int64Data[l].high>>>0).toNumber():t.int64Data[l]}if(t.name!=null&&t.hasOwnProperty("name")&&(i.name=t.name),t.rawData!=null&&t.hasOwnProperty("rawData")&&(i.rawData=o.bytes===String?$util.base64.encode(t.rawData,0,t.rawData.length):o.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length){i.doubleData=[];for(var l=0;l<t.doubleData.length;++l)i.doubleData[l]=o.json&&!isFinite(t.doubleData[l])?String(t.doubleData[l]):t.doubleData[l]}if(t.uint64Data&&t.uint64Data.length){i.uint64Data=[];for(var l=0;l<t.uint64Data.length;++l)typeof t.uint64Data[l]=="number"?i.uint64Data[l]=o.longs===String?String(t.uint64Data[l]):t.uint64Data[l]:i.uint64Data[l]=o.longs===String?$util.Long.prototype.toString.call(t.uint64Data[l]):o.longs===Number?new $util.LongBits(t.uint64Data[l].low>>>0,t.uint64Data[l].high>>>0).toNumber(!0):t.uint64Data[l]}if(t.docString!=null&&t.hasOwnProperty("docString")&&(i.docString=t.docString),t.externalData&&t.externalData.length){i.externalData=[];for(var l=0;l<t.externalData.length;++l)i.externalData[l]=$root.onnx.StringStringEntryProto.toObject(t.externalData[l],o)}return t.dataLocation!=null&&t.hasOwnProperty("dataLocation")&&(i.dataLocation=o.enums===String?$root.onnx.TensorProto.DataLocation[t.dataLocation]:t.dataLocation),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e.DataType=function(){var r={},t=Object.create(r);return t[r[0]="UNDEFINED"]=0,t[r[1]="FLOAT"]=1,t[r[2]="UINT8"]=2,t[r[3]="INT8"]=3,t[r[4]="UINT16"]=4,t[r[5]="INT16"]=5,t[r[6]="INT32"]=6,t[r[7]="INT64"]=7,t[r[8]="STRING"]=8,t[r[9]="BOOL"]=9,t[r[10]="FLOAT16"]=10,t[r[11]="DOUBLE"]=11,t[r[12]="UINT32"]=12,t[r[13]="UINT64"]=13,t[r[14]="COMPLEX64"]=14,t[r[15]="COMPLEX128"]=15,t[r[16]="BFLOAT16"]=16,t}(),e.Segment=function(){function r(t){if(t)for(var o=Object.keys(t),i=0;i<o.length;++i)t[o[i]]!=null&&(this[o[i]]=t[o[i]])}return r.prototype.begin=$util.Long?$util.Long.fromBits(0,0,!1):0,r.prototype.end=$util.Long?$util.Long.fromBits(0,0,!1):0,r.create=function(o){return new r(o)},r.encode=function(o,i){return i||(i=$Writer.create()),o.begin!=null&&o.hasOwnProperty("begin")&&i.uint32(8).int64(o.begin),o.end!=null&&o.hasOwnProperty("end")&&i.uint32(16).int64(o.end),i},r.encodeDelimited=function(o,i){return this.encode(o,i).ldelim()},r.decode=function(o,i){o instanceof $Reader||(o=$Reader.create(o));for(var l=i===void 0?o.len:o.pos+i,a=new $root.onnx.TensorProto.Segment;o.pos<l;){var s=o.uint32();switch(s>>>3){case 1:a.begin=o.int64();break;case 2:a.end=o.int64();break;default:o.skipType(s&7);break}}return a},r.decodeDelimited=function(o){return o instanceof $Reader||(o=new $Reader(o)),this.decode(o,o.uint32())},r.verify=function(o){return typeof o!="object"||o===null?"object expected":o.begin!=null&&o.hasOwnProperty("begin")&&!$util.isInteger(o.begin)&&!(o.begin&&$util.isInteger(o.begin.low)&&$util.isInteger(o.begin.high))?"begin: integer|Long expected":o.end!=null&&o.hasOwnProperty("end")&&!$util.isInteger(o.end)&&!(o.end&&$util.isInteger(o.end.low)&&$util.isInteger(o.end.high))?"end: integer|Long expected":null},r.fromObject=function(o){if(o instanceof $root.onnx.TensorProto.Segment)return o;var i=new $root.onnx.TensorProto.Segment;return o.begin!=null&&($util.Long?(i.begin=$util.Long.fromValue(o.begin)).unsigned=!1:typeof o.begin=="string"?i.begin=parseInt(o.begin,10):typeof o.begin=="number"?i.begin=o.begin:typeof o.begin=="object"&&(i.begin=new $util.LongBits(o.begin.low>>>0,o.begin.high>>>0).toNumber())),o.end!=null&&($util.Long?(i.end=$util.Long.fromValue(o.end)).unsigned=!1:typeof o.end=="string"?i.end=parseInt(o.end,10):typeof o.end=="number"?i.end=o.end:typeof o.end=="object"&&(i.end=new $util.LongBits(o.end.low>>>0,o.end.high>>>0).toNumber())),i},r.toObject=function(o,i){i||(i={});var l={};if(i.defaults){if($util.Long){var a=new $util.Long(0,0,!1);l.begin=i.longs===String?a.toString():i.longs===Number?a.toNumber():a}else l.begin=i.longs===String?"0":0;if($util.Long){var a=new $util.Long(0,0,!1);l.end=i.longs===String?a.toString():i.longs===Number?a.toNumber():a}else l.end=i.longs===String?"0":0}return o.begin!=null&&o.hasOwnProperty("begin")&&(typeof o.begin=="number"?l.begin=i.longs===String?String(o.begin):o.begin:l.begin=i.longs===String?$util.Long.prototype.toString.call(o.begin):i.longs===Number?new $util.LongBits(o.begin.low>>>0,o.begin.high>>>0).toNumber():o.begin),o.end!=null&&o.hasOwnProperty("end")&&(typeof o.end=="number"?l.end=i.longs===String?String(o.end):o.end:l.end=i.longs===String?$util.Long.prototype.toString.call(o.end):i.longs===Number?new $util.LongBits(o.end.low>>>0,o.end.high>>>0).toNumber():o.end),l},r.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},r}(),e.DataLocation=function(){var r={},t=Object.create(r);return t[r[0]="DEFAULT"]=0,t[r[1]="EXTERNAL"]=1,t}(),e}(),n.TensorShapeProto=function(){function e(r){if(this.dim=[],r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.dim=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(t,o){if(o||(o=$Writer.create()),t.dim!=null&&t.dim.length)for(var i=0;i<t.dim.length;++i)$root.onnx.TensorShapeProto.Dimension.encode(t.dim[i],o.uint32(10).fork()).ldelim();return o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.TensorShapeProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.dim&&l.dim.length||(l.dim=[]),l.dim.push($root.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()));break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dim!=null&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var o=0;o<t.dim.length;++o){var i=$root.onnx.TensorShapeProto.Dimension.verify(t.dim[o]);if(i)return"dim."+i}}return null},e.fromObject=function(t){if(t instanceof $root.onnx.TensorShapeProto)return t;var o=new $root.onnx.TensorShapeProto;if(t.dim){if(!Array.isArray(t.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");o.dim=[];for(var i=0;i<t.dim.length;++i){if(typeof t.dim[i]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");o.dim[i]=$root.onnx.TensorShapeProto.Dimension.fromObject(t.dim[i])}}return o},e.toObject=function(t,o){o||(o={});var i={};if((o.arrays||o.defaults)&&(i.dim=[]),t.dim&&t.dim.length){i.dim=[];for(var l=0;l<t.dim.length;++l)i.dim[l]=$root.onnx.TensorShapeProto.Dimension.toObject(t.dim[l],o)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e.Dimension=function(){function r(o){if(o)for(var i=Object.keys(o),l=0;l<i.length;++l)o[i[l]]!=null&&(this[i[l]]=o[i[l]])}r.prototype.dimValue=$util.Long?$util.Long.fromBits(0,0,!1):0,r.prototype.dimParam="",r.prototype.denotation="";var t;return Object.defineProperty(r.prototype,"value",{get:$util.oneOfGetter(t=["dimValue","dimParam"]),set:$util.oneOfSetter(t)}),r.create=function(i){return new r(i)},r.encode=function(i,l){return l||(l=$Writer.create()),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&l.uint32(8).int64(i.dimValue),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&l.uint32(18).string(i.dimParam),i.denotation!=null&&i.hasOwnProperty("denotation")&&l.uint32(26).string(i.denotation),l},r.encodeDelimited=function(i,l){return this.encode(i,l).ldelim()},r.decode=function(i,l){i instanceof $Reader||(i=$Reader.create(i));for(var a=l===void 0?i.len:i.pos+l,s=new $root.onnx.TensorShapeProto.Dimension;i.pos<a;){var u=i.uint32();switch(u>>>3){case 1:s.dimValue=i.int64();break;case 2:s.dimParam=i.string();break;case 3:s.denotation=i.string();break;default:i.skipType(u&7);break}}return s},r.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},r.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var l={};if(i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(l.value=1,!$util.isInteger(i.dimValue)&&!(i.dimValue&&$util.isInteger(i.dimValue.low)&&$util.isInteger(i.dimValue.high))))return"dimValue: integer|Long expected";if(i.dimParam!=null&&i.hasOwnProperty("dimParam")){if(l.value===1)return"value: multiple values";if(l.value=1,!$util.isString(i.dimParam))return"dimParam: string expected"}return i.denotation!=null&&i.hasOwnProperty("denotation")&&!$util.isString(i.denotation)?"denotation: string expected":null},r.fromObject=function(i){if(i instanceof $root.onnx.TensorShapeProto.Dimension)return i;var l=new $root.onnx.TensorShapeProto.Dimension;return i.dimValue!=null&&($util.Long?(l.dimValue=$util.Long.fromValue(i.dimValue)).unsigned=!1:typeof i.dimValue=="string"?l.dimValue=parseInt(i.dimValue,10):typeof i.dimValue=="number"?l.dimValue=i.dimValue:typeof i.dimValue=="object"&&(l.dimValue=new $util.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber())),i.dimParam!=null&&(l.dimParam=String(i.dimParam)),i.denotation!=null&&(l.denotation=String(i.denotation)),l},r.toObject=function(i,l){l||(l={});var a={};return l.defaults&&(a.denotation=""),i.dimValue!=null&&i.hasOwnProperty("dimValue")&&(typeof i.dimValue=="number"?a.dimValue=l.longs===String?String(i.dimValue):i.dimValue:a.dimValue=l.longs===String?$util.Long.prototype.toString.call(i.dimValue):l.longs===Number?new $util.LongBits(i.dimValue.low>>>0,i.dimValue.high>>>0).toNumber():i.dimValue,l.oneofs&&(a.value="dimValue")),i.dimParam!=null&&i.hasOwnProperty("dimParam")&&(a.dimParam=i.dimParam,l.oneofs&&(a.value="dimParam")),i.denotation!=null&&i.hasOwnProperty("denotation")&&(a.denotation=i.denotation),a},r.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},r}(),e}(),n.TypeProto=function(){function e(t){if(t)for(var o=Object.keys(t),i=0;i<o.length;++i)t[o[i]]!=null&&(this[o[i]]=t[o[i]])}e.prototype.tensorType=null,e.prototype.denotation="";var r;return Object.defineProperty(e.prototype,"value",{get:$util.oneOfGetter(r=["tensorType"]),set:$util.oneOfSetter(r)}),e.create=function(o){return new e(o)},e.encode=function(o,i){return i||(i=$Writer.create()),o.tensorType!=null&&o.hasOwnProperty("tensorType")&&$root.onnx.TypeProto.Tensor.encode(o.tensorType,i.uint32(10).fork()).ldelim(),o.denotation!=null&&o.hasOwnProperty("denotation")&&i.uint32(50).string(o.denotation),i},e.encodeDelimited=function(o,i){return this.encode(o,i).ldelim()},e.decode=function(o,i){o instanceof $Reader||(o=$Reader.create(o));for(var l=i===void 0?o.len:o.pos+i,a=new $root.onnx.TypeProto;o.pos<l;){var s=o.uint32();switch(s>>>3){case 1:a.tensorType=$root.onnx.TypeProto.Tensor.decode(o,o.uint32());break;case 6:a.denotation=o.string();break;default:o.skipType(s&7);break}}return a},e.decodeDelimited=function(o){return o instanceof $Reader||(o=new $Reader(o)),this.decode(o,o.uint32())},e.verify=function(o){if(typeof o!="object"||o===null)return"object expected";if(o.tensorType!=null&&o.hasOwnProperty("tensorType")){var i=$root.onnx.TypeProto.Tensor.verify(o.tensorType);if(i)return"tensorType."+i}return o.denotation!=null&&o.hasOwnProperty("denotation")&&!$util.isString(o.denotation)?"denotation: string expected":null},e.fromObject=function(o){if(o instanceof $root.onnx.TypeProto)return o;var i=new $root.onnx.TypeProto;if(o.tensorType!=null){if(typeof o.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");i.tensorType=$root.onnx.TypeProto.Tensor.fromObject(o.tensorType)}return o.denotation!=null&&(i.denotation=String(o.denotation)),i},e.toObject=function(o,i){i||(i={});var l={};return i.defaults&&(l.denotation=""),o.tensorType!=null&&o.hasOwnProperty("tensorType")&&(l.tensorType=$root.onnx.TypeProto.Tensor.toObject(o.tensorType,i),i.oneofs&&(l.value="tensorType")),o.denotation!=null&&o.hasOwnProperty("denotation")&&(l.denotation=o.denotation),l},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e.Tensor=function(){function t(o){if(o)for(var i=Object.keys(o),l=0;l<i.length;++l)o[i[l]]!=null&&(this[i[l]]=o[i[l]])}return t.prototype.elemType=0,t.prototype.shape=null,t.create=function(i){return new t(i)},t.encode=function(i,l){return l||(l=$Writer.create()),i.elemType!=null&&i.hasOwnProperty("elemType")&&l.uint32(8).int32(i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&$root.onnx.TensorShapeProto.encode(i.shape,l.uint32(18).fork()).ldelim(),l},t.encodeDelimited=function(i,l){return this.encode(i,l).ldelim()},t.decode=function(i,l){i instanceof $Reader||(i=$Reader.create(i));for(var a=l===void 0?i.len:i.pos+l,s=new $root.onnx.TypeProto.Tensor;i.pos<a;){var u=i.uint32();switch(u>>>3){case 1:s.elemType=i.int32();break;case 2:s.shape=$root.onnx.TensorShapeProto.decode(i,i.uint32());break;default:i.skipType(u&7);break}}return s},t.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},t.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.elemType!=null&&i.hasOwnProperty("elemType")&&!$util.isInteger(i.elemType))return"elemType: integer expected";if(i.shape!=null&&i.hasOwnProperty("shape")){var l=$root.onnx.TensorShapeProto.verify(i.shape);if(l)return"shape."+l}return null},t.fromObject=function(i){if(i instanceof $root.onnx.TypeProto.Tensor)return i;var l=new $root.onnx.TypeProto.Tensor;if(i.elemType!=null&&(l.elemType=i.elemType|0),i.shape!=null){if(typeof i.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");l.shape=$root.onnx.TensorShapeProto.fromObject(i.shape)}return l},t.toObject=function(i,l){l||(l={});var a={};return l.defaults&&(a.elemType=0,a.shape=null),i.elemType!=null&&i.hasOwnProperty("elemType")&&(a.elemType=i.elemType),i.shape!=null&&i.hasOwnProperty("shape")&&(a.shape=$root.onnx.TensorShapeProto.toObject(i.shape,l)),a},t.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},t}(),e}(),n.OperatorSetIdProto=function(){function e(r){if(r)for(var t=Object.keys(r),o=0;o<t.length;++o)r[t[o]]!=null&&(this[t[o]]=r[t[o]])}return e.prototype.domain="",e.prototype.version=$util.Long?$util.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(t,o){return o||(o=$Writer.create()),t.domain!=null&&t.hasOwnProperty("domain")&&o.uint32(10).string(t.domain),t.version!=null&&t.hasOwnProperty("version")&&o.uint32(16).int64(t.version),o},e.encodeDelimited=function(t,o){return this.encode(t,o).ldelim()},e.decode=function(t,o){t instanceof $Reader||(t=$Reader.create(t));for(var i=o===void 0?t.len:t.pos+o,l=new $root.onnx.OperatorSetIdProto;t.pos<i;){var a=t.uint32();switch(a>>>3){case 1:l.domain=t.string();break;case 2:l.version=t.int64();break;default:t.skipType(a&7);break}}return l},e.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},e.verify=function(t){return typeof t!="object"||t===null?"object expected":t.domain!=null&&t.hasOwnProperty("domain")&&!$util.isString(t.domain)?"domain: string expected":t.version!=null&&t.hasOwnProperty("version")&&!$util.isInteger(t.version)&&!(t.version&&$util.isInteger(t.version.low)&&$util.isInteger(t.version.high))?"version: integer|Long expected":null},e.fromObject=function(t){if(t instanceof $root.onnx.OperatorSetIdProto)return t;var o=new $root.onnx.OperatorSetIdProto;return t.domain!=null&&(o.domain=String(t.domain)),t.version!=null&&($util.Long?(o.version=$util.Long.fromValue(t.version)).unsigned=!1:typeof t.version=="string"?o.version=parseInt(t.version,10):typeof t.version=="number"?o.version=t.version:typeof t.version=="object"&&(o.version=new $util.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),o},e.toObject=function(t,o){o||(o={});var i={};if(o.defaults)if(i.domain="",$util.Long){var l=new $util.Long(0,0,!1);i.version=o.longs===String?l.toString():o.longs===Number?l.toNumber():l}else i.version=o.longs===String?"0":0;return t.domain!=null&&t.hasOwnProperty("domain")&&(i.domain=t.domain),t.version!=null&&t.hasOwnProperty("version")&&(typeof t.version=="number"?i.version=o.longs===String?String(t.version):t.version:i.version=o.longs===String?$util.Long.prototype.toString.call(t.version):o.longs===Number?new $util.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),n}();var onnx=$root,ortGenerated={},flatbuffers={};flatbuffers.Offset;flatbuffers.Table;flatbuffers.SIZEOF_SHORT=2;flatbuffers.SIZEOF_INT=4;flatbuffers.FILE_IDENTIFIER_LENGTH=4;flatbuffers.SIZE_PREFIX_LENGTH=4;flatbuffers.Encoding={UTF8_BYTES:1,UTF16_STRING:2};flatbuffers.int32=new Int32Array(2);flatbuffers.float32=new Float32Array(flatbuffers.int32.buffer);flatbuffers.float64=new Float64Array(flatbuffers.int32.buffer);flatbuffers.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;flatbuffers.Long=function(n,e){this.low=n|0,this.high=e|0};flatbuffers.Long.create=function(n,e){return n==0&&e==0?flatbuffers.Long.ZERO:new flatbuffers.Long(n,e)};flatbuffers.Long.prototype.toFloat64=function(){return(this.low>>>0)+this.high*4294967296};flatbuffers.Long.prototype.equals=function(n){return this.low==n.low&&this.high==n.high};flatbuffers.Long.ZERO=new flatbuffers.Long(0,0);flatbuffers.Builder=function(n){if(n)var e=n;else var e=1024;this.bb=flatbuffers.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1};flatbuffers.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};flatbuffers.Builder.prototype.forceDefaults=function(n){this.force_defaults=n};flatbuffers.Builder.prototype.dataBuffer=function(){return this.bb};flatbuffers.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())};flatbuffers.Builder.prototype.prep=function(n,e){n>this.minalign&&(this.minalign=n);for(var r=~(this.bb.capacity()-this.space+e)+1&n-1;this.space<r+n+e;){var t=this.bb.capacity();this.bb=flatbuffers.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)};flatbuffers.Builder.prototype.pad=function(n){for(var e=0;e<n;e++)this.bb.writeInt8(--this.space,0)};flatbuffers.Builder.prototype.writeInt8=function(n){this.bb.writeInt8(this.space-=1,n)};flatbuffers.Builder.prototype.writeInt16=function(n){this.bb.writeInt16(this.space-=2,n)};flatbuffers.Builder.prototype.writeInt32=function(n){this.bb.writeInt32(this.space-=4,n)};flatbuffers.Builder.prototype.writeInt64=function(n){this.bb.writeInt64(this.space-=8,n)};flatbuffers.Builder.prototype.writeFloat32=function(n){this.bb.writeFloat32(this.space-=4,n)};flatbuffers.Builder.prototype.writeFloat64=function(n){this.bb.writeFloat64(this.space-=8,n)};flatbuffers.Builder.prototype.addInt8=function(n){this.prep(1,0),this.writeInt8(n)};flatbuffers.Builder.prototype.addInt16=function(n){this.prep(2,0),this.writeInt16(n)};flatbuffers.Builder.prototype.addInt32=function(n){this.prep(4,0),this.writeInt32(n)};flatbuffers.Builder.prototype.addInt64=function(n){this.prep(8,0),this.writeInt64(n)};flatbuffers.Builder.prototype.addFloat32=function(n){this.prep(4,0),this.writeFloat32(n)};flatbuffers.Builder.prototype.addFloat64=function(n){this.prep(8,0),this.writeFloat64(n)};flatbuffers.Builder.prototype.addFieldInt8=function(n,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldInt16=function(n,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldInt32=function(n,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldInt64=function(n,e,r){(this.force_defaults||!e.equals(r))&&(this.addInt64(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldFloat32=function(n,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldFloat64=function(n,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldOffset=function(n,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(n))};flatbuffers.Builder.prototype.addFieldStruct=function(n,e,r){e!=r&&(this.nested(e),this.slot(n))};flatbuffers.Builder.prototype.nested=function(n){if(n!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")};flatbuffers.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")};flatbuffers.Builder.prototype.slot=function(n){this.vtable[n]=this.offset()};flatbuffers.Builder.prototype.offset=function(){return this.bb.capacity()-this.space};flatbuffers.Builder.growByteBuffer=function(n){var e=n.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var r=e<<1,t=flatbuffers.ByteBuffer.allocate(r);return t.setPosition(r-e),t.bytes().set(n.bytes(),r-e),t};flatbuffers.Builder.prototype.addOffset=function(n){this.prep(flatbuffers.SIZEOF_INT,0),this.writeInt32(this.offset()-n+flatbuffers.SIZEOF_INT)};flatbuffers.Builder.prototype.startObject=function(n){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=n;for(var e=0;e<n;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()};flatbuffers.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var n=this.offset(),e=this.vtable_in_use-1;e>=0&&this.vtable[e]==0;e--);for(var r=e+1;e>=0;e--)this.addInt16(this.vtable[e]!=0?n-this.vtable[e]:0);var t=2;this.addInt16(n-this.object_start);var o=(r+t)*flatbuffers.SIZEOF_SHORT;this.addInt16(o);var i=0,l=this.space;e:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(o==this.bb.readInt16(a)){for(var s=flatbuffers.SIZEOF_SHORT;s<o;s+=flatbuffers.SIZEOF_SHORT)if(this.bb.readInt16(l+s)!=this.bb.readInt16(a+s))continue e;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-n,this.bb.writeInt32(this.space,i-n)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-n,this.offset()-n)),this.isNested=!1,n};flatbuffers.Builder.prototype.finish=function(n,e,r){var t=r?flatbuffers.SIZE_PREFIX_LENGTH:0;if(e){var o=e;if(this.prep(this.minalign,flatbuffers.SIZEOF_INT+flatbuffers.FILE_IDENTIFIER_LENGTH+t),o.length!=flatbuffers.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+flatbuffers.FILE_IDENTIFIER_LENGTH);for(var i=flatbuffers.FILE_IDENTIFIER_LENGTH-1;i>=0;i--)this.writeInt8(o.charCodeAt(i))}this.prep(this.minalign,flatbuffers.SIZEOF_INT+t),this.addOffset(n),t&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)};flatbuffers.Builder.prototype.finishSizePrefixed=function(n,e){this.finish(n,e,!0)};flatbuffers.Builder.prototype.requiredField=function(n,e){var r=this.bb.capacity()-n,t=r-this.bb.readInt32(r),o=this.bb.readInt16(t+e)!=0;if(!o)throw new Error("FlatBuffers: field "+e+" must be set")};flatbuffers.Builder.prototype.startVector=function(n,e,r){this.notNested(),this.vector_num_elems=e,this.prep(flatbuffers.SIZEOF_INT,n*e),this.prep(r,n*e)};flatbuffers.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()};flatbuffers.Builder.prototype.createString=function(n){if(n instanceof Uint8Array)var e=n;else for(var e=[],r=0;r<n.length;){var t,o=n.charCodeAt(r++);if(o<55296||o>=56320)t=o;else{var i=n.charCodeAt(r++);t=(o<<10)+i+(65536-(55296<<10)-56320)}t<128?e.push(t):(t<2048?e.push(t>>6&31|192):(t<65536?e.push(t>>12&15|224):e.push(t>>18&7|240,t>>12&63|128),e.push(t>>6&63|128)),e.push(t&63|128))}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(var r=0,l=this.space,a=this.bb.bytes();r<e.length;r++)a[l++]=e[r];return this.endVector()};flatbuffers.Builder.prototype.createLong=function(n,e){return flatbuffers.Long.create(n,e)};flatbuffers.ByteBuffer=function(n){this.bytes_=n,this.position_=0};flatbuffers.ByteBuffer.allocate=function(n){return new flatbuffers.ByteBuffer(new Uint8Array(n))};flatbuffers.ByteBuffer.prototype.clear=function(){this.position_=0};flatbuffers.ByteBuffer.prototype.bytes=function(){return this.bytes_};flatbuffers.ByteBuffer.prototype.position=function(){return this.position_};flatbuffers.ByteBuffer.prototype.setPosition=function(n){this.position_=n};flatbuffers.ByteBuffer.prototype.capacity=function(){return this.bytes_.length};flatbuffers.ByteBuffer.prototype.readInt8=function(n){return this.readUint8(n)<<24>>24};flatbuffers.ByteBuffer.prototype.readUint8=function(n){return this.bytes_[n]};flatbuffers.ByteBuffer.prototype.readInt16=function(n){return this.readUint16(n)<<16>>16};flatbuffers.ByteBuffer.prototype.readUint16=function(n){return this.bytes_[n]|this.bytes_[n+1]<<8};flatbuffers.ByteBuffer.prototype.readInt32=function(n){return this.bytes_[n]|this.bytes_[n+1]<<8|this.bytes_[n+2]<<16|this.bytes_[n+3]<<24};flatbuffers.ByteBuffer.prototype.readUint32=function(n){return this.readInt32(n)>>>0};flatbuffers.ByteBuffer.prototype.readInt64=function(n){return new flatbuffers.Long(this.readInt32(n),this.readInt32(n+4))};flatbuffers.ByteBuffer.prototype.readUint64=function(n){return new flatbuffers.Long(this.readUint32(n),this.readUint32(n+4))};flatbuffers.ByteBuffer.prototype.readFloat32=function(n){return flatbuffers.int32[0]=this.readInt32(n),flatbuffers.float32[0]};flatbuffers.ByteBuffer.prototype.readFloat64=function(n){return flatbuffers.int32[flatbuffers.isLittleEndian?0:1]=this.readInt32(n),flatbuffers.int32[flatbuffers.isLittleEndian?1:0]=this.readInt32(n+4),flatbuffers.float64[0]};flatbuffers.ByteBuffer.prototype.writeInt8=function(n,e){this.bytes_[n]=e};flatbuffers.ByteBuffer.prototype.writeUint8=function(n,e){this.bytes_[n]=e};flatbuffers.ByteBuffer.prototype.writeInt16=function(n,e){this.bytes_[n]=e,this.bytes_[n+1]=e>>8};flatbuffers.ByteBuffer.prototype.writeUint16=function(n,e){this.bytes_[n]=e,this.bytes_[n+1]=e>>8};flatbuffers.ByteBuffer.prototype.writeInt32=function(n,e){this.bytes_[n]=e,this.bytes_[n+1]=e>>8,this.bytes_[n+2]=e>>16,this.bytes_[n+3]=e>>24};flatbuffers.ByteBuffer.prototype.writeUint32=function(n,e){this.bytes_[n]=e,this.bytes_[n+1]=e>>8,this.bytes_[n+2]=e>>16,this.bytes_[n+3]=e>>24};flatbuffers.ByteBuffer.prototype.writeInt64=function(n,e){this.writeInt32(n,e.low),this.writeInt32(n+4,e.high)};flatbuffers.ByteBuffer.prototype.writeUint64=function(n,e){this.writeUint32(n,e.low),this.writeUint32(n+4,e.high)};flatbuffers.ByteBuffer.prototype.writeFloat32=function(n,e){flatbuffers.float32[0]=e,this.writeInt32(n,flatbuffers.int32[0])};flatbuffers.ByteBuffer.prototype.writeFloat64=function(n,e){flatbuffers.float64[0]=e,this.writeInt32(n,flatbuffers.int32[flatbuffers.isLittleEndian?0:1]),this.writeInt32(n+4,flatbuffers.int32[flatbuffers.isLittleEndian?1:0])};flatbuffers.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+flatbuffers.SIZEOF_INT+flatbuffers.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var n="",e=0;e<flatbuffers.FILE_IDENTIFIER_LENGTH;e++)n+=String.fromCharCode(this.readInt8(this.position_+flatbuffers.SIZEOF_INT+e));return n};flatbuffers.ByteBuffer.prototype.__offset=function(n,e){var r=n-this.readInt32(n);return e<this.readInt16(r)?this.readInt16(r+e):0};flatbuffers.ByteBuffer.prototype.__union=function(n,e){return n.bb_pos=e+this.readInt32(e),n.bb=this,n};flatbuffers.ByteBuffer.prototype.__string=function(n,e){n+=this.readInt32(n);var r=this.readInt32(n),t="",o=0;if(n+=flatbuffers.SIZEOF_INT,e===flatbuffers.Encoding.UTF8_BYTES)return this.bytes_.subarray(n,n+r);for(;o<r;){var i,l=this.readUint8(n+o++);if(l<192)i=l;else{var a=this.readUint8(n+o++);if(l<224)i=(l&31)<<6|a&63;else{var s=this.readUint8(n+o++);if(l<240)i=(l&15)<<12|(a&63)<<6|s&63;else{var u=this.readUint8(n+o++);i=(l&7)<<18|(a&63)<<12|(s&63)<<6|u&63}}}i<65536?t+=String.fromCharCode(i):(i-=65536,t+=String.fromCharCode((i>>10)+55296,(i&(1<<10)-1)+56320))}return t};flatbuffers.ByteBuffer.prototype.__indirect=function(n){return n+this.readInt32(n)};flatbuffers.ByteBuffer.prototype.__vector=function(n){return n+this.readInt32(n)+flatbuffers.SIZEOF_INT};flatbuffers.ByteBuffer.prototype.__vector_len=function(n){return this.readInt32(n+this.readInt32(n))};flatbuffers.ByteBuffer.prototype.__has_identifier=function(n){if(n.length!=flatbuffers.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+flatbuffers.FILE_IDENTIFIER_LENGTH);for(var e=0;e<flatbuffers.FILE_IDENTIFIER_LENGTH;e++)if(n.charCodeAt(e)!=this.readInt8(this.position_+flatbuffers.SIZEOF_INT+e))return!1;return!0};flatbuffers.ByteBuffer.prototype.createLong=function(n,e){return flatbuffers.Long.create(n,e)};var flatbuffers$1=Object.freeze(Object.defineProperty({__proto__:null,flatbuffers},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(flatbuffers$1);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.onnxruntime=void 0;const e=require$$0;(function(r){(function(t){(function(o){(function(i){i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.INT=2]="INT",i[i.STRING=3]="STRING",i[i.TENSOR=4]="TENSOR",i[i.GRAPH=5]="GRAPH",i[i.FLOATS=6]="FLOATS",i[i.INTS=7]="INTS",i[i.STRINGS=8]="STRINGS",i[i.TENSORS=9]="TENSORS",i[i.GRAPHS=10]="GRAPHS",i[i.SPARSE_TENSOR=11]="SPARSE_TENSOR",i[i.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(o.AttributeType||(o.AttributeType={}))})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))})(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){(function(i){i[i.UNKNOWN=0]="UNKNOWN",i[i.VALUE=1]="VALUE",i[i.PARAM=2]="PARAM"})(o.DimensionValueType||(o.DimensionValueType={}))})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){(function(i){i[i.UNDEFINED=0]="UNDEFINED",i[i.FLOAT=1]="FLOAT",i[i.UINT8=2]="UINT8",i[i.INT8=3]="INT8",i[i.UINT16=4]="UINT16",i[i.INT16=5]="INT16",i[i.INT32=6]="INT32",i[i.INT64=7]="INT64",i[i.STRING=8]="STRING",i[i.BOOL=9]="BOOL",i[i.FLOAT16=10]="FLOAT16",i[i.DOUBLE=11]="DOUBLE",i[i.UINT32=12]="UINT32",i[i.UINT64=13]="UINT64",i[i.COMPLEX64=14]="COMPLEX64",i[i.COMPLEX128=15]="COMPLEX128",i[i.BFLOAT16=16]="BFLOAT16"})(o.TensorDataType||(o.TensorDataType={}))})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){(function(i){i[i.Primitive=0]="Primitive",i[i.Fused=1]="Fused"})(o.NodeType||(o.NodeType={}))})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){(function(i){i[i.NONE=0]="NONE",i[i.tensor_type=1]="tensor_type",i[i.sequence_type=2]="sequence_type",i[i.map_type=3]="map_type"})(o.TypeInfoValue||(o.TypeInfoValue={}))})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsShape(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsShape(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}dim(a,s){let u=this.bb.__offset(this.bb_pos,4);return u?(s||new r.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}dimLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}static startShape(a){a.startObject(1)}static addDim(a,s){a.addFieldOffset(0,s,0)}static createDimVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startDimVector(a,s){a.startVector(4,s,4)}static endShape(a){return a.endObject()}static createShape(a,s){return i.startShape(a),i.addDim(a,s),i.endShape(a)}}o.Shape=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsDimension(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimension(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}value(a){let s=this.bb.__offset(this.bb_pos,4);return s?(a||new r.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}denotation(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,a):null}static startDimension(a){a.startObject(2)}static addValue(a,s){a.addFieldOffset(0,s,0)}static addDenotation(a,s){a.addFieldOffset(1,s,0)}static endDimension(a){return a.endObject()}static createDimension(a,s,u){return i.startDimension(a),i.addValue(a,s),i.addDenotation(a,u),i.endDimension(a)}}o.Dimension=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsDimensionValue(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsDimensionValue(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}dimType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt8(this.bb_pos+a):r.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}dimParam(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,a):null}static startDimensionValue(a){a.startObject(3)}static addDimType(a,s){a.addFieldInt8(0,s,r.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(a,s){a.addFieldInt64(1,s,a.createLong(0,0))}static addDimParam(a,s){a.addFieldOffset(2,s,0)}static endDimensionValue(a){return a.endObject()}static createDimensionValue(a,s,u,c){return i.startDimensionValue(a),i.addDimType(a,s),i.addDimValue(a,u),i.addDimParam(a,c),i.endDimensionValue(a)}}o.DimensionValue=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsTensorTypeAndShape(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensorTypeAndShape(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}elemType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):r.experimental.fbs.TensorDataType.UNDEFINED}shape(a){let s=this.bb.__offset(this.bb_pos,6);return s?(a||new r.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startTensorTypeAndShape(a){a.startObject(2)}static addElemType(a,s){a.addFieldInt32(0,s,r.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(a,s){a.addFieldOffset(1,s,0)}static endTensorTypeAndShape(a){return a.endObject()}static createTensorTypeAndShape(a,s,u){return i.startTensorTypeAndShape(a),i.addElemType(a,s),i.addShape(a,u),i.endTensorTypeAndShape(a)}}o.TensorTypeAndShape=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsMapType(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsMapType(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}keyType(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt32(this.bb_pos+a):r.experimental.fbs.TensorDataType.UNDEFINED}valueType(a){let s=this.bb.__offset(this.bb_pos,6);return s?(a||new r.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startMapType(a){a.startObject(2)}static addKeyType(a,s){a.addFieldInt32(0,s,r.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(a,s){a.addFieldOffset(1,s,0)}static endMapType(a){return a.endObject()}static createMapType(a,s,u){return i.startMapType(a),i.addKeyType(a,s),i.addValueType(a,u),i.endMapType(a)}}o.MapType=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsSequenceType(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSequenceType(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}elemType(a){let s=this.bb.__offset(this.bb_pos,4);return s?(a||new r.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSequenceType(a){a.startObject(1)}static addElemType(a,s){a.addFieldOffset(0,s,0)}static endSequenceType(a){return a.endObject()}static createSequenceType(a,s){return i.startSequenceType(a),i.addElemType(a,s),i.endSequenceType(a)}}o.SequenceType=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,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(a,s,u,c){return a.prep(4,12),a.writeInt32(c),a.writeInt32(u),a.writeInt32(s),a.offset()}}o.EdgeEnd=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsNodeEdge(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNodeEdge(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}nodeIndex(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readUint32(this.bb_pos+a):0}inputEdges(a,s){let u=this.bb.__offset(this.bb_pos,6);return u?(s||new r.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+u)+a*12,this.bb):null}inputEdgesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}outputEdges(a,s){let u=this.bb.__offset(this.bb_pos,8);return u?(s||new r.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+u)+a*12,this.bb):null}outputEdgesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNodeEdge(a){a.startObject(3)}static addNodeIndex(a,s){a.addFieldInt32(0,s,0)}static addInputEdges(a,s){a.addFieldOffset(1,s,0)}static startInputEdgesVector(a,s){a.startVector(12,s,4)}static addOutputEdges(a,s){a.addFieldOffset(2,s,0)}static startOutputEdgesVector(a,s){a.startVector(12,s,4)}static endNodeEdge(a){return a.endObject()}static createNodeEdge(a,s,u,c){return i.startNodeEdge(a),i.addNodeIndex(a,s),i.addInputEdges(a,u),i.addOutputEdges(a,c),i.endNodeEdge(a)}}o.NodeEdge=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsNode(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsNode(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}name(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}docString(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,a):null}domain(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,a):null}sinceVersion(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):0}index(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readUint32(this.bb_pos+a):0}opType(a){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,a):null}type(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.readInt32(this.bb_pos+a):r.experimental.fbs.NodeType.Primitive}executionProviderType(a){let s=this.bb.__offset(this.bb_pos,18);return s?this.bb.__string(this.bb_pos+s,a):null}inputs(a,s){let u=this.bb.__offset(this.bb_pos,20);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,s){let u=this.bb.__offset(this.bb_pos,22);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}attributes(a,s){let u=this.bb.__offset(this.bb_pos,24);return u?(s||new r.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}attributesLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCounts(a){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.readInt32(this.bb.__vector(this.bb_pos+s)+a*4):0}inputArgCountsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}inputArgCountsArray(){let a=this.bb.__offset(this.bb_pos,26);return a?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}implicitInputs(a,s){let u=this.bb.__offset(this.bb_pos,28);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}implicitInputsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startNode(a){a.startObject(13)}static addName(a,s){a.addFieldOffset(0,s,0)}static addDocString(a,s){a.addFieldOffset(1,s,0)}static addDomain(a,s){a.addFieldOffset(2,s,0)}static addSinceVersion(a,s){a.addFieldInt32(3,s,0)}static addIndex(a,s){a.addFieldInt32(4,s,0)}static addOpType(a,s){a.addFieldOffset(5,s,0)}static addType(a,s){a.addFieldInt32(6,s,r.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(a,s){a.addFieldOffset(7,s,0)}static addInputs(a,s){a.addFieldOffset(8,s,0)}static createInputsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startInputsVector(a,s){a.startVector(4,s,4)}static addOutputs(a,s){a.addFieldOffset(9,s,0)}static createOutputsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startOutputsVector(a,s){a.startVector(4,s,4)}static addAttributes(a,s){a.addFieldOffset(10,s,0)}static createAttributesVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startAttributesVector(a,s){a.startVector(4,s,4)}static addInputArgCounts(a,s){a.addFieldOffset(11,s,0)}static createInputArgCountsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addInt32(s[u]);return a.endVector()}static startInputArgCountsVector(a,s){a.startVector(4,s,4)}static addImplicitInputs(a,s){a.addFieldOffset(12,s,0)}static createImplicitInputsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startImplicitInputsVector(a,s){a.startVector(4,s,4)}static endNode(a){return a.endObject()}static createNode(a,s,u,c,f,d,m,_,S,E,$,y,v,A){return i.startNode(a),i.addName(a,s),i.addDocString(a,u),i.addDomain(a,c),i.addSinceVersion(a,f),i.addIndex(a,d),i.addOpType(a,m),i.addType(a,_),i.addExecutionProviderType(a,S),i.addInputs(a,E),i.addOutputs(a,$),i.addAttributes(a,y),i.addInputArgCounts(a,v),i.addImplicitInputs(a,A),i.endNode(a)}}o.Node=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsValueInfo(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsValueInfo(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}name(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}docString(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,a):null}type(a){let s=this.bb.__offset(this.bb_pos,8);return s?(a||new r.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startValueInfo(a){a.startObject(3)}static addName(a,s){a.addFieldOffset(0,s,0)}static addDocString(a,s){a.addFieldOffset(1,s,0)}static addType(a,s){a.addFieldOffset(2,s,0)}static endValueInfo(a){return a.endObject()}static createValueInfo(a,s,u,c){return i.startValueInfo(a),i.addName(a,s),i.addDocString(a,u),i.addType(a,c),i.endValueInfo(a)}}o.ValueInfo=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsTypeInfo(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTypeInfo(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}denotation(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}valueType(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readUint8(this.bb_pos+a):r.experimental.fbs.TypeInfoValue.NONE}value(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__union(a,this.bb_pos+s):null}static startTypeInfo(a){a.startObject(3)}static addDenotation(a,s){a.addFieldOffset(0,s,0)}static addValueType(a,s){a.addFieldInt8(1,s,r.experimental.fbs.TypeInfoValue.NONE)}static addValue(a,s){a.addFieldOffset(2,s,0)}static endTypeInfo(a){return a.endObject()}static createTypeInfo(a,s,u,c){return i.startTypeInfo(a),i.addDenotation(a,s),i.addValueType(a,u),i.addValue(a,c),i.endTypeInfo(a)}}o.TypeInfo=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsOperatorSetId(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsOperatorSetId(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}domain(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}version(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}static startOperatorSetId(a){a.startObject(2)}static addDomain(a,s){a.addFieldOffset(0,s,0)}static addVersion(a,s){a.addFieldInt64(1,s,a.createLong(0,0))}static endOperatorSetId(a){return a.endObject()}static createOperatorSetId(a,s,u){return i.startOperatorSetId(a),i.addDomain(a,s),i.addVersion(a,u),i.endOperatorSetId(a)}}o.OperatorSetId=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsTensor(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsTensor(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}name(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}docString(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,a):null}dims(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+a*8):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}dataType(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readInt32(this.bb_pos+a):r.experimental.fbs.TensorDataType.UNDEFINED}rawData(a){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readUint8(this.bb.__vector(this.bb_pos+s)+a):0}rawDataLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}rawDataArray(){let a=this.bb.__offset(this.bb_pos,12);return a?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}stringData(a,s){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}stringDataLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}static startTensor(a){a.startObject(6)}static addName(a,s){a.addFieldOffset(0,s,0)}static addDocString(a,s){a.addFieldOffset(1,s,0)}static addDims(a,s){a.addFieldOffset(2,s,0)}static createDimsVector(a,s){a.startVector(8,s.length,8);for(let u=s.length-1;u>=0;u--)a.addInt64(s[u]);return a.endVector()}static startDimsVector(a,s){a.startVector(8,s,8)}static addDataType(a,s){a.addFieldInt32(3,s,r.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(a,s){a.addFieldOffset(4,s,0)}static createRawDataVector(a,s){a.startVector(1,s.length,1);for(let u=s.length-1;u>=0;u--)a.addInt8(s[u]);return a.endVector()}static startRawDataVector(a,s){a.startVector(1,s,1)}static addStringData(a,s){a.addFieldOffset(5,s,0)}static createStringDataVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startStringDataVector(a,s){a.startVector(4,s,4)}static endTensor(a){return a.endObject()}static createTensor(a,s,u,c,f,d,m){return i.startTensor(a),i.addName(a,s),i.addDocString(a,u),i.addDims(a,c),i.addDataType(a,f),i.addRawData(a,d),i.addStringData(a,m),i.endTensor(a)}}o.Tensor=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsSparseTensor(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSparseTensor(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}values(a){let s=this.bb.__offset(this.bb_pos,4);return s?(a||new r.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}indices(a){let s=this.bb.__offset(this.bb_pos,6);return s?(a||new r.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}dims(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+a*8):this.bb.createLong(0,0)}dimsLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSparseTensor(a){a.startObject(3)}static addValues(a,s){a.addFieldOffset(0,s,0)}static addIndices(a,s){a.addFieldOffset(1,s,0)}static addDims(a,s){a.addFieldOffset(2,s,0)}static createDimsVector(a,s){a.startVector(8,s.length,8);for(let u=s.length-1;u>=0;u--)a.addInt64(s[u]);return a.endVector()}static startDimsVector(a,s){a.startVector(8,s,8)}static endSparseTensor(a){return a.endObject()}static createSparseTensor(a,s,u,c){return i.startSparseTensor(a),i.addValues(a,s),i.addIndices(a,u),i.addDims(a,c),i.endSparseTensor(a)}}o.SparseTensor=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsAttribute(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsAttribute(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}name(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}docString(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__string(this.bb_pos+s,a):null}type(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.readInt32(this.bb_pos+a):r.experimental.fbs.AttributeType.UNDEFINED}f(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readFloat32(this.bb_pos+a):0}i(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}s(a){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__string(this.bb_pos+s,a):null}t(a){let s=this.bb.__offset(this.bb_pos,16);return s?(a||new r.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}g(a){let s=this.bb.__offset(this.bb_pos,18);return s?(a||new r.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}floats(a){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.readFloat32(this.bb.__vector(this.bb_pos+s)+a*4):0}floatsLength(){let a=this.bb.__offset(this.bb_pos,20);return a?this.bb.__vector_len(this.bb_pos+a):0}floatsArray(){let a=this.bb.__offset(this.bb_pos,20);return a?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}ints(a){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.readInt64(this.bb.__vector(this.bb_pos+s)+a*8):this.bb.createLong(0,0)}intsLength(){let a=this.bb.__offset(this.bb_pos,22);return a?this.bb.__vector_len(this.bb_pos+a):0}strings(a,s){let u=this.bb.__offset(this.bb_pos,24);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}stringsLength(){let a=this.bb.__offset(this.bb_pos,24);return a?this.bb.__vector_len(this.bb_pos+a):0}tensors(a,s){let u=this.bb.__offset(this.bb_pos,26);return u?(s||new r.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}tensorsLength(){let a=this.bb.__offset(this.bb_pos,26);return a?this.bb.__vector_len(this.bb_pos+a):0}graphs(a,s){let u=this.bb.__offset(this.bb_pos,28);return u?(s||new r.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}graphsLength(){let a=this.bb.__offset(this.bb_pos,28);return a?this.bb.__vector_len(this.bb_pos+a):0}static startAttribute(a){a.startObject(13)}static addName(a,s){a.addFieldOffset(0,s,0)}static addDocString(a,s){a.addFieldOffset(1,s,0)}static addType(a,s){a.addFieldInt32(2,s,r.experimental.fbs.AttributeType.UNDEFINED)}static addF(a,s){a.addFieldFloat32(3,s,0)}static addI(a,s){a.addFieldInt64(4,s,a.createLong(0,0))}static addS(a,s){a.addFieldOffset(5,s,0)}static addT(a,s){a.addFieldOffset(6,s,0)}static addG(a,s){a.addFieldOffset(7,s,0)}static addFloats(a,s){a.addFieldOffset(8,s,0)}static createFloatsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addFloat32(s[u]);return a.endVector()}static startFloatsVector(a,s){a.startVector(4,s,4)}static addInts(a,s){a.addFieldOffset(9,s,0)}static createIntsVector(a,s){a.startVector(8,s.length,8);for(let u=s.length-1;u>=0;u--)a.addInt64(s[u]);return a.endVector()}static startIntsVector(a,s){a.startVector(8,s,8)}static addStrings(a,s){a.addFieldOffset(10,s,0)}static createStringsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startStringsVector(a,s){a.startVector(4,s,4)}static addTensors(a,s){a.addFieldOffset(11,s,0)}static createTensorsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startTensorsVector(a,s){a.startVector(4,s,4)}static addGraphs(a,s){a.addFieldOffset(12,s,0)}static createGraphsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startGraphsVector(a,s){a.startVector(4,s,4)}static endAttribute(a){return a.endObject()}static createAttribute(a,s,u,c,f,d,m,_,S,E,$,y,v,A){return i.startAttribute(a),i.addName(a,s),i.addDocString(a,u),i.addType(a,c),i.addF(a,f),i.addI(a,d),i.addS(a,m),i.addT(a,_),i.addG(a,S),i.addFloats(a,E),i.addInts(a,$),i.addStrings(a,y),i.addTensors(a,v),i.addGraphs(a,A),i.endAttribute(a)}}o.Attribute=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsGraph(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsGraph(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}initializers(a,s){let u=this.bb.__offset(this.bb_pos,4);return u?(s||new r.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}initializersLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeArgs(a,s){let u=this.bb.__offset(this.bb_pos,6);return u?(s||new r.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}nodeArgsLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}nodes(a,s){let u=this.bb.__offset(this.bb_pos,8);return u?(s||new r.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}nodesLength(){let a=this.bb.__offset(this.bb_pos,8);return a?this.bb.__vector_len(this.bb_pos+a):0}maxNodeIndex(){let a=this.bb.__offset(this.bb_pos,10);return a?this.bb.readUint32(this.bb_pos+a):0}nodeEdges(a,s){let u=this.bb.__offset(this.bb_pos,12);return u?(s||new r.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}nodeEdgesLength(){let a=this.bb.__offset(this.bb_pos,12);return a?this.bb.__vector_len(this.bb_pos+a):0}inputs(a,s){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}inputsLength(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.__vector_len(this.bb_pos+a):0}outputs(a,s){let u=this.bb.__offset(this.bb_pos,16);return u?this.bb.__string(this.bb.__vector(this.bb_pos+u)+a*4,s):null}outputsLength(){let a=this.bb.__offset(this.bb_pos,16);return a?this.bb.__vector_len(this.bb_pos+a):0}sparseInitializers(a,s){let u=this.bb.__offset(this.bb_pos,18);return u?(s||new r.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}sparseInitializersLength(){let a=this.bb.__offset(this.bb_pos,18);return a?this.bb.__vector_len(this.bb_pos+a):0}static startGraph(a){a.startObject(8)}static addInitializers(a,s){a.addFieldOffset(0,s,0)}static createInitializersVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startInitializersVector(a,s){a.startVector(4,s,4)}static addNodeArgs(a,s){a.addFieldOffset(1,s,0)}static createNodeArgsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startNodeArgsVector(a,s){a.startVector(4,s,4)}static addNodes(a,s){a.addFieldOffset(2,s,0)}static createNodesVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startNodesVector(a,s){a.startVector(4,s,4)}static addMaxNodeIndex(a,s){a.addFieldInt32(3,s,0)}static addNodeEdges(a,s){a.addFieldOffset(4,s,0)}static createNodeEdgesVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startNodeEdgesVector(a,s){a.startVector(4,s,4)}static addInputs(a,s){a.addFieldOffset(5,s,0)}static createInputsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startInputsVector(a,s){a.startVector(4,s,4)}static addOutputs(a,s){a.addFieldOffset(6,s,0)}static createOutputsVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startOutputsVector(a,s){a.startVector(4,s,4)}static addSparseInitializers(a,s){a.addFieldOffset(7,s,0)}static createSparseInitializersVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startSparseInitializersVector(a,s){a.startVector(4,s,4)}static endGraph(a){return a.endObject()}static createGraph(a,s,u,c,f,d,m,_,S){return i.startGraph(a),i.addInitializers(a,s),i.addNodeArgs(a,u),i.addNodes(a,c),i.addMaxNodeIndex(a,f),i.addNodeEdges(a,d),i.addInputs(a,m),i.addOutputs(a,_),i.addSparseInitializers(a,S),i.endGraph(a)}}o.Graph=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsModel(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsModel(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}irVersion(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}opsetImport(a,s){let u=this.bb.__offset(this.bb_pos,6);return u?(s||new r.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}opsetImportLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}producerName(a){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__string(this.bb_pos+s,a):null}producerVersion(a){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.__string(this.bb_pos+s,a):null}domain(a){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__string(this.bb_pos+s,a):null}modelVersion(){let a=this.bb.__offset(this.bb_pos,14);return a?this.bb.readInt64(this.bb_pos+a):this.bb.createLong(0,0)}docString(a){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.__string(this.bb_pos+s,a):null}graph(a){let s=this.bb.__offset(this.bb_pos,18);return s?(a||new r.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}graphDocString(a){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__string(this.bb_pos+s,a):null}static startModel(a){a.startObject(9)}static addIrVersion(a,s){a.addFieldInt64(0,s,a.createLong(0,0))}static addOpsetImport(a,s){a.addFieldOffset(1,s,0)}static createOpsetImportVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startOpsetImportVector(a,s){a.startVector(4,s,4)}static addProducerName(a,s){a.addFieldOffset(2,s,0)}static addProducerVersion(a,s){a.addFieldOffset(3,s,0)}static addDomain(a,s){a.addFieldOffset(4,s,0)}static addModelVersion(a,s){a.addFieldInt64(5,s,a.createLong(0,0))}static addDocString(a,s){a.addFieldOffset(6,s,0)}static addGraph(a,s){a.addFieldOffset(7,s,0)}static addGraphDocString(a,s){a.addFieldOffset(8,s,0)}static endModel(a){return a.endObject()}static createModel(a,s,u,c,f,d,m,_,S,E){return i.startModel(a),i.addIrVersion(a,s),i.addOpsetImport(a,u),i.addProducerName(a,c),i.addProducerVersion(a,f),i.addDomain(a,d),i.addModelVersion(a,m),i.addDocString(a,_),i.addGraph(a,S),i.addGraphDocString(a,E),i.endModel(a)}}o.Model=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsKernelCreateInfos(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsKernelCreateInfos(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}nodeIndices(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readUint32(this.bb.__vector(this.bb_pos+s)+a*4):0}nodeIndicesLength(){let a=this.bb.__offset(this.bb_pos,4);return a?this.bb.__vector_len(this.bb_pos+a):0}nodeIndicesArray(){let a=this.bb.__offset(this.bb_pos,4);return a?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+a),this.bb.__vector_len(this.bb_pos+a)):null}kernelDefHashes(a){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readUint64(this.bb.__vector(this.bb_pos+s)+a*8):this.bb.createLong(0,0)}kernelDefHashesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startKernelCreateInfos(a){a.startObject(2)}static addNodeIndices(a,s){a.addFieldOffset(0,s,0)}static createNodeIndicesVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addInt32(s[u]);return a.endVector()}static startNodeIndicesVector(a,s){a.startVector(4,s,4)}static addKernelDefHashes(a,s){a.addFieldOffset(1,s,0)}static createKernelDefHashesVector(a,s){a.startVector(8,s.length,8);for(let u=s.length-1;u>=0;u--)a.addInt64(s[u]);return a.endVector()}static startKernelDefHashesVector(a,s){a.startVector(8,s,8)}static endKernelCreateInfos(a){return a.endObject()}static createKernelCreateInfos(a,s,u){return i.startKernelCreateInfos(a),i.addNodeIndices(a,s),i.addKernelDefHashes(a,u),i.endKernelCreateInfos(a)}}o.KernelCreateInfos=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsSubGraphSessionState(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSubGraphSessionState(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}graphId(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}sessionState(a){let s=this.bb.__offset(this.bb_pos,6);return s?(a||new r.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startSubGraphSessionState(a){a.startObject(2)}static addGraphId(a,s){a.addFieldOffset(0,s,0)}static addSessionState(a,s){a.addFieldOffset(1,s,0)}static endSubGraphSessionState(a){let s=a.endObject();return a.requiredField(s,4),s}static createSubGraphSessionState(a,s,u){return i.startSubGraphSessionState(a),i.addGraphId(a,s),i.addSessionState(a,u),i.endSubGraphSessionState(a)}}o.SubGraphSessionState=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsSessionState(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsSessionState(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}kernels(a){let s=this.bb.__offset(this.bb_pos,4);return s?(a||new r.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}subGraphSessionStates(a,s){let u=this.bb.__offset(this.bb_pos,6);return u?(s||new r.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+u)+a*4),this.bb):null}subGraphSessionStatesLength(){let a=this.bb.__offset(this.bb_pos,6);return a?this.bb.__vector_len(this.bb_pos+a):0}static startSessionState(a){a.startObject(2)}static addKernels(a,s){a.addFieldOffset(0,s,0)}static addSubGraphSessionStates(a,s){a.addFieldOffset(1,s,0)}static createSubGraphSessionStatesVector(a,s){a.startVector(4,s.length,4);for(let u=s.length-1;u>=0;u--)a.addOffset(s[u]);return a.endVector()}static startSubGraphSessionStatesVector(a,s){a.startVector(4,s,4)}static endSessionState(a){return a.endObject()}static createSessionState(a,s,u){return i.startSessionState(a),i.addKernels(a,s),i.addSubGraphSessionStates(a,u),i.endSessionState(a)}}o.SessionState=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={})),function(r){(function(t){(function(o){class i{constructor(){this.bb=null,this.bb_pos=0}__init(a,s){return this.bb_pos=a,this.bb=s,this}static getRootAsInferenceSession(a,s){return(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static getSizePrefixedRootAsInferenceSession(a,s){return a.setPosition(a.position()+e.flatbuffers.SIZE_PREFIX_LENGTH),(s||new i).__init(a.readInt32(a.position())+a.position(),a)}static bufferHasIdentifier(a){return a.__has_identifier("ORTM")}ortVersion(a){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__string(this.bb_pos+s,a):null}model(a){let s=this.bb.__offset(this.bb_pos,6);return s?(a||new r.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}sessionState(a){let s=this.bb.__offset(this.bb_pos,8);return s?(a||new r.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+s),this.bb):null}static startInferenceSession(a){a.startObject(3)}static addOrtVersion(a,s){a.addFieldOffset(0,s,0)}static addModel(a,s){a.addFieldOffset(1,s,0)}static addSessionState(a,s){a.addFieldOffset(2,s,0)}static endInferenceSession(a){return a.endObject()}static finishInferenceSessionBuffer(a,s){a.finish(s,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(a,s){a.finish(s,"ORTM",!0)}static createInferenceSession(a,s,u,c){return i.startInferenceSession(a),i.addOrtVersion(a,s),i.addModel(a,u),i.addSessionState(a,c),i.endInferenceSession(a)}}o.InferenceSession=i})(t.fbs||(t.fbs={}))})(r.experimental||(r.experimental={}))}(n.onnxruntime||(n.onnxruntime={}))})(ortGenerated);var util={},__importDefault$2=commonjsGlobal$1&&commonjsGlobal$1.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(util,"__esModule",{value:!0});util.decodeUtf8String=util.MAX_CLIP=util.MIN_CLIP=util.PoolConvUtil=util.ReduceUtil=util.SplitUtil=util.MathUtil=util.ShapeUtil=util.LongUtil=util.ProtoUtil=util.GemmUtil=util.arrayCopyHelper=util.BroadcastUtil=util.MatMulUtil=util.ArrayUtil=util.assert=util.checkInputsShape=void 0;const flatbuffers_1$1=require$$0,long_1$1=__importDefault$2(long),onnx_proto_1$4=onnx,tensor_1$5=tensor;function checkInputsShape(n,...e){if(!n||n.length!==e.length)return!1;for(let r=0;r<n.length;r++)if(!n[r].dims||n[r].dims.length!==e[r])return!1;return!0}util.checkInputsShape=checkInputsShape;function assert(n,e){if(!n)throw new Error(typeof e=="string"?e:e())}util.assert=assert;class ArrayUtil{static arraysEqual(e,r){if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}}util.ArrayUtil=ArrayUtil;class MatMulUtil{static preprocessInputShapes(e,r){const t=e.length===1?[1,e[0]]:e,o=r.length===1?[r[0],1]:r;return[t,o]}static postprocessOutputShape(e,r,t){r===1&&e.splice(e.length-2,1),t===1&&e.pop()}static calcMatMulShape(e,r){return e[1]!==r[0]?void 0:[e[0],r[1]]}}util.MatMulUtil=MatMulUtil;class BroadcastUtil{static calcShape(e,r,t=!1){const o=e.length,i=r.length;if(o===0)return r;if(i===0)return e;const l=Math.max(e.length,r.length),a=new Array(l);if(t){if(o<2||i<2)return;const s=MatMulUtil.calcMatMulShape([e[o-2],e[o-1]],[r[i-2],r[i-1]]);if(s===void 0)return;[a[l-2],a[l-1]]=s}for(let s=t?3:1;s<=l;s++){const u=o-s<0?1:e[o-s],c=i-s<0?1:r[i-s];if(u!==c&&u>1&&c>1)return;a[l-s]=Math.max(u,c)}return a}static index(e,r){const t=new Array(r.length);return BroadcastUtil.fillIndex(e,r,t),t}static fillIndex(e,r,t){const o=e.length-r.length;for(let i=0;i<r.length;i++)t[i]=e[o+i]%r[i]}static calc(e,r,t,o,i){const l=BroadcastUtil.calcShape(e.dims,r.dims);if(l){if(o&&!ShapeUtil.areEqual(l,e.dims))return;const a=ShapeUtil.size(l),s=o?e:new tensor_1$5.Tensor(l,i||e.type);if(l.length===0)s.set([],t(e.get([]),r.get([])));else{const u=new Array(l.length),c=new Array(e.dims.length),f=new Array(r.dims.length);let d=0,m=0,_=!1,S=!1;e.dims.length===0&&(d=e.get([]),_=!0),r.dims.length===0&&(m=r.get([]),S=!0);let E;for(let $=0;$<a;$++){E=$;for(let y=l.length-1;y>=0;y--)u[y]=E%l[y],E=Math.floor(E/l[y]);_||(BroadcastUtil.fillIndex(u,e.dims,c),d=e.get(c)),S||(BroadcastUtil.fillIndex(u,r.dims,f),m=r.get(f)),s.set(u,t(d,m))}}return s}}static isValidBroadcast(e,r){const t=e.length,o=r.length;if(t>o)return!1;for(let i=1;i<=t;i++)if(e[t-i]!==1&&e[t-i]!==r[o-i])return!1;return!0}static getBroadcastDims(e,r){const t=e.length,o=[];for(let i=0;i<t;i++){const l=t-1-i,a=e[l]||1;(r[r.length-1-i]||1)>1&&a===1&&o.unshift(l)}return o}}util.BroadcastUtil=BroadcastUtil;function arrayCopyHelper(n,e,r,t,o){if(t<0||t>=e.length)throw new Error("sourceIndex out of bounds");if(r<0||r>=n.length)throw new Error("targetIndex out of bounds");if(t+o>e.length)throw new Error("source indices to be copied are outside bounds");if(r+o>n.length)throw new Error("target array is too small to hold result");for(let i=0;i<o;i++)n[r+i]=e[t+i]}util.arrayCopyHelper=arrayCopyHelper;class GemmUtil{static getShapeOfGemmResult(e,r,t,o,i){if(e.length!==2||t.length!==2)throw new Error("shape need to be of size 2");let l,a,s;r?(l=e[1],a=e[0]):(l=e[0],a=e[1]);let u=-1;if(o?(s=t[0],u=1):(s=t[1],u=0),t[u]!==a)throw new Error("dimension mismatch");if(l<=0||s<=0||a<=0)throw new Error("invalid shape specified");if(i&&!BroadcastUtil.isValidBroadcast(i,[l,s]))throw new Error("gemm: invalid bias shape for broadcast");return[l,s,a]}}util.GemmUtil=GemmUtil;class ProtoUtil{static tensorDataTypeFromProto(e){switch(e){case onnx_proto_1$4.onnx.TensorProto.DataType.INT8:return"int8";case onnx_proto_1$4.onnx.TensorProto.DataType.UINT8:return"uint8";case onnx_proto_1$4.onnx.TensorProto.DataType.BOOL:return"bool";case onnx_proto_1$4.onnx.TensorProto.DataType.INT16:return"int16";case onnx_proto_1$4.onnx.TensorProto.DataType.UINT16:return"uint16";case onnx_proto_1$4.onnx.TensorProto.DataType.INT32:return"int32";case onnx_proto_1$4.onnx.TensorProto.DataType.UINT32:return"uint32";case onnx_proto_1$4.onnx.TensorProto.DataType.FLOAT:return"float32";case onnx_proto_1$4.onnx.TensorProto.DataType.DOUBLE:return"float64";case onnx_proto_1$4.onnx.TensorProto.DataType.STRING:return"string";case onnx_proto_1$4.onnx.TensorProto.DataType.INT64:return"int32";case onnx_proto_1$4.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${onnx_proto_1$4.onnx.TensorProto.DataType[e]}`)}}static tensorDataTypeStringToEnum(e){switch(e){case"int8":return onnx_proto_1$4.onnx.TensorProto.DataType.INT8;case"uint8":return onnx_proto_1$4.onnx.TensorProto.DataType.UINT8;case"bool":return onnx_proto_1$4.onnx.TensorProto.DataType.BOOL;case"int16":return onnx_proto_1$4.onnx.TensorProto.DataType.INT16;case"uint16":return onnx_proto_1$4.onnx.TensorProto.DataType.UINT16;case"int32":return onnx_proto_1$4.onnx.TensorProto.DataType.INT32;case"uint32":return onnx_proto_1$4.onnx.TensorProto.DataType.UINT32;case"float32":return onnx_proto_1$4.onnx.TensorProto.DataType.FLOAT;case"float64":return onnx_proto_1$4.onnx.TensorProto.DataType.DOUBLE;case"string":return onnx_proto_1$4.onnx.TensorProto.DataType.STRING;case"int64":return onnx_proto_1$4.onnx.TensorProto.DataType.INT64;case"uint64":return onnx_proto_1$4.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${e}`)}}static tensorDimsFromProto(e){return e.map(r=>long_1$1.default.isLong(r)?r.toNumber():r)}static tensorValueTypeFromProto(e){return{tensorType:ProtoUtil.tensorDataTypeFromProto(e.elemType),shape:{dims:ProtoUtil.tensorDimsFromProto(e.shape.dim.map(r=>r.dimValue))}}}static tensorDimsFromORTFormat(e){const r=[];for(let t=0;t<e.dimsLength();t++)r.push(LongUtil.longToNumber(e.dims(t)));return r}static tensorAttributesFromORTFormat(e){const r=[];for(let t=0;t<e.attributesLength();t++)r.push(e.attributes(t));return r}}util.ProtoUtil=ProtoUtil;class LongUtil{static longToNumber(e,r){return long_1$1.default.isLong(e)?e.toNumber():e instanceof flatbuffers_1$1.flatbuffers.Long?long_1$1.default.fromValue({low:e.low,high:e.high,unsigned:r!=null?r:!1}).toNumber():e}static isLong(e){return long_1$1.default.isLong(e)||e instanceof flatbuffers_1$1.flatbuffers.Long}}util.LongUtil=LongUtil;class ShapeUtil{static size(e){return ShapeUtil.getSizeFromDimensionRange(e,0,e.length)}static sizeFromDimension(e,r){if(r<0||r>e.length)throw new Error(`invalid dimension of ${r} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return ShapeUtil.getSizeFromDimensionRange(e,r,e.length)}static sizeToDimension(e,r){if(r<0||r>e.length)throw new Error(`invalid dimension of ${r} for sizeToDimension as Tensor has ${e.length} dimensions.`);return ShapeUtil.getSizeFromDimensionRange(e,0,r)}static getSizeFromDimensionRange(e,r,t){let o=1;for(let i=r;i<t;i++){if(e[i]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");o*=e[i]}return o}static computeStrides(e){const r=e.length;if(r===0)return[];if(r===1)return[1];const t=new Array(r);t[r-1]=1,t[r-2]=e[r-1];for(let o=r-3;o>=0;--o)t[o]=t[o+1]*e[o+1];return t}static transpose(e){return e.slice().reverse()}static indicesToOffset(e,r,t){t===void 0&&(t=e.length);let o=0;for(let i=0;i<t;++i)o+=r[i]*e[i];return o}static offsetToIndices(e,r){const t=r.length;if(t===0)return[];if(t===1)return[e*r[0]];const o=new Array(r.length);for(let i=0;i<o.length-1;++i)o[i]=Math.floor(e/r[i]),e-=o[i]*r[i];return o[o.length-1]=e,o}static normalizeAxis(e,r){if(e<-r&&e>=r)throw new Error("unsupported axis for this operation.");return e<0?e+r:e}static normalizeAxes(e,r){return e.map(t=>this.normalizeAxis(t,r))}static incrementIndex(e,r,t){if(r.length===0||e.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(t===void 0)t=r.length;else if(t<=0||t>r.length)throw new Error("Incorrect axis to increment on");for(let o=t-1;o>=0&&(e[o]++,!(e[o]<r[o]));--o)e[o]=0}static calculateReshapedDims(e,r){if(r.length===0){if(e.length===0||ShapeUtil.size(e)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const t=r.length,o=new Array(t);let i=-1,l=1;for(let s=0;s<t;s++){if(r[s]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(r[s]===-1){if(i!==-1)throw new Error("at most one dimension in shape hints can be -1");i=s}else{if(r[s]===0){if(s>=e.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");o[s]=e[s]}else o[s]=r[s];l*=o[s]}}const a=ShapeUtil.size(e);if(i!==-1){if(a%l!==0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${e}] Output shape: [${r}]`);o[i]=a/l}else if(l!==a)throw new Error("reshapedDims and originalDims don't have matching sizes");return o}static sortBasedOnPerm(e,r){return r?r.map(t=>e[t]):e.slice().reverse()}static padShape(e,r){const t=e.length;return e.map((o,i)=>o+r[i]+r[i+t])}static areEqual(e,r){return e.length!==r.length?!1:e.every((t,o)=>t===r[o])}static validateDimsAndCalcSize(e){if(e.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let r=1;for(const t of e){if(!Number.isInteger(t))throw new TypeError(`Invalid shape: ${t} is not an integer`);if(t<0||t>2147483647)throw new TypeError(`Invalid shape: length ${t} is not allowed`);r*=t}return r}static flattenShape(e,r){r<0&&(r+=e.length);const t=e.reduce((l,a)=>l*a,1),o=e.slice(r).reduce((l,a)=>l*a,1);return[t/o,o]}static squeezeShape(e,r){const t=new Array;r=ShapeUtil.normalizeAxes(r,e.length);for(let o=0;o<e.length;o++){const i=r.indexOf(o)>=0;if(i&&e[o]!==1)throw new Error("squeeze an axis of size different than 1");(r.length===0&&e[o]>1||r.length>0&&!i)&&t.push(e[o])}return t}static unsqueezeShape(e,r){const t=new Array(e.length+r.length);t.fill(0);for(let i=0;i<r.length;i++){const l=ShapeUtil.normalizeAxis(r[i],e.length);if(l>=t.length)throw new Error("'axes' has an out of range axis");if(t[l]!==0)throw new Error("'axes' has a duplicate axis");t[l]=1}let o=0;for(let i=0;i<t.length;i++)t[i]===0&&(t[i]=e[o++]);if(o!==e.length)throw new Error("the unsqueezed dimension could not be established");return t}}util.ShapeUtil=ShapeUtil;class MathUtil{static sqr(e,r,t,o,i){if(o<0||o>=r.length)throw new Error("sourceIndex out of bounds");if(t<0||t>=e.length)throw new Error("targetIndex out of bounds");if(o+i>r.length)throw new Error("source indices to be copied are outside bounds");if(t+i>e.length)throw new Error("target array is too small to hold result");for(let l=0;l<i;l++)e[t+l]+=Math.pow(r[o+l],2)}static axpy(e,r,t,o,i,l){if(o<0||o>=r.length)throw new Error("sourceIndex out of bounds");if(t<0||t>=e.length)throw new Error("targetIndex out of bounds");if(o+i>r.length)throw new Error("source indices to be copied are outside bounds");if(t+i>e.length)throw new Error("target array is too small to hold result");for(let a=0;a<i;a++)e[t+a]+=l*r[o+a]}static powx(e,r,t,o,i,l){if(o<0||o>=r.length)throw new Error("sourceIndex out of bounds");if(t<0||t>=e.length)throw new Error("targetIndex out of bounds");if(o+i>r.length)throw new Error("source indices to be copied are outside bounds");if(t+i>e.length)throw new Error("target array is too small to hold result");for(let a=0;a<i;a++)e[t+a]=Math.pow(r[o+a],l)}static mul(e,r,t,o,i){if(o<0||o>=r.length)throw new Error("sourceIndex out of bounds");if(t<0||t>=e.length)throw new Error("targetIndex out of bounds");if(o+i>r.length)throw new Error("source indices to be copied are outside bounds");if(t+i>e.length)throw new Error("target array is too small to hold result");for(let l=0;l<i;l++)e[t+l]=r[o+l]*e[t+l]}}util.MathUtil=MathUtil;class SplitUtil{static splitShape(e,r,t,o){if(t.length===0){if(!o)throw new Error("need to know number of outputs when the 'split' attribute is not specified");SplitUtil.determineSplit(e[r],o,t)}const i=[],l=[0];for(let a=0;a<t.length;++a){a!==0&&l.push(l[a-1]+t[a-1]);const s=e.slice();s[r]=t[a],i.push(s)}return[i,l]}static determineSplit(e,r,t){if(e%r!==0)throw new Error("cannot split tensor to equal sized parts");for(let o=0;o<r;++o)t.push(e/r)}}util.SplitUtil=SplitUtil;class ReduceUtil{static calcReduce(e,r,t,o,i){const l=e.dims.slice(0);r.length===0&&l.forEach((m,_)=>r.push(_));const a=ReduceUtil.calcReduceShape(l,r,!0),s=ShapeUtil.size(a),u=new tensor_1$5.Tensor(a,e.type),c=ShapeUtil.computeStrides(a),f=ShapeUtil.computeStrides(l),d=new Array(l.length);for(let m=0;m<s;m++){const _=ShapeUtil.offsetToIndices(m,c);BroadcastUtil.fillIndex(_,l,d),u.set(_,ReduceUtil.calcReduceByAxis(e.numberData,r,l,0,ShapeUtil.indicesToOffset(d,f),o,i))}return t?u:new tensor_1$5.Tensor(ReduceUtil.calcReduceShape(l,r,t),u.type,void 0,void 0,u.data,u.dataId)}static calcReduceByAxis(e,r,t,o,i,l,a){let s=0;if(o>=r.length)return l(e[i]);const u=r[o],c=u>=t.length?1:ShapeUtil.size(t.slice(u+1));for(let f=0;f<t[u];f++)s=f===0?ReduceUtil.calcReduceByAxis(e,r,t,o+1,i,l,a):a(s,ReduceUtil.calcReduceByAxis(e,r,t,o+1,i,l,a)),i+=c;return s}static calcReduceShape(e,r,t){const o=e.slice();for(let i=0;i<r.length;i++)t?o[r[i]]=1:o[r[i]]=0;return o.filter(i=>i!==0)}}util.ReduceUtil=ReduceUtil;class PoolConvUtil{static adjustPoolAttributes(e,r,t,o,i,l){if(!e&&t.length!==r.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let a=0;a<r.length-2;a++)a>=t.length?t.push(r[a+2]):t[a]=r[a+2];for(let a=0;a<t.length;a++)if(a<o.length){if(o[a]<0)throw new Error("strides should be greater than or equal to 1")}else o.push(1);for(let a=0;a<t.length;a++)if(a<i.length){if(i[a]<0)throw new Error("dilations should be greater than or equal to 1")}else i.push(1);for(let a=0;a<t.length*2;a++)if(a<l.length){if(l[a]<0)throw new Error("pad should be greater than or equal to 1")}else l.push(0);for(let a=0;a<t.length;a++){if(t[a]<=0)throw new Error("kernel shapes need to be greater than 0");if(l[a]>=t[a]||l[a+t.length]>=t[a])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,r,t,o,i,l){if(!!l){if(i.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(o.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let a=0;a<e.length-2;a++)PoolConvUtil.adjustPadAndReturnShape(e[a+2],r[a],t[a],o[a],i,a,a+e.length-2,l)}}static computePoolOutputShape(e,r,t,o,i,l,a){if(r.length<=0)throw new Error("input shape must be of size greater than 0");const s=[r[0],r[1]];return PoolConvUtil.computeShapeHelper(e,r,s,t,o,i,l,a),s}static computeConvOutputShape(e,r,t,o,i,l,a){if(e.length<=0||r.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const s=[e[0],r[0]];return PoolConvUtil.computeShapeHelper(!1,e,s,t,o,i,l,a),s}static computeShapeHelper(e,r,t,o,i,l,a,s){if(e)for(let u=0;u<r.length-2;u++)t.push(1);else for(let u=0;u<r.length-2;u++)t.push(PoolConvUtil.adjustPadAndReturnShape(r[u+2],o[u],i[u],l[u],a,u,u+r.length-2,s))}static adjustPadAndReturnShape(e,r,t,o,i,l,a,s){const u=t*(o-1)+1;if(s&&s!=="NOTSET")switch(s){case"VALID":return i[l]=0,i[a]=0,Math.floor((e-u)/r+1);case"SAME_LOWER":case"SAME_UPPER":if(t!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const f=((e+r-1)/r-1)*r+o-e;return i[l]=Math.floor(s==="SAME_LOWER"?(f+1)/2:f/2),i[a]=f-i[l],Math.floor((e+f-o)/r+1)}default:throw new Error("Unsupported AutoPad type")}else return Math.floor((e+i[l]+i[a]-u)/r+1)}}util.PoolConvUtil=PoolConvUtil;util.MIN_CLIP=-34028234663852886e22;util.MAX_CLIP=34028234663852886e22;function decodeUtf8String(n){return new TextDecoder().decode(n)}util.decodeUtf8String=decodeUtf8String;var __importDefault$1=commonjsGlobal$1&&commonjsGlobal$1.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(tensor,"__esModule",{value:!0});tensor.Tensor=void 0;const guid_typescript_1=guid,long_1=__importDefault$1(long),onnx_proto_1$3=onnx,ort_generated_1$3=ortGenerated;var ortFbs$3=ort_generated_1$3.onnxruntime.experimental.fbs;const util_1$p=util;class Tensor{constructor(e,r,t,o,i,l=guid_typescript_1.Guid.create()){this.dims=e,this.type=r,this.dataProvider=t,this.asyncDataProvider=o,this.cache=i,this.dataId=l,this.size=util_1$p.ShapeUtil.validateDimsAndCalcSize(e);const a=this.size,s=t===void 0&&o===void 0&&i===void 0;if(i!==void 0&&i.length!==a)throw new RangeError("Input dims doesn't match data length.");if(r==="string"){if(i!==void 0&&(!Array.isArray(i)||!i.every(u=>typeof u=="string")))throw new TypeError("cache should be a string array");s&&(this.cache=new Array(a))}else{if(i!==void 0){const u=dataviewConstructor(r);if(!(i instanceof u))throw new TypeError(`cache should be type ${u.name}`)}if(s){const u=new ArrayBuffer(a*sizeof(r));this.cache=createView(u,r)}}}get data(){if(this.cache===void 0){const e=this.dataProvider(this.dataId);if(e.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=e}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(e){return this.data[util_1$p.ShapeUtil.indicesToOffset(e,this.strides)]}set(e,r){this.data[util_1$p.ShapeUtil.indicesToOffset(e,this.strides)]=r}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=util_1$p.ShapeUtil.computeStrides(this.dims)),this._strides}static fromProto(e){if(!e)throw new Error("cannot construct Value from an empty tensor");const r=util_1$p.ProtoUtil.tensorDataTypeFromProto(e.dataType),t=util_1$p.ProtoUtil.tensorDimsFromProto(e.dims),o=new Tensor(t,r);if(r==="string")e.stringData.forEach((i,l)=>{o.data[l]=util_1$p.decodeUtf8String(i)});else if(e.rawData&&typeof e.rawData.byteLength=="number"&&e.rawData.byteLength>0){const i=o.data,l=new DataView(e.rawData.buffer,e.rawData.byteOffset,e.rawData.byteLength),a=sizeofProto(e.dataType),s=e.rawData.byteLength/a;if(e.rawData.byteLength%a!==0)throw new Error("invalid buffer length");if(i.length!==s)throw new Error("buffer length mismatch");for(let u=0;u<s;u++){const c=readProto(l,e.dataType,u*a);i[u]=c}}else{let i;switch(e.dataType){case onnx_proto_1$3.onnx.TensorProto.DataType.FLOAT:i=e.floatData;break;case onnx_proto_1$3.onnx.TensorProto.DataType.INT32:case onnx_proto_1$3.onnx.TensorProto.DataType.INT16:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT16:case onnx_proto_1$3.onnx.TensorProto.DataType.INT8:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT8:case onnx_proto_1$3.onnx.TensorProto.DataType.BOOL:i=e.int32Data;break;case onnx_proto_1$3.onnx.TensorProto.DataType.INT64:i=e.int64Data;break;case onnx_proto_1$3.onnx.TensorProto.DataType.DOUBLE:i=e.doubleData;break;case onnx_proto_1$3.onnx.TensorProto.DataType.UINT32:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT64:i=e.uint64Data;break;default:throw new Error("unspecific error")}if(i==null)throw new Error("failed to populate data from a tensorproto value");const l=o.data;if(l.length!==i.length)throw new Error("array length mismatch");for(let a=0;a<i.length;a++){const s=i[a];long_1.default.isLong(s)?l[a]=longToNumber(s,e.dataType):l[a]=s}}return o}static fromData(e,r,t){return new Tensor(r,t,void 0,void 0,e)}static fromOrtTensor(e){if(!e)throw new Error("cannot construct Value from an empty tensor");const r=util_1$p.ProtoUtil.tensorDimsFromORTFormat(e),t=util_1$p.ProtoUtil.tensorDataTypeFromProto(e.dataType()),o=new Tensor(r,t);if(t==="string")for(let i=0;i<e.stringDataLength();i++)o.data[i]=e.stringData(i);else if(e.rawDataArray()&&typeof e.rawDataLength()=="number"&&e.rawDataLength()>0){const i=o.data,l=new DataView(e.rawDataArray().buffer,e.rawDataArray().byteOffset,e.rawDataLength()),a=sizeofProto(e.dataType()),s=e.rawDataLength()/a;if(e.rawDataLength()%a!==0)throw new Error("invalid buffer length");if(i.length!==s)throw new Error("buffer length mismatch");for(let u=0;u<s;u++){const c=readProto(l,e.dataType(),u*a);i[u]=c}}return o}}tensor.Tensor=Tensor;function sizeof(n){switch(n){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 ${n}`)}}function sizeofProto(n){switch(n){case onnx_proto_1$3.onnx.TensorProto.DataType.UINT8:case onnx_proto_1$3.onnx.TensorProto.DataType.INT8:case onnx_proto_1$3.onnx.TensorProto.DataType.BOOL:return 1;case onnx_proto_1$3.onnx.TensorProto.DataType.UINT16:case onnx_proto_1$3.onnx.TensorProto.DataType.INT16:return 2;case onnx_proto_1$3.onnx.TensorProto.DataType.FLOAT:case onnx_proto_1$3.onnx.TensorProto.DataType.INT32:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT32:return 4;case onnx_proto_1$3.onnx.TensorProto.DataType.INT64:case onnx_proto_1$3.onnx.TensorProto.DataType.DOUBLE:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${onnx_proto_1$3.onnx.TensorProto.DataType[n]}`)}}function createView(n,e){return new(dataviewConstructor(e))(n)}function dataviewConstructor(n){switch(n){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function longToNumber(n,e){if(e===onnx_proto_1$3.onnx.TensorProto.DataType.INT64||e===ortFbs$3.TensorDataType.INT64){if(n.greaterThanOrEqual(2147483648)||n.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else if(e===onnx_proto_1$3.onnx.TensorProto.DataType.UINT32||e===ortFbs$3.TensorDataType.UINT32||e===onnx_proto_1$3.onnx.TensorProto.DataType.UINT64||e===ortFbs$3.TensorDataType.UINT64){if(n.greaterThanOrEqual(4294967296)||n.lessThan(0))throw new TypeError("uint64 is not supported")}else throw new TypeError(`not a LONG type: ${onnx_proto_1$3.onnx.TensorProto.DataType[e]}`);return n.toNumber()}function readProto(n,e,r){switch(e){case onnx_proto_1$3.onnx.TensorProto.DataType.BOOL:case onnx_proto_1$3.onnx.TensorProto.DataType.UINT8:return n.getUint8(r);case onnx_proto_1$3.onnx.TensorProto.DataType.INT8:return n.getInt8(r);case onnx_proto_1$3.onnx.TensorProto.DataType.UINT16:return n.getUint16(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.INT16:return n.getInt16(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.FLOAT:return n.getFloat32(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.INT32:return n.getInt32(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.UINT32:return n.getUint32(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.INT64:return longToNumber(long_1.default.fromBits(n.getUint32(r,!0),n.getUint32(r+4,!0),!1),e);case onnx_proto_1$3.onnx.TensorProto.DataType.DOUBLE:return n.getFloat64(r,!0);case onnx_proto_1$3.onnx.TensorProto.DataType.UINT64:return longToNumber(long_1.default.fromBits(n.getUint32(r,!0),n.getUint32(r+4,!0),!0),e);default:throw new Error(`cannot read from DataView for type ${onnx_proto_1$3.onnx.TensorProto.DataType[e]}`)}}var pack={},glslSource={};Object.defineProperty(glslSource,"__esModule",{value:!0});glslSource.getDefaultFragShaderMain=glslSource.getFragShaderPreamble=glslSource.getVertexShaderSource=glslSource.getGlsl=void 0;const GLSL_ES_2_0={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},GLSL_ES_3_0={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function getGlsl(n){return n===1?GLSL_ES_2_0:GLSL_ES_3_0}glslSource.getGlsl=getGlsl;function getVertexShaderSource(n){const e=getGlsl(n);return`${e.version}
- precision highp float;
- ${e.attribute} vec3 position;
- ${e.attribute} vec2 textureCoord;
-
- ${e.varyingVertex} vec2 TexCoords;
-
- void main()
- {
- gl_Position = vec4(position, 1.0);
- TexCoords = textureCoord;
- }`}glslSource.getVertexShaderSource=getVertexShaderSource;function getFragShaderPreamble(n){const e=getGlsl(n);return`${e.version}
- precision highp float;
- precision highp int;
- precision highp sampler2D;
- ${e.varyingFrag} vec2 TexCoords;
- ${e.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);
- }
-
- `}glslSource.getFragShaderPreamble=getFragShaderPreamble;function getDefaultFragShaderMain(n,e){const r=getGlsl(n);return`
- void main() {
- int indices[${e}];
- toVec(TexCoords, indices);
- vec4 result = vec4(process(indices));
- ${r.output} = result;
- }
- `}glslSource.getDefaultFragShaderMain=getDefaultFragShaderMain;var types={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.TextureType=void 0,function(e){e[e.unpacked=0]="unpacked",e[e.unpackedReversed=1]="unpackedReversed",e[e.packed=2]="packed",e[e.downloadUint8AsFloat=3]="downloadUint8AsFloat",e[e.packedLastDimension=4]="packedLastDimension"}(n.TextureType||(n.TextureType={}))})(types);var utils={};Object.defineProperty(utils,"__esModule",{value:!0});utils.getGlChannels=utils.getCoordsDataType=utils.getSqueezedParams=utils.squeezeInputShape=utils.generateShaderFuncNameFromInputSamplerNameAtOutCoords=utils.generateShaderFuncNameFromInputSamplerName=utils.repeatedTry=utils.getPackedShape=void 0;const util_1$o=util;function getPackedShape(n){const e=n.length;return n.slice(0,e-1).concat(n[e-1]/4)}utils.getPackedShape=getPackedShape;async function repeatedTry(n,e=t=>0,r){return new Promise((t,o)=>{let i=0;const l=()=>{if(n()){t();return}i++;const a=e(i);if(r!=null&&i>=r){o();return}setTimeout(l,a)};l()})}utils.repeatedTry=repeatedTry;function generateShaderFuncNameFromInputSamplerName(n){return util_1$o.assert(typeof n!="undefined"&&n.length!==0,()=>"empty string found for sampler name"),"get"+n.charAt(0).toUpperCase()+n.slice(1)}utils.generateShaderFuncNameFromInputSamplerName=generateShaderFuncNameFromInputSamplerName;function generateShaderFuncNameFromInputSamplerNameAtOutCoords(n){return util_1$o.assert(typeof n!="undefined"&&n.length!==0,()=>"empty string found for sampler name"),"get"+n.charAt(0).toUpperCase()+n.slice(1)+"AtOutCoords"}utils.generateShaderFuncNameFromInputSamplerNameAtOutCoords=generateShaderFuncNameFromInputSamplerNameAtOutCoords;function squeezeInputShape(n,e){let r=JSON.parse(JSON.stringify(n));return r=e,r}utils.squeezeInputShape=squeezeInputShape;function getSqueezedParams(n,e){return e.map(r=>n[r]).join(", ")}utils.getSqueezedParams=getSqueezedParams;function getCoordsDataType(n){if(n<=1)return"int";if(n===2)return"ivec2";if(n===3)return"ivec3";if(n===4)return"ivec4";if(n===5)return"ivec5";if(n===6)return"ivec6";throw Error(`GPU for rank ${n} is not yet supported`)}utils.getCoordsDataType=getCoordsDataType;function getGlChannels(n=6){return["x","y","z","w","u","v"].slice(0,n)}utils.getGlChannels=getGlChannels;var packingUtils={};Object.defineProperty(packingUtils,"__esModule",{value:!0});packingUtils.unpackFromChannel=packingUtils.getChannels=packingUtils.getVecChannels=void 0;const utils_1$7=utils;function getVecChannels(n,e){return utils_1$7.getGlChannels(e).map(r=>`${n}.${r}`)}packingUtils.getVecChannels=getVecChannels;function getChannels(n,e){return e===1?[n]:getVecChannels(n,e)}packingUtils.getChannels=getChannels;function unpackFromChannel(){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);
- }
- `}packingUtils.unpackFromChannel=unpackFromChannel;Object.defineProperty(pack,"__esModule",{value:!0});pack.createPackProgramInfoLoader=void 0;const glsl_source_1$h=glslSource,types_1$p=types,utils_1$6=utils,packing_utils_1$4=packingUtils,packProgramMetadata={name:"pack",inputNames:["A"],inputTypes:[types_1$p.TextureType.unpackedReversed]},createPackProgramInfo=(n,e)=>{const r=glsl_source_1$h.getGlsl(n.session.backend.glContext.version),t=e.dims,o=t.length,i=e.dims.length,l=utils_1$6.getCoordsDataType(i),a=packing_utils_1$4.getChannels("rc",i),s=getSetup(i,a,t[t.length-2],t[t.length-1]);let u;o===0?u=[1,1]:o===1?u=[t[0],1]:u=[t[i-1],t[i-2]];const c=getOutOfBoundsCondition(i,u,a),f=getOutput(t,a),d=`
- void main() {
- ${l} rc = getOutputCoords();
-
- if(${c}) {
- ${r.output} = vec4(0);
- } else {
- ${s}
-
- ${r.output} = vec4(${f});
- }
- }
- `;return Object.assign(Object.assign({},packProgramMetadata),{hasMain:!0,output:{dims:e.dims,type:e.type,textureType:types_1$p.TextureType.packed},shaderSource:d})},createPackProgramInfoLoader=(n,e)=>Object.assign(Object.assign({},packProgramMetadata),{get:()=>createPackProgramInfo(n,e)});pack.createPackProgramInfoLoader=createPackProgramInfoLoader;function getOutOfBoundsCondition(n,e,r){if(n===0)return"false";if(n===1)return`rc > ${e[0]}`;let t="";for(let o=n-2;o<n;o++)t+=`${r[o]} >= ${e[o-n+2]}`,o<n-1&&(t+="||");return t}function getOutput(n,e){const r=n.length;if(r===0)return"getA(), 0, 0, 0";if(r===1)return`getA(rc),
- rc + 1 >= ${n[0]} ? 0. : getA(rc + 1),
- 0, 0`;const t="r, c",o="r, cp1",i="rp1, c",l="rp1, cp1";let a="";if(r>2)for(let s=0;s<r-2;++s)a=a+`${e[s]},`;return`getA(${a}${t}),
- rEdge ? 0. : getA(${a}${i}),
- cEdge ? 0. : getA(${a}${o}),
- rEdge || cEdge ? 0. : getA(${a}${l})`}function getSetup(n,e,r,t){return n===0||n===1?"":`
- int r = ${e[n-2]};
- int c = ${e[n-1]};
- int rp1 = ${e[n-2]} + 1;
- int cp1 = ${e[n-1]} + 1;
- bool rEdge = rp1 >= ${t};
- bool cEdge = cp1 >= ${r};
- `}var reshapePacked={};Object.defineProperty(reshapePacked,"__esModule",{value:!0});reshapePacked.isReshapeCheap=reshapePacked.processDims3D=reshapePacked.createPackedReshape3DProgramInfoLoader=void 0;const util_1$n=util,glsl_source_1$g=glslSource,types_1$o=types,packing_utils_1$3=packingUtils,createPackedReshape3DProgramMetadata=n=>({name:"Reshape (packed)",inputTypes:[types_1$o.TextureType.packed],inputNames:["A"],cacheHint:`${n}`}),createPackedReshape3DProgramInfo=(n,e,r,t)=>{const o=e.dims,i=t;let l="";for(let u=0;u<4;u++){let c="";switch(u){case 0:c="outputCoords = rc;";break;case 1:c="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:c="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:c="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}l+=`
- ${c}
- ${u>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[${u}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);
-
- ${u>0?"}":""}
- `}const a=glsl_source_1$g.getGlsl(n.session.backend.glContext.version),s=`
- ${getReshapedInputCoords(o)}
- ${getFlattenedIndexFrom3D(i)}
- ${packing_utils_1$3.unpackFromChannel()}
-
- void main() {
- ivec3 rc = getOutputCoords();
-
- vec4 result = vec4(0.0);
-
- ivec3 outputCoords;
- int rows = ${i[2]};
- int cols = ${i[1]};
-
- ${l}
- ${a.output} = result;
- }
- `;return Object.assign(Object.assign({},r),{output:{dims:i,type:e.type,textureType:types_1$o.TextureType.packed},shaderSource:s,hasMain:!0})},createPackedReshape3DProgramInfoLoader=(n,e,r)=>{const t=createPackedReshape3DProgramMetadata(r);return Object.assign(Object.assign({},t),{get:()=>createPackedReshape3DProgramInfo(n,e,t,r)})};reshapePacked.createPackedReshape3DProgramInfoLoader=createPackedReshape3DProgramInfoLoader;function processDims3D(n){if(n.length===0)return[1,1,1];let e=1;for(let r=0;r<n.length-2;++r)e*=n[r];return[e,n.length>1?n[n.length-2]:1,n[n.length-1]]}reshapePacked.processDims3D=processDims3D;function isReshapeCheap(n,e){let r=!1;return n.length===0||e.length===0?r=!0:n.length<2||e.length<2?r=n[n.length-1]===e[e.length-1]:r=n[n.length-1]===e[e.length-1]&&n[n.length-2]===e[e.length-2],r}reshapePacked.isReshapeCheap=isReshapeCheap;function getReshapedInputCoords(n){const e=util_1$n.ShapeUtil.computeStrides(n),r=["b","r","c"],t="index";return`
- ivec3 inputCoordsFromReshapedOutCoords(int index) {
- ${e.map((i,l)=>{const a=`int ${r[l]} = ${t} / ${i}`,s=l===e.length-1?`int ${r[l+1]} = ${t} - ${r[l]} * ${i}`:`index -= ${r[l]} * ${i}`;return`${a}; ${s};`}).join("")}
- return ivec3(b, r, c);
- }
- `}function getFlattenedIndexFrom3D(n){const e=util_1$n.ShapeUtil.computeStrides(n);return`
- int getFlattenedIndex(ivec3 coords) {
- // reverse y, z order
- return coords.x * ${e[0]} + coords.z * ${e[1]} + coords.y;
- }
- `}var uint8Encode={};Object.defineProperty(uint8Encode,"__esModule",{value:!0});uint8Encode.encodeAsUint8=void 0;const glsl_source_1$f=glslSource,types_1$n=types,encodeAsUint8=(n,e)=>{const r=e.shape,t=glsl_source_1$f.getGlsl(n.session.backend.glContext.version),o=`
- 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 = ${t.texture2D}(X,TexCoords).r;
- ${t.output} = encodeAsUint8(value);
- }`,i={name:"Uint8Encode",inputTypes:[types_1$n.TextureType.unpacked],inputNames:["X"],output:{dims:r,type:e.tensor.type,textureType:types_1$n.TextureType.downloadUint8AsFloat},shaderSource:o,hasMain:!0};return n.executeProgram(i,[e.tensor])};uint8Encode.encodeAsUint8=encodeAsUint8;var unpack={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.createUnpackProgramInfoLoader=n.createUnpackProgramInfo=void 0;const e=glslSource,r=types,t=utils,o=packingUtils,i={name:"unpack",inputNames:["A"],inputTypes:[r.TextureType.packed]},l=(u,c)=>{const f=c.dims.length,d=o.getChannels("rc",f),m=d.slice(-2),_=t.getCoordsDataType(f),S=o.unpackFromChannel(),$=c.dims.length===0?"":s(f,d),y=f<=1?"rc":`vec2(${m.join(",")})`,v=e.getGlsl(u.session.backend.glContext.version),A=`
- ${S}
- void main() {
- ${_} rc = getOutputCoords();
-
- // Sample the texture with the coords to get the rgba channel value.
- vec4 packedInput = getA(${$});
-
- ${v.output} = vec4(getChannel(packedInput, ${y}), 0, 0, 0);
- }
- `;return Object.assign(Object.assign({},i),{hasMain:!0,output:{dims:c.dims,type:c.type,textureType:r.TextureType.unpacked},shaderSource:A})};n.createUnpackProgramInfo=l;const a=(u,c)=>Object.assign(Object.assign({},i),{get:()=>n.createUnpackProgramInfo(u,c)});n.createUnpackProgramInfoLoader=a;function s(u,c){if(u===1)return"rc";let f="";for(let d=0;d<u;d++)f+=c[d],d<u-1&&(f+=",");return f}})(unpack);var textureLayout={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.createTextureLayoutFromShape=n.calculateTextureWidthAndHeight=n.createTextureLayoutFromTextureType=void 0;const e=util,r=types,t=(l,a,s)=>{const u=s===r.TextureType.unpacked||s===r.TextureType.unpackedReversed?1:4,c=s===r.TextureType.packed,f=s===r.TextureType.unpackedReversed||s===r.TextureType.packed,d=s===r.TextureType.packedLastDimension?a.length-1:void 0,m=s===r.TextureType.packedLastDimension?a.map((_,S)=>S===a.length-1?_*4:_):void 0;return n.createTextureLayoutFromShape(l,a,u,m,{isPacked:c,reverseWH:f,breakAxis:d})};n.createTextureLayoutFromTextureType=t;const o=(l,a,s)=>{const u=n.createTextureLayoutFromTextureType(l,a,s);return[u.width,u.height]};n.calculateTextureWidthAndHeight=o;const i=(l,a,s=1,u,c)=>{const f=!!(c&&c.isPacked),[d,m]=l.computeTextureWH(f&&u||a,c),_=a.length;let S=a.slice(0);if(_===0&&(S=[1]),s===1)u=a;else if(f){if(s!==4)throw new Error("a packed texture must be 4-channel");u=a,_>0&&(S[_-1]=Math.ceil(S[_-1]/2)),_>1&&(S[_-2]=Math.ceil(S[_-2]/2))}else if(!u)throw new Error("Unpacked shape is needed when using channels > 1");return{width:d,height:m,channels:s,isPacked:f,shape:S,strides:e.ShapeUtil.computeStrides(S),unpackedShape:u,reversedWH:c&&c.reverseWH}};n.createTextureLayoutFromShape=i})(textureLayout);Object.defineProperty(inferenceHandler,"__esModule",{value:!0});inferenceHandler.WebGLInferenceHandler=void 0;const instrument_1$a=instrument,tensor_1$4=tensor,util_1$m=util,pack_1=pack,reshape_packed_1=reshapePacked,uint8_encode_1=uint8Encode,unpack_1=unpack,texture_layout_1=textureLayout,types_1$m=types,getProgramInfoUniqueKey=(n,e)=>{const r=e.map(o=>`${o.unpackedShape.join(",")};${o.width}x${o.height}`).join("_");let t=n.name;return n.cacheHint&&(t+="["+n.cacheHint+"]"),t+=":"+r,t};class WebGLInferenceHandler{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,r){return texture_layout_1.calculateTextureWidthAndHeight(this.session.layoutStrategy,e,r)}executeProgram(e,r){if(r.length<e.inputNames.length)throw new Error(`Input size mustn't be less than ${e.inputNames.length}.`);if(e.inputNames.length!==e.inputTypes.length)throw new Error("input names size does not match input types");const t=[];for(let u=0;u<e.inputNames.length;++u)t[u]=this.getOrCreateTextureData(r[u],e.inputTypes[u]);const o=getProgramInfoUniqueKey(e,t);let i=this.session.programManager.getArtifact(o);const l=i?i.programInfo:typeof e.get=="function"?e.get():e,a=texture_layout_1.createTextureLayoutFromTextureType(this.session.layoutStrategy,l.output.dims,l.output.textureType),s=this.createTextureData(a,l.output.type);return i||(i=this.session.programManager.build(l,t,s),this.session.programManager.setArtifact(o,i)),this.runProgram(i,t,s),s}run(e,r){return this.executeProgram(e,r).tensor}runProgram(e,r,t){for(let o=0;o<r.length;++o)if(!!r[o].isPacked!=(e.programInfo.inputTypes[o]===types_1$m.TextureType.packed))throw new Error(`input[${o}] property packed inconsistent`);if(!!t.isPacked!=(e.programInfo.output.textureType===types_1$m.TextureType.packed))throw new Error("output property packed inconsistent");this.session.programManager.run(e,r,t)}getOrCreateTextureData(e,r){let t=this.getTextureData(e.dataId,r===types_1$m.TextureType.packed);if(!t&&(t=this.getTextureData(e.dataId,r!==types_1$m.TextureType.packed),t))return r===types_1$m.TextureType.packed?this.pack(t):this.unpack(t);if(!t){const o=texture_layout_1.createTextureLayoutFromTextureType(this.session.layoutStrategy,e.dims,r);if(r===types_1$m.TextureType.packedLastDimension){const a=e.dims;if(a.length===4){const s=[a[0],Math.ceil(a[1]*a[2]*a[3]/4)],u=texture_layout_1.createTextureLayoutFromTextureType(this.session.layoutStrategy,s,r);let c=e.numberData;if(a[1]*a[2]*a[3]%4!==0){const f=a[0],d=a[1]*a[2]*a[3],m=Math.ceil(d*1/4)*4,_=f*m;c=new Float32Array(_);for(let S=0;S<f;++S){const E=S*d,$=S*m+S%1*d;c.set(e.numberData.subarray(E,E+d),$)}}return this.createTextureData(u,e.type,c,e,1)}}if(r===types_1$m.TextureType.packed){const i=texture_layout_1.createTextureLayoutFromShape(this.session.layoutStrategy,e.dims,1,[],{reverseWH:!0}),l=this.createTextureData(i,e.type,e.numberData,e,1);t=this.pack(l)}else t=this.createTextureData(o,e.type,e.numberData,e,1)}return t}createTextureDataFromLayoutBindTensor(e,r,t,o){return this.createTextureData(e,r,t,o,1)}createTextureData(e,r,t,o,i){instrument_1$a.Logger.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(e)}]`);const l=this.session.textureManager.createTextureFromLayout(r,e,t,i);return this.createTextureDataFromTexture(e,r,l,o)}reshapeUnpacked(e,r){const t=this.getOrCreateTextureData(e,types_1$m.TextureType.unpacked),o={channels:t.channels,height:t.height,width:t.width,shape:r.length!==0?r:[1],strides:util_1$m.ShapeUtil.computeStrides(r),unpackedShape:r};return this.createTextureDataFromTexture(o,e.type,t.texture).tensor}reshapePacked(e,r){const t=this.getOrCreateTextureData(e,types_1$m.TextureType.packed);if(reshape_packed_1.isReshapeCheap(e.dims,r)){const u={channels:t.channels,height:t.height,width:t.width,shape:r.length!==0?r:[1],strides:util_1$m.ShapeUtil.computeStrides(r),unpackedShape:r,isPacked:!0};return this.createTextureDataFromTexture(u,e.type,t.texture).tensor}const o=reshape_packed_1.processDims3D(e.dims),i=reshape_packed_1.processDims3D(r),l=this.reshapePacked(e,o),a=this.run(reshape_packed_1.createPackedReshape3DProgramInfoLoader(this,l,i),[l]);return this.reshapePacked(a,r)}cast(e,r){const t=this.getOrCreateTextureData(e,types_1$m.TextureType.unpacked);return this.createTextureDataFromTexture(t,r,t.texture).tensor}createTextureDataFromTexture(e,r,t,o,i){const l=Object.assign(Object.assign({},e),{tensor:o||new tensor_1$4.Tensor(e.unpackedShape,r,a=>this.readTexture(l),async a=>this.readTextureAsync(l),void 0,i),texture:t});return this.setTextureData(l.tensor.dataId,l,e.isPacked),l}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,t=!1){this.session.isInitializer(e)?this.session.setTextureData(e,r,t):(t?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(uint8_encode_1.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(uint8_encode_1.encodeAsUint8(this,e))}pack(e){return this.executeProgram(pack_1.createPackProgramInfoLoader(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram(unpack_1.createUnpackProgramInfoLoader(this,e.tensor),[e.tensor])}}inferenceHandler.WebGLInferenceHandler=WebGLInferenceHandler;var opResolveRules={},batchNormalization$1={},attributeWithCacheKey={};Object.defineProperty(attributeWithCacheKey,"__esModule",{value:!0});attributeWithCacheKey.createAttributeWithCacheKey=void 0;class AttributeWithCacheKeyImpl{constructor(e){Object.assign(this,e)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(e=>`${this[e]}`).join(";")),this._cacheKey}}const createAttributeWithCacheKey=n=>new AttributeWithCacheKeyImpl(n);attributeWithCacheKey.createAttributeWithCacheKey=createAttributeWithCacheKey;Object.defineProperty(batchNormalization$1,"__esModule",{value:!0});batchNormalization$1.parseBatchNormalizationAttributes=batchNormalization$1.batchNormalization=void 0;const attribute_with_cache_key_1$a=attributeWithCacheKey,glsl_source_1$e=glslSource,types_1$l=types,batchNormalizationProgramMetadata={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[types_1$l.TextureType.unpacked,types_1$l.TextureType.unpacked,types_1$l.TextureType.unpacked,types_1$l.TextureType.unpacked,types_1$l.TextureType.unpacked]},batchNormalization=(n,e,r)=>(validateInputs$i(e),[n.run(Object.assign(Object.assign({},batchNormalizationProgramMetadata),{cacheHint:r.cacheKey,get:()=>createBatchNormalizationProgramInfo(n,e,r)}),e)]);batchNormalization$1.batchNormalization=batchNormalization;const parseBatchNormalizationAttributes=n=>{const e=n.attributes.getFloat("epsilon",1e-5),r=n.attributes.getFloat("momentum",.9),t=n.attributes.getInt("spatial",1);return attribute_with_cache_key_1$a.createAttributeWithCacheKey({epsilon:e,momentum:r,spatial:t})};batchNormalization$1.parseBatchNormalizationAttributes=parseBatchNormalizationAttributes;const createBatchNormalizationProgramInfo=(n,e,r)=>{const t=glsl_source_1$e.getGlsl(n.session.backend.glContext.version),o=e[0].dims.length,[i,l]=n.calculateTextureWidthAndHeight(e[1].dims,types_1$l.TextureType.unpacked),a=`
- float process(int[${o}] indices) {
- vec2 position = offsetToCoords(indices[1], ${i}, ${l});
- float scale = getColorAsFloat(${t.texture2D}(Scale, position));
- float mean = getColorAsFloat(${t.texture2D}(Mean, position));
- float variance = getColorAsFloat(${t.texture2D}(Variance, position));
- float b = getColorAsFloat(${t.texture2D}(B, position));
-
- return scale * ( (_A(indices) - mean) / sqrt(variance + float(${r.epsilon})) ) + b;
- }`;return Object.assign(Object.assign({},batchNormalizationProgramMetadata),{output:{dims:e[0].dims,type:e[0].type,textureType:types_1$l.TextureType.unpacked},shaderSource:a})},validateInputs$i=n=>{if(!n||n.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const e=n[0],r=n[1],t=n[2],o=n[3],i=n[4];if(e.dims.length<3||r.dims.length!==1||t.dims.length!==1||o.dims.length!==1||i.dims.length!==1)throw new Error("invalid input shape.");if(r.dims[0]!==e.dims[1]||t.dims[0]!==e.dims[1]||o.dims[0]!==e.dims[1]||i.dims[0]!==e.dims[1])throw new Error("invalid input shape.");if(e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||o.type!=="float32"&&o.type!=="float64"||i.type!=="float32"&&i.type!=="float64")throw new Error("invalid input tensor types.")};var binaryOp={},glslDefinitions={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.TopologicalSortGlslRoutines=n.GlslLibRoutineNode=n.GlslLibRoutine=n.GlslLib=n.GlslContext=n.FunctionType=void 0,function(l){l[l.ValueBased=0]="ValueBased",l[l.Positional=1]="Positional"}(n.FunctionType||(n.FunctionType={}));class e{constructor(a,s,u,c){this.glContext=a,this.programInfo=s,this.inputTextureLayouts=u,this.outputTextureLayout=c}}n.GlslContext=e;class r{constructor(a){this.context=a}}n.GlslLib=r;class t{constructor(a,s){this.routineBody=a,this.dependencies=s}}n.GlslLibRoutine=t;class o{constructor(a,s,u){this.name=a,u?this.dependencies=u:this.dependencies=[],s&&(this.routineBody=s)}addDependency(a){a&&this.dependencies.push(a)}}n.GlslLibRoutineNode=o;class i{static returnOrderedNodes(a){if(!a||a.length===0)return[];if(a.length===1)return a;const s=new Set,u=new Set,c=new Array;return this.createOrderedNodes(a,s,u,c),c}static createOrderedNodes(a,s,u,c){for(let f=0;f<a.length;++f)this.dfsTraverse(a[f],s,u,c)}static dfsTraverse(a,s,u,c){if(!a||u.has(a.name))return;if(s.has(a.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");s.add(a.name);const f=a.dependencies;if(f&&f.length>0)for(let d=0;d<f.length;++d)this.dfsTraverse(f[d],s,u,c);c.push(a),u.add(a.name),s.delete(a.name)}}n.TopologicalSortGlslRoutines=i})(glslDefinitions);Object.defineProperty(binaryOp,"__esModule",{value:!0});binaryOp.xor=binaryOp.sub=binaryOp.pRelu=binaryOp.pow=binaryOp.or=binaryOp.mul=binaryOp.less=binaryOp.greater=binaryOp.equal=binaryOp.div=binaryOp.and=binaryOp.add=binaryOp.glslPRelu=binaryOp.glslPow=binaryOp.glslXor=binaryOp.glslOr=binaryOp.glslAnd=binaryOp.glslLess=binaryOp.glslGreater=binaryOp.glslEqual=binaryOp.glslSub=binaryOp.glslMul=binaryOp.glslDiv=binaryOp.glslAdd=void 0;const util_1$l=util,glsl_definitions_1$6=glslDefinitions,glsl_source_1$d=glslSource,types_1$k=types;function glslAdd(){const n="add_";return{body:`
- float ${n}(float a, float b) {
- return a + b;
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return v1 + v2;
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslAdd=glslAdd;function glslDiv(){const n="div_";return{body:`
- float ${n}(float a, float b) {
- return a / b;
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return v1 / v2;
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslDiv=glslDiv;function glslMul(){const n="mul_";return{body:`
- float ${n}(float a, float b) {
- return a * b;
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return v1 * v2;
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslMul=glslMul;function glslSub(){const n="sub_";return{body:`
- float ${n}(float a, float b) {
- return a - b;
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return v1 - v2;
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslSub=glslSub;function glslEqual(){const n="equal_";return{body:`
- float ${n}(float a, float b) {
- return float(a == b);
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return vec4(equal(v1, v2));
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslEqual=glslEqual;function glslGreater(){const n="greater_";return{body:`
- float ${n}(float a, float b) {
- return float(a > b);
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return vec4( v1.r > v2.r ,
- v1.g > v2.g,
- v1.b > v2.b,
- v1.a > v2.a );
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslGreater=glslGreater;function glslLess(){const n="less_";return{body:`
- float ${n}(float a, float b) {
- return float(a < b);
- }
- vec4 ${n}(vec4 v1, vec4 v2) {
- return vec4( v1.r < v2.r ,
- v1.g < v2.g,
- v1.b < v2.b,
- v1.a < v2.a );
- }
- `,name:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslLess=glslLess;function glslAnd(){const n="and_";return{body:`
- float ${n}(float a, float b) {
- return float( bool(a) && bool(b) );
- }
- vec4 ${n}(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:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslAnd=glslAnd;function glslOr(){const n="or_";return{body:`
- float ${n}(float a, float b) {
- return float( bool(a) || bool(b) );
- }
- vec4 ${n}(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:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslOr=glslOr;function glslXor(){const n="xor_";return{body:`
- float ${n}(float a, float b) {
- return float( bool(a) ^^ bool(b) );
- }
- vec4 ${n}(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:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslXor=glslXor;function glslPow(){return glslBuiltinBinary("pow")}binaryOp.glslPow=glslPow;function glslPRelu(){const n="prelu_";return{body:`
- float ${n}(float a, float b) {
- return a < 0.0 ? a * b: a;
- }
- vec4 ${n}(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:n,type:glsl_definitions_1$6.FunctionType.ValueBased}}binaryOp.glslPRelu=glslPRelu;function glslBuiltinBinary(n){const e=`${n}_`;return{body:`
- float ${e}(float a, float b) {
- return ${n}(a, b);
- }
- vec4 ${e}(vec4 v1, vec4 v2) {
- return ${n}(v1, v2);
- }
- `,name:e,type:glsl_definitions_1$6.FunctionType.ValueBased}}const createBinaryProgramInfoLoader=(n,e,r,t=e[0].type,o)=>{const i=n.session.pack?types_1$k.TextureType.packed:types_1$k.TextureType.unpacked;return{name:r.name,inputNames:["A","B"],inputTypes:[i,i],cacheHint:o,get:()=>createBinaryProgramInfo(n,e,r,t)}},createBinaryProgramInfo=(n,e,r,t=e[0].type)=>{const o=n.session.pack?types_1$k.TextureType.packed:types_1$k.TextureType.unpacked,i=!util_1$l.ShapeUtil.areEqual(e[0].dims,e[1].dims);let l=e[0].dims;const a=n.session.pack;if(i){const c=util_1$l.BroadcastUtil.calcShape(e[0].dims,e[1].dims,!1);if(!c)throw new Error("Can't perform binary op on the given tensors");l=c;const f=l.length,d=e[0].dims.length!==0?e[0].dims.length:1,m=e[1].dims.length!==0?e[1].dims.length:1,_=e[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",S=e[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",E=glsl_source_1$d.getGlsl(n.session.backend.glContext.version),$=a?`
- ${r.body}
- void main() {
- vec4 a = getAAtOutCoords();
- vec4 b = getBAtOutCoords();
- vec4 result = ${r.name}(a, b);
- ${E.output} = result;
- }`:`
- ${r.body}
- float process(int indices[${f}]) {
- int aindices[${d}];
- int bindices[${m}];
- ${_}
- ${S}
- return ${r.name}(_A(aindices), _B(bindices));
- }`;return{name:r.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:l,type:t,textureType:o},shaderSource:$,hasMain:a}}const s=glsl_source_1$d.getGlsl(n.session.backend.glContext.version),u=`
- ${r.body}
- void main() {
- vec4 v1 = ${s.texture2D}(A, TexCoords);
- vec4 v2 = ${s.texture2D}(B, TexCoords);
- vec4 result = ${r.name}(v1, v2);
- ${s.output} = result;
- }
- `;return{name:r.name,inputNames:["A","B"],inputTypes:[o,o],output:{dims:e[0].dims,type:t,textureType:o},shaderSource:u,hasMain:!0}},add=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslAdd()),e)];binaryOp.add=add;const and=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslAnd(),"bool"),e)];binaryOp.and=and;const div=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslDiv()),e)];binaryOp.div=div;const equal=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslEqual(),"bool"),e)];binaryOp.equal=equal;const greater=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslGreater(),"bool"),e)];binaryOp.greater=greater;const less=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslLess(),"bool"),e)];binaryOp.less=less;const mul=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslMul()),e)];binaryOp.mul=mul;const or=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslOr(),"bool"),e)];binaryOp.or=or;const pow=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslPow()),e)];binaryOp.pow=pow;const pRelu=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslPRelu()),e)];binaryOp.pRelu=pRelu;const sub=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslSub()),e)];binaryOp.sub=sub;const xor=(n,e)=>[n.run(createBinaryProgramInfoLoader(n,e,glslXor(),"bool"),e)];binaryOp.xor=xor;var cast$1={};Object.defineProperty(cast$1,"__esModule",{value:!0});cast$1.parseCastAttributes=cast$1.cast=void 0;const util_1$k=util,cast=(n,e,r)=>(validateInputs$h(e),[n.cast(e[0],r)]);cast$1.cast=cast;const parseCastAttributes=n=>util_1$k.ProtoUtil.tensorDataTypeFromProto(n.attributes.getInt("to"));cast$1.parseCastAttributes=parseCastAttributes;const validateInputs$h=n=>{if(!n||n.length!==1)throw new Error("Cast requires 1 input.");if(n[0].type==="string")throw new Error("Invalid input type.")};var concat$1={},concatPacked={};Object.defineProperty(concatPacked,"__esModule",{value:!0});concatPacked.createPackedConcatProgramInfoLoader=void 0;const glsl_source_1$c=glslSource,types_1$j=types,utils_1$5=utils,packing_utils_1$2=packingUtils,createPackedConcatProgramMetadata=(n,e)=>({name:"Concat (packed)",inputNames:Array.from({length:n},(r,t)=>`X${t}`),inputTypes:Array(n).fill(types_1$j.TextureType.packed),cacheHint:e}),createPackedConcatProgramInfo=(n,e,r,t)=>{const o=r[0].dims.slice();if(t>=o.length||t<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");t<0&&(t=o.length+t);const i=o.slice(0);for(let P=1;P<r.length;P++){const C=r[P].dims.slice();for(let L=0;L<o.length;L++)if(L===t)i[t]+=C[L];else if(o[L]!==C[L])throw new Error("non concat dimensions must match")}const l=i.length,a=packing_utils_1$2.getChannels("coords",l),s=utils_1$5.getCoordsDataType(l),u=packing_utils_1$2.unpackFromChannel(),c=r.map(P=>P.dims),f=utils_1$5.getGlChannels(l),d=new Array(c.length-1);d[0]=c[0][t];for(let P=1;P<d.length;P++)d[P]=d[P-1]+c[P][t];const m=f[t],_=f.slice(-2),S=f.join();let E=`if (${m} < ${d[0]}) {
- return getChannel(
- getX0(${S}), vec2(${_.join()}));
- }`;for(let P=1;P<d.length;P++){const C=d[P-1];E+=`
- if (${m} < ${d[P]} && ${m} >= ${d[P-1]}) {
- return getChannel(
- getX${P}(${getShiftedChannelsSnippet(f,m,C)}),
- vec2(${getShiftedChannelsSnippet(_,m,C)}));
- }`}const $=d.length,y=d[d.length-1];E+=`
- return getChannel(
- getX${$}(${getShiftedChannelsSnippet(f,m,y)}),
- vec2(${getShiftedChannelsSnippet(_,m,y)}));`;const v=glsl_source_1$c.getGlsl(n.session.backend.glContext.version),A=`
- ${u}
- float getValue(${f.map(P=>"int "+P)}) {
- ${E}
- }
-
- void main() {
- ${s} coords = getOutputCoords();
- int lastDim = coords.${f[l-1]};
- coords.${f[l-1]} = coords.${f[l-2]};
- coords.${f[l-2]} = lastDim;
-
- vec4 result = vec4(getValue(${a}), 0., 0., 0.);
-
- ${a[l-1]} = ${a[l-1]} + 1;
- if (${a[l-1]} < ${i[l-1]}) {
- result.g = getValue(${a});
- }
-
- ${a[l-2]} = ${a[l-2]} + 1;
- if (${a[l-2]} < ${i[l-2]}) {
- result.a = getValue(${a});
- }
-
- ${a[l-1]} = ${a[l-1]} - 1;
- if (${a[l-2]} < ${i[l-2]} &&
- ${a[l-1]} < ${i[l-1]}) {
- result.b = getValue(${a});
- }
- ${v.output} = result;
- }
- `;return Object.assign(Object.assign({},e),{output:{dims:i,type:r[0].type,textureType:types_1$j.TextureType.packed},shaderSource:A,hasMain:!0})},createPackedConcatProgramInfoLoader=(n,e,r)=>{const t=createPackedConcatProgramMetadata(e.length,r.cacheKey);return Object.assign(Object.assign({},t),{get:()=>createPackedConcatProgramInfo(n,t,e,r.axis)})};concatPacked.createPackedConcatProgramInfoLoader=createPackedConcatProgramInfoLoader;const getShiftedChannelsSnippet=(n,e,r)=>{const t=n.indexOf(e);return n.map((i,l)=>l===t?`${i} - ${r}`:i).join()};Object.defineProperty(concat$1,"__esModule",{value:!0});concat$1.parseConcatAttributes=concat$1.concat=void 0;const attribute_with_cache_key_1$9=attributeWithCacheKey,types_1$i=types,concat_packed_1=concatPacked,concat=(n,e,r)=>(validateInputs$g(e),n.session.pack&&e[0].dims.length>1?[n.run(concat_packed_1.createPackedConcatProgramInfoLoader(n,e,r),e)]:[n.run(createUnpackedConcatProgramInfoLoader(n,e,r),e)]);concat$1.concat=concat;const createUnpackedConcatProgramMetadata=(n,e)=>({name:"Concat",inputNames:Array.from({length:n},(r,t)=>`X${t}`),inputTypes:Array(n).fill(types_1$i.TextureType.unpacked),cacheHint:e}),createUnpackedConcatProgramInfo=(n,e,r,t)=>{const o=r[0].dims.slice();if(t>=o.length||t<-1*o.length)throw new Error("axis specified for concat doesn't match input dimensionality");t<0&&(t=o.length+t);const i=o.slice(0);for(let m=1;m<r.length;m++){const _=r[m].dims.slice();for(let S=0;S<o.length;S++)if(S===t)i[t]+=_[S];else if(o[S]!==_[S])throw new Error("non concat dimensions must match")}const l=i.length,a=new Array(r.length);let s=0;for(let m=0;m<a.length;++m)s+=r[m].dims[t],a[m]=s;let u="";r.length<5?u=getTextureIndexWhereDataResidesLinearSearch(a):u=getTextureIndexWhereDataResidesBinarySearch(a);const c=getFetchDataFromCorrectTextureMethod(r.length,l),f=getGetSizeInConcatAxisValueFromIndexMethod(a),d=`
- ${c}
- ${f}
- ${u}
- float process(int indices[${l}]) {
- int textureIndex = getTextureWhereDataResides (indices[${t}]);
-
- if(textureIndex != 0) {
- indices[${t}] = indices[${t}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
- }
-
- return fetchDataFromCorrectTexture(textureIndex, indices);
- }`;return Object.assign(Object.assign({},e),{output:{dims:i,type:r[0].type,textureType:types_1$i.TextureType.unpacked},shaderSource:d})},createUnpackedConcatProgramInfoLoader=(n,e,r)=>{const t=createUnpackedConcatProgramMetadata(e.length,r.cacheKey);return Object.assign(Object.assign({},t),{get:()=>createUnpackedConcatProgramInfo(n,t,e,r.axis)})},getTextureIndexWhereDataResidesLinearSearch=n=>`int getTextureWhereDataResides(int index) {
- ${n.map((r,t)=>`if(index<${r}) {return ${t};}
- `).join("")}
- }`,getTextureIndexWhereDataResidesBinarySearch=n=>getTextureIndexWhereDataResidesLinearSearch(n),getFetchDataFromCorrectTextureMethod=(n,e)=>{const r=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${e}]) {`];for(let t=0;t<n;++t)t===0?r.push(` if (textureIndex == ${t}) { return _X${t}(indices); }`):t===n-1?r.push(` else { return _X${t}(indices); }`):r.push(` else if (textureIndex == ${t}) { return _X${t}(indices); }`);return r.push(" }"),r.join(`
- `)},getGetSizeInConcatAxisValueFromIndexMethod=n=>{const e=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let r=0;r<n.length;++r)r===0?e.push(` if (index == ${r}) { return ${n[r]}; }`):r===n.length-1?e.push(` else { return ${n[r]}; }`):e.push(` else if (index == ${r}) { return ${n[r]}; }`);return e.push(" }"),e.join(`
- `)},parseConcatAttributes=n=>attribute_with_cache_key_1$9.createAttributeWithCacheKey({axis:n.attributes.getInt("axis")});concat$1.parseConcatAttributes=parseConcatAttributes;const validateInputs$g=n=>{if(!n||n.length<1)throw new Error("too few inputs");const e=n[0].type,r=n[0].dims.length;if(e==="string")throw new Error("string tensor is not supported yet");for(const t of n){if(t.type!==e)throw new Error("input tensors should be one type");if(t.dims.length!==r)throw new Error("input tensors should have the same shape")}};var conv={},convGrouped={},fuseUtils={},unaryOp={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.tanh=n.tan=n.sqrt=n.sin=n.sigmoid=n.relu=n.not=n.neg=n.log=n.parseLeakyReluAttributes=n.leakyRelu=n.identity=n.floor=n.exp=n.parseEluAttributes=n.elu=n.cos=n.ceil=n.clipV11=n.parseClipAttributes=n.clip=n.atan=n.asin=n.acos=n.abs=n.glslTanh=n.glslTan=n.glslSqrt=n.glslSigmoid=n.glslRelu=n.glslSin=n.glslNot=n.glslNeg=n.glslLog=n.glslLeakyRelu=n.glslIdentity=n.glslClip=n.glslFloor=n.glslExp=n.glslElu=n.glslCos=n.glslCeil=n.glslAtan=n.glslAsin=n.glslAcos=n.glslAbs=void 0;const e=attributeWithCacheKey,r=util,t=glslDefinitions,o=glslSource,i=types;function l(){return U("abs")}n.glslAbs=l;function a(){return U("acos")}n.glslAcos=a;function s(){return U("asin")}n.glslAsin=s;function u(){return U("atan")}n.glslAtan=u;function c(){return U("ceil")}n.glslCeil=c;function f(){return U("cos")}n.glslCos=f;function d(O){const k="elu";return{body:`
- const float alpha = float(${O});
-
- float ${k}_(float a) {
- return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
- }
- vec4 ${k}_(vec4 v) {
- return vec4(${k}_(v.x), ${k}_(v.y), ${k}_(v.z), ${k}_(v.w));
- }
- `,name:k,type:t.FunctionType.ValueBased}}n.glslElu=d;function m(){return U("exp")}n.glslExp=m;function _(){return U("floor")}n.glslFloor=_;function S(O,k){const te="clip";return{body:`
- const float min = float(${O});
- const float max = float(${k});
-
- float ${te}_(float a) {
- return clamp(a, min, max);
- }
- vec4 ${te}_(vec4 v) {
- return clamp(v, min, max);
- }
- `,name:te,type:t.FunctionType.ValueBased}}n.glslClip=S;function E(){const O="indentity";return{body:`
- float ${O}_(float a) {
- return a;
- }
- vec4 ${O}_(vec4 v) {
- return v;
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslIdentity=E;function $(O){const k="leakyRelu";return{body:`
- const float alpha = float(${O});
-
- float ${k}_(float a) {
- return a < 0.0 ? a * alpha : a;
- }
- vec4 ${k}_(vec4 v) {
- return vec4(${k}_(v.x), ${k}_(v.y), ${k}_(v.z), ${k}_(v.w));
- }
- `,name:k,type:t.FunctionType.ValueBased}}n.glslLeakyRelu=$;function y(){return U("log")}n.glslLog=y;function v(){const O="neg";return{body:`
- float ${O}_(float a) {
- return -a;
- }
- vec4 ${O}_(vec4 v) {
- return -v;
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslNeg=v;function A(){const O="not";return{body:`
- float ${O}_(float a) {
- return float( ! bool(a) );
- }
- bool ${O}_(bool a) {
- return !a;
- }
- vec4 ${O}_(vec4 v) {
- return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
- }
- bvec4 ${O}_(bvec4 v) {
- return bvec4(!v.x, !v.y, !v.z, !v.w);
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslNot=A;function P(){return U("sin")}n.glslSin=P;function C(){const O="relu";return{body:`
- float ${O}_(float a) {
- return max( a, 0.0 );
- }
- vec4 ${O}_(vec4 v) {
- return max( v, 0.0 );
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslRelu=C;function L(){const O="sigmoid";return{body:`
- float ${O}_(float a) {
- return 1.0 / (1.0 + exp(-a));
- }
- vec4 ${O}_(vec4 v) {
- return 1.0 / (1.0 + exp(-v));
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslSigmoid=L;function B(){return U("sqrt")}n.glslSqrt=B;function V(){return U("tan")}n.glslTan=V;function j(){const O="tanh";return{body:`
- float ${O}_(float a) {
- a = clamp(a, -10., 10.);
- a = exp(2.*a);
- return (a - 1.) / (a + 1.);
- }
- vec4 ${O}_(vec4 v) {
- v = clamp(v, -10., 10.);
- v = exp(2.*v);
- return (v - 1.) / (v + 1.);
- }
- `,name:O,type:t.FunctionType.ValueBased}}n.glslTanh=j;function U(O){return{body:`
- float ${O}_(float a) {
- return ${O}(a);
- }
- vec4 ${O}_(vec4 v) {
- return ${O}(v);
- }
- `,name:O,type:t.FunctionType.ValueBased}}const re=(O,k,te,$e)=>{const Ee=O.session.pack?i.TextureType.packed:i.TextureType.unpacked,Oe=o.getGlsl(O.session.backend.glContext.version);return Object.assign(Object.assign({},k),{output:{dims:te.dims,type:te.type,textureType:Ee},shaderSource:`
- ${$e.body}
- void main() {
- vec4 v = ${Oe.texture2D}(A, TexCoords);
- v = ${$e.name}_(v);
- ${Oe.output} = v;
- }
- `,hasMain:!0})},Z=(O,k,te,$e)=>{const Ee=O.session.pack?i.TextureType.packed:i.TextureType.unpacked,Oe={name:te.name,inputTypes:[Ee],inputNames:["A"],cacheHint:$e};return Object.assign(Object.assign({},Oe),{get:()=>re(O,Oe,k,te)})},ee=(O,k)=>[O.run(Z(O,k[0],l()),k)];n.abs=ee;const X=(O,k)=>[O.run(Z(O,k[0],a()),k)];n.acos=X;const J=(O,k)=>[O.run(Z(O,k[0],s()),k)];n.asin=J;const ae=(O,k)=>[O.run(Z(O,k[0],u()),k)];n.atan=ae;const de=(O,k,te)=>[O.run(Z(O,k[0],S(te.min,te.max),te.cacheKey),k)];n.clip=de;const M=O=>e.createAttributeWithCacheKey({min:O.attributes.getFloat("min",r.MIN_CLIP),max:O.attributes.getFloat("max",r.MAX_CLIP)});n.parseClipAttributes=M;const we=(O,k)=>{const te=le(O,k);return n.clip(O,[k[0]],te)};n.clipV11=we;const le=(O,k)=>{if(k.length>=3&&(!O.session.isInitializer(k[1].dataId)||!O.session.isInitializer(k[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const te=k.length>=3?k[1].numberData[0]:r.MIN_CLIP,$e=k.length>=3?k[2].numberData[0]:r.MAX_CLIP;return e.createAttributeWithCacheKey({min:te,max:$e})},me=(O,k)=>[O.run(Z(O,k[0],c()),k)];n.ceil=me;const Y=(O,k)=>[O.run(Z(O,k[0],f()),k)];n.cos=Y;const ie=(O,k,te)=>[O.run(Z(O,k[0],d(te.alpha),te.cacheKey),k)];n.elu=ie;const ve=O=>e.createAttributeWithCacheKey({alpha:O.attributes.getFloat("alpha",1)});n.parseEluAttributes=ve;const ge=(O,k)=>[O.run(Z(O,k[0],m()),k)];n.exp=ge;const Te=(O,k)=>[O.run(Z(O,k[0],_()),k)];n.floor=Te;const Se=(O,k)=>[O.run(Z(O,k[0],E()),k)];n.identity=Se;const Be=(O,k,te)=>[O.run(Z(O,k[0],$(te.alpha),te.cacheKey),k)];n.leakyRelu=Be;const _e=O=>e.createAttributeWithCacheKey({alpha:O.attributes.getFloat("alpha",.01)});n.parseLeakyReluAttributes=_e;const ye=(O,k)=>[O.run(Z(O,k[0],y()),k)];n.log=ye;const Ue=(O,k)=>[O.run(Z(O,k[0],v()),k)];n.neg=Ue;const He=(O,k)=>[O.run(Z(O,k[0],A()),k)];n.not=He;const Re=(O,k)=>[O.run(Z(O,k[0],C()),k)];n.relu=Re;const ke=(O,k)=>[O.run(Z(O,k[0],L()),k)];n.sigmoid=ke;const Ae=(O,k)=>[O.run(Z(O,k[0],P()),k)];n.sin=Ae;const qe=(O,k)=>[O.run(Z(O,k[0],B()),k)];n.sqrt=qe;const Me=(O,k)=>[O.run(Z(O,k[0],V()),k)];n.tan=Me;const Ye=(O,k)=>[O.run(Z(O,k[0],j()),k)];n.tanh=Ye})(unaryOp);Object.defineProperty(fuseUtils,"__esModule",{value:!0});fuseUtils.parseInternalActivationAttributes=fuseUtils.getActicationSnippet=void 0;const util_1$j=util,unary_op_1=unaryOp;function getActicationSnippet(n){let e;switch(n.activation){case"Relu":e=unary_op_1.glslRelu();break;case"Sigmoid":e=unary_op_1.glslSigmoid();break;case"Clip":e=unary_op_1.glslClip(n.clipMin,n.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const r=e.name,t=e.body,o=`value = ${r}_(value);`;return{activationFunction:t,applyActivation:o}}fuseUtils.getActicationSnippet=getActicationSnippet;const parseInternalActivationAttributes=n=>{const e=n.getString("activation","");if(e==="Clip"){const[r,t]=n.getFloats("activation_params",[util_1$j.MIN_CLIP,util_1$j.MAX_CLIP]);return{activation:e,clipMax:t,clipMin:r,activationCacheKey:`${e}:${r},${t}`}}return{activation:e,activationCacheKey:e}};fuseUtils.parseInternalActivationAttributes=parseInternalActivationAttributes;Object.defineProperty(convGrouped,"__esModule",{value:!0});convGrouped.createUnpackedGroupedConvProgramInfoLoader=void 0;const instrument_1$9=instrument,glsl_source_1$b=glslSource,types_1$h=types,conv_1$2=conv,fuse_utils_1$3=fuseUtils,createUnpackedGroupedConvProgramMetadata=(n,e)=>({name:"GroupedConv",inputNames:n?["X","W","Bias"]:["X","W"],inputTypes:n?[types_1$h.TextureType.unpacked,types_1$h.TextureType.unpacked,types_1$h.TextureType.unpacked]:[types_1$h.TextureType.unpacked,types_1$h.TextureType.unpacked],cacheHint:e}),createUnpackedGroupedConvProgramInfo=(n,e,r,t)=>{const i=e.length>2?"value += getBias(output_channel);":"",l=e[0].dims.slice(),a=e[1].dims.slice(),s=a[0]/t.group;instrument_1$9.Logger.verbose("GroupedConv",`autpPad:${t.autoPad}, dilations:${t.dilations}, group:${t.group}, kernelShape:${t.kernelShape}, pads:${t.pads}, strides:${t.strides}`);const u=conv_1$2.calculateOutputShape(l,a,t.dilations,t.pads,t.strides),c=glsl_source_1$b.getGlsl(n.session.backend.glContext.version),{activationFunction:f,applyActivation:d}=fuse_utils_1$3.getActicationSnippet(t),m=`
- const ivec2 strides = ivec2(${t.strides[0]}, ${t.strides[1]});
- const ivec2 pads = ivec2(${t.pads[0]}, ${t.pads[1]});
- ${f}
- 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 / ${s};
-
- float value = 0.0;
- for (int wInChannel = 0; wInChannel < ${a[1]}; wInChannel++) {
- int input_channel = group_id * ${a[1]} + wInChannel;
- for (int wHeight = 0; wHeight < ${a[2]}; wHeight++) {
- int xHeight = xRCCorner.x + wHeight * ${t.dilations[0]};
-
- if (xHeight < 0 || xHeight >= ${l[2]}) {
- continue;
- }
-
- for (int wWidth = 0; wWidth < ${a[3]}; wWidth++) {
- int xWidth = xRCCorner.y + wWidth * ${t.dilations[1]};
- if (xWidth < 0 || xWidth >= ${l[3]}) {
- continue;
- }
-
- float xVal = getX(batch, input_channel, xWidth, xHeight);
- float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
- value += xVal*wVal;
- }
- }
- }
- ${i}
- ${d}
- ${c.output} = vec4(value, .0, .0, .0);
- }
- `;return Object.assign(Object.assign({},r),{output:{dims:u,type:e[0].type,textureType:types_1$h.TextureType.unpacked},shaderSource:m,hasMain:!0})},createUnpackedGroupedConvProgramInfoLoader=(n,e,r)=>{const t=createUnpackedGroupedConvProgramMetadata(e.length>2,r.cacheKey);return Object.assign(Object.assign({},t),{get:()=>createUnpackedGroupedConvProgramInfo(n,e,t,r)})};convGrouped.createUnpackedGroupedConvProgramInfoLoader=createUnpackedGroupedConvProgramInfoLoader;var convPack={},im2colPack={};Object.defineProperty(im2colPack,"__esModule",{value:!0});im2colPack.createPackedIm2ColProgramInfoLoader=void 0;const glsl_source_1$a=glslSource,types_1$g=types,packing_utils_1$1=packingUtils,createPackedIm2ColProgramMetadata=n=>({name:"Im2Col (packed)",inputNames:["A"],inputTypes:[types_1$g.TextureType.packed],cacheHint:n}),createPackedIm2ColProgramInfo=(n,e,r,t,o,i)=>{const l=r.dims,a=t.dims,s=2,u=3,c=o.length,f=[a[1]*a[2]*a[3],o[2]*o[3]],d=a[2]*a[3],m=packing_utils_1$1.unpackFromChannel(),_=glsl_source_1$a.getGlsl(n.session.backend.glContext.version);let S="";for(let $=0;$<=1;$++)for(let y=0;y<=1;y++)S+=`
- blockIndex = rc.x + ${y};
- pos = rc.y + ${$};
-
- if(blockIndex < ${f[1]} && pos < ${f[0]}) {
- offsetY = int(blockIndex / (${o[c-1]})) * ${i.strides[0]} -
- ${i.pads[0]};
- d0 = offsetY + ${i.dilations[0]} * (imod(pos, ${d}) / ${a[2]});
-
- if(d0 < ${l[s]} && d0 >= 0) {
- offsetX = imod(blockIndex, ${o[c-1]}) * ${i.strides[1]} -
- ${i.pads[1]};
- d1 = offsetX + ${i.dilations[1]} * imod(imod(pos, ${d}), ${a[2]});
-
- if(d1 < ${l[u]} && d1 >= 0) {
-
- ch = int(float(pos)/ ${d}.);
- innerDims = vec2(d0, d1);
- result[${$*2+y}] = getChannel(
- getA(0, ch, int(innerDims.x),
- int(innerDims.y)), innerDims);
- }
- }
- }
-
- `;const E=`
- ${m}
-
- void main() {
- ivec2 rc = getOutputCoords();
- vec4 result = vec4(0.0);
- int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
- vec2 innerDims;
- ${S}
- ${_.output} = result;
- }
- `;return Object.assign(Object.assign({},e),{output:{dims:f,type:r.type,textureType:types_1$g.TextureType.packed},shaderSource:E,hasMain:!0})},createPackedIm2ColProgramInfoLoader=(n,e,r,t,o)=>{const i=createPackedIm2ColProgramMetadata(o.cacheKey);return Object.assign(Object.assign({},i),{get:()=>createPackedIm2ColProgramInfo(n,i,e,r,t,o)})};im2colPack.createPackedIm2ColProgramInfoLoader=createPackedIm2ColProgramInfoLoader;var matmulPack={},matmul={};Object.defineProperty(matmul,"__esModule",{value:!0});matmul.getBiasForMatmul=matmul.createMatmulProgramInfoLoader=matmul.parseMatMulAttributes=matmul.matMul=void 0;const util_1$i=util,types_1$f=types,utils_1$4=utils,fuse_utils_1$2=fuseUtils,matmul_pack_1$1=matmulPack,matMul=(n,e,r)=>(validateInputs$f(e),n.session.pack?[n.run(matmul_pack_1$1.createPackedMatmulProgramInfoLoader(n,e,r),e)]:[n.run(createMatmulProgramInfoLoader(e,r),e)]);matmul.matMul=matMul;const parseMatMulAttributes=n=>fuse_utils_1$2.parseInternalActivationAttributes(n.attributes);matmul.parseMatMulAttributes=parseMatMulAttributes;const createMatmulProgramMetadata=(n,e)=>({name:"MatMul",inputNames:n?["A","B","Bias"]:["A","B"],inputTypes:n?[types_1$f.TextureType.unpacked,types_1$f.TextureType.unpacked,types_1$f.TextureType.unpacked]:[types_1$f.TextureType.unpacked,types_1$f.TextureType.unpacked],cacheHint:e});function createMatmulProgramInfo(n,e,r){const t=e[0].dims,o=e[1].dims,i=util_1$i.BroadcastUtil.calcShape(t,o,!0);if(!i)throw new Error("Can't use matmul on the given tensors");const l=utils_1$4.getCoordsDataType(i.length),a=utils_1$4.getGlChannels(),{activationFunction:s,applyActivation:u}=fuse_utils_1$2.getActicationSnippet(r),c=e.length>2,f=c?"value += getBiasForMatmul();":"",d=c?`${getBiasForMatmul(l,a,e[2].dims,i,!1)}`:"",m=i.length,_=t.length,S=o.length,E=t[t.length-1],$=`
- ${s}
- ${d}
- float process(int indices[${m}]) {
- int a[${_}];
- int b[${S}];
- bcastMatmulIndices_A(indices, a);
- bcastMatmulIndices_B(indices, b);
-
- float value;
- for (int k=0; k<${E}; ++k) {
- a[${_-1}] = k;
- b[${S-2}] = k;
- value += _A(a) * _B(b);
- }
- ${f}
- ${u}
- return value;
- }`;return Object.assign(Object.assign({},n),{output:{dims:i,type:e[0].type,textureType:types_1$f.TextureType.unpacked},shaderSource:$})}function createMatmulProgramInfoLoader(n,e){const r=createMatmulProgramMetadata(n.length>2,e.activationCacheKey);return Object.assign(Object.assign({},r),{get:()=>createMatmulProgramInfo(r,n,e)})}matmul.createMatmulProgramInfoLoader=createMatmulProgramInfoLoader;const validateInputs$f=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 getBiasForMatmul(n,e,r,t,o){let i="";const l=r.length,a=t.length,s=a-l;a<2&&l>0?i="coords":i=r.map((S,E)=>`coords.${e[E+s]}`).join(", ");const c=util_1$i.BroadcastUtil.getBroadcastDims(r,t).map(S=>`coords.${e[S+s]} = 0;`).join(`
- `),d=util_1$i.ShapeUtil.size(r)===1;let m="vec4(outputValue.xx, outputValue.yy)";return d&&(m="vec4(outputValue.x)"),o?`
- vec4 getBiasForMatmul() {
- ${n} coords = getOutputCoords();
- ${c}
- vec4 outputValue = getBias(${i});
- return ${m};
- }`:`
- float getBiasForMatmul() {
- ${n} coords = getOutputCoords();
- ${c}
- return getBias(coords.x);
- }`}matmul.getBiasForMatmul=getBiasForMatmul;Object.defineProperty(matmulPack,"__esModule",{value:!0});matmulPack.createPackedMatmulProgramInfoLoader=void 0;const util_1$h=util,util_2=util,glsl_source_1$9=glslSource,types_1$e=types,utils_1$3=utils,fuse_utils_1$1=fuseUtils,matmul_1$1=matmul,createPackedMatmulProgramMetadata=(n,e)=>({name:"MatMul (packed)",inputNames:n?["A","B","Bias"]:["A","B"],inputTypes:n?[types_1$e.TextureType.packed,types_1$e.TextureType.packed,types_1$e.TextureType.packed]:[types_1$e.TextureType.packed,types_1$e.TextureType.packed],cacheHint:e}),createPackedMatmulProgramInfo=(n,e,r,t)=>{const o=r.length>2,i=o?"value += getBiasForMatmul();":"",l=r[0].dims,a=r[1].dims,s=util_1$h.BroadcastUtil.calcShape(l,a,!0),u=!util_2.ShapeUtil.areEqual(r[0].dims,r[1].dims);if(!s)throw new Error("Can't use matmul on the given tensors");const c=l[l.length-1],f=Math.ceil(c/2),d=l.length,m=a.length,_=glsl_source_1$9.getGlsl(n.session.backend.glContext.version),S=utils_1$3.getCoordsDataType(s.length),E=s.length,$=utils_1$3.getGlChannels(),{activationFunction:y,applyActivation:v}=fuse_utils_1$1.getActicationSnippet(t),A=o?`${matmul_1$1.getBiasForMatmul(S,$,r[2].dims,s,!0)}`:"",P=u?`${getBcastSamplerForMatmul(S,$,r,s)}`:"",C=u?"getAAtOutCoordsMatmul(i)":`getA(${getA($,d)})`,L=u?"getBAtOutCoordsMatmul(i)":`getB(${getB($,m)})`,B=u?"":`${S} rc =
- getOutputCoords(); int lastDim = rc.${$[E-1]}; rc.${$[E-1]} =
- rc.${$[E-2]}; rc.${$[E-2]} = lastDim;
- `,V=`
- ${P}
- ${A}
- ${y}
- void main() {
- ${B}
-
- vec4 value = vec4(0);
- for (int i = 0; i < ${f}; i++) {
- vec4 a = ${C};
- vec4 b = ${L};
-
- value += (a.rrbb * b.rgrg);
- value += (a.ggaa * b.baba);
- }
- ${i}
- ${v}
- ${_.output} = value;
- }`;return Object.assign(Object.assign({},e),{output:{dims:s,type:r[0].type,textureType:types_1$e.TextureType.packed},shaderSource:V,hasMain:!0})},createPackedMatmulProgramInfoLoader=(n,e,r)=>{const t=createPackedMatmulProgramMetadata(e.length>2,r.activationCacheKey);return Object.assign(Object.assign({},t),{get:()=>createPackedMatmulProgramInfo(n,t,e,r)})};matmulPack.createPackedMatmulProgramInfoLoader=createPackedMatmulProgramInfoLoader;function getBcastSamplerForMatmul(n,e,r,t){let o=[],i=[];const l=r[0].dims,a=r[1].dims,s=l.length,u=a.length,c=t.length,f=c-s,d=c-u;o=l.map((v,A)=>`coords.${e[A+f]}`),o[s-1]="i*2",o.join(", "),i=a.map((v,A)=>`coords.${e[A+d]}`),i[u-2]="i*2",i.join(", ");const m=util_1$h.BroadcastUtil.getBroadcastDims(l,t),_=util_1$h.BroadcastUtil.getBroadcastDims(a,t),S=m.map(v=>`coords.${e[v+f]} = 0;`).join(`
- `),E=_.map(v=>`coords.${e[v+d]} = 0;`).join(`
- `),$=`int lastDim = coords.${e[c-1]};
- coords.${e[c-1]} = coords.${e[c-2]};
- coords.${e[c-2]} = lastDim;`;return`
- vec4 getAAtOutCoordsMatmul(int i) {
- ${n} coords = getOutputCoords();
- ${$}
- ${S}
- vec4 outputValue = getA(${o});
- return outputValue;
- }
-
- vec4 getBAtOutCoordsMatmul(int i) {
- ${n} coords = getOutputCoords();
- ${$}
- ${E}
- vec4 outputValue = getB(${i});
- return outputValue;
- }`}function getA(n,e){let r="";for(let t=0;t<e-2;t++)r+=`rc.${n[t]}, `;return r+=`rc.${n[e-2]}, i*2`,r}function getB(n,e){let r="";for(let t=0;t<e-2;t++)r+=`rc.${n[t]}, `;return r+=`i*2, rc.${n[e-1]}`,r}Object.defineProperty(convPack,"__esModule",{value:!0});convPack.conv2DPacked=convPack.conv2DPackedPointwise=void 0;const conv_1$1=conv,im2col_pack_1=im2colPack,matmul_pack_1=matmulPack,conv2DPackedPointwise=(n,e,r)=>{const t=e[0].dims,o=e[1].dims,i=conv_1$1.calculateOutputShape(t,o,r.dilations,r.pads,r.strides),l=n.reshapePacked(e[0],[t[1],t[2]*t[3]]),a=n.reshapePacked(e[1],[o[0],o[1]]),s=e.length>2?[a,l,e[2]]:[a,l],u=n.run(matmul_pack_1.createPackedMatmulProgramInfoLoader(n,s,r),s);return n.reshapePacked(u,i)};convPack.conv2DPackedPointwise=conv2DPackedPointwise;const conv2DPacked=(n,e,r)=>{const t=e[0].dims,o=e[1].dims,i=conv_1$1.calculateOutputShape(t,o,r.dilations,r.pads,r.strides),l=n.run(im2col_pack_1.createPackedIm2ColProgramInfoLoader(n,e[0],e[1],i,r),[e[0]]),a=n.reshapePacked(e[1],[o[0],o[1]*o[2]*o[3]]),s=e.length===3?[a,l,e[2]]:[a,l],u=n.run(matmul_pack_1.createPackedMatmulProgramInfoLoader(n,s,r),s);return n.reshapePacked(u,i)};convPack.conv2DPacked=conv2DPacked;var dotProduct={},im2col={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.calculateIm2ColDims=n.createIm2ColProgramInfoLoader=void 0;const e=types,r=l=>({name:"Im2Col",inputNames:["X"],inputTypes:[e.TextureType.unpacked],cacheHint:l}),t=(l,a,s,u,c,f)=>{const d=s.dims,m=u.dims,_=c.length,S=n.calculateIm2ColDims(d,m,c,4),E=`
- const int XC = ${d[1]};
- const int XH = ${d[2]};
- const int XW = ${d[3]};
- const int KH = ${f.kernelShape[0]};
- const int KW = ${f.kernelShape[1]};
- const int dilationH = ${f.dilations[0]};
- const int dilationW = ${f.dilations[1]};
- const int strideH = ${f.strides[0]};
- const int strideW = ${f.strides[1]};
- const int padH = ${f.pads[0]};
- const int padW = ${f.pads[1]};
- const int KHKW = KH*KW;
- const int XCKHKW = XC * KHKW;
- const int outputChannels = 4;
- vec4 process(int indices[${_}]) {
- 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[${d.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({},a),{output:{dims:S,type:s.type,textureType:e.TextureType.packedLastDimension},shaderSource:E})},o=(l,a,s,u,c)=>{const f=r(c.cacheKey);return Object.assign(Object.assign({},f),{get:()=>t(l,f,a,s,u,c)})};n.createIm2ColProgramInfoLoader=o;const i=(l,a,s,u=4)=>[s[0],s[2],s[3],Math.ceil(l[1]*a[2]*a[3]/u)];n.calculateIm2ColDims=i})(im2col);Object.defineProperty(dotProduct,"__esModule",{value:!0});dotProduct.createDotProductProgramInfoLoader=void 0;const util_1$g=util,glsl_source_1$8=glslSource,types_1$d=types,fuse_utils_1=fuseUtils,im2col_1=im2col,createDotProductProgramMetadata=(n,e)=>({name:"ConvDotProduct",inputNames:n?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:n?[types_1$d.TextureType.unpacked,types_1$d.TextureType.packedLastDimension,types_1$d.TextureType.unpacked]:[types_1$d.TextureType.unpacked,types_1$d.TextureType.packedLastDimension],cacheKey:e.activationCacheKey}),createDotProductProgramInfo=(n,e,r,t,o)=>{const i=r[0].dims,l=r[1].dims,a=[l[0],Math.ceil(i[1]*l[2]*l[3]/4)],s=im2col_1.calculateIm2ColDims(i,l,t),[u,c]=n.calculateTextureWidthAndHeight(a,types_1$d.TextureType.packedLastDimension),f=util_1$g.ShapeUtil.computeStrides(s),[d,m]=n.calculateTextureWidthAndHeight(s,types_1$d.TextureType.packedLastDimension),_=t.length,S=r.length<3?"0.0":"_B(b)",E=Math.ceil(i[1]*l[2]*l[3]/4),{activationFunction:$,applyActivation:y}=fuse_utils_1.getActicationSnippet(o),v=glsl_source_1$8.getGlsl(n.session.backend.glContext.version),A=`
- ${$}
- float process(int indices[${_}]) {
- 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] * ${f[0]} + im2col[1] * ${f[1]} + im2col[2] * ${f[2]};
- int kernelOffset = indices[1] * ${a[1]};
- float value = ${S};
- for (int i = 0; i < ${E}; ++i) {
- vec2 im2colCoords = offsetToCoords(im2colOffset, ${d}, ${m});
- vec2 kernelCoords = offsetToCoords(kernelOffset, ${u}, ${c});
- value += dot(${v.texture2D}(Im2Col, im2colCoords), ${v.texture2D}(K, kernelCoords));
- ++im2colOffset;
- ++kernelOffset;
- }
- ${y}
- return value;
- }`;return Object.assign(Object.assign({},e),{output:{dims:t,type:r[0].type,textureType:types_1$d.TextureType.unpacked},shaderSource:A})},createDotProductProgramInfoLoader=(n,e,r,t)=>{const o=createDotProductProgramMetadata(e.length>2,t);return Object.assign(Object.assign({},o),{get:()=>createDotProductProgramInfo(n,o,e,r,t)})};dotProduct.createDotProductProgramInfoLoader=createDotProductProgramInfoLoader;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.parseConvAttributes=n.conv=n.calculateOutputShape=void 0;const e=attributeWithCacheKey,r=util,t=convGrouped,o=convPack,i=dotProduct,l=fuseUtils,a=im2col,s=matmul,u=($,y,v,A,P)=>{const C=$[0],L=$.slice(2),B=L.length,V=y[0],U=y.slice(2).map((X,J)=>X+(X-1)*(v[J]-1)),Z=L.map((X,J)=>X+A[J]+A[J+B]).map((X,J)=>Math.floor((X-U[J]+P[J])/P[J]));return[C,V].concat(...Z)};n.calculateOutputShape=u;const c=($,y,v)=>(E(y,v),f($,y,v));n.conv=c;const f=($,y,v)=>{const A=_(v,y),P=$.session.pack,C=A.kernelShape[0]===1&&A.kernelShape[1]===1;return A.group>1?[$.run(t.createUnpackedGroupedConvProgramInfoLoader($,y,A),y)]:C&&P?[d($,y,A)]:P&&y[0].dims.length===4&&y[0].dims[0]===1&&!C?[o.conv2DPacked($,y,A)]:[m($,y,A)]},d=($,y,v)=>{const A=y[0].dims,P=y[1].dims,C=n.calculateOutputShape(A,P,v.dilations,v.pads,v.strides),L=$.reshapeUnpacked(y[0],[A[1],A[2]*A[3]]),B=$.reshapeUnpacked(y[1],[P[0],P[1]]),V=y.length>2?[B,L,y[2]]:[B,L],j=$.run(s.createMatmulProgramInfoLoader(V,v),V);return $.reshapeUnpacked(j,C)},m=($,y,v)=>{const A=y[0].dims,P=y[1].dims,C=n.calculateOutputShape(A,P,v.dilations,v.pads,v.strides),L=$.run(a.createIm2ColProgramInfoLoader($,y[0],y[1],C,v),[y[0]]),B=y.length===3?[L,y[1],y[2]]:[L,y[1]];return $.run(i.createDotProductProgramInfoLoader($,y,C,v),B)},_=($,y)=>{const v=$.kernelShape.slice();if($.kernelShape.length===0)for(let C=2;C<y[1].dims.length;++C)v.push(y[1].dims[C]);const A=$.pads.slice();r.PoolConvUtil.adjustPadsBasedOnAutoPad(y[0].dims,$.strides,$.dilations,v,A,$.autoPad);const P=Object.assign({},$);return Object.assign(P,{kernelShape:v,pads:A,cacheKey:$.cacheKey}),P},S=$=>{const y=$.attributes,v=l.parseInternalActivationAttributes(y),A=y.getString("auto_pad","NOTSET"),P=y.getInts("dilations",[1,1]),C=y.getInt("group",1),L=y.getInts("kernel_shape",[]),B=y.getInts("pads",[0,0,0,0]),V=y.getInts("strides",[1,1]);return e.createAttributeWithCacheKey(Object.assign({autoPad:A,dilations:P,group:C,kernelShape:L,pads:B,strides:V},v))};n.parseConvAttributes=S;const E=($,y)=>{if(!$||$.length!==2&&$.length!==3)throw new Error("Conv requires 2 or 3 inputs");if($[0].dims.length!==4||$[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");const v=$[0].dims[1],A=$[1].dims[1]*y.group;if(v!==A)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if($.length===3&&($[2].dims.length!==1||$[1].dims[0]!==$[2].dims[0]))throw new Error("invalid bias");const P=$[0].dims.length-2;if(y.dilations.length!==P)throw new Error(`dilations should be ${P}D`);if(y.strides.length!==P)throw new Error(`strides should be ${P}D`);if(y.pads.length!==P*2)throw new Error(`pads should be ${P*2}D`);if(y.kernelShape.length!==0&&y.kernelShape.length!==$[1].dims.length-2)throw new Error("invalid kernel shape");if($[0].type!=="float32"||$[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if($.length===3&&$[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}})(conv);var depthToSpace$1={},transpose$1={};Object.defineProperty(transpose$1,"__esModule",{value:!0});transpose$1.parseTransposeAttributes=transpose$1.transpose=void 0;const attribute_with_cache_key_1$8=attributeWithCacheKey,util_1$f=util,types_1$c=types,transposeProgramMetadata={name:"Transpose",inputNames:["A"],inputTypes:[types_1$c.TextureType.unpacked]},transpose=(n,e,r)=>(validateInputs$e(e),[n.run(Object.assign(Object.assign({},transposeProgramMetadata),{cacheHint:r.cacheKey,get:()=>createTransposeProgramInfo(n,e[0],r.perm)}),e)]);transpose$1.transpose=transpose;const parseTransposeAttributes=n=>attribute_with_cache_key_1$8.createAttributeWithCacheKey({perm:n.attributes.getInts("perm",[])});transpose$1.parseTransposeAttributes=parseTransposeAttributes;const createTransposeProgramInfo=(n,e,r)=>{const t=e.dims;r=getAdjustedPerm(t,r);const o=getOutputShape(t,r),i=t.length,l=`
- ${getPermFunctionBody("perm",r,i)}
- float process(int indices[${i}]) {
- int a[${i}];
- perm(a, indices);
- return _A(a);
- }`;return Object.assign(Object.assign({},transposeProgramMetadata),{output:{dims:o,type:e.type,textureType:types_1$c.TextureType.unpacked},shaderSource:l})},getAdjustedPerm=(n,e)=>(e&&e.length!==n.length&&(e=[...n.keys()].reverse()),e),getOutputShape=(n,e)=>(e=getAdjustedPerm(n,e),util_1$f.ShapeUtil.sortBasedOnPerm(n,e)),getPermFunctionBody=(n,e,r)=>{const t=[];t.push(`void ${n}(out int a[${r}], int src[${r}]) {`);for(let o=0;o<r;++o)t.push(` a[${e[o]}]=src[${o}];`);return t.push(" }"),t.join(`
- `)},validateInputs$e=n=>{if(!n||n.length!==1)throw new Error("Transpose requires 1 input.");if(n[0].type!=="float32"&&n[0].type!=="float64")throw new Error("input should be float tensor")};Object.defineProperty(depthToSpace$1,"__esModule",{value:!0});depthToSpace$1.parseDepthToSpaceAttributes=depthToSpace$1.depthToSpace=void 0;const transpose_1$2=transpose$1,depthToSpace=(n,e,r)=>{validateInputs$d(e);const t=r.blocksize,o=t*t,i=r.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],l=r.mode==="DCR"?[e[0].dims[0],t,t,e[0].dims[1]/o,e[0].dims[2],e[0].dims[3]]:[e[0].dims[0],e[0].dims[1]/o,t,t,e[0].dims[2],e[0].dims[3]],a=n.reshapeUnpacked(e[0],l),s={perm:i,cacheKey:`${i}`},[u]=transpose_1$2.transpose(n,[a],s),c=[e[0].dims[0],e[0].dims[1]/o,e[0].dims[2]*t,e[0].dims[3]*t];return[n.reshapeUnpacked(u,c)]};depthToSpace$1.depthToSpace=depthToSpace;const parseDepthToSpaceAttributes=n=>{const e=n.attributes.getInt("blocksize");if(e<1)throw new Error(`blocksize must be >= 1, but got : ${e} for DepthToSpace`);const r=n.attributes.getString("mode","DCR");if(r!=="DCR"&&r!=="CRD")throw new Error(`unrecognized mode: ${r} for DepthToSpace`);return{mode:r,blocksize:e}};depthToSpace$1.parseDepthToSpaceAttributes=parseDepthToSpaceAttributes;const validateInputs$d=n=>{if(n.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${n.length}`);if(n[0].type==="string"||n[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")};var flatten$1={};Object.defineProperty(flatten$1,"__esModule",{value:!0});flatten$1.parseFlattenAttributes=flatten$1.flatten=void 0;const util_1$e=util,flatten=(n,e,r)=>{validateInputs$c(e,r);const t=util_1$e.ShapeUtil.flattenShape(e[0].dims,r);return[n.reshapeUnpacked(e[0],t)]};flatten$1.flatten=flatten;const parseFlattenAttributes=n=>n.attributes.getInt("axis",1);flatten$1.parseFlattenAttributes=parseFlattenAttributes;const validateInputs$c=(n,e)=>{if(!n||n.length!==1)throw new Error("Flatten requires 1 input.");const r=n[0].dims.length;if(r===0)throw new Error("scalar tensor is not supported.");if(e<-r||e>r)throw new Error("Invalid axis");if(n[0].type==="string")throw new Error("string tensor is not supported.")};var gather$1={},operators={};Object.defineProperty(operators,"__esModule",{value:!0});operators.FLOAT_TYPES=operators.INT_TYPES=operators.NUMBER_TYPES=void 0;operators.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"];operators.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"];operators.FLOAT_TYPES=["float32","float64"];Object.defineProperty(gather$1,"__esModule",{value:!0});gather$1.parseGatherAttributes=gather$1.gather=void 0;const attribute_with_cache_key_1$7=attributeWithCacheKey,operators_1$3=operators,util_1$d=util,types_1$b=types,gather=(n,e,r)=>(validateInputs$b(e,r.axis),[n.run(createGatherProgramInfoLoader(n,e,r),e)]);gather$1.gather=gather;const parseGatherAttributes=n=>attribute_with_cache_key_1$7.createAttributeWithCacheKey({axis:n.attributes.getInt("axis",0)});gather$1.parseGatherAttributes=parseGatherAttributes;const gatherProgramMetadata={name:"Gather",inputNames:["A","B"],inputTypes:[types_1$b.TextureType.unpacked,types_1$b.TextureType.unpacked]},createGatherProgramInfo=(n,e,r,t)=>{const o=r[0].dims.slice(),i=r[1].dims.slice(),l=new Array(o.length+i.length-1);t=util_1$d.ShapeUtil.normalizeAxis(t,o.length);const a=[];for(let d=0;d<l.length;d++)d<t?(l[d]=o[d],a.push(`inputIdx[${d}] = outputIdx[${d}];`)):d<t+i.length?(l[d]=i[d-t],a.push(`indexDataIdx[${d-t}] = outputIdx[${d}];`)):(l[d]=o[d-i.length+1],a.push(`inputIdx[${d-i.length+1}] = outputIdx[${d}];`));const s=l.length||1,u=o.length,c=i.length||1,f=`
- float process(int outputIdx[${s}]) {
- int inputIdx[${u}];
- int indexDataIdx[${c}];
- indexDataIdx[0] = 0;
- ${a.join(`
- `)}
- int idx = int(_B(indexDataIdx));
- inputIdx[${t}] = idx < 0 ? idx + ${o[t]} : idx;
- return _A(inputIdx);
- }`;return Object.assign(Object.assign({},e),{output:{dims:l,type:r[0].type,textureType:types_1$b.TextureType.unpacked},shaderSource:f})},createGatherProgramInfoLoader=(n,e,r)=>{const t=Object.assign(Object.assign({},gatherProgramMetadata),{cacheHint:r.cacheKey});return Object.assign(Object.assign({},t),{get:()=>createGatherProgramInfo(n,t,e,r.axis)})},validateInputs$b=(n,e)=>{if(!n||n.length!==2)throw new Error("Gather requires 2 inputs.");const r=n[0].dims.length;if(r<1)throw new Error("Invalid input shape.");if(e<-r||e>r-1)throw new Error("Invalid axis.");if(operators_1$3.NUMBER_TYPES.indexOf(n[0].type)===-1)throw new Error("Invaid input type.");if(n[1].type!=="int32"&&n[1].type!=="int16")throw new Error("Invaid input type.")};var gemm$1={};Object.defineProperty(gemm$1,"__esModule",{value:!0});gemm$1.parseGemmAttributesV11=gemm$1.parseGemmAttributesV7=gemm$1.gemm=void 0;const attribute_with_cache_key_1$6=attributeWithCacheKey,util_1$c=util,types_1$a=types,gemm=(n,e,r)=>(validateInputs$a(e,r),[n.run(createGemmProgramInfoLoader(e,r),e)]);gemm$1.gemm=gemm;const parseGemmAttributes=(n,e)=>{const r=n.attributes.getInt("transA",0)!==0,t=n.attributes.getInt("transB",0)!==0,o=n.attributes.getFloat("alpha",1),i=n.attributes.getFloat("beta",1);return attribute_with_cache_key_1$6.createAttributeWithCacheKey({transA:r,transB:t,alpha:o,beta:i,isOptionalC:e})},parseGemmAttributesV7=n=>parseGemmAttributes(n,!1);gemm$1.parseGemmAttributesV7=parseGemmAttributesV7;const parseGemmAttributesV11=n=>parseGemmAttributes(n,!0);gemm$1.parseGemmAttributesV11=parseGemmAttributesV11;const createGemmProgramInfoLoader=(n,e)=>{const r={name:"Gemm",inputNames:n.length===3?["A","B","C"]:["A","B"],inputTypes:n.length===3?[types_1$a.TextureType.unpacked,types_1$a.TextureType.unpacked,types_1$a.TextureType.unpacked]:[types_1$a.TextureType.unpacked,types_1$a.TextureType.unpacked],key:e.cacheKey};return Object.assign(Object.assign({},r),{get:()=>createGemmProgramInfo(r,n,e)})},createGemmProgramInfo=(n,e,r)=>{const t=e[0].dims.slice(),o=e[1].dims.slice(),[i,l]=util_1$c.GemmUtil.getShapeOfGemmResult(t,r.transA,o,r.transB,e.length===3?e[2].dims:void 0),a=[i,l];if(!a)throw new Error("Can't use gemm on the given tensors");let s=t[t.length-1],u="";r.transA&&(s=t[0]),r.transA&&r.transB?u="value += _A_T(a) * _B_T(b);":r.transA&&!r.transB?u="value += _A_T(a) * _B(b);":!r.transA&&r.transB?u="value += _A(a) * _B_T(b);":!r.transA&&!r.transB&&(u="value += _A(a) * _B(b);");const c=a.length,f=e.length===3?`int c[${e[2].dims.length}];`:"",d=e.length===3?"bcastIndices_C(indices, c);":"",m=e.length===3?"value += beta * _C(c);":"",_=`
- float process(int indices[${c}]) {
- int a[${c}];
- int b[${c}];
- ${f}
-
- copyVec(indices, a);
- copyVec(indices, b);
- ${d}
-
- float value = 0.0;
- for (int k=0; k<${s}; ++k) {
- a[${c-1}] = k;
- b[${c-2}] = k;
- ${u}
- }
-
- value = value * alpha;
- ${m}
- return value;
- }`;return Object.assign(Object.assign({},n),{output:{dims:a,type:e[0].type,textureType:types_1$a.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:r.alpha},{name:"beta",type:"float",data:r.beta}],shaderSource:_})},validateInputs$a=(n,e)=>{if(!n)throw new Error("Input is missing");if(e.isOptionalC&&(n.length<2||n.length>3))throw new Error("Invaid input shape.");if(!e.isOptionalC&&n.length!==3)throw new Error("Gemm requires 3 inputs");if(n.length===3&&n[2].dims.length!==1&&n[2].dims.length!==2)throw new Error("Invalid input shape of C");if(n[0].type!=="float32"&&n[0].type!=="float64"||n[1].type!=="float32"&&n[1].type!=="float64"||n.length===3&&n[2].type!=="float32"&&n[2].type!=="float64")throw new Error("Invalid input type.");if(n[0].type!==n[1].type||n.length===3&&n[0].type!==n[2].type)throw new Error("Input types are mismatched")};var imageScaler$1={};Object.defineProperty(imageScaler$1,"__esModule",{value:!0});imageScaler$1.parseImageScalerAttributes=imageScaler$1.imageScaler=void 0;const attribute_with_cache_key_1$5=attributeWithCacheKey,types_1$9=types,imageScaler=(n,e,r)=>(validateInputs$9(e),[n.run(createImageScalerProgramInfoLoader(n,e,r),e)]);imageScaler$1.imageScaler=imageScaler;const parseImageScalerAttributes=n=>{const e=n.attributes.getFloat("scale"),r=n.attributes.getFloats("bias");return attribute_with_cache_key_1$5.createAttributeWithCacheKey({scale:e,bias:r})};imageScaler$1.parseImageScalerAttributes=parseImageScalerAttributes;const imageScalerProgramMetadata={name:"ImageScaler",inputNames:["X"],inputTypes:[types_1$9.TextureType.unpacked]},createImageScalerProgramInfo=(n,e,r,t)=>{const o=r[0].dims.slice(),i=o.length,a=`
- ${createGetBiasMethod(t.bias.length)}
- float process(int indices[${i}]) {
- return _X(indices) * scale + getBias(bias, indices[1]);
- }`;return Object.assign(Object.assign({},e),{output:{dims:o,type:r[0].type,textureType:types_1$9.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:t.bias.length,data:t.bias},{name:"scale",type:"float",data:t.scale}],shaderSource:a})},createImageScalerProgramInfoLoader=(n,e,r)=>{const t=Object.assign(Object.assign({},imageScalerProgramMetadata),{cacheHint:r.cacheKey});return Object.assign(Object.assign({},t),{get:()=>createImageScalerProgramInfo(n,t,e,r)})},createGetBiasMethod=n=>{const e=[`float getBias(float bias[${n}], int channel) {`];for(let r=0;r<n;++r)r===0?e.push(` if (channel == ${r}) { return bias[${r}]; }`):r===n-1?e.push(` else { return bias[${r}]; }`):e.push(` else if (channel == ${r}) { return bias[${r}]; }`);return e.push(" }"),e.join(`
- `)},validateInputs$9=n=>{if(!n||n.length!==1)throw new Error("ImageScaler requires 1 input.");if(n[0].dims.length!==4)throw new Error("Invalid input shape.");if(n[0].type!=="float32"&&n[0].type!=="float64")throw new Error("Invalid input type.")};var instanceNormalization$1={};Object.defineProperty(instanceNormalization$1,"__esModule",{value:!0});instanceNormalization$1.parseInstanceNormalizationAttributes=instanceNormalization$1.instanceNormalization=void 0;const glsl_source_1$7=glslSource,types_1$8=types,instanceNormalization=(n,e,r)=>{validateInputs$8(e);const t=n.run(createMeanAndVarianceProgramInfoLoader(e[0]),e);return[n.run(createComputeOutputProgramInfoLoader(n,e[0],r,t.dims),[e[0],t,e[1],e[2]])]};instanceNormalization$1.instanceNormalization=instanceNormalization;const parseInstanceNormalizationAttributes=n=>n.attributes.getFloat("epsilon",1e-5);instanceNormalization$1.parseInstanceNormalizationAttributes=parseInstanceNormalizationAttributes;const meanAndVarianceProgramMetadata={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[types_1$8.TextureType.unpacked]},createMeanAndVarianceProgramInfo=(n,e)=>{const r=e.dims.slice(),t=r[1],o=r[2]*r[3],i=[r[0],t],l=`
- 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(${o});
- 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(${o});
-
- return v;
- }`;return Object.assign(Object.assign({},n),{output:{dims:i,type:e.type,textureType:types_1$8.TextureType.packedLastDimension},shaderSource:l})},createMeanAndVarianceProgramInfoLoader=n=>Object.assign(Object.assign({},meanAndVarianceProgramMetadata),{get:()=>createMeanAndVarianceProgramInfo(meanAndVarianceProgramMetadata,n)}),computeOutputProgramMetadata={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[types_1$8.TextureType.unpacked,types_1$8.TextureType.packedLastDimension,types_1$8.TextureType.unpacked,types_1$8.TextureType.unpacked]},createComputeOutputProgramInfo=(n,e,r,t,o)=>{const i=glsl_source_1$7.getGlsl(n.session.backend.glContext.version),[l,a]=n.calculateTextureWidthAndHeight(o,types_1$8.TextureType.packedLastDimension),[s,u]=[l/4,a],c=`
- vec4 get_MeanAndVariance(int[2] mv) {
- int offset = indicesToOffset_MeanAndVariance(mv);
- vec2 coords = offsetToCoords(offset, ${s}, ${u});
- return ${i.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({},e),{output:{dims:r.dims,type:r.type,textureType:types_1$8.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:t}],shaderSource:c})},createComputeOutputProgramInfoLoader=(n,e,r,t)=>{const o=Object.assign(Object.assign({},computeOutputProgramMetadata),{cacheHint:`${r}`});return Object.assign(Object.assign({},o),{get:()=>createComputeOutputProgramInfo(n,o,e,r,t)})},validateInputs$8=n=>{if(!n||n.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const e=n[0],r=n[1],t=n[2];if(e.dims.length<3||r.dims.length!==1||t.dims.length!==1)throw new Error("Invalid input shape.");if(r.dims[0]!==e.dims[1]||t.dims[0]!==e.dims[1])throw new Error("Input shapes are mismatched.");if(e.type!=="float32"&&e.type!=="float64"||r.type!=="float32"&&r.type!=="float64"||t.type!=="float32"&&t.type!=="float64")throw new Error("Invalid input type.");if(n[0].dims.length!==4)throw new Error("Only support 4-D input shape.")};var pad={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.parsePadAttributesV11=n.padV11=n.parsePadAttributesV2=n.padV2=void 0;const e=attributeWithCacheKey,r=util,t=glslSource,o=types,i={name:"Pad",inputNames:["A"],inputTypes:[o.TextureType.unpacked]},l=(y,v,A)=>(d(v),[y.run(Object.assign(Object.assign({},i),{cacheHint:A.cacheKey,get:()=>f(y,v[0],A)}),v)]);n.padV2=l;const a=y=>{const v=y.attributes.getString("mode","constant"),A=y.attributes.getFloat("value",0),P=y.attributes.getInts("pads");return e.createAttributeWithCacheKey({mode:v,value:A,pads:P})};n.parsePadAttributesV2=a;const s=(y,v,A)=>{m(v);const P=c(y,v,A);return n.padV2(y,[v[0]],P)};n.padV11=s;const u=y=>y.attributes.getString("mode","constant");n.parsePadAttributesV11=u;const c=(y,v,A)=>{if(!y.session.isInitializer(v[1].dataId)||v.length>=3&&!y.session.isInitializer(v[2].dataId))throw new Error("dynamic pad attributes are not allowed");const P=Array.from(v[1].integerData),C=v.length>=3?v[2].floatData[0]:0;return e.createAttributeWithCacheKey({mode:A,pads:P,value:C})},f=(y,v,A)=>{const P=r.ShapeUtil.padShape(v.dims.slice(),A.pads),C=P.length,B=`
- ${_(y,v,A)}
- float process(int[${C}] indices) {
- return padA(indices);
- }`;return{name:"Pad",inputNames:["A"],inputTypes:[o.TextureType.unpacked],output:{dims:P,type:v.type,textureType:o.TextureType.unpacked},shaderSource:B}},d=y=>{if(!y||y.length!==1)throw new Error("Pad requires 1 input");if(y[0].type!=="float32"&&y[0].type!=="float64")throw new Error("Invalid input type.")},m=y=>{if(!y||y.length!==2&&y.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(y[1].type!=="int32")throw new Error("Invalid input type.");if(y.length>=3&&y[2].type==="string")throw new Error("Invalid input type.")},_=(y,v,A)=>{const P=t.getGlsl(y.session.backend.glContext.version),[C,L]=y.calculateTextureWidthAndHeight(v.dims,o.TextureType.unpacked),B=r.ShapeUtil.computeStrides(v.dims);switch(A.mode){case"constant":return S(P,v.dims,B,C,L,A.pads,A.value);case"reflect":return E(P,v.dims,B,C,L,A.pads);case"edge":return $(P,v.dims,B,C,L,A.pads);default:throw new Error("Invalid mode")}},S=(y,v,A,P,C,L,B)=>{const V=v.length;let j="";for(let U=V-1;U>=0;--U)j+=`
- k = m[${U}] - ${L[U]};
- if (k < 0) return constant;
- if (k >= ${v[U]}) return constant;
- offset += k * ${A[U]};
- `;return`
- float padA(int m[${V}]) {
- const float constant = float(${B});
- int offset = 0;
- int k = 0;
- ${j}
- vec2 coords = offsetToCoords(offset, ${P}, ${C});
- float value = getColorAsFloat(${y.texture2D}(A, coords));
- return value;
- }
- `},E=(y,v,A,P,C,L)=>{const B=v.length;let V="";for(let j=B-1;j>=0;--j)V+=`
- k = m[${j}] - ${L[j]};
- if (k < 0) { k = -k; }
- {
- const int _2n_1 = ${2*(v[j]-1)};
- k = int( mod( float(k), float(_2n_1) ) ) ;
- if(k >= ${v[j]}) { k = _2n_1 - k; }
- }
- offset += k * ${A[j]};
- `;return`
- float padA(int m[${B}]) {
- int offset = 0;
- int k = 0;
- ${V}
- vec2 coords = offsetToCoords(offset, ${P}, ${C});
- float value = getColorAsFloat(${y.texture2D}(A, coords));
- return value;
- }
- `},$=(y,v,A,P,C,L)=>{const B=v.length;let V="";for(let j=B-1;j>=0;--j)V+=`
- k = m[${j}] - ${L[j]};
- if (k < 0) k = 0;
- if (k >= ${v[j]}) k = ${v[j]-1};
- offset += k * ${A[j]};
- `;return`
- float padA(int m[${B}]) {
- int offset = 0;
- int k = 0;
- ${V}
- vec2 coords = offsetToCoords(offset, ${P}, ${C});
- float value = getColorAsFloat(${y.texture2D}(A, coords));
- return value;
- }
- `}})(pad);var pool={};Object.defineProperty(pool,"__esModule",{value:!0});pool.globalMaxPool=pool.parseMaxPoolAttributes=pool.maxPool=pool.parseGlobalAveragePoolAttributes=pool.globalAveragePool=pool.parseAveragePoolAttributes=pool.averagePool=void 0;const attribute_with_cache_key_1$4=attributeWithCacheKey,util_1$b=util,types_1$7=types,averagePool=(n,e,r)=>{validateInputs$7(e);const t={name:"AveragePool",inputNames:["X"],inputTypes:[types_1$7.TextureType.unpacked],cacheHint:r.cacheKey};return[n.run(Object.assign(Object.assign({},t),{get:()=>createAveragePoolProgramInfo(e,t,!1,r)}),e)]};pool.averagePool=averagePool;const parseAveragePoolAttributes=n=>{const e=n.attributes.getString("auto_pad","NOTSET"),r=n.attributes.getInt("ceil_mode",0),t=n.attributes.getInt("count_include_pad",0)!==0,o=n.attributes.getInts("kernel_shape"),i=n.attributes.getInts("strides",[]),l=n.attributes.getInts("pads",[]);if(r!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return attribute_with_cache_key_1$4.createAttributeWithCacheKey({autoPad:e,ceilMode:r,countIncludePad:t,kernelShape:o,strides:i,pads:l})};pool.parseAveragePoolAttributes=parseAveragePoolAttributes;const createAveragePoolProgramInfo=(n,e,r,t)=>{const[o,i]=getAdjustedPoolAttributesAndOutputShape(n,t,r),l=util_1$b.ShapeUtil.size(o.kernelShape),a="value += _X(x);";let s="";o.countIncludePad?s+=`value /= float(${l});`:s+=`value /= float(${l} - pad);`;const c=`
- ${generatePoolingCode(n[0].dims,o,a,s,"0.0")}
- `;return Object.assign(Object.assign({},e),{output:{dims:i,type:n[0].type,textureType:types_1$7.TextureType.unpacked},shaderSource:c})},globalAveragePool=(n,e,r)=>{validateInputs$7(e);const t={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[types_1$7.TextureType.unpacked],cacheHint:`${r.countIncludePad}`};return[n.run(Object.assign(Object.assign({},t),{get:()=>createAveragePoolProgramInfo(e,t,!0,r)}),e)]};pool.globalAveragePool=globalAveragePool;const parseGlobalAveragePoolAttributes=n=>{const e=n.attributes.getInt("count_include_pad",0)!==0;return attribute_with_cache_key_1$4.createAttributeWithCacheKey({autoPad:"",ceilMode:0,countIncludePad:e,kernelShape:[],strides:[],pads:[]})};pool.parseGlobalAveragePoolAttributes=parseGlobalAveragePoolAttributes;const maxPool=(n,e,r)=>{validateInputs$7(e);const t={name:"MaxPool",inputNames:["X"],inputTypes:[types_1$7.TextureType.unpacked],cacheHint:r.cacheKey};return[n.run(Object.assign(Object.assign({},t),{get:()=>createMaxPoolProgramInfo(e,t,!1,r)}),e)]};pool.maxPool=maxPool;const parseMaxPoolAttributes=n=>{const e=n.attributes.getString("auto_pad","NOTSET"),r=n.attributes.getInt("ceil_mode",0),t=n.attributes.getInts("kernel_shape"),o=n.attributes.getInts("strides",[]),i=n.attributes.getInts("pads",[]),l=n.attributes.getInt("storage_order",0),a=n.attributes.getInts("dilations",[]);if(l!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(r!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return attribute_with_cache_key_1$4.createAttributeWithCacheKey({autoPad:e,ceilMode:r,countIncludePad:!1,kernelShape:t,strides:o,pads:i,storageOrder:l,dilations:a})};pool.parseMaxPoolAttributes=parseMaxPoolAttributes;const createMaxPoolProgramInfo=(n,e,r,t)=>{const[o,i]=getAdjustedPoolAttributesAndOutputShape(n,t,r),l=`
- value = max(_X(x), value);
- `,a="",u=`
- ${generatePoolingCode(n[0].dims,o,l,a,"-1e5")}
- `;return Object.assign(Object.assign({},e),{output:{dims:i,type:n[0].type,textureType:types_1$7.TextureType.unpacked},shaderSource:u})},getAdjustedPoolAttributesAndOutputShape=(n,e,r)=>{const t=n[0].dims.slice(),o=Object.hasOwnProperty.call(e,"dilations"),i=e.kernelShape.slice(),l=e.strides.slice(),a=o?e.dilations.slice():[],s=e.pads.slice();util_1$b.PoolConvUtil.adjustPoolAttributes(r,t,i,l,a,s);const u=util_1$b.PoolConvUtil.computePoolOutputShape(r,t,l,a,i,s,e.autoPad),c=Object.assign({},e);return o?Object.assign(c,{kernelShape:i,strides:l,pads:s,dilations:a,cacheKey:e.cacheKey}):Object.assign(c,{kernelShape:i,strides:l,pads:s,cacheKey:e.cacheKey}),[c,u]},globalMaxPoolAttributes={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},globalMaxPoolMetadata={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[types_1$7.TextureType.unpacked]},globalMaxPool=(n,e)=>(validateInputs$7(e),[n.run(Object.assign(Object.assign({},globalMaxPoolMetadata),{get:()=>createMaxPoolProgramInfo(e,globalMaxPoolMetadata,!0,globalMaxPoolAttributes)}),e)]);pool.globalMaxPool=globalMaxPool;const validateInputs$7=n=>{if(!n||n.length!==1)throw new Error("Pool ops requires 1 input.");if(n[0].type!=="float32"&&n[0].type!=="float64")throw new Error("Invalid input type.")},generatePoolingCode=(n,e,r,t,o)=>{const i=n.length;if(e.kernelShape.length<=2){const l=e.kernelShape[e.kernelShape.length-1],a=e.strides[e.strides.length-1],s=e.pads[e.pads.length/2-1],u=e.pads[e.pads.length-1],c=n[i-1];let f="",d="",m="";if(s+u!==0?f=`
- for (int i = 0; i < ${l}; i++) {
- x[${i} - 1] = indices[${i} - 1] * ${a} - ${s} + i;
- if (x[${i} - 1] < 0 || x[${i} - 1] >= ${c}) {
- pad++;
- continue;
- }
- ${r}
- }`:f=`
- for (int i = 0; i < ${l}; i++) {
- x[${i} - 1] = indices[${i} - 1] * ${a} - ${s} + i;
- ${r}
- }`,e.kernelShape.length===2){const S=e.kernelShape[e.kernelShape.length-2],E=e.strides[e.strides.length-2],$=e.pads[e.pads.length/2-2],y=e.pads[e.pads.length-2],v=n[i-2];$+y!==0?d=`
- for (int j = 0; j < ${S}; j++) {
- x[${i} - 2] = indices[${i} - 2] * ${E} - ${$} + j;
- if (x[${i} - 2] < 0 || x[${i} - 2] >= ${v}) {
- pad+= ${l};
- continue;
- }
- `:d=`
- for (int j = 0; j < ${S}; j++) {
- x[${i} - 2] = indices[${i} - 2] * ${E} - ${$} + j;
- `,m=`
- }
- `}return`
- float process(int indices[${i}]) {
- int x[${i}];
- copyVec(indices, x);
-
- float value = ${o};
- int pad = 0;
- ${d}
- ${f}
- ${m}
- ${t}
- return value;
- }
- `}else{const l=util_1$b.ShapeUtil.size(e.kernelShape),a=util_1$b.ShapeUtil.computeStrides(e.kernelShape),s=a.length,u=e.pads.length,c=offsetToIndices(s),f=copyArray(n,"inputDims"),d=copyArray(e.pads,"pads"),m=copyArray(a,"kernelStrides"),_=copyArray(e.strides,"strides"),S=e.pads.reduce((y,v)=>y+v);let E="";return S?E=`
- if (x[j] >= inputDims[j] || x[j] < 0) {
- pad++;
- isPad = true;
- break;
- }
- }
- if (!isPad) {
- ${r}
- }`:E=`
- }
- ${r}
- `,`
- ${c}
- float process(int indices[${i}]) {
- int x[${i}];
- copyVec(indices, x);
- int offset[${s}];
- int pads[${u}];
- int inputDims[${i}];
- int kernelStrides[${s}];
- int strides[${s}];
- ${d}
- ${f}
- ${_}
- ${m}
-
- float value = ${o};
- int pad = 0;
- bool isPad = false;
- for (int i = 0; i < ${l}; i++) {
- offsetToIndices(i, kernelStrides, offset);
- isPad = false;
- for (int j = ${i} - ${s}; j < ${i}; j++) {
- x[j] = indices[j] * strides[j - ${i} + ${s}]
- + offset[j - ${i} + ${s}] - pads[j - 2];
- ${E}
- }
- ${t}
-
- return value;
- }
- `}},copyArray=(n,e)=>{let r="";for(let t=0;t<n.length;t++)r+=`
- ${e}[${t}] = ${n[t]};
- `;return r},offsetToIndices=n=>`
- void offsetToIndices(int offset, int[${n}] strides, out int[${n}] indices) {
- if (${n} == 0) {
- return;
- }
- for (int i = 0; i < ${n} - 1; ++i) {
- indices[i] = offset / strides[i];
- offset -= indices[i] * strides[i];
- }
- indices[${n} - 1] = offset;
- }`;var reduce$1={};Object.defineProperty(reduce$1,"__esModule",{value:!0});reduce$1.reduceLogSumSquare=reduce$1.reduceLogSum=reduce$1.reduceProd=reduce$1.reduceMin=reduce$1.reduceMax=reduce$1.reduceMean=reduce$1.reduceSum=reduce$1.parseReduceAttributes=void 0;const attribute_with_cache_key_1$3=attributeWithCacheKey,operators_1$2=operators,util_1$a=util,types_1$6=types,reduce=(n,e,r,t,o)=>{validateInputs$6(e);const i={name:t,inputNames:["A"],inputTypes:[types_1$6.TextureType.unpacked]};return[n.run(Object.assign(Object.assign({},i),{cacheHint:r.cacheKey,get:()=>createReduceProgramInfo(n,e,r,t,o,i)}),e)]},parseReduceAttributes=n=>{const e=n.attributes.getInts("axes",[]),r=n.attributes.getInt("keepdims",1)===1;return attribute_with_cache_key_1$3.createAttributeWithCacheKey({axes:e,keepDims:r})};reduce$1.parseReduceAttributes=parseReduceAttributes;const createReduceProgramInfo=(n,e,r,t,o,i)=>{const l=[],a=e[0].dims.length||1,s=[],u=util_1$a.ShapeUtil.normalizeAxes(r.axes,e[0].dims.length),c=o(e,u);let f=c[1];for(let _=0;_<e[0].dims.length;_++)u.indexOf(_)>=0||u.length===0?(r.keepDims&&l.push(1),f=`
- for(int j${_} = 0; j${_} < ${e[0].dims[_]}; j${_}++) {
- inputIdx[${_}] = j${_};
- ${f}
- }`):(s.push(`inputIdx[${_}] = outputIdx[${l.length}];`),l.push(e[0].dims[_]));const m=`
- float process(int outputIdx[${l.length||1}]) {
- float value; // final result
- int inputIdx[${a}]; // addressing input data
- ${s.join(`
- `)}
- ${c[0]} // init ops for reduce max/min
- ${f}
- ${c[2]} // final computation for reduce mean
- return value;
- }`;return Object.assign(Object.assign({},i),{output:{dims:l,type:e[0].type,textureType:types_1$6.TextureType.unpacked},shaderSource:m})},validateInputs$6=n=>{if(!n||n.length!==1)throw new Error("Reduce op requires 1 input.");if(operators_1$2.NUMBER_TYPES.indexOf(n[0].type)===-1)throw new Error("Invalid input type.")},reduceSum=(n,e,r)=>reduce(n,e,r,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]);reduce$1.reduceSum=reduceSum;const reduceMean=(n,e,r)=>reduce(n,e,r,"ReduceMean",(o,i)=>{let l=1;for(let a=0;a<o[0].dims.length;a++)(i.indexOf(a)>=0||i.length===0)&&(l*=o[0].dims[a]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${l}.;`]});reduce$1.reduceMean=reduceMean;const reduceMax=(n,e,r)=>reduce(n,e,r,"ReduceMax",(o,i)=>{const l=[];for(let a=0;a<o[0].dims.length;a++)(i.indexOf(a)>=0||i.length===0)&&l.push(`inputIdx[${a}] = 0;`);return[`${l.join(`
- `)}
- value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]});reduce$1.reduceMax=reduceMax;const reduceMin=(n,e,r)=>reduce(n,e,r,"ReduceMin",(o,i)=>{const l=[];for(let a=0;a<o[0].dims.length;a++)(i.indexOf(a)>=0||i.length===0)&&l.push(`inputIdx[${a}] = 0;`);return[`${l.join(`
- `)}
- value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]});reduce$1.reduceMin=reduceMin;const reduceProd=(n,e,r)=>reduce(n,e,r,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]);reduce$1.reduceProd=reduceProd;const reduceLogSum=(n,e,r)=>reduce(n,e,r,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]);reduce$1.reduceLogSum=reduceLogSum;const reduceLogSumSquare=(n,e,r)=>reduce(n,e,r,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""]);reduce$1.reduceLogSumSquare=reduceLogSumSquare;var reshape$1={};Object.defineProperty(reshape$1,"__esModule",{value:!0});reshape$1.reshape=void 0;const util_1$9=util,reshape=(n,e)=>{const r=util_1$9.ShapeUtil.calculateReshapedDims(e[0].dims,e[1].integerData);return n.session.pack?[n.reshapePacked(e[0],r)]:[n.reshapeUnpacked(e[0],r)]};reshape$1.reshape=reshape;var resizePacked={},upsample={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.scalesValidation=n.validateInputs=n.parseUpsampleAttributes=n.parseUpsampleAttributesV9=n.parseUpsampleAttributesV7=n.upsample=void 0;const e=attributeWithCacheKey,r=glslSource,t=types,o={name:"Upsample",inputNames:["X"],inputTypes:[t.TextureType.unpacked]},i=(d,m,_)=>(n.validateInputs(m,_),[d.run(Object.assign(Object.assign({},o),{cacheHint:_.cacheKey,get:()=>u(d,m,_)}),m)]);n.upsample=i;const l=d=>n.parseUpsampleAttributes(d,7);n.parseUpsampleAttributesV7=l;const a=d=>n.parseUpsampleAttributes(d,9);n.parseUpsampleAttributesV9=a;const s=(d,m)=>{const _=m>=10,S=d.attributes.getString("mode","nearest");if(S!=="nearest"&&S!=="linear"&&(m<11||S!=="cubic"))throw new Error(`unrecognized mode: ${S}`);let E=[];m<9&&(E=d.attributes.getFloats("scales"),n.scalesValidation(E,S,_));const $=d.attributes.getFloat("extrapolation_value",0),y=m>10?d.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(y)===-1)throw new Error(`coordinate_transform_mode '${y}' is not supported`);const v=y==="tf_crop_and_resize",A=v,P=S==="nearest"&&m>=11?d.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(P)===-1)throw new Error(`nearest_mode '${P}' is not supported`);const C=d.attributes.getFloat("cubic_coeff_a",-.75),L=d.attributes.getInt("exclude_outside",0)!==0;if(L&&S!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const B=m<11?!0:S==="nearest"&&y==="asymmetric"&&P==="floor";let V=0,j=0,U=0;return m>10?(V=1,j=2,U=3):m===9&&(j=1),e.createAttributeWithCacheKey({opset:m,isResize:_,mode:S,scales:E,extrapolationValue:$,coordinateTransformMode:y,useExtrapolation:A,needRoiInput:v,nearestMode:P,cubicCoefficientA:C,excludeOutside:L,useNearest2xOptimization:B,roiInputIdx:V,scalesInputIdx:j,sizesInputIdx:U})};n.parseUpsampleAttributes=s;const u=(d,m,_)=>{const S=r.getGlsl(d.session.backend.glContext.version),[E,$]=d.calculateTextureWidthAndHeight(m[0].dims,t.TextureType.unpacked),y=m[0].dims.map((U,re)=>Math.floor(U*_.scales[re])),[v,A]=d.calculateTextureWidthAndHeight(y,t.TextureType.unpacked),P=y.length,C=new Array(P),L=new Array(P);let B=`
- int output_pitches[${P}];
- int input_pitches[${P}];
- `;for(let U=P-1;U>=0;U--)C[U]=U===P-1?1:C[U+1]*y[U+1],L[U]=U===P-1?1:L[U+1]*m[0].dims[U+1],B+=`
- output_pitches[${U}] = ${C[U]};
- input_pitches[${U}] = ${L[U]};
- `;const V=`
- float getInputFloat(int index) {
- vec2 coords = offsetToCoords(index, ${E}, ${$});
- float value = getColorAsFloat(${S.texture2D}(X, coords));
- return value;
- }
- `,j=_.mode==="nearest"?`
- ${V}
- float process(int indices[${P}]) {
- int input_index = 0;
- int output_index = coordsToOffset(TexCoords, ${v}, ${A});
-
- ${B}
-
- int d, m;
- for (int dim = 0; dim < ${P}; ++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);
- }`:P===4?`
- ${V}
- float process(int indices[4]) {
- int input_index = 0;
- int output_index = coordsToOffset(TexCoords, ${v}, ${A});
-
- ${B}
-
- 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 == (${m[0].dims[2]} - 1)) {
- // It's the end in dimension 2
- x01 = x00;
- end_of_dim2 = true;
- } else {
- x01 = getInputFloat(input_index + input_pitches[2]);
- }
-
- if (index_of_input_dim3 == (input_pitches[2] - 1)) {
- // It's the end in dimension 3
- x10 = x00;
- x11 = x01;
- }
- else {
- x10 = getInputFloat(input_index + 1);
- x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
- }
-
- float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
- float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
- return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
- }`:`
- ${V}
- float process(int indices[2]) {
- int input_index = 0;
- int output_index = coordsToOffset(TexCoords, ${v}, ${A});
-
- ${B}
-
- 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 == (${m[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({},o),{output:{dims:y,type:m[0].type,textureType:t.TextureType.unpacked},shaderSource:j,variables:[{name:"scales",type:"int",arrayLength:_.scales.length,data:_.scales.map(U=>Math.ceil(U))}]})},c=(d,m)=>{if(!d||m.opset<9&&d.length!==1||m.opset>=9&&m.opset<11&&d.length!==2||m.opset>=11&&d.length!==3&&d.length!==4)throw new Error("invalid inputs.");if(m.scales.length>0&&d[0].dims.length!==m.scales.length)throw new Error("Invalid input shape.");if(d[0].type==="string")throw new Error("Invalid input tensor types.")};n.validateInputs=c;const f=(d,m,_)=>{if(_){for(const S of d)if(S<=0)throw new Error("Scale value should be greater than 0.")}else for(const S of d)if(S<1)throw new Error("Scale value should be greater than or equal to 1.");if((m==="linear"||m==="cubic")&&d.length!==2&&(d.length!==4||d[0]!==1||d[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 ${_?"Resize":"Upsample"} opeartor.`)};n.scalesValidation=f})(upsample);Object.defineProperty(resizePacked,"__esModule",{value:!0});resizePacked.parseResizeAttributesV11=resizePacked.parseResizeAttributesV10=resizePacked.resize=void 0;const glsl_source_1$6=glslSource,types_1$5=types,utils_1$2=utils,packing_utils_1=packingUtils,upsample_1$1=upsample,resizeProgramMetadata={name:"Resize",inputNames:["A"],inputTypes:[types_1$5.TextureType.packed]},resize=(n,e,r)=>(upsample_1$1.validateInputs(e,r),[n.run(Object.assign(Object.assign({},resizeProgramMetadata),{cacheHint:r.cacheKey,get:()=>createPackedResizeProgramInfo(n,e,r)}),e)]);resizePacked.resize=resize;const parseResizeAttributesV10=n=>upsample_1$1.parseUpsampleAttributes(n,10);resizePacked.parseResizeAttributesV10=parseResizeAttributesV10;const parseResizeAttributesV11=n=>upsample_1$1.parseUpsampleAttributes(n,11);resizePacked.parseResizeAttributesV11=parseResizeAttributesV11;const createPackedResizeProgramInfo=(n,e,r)=>{const t=glsl_source_1$6.getGlsl(n.session.backend.glContext.version),[o,i]=prepareInputs(e,r);if(o.every(v=>v===1)&&r.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},resizeProgramMetadata),{output:{dims:i,type:e[0].type,textureType:types_1$5.TextureType.packed},hasMain:!0,shaderSource:`void main() {
- vec4 v = ${t.texture2D}(X, TexCoords);
- ${t.output} = v;
- }`});const a=i.length;if(a<2)throw new Error(`output dimension should be at least 2, but got ${a}`);const s=i[a-2],u=i[a-1],c=e[0].dims;if(a!==c.length)throw new Error(`output dimension should match input ${c.length}, but got ${a}`);const f=c[a-2],d=c[a-1],m=o[a-2],_=o[a-1];let S="";if(r.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${r.mode}'`);switch(r.coordinateTransformMode){case"asymmetric":S=`
- vec4 getSourceFracIndex(ivec4 coords) {
- return vec4(coords) / scaleWHWH;
- }
- `;break;case"half_pixel":S=`
- vec4 getSourceFracIndex(ivec4 coords) {
- return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
- }
- `;break;case"align_corners":S=`
- vec4 getSourceFracIndex(ivec4 coords) {
- vec4 resized = vec4(${u}.0 - 1.0, ${s}.0 - 1.0, ${u}.0 - 1.0,
- ${s}.0 - 1.0);
- vec4 original = vec4(${d}.0 - 1.0, ${f}.0 - 1.0, ${d}.0 - 1.0,
- ${f}.0 - 1.0);
- vec4 new_scale = original / resized;
- return vec4(coords) * new_scale;
- }
- `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${r.coordinateTransformMode}'`)}const E=utils_1$2.getCoordsDataType(a),$=packing_utils_1.unpackFromChannel(),y=`
- const vec2 inputWH = vec2(${f}.0, ${d}.0);
- const vec4 scaleWHWH = vec4(${m}.0, ${_}.0, ${m}.0, ${_}.0);
- ${$}
- ${S}
- float getAValue(int x10, int r, int c, int d) {
- return getChannel(getA(x10, r, c, d), vec2(c, d));
- }
- void main() {
- ${E} 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 < ${s-1};
- bool hasNextCol = rc.z < ${u-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);
-
- ${t.output} = vec4(newValue);
- }
- `;return Object.assign(Object.assign({},resizeProgramMetadata),{output:{dims:i,type:e[0].type,textureType:types_1$5.TextureType.packed},hasMain:!0,shaderSource:y})},prepareInputs=(n,e)=>{const t=n[0].dims;let o=e.scales,i;if(o.length===0){const a=n[e.scalesInputIdx];if(a&&a.size!==0){if(n[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");o=parseScalesData(a,e.mode,e.isResize)}else{const s=n[e.sizesInputIdx];if(!s||s.size===0)throw new Error("Either scales or sizes MUST be provided as input.");i=Array.from(s.integerData),o=parseScalesDataFromOutputSize(i,t,e.mode,e.isResize)}}else if(n[e.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const l=i||t.map((a,s)=>Math.floor(a*o[s]));return[o,l]},parseScalesData=(n,e,r)=>{const t=Array.from(n.floatData);return upsample_1$1.scalesValidation(t,e,r),t},parseScalesDataFromOutputSize=(n,e,r,t)=>{const o=e.length,i=new Array(o);for(let l=0,a=o;l<a;l++)if(e[l]===0){if(n[l]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");i[l]=1}else i[l]=n[l]/e[l];return upsample_1$1.scalesValidation(i,r,t),i};var shape$1={};Object.defineProperty(shape$1,"__esModule",{value:!0});shape$1.shape=void 0;const tensor_1$3=tensor,shape=(n,e)=>(validateInputs$5(e),[new tensor_1$3.Tensor([e[0].dims.length],"int32",void 0,void 0,new Int32Array(e[0].dims))]);shape$1.shape=shape;const validateInputs$5=n=>{if(!n||n.length!==1)throw new Error("Shape requires 1 input.")};var slice$1={};Object.defineProperty(slice$1,"__esModule",{value:!0});slice$1.sliceV10=slice$1.parseSliceAttributes=slice$1.slice=void 0;const attribute_with_cache_key_1$2=attributeWithCacheKey,operators_1$1=operators,util_1$8=util,types_1$4=types,sliceProgramMetadata={name:"Slice",inputNames:["A"],inputTypes:[types_1$4.TextureType.unpacked]},slice=(n,e,r)=>(validateInputs$4(e),[n.run(Object.assign(Object.assign({},sliceProgramMetadata),{cacheHint:r.cacheKey,get:()=>createSliceProgramInfo(n,e[0],r)}),e)]);slice$1.slice=slice;const parseSliceAttributes=n=>{const e=n.attributes.getInts("starts"),r=n.attributes.getInts("ends"),t=n.attributes.getInts("axes",[]);return attribute_with_cache_key_1$2.createAttributeWithCacheKey({starts:e,ends:r,axes:t})};slice$1.parseSliceAttributes=parseSliceAttributes;const createSliceProgramInfo=(n,e,r)=>{const t=r.axes.length===0?e.dims.slice(0).map((f,d)=>d):r.axes,o=util_1$8.ShapeUtil.normalizeAxes(t,e.dims.length),i=r.starts.map((f,d)=>f>e.dims[o[d]]-1?e.dims[o[d]]:util_1$8.ShapeUtil.normalizeAxis(f,e.dims[o[d]])),l=r.ends.map((f,d)=>f>e.dims[o[d]]-1?e.dims[o[d]]:util_1$8.ShapeUtil.normalizeAxis(f,e.dims[o[d]])),a=e.dims.slice(),s=[];for(let f=0;f<o.length;f++)a[o[f]]=l[f]-i[f],i[f]>0&&s.push(`outputIdx[${o[f]}] += ${i[f]};`);const c=`
- float process(int outputIdx[${a.length}]) {
- ${s.join(`
- `)}
- return _A(outputIdx);
- }`;return Object.assign(Object.assign({},sliceProgramMetadata),{output:{dims:a,type:e.type,textureType:types_1$4.TextureType.unpacked},shaderSource:c})},validateInputs$4=n=>{if(!n||n.length!==1)throw new Error("Slice requires 1 input.");if(operators_1$1.NUMBER_TYPES.indexOf(n[0].type)===-1)throw new Error("Invalid input type.")},sliceV10=(n,e)=>{validateInputsV10(e);const r=generateSliceAttributesFromInputs(n,e);return[n.run(Object.assign(Object.assign({},sliceProgramMetadata),{cacheHint:r.cacheKey,get:()=>createSliceProgramInfo(n,e[0],r)}),[e[0]])]};slice$1.sliceV10=sliceV10;const generateSliceAttributesFromInputs=(n,e)=>{if(!n.session.isInitializer(e[1].dataId)||!n.session.isInitializer(e[2].dataId)||e.length>=4&&!n.session.isInitializer(e[3].dataId)||e.length>=5&&!n.session.isInitializer(e[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(e.length>=5&&e[4].integerData.some(l=>l!==1))throw new Error("currently non-1 steps is not supported for Slice");const r=Array.from(e[1].integerData),t=Array.from(e[2].integerData),o=e.length>=4?Array.from(e[3].integerData):[],i=`${o};${r};${t}`;return{starts:r,ends:t,axes:o,cacheKey:i}},validateInputsV10=n=>{if(!n||n.length<3||n.length>5)throw new Error("Invalid input number.");if(n[1].type!=="int32"||n[1].dims.length!==1)throw new Error("Invalid input type.");if(n[2].type!=="int32"||n[2].dims.length!==1)throw new Error("Invalid input type.");if(n.length>=4&&(n[3].type!=="int32"||n[3].dims.length!==1))throw new Error("Invalid input type.");if(n.length>=5&&(n[4].type!=="int32"||n[4].dims.length!==1))throw new Error("Invalid input type.")};var softmax$1={};Object.defineProperty(softmax$1,"__esModule",{value:!0});softmax$1.softmaxV13=softmax$1.parseSoftmaxAttributesV13=softmax$1.parseSoftmaxAttributes=softmax$1.softmax=void 0;const attribute_with_cache_key_1$1=attributeWithCacheKey,util_1$7=util,glsl_source_1$5=glslSource,types_1$3=types,transpose_1$1=transpose$1,softmaxComputeMaxProgramMetadata={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[types_1$3.TextureType.unpacked]},softmaxComputeScaleProgramMetadata={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[types_1$3.TextureType.unpacked,types_1$3.TextureType.unpacked]},softmaxProgramMetadata={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[types_1$3.TextureType.unpacked,types_1$3.TextureType.unpacked,types_1$3.TextureType.unpacked]},softmax=(n,e,r)=>{validateInputs$3(e);const t=e[0].dims.slice(),o=util_1$7.ShapeUtil.normalizeAxis(r.axis,t.length),i=util_1$7.ShapeUtil.sizeToDimension(t,o),l=util_1$7.ShapeUtil.sizeFromDimension(t,o);return computeSoftmax(n,e,r,i,l)};softmax$1.softmax=softmax;const parseSoftmaxAttributes=n=>attribute_with_cache_key_1$1.createAttributeWithCacheKey({axis:n.attributes.getInt("axis",1)});softmax$1.parseSoftmaxAttributes=parseSoftmaxAttributes;const parseSoftmaxAttributesV13=n=>attribute_with_cache_key_1$1.createAttributeWithCacheKey({axis:n.attributes.getInt("axis",-1)});softmax$1.parseSoftmaxAttributesV13=parseSoftmaxAttributesV13;const softmaxV13=(n,e,r)=>{validateInputs$3(e);const t=e[0].dims.slice(),o=util_1$7.ShapeUtil.normalizeAxis(r.axis,t.length),i=t.length,l=o!==i-1,a=[];let s=[],u=[],c;l&&(s=Array.from({length:i}).map((_,S)=>S),s[o]=i-1,s[i-1]=o,s.map(_=>a.push(t[_])),c=attribute_with_cache_key_1$1.createAttributeWithCacheKey({perm:s}),u=transpose_1$1.transpose(n,e,c));const f=l?util_1$7.ShapeUtil.sizeToDimension(a,i-1):util_1$7.ShapeUtil.sizeToDimension(t,i-1),d=l?util_1$7.ShapeUtil.sizeFromDimension(a,i-1):util_1$7.ShapeUtil.sizeFromDimension(t,i-1),m=computeSoftmax(n,l?u:e,r,f,d);return l?transpose_1$1.transpose(n,m,c):m};softmax$1.softmaxV13=softmaxV13;const computeSoftmax=(n,e,r,t,o)=>{const i=createComputeMaxProgramInfo(n,e[0],t,o,[t]),l=n.run(Object.assign(Object.assign({},softmaxComputeMaxProgramMetadata),{cacheHint:r.cacheKey,get:()=>i}),e),a=createComputScaleProgramInfo(n,e[0],t,o,i.output.dims,[t]),s=n.run(Object.assign(Object.assign({},softmaxComputeScaleProgramMetadata),{cacheHint:r.cacheKey,get:()=>a}),[e[0],l]),u=createSoftMaxProgramInfo(n,e[0],t,o,i.output.dims,a.output.dims);return[n.run(Object.assign(Object.assign({},softmaxProgramMetadata),{cacheHint:r.cacheKey,get:()=>u}),[e[0],l,s])]},createComputeMaxProgramInfo=(n,e,r,t,o)=>{const[i,l]=n.calculateTextureWidthAndHeight(e.dims,types_1$3.TextureType.unpacked),a=o.length;if(r<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1)throw new Error("Dimensionality of the output should be 1");if(o[0]!==r)throw new Error("Shape of the output should be equal to logical row count");const s=glsl_source_1$5.getGlsl(n.session.backend.glContext.version),u=`
- float process(int[${a}] indices) {
- int logical_row_start_offset = indices[0] * ${t};
-
- float max = getColorAsFloat(${s.texture2D}(A, offsetToCoords(logical_row_start_offset, ${i},
- ${l} )));
- for(int i=1; i<${t}; ++i)
- {
- float current = getColorAsFloat(${s.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
- ${i}, ${l})));
- if(current > max)
- max = current;
- }
-
- return max;
- }`;return Object.assign(Object.assign({},softmaxComputeMaxProgramMetadata),{output:{dims:o,type:e.type,textureType:types_1$3.TextureType.unpacked},shaderSource:u})},createComputScaleProgramInfo=(n,e,r,t,o,i)=>{const[l,a]=n.calculateTextureWidthAndHeight(e.dims,types_1$3.TextureType.unpacked),s=i.length;if(r<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(i.length!==1)throw new Error("Dimensionality of the output should be 1");if(i[0]!==r)throw new Error("Shape of the output should be equal to logical row count");if(o.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==r)throw new Error("Shape of the intermediate results should be equal to logical row count");const u=glsl_source_1$5.getGlsl(n.session.backend.glContext.version),c=`
- float process(int[${s}] indices) {
- int logical_row_start_offset = indices[0] * ${t};
-
- float norm_factor = 0.0;
- float max = _Max(indices);
- for(int i=0; i<${t}; ++i)
- {
- norm_factor += exp(getColorAsFloat(${u.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
- ${l}, ${a}))) - max);
- }
-
- return norm_factor;
- }`;return Object.assign(Object.assign({},softmaxComputeScaleProgramMetadata),{output:{dims:i,type:e.type,textureType:types_1$3.TextureType.unpacked},shaderSource:c})},createSoftMaxProgramInfo=(n,e,r,t,o,i)=>{const[l,a]=n.calculateTextureWidthAndHeight(e.dims,types_1$3.TextureType.unpacked),s=e.dims.length;if(r<1||t<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(o.length!==1||i.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==r||i[0]!==r)throw new Error("Shape of the intermediate results should be equal to logical row count");const u=`
- float process(int[${s}] indices) {
-
- // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
- int offset = coordsToOffset(TexCoords, ${l}, ${a});
-
- //determine the logical row for this index
- int logical_row_index[1];
- logical_row_index[0] = offset / ${t};
-
- 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({},softmaxProgramMetadata),{output:{dims:e.dims,type:e.type,textureType:types_1$3.TextureType.unpacked},shaderSource:u})},validateInputs$3=n=>{if(!n||n.length!==1)throw new Error("Softmax requires 1 input.");if(n[0].type!=="float32"&&n[0].type!=="float64")throw new Error("Invalid input type")};var split$1={};Object.defineProperty(split$1,"__esModule",{value:!0});split$1.parseSplitAttributes=split$1.split=void 0;const attribute_with_cache_key_1=attributeWithCacheKey,util_1$6=util,types_1$2=types,splitProgramMetadata={name:"Split",inputNames:["A"],inputTypes:[types_1$2.TextureType.unpacked]},split=(n,e,r)=>{validateInputs$2(e);const t=util_1$6.ShapeUtil.normalizeAxis(r.axis,e[0].dims.length),o=getProgramCount(n,e,t,r),i=[];for(let l=0;l<o;++l)i.push(n.run(Object.assign(Object.assign({},splitProgramMetadata),{cacheHint:`${r.cacheKey};${l}`,get:()=>createSplitProgramInfo(n,e[0],r,t,l)}),e));return i};split$1.split=split;const parseSplitAttributes=n=>{const e=n.attributes.getInt("axis",0),r=n.attributes.getInts("split",[]),t=n.outputs.length;return attribute_with_cache_key_1.createAttributeWithCacheKey({axis:e,split:r,numOutputs:t})};split$1.parseSplitAttributes=parseSplitAttributes;const getProgramCount=(n,e,r,t)=>{const[,o]=util_1$6.SplitUtil.splitShape(e[0].dims,r,t.split,t.numOutputs);return o.length},createSplitProgramInfo=(n,e,r,t,o)=>{const[i,l]=util_1$6.SplitUtil.splitShape(e.dims,t,r.split,r.numOutputs),a=l[o],s=i[o],c=`
- float process(int indices[${s.length}]) {
- indices[${t}] += ${a};
- return _A(indices);
- }
- `;return Object.assign(Object.assign({},splitProgramMetadata),{cacheHint:`${r.cacheKey}:${o}`,output:{dims:s,type:e.type,textureType:types_1$2.TextureType.unpacked},shaderSource:c})},validateInputs$2=n=>{if(!n||n.length!==1)throw new Error("Split requires one input.");if(n[0].type!=="int8"&&n[0].type!=="uint8"&&n[0].type!=="int16"&&n[0].type!=="uint16"&&n[0].type!=="int32"&&n[0].type!=="uint32"&&n[0].type!=="float32"&&n[0].type!=="float64"&&n[0].type!=="bool")throw new Error("Invalid input type.")};var squeeze={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.parseSqueezeAttributes=n.squeezeV13=n.squeeze=void 0;const e=util,r=(a,s,u)=>{i(s);const c=e.ShapeUtil.squeezeShape(s[0].dims,u);return[a.reshapeUnpacked(s[0],c)]};n.squeeze=r;const t=(a,s)=>(l(s),n.squeeze(a,[s[0]],Array.from(s[1].integerData)));n.squeezeV13=t;const o=a=>a.attributes.getInts("axes");n.parseSqueezeAttributes=o;const i=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.")},l=a=>{if(!a||a.length!==2)throw new Error("Squeeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}})(squeeze);var sum$1={};Object.defineProperty(sum$1,"__esModule",{value:!0});sum$1.sum=void 0;const glsl_source_1$4=glslSource,types_1$1=types,sum=(n,e)=>{validateInputs$1(e);const r={name:"Sum",inputNames:e.map((o,i)=>`X${i}`),inputTypes:new Array(e.length).fill(types_1$1.TextureType.unpacked)};return[n.run(Object.assign(Object.assign({},r),{get:()=>createSumProgramInfo(n,e,r)}),e)]};sum$1.sum=sum;const createSumProgramInfo=(n,e,r)=>{const t=glsl_source_1$4.getGlsl(n.session.backend.glContext.version),o=e[0].dims.slice(),l=`
- void main() {
- vec4 result = ${e.map((a,s)=>`${t.texture2D}(X${s},TexCoords)`).join(" + ")};
- ${t.output} = result;
- }
- `;return Object.assign(Object.assign({},r),{output:{dims:o,type:e[0].type,textureType:types_1$1.TextureType.unpacked},hasMain:!0,shaderSource:l})},validateInputs$1=n=>{if(!n||n.length===0)throw new Error("Sum requires inputs.");const e=n[0].dims.length;for(let r=1;r<n.length;r++){if(e!==n[r].dims.length)throw new Error("Input shapes are mismatched.");for(let t=0;t<e;t++)if(n[0].dims[t]!==n[r].dims[t])throw new Error("Input shapes are not matched.")}if(n[0].type!=="float32"&&n[0].type!=="float64")throw new Error("Invalid input type.");for(let r=1;r<n.length;r++)if(n[0].type!==n[r].type)throw new Error("Input types are not matched.")};var tile$1={};Object.defineProperty(tile$1,"__esModule",{value:!0});tile$1.tile=void 0;const operators_1=operators,types_1=types,tile=(n,e)=>{validateInputs(e);const r={name:"Tile",inputNames:["A"],inputTypes:[types_1.TextureType.unpacked]};return[n.run(Object.assign(Object.assign({},r),{get:()=>createTileProgramInfo(n,e,r)}),e)]};tile$1.tile=tile;const createTileProgramInfo=(n,e,r)=>{const t=e[0].dims.slice(),o=new Array(t.length),i=[];for(let s=0;s<t.length;s++)o[s]=t[s]*e[1].numberData[s],i.push(`inputIdx[${s}] = int(mod(float(outputIdx[${s}]), ${t[s]}.));`);const l=o.length,a=`
- float process(int outputIdx[${l}]) {
- int inputIdx[${l}];
- ${i.join(`
- `)}
- return _A(inputIdx);
- }
- `;return Object.assign(Object.assign({},r),{output:{dims:o,type:e[0].type,textureType:types_1.TextureType.unpacked},shaderSource:a})},validateInputs=n=>{if(!n||n.length!==2)throw new Error("Tile requires 2 input.");if(n[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(n[1].dims[0]!==n[0].dims.length)throw new Error("Invalid input shape.");if(operators_1.NUMBER_TYPES.indexOf(n[0].type)===-1)throw new Error("Invalid input type.");if(n[1].type!=="int32"&&n[1].type!=="int16")throw new Error("Invalid repeat type.")};var unsqueeze={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.parseUnsqueezeAttributes=n.unsqueezeV13=n.unsqueeze=void 0;const e=util,r=(a,s,u)=>{i(s);const c=e.ShapeUtil.unsqueezeShape(s[0].dims,u);return[a.reshapeUnpacked(s[0],c)]};n.unsqueeze=r;const t=(a,s)=>(l(s),n.unsqueeze(a,[s[0]],Array.from(s[1].integerData)));n.unsqueezeV13=t;const o=a=>a.attributes.getInts("axes");n.parseUnsqueezeAttributes=o;const i=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.")},l=a=>{if(!a||a.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}})(unsqueeze);var __createBinding$3=commonjsGlobal$1&&commonjsGlobal$1.__createBinding||(Object.create?function(n,e,r,t){t===void 0&&(t=r),Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[r]}})}:function(n,e,r,t){t===void 0&&(t=r),n[t]=e[r]}),__setModuleDefault$3=commonjsGlobal$1&&commonjsGlobal$1.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),__importStar$3=commonjsGlobal$1&&commonjsGlobal$1.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var r in n)r!=="default"&&Object.prototype.hasOwnProperty.call(n,r)&&__createBinding$3(e,n,r);return __setModuleDefault$3(e,n),e};Object.defineProperty(opResolveRules,"__esModule",{value:!0});opResolveRules.WEBGL_OP_RESOLVE_RULES=void 0;const batch_normalization_1=batchNormalization$1,binaryOps=__importStar$3(binaryOp),cast_1=cast$1,concat_1=concat$1,conv_1=conv,depth_to_space_1=depthToSpace$1,flatten_1=flatten$1,gather_1=gather$1,gemm_1=gemm$1,image_scaler_1=imageScaler$1,instance_normalization_1=instanceNormalization$1,matmul_1=matmul,pad_1=pad,pool_1=pool,pool_2=pool,pool_3=pool,pool_4=pool,reduce_1=reduce$1,reduce_2=reduce$1,reshape_1=reshape$1,resize_packed_1=resizePacked,shape_1=shape$1,slice_1=slice$1,softmax_1=softmax$1,split_1=split$1,squeeze_1=squeeze,sum_1=sum$1,tile_1=tile$1,transpose_1=transpose$1,unaryOps=__importStar$3(unaryOp),unsqueeze_1=unsqueeze,upsample_1=upsample;opResolveRules.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",unaryOps.abs],["Acos","","7+",unaryOps.acos],["Add","","7+",binaryOps.add],["And","","7+",binaryOps.and],["Asin","","7+",unaryOps.asin],["Atan","","7+",unaryOps.atan],["AveragePool","","7+",pool_1.averagePool,pool_1.parseAveragePoolAttributes],["BatchNormalization","","7+",batch_normalization_1.batchNormalization,batch_normalization_1.parseBatchNormalizationAttributes],["Cast","","6+",cast_1.cast,cast_1.parseCastAttributes],["Ceil","","6+",unaryOps.ceil],["Clip","","6-10",unaryOps.clip,unaryOps.parseClipAttributes],["Clip","","11+",unaryOps.clipV11],["Concat","","4+",concat_1.concat,concat_1.parseConcatAttributes],["Conv","","1+",conv_1.conv,conv_1.parseConvAttributes],["Cos","","7+",unaryOps.cos],["Div","","7+",binaryOps.div],["Dropout","","7+",unaryOps.identity],["DepthToSpace","","1+",depth_to_space_1.depthToSpace,depth_to_space_1.parseDepthToSpaceAttributes],["Equal","","7+",binaryOps.equal],["Elu","","6+",unaryOps.elu,unaryOps.parseEluAttributes],["Exp","","6+",unaryOps.exp],["Flatten","","1+",flatten_1.flatten,flatten_1.parseFlattenAttributes],["Floor","","6+",unaryOps.floor],["FusedConv","com.microsoft","1+",conv_1.conv,conv_1.parseConvAttributes],["Gather","","1+",gather_1.gather,gather_1.parseGatherAttributes],["Gemm","","7-10",gemm_1.gemm,gemm_1.parseGemmAttributesV7],["Gemm","","11+",gemm_1.gemm,gemm_1.parseGemmAttributesV11],["GlobalAveragePool","","1+",pool_2.globalAveragePool,pool_2.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",pool_4.globalMaxPool],["Greater","","7+",binaryOps.greater],["Identity","","1+",unaryOps.identity],["ImageScaler","","1+",image_scaler_1.imageScaler,image_scaler_1.parseImageScalerAttributes],["InstanceNormalization","","6+",instance_normalization_1.instanceNormalization,instance_normalization_1.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",unaryOps.leakyRelu,unaryOps.parseLeakyReluAttributes],["Less","","7+",binaryOps.less],["Log","","6+",unaryOps.log],["MatMul","","1+",matmul_1.matMul,matmul_1.parseMatMulAttributes],["MaxPool","","1+",pool_3.maxPool,pool_3.parseMaxPoolAttributes],["Mul","","7+",binaryOps.mul],["Neg","","6+",unaryOps.neg],["Not","","1+",unaryOps.not],["Or","","7+",binaryOps.or],["Pad","","2-10",pad_1.padV2,pad_1.parsePadAttributesV2],["Pad","","11+",pad_1.padV11,pad_1.parsePadAttributesV11],["Pow","","7+",binaryOps.pow],["PRelu","","7+",binaryOps.pRelu],["ReduceLogSum","","1+",reduce_1.reduceLogSum,reduce_2.parseReduceAttributes],["ReduceMax","","1+",reduce_1.reduceMax,reduce_2.parseReduceAttributes],["ReduceMean","","1+",reduce_1.reduceMean,reduce_2.parseReduceAttributes],["ReduceMin","","1+",reduce_1.reduceMin,reduce_2.parseReduceAttributes],["ReduceProd","","1+",reduce_1.reduceProd,reduce_2.parseReduceAttributes],["ReduceSum","","1-12",reduce_1.reduceSum,reduce_2.parseReduceAttributes],["ReduceSumSquare","","1+",reduce_1.reduceLogSumSquare,reduce_2.parseReduceAttributes],["Relu","","6+",unaryOps.relu],["Reshape","","5+",reshape_1.reshape],["Resize","","10",resize_packed_1.resize,resize_packed_1.parseResizeAttributesV10],["Resize","","11+",resize_packed_1.resize,resize_packed_1.parseResizeAttributesV11],["Shape","","1+",shape_1.shape],["Sigmoid","","6+",unaryOps.sigmoid],["Sin","","7+",unaryOps.sin],["Slice","","10+",slice_1.sliceV10],["Slice","","1-9",slice_1.slice,slice_1.parseSliceAttributes],["Softmax","","1-12",softmax_1.softmax,softmax_1.parseSoftmaxAttributes],["Softmax","","13+",softmax_1.softmaxV13,softmax_1.parseSoftmaxAttributesV13],["Split","","2-12",split_1.split,split_1.parseSplitAttributes],["Sqrt","","6+",unaryOps.sqrt],["Squeeze","","1-12",squeeze_1.squeeze,squeeze_1.parseSqueezeAttributes],["Squeeze","","13+",squeeze_1.squeezeV13],["Sub","","7+",binaryOps.sub],["Sum","","6+",sum_1.sum],["Tan","","7+",unaryOps.tan],["Tanh","","6+",unaryOps.tanh],["Tile","","6+",tile_1.tile],["Transpose","","1+",transpose_1.transpose,transpose_1.parseTransposeAttributes],["Upsample","","7-8",upsample_1.upsample,upsample_1.parseUpsampleAttributesV7],["Upsample","","9",upsample_1.upsample,upsample_1.parseUpsampleAttributesV9],["Unsqueeze","","1-12",unsqueeze_1.unsqueeze,unsqueeze_1.parseUnsqueezeAttributes],["Unsqueeze","","13+",unsqueeze_1.unsqueezeV13],["Xor","","7+",binaryOps.xor]];var programManager={},glslPreprocessor={},glslFunctionInliner={};Object.defineProperty(glslFunctionInliner,"__esModule",{value:!0});glslFunctionInliner.replaceInlines=void 0;const INLINE_FUNC_DEF_REGEX=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm,FUNC_CALL_REGEX="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;";function replaceInlines(n){const e={};let r;for(;(r=INLINE_FUNC_DEF_REGEX.exec(n))!==null;){const t=r[3].split(",").map(o=>{const i=o.trim().split(" ");return i&&i.length===2?{type:i[0],name:i[1]}:null}).filter(o=>o!==null);e[r[2]]={params:t,body:r[4]}}for(const t in e){const o=FUNC_CALL_REGEX.replace("__FUNC__",t),i=new RegExp(o,"gm");for(;(r=i.exec(n))!==null;){const l=r[1],a=r[2],s=r[3].split(","),u=l?`${l} ${a};`:"";let c=e[t].body,f="";e[t].params.forEach((m,_)=>{m&&(f+=`${m.type} ${m.name} = ${s[_]};
- `)}),c=`${f}
- ${c}`,c=c.replace("return",`${a} = `);const d=`
- ${u}
- {
- ${c}
- }
- `;n=n.replace(r[0],d)}}return n=n.replace(INLINE_FUNC_DEF_REGEX,""),n}glslFunctionInliner.replaceInlines=replaceInlines;var glslRegisteredLibs={},glslCoordinateLib={},textureLayoutStrategy={};Object.defineProperty(textureLayoutStrategy,"__esModule",{value:!0});textureLayoutStrategy.getBatchDim=textureLayoutStrategy.sizeToSquarishShape=textureLayoutStrategy.getRowsCols=textureLayoutStrategy.sizeFromShape=textureLayoutStrategy.isInt=textureLayoutStrategy.parseAxisParam=textureLayoutStrategy.squeezeShape=textureLayoutStrategy.PreferLogicalStrategy=textureLayoutStrategy.AlwaysKeepOriginalSizeStrategy=void 0;const instrument_1$8=instrument,util_1$5=util;class AlwaysKeepOriginalSizeStrategy{constructor(e){this.maxTextureSize=e}computeTextureWH(e,r){if(e.length===0)return[1,1];const t=this.maxTextureSize;if(r&&r.breakAxis!==void 0){const l=r.breakAxis>=e.length?1:e.slice(r.breakAxis).reduce((s,u)=>s*u),a=r.breakAxis<=0?1:e.slice(0,r.breakAxis).reduce((s,u)=>s*u);if(l>t||a>t)instrument_1$8.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${r.breakAxis}`);else return[l,a]}const o=e.reduce((l,a)=>l*a);let i=Math.floor(Math.sqrt(o));for(;i<t&&i<o&&o%i!==0;i++);if(i>=t||o%i!==0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${e}`);return[i,o/i]}}textureLayoutStrategy.AlwaysKeepOriginalSizeStrategy=AlwaysKeepOriginalSizeStrategy;class PreferLogicalStrategy{constructor(e){this.maxTextureSize=e}computeTextureWH(e,r){const t=this.computeTexture(e,r);return r&&r.isPacked&&(t[0]/=2,t[1]/=2),r&&r.reverseWH?[t[1],t[0]]:t}computeTexture(e,r){const t=r&&r.isPacked;if(e.length===0)return t?[2,2]:[1,1];let o=this.maxTextureSize;if(r&&r.breakAxis!==void 0){const a=r.breakAxis>=e.length?1:e.slice(r.breakAxis).reduce((u,c)=>u*c),s=r.breakAxis<=0?1:e.slice(0,r.breakAxis).reduce((u,c)=>u*c);if(a>o||s>o)instrument_1$8.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${r.breakAxis}`);else return[a,s]}let i=e.slice(0);t&&(o=o*2,i=i.map((a,s)=>s>=i.length-2?i[s]%2===0?i[s]:i[s]+1:i[s]),i.length===1&&(i=[2,i[0]])),i.length!==2&&(i=squeezeShape(i).newShape);const l=sizeFromShape(i);return i.length<=1&&l<=o?[1,l]:i.length===2&&i[0]<=o&&i[1]<=o?i:i.length===3&&i[0]*i[1]<=o&&i[2]<=o?[i[0]*i[1],i[2]]:i.length===3&&i[0]<=o&&i[1]*i[2]<=o?[i[0],i[1]*i[2]]:i.length===4&&i[0]*i[1]*i[2]<=o&&i[3]<=o?[i[0]*i[1]*i[2],i[3]]:i.length===4&&i[0]<=o&&i[1]*i[2]*i[3]<=o?[i[0],i[1]*i[2]*i[3]]:t?sizeToSquarishShape(l/4).map(a=>a*2):sizeToSquarishShape(l)}}textureLayoutStrategy.PreferLogicalStrategy=PreferLogicalStrategy;function squeezeShape(n,e){const r=[],t=[],o=e!=null&&Array.isArray(e)&&e.length===0,i=e==null||o?null:parseAxisParam(e,n).sort();let l=0;for(let a=0;a<n.length;++a){if(i!=null){if(i[l]===a&&n[a]!==1)throw new Error(`Can't squeeze axis ${a} since its dim '${n[a]}' is not 1`);(i[l]==null||i[l]>a)&&n[a]===1&&(r.push(n[a]),t.push(a)),i[l]<=a&&l++}n[a]!==1&&(r.push(n[a]),t.push(a))}return{newShape:r,keptDims:t}}textureLayoutStrategy.squeezeShape=squeezeShape;function parseAxisParam(n,e){const r=e.length;return n=n==null?e.map((t,o)=>o):[].concat(n),util_1$5.assert(n.every(t=>t>=-r&&t<r),()=>`All values in axis param must be in range [-${r}, ${r}) but got axis ${n}`),util_1$5.assert(n.every(isInt),()=>`All values in axis param must be integers but got axis ${n}`),n.map(t=>t<0?r+t:t)}textureLayoutStrategy.parseAxisParam=parseAxisParam;function isInt(n){return n%1===0}textureLayoutStrategy.isInt=isInt;function sizeFromShape(n){if(n.length===0)return 1;let e=n[0];for(let r=1;r<n.length;r++)e*=n[r];return e}textureLayoutStrategy.sizeFromShape=sizeFromShape;function getRowsCols(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}textureLayoutStrategy.getRowsCols=getRowsCols;function sizeToSquarishShape(n){const e=Math.ceil(Math.sqrt(n));return[e,Math.ceil(n/e)]}textureLayoutStrategy.sizeToSquarishShape=sizeToSquarishShape;function getBatchDim(n,e=2){return sizeFromShape(n.slice(0,n.length-e))}textureLayoutStrategy.getBatchDim=getBatchDim;Object.defineProperty(glslCoordinateLib,"__esModule",{value:!0});glslCoordinateLib.CoordsGlslLib=void 0;const util_1$4=util,glsl_definitions_1$5=glslDefinitions,glsl_source_1$3=glslSource,texture_layout_strategy_1$1=textureLayoutStrategy,utils_1$1=utils;class CoordsGlslLib extends glsl_definitions_1$5.GlslLib{constructor(e){super(e)}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(){const e="offsetToCoords";return{offsetToCoords:new glsl_definitions_1$5.GlslLibRoutine(`
- vec2 ${e}(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(){const e="coordsToOffset";return{coordsToOffset:new glsl_definitions_1$5.GlslLibRoutine(`
- int ${e}(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 e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){const r=e.unpackedShape,t=[e.width,e.height],o={},i="getOutputCoords";switch(r.length){case 0:o[i]=this.getOutputScalarCoords();break;case 1:o[i]=this.getOutputPacked1DCoords(r,t);break;case 2:o[i]=this.getOutputPacked2DCoords(r,t);break;case 3:o[i]=this.getOutputPacked3DCoords(r,t);break;default:o[i]=this.getOutputPackedNDCoords(r,t)}const a=`
- void setOutput(vec4 val) {
- ${glsl_source_1$3.getGlsl(this.context.glContext.version).output} = val;
- }
- `,s="floatTextureSetRGBA";return o[s]=new glsl_definitions_1$5.GlslLibRoutine(a),o}getUnpackedOutputSamplingSnippet(e){const r=e.unpackedShape,t=[e.width,e.height],o={},i="getOutputCoords";switch(r.length){case 0:o[i]=this.getOutputScalarCoords();break;case 1:o[i]=this.getOutputUnpacked1DCoords(r,t);break;case 2:o[i]=this.getOutputUnpacked2DCoords(r,t);break;case 3:o[i]=this.getOutputUnpacked3DCoords(r,t);break;case 4:o[i]=this.getOutputUnpacked4DCoords(r,t);break;case 5:o[i]=this.getOutputUnpacked5DCoords(r,t);break;case 6:o[i]=this.getOutputUnpacked6DCoords(r,t);break;default:throw new Error(`Unsupported output dimensionality: ${r.length}`)}const a=`
- void setOutput(float val) {
- ${glsl_source_1$3.getGlsl(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
- }
- `,s="floatTextureSetR";return o[s]=new glsl_definitions_1$5.GlslLibRoutine(a),o}getOutputScalarCoords(){return new glsl_definitions_1$5.GlslLibRoutine(`
- int getOutputCoords() {
- return 0;
- }
- `)}getOutputPacked1DCoords(e,r){const t=r;let o="";return t[0]===1?(o=`
- int getOutputCoords() {
- return 2 * int(TexCoords.y * ${t[1]}.0);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(o)):t[1]===1?(o=`
- int getOutputCoords() {
- return 2 * int(TexCoords.x * ${t[0]}.0);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(o)):(o=`
- int getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${t[0]}, ${t[1]}));
- return 2 * (resTexRC.y * ${t[0]} + resTexRC.x);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(o))}getOutputPacked2DCoords(e,r){let t="";if(util_1$4.ArrayUtil.arraysEqual(e,r))return t=`
- ivec2 getOutputCoords() {
- return 2 * ivec2(TexCoords.xy * vec2(${r[0]}, ${r[1]}));
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t);const o=r,i=Math.ceil(e[1]/2);return t=`
- ivec2 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${o[0]}, ${o[1]}));
-
- int index = resTexRC.y * ${o[0]} + resTexRC.x;
-
- // reverse r and c order for packed texture
- int r = imod(index, ${i}) * 2;
- int c = 2 * (index / ${i});
-
- return ivec2(r, c);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputPacked3DCoords(e,r){const t=[r[0],r[1]],o=Math.ceil(e[2]/2),i=o*Math.ceil(e[1]/2),l=`
- ivec3 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${t[0]}, ${t[1]}));
- int index = resTexRC.y * ${t[0]} + resTexRC.x;
-
- int b = index / ${i};
- index -= b * ${i};
-
- // reverse r and c order for packed texture
- int r = imod(index, ${o}) * 2;
- int c = 2 * (index / ${o});
-
- return ivec3(b, r, c);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(l)}getOutputPackedNDCoords(e,r){const t=[r[0],r[1]],o=Math.ceil(e[e.length-1]/2),i=o*Math.ceil(e[e.length-2]/2);let l=i,a="",s="b, r, c";for(let c=2;c<e.length-1;c++)l*=e[e.length-c-1],a=`
- int b${c} = index / ${l};
- index -= b${c} * ${l};
- `+a,s=`b${c}, `+s;const u=`
- ivec${e.length} getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${t[0]}, ${t[1]}));
- int index = resTexRC.y * ${t[0]} + resTexRC.x;
-
- ${a}
-
- int b = index / ${i};
- index -= b * ${i};
-
- // reverse r and c order for packed texture
- int r = imod(index, ${o}) * 2;
- int c = 2 * (index / ${o});
-
- return ivec${e.length}(${s});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(u)}getOutputUnpacked1DCoords(e,r){const t=`
- int getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- return resTexRC.y * ${r[0]} + resTexRC.x;
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputUnpacked2DCoords(e,r){const t=`
- ivec2 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
- int r = index / ${e[1]};
- int c = index - r * ${e[1]};
- return ivec2(r, c);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputUnpacked3DCoords(e,r){let t="";const o=e.length;let i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=e[o-1];for(let s=o-3;s>=0;--s)i[s]=i[s+1]*e[s+1];const l=["r","c","d"],a=i.map((s,u)=>{const c=`int ${l[u]} = index / ${s}`,f=u===i.length-1?`int ${l[u+1]} = index - ${l[u]} * ${s}`:`index -= ${l[u]} * ${s}`;return`${c}; ${f};`}).join("");return t=`
- ivec3 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
- ${a}
- return ivec3(r, c, d);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputUnpacked4DCoords(e,r){let t="";const o=e.length;let i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=e[o-1];for(let s=o-3;s>=0;--s)i[s]=i[s+1]*e[s+1];const l=["r","c","d","d2"],a=i.map((s,u)=>{const c=`int ${l[u]} = index / ${s}`,f=u===i.length-1?`int ${l[u+1]} = index - ${l[u]} * ${s}`:`index -= ${l[u]} * ${s}`;return`${c}; ${f};`}).join("");return t=`
- ivec4 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
- ${a}
- return ivec4(r, c, d, d2);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputUnpacked5DCoords(e,r){let t="";const o=e.length;let i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=e[o-1];for(let s=o-3;s>=0;--s)i[s]=i[s+1]*e[s+1];const l=["r","c","d","d2","d3"],a=i.map((s,u)=>{const c=`int ${l[u]} = index / ${s}`,f=u===i.length-1?`int ${l[u+1]} = index - ${l[u]} * ${s}`:`index -= ${l[u]} * ${s}`;return`${c}; ${f};`}).join("");return t=`
- ivec5 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
- ${a}
- return ivec5(r, c, d, d2, d3);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t)}getOutputUnpacked6DCoords(e,r){let t="";const o=e.length;let i=null;o<2&&(i=[]),i=new Array(o-1),i[o-2]=e[o-1];for(let s=o-3;s>=0;--s)i[s]=i[s+1]*e[s+1];const l=["r","c","d","d2","d3","d4"],a=i.map((s,u)=>{const c=`int ${l[u]} = index / ${s}`,f=u===i.length-1?`int ${l[u+1]} = index - ${l[u]} * ${s}`:`index -= ${l[u]} * ${s}`;return`${c}; ${f};`}).join("");return t=`
- ivec6 getOutputCoords() {
- ivec2 resTexRC = ivec2(TexCoords.xy *
- vec2(${r[0]}, ${r[1]}));
- int index = resTexRC.y * ${r[0]} + resTexRC.x;
- ${a}
- return ivec6(r, c, d, d2, d3, d4);
- }
- `,new glsl_definitions_1$5.GlslLibRoutine(t)}getCommonUtilFuncs(){const e={};let r="uvFromFlat";e[r]=new glsl_definitions_1$5.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);
- }
- `),r="packedUVfrom1D",e[r]=new glsl_definitions_1$5.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);
- }
- `),r="packedUVfrom2D",e[r]=new glsl_definitions_1$5.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);
- }
- `),r="packedUVfrom3D",e[r]=new glsl_definitions_1$5.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);
- }
- `),r="sampleTexture";const t=glsl_source_1$3.getGlsl(this.context.glContext.version);return e[r]=new glsl_definitions_1$5.GlslLibRoutine(`
- float sampleTexture(sampler2D textureSampler, vec2 uv) {
- return ${t.texture2D}(textureSampler, uv).r;
- }`),e}getInputsSamplingSnippets(){const e={},r=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((t,o)=>{const i=this.context.inputTextureLayouts[o],l=utils_1$1.generateShaderFuncNameFromInputSamplerName(t);i.isPacked?e[l]=this.getPackedSamplerFromInput(l,t,i):e[l]=this.getUnpackedSamplerFromInput(l,t,i);const a=utils_1$1.generateShaderFuncNameFromInputSamplerNameAtOutCoords(t);i.unpackedShape.length<=r.unpackedShape.length&&(i.isPacked?e[a]=this.getPackedSamplerAtOutputCoords(a,i,r,t):e[a]=this.getUnpackedSamplerAtOutputCoords(a,i,r,t))}),e}getPackedSamplerAtOutputCoords(e,r,t,o){const i=r.unpackedShape,l=t.unpackedShape,a=o,s=utils_1$1.generateShaderFuncNameFromInputSamplerName(a),u=i.length,c=l.length,f=util_1$4.BroadcastUtil.getBroadcastDims(i,l),d=utils_1$1.getCoordsDataType(c),m=c-u;let _;const S=utils_1$1.getGlChannels();u===0?_="":c<2&&f.length>=1?_="coords = 0;":_=f.map(B=>`coords.${S[B+m]} = 0;`).join(`
- `);let E="";c<2&&u>0?E="coords":E=i.map((B,V)=>`coords.${S[V+m]}`).join(", ");let $="return outputValue;";const v=util_1$4.ShapeUtil.size(i)===1,P=util_1$4.ShapeUtil.size(l)===1;if(u===1&&!v&&!P)$=`
- return vec4(outputValue.xy, outputValue.xy);
- `;else if(v&&!P)c===1?$=`
- return vec4(outputValue.x, outputValue.x, 0., 0.);
- `:$=`
- return vec4(outputValue.x);
- `;else if(f.length){const B=u-2,V=u-1;f.indexOf(B)>-1&&f.indexOf(V)>-1?$="return vec4(outputValue.x);":f.indexOf(B)>-1?$="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":f.indexOf(V)>-1&&($="return vec4(outputValue.xx, outputValue.zz);")}const C=`
- int lastDim = coords.${S[c-1]};
- coords.${S[c-1]} = coords.${S[c-2]};
- coords.${S[c-2]} = lastDim;
- `,L=`
- vec4 ${e}() {
- ${d} coords = getOutputCoords();
- ${C}
- ${_}
- vec4 outputValue = ${s}(${E});
- ${$}
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(L,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,r,t,o){const i=[t.width,t.height],l=[r.width,r.height],a=r.unpackedShape.length,s=t.unpackedShape.length,u=r.unpackedShape,c=t.unpackedShape,f=utils_1$1.generateShaderFuncNameFromInputSamplerName(o);if(a===s&&util_1$4.ArrayUtil.arraysEqual(l,i)){const v=`
- float ${e}() {
- return sampleTexture(${o}, TexCoords);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(v,["coordinates.sampleTexture"])}const d=utils_1$1.getCoordsDataType(s),m=util_1$4.BroadcastUtil.getBroadcastDims(u,c),_=s-a;let S;const E=utils_1$1.getGlChannels();a===0?S="":s<2&&m.length>=1?S="coords = 0;":S=m.map(v=>`coords.${E[v+_]} = 0;`).join(`
- `);let $="";s<2&&a>0?$="coords":$=r.unpackedShape.map((v,A)=>`coords.${E[A+_]}`).join(", ");const y=`
- float ${e}() {
- ${d} coords = getOutputCoords();
- ${S}
- return ${f}(${$});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(y,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,r,t){switch(t.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,r);case 1:return this.getPackedSampler1D(e,r,t);case 2:return this.getPackedSampler2D(e,r,t);case 3:return this.getPackedSampler3D(e,r,t);default:return this.getPackedSamplerND(e,r,t)}}getUnpackedSamplerFromInput(e,r,t){const o=t.unpackedShape;switch(o.length){case 0:return this.getUnpackedSamplerScalar(e,r,t);case 1:return this.getUnpackedSampler1D(e,r,t);case 2:return this.getUnpackedSampler2D(e,r,t);case 3:return this.getUnpackedSampler3D(e,r,t);case 4:return this.getUnpackedSampler4D(e,r,t);case 5:return this.getUnpackedSampler5D(e,r,t);case 6:return this.getUnpackedSampler6D(e,r,t);default:throw new Error(`Unsupported dimension ${o.length}-D`)}}getPackedSamplerScalar(e,r){const t=glsl_source_1$3.getGlsl(this.context.glContext.version),o=`
- vec4 ${e}() {
- return ${t.texture2D}(${r}, halfCR);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(o)}getPackedSampler1D(e,r,t){const o=[t.width,t.height],i=[o[1],o[0]],l=glsl_source_1$3.getGlsl(this.context.glContext.version),s=`vec4 ${e}(int index) {
- vec2 uv = packedUVfrom1D(
- ${i[0]}, ${i[1]}, index);
- return ${l.texture2D}(${r}, uv);
- }`;return new glsl_definitions_1$5.GlslLibRoutine(s,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,r,t){const o=t.unpackedShape,i=[t.width,t.height],l=glsl_source_1$3.getGlsl(this.context.glContext.version),a=i[0],s=i[1];if(i!=null&&util_1$4.ArrayUtil.arraysEqual(o,i)){const m=`vec4 ${e}(int row, int col) {
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}.0, ${a}.0);
- return ${l.texture2D}(${r}, uv);
- }`;return new glsl_definitions_1$5.GlslLibRoutine(m)}const u=i,c=Math.ceil(o[1]/2),d=`vec4 ${e}(int row, int col) {
- vec2 uv = packedUVfrom2D(${u[1]}, ${u[0]}, ${c}, row, col);
- return ${l.texture2D}(${r}, uv);
- }`;return new glsl_definitions_1$5.GlslLibRoutine(d,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,r,t){const o=t.unpackedShape,i=[t.width,t.height],l=[i[0],i[1]],a=glsl_source_1$3.getGlsl(this.context.glContext.version);if(o[0]===1){const _=o.slice(1),S=[1,2],E=utils_1$1.squeezeInputShape(o,_),$=["b","row","col"],y=JSON.parse(JSON.stringify(t));y.unpackedShape=E;const v=this.getPackedSamplerFromInput(e,r,y),P=`${v.routineBody}
- vec4 ${e}(int b, int row, int col) {
- return ${e}(${utils_1$1.getSqueezedParams($,S)});
- } `;return new glsl_definitions_1$5.GlslLibRoutine(P,v.dependencies)}const s=l[0],u=l[1],c=Math.ceil(o[2]/2),f=c*Math.ceil(o[1]/2),m=`vec4 ${e}(int b, int row, int col) {
- vec2 uv = packedUVfrom3D(
- ${u}, ${s}, ${f}, ${c}, b, row, col);
- return ${a.texture2D}(${r}, uv);}`;return new glsl_definitions_1$5.GlslLibRoutine(m,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,r,t){const o=t.unpackedShape,i=o.length,l=[t.width,t.height],a=glsl_source_1$3.getGlsl(this.context.glContext.version),s=[l[0],l[1]],u=s[1],c=s[0],f=Math.ceil(o[i-1]/2);let d=f*Math.ceil(o[i-2]/2),m="int b, int row, int col",_=`b * ${d} + (row / 2) * ${f} + (col / 2)`;for(let $=2;$<i-1;$++)m=`int b${$}, `+m,d*=o[i-$-1],_=`b${$} * ${d} + `+_;const E=`vec4 ${e}(${m}) {
- int index = ${_};
- int texR = index / ${c};
- int texC = index - texR * ${c};
- vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${u});
- return ${a.texture2D}(${r}, uv);
- }`;return new glsl_definitions_1$5.GlslLibRoutine(E)}getUnpackedSamplerScalar(e,r,t){const[o,i]=[t.width,t.height];if(o===1&&i===1){const a=`
- float ${e}() {
- return sampleTexture(${r}, halfCR);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(a,["coordinates.sampleTexture"])}const l=`
- float ${e}() {
- int offset_${r} = coordsToOffset(TexCoords, ${o}, ${i});
- vec2 uv = uvFromFlat(${o}, ${i}, offset_${r});
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(l,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(e,r,t){const o=t.width,i=t.height;if(i===1&&o===1){const a=`
- float ${e}(int index) {
- return sampleTexture(${r}, halfCR);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(a,["coordinates.sampleTexture"])}if(i===1){const a=`
- float ${e}(int index) {
- vec2 uv = vec2((float(index) + 0.5) / ${o}.0, 0.5);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(a,["coordinates.sampleTexture"])}if(o===1){const a=`
- float ${e}(int index) {
- vec2 uv = vec2(0.5, (float(index) + 0.5) / ${i}.0);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(a,["coordinates.sampleTexture"])}const l=`
- float ${e}(int index) {
- vec2 uv = uvFromFlat(${o}, ${i}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(l,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(e,r,t){const o=t.unpackedShape,i=[t.height,t.width];if(i!=null&&util_1$4.ArrayUtil.arraysEqual(o,i)){const d=i[1],m=i[0],_=`
- float ${e}(int row, int col) {
- vec2 uv = (vec2(row, col) + halfCR) / vec2(${d}.0, ${m}.0);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(_,["coordinates.sampleTexture"])}const{newShape:l,keptDims:a}=texture_layout_strategy_1$1.squeezeShape(o),s=l;if(s.length<o.length){const d=utils_1$1.squeezeInputShape(o,s),m=JSON.parse(JSON.stringify(t));m.unpackedShape=d;const _=["col","row"],S=`
- ${this.getUnpackedSamplerFromInput(e,r,m).routineBody}
- float ${e}(int row, int col) {
- return ${e}(${utils_1$1.getSqueezedParams(_,a)});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(S,["coordinates.sampleTexture"])}const u=i[1],c=i[0];if(c===1){const d=`
- float ${e}(int row, int col) {
- int offset_${r} = coordsToOffset(TexCoords, ${u}, ${c});
- float index = dot(vec3(row, col, offset_${r}), vec3(${o[1]}, 1, 1));
- vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(d,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(u===1){const d=`
- float ${e}(int row, int col) {
- int offset_${r} = coordsToOffset(TexCoords, ${u}, ${c});
- float index = dot(vec3(row, col, offset_${r}), vec3(${o[1]}, 1, 1));
- vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(d,["coordinates.sampleTexture","coordinates.coordsToOffset"])}const f=`
- float ${e}(int row, int col) {
- int index = col * ${o[1]} + row;
- vec2 uv = uvFromFlat(${u}, ${c}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(f,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(e,r,t){const o=t.unpackedShape,i=o[1]*o[2],l=o[2],{newShape:a,keptDims:s}=texture_layout_strategy_1$1.squeezeShape(o),u=a;if(u.length<o.length){const m=utils_1$1.squeezeInputShape(o,u),_=["batch","col","row"],S=JSON.parse(JSON.stringify(t));S.unpackedShape=m;const E=this.getUnpackedSamplerFromInput(e,r,S),$=s.reverse(),y=`
- ${E.routineBody}
- float ${e}(int batch, int row, int col) {
- return ${e}(${utils_1$1.getSqueezedParams(_,$)});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(y,E.dependencies)}const c=t.width,f=t.height,d=`
- float ${e}(int depth, int row, int col) {
- // Explicitly use integer operations as dot() only works on floats.
- int index = depth * ${i} + col * ${l} + row;
- vec2 uv = uvFromFlat(${c}, ${f}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(d,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(e,r,t){const o=t.unpackedShape,i=o[3],l=o[2]*i,a=o[1]*l,s=t.width,u=t.height,c=`
- float ${e}(int row, int col, int depth, int depth2) {
- int index = row * ${a} + col * ${l} +
- depth2 * ${i} + depth;
- vec2 uv = uvFromFlat(${s}, ${u}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(c,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(e,r,t){const o=t.unpackedShape,i=o[4],l=o[3]*i,a=o[2]*l,s=o[1]*a,{newShape:u,keptDims:c}=texture_layout_strategy_1$1.squeezeShape(o);if(u.length<o.length){const _=utils_1$1.squeezeInputShape(o,u),S=["row","col","depth","depth2","depth3"],E=JSON.parse(JSON.stringify(t));E.unpackedShape=_;const $=`
- ${this.getUnpackedSamplerFromInput(e,r,E).routineBody}
- float ${e}(int row, int col, int depth, int depth2, int depth3) {
- return ${e}(${utils_1$1.getSqueezedParams(S,c)});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine($,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const f=t.width,d=t.height,m=`
- float ${e}(int row, int col, int depth, int depth2, int depth3) {
- int index = row * ${s} + col * ${a} + depth * ${l} +
- depth3 * ${i} + depth2;
- vec2 uv = uvFromFlat(${f}, ${d}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(m,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(e,r,t){const o=t.unpackedShape,i=o[5],l=o[4]*i,a=o[3]*l,s=o[2]*a,u=o[1]*s,{newShape:c,keptDims:f}=texture_layout_strategy_1$1.squeezeShape(o);if(c.length<o.length){const S=utils_1$1.squeezeInputShape(o,c),E=["row","col","depth","depth2","depth3","depth4"],$=JSON.parse(JSON.stringify(t));$.unpackedShape=S;const y=`
- ${this.getUnpackedSamplerFromInput(e,r,$).routineBody}
- float ${e}(int row, int col, int depth,
- int depth2, int depth3, int depth4) {
- return ${e}(${utils_1$1.getSqueezedParams(E,f)});
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(y,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const d=t.width,m=t.height,_=`
- float ${e}(int row, int col, int depth,
- int depth2, int depth3, int depth4) {
- int index = row * ${u} + col * ${s} + depth * ${a} +
- depth2 * ${l} + depth3 * ${i} + depth4;
- vec2 uv = uvFromFlat(${d}, ${m}, index);
- return sampleTexture(${r}, uv);
- }
- `;return new glsl_definitions_1$5.GlslLibRoutine(_,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){const e=this.context.outputTextureLayout,r=e.shape.length,t=e.strides,o=e.width,i=e.height,l=[];for(let s=0;s<r-1;++s)l.push(`
- c[${s}] = offset / ${t[s]};`),l.push(`
- offset -= c[${s}] * ${t[s]};`);l.push(`
- c[${r-1}] = offset;`);const a=`
- void toVec(vec2 texCoords, out int c[${r}]) {
- int offset = coordsToOffset(texCoords, ${o}, ${i});
- ${l.join("")}
- }
- void toVec(int offset, out int c[${r}]) {
- ${l.join("")}
- }
- `;return{toVec:new glsl_definitions_1$5.GlslLibRoutine(a,["coordinates.coordsToOffset"])}}valueFrom(){const e={};return this.context.programInfo.inputNames.forEach((r,t)=>{const o=this.context.inputTextureLayouts[t],l=(o.unpackedShape.length>0?o.unpackedShape:o.shape).length;let a=`_${r}`;e[a]=new glsl_definitions_1$5.GlslLibRoutine(this.getValueFromSingle(r,l,o.width,o.height,!1),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),a=a+"_T",e[a]=new glsl_definitions_1$5.GlslLibRoutine(this.getValueFromSingle(r,l,o.width,o.height,!0),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),e}getValueFromSingle(e,r,t,o,i){let l=`_${e}`;i&&(l=l+"_T");const a=glsl_source_1$3.getGlsl(this.context.glContext.version);return`
- float ${l}(int m[${r}]) {
- int offset = indicesToOffset${l}(m);
- vec2 coords = offsetToCoords(offset, ${t}, ${o});
- float value = getColorAsFloat(${a.texture2D}(${e}, coords));
- return value;
- }
- `}getPackedValueFrom(e,r,t,o,i){let l=`_${e}_Pack`;i&&(l=l+"_T");const a=glsl_source_1$3.getGlsl(this.context.glContext.version);return`
- vec4 ${l}(int m[${r}]) {
- int offset = indicesToOffset_${e}(m);
- vec2 coords = offsetToCoords(offset, ${t}, ${o});
- return ${a.texture2D}(${e}, coords);
- }
- `}}glslCoordinateLib.CoordsGlslLib=CoordsGlslLib;var glslEncodingLib={};Object.defineProperty(glslEncodingLib,"__esModule",{value:!0});glslEncodingLib.EncodingGlslLib=void 0;const glsl_definitions_1$4=glslDefinitions;class EncodingGlslLib extends glsl_definitions_1$4.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new glsl_definitions_1$4.GlslLibRoutine(`highp vec4 encode(highp float f) {
- return vec4(f, 0.0, 0.0, 0.0);
- }
- `)}}decodeFloat32(){return{decode:new glsl_definitions_1$4.GlslLibRoutine(`highp float decode(highp vec4 rgba) {
- return rgba.r;
- }
- `)}}encodeUint8(){const e=EncodingGlslLib.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new glsl_definitions_1$4.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)));
- ${e}
- rgba = rgba / 255.0; // values need to be normalized to [0,1]
- return rgba;
- }
- `)}}decodeUint8(){const e=EncodingGlslLib.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new glsl_definitions_1$4.GlslLibRoutine(`
- highp float decode(highp vec4 rgba) {
- rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
- ${e}
- 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 e=new ArrayBuffer(4),r=new Uint32Array(e),t=new Uint8Array(e);if(r[0]=3735928559,t[0]===239)return!0;if(t[0]===222)return!1;throw new Error("unknown endianness")}}glslEncodingLib.EncodingGlslLib=EncodingGlslLib;var glslFragcolorLib={};Object.defineProperty(glslFragcolorLib,"__esModule",{value:!0});glslFragcolorLib.FragColorGlslLib=void 0;const glsl_definitions_1$3=glslDefinitions,glsl_source_1$2=glslSource;class FragColorGlslLib extends glsl_definitions_1$3.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const e=glsl_source_1$2.getGlsl(this.context.glContext.version);return{setFragColor:new glsl_definitions_1$3.GlslLibRoutine(`
- void setFragColor(float value) {
- ${e.output} = encode(value);
- }
- `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new glsl_definitions_1$3.GlslLibRoutine(`
- float getColorAsFloat(vec4 color) {
- return decode(color);
- }
- `,["encoding.decode"])}}}glslFragcolorLib.FragColorGlslLib=FragColorGlslLib;var glslShapeUtilsLib={};Object.defineProperty(glslShapeUtilsLib,"__esModule",{value:!0});glslShapeUtilsLib.ShapeUtilsGlslLib=void 0;const glsl_definitions_1$2=glslDefinitions;class ShapeUtilsGlslLib extends glsl_definitions_1$2.GlslLib{constructor(e){super(e)}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 e=this.context.outputTextureLayout.shape.length,r={};return this.context.programInfo.inputNames.forEach((t,o)=>{const i=this.context.inputTextureLayouts[o].unpackedShape;if(i.length<=e){const l=i.length,a=e-l,s=`bcastIndices_${t}`;let u="";for(let f=0;f<l;++f)u+=`
- realIndices[${f}] = int( mod(float(bcastedIndices[${a+f}]), ${i[f]}.0) );
- `;const c=`
- void ${s} (int bcastedIndices[${e}], out int realIndices[${l}]) {
- ${u}
- }
- `;r[s]=new glsl_definitions_1$2.GlslLibRoutine(c)}}),r}bcastMatmulIndex(){const e=this.context.outputTextureLayout.shape.length,r={};return this.context.programInfo.inputNames.forEach((t,o)=>{const i=this.context.inputTextureLayouts[o].shape;if(!(i.length<2||i.length>e)){const l=i.length,a=e-l,s=`bcastMatmulIndices_${t}`;let u="";for(let f=0;f<l-2;++f)u+=`
- realIndices[${f}] = int( mod(float(bcastedIndices[${a+f}]), ${i[f]}.0) );
- `;const c=`
- void ${s}(int bcastedIndices[${e}], out int realIndices[${l}]) {
- ${u}
- realIndices[${l-1}] = bcastedIndices[${e-1}];
- realIndices[${l-2}] = bcastedIndices[${e-2}];
- }
- `;r[s]=new glsl_definitions_1$2.GlslLibRoutine(c)}}),r}indicesToOffset(){const e={};return this.context.programInfo.inputNames.forEach((r,t)=>{const o=this.context.inputTextureLayouts[t].shape,i=this.context.inputTextureLayouts[t].strides,l=o.length;let a=`indicesToOffset_${r}`;e[a]=new glsl_definitions_1$2.GlslLibRoutine(ShapeUtilsGlslLib.indexToOffsetSingle(a,l,i)),a=`indicesToOffset_${r}_T`,e[a]=new glsl_definitions_1$2.GlslLibRoutine(ShapeUtilsGlslLib.indexToOffsetSingle(a,l,i.slice().reverse()))}),e}static indexToOffsetSingle(e,r,t){let o="";for(let i=r-1;i>=0;--i)o+=`
- offset += indices[${i}] * ${t[i]};
- `;return`
- int ${e}(int indices[${r}]) {
- int offset = 0;
- ${o}
- return offset;
- }
- `}offsetToIndices(){const e={};return this.context.programInfo.inputNames.forEach((r,t)=>{const o=this.context.inputTextureLayouts[t].shape,i=this.context.inputTextureLayouts[t].strides,l=o.length;let a=`offsetToIndices_${r}`;e[a]=new glsl_definitions_1$2.GlslLibRoutine(ShapeUtilsGlslLib.offsetToIndicesSingle(a,l,i)),a=`offsetToIndices_${r}_T`,e[a]=new glsl_definitions_1$2.GlslLibRoutine(ShapeUtilsGlslLib.offsetToIndicesSingle(a,l,i.slice().reverse()))}),e}static offsetToIndicesSingle(e,r,t){const o=[];for(let i=0;i<r-1;++i)o.push(`
- indices[${i}] = offset / ${t[i]};`),o.push(`
- offset -= indices[${i}] * ${t[i]};`);return o.push(`
- indices[${r-1}] = offset;`),`
- void ${e}(int offset, out int indices[${r}]) {
- ${o.join("")}
- }
- `}incrementIndices(){const e={};return this.context.programInfo.inputNames.forEach((r,t)=>{const o=this.context.inputTextureLayouts[t].shape,i=o.length,l=`incrementIndices_${r}`;let a="";for(let u=0;u<i;++u)a+=`
- shape[${u}] = ${o[u]};`;const s=`
- void ${l}(int axis, out int indices[${i}]) {
- int shape[${i}];
- ${a};
- for(int i = ${i} -1 ; i >= 0; --i) {
- if(i > axis) continue;
- indices[i] += 1;
- if(indices[i] < shape[i]) {
- break;
- }
- indices[i] = 0;
- }
- }
- `;e[l]=new glsl_definitions_1$2.GlslLibRoutine(s)}),e}}glslShapeUtilsLib.ShapeUtilsGlslLib=ShapeUtilsGlslLib;var glslVecLib={};Object.defineProperty(glslVecLib,"__esModule",{value:!0});glslVecLib.VecGlslLib=void 0;const glsl_definitions_1$1=glslDefinitions;class VecGlslLib extends glsl_definitions_1$1.GlslLib{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const r=this.context.outputTextureLayout.shape.length,t={add:"+=",sub:"-=",mul:"*=",div:"/="},o={};for(const i in t){const l=`${i}Vec`;let a="";for(let u=0;u<r;++u)a+=`
- dest[${u}] ${t[i]} src[${u}];
- `;const s=`
- void ${l}(int src[${r}], out int dest[${r}]) {
- ${a}
- }
- `;o[l]=new glsl_definitions_1$1.GlslLibRoutine(s)}return o}copyVec(){const r=this.context.outputTextureLayout.shape.length;let t="";for(let i=0;i<r;++i)t+=`
- dest[${i}] = src[${i}];
- `;const o=`
- void copyVec(int src[${r}], out int dest[${r}]) {
- ${t}
- }
- `;return{copyVec:new glsl_definitions_1$1.GlslLibRoutine(o)}}setVecItem(){const r=this.context.outputTextureLayout.shape.length;let t=`
- if(index < 0)
- index =${r} + index;
- if (index == 0)
- m[0] = value;
- `;for(let i=1;i<r-1;++i)t+=`
- else if (index == ${i})
- m[${i}] = value;
- `;t+=`
- else
- m[${r-1}] = value;
- `;const o=`
- void setVecItem(out int m[${r}], int index, int value) {
- ${t}
- }
- `;return{setVecItem:new glsl_definitions_1$1.GlslLibRoutine(o)}}getVecItem(){const r=this.context.outputTextureLayout.shape.length;let t=`
- if(index < 0)
- index = ${r} + index;
- if (index == 0)
- return m[0];
- `;for(let i=1;i<r-1;++i)t+=`
- else if (index == ${i})
- return m[${i}];
- `;t+=`
- else
- return m[${r-1}];
- `;const o=`
- int getVecItem(int m[${r}], int index) {
- ${t}
- }
- `;return{getVecItem:new glsl_definitions_1$1.GlslLibRoutine(o)}}}glslVecLib.VecGlslLib=VecGlslLib;Object.defineProperty(glslRegisteredLibs,"__esModule",{value:!0});glslRegisteredLibs.glslRegistry=void 0;const glsl_coordinate_lib_1=glslCoordinateLib,glsl_encoding_lib_1=glslEncodingLib,glsl_fragcolor_lib_1=glslFragcolorLib,glsl_shape_utils_lib_1=glslShapeUtilsLib,glsl_vec_lib_1=glslVecLib;glslRegisteredLibs.glslRegistry={encoding:glsl_encoding_lib_1.EncodingGlslLib,fragcolor:glsl_fragcolor_lib_1.FragColorGlslLib,vec:glsl_vec_lib_1.VecGlslLib,shapeUtils:glsl_shape_utils_lib_1.ShapeUtilsGlslLib,coordinates:glsl_coordinate_lib_1.CoordsGlslLib};Object.defineProperty(glslPreprocessor,"__esModule",{value:!0});glslPreprocessor.GlslPreprocessor=void 0;const glsl_definitions_1=glslDefinitions,glsl_function_inliner_1=glslFunctionInliner,glsl_registered_libs_1=glslRegisteredLibs,glsl_source_1$1=glslSource;class GlslPreprocessor{constructor(e,r,t,o){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new glsl_definitions_1.GlslContext(e,r,t,o),Object.keys(glsl_registered_libs_1.glslRegistry).forEach(l=>{const a=new glsl_registered_libs_1.glslRegistry[l](this.context);this.libs[l]=a});const i=this.glslLibRoutineDependencyGraph;for(const l in this.libs){const s=this.libs[l].getFunctions();for(const u in s){const c=l+"."+u;let f;i[c]?(f=i[c],f.routineBody=s[u].routineBody):(f=new glsl_definitions_1.GlslLibRoutineNode(c,s[u].routineBody),i[c]=f);const d=s[u].dependencies;if(d)for(let m=0;m<d.length;++m)if(i[d[m]])f.addDependency(i[d[m]]);else{const _=new glsl_definitions_1.GlslLibRoutineNode(d[m]);i[d[m]]=_,f.addDependency(_)}}}}preprocess(){const e=this.context.programInfo;let r=e.shaderSource;return this.context.programInfo.hasMain||(r=`${r}
- ${glsl_source_1$1.getDefaultFragShaderMain(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),r=glsl_function_inliner_1.replaceInlines(r),`${glsl_source_1$1.getFragShaderPreamble(this.context.glContext.version)}
- ${this.getUniforms(e.inputNames,e.variables)}
- ${this.getImports(r)}
- ${r}`}getImports(e){const r=this.selectGlslLibRoutinesToBeIncluded(e);if(r.length===0)return"";let t="";for(let o=0;o<r.length;++o)if(r[o].routineBody)t+=r[o].routineBody+`
- `;else throw new Error(`Missing body for the Glsl Library routine: ${r[o].name}`);return t}selectGlslLibRoutinesToBeIncluded(e){const r=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(t=>{const o=t.split(".")[1];e.indexOf(o)!==-1&&r.push(this.glslLibRoutineDependencyGraph[t])}),glsl_definitions_1.TopologicalSortGlslRoutines.returnOrderedNodes(r)}getUniforms(e,r){const t=[];if(e)for(const o of e)t.push(`uniform sampler2D ${o};`);if(r)for(const o of r)t.push(`uniform ${o.type} ${o.name}${o.arrayLength?`[${o.arrayLength}]`:""};`);return t.join(`
- `)}}glslPreprocessor.GlslPreprocessor=GlslPreprocessor;Object.defineProperty(programManager,"__esModule",{value:!0});programManager.ProgramManager=void 0;const onnxruntime_common_1$5=require$$0$1,instrument_1$7=instrument,glsl_preprocessor_1=glslPreprocessor,glsl_source_1=glslSource;class ProgramManager{constructor(e,r,t){this.profiler=e,this.glContext=r,this.textureLayoutStrategy=t,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,r){this.repo.set(e,r)}run(e,r,t){var o;this.profiler.event("op",`ProgramManager.run ${(o=e.programInfo.name)!==null&&o!==void 0?o:"unknown kernel"}`,()=>{var i;const l=this.glContext.gl,a=e.program;l.useProgram(a);try{this.bindOutput(t),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,(i=e.programInfo.variables)!==null&&i!==void 0?i:[],r)}catch(s){throw instrument_1$7.Logger.error("ProgramManager",e.programInfo.shaderSource),s}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(e=>this.glContext.deleteProgram(e.program))}build(e,r,t){return this.profiler.event("backend","ProgramManager.build",()=>{const o=new glsl_preprocessor_1.GlslPreprocessor(this.glContext,e,r,t),i=o.preprocess(),l=this.compile(i);return{programInfo:e,program:l,uniformLocations:this.getUniformLocations(l,o.context.programInfo.inputNames,o.context.programInfo.variables),attribLocations:this.getAttribLocations(l)}})}compile(e){if(!this.vertexShader){instrument_1$7.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const o=glsl_source_1.getVertexShaderSource(this.glContext.version);this.vertexShader=this.glContext.compileShader(o,this.glContext.gl.VERTEX_SHADER)}onnxruntime_common_1$5.env.debug&&instrument_1$7.Logger.verbose("ProrgramManager",`FragShader:
- ${e}
- `);const r=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),t=this.glContext.createProgram(this.vertexShader,r);return this.glContext.deleteShader(r),t}bindOutput(e){const r=e.width,t=e.height;instrument_1$7.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${r}/${t}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,r,t)}bindAttributes(e){const r=e.position,t=e.textureCoord;this.glContext.setVertexAttributes(r,t),this.attributesBound=!0}bindUniforms(e,r,t){var o;const i=this.glContext.gl;let l=0;for(const{name:a,type:s,location:u,arrayLength:c}of e){const f=(o=r.find(d=>d.name===a))===null||o===void 0?void 0:o.data;if(s!=="sampler2D"&&!f)throw new Error(`variable '${a}' does not have data defined in program info`);switch(s){case"sampler2D":this.bindTexture(t[l],u,l),l++;break;case"float":c?i.uniform1fv(u,f):i.uniform1f(u,f);break;case"int":c?i.uniform1iv(u,f):i.uniform1i(u,f);break;default:throw new Error(`Uniform not implemented: ${s}`)}}}bindTexture(e,r,t){this.glContext.bindTextureToUniform(e.texture,t,r)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,r,t){const o=[];if(r)for(const i of r)o.push({name:i,type:"sampler2D",location:this.getUniformLocation(e,i)});if(t)for(const i of t)o.push(Object.assign(Object.assign({},i),{location:this.getUniformLocation(e,i.name)}));return o}getUniformLocation(e,r){const o=this.glContext.gl.getUniformLocation(e,r);if(o===null)throw new Error(`Uniform ${r} not found.`);return o}getAttribLocation(e,r){return this.glContext.gl.getAttribLocation(e,r)}}programManager.ProgramManager=ProgramManager;var textureManager={};Object.defineProperty(textureManager,"__esModule",{value:!0});textureManager.TextureManager=void 0;const instrument_1$6=instrument;class TextureManager{constructor(e,r,t,o){this.glContext=e,this.layoutStrategy=r,this.profiler=t,this.config=o,this.pendingRead=new Map,o.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,r,t,o){const i=this.toEncoderType(e),l=this.glContext.getEncoder(i,r.channels||1,o);if(r.isPacked&&o===1)throw new Error("not implemented");const a=r.width,s=r.height;let u,c;if(this.config.reuseTextures){u=`${a}x${s}_${l.format}_${l.internalFormat}_${l.textureType}`,c=this.inUseTextures.get(u),c||(c=[],this.inUseTextures.set(u,c));const d=this.idleTextures.get(u);if(d&&d.length>0){const m=d.pop();return c.push(m),o===1&&this.glContext.updateTexture(m,a,s,l,this.toTextureData(e,t)),m}}instrument_1$6.Logger.verbose("TextureManager",`Creating new texture of size ${r.width}x${r.height}`);const f=this.glContext.allocateTexture(a,s,l,this.toTextureData(e,t));return this.config.reuseTextures&&(c.push(f),this.textureLookup.set(f,u)),f}readTexture(e,r,t){return t||(t=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const o=e.shape.reduce((l,a)=>l*a)*t,i=this.glContext.readTexture(e.texture,e.width,e.height,o,this.toEncoderType(r),t);return this.toTensorData(r,i)})}async readTextureAsync(e,r,t){const o=e.tensor.dataId;if(t||(t=1),this.pendingRead.has(o)){const i=this.pendingRead.get(o);return new Promise(l=>i==null?void 0:i.push(l))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(o,[]);const i=e.shape.reduce((u,c)=>u*c)*t;await this.glContext.createAndWaitForFence();const l=this.glContext.readTexture(e.texture,e.width,e.height,i,this.toEncoderType(r),t),a=this.toTensorData(r,l),s=this.pendingRead.get(o);return this.pendingRead.delete(o),s==null||s.forEach(u=>u(a)),a})}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const r=e.shape.reduce((o,i)=>o*i),t=this.glContext.readTexture(e.texture,e.width,e.height,r*4,"byte",4);return new Float32Array(t.buffer,t.byteOffset,r)})}releaseTexture(e,r){let t;if(this.config.reuseTextures&&(t=this.textureLookup.get(e.texture),t)){r&&this.textureLookup.delete(t);const o=this.inUseTextures.get(t);if(o){const i=o.indexOf(e.texture);if(i!==-1){o.splice(i,1);let l=this.idleTextures.get(t);l||(l=[],this.idleTextures.set(t,l)),l.push(e.texture)}}}(!t||r)&&(instrument_1$6.Logger.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,r){switch(e){case"int16":return r instanceof Int16Array?r:Int16Array.from(r);case"int32":return r instanceof Int32Array?r:Int32Array.from(r);case"int8":return r instanceof Int8Array?r:Int8Array.from(r);case"uint16":return r instanceof Uint16Array?r:Uint16Array.from(r);case"uint32":return r instanceof Uint32Array?r:Uint32Array.from(r);case"uint8":case"bool":return r instanceof Uint8Array?r:Uint8Array.from(r);case"float32":return r instanceof Float32Array?r:Float32Array.from(r);case"float64":return r instanceof Float64Array?r:Float64Array.from(r);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,r){if(!!r)return r instanceof Float32Array?r:new Float32Array(r)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}textureManager.TextureManager=TextureManager;Object.defineProperty(sessionHandler$2,"__esModule",{value:!0});sessionHandler$2.WebGLSessionHandler=void 0;const instrument_1$5=instrument,opset_1=opset,inference_handler_1=inferenceHandler,op_resolve_rules_1=opResolveRules,program_manager_1=programManager,texture_layout_strategy_1=textureLayoutStrategy,texture_manager_1=textureManager;class WebGLSessionHandler{constructor(e,r){this.backend=e,this.context=r,this.layoutStrategy=new texture_layout_strategy_1.PreferLogicalStrategy(e.glContext.maxTextureSize),this.programManager=new program_manager_1.ProgramManager(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new texture_manager_1.TextureManager(e.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:e.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=e.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new inference_handler_1.WebGLInferenceHandler(this)}onGraphInitialized(e){const r=e.getValues().filter(t=>t.from===-1&&t.tensor).map(t=>t.tensor.dataId);this.initializers=new Set(r)}isInitializer(e){return this.initializers?this.initializers.has(e):!1}addInitializer(e){this.initializers.add(e)}getTextureData(e,r){return r?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,r,t=!1){instrument_1$5.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),t?this.packedTextureDataCache.set(e,r):this.unpackedTextureDataCache.set(e,r)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(e=>this.textureManager.releaseTexture(e,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(e=>this.textureManager.releaseTexture(e,!0)),this.unpackedTextureDataCache=new Map}resolve(e,r,t){const o=opset_1.resolveOperator(e,r,op_resolve_rules_1.WEBGL_OP_RESOLVE_RULES);return{impl:o.opImpl,context:o.opInit?o.opInit(e,t):e}}}sessionHandler$2.WebGLSessionHandler=WebGLSessionHandler;var webglContextFactory={},webglContext={},textureDataEncoder={};Object.defineProperty(textureDataEncoder,"__esModule",{value:!0});textureDataEncoder.Uint8DataEncoder=textureDataEncoder.RGBAFloatDataEncoder=textureDataEncoder.RedFloat32DataEncoder=void 0;const instrument_1$4=instrument;class RedFloat32DataEncoder{constructor(e,r=1){if(r===1)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=r;else if(r===4)this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(e,r){let t,o;return e.constructor!==Float32Array&&(instrument_1$4.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),o=new Float32Array(e)),r*this.channelSize>e.length?(instrument_1$4.Logger.warning("Encoder","Source data too small. Allocating larger array"),o=e,t=this.allocate(r*this.channelSize),o.forEach((i,l)=>t[l]=i)):(o=e,t=o),t}allocate(e){return new Float32Array(e*4)}decode(e,r){return this.channelSize===1?e.filter((o,i)=>i%4===0).subarray(0,r):e.subarray(0,r)}}textureDataEncoder.RedFloat32DataEncoder=RedFloat32DataEncoder;class RGBAFloatDataEncoder{constructor(e,r=1,t){if(r!==1&&r!==4)throw new Error(`Invalid number of channels: ${r}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=r,this.textureType=t||e.FLOAT}encode(e,r){let t=e;return this.channelSize===1&&(instrument_1$4.Logger.verbose("Encoder","Exploding into a larger array"),t=this.allocate(r),e.forEach((o,i)=>t[i*4]=o)),t}allocate(e){return new Float32Array(e*4)}decode(e,r){return this.channelSize===1?e.filter((o,i)=>i%4===0).subarray(0,r):e.subarray(0,r)}}textureDataEncoder.RGBAFloatDataEncoder=RGBAFloatDataEncoder;class Uint8DataEncoder{constructor(e,r=1){if(this.channelSize=4,r===1)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=r;else if(r===4)this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=r;else throw new Error(`Invalid number of channels: ${r}`)}encode(e,r){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,r){if(e instanceof Uint8Array)return e.subarray(0,r);throw new Error(`Invalid array type: ${e.constructor}`)}}textureDataEncoder.Uint8DataEncoder=Uint8DataEncoder;var __createBinding$2=commonjsGlobal$1&&commonjsGlobal$1.__createBinding||(Object.create?function(n,e,r,t){t===void 0&&(t=r),Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[r]}})}:function(n,e,r,t){t===void 0&&(t=r),n[t]=e[r]}),__setModuleDefault$2=commonjsGlobal$1&&commonjsGlobal$1.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),__importStar$2=commonjsGlobal$1&&commonjsGlobal$1.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var r in n)r!=="default"&&Object.prototype.hasOwnProperty.call(n,r)&&__createBinding$2(e,n,r);return __setModuleDefault$2(e,n),e};Object.defineProperty(webglContext,"__esModule",{value:!0});webglContext.WebGLContext=webglContext.linearSearchLastTrue=void 0;const onnxruntime_common_1$4=require$$0$1,DataEncoders=__importStar$2(textureDataEncoder),utils_1=utils;function linearSearchLastTrue(n){let e=0;for(;e<n.length&&n[e]();++e);return e-1}webglContext.linearSearchLastTrue=linearSearchLastTrue;class WebGLContext{constructor(e,r){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=e,this.version=r,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(e,r,t,o){const i=this.gl,l=i.createTexture();i.bindTexture(i.TEXTURE_2D,l),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);const a=o?t.encode(o,e*r):null;return i.texImage2D(i.TEXTURE_2D,0,t.internalFormat,e,r,0,t.format,t.textureType,a),this.checkError(),l}updateTexture(e,r,t,o,i){const l=this.gl;l.bindTexture(l.TEXTURE_2D,e);const a=o.encode(i,r*t);l.texSubImage2D(l.TEXTURE_2D,0,0,0,r,t,o.format,o.textureType,a),this.checkError()}attachFramebuffer(e,r,t){const o=this.gl;o.bindTexture(o.TEXTURE_2D,e),o.bindFramebuffer(o.FRAMEBUFFER,this.framebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,e,0),this.checkError(),o.viewport(0,0,r,t),o.scissor(0,0,r,t)}readTexture(e,r,t,o,i,l){const a=this.gl;l||(l=1),this.frameBufferBound||this.attachFramebuffer(e,r,t);const s=this.getEncoder(i,l),u=s.allocate(r*t);return a.bindTexture(a.TEXTURE_2D,e),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e,0),a.readPixels(0,0,r,t,a.RGBA,s.textureType,u),this.checkError(),s.decode(u,o)}isFramebufferReady(){return!0}getActiveTexture(){const e=this.gl;return`TEXTURE${e.getParameter(this.gl.ACTIVE_TEXTURE)-e.TEXTURE0}`}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(e,r){const t=this.gl;t.vertexAttribPointer(e,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(e),r!==-1&&(t.vertexAttribPointer(r,2,t.FLOAT,!1,20,12),t.enableVertexAttribArray(r)),this.checkError()}createProgram(e,r){const t=this.gl,o=t.createProgram();return t.attachShader(o,e),t.attachShader(o,r),t.linkProgram(o),o}compileShader(e,r){const t=this.gl,o=t.createShader(r);if(!o)throw new Error(`createShader() returned null with type ${r}`);if(t.shaderSource(o,e),t.compileShader(o),t.getShaderParameter(o,t.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${t.getShaderInfoLog(o)}
- Shader source:
- ${e}`);return o}deleteShader(e){this.gl.deleteShader(e)}bindTextureToUniform(e,r,t){const o=this.gl;o.activeTexture(o.TEXTURE0+r),this.checkError(),o.bindTexture(o.TEXTURE_2D,e),this.checkError(),o.uniform1i(t,r),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(onnxruntime_common_1$4.env.debug){const e=this.gl,r=e.getError();let t="";switch(r){case e.NO_ERROR:return;case e.INVALID_ENUM:t="INVALID_ENUM";break;case e.INVALID_VALUE:t="INVALID_VALUE";break;case e.INVALID_OPERATION:t="INVALID_OPERATION";break;case e.INVALID_FRAMEBUFFER_OPERATION:t="INVALID_FRAMEBUFFER_OPERATION";break;case e.OUT_OF_MEMORY:t="OUT_OF_MEMORY";break;case e.CONTEXT_LOST_WEBGL:t="CONTEXT_LOST_WEBGL";break;default:t=`Unknown WebGL Error: ${r.toString(16)}`}throw new Error(t)}}deleteTexture(e){this.gl.deleteTexture(e)}deleteProgram(e){this.gl.deleteProgram(e)}getEncoder(e,r,t=0){if(this.version===2)return new DataEncoders.RedFloat32DataEncoder(this.gl,r);switch(e){case"float":return t===1||this.isRenderFloat32Supported?new DataEncoders.RGBAFloatDataEncoder(this.gl,r):new DataEncoders.RGBAFloatDataEncoder(this.gl,r,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new DataEncoders.Uint8DataEncoder(this.gl,r);default:throw new Error(`Invalid dataType: ${e}`)}}clearActiveTextures(){const e=this.gl;for(let r=0;r<this.maxTextureImageUnits;++r)e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,null)}dispose(){if(this.disposed)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(this.framebuffer),e.bindBuffer(e.ARRAY_BUFFER,null),e.deleteBuffer(this.vertexbuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){const e=this.gl,r=e.createBuffer();if(!r)throw new Error("createBuffer() returned null");const t=this.createDefaultGeometry();return e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),this.checkError(),r}createFramebuffer(){const e=this.gl.createFramebuffer();if(!e)throw new Error("createFramebuffer returned null");return e}queryVitalParameters(){const e=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){const e=this.gl,r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const t=this.version===2?e.RGBA32F:e.RGBA;e.texImage2D(e.TEXTURE_2D,0,t,1,1,0,e.RGBA,e.FLOAT,null);const o=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(o),i}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){const e=this.gl;let r,t,o,i,l;try{r=e.createTexture(),t=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,r);const a=this.version===2?e.RGBA32F:e.RGBA;return e.texImage2D(e.TEXTURE_2D,0,a,1,1,0,e.RGBA,e.FLOAT,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.enable(e.BLEND),o=e.createShader(e.VERTEX_SHADER),!o||(e.shaderSource(o,"void main(){}"),e.compileShader(o),i=e.createShader(e.FRAGMENT_SHADER),!i)||(e.shaderSource(i,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),e.compileShader(i),l=e.createProgram(),!l)?!1:(e.attachShader(l,o),e.attachShader(l,i),e.linkProgram(l),e.useProgram(l),e.drawArrays(e.POINTS,0,1),e.getError()===e.NO_ERROR)}finally{e.disable(e.BLEND),l&&e.deleteProgram(l),o&&e.deleteShader(o),i&&e.deleteShader(i),t&&(e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(t)),r&&(e.bindTexture(e.TEXTURE_2D,null),e.deleteTexture(r))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const e=this.gl,r=this.disjointTimerQueryWebgl2Extension,t=e.createQuery();return e.beginQuery(r.TIME_ELAPSED_EXT,t),t}else throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const e=this.gl,r=this.disjointTimerQueryWebgl2Extension;e.endQuery(r.TIME_ELAPSED_EXT);return}else throw new Error("WebGL1 profiling currently not supported")}isTimerResultAvailable(e){let r=!1,t=!1;if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const o=this.gl,i=this.disjointTimerQueryWebgl2Extension;r=o.getQueryParameter(e,o.QUERY_RESULT_AVAILABLE),t=o.getParameter(i.GPU_DISJOINT_EXT)}else throw new Error("WebGL1 profiling currently not supported");return r&&!t}getTimerResult(e){let r=0;if(this.version===2){const t=this.gl;r=t.getQueryParameter(e,t.QUERY_RESULT),t.deleteQuery(e)}else throw new Error("WebGL1 profiling currently not supported");return r/1e6}async waitForQueryAndGetTime(e){return await utils_1.repeatedTry(()=>this.isTimerResultAvailable(e)),this.getTimerResult(e)}async createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let r;const t=e,o=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),o===null?r=()=>!0:r=()=>{const i=t.clientWaitSync(o,0,0);return i===t.ALREADY_SIGNALED||i===t.CONDITION_SATISFIED},{query:o,isFencePassed:r}}async pollFence(e){return new Promise(r=>{this.addItemToPoll(()=>e.isFencePassed(),()=>r())})}pollItems(){const e=linearSearchLastTrue(this.itemsToPoll.map(r=>r.isDoneFn));for(let r=0;r<=e;++r){const{resolveFn:t}=this.itemsToPoll[r];t()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,r){this.itemsToPoll.push({isDoneFn:e,resolveFn:r}),!(this.itemsToPoll.length>1)&&await utils_1.repeatedTry(()=>(this.pollItems(),this.itemsToPoll.length===0))}}webglContext.WebGLContext=WebGLContext;Object.defineProperty(webglContextFactory,"__esModule",{value:!0});webglContextFactory.createNewWebGLContext=webglContextFactory.createWebGLContext=void 0;const instrument_1$3=instrument,webgl_context_1=webglContext,cache={};function createWebGLContext(n){let e;(!n||n==="webgl2")&&"webgl2"in cache?e=cache.webgl2:(!n||n==="webgl")&&"webgl"in cache&&(e=cache.webgl),e=e||createNewWebGLContext(n),n=n||e.version===1?"webgl":"webgl2";const r=e.gl;return cache[n]=e,r.isContextLost()?(delete cache[n],createWebGLContext(n)):(r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.disable(r.BLEND),r.disable(r.DITHER),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SAMPLE_COVERAGE),r.enable(r.SCISSOR_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),e)}webglContextFactory.createWebGLContext=createWebGLContext;function createNewWebGLContext(n){const e=createCanvas(),r={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};let t;const o=r;if((!n||n==="webgl2")&&(t=e.getContext("webgl2",o),t))try{return new webgl_context_1.WebGLContext(t,2)}catch(i){instrument_1$3.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${i}`)}if((!n||n==="webgl")&&(t=e.getContext("webgl",o)||e.getContext("experimental-webgl",o),t))try{return new webgl_context_1.WebGLContext(t,1)}catch(i){instrument_1$3.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${i}`)}throw new Error("WebGL is not supported")}webglContextFactory.createNewWebGLContext=createNewWebGLContext;function createCanvas(){const n=document.createElement("canvas");return n.width=1,n.height=1,n}Object.defineProperty(backendWebgl,"__esModule",{value:!0});backendWebgl.WebGLBackend=void 0;const onnxruntime_common_1$3=require$$0$1,instrument_1$2=instrument,session_handler_1$1=sessionHandler$2,webgl_context_factory_1=webglContextFactory;class WebGLBackend{get contextId(){return onnxruntime_common_1$3.env.webgl.contextId}set contextId(e){onnxruntime_common_1$3.env.webgl.contextId=e}get matmulMaxBatchSize(){return onnxruntime_common_1$3.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){onnxruntime_common_1$3.env.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return onnxruntime_common_1$3.env.webgl.textureCacheMode}set textureCacheMode(e){onnxruntime_common_1$3.env.webgl.textureCacheMode=e}get pack(){return onnxruntime_common_1$3.env.webgl.pack}set pack(e){onnxruntime_common_1$3.env.webgl.pack=e}get async(){return onnxruntime_common_1$3.env.webgl.async}set async(e){onnxruntime_common_1$3.env.webgl.async=e}initialize(){try{return this.glContext=webgl_context_factory_1.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),instrument_1$2.Logger.setWithEnv(onnxruntime_common_1$3.env),instrument_1$2.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return instrument_1$2.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new session_handler_1$1.WebGLSessionHandler(this,e)}dispose(){this.glContext.dispose()}}backendWebgl.WebGLBackend=WebGLBackend;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.resolveBackend=n.backend=void 0;const e=backendWebgl,r=new Map;n.backend={webgl:new e.WebGLBackend};async function t(l){if(l){const a=typeof l=="string"?[l]:l;for(const s of a){const u=r.get(s);if(u)return u;const c=await o(s);if(c)return c}}else return t(["webgl"]);throw new Error("no available backend to use")}n.resolveBackend=t;async function o(l){const a=n.backend;if(typeof a[l]!="undefined"&&i(a[l])){const s=a[l];let u=s.initialize();if(typeof u=="object"&&"then"in u&&(u=await u),u)return r.set(l,s),s}}function i(l){const a=l;return"initialize"in a&&typeof a.initialize=="function"&&"createSessionHandler"in a&&typeof a.createSessionHandler=="function"&&"dispose"in a&&typeof a.dispose=="function"}})(backend);var executionPlan={};Object.defineProperty(executionPlan,"__esModule",{value:!0});executionPlan.ExecutionPlan=void 0;const instrument_1$1=instrument;class KernelOp{constructor(e,r){this.op=e,this.node=r}}class ExecutionPlan{constructor(e,r,t){this.graph=e,this.profiler=t,this.initialize(r)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",()=>{const r=this.graph.getNodes();if(r.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map((t,o)=>new KernelOp(t,r[o])),this.reset(),this._starter=[],this._ops.forEach((t,o)=>{let i=!0;for(const l of t.node.inputs)if(!this._values[l]&&this.graph.getInputIndices().indexOf(l)===-1){i=!1;break}i&&this._starter.push(o)})})}reset(){this._values=this.graph.getValues().map(e=>e.tensor)}async execute(e,r){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const t=e.createInferenceHandler(),o=this.graph.getInputIndices();if(r.length!==o.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${r.length} expected: ${o.length}`);r.forEach((c,f)=>{const d=o[f];this._values[d]=c});const i=this._starter.slice(0),l=this.graph.getValues(),a=this.graph.getNodes();let s=0;for(;s<i.length;){const c=i[s++],f=this._ops[c],d=f.node.inputs.map(E=>this._values[E]);if(d.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${f.node}`);const m=d;instrument_1$1.Logger.verbose("ExecPlan",`Runing op:${f.node.name} (${m.map((E,$)=>`'${f.node.inputs[$]}': ${E.type}[${E.dims.join(",")}]`).join(", ")})`);const _=await this.profiler.event("node",f.node.name,async()=>f.op.impl(t,m,f.op.context));if(_.length!==f.node.outputs.length)throw new Error("the size of output does not match model definition.");_.forEach((E,$)=>{const y=f.node.outputs[$];if(this._values[y])throw new Error(`output [${y}] already has value: op:${f.node.name}`);this._values[y]=E});const S=new Set;_.forEach((E,$)=>{const y=f.node.outputs[$];for(const v of l[y].to){const A=a[v];let P=!0;for(const C of A.inputs)if(!this._values[C]){P=!1;break}P&&S.add(v)}}),i.push(...S)}const u=[];for(let c=0;c<this.graph.getOutputIndices().length;c++){const f=this.graph.getOutputIndices()[c],d=this._values[f];if(d===void 0)throw new Error(`required output [${f}] does not have value`);f===0?await d.getData():d.data,u.push(d)}return instrument_1$1.Logger.verbose("ExecPlan","disposing of inferenceHandler"),t.dispose(),u})}}executionPlan.ExecutionPlan=ExecutionPlan;var model$1={},graph={},attribute={};Object.defineProperty(attribute,"__esModule",{value:!0});attribute.Attribute=void 0;const onnx_proto_1$2=onnx,ort_generated_1$2=ortGenerated;var ortFbs$2=ort_generated_1$2.onnxruntime.experimental.fbs;const tensor_1$2=tensor,util_1$3=util;class Attribute{constructor(e){if(this._attributes=new Map,e!=null){for(const r of e)r instanceof onnx_proto_1$2.onnx.AttributeProto?this._attributes.set(r.name,[Attribute.getValue(r),Attribute.getType(r)]):r instanceof ortFbs$2.Attribute&&this._attributes.set(r.name(),[Attribute.getValue(r),Attribute.getType(r)]);if(this._attributes.size<e.length)throw new Error("duplicated attribute names")}}set(e,r,t){this._attributes.set(e,[t,r])}delete(e){this._attributes.delete(e)}getFloat(e,r){return this.get(e,"float",r)}getInt(e,r){return this.get(e,"int",r)}getString(e,r){return this.get(e,"string",r)}getTensor(e,r){return this.get(e,"tensor",r)}getFloats(e,r){return this.get(e,"floats",r)}getInts(e,r){return this.get(e,"ints",r)}getStrings(e,r){return this.get(e,"strings",r)}getTensors(e,r){return this.get(e,"tensors",r)}get(e,r,t){const o=this._attributes.get(e);if(o===void 0){if(t!==void 0)return t;throw new Error(`required attribute not found: ${e}`)}if(o[1]!==r)throw new Error(`type mismatch: expected ${r} but got ${o[1]}`);return o[0]}static getType(e){const r=e instanceof onnx_proto_1$2.onnx.AttributeProto?e.type:e.type();switch(r){case onnx_proto_1$2.onnx.AttributeProto.AttributeType.FLOAT:return"float";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.INT:return"int";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRING:return"string";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.INTS:return"ints";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${onnx_proto_1$2.onnx.AttributeProto.AttributeType[r]}`)}}static getValue(e){const r=e instanceof onnx_proto_1$2.onnx.AttributeProto?e.type:e.type();if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.GRAPH||r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");const t=this.getValueNoCheck(e);if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.INT&&util_1$3.LongUtil.isLong(t))return util_1$3.LongUtil.longToNumber(t);if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.INTS){const o=t,i=new Array(o.length);for(let l=0;l<o.length;l++){const a=o[l];i[l]=util_1$3.LongUtil.longToNumber(a)}return i}if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSOR)return e instanceof onnx_proto_1$2.onnx.AttributeProto?tensor_1$2.Tensor.fromProto(t):tensor_1$2.Tensor.fromOrtTensor(t);if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSORS){if(e instanceof onnx_proto_1$2.onnx.AttributeProto)return t.map(i=>tensor_1$2.Tensor.fromProto(i));if(e instanceof ortFbs$2.Attribute)return t.map(i=>tensor_1$2.Tensor.fromOrtTensor(i))}if(r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRING&&e instanceof onnx_proto_1$2.onnx.AttributeProto){const o=t;return util_1$3.decodeUtf8String(o)}return r===onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRINGS&&e instanceof onnx_proto_1$2.onnx.AttributeProto?t.map(util_1$3.decodeUtf8String):t}static getValueNoCheck(e){return e instanceof onnx_proto_1$2.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(e):this.getValueNoCheckFromOrtFormat(e)}static getValueNoCheckFromOnnxFormat(e){switch(e.type){case onnx_proto_1$2.onnx.AttributeProto.AttributeType.FLOAT:return e.f;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.INT:return e.i;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRING:return e.s;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSOR:return e.t;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.GRAPH:return e.g;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.FLOATS:return e.floats;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.INTS:return e.ints;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.STRINGS:return e.strings;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.TENSORS:return e.tensors;case onnx_proto_1$2.onnx.AttributeProto.AttributeType.GRAPHS:return e.graphs;default:throw new Error(`unsupported attribute type: ${onnx_proto_1$2.onnx.AttributeProto.AttributeType[e.type]}`)}}static getValueNoCheckFromOrtFormat(e){switch(e.type()){case ortFbs$2.AttributeType.FLOAT:return e.f();case ortFbs$2.AttributeType.INT:return e.i();case ortFbs$2.AttributeType.STRING:return e.s();case ortFbs$2.AttributeType.TENSOR:return e.t();case ortFbs$2.AttributeType.GRAPH:return e.g();case ortFbs$2.AttributeType.FLOATS:return e.floatsArray();case ortFbs$2.AttributeType.INTS:{const r=[];for(let t=0;t<e.intsLength();t++)r.push(e.ints(t));return r}case ortFbs$2.AttributeType.STRINGS:{const r=[];for(let t=0;t<e.stringsLength();t++)r.push(e.strings(t));return r}case ortFbs$2.AttributeType.TENSORS:{const r=[];for(let t=0;t<e.tensorsLength();t++)r.push(e.tensors(t));return r}default:throw new Error(`unsupported attribute type: ${ortFbs$2.AttributeType[e.type()]}`)}}}attribute.Attribute=Attribute;Object.defineProperty(graph,"__esModule",{value:!0});graph.Graph=void 0;const onnx_proto_1$1=onnx,attribute_1=attribute,ort_generated_1$1=ortGenerated;var ortFbs$1=ort_generated_1$1.onnxruntime.experimental.fbs;const tensor_1$1=tensor,util_1$2=util;graph.Graph={from:(n,e)=>new GraphImpl(n,e)};class Value{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=util_1$2.ProtoUtil.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}}class Node{constructor(e,r){e instanceof onnx_proto_1$1.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new attribute_1.Attribute(e.attribute)):e instanceof ortFbs$1.Node&&(this.name=r!=null?r:e.name(),this.opType=e.opType(),this.attributes=new attribute_1.Attribute(util_1$2.ProtoUtil.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class GraphImpl{constructor(e,r){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(r),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(e){if(e instanceof onnx_proto_1$1.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else if(e instanceof ortFbs$1.Graph)this.buildGraphFromOrtFormat(e);else throw new TypeError("Graph type is not supported.")}buildGraphFromOnnxFormat(e){const r=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const t=new Map;if(!e.input)throw new Error("missing information in graph: input");const o=[];for(const i of e.input){if(r.has(i.name))throw new Error(`duplicated input name: ${i.name}`);const l=this._allData.push(new Value(i))-1;r.set(i.name,l),o.push(i.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(const i of e.initializer){let l=r.get(i.name);if(l===void 0){const a=new Value;a.type={shape:{dims:util_1$2.ProtoUtil.tensorDimsFromProto(i.dims)},tensorType:util_1$2.ProtoUtil.tensorDataTypeFromProto(i.dataType)},l=this._allData.push(a)-1,r.set(i.name,l)}this._allData[l]._from=-1,this._allData[l].tensor=tensor_1$1.Tensor.fromProto(i)}for(let i=0;i<this._allData.length;i++)this._allData[i].tensor||(this._allInputIndices.push(i),this._allInputNames.push(o[i]));if(!e.output)throw new Error("missing information in graph: output");for(const i of e.output){if(r.has(i.name))throw new Error(`duplicated output name: ${i.name}`);const l=this._allData.push(new Value(i))-1;r.set(i.name,l),this._allOutputIndices.push(l),this._allOutputNames.push(i.name)}if(!e.node)throw new Error("missing information in graph: node");for(const i of e.node){if(!i.name)for(let a=0;;a++){const s=`unnamed_${i.opType}_${a}`;if(!t.has(s)){i.name=s;break}}if(t.has(i.name))throw new Error(`duplicated node name: ${i.name}`);const l=this._nodes.push(new Node(i))-1;t.set(i.name,l)}for(let i=0;i<this._nodes.length;i++){const l=this._nodes[i],a=e.node[i];if(!a.output)throw new Error(`missing output for node: ${a.name}`);for(const s of a.output){let u=r.get(s);if(typeof u=="undefined"&&(u=this._allData.push(new Value)-1,r.set(s,u)),l.outputs.push(u),this._allData[u]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${u}`);if(this._allData[u]._from=i,a.opType==="Constant"){if(!a.attribute||a.attribute.length!==1||!a.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!a.output||a.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");l.outputs.pop(),l.executeNode=!1,this._allData[u]._from=-1,this._allData[u].tensor=tensor_1$1.Tensor.fromProto(a.attribute[0].t)}}}for(let i=0;i<this._nodes.length;i++){const l=this._nodes[i],a=e.node[i];if(!a.input)throw new Error(`missing input for node: ${a.name}`);for(const s of a.input){const u=r.get(s);if(typeof u=="undefined")throw new Error(`unrecognized input '${s}' for node: ${a.name}`);l.inputs.push(u),this._allData[u]._to.push(i)}}return!0}buildGraphFromOrtFormat(e){var r,t,o;const i=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const l=new Map,a=[];for(let s=0;s<e.inputsLength();s++){const u=e.inputs(s);if(i.has(u))throw new Error(`duplicated input name: ${u}`);for(let c=0;c<e.nodeArgsLength();c++)if(((r=e.nodeArgs(c))===null||r===void 0?void 0:r.name())===u){const f=new Value;if(((o=(t=e.nodeArgs(c))===null||t===void 0?void 0:t.type())===null||o===void 0?void 0:o.valueType())!==ortFbs$1.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const m=e.nodeArgs(c).type().value(new ortFbs$1.TensorTypeAndShape),_=util_1$2.ProtoUtil.tensorDataTypeFromProto(m.elemType()),S=m.shape(),E=[];for(let y=0;y<S.dimLength();y++)E.push(util_1$2.LongUtil.longToNumber(S.dim(y).value().dimValue()));f.type={shape:{dims:E},tensorType:_};const $=this._allData.push(f)-1;i.set(u,$),a.push(u)}}for(let s=0;s<e.initializersLength();s++){const u=e.initializers(s);let c=i.get(u.name());if(c===void 0){const f=new Value,d=util_1$2.ProtoUtil.tensorDimsFromORTFormat(u),m=util_1$2.ProtoUtil.tensorDataTypeFromProto(u.dataType());f.type={shape:{dims:d},tensorType:m},c=this._allData.push(f)-1,i.set(u.name(),c)}this._allData[c]._from=-1,this._allData[c].tensor=tensor_1$1.Tensor.fromOrtTensor(u)}for(let s=0;s<this._allData.length;s++)this._allData[s].tensor||(this._allInputIndices.push(s),this._allInputNames.push(a[s]));for(let s=0;s<e.outputsLength();s++){const u=e.outputs(s);if(i.has(u))throw new Error(`duplicated output name: ${u}`);const c=this._allData.push(new Value)-1;i.set(u,c),this._allOutputIndices.push(c),this._allOutputNames.push(u)}if(!e.nodes)throw new Error("missing information in graph: node");for(let s=0;s<e.nodesLength();s++){const u=e.nodes(s);let c=u.name();if(!c)for(let d=0;c=`unnamed_${u.opType()}_${d}`,!!l.has(c);d++);if(l.has(c))throw new Error(`duplicated node name: ${c}`);const f=this._nodes.push(new Node(u,c))-1;l.set(c,f)}for(let s=0;s<this._nodes.length;s++){const u=this._nodes[s],c=e.nodes(s);if(c==null)throw new Error(`No node exists at index ${s}`);if((c==null?void 0:c.outputsLength())===0)throw new Error(`missing output for node: ${c.name}`);for(let f=0;f<(c==null?void 0:c.outputsLength());f++){const d=c==null?void 0:c.outputs(f);let m=i.get(d);if(typeof m=="undefined"&&(m=this._allData.push(new Value)-1,i.set(d,m)),u.outputs.push(m),this._allData[m]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${m}`);if(this._allData[m]._from=s,c.opType()==="Constant"){if(c.attributesLength()!==1||!c.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(c.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");u.outputs.pop(),u.executeNode=!1,this._allData[m]._from=-1,this._allData[m].tensor=tensor_1$1.Tensor.fromOrtTensor(c.attributes(0).t())}}}for(let s=0;s<this._nodes.length;s++){const u=this._nodes[s],c=e.nodes(s);if(c.inputsLength()===0)throw new Error(`missing input for node: ${c.name}`);for(let f=0;f<c.inputsLength();f++){const d=c.inputs(f),m=i.get(d);if(typeof m=="undefined")throw new Error(`unrecognized input '${d}' for node: ${c.name()}`);u.inputs.push(m),this._allData[m]._to.push(s)}}}checkIsAcyclic(){const e=new Set;this._allInputIndices.forEach(o=>{this._allData[o]._to.forEach(l=>{e.add(l)})});const r=Array.from(e),t=new Array(this._nodes.length).fill("white");for(;r.length>0;){const o=r.pop();t[o]==="gray"?t[o]="black":(r.push(o),t[o]="gray",this._nodes[o].outputs.forEach(i=>{const l=this._allData[i];if(typeof l.tensor!="undefined")throw new Error("node outputs should not be initialized");if(l._from!==o)throw new Error("from property of the Value object doesn't match index of Node being processed");l._to.forEach(a=>{if(t[a]==="gray")throw new Error("model graph is cyclic");t[a]==="white"&&r.push(a)})}))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0;for(let r=0;r<this._nodes.length;r++){if(!this._nodes[r].executeNode){e++,this._nodes[r].outputs.forEach(t=>{this._allData[t]._from=-2}),this._nodes.splice(r,1),r--;continue}e>0&&(this._nodes[r].inputs.forEach(t=>{const o=this._allData[t]._to.indexOf(r+e);o!==-1&&(this._allData[t]._to[o]=r)}),this._nodes[r].outputs.forEach(t=>{this._allData[t]._from&&this._allData[t]._from===r+e&&(this._allData[t]._from=r)}))}e=0;for(let r=0;r<this._allData.length;r++){if(this._allData[r].from===-2&&this._allOutputIndices.indexOf(r+e)===-1){e++,this._allData.splice(r,1),r--;continue}if(e>0){let t=-1;this._allData[r].from!==void 0&&this._allData[r].from!==-1?(t=this._nodes[this._allData[r].from].outputs.indexOf(r+e),t!==-1&&(this._nodes[this._allData[r].from].outputs[t]=r)):(t=this._allInputIndices.indexOf(r+e),t!==-1&&(this._allInputIndices[t]=r)),this._allData[r].to.forEach(o=>{t=this._nodes[o].inputs.indexOf(r+e),t!==-1&&(this._nodes[o].inputs[t]=r)}),this._allData[r].to.length===0&&(t=this._allOutputIndices.indexOf(r+e),t!==-1&&(this._allOutputIndices[t]=r))}}}deleteNode(e){const r=this._nodes[e];if(r.outputs.length>1){for(let s=1;s<r.outputs.length;s++)if(this._allData[r.outputs[s]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}r.executeNode=!1;const t=r.inputs[0],o=r.outputs[0],i=this._allData[o].to,l=this._allData[t].to.indexOf(e);if(l===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[t].to.splice(l,1),this._allData[o]._to=[];const a=this._allOutputIndices.indexOf(o);if(a!==-1&&(this._allOutputIndices[a]=t),i&&i.length>0)for(const s of i){const u=this._nodes[s].inputs.indexOf(o);if(u===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[s].inputs[u]=t,this._allData[t].to.push(s)}}removeAllDropoutNodes(){let e=0;for(const r of this._nodes){if(r.opType==="Dropout"){if(r.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(r.outputs.length!==1&&r.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(r.outputs.length===2&&this._allData[r.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(e)}e++}}removeAllIdentityNodes(){let e=0;for(const r of this._nodes)r.opType==="Identity"&&this.deleteNode(e),e++}isActivation(e){switch(e.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const e of this._nodes)if(e.opType==="Conv"){const r=this._allData[e.outputs[0]]._to;if(r.length===1&&this.isActivation(this._nodes[r[0]])){const t=this._nodes[r[0]];if(t.opType==="Clip")if(t.inputs.length===1)try{e.attributes.set("activation_params","floats",[t.attributes.getFloat("min"),t.attributes.getFloat("max")])}catch{e.attributes.set("activation_params","floats",[util_1$2.MIN_CLIP,util_1$2.MAX_CLIP])}else if(t.inputs.length>=3&&this._allData[t.inputs[1]].tensor!==void 0&&this._allData[t.inputs[2]].tensor!==void 0)e.attributes.set("activation_params","floats",[this._allData[t.inputs[1]].tensor.floatData[0],this._allData[t.inputs[2]].tensor.floatData[0]]);else continue;e.attributes.set("activation","string",t.opType),this.deleteNode(r[0])}}}}Object.defineProperty(model$1,"__esModule",{value:!0});model$1.Model=void 0;const flatbuffers_1=require$$0,onnx_proto_1=onnx,graph_1=graph,ort_generated_1=ortGenerated;var ortFbs=ort_generated_1.onnxruntime.experimental.fbs;const util_1$1=util;class Model$1{constructor(){}load(e,r,t){if(!t)try{this.loadFromOnnxFormat(e,r);return}catch(o){if(t!==void 0)throw o}this.loadFromOrtFormat(e,r)}loadFromOnnxFormat(e,r){const t=onnx_proto_1.onnx.ModelProto.decode(e);if(util_1$1.LongUtil.longToNumber(t.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=t.opsetImport.map(i=>({domain:i.domain,version:util_1$1.LongUtil.longToNumber(i.version)})),this._graph=graph_1.Graph.from(t.graph,r)}loadFromOrtFormat(e,r){const t=new flatbuffers_1.flatbuffers.ByteBuffer(e),o=ortFbs.InferenceSession.getRootAsInferenceSession(t).model();if(util_1$1.LongUtil.longToNumber(o.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let l=0;l<o.opsetImportLength();l++){const a=o.opsetImport(l);this._opsets.push({domain:a==null?void 0:a.domain(),version:util_1$1.LongUtil.longToNumber(a.version())})}this._graph=graph_1.Graph.from(o.graph(),r)}get graph(){return this._graph}get opsets(){return this._opsets}}model$1.Model=Model$1;Object.defineProperty(session,"__esModule",{value:!0});session.Session=void 0;const fs_1=require$$3$1,util_1=require$$3$1,backend_1=backend,execution_plan_1=executionPlan,instrument_1=instrument,model_1=model$1;class Session{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=instrument_1.Profiler.create(e.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(e,r,t){await this.profiler.event("session","Session.loadModel",async()=>{const o=await backend_1.resolveBackend(this.backendHint);if(this.sessionHandler=o.createSessionHandler(this.context),this._model=new model_1.Model,typeof e=="string"){const i=e.endsWith(".ort");if(typeof fetch=="undefined"){const l=await util_1.promisify(fs_1.readFile)(e);this.initialize(l,i)}else{const a=await(await fetch(e)).arrayBuffer();this.initialize(new Uint8Array(a),i)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{const i=new Uint8Array(e,r||0,t||e.byteLength);this.initialize(i)}})}initialize(e,r){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const t=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,t,r),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new execution_plan_1.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(e){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const r=this.normalizeAndValidateInputs(e),t=await this._executionPlan.execute(this.sessionHandler,r);return this.createOutput(t)})}normalizeAndValidateInputs(e){const r=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==r.length)throw new Error(`incorrect input array length: expected ${r.length} but got ${e.length}`)}else{if(e.size!==r.length)throw new Error(`incorrect input map size: expected ${r.length} but got ${e.size}`);const t=new Array(e.size);let o=0;for(let i=0;i<r.length;++i){const l=e.get(r[i]);if(!l)throw new Error(`missing input tensor for: '${name}'`);t[o++]=l}e=t}if(!this.context.graphInputTypes||this.context.graphInputTypes.length===0||!this.context.graphInputDims||this.context.graphInputDims.length===0){const t=this._model.graph.getInputIndices(),o=this._model.graph.getValues(),i=new Array(t.length);for(let l=0;l<t.length;++l){const a=o[t[l]];i[l]=a.type.shape.dims,this.context.graphInputTypes.push(a.type.tensorType),this.context.graphInputDims.push(e[l].dims)}this.validateInputTensorDims(i,e,!0)}else this.validateInputTensorDims(this.context.graphInputDims,e,!1);return this.validateInputTensorTypes(this.context.graphInputTypes,e),e}validateInputTensorTypes(e,r){for(let t=0;t<r.length;t++){const o=e[t],i=r[t].type;if(o!==i)throw new Error(`input tensor[${t}] check failed: expected type '${o}' but got ${i}`)}}validateInputTensorDims(e,r,t){for(let o=0;o<r.length;o++){const i=e[o],l=r[o].dims;if(!this.compareTensorDims(i,l,t))throw new Error(`input tensor[${o}] check failed: expected shape '[${i.join(",")}]' but got [${l.join(",")}]`)}}compareTensorDims(e,r,t){if(e.length!==r.length)return!1;for(let o=0;o<e.length;++o)if(e[o]!==r[o]&&(!t||e[o]!==0))return!1;return!0}createOutput(e){const r=this._model.graph.getOutputNames();if(e.length!==r.length)throw new Error("expected number of outputs do not match number of generated outputs");const t=new Map;for(let o=0;o<r.length;++o)t.set(r[o],e[o]);return t}initializeOps(e){const r=e.getNodes();this._ops=new Array(r.length);for(let t=0;t<r.length;t++)this._ops[t]=this.sessionHandler.resolve(r[t],this._model.opsets,e)}}session.Session=Session;var sessionHandler$1={};Object.defineProperty(sessionHandler$1,"__esModule",{value:!0});sessionHandler$1.OnnxjsSessionHandler=void 0;const onnxruntime_common_1$2=require$$0$1,tensor_1=tensor;class OnnxjsSessionHandler{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,r,t){const o=new Map;for(const a in e)if(Object.hasOwnProperty.call(e,a)){const s=e[a];o.set(a,new tensor_1.Tensor(s.dims,s.type,void 0,void 0,s.data))}const i=await this.session.run(o),l={};return i.forEach((a,s)=>{l[s]=new onnxruntime_common_1$2.Tensor(a.type,a.data,a.dims)}),l}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}sessionHandler$1.OnnxjsSessionHandler=OnnxjsSessionHandler;Object.defineProperty(backendOnnxjs,"__esModule",{value:!0});backendOnnxjs.onnxjsBackend=void 0;const session_1=session,session_handler_1=sessionHandler$1;class OnnxjsBackend{async init(){}async createSessionHandler(e,r){const t=new session_1.Session(r);return typeof e=="string"?await t.loadModel(e):await t.loadModel(e),new session_handler_1.OnnxjsSessionHandler(t)}}backendOnnxjs.onnxjsBackend=new OnnxjsBackend;var backendWasm={},proxyWrapper={},wasmCoreImpl={},runOptions={},optionsUtils={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.iterateExtraOptions=void 0;const e=(r,t,o,i)=>{if(typeof r=="object"&&r!==null){if(o.has(r))throw new Error("Circular reference in options");o.add(r)}Object.entries(r).forEach(([l,a])=>{const s=t?t+l:l;if(typeof a=="object")n.iterateExtraOptions(a,s+".",o,i);else if(typeof a=="string"||typeof a=="number")i(s,a.toString());else if(typeof a=="boolean")i(s,a?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof a}`)})};n.iterateExtraOptions=e})(optionsUtils);var stringUtils={},wasmFactory={},ortWasm={exports:{}};(function(n,e){var r=(()=>{var t=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(t=t||__filename),function(o){o=o||{};var i;i||(i=typeof o!="undefined"?o:{});var l=Object.assign,a,s;i.ready=new Promise(function(b,x){a=b,s=x});var u=l({},i),c="./this.program",f=typeof window=="object",d=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",_="",S,E,$,y,v,A;m?(_=d?require$$3$1.dirname(_)+"/":__dirname+"/",A=()=>{v||(y=require$$3$1,v=require$$3$1)},S=function(b,x){return A(),b=v.normalize(b),y.readFileSync(b,x?null:"utf8")},$=b=>(b=S(b,!0),b.buffer||(b=new Uint8Array(b)),b),E=(b,x,F)=>{A(),b=v.normalize(b),y.readFile(b,function(R,G){R?F(R):x(G.buffer)})},1<process.argv.length&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(b){throw b}),process.on("unhandledRejection",function(b){throw b}),i.inspect=function(){return"[Emscripten Module object]"}):(f||d)&&(d?_=self.location.href:typeof document!="undefined"&&document.currentScript&&(_=document.currentScript.src),t&&(_=t),_.indexOf("blob:")!==0?_=_.substr(0,_.replace(/[?#].*/,"").lastIndexOf("/")+1):_="",S=b=>{var x=new XMLHttpRequest;return x.open("GET",b,!1),x.send(null),x.responseText},d&&($=b=>{var x=new XMLHttpRequest;return x.open("GET",b,!1),x.responseType="arraybuffer",x.send(null),new Uint8Array(x.response)}),E=(b,x,F)=>{var R=new XMLHttpRequest;R.open("GET",b,!0),R.responseType="arraybuffer",R.onload=()=>{R.status==200||R.status==0&&R.response?x(R.response):F()},R.onerror=F,R.send(null)});var P=i.print||console.log.bind(console),C=i.printErr||console.warn.bind(console);l(i,u),u=null,i.thisProgram&&(c=i.thisProgram);var L;i.wasmBinary&&(L=i.wasmBinary),i.noExitRuntime,typeof WebAssembly!="object"&&Se("no native wasm support detected");var B,V=!1,j=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function U(b,x,F){var R=x+F;for(F=x;b[F]&&!(F>=R);)++F;if(16<F-x&&b.subarray&&j)return j.decode(b.subarray(x,F));for(R="";x<F;){var G=b[x++];if(G&128){var W=b[x++]&63;if((G&224)==192)R+=String.fromCharCode((G&31)<<6|W);else{var K=b[x++]&63;G=(G&240)==224?(G&15)<<12|W<<6|K:(G&7)<<18|W<<12|K<<6|b[x++]&63,65536>G?R+=String.fromCharCode(G):(G-=65536,R+=String.fromCharCode(55296|G>>10,56320|G&1023))}}else R+=String.fromCharCode(G)}return R}function re(b,x){return b?U(de,b,x):""}function Z(b,x,F,R){if(!(0<R))return 0;var G=F;R=F+R-1;for(var W=0;W<b.length;++W){var K=b.charCodeAt(W);if(55296<=K&&57343>=K){var ue=b.charCodeAt(++W);K=65536+((K&1023)<<10)|ue&1023}if(127>=K){if(F>=R)break;x[F++]=K}else{if(2047>=K){if(F+1>=R)break;x[F++]=192|K>>6}else{if(65535>=K){if(F+2>=R)break;x[F++]=224|K>>12}else{if(F+3>=R)break;x[F++]=240|K>>18,x[F++]=128|K>>12&63}x[F++]=128|K>>6&63}x[F++]=128|K&63}}return x[F]=0,F-G}function ee(b){for(var x=0,F=0;F<b.length;++F){var R=b.charCodeAt(F);55296<=R&&57343>=R&&(R=65536+((R&1023)<<10)|b.charCodeAt(++F)&1023),127>=R?++x:x=2047>=R?x+2:65535>=R?x+3:x+4}return x}function X(b){var x=ee(b)+1,F=Xe(x);return F&&Z(b,ae,F,x),F}var J,ae,de,M;function we(){var b=B.buffer;J=b,i.HEAP8=ae=new Int8Array(b),i.HEAP16=new Int16Array(b),i.HEAP32=M=new Int32Array(b),i.HEAPU8=de=new Uint8Array(b),i.HEAPU16=new Uint16Array(b),i.HEAPU32=new Uint32Array(b),i.HEAPF32=new Float32Array(b),i.HEAPF64=new Float64Array(b)}var le,me=[],Y=[],ie=[];function ve(){var b=i.preRun.shift();me.unshift(b)}var ge=0,Te=null;i.preloadedImages={},i.preloadedAudios={};function Se(b){throw i.onAbort&&i.onAbort(b),b="Aborted("+b+")",C(b),V=!0,b=new WebAssembly.RuntimeError(b+". Build with -s ASSERTIONS=1 for more info."),s(b),b}function Be(){return _e.startsWith("data:application/octet-stream;base64,")}var _e;if(_e="ort-wasm.wasm",!Be()){var ye=_e;_e=i.locateFile?i.locateFile(ye,_):_+ye}function Ue(){var b=_e;try{if(b==_e&&L)return new Uint8Array(L);if($)return $(b);throw"both async and sync fetching of the wasm failed"}catch(x){Se(x)}}function He(){if(!L&&(f||d)){if(typeof fetch=="function"&&!_e.startsWith("file://"))return fetch(_e,{credentials:"same-origin"}).then(function(b){if(!b.ok)throw"failed to load wasm binary file at '"+_e+"'";return b.arrayBuffer()}).catch(function(){return Ue()});if(E)return new Promise(function(b,x){E(_e,function(F){b(new Uint8Array(F))},x)})}return Promise.resolve().then(function(){return Ue()})}function Re(b){for(;0<b.length;){var x=b.shift();if(typeof x=="function")x(i);else{var F=x.Na;typeof F=="number"?x.va===void 0?Ae(F)():Ae(F)(x.va):F(x.va===void 0?null:x.va)}}}var ke=[];function Ae(b){var x=ke[b];return x||(b>=ke.length&&(ke.length=b+1),ke[b]=x=le.get(b)),x}function qe(b){this.qa=b-16,this.Fa=function(x){M[this.qa+4>>2]=x},this.Ca=function(x){M[this.qa+8>>2]=x},this.Da=function(){M[this.qa>>2]=0},this.Ba=function(){ae[this.qa+12>>0]=0},this.Ea=function(){ae[this.qa+13>>0]=0},this.ya=function(x,F){this.Fa(x),this.Ca(F),this.Da(),this.Ba(),this.Ea()}}var Me={},Ye=[null,[],[]],O={};function k(b,x,F){function R(xe){return(xe=xe.toTimeString().match(/\(([A-Za-z ]+)\)$/))?xe[1]:"GMT"}var G=new Date().getFullYear(),W=new Date(G,0,1),K=new Date(G,6,1);G=W.getTimezoneOffset();var ue=K.getTimezoneOffset();M[b>>2]=60*Math.max(G,ue),M[x>>2]=Number(G!=ue),b=R(W),x=R(K),b=X(b),x=X(x),ue<G?(M[F>>2]=b,M[F+4>>2]=x):(M[F>>2]=x,M[F+4>>2]=b)}function te(b,x,F){te.xa||(te.xa=!0,k(b,x,F))}var $e;$e=m?()=>{var b=process.hrtime();return 1e3*b[0]+b[1]/1e6}:()=>performance.now();var Ee={};function Oe(){if(!Ce){var b={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",_:c||"./this.program"},x;for(x in Ee)Ee[x]===void 0?delete b[x]:b[x]=Ee[x];var F=[];for(x in b)F.push(x+"="+b[x]);Ce=F}return Ce}var Ce;function Ie(b){return b%4===0&&(b%100!==0||b%400===0)}function Fe(b,x){for(var F=0,R=0;R<=x;F+=b[R++]);return F}var ze=[31,29,31,30,31,30,31,31,30,31,30,31],pe=[31,28,31,30,31,30,31,31,30,31,30,31];function Ve(b,x){for(b=new Date(b.getTime());0<x;){var F=b.getMonth(),R=(Ie(b.getFullYear())?ze:pe)[F];if(x>R-b.getDate())x-=R-b.getDate()+1,b.setDate(1),11>F?b.setMonth(F+1):(b.setMonth(0),b.setFullYear(b.getFullYear()+1));else{b.setDate(b.getDate()+x);break}}return b}function st(b,x,F,R){function G(I,Q,se){for(I=typeof I=="number"?I.toString():I||"";I.length<Q;)I=se[0]+I;return I}function W(I,Q){return G(I,Q,"0")}function K(I,Q){function se(it){return 0>it?-1:0<it?1:0}var De;return(De=se(I.getFullYear()-Q.getFullYear()))===0&&(De=se(I.getMonth()-Q.getMonth()))===0&&(De=se(I.getDate()-Q.getDate())),De}function ue(I){switch(I.getDay()){case 0:return new Date(I.getFullYear()-1,11,29);case 1:return I;case 2:return new Date(I.getFullYear(),0,3);case 3:return new Date(I.getFullYear(),0,2);case 4:return new Date(I.getFullYear(),0,1);case 5:return new Date(I.getFullYear()-1,11,31);case 6:return new Date(I.getFullYear()-1,11,30)}}function xe(I){I=Ve(new Date(I.oa+1900,0,1),I.ua);var Q=new Date(I.getFullYear()+1,0,4),se=ue(new Date(I.getFullYear(),0,4));return Q=ue(Q),0>=K(se,I)?0>=K(Q,I)?I.getFullYear()+1:I.getFullYear():I.getFullYear()-1}var be=M[R+40>>2];R={Ia:M[R>>2],Ha:M[R+4>>2],sa:M[R+8>>2],ra:M[R+12>>2],pa:M[R+16>>2],oa:M[R+20>>2],ta:M[R+24>>2],ua:M[R+28>>2],Qa:M[R+32>>2],Ga:M[R+36>>2],Ja:be?re(be):""},F=re(F),be={"%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"};for(var he in be)F=F.replace(new RegExp(he,"g"),be[he]);var nt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),rt="January February March April May June July August September October November December".split(" ");be={"%a":function(I){return nt[I.ta].substring(0,3)},"%A":function(I){return nt[I.ta]},"%b":function(I){return rt[I.pa].substring(0,3)},"%B":function(I){return rt[I.pa]},"%C":function(I){return W((I.oa+1900)/100|0,2)},"%d":function(I){return W(I.ra,2)},"%e":function(I){return G(I.ra,2," ")},"%g":function(I){return xe(I).toString().substring(2)},"%G":function(I){return xe(I)},"%H":function(I){return W(I.sa,2)},"%I":function(I){return I=I.sa,I==0?I=12:12<I&&(I-=12),W(I,2)},"%j":function(I){return W(I.ra+Fe(Ie(I.oa+1900)?ze:pe,I.pa-1),3)},"%m":function(I){return W(I.pa+1,2)},"%M":function(I){return W(I.Ha,2)},"%n":function(){return`
- `},"%p":function(I){return 0<=I.sa&&12>I.sa?"AM":"PM"},"%S":function(I){return W(I.Ia,2)},"%t":function(){return" "},"%u":function(I){return I.ta||7},"%U":function(I){var Q=new Date(I.oa+1900,0,1),se=Q.getDay()===0?Q:Ve(Q,7-Q.getDay());return I=new Date(I.oa+1900,I.pa,I.ra),0>K(se,I)?W(Math.ceil((31-se.getDate()+(Fe(Ie(I.getFullYear())?ze:pe,I.getMonth()-1)-31)+I.getDate())/7),2):K(se,Q)===0?"01":"00"},"%V":function(I){var Q=new Date(I.oa+1901,0,4),se=ue(new Date(I.oa+1900,0,4));Q=ue(Q);var De=Ve(new Date(I.oa+1900,0,1),I.ua);return 0>K(De,se)?"53":0>=K(Q,De)?"01":W(Math.ceil((se.getFullYear()<I.oa+1900?I.ua+32-se.getDate():I.ua+1-se.getDate())/7),2)},"%w":function(I){return I.ta},"%W":function(I){var Q=new Date(I.oa,0,1),se=Q.getDay()===1?Q:Ve(Q,Q.getDay()===0?1:7-Q.getDay()+1);return I=new Date(I.oa+1900,I.pa,I.ra),0>K(se,I)?W(Math.ceil((31-se.getDate()+(Fe(Ie(I.getFullYear())?ze:pe,I.getMonth()-1)-31)+I.getDate())/7),2):K(se,Q)===0?"01":"00"},"%y":function(I){return(I.oa+1900).toString().substring(2)},"%Y":function(I){return I.oa+1900},"%z":function(I){I=I.Ga;var Q=0<=I;return I=Math.abs(I)/60,(Q?"+":"-")+String("0000"+(I/60*100+I%60)).slice(-4)},"%Z":function(I){return I.Ja},"%%":function(){return"%"}};for(he in be)F.includes(he)&&(F=F.replace(new RegExp(he,"g"),be[he](R)));return he=_t(F),he.length>x?0:(ae.set(he,b),he.length-1)}function _t(b){var x=Array(ee(b)+1);return Z(b,x,0,x.length),x}var Ge={a:function(b){return Xe(b+16)+16},b:function(b,x,F){throw new qe(b).ya(x,F),b},g:function(){return 0},I:function(){},F:function(){},v:function(){},y:function(){},r:function(){return 0},G:function(){},B:function(b,x){return b=re(b),O.Ka(b,x)},A:function(b,x,F,R,G,W){if(W<<=12,(R&16)!==0&&b%65536!==0)x=-28;else if((R&32)!==0){b=65536*Math.ceil(x/65536);var K=tt(65536,b);K?(de.fill(0,K,K+b),b=K):b=0,b?(Me[b]={Aa:b,za:x,wa:!0,fd:G,Pa:F,flags:R,offset:W},x=b):x=-48}else x=-52;return x},z:function(b,x){var F=Me[b];return x!==0&&F?(x===F.za&&(Me[b]=null,F.wa&&H(F.Aa)),b=0):b=-28,b},k:function(){},x:function(b,x,F){return b=re(b),O.La(b,x,F)},t:function(){},H:function(){},u:function(){},h:function(){Se("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},n:function(){Se("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},J:function(b,x){b=new Date(1e3*M[b>>2]),M[x>>2]=b.getUTCSeconds(),M[x+4>>2]=b.getUTCMinutes(),M[x+8>>2]=b.getUTCHours(),M[x+12>>2]=b.getUTCDate(),M[x+16>>2]=b.getUTCMonth(),M[x+20>>2]=b.getUTCFullYear()-1900,M[x+24>>2]=b.getUTCDay(),M[x+28>>2]=(b.getTime()-Date.UTC(b.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},K:function(b,x){b=new Date(1e3*M[b>>2]),M[x>>2]=b.getSeconds(),M[x+4>>2]=b.getMinutes(),M[x+8>>2]=b.getHours(),M[x+12>>2]=b.getDate(),M[x+16>>2]=b.getMonth(),M[x+20>>2]=b.getFullYear()-1900,M[x+24>>2]=b.getDay();var F=new Date(b.getFullYear(),0,1);M[x+28>>2]=(b.getTime()-F.getTime())/864e5|0,M[x+36>>2]=-(60*b.getTimezoneOffset());var R=new Date(b.getFullYear(),6,1).getTimezoneOffset();F=F.getTimezoneOffset(),M[x+32>>2]=(R!=F&&b.getTimezoneOffset()==Math.min(F,R))|0},L:function(b){var x=new Date(M[b+20>>2]+1900,M[b+16>>2],M[b+12>>2],M[b+8>>2],M[b+4>>2],M[b>>2],0),F=M[b+32>>2],R=x.getTimezoneOffset(),G=new Date(x.getFullYear(),0,1),W=new Date(x.getFullYear(),6,1).getTimezoneOffset(),K=G.getTimezoneOffset(),ue=Math.min(K,W);return 0>F?M[b+32>>2]=Number(W!=K&&ue==R):0<F!=(ue==R)&&(W=Math.max(K,W),x.setTime(x.getTime()+6e4*((0<F?ue:W)-R))),M[b+24>>2]=x.getDay(),M[b+28>>2]=(x.getTime()-G.getTime())/864e5|0,M[b>>2]=x.getSeconds(),M[b+4>>2]=x.getMinutes(),M[b+8>>2]=x.getHours(),M[b+12>>2]=x.getDate(),M[b+16>>2]=x.getMonth(),x.getTime()/1e3|0},M:te,d:function(){Se("")},m:function(b,x){if(b===0)b=Date.now();else if(b===1||b===4)b=$e();else return M[et()>>2]=28,-1;return M[x>>2]=b/1e3|0,M[x+4>>2]=b%1e3*1e6|0,0},p:function(b,x){return b-x},s:function(){return 2147483648},l:$e,E:function(b,x,F){de.copyWithin(b,x,x+F)},f:function(b){var x=de.length;if(b>>>=0,2147483648<b)return!1;for(var F=1;4>=F;F*=2){var R=x*(1+.2/F);R=Math.min(R,b+100663296),R=Math.max(b,R),0<R%65536&&(R+=65536-R%65536);e:{try{B.grow(Math.min(2147483648,R)-J.byteLength+65535>>>16),we();var G=1;break e}catch{}G=void 0}if(G)return!0}return!1},C:function(b,x){var F=0;return Oe().forEach(function(R,G){var W=x+F;for(G=M[b+4*G>>2]=W,W=0;W<R.length;++W)ae[G++>>0]=R.charCodeAt(W);ae[G>>0]=0,F+=R.length+1}),0},D:function(b,x){var F=Oe();M[b>>2]=F.length;var R=0;return F.forEach(function(G){R+=G.length+1}),M[x>>2]=R,0},e:function(){return 0},j:function(b,x,F,R){return b=O.Oa(b),x=O.Ma(b,x,F),M[R>>2]=x,0},q:function(){},i:function(b,x,F,R){for(var G=0,W=0;W<F;W++){var K=M[x>>2],ue=M[x+4>>2];x+=8;for(var xe=0;xe<ue;xe++){var be=de[K+xe],he=Ye[b];be===0||be===10?((b===1?P:C)(U(he,0)),he.length=0):he.push(be)}G+=ue}return M[R>>2]=G,0},w:function(b){var x=Date.now();return M[b>>2]=x/1e3|0,M[b+4>>2]=x%1e3*1e3|0,0},o:st,c:function(b,x,F,R){return st(b,x,F,R)}};(function(){function b(G){i.asm=G.exports,B=i.asm.N,we(),le=i.asm.ja,Y.unshift(i.asm.O),ge--,i.monitorRunDependencies&&i.monitorRunDependencies(ge),ge==0&&Te&&(G=Te,Te=null,G())}function x(G){b(G.instance)}function F(G){return He().then(function(W){return WebAssembly.instantiate(W,R)}).then(function(W){return W}).then(G,function(W){C("failed to asynchronously prepare wasm: "+W),Se(W)})}var R={a:Ge};if(ge++,i.monitorRunDependencies&&i.monitorRunDependencies(ge),i.instantiateWasm)try{return i.instantiateWasm(R,b)}catch(G){return C("Module.instantiateWasm callback failed with error: "+G),!1}return function(){return L||typeof WebAssembly.instantiateStreaming!="function"||Be()||_e.startsWith("file://")||typeof fetch!="function"?F(x):fetch(_e,{credentials:"same-origin"}).then(function(G){return WebAssembly.instantiateStreaming(G,R).then(x,function(W){return C("wasm streaming compile failed: "+W),C("falling back to ArrayBuffer instantiation"),F(x)})})}().catch(s),{}})(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.O).apply(null,arguments)},i._OrtInit=function(){return(i._OrtInit=i.asm.P).apply(null,arguments)},i._OrtCreateSessionOptions=function(){return(i._OrtCreateSessionOptions=i.asm.Q).apply(null,arguments)},i._OrtAddSessionConfigEntry=function(){return(i._OrtAddSessionConfigEntry=i.asm.R).apply(null,arguments)},i._OrtReleaseSessionOptions=function(){return(i._OrtReleaseSessionOptions=i.asm.S).apply(null,arguments)},i._OrtCreateSession=function(){return(i._OrtCreateSession=i.asm.T).apply(null,arguments)},i._OrtReleaseSession=function(){return(i._OrtReleaseSession=i.asm.U).apply(null,arguments)},i._OrtGetInputCount=function(){return(i._OrtGetInputCount=i.asm.V).apply(null,arguments)},i._OrtGetOutputCount=function(){return(i._OrtGetOutputCount=i.asm.W).apply(null,arguments)},i._OrtGetInputName=function(){return(i._OrtGetInputName=i.asm.X).apply(null,arguments)},i._OrtGetOutputName=function(){return(i._OrtGetOutputName=i.asm.Y).apply(null,arguments)},i._OrtFree=function(){return(i._OrtFree=i.asm.Z).apply(null,arguments)},i._OrtCreateTensor=function(){return(i._OrtCreateTensor=i.asm._).apply(null,arguments)},i._OrtGetTensorData=function(){return(i._OrtGetTensorData=i.asm.$).apply(null,arguments)},i._OrtReleaseTensor=function(){return(i._OrtReleaseTensor=i.asm.aa).apply(null,arguments)},i._OrtCreateRunOptions=function(){return(i._OrtCreateRunOptions=i.asm.ba).apply(null,arguments)},i._OrtAddRunConfigEntry=function(){return(i._OrtAddRunConfigEntry=i.asm.ca).apply(null,arguments)},i._OrtReleaseRunOptions=function(){return(i._OrtReleaseRunOptions=i.asm.da).apply(null,arguments)},i._OrtRun=function(){return(i._OrtRun=i.asm.ea).apply(null,arguments)},i._OrtEndProfiling=function(){return(i._OrtEndProfiling=i.asm.fa).apply(null,arguments)};var et=i.___errno_location=function(){return(et=i.___errno_location=i.asm.ga).apply(null,arguments)},Xe=i._malloc=function(){return(Xe=i._malloc=i.asm.ha).apply(null,arguments)},H=i._free=function(){return(H=i._free=i.asm.ia).apply(null,arguments)},tt=i._memalign=function(){return(tt=i._memalign=i.asm.ka).apply(null,arguments)},je=i.stackSave=function(){return(je=i.stackSave=i.asm.la).apply(null,arguments)},Ke=i.stackRestore=function(){return(Ke=i.stackRestore=i.asm.ma).apply(null,arguments)},Ze=i.stackAlloc=function(){return(Ze=i.stackAlloc=i.asm.na).apply(null,arguments)};i.UTF8ToString=re,i.stringToUTF8=function(b,x,F){return Z(b,de,x,F)},i.lengthBytesUTF8=ee,i.stackSave=je,i.stackRestore=Ke,i.stackAlloc=Ze;var Je;Te=function b(){Je||Qe(),Je||(Te=b)};function Qe(){function b(){if(!Je&&(Je=!0,i.calledRun=!0,!V)){if(Re(Y),a(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;){var x=i.postRun.shift();ie.unshift(x)}Re(ie)}}if(!(0<ge)){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)ve();Re(me),0<ge||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),b()},1)):b())}}if(i.run=Qe,i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();return Qe(),o.ready}})();n.exports=r})(ortWasm);var ortWasmThreaded$1={exports:{}};(function(n,e){var r=(()=>{var t=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(t=t||__filename),function(o){o=o||{};function i(){return M.buffer!=ye&&Ae(M.buffer),Ue}function l(){return M.buffer!=ye&&Ae(M.buffer),He}function a(){return M.buffer!=ye&&Ae(M.buffer),Re}function s(){return M.buffer!=ye&&Ae(M.buffer),ke}var u;u||(u=typeof o!="undefined"?o:{});var c=Object.assign,f,d;u.ready=new Promise(function(h,g){f=h,d=g});var m=c({},u),_="./this.program",S=(h,g)=>{throw g},E=typeof window=="object",$=typeof importScripts=="function",y=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v=u.ENVIRONMENT_IS_PTHREAD||!1,A="";function P(h){return u.locateFile?u.locateFile(h,A):A+h}var C,L,B,V,j,U;if(y){A=$?require$$3$1.dirname(A)+"/":__dirname+"/",U=()=>{j||(V=require$$3$1,j=require$$3$1)},C=function(g,w){return U(),g=j.normalize(g),V.readFileSync(g,w?null:"utf8")},B=g=>(g=C(g,!0),g.buffer||(g=new Uint8Array(g)),g),L=(g,w,T)=>{U(),g=j.normalize(g),V.readFile(g,function(N,z){N?T(N):w(z.buffer)})},1<process.argv.length&&(_=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(g){if(!(g instanceof at))throw g}),process.on("unhandledRejection",function(g){throw g}),S=(g,w)=>{if(Ee())throw process.exitCode=g,w;w instanceof at||X("exiting due to exception: "+w),process.exit(g)},u.inspect=function(){return"[Emscripten Module object]"};let h;try{h=require("worker_threads")}catch(g){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),g}commonjsGlobal$1.Worker=h.Worker}else(E||$)&&($?A=self.location.href:typeof document!="undefined"&&document.currentScript&&(A=document.currentScript.src),t&&(A=t),A.indexOf("blob:")!==0?A=A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):A="",y||(C=h=>{var g=new XMLHttpRequest;return g.open("GET",h,!1),g.send(null),g.responseText},$&&(B=h=>{var g=new XMLHttpRequest;return g.open("GET",h,!1),g.responseType="arraybuffer",g.send(null),new Uint8Array(g.response)}),L=(h,g,w)=>{var T=new XMLHttpRequest;T.open("GET",h,!0),T.responseType="arraybuffer",T.onload=()=>{T.status==200||T.status==0&&T.response?g(T.response):w()},T.onerror=w,T.send(null)}));y&&typeof performance=="undefined"&&(commonjsGlobal$1.performance=require$$3$1.performance);var re=console.log.bind(console),Z=console.warn.bind(console);y&&(U(),re=h=>V.writeSync(1,h+`
- `),Z=h=>V.writeSync(2,h+`
- `));var ee=u.print||re,X=u.printErr||Z;c(u,m),m=null,u.thisProgram&&(_=u.thisProgram),u.quit&&(S=u.quit);var J,ae;u.wasmBinary&&(ae=u.wasmBinary);var de=u.noExitRuntime||!1;typeof WebAssembly!="object"&&Fe("no native wasm support detected");var M,we,le=!1;function me(h){var g=new TextDecoder(h);this.decode=w=>(w.buffer instanceof SharedArrayBuffer&&(w=new Uint8Array(w)),g.decode.call(g,w))}var Y=typeof TextDecoder!="undefined"?new me("utf8"):void 0;function ie(h,g,w){var T=g+w;for(w=g;h[w]&&!(w>=T);)++w;if(16<w-g&&h.subarray&&Y)return Y.decode(h.subarray(g,w));for(T="";g<w;){var N=h[g++];if(N&128){var z=h[g++]&63;if((N&224)==192)T+=String.fromCharCode((N&31)<<6|z);else{var q=h[g++]&63;N=(N&240)==224?(N&15)<<12|z<<6|q:(N&7)<<18|z<<12|q<<6|h[g++]&63,65536>N?T+=String.fromCharCode(N):(N-=65536,T+=String.fromCharCode(55296|N>>10,56320|N&1023))}}else T+=String.fromCharCode(N)}return T}function ve(h,g){return h?ie(l(),h,g):""}function ge(h,g,w,T){if(!(0<T))return 0;var N=w;T=w+T-1;for(var z=0;z<h.length;++z){var q=h.charCodeAt(z);if(55296<=q&&57343>=q){var fe=h.charCodeAt(++z);q=65536+((q&1023)<<10)|fe&1023}if(127>=q){if(w>=T)break;g[w++]=q}else{if(2047>=q){if(w+1>=T)break;g[w++]=192|q>>6}else{if(65535>=q){if(w+2>=T)break;g[w++]=224|q>>12}else{if(w+3>=T)break;g[w++]=240|q>>18,g[w++]=128|q>>12&63}g[w++]=128|q>>6&63}g[w++]=128|q&63}}return g[w]=0,w-N}function Te(h,g,w){return ge(h,l(),g,w)}function Se(h){for(var g=0,w=0;w<h.length;++w){var T=h.charCodeAt(w);55296<=T&&57343>=T&&(T=65536+((T&1023)<<10)|h.charCodeAt(++w)&1023),127>=T?++g:g=2047>=T?g+2:65535>=T?g+3:g+4}return g}typeof TextDecoder!="undefined"&&new me("utf-16le");function Be(h){var g=Se(h)+1,w=ot(g);return w&&ge(h,i(),w,g),w}function _e(h,g){i().set(h,g)}var ye,Ue,He,Re,ke;v&&(ye=u.buffer);function Ae(h){ye=h,u.HEAP8=Ue=new Int8Array(h),u.HEAP16=new Int16Array(h),u.HEAP32=Re=new Int32Array(h),u.HEAPU8=He=new Uint8Array(h),u.HEAPU16=new Uint16Array(h),u.HEAPU32=new Uint32Array(h),u.HEAPF32=new Float32Array(h),u.HEAPF64=ke=new Float64Array(h)}var qe=u.INITIAL_MEMORY||16777216;if(v)M=u.wasmMemory,ye=u.buffer;else if(u.wasmMemory)M=u.wasmMemory;else if(M=new WebAssembly.Memory({initial:qe/65536,maximum:32768,shared:!0}),!(M.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"),y&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");M&&(ye=M.buffer),qe=ye.byteLength,Ae(ye);var Me,Ye=[],O=[],k=[],te=[],$e=0;function Ee(){return de||0<$e}function Oe(){var h=u.preRun.shift();Ye.unshift(h)}var Ce=0,Ie=null;u.preloadedImages={},u.preloadedAudios={};function Fe(h){throw v?postMessage({cmd:"onAbort",arg:h}):u.onAbort&&u.onAbort(h),h="Aborted("+h+")",X(h),le=!0,h=new WebAssembly.RuntimeError(h+". Build with -s ASSERTIONS=1 for more info."),d(h),h}function ze(){return pe.startsWith("data:application/octet-stream;base64,")}var pe;pe="ort-wasm-threaded.wasm",ze()||(pe=P(pe));function Ve(){var h=pe;try{if(h==pe&&ae)return new Uint8Array(ae);if(B)return B(h);throw"both async and sync fetching of the wasm failed"}catch(g){Fe(g)}}function st(){if(!ae&&(E||$)){if(typeof fetch=="function"&&!pe.startsWith("file://"))return fetch(pe,{credentials:"same-origin"}).then(function(h){if(!h.ok)throw"failed to load wasm binary file at '"+pe+"'";return h.arrayBuffer()}).catch(function(){return Ve()});if(L)return new Promise(function(h,g){L(pe,function(w){h(new Uint8Array(w))},g)})}return Promise.resolve().then(function(){return Ve()})}var _t={};function Ge(h){for(;0<h.length;){var g=h.shift();if(typeof g=="function")g(u);else{var w=g.Tb;typeof w=="number"?g.Sa===void 0?Ke(w)():Ke(w)(g.Sa):w(g.Sa===void 0?null:g.Sa)}}}function et(h){var g=Et();return h=h(),pt(g),h}function Xe(h){var g=H.Oa[h];g&&(a()[h>>2]=0,H.jb(g.worker))}var H={Pa:[],Va:[],fb:[],Wb:function(){},ub:function(){H.receiveObjectTransfer=H.zb,H.threadInit=H.lb,H.setExitStatus=H.Bb},Oa:{},Bb:function(){},kb:function(){for(var h in H.Oa){var g=H.Oa[h];g&&g.worker&&H.jb(g.worker)}for(h=0;h<H.Pa.length;++h)H.Pa[h].terminate();H.Pa=[]},jb:function(h){H.Ab(function(){delete H.Oa[h.Qa.eb],H.Pa.push(h),H.Va.splice(H.Va.indexOf(h),1),Tt(h.Qa.eb),h.Qa=void 0})},Ab:function(h){a()[Xt>>2]=0;try{h()}finally{a()[Xt>>2]=1}},zb:function(){},lb:function(){for(var h in H.fb)H.fb[h]()},wb:function(h,g){h.onmessage=w=>{w=w.data;var T=w.cmd;if(h.Qa&&(H.pb=h.Qa.eb),w.targetThread&&w.targetThread!=dt()){var N=H.Oa[w.bc];N?N.worker.postMessage(w,w.transferList):X('Internal error! Worker sent a message "'+T+'" to target pthread '+w.targetThread+", but that thread no longer exists!")}else T==="processQueuedMainThreadWork"?xt():T==="spawnThread"?Qe(w):T==="cleanupThread"?Xe(w.thread):T==="killThread"?(w=w.thread,a()[w>>2]=0,T=H.Oa[w],delete H.Oa[w],T.worker.terminate(),Tt(w),H.Va.splice(H.Va.indexOf(T.worker),1),T.worker.Qa=void 0):T==="cancelThread"?H.Oa[w.thread].worker.postMessage({cmd:"cancel"}):T==="loaded"?(h.loaded=!0,g&&g(h),h.Ua&&(h.Ua(),delete h.Ua)):T==="print"?ee("Thread "+w.threadId+": "+w.text):T==="printErr"?X("Thread "+w.threadId+": "+w.text):T==="alert"?alert("Thread "+w.threadId+": "+w.text):w.target==="setimmediate"?h.postMessage(w):T==="onAbort"?u.onAbort&&u.onAbort(w.arg):X("worker sent an unknown command "+T);H.pb=void 0},h.onerror=w=>{throw X("worker sent an error! "+w.filename+":"+w.lineno+": "+w.message),w},y&&(h.on("message",function(w){h.onmessage({data:w})}),h.on("error",function(w){h.onerror(w)}),h.on("detachedExit",function(){})),h.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||t,wasmMemory:M,wasmModule:we})},mb:function(){var h=P("ort-wasm-threaded.worker.js");H.Pa.push(new Worker(h))},rb:function(){return H.Pa.length==0&&(H.mb(),H.wb(H.Pa[0])),H.Pa.pop()}};u.establishStackSpace=function(){var h=dt(),g=a()[h+44>>2];h=a()[h+48>>2],Yt(g,g-h),pt(g)};function tt(h){if(v)return oe(1,0,h);try{Kt(h)}catch(g){g instanceof at||g=="unwind"||S(1,g)}}var je=[];function Ke(h){var g=je[h];return g||(h>=je.length&&(je.length=h+1),je[h]=g=Me.get(h)),g}u.invokeEntryPoint=function(h,g){return Ke(h)(g)};var Ze;Ze=y?()=>{var h=process.hrtime();return 1e3*h[0]+h[1]/1e6}:v?()=>performance.now()-u.__performance_now_clock_drift:()=>performance.now();function Je(h){this.Ta=h-16,this.Gb=function(g){a()[this.Ta+4>>2]=g},this.Db=function(g){a()[this.Ta+8>>2]=g},this.Eb=function(){a()[this.Ta>>2]=0},this.Cb=function(){var g=0;i()[this.Ta+12>>0]=g},this.Fb=function(){var g=0;i()[this.Ta+13>>0]=g},this.sb=function(g,w){this.Gb(g),this.Db(w),this.Eb(),this.Cb(),this.Fb()}}function Qe(h){var g=H.rb();if(!g)return 6;H.Va.push(g);var w=H.Oa[h.cb]={worker:g,eb:h.cb};g.Qa=w;var T={cmd:"run",start_routine:h.Hb,arg:h.Sa,threadInfoStruct:h.cb};return g.Ua=()=>{T.time=performance.now(),g.postMessage(T,h.Mb)},g.loaded&&(g.Ua(),delete g.Ua),0}var b={},x=[null,[],[]];function F(h,g){var w=x[h];g===0||g===10?((h===1?ee:X)(ie(w,0)),w.length=0):w.push(g)}var R={};function G(h,g,w){return v?oe(2,1,h,g,w):0}function W(h,g){if(v)return oe(3,1,h,g)}function K(h,g,w,T){if(v)return oe(4,1,h,g,w,T)}function ue(h,g){if(v)return oe(5,1,h,g)}function xe(h,g,w){if(v)return oe(6,1,h,g,w)}function be(h,g,w){return v?oe(7,1,h,g,w):0}function he(h,g){if(v)return oe(8,1,h,g)}function nt(h,g){return v?oe(9,1,h,g):(h=ve(h),R.Qb(h,g))}function rt(h,g,w,T,N,z){if(v)g=oe(10,1,h,g,w,T,N,z);else if(z<<=12,(T&16)!==0&&h%65536!==0)g=-28;else if((T&32)!==0){var q=65536*Math.ceil(g/65536);(h=qt(65536,q))?l().fill(0,h,h+q):h=0,h?(b[h]={yb:h,vb:g,nb:!0,fd:N,Zb:w,flags:T,offset:z},g=h):g=-48}else g=-52;return g}function I(h,g){if(v)h=oe(11,1,h,g);else{var w=b[h];g!==0&&w?(g===w.vb&&(b[h]=null,w.nb&&zt(w.yb)),h=0):h=-28}return h}function Q(h,g,w){if(v)return oe(12,1,h,g,w)}function se(h,g,w){return v?oe(13,1,h,g,w):(h=ve(h),R.Rb(h,g,w))}function De(h){if(v)return oe(14,1,h)}function it(h,g){if(v)return oe(15,1,h,g)}function At(h){if(v)return oe(16,1,h)}function Ct(h,g,w){function T(Pe){return(Pe=Pe.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Pe[1]:"GMT"}if(v)return oe(17,1,h,g,w);var N=new Date().getFullYear(),z=new Date(N,0,1),q=new Date(N,6,1);N=z.getTimezoneOffset();var fe=q.getTimezoneOffset(),Ne=Math.max(N,fe);a()[h>>2]=60*Ne,a()[g>>2]=Number(N!=fe),h=T(z),g=T(q),h=Be(h),g=Be(g),fe<N?(a()[w>>2]=h,a()[w+4>>2]=g):(a()[w>>2]=g,a()[w+4>>2]=h)}function yt(h,g,w){yt.ob||(yt.ob=!0,Ct(h,g,w))}function oe(h,g){var w=arguments.length-2,T=arguments;return et(function(){for(var N=ht(8*w),z=N>>3,q=0;q<w;q++){var fe=T[2+q];s()[z+q]=fe}return Wt(h,w,N,g)})}var vt=[];function en(h,g,w,T){et(function(){var N=ht(12),z=0;if(g){z=Se(g)+1;var q=ot(z);Te(g,q,z),z=q}a()[N>>2]=z,a()[N+4>>2]=w,a()[N+8>>2]=T,Ht(h,657457152,0,z,N)})}var tn=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function bt(h){return h=2<h?ve(h):h,tn[h]||(typeof document!="undefined"?document.querySelector(h):void 0)}function Ot(h,g,w){var T=bt(h);if(!T)return-4;if(T.Za&&(a()[T.Za>>2]=g,a()[T.Za+4>>2]=w),T.ib||!T.Ob)T.ib&&(T=T.ib),h=!1,T.Ya&&T.Ya.Xa&&(h=T.Ya.Xa.getParameter(2978),h=h[0]===0&&h[1]===0&&h[2]===T.width&&h[3]===T.height),T.width=g,T.height=w,h&&T.Ya.Xa.viewport(0,0,g,w);else return T.Za?(T=a()[T.Za+8>>2],h=h?ve(h):"",en(T,h,g,w),1):-4;return 0}function It(h,g,w){return v?oe(18,1,h,g,w):Ot(h,g,w)}function nn(h){var g=h.getExtension("ANGLE_instanced_arrays");g&&(h.vertexAttribDivisor=function(w,T){g.vertexAttribDivisorANGLE(w,T)},h.drawArraysInstanced=function(w,T,N,z){g.drawArraysInstancedANGLE(w,T,N,z)},h.drawElementsInstanced=function(w,T,N,z,q){g.drawElementsInstancedANGLE(w,T,N,z,q)})}function rn(h){var g=h.getExtension("OES_vertex_array_object");g&&(h.createVertexArray=function(){return g.createVertexArrayOES()},h.deleteVertexArray=function(w){g.deleteVertexArrayOES(w)},h.bindVertexArray=function(w){g.bindVertexArrayOES(w)},h.isVertexArray=function(w){return g.isVertexArrayOES(w)})}function on(h){var g=h.getExtension("WEBGL_draw_buffers");g&&(h.drawBuffers=function(w,T){g.drawBuffersWEBGL(w,T)})}function an(h,g){h.hb||(h.hb=h.getContext,h.getContext=function(T,N){return N=h.hb(T,N),T=="webgl"==N instanceof WebGLRenderingContext?N:null});var w=h.getContext("webgl",g);return w?sn(w,g):0}function sn(h,g){var w=ot(8);a()[w+4>>2]=dt();var T={Vb:w,attributes:g,version:g.xb,Xa:h};return h.canvas&&(h.canvas.Ya=T),(typeof g.gb=="undefined"||g.gb)&&ln(T),w}function ln(h){if(h||(h=un),!h.tb){h.tb=!0;var g=h.Xa;nn(g),rn(g),on(g),g.Pb=g.getExtension("EXT_disjoint_timer_query"),g.Yb=g.getExtension("WEBGL_multi_draw"),(g.getSupportedExtensions()||[]).forEach(function(w){w.includes("lose_context")||w.includes("debug")||g.getExtension(w)})}}var un,cn=["default","low-power","high-performance"],wt={};function Ft(){if(!St){var h={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",_:_||"./this.program"},g;for(g in wt)wt[g]===void 0?delete h[g]:h[g]=wt[g];var w=[];for(g in h)w.push(g+"="+h[g]);St=w}return St}var St;function Dt(h,g){if(v)return oe(19,1,h,g);var w=0;return Ft().forEach(function(T,N){var z=g+w;for(N=a()[h+4*N>>2]=z,z=0;z<T.length;++z)i()[N++>>0]=T.charCodeAt(z);i()[N>>0]=0,w+=T.length+1}),0}function Lt(h,g){if(v)return oe(20,1,h,g);var w=Ft();a()[h>>2]=w.length;var T=0;return w.forEach(function(N){T+=N.length+1}),a()[g>>2]=T,0}function kt(h){return v?oe(21,1,h):0}function Rt(h,g,w,T){return v?oe(22,1,h,g,w,T):(h=R.Ub(h),g=R.Sb(h,g,w),a()[T>>2]=g,0)}function Mt(h,g,w,T,N){if(v)return oe(23,1,h,g,w,T,N)}function Nt(h,g,w,T){if(v)return oe(24,1,h,g,w,T);for(var N=0,z=0;z<w;z++){var q=a()[g>>2],fe=a()[g+4>>2];g+=8;for(var Ne=0;Ne<fe;Ne++)F(h,l()[q+Ne]);N+=fe}return a()[T>>2]=N,0}function lt(h){return h%4===0&&(h%100!==0||h%400===0)}function $t(h,g){for(var w=0,T=0;T<=g;w+=h[T++]);return w}var ut=[31,29,31,30,31,30,31,31,30,31,30,31],ct=[31,28,31,30,31,30,31,31,30,31,30,31];function ft(h,g){for(h=new Date(h.getTime());0<g;){var w=h.getMonth(),T=(lt(h.getFullYear())?ut:ct)[w];if(g>T-h.getDate())g-=T-h.getDate()+1,h.setDate(1),11>w?h.setMonth(w+1):(h.setMonth(0),h.setFullYear(h.getFullYear()+1));else{h.setDate(h.getDate()+g);break}}return h}function Bt(h,g,w,T){function N(D,ne,ce){for(D=typeof D=="number"?D.toString():D||"";D.length<ne;)D=ce[0]+D;return D}function z(D,ne){return N(D,ne,"0")}function q(D,ne){function ce(Qt){return 0>Qt?-1:0<Qt?1:0}var We;return(We=ce(D.getFullYear()-ne.getFullYear()))===0&&(We=ce(D.getMonth()-ne.getMonth()))===0&&(We=ce(D.getDate()-ne.getDate())),We}function fe(D){switch(D.getDay()){case 0:return new Date(D.getFullYear()-1,11,29);case 1:return D;case 2:return new Date(D.getFullYear(),0,3);case 3:return new Date(D.getFullYear(),0,2);case 4:return new Date(D.getFullYear(),0,1);case 5:return new Date(D.getFullYear()-1,11,31);case 6:return new Date(D.getFullYear()-1,11,30)}}function Ne(D){D=ft(new Date(D.Na+1900,0,1),D.bb);var ne=new Date(D.getFullYear()+1,0,4),ce=fe(new Date(D.getFullYear(),0,4));return ne=fe(ne),0>=q(ce,D)?0>=q(ne,D)?D.getFullYear()+1:D.getFullYear():D.getFullYear()-1}var Pe=a()[T+40>>2];T={Kb:a()[T>>2],Jb:a()[T+4>>2],$a:a()[T+8>>2],Wa:a()[T+12>>2],Ra:a()[T+16>>2],Na:a()[T+20>>2],ab:a()[T+24>>2],bb:a()[T+28>>2],cc:a()[T+32>>2],Ib:a()[T+36>>2],Lb:Pe?ve(Pe):""},w=ve(w),Pe={"%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"};for(var Le in Pe)w=w.replace(new RegExp(Le,"g"),Pe[Le]);var Zt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Jt="January February March April May June July August September October November December".split(" ");Pe={"%a":function(D){return Zt[D.ab].substring(0,3)},"%A":function(D){return Zt[D.ab]},"%b":function(D){return Jt[D.Ra].substring(0,3)},"%B":function(D){return Jt[D.Ra]},"%C":function(D){return z((D.Na+1900)/100|0,2)},"%d":function(D){return z(D.Wa,2)},"%e":function(D){return N(D.Wa,2," ")},"%g":function(D){return Ne(D).toString().substring(2)},"%G":function(D){return Ne(D)},"%H":function(D){return z(D.$a,2)},"%I":function(D){return D=D.$a,D==0?D=12:12<D&&(D-=12),z(D,2)},"%j":function(D){return z(D.Wa+$t(lt(D.Na+1900)?ut:ct,D.Ra-1),3)},"%m":function(D){return z(D.Ra+1,2)},"%M":function(D){return z(D.Jb,2)},"%n":function(){return`
- `},"%p":function(D){return 0<=D.$a&&12>D.$a?"AM":"PM"},"%S":function(D){return z(D.Kb,2)},"%t":function(){return" "},"%u":function(D){return D.ab||7},"%U":function(D){var ne=new Date(D.Na+1900,0,1),ce=ne.getDay()===0?ne:ft(ne,7-ne.getDay());return D=new Date(D.Na+1900,D.Ra,D.Wa),0>q(ce,D)?z(Math.ceil((31-ce.getDate()+($t(lt(D.getFullYear())?ut:ct,D.getMonth()-1)-31)+D.getDate())/7),2):q(ce,ne)===0?"01":"00"},"%V":function(D){var ne=new Date(D.Na+1901,0,4),ce=fe(new Date(D.Na+1900,0,4));ne=fe(ne);var We=ft(new Date(D.Na+1900,0,1),D.bb);return 0>q(We,ce)?"53":0>=q(ne,We)?"01":z(Math.ceil((ce.getFullYear()<D.Na+1900?D.bb+32-ce.getDate():D.bb+1-ce.getDate())/7),2)},"%w":function(D){return D.ab},"%W":function(D){var ne=new Date(D.Na,0,1),ce=ne.getDay()===1?ne:ft(ne,ne.getDay()===0?1:7-ne.getDay()+1);return D=new Date(D.Na+1900,D.Ra,D.Wa),0>q(ce,D)?z(Math.ceil((31-ce.getDate()+($t(lt(D.getFullYear())?ut:ct,D.getMonth()-1)-31)+D.getDate())/7),2):q(ce,ne)===0?"01":"00"},"%y":function(D){return(D.Na+1900).toString().substring(2)},"%Y":function(D){return D.Na+1900},"%z":function(D){D=D.Ib;var ne=0<=D;return D=Math.abs(D)/60,(ne?"+":"-")+String("0000"+(D/60*100+D%60)).slice(-4)},"%Z":function(D){return D.Lb},"%%":function(){return"%"}};for(Le in Pe)w.includes(Le)&&(w=w.replace(new RegExp(Le,"g"),Pe[Le](T)));return Le=dn(w),Le.length>g?0:(_e(Le,h),Le.length-1)}var fn=[null,tt,G,W,K,ue,xe,be,he,nt,rt,I,Q,se,De,it,At,Ct,It,Dt,Lt,kt,Rt,Mt,Nt];function dn(h){var g=Array(Se(h)+1);return ge(h,g,0,g.length),g}var pn={b:function(h){return ot(h+16)+16},c:function(h,g,w){throw new Je(h).sb(g,w),h},M:function(h){Gt(h,!$,1,!E),H.lb()},n:function(h){v?postMessage({cmd:"cleanupThread",thread:h}):Xe(h)},p:function(h,g,w,T){if(typeof SharedArrayBuffer=="undefined")return X("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var N=[];return v&&N.length===0?jt(687865856,h,g,w,T):(h={Hb:w,cb:h,Sa:T,Mb:N},v?(h.Nb="spawnThread",postMessage(h,N),0):Qe(h))},i:G,U:W,R:K,y:ue,A:xe,t:be,S:he,H:nt,G:rt,F:I,o:Q,z:se,w:De,T:it,x:At,j:function(){Fe("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},_:function(){Fe("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},E:function(){return 2097152},Z:function(h,g,w){var T=performance.now();for(w=T+w,Atomics.exchange(a(),mt>>2,h);;){if(T=performance.now(),T>w)return Atomics.exchange(a(),mt>>2,0),-73;if(T=Atomics.exchange(a(),mt>>2,0),T==0)break;if(xt(),Atomics.load(a(),h>>2)!=g)return-6;Atomics.exchange(a(),mt>>2,h)}return 0},N:function(h,g){if(h==g)postMessage({cmd:"processQueuedMainThreadWork"});else if(v)postMessage({targetThread:h,cmd:"processThreadQueue"});else{if(h=(h=H.Oa[h])&&h.worker,!h)return;h.postMessage({cmd:"processThreadQueue"})}return 1},V:function(h,g){h=new Date(1e3*a()[h>>2]),a()[g>>2]=h.getUTCSeconds(),a()[g+4>>2]=h.getUTCMinutes(),a()[g+8>>2]=h.getUTCHours(),a()[g+12>>2]=h.getUTCDate(),a()[g+16>>2]=h.getUTCMonth(),a()[g+20>>2]=h.getUTCFullYear()-1900,a()[g+24>>2]=h.getUTCDay(),h=(h.getTime()-Date.UTC(h.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[g+28>>2]=h},W:function(h,g){h=new Date(1e3*a()[h>>2]),a()[g>>2]=h.getSeconds(),a()[g+4>>2]=h.getMinutes(),a()[g+8>>2]=h.getHours(),a()[g+12>>2]=h.getDate(),a()[g+16>>2]=h.getMonth(),a()[g+20>>2]=h.getFullYear()-1900,a()[g+24>>2]=h.getDay();var w=new Date(h.getFullYear(),0,1),T=(h.getTime()-w.getTime())/864e5|0;a()[g+28>>2]=T,a()[g+36>>2]=-(60*h.getTimezoneOffset()),T=new Date(h.getFullYear(),6,1).getTimezoneOffset(),w=w.getTimezoneOffset(),h=(T!=w&&h.getTimezoneOffset()==Math.min(w,T))|0,a()[g+32>>2]=h},X:function(h){var g=new Date(a()[h+20>>2]+1900,a()[h+16>>2],a()[h+12>>2],a()[h+8>>2],a()[h+4>>2],a()[h>>2],0),w=a()[h+32>>2],T=g.getTimezoneOffset(),N=new Date(g.getFullYear(),0,1),z=new Date(g.getFullYear(),6,1).getTimezoneOffset(),q=N.getTimezoneOffset(),fe=Math.min(q,z);return 0>w?a()[h+32>>2]=Number(z!=q&&fe==T):0<w!=(fe==T)&&(z=Math.max(q,z),g.setTime(g.getTime()+6e4*((0<w?fe:z)-T))),a()[h+24>>2]=g.getDay(),w=(g.getTime()-N.getTime())/864e5|0,a()[h+28>>2]=w,a()[h>>2]=g.getSeconds(),a()[h+4>>2]=g.getMinutes(),a()[h+8>>2]=g.getHours(),a()[h+12>>2]=g.getDate(),a()[h+16>>2]=g.getMonth(),g.getTime()/1e3|0},Y:yt,d:function(){Fe("")},q:function(h,g){if(h===0)h=Date.now();else if(h===1||h===4)h=Ze();else return a()[Ut()>>2]=28,-1;return a()[g>>2]=h/1e3|0,a()[g+4>>2]=h%1e3*1e6|0,0},B:function(h,g){return h-g},m:function(){y||$||(J||(J={}),J["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]||(J["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]=1,X("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")))},v:function(){return 2147483648},f:Ze,Q:function(h,g,w){l().copyWithin(h,g,g+w)},g:function(){return y?require$$3$1.cpus().length:navigator.hardwareConcurrency},I:function(h,g,w){vt.length=g,w>>=3;for(var T=0;T<g;T++)vt[T]=s()[w+T];return(0>h?_t[-h-1]:fn[h]).apply(null,vt)},u:function(h){var g=l().length;if(h>>>=0,h<=g||2147483648<h)return!1;for(var w=1;4>=w;w*=2){var T=g*(1+.2/w);T=Math.min(T,h+100663296),T=Math.max(h,T),0<T%65536&&(T+=65536-T%65536);e:{try{M.grow(Math.min(2147483648,T)-ye.byteLength+65535>>>16),Ae(M.buffer);var N=1;break e}catch{}N=void 0}if(N)return!0}return!1},K:function(h,g,w){return bt(h)?Ot(h,g,w):It(h,g,w)},C:function(){throw"unwind"},L:function(h,g){g>>=2;var w=a()[g+6];return g={alpha:!!a()[g],depth:!!a()[g+1],stencil:!!a()[g+2],antialias:!!a()[g+3],premultipliedAlpha:!!a()[g+4],preserveDrawingBuffer:!!a()[g+5],powerPreference:cn[w],failIfMajorPerformanceCaveat:!!a()[g+7],xb:a()[g+8],Xb:a()[g+9],gb:a()[g+10],qb:a()[g+11],$b:a()[g+12],ac:a()[g+13]},h=bt(h),!h||g.qb?0:an(h,g)},O:Dt,P:Lt,D:function(h){Kt(h)},h:kt,l:Rt,s:Mt,k:Nt,J:function(h){var g=Date.now();return a()[h>>2]=g/1e3|0,a()[h+4>>2]=g%1e3*1e3|0,0},a:M||u.wasmMemory,r:Bt,e:function(h,g,w,T){return Bt(h,g,w,T)}};(function(){function h(N,z){u.asm=N.exports,H.fb.push(u.asm.xa),Me=u.asm.Ba,O.unshift(u.asm.$),we=z,v||(Ce--,u.monitorRunDependencies&&u.monitorRunDependencies(Ce),Ce==0&&Ie&&(N=Ie,Ie=null,N()))}function g(N){h(N.instance,N.module)}function w(N){return st().then(function(z){return WebAssembly.instantiate(z,T)}).then(function(z){return z}).then(N,function(z){X("failed to asynchronously prepare wasm: "+z),Fe(z)})}var T={a:pn};if(v||(Ce++,u.monitorRunDependencies&&u.monitorRunDependencies(Ce)),u.instantiateWasm)try{return u.instantiateWasm(T,h)}catch(N){return X("Module.instantiateWasm callback failed with error: "+N),!1}return function(){return ae||typeof WebAssembly.instantiateStreaming!="function"||ze()||pe.startsWith("file://")||typeof fetch!="function"?w(g):fetch(pe,{credentials:"same-origin"}).then(function(N){return WebAssembly.instantiateStreaming(N,T).then(g,function(z){return X("wasm streaming compile failed: "+z),X("falling back to ArrayBuffer instantiation"),w(g)})})}().catch(d),{}})(),u.___wasm_call_ctors=function(){return(u.___wasm_call_ctors=u.asm.$).apply(null,arguments)},u._OrtInit=function(){return(u._OrtInit=u.asm.aa).apply(null,arguments)},u._OrtCreateSessionOptions=function(){return(u._OrtCreateSessionOptions=u.asm.ba).apply(null,arguments)},u._OrtAddSessionConfigEntry=function(){return(u._OrtAddSessionConfigEntry=u.asm.ca).apply(null,arguments)},u._OrtReleaseSessionOptions=function(){return(u._OrtReleaseSessionOptions=u.asm.da).apply(null,arguments)},u._OrtCreateSession=function(){return(u._OrtCreateSession=u.asm.ea).apply(null,arguments)},u._OrtReleaseSession=function(){return(u._OrtReleaseSession=u.asm.fa).apply(null,arguments)},u._OrtGetInputCount=function(){return(u._OrtGetInputCount=u.asm.ga).apply(null,arguments)},u._OrtGetOutputCount=function(){return(u._OrtGetOutputCount=u.asm.ha).apply(null,arguments)},u._OrtGetInputName=function(){return(u._OrtGetInputName=u.asm.ia).apply(null,arguments)},u._OrtGetOutputName=function(){return(u._OrtGetOutputName=u.asm.ja).apply(null,arguments)},u._OrtFree=function(){return(u._OrtFree=u.asm.ka).apply(null,arguments)},u._OrtCreateTensor=function(){return(u._OrtCreateTensor=u.asm.la).apply(null,arguments)},u._OrtGetTensorData=function(){return(u._OrtGetTensorData=u.asm.ma).apply(null,arguments)},u._OrtReleaseTensor=function(){return(u._OrtReleaseTensor=u.asm.na).apply(null,arguments)},u._OrtCreateRunOptions=function(){return(u._OrtCreateRunOptions=u.asm.oa).apply(null,arguments)},u._OrtAddRunConfigEntry=function(){return(u._OrtAddRunConfigEntry=u.asm.pa).apply(null,arguments)},u._OrtReleaseRunOptions=function(){return(u._OrtReleaseRunOptions=u.asm.qa).apply(null,arguments)},u._OrtRun=function(){return(u._OrtRun=u.asm.ra).apply(null,arguments)},u._OrtEndProfiling=function(){return(u._OrtEndProfiling=u.asm.sa).apply(null,arguments)};var Ut=u.___errno_location=function(){return(Ut=u.___errno_location=u.asm.ta).apply(null,arguments)},dt=u._pthread_self=function(){return(dt=u._pthread_self=u.asm.ua).apply(null,arguments)},ot=u._malloc=function(){return(ot=u._malloc=u.asm.va).apply(null,arguments)},zt=u._free=function(){return(zt=u._free=u.asm.wa).apply(null,arguments)};u._emscripten_tls_init=function(){return(u._emscripten_tls_init=u.asm.xa).apply(null,arguments)};var Vt=u.___funcs_on_exit=function(){return(Vt=u.___funcs_on_exit=u.asm.ya).apply(null,arguments)},xt=u._emscripten_main_thread_process_queued_calls=function(){return(xt=u._emscripten_main_thread_process_queued_calls=u.asm.za).apply(null,arguments)},Gt=u.__emscripten_thread_init=function(){return(Gt=u.__emscripten_thread_init=u.asm.Aa).apply(null,arguments)};u._emscripten_current_thread_process_queued_calls=function(){return(u._emscripten_current_thread_process_queued_calls=u.asm.Ca).apply(null,arguments)};var jt=u._emscripten_sync_run_in_main_thread_4=function(){return(jt=u._emscripten_sync_run_in_main_thread_4=u.asm.Da).apply(null,arguments)},Wt=u._emscripten_run_in_main_runtime_thread_js=function(){return(Wt=u._emscripten_run_in_main_runtime_thread_js=u.asm.Ea).apply(null,arguments)},Ht=u._emscripten_dispatch_to_thread_=function(){return(Ht=u._emscripten_dispatch_to_thread_=u.asm.Fa).apply(null,arguments)},Tt=u.__emscripten_thread_free_data=function(){return(Tt=u.__emscripten_thread_free_data=u.asm.Ga).apply(null,arguments)};u.__emscripten_thread_exit=function(){return(u.__emscripten_thread_exit=u.asm.Ha).apply(null,arguments)};var qt=u._memalign=function(){return(qt=u._memalign=u.asm.Ia).apply(null,arguments)},Yt=u._emscripten_stack_set_limits=function(){return(Yt=u._emscripten_stack_set_limits=u.asm.Ja).apply(null,arguments)},Et=u.stackSave=function(){return(Et=u.stackSave=u.asm.Ka).apply(null,arguments)},pt=u.stackRestore=function(){return(pt=u.stackRestore=u.asm.La).apply(null,arguments)},ht=u.stackAlloc=function(){return(ht=u.stackAlloc=u.asm.Ma).apply(null,arguments)},mt=u.__emscripten_main_thread_futex=687896,Xt=u.__emscripten_allow_main_runtime_queued_calls=683012;u.UTF8ToString=ve,u.stringToUTF8=Te,u.lengthBytesUTF8=Se,u.keepRuntimeAlive=Ee,u.PThread=H,u.stackSave=Et,u.stackRestore=pt,u.stackAlloc=ht,u.PThread=H,u.wasmMemory=M,u.ExitStatus=at;var gt;function at(h){this.name="ExitStatus",this.message="Program terminated with exit("+h+")",this.status=h}Ie=function h(){gt||Pt(),gt||(Ie=h)};function Pt(){function h(){if(!gt&&(gt=!0,u.calledRun=!0,!le)&&(v||Ge(O),f(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),!v)){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;){var g=u.postRun.shift();te.unshift(g)}Ge(te)}}if(!(0<Ce))if(v)f(u),v||Ge(O),postMessage({cmd:"loaded"});else{if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Oe();Ge(Ye),0<Ce||(u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),h()},1)):h())}}u.run=Pt;function Kt(h){if(v)throw tt(h),"unwind";Ee()||v||(Vt(),Ge(k),x[1].length&&F(1,10),x[2].length&&F(2,10),H.kb()),Ee()||(H.kb(),u.onExit&&u.onExit(h),le=!0),S(h,new at(h))}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();return v&&(de=!1,H.ub()),Pt(),o.ready}})();n.exports=r})(ortWasmThreaded$1);var ortWasmThreaded_worker={},Module={};if(typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"){var nodeWorkerThreads=require$$3$1,parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(n){onmessage({data:n})});var nodeFS=require$$3$1;Object.assign(commonjsGlobal$1,{self:commonjsGlobal$1,require:commonjsRequire$1,Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(n){(0,eval)(nodeFS.readFileSync(n,"utf8"))},postMessage:function(n){parentPort.postMessage(n)},performance:commonjsGlobal$1.performance||{now:function(){return Date.now()}}})}function threadPrintErr(){var n=Array.prototype.slice.call(arguments).join(" ");console.error(n)}function threadAlert(){var n=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:n,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert;Module.instantiateWasm=(n,e)=>{var r=new WebAssembly.Instance(Module.wasmModule,n);return e(r),Module.wasmModule=null,r.exports};self.onmessage=n=>{try{if(n.data.cmd==="load"){if(Module.wasmModule=n.data.wasmModule,Module.wasmMemory=n.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,typeof n.data.urlOrBlob=="string")importScripts(n.data.urlOrBlob);else{var e=URL.createObjectURL(n.data.urlOrBlob);importScripts(e),URL.revokeObjectURL(e)}ortWasmThreaded(Module).then(function(t){Module=t})}else if(n.data.cmd==="run"){Module.__performance_now_clock_drift=performance.now()-n.data.time,Module.__emscripten_thread_init(n.data.threadInfoStruct,0,0,1),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(n.data),Module.PThread.threadInit();try{var r=Module.invokeEntryPoint(n.data.start_routine,n.data.arg);Module.keepRuntimeAlive()?Module.PThread.setExitStatus(r):Module.__emscripten_thread_exit(r)}catch(t){if(t!="unwind")if(t instanceof Module.ExitStatus)Module.keepRuntimeAlive()||Module.__emscripten_thread_exit(t.status);else throw t}}else n.data.cmd==="cancel"?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):n.data.target==="setimmediate"||(n.data.cmd==="processThreadQueue"?Module._pthread_self()&&Module._emscripten_current_thread_process_queued_calls():(err("worker.js received unknown command "+n.data.cmd),err(n.data)))}catch(t){throw err("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&err(t.stack),t}};var __createBinding$1=commonjsGlobal$1&&commonjsGlobal$1.__createBinding||(Object.create?function(n,e,r,t){t===void 0&&(t=r),Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[r]}})}:function(n,e,r,t){t===void 0&&(t=r),n[t]=e[r]}),__setModuleDefault$1=commonjsGlobal$1&&commonjsGlobal$1.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),__importStar$1=commonjsGlobal$1&&commonjsGlobal$1.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var r in n)r!=="default"&&Object.prototype.hasOwnProperty.call(n,r)&&__createBinding$1(e,n,r);return __setModuleDefault$1(e,n),e},__importDefault=commonjsGlobal$1&&commonjsGlobal$1.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(wasmFactory,"__esModule",{value:!0});wasmFactory.dispose=wasmFactory.getInstance=wasmFactory.initializeWebAssembly=void 0;const path=__importStar$1(require$$3$1),ort_wasm_js_1=__importDefault(ortWasm.exports),ortWasmFactoryThreaded=ortWasmThreaded$1.exports;let wasm,initialized$1=!1,initializing$1=!1,aborted$1=!1;const isMultiThreadSupported=()=>{try{return typeof SharedArrayBuffer=="undefined"?!1:(typeof MessageChannel!="undefined"&&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}},isSimdSupported=()=>{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}},getWasmFileName=(n,e)=>e?n?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":n?"ort-wasm-simd.wasm":"ort-wasm.wasm",initializeWebAssembly=async n=>{if(initialized$1)return Promise.resolve();if(initializing$1)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(aborted$1)throw new Error("previous call to 'initializeWebAssembly()' failed.");initializing$1=!0;const e=n.initTimeout,r=n.numThreads,t=n.simd,o=r>1&&isMultiThreadSupported(),i=t&&isSimdSupported(),l=typeof n.wasmPaths=="string"?n.wasmPaths:void 0,a=getWasmFileName(!1,o),s=getWasmFileName(i,o),u=typeof n.wasmPaths=="object"?n.wasmPaths[s]:void 0;let c=!1;const f=[];if(e>0&&f.push(new Promise(d=>{setTimeout(()=>{c=!0,d()},e)})),f.push(new Promise((d,m)=>{const _=o?ortWasmFactoryThreaded:ort_wasm_js_1.default,S={locateFile:(E,$)=>{if(o&&E.endsWith(".worker.js")&&typeof Blob!="undefined")return URL.createObjectURL(new Blob([ortWasmThreaded_worker],{type:"text/javascript"}));if(E===a){const y=l!=null?l:$;return u!=null?u:y+s}return $+E}};if(o)if(typeof Blob=="undefined")S.mainScriptUrlOrBlob=path.join(__dirname,"ort-wasm-threaded.js");else{const E=`var ortWasmThreaded=(function(){var _scriptDir;return ${_.toString()}})();`;S.mainScriptUrlOrBlob=new Blob([E],{type:"text/javascript"})}_(S).then(E=>{initializing$1=!1,initialized$1=!0,wasm=E,d()},E=>{initializing$1=!1,aborted$1=!0,m(E)})})),await Promise.race(f),c)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)};wasmFactory.initializeWebAssembly=initializeWebAssembly;const getInstance=()=>{if(initialized$1&&wasm)return wasm;throw new Error("WebAssembly is not initialized yet.")};wasmFactory.getInstance=getInstance;const dispose=()=>{var n;initialized$1&&!initializing$1&&!aborted$1&&(initializing$1=!0,(n=wasm.PThread)===null||n===void 0||n.terminateAllThreads(),wasm=void 0,initializing$1=!1,initialized$1=!1,aborted$1=!0)};wasmFactory.dispose=dispose;Object.defineProperty(stringUtils,"__esModule",{value:!0});stringUtils.allocWasmString=void 0;const wasm_factory_1$4=wasmFactory,allocWasmString=(n,e)=>{const r=wasm_factory_1$4.getInstance(),t=r.lengthBytesUTF8(n)+1,o=r._malloc(t);return r.stringToUTF8(n,o,t),e.push(o),o};stringUtils.allocWasmString=allocWasmString;Object.defineProperty(runOptions,"__esModule",{value:!0});runOptions.setRunOptions=void 0;const options_utils_1$1=optionsUtils,string_utils_1$2=stringUtils,wasm_factory_1$3=wasmFactory,setRunOptions=n=>{const e=wasm_factory_1$3.getInstance();let r=0;const t=[],o=n||{};try{if((n==null?void 0:n.logSeverityLevel)===void 0)o.logSeverityLevel=2;else if(typeof n.logSeverityLevel!="number"||!Number.isInteger(n.logSeverityLevel)||n.logSeverityLevel<0||n.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${n.logSeverityLevel}`);if((n==null?void 0:n.logVerbosityLevel)===void 0)o.logVerbosityLevel=0;else if(typeof n.logVerbosityLevel!="number"||!Number.isInteger(n.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${n.logVerbosityLevel}`);(n==null?void 0:n.terminate)===void 0&&(o.terminate=!1);let i=0;if((n==null?void 0:n.tag)!==void 0&&(i=string_utils_1$2.allocWasmString(n.tag,t)),r=e._OrtCreateRunOptions(o.logSeverityLevel,o.logVerbosityLevel,!!o.terminate,i),r===0)throw new Error("Can't create run options");return(n==null?void 0:n.extra)!==void 0&&options_utils_1$1.iterateExtraOptions(n.extra,"",new WeakSet,(l,a)=>{const s=string_utils_1$2.allocWasmString(l,t),u=string_utils_1$2.allocWasmString(a,t);if(e._OrtAddRunConfigEntry(r,s,u)!==0)throw new Error(`Can't set a run config entry: ${l} - ${a}`)}),[r,t]}catch(i){throw r!==0&&e._OrtReleaseRunOptions(r),t.forEach(e._free),i}};runOptions.setRunOptions=setRunOptions;var sessionOptions={};Object.defineProperty(sessionOptions,"__esModule",{value:!0});sessionOptions.setSessionOptions=void 0;const options_utils_1=optionsUtils,string_utils_1$1=stringUtils,wasm_factory_1$2=wasmFactory,getGraphOptimzationLevel=n=>{switch(n){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${n}`)}},getExecutionMode=n=>{switch(n){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${n}`)}},appendDefaultOptions=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")},setSessionOptions=n=>{const e=wasm_factory_1$2.getInstance();let r=0;const t=[],o=n||{};appendDefaultOptions(o);try{(n==null?void 0:n.graphOptimizationLevel)===void 0&&(o.graphOptimizationLevel="all");const i=getGraphOptimzationLevel(o.graphOptimizationLevel);(n==null?void 0:n.enableCpuMemArena)===void 0&&(o.enableCpuMemArena=!0),(n==null?void 0:n.enableMemPattern)===void 0&&(o.enableMemPattern=!0),(n==null?void 0:n.executionMode)===void 0&&(o.executionMode="sequential");const l=getExecutionMode(o.executionMode);let a=0;if((n==null?void 0:n.logId)!==void 0&&(a=string_utils_1$1.allocWasmString(n.logId,t)),(n==null?void 0:n.logSeverityLevel)===void 0)o.logSeverityLevel=2;else if(typeof n.logSeverityLevel!="number"||!Number.isInteger(n.logSeverityLevel)||n.logSeverityLevel<0||n.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${n.logSeverityLevel}`);if((n==null?void 0:n.logVerbosityLevel)===void 0)o.logVerbosityLevel=0;else if(typeof n.logVerbosityLevel!="number"||!Number.isInteger(n.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${n.logVerbosityLevel}`);if((n==null?void 0:n.enableProfiling)===void 0&&(o.enableProfiling=!1),r=e._OrtCreateSessionOptions(i,!!o.enableCpuMemArena,!!o.enableMemPattern,l,!!o.enableProfiling,0,a,o.logSeverityLevel,o.logVerbosityLevel),r===0)throw new Error("Can't create session options");return(n==null?void 0:n.extra)!==void 0&&options_utils_1.iterateExtraOptions(n.extra,"",new WeakSet,(s,u)=>{const c=string_utils_1$1.allocWasmString(s,t),f=string_utils_1$1.allocWasmString(u,t);if(e._OrtAddSessionConfigEntry(r,c,f)!==0)throw new Error(`Can't set a session config entry: ${s} - ${u}`)}),[r,t]}catch(i){throw r!==0&&e._OrtReleaseSessionOptions(r),t.forEach(e._free),i}};sessionOptions.setSessionOptions=setSessionOptions;Object.defineProperty(wasmCoreImpl,"__esModule",{value:!0});wasmCoreImpl.extractTransferableBuffers=wasmCoreImpl.endProfiling=wasmCoreImpl.run=wasmCoreImpl.releaseSession=wasmCoreImpl.createSession=wasmCoreImpl.initOrt=void 0;const run_options_1=runOptions,session_options_1=sessionOptions,string_utils_1=stringUtils,wasm_factory_1$1=wasmFactory,initOrt$1=(n,e)=>{const r=wasm_factory_1$1.getInstance()._OrtInit(n,e);if(r!==0)throw new Error(`Can't initialize onnxruntime. error code = ${r}`)};wasmCoreImpl.initOrt=initOrt$1;const activeSessions=new Map,createSession$1=(n,e)=>{const r=wasm_factory_1$1.getInstance(),t=r._malloc(n.byteLength);let o=0,i=0,l=[];try{if([i,l]=session_options_1.setSessionOptions(e),r.HEAPU8.set(n,t),o=r._OrtCreateSession(t,n.byteLength,i),o===0)throw new Error("Can't create a session")}finally{r._free(t),r._OrtReleaseSessionOptions(i),l.forEach(r._free)}const a=r._OrtGetInputCount(o),s=r._OrtGetOutputCount(o),u=[],c=[],f=[],d=[];for(let m=0;m<a;m++){const _=r._OrtGetInputName(o,m);if(_===0)throw new Error("Can't get an input name");c.push(_),u.push(r.UTF8ToString(_))}for(let m=0;m<s;m++){const _=r._OrtGetOutputName(o,m);if(_===0)throw new Error("Can't get an output name");d.push(_),f.push(r.UTF8ToString(_))}return activeSessions.set(o,[o,c,d]),[o,u,f]};wasmCoreImpl.createSession=createSession$1;const releaseSession$1=n=>{const e=wasm_factory_1$1.getInstance(),r=activeSessions.get(n);if(!r)throw new Error("invalid session id");const t=r[0],o=r[1],i=r[2];o.forEach(e._OrtFree),i.forEach(e._OrtFree),e._OrtReleaseSession(t),activeSessions.delete(n)};wasmCoreImpl.releaseSession=releaseSession$1;const tensorDataTypeStringToEnum=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}`)}},tensorDataTypeEnumToString=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"int32";case 13:return"uint32";default:throw new Error(`unsupported data type: ${n}`)}},numericTensorTypeToTypedArray=n=>{switch(n){case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}},run$1=(n,e,r,t,o)=>{const i=wasm_factory_1$1.getInstance(),l=activeSessions.get(n);if(!l)throw new Error("invalid session id");const a=l[0],s=l[1],u=l[2],c=e.length,f=t.length;let d=0,m=[];const _=[],S=[];try{[d,m]=run_options_1.setRunOptions(o);for(let P=0;P<c;P++){const C=r[P][0],L=r[P][1],B=r[P][2];let V,j;if(Array.isArray(B)){j=4*B.length,V=i._malloc(j),S.push(V);let Z=V/4;for(let ee=0;ee<B.length;ee++){if(typeof B[ee]!="string")throw new TypeError(`tensor data at index ${ee} is not a string`);i.HEAPU32[Z++]=string_utils_1.allocWasmString(B[ee],S)}}else j=B.byteLength,V=i._malloc(j),S.push(V),i.HEAPU8.set(new Uint8Array(B.buffer,B.byteOffset,j),V);const U=i.stackSave(),re=i.stackAlloc(4*L.length);try{let Z=re/4;L.forEach(X=>i.HEAP32[Z++]=X);const ee=i._OrtCreateTensor(tensorDataTypeStringToEnum(C),V,j,re,L.length);if(ee===0)throw new Error("Can't create a tensor");_.push(ee)}finally{i.stackRestore(U)}}const E=i.stackSave(),$=i.stackAlloc(c*4),y=i.stackAlloc(c*4),v=i.stackAlloc(f*4),A=i.stackAlloc(f*4);try{let P=$/4,C=y/4,L=v/4,B=A/4;for(let U=0;U<c;U++)i.HEAPU32[P++]=_[U],i.HEAPU32[C++]=s[e[U]];for(let U=0;U<f;U++)i.HEAPU32[L++]=0,i.HEAPU32[B++]=u[t[U]];let V=i._OrtRun(a,y,$,c,A,f,v,d);const j=[];if(V===0)for(let U=0;U<f;U++){const re=i.HEAPU32[v/4+U],Z=i.stackSave(),ee=i.stackAlloc(4*4);let X,J=0;try{if(V=i._OrtGetTensorData(re,ee,ee+4,ee+8,ee+12),V!==0)throw new Error(`Can't get a tensor data. error code = ${V}`);let ae=ee/4;const de=i.HEAPU32[ae++];J=i.HEAPU32[ae++];const M=i.HEAPU32[ae++],we=i.HEAPU32[ae++],le=[];for(let Y=0;Y<we;Y++)le.push(i.HEAPU32[M/4+Y]);i._OrtFree(M);const me=le.length===0?1:le.reduce((Y,ie)=>Y*ie);if(X=tensorDataTypeEnumToString(de),X==="string"){const Y=[];let ie=J/4;for(let ve=0;ve<me;ve++){const ge=i.HEAPU32[ie++],Te=ve===me-1?void 0:i.HEAPU32[ie]-ge;Y.push(i.UTF8ToString(ge,Te))}j.push([X,le,Y])}else{const Y=numericTensorTypeToTypedArray(X),ie=new Y(me);new Uint8Array(ie.buffer,ie.byteOffset,ie.byteLength).set(i.HEAPU8.subarray(J,J+ie.byteLength)),j.push([X,le,ie])}}finally{i.stackRestore(Z),X==="string"&&J&&i._free(J),i._OrtReleaseTensor(re)}}if(V===0)return j;throw new Error(`failed to call OrtRun(). error code = ${V}.`)}finally{i.stackRestore(E)}}finally{_.forEach(i._OrtReleaseTensor),S.forEach(i._free),i._OrtReleaseRunOptions(d),m.forEach(i._free)}};wasmCoreImpl.run=run$1;const endProfiling$1=n=>{const e=wasm_factory_1$1.getInstance(),r=activeSessions.get(n);if(!r)throw new Error("invalid session id");const t=r[0],o=e._OrtEndProfiling(t);if(o===0)throw new Error("Can't get an profile file name");e._OrtFree(o)};wasmCoreImpl.endProfiling=endProfiling$1;const extractTransferableBuffers=n=>{const e=[];for(const r of n){const t=r[2];!Array.isArray(t)&&t.buffer&&e.push(t.buffer)}return e};wasmCoreImpl.extractTransferableBuffers=extractTransferableBuffers;function WorkerWrapper(){return new Worker("/worker.js",{type:"module"})}var main=Object.freeze(Object.defineProperty({__proto__:null,default:WorkerWrapper},Symbol.toStringTag,{value:"Module"})),require$$3=getAugmentedNamespace(main),__createBinding=commonjsGlobal$1&&commonjsGlobal$1.__createBinding||(Object.create?function(n,e,r,t){t===void 0&&(t=r),Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[r]}})}:function(n,e,r,t){t===void 0&&(t=r),n[t]=e[r]}),__setModuleDefault=commonjsGlobal$1&&commonjsGlobal$1.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),__importStar=commonjsGlobal$1&&commonjsGlobal$1.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var r in n)r!=="default"&&Object.prototype.hasOwnProperty.call(n,r)&&__createBinding(e,n,r);return __setModuleDefault(e,n),e},_a;Object.defineProperty(proxyWrapper,"__esModule",{value:!0});proxyWrapper.endProfiling=proxyWrapper.run=proxyWrapper.releaseSession=proxyWrapper.createSession=proxyWrapper.initOrt=proxyWrapper.initWasm=void 0;const onnxruntime_common_1$1=require$$0$1,core=__importStar(wasmCoreImpl),wasm_factory_1=wasmFactory,isProxy=()=>!!onnxruntime_common_1$1.env.wasm.proxy&&typeof document!="undefined";let proxyWorker,initializing=!1,initialized=!1,aborted=!1,initWasmCallbacks,initOrtCallbacks;const createSessionCallbacks=[],releaseSessionCallbacks=[],runCallbacks=[],endProfilingCallbacks=[],ensureWorker=()=>{if(initializing||!initialized||aborted||!proxyWorker)throw new Error("worker not ready")},onProxyWorkerMessage=n=>{switch(n.data.type){case"init-wasm":initializing=!1,n.data.err?(aborted=!0,initWasmCallbacks[1](n.data.err)):(initialized=!0,initWasmCallbacks[0]());break;case"init-ort":n.data.err?initOrtCallbacks[1](n.data.err):initOrtCallbacks[0]();break;case"create":n.data.err?createSessionCallbacks.shift()[1](n.data.err):createSessionCallbacks.shift()[0](n.data.out);break;case"release":n.data.err?releaseSessionCallbacks.shift()[1](n.data.err):releaseSessionCallbacks.shift()[0]();break;case"run":n.data.err?runCallbacks.shift()[1](n.data.err):runCallbacks.shift()[0](n.data.out);break;case"end-profiling":n.data.err?endProfilingCallbacks.shift()[1](n.data.err):endProfilingCallbacks.shift()[0]();break}},scriptSrc=typeof document!="undefined"?(_a=document==null?void 0:document.currentScript)===null||_a===void 0?void 0:_a.src:void 0,initWasm=async()=>{if(isProxy()){if(initialized)return;if(initializing)throw new Error("multiple calls to 'initWasm()' detected.");if(aborted)throw new Error("previous call to 'initWasm()' failed.");return initializing=!0,onnxruntime_common_1$1.env.wasm.wasmPaths===void 0&&scriptSrc&&scriptSrc.indexOf("blob:")!==0&&(onnxruntime_common_1$1.env.wasm.wasmPaths=scriptSrc.substr(0,scriptSrc.lastIndexOf("/")+1)),new Promise((n,e)=>{proxyWorker==null||proxyWorker.terminate(),proxyWorker=require$$3.default(),proxyWorker.onmessage=onProxyWorkerMessage,initWasmCallbacks=[n,e];const r={type:"init-wasm",in:onnxruntime_common_1$1.env.wasm};proxyWorker.postMessage(r)})}else return wasm_factory_1.initializeWebAssembly(onnxruntime_common_1$1.env.wasm)};proxyWrapper.initWasm=initWasm;const initOrt=async(n,e)=>{if(isProxy())return ensureWorker(),new Promise((r,t)=>{initOrtCallbacks=[r,t];const o={type:"init-ort",in:{numThreads:n,loggingLevel:e}};proxyWorker.postMessage(o)});core.initOrt(n,e)};proxyWrapper.initOrt=initOrt;const createSession=async(n,e)=>isProxy()?(ensureWorker(),new Promise((r,t)=>{createSessionCallbacks.push([r,t]);const o={type:"create",in:{model:n,options:e}};proxyWorker.postMessage(o,[n.buffer])})):core.createSession(n,e);proxyWrapper.createSession=createSession;const releaseSession=async n=>{if(isProxy())return ensureWorker(),new Promise((e,r)=>{releaseSessionCallbacks.push([e,r]);const t={type:"release",in:n};proxyWorker.postMessage(t)});core.releaseSession(n)};proxyWrapper.releaseSession=releaseSession;const run=async(n,e,r,t,o)=>isProxy()?(ensureWorker(),new Promise((i,l)=>{runCallbacks.push([i,l]);const a={type:"run",in:{sessionId:n,inputIndices:e,inputs:r,outputIndices:t,options:o}};proxyWorker.postMessage(a,core.extractTransferableBuffers(r))})):core.run(n,e,r,t,o);proxyWrapper.run=run;const endProfiling=async n=>{if(isProxy())return ensureWorker(),new Promise((e,r)=>{endProfilingCallbacks.push([e,r]);const t={type:"end-profiling",in:n};proxyWorker.postMessage(t)});core.endProfiling(n)};proxyWrapper.endProfiling=endProfiling;var sessionHandler={};Object.defineProperty(sessionHandler,"__esModule",{value:!0});sessionHandler.OnnxruntimeWebAssemblySessionHandler=void 0;const onnxruntime_common_1=require$$0$1,proxy_wrapper_1=proxyWrapper;let ortInit;const getLogLevel=n=>{switch(n){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: ${n}`)}};class OnnxruntimeWebAssemblySessionHandler{async loadModel(e,r){ortInit||(await proxy_wrapper_1.initOrt(onnxruntime_common_1.env.wasm.numThreads,getLogLevel(onnxruntime_common_1.env.logLevel)),ortInit=!0),[this.sessionId,this.inputNames,this.outputNames]=await proxy_wrapper_1.createSession(e,r)}async dispose(){return proxy_wrapper_1.releaseSession(this.sessionId)}async run(e,r,t){const o=[],i=[];Object.entries(e).forEach(u=>{const c=u[0],f=u[1],d=this.inputNames.indexOf(c);if(d===-1)throw new Error(`invalid input '${c}'`);o.push(f),i.push(d)});const l=[];Object.entries(r).forEach(u=>{const c=u[0],f=this.outputNames.indexOf(c);if(f===-1)throw new Error(`invalid output '${c}'`);l.push(f)});const a=await proxy_wrapper_1.run(this.sessionId,i,o.map(u=>[u.type,u.dims,u.data]),l,t),s={};for(let u=0;u<a.length;u++)s[this.outputNames[l[u]]]=new onnxruntime_common_1.Tensor(a[u][0],a[u][2],a[u][1]);return s}startProfiling(){}endProfiling(){proxy_wrapper_1.endProfiling(this.sessionId)}}sessionHandler.OnnxruntimeWebAssemblySessionHandler=OnnxruntimeWebAssemblySessionHandler;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.wasmBackend=n.initializeFlags=void 0;const e=require$$3$1,r=require$$0$1,t=require$$3$1,o=require$$3$1,i=proxyWrapper,l=sessionHandler,a=()=>{if((typeof r.env.wasm.initTimeout!="number"||r.env.wasm.initTimeout<0)&&(r.env.wasm.initTimeout=0),typeof r.env.wasm.simd!="boolean"&&(r.env.wasm.simd=!0),typeof r.env.wasm.proxy!="boolean"&&(r.env.wasm.proxy=!1),typeof r.env.wasm.numThreads!="number"||!Number.isInteger(r.env.wasm.numThreads)||r.env.wasm.numThreads<=0){const u=typeof navigator=="undefined"?t.cpus().length:navigator.hardwareConcurrency;r.env.wasm.numThreads=Math.min(4,Math.ceil((u||1)/2))}};n.initializeFlags=a;class s{async init(){n.initializeFlags(),await i.initWasm()}async createSessionHandler(c,f){let d;if(typeof c=="string")if(typeof fetch=="undefined")d=await o.promisify(e.readFile)(c);else{const S=await(await fetch(c)).arrayBuffer();d=new Uint8Array(S)}else d=c;const m=new l.OnnxruntimeWebAssemblySessionHandler;return await m.loadModel(d,f),Promise.resolve(m)}}n.wasmBackend=new s})(backendWasm);(function(n){var e=commonjsGlobal$1&&commonjsGlobal$1.__createBinding||(Object.create?function(o,i,l,a){a===void 0&&(a=l),Object.defineProperty(o,a,{enumerable:!0,get:function(){return i[l]}})}:function(o,i,l,a){a===void 0&&(a=l),o[a]=i[l]}),r=commonjsGlobal$1&&commonjsGlobal$1.__exportStar||function(o,i){for(var l in o)l!=="default"&&!Object.prototype.hasOwnProperty.call(i,l)&&e(i,o,l)};Object.defineProperty(n,"__esModule",{value:!0}),r(require$$0$1,n);const t=require$$0$1;{const o=backendOnnxjs.onnxjsBackend;t.registerBackend("webgl",o,-1)}{const o=backendWasm.wasmBackend;t.registerBackend("wasm",o,0)}})(lib$1);class Model{constructor(e,r,t,o,i){this.promises=Promise.all([cv.init(),lib$1.InferenceSession.create(e,r).then(l=>this.session=l)]),typeof t!="undefined"&&t(this),typeof o!="undefined"&&(this.preProcess=o),typeof i!="undefined"&&(this.postProcess=i)}async infer(...e){await this.promises,console.time("Infer"),console.time("Infer.Preprocess");let r=this.preProcess(...e);console.timeEnd("Infer.Preprocess"),console.time("Infer.Run");let t=await this.session.run(r);console.timeEnd("Infer.Run"),console.time("Infer.Postprocess");let o=this.postProcess(t,...e);return console.timeEnd("Infer.Postprocess"),console.timeEnd("Infer"),o}}class CV extends Model{constructor(e,r,t,o,i){super(e,t,void 0,void 0,i),this.loadConfigs(r),typeof o!="undefined"&&(this.getFeeds=o)}loadConfigs(e){let r=JSON.parse(WebAI.loadText(e)),t=r.Preprocess;this.isPermute=!1,this.isCrop=!1,this.isResize=!1;for(let o=0;o<t.length;o++){let i=t[o];if(i.type=="Decode"){if(this.mode=i.mode,!(this.mode=="RGB"||this.mode=="BGR"))throw`Not support ${i.mode} mode.`}else if(i.type=="Resize")this.isResize=!0,this.interp=i.interp,this.keepRatio=i.keep_ratio,this.targetSize=i.target_size,this.limitMax=i.limit_max;else if(i.type=="Normalize")this.isScale=i.is_scale,this.isScale&&(this.scale=new cv.Scalar(255,255,255)),this.mean=new cv.Scalar(...i.mean),this.std=new cv.Scalar(...i.std);else if(i.type=="Crop")this.isCrop=!0,this.cropSize=i.crop_size;else if(i.type=="Permute")this.isPermute=!0;else throw`Not support ${i.type} OP.`}r.hasOwnProperty("label_list")&&(this.labelList=r.label_list,this.colorMap=WebAI.getColorMap(this.labelList)),console.info("model info: ",{mode:this.mode,isResize:this.isResize,interp:this.interp,keepRatio:this.keepRatio,targetSize:this.targetSize,isScale:this.isScale,limitMax:this.limitMax,mean:this.mean,std:this.std,isCrop:this.isCrop,cropSize:this.cropSize,isPermute:this.isPermute,labelList:this.labelList})}preProcess(...e){let[r,t,o]=e.slice(0,3),i,l,a;this.isResize?[i,l,a]=WebAI.resize(r,t,o,this.targetSize,this.keepRatio,this.limitMax,this.interp):i=r.clone();let s;if(this.isCrop){let m=WebAI.crop(i,this.cropSize);this.mode=="RGB"?s=WebAI.rgba2rgb(m):this.mode=="BGR"&&(s=WebAI.rgba2bgr(m)),m.delete()}else this.mode=="RGB"?s=WebAI.rgba2rgb(i):this.mode=="BGR"&&(s=WebAI.rgba2bgr(i)),i.delete();let u=WebAI.normalize(s,this.scale,this.mean,this.std,this.isScale),c,[f,d]=[u.rows,u.cols];return this.isPermute?c=new lib$1.Tensor("float32",WebAI.permute(u),[1,3,f,d]):(c=new lib$1.Tensor("float32",u.data32F,[1,f,d,3]),u.delete()),this.getFeeds(c,l,a)}}class Det extends CV{getFeeds(e,r,t){let o=this.session.inputNames,i={im_shape:new lib$1.Tensor("float32",Float32Array.from(e.dims.slice(2,4)),[1,2]),image:e,scale_factor:new lib$1.Tensor("float32",Float32Array.from([t,r]),[1,2])},l={};return o.forEach(a=>{l[a]=i[a]}),l}postProcess(e,...r){let[t,o,i]=r.slice(1,4),l=Object.values(e)[0],a=[],s=l.dims[0],u=l.data;for(let c=0;c<s;c++){let f=u[c*6+0],d=u[c*6+1],m=Math.max(0,Math.round(u[c*6+2])),_=Math.max(0,Math.round(u[c*6+3])),S=Math.min(o,Math.round(u[c*6+4])),E=Math.min(t,Math.round(u[c*6+5])),$=this.labelList[f],y=this.colorMap[f].color;if(d>i){let v={label:$,color:y,score:d,x1:m,y1:_,x2:S,y2:E};a.push(v)}}return a}infer(e,r=.5){return super.infer(e,e.rows,e.cols,r)}}class Cls extends CV{getFeeds(e){return{x:e}}postProcess(e,...r){let t=r[3],i=Object.values(e)[0].data,l=[];for(let a=0;a<this.labelList.length;a++)l.push({label:this.labelList[a],prob:i[a]});return t>0?l.sort((a,s)=>s.prob-a.prob).slice(0,t):l.sort((a,s)=>s.prob-a.prob)}infer(e,r=5){return super.infer(e,e.rows,e.cols,r)}}class Seg extends CV{getFeeds(e){return{x:e}}postProcess(e){let r=Object.values(e)[0],t=r.data,[o,i,l,a]=r.dims,s=l*a,u=[];for(let m=0;m<i;m++)u.push(t.slice(m*s,(m+1)*s));let c=[],f=[],d;for(let m=0;m<s;m++){let _=[];for(let S=0;S<i;S++)_.push(u[S][m]);d=WebAI.argmax(_),f.push(d),c.push(...this.colorMap[d].color)}return{gray:cv.matFromArray(l,a,cv.CV_8UC1,f),colorRGBA:cv.matFromArray(l,a,cv.CV_8UC4,c),colorMap:this.colorMap,delete:function(){this.gray.isDeleted()||this.gray.delete(),this.colorRGBA.isDeleted()||this.colorRGBA.delete()}}}infer(e){return super.infer(e,e.rows,e.cols)}}const WebAI={argmax(n){let e=Math.max.apply(null,n);return n.findIndex(function(t){return t==e})},getIMScale(n,e,r,t,o){let i,l;if(t){let a=Math.min(n,e),u=Math.min(r[0],r[1])/a;if(o){let c=Math.max(n,e),f=Math.max(r[0],r[1]);Math.round(u*c)>f&&(u=f/c)}i=u,l=u}else l=r[0]/n,i=r[1]/e;return[i,l]},rgba2rgb(n){let e=new cv.Mat;return cv.cvtColor(n,e,cv.COLOR_RGBA2RGB),e},rgba2bgr(n){let e=new cv.Mat;return cv.cvtColor(n,e,cv.COLOR_RGBA2BGR),e},resize(n,e,r,t,o,i,l){let[a,s]=WebAI.getIMScale(e,r,t,o,i),u=new cv.Mat;return cv.resize(n,u,new cv.Size(0,0),a,s,l),[u,a,s]},crop(n,e){let r=n.roi(new cv.Rect(Math.ceil((n.cols-e[1])/2),Math.ceil((n.rows-e[0])/2),e[1],e[0]));return n.delete(),r},normalize(n,e,r,t,o){if(n.convertTo(n,cv.CV_32F),o){let a=new cv.Mat(n.rows,n.cols,cv.CV_32FC3,e);cv.divide(n,a,n),a.delete()}let i=new cv.Mat(n.rows,n.cols,cv.CV_32FC3,r);cv.subtract(n,i,n),i.delete();let l=new cv.Mat(n.rows,n.cols,cv.CV_32FC3,t);return cv.divide(n,l,n),l.delete(),n},permute(n){let e=new cv.MatVector;cv.split(n,e);let r=e.get(0),t=e.get(1),o=e.get(2);e.delete();let i=new Float32Array(r.data32F.length*3);return i.set(r.data32F,0),i.set(t.data32F,r.data32F.length),i.set(o.data32F,r.data32F.length*2),r.delete(),t.delete(),o.delete(),n.delete(),i},loadText(n){let e=new XMLHttpRequest;return e.open("get",n,!1),e.send(null),e.responseText},getColorMap(n){let e=n.length,r=[],t=Math.ceil(256*256*256/e);for(let o=0;o<e;o++){let i=(t*o).toString(16),l=[];for(let a=0;a<6;a+=2){let s=i.slice(a,a+2);s==""?l.push(0):l.push(parseInt("0x"+s))}l.push(255),r.push({label:n[o],color:l})}return r},drawBBoxes(n,e,r=!0,t=!0,o=2,i=8,l=0,a=.7){let s=n.clone();for(let u=0;u<e.length;u++){let c=e[u];cv.rectangle(s,new cv.Point(c.x1,c.y1),new cv.Point(c.x2,c.y2),c.color,o,i),r&&t?cv.putText(s,`${c.label} ${(c.score*100).toFixed(2)}%`,new cv.Point(c.x1,c.y2),l,a,c.color,o,i):r?cv.putText(s,`${c.label}`,new cv.Point(c.x1,c.y2),l,a,c.color,o,i):t&&cv.putText(s,`${(c.score*100).toFixed(2)}%`,new cv.Point(c.x1,c.y2),l,a,c.color,o,i)}return s},Model,CV,Det,Cls,Seg};var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function commonjsRequire(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Pattern$5;Pattern$5=function(){n.prototype.regex=null,n.prototype.rawRegex=null,n.prototype.cleanedRegex=null,n.prototype.mapping=null;function n(e,r){var t,o,i,l,a,s,u,c,f;for(r==null&&(r=""),i="",a=e.length,s=null,o=0,l=0;l<a;){if(t=e.charAt(l),t==="\\")i+=e.slice(l,+(l+1)+1||9e9),l++;else if(t==="(")if(l<a-2)if(c=e.slice(l,+(l+2)+1||9e9),c==="(?:")l+=2,i+=c;else if(c==="(?<")for(o++,l+=2,u="";l+1<a;){if(f=e.charAt(l+1),f===">"){i+="(",l++,u.length>0&&(s==null&&(s={}),s[u]=o);break}else u+=f;l++}else i+=t,o++;else i+=t;else i+=t;l++}this.rawRegex=e,this.cleanedRegex=i,this.regex=new RegExp(this.cleanedRegex,"g"+r.replace("g","")),this.mapping=s}return n.prototype.exec=function(e){var r,t,o,i;if(this.regex.lastIndex=0,t=this.regex.exec(e),t==null)return null;if(this.mapping!=null){i=this.mapping;for(o in i)r=i[o],t[o]=t[r]}return t},n.prototype.test=function(e){return this.regex.lastIndex=0,this.regex.test(e)},n.prototype.replace=function(e,r){return this.regex.lastIndex=0,e.replace(this.regex,r)},n.prototype.replaceAll=function(e,r,t){var o;for(t==null&&(t=0),this.regex.lastIndex=0,o=0;this.regex.test(e)&&(t===0||o<t);)this.regex.lastIndex=0,e=e.replace(this.regex,r),o++;return[e,o]},n}();var Pattern_1=Pattern$5,Pattern$4,Utils$5,hasProp$3={}.hasOwnProperty;Pattern$4=Pattern_1;Utils$5=function(){function n(){}return n.REGEX_LEFT_TRIM_BY_CHAR={},n.REGEX_RIGHT_TRIM_BY_CHAR={},n.REGEX_SPACES=/\s+/g,n.REGEX_DIGITS=/^\d+$/,n.REGEX_OCTAL=/[^0-7]/gi,n.REGEX_HEXADECIMAL=/[^a-f0-9]/gi,n.PATTERN_DATE=new Pattern$4("^(?<year>[0-9][0-9][0-9][0-9])-(?<month>[0-9][0-9]?)-(?<day>[0-9][0-9]?)(?:(?:[Tt]|[ ]+)(?<hour>[0-9][0-9]?):(?<minute>[0-9][0-9]):(?<second>[0-9][0-9])(?:.(?<fraction>[0-9]*))?(?:[ ]*(?<tz>Z|(?<tz_sign>[-+])(?<tz_hour>[0-9][0-9]?)(?::(?<tz_minute>[0-9][0-9]))?))?)?$","i"),n.LOCAL_TIMEZONE_OFFSET=new Date().getTimezoneOffset()*60*1e3,n.trim=function(e,r){var t,o;return r==null&&(r="\\s"),t=this.REGEX_LEFT_TRIM_BY_CHAR[r],t==null&&(this.REGEX_LEFT_TRIM_BY_CHAR[r]=t=new RegExp("^"+r+r+"*")),t.lastIndex=0,o=this.REGEX_RIGHT_TRIM_BY_CHAR[r],o==null&&(this.REGEX_RIGHT_TRIM_BY_CHAR[r]=o=new RegExp(r+""+r+"*$")),o.lastIndex=0,e.replace(t,"").replace(o,"")},n.ltrim=function(e,r){var t;return r==null&&(r="\\s"),t=this.REGEX_LEFT_TRIM_BY_CHAR[r],t==null&&(this.REGEX_LEFT_TRIM_BY_CHAR[r]=t=new RegExp("^"+r+r+"*")),t.lastIndex=0,e.replace(t,"")},n.rtrim=function(e,r){var t;return r==null&&(r="\\s"),t=this.REGEX_RIGHT_TRIM_BY_CHAR[r],t==null&&(this.REGEX_RIGHT_TRIM_BY_CHAR[r]=t=new RegExp(r+""+r+"*$")),t.lastIndex=0,e.replace(t,"")},n.isEmpty=function(e){return!e||e===""||e==="0"||e instanceof Array&&e.length===0||this.isEmptyObject(e)},n.isEmptyObject=function(e){var r;return e instanceof Object&&function(){var t;t=[];for(r in e)!hasProp$3.call(e,r)||t.push(r);return t}().length===0},n.subStrCount=function(e,r,t,o){var i,l,a,s,u,c;for(i=0,e=""+e,r=""+r,t!=null&&(e=e.slice(t)),o!=null&&(e=e.slice(0,o)),s=e.length,c=r.length,l=a=0,u=s;0<=u?a<u:a>u;l=0<=u?++a:--a)r===e.slice(l,c)&&(i++,l+=c-1);return i},n.isDigits=function(e){return this.REGEX_DIGITS.lastIndex=0,this.REGEX_DIGITS.test(e)},n.octDec=function(e){return this.REGEX_OCTAL.lastIndex=0,parseInt((e+"").replace(this.REGEX_OCTAL,""),8)},n.hexDec=function(e){return this.REGEX_HEXADECIMAL.lastIndex=0,e=this.trim(e),(e+"").slice(0,2)==="0x"&&(e=(e+"").slice(2)),parseInt((e+"").replace(this.REGEX_HEXADECIMAL,""),16)},n.utf8chr=function(e){var r;return r=String.fromCharCode,128>(e%=2097152)?r(e):2048>e?r(192|e>>6)+r(128|e&63):65536>e?r(224|e>>12)+r(128|e>>6&63)+r(128|e&63):r(240|e>>18)+r(128|e>>12&63)+r(128|e>>6&63)+r(128|e&63)},n.parseBoolean=function(e,r){var t;return r==null&&(r=!0),typeof e=="string"?(t=e.toLowerCase(),!(!r&&t==="no"||t==="0"||t==="false"||t==="")):!!e},n.isNumeric=function(e){return this.REGEX_SPACES.lastIndex=0,typeof e=="number"||typeof e=="string"&&!isNaN(e)&&e.replace(this.REGEX_SPACES,"")!==""},n.stringToDate=function(e){var r,t,o,i,l,a,s,u,c,f,d,m;if(!(e!=null&&e.length)||(l=this.PATTERN_DATE.exec(e),!l))return null;if(m=parseInt(l.year,10),s=parseInt(l.month,10)-1,t=parseInt(l.day,10),l.hour==null)return r=new Date(Date.UTC(m,s,t)),r;if(i=parseInt(l.hour,10),a=parseInt(l.minute,10),u=parseInt(l.second,10),l.fraction!=null){for(o=l.fraction.slice(0,3);o.length<3;)o+="0";o=parseInt(o,10)}else o=0;return l.tz!=null&&(c=parseInt(l.tz_hour,10),l.tz_minute!=null?f=parseInt(l.tz_minute,10):f=0,d=(c*60+f)*6e4,l.tz_sign==="-"&&(d*=-1)),r=new Date(Date.UTC(m,s,t,i,a,u,o)),d&&r.setTime(r.getTime()-d),r},n.strRepeat=function(e,r){var t,o;for(o="",t=0;t<r;)o+=e,t++;return o},n.getStringFromFile=function(e,r){var t,o,i,l,a,s,u,c;if(r==null&&(r=null),c=null,typeof window!="undefined"&&window!==null){if(window.XMLHttpRequest)c=new XMLHttpRequest;else if(window.ActiveXObject)for(s=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"],i=0,l=s.length;i<l;i++){a=s[i];try{c=new ActiveXObject(a)}catch{}}}return c!=null?r!=null?(c.onreadystatechange=function(){if(c.readyState===4)return c.status===200||c.status===0?r(c.responseText):r(null)},c.open("GET",e,!0),c.send(null)):(c.open("GET",e,!1),c.send(null),c.status===200||c.status===0?c.responseText:null):(u=commonjsRequire,o=u("fs"),r!=null?o.readFile(e,function(f,d){return r(f?null:String(d))}):(t=o.readFileSync(e),t!=null?String(t):null))},n}();var Utils_1=Utils$5,Pattern$3,Unescaper$1,Utils$4;Utils$4=Utils_1;Pattern$3=Pattern_1;Unescaper$1=function(){function n(){}return n.PATTERN_ESCAPED_CHARACTER=new Pattern$3('\\\\([0abt nvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})'),n.unescapeSingleQuotedString=function(e){return e.replace(/\'\'/g,"'")},n.unescapeDoubleQuotedString=function(e){return this._unescapeCallback==null&&(this._unescapeCallback=function(r){return function(t){return r.unescapeCharacter(t)}}(this)),this.PATTERN_ESCAPED_CHARACTER.replace(e,this._unescapeCallback)},n.unescapeCharacter=function(e){var r;switch(r=String.fromCharCode,e.charAt(1)){case"0":return r(0);case"a":return r(7);case"b":return r(8);case"t":return" ";case" ":return" ";case"n":return`
- `;case"v":return r(11);case"f":return r(12);case"r":return r(13);case"e":return r(27);case" ":return" ";case'"':return'"';case"/":return"/";case"\\":return"\\";case"N":return r(133);case"_":return r(160);case"L":return r(8232);case"P":return r(8233);case"x":return Utils$4.utf8chr(Utils$4.hexDec(e.substr(2,2)));case"u":return Utils$4.utf8chr(Utils$4.hexDec(e.substr(2,4)));case"U":return Utils$4.utf8chr(Utils$4.hexDec(e.substr(2,8)));default:return""}},n}();var Unescaper_1=Unescaper$1,Escaper$1,Pattern$2;Pattern$2=Pattern_1;Escaper$1=function(){var n;function e(){}return e.LIST_ESCAPEES=["\\","\\\\",'\\"','"',"\0","","","","","","","\x07","\b"," ",`
- `,"\v","\f","\r","","","","","","","","","","","","","","\x1B","","","","",(n=String.fromCharCode)(133),n(160),n(8232),n(8233)],e.LIST_ESCAPED=["\\\\",'\\"','\\"','\\"',"\\0","\\x01","\\x02","\\x03","\\x04","\\x05","\\x06","\\a","\\b","\\t","\\n","\\v","\\f","\\r","\\x0e","\\x0f","\\x10","\\x11","\\x12","\\x13","\\x14","\\x15","\\x16","\\x17","\\x18","\\x19","\\x1a","\\e","\\x1c","\\x1d","\\x1e","\\x1f","\\N","\\_","\\L","\\P"],e.MAPPING_ESCAPEES_TO_ESCAPED=function(){var r,t,o,i;for(o={},r=t=0,i=e.LIST_ESCAPEES.length;0<=i?t<i:t>i;r=0<=i?++t:--t)o[e.LIST_ESCAPEES[r]]=e.LIST_ESCAPED[r];return o}(),e.PATTERN_CHARACTERS_TO_ESCAPE=new Pattern$2("[\\x00-\\x1f]|\xC2\x85|\xC2\xA0|\xE2\x80\xA8|\xE2\x80\xA9"),e.PATTERN_MAPPING_ESCAPEES=new Pattern$2(e.LIST_ESCAPEES.join("|").split("\\").join("\\\\")),e.PATTERN_SINGLE_QUOTING=new Pattern$2("[\\s'\":{}[\\],&*#?]|^[-?|<>=!%@`]"),e.requiresDoubleQuoting=function(r){return this.PATTERN_CHARACTERS_TO_ESCAPE.test(r)},e.escapeWithDoubleQuotes=function(r){var t;return t=this.PATTERN_MAPPING_ESCAPEES.replace(r,function(o){return function(i){return o.MAPPING_ESCAPEES_TO_ESCAPED[i]}}(this)),'"'+t+'"'},e.requiresSingleQuoting=function(r){return this.PATTERN_SINGLE_QUOTING.test(r)},e.escapeWithSingleQuotes=function(r){return"'"+r.replace(/'/g,"''")+"'"},e}();var Escaper_1=Escaper$1,ParseException$2,extend$2=function(n,e){for(var r in e)hasProp$2.call(e,r)&&(n[r]=e[r]);function t(){this.constructor=n}return t.prototype=e.prototype,n.prototype=new t,n.__super__=e.prototype,n},hasProp$2={}.hasOwnProperty;ParseException$2=function(n){extend$2(e,n);function e(r,t,o){this.message=r,this.parsedLine=t,this.snippet=o}return e.prototype.toString=function(){return this.parsedLine!=null&&this.snippet!=null?"<ParseException> "+this.message+" (line "+this.parsedLine+": '"+this.snippet+"')":"<ParseException> "+this.message},e}(Error);var ParseException_1=ParseException$2,ParseMore$2,extend$1=function(n,e){for(var r in e)hasProp$1.call(e,r)&&(n[r]=e[r]);function t(){this.constructor=n}return t.prototype=e.prototype,n.prototype=new t,n.__super__=e.prototype,n},hasProp$1={}.hasOwnProperty;ParseMore$2=function(n){extend$1(e,n);function e(r,t,o){this.message=r,this.parsedLine=t,this.snippet=o}return e.prototype.toString=function(){return this.parsedLine!=null&&this.snippet!=null?"<ParseMore> "+this.message+" (line "+this.parsedLine+": '"+this.snippet+"')":"<ParseMore> "+this.message},e}(Error);var ParseMore_1=ParseMore$2,extend=function(n,e){for(var r in e)hasProp.call(e,r)&&(n[r]=e[r]);function t(){this.constructor=n}return t.prototype=e.prototype,n.prototype=new t,n.__super__=e.prototype,n},hasProp={}.hasOwnProperty;(function(n){extend(e,n);function e(r,t,o){this.message=r,this.parsedLine=t,this.snippet=o}return e.prototype.toString=function(){return this.parsedLine!=null&&this.snippet!=null?"<DumpException> "+this.message+" (line "+this.parsedLine+": '"+this.snippet+"')":"<DumpException> "+this.message},e})(Error);var Escaper,Inline$2,ParseException$1,ParseMore$1,Pattern$1,Unescaper,Utils$3,indexOf=[].indexOf||function(n){for(var e=0,r=this.length;e<r;e++)if(e in this&&this[e]===n)return e;return-1};Pattern$1=Pattern_1;Unescaper=Unescaper_1;Escaper=Escaper_1;Utils$3=Utils_1;ParseException$1=ParseException_1;ParseMore$1=ParseMore_1;Inline$2=function(){function n(){}return n.REGEX_QUOTED_STRING=`(?:"(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|'(?:[^']*(?:''[^']*)*)')`,n.PATTERN_TRAILING_COMMENTS=new Pattern$1("^\\s*#.*$"),n.PATTERN_QUOTED_SCALAR=new Pattern$1("^"+n.REGEX_QUOTED_STRING),n.PATTERN_THOUSAND_NUMERIC_SCALAR=new Pattern$1("^(-|\\+)?[0-9,]+(\\.[0-9]+)?$"),n.PATTERN_SCALAR_BY_DELIMITERS={},n.settings={},n.configure=function(e,r){e==null&&(e=null),r==null&&(r=null),this.settings.exceptionOnInvalidType=e,this.settings.objectDecoder=r},n.parse=function(e,r,t){var o,i;if(r==null&&(r=!1),t==null&&(t=null),this.settings.exceptionOnInvalidType=r,this.settings.objectDecoder=t,e==null||(e=Utils$3.trim(e),e.length===0))return"";switch(o={exceptionOnInvalidType:r,objectDecoder:t,i:0},e.charAt(0)){case"[":i=this.parseSequence(e,o),++o.i;break;case"{":i=this.parseMapping(e,o),++o.i;break;default:i=this.parseScalar(e,null,['"',"'"],o)}if(this.PATTERN_TRAILING_COMMENTS.replace(e.slice(o.i),"")!=="")throw new ParseException$1('Unexpected characters near "'+e.slice(o.i)+'".');return i},n.dump=function(e,r,t){var o,i,l;return t==null&&(t=null),e==null?"null":(l=typeof e,l==="object"?e instanceof Date?e.toISOString():t!=null&&(i=t(e),typeof i=="string"||i!=null)?i:this.dumpObject(e):l==="boolean"?e?"true":"false":Utils$3.isDigits(e)?l==="string"?"'"+e+"'":String(parseInt(e)):Utils$3.isNumeric(e)?l==="string"?"'"+e+"'":String(parseFloat(e)):l==="number"?e===1/0?".Inf":e===-1/0?"-.Inf":isNaN(e)?".NaN":e:Escaper.requiresDoubleQuoting(e)?Escaper.escapeWithDoubleQuotes(e):Escaper.requiresSingleQuoting(e)?Escaper.escapeWithSingleQuotes(e):e===""?'""':Utils$3.PATTERN_DATE.test(e)||(o=e.toLowerCase())==="null"||o==="~"||o==="true"||o==="false"?"'"+e+"'":e)},n.dumpObject=function(e,r,t){var o,i,l,a,s;if(e instanceof Array){for(a=[],o=0,l=e.length;o<l;o++)s=e[o],a.push(this.dump(s));return"["+a.join(", ")+"]"}else{a=[];for(i in e)s=e[i],a.push(this.dump(i)+": "+this.dump(s));return"{"+a.join(", ")+"}"}},n.parseScalar=function(e,r,t,o,i){var l,a,s,u,c,f,d,m,_;if(r==null&&(r=null),t==null&&(t=['"',"'"]),o==null&&(o=null),i==null&&(i=!0),o==null&&(o={exceptionOnInvalidType:this.settings.exceptionOnInvalidType,objectDecoder:this.settings.objectDecoder,i:0}),l=o.i,f=e.charAt(l),indexOf.call(t,f)>=0){if(u=this.parseQuotedScalar(e,o),l=o.i,r!=null&&(_=Utils$3.ltrim(e.slice(l)," "),d=_.charAt(0),!(indexOf.call(r,d)>=0)))throw new ParseException$1("Unexpected characters ("+e.slice(l)+").")}else{if(!r)u=e.slice(l),l+=u.length,m=u.indexOf(" #"),m!==-1&&(u=Utils$3.rtrim(u.slice(0,m)));else if(a=r.join("|"),c=this.PATTERN_SCALAR_BY_DELIMITERS[a],c==null&&(c=new Pattern$1("^(.+?)("+a+")"),this.PATTERN_SCALAR_BY_DELIMITERS[a]=c),s=c.exec(e.slice(l)))u=s[1],l+=u.length;else throw new ParseException$1("Malformed inline YAML string ("+e+").");i&&(u=this.evaluateScalar(u,o))}return o.i=l,u},n.parseQuotedScalar=function(e,r){var t,o,i;if(t=r.i,!(o=this.PATTERN_QUOTED_SCALAR.exec(e.slice(t))))throw new ParseMore$1("Malformed inline YAML string ("+e.slice(t)+").");return i=o[0].substr(1,o[0].length-2),e.charAt(t)==='"'?i=Unescaper.unescapeDoubleQuotedString(i):i=Unescaper.unescapeSingleQuotedString(i),t+=o[0].length,r.i=t,i},n.parseSequence=function(e,r){var t,o,i,l,a,s;for(l=[],i=e.length,t=r.i,t+=1;t<i;){switch(r.i=t,e.charAt(t)){case"[":l.push(this.parseSequence(e,r)),t=r.i;break;case"{":l.push(this.parseMapping(e,r)),t=r.i;break;case"]":return l;case",":case" ":case`
- `:break;default:if(o=(a=e.charAt(t))==='"'||a==="'",s=this.parseScalar(e,[",","]"],['"',"'"],r),t=r.i,!o&&typeof s=="string"&&(s.indexOf(": ")!==-1||s.indexOf(`:
- `)!==-1))try{s=this.parseMapping("{"+s+"}")}catch{}l.push(s),--t}++t}throw new ParseMore$1("Malformed inline YAML string "+e)},n.parseMapping=function(e,r){var t,o,i,l,a,s,u;for(a={},l=e.length,o=r.i,o+=1,s=!1;o<l;){switch(r.i=o,e.charAt(o)){case" ":case",":case`
- `:++o,r.i=o,s=!0;break;case"}":return a}if(s){s=!1;continue}for(i=this.parseScalar(e,[":"," ",`
- `],['"',"'"],r,!1),o=r.i,t=!1;o<l;){switch(r.i=o,e.charAt(o)){case"[":u=this.parseSequence(e,r),o=r.i,a[i]===void 0&&(a[i]=u),t=!0;break;case"{":u=this.parseMapping(e,r),o=r.i,a[i]===void 0&&(a[i]=u),t=!0;break;case":":case" ":case`
- `:break;default:u=this.parseScalar(e,[",","}"],['"',"'"],r),o=r.i,a[i]===void 0&&(a[i]=u),t=!0,--o}if(++o,t)break}}throw new ParseMore$1("Malformed inline YAML string "+e)},n.evaluateScalar=function(e,r){var t,o,i,l,a,s,u,c,f,d,m;switch(e=Utils$3.trim(e),f=e.toLowerCase(),f){case"null":case"":case"~":return null;case"true":return!0;case"false":return!1;case".inf":return 1/0;case".nan":return 0/0;case"-.inf":return 1/0;default:switch(l=f.charAt(0),l){case"!":switch(a=e.indexOf(" "),a===-1?s=f:s=f.slice(0,a),s){case"!":return a!==-1?parseInt(this.parseScalar(e.slice(2))):null;case"!str":return Utils$3.ltrim(e.slice(4));case"!!str":return Utils$3.ltrim(e.slice(5));case"!!int":return parseInt(this.parseScalar(e.slice(5)));case"!!bool":return Utils$3.parseBoolean(this.parseScalar(e.slice(6)),!1);case"!!float":return parseFloat(this.parseScalar(e.slice(7)));case"!!timestamp":return Utils$3.stringToDate(Utils$3.ltrim(e.slice(11)));default:if(r==null&&(r={exceptionOnInvalidType:this.settings.exceptionOnInvalidType,objectDecoder:this.settings.objectDecoder,i:0}),u=r.objectDecoder,i=r.exceptionOnInvalidType,u)return m=Utils$3.rtrim(e),a=m.indexOf(" "),a===-1?u(m,null):(d=Utils$3.ltrim(m.slice(a+1)),d.length>0||(d=null),u(m.slice(0,a),d));if(i)throw new ParseException$1("Custom object support when parsing a YAML file has been disabled.");return null}case"0":return e.slice(0,2)==="0x"?Utils$3.hexDec(e):Utils$3.isDigits(e)?Utils$3.octDec(e):Utils$3.isNumeric(e)?parseFloat(e):e;case"+":return Utils$3.isDigits(e)?(c=e,t=parseInt(c),c===String(t)?t:c):Utils$3.isNumeric(e)?parseFloat(e):this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(e)?parseFloat(e.replace(",","")):e;case"-":return Utils$3.isDigits(e.slice(1))?e.charAt(1)==="0"?-Utils$3.octDec(e.slice(1)):(c=e.slice(1),t=parseInt(c),c===String(t)?-t:-c):Utils$3.isNumeric(e)?parseFloat(e):this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(e)?parseFloat(e.replace(",","")):e;default:return(o=Utils$3.stringToDate(e))?o:Utils$3.isNumeric(e)?parseFloat(e):this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(e)?parseFloat(e.replace(",","")):e}}},n}();var Inline_1=Inline$2,Inline$1,ParseException,ParseMore,Parser$1,Pattern,Utils$2;Inline$1=Inline_1;Pattern=Pattern_1;Utils$2=Utils_1;ParseException=ParseException_1;ParseMore=ParseMore_1;Parser$1=function(){n.prototype.PATTERN_FOLDED_SCALAR_ALL=new Pattern("^(?:(?<type>![^\\|>]*)\\s+)?(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$"),n.prototype.PATTERN_FOLDED_SCALAR_END=new Pattern("(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$"),n.prototype.PATTERN_SEQUENCE_ITEM=new Pattern("^\\-((?<leadspaces>\\s+)(?<value>.+?))?\\s*$"),n.prototype.PATTERN_ANCHOR_VALUE=new Pattern("^&(?<ref>[^ ]+) *(?<value>.*)"),n.prototype.PATTERN_COMPACT_NOTATION=new Pattern("^(?<key>"+Inline$1.REGEX_QUOTED_STRING+`|[^ '"\\{\\[].*?) *\\:(\\s+(?<value>.+?))?\\s*$`),n.prototype.PATTERN_MAPPING_ITEM=new Pattern("^(?<key>"+Inline$1.REGEX_QUOTED_STRING+`|[^ '"\\[\\{].*?) *\\:(\\s+(?<value>.+?))?\\s*$`),n.prototype.PATTERN_DECIMAL=new Pattern("\\d+"),n.prototype.PATTERN_INDENT_SPACES=new Pattern("^ +"),n.prototype.PATTERN_TRAILING_LINES=new Pattern(`(
- *)$`),n.prototype.PATTERN_YAML_HEADER=new Pattern(`^\\%YAML[: ][\\d\\.]+.*
- `,"m"),n.prototype.PATTERN_LEADING_COMMENTS=new Pattern(`^(\\#.*?
- )+`,"m"),n.prototype.PATTERN_DOCUMENT_MARKER_START=new Pattern(`^\\-\\-\\-.*?
- `,"m"),n.prototype.PATTERN_DOCUMENT_MARKER_END=new Pattern("^\\.\\.\\.\\s*$","m"),n.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION={},n.prototype.CONTEXT_NONE=0,n.prototype.CONTEXT_SEQUENCE=1,n.prototype.CONTEXT_MAPPING=2;function n(e){this.offset=e!=null?e:0,this.lines=[],this.currentLineNb=-1,this.currentLine="",this.refs={}}return n.prototype.parse=function(e,r,t){var o,i,l,a,s,u,c,f,d,m,_,S,E,$,y,v,A,P,C,L,B,V,j,U,re,Z,ee,X,J,ae,de,M,we,le,me,Y;for(r==null&&(r=!1),t==null&&(t=null),this.currentLineNb=-1,this.currentLine="",this.lines=this.cleanup(e).split(`
- `),u=null,s=this.CONTEXT_NONE,i=!1;this.moveToNextLine();)if(!this.isCurrentLineEmpty()){if(this.currentLine[0]===" ")throw new ParseException("A YAML file cannot contain tabs as indentation.",this.getRealCurrentLineNb()+1,this.currentLine);if(_=U=!1,Y=this.PATTERN_SEQUENCE_ITEM.exec(this.currentLine)){if(this.CONTEXT_MAPPING===s)throw new ParseException("You cannot define a sequence item when in a mapping");s=this.CONTEXT_SEQUENCE,u==null&&(u=[]),Y.value!=null&&(j=this.PATTERN_ANCHOR_VALUE.exec(Y.value))&&(_=j.ref,Y.value=j.value),Y.value==null||Utils$2.trim(Y.value," ")===""||Utils$2.ltrim(Y.value," ").indexOf("#")===0?this.currentLineNb<this.lines.length-1&&!this.isNextLineUnIndentedCollection()?(a=this.getRealCurrentLineNb()+1,J=new n(a),J.refs=this.refs,u.push(J.parse(this.getNextEmbedBlock(null,!0),r,t))):u.push(null):((ae=Y.leadspaces)!=null?ae.length:void 0)&&(j=this.PATTERN_COMPACT_NOTATION.exec(Y.value))?(a=this.getRealCurrentLineNb(),J=new n(a),J.refs=this.refs,l=Y.value,m=this.getCurrentLineIndentation(),this.isNextLineIndented(!1)&&(l+=`
- `+this.getNextEmbedBlock(m+Y.leadspaces.length+1,!0)),u.push(J.parse(l,r,t))):u.push(this.parseValue(Y.value,r,t))}else if((Y=this.PATTERN_MAPPING_ITEM.exec(this.currentLine))&&Y.key.indexOf(" #")===-1){if(this.CONTEXT_SEQUENCE===s)throw new ParseException("You cannot define a mapping item when in a sequence");s=this.CONTEXT_MAPPING,u==null&&(u={}),Inline$1.configure(r,t);try{$=Inline$1.parseScalar(Y.key)}catch(ie){throw c=ie,c.parsedLine=this.getRealCurrentLineNb()+1,c.snippet=this.currentLine,c}if($==="<<")if(U=!0,i=!0,((de=Y.value)!=null?de.indexOf("*"):void 0)===0){if(we=Y.value.slice(1),this.refs[we]==null)throw new ParseException('Reference "'+we+'" does not exist.',this.getRealCurrentLineNb()+1,this.currentLine);if(le=this.refs[we],typeof le!="object")throw new ParseException("YAML merge keys used with a scalar value instead of an object.",this.getRealCurrentLineNb()+1,this.currentLine);if(le instanceof Array)for(d=S=0,A=le.length;S<A;d=++S)e=le[d],u[Z=String(d)]==null&&(u[Z]=e);else for($ in le)e=le[$],u[$]==null&&(u[$]=e)}else{if(Y.value!=null&&Y.value!==""?e=Y.value:e=this.getNextEmbedBlock(),a=this.getRealCurrentLineNb()+1,J=new n(a),J.refs=this.refs,ee=J.parse(e,r),typeof ee!="object")throw new ParseException("YAML merge keys used with a scalar value instead of an object.",this.getRealCurrentLineNb()+1,this.currentLine);if(ee instanceof Array)for(y=0,P=ee.length;y<P;y++){if(X=ee[y],typeof X!="object")throw new ParseException("Merge items must be objects.",this.getRealCurrentLineNb()+1,X);if(X instanceof Array)for(d=V=0,C=X.length;V<C;d=++V)e=X[d],E=String(d),u.hasOwnProperty(E)||(u[E]=e);else for($ in X)e=X[$],u.hasOwnProperty($)||(u[$]=e)}else for($ in ee)e=ee[$],u.hasOwnProperty($)||(u[$]=e)}else Y.value!=null&&(j=this.PATTERN_ANCHOR_VALUE.exec(Y.value))&&(_=j.ref,Y.value=j.value);U||(Y.value==null||Utils$2.trim(Y.value," ")===""||Utils$2.ltrim(Y.value," ").indexOf("#")===0?!this.isNextLineIndented()&&!this.isNextLineUnIndentedCollection()?(i||u[$]===void 0)&&(u[$]=null):(a=this.getRealCurrentLineNb()+1,J=new n(a),J.refs=this.refs,me=J.parse(this.getNextEmbedBlock(),r,t),(i||u[$]===void 0)&&(u[$]=me)):(me=this.parseValue(Y.value,r,t),(i||u[$]===void 0)&&(u[$]=me)))}else{if(B=this.lines.length,B===1||B===2&&Utils$2.isEmpty(this.lines[1])){try{e=Inline$1.parse(this.lines[0],r,t)}catch(ie){throw c=ie,c.parsedLine=this.getRealCurrentLineNb()+1,c.snippet=this.currentLine,c}if(typeof e=="object"){if(e instanceof Array)f=e[0];else for($ in e){f=e[$];break}if(typeof f=="string"&&f.indexOf("*")===0){for(u=[],re=0,L=e.length;re<L;re++)o=e[re],u.push(this.refs[o.slice(1)]);e=u}}return e}else if((M=Utils$2.ltrim(e).charAt(0))==="["||M==="{")try{return Inline$1.parse(e,r,t)}catch(ie){throw c=ie,c.parsedLine=this.getRealCurrentLineNb()+1,c.snippet=this.currentLine,c}throw new ParseException("Unable to parse.",this.getRealCurrentLineNb()+1,this.currentLine)}if(_)if(u instanceof Array)this.refs[_]=u[u.length-1];else{v=null;for($ in u)v=$;this.refs[_]=u[v]}}return Utils$2.isEmpty(u)?null:u},n.prototype.getRealCurrentLineNb=function(){return this.currentLineNb+this.offset},n.prototype.getCurrentLineIndentation=function(){return this.currentLine.length-Utils$2.ltrim(this.currentLine," ").length},n.prototype.getNextEmbedBlock=function(e,r){var t,o,i,l,a,s,u;if(e==null&&(e=null),r==null&&(r=!1),this.moveToNextLine(),e==null){if(l=this.getCurrentLineIndentation(),u=this.isStringUnIndentedCollectionItem(this.currentLine),!this.isCurrentLineEmpty()&&l===0&&!u)throw new ParseException("Indentation problem.",this.getRealCurrentLineNb()+1,this.currentLine)}else l=e;for(t=[this.currentLine.slice(l)],r||(i=this.isStringUnIndentedCollectionItem(this.currentLine)),s=this.PATTERN_FOLDED_SCALAR_END,a=!s.test(this.currentLine);this.moveToNextLine();)if(o=this.getCurrentLineIndentation(),o===l&&(a=!s.test(this.currentLine)),!(a&&this.isCurrentLineComment())){if(this.isCurrentLineBlank()){t.push(this.currentLine.slice(l));continue}if(i&&!this.isStringUnIndentedCollectionItem(this.currentLine)&&o===l){this.moveToPreviousLine();break}if(o>=l)t.push(this.currentLine.slice(l));else if(Utils$2.ltrim(this.currentLine).charAt(0)!=="#")if(o===0){this.moveToPreviousLine();break}else throw new ParseException("Indentation problem.",this.getRealCurrentLineNb()+1,this.currentLine)}return t.join(`
- `)},n.prototype.moveToNextLine=function(){return this.currentLineNb>=this.lines.length-1?!1:(this.currentLine=this.lines[++this.currentLineNb],!0)},n.prototype.moveToPreviousLine=function(){this.currentLine=this.lines[--this.currentLineNb]},n.prototype.parseValue=function(e,r,t){var o,i,l,a,s,u,c,f;if(e.indexOf("*")===0){if(s=e.indexOf("#"),s!==-1?e=e.substr(1,s-2):e=e.slice(1),this.refs[e]===void 0)throw new ParseException('Reference "'+e+'" does not exist.',this.currentLine);return this.refs[e]}if(l=this.PATTERN_FOLDED_SCALAR_ALL.exec(e))return a=(u=l.modifiers)!=null?u:"",i=Math.abs(parseInt(a)),isNaN(i)&&(i=0),f=this.parseFoldedScalar(l.separator,this.PATTERN_DECIMAL.replace(a,""),i),l.type!=null?(Inline$1.configure(r,t),Inline$1.parseScalar(l.type+" "+f)):f;if((c=e.charAt(0))==="["||c==="{"||c==='"'||c==="'")for(;;)try{return Inline$1.parse(e,r,t)}catch(d){if(o=d,o instanceof ParseMore&&this.moveToNextLine())e+=`
- `+Utils$2.trim(this.currentLine," ");else throw o.parsedLine=this.getRealCurrentLineNb()+1,o.snippet=this.currentLine,o}else return this.isNextLineIndented()&&(e+=`
- `+this.getNextEmbedBlock()),Inline$1.parse(e,r,t)},n.prototype.parseFoldedScalar=function(e,r,t){var o,i,l,a,s,u,c,f,d,m;if(r==null&&(r=""),t==null&&(t=0),c=this.moveToNextLine(),!c)return"";for(o=this.isCurrentLineBlank(),m="";c&&o;)(c=this.moveToNextLine())&&(m+=`
- `,o=this.isCurrentLineBlank());if(t===0&&(s=this.PATTERN_INDENT_SPACES.exec(this.currentLine))&&(t=s[0].length),t>0)for(f=this.PATTERN_FOLDED_SCALAR_BY_INDENTATION[t],f==null&&(f=new Pattern("^ {"+t+"}(.*)$"),n.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION[t]=f);c&&(o||(s=f.exec(this.currentLine)));)o?m+=this.currentLine.slice(t):m+=s[1],(c=this.moveToNextLine())&&(m+=`
- `,o=this.isCurrentLineBlank());else c&&(m+=`
- `);if(c&&this.moveToPreviousLine(),e===">"){for(u="",d=m.split(`
- `),i=0,l=d.length;i<l;i++)a=d[i],a.length===0||a.charAt(0)===" "?u=Utils$2.rtrim(u," ")+a+`
- `:u+=a+" ";m=u}return r!=="+"&&(m=Utils$2.rtrim(m)),r===""?m=this.PATTERN_TRAILING_LINES.replace(m,`
- `):r==="-"&&(m=this.PATTERN_TRAILING_LINES.replace(m,"")),m},n.prototype.isNextLineIndented=function(e){var r,t,o;if(e==null&&(e=!0),t=this.getCurrentLineIndentation(),r=!this.moveToNextLine(),e)for(;!r&&this.isCurrentLineEmpty();)r=!this.moveToNextLine();else for(;!r&&this.isCurrentLineBlank();)r=!this.moveToNextLine();return r?!1:(o=!1,this.getCurrentLineIndentation()>t&&(o=!0),this.moveToPreviousLine(),o)},n.prototype.isCurrentLineEmpty=function(){var e;return e=Utils$2.trim(this.currentLine," "),e.length===0||e.charAt(0)==="#"},n.prototype.isCurrentLineBlank=function(){return Utils$2.trim(this.currentLine," ")===""},n.prototype.isCurrentLineComment=function(){var e;return e=Utils$2.ltrim(this.currentLine," "),e.charAt(0)==="#"},n.prototype.cleanup=function(e){var r,t,o,i,l,a,s,u,c,f,d,m,_,S;for(e.indexOf("\r")!==-1&&(e=e.split(`\r
- `).join(`
- `).split("\r").join(`
- `)),r=0,f=this.PATTERN_YAML_HEADER.replaceAll(e,""),e=f[0],r=f[1],this.offset+=r,d=this.PATTERN_LEADING_COMMENTS.replaceAll(e,"",1),S=d[0],r=d[1],r===1&&(this.offset+=Utils$2.subStrCount(e,`
- `)-Utils$2.subStrCount(S,`
- `),e=S),m=this.PATTERN_DOCUMENT_MARKER_START.replaceAll(e,"",1),S=m[0],r=m[1],r===1&&(this.offset+=Utils$2.subStrCount(e,`
- `)-Utils$2.subStrCount(S,`
- `),e=S,e=this.PATTERN_DOCUMENT_MARKER_END.replace(e,"")),c=e.split(`
- `),_=-1,i=0,a=c.length;i<a;i++)u=c[i],Utils$2.trim(u," ").length!==0&&(o=u.length-Utils$2.ltrim(u).length,(_===-1||o<_)&&(_=o));if(_>0){for(t=l=0,s=c.length;l<s;t=++l)u=c[t],c[t]=u.slice(_);e=c.join(`
- `)}return e},n.prototype.isNextLineUnIndentedCollection=function(e){var r,t;for(e==null&&(e=null),e==null&&(e=this.getCurrentLineIndentation()),r=this.moveToNextLine();r&&this.isCurrentLineEmpty();)r=this.moveToNextLine();return r===!1?!1:(t=!1,this.getCurrentLineIndentation()===e&&this.isStringUnIndentedCollectionItem(this.currentLine)&&(t=!0),this.moveToPreviousLine(),t)},n.prototype.isStringUnIndentedCollectionItem=function(){return this.currentLine==="-"||this.currentLine.slice(0,2)==="- "},n}();var Parser_1=Parser$1,Dumper$1,Inline,Utils$1;Utils$1=Utils_1;Inline=Inline_1;Dumper$1=function(){function n(){}return n.indentation=4,n.prototype.dump=function(e,r,t,o,i){var l,a,s,u,c,f,d;if(r==null&&(r=0),t==null&&(t=0),o==null&&(o=!1),i==null&&(i=null),u="",c=t?Utils$1.strRepeat(" ",t):"",r<=0||typeof e!="object"||e instanceof Date||Utils$1.isEmpty(e))u+=c+Inline.dump(e,o,i);else if(e instanceof Array)for(l=0,s=e.length;l<s;l++)f=e[l],d=r-1<=0||typeof f!="object"||Utils$1.isEmpty(f),u+=c+"-"+(d?" ":`
- `)+this.dump(f,r-1,d?0:t+this.indentation,o,i)+(d?`
- `:"");else for(a in e)f=e[a],d=r-1<=0||typeof f!="object"||Utils$1.isEmpty(f),u+=c+Inline.dump(a,o,i)+":"+(d?" ":`
- `)+this.dump(f,r-1,d?0:t+this.indentation,o,i)+(d?`
- `:"");return u},n}();var Dumper_1=Dumper$1,Dumper,Parser,Utils,Yaml;Parser=Parser_1;Dumper=Dumper_1;Utils=Utils_1;Yaml=function(){function n(){}return n.parse=function(e,r,t){return r==null&&(r=!1),t==null&&(t=null),new Parser().parse(e,r,t)},n.parseFile=function(e,r,t,o){var i;return r==null&&(r=null),t==null&&(t=!1),o==null&&(o=null),r!=null?Utils.getStringFromFile(e,function(l){return function(a){var s;s=null,a!=null&&(s=l.parse(a,t,o)),r(s)}}(this)):(i=Utils.getStringFromFile(e),i!=null?this.parse(i,t,o):null)},n.dump=function(e,r,t,o,i){var l;return r==null&&(r=2),t==null&&(t=4),o==null&&(o=!1),i==null&&(i=null),l=new Dumper,l.indentation=t,l.dump(e,r,0,o,i)},n.stringify=function(e,r,t,o,i){return this.dump(e,r,t,o,i)},n.load=function(e,r,t,o){return this.parseFile(e,r,t,o)},n}();typeof window!="undefined"&&window!==null&&(window.YAML=Yaml);(typeof window=="undefined"||window===null)&&(commonjsGlobal.YAML=Yaml);var Yaml_1=Yaml;const aDet=document.getElementById("aDet"),aCls=document.getElementById("aCls"),aSeg=document.getElementById("aSeg"),aConvertor=document.getElementById("aConvertor"),detDoms=document.getElementsByClassName("det"),clsDoms=document.getElementsByClassName("cls"),segDoms=document.getElementsByClassName("seg"),detModel=document.getElementById("detModel"),clsModel=document.getElementById("clsModel"),segModel=document.getElementById("segModel"),drawThresholdDoms=document.getElementsByClassName("drawThreshold"),topKDoms=document.getElementsByClassName("topK"),mixingFactorDoms=document.getElementsByClassName("mixingFactor"),imgDom=document.getElementById("imgDom"),inputFile=document.getElementById("inputFile"),videoDom=document.getElementById("videoDom"),canvasDom=document.getElementById("canvasDom"),buttonUser=document.getElementById("buttonUser"),buttonEnv=document.getElementById("buttonEnv"),tableDiv=document.getElementById("tableDiv"),convertor=document.getElementById("convertor"),predictor=document.getElementById("predictor");let MODE="det",modelName="blazeface_1000e",drawThreshold=.5,topK=5,mixingFactor=.5,cap,model,imgRGBA,bboxes,probs,seg,modelDir;modelDir="./pretrained_models";async function switchType(n){if(n.target.id=="aDet"){for(let e=0;e<detDoms.length;e++)detDoms[e].style.display="";for(let e=0;e<clsDoms.length;e++)clsDoms[e].style.display="none";for(let e=0;e<segDoms.length;e++)segDoms[e].style.display="none";predictor.style.display="",convertor.style.display="none",tableDiv.style.display="none",modelName="blazeface_1000e",await loadModel("det"),MODE="det",await restart()}else if(n.target.id=="aCls"){for(let e=0;e<detDoms.length;e++)detDoms[e].style.display="none";for(let e=0;e<clsDoms.length;e++)clsDoms[e].style.display="";for(let e=0;e<segDoms.length;e++)segDoms[e].style.display="none";predictor.style.display="",convertor.style.display="none",tableDiv.style.display="",modelName="efficientnetb0_imagenet",await loadModel("cls"),MODE="cls",await restart()}else if(n.target.id=="aSeg"){for(let e=0;e<detDoms.length;e++)detDoms[e].style.display="none";for(let e=0;e<clsDoms.length;e++)clsDoms[e].style.display="none";for(let e=0;e<segDoms.length;e++)segDoms[e].style.display="";predictor.style.display="",convertor.style.display="none",tableDiv.style.display="",modelName="ppseg_lite_portrait_398x224",await loadModel("seg"),MODE="seg",await restart()}else n.target.id=="aConvertor"&&(predictor.style.display="none",convertor.style.display="")}aDet.onclick=n=>switchType(n);aCls.onclick=n=>switchType(n);aSeg.onclick=n=>switchType(n);aConvertor.onclick=n=>switchType(n);async function switchModel(n){modelName=n.target.value,await loadModel(MODE),await restart()}detModel.onchange=n=>switchModel(n);clsModel.onchange=n=>switchModel(n);segModel.onchange=n=>switchModel(n);function getConfig(n){if(n.target.className=="drawThreshold"){drawThreshold=n.target.value*1;for(let e=0;e<drawThresholdDoms.length;e++)drawThresholdDoms[e].value=drawThreshold}else if(n.target.className=="topK"){topK=n.target.value*1;for(let e=0;e<topKDoms.length;e++)topKDoms[e].value=topK}else if(n.target.className=="mixingFactor"){mixingFactor=n.target.value*1;for(let e=0;e<mixingFactorDoms.length;e++)mixingFactorDoms[e].value=mixingFactor}typeof imgRGBA!="undefined"&&postProcess()}for(let n=0;n<drawThresholdDoms.length;n++)drawThresholdDoms[n].onchange=e=>getConfig(e);for(let n=0;n<topKDoms.length;n++)topKDoms[n].onchange=e=>getConfig(e);for(let n=0;n<mixingFactorDoms.length;n++)mixingFactorDoms[n].onchange=e=>getConfig(e);inputFile.onchange=n=>{n.target.files[0]&&(imgDom.src=URL.createObjectURL(n.target.files[0]))};async function loadModel(n){inputFile.disabled=!0,buttonUser.disabled=!0,buttonEnv.disabled=!0;let e=`${modelDir}/${n}/${modelName}/model.onnx.json`,r=`${modelDir}/${n}/${modelName}/configs.json`;n=="det"?model=new WebAI.Det(e,r):n=="cls"?model=new WebAI.Cls(e,r):n=="seg"&&(model=new WebAI.Seg(e,r)),inputFile.disabled=!1,buttonUser.disabled=!1,buttonEnv.disabled=!1}loadModel(MODE);function getUserMedia(n){navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia({video:{width:1280,height:720,facingMode:n}}).then(successCap).catch(errorCap):navigator.webkitGetUserMedia?navigator.webkitGetUserMedia({video:{width:1280,height:720,facingMode:n}},successCap,errorCap):navigator.mozGetUserMedia?navigator.mozGetUserMedia({video:{width:1280,height:720,facingMode:n}},successCap,errorCap):navigator.getUserMedia&&navigator.getUserMedia({video:{width:1280,height:720,facingMode:n}},successCap,errorCap)}function successCap(n){let e=n.getVideoTracks()[0].getSettings().height,r=n.getVideoTracks()[0].getSettings().width;videoDom.width=r,videoDom.height=e,videoDom.srcObject=n,videoDom.play(),cap=new cv.VideoCapture(videoDom),setTimeout(inferVideo,0)}function errorCap(n){console.log(`\u8BBF\u95EE\u7528\u6237\u5A92\u4F53\u8BBE\u5907\u5931\u8D25${n.name}, ${n.message}`)}buttonUser.onclick=function(n){buttonUser.innerHTML=="Open User Camera"?(buttonEnv.innerHTML=="Stop Environment Camera"&&(buttonEnv.innerHTML="Open Environment Camera",videoDom.pause(),videoDom.srcObject.getTracks()[0].stop()),buttonUser.innerHTML="Stop User Camera",getUserMedia("user"),setTimeout(inferVideo(),0)):(buttonUser.innerHTML="Open User Camera",videoDom.pause(),videoDom.srcObject.getTracks()[0].stop())};buttonEnv.onclick=function(n){buttonEnv.innerHTML=="Open Environment Camera"?(buttonUser.innerHTML=="Stop User Camera"&&(buttonUser.innerHTML="Open User Camera",videoDom.pause(),videoDom.srcObject.getTracks()[0].stop()),buttonEnv.innerHTML="Stop Environment Camera",getUserMedia("environment")):(buttonEnv.innerHTML="Open Environment Camera",videoDom.pause(),videoDom.srcObject.getTracks()[0].stop())};async function inferImage(){MODE=="det"?bboxes=await model.infer(imgRGBA,0):MODE=="cls"?probs=await model.infer(imgRGBA,-1):MODE=="seg"&&(typeof seg!="undefined"&&seg.delete(),seg=await model.infer(imgRGBA))}function postProcess(){if(MODE=="det"){let n=[];for(let r=0;r<bboxes.length;r++)bboxes[r].score>drawThreshold&&n.push(bboxes[r]);let e=WebAI.drawBBoxes(imgRGBA,n);cv.imshow(canvasDom,e),e.delete()}else if(MODE=="cls")cv.imshow(canvasDom,imgRGBA),buildTable(probs.slice(0,topK));else if(MODE=="seg"){let n=imgRGBA.clone();cv.addWeighted(imgRGBA,1-mixingFactor,seg.colorRGBA,mixingFactor,0,n),cv.imshow(canvasDom,n),buildTable(seg.colorMap),n.delete()}}imgDom.onload=async function(){videoDom.pause(),buttonUser.innerHTML="Open User Camera",buttonEnv.innerHTML="Open Environment Camera",videoDom.srcObject!=null&&videoDom.srcObject.getTracks()[0].stop(),typeof imgRGBA!="undefined"&&imgRGBA.delete(),imgRGBA=cv.imread(imgDom),await inferImage(),postProcess()};function buildTable(n){let e=document.getElementById("tableDom");tableDiv.removeChild(e);let r=document.createElement("table"),t=document.createElement("tr");for(let o in n[0]){let i=document.createElement("th");i.innerText=o,t.appendChild(i)}r.appendChild(t),n.forEach((o,i)=>{let l=document.createElement("tr");for(let a in n[i]){let s=document.createElement("td"),u=n[i][a];typeof u=="object"&&(s.setAttribute("style",`background: rgba(${u.toString()})`),u=""),s.innerText=u,l.appendChild(s)}r.appendChild(l)}),r.setAttribute("border","1"),r.setAttribute("id","tableDom"),tableDiv.appendChild(r)}async function restart(){typeof imgRGBA!="undefined"&&(await inferImage(),postProcess())}function inferVideo(){videoDom.paused!=!0&&(typeof imgRGBA!="undefined"&&imgRGBA.delete(),imgRGBA=new cv.Mat(videoDom.height,videoDom.width,cv.CV_8UC4),cap.read(imgRGBA),inferImage().then(function(){postProcess(),setTimeout(inferVideo,0)}))}let form=layui.form,configs;layui.use("form",function(){var n=layui.form;let e=layui.layer;n.on("submit(formDemo)",function(r){let t=r.field;if(configs={Preprocess:[{type:"Decode",mode:t.mode}],label_list:[]},t.resize&&configs.Preprocess.push({type:"Resize",interp:t.interp*1,keep_ratio:t.keep_ratio=="true",limit_max:t.limit_max=="true",target_size:[t["target_size.h"]*1,t["target_size.w"]*1]}),t.crop&&configs.Preprocess.push({type:"Crop",crop_size:[t["crop_size.h"]*1,t["crop_size.w"]*1]}),configs.Preprocess.push({type:"Normalize",is_scale:t.is_scale=="true",mean:[t["mean.R"]*1,t["mean.G"]*1,t["mean.B"]*1],std:[t["std.R"]*1,t["std.G"]*1,t["std.B"]*1]}),t.permute&&configs.Preprocess.push({type:"Permute"}),t.label_list=="")e.prompt({title:"label list is empty, please input the number of the labels"},function(l,a,s){e.close(a);for(let f=0;f<l*1;f++)configs.label_list.push(f.toString());var u=document.createElement("a");u.download="configs.json",u.style.display="none";var c=new Blob([JSON.stringify(configs,null,4)]);u.href=URL.createObjectURL(c),document.body.appendChild(u),u.click(),document.body.removeChild(u)});else{let l=t.label_list.split(`
- `);for(let a=0;a<l.length;a++)l[a]!=""&&configs.label_list.push(l[a]);var o=document.createElement("a");o.download="configs.json",o.style.display="none";var i=new Blob([JSON.stringify(configs,null,4)]);o.href=URL.createObjectURL(i),document.body.appendChild(o),o.click(),document.body.removeChild(o)}return!1}),n.verify({mean_std:function(r){if(n.val("configs").is_scale){if(r<0||r>1)return"value must be 0 - 1"}else if(r<0||r>255)return"value must be 0 - 255"},size:function(r){if(r<=0)return"value must be > 0"}})});const buttonLoad=document.getElementById("buttonLoad"),inputLoad=document.getElementById("inputLoad");document.getElementById("buttonDownload");function loadText(n){let e=new XMLHttpRequest;return e.open("get",n,!1),e.send(null),e.responseText}buttonLoad.onclick=function(){inputLoad.click()};inputLoad.onchange=function(n){if(n.target.files[0].name.endsWith(".json")){configs=JSON.parse(loadText(URL.createObjectURL(n.target.files[0])));let e={resize:!1,crop:!1,is_scale:!1,permute:!1};for(let r=0;r<configs.Preprocess.length;r++){let t=configs.Preprocess[r],o=t.type;o=="Decode"?e.mode=t.mode:o=="Resize"?(e.resize=!0,e.interp=t.interp,e.keep_ratio=t.keep_ratio,e.limit_max=t.limit_max,e["target_size.h"]=t.target_size[0],e["target_size.w"]=t.target_size[1]):o=="Crop"?(e.crop=!0,e["crop_size.h"]=t.crop_size[0],e["crop_size.w"]=t.crop_size[1]):o=="Normalize"?(e.is_scale=t.is_scale,e["mean.R"]=t.mean[0],e["mean.G"]=t.mean[1],e["mean.B"]=t.mean[2],e["std.R"]=t.std[0],e["std.G"]=t.std[1],e["std.B"]=t.std[2]):o=="Permute"&&(e.permute=!0)}e.label_list=configs.label_list.join(`
- `),form.val("configs",e)}else if(n.target.files[0].name.endsWith(".yml")||n.target.files[0].name.endsWith(".yaml")){if(configs=Yaml_1.load(URL.createObjectURL(n.target.files[0])),configs.hasOwnProperty("Deploy")){let e={resize:!1,crop:!1,is_scale:!0,permute:!0};configs.Deploy.transforms.forEach(t=>{t.type=="Normalize"&&(t.hasOwnProperty("mean")?(e["mean.R"]=t.mean[0],e["mean.G"]=t.mean[1],e["mean.B"]=t.mean[2]):(e["mean.R"]=.5,e["mean.G"]=.5,e["mean.B"]=.5),t.hasOwnProperty("std")?(e["std.R"]=t.std[0],e["std.G"]=t.std[1],e["std.B"]=t.std[2]):(e["std.R"]=.5,e["std.G"]=.5,e["std.B"]=.5))}),form.val("configs",e)}else if(configs.hasOwnProperty("Global")){let e=configs.PreProcess.transform_ops,r={resize:!1,crop:!1,is_scale:!1,permute:!1};e.forEach(t=>{t.hasOwnProperty("ResizeImage")?t.ResizeImage.hasOwnProperty("resize_short")&&(r.keep_ratio=!0,r.limit_max=!1,r.resize=!0,r.interp=1,r["target_size.h"]=t.ResizeImage.resize_short,r["target_size.w"]=t.ResizeImage.resize_short):t.hasOwnProperty("CropImage")?t.CropImage.hasOwnProperty("size")&&(r.crop=!0,r["crop_size.h"]=t.CropImage.size,r["crop_size.w"]=t.CropImage.size):t.hasOwnProperty("NormalizeImage")?(t.NormalizeImage.hasOwnProperty("scale")&&(r.is_scale=!0),t.NormalizeImage.hasOwnProperty("mean")&&(r["mean.R"]=t.NormalizeImage.mean[0],r["mean.G"]=t.NormalizeImage.mean[1],r["mean.B"]=t.NormalizeImage.mean[2]),t.NormalizeImage.hasOwnProperty("std")&&(r["std.R"]=t.NormalizeImage.std[0],r["std.G"]=t.NormalizeImage.std[1],r["std.B"]=t.NormalizeImage.std[2])):t.hasOwnProperty("ToCHWImage")&&(r.permute=!0)}),form.val("configs",r)}else if(configs.hasOwnProperty("mode")){let e=configs.Preprocess,r={resize:!1,crop:!1,is_scale:!1,permute:!1};e.forEach(t=>{let o=t.type;o=="Resize"?(r.resize=!0,r.interp=t.interp,r.keep_ratio=t.keep_ratio,r.limit_max=t.keep_ratio,r["target_size.h"]=t.target_size[0],r["target_size.w"]=t.target_size[1]):o=="NormalizeImage"?(r.is_scale=t.is_scale,r["mean.R"]=t.mean[0],r["mean.G"]=t.mean[1],r["mean.B"]=t.mean[2],r["std.R"]=t.std[0],r["std.G"]=t.std[1],r["std.B"]=t.std[2]):o=="Permute"&&(r.permute=!0)}),r.label_list=configs.label_list.join(`
- `),form.val("configs",r)}}inputLoad.value=null};
|