deepar 5.4.0-canvasInDiv-alpha-13 → 5.4.0-chromeExtension
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -57
- package/VERSION.txt +1 -1
- package/effects/background_blur.deepar +0 -0
- package/js/deepar.esm.js +2 -1
- package/js/deepar.esm.js.LICENSE.txt +6 -0
- package/js/deepar.js +2 -1
- package/js/deepar.js.LICENSE.txt +6 -0
- package/js/dynamicModules/mediaPipe.esm.js +1 -0
- package/js/dynamicModules/xzimg.esm.js +2 -0
- package/js/dynamicModules/xzimg.esm.js.LICENSE.txt +219 -0
- package/js/types/DeepAR.d.ts +60 -27
- package/js/types/callbacks.d.ts +1 -0
- package/js/types/canvasHelper.d.ts +2 -2
- package/js/types/canvasTouchHelper.d.ts +13 -0
- package/js/types/initParams.d.ts +64 -12
- package/js/types/mediaRecorderVideoRecording.d.ts +10 -0
- package/js/types/version.d.ts +1 -1
- package/js/types/webCodecsVideoRecording.d.ts +11 -0
- package/lib/LICENSE +1 -0
- package/lib/README.md +326 -0
- package/lib/VERSION.txt +1 -0
- package/lib/effects/background_blur.deepar +0 -0
- package/lib/effects/background_replacement.deepar +0 -0
- package/lib/js/deepar.esm.js +2 -0
- package/lib/js/deepar.esm.js.LICENSE.txt +6 -0
- package/lib/js/deepar.js +2 -0
- package/lib/js/deepar.js.LICENSE.txt +6 -0
- package/lib/js/dynamicModules/mediaPipe.esm.js +1 -0
- package/lib/js/dynamicModules/xzimg.esm.js +2 -0
- package/lib/js/dynamicModules/xzimg.esm.js.LICENSE.txt +219 -0
- package/lib/js/types/DeepAR.d.ts +387 -0
- package/lib/js/types/callbacks.d.ts +64 -0
- package/lib/js/types/canvasHelper.d.ts +18 -0
- package/lib/js/types/canvasTouchHelper.d.ts +13 -0
- package/lib/js/types/errors.d.ts +6 -0
- package/lib/js/types/faceData.d.ts +33 -0
- package/lib/js/types/footData.d.ts +9 -0
- package/lib/js/types/index.d.ts +10 -0
- package/lib/js/types/initParams.d.ts +244 -0
- package/lib/js/types/logType.d.ts +18 -0
- package/lib/js/types/mediaRecorderVideoRecording.d.ts +10 -0
- package/lib/js/types/scriptingApi.d.ts +107 -0
- package/lib/js/types/touchType.d.ts +34 -0
- package/lib/js/types/version.d.ts +5 -0
- package/lib/js/types/webCodecsVideoRecording.d.ts +11 -0
- package/lib/js/types/wristData.d.ts +13 -0
- package/lib/mediaPipe/segmentation/models/selfie_segmenter.tflite +0 -0
- package/lib/mediaPipe/segmentation/models/selfie_segmenter_landscape.tflite +0 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.js +22 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.wasm +0 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.js +22 -0
- package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.wasm +0 -0
- package/lib/models/face/models-68-extreme.bin +0 -0
- package/lib/models/face-cnn/face-det.bin +0 -0
- package/lib/models/face-cnn/face-track-19.bin +0 -0
- package/lib/models/foot/foot-detection-96x96x6.bin +0 -0
- package/lib/models/foot/foot-model.obj +3965 -0
- package/lib/models/foot/foot-tracker-96x96x13-test.bin +0 -0
- package/lib/models/foot/foot-tracker-96x96x18-test.bin +0 -0
- package/lib/models/segmentation/segmentation-160x160-opt.bin +0 -0
- package/lib/models/wrist/wrist-base-2.obj +3815 -0
- package/lib/models/wrist/wrist-det-9.bin +0 -0
- package/lib/models/wrist/wrist-track.bin +0 -0
- package/lib/wasm/deepar.wasm +0 -0
- package/lib/wasm/libxzimgPoseEstimation.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm-simd.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm-threaded-simd.wasm +0 -0
- package/lib/wasm/tfjs-backend-wasm.wasm +0 -0
- package/mediaPipe/segmentation/models/selfie_segmenter.tflite +0 -0
- package/mediaPipe/segmentation/models/selfie_segmenter_landscape.tflite +0 -0
- package/mediaPipe/segmentation/wasm/vision_wasm_internal.js +22 -0
- package/mediaPipe/segmentation/wasm/vision_wasm_internal.wasm +0 -0
- package/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.js +22 -0
- package/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.wasm +0 -0
- package/models/face-cnn/face-det.bin +0 -0
- package/models/face-cnn/face-track-19.bin +0 -0
- package/package.json +1 -1
- package/wasm/deepar.wasm +0 -0
package/js/deepar.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepar=t():e.deepar=t()}(self,(()=>(()=>{var e={683:()=>{},345:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ARTouchType:()=>HC,DeepAR:()=>GC,ScriptingAPI:()=>EC,VarType:()=>wC,errors:()=>e,initialize:()=>jC,version:()=>a});var e={};n.r(e),n.d(e,{SwitchEffectCanceled:()=>TC});var t,a="5.4.0-canvasInDiv-alpha-13",o=(t="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var n,r,a;n||(n=void 0!==e?e:{}),n.ready=new Promise((function(e,t){r=e,a=t}));let o=null;const s=[];function i(){for(const e of s)e()}function u(){for(const e of s)e()}n.addPreRenderListener=function(e){s.push(e)},n.addPostRenderListener=function(e){s.push(e)};var l=null;const c=new ImageData(640,360);c.xl=!0;let p,h,d,f,m,g,y,b,v,w,x,_,k,T,S,E,I,C,A=!1,N=null,R=null,F=null,O=null,M=null;var $=!1,D={},P=null,L=[];function B(e){const t=n.sk.length;return n.sk[t]=e,t}n.sk=[null],n.preinitializedWebGLContext=n.canvas.getContext("webgl2",{alpha:!1,antialias:!0,powerPreference:"high-performance"}),n.process=function(){};let U=new class{get Ak(){switch(this.type){case"Timer":return this.Lk;case"RAF":return this.Kk;case"Oscillator":return this.Jk}}constructor(){this.Jk=this.Kk=this.Lk=!1,this.type="RAF",this.Sk=1e3/33}add(e){this.xk=e}start(){switch(this.type){case"Timer":if(!this.Lk){this.Lk=!0;const e=()=>{setTimeout((()=>{this.xk&&this.xk(),this.Lk&&e()}),this.Sk)};e()}break;case"RAF":if(!this.Kk){this.Kk=!0;const e=t=>{requestAnimationFrame((n=>{n-t<=this.Sk?this.Kk&&e(t):this.xk&&(this.xk(),e(n))}))};e(-this.Sk-10)}break;case"Oscillator":if(!this.Jk){o=o||new AudioContext,this.Jk=!0;const e=o.createGain();let t;e.gain.value=0,e.connect(o.destination);const n=()=>{this.xk&&this.xk(),t&&t.disconnect(),this.bl=t=o.createOscillator(),t.connect(e),this.Jk&&(t.onended=n,t.start(),t.stop(o.currentTime+this.Sk/1e3))};n()}}}stop(){switch(this.type){case"Timer":this.Lk=!1;break;case"RAF":this.Kk=!1;break;case"Oscillator":this.Jk=!1,this.bl&&(this.bl.onended=null,this.bl=void 0)}}};function W(){var e=n.sk[0];if(e&&e.readyState===e.HAVE_ENOUGH_DATA)n._processFrameVideo(0,q),A=!0;else if(!A||0<Object.entries(H).length||null!=G||null!=K){e=p||c;var t=n._malloc(e.data.length);if(!t)return;ue.set(e.data,t),n._processFrameRawPixels(t,e.width,e.height,e.xl),A=!0,n._free(t)}i(),e=n.canvas.width,t=n.canvas.height,n.canvasWidth===e&&n.canvasHeight===t||(n.canvasWidth=e,n.canvasHeight=t,io(e,t)),n._render(),u(),n.apiObject.__deeparRendered&&n.apiObject.__deeparRendered(ca)}function V(){W()}n.setFps=function(e){U.Sk=1e3/e},U.add(V),n.startLoop=function(){U.add(V),U.start()},n.endLoop=function(){U.xk=void 0,U.stop()};var z=!1,j=null;n.takeScreenshot=function(e){if(z)throw Error("The last call to takeScreenshot is not finished yet. Wait for the screenshot to finish.");z=!0,j=e;try{so(),U.Ak||(i(),n._render(),u())}catch(e){throw z=!1,j=null,e}},n.startVideoRecording=function(e){if($)throw Error("Video recording already started!");if($=!0,null==P||function(e){var t=D;return Object.keys(t).length===Object.keys(e).length&&Object.keys(t).every((n=>e.hasOwnProperty(n)&&t[n]===e[n]))}(e)){const t={};e.mimeType&&(t.mimeType=e.mimeType),P=new MediaRecorder(n.canvas.captureStream(),t),D=Object.assign({},e),P.ondataavailable=function(e){L.push(e.data)}}P.start()},n.finishVideoRecording=function(e){if(!$)throw Error("Video recording not started!");P.onstop=function(){e(new Blob(L,{type:D.mimeType||"video/webm"})),L=[],$=!1},P.stop()},n.processFrameRawPixels=function(e,t,r,a){var o=n._malloc(e.length);o&&(ue.set(e,o),n._processFrameRawPixels(o,t,r,a),p=new ImageData(new Uint8ClampedArray(e),t,r),p.xl=a,A=!0,U.Ak||(i(),n._render(),u()),n._free(o))},n.initializeFootTracking=function(){Sa(),lo()},n.isFootTrackingInitialized=function(){return Ea()},n.initializeSegmentation=function(){Oa()},n.isSegmentationInitialized=function(){return Ma()},n.isWristTrackingInitialized=function(){return za()};let H={},G=null,K=null;n.switchEffectByteArray=function(e,t,r,a,o){if(!N)throw Error("Error in internal API: __switchEffect is null!");const s=n._malloc(r.length);if(!s)throw Error("Cannot allocate buffer for switch effect.");ue.set(r,s),H[t]&&H[t].error&&H[t].error(new n.customErrors.SwitchEffectCanceled(`Switch effect canceled by another switch effect to the same slot: ${t}.`)),H[t]={Ck:a,error:o};try{N(t,s,r.length,e),A=!1,U.Ak||W()}catch(e){throw delete H[t],e}},n.hasVar=function(e,t){return h(e,t)},n.getVarType=function(e,t){if(d(e,t))return b(e,t);throw Error("Variable named '"+e+"' does not exist.")},n.getBoolVar=function(e,t){if(f(e,t))return v(e,t);throw Error("Variable named '"+e+"' does not exist or is not a boolean.")},n.getIntVar=function(e,t){if(m(e,t))return w(e,t);throw Error("Variable named '"+e+"' does not exist or is not an integer.")},n.getDoubleVar=function(e,t){if(g(e,t))return x(e,t);throw Error("Variable named '"+e+"' does not exist or is not a double.")},n.getStringVar=function(e,t){if(y(e,t))return _(e,t);throw Error("Variable named '"+e+"' does not exist or is not a string.")},n.setBoolVar=function(e,t,n){return k(e,t,n)},n.setIntVar=function(e,t,n){return T(e,t,n)},n.setDoubleVar=function(e,t,n){return S(e,t,n)},n.setStringVar=function(e,t,n){return E(e,t,n)},n.deleteVar=function(e,t){return I(e,t)},n.clearVars=function(e){return C(e)},n.clearEffect=function(e){H[e]&&H[e].error&&(H[e].error(new n.customErrors.SwitchEffectCanceled(`Switch effect canceled by the call to clearEffect() on the same slot: ${e}.`)),delete H[e]),R&&(R(e),U.Ak||W())},n.moveGameObject=function(e,t){F&&(F(e,t),U.Ak||W())};let q=!0;n.setMirror=function(e){q=!!e};let Y=!1;n.startCamera=function(e,t,r,a,o,s){n.stopVideo(),q=!!e;let i=document.createElement("video");i.Ak=!0,n.sk[0]=i,t=t||!0,o&&o(),navigator.mediaDevices.getUserMedia({video:t}).then((function(e){s&&s(),i.srcObject=e,i.onloadedmetadata=()=>{i.play().then((()=>{r&&r()}))},Y=!0})).catch((e=>{a&&a(e),console.error(`${e.name}: ${e.message}`)}))},n.shutdown=function(){n.stopVideo(),oo(),n.cm()},n.setVideoElement=function(e,t){n.stopVideo(),q=!!t,n.sk[0]=e},n.stopVideo=function(){n.sk[0]&&(Y&&(n.sk[0].srcObject.getTracks().forEach((e=>{e.stop()})),n.sk[0].srcObject=null,Y=!1),n.sk[0]=null)},n.touchOccurred=function(e){uo(e.x,e.y,e.type)},n.setOffscreenRenderingEnabled=function(e){!function(e){var t=U;if(t.type!==e){var n=t.Lk|t.Jk|t.Kk;t.stop(),t.type=e,n&&t.start()}}(e?"Oscillator":"RAF")},n.backgroundReplacement=function(e,t,n,r){if(e){K&&K.error&&K.error(""),K={Ck:n,error:r};var a=new Image;a.onload=()=>{const t=document.createElement("canvas");var n=t.getContext("2d",{un:!0});t.width=a.width,t.height=a.height,n.drawImage(a,0,0),n=n.getImageData(0,0,t.width,t.height),n=new Uint8Array(n.data.buffer);const r=co(n.length);ue.set(n,r);try{M(e,r,n.length,t.width,t.height),A=!1,U.Ak||W()}catch(e){throw K=null,e}},a.src=t}else M(!1,null,0,0,0),n()},n.backgroundBlur=function(e,t,n,r){if(e){G&&G.error&&G.error(""),G={Ck:n,error:r};try{O(e,t),A=!1,U.Ak||W()}catch(e){throw G=null,e}}else O(!1,0),n()},n.Ul=function(e,t,r,a){if(n.apiObject.onFaceTracked){var o=[];for(let c=0;c<a;c++){let a={detected:!1,translation:[],rotation:[],poseMatrix:[],landmarks:[],landmarks2d:[],faceRect:[]};var s=t+c*r,i=s+e.translationOffset;let p=s+e.rotationOffset;var u=s+e.poseMatrixOffset,l=s+e.landmarksOffset;let h=s+e.landmarks2DOffset,d=s+e.faceRectOffset;for(a.detected=!!n.HEAP32[s/Float32Array.BYTES_PER_ELEMENT],s=0;3>s;s++)a.translation.push(n.HEAPF32[i/Float32Array.BYTES_PER_ELEMENT+s]),a.rotation.push(n.HEAPF32[p/Float32Array.BYTES_PER_ELEMENT+s]);for(i=0;16>i;i++)a.poseMatrix.push(n.HEAPF32[u/Float32Array.BYTES_PER_ELEMENT+i]);for(u=0;204>u;u++)a.landmarks.push(n.HEAPF32[l/Float32Array.BYTES_PER_ELEMENT+u]),136>u&&a.landmarks2d.push(n.HEAPF32[h/Float32Array.BYTES_PER_ELEMENT+u]);for(l=0;4>l;l++)a.faceRect.push(n.HEAPF32[d/Float32Array.BYTES_PER_ELEMENT+l]);o.push(a)}n.apiObject.onFaceTracked(o)}},n.bn=function(){n.apiObject.onVideoStarted&&n.apiObject.onVideoStarted()},n.Zl=function(){n.apiObject.onInitialize&&n.apiObject.onInitialize()},n.Vl=function(e){n.apiObject.onFaceVisibilityChanged&&n.apiObject.onFaceVisibilityChanged(e)},n.Yl=function(e){n.apiObject.onImageVisibilityChanged&&n.apiObject.onImageVisibilityChanged(e)},n.an=function(){n.apiObject.onCameraPermissionGranted&&n.apiObject.onCameraPermissionGranted()},n.$m=function(){n.apiObject.onCameraPermissionDenied&&n.apiObject.onCameraPermissionDenied()},n.Zm=function(){n.apiObject.onCameraPermissionAsked&&n.apiObject.onCameraPermissionAsked()},n.am=function(e,t,n){const r=document.createElement("canvas"),a=r.getContext("2d");r.width=t,r.height=n;const o=a.getImageData(0,0,r.width,r.height),s=o.data;for(let r=0;r<n;r++)for(let a=0;a<t;a++){const o=4*((n-r-1)*t+a),i=4*(r*t+a);s[i]=ue[e+o+2],s[i+1]=ue[e+o+1],s[i+2]=ue[e+o+0],s[i+3]=ue[e+o+3]}a.putImageData(o,0,0),z?(z=!1,j(r.toDataURL("image/png")),j=null):console.error("DeepAR screenshot taken but no registered callback.")},n.Pl=function(e){n.apiObject.onAnimationTransitionedToState&&n.apiObject.onAnimationTransitionedToState(e)},n.Tl=function(e,t){"Error"===e?console.error(t):"Debug"===e?console.debug(t):"Info"===e?console.info(t):"Warning"===e?console.warn(t):console.log(t)},n.Sl=function(e){H[e]&&H[e].Ck&&H[e].Ck(),delete H[e]},n.Rl=function(){K&&K.Ck&&K.Ck(),K={}},n.Ql=function(){G&&G.Ck&&G.Ck(),G={}},n.$l=function(e){n.apiObject.onNumberOfFacesVisibleChanged&&n.apiObject.onNumberOfFacesVisibleChanged(e)},n.cm=function(){n.apiObject.onShutdown&&n.apiObject.onShutdown()},n.Xl=function(){n.apiObject.onFootTrackingInitialized&&n.apiObject.onFootTrackingInitialized()},n.bm=function(){n.apiObject.onSegmentationInitialized&&n.apiObject.onSegmentationInitialized()},n.Wl=function(e,t){n.apiObject.onFeetTracked&&n.apiObject.onFeetTracked(e,t)},n.em=function(){n.apiObject.onWristTrackingInitialized&&n.apiObject.onWristTrackingInitialized()},n.dm=function(e){n.apiObject.onWristTracked&&n.apiObject.onWristTracked(e)},n.noInitialRun=!0,n.initializeDeepAR=function(){l=n.xzimg,n.initializeML&&(n.initializeML.faceModelsPredownload&&J("face"),n.initializeML.segmentationInit&&Oa(),n.initializeML.footInit&&Sa(),n.initializeML.segmentationModelsPredownload&&J("segmentation"),n.initializeML.footModelsPredownload&&(J("footDetector"),J("footTracker"),J("footObj"))),N=Qa("switchEffect",null,["string","number","number","number"]),R=Qa("clearEffect",null,["string"]),F=Qa("moveGameObject",null,["string","string"]),O=Qa("backgroundBlur",null,["boolean","number"]),M=Qa("backgroundReplacement",null,["boolean","number","number","number","number"]),h=Qa("hasVar","boolean",["string","string"]),d=Qa("getVarTypeStatus","boolean",["string","string"]),f=Qa("getBoolVarStatus","boolean",["string","string"]),m=Qa("getIntVarStatus","boolean",["string","string"]),g=Qa("getDoubleVarStatus","boolean",["string","string"]),y=Qa("getStringVarStatus","boolean",["string","string"]),b=Qa("getVarType","int",["string","string"]),v=Qa("getBoolVar","boolean",["string","string"]),w=Qa("getIntVar","int",["string","string"]),x=Qa("getDoubleVar","number",["string","string"]),_=Qa("getStringVar","string",["string","string"]),k=Qa("setBoolVar","boolean",["string","boolean","string"]),T=Qa("setIntVar","boolean",["string","int","string"]),S=Qa("setDoubleVar","boolean",["string","number","string"]),E=Qa("setStringVar","boolean",["string","string","string"]),I=Qa("deleteVar","boolean",["string","string"]),C=Qa("clearVars","boolean",["string"]),n.pushConsoleLog=Qa("pushConsoleLog","boolean",["string","int"]),n.changeParameterFloat=Qa("changeParameterFloat",null,["string","string","string","number"]),n.changeParameterVector=Qa("changeParameterVector",null,"string string string number number number number".split(" ")),n.changeParameterBool=Qa("changeParameterBool",null,["string","string","string","boolean"]),n.changeParameterTexture=Qa("changeParameterTexture",null,"string string string number number number number".split(" ")),n.fireTrigger=Qa("fireTrigger",null,["string"]),n.setFaceDetectionSensitivity=Qa("setFaceDetectionSensitivity",null,["number"]),n.showStats=Qa("showStats",null,["number"]),n.simulatePhysics=Qa("simulatePhysics",null,["number"]),n.showColliders=Qa("showColliders",null,["number"]),n.setLicenseKey=Qa("setLicenseKey",null,["string"]),n.muteSound=Qa("muteSound",null,["boolean"]),n.setLicenseKey(n.licenseKey),ro(n.canvasWidth,n.canvasHeight)};let X={};function Q(e,t,n){X[e]={path:t,Yk:!1,data:null,Xk:!1,Mk:[],ul:n,Fl:function(n){n&&this.Mk.push(n),this.data?this.Mk.forEach((e=>{e.Ck(this.data)})):this.Yk||(this.Xk&&this.Mk.forEach((e=>{e.error()})),this.path||(console.error(`The ${e} model was requested but the path to it is not defined.`),this.Xk=!0,this.Mk.forEach((e=>{e.error()}))),this.Yk=!0,fetch(this.path).then((n=>{n.ok?n.arrayBuffer().then((n=>{this.data=n,this.Yk=!1,this.Xk=!0,async function(e){return e=await crypto.subtle.digest("SHA-256",e),Array.from(new Uint8Array(e)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(n).then((n=>{this.ul.some((e=>e===n))||console.warn(`The loaded ${e} model (${t}) does not pass the validity check. DeepAR may not function as expected or it might crash. Expected digests: ${this.ul} but got this digest ${n}.`)})),this.Mk.forEach((e=>{e.Ck(n)}))})).catch((t=>{console.error(t),console.error(`Error downloading the ${e} model (${this.path}), could not resolve the array buffer`),this.Mk.forEach((e=>{e.error()}))})):(this.Yk=!1,this.Xk=!0,console.error(`Error downloading the ${e} model (${this.path}), response status = ${n.status}. Effects using ${e} will not work properly or at all.`),this.Mk.forEach((e=>{e.error()})))})))},mm:function(){return this.data?this.data:this.Xk||this.Yk?null:void this.Fl()},lm:async function(){return new Promise(((e,t)=>{this.Fl({Ck:e,error:t})}))}}}function J(e){if(!X[e])throw Error(`No ML model with name ${e}.`);return X[e].mm()}function Z(e){if(!X[e])throw Error(`No ML model with name ${e}.`);return X[e].lm()}Q("face",n.faceTrackingModelPath,["d77b98c4cbe7f514b541ff79f79503bf23bc8f2b27046c8c785f2d89d2c3a44b"]),Q("segmentation",n.segmentationModel,["373cb9dd1fbf3972245665a81607ec7d33078ee0dae380c9d9e8bc03034dc09a"]),Q("footDetector",n.footTrackingConfig.detectorPath,["2c6d4af14fbe42bdc37fba53526429ac7453e19971a4a070e64bae6460872ac3"]),Q("footTracker",n.footTrackingConfig.trackerPath,["ddfc598f45ae5e5a8169518a9daecedc556df623cb3a1d676e7de0f85f14f337","f0ec050f034b9ade54711705213d2dd336b76452a7d81bd17ba2505a5293438a"]),Q("footObj",n.footTrackingConfig.objPath,["689ec395dc4382e15af1304405546fcdcb677044d61bf73db0b2d6c163be35f2"]),Q("wristDetector",n.wristTrackingConfig.detectorPath,["b4c14a6f4b7bed1bc1cb313bbad5e877c7958c25b8e47d12583404f9a611d7ff"]),Q("wristTracker",n.wristTrackingConfig.trackerPath,["6da1ab155e8f7f36b550b09ece3bee810b839f85a96de507ef6daeac3e8328cd"]),Q("wristObj",n.wristTrackingConfig.objPath,["5c763303cac33e377bbfbc3bd13475c0b99ca6412f9774ecc7a65fe72ac01732"]),Q("background_replacement.deepar",n.embeddedEffectConfig.backgroundReplacementPath,["40e3ea2148e50af361eabc79a27b7d5b5c1ad04c4d9c0b48a296acd29054f3c9"]),Q("background_blur.deepar",n.embeddedEffectConfig.backgroundBlurPath,["ea3df8771d24e44c576bcc50bb11b3c6866285c3ce88a39de042d1e9211f67fe"]);var ee=Object.assign({},n),te="";"undefined"!=typeof document&&document.currentScript&&(te=document.currentScript.src),t&&(te=t),te=0!==te.indexOf("blob:")?te.substr(0,te.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var ne=console.log.bind(console),re=console.warn.bind(console);Object.assign(n,ee),ee=null;var ae=!1;"object"!=typeof WebAssembly&&Me("no native wasm support detected");var oe,se,ie,ue,le,ce,pe,he,de,fe,me=!1,ge="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function ye(e,t,n){var r=t+n;for(n=t;e[n]&&!(n>=r);)++n;if(16<n-t&&e.buffer&&ge)return ge.decode(e.subarray(t,n));for(r="";t<n;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|o);else{var s=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|s:(7&a)<<18|o<<12|s<<6|63&e[t++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function be(e,t){return e?ye(ue,e,t):""}function ve(e,t,n,r){if(!(0<r))return 0;var a=n;r=n+r-1;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),127>=s){if(n>=r)break;t[n++]=s}else{if(2047>=s){if(n+1>=r)break;t[n++]=192|s>>6}else{if(65535>=s){if(n+2>=r)break;t[n++]=224|s>>12}else{if(n+3>=r)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63}t[n++]=128|s>>6&63}t[n++]=128|63&s}}return t[n]=0,n-a}function we(e,t,n){return ve(e,ue,t,n)}function xe(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function _e(){var e=oe.buffer;n.HEAP8=ie=new Int8Array(e),n.HEAP16=le=new Int16Array(e),n.HEAP32=pe=new Int32Array(e),n.HEAPU8=ue=new Uint8Array(e),n.HEAPU16=ce=new Uint16Array(e),n.HEAPU32=he=new Uint32Array(e),n.HEAPF32=de=new Float32Array(e),n.HEAPF64=fe=new Float64Array(e)}var ke,Te,Se=[],Ee=[],Ie=[],Ce=[],Ae=!1,Ne=0,Re=0,Fe=null,Oe=null;function Me(e){throw re(e="Aborted("+e+")"),me=!0,se=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),a(e),e}function $e(e){return e.startsWith("data:application/octet-stream;base64,")}if(!$e(Te="deepar.wasm")){var De=Te;Te=n.locateFile?n.locateFile(De,te):te+De}function Pe(){try{throw"both async and sync fetching of the wasm failed"}catch(e){Me(e)}}function Le(e,t,n){return function(e){return"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return Pe()})):Promise.resolve().then((function(){return Pe()}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){re("failed to asynchronously prepare wasm: "+e),Me(e)}))}var Be={979624:(e,t,n,r,a,o)=>{var s=document.createElement("canvas"),i=s.getContext("2d");s.width=t,s.height=n,e=new Uint8ClampedArray(ue.subarray(e,e+s.width*s.height*4)),e=new ImageData(e,s.width,s.height),i.putImageData(e,0,0),e=(i=document.createElement("canvas")).getContext("2d"),i.width=a,i.height=o,e.drawImage(s,0,0,i.width,i.height),a=e.getImageData(0,0,i.width,i.height),a=new Uint8Array(a.data.buffer),ue.set(a,r)},980478:(e,t,n,r,a,o)=>{var s=document.createElement("canvas"),i=s.getContext("2d");s.width=t,s.height=n,e=new Uint8ClampedArray(ue.subarray(e,e+s.width*s.height*4)),e=new ImageData(e,s.width,s.height),i.putImageData(e,0,0),e=(i=document.createElement("canvas")).getContext("2d"),i.width=a,i.height=o,e.drawImage(s,0,0,i.width,i.height),a=e.getImageData(0,0,i.width,i.height),a=new Uint8Array(a.data.buffer),ue.set(a,r)},981332:()=>{console.log("License key not valid")},981369:()=>{n.Zl()},981393:(e,t,r)=>{n.am(e,t,r)},981436:e=>{n.$l(e)},981483:e=>{n.Sl(be(e))},981527:(e,t,r,a,o,s,i,u,l)=>{n.Ul({translationOffset:e,rotationOffset:t,poseMatrixOffset:r,landmarksOffset:a,landmarks2DOffset:o,faceRectOffset:s},i,u,l)},981711:(e,t)=>{n.Tl(be(e),be(t))},981768:()=>{n.Ql()},981806:()=>{n.Rl()},981851:()=>{n.Xl()},981892:()=>{n.em()},981934:(e,t)=>{n.Wl({detected:!!e},{detected:!!t})},982005:(e,t)=>{n.dm({detected:!!e,isLeft:!!t})},982070:()=>{n.bm()},982111:e=>{n.Vl(!!e)},982152:e=>{n.Yl(!!e)},982196:(e,t)=>{e=be(e,t),n.Pl(e)},982277:()=>{alert("DeepAR license not valid")},982311:()=>{n.endLoop()},982332:()=>{let e=J("face");if(!e)return 0;e=new Uint8Array(e);var t=co(e.length);return ue.set(e,t),t},982541:()=>{var e=Qr,t=xe(e)+1,n=co(t);return we(e,n,t),n},982695:()=>{var e=Jr,t=xe(e)+1,n=co(t);return we(e,n,t),n},982854:()=>{var e=Zr,t=xe(e)+1,n=co(t);return we(e,n,t),n},983020:()=>{var e=ta,t=xe(e)+1,n=co(t);return we(e,n,t),n},983183:()=>{var e=na,t=xe(e)+1,n=co(t);return we(e,n,t),n},983351:()=>{var e=ea,t=xe(e)+1,n=co(t);return we(e,n,t),n},983516:()=>{var e=ra,t=xe(e)+1,n=co(t);return we(e,n,t),n},983678:()=>{var e=aa,t=xe(e)+1,n=co(t);return we(e,n,t),n},983839:()=>{var e=oa,t=xe(e)+1,n=co(t);return we(e,n,t),n}};function Ue(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function We(e){for(;0<e.length;)e.shift()(n)}var Ve=[],ze=0,je=0;function He(e){return ke.get(e)}function Ge(e){this.Zk=e,this.qk=e-24,this.Mm=function(e){he[this.qk+4>>2]=e},this.xk=function(){return he[this.qk+4>>2]},this.Km=function(e){he[this.qk+8>>2]=e},this.om=function(){return he[this.qk+8>>2]},this.Lm=function(){pe[this.qk>>2]=0},this.ol=function(e){ie[this.qk+12>>0]=e?1:0},this.Lk=function(){return 0!=ie[this.qk+12>>0]},this.pl=function(e){ie[this.qk+13>>0]=e?1:0},this.wl=function(){return 0!=ie[this.qk+13>>0]},this.bl=function(e,t){this.Ak(0),this.Mm(e),this.Km(t),this.Lm(),this.ol(!1),this.pl(!1)},this.Jk=function(){pe[this.qk>>2]+=1},this.zm=function(){var e=pe[this.qk>>2];return pe[this.qk>>2]=e-1,1===e},this.Ak=function(e){he[this.qk+16>>2]=e},this.Kk=function(){return he[this.qk+16>>2]},this.Sk=function(){if(_o(this.xk()))return he[this.Zk>>2];var e=this.Kk();return 0!==e?e:this.Zk}}function Ke(){var e=je;if(!e)return ho(0),0;var t=new Ge(e);t.Ak(e);var n=t.xk();if(!n)return ho(0),e;for(var r=0;r<arguments.length;r++){var a=arguments[r];if(0===a||a===n)break;if(xo(a,n,t.qk+16))return ho(a),e}return ho(n),e}var qe={};function Ye(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Xe(e){return this.fromWireType(pe[e>>2])}var Qe={},Je={},Ze={};function et(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?"_"+e:e}function tt(e,t){return{[e=et(e)]:function(){return t.apply(this,arguments)}}[e]}function nt(e){var t=Error,n=tt(e,(function(t){this.name=e,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var rt=void 0;function at(e){throw new rt(e)}function ot(e,t,n){function r(t){(t=n(t)).length!==e.length&&at("Mismatched type converter count");for(var r=0;r<e.length;++r)pt(e[r],t[r])}e.forEach((function(e){Ze[e]=t}));var a=Array(t.length),o=[],s=0;t.forEach(((e,t)=>{Je.hasOwnProperty(e)?a[t]=Je[e]:(o.push(e),Qe.hasOwnProperty(e)||(Qe[e]=[]),Qe[e].push((()=>{a[t]=Je[e],++s===o.length&&r(a)})))})),0===o.length&&r(a)}function st(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var it=void 0;function ut(e){for(var t="";ue[e];)t+=it[ue[e++]];return t}var lt=void 0;function ct(e){throw new lt(e)}function pt(e,t,n={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var r=t.name;if(e||ct('type "'+r+'" must have a positive integer typeid pointer'),Je.hasOwnProperty(e)){if(n.tm)return;ct("Cannot register type '"+r+"' twice")}Je[e]=t,delete Ze[e],Qe.hasOwnProperty(e)&&(t=Qe[e],delete Qe[e],t.forEach((e=>e())))}function ht(e){ct(e.pk.tk.rk.name+" instance already deleted")}var dt=!1;function ft(){}function mt(e){--e.count.value,0===e.count.value&&(e.yk?e.Bk.Ik(e.yk):e.tk.rk.Ik(e.qk))}function gt(e,t,n){return t===n?e:void 0===n.Dk||null===(e=gt(e,t,n.Dk))?null:n.hm(e)}var yt={},bt=[];function vt(){for(;bt.length;){var e=bt.pop();e.pk.Vk=!1,e.delete()}}var wt=void 0,xt={};function _t(e,t){return t.tk&&t.qk||at("makeClassHandle requires ptr and ptrType"),!!t.Bk!=!!t.yk&&at("Both smartPtrType and smartPtr must be specified"),t.count={value:1},kt(Object.create(e,{pk:{value:t}}))}function kt(e){return"undefined"==typeof FinalizationRegistry?(kt=e=>e,e):(dt=new FinalizationRegistry((e=>{mt(e.pk)})),kt=e=>{var t=e.pk;return t.yk&&dt.register(e,{pk:t},e),e},ft=e=>{dt.unregister(e)},kt(e))}function Tt(){}function St(e,t,n){if(void 0===e[t].vk){var r=e[t];e[t]=function(){return e[t].vk.hasOwnProperty(arguments.length)||ct("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].vk+")!"),e[t].vk[arguments.length].apply(this,arguments)},e[t].vk=[],e[t].vk[r.cl]=r}}function Et(e,t,r){n.hasOwnProperty(e)?((void 0===r||void 0!==n[e].vk&&void 0!==n[e].vk[r])&&ct("Cannot register public name '"+e+"' twice"),St(n,e,e),n.hasOwnProperty(r)&&ct("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!"),n[e].vk[r]=t):(n[e]=t,void 0!==r&&(n[e].pn=r))}function It(e,t,n,r,a,o,s,i){this.name=e,this.constructor=t,this.Wk=n,this.Ik=r,this.Dk=a,this.km=o,this.al=s,this.hm=i,this.wm=[]}function Ct(e,t,n){for(;t!==n;)t.al||ct("Expected null or instance of "+n.name+", got an instance of "+t.name),e=t.al(e),t=t.Dk;return e}function At(e,t){return null===t?(this.kl&&ct("null is not a valid "+this.name),0):(t.pk||ct('Cannot pass "'+Kt(t)+'" as a '+this.name),t.pk.qk||ct("Cannot pass deleted object as a pointer of type "+this.name),Ct(t.pk.qk,t.pk.tk.rk,this.rk))}function Nt(e,t){if(null===t){if(this.kl&&ct("null is not a valid "+this.name),this.el){var n=this.ml();return null!==e&&e.push(this.Ik,n),n}return 0}if(t.pk||ct('Cannot pass "'+Kt(t)+'" as a '+this.name),t.pk.qk||ct("Cannot pass deleted object as a pointer of type "+this.name),!this.dl&&t.pk.tk.dl&&ct("Cannot convert argument of type "+(t.pk.Bk?t.pk.Bk.name:t.pk.tk.name)+" to parameter type "+this.name),n=Ct(t.pk.qk,t.pk.tk.rk,this.rk),this.el)switch(void 0===t.pk.yk&&ct("Passing raw pointer to smart pointer is illegal"),this.Dm){case 0:t.pk.Bk===this?n=t.pk.yk:ct("Cannot convert argument of type "+(t.pk.Bk?t.pk.Bk.name:t.pk.tk.name)+" to parameter type "+this.name);break;case 1:n=t.pk.yk;break;case 2:if(t.pk.Bk===this)n=t.pk.yk;else{var r=t.clone();n=this.ym(n,jt((function(){r.delete()}))),null!==e&&e.push(this.Ik,n)}break;default:ct("Unsupporting sharing policy")}return n}function Rt(e,t){return null===t?(this.kl&&ct("null is not a valid "+this.name),0):(t.pk||ct('Cannot pass "'+Kt(t)+'" as a '+this.name),t.pk.qk||ct("Cannot pass deleted object as a pointer of type "+this.name),t.pk.tk.dl&&ct("Cannot convert argument of type "+t.pk.tk.name+" to parameter type "+this.name),Ct(t.pk.qk,t.pk.tk.rk,this.rk))}function Ft(e,t,n,r){this.name=e,this.rk=t,this.kl=n,this.dl=r,this.el=!1,this.Ik=this.ym=this.ml=this.Al=this.Dm=this.vm=void 0,void 0!==t.Dk?this.toWireType=Nt:(this.toWireType=r?At:Rt,this.zk=null)}function Ot(e,t,r){n.hasOwnProperty(e)||at("Replacing nonexistant public symbol"),void 0!==n[e].vk&&void 0!==r?n[e].vk[r]=t:(n[e]=t,n[e].cl=r)}function Mt(e,t,r){return e.includes("j")?(e=n["dynCall_"+e],t=r&&r.length?e.apply(null,[t].concat(r)):e.call(null,t)):t=He(t).apply(null,r),t}function $t(e,t){var n=(e=ut(e)).includes("j")?function(e,t){var n=[];return function(){return n.length=0,Object.assign(n,arguments),Mt(e,t,n)}}(e,t):He(t);return"function"!=typeof n&&ct("unknown function pointer with signature "+e+": "+t),n}var Dt=void 0;function Pt(e){var t=ut(e=mo(e));return po(e),t}function Lt(e,t){var n=[],r={};throw t.forEach((function e(t){r[t]||Je[t]||(Ze[t]?Ze[t].forEach(e):(n.push(t),r[t]=!0))})),new Dt(e+": "+n.map(Pt).join([", "]))}function Bt(e,t){for(var n=[],r=0;r<e;r++)n.push(he[t+4*r>>2]);return n}function Ut(e,t,n,r,a){var o=t.length;2>o&&ct("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==t[1]&&null!==n,i=!1;for(n=1;n<t.length;++n)if(null!==t[n]&&void 0===t[n].zk){i=!0;break}var u="void"!==t[0].name,l="",c="";for(n=0;n<o-2;++n)l+=(0!==n?", ":"")+"arg"+n,c+=(0!==n?", ":"")+"arg"+n+"Wired";e="return function "+et(e)+"("+l+") {\nif (arguments.length !== "+(o-2)+") {\nthrowBindingError('function "+e+" called with ' + arguments.length + ' arguments, expected "+(o-2)+" args!');\n}\n",i&&(e+="var destructors = [];\n");var p=i?"destructors":"null";for(l="throwBindingError invoker fn runDestructors retType classParam".split(" "),r=[ct,r,a,Ye,t[0],t[1]],s&&(e+="var thisWired = classParam.toWireType("+p+", this);\n"),n=0;n<o-2;++n)e+="var arg"+n+"Wired = argType"+n+".toWireType("+p+", arg"+n+"); // "+t[n+2].name+"\n",l.push("argType"+n),r.push(t[n+2]);if(s&&(c="thisWired"+(0<c.length?", ":"")+c),e+=(u?"var rv = ":"")+"invoker(fn"+(0<c.length?", ":"")+c+");\n",i)e+="runDestructors(destructors);\n";else for(n=s?1:2;n<t.length;++n)o=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==t[n].zk&&(e+=o+"_dtor("+o+"); // "+t[n].name+"\n",l.push(o+"_dtor"),r.push(t[n].zk));return u&&(e+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),l.push(e+"}\n"),function(e){var t=Function;if(!(t instanceof Function))throw new TypeError("new_ called with constructor type "+typeof t+" which is not a function");var n=tt(t.name||"unknownFunctionName",(function(){}));return n.prototype=t.prototype,n=new n,(e=t.apply(n,e))instanceof Object?e:n}(l).apply(null,r)}var Wt=[],Vt=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function zt(e){4<e&&0==--Vt[e].nl&&(Vt[e]=void 0,Wt.push(e))}var jt=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=Wt.length?Wt.pop():Vt.length;return Vt[t]={nl:1,value:e},t}};function Ht(e,t,n){switch(t){case 0:return function(e){return this.fromWireType((n?ie:ue)[e])};case 1:return function(e){return this.fromWireType((n?le:ce)[e>>1])};case 2:return function(e){return this.fromWireType((n?pe:he)[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Gt(e,t){var n=Je[e];return void 0===n&&ct(t+" has unknown type "+Pt(e)),n}function Kt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function qt(e,t){switch(t){case 2:return function(e){return this.fromWireType(de[e>>2])};case 3:return function(e){return this.fromWireType(fe[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Yt(e,t,n){switch(t){case 0:return n?function(e){return ie[e]}:function(e){return ue[e]};case 1:return n?function(e){return le[e>>1]}:function(e){return ce[e>>1]};case 2:return n?function(e){return pe[e>>2]}:function(e){return he[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Qt(e,t){for(var n=e>>1,r=n+t/2;!(n>=r)&&ce[n];)++n;if(32<(n<<=1)-e&&Xt)return Xt.decode(ue.subarray(e,n));for(n="",r=0;!(r>=t/2);++r){var a=le[e+2*r>>1];if(0==a)break;n+=String.fromCharCode(a)}return n}function Jt(e,t,n){if(void 0===n&&(n=2147483647),2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var a=0;a<n;++a)le[t>>1]=e.charCodeAt(a),t+=2;return le[t>>1]=0,t-r}function Zt(e){return 2*e.length}function en(e,t){for(var n=0,r="";!(n>=t/4);){var a=pe[e+4*n>>2];if(0==a)break;++n,65536<=a?(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a)):r+=String.fromCharCode(a)}return r}function tn(e,t,n){if(void 0===n&&(n=2147483647),4>n)return 0;var r=t;n=r+n-4;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a)),pe[t>>2]=o,(t+=4)+4>n)break}return pe[t>>2]=0,t-r}function nn(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);55296<=r&&57343>=r&&++n,t+=4}return t}function rn(e){return 0==e%4&&(0!=e%100||0==e%400)}var an,on=[0,31,60,91,121,152,182,213,244,274,305,335],sn=[0,31,59,90,120,151,181,212,243,273,304,334];function un(e){return(rn(e.getFullYear())?on:sn)[e.getMonth()]+e.getDate()-1}function ln(e){var t=xe(e)+1,n=co(t);return n&&ve(e,ie,n,t),n}function cn(e,t){if(Tn=e,Sn=t,kn)if(wn||(Ne+=1,wn=!0),0==e)xn=function(){var e=0|Math.max(0,yn+t-an());setTimeout(bn,e)};else if(1==e)xn=function(){Pn(bn)};else if(2==e){if("undefined"==typeof setImmediate){var n=[];addEventListener("message",(e=>{"setimmediate"!==e.data&&"setimmediate"!==e.data.target||(e.stopPropagation(),n.shift()())}),!0),setImmediate=function(e){n.push(e),postMessage("setimmediate","*")}}xn=function(){setImmediate(bn)}}}function pn(e){throw se=e,ae||0<Ne||(go(),We(Ie),fo(0),Yr[1].length&&Xr(1,10),Yr[2].length&&Xr(2,10),Ae=!0),se=e,ae||0<Ne||(me=!0),new Ue(e)}function hn(e){if(!(e instanceof Ue||"unwind"==e))throw e}function dn(){if(!(ae||0<Ne))try{pn(se)}catch(e){hn(e)}}function fn(e){if(!Ae&&!me)try{e(),dn()}catch(e){hn(e)}}function mn(e){gn||(gn={}),gn[e]||(gn[e]=1,re(e))}an=()=>performance.now();var gn,yn,bn,vn,wn=!1,xn=null,_n=0,kn=null,Tn=0,Sn=0,En=0,In=[],Cn={},An=!1,Nn=!1,Rn=[];var Fn=!1,On=void 0,Mn=void 0;function $n(){return!!An&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){}).apply(document,[]),!0)}var Dn=0;function Pn(e){if("function"==typeof requestAnimationFrame)requestAnimationFrame(e);else{var t=Date.now();if(0===Dn)Dn=t+1e3/60;else for(;t+2>=Dn;)Dn+=1e3/60;setTimeout(e,Math.max(Dn-t,0))}}function Ln(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}var Bn=[];function Un(){var e=n.canvas;Bn.forEach((function(t){t(e.width,e.height)}))}function Wn(e,t,r){t&&r?(e.Jm=t,e.sm=r):(t=e.Jm,r=e.sm);var a=t,o=r;if(n.forcedAspectRatio&&0<n.forcedAspectRatio&&(a/o<n.forcedAspectRatio?a=Math.round(o*n.forcedAspectRatio):o=Math.round(a/n.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e.parentNode&&"undefined"!=typeof screen){var s=Math.min(screen.width/a,screen.height/o);a=Math.round(a*s),o=Math.round(o*s)}Mn?(e.width!=a&&(e.width=a),e.height!=o&&(e.height=o),void 0!==e.style&&(e.style.removeProperty("width"),e.style.removeProperty("height"))):(e.width!=t&&(e.width=t),e.height!=r&&(e.height=r),void 0!==e.style&&(a!=t||o!=r?(e.style.setProperty("width",a+"px","important"),e.style.setProperty("height",o+"px","important")):(e.style.removeProperty("width"),e.style.removeProperty("height"))))}var Vn,zn,jn,Hn,Gn,Kn=!1,qn=0,Yn=0,Xn=0,Qn={alpha:!1,depth:!1,stencil:!1,antialias:!1},Jn={},Zn=1,er=[],tr=[],nr=[],rr=[],ar=[],or=[],sr=[],ir=[],ur=[],lr=[],cr=[],pr=[],hr={},dr={};function fr(e){vr||(vr=e)}function mr(e){for(var t=Zn++,n=e.length;n<t;n++)e[n]=null;return t}function gr(e,t,n){for(var r="",a=0;a<e;++a){var o=n?pe[n+4*a>>2]:-1;r+=be(pe[t+4*a>>2],0>o?void 0:o)}return r}function yr(e,t){if(n.preinitializedWebGLContext){var r=n.preinitializedWebGLContext;t.ll=Number(r.getParameter(r.VERSION).match(/^WebGL (\d+).\d+/)[1])}else e.xk||(e.xk=e.getContext,e.getContext=function(t,n){return"webgl"==t==(n=e.xk(t,n))instanceof WebGLRenderingContext?n:null}),r=e.getContext("webgl2",t);return r?function(e,t){var n=mr(ir),r={hn:n,attributes:t,version:t.ll,Uk:e};return e.canvas&&(e.canvas.Il=r),ir[n]=r,(void 0===t.im||t.im)&&function(e){if(e||(e=wr),!e.um){e.um=!0;var t=e.Uk;t.en=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),t.ln=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(t.wk=t.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!t.wk)&&(t.wk=t.getExtension("EXT_disjoint_timer_query")),t.nn=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach((function(e){e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}(r),n}(r,t):0}function br(e){wr=ir[e],n.Ok=eo=wr&&wr.Uk}var vr,wr,xr={},_r=[];function kr(e,t,n){var r;for(_r.length=0,n>>=2;r=ue[t++];)n+=105!=r&n,_r.push(105==r?pe[n]:fe[n++>>1]),++n;return Be[e].apply(null,_r)}var Tr={},Sr=0,Er=[];function Ir(e,t,n,r){eo.drawElements(e,t,n,r)}function Cr(e,t,n,r){for(var a=0;a<e;a++){var o=eo[n](),s=o&&mr(r);o?(o.name=s,r[s]=o):fr(1282),pe[t+4*a>>2]=s}}function Ar(e,t,n,r,a,o,s,i){t=tr[t],(e=eo[e](t,n))&&(r=i&&we(e.name,i,r),a&&(pe[a>>2]=r),o&&(pe[o>>2]=e.size),s&&(pe[s>>2]=e.type))}function Nr(e,t){he[e>>2]=t,he[e+4>>2]=(t-he[e>>2])/4294967296}function Rr(e,t,n){if(t){var r=void 0;switch(e){case 36346:r=1;break;case 36344:return void(0!=n&&1!=n&&fr(1280));case 34814:case 36345:r=0;break;case 34466:var a=eo.getParameter(34467);r=a?a.length:0;break;case 33309:if(2>wr.version)return void fr(1282);r=2*(eo.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>wr.version)return void fr(1280);r=33307==e?3:0}if(void 0===r)switch(a=eo.getParameter(e),typeof a){case"number":r=a;break;case"boolean":r=a?1:0;break;case"string":return void fr(1280);case"object":if(null===a)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:r=0;break;default:return void fr(1280)}else{if(a instanceof Float32Array||a instanceof Uint32Array||a instanceof Int32Array||a instanceof Array){for(e=0;e<a.length;++e)switch(n){case 0:pe[t+4*e>>2]=a[e];break;case 2:de[t+4*e>>2]=a[e];break;case 4:ie[t+e>>0]=a[e]?1:0}return}try{r=0|a.name}catch(t){return fr(1280),void re("GL_INVALID_ENUM in glGet"+n+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+t+")")}}break;default:return fr(1280),void re("GL_INVALID_ENUM in glGet"+n+"v: Native code calling glGet"+n+"v("+e+") and it returns "+a+" of type "+typeof a+"!")}switch(n){case 1:Nr(t,r);break;case 0:pe[t>>2]=r;break;case 2:de[t>>2]=r;break;case 4:ie[t>>0]=r?1:0}}else fr(1281)}function Fr(e,t,n,r){if(n){switch(typeof(t=eo.getIndexedParameter(e,t))){case"boolean":e=t?1:0;break;case"number":e=t;break;case"object":if(null===t)switch(e){case 35983:case 35368:e=0;break;default:return void fr(1280)}else{if(!(t instanceof WebGLBuffer))return void fr(1280);e=0|t.name}break;default:return void fr(1280)}switch(r){case 1:Nr(n,e);break;case 0:pe[n>>2]=e;break;case 2:de[n>>2]=e;break;case 4:ie[n>>0]=e?1:0;break;default:throw"internal emscriptenWebGLGetIndexed() error, bad type: "+r}}else fr(1281)}function Or(e){var t=xe(e)+1,n=co(t);return we(e,n,t),n}function Mr(e){return"]"==e.slice(-1)&&e.lastIndexOf("[")}function $r(e){var t,n=e.Tk,r=e.jl;if(!n)for(e.Tk=n={},e.Gl={},t=0;t<eo.getProgramParameter(e,35718);++t){var a=eo.getActiveUniform(e,t),o=a.name;a=a.size;var s=Mr(o);s=0<s?o.slice(0,s):o;var i=e.il;for(e.il+=a,r[s]=[a,i],o=0;o<a;++o)n[i]=o,e.Gl[i++]=s}}function Dr(e){var t=eo.sl;if(t){var n=t.Tk[e];return"number"==typeof n&&(t.Tk[e]=n=eo.getUniformLocation(t,t.Gl[e]+(0<n?"["+n+"]":""))),n}fr(1282)}function Pr(e,t,n,r){if(n)if($r(e=tr[e]),"number"==typeof(e=eo.getUniform(e,Dr(t)))||"boolean"==typeof e)switch(r){case 0:pe[n>>2]=e;break;case 2:de[n>>2]=e}else for(t=0;t<e.length;t++)switch(r){case 0:pe[n+4*t>>2]=e[t];break;case 2:de[n+4*t>>2]=e[t]}else fr(1281)}function Lr(e,t,n,r){if(n)if(e=eo.getVertexAttrib(e,t),34975==t)pe[n>>2]=e&&e.name;else if("number"==typeof e||"boolean"==typeof e)switch(r){case 0:pe[n>>2]=e;break;case 2:de[n>>2]=e;break;case 5:pe[n>>2]=Math.fround(e)}else for(t=0;t<e.length;t++)switch(r){case 0:pe[n+4*t>>2]=e[t];break;case 2:de[n+4*t>>2]=e[t];break;case 5:pe[n+4*t>>2]=Math.fround(e[t])}else fr(1281)}function Br(e){return 0==(e-=5120)?ie:1==e?ue:2==e?le:4==e?pe:6==e?de:5==e||28922==e||28520==e||30779==e||30782==e?he:ce}function Ur(e){return 31-Math.clz32(e.BYTES_PER_ELEMENT)}function Wr(e,t){if(0>=e)return e;var n=32>=t?Math.abs(1<<t-1):Math.pow(2,t-1);return e>=n&&(32>=t||e>n)&&(e=-2*n+e),e}function Vr(e,t){return 0<=e?e:32>=t?2*Math.abs(1<<t-1)+e:Math.pow(2,t)+e}function zr(e){for(var t=e;ue[t];)++t;return t-e}function jr(e,t){var n=Array(xe(e)+1);return e=ve(e,n,0,n.length),t&&(n.length=e),n}function Hr(e){if(!e||!e.callee||!e.callee.name)return[null,"",""];var t,n=e.callee.name,r="(",a=!0;for(t in e){var o=e[t];a||(r+=", "),a=!1,r="number"==typeof o||"string"==typeof o?r+o:r+"("+typeof o+")"}return r+=")",a&&(r=""),[e=(e=e.callee.caller)?e.arguments:[],n,r]}var Gr={};function Kr(){if(!qr){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(e in Gr)void 0===Gr[e]?delete t[e]:t[e]=Gr[e];var n=[];for(e in t)n.push(e+"="+t[e]);qr=n}return qr}var qr,Yr=[null,[],[]];function Xr(e,t){var n=Yr[e];0===t||10===t?((1===e?ne:re)(ye(n,0)),n.length=0):n.push(t)}var Qr=null,Jr=null,Zr=null,ea=null,ta=null,na=null,ra=null,aa=null,oa=null,sa=null,ia=null,ua={},la=!1,ca=null,pa=null,ha=0,da=null,fa=-1,ma=-1,ga=!1,ya=null,ba=null,va=null,wa=null,xa=null,_a=null,ka=null,Ta=null;async function Sa(){if(null==ya&&(ya=new l.Foot),null==ba&&(ba=new l.VideoManager(null)),!ya.isInitialized()&&!ga){ga=!0,console.log("DeepAR FootTracking initialize started.");var e,t=J("footDetector");t||(e=Z("footDetector"));var r,a=J("footTracker");a||(r=Z("footTracker"));var o,s=J("footObj");s||(o=Z("footObj")),t||(t=await e),a||(a=await r),s||(s=await o),await ya.initialize(ba,{poseEstimationWasmFilename:n.footTrackingConfig.poseEstimationWasmPath,modelFilename:t,featuresFilename:a,objFilename:s,fovY:50,detectScoreThs:.25,validTrackedKeypThs:.3,trackScoreThs:.3,footToDetect:"BOTH",wasmBackend:{enable:!0,tfjsBackendWasmPath:n.footTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:n.footTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:n.footTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),ga=!1,console.log("DeepAR FootTracking initialized!")}}function Ea(){return null!=ya&&ya.isInitialized()}function Ia(e){if(!ga&&null!=ya&&ya.isInitialized()){var t=ba.getVideoCanvas();t.width=e.width,t.height=e.height,ba.preProcessWithBuffer(e);try{ya.trackSync()}catch(e){return console.log(e),void(Ta=xa=!1)}e=ya.getInterpolatedPose("LEFT_FOOT"),t=ya.getInterpolatedPose("RIGHT_FOOT"),null!=e&&e.isDetected()?(va=e.t(),wa=e.R(),xa=!0):xa=!1,null!=t&&t.isDetected()?(_a=t.t(),ka=t.R(),Ta=!0):Ta=!1}}var Ca=null,Aa=null,Na=null,Ra=!1;function Fa(e,t){if(Ca.isInitialized()){var n=Aa.getVideoCanvas();n.width=e.width,n.height=e.height,Aa.preProcessWithBuffer(e),Ca.processSync(),Na=Ca.getOutput(),Aa.postProcess(),de.set(Na,t>>2)}}async function Oa(){if(null==Ca&&(Ca=new l.Segmentation),null==Aa&&(Aa=new l.VideoManager(null)),!Ca.isInitialized()&&!Ra){console.log("DeepAR segmentation initialize started"),Ra=!0;var e=J("segmentation");e||(e=await Z("segmentation")),await Ca.initialize(Aa,{filename:e}),Ra=!1,console.log("DeepAR segmentation initialized")}}function Ma(){return null!=Ca&&Ca.isInitialized()}var $a=!1,Da=null,Pa=null,La=null,Ba=null,Ua=null,Wa=0,Va=0;function za(){return null!=Da&&Da.isInitialized()}function ja(e){if(za()){var t=Pa.getVideoCanvas();t.width=e.width,t.height=e.height,Pa.preProcessWithBuffer(e);try{Da.trackSync()}catch(e){return console.log(e),void(La=!1)}e=!1,Da.isDetected()?(++Wa>Va&&(e=!0),(La=e)&&(e=Da.getInterpolatedPose(),Ba=e.t(),Ua=e.R())):(Wa=0,La=!1)}}function Ha(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var Ga=[31,29,31,30,31,30,31,31,30,31,30,31],Ka=[31,28,31,30,31,30,31,31,30,31,30,31];function qa(e,t){for(e=new Date(e.getTime());0<t;){var n=e.getMonth(),r=(rn(e.getFullYear())?Ga:Ka)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function Ya(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function o(e,t){return a(e,t,"0")}function s(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function i(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){e=qa(new Date(e.Rk+1900,0,1),e.Qk);var t=new Date(e.getFullYear()+1,0,4),n=i(new Date(e.getFullYear(),0,4));return t=i(t),0>=s(n,e)?0>=s(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=pe[r+40>>2];for(var c in r={Gm:pe[r>>2],Fm:pe[r+4>>2],gl:pe[r+8>>2],ql:pe[r+12>>2],hl:pe[r+16>>2],Rk:pe[r+20>>2],Ek:pe[r+24>>2],Qk:pe[r+28>>2],tn:pe[r+32>>2],Em:pe[r+36>>2],Hm:l?be(l):""},n=be(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),l[c]);var p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),h="January February March April May June July August September October November December".split(" ");for(c in l={"%a":function(e){return p[e.Ek].substring(0,3)},"%A":function(e){return p[e.Ek]},"%b":function(e){return h[e.hl].substring(0,3)},"%B":function(e){return h[e.hl]},"%C":function(e){return o((e.Rk+1900)/100|0,2)},"%d":function(e){return o(e.ql,2)},"%e":function(e){return a(e.ql,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return o(e.gl,2)},"%I":function(e){return 0==(e=e.gl)?e=12:12<e&&(e-=12),o(e,2)},"%j":function(e){return o(e.ql+Ha(rn(e.Rk+1900)?Ga:Ka,e.hl-1),3)},"%m":function(e){return o(e.hl+1,2)},"%M":function(e){return o(e.Fm,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.gl&&12>e.gl?"AM":"PM"},"%S":function(e){return o(e.Gm,2)},"%t":function(){return"\t"},"%u":function(e){return e.Ek||7},"%U":function(e){return o(Math.floor((e.Qk+7-e.Ek)/7),2)},"%V":function(e){var t=Math.floor((e.Qk+7-(e.Ek+6)%7)/7);if(2>=(e.Ek+371-e.Qk-2)%7&&t++,t)53==t&&(4==(n=(e.Ek+371-e.Qk)%7)||3==n&&rn(e.Rk)||(t=1));else{t=52;var n=(e.Ek+7-e.Qk-1)%7;(4==n||5==n&&rn(e.Rk%400-1))&&t++}return o(t,2)},"%w":function(e){return e.Ek},"%W":function(e){return o(Math.floor((e.Qk+7-(e.Ek+6)%7)/7),2)},"%y":function(e){return(e.Rk+1900).toString().substring(2)},"%Y":function(e){return e.Rk+1900},"%z":function(e){var t=0<=(e=e.Em);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Hm},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return(c=jr(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(ie.set(c,e),c.length-1)}function Xa(e,t,r,a){var o={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);we(e,t=wo(n),n)}return t},array:e=>{var t=wo(e.length);return ie.set(e,t),t}};e=n["_"+e];var s=[],i=0;if(a)for(var u=0;u<a.length;u++){var l=o[r[u]];l?(0===i&&(i=bo()),s[u]=l(a[u])):s[u]=a[u]}return function(e){return 0!==i&&vo(i),"string"===t?be(e):"boolean"===t?!!e:e}(r=e.apply(null,s))}function Qa(e,t,r,a){var o=!r||r.every((e=>"number"===e||"boolean"===e));return"string"!==t&&o&&!a?n["_"+e]:function(){return Xa(e,t,r,arguments)}}rt=n.InternalError=nt("InternalError");for(var Ja=Array(256),Za=0;256>Za;++Za)Ja[Za]=String.fromCharCode(Za);it=Ja,lt=n.BindingError=nt("BindingError"),Tt.prototype.isAliasOf=function(e){if(!(this instanceof Tt&&e instanceof Tt))return!1;var t=this.pk.tk.rk,n=this.pk.qk,r=e.pk.tk.rk;for(e=e.pk.qk;t.Dk;)n=t.al(n),t=t.Dk;for(;r.Dk;)e=r.al(e),r=r.Dk;return t===r&&n===e},Tt.prototype.clone=function(){if(this.pk.qk||ht(this),this.pk.$k)return this.pk.count.value+=1,this;var e=kt,t=Object,n=t.create,r=Object.getPrototypeOf(this),a=this.pk;return(e=e(n.call(t,r,{pk:{value:{count:a.count,Vk:a.Vk,$k:a.$k,qk:a.qk,tk:a.tk,yk:a.yk,Bk:a.Bk}}}))).pk.count.value+=1,e.pk.Vk=!1,e},Tt.prototype.delete=function(){this.pk.qk||ht(this),this.pk.Vk&&!this.pk.$k&&ct("Object already scheduled for deletion"),ft(this),mt(this.pk),this.pk.$k||(this.pk.yk=void 0,this.pk.qk=void 0)},Tt.prototype.isDeleted=function(){return!this.pk.qk},Tt.prototype.deleteLater=function(){return this.pk.qk||ht(this),this.pk.Vk&&!this.pk.$k&&ct("Object already scheduled for deletion"),bt.push(this),1===bt.length&&wt&&wt(vt),this.pk.Vk=!0,this},n.getInheritedInstanceCount=function(){return Object.keys(xt).length},n.getLiveInheritedInstances=function(){var e,t=[];for(e in xt)xt.hasOwnProperty(e)&&t.push(xt[e]);return t},n.flushPendingDeletes=vt,n.setDelayFunction=function(e){wt=e,bt.length&&wt&&wt(vt)},Ft.prototype.nm=function(e){return this.Al&&(e=this.Al(e)),e},Ft.prototype.tl=function(e){this.Ik&&this.Ik(e)},Ft.prototype.argPackAdvance=8,Ft.prototype.readValueFromPointer=Xe,Ft.prototype.deleteObject=function(e){null!==e&&e.delete()},Ft.prototype.fromWireType=function(e){function t(){return this.el?_t(this.rk.Wk,{tk:this.vm,qk:n,Bk:this,yk:e}):_t(this.rk.Wk,{tk:this,qk:e})}var n=this.nm(e);if(!n)return this.tl(e),null;var r=function(e,t){for(void 0===t&&ct("ptr should not be undefined");e.Dk;)t=e.al(t),e=e.Dk;return xt[t]}(this.rk,n);if(void 0!==r)return 0===r.pk.count.value?(r.pk.qk=n,r.pk.yk=e,r.clone()):(r=r.clone(),this.tl(e),r);if(r=this.rk.km(n),!(r=yt[r]))return t.call(this);r=this.dl?r.gm:r.pointerType;var a=gt(n,this.rk,r.rk);return null===a?t.call(this):this.el?_t(r.rk.Wk,{tk:r,qk:a,Bk:this,yk:e}):_t(r.rk.Wk,{tk:r,qk:a})},Dt=n.UnboundTypeError=nt("UnboundTypeError"),n.count_emval_handles=function(){for(var e=0,t=5;t<Vt.length;++t)void 0!==Vt[t]&&++e;return e},n.get_first_emval=function(){for(var e=5;e<Vt.length;++e)if(void 0!==Vt[e])return Vt[e];return null},n.requestFullscreen=function(e,t){!function(e,t){function r(){An=!1;var e=a.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(a.exitFullscreen=$n,On&&a.requestPointerLock(),An=!0,Mn?("undefined"!=typeof SDL&&(pe[SDL.screen>>2]=8388608|he[SDL.screen>>2]),Wn(n.canvas),Un()):Wn(a)):(e.parentNode.insertBefore(a,e),e.parentNode.removeChild(e),Mn?("undefined"!=typeof SDL&&(pe[SDL.screen>>2]=-8388609&he[SDL.screen>>2]),Wn(n.canvas),Un()):Wn(a)),n.onFullScreen&&n.onFullScreen(An),n.onFullscreen&&n.onFullscreen(An)}void 0===(On=e)&&(On=!0),void 0===(Mn=t)&&(Mn=!1);var a=n.canvas;Fn||(Fn=!0,document.addEventListener("fullscreenchange",r,!1),document.addEventListener("mozfullscreenchange",r,!1),document.addEventListener("webkitfullscreenchange",r,!1),document.addEventListener("MSFullscreenChange",r,!1));var o=document.createElement("div");a.parentNode.insertBefore(o,a),o.appendChild(a),o.requestFullscreen=o.requestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen||(o.webkitRequestFullscreen?()=>o.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):null)||(o.webkitRequestFullScreen?()=>o.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):null),o.requestFullscreen()}(e,t)},n.requestAnimationFrame=function(e){Pn(e)},n.setCanvasSize=function(e,t,r){Wn(n.canvas,e,t),r||Un()},n.pauseMainLoop=function(){xn=null,_n++},n.resumeMainLoop=function(){_n++;var e=Tn,t=Sn,r=kn;kn=null,function(e){function t(){return!(r<_n&&(--Ne,dn(),1))}!kn||Me("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."),kn=e;var r=_n;wn=!1,bn=function(){if(!me)if(0<In.length){var r=Date.now(),a=In.shift();if(a.gn(a.cn),vn){var o=vn,s=0==o%1?o-1:Math.floor(o);vn=a.dn?s:(8*o+(s+.5))/9}ne('main loop blocker "'+a.name+'" took '+(Date.now()-r)+" ms"),n.setStatus&&(r=n.statusMessage||"Please wait...",o=Cn.fn,(a=vn)?a<o?n.setStatus(r+" ("+(o-a)+"/"+o+")"):n.setStatus(r):n.setStatus("")),t()&&setTimeout(bn,0)}else t()&&(En=En+1|0,1==Tn&&1<Sn&&0!=En%Sn?xn():(0==Tn&&(yn=an()),me||n.preMainLoop&&!1===n.preMainLoop()||(fn(e),n.postMainLoop&&n.postMainLoop()),t()&&("object"==typeof SDL&&SDL.audio&&SDL.audio.xm&&SDL.audio.xm(),xn())))}}(r),cn(e,t),xn()},n.getUserMedia=function(){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(void 0)},n.createContext=function(e,t,r,a){return function(e,t,r,a){if(t&&n.Ok&&e==n.canvas)return n.Ok;var o;if(t){var s={antialias:!1,alpha:!1,ll:2};if(a)for(var i in a)s[i]=a[i];if(void 0!==xr&&(o=yr(e,s)))var u=ir[o].Uk}else u=e.getContext("2d");return u?(r&&(t||void 0===eo||Me("cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),n.Ok=u,t&&br(o),n.Im=t,Rn.forEach((function(e){e()})),function(){function e(){Nn=document.pointerLockElement===n.canvas||document.mozPointerLockElement===n.canvas||document.webkitPointerLockElement===n.canvas||document.msPointerLockElement===n.canvas}if(n.preloadPlugins||(n.preloadPlugins=[]),!Vn){Vn=!0;try{zn=!0}catch(e){zn=!1,re("warning: no blob constructor, cannot create blobs with mimetypes")}jn="undefined"!=typeof MozBlobBuilder?MozBlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:zn?null:re("warning: no BlobBuilder"),Hn="undefined"!=typeof window?window.URL?window.URL:window.webkitURL:void 0,n.yl||void 0!==Hn||(re("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),n.yl=!0),n.preloadPlugins.push({canHandle:function(e){return!n.yl&&/\.(jpg|jpeg|png|bmp)$/i.test(e)},handle:function(e,t,n,r){var a=null;if(zn)try{(a=new Blob([e],{type:Ln(t)})).size!==e.length&&(a=new Blob([new Uint8Array(e).buffer],{type:Ln(t)}))}catch(e){mn("Blob constructor present but fails: "+e+"; falling back to blob builder")}a||((a=new jn).append(new Uint8Array(e).buffer),a=a.getBlob());var o=Hn.createObjectURL(a),s=new Image;s.onload=()=>{s.complete||Me("Image "+t+" could not be decoded");var r=document.createElement("canvas");r.width=s.width,r.height=s.height,r.getContext("2d").drawImage(s,0,0),Hn.revokeObjectURL(o),n&&n(e)},s.onerror=()=>{ne("Image "+o+" could not be decoded"),r&&r()},s.src=o}}),n.preloadPlugins.push({canHandle:function(e){return!n.on&&e.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},handle:function(e,t,n,r){function a(){s||(s=!0,n&&n(e))}function o(){s||(s=!0,new Audio,r&&r())}var s=!1;if(!zn)return o();try{var i=new Blob([e],{type:Ln(t)})}catch(e){return o()}i=Hn.createObjectURL(i);var u=new Audio;u.addEventListener("canplaythrough",(()=>a()),!1),u.onerror=function(){if(!s){re("warning: browser could not fully decode audio "+t+", trying slower base64 approach");for(var n="",r=0,o=0,i=0;i<e.length;i++)for(r=r<<8|e[i],o+=8;6<=o;){var l=r>>o-6&63;o-=6,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[l]}2==o?(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&r)<<4],n+="=="):4==o&&(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&r)<<2],n+="="),u.src="data:audio/x-"+t.substr(-3)+";base64,"+n,a()}},u.src=i,function(e){Ne+=1,setTimeout((function(){--Ne,fn(e)}),1e4)}((function(){a()}))}});var t=n.canvas;t&&(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock||t.msRequestPointerLock||(()=>{}),t.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||(()=>{}),t.exitPointerLock=t.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",e,!1),document.addEventListener("mozpointerlockchange",e,!1),document.addEventListener("webkitpointerlockchange",e,!1),document.addEventListener("mspointerlockchange",e,!1),n.elementPointerLock&&t.addEventListener("click",(e=>{!Nn&&n.canvas.requestPointerLock&&(n.canvas.requestPointerLock(),e.preventDefault())}),!1))}}()),u):null}(e,t,r,a)};for(var eo,to=0;32>to;++to)Er.push(Array(to));(ca=document.createElement("canvas")).style.display="none",pa=ca.getContext("2d",{willReadFrequently:!0,desynchronized:!0,alpha:!1});e:{if(!window.AudioContext){if(!window.webkitAudioContext){console.error("Audio playback is not supported!");break e}window.AudioContext=window.webkitAudioContext}sa=new AudioContext,(ia=sa.createGain()).connect(sa.destination),la=!0}var no={l:function(e,t,n,r){Me("Assertion failed: "+be(e)+", at: "+[t?be(t):"unknown filename",n,r?be(r):"unknown function"])},m:function(e){return(e=new Ge(e)).Lk()||(e.ol(!0),ze--),e.pl(!1),Ve.push(e),e.Jk(),e.Sk()},w:function(){yo(0);var e=Ve.pop();if(e.zm()&&!e.wl()){var t=e.om();t&&He(t)(e.Zk),ao(e.Zk)}je=0},a:Ke,c:Ke,f:Ke,ba:Ke,mb:function(){var e=Ve.pop();e||Me("no exception to throw");var t=e.Zk;throw e.wl()||(Ve.push(e),e.pl(!0),e.ol(!1),ze++),je=t,t},I:function(e,t,n){throw new Ge(e).bl(t,n),je=e,ze++,e},jc:function(){return ze},e:function(e){throw je||(je=e),e},Na:function(){return 0},rc:function(){return 0},sc:function(){},lh:function(e){var t=qe[e];delete qe[e];var n=t.ml,r=t.Ik,a=t.vl,o=a.map((e=>e.rm)).concat(a.map((e=>e.Bm)));ot([e],o,(e=>{var o={};return a.forEach(((t,n)=>{var r=e[n],s=t.pm,i=t.qm,u=e[n+a.length],l=t.Am,c=t.Cm;o[t.jm]={read:e=>r.fromWireType(s(i,e)),write:(e,t)=>{var n=[];l(c,e,u.toWireType(n,t)),Ye(n)}}})),[{name:t.name,fromWireType:function(e){var t,n={};for(t in o)n[t]=o[t].read(e);return r(e),n},toWireType:function(e,t){for(var a in o)if(!(a in t))throw new TypeError('Missing field: "'+a+'"');var s=n();for(a in o)o[a].write(s,t[a]);return null!==e&&e.push(r,s),s},argPackAdvance:8,readValueFromPointer:Xe,zk:r}]}))},Zb:function(){},Wh:function(e,t,n,r,a){var o=st(n);pt(e,{name:t=ut(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:a},argPackAdvance:8,readValueFromPointer:function(e){if(1===n)var r=ie;else if(2===n)r=le;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+t);r=pe}return this.fromWireType(r[e>>o])},zk:null})},Hg:function(e,t,n,r,a,o,s,i,u,l,c,p,h){c=ut(c),o=$t(a,o),i&&(i=$t(s,i)),l&&(l=$t(u,l)),h=$t(p,h);var d=et(c);Et(d,(function(){Lt("Cannot construct "+c+" due to unbound types",[r])})),ot([e,t,n],r?[r]:[],(function(t){if(t=t[0],r)var n=t.rk,a=n.Wk;else a=Tt.prototype;t=tt(d,(function(){if(Object.getPrototypeOf(this)!==s)throw new lt("Use 'new' to construct "+c);if(void 0===u.Nk)throw new lt(c+" has no accessible constructor");var e=u.Nk[arguments.length];if(void 0===e)throw new lt("Tried to invoke ctor of "+c+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(u.Nk).toString()+") parameters instead!");return e.apply(this,arguments)}));var s=Object.create(a,{constructor:{value:t}});t.prototype=s;var u=new It(c,t,s,h,n,o,i,l);n=new Ft(c,u,!0,!1),a=new Ft(c+"*",u,!1,!1);var p=new Ft(c+" const*",u,!1,!0);return yt[e]={pointerType:a,gm:p},Ot(d,t),[n,a,p]}))},wg:function(e,t,n,r,a,o){0<t||Me();var s=Bt(t,n);a=$t(r,a),ot([],[e],(function(e){var n="constructor "+(e=e[0]).name;if(void 0===e.rk.Nk&&(e.rk.Nk=[]),void 0!==e.rk.Nk[t-1])throw new lt("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.rk.Nk[t-1]=()=>{Lt("Cannot construct "+e.name+" due to unbound types",s)},ot([],s,(function(r){return r.splice(1,0,null),e.rk.Nk[t-1]=Ut(n,r,null,a,o),[]})),[]}))},_:function(e,t,n,r,a,o,s,i){var u=Bt(n,r);t=ut(t),o=$t(a,o),ot([],[e],(function(e){function r(){Lt("Cannot call "+a+" due to unbound types",u)}var a=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),i&&e.rk.wm.push(t);var l=e.rk.Wk,c=l[t];return void 0===c||void 0===c.vk&&c.className!==e.name&&c.cl===n-2?(r.cl=n-2,r.className=e.name,l[t]=r):(St(l,t,a),l[t].vk[n-2]=r),ot([],u,(function(r){return r=Ut(a,r,e,o,s),void 0===l[t].vk?(r.cl=n-2,l[t]=r):l[t].vk[n-2]=r,[]})),[]}))},Vh:function(e,t){pt(e,{name:t=ut(t),fromWireType:function(e){e||ct("Cannot use deleted val. handle = "+e);var t=Vt[e].value;return zt(e),t},toWireType:function(e,t){return jt(t)},argPackAdvance:8,readValueFromPointer:Xe,zk:null})},Rh:function(e,t,n,r){function a(){}n=st(n),t=ut(t),a.values={},pt(e,{name:t,constructor:a,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:Ht(t,n,r),zk:null}),Et(t,a)},qa:function(e,t,n){var r=Gt(e,"enum");t=ut(t),e=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:tt(r.name+"_"+t,(function(){}))}}),e.values[n]=r,e[t]=r},Qa:function(e,t,n){n=st(n),pt(e,{name:t=ut(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:qt(t,n),zk:null})},ah:function(e,t,n,r,a,o){var s=Bt(t,n);e=ut(e),a=$t(r,a),Et(e,(function(){Lt("Cannot call "+e+" due to unbound types",s)}),t-1),ot([],s,(function(n){return Ot(e,Ut(e,[n[0],null].concat(n.slice(1)),null,a,o),t-1),[]}))},P:function(e,t,n,r,a){t=ut(t),-1===a&&(a=4294967295),a=st(n);var o=e=>e;if(0===r){var s=32-8*n;o=e=>e<<s>>>s}n=t.includes("unsigned")?function(e,t){return t>>>0}:function(e,t){return t},pt(e,{name:t,fromWireType:o,toWireType:n,argPackAdvance:8,readValueFromPointer:Yt(t,a,0!==r),zk:null})},G:function(e,t,n){function r(e){e>>=2;var t=he;return new a(t.buffer,t[e+1],t[e])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];pt(e,{name:n=ut(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{tm:!0})},Pa:function(e,t){var n="std::string"===(t=ut(t));pt(e,{name:t,fromWireType:function(e){var t=he[e>>2],r=e+4;if(n)for(var a=r,o=0;o<=t;++o){var s=r+o;if(o==t||0==ue[s]){if(a=be(a,s-a),void 0===i)var i=a;else i+=String.fromCharCode(0),i+=a;a=s+1}}else{for(i=Array(t),o=0;o<t;++o)i[o]=String.fromCharCode(ue[r+o]);i=i.join("")}return po(e),i},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r,a="string"==typeof t;a||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||ct("Cannot pass non-string to std::string"),r=n&&a?xe(t):t.length;var o=co(4+r+1),s=o+4;if(he[o>>2]=r,n&&a)we(t,s,r+1);else if(a)for(a=0;a<r;++a){var i=t.charCodeAt(a);255<i&&(po(s),ct("String has UTF-16 code units that do not fit in 8 bits")),ue[s+a]=i}else for(a=0;a<r;++a)ue[s+a]=t[a];return null!==e&&e.push(po,o),o},argPackAdvance:8,readValueFromPointer:Xe,zk:function(e){po(e)}})},ra:function(e,t,n){if(n=ut(n),2===t)var r=Qt,a=Jt,o=Zt,s=()=>ce,i=1;else 4===t&&(r=en,a=tn,o=nn,s=()=>he,i=2);pt(e,{name:n,fromWireType:function(e){for(var n,a=he[e>>2],o=s(),u=e+4,l=0;l<=a;++l){var c=e+4+l*t;l!=a&&0!=o[c>>i]||(u=r(u,c-u),void 0===n?n=u:(n+=String.fromCharCode(0),n+=u),u=c+t)}return po(e),n},toWireType:function(e,r){"string"!=typeof r&&ct("Cannot pass non-string to C++ string type "+n);var s=o(r),u=co(4+s+t);return he[u>>2]=s>>i,a(r,u+4,s+t),null!==e&&e.push(po,u),u},argPackAdvance:8,readValueFromPointer:Xe,zk:function(e){po(e)}})},wh:function(e,t,n,r,a,o){qe[e]={name:ut(t),ml:$t(n,r),Ik:$t(a,o),vl:[]}},Oa:function(e,t,n,r,a,o,s,i,u,l){qe[e].vl.push({jm:ut(t),rm:n,pm:$t(r,a),qm:o,Bm:s,Am:$t(i,u),Cm:l})},Xh:function(e,t){pt(e,{jn:!0,name:t=ut(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},tc:function(){return!0},kc:function(){throw 1/0},Hf:zt,Sf:function(e){4<e&&(Vt[e].nl+=1)},bg:function(e,t){return e=(e=Gt(e,"_emval_take_value")).readValueFromPointer(t),jt(e)},uc:function(e,t){e=new Date(1e3*(he[e>>2]+4294967296*pe[e+4>>2])),pe[t>>2]=e.getUTCSeconds(),pe[t+4>>2]=e.getUTCMinutes(),pe[t+8>>2]=e.getUTCHours(),pe[t+12>>2]=e.getUTCDate(),pe[t+16>>2]=e.getUTCMonth(),pe[t+20>>2]=e.getUTCFullYear()-1900,pe[t+24>>2]=e.getUTCDay(),pe[t+28>>2]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},vc:function(e,t){e=new Date(1e3*(he[e>>2]+4294967296*pe[e+4>>2])),pe[t>>2]=e.getSeconds(),pe[t+4>>2]=e.getMinutes(),pe[t+8>>2]=e.getHours(),pe[t+12>>2]=e.getDate(),pe[t+16>>2]=e.getMonth(),pe[t+20>>2]=e.getFullYear()-1900,pe[t+24>>2]=e.getDay(),pe[t+28>>2]=0|un(e),pe[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset(),r=new Date(e.getFullYear(),0,1).getTimezoneOffset();pe[t+32>>2]=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n))},wc:function(e){var t=new Date(pe[e+20>>2]+1900,pe[e+16>>2],pe[e+12>>2],pe[e+8>>2],pe[e+4>>2],pe[e>>2],0),n=pe[e+32>>2],r=t.getTimezoneOffset(),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),o=new Date(t.getFullYear(),0,1).getTimezoneOffset(),s=Math.min(o,a);return 0>n?pe[e+32>>2]=Number(a!=o&&s==r):0<n!=(s==r)&&(a=Math.max(o,a),t.setTime(t.getTime()+6e4*((0<n?s:a)-r))),pe[e+24>>2]=t.getDay(),pe[e+28>>2]=0|un(t),pe[e>>2]=t.getSeconds(),pe[e+4>>2]=t.getMinutes(),pe[e+8>>2]=t.getHours(),pe[e+12>>2]=t.getDate(),pe[e+16>>2]=t.getMonth(),pe[e+20>>2]=t.getYear(),t.getTime()/1e3|0},yc:function(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}var a=(new Date).getFullYear(),o=new Date(a,0,1),s=new Date(a,6,1);a=o.getTimezoneOffset();var i=s.getTimezoneOffset();he[e>>2]=60*Math.max(a,i),pe[t>>2]=Number(a!=i),e=r(o),t=r(s),e=ln(e),t=ln(t),i<a?(he[n>>2]=e,he[n+4>>2]=t):(he[n>>2]=t,he[n+4>>2]=e)},N:function(){Me("")},ke:function(e){try{var t=Function('return (function() {}.constructor("return this")( ));')()}catch(e){t=window}var n;for(n in t)if(8==n.length&&116==n.charCodeAt(7)&&101==n.charCodeAt(5)&&117==n.charCodeAt(3)&&100==n.charCodeAt(0)){var r=n;break}for(var a in t[r])if(6==a.length&&110==a.charCodeAt(5)&&100==a.charCodeAt(0)){var o=a;break}return t[r][o].charCodeAt(e)},Gi:function(e,t,n,r,a){if(62e3!=e)n=0;else{if(t)for(;;){if(12321==(e=pe[t>>2]))Qn.alpha=0<pe[t+4>>2];else if(12325==e)Qn.depth=0<pe[t+4>>2];else if(12326==e)Qn.stencil=0<pe[t+4>>2];else if(12337==e)e=pe[t+4>>2],Qn.antialias=0<e;else if(12338==e)e=pe[t+4>>2],Qn.antialias=1==e;else if(12544==e)Qn.kn=12547!=pe[t+4>>2];else if(12344==e)break;t+=8}n&&r||a?(a&&(pe[a>>2]=1),n&&0<r&&(pe[n>>2]=62002),n=1):n=0}return n},nb:function(e,t,r,a){if(62e3!=e)return 0;for(e=1;;){if(12440!=(t=pe[a>>2])){if(12344==t)break;return 0}e=pe[a+4>>2],a+=8}return 2>e||3<e?0:(Qn.ll=e-1,Qn.mn=0,0!=(Gn=yr(n.canvas,Qn))?(br(Gn),n.Im=!0,Rn.forEach((function(e){e()})),br(null),62004):0)},ob:function(e,t){return 62e3!=e||62002!=t?0:62006},lb:function(e,t){return 62e3!=e||62004!=t?0:(wr===ir[e=Gn]&&(wr=null),"object"==typeof JSEvents&&JSEvents.rn(ir[e].Uk.canvas),ir[e]&&ir[e].Uk.canvas&&(ir[e].Uk.canvas.Il=void 0),ir[e]=null,qn==t&&(qn=0),1)},kb:function(e,t){return 62e3!=e?0:(62006!=t||(Yn==t&&(Yn=0),Xn==t&&(Xn=0)),1)},Ii:function(){return 62e3},Hi:function(e,t,n){return 62e3!=e?0:(t&&(pe[t>>2]=1),n&&(pe[n>>2]=4),Kn=!0,1)},R:function(e,t,n,r){return 62e3!=e||0!=r&&62004!=r||0!=n&&62006!=n||0!=t&&62006!=t?0:(br(r?Gn:null),qn=r,Xn=t,Yn=n,1)},ma:function(e,t){if(62e3!=e)return 0;if(Jn[t])return Jn[t];switch(t){case 12371:e=ln("Emscripten");break;case 12372:e=ln("1.4 Emscripten EGL");break;case 12373:e=ln("");break;case 12429:e=ln("OpenGL_ES");break;default:return 0}return Jn[t]=e},jb:function(){return Kn&&n.Ok&&!n.Ok.isContextLost()?1:0},ib:function(e,t){return 62e3!=e?0:(0==t?cn(0,0):cn(1,t),1)},Fi:function(e){return 62e3!=e?0:(Xn=Yn=qn=0,Kn=!1,1)},u:kr,Ic:kr,Ub:function(e,t,n,r,a,o,s,i){function u(){if(s){var e=0;if(c.statusText){var t=xe(c.statusText)+1;e=wo(t),we(c.statusText,e,t)}He(s)(p,r,c.status,e)}}var l=be(e);e=be(t),n=be(n);var c=new XMLHttpRequest;c.open(e,l,!0),c.responseType="arraybuffer";var p=function(){var e=Sr;return Sr++,e}();return c.onload=function(){if(200<=c.status&&300>c.status||0===c.status&&"http"!=l.substr(0,4).toLowerCase()){var e=new Uint8Array(c.response),t=co(e.length);ue.set(e,t),o&&He(o)(p,r,t,e.length),a&&po(t)}else u();delete Tr[p]},c.onerror=function(){u(),delete Tr[p]},c.onprogress=function(e){i&&He(i)(p,r,e.loaded,e.lengthComputable||void 0===e.lengthComputable?e.total:0)},c.onabort=function(){delete Tr[p]},"POST"==e?(c.setRequestHeader("Content-type","application/x-www-form-urlencoded"),c.send(n)):c.send(null),Tr[p]=c,p},pa:function(){return Date.now()},mf:function(e){ae=!1,Ne=0,pn(e)},mc:function(){return 2147483648},na:an,Ah:function(e){eo.activeTexture(e)},zh:function(e,t){eo.attachShader(tr[e],or[t])},se:function(e,t){eo.beginQuery(e,ur[t])},Qh:function(e,t){eo.wk.beginQueryEXT(e,ur[t])},Yd:function(e){eo.beginTransformFeedback(e)},yh:function(e,t,n){eo.bindAttribLocation(tr[e],t,be(n))},xh:function(e,t){35051==e?eo.Pk=t:35052==e&&(eo.uk=t),eo.bindBuffer(e,er[t])},Vd:function(e,t,n){eo.bindBufferBase(e,t,er[n])},Wd:function(e,t,n,r,a){eo.bindBufferRange(e,t,er[n],r,a)},vh:function(e,t){eo.bindFramebuffer(e,nr[t])},uh:function(e,t){eo.bindRenderbuffer(e,rr[t])},ad:function(e,t){eo.bindSampler(e,lr[t])},th:function(e,t){eo.bindTexture(e,ar[t])},Uc:function(e,t){eo.bindTransformFeedback(e,cr[t])},ce:function(e){eo.bindVertexArray(sr[e])},Ih:function(e){eo.bindVertexArray(sr[e])},sh:function(e,t,n,r){eo.blendColor(e,t,n,r)},rh:function(e){eo.blendEquation(e)},qh:function(e,t){eo.blendEquationSeparate(e,t)},ph:function(e,t){eo.blendFunc(e,t)},oh:function(e,t,n,r){eo.blendFuncSeparate(e,t,n,r)},fe:function(e,t,n,r,a,o,s,i,u,l){eo.blitFramebuffer(e,t,n,r,a,o,s,i,u,l)},nh:function(e,t,n,r){n&&t?eo.bufferData(e,ue,r,n,t):eo.bufferData(e,t,r)},mh:function(e,t,n,r){n&&eo.bufferSubData(e,t,ue,r,n)},kh:function(e){return eo.checkFramebufferStatus(e)},jh:function(e){eo.clear(e)},yd:function(e,t,n,r){eo.clearBufferfi(e,t,n,r)},zd:function(e,t,n){eo.clearBufferfv(e,t,de,n>>2)},Bd:function(e,t,n){eo.clearBufferiv(e,t,pe,n>>2)},Ad:function(e,t,n){eo.clearBufferuiv(e,t,he,n>>2)},ih:function(e,t,n,r){eo.clearColor(e,t,n,r)},hh:function(e){eo.clearDepth(e)},gh:function(e){eo.clearStencil(e)},kd:function(e,t,n,r){return eo.clientWaitSync(pr[e],t,(n>>>0)+4294967296*r)},fh:function(e,t,n,r){eo.colorMask(!!e,!!t,!!n,!!r)},eh:function(e){eo.compileShader(or[e])},dh:function(e,t,n,r,a,o,s,i){eo.uk||!s?eo.compressedTexImage2D(e,t,n,r,a,o,s,i):eo.compressedTexImage2D(e,t,n,r,a,o,ue,i,s)},ye:function(e,t,n,r,a,o,s,i,u){eo.uk?eo.compressedTexImage3D(e,t,n,r,a,o,s,i,u):eo.compressedTexImage3D(e,t,n,r,a,o,s,ue,u,i)},ch:function(e,t,n,r,a,o,s,i,u){eo.uk||!i?eo.compressedTexSubImage2D(e,t,n,r,a,o,s,i,u):eo.compressedTexSubImage2D(e,t,n,r,a,o,s,ue,u,i)},xe:function(e,t,n,r,a,o,s,i,u,l,c){eo.uk?eo.compressedTexSubImage3D(e,t,n,r,a,o,s,i,u,l,c):eo.compressedTexSubImage3D(e,t,n,r,a,o,s,i,u,ue,c,l)},wd:function(e,t,n,r,a){eo.copyBufferSubData(e,t,n,r,a)},bh:function(e,t,n,r,a,o,s,i){eo.copyTexImage2D(e,t,n,r,a,o,s,i)},$g:function(e,t,n,r,a,o,s,i){eo.copyTexSubImage2D(e,t,n,r,a,o,s,i)},ze:function(e,t,n,r,a,o,s,i,u){eo.copyTexSubImage3D(e,t,n,r,a,o,s,i,u)},_g:function(){var e=mr(tr),t=eo.createProgram();return t.name=e,t.Hk=t.Fk=t.Gk=0,t.il=1,tr[e]=t,e},Zg:function(e){var t=mr(or);return or[t]=eo.createShader(e),t},Yg:function(e){eo.cullFace(e)},Xg:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=er[r];a&&(eo.deleteBuffer(a),a.name=0,er[r]=null,r==eo.Pk&&(eo.Pk=0),r==eo.uk&&(eo.uk=0))}},Wg:function(e,t){for(var n=0;n<e;++n){var r=pe[t+4*n>>2],a=nr[r];a&&(eo.deleteFramebuffer(a),a.name=0,nr[r]=null)}},Vg:function(e){if(e){var t=tr[e];t?(eo.deleteProgram(t),t.name=0,tr[e]=null):fr(1281)}},ue:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=ur[r];a&&(eo.deleteQuery(a),ur[r]=null)}},Th:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=ur[r];a&&(eo.wk.deleteQueryEXT(a),ur[r]=null)}},Ug:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=rr[r];a&&(eo.deleteRenderbuffer(a),a.name=0,rr[r]=null)}},dd:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=lr[r];a&&(eo.deleteSampler(a),a.name=0,lr[r]=null)}},Tg:function(e){if(e){var t=or[e];t?(eo.deleteShader(t),or[e]=null):fr(1281)}},ld:function(e){if(e){var t=pr[e];t?(eo.deleteSync(t),t.name=0,pr[e]=null):fr(1281)}},Sg:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=ar[r];a&&(eo.deleteTexture(a),a.name=0,ar[r]=null)}},Tc:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=cr[r];a&&(eo.deleteTransformFeedback(a),a.name=0,cr[r]=null)}},be:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2];eo.deleteVertexArray(sr[r]),sr[r]=null}},Hh:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2];eo.deleteVertexArray(sr[r]),sr[r]=null}},Rg:function(e){eo.depthFunc(e)},Qg:function(e){eo.depthMask(!!e)},Pg:function(e,t){eo.depthRange(e,t)},Og:function(e,t){eo.detachShader(tr[e],or[t])},Ng:function(e){eo.disable(e)},Mg:function(e){eo.disableVertexAttribArray(e)},Lg:function(e,t,n){eo.drawArrays(e,t,n)},pd:function(e,t,n,r){eo.drawArraysInstanced(e,t,n,r)},Dh:function(e,t,n,r){eo.drawArraysInstanced(e,t,n,r)},Cc:function(e,t,n,r){eo.drawArraysInstanced(e,t,n,r)},He:function(e,t,n,r){eo.drawArraysInstanced(e,t,n,r)},Dc:function(e,t,n,r){eo.drawArraysInstanced(e,t,n,r)},oe:function(e,t){for(var n=Er[e],r=0;r<e;r++)n[r]=pe[t+4*r>>2];eo.drawBuffers(n)},Ee:function(e,t){for(var n=Er[e],r=0;r<e;r++)n[r]=pe[t+4*r>>2];eo.drawBuffers(n)},Eh:function(e,t){for(var n=Er[e],r=0;r<e;r++)n[r]=pe[t+4*r>>2];eo.drawBuffers(n)},Kg:function(e,t,n,r){eo.drawElements(e,t,n,r)},od:function(e,t,n,r,a){eo.drawElementsInstanced(e,t,n,r,a)},Ch:function(e,t,n,r,a){eo.drawElementsInstanced(e,t,n,r,a)},Ac:function(e,t,n,r,a){eo.drawElementsInstanced(e,t,n,r,a)},Bc:function(e,t,n,r,a){eo.drawElementsInstanced(e,t,n,r,a)},Fe:function(e,t,n,r,a){eo.drawElementsInstanced(e,t,n,r,a)},Ce:function(e,t,n,r,a,o){Ir(e,r,a,o)},Jg:function(e){eo.enable(e)},Ig:function(e){eo.enableVertexAttribArray(e)},re:function(e){eo.endQuery(e)},Ph:function(e){eo.wk.endQueryEXT(e)},Xd:function(){eo.endTransformFeedback()},nd:function(e,t){return(e=eo.fenceSync(e,t))?(t=mr(pr),e.name=t,pr[t]=e,t):0},Gg:function(){eo.finish()},Fg:function(){eo.flush()},Eg:function(e,t,n,r){eo.framebufferRenderbuffer(e,t,n,rr[r])},Dg:function(e,t,n,r,a){eo.framebufferTexture2D(e,t,n,ar[r],a)},de:function(e,t,n,r,a){eo.framebufferTextureLayer(e,t,ar[n],r,a)},Cg:function(e){eo.frontFace(e)},Bg:function(e,t){Cr(e,t,"createBuffer",er)},zg:function(e,t){Cr(e,t,"createFramebuffer",nr)},we:function(e,t){Cr(e,t,"createQuery",ur)},Uh:function(e,t){for(var n=0;n<e;n++){var r=eo.wk.createQueryEXT();if(!r){for(fr(1282);n<e;)pe[t+4*n++>>2]=0;break}var a=mr(ur);r.name=a,ur[a]=r,pe[t+4*n>>2]=a}},yg:function(e,t){Cr(e,t,"createRenderbuffer",rr)},ed:function(e,t){Cr(e,t,"createSampler",lr)},xg:function(e,t){Cr(e,t,"createTexture",ar)},Sc:function(e,t){Cr(e,t,"createTransformFeedback",cr)},ae:function(e,t){Cr(e,t,"createVertexArray",sr)},Gh:function(e,t){Cr(e,t,"createVertexArray",sr)},Ag:function(e){eo.generateMipmap(e)},vg:function(e,t,n,r,a,o,s){Ar("getActiveAttrib",e,t,n,r,a,o,s)},ug:function(e,t,n,r,a,o,s){Ar("getActiveUniform",e,t,n,r,a,o,s)},rd:function(e,t,n,r,a){e=tr[e],(e=eo.getActiveUniformBlockName(e,t))&&(a&&0<n?(n=we(e,a,n),r&&(pe[r>>2]=n)):r&&(pe[r>>2]=0))},sd:function(e,t,n,r){if(r){if(e=tr[e],35393==n)n=eo.getActiveUniformBlockName(e,t),pe[r>>2]=n.length+1;else if(null!==(e=eo.getActiveUniformBlockParameter(e,t,n)))if(35395==n)for(n=0;n<e.length;n++)pe[r+4*n>>2]=e[n];else pe[r>>2]=e}else fr(1281)},ud:function(e,t,n,r,a){if(a)if(0<t&&0==n)fr(1281);else{e=tr[e];for(var o=[],s=0;s<t;s++)o.push(pe[n+4*s>>2]);if(e=eo.getActiveUniforms(e,o,r))for(t=e.length,s=0;s<t;s++)pe[a+4*s>>2]=e[s]}else fr(1281)},tg:function(e,t,n,r){var a=(e=eo.getAttachedShaders(tr[e])).length;for(a>t&&(a=t),pe[n>>2]=a,t=0;t<a;++t)pe[r+4*t>>2]=or.indexOf(e[t])},sg:function(e,t){return eo.getAttribLocation(tr[e],be(t))},rg:function(e,t){Rr(e,t,4)},fd:function(e,t,n){n?Nr(n,eo.getBufferParameter(e,t)):fr(1281)},qg:function(e,t,n){n?pe[n>>2]=eo.getBufferParameter(e,t):fr(1281)},pg:function(){var e=eo.getError()||vr;return vr=0,e},og:function(e,t){Rr(e,t,2)},Kd:function(e,t){return eo.getFragDataLocation(tr[e],be(t))},ng:function(e,t,n,r){((e=eo.getFramebufferAttachmentParameter(e,t,n))instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=0|e.name),pe[r>>2]=e},gd:function(e,t,n){Fr(e,t,n,1)},id:function(e,t){Rr(e,t,1)},Zd:function(e,t,n){Fr(e,t,n,0)},mg:function(e,t){Rr(e,t,0)},Gc:function(e,t,n,r,a){if(0>r)fr(1281);else if(a){if(null!==(e=eo.getInternalformatParameter(e,t,n)))for(t=0;t<e.length&&t<r;++t)pe[a+4*t>>2]=e[t]}else fr(1281)},Oc:function(){fr(1282)},kg:function(e,t,n,r){null===(e=eo.getProgramInfoLog(tr[e]))&&(e="(unknown error)"),t=0<t&&r?we(e,r,t):0,n&&(pe[n>>2]=t)},lg:function(e,t,n){if(n)if(e>=Zn)fr(1281);else if(e=tr[e],35716==t)null===(e=eo.getProgramInfoLog(e))&&(e="(unknown error)"),pe[n>>2]=e.length+1;else if(35719==t){if(!e.Hk)for(t=0;t<eo.getProgramParameter(e,35718);++t)e.Hk=Math.max(e.Hk,eo.getActiveUniform(e,t).name.length+1);pe[n>>2]=e.Hk}else if(35722==t){if(!e.Fk)for(t=0;t<eo.getProgramParameter(e,35721);++t)e.Fk=Math.max(e.Fk,eo.getActiveAttrib(e,t).name.length+1);pe[n>>2]=e.Fk}else if(35381==t){if(!e.Gk)for(t=0;t<eo.getProgramParameter(e,35382);++t)e.Gk=Math.max(e.Gk,eo.getActiveUniformBlockName(e,t).length+1);pe[n>>2]=e.Gk}else pe[n>>2]=eo.getProgramParameter(e,t);else fr(1281)},Kh:function(e,t,n){n?(e=ur[e],Nr(n,"boolean"==typeof(t=2>wr.version?eo.wk.getQueryObjectEXT(e,t):eo.getQueryParameter(e,t))?t?1:0:t)):fr(1281)},Mh:function(e,t,n){var r;n?(r="boolean"==typeof(e=eo.wk.getQueryObjectEXT(ur[e],t))?e?1:0:e,pe[n>>2]=r):fr(1281)},Jh:function(e,t,n){n?(e=ur[e],Nr(n,"boolean"==typeof(t=2>wr.version?eo.wk.getQueryObjectEXT(e,t):eo.getQueryParameter(e,t))?t?1:0:t)):fr(1281)},pe:function(e,t,n){var r;n?(r="boolean"==typeof(e=eo.getQueryParameter(ur[e],t))?e?1:0:e,pe[n>>2]=r):fr(1281)},Lh:function(e,t,n){var r;n?(r="boolean"==typeof(e=eo.wk.getQueryObjectEXT(ur[e],t))?e?1:0:e,pe[n>>2]=r):fr(1281)},qe:function(e,t,n){n?pe[n>>2]=eo.getQuery(e,t):fr(1281)},Nh:function(e,t,n){n?pe[n>>2]=eo.wk.getQueryEXT(e,t):fr(1281)},jg:function(e,t,n){n?pe[n>>2]=eo.getRenderbufferParameter(e,t):fr(1281)},Wc:function(e,t,n){n?de[n>>2]=eo.getSamplerParameter(lr[e],t):fr(1281)},Xc:function(e,t,n){n?pe[n>>2]=eo.getSamplerParameter(lr[e],t):fr(1281)},hg:function(e,t,n,r){null===(e=eo.getShaderInfoLog(or[e]))&&(e="(unknown error)"),t=0<t&&r?we(e,r,t):0,n&&(pe[n>>2]=t)},gg:function(e,t,n,r){e=eo.getShaderPrecisionFormat(e,t),pe[n>>2]=e.rangeMin,pe[n+4>>2]=e.rangeMax,pe[r>>2]=e.precision},fg:function(e,t,n,r){(e=eo.getShaderSource(or[e]))&&(t=0<t&&r?we(e,r,t):0,n&&(pe[n>>2]=t))},ig:function(e,t,n){n?35716==t?(null===(e=eo.getShaderInfoLog(or[e]))&&(e="(unknown error)"),pe[n>>2]=e?e.length+1:0):35720==t?(e=eo.getShaderSource(or[e]),pe[n>>2]=e?e.length+1:0):pe[n>>2]=eo.getShaderParameter(or[e],t):fr(1281)},eg:function(e){var t=hr[e];if(!t){switch(e){case 7939:t=(t=eo.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e}))),t=Or(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=eo.getParameter(e))||fr(1280),t=t&&Or(t);break;case 7938:t=Or("OpenGL ES 3.0 ("+eo.getParameter(7938)+")");break;case 35724:var n=(t=eo.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Or(t);break;default:fr(1280)}hr[e]=t}return t},xd:function(e,t){if(2>wr.version)return fr(1282),0;var n=dr[e];return n?0>t||t>=n.length?(fr(1281),0):n[t]:7939===e?(n=(n=eo.getSupportedExtensions()||[]).concat(n.map((function(e){return"GL_"+e}))),n=n.map((function(e){return Or(e)})),n=dr[e]=n,0>t||t>=n.length?(fr(1281),0):n[t]):(fr(1280),0)},hd:function(e,t,n,r,a){0>n?fr(1281):a?null!==(e=eo.getSyncParameter(pr[e],t))&&(pe[a>>2]=e,r&&(pe[r>>2]=1)):fr(1281)},dg:function(e,t,n){n?de[n>>2]=eo.getTexParameter(e,t):fr(1281)},cg:function(e,t,n){n?pe[n>>2]=eo.getTexParameter(e,t):fr(1281)},Td:function(e,t,n,r,a,o,s){e=tr[e],(e=eo.getTransformFeedbackVarying(e,t))&&(s&&0<n?(n=we(e.name,s,n),r&&(pe[r>>2]=n)):r&&(pe[r>>2]=0),a&&(pe[a>>2]=e.size),o&&(pe[o>>2]=e.type))},td:function(e,t){return eo.getUniformBlockIndex(tr[e],be(t))},vd:function(e,t,n,r){if(r)if(0<t&&(0==n||0==r))fr(1281);else{e=tr[e];for(var a=[],o=0;o<t;o++)a.push(be(pe[n+4*o>>2]));if(e=eo.getUniformIndices(e,a))for(t=e.length,o=0;o<t;o++)pe[r+4*o>>2]=e[o]}else fr(1281)},_f:function(e,t){if(t=be(t),e=tr[e]){$r(e);var n=e.Tk,r=0,a=t,o=Mr(t);if(0<o&&(r=parseInt(t.slice(o+1))>>>0,a=t.slice(0,o)),(a=e.jl[a])&&r<a[0]&&(n[r+=a[1]]=n[r]||eo.getUniformLocation(e,t)))return r}else fr(1281);return-1},ag:function(e,t,n){Pr(e,t,n,2)},$f:function(e,t,n){Pr(e,t,n,0)},Ld:function(e,t,n){Pr(e,t,n,0)},Rd:function(e,t,n){Lr(e,t,n,0)},Qd:function(e,t,n){Lr(e,t,n,0)},Xf:function(e,t,n){n?pe[n>>2]=eo.getVertexAttribOffset(e,t):fr(1281)},Zf:function(e,t,n){Lr(e,t,n,2)},Yf:function(e,t,n){Lr(e,t,n,5)},Wf:function(e,t){eo.hint(e,t)},Lc:function(e,t,n){for(var r=Er[t],a=0;a<t;a++)r[a]=pe[n+4*a>>2];eo.invalidateFramebuffer(e,r)},Kc:function(e,t,n,r,a,o,s){for(var i=Er[t],u=0;u<t;u++)i[u]=pe[n+4*u>>2];eo.invalidateSubFramebuffer(e,i,r,a,o,s)},Vf:function(e){return(e=er[e])?eo.isBuffer(e):0},Uf:function(e){return eo.isEnabled(e)},Tf:function(e){return(e=nr[e])?eo.isFramebuffer(e):0},Rf:function(e){return(e=tr[e])?eo.isProgram(e):0},te:function(e){return(e=ur[e])?eo.isQuery(e):0},Sh:function(e){return(e=ur[e])?eo.wk.isQueryEXT(e):0},Qf:function(e){return(e=rr[e])?eo.isRenderbuffer(e):0},cd:function(e){return(e=lr[e])?eo.isSampler(e):0},Pf:function(e){return(e=or[e])?eo.isShader(e):0},md:function(e){return eo.isSync(pr[e])},Of:function(e){return(e=ar[e])?eo.isTexture(e):0},Rc:function(e){return eo.isTransformFeedback(cr[e])},$d:function(e){return(e=sr[e])?eo.isVertexArray(e):0},Fh:function(e){return(e=sr[e])?eo.isVertexArray(e):0},Nf:function(e){eo.lineWidth(e)},Mf:function(e){e=tr[e],eo.linkProgram(e),e.Tk=0,e.jl={}},Qc:function(){eo.pauseTransformFeedback()},Lf:function(e,t){eo.pixelStorei(e,t)},Kf:function(e,t){eo.polygonOffset(e,t)},Nc:function(){fr(1280)},Mc:function(){fr(1280)},Oh:function(e,t){eo.wk.queryCounterEXT(ur[e],t)},De:function(e){eo.readBuffer(e)},Jf:function(e,t,n,r,a,o,s){if(eo.Pk)eo.readPixels(e,t,n,r,a,o,s);else{var i=Br(o);eo.readPixels(e,t,n,r,a,o,i,s>>Ur(i))}},If:function(){},Gf:function(e,t,n,r){eo.renderbufferStorage(e,t,n,r)},ee:function(e,t,n,r,a){eo.renderbufferStorageMultisample(e,t,n,r,a)},Pc:function(){eo.resumeTransformFeedback()},Ff:function(e,t){eo.sampleCoverage(e,!!t)},Zc:function(e,t,n){eo.samplerParameterf(lr[e],t,n)},Yc:function(e,t,n){eo.samplerParameterf(lr[e],t,de[n>>2])},$c:function(e,t,n){eo.samplerParameteri(lr[e],t,n)},_c:function(e,t,n){eo.samplerParameteri(lr[e],t,pe[n>>2])},Ef:function(e,t,n,r){eo.scissor(e,t,n,r)},Df:function(){fr(1280)},Cf:function(e,t,n,r){t=gr(t,n,r),eo.shaderSource(or[e],t)},Bf:function(e,t,n){eo.stencilFunc(e,t,n)},Af:function(e,t,n,r){eo.stencilFuncSeparate(e,t,n,r)},zf:function(e){eo.stencilMask(e)},yf:function(e,t){eo.stencilMaskSeparate(e,t)},xf:function(e,t,n){eo.stencilOp(e,t,n)},wf:function(e,t,n,r){eo.stencilOpSeparate(e,t,n,r)},vf:function(e,t,n,r,a,o,s,i,u){if(eo.uk)eo.texImage2D(e,t,n,r,a,o,s,i,u);else if(u){var l=Br(i);eo.texImage2D(e,t,n,r,a,o,s,i,l,u>>Ur(l))}else eo.texImage2D(e,t,n,r,a,o,s,i,null)},Be:function(e,t,n,r,a,o,s,i,u,l){if(eo.uk)eo.texImage3D(e,t,n,r,a,o,s,i,u,l);else if(l){var c=Br(u);eo.texImage3D(e,t,n,r,a,o,s,i,u,c,l>>Ur(c))}else eo.texImage3D(e,t,n,r,a,o,s,i,u,null)},uf:function(e,t,n){eo.texParameterf(e,t,n)},tf:function(e,t,n){eo.texParameterf(e,t,de[n>>2])},sf:function(e,t,n){eo.texParameteri(e,t,n)},rf:function(e,t,n){eo.texParameteri(e,t,pe[n>>2])},Jc:function(e,t,n,r,a){eo.texStorage2D(e,t,n,r,a)},Hc:function(e,t,n,r,a,o){eo.texStorage3D(e,t,n,r,a,o)},qf:function(e,t,n,r,a,o,s,i,u){if(eo.uk)eo.texSubImage2D(e,t,n,r,a,o,s,i,u);else if(u){var l=Br(i);eo.texSubImage2D(e,t,n,r,a,o,s,i,l,u>>Ur(l))}else eo.texSubImage2D(e,t,n,r,a,o,s,i,null)},Ae:function(e,t,n,r,a,o,s,i,u,l,c){if(eo.uk)eo.texSubImage3D(e,t,n,r,a,o,s,i,u,l,c);else if(c){var p=Br(l);eo.texSubImage3D(e,t,n,r,a,o,s,i,u,l,p,c>>Ur(p))}else eo.texSubImage3D(e,t,n,r,a,o,s,i,u,l,null)},Ud:function(e,t,n,r){e=tr[e];for(var a=[],o=0;o<t;o++)a.push(be(pe[n+4*o>>2]));eo.transformFeedbackVaryings(e,a,r)},pf:function(e,t){eo.uniform1f(Dr(e),t)},of:function(e,t,n){t&&eo.uniform1fv(Dr(e),de,n>>2,t)},nf:function(e,t){eo.uniform1i(Dr(e),t)},lf:function(e,t,n){t&&eo.uniform1iv(Dr(e),pe,n>>2,t)},Jd:function(e,t){eo.uniform1ui(Dr(e),t)},Fd:function(e,t,n){t&&eo.uniform1uiv(Dr(e),he,n>>2,t)},kf:function(e,t,n){eo.uniform2f(Dr(e),t,n)},jf:function(e,t,n){t&&eo.uniform2fv(Dr(e),de,n>>2,2*t)},hf:function(e,t,n){eo.uniform2i(Dr(e),t,n)},gf:function(e,t,n){t&&eo.uniform2iv(Dr(e),pe,n>>2,2*t)},Id:function(e,t,n){eo.uniform2ui(Dr(e),t,n)},Ed:function(e,t,n){t&&eo.uniform2uiv(Dr(e),he,n>>2,2*t)},ff:function(e,t,n,r){eo.uniform3f(Dr(e),t,n,r)},ef:function(e,t,n){t&&eo.uniform3fv(Dr(e),de,n>>2,3*t)},df:function(e,t,n,r){eo.uniform3i(Dr(e),t,n,r)},cf:function(e,t,n){t&&eo.uniform3iv(Dr(e),pe,n>>2,3*t)},Hd:function(e,t,n,r){eo.uniform3ui(Dr(e),t,n,r)},Dd:function(e,t,n){t&&eo.uniform3uiv(Dr(e),he,n>>2,3*t)},bf:function(e,t,n,r,a){eo.uniform4f(Dr(e),t,n,r,a)},$e:function(e,t,n){t&&eo.uniform4fv(Dr(e),de,n>>2,4*t)},_e:function(e,t,n,r,a){eo.uniform4i(Dr(e),t,n,r,a)},Ze:function(e,t,n){t&&eo.uniform4iv(Dr(e),pe,n>>2,4*t)},Gd:function(e,t,n,r,a){eo.uniform4ui(Dr(e),t,n,r,a)},Cd:function(e,t,n){t&&eo.uniform4uiv(Dr(e),he,n>>2,4*t)},qd:function(e,t,n){e=tr[e],eo.uniformBlockBinding(e,t,n)},Ye:function(e,t,n,r){t&&eo.uniformMatrix2fv(Dr(e),!!n,de,r>>2,4*t)},ne:function(e,t,n,r){t&&eo.uniformMatrix2x3fv(Dr(e),!!n,de,r>>2,6*t)},le:function(e,t,n,r){t&&eo.uniformMatrix2x4fv(Dr(e),!!n,de,r>>2,8*t)},Xe:function(e,t,n,r){t&&eo.uniformMatrix3fv(Dr(e),!!n,de,r>>2,9*t)},me:function(e,t,n,r){t&&eo.uniformMatrix3x2fv(Dr(e),!!n,de,r>>2,6*t)},he:function(e,t,n,r){t&&eo.uniformMatrix3x4fv(Dr(e),!!n,de,r>>2,12*t)},We:function(e,t,n,r){t&&eo.uniformMatrix4fv(Dr(e),!!n,de,r>>2,16*t)},ie:function(e,t,n,r){t&&eo.uniformMatrix4x2fv(Dr(e),!!n,de,r>>2,8*t)},ge:function(e,t,n,r){t&&eo.uniformMatrix4x3fv(Dr(e),!!n,de,r>>2,12*t)},Ve:function(e){e=tr[e],eo.useProgram(e),eo.sl=e},Ue:function(e){eo.validateProgram(tr[e])},Te:function(e,t){eo.vertexAttrib1f(e,t)},Se:function(e,t){eo.vertexAttrib1f(e,de[t>>2])},Qe:function(e,t,n){eo.vertexAttrib2f(e,t,n)},Pe:function(e,t){eo.vertexAttrib2f(e,de[t>>2],de[t+4>>2])},Oe:function(e,t,n,r){eo.vertexAttrib3f(e,t,n,r)},Ne:function(e,t){eo.vertexAttrib3f(e,de[t>>2],de[t+4>>2],de[t+8>>2])},Me:function(e,t,n,r,a){eo.vertexAttrib4f(e,t,n,r,a)},Le:function(e,t){eo.vertexAttrib4f(e,de[t>>2],de[t+4>>2],de[t+8>>2],de[t+12>>2])},Vc:function(e,t){eo.vertexAttribDivisor(e,t)},Bh:function(e,t){eo.vertexAttribDivisor(e,t)},Ec:function(e,t){eo.vertexAttribDivisor(e,t)},Ie:function(e,t){eo.vertexAttribDivisor(e,t)},Fc:function(e,t){eo.vertexAttribDivisor(e,t)},Pd:function(e,t,n,r,a){eo.vertexAttribI4i(e,t,n,r,a)},Nd:function(e,t){eo.vertexAttribI4i(e,pe[t>>2],pe[t+4>>2],pe[t+8>>2],pe[t+12>>2])},Od:function(e,t,n,r,a){eo.vertexAttribI4ui(e,t,n,r,a)},Md:function(e,t){eo.vertexAttribI4ui(e,he[t>>2],he[t+4>>2],he[t+8>>2],he[t+12>>2])},Sd:function(e,t,n,r,a){eo.vertexAttribIPointer(e,t,n,r,a)},Ke:function(e,t,n,r,a,o){eo.vertexAttribPointer(e,t,n,!!r,a,o)},Je:function(e,t,n,r){eo.viewport(e,t,n,r)},jd:function(e,t,n,r){eo.waitSync(pr[e],t,(n>>>0)+4294967296*r)},pb:function(e,t,n){t=function(e,t){function n(e){var t=o;return("double"===e||"i64"===e)&&7&t&&(t+=4),o=t,"double"===e?(e=fe[o>>3],o+=8):"i64"==e?(e=[pe[o>>2],pe[o+4>>2]],o+=8):(e=pe[o>>2],o+=4),e}for(var r,a,o=t,s=[];;){var i=e;if(0===(r=ie[e>>0]))break;if(a=ie[e+1>>0],37==r){var u=!1,l=t=!1,c=!1,p=!1;e:for(;;){switch(a){case 43:u=!0;break;case 45:t=!0;break;case 35:l=!0;break;case 48:if(c)break e;c=!0;break;case 32:p=!0;break;default:break e}e++,a=ie[e+1>>0]}var h=0;if(42==a)h=n("i32"),e++,a=ie[e+1>>0];else for(;48<=a&&57>=a;)h=10*h+(a-48),e++,a=ie[e+1>>0];var d=!1,f=-1;if(46==a){if(f=0,d=!0,e++,42==(a=ie[e+1>>0]))f=n("i32"),e++;else for(;!(48>(a=ie[e+1>>0])||57<a);)f=10*f+(a-48),e++;a=ie[e+1>>0]}switch(0>f&&(f=6,d=!1),String.fromCharCode(a)){case"h":if(104==(a=ie[e+2>>0])){e++;var m=1}else m=2;break;case"l":108==(a=ie[e+2>>0])?(e++,m=8):m=4;break;case"L":case"q":case"j":m=8;break;case"z":case"t":case"I":m=4;break;default:m=null}switch(m&&e++,a=ie[e+1>>0],String.fromCharCode(a)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":i=100==a||105==a,r=n("i"+8*(m=m||4)),8==m&&(r=117==a?(r[0]>>>0)+4294967296*(r[1]>>>0):(r[0]>>>0)+4294967296*r[1]),4>=m&&(r=(i?Wr:Vr)(r&Math.pow(256,m)-1,8*m));var g=Math.abs(r);if(i="",100==a||105==a)var y=Wr(r,8*m).toString(10);else if(117==a)y=Vr(r,8*m).toString(10),r=Math.abs(r);else if(111==a)y=(l?"0":"")+g.toString(8);else if(120==a||88==a){if(i=l&&0!=r?"0x":"",0>r){for(r=-r,y=(g-1).toString(16),g=[],l=0;l<y.length;l++)g.push((15-parseInt(y[l],16)).toString(16));for(y=g.join("");y.length<2*m;)y="f"+y}else y=g.toString(16);88==a&&(i=i.toUpperCase(),y=y.toUpperCase())}else 112==a&&(0===g?y="(nil)":(i="0x",y=g.toString(16)));if(d)for(;y.length<f;)y="0"+y;for(0<=r&&(u?i="+"+i:p&&(i=" "+i)),"-"==y.charAt(0)&&(i="-"+i,y=y.substr(1));i.length+y.length<h;)t?y+=" ":c?y="0"+y:i=" "+i;(y=i+y).split("").forEach((function(e){s.push(e.charCodeAt(0))}));break;case"f":case"F":case"e":case"E":case"g":case"G":if(r=n("double"),isNaN(r))y="nan",c=!1;else if(isFinite(r)){if(d=!1,m=Math.min(f,20),103!=a&&71!=a||(d=!0,(f=f||1)>(m=parseInt(r.toExponential(m).split("e")[1],10))&&-4<=m?(a=(103==a?"f":"F").charCodeAt(0),f-=m+1):(a=(103==a?"e":"E").charCodeAt(0),f--),m=Math.min(f,20)),101==a||69==a?(y=r.toExponential(m),/[eE][-+]\d$/.test(y)&&(y=y.slice(0,-1)+"0"+y.slice(-1))):102!=a&&70!=a||(y=r.toFixed(m),0===r&&(0>r||0===r&&-1/0==1/r)&&(y="-"+y)),i=y.split("e"),d&&!l)for(;1<i[0].length&&i[0].includes(".")&&("0"==i[0].slice(-1)||"."==i[0].slice(-1));)i[0]=i[0].slice(0,-1);else for(l&&-1==y.indexOf(".")&&(i[0]+=".");f>m++;)i[0]+="0";y=i[0]+(1<i.length?"e"+i[1]:""),69==a&&(y=y.toUpperCase()),0<=r&&(u?y="+"+y:p&&(y=" "+y))}else y=(0>r?"-":"")+"inf",c=!1;for(;y.length<h;)y=t?y+" ":!c||"-"!=y[0]&&"+"!=y[0]?(c?"0":" ")+y:y[0]+"0"+y.slice(1);97>a&&(y=y.toUpperCase()),y.split("").forEach((function(e){s.push(e.charCodeAt(0))}));break;case"s":if(c=(u=n("i8*"))?zr(u):6,d&&(c=Math.min(c,f)),!t)for(;c<h--;)s.push(32);if(u)for(l=0;l<c;l++)s.push(ue[u++>>0]);else s=s.concat(jr("(null)".substr(0,c),!0));if(t)for(;c<h--;)s.push(32);break;case"c":for(t&&s.push(n("i8"));0<--h;)s.push(32);t||s.push(n("i8"));break;case"n":t=n("i32*"),pe[t>>2]=s.length;break;case"%":s.push(r);break;default:for(l=i;l<e+2;l++)s.push(ie[l>>0])}e+=2}else s.push(r),e+=1}return s}(t,n),t=ye(t,0),24&e&&(t=t.replace(/\s+$/,""),t+=(0<t.length?"\n":"")+function(e){e:{var t=Error();if(!t.stack){try{throw Error()}catch(e){t=e}if(!t.stack){t="(no stack trace available)";break e}}t=t.stack.toString()}t=t.slice(t.indexOf("\n",Math.max(t.lastIndexOf("_emscripten_log"),t.lastIndexOf("_emscripten_get_callstack")))+1),32&e&&mn("EM_LOG_DEMANGLE is deprecated; ignoring"),8&e&&"undefined"==typeof emscripten_source_map&&(mn('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.'),e=8^e|16);var n=null;if(128&e)for(n=Hr(arguments);n[1].includes("_emscripten_");)n=Hr(n[0]);var r=t.split("\n");t="";var a,o=RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),s=RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),i=RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(a in r){var u,l=r[a];if((u=i.exec(l))&&5==u.length){l=u[1];var c=u[2],p=u[3];u=u[4]}else{if((u=o.exec(l))||(u=s.exec(l)),!(u&&4<=u.length)){t+=l+"\n";continue}l=u[1],c=u[2],p=u[3],u=0|u[4]}var h=!1;if(8&e){var d=emscripten_source_map.qn({line:p,fm:u});(h=d&&d.source)&&(64&e&&(d.source=d.source.substring(d.source.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=" at "+l+" ("+d.source+":"+d.line+":"+d.fm+")\n")}(16&e||!h)&&(64&e&&(c=c.substring(c.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=(h?" = "+l:" at "+l)+" ("+c+":"+p+":"+u+")\n"),128&e&&n[0]&&(n[1]==l&&0<n[2].length&&(t=t.replace(/\s+$/,""),t+=" with values: "+n[1]+n[2]+"\n"),n=Hr(n[0]))}return t.replace(/\s+$/,"")}(e)),1&e?4&e?console.error(t):2&e?console.warn(t):512&e?console.info(t):256&e?console.debug(t):console.log(t):6&e?re(t):ne(t)},zc:function(e,t,n){ue.copyWithin(e,t,t+n)},lc:function(e){var t=ue.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math,o=a.min;r=Math.max(e,r),r+=(65536-r%65536)%65536;e:{var s=oe.buffer;try{oe.grow(o.call(a,2147483648,r)-s.byteLength+65535>>>16),_e();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},Ei:function(e,t){Wn(n.canvas,e,t),Un()},nc:function(e,t){var n=0;return Kr().forEach((function(r,a){var o=t+n;for(a=he[e+4*a>>2]=o,o=0;o<r.length;++o)ie[a++>>0]=r.charCodeAt(o);ie[a>>0]=0,n+=r.length+1})),0},oc:function(e,t){var n=Kr();he[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),he[t>>2]=r,0},_h:pn,La:function(){return 52},qc:function(){return 52},Yb:function(){return 70},Ma:function(e,t,n,r){for(var a=0,o=0;o<n;o++){var s=he[t>>2],i=he[t+4>>2];t+=8;for(var u=0;u<i;u++)Xr(e,ue[s+u]);a+=i}return he[r>>2]=a,0},pc:async function(e,t){var n=J("background_blur.deepar");n||(n=await Z("background_blur.deepar")),n=new Uint8Array(n);var r=co(n.length);ue.set(n,r),Mt("vii",e,[t,r])},xc:async function(e,t){var n=J("background_replacement.deepar");n||(n=await Z("background_replacement.deepar")),n=new Uint8Array(n);var r=co(n.length);ue.set(n,r),Mt("vii",e,[t,r])},gc:function e(t,n){e.zl||(e.zl=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>Me("randomDevice")}());for(var r=0;r<n;r++)ie[t+r>>0]=e.zl();return 0},$a:function(e){eo.activeTexture(e)},hb:function(e,t){eo.attachShader(tr[e],or[t])},C:function(e,t){35051==e?eo.Pk=t:35052==e&&(eo.uk=t),eo.bindBuffer(e,er[t])},x:function(e,t){eo.bindFramebuffer(e,nr[t])},U:function(e,t){eo.bindRenderbuffer(e,rr[t])},B:function(e,t){eo.bindTexture(e,ar[t])},ii:function(e,t,n,r){eo.blendColor(e,t,n,r)},ji:function(e,t){eo.blendEquationSeparate(e,t)},ki:function(e,t,n,r){eo.blendFuncSeparate(e,t,n,r)},Ra:function(e,t,n,r){n&&t?eo.bufferData(e,ue,r,n,t):eo.bufferData(e,t,r)},Ua:function(e,t,n,r){n&&eo.bufferSubData(e,t,ue,r,n)},ga:function(e){return eo.checkFramebufferStatus(e)},ei:function(e){eo.clear(e)},Ta:function(e,t,n,r){eo.clearColor(e,t,n,r)},gi:function(e){eo.clearDepth(e)},fi:function(e){eo.clearStencil(e)},fa:function(e,t,n,r){eo.colorMask(!!e,!!t,!!n,!!r)},ni:function(e){eo.compileShader(or[e])},Ji:function(e,t,n,r,a,o,s,i){eo.uk||!s?eo.compressedTexImage2D(e,t,n,r,a,o,s,i):eo.compressedTexImage2D(e,t,n,r,a,o,ue,i,s)},ti:function(e,t,n,r,a,o,s,i,u){eo.uk||!i?eo.compressedTexSubImage2D(e,t,n,r,a,o,s,i,u):eo.compressedTexSubImage2D(e,t,n,r,a,o,s,ue,u,i)},Bi:function(){var e=mr(tr),t=eo.createProgram();return t.name=e,t.Hk=t.Fk=t.Gk=0,t.il=1,tr[e]=t,e},pi:function(e){var t=mr(or);return or[t]=eo.createShader(e),t},Va:function(e){eo.cullFace(e)},ka:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=er[r];a&&(eo.deleteBuffer(a),a.name=0,er[r]=null,r==eo.Pk&&(eo.Pk=0),r==eo.uk&&(eo.uk=0))}},va:function(e,t){for(var n=0;n<e;++n){var r=pe[t+4*n>>2],a=nr[r];a&&(eo.deleteFramebuffer(a),a.name=0,nr[r]=null)}},gb:function(e){if(e){var t=tr[e];t?(eo.deleteProgram(t),t.name=0,tr[e]=null):fr(1281)}},xa:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=rr[r];a&&(eo.deleteRenderbuffer(a),a.name=0,rr[r]=null)}},Za:function(e){if(e){var t=or[e];t?(eo.deleteShader(t),or[e]=null):fr(1281)}},qi:function(e){if(e){var t=pr[e];t?(eo.deleteSync(t),t.name=0,pr[e]=null):fr(1281)}},T:function(e,t){for(var n=0;n<e;n++){var r=pe[t+4*n>>2],a=ar[r];a&&(eo.deleteTexture(a),a.name=0,ar[r]=null)}},aa:function(e){eo.depthFunc(e)},ta:function(e){eo.depthMask(!!e)},fb:function(e,t){eo.detachShader(tr[e],or[t])},y:function(e){eo.disable(e)},db:function(e){eo.disableVertexAttribArray(e)},di:function(e,t,n){eo.drawArrays(e,t,n)},$h:Ir,H:function(e){eo.enable(e)},cb:function(e){eo.enableVertexAttribArray(e)},hi:function(){eo.flush()},wa:function(e,t,n,r){eo.framebufferRenderbuffer(e,t,n,rr[r])},ha:function(e,t,n,r,a){eo.framebufferTexture2D(e,t,n,ar[r],a)},Sa:function(e,t){Cr(e,t,"createBuffer",er)},ia:function(e,t){Cr(e,t,"createFramebuffer",nr)},ya:function(e,t){Cr(e,t,"createRenderbuffer",rr)},Z:function(e,t){Cr(e,t,"createTexture",ar)},_a:function(e){eo.generateMipmap(e)},yi:function(e,t,n,r,a,o,s){Ar("getActiveAttrib",e,t,n,r,a,o,s)},xi:function(e,t,n,r,a,o,s){Ar("getActiveUniform",e,t,n,r,a,o,s)},eb:function(e,t){return eo.getAttribLocation(tr[e],be(t))},z:function(){var e=eo.getError()||vr;return vr=0,e},Ci:function(e,t){Rr(e,t,2)},X:function(e,t){Rr(e,t,0)},zi:function(e,t,n,r){null===(e=eo.getProgramInfoLog(tr[e]))&&(e="(unknown error)"),t=0<t&&r?we(e,r,t):0,n&&(pe[n>>2]=t)},V:function(e,t,n){if(n)if(e>=Zn)fr(1281);else if(e=tr[e],35716==t)null===(e=eo.getProgramInfoLog(e))&&(e="(unknown error)"),pe[n>>2]=e.length+1;else if(35719==t){if(!e.Hk)for(t=0;t<eo.getProgramParameter(e,35718);++t)e.Hk=Math.max(e.Hk,eo.getActiveUniform(e,t).name.length+1);pe[n>>2]=e.Hk}else if(35722==t){if(!e.Fk)for(t=0;t<eo.getProgramParameter(e,35721);++t)e.Fk=Math.max(e.Fk,eo.getActiveAttrib(e,t).name.length+1);pe[n>>2]=e.Fk}else if(35381==t){if(!e.Gk)for(t=0;t<eo.getProgramParameter(e,35382);++t)e.Gk=Math.max(e.Gk,eo.getActiveUniformBlockName(e,t).length+1);pe[n>>2]=e.Gk}else pe[n>>2]=eo.getProgramParameter(e,t);else fr(1281)},li:function(e,t,n,r){null===(e=eo.getShaderInfoLog(or[e]))&&(e="(unknown error)"),t=0<t&&r?we(e,r,t):0,n&&(pe[n>>2]=t)},mi:function(e,t,n){n?35716==t?(null===(e=eo.getShaderInfoLog(or[e]))&&(e="(unknown error)"),pe[n>>2]=e?e.length+1:0):35720==t?(e=eo.getShaderSource(or[e]),pe[n>>2]=e?e.length+1:0):pe[n>>2]=eo.getShaderParameter(or[e],t):fr(1281)},W:function(e){var t=hr[e];if(!t){switch(e){case 7939:t=(t=eo.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e}))),t=Or(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=eo.getParameter(e))||fr(1280),t=t&&Or(t);break;case 7938:t=Or("OpenGL ES 3.0 ("+eo.getParameter(7938)+")");break;case 35724:var n=(t=eo.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Or(t);break;default:fr(1280)}hr[e]=t}return t},wi:function(e,t){if(t=be(t),e=tr[e]){$r(e);var n=e.Tk,r=0,a=t,o=Mr(t);if(0<o&&(r=parseInt(t.slice(o+1))>>>0,a=t.slice(0,o)),(a=e.jl[a])&&r<a[0]&&(n[r+=a[1]]=n[r]||eo.getUniformLocation(e,t)))return r}else fr(1281);return-1},ri:function(e){return eo.isSync(pr[e])},Ai:function(e){e=tr[e],eo.linkProgram(e),e.Tk=0,e.jl={}},ja:function(e,t){eo.pixelStorei(e,t)},sa:function(e,t,n,r,a,o,s){if(eo.Pk)eo.readPixels(e,t,n,r,a,o,s);else{var i=Br(o);eo.readPixels(e,t,n,r,a,o,i,s>>Ur(i))}},ab:function(e,t,n,r){eo.renderbufferStorage(e,t,n,r)},ua:function(e,t,n,r){eo.scissor(e,t,n,r)},oi:function(e,t,n,r){t=gr(t,n,r),eo.shaderSource(or[e],t)},Xa:function(e,t,n,r){eo.stencilFuncSeparate(e,t,n,r)},Wa:function(e,t,n,r){eo.stencilOpSeparate(e,t,n,r)},Di:function(e,t,n,r,a,o,s,i,u){if(eo.uk)eo.texImage2D(e,t,n,r,a,o,s,i,u);else if(u){var l=Br(i);eo.texImage2D(e,t,n,r,a,o,s,i,l,u>>Ur(l))}else eo.texImage2D(e,t,n,r,a,o,s,i,null)},ui:function(e,t,n){eo.texParameterf(e,t,n)},vi:function(e,t,n){eo.texParameterf(e,t,de[n>>2])},J:function(e,t,n){eo.texParameteri(e,t,n)},si:function(e,t,n,r,a,o,s,i,u){if(eo.uk)eo.texSubImage2D(e,t,n,r,a,o,s,i,u);else if(u){var l=Br(i);eo.texSubImage2D(e,t,n,r,a,o,s,i,l,u>>Ur(l))}else eo.texSubImage2D(e,t,n,r,a,o,s,i,null)},ai:function(e,t){eo.uniform1i(Dr(e),t)},ci:function(e,t,n){t&&eo.uniform1iv(Dr(e),pe,n>>2,t)},$:function(e,t,n){t&&eo.uniform4fv(Dr(e),de,n>>2,4*t)},bi:function(e,t,n,r){t&&eo.uniformMatrix3fv(Dr(e),!!n,de,r>>2,9*t)},M:function(e,t,n,r){t&&eo.uniformMatrix4fv(Dr(e),!!n,de,r>>2,16*t)},la:function(e){e=tr[e],eo.useProgram(e),eo.sl=e},bb:function(e,t,n,r,a,o){eo.vertexAttribPointer(e,t,n,!!r,a,o)},Ya:function(e,t,n,r){eo.viewport(e,t,n,r)},_b:function(e,t,n,r){eo.waitSync(pr[e],t,(n>>>0)+4294967296*r)},v:function(e,t,n){var r=bo();try{return He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},rb:function(e,t,n,r){var a=bo();try{return He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},za:function(e,t){var n=bo();try{return He(e)(t)}catch(e){if(vo(n),e!==e+0)throw e;yo(1,0)}},Ja:function(e,t,n,r){var a=bo();try{return He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},s:function(e){var t=bo();try{return He(e)()}catch(e){if(vo(t),e!==e+0)throw e;yo(1,0)}},j:function(e,t){var n=bo();try{return He(e)(t)}catch(e){if(vo(n),e!==e+0)throw e;yo(1,0)}},K:function(e,t,n){var r=bo();try{return He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},Q:function(e,t,n){var r=bo();try{return He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},Ki:function(e,t,n,r,a){var o=bo();try{return He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},qb:function(e,t,n,r,a,o,s,i,u,l,c,p,h,d){var f=bo();try{return He(e)(t,n,r,a,o,s,i,u,l,c,p,h,d)}catch(e){if(vo(f),e!==e+0)throw e;yo(1,0)}},Pi:function(e,t,n,r,a){var o=bo();try{return He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},b:function(e,t,n){var r=bo();try{return He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},h:function(e,t,n,r){var a=bo();try{return He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},Li:function(e,t,n,r,a,o,s,i,u){var l=bo();try{return He(e)(t,n,r,a,o,s,i,u)}catch(e){if(vo(l),e!==e+0)throw e;yo(1,0)}},p:function(e,t,n,r,a){var o=bo();try{return He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},Ka:function(e,t,n,r,a,o){var s=bo();try{return He(e)(t,n,r,a,o)}catch(e){if(vo(s),e!==e+0)throw e;yo(1,0)}},Mi:function(e,t,n,r,a,o,s,i,u,l){var c=bo();try{return He(e)(t,n,r,a,o,s,i,u,l)}catch(e){if(vo(c),e!==e+0)throw e;yo(1,0)}},E:function(e,t,n,r,a,o){var s=bo();try{return He(e)(t,n,r,a,o)}catch(e){if(vo(s),e!==e+0)throw e;yo(1,0)}},q:function(e,t,n,r,a,o,s){var i=bo();try{return He(e)(t,n,r,a,o,s)}catch(e){if(vo(i),e!==e+0)throw e;yo(1,0)}},L:function(e,t,n,r,a,o,s,i){var u=bo();try{return He(e)(t,n,r,a,o,s,i)}catch(e){if(vo(u),e!==e+0)throw e;yo(1,0)}},Ia:function(e,t,n,r,a,o,s,i,u){var l=bo();try{return He(e)(t,n,r,a,o,s,i,u)}catch(e){if(vo(l),e!==e+0)throw e;yo(1,0)}},Ha:function(e,t,n,r,a,o,s,i,u,l){var c=bo();try{return He(e)(t,n,r,a,o,s,i,u,l)}catch(e){if(vo(c),e!==e+0)throw e;yo(1,0)}},ea:function(e,t,n,r,a,o,s,i,u,l,c,p){var h=bo();try{return He(e)(t,n,r,a,o,s,i,u,l,c,p)}catch(e){if(vo(h),e!==e+0)throw e;yo(1,0)}},Wb:function(e,t,n,r,a,o,s){var i=bo();try{return Fo(e,t,n,r,a,o,s)}catch(e){if(vo(i),e!==e+0)throw e;yo(1,0)}},bc:function(e,t,n,r,a,o){var s=bo();try{return Io(e,t,n,r,a,o)}catch(e){if(vo(s),e!==e+0)throw e;yo(1,0)}},$b:function(e,t,n,r){var a=bo();try{return Eo(e,t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},fc:function(e){var t=bo();try{return ko(e)}catch(e){if(vo(t),e!==e+0)throw e;yo(1,0)}},ec:function(e,t){var n=bo();try{return To(e,t)}catch(e){if(vo(n),e!==e+0)throw e;yo(1,0)}},Vb:function(e,t,n,r,a){var o=bo();try{return Oo(e,t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},cc:function(e,t,n,r,a){var o=bo();try{return Ao(e,t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},k:function(e){var t=bo();try{He(e)()}catch(e){if(vo(t),e!==e+0)throw e;yo(1,0)}},i:function(e,t){var n=bo();try{He(e)(t)}catch(e){if(vo(n),e!==e+0)throw e;yo(1,0)}},F:function(e,t,n){var r=bo();try{He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},ca:function(e,t,n){var r=bo();try{He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},Oi:function(e,t,n,r){var a=bo();try{He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},d:function(e,t,n){var r=bo();try{He(e)(t,n)}catch(e){if(vo(r),e!==e+0)throw e;yo(1,0)}},Ea:function(e,t,n,r){var a=bo();try{He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},Ba:function(e,t,n,r,a){var o=bo();try{He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},A:function(e,t,n,r,a,o,s){var i=bo();try{He(e)(t,n,r,a,o,s)}catch(e){if(vo(i),e!==e+0)throw e;yo(1,0)}},Y:function(e,t,n,r,a){var o=bo();try{He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},g:function(e,t,n,r){var a=bo();try{He(e)(t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},o:function(e,t,n,r,a){var o=bo();try{He(e)(t,n,r,a)}catch(e){if(vo(o),e!==e+0)throw e;yo(1,0)}},Ni:function(e,t,n,r,a,o){var s=bo();try{He(e)(t,n,r,a,o)}catch(e){if(vo(s),e!==e+0)throw e;yo(1,0)}},r:function(e,t,n,r,a,o){var s=bo();try{He(e)(t,n,r,a,o)}catch(e){if(vo(s),e!==e+0)throw e;yo(1,0)}},t:function(e,t,n,r,a,o,s){var i=bo();try{He(e)(t,n,r,a,o,s)}catch(e){if(vo(i),e!==e+0)throw e;yo(1,0)}},D:function(e,t,n,r,a,o,s,i){var u=bo();try{He(e)(t,n,r,a,o,s,i)}catch(e){if(vo(u),e!==e+0)throw e;yo(1,0)}},O:function(e,t,n,r,a,o,s,i,u){var l=bo();try{He(e)(t,n,r,a,o,s,i,u)}catch(e){if(vo(l),e!==e+0)throw e;yo(1,0)}},Pb:function(e,t,n,r,a,o,s,i,u,l){var c=bo();try{He(e)(t,n,r,a,o,s,i,u,l)}catch(e){if(vo(c),e!==e+0)throw e;yo(1,0)}},S:function(e,t,n,r,a,o,s,i,u,l,c){var p=bo();try{He(e)(t,n,r,a,o,s,i,u,l,c)}catch(e){if(vo(p),e!==e+0)throw e;yo(1,0)}},Aa:function(e,t,n,r,a,o,s,i,u,l,c,p,h){var d=bo();try{He(e)(t,n,r,a,o,s,i,u,l,c,p,h)}catch(e){if(vo(d),e!==e+0)throw e;yo(1,0)}},da:function(e,t,n,r,a,o,s,i,u,l,c,p,h,d,f,m){var g=bo();try{He(e)(t,n,r,a,o,s,i,u,l,c,p,h,d,f,m)}catch(e){if(vo(g),e!==e+0)throw e;yo(1,0)}},Xb:function(e,t,n,r,a,o,s){var i=bo();try{Ro(e,t,n,r,a,o,s)}catch(e){if(vo(i),e!==e+0)throw e;yo(1,0)}},dc:function(e,t,n,r){var a=bo();try{So(e,t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},ac:function(e,t,n,r){var a=bo();try{Co(e,t,n,r)}catch(e){if(vo(a),e!==e+0)throw e;yo(1,0)}},hc:function(){let e=window.localStorage.getItem("k39d");e||(e=function(){let e=(new Date).getTime(),t=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){let r=16*Math.random();return 0<e?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16)}))}(),window.localStorage.setItem("k39d",e));let t=document.title;t&&0!==t.length||(t="No title");let n=navigator.vendor;n&&0!==n.length||(n="N/A");let r=navigator.platform;r&&0!==r.length||(r="N/A"),Qr=e,Jr=navigator.userAgent,Zr=window.screen.width+"x"+window.screen.height,ea=t,ta=document.domain,na="1.0.0",ra=n,oa=aa=r},Ge:function(e,t){if(la){var n=sa.createBufferSource();n.connect(ia),n.buffer=ua[e].Cl,n.loop=t,n.start(0),ua[e].fl=n,ua[e].El=!0}},Re:async function(e,t,n){if(la){ua[e]={fl:null,Cl:null,Dl:!1,sn:!1};var r=new ArrayBuffer(n);new Uint8Array(r).set(ue.subarray(t,t+n)),ua[e].Cl=await sa.decodeAudioData(r),ua[e].Dl=!0}},ve:function(e){la&&(ua[e].fl.stop(),ua[e].El=!1,ua[e].fl.currentTime=0)},af:function(e){return!!la&&ua[e].Dl},je:function(e){la&&(ua[e].El&&ua[e].fl.stop(),delete ua[e])},_d:function(e){la&&ia.gain.setValueAtTime(e,sa.currentTime)},Fa:function(e){n.sk[e]=null},Da:function(e,t,r){const a=(e=n.sk[e]).canvas;return(e.rl||fa!==t||ma!==r)&&(ca.width===t&&ca.height===r||(ca.width=t,ca.height=r),pa.drawImage(a,0,0,a.width,a.height,0,0,t,r),da=pa.getImageData(0,0,t,r),fa=t,ma=r,e.rl=!1),B(da)},Ca:function(e,t){if(!(e=n.sk[e]))throw Error("Image data does not exist.");ue.set(e.data,t)},Rb:function(){if(!ha){const e=document.createElement("canvas"),t=e.getContext("2d",{alpha:!1,desynchronized:!0});ha=B({canvas:e,Ok:t,rl:!0})}return ha},Sb:function(e){return n.sk[e].videoHeight},Tb:function(e){return n.sk[e].videoWidth},bd:function(e,t){if(({canvas:e}=n.sk[e]),t=ar[t],!wr||!t)return-1;eo.bindTexture(eo.TEXTURE_2D,t),eo.texImage2D(eo.TEXTURE_2D,0,eo.RGBA,eo.RGBA,eo.UNSIGNED_BYTE,e)},Qb:function(e,t){const r=(e=n.sk[e]).canvas,a=e.Ok;t=n.sk[t],r.width===t.videoWidth&&r.height===t.videoHeight||(r.width=t.videoWidth,r.height=t.videoHeight),a.drawImage(t,0,0),e.rl=!0},Db:function(e){de.set(va,e>>2)},Cb:function(e){de.set(wa,e>>2)},Ab:function(e){de.set(_a,e>>2)},zb:function(e){de.set(ka,e>>2)},Hb:Sa,oa:Ea,Ib:function(){return ga},Eb:function(){return xa},Bb:function(){return Ta},Gb:function(e){if(!(e=n.sk[e]))throw Error("No image data.");Ia(e)},Fb:function(e,t,n){Ia(e=new ImageData(new Uint8ClampedArray(ue.subarray(e,e+t*n*4)),t,n))},Lb:function(){return Ca.getHeight()},Mb:function(){return Ca.getWidth()},Kb:function(e,t){if(!(e=n.sk[e]))throw Error("Image is null.");Fa(e,t)},Jb:function(e,t,n,r){Fa(e=new ImageData(new Uint8ClampedArray(ue.subarray(e,e+t*n*4)),t,n),r)},Ob:Oa,Nb:Ma,tb:function(e){de.set(Ba,e>>2)},vb:function(e){de.set(Ua,e>>2)},sb:async function(e,t){if(!$a&&(null==Da&&(Da=new l.Geometry),null==Pa&&(Pa=new l.VideoManager(null),Va=t,Pa.setNbFramesDelay(Va)),!Da.isInitialized())){var r;$a=!0,console.log("DeepAR WristTracking initialize started."),(t=J("wristDetector"))||(r=Z("wristDetector"));var a,o=J("wristTracker");o||(a=Z("wristTracker"));var s,i=J("wristObj");i||(s=Z("wristObj")),t||(t=await r),o||(o=await a),i||(i=await s),await Da.initialize(Pa,{geometryToDetect:"WRIST",poseEstimationWasmFilename:n.wristTrackingConfig.poseEstimationWasmPath,modelFilename:t,featuresFilename:o,objFilename:i,fovY:e,detectScoreThs:.3,trackScoreThs:.4,validTrackedKeypThs:.4,filteringShift:.5,trackedNumKeypsThs:50,reprojThs:50,activeIds:[44,46,47,65,66,78,108,110,111,113,114,115,123,127,130,136,139,140,142,143,145,148,151,153,158,160,166,170,171,174,175,177,178],wasmBackend:{enable:!0,tfjsBackendWasmPath:n.wristTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:n.wristTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:n.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),$a=!1,console.log("DeepAR WristTracking initialized!")}},Ga:za,ub:function(){return Da.isMirrored()},wb:function(){return La},yb:function(e){if(!(e=n.sk[e]))throw Error("No image data.");ja(e)},xb:function(e,t,n){ja(e=new ImageData(new Uint8ClampedArray(ue.subarray(e,e+t*n*4)),t,n))},n:function(e){return e},Zh:Ya,ic:function(e,t,n,r){return Ya(e,t,n,r)},Yh:function(e,t,n){for(var r=be(t),a=0;25>a;++a)r=r.replace(new RegExp("\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[a],"g"),"\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[a]);for(var o in t={"%A":"%a","%B":"%b","%c":"%a %b %d %H:%M:%S %Y","%D":"%m\\/%d\\/%y","%e":"%d","%F":"%Y-%m-%d","%h":"%b","%R":"%H\\:%M","%r":"%I\\:%M\\:%S\\s%p","%T":"%H\\:%M\\:%S","%x":"%m\\/%d\\/(?:%y|%Y)","%X":"%H\\:%M\\:%S"})r=r.replace(o,t[o]);a={"%a":"(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)","%b":"(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)","%C":"\\d\\d","%d":"0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31","%H":"\\d(?!\\d)|[0,1]\\d|20|21|22|23","%I":"\\d(?!\\d)|0\\d|10|11|12","%j":"00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d","%m":"0[1-9]|[1-9](?!\\d)|10|11|12","%M":"0\\d|\\d(?!\\d)|[1-5]\\d","%n":"\\s","%p":"AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.","%S":"0\\d|\\d(?!\\d)|[1-5]\\d|60","%U":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%W":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%w":"[0-6]","%y":"\\d\\d","%Y":"\\d\\d\\d\\d","%%":"%","%t":"\\s"};var s={Rm:0,Qm:1,Um:2,Nm:3,Vm:4,Tm:5,Sm:6,Om:7,Ym:8,Xm:9,Wm:10,Pm:11};for(var i in o={Ll:0,Jl:1,Nl:2,Ol:3,Ml:4,Hl:5,Kl:6},t={Jl:0,Nl:1,Ol:2,Ml:3,Hl:4,Kl:5,Ll:6},a)r=r.replace(i,"("+i+a[i]+")");var u=[];for(a=r.indexOf("%");0<=a;a=r.indexOf("%"))u.push(r[a+1]),r=r.replace(new RegExp("\\%"+r[a+1],"g"),"");var l=new RegExp("^"+r,"i").exec(be(e));if(l){if(i=function(){function e(e,t,n){return"number"!=typeof e||isNaN(e)?t:e>=t?e<=n?e:n:t}return{year:e(pe[n+20>>2]+1900,1970,9999),month:e(pe[n+16>>2],0,11),day:e(pe[n+12>>2],1,31),hour:e(pe[n+8>>2],0,23),min:e(pe[n+4>>2],0,59),Bl:e(pe[n>>2],0,59)}}(),a=e=>{if(0<=(e=u.indexOf(e)))return l[e+1]},(r=a("S"))&&(i.Bl=parseInt(r)),(r=a("M"))&&(i.min=parseInt(r)),r=a("H"))i.hour=parseInt(r);else if(r=a("I")){var c=parseInt(r);(r=a("p"))&&(c+="P"===r.toUpperCase()[0]?12:0),i.hour=c}if((r=a("Y"))?i.year=parseInt(r):(r=a("y"))&&(c=parseInt(r),c=(r=a("C"))?c+100*parseInt(r):c+(69>c?2e3:1900),i.year=c),(r=a("m"))?i.month=parseInt(r)-1:(r=a("b"))&&(i.month=s[r.substring(0,3).toUpperCase()]||0),r=a("d"))i.day=parseInt(r);else if(r=a("j"))for(o=parseInt(r),t=rn(i.year),s=0;12>s;++s)o<=(r=Ha(t?Ga:Ka,s-1))+(t?Ga:Ka)[s]&&(i.day=o-r);else(r=a("a"))&&(s=r.substring(0,3).toUpperCase(),(r=a("U"))?(o=o[s],t=parseInt(r),o=0===(s=new Date(i.year,0,1)).getDay()?qa(s,o+7*(t-1)):qa(s,7-s.getDay()+o+7*(t-1)),i.day=o.getDate(),i.month=o.getMonth()):(r=a("W"))&&(o=t[s],t=parseInt(r),o=1===(s=new Date(i.year,0,1)).getDay()?qa(s,o+7*(t-1)):qa(s,7-s.getDay()+1+o+7*(t-1)),i.day=o.getDate(),i.month=o.getMonth()));return i=new Date(i.year,i.month,i.day,i.hour,i.min,i.Bl,0),pe[n>>2]=i.getSeconds(),pe[n+4>>2]=i.getMinutes(),pe[n+8>>2]=i.getHours(),pe[n+12>>2]=i.getDate(),pe[n+16>>2]=i.getMonth(),pe[n+20>>2]=i.getFullYear()-1900,pe[n+24>>2]=i.getDay(),pe[n+28>>2]=Ha(rn(i.getFullYear())?Ga:Ka,i.getMonth()-1)+i.getDate()-1,pe[n+32>>2]=0,e+jr(l[0]).length-1}return 0}};Re++,function(e,t){var n=Te;return"function"!=typeof WebAssembly.instantiateStreaming||$e(n)||"function"!=typeof fetch?Le(n,e,t):fetch(n,{credentials:"same-origin"}).then((function(r){return WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return re("wasm streaming compile failed: "+r),re("falling back to ArrayBuffer instantiation"),Le(n,e,t)}))}))}({a:no},(function(e){n.asm=e.instance.exports,oe=n.asm.Qi,_e(),ke=n.asm.Lj,Ee.unshift(n.asm.Ri),0==--Re&&(null!==Fe&&(clearInterval(Fe),Fe=null),Oe&&(e=Oe,Oe=null,e()))})).catch(a);var ro=n._initialize=function(){return(ro=n._initialize=n.asm.Si).apply(null,arguments)};function ao(){return(ao=n.asm.Yi).apply(null,arguments)}n._setLicenseKey=function(){return(n._setLicenseKey=n.asm.Ti).apply(null,arguments)},n._hasVar=function(){return(n._hasVar=n.asm.Ui).apply(null,arguments)},n._getVarTypeStatus=function(){return(n._getVarTypeStatus=n.asm.Vi).apply(null,arguments)},n._getVarType=function(){return(n._getVarType=n.asm.Wi).apply(null,arguments)},n._getBoolVarStatus=function(){return(n._getBoolVarStatus=n.asm.Xi).apply(null,arguments)},n._getBoolVar=function(){return(n._getBoolVar=n.asm.Zi).apply(null,arguments)},n._getIntVarStatus=function(){return(n._getIntVarStatus=n.asm._i).apply(null,arguments)},n._getIntVar=function(){return(n._getIntVar=n.asm.$i).apply(null,arguments)},n._getDoubleVarStatus=function(){return(n._getDoubleVarStatus=n.asm.aj).apply(null,arguments)},n._getDoubleVar=function(){return(n._getDoubleVar=n.asm.bj).apply(null,arguments)},n._getStringVarStatus=function(){return(n._getStringVarStatus=n.asm.cj).apply(null,arguments)},n._getStringVar=function(){return(n._getStringVar=n.asm.dj).apply(null,arguments)},n._setBoolVar=function(){return(n._setBoolVar=n.asm.ej).apply(null,arguments)},n._setIntVar=function(){return(n._setIntVar=n.asm.fj).apply(null,arguments)},n._setDoubleVar=function(){return(n._setDoubleVar=n.asm.gj).apply(null,arguments)},n._setStringVar=function(){return(n._setStringVar=n.asm.hj).apply(null,arguments)},n._deleteVar=function(){return(n._deleteVar=n.asm.ij).apply(null,arguments)},n._clearVars=function(){return(n._clearVars=n.asm.jj).apply(null,arguments)};var oo=n._shutdownEngine=function(){return(oo=n._shutdownEngine=n.asm.kj).apply(null,arguments)};n._processFrameVideo=function(){return(n._processFrameVideo=n.asm.lj).apply(null,arguments)},n._processFrameRawPixels=function(){return(n._processFrameRawPixels=n.asm.mj).apply(null,arguments)};var so=n._takeScreenshot=function(){return(so=n._takeScreenshot=n.asm.nj).apply(null,arguments)};n._switchEffect=function(){return(n._switchEffect=n.asm.oj).apply(null,arguments)},n._clearEffect=function(){return(n._clearEffect=n.asm.pj).apply(null,arguments)},n._showStats=function(){return(n._showStats=n.asm.qj).apply(null,arguments)},n._simulatePhysics=function(){return(n._simulatePhysics=n.asm.rj).apply(null,arguments)},n._showColliders=function(){return(n._showColliders=n.asm.sj).apply(null,arguments)},n._render=function(){return(n._render=n.asm.tj).apply(null,arguments)},n._fireTrigger=function(){return(n._fireTrigger=n.asm.uj).apply(null,arguments)},n._setFaceDetectionSensitivity=function(){return(n._setFaceDetectionSensitivity=n.asm.vj).apply(null,arguments)},n._changeParameterFloat=function(){return(n._changeParameterFloat=n.asm.wj).apply(null,arguments)},n._changeParameterBool=function(){return(n._changeParameterBool=n.asm.xj).apply(null,arguments)},n._changeParameterVector=function(){return(n._changeParameterVector=n.asm.yj).apply(null,arguments)},n._changeParameterTexture=function(){return(n._changeParameterTexture=n.asm.zj).apply(null,arguments)};var io=n._reset=function(){return(io=n._reset=n.asm.Aj).apply(null,arguments)};n._moveGameObject=function(){return(n._moveGameObject=n.asm.Bj).apply(null,arguments)};var uo=n._touchOccurred=function(){return(uo=n._touchOccurred=n.asm.Cj).apply(null,arguments)};n._pushConsoleLog=function(){return(n._pushConsoleLog=n.asm.Dj).apply(null,arguments)},n._enableAutoframing=function(){return(n._enableAutoframing=n.asm.Ej).apply(null,arguments)},n._muteSound=function(){return(n._muteSound=n.asm.Fj).apply(null,arguments)},n._backgroundBlur=function(){return(n._backgroundBlur=n.asm.Gj).apply(null,arguments)},n._backgroundReplacement=function(){return(n._backgroundReplacement=n.asm.Hj).apply(null,arguments)};var lo=n._initializeFootTracking=function(){return(lo=n._initializeFootTracking=n.asm.Ij).apply(null,arguments)};n._setZoom=function(){return(n._setZoom=n.asm.Jj).apply(null,arguments)};var co=n._malloc=function(){return(co=n._malloc=n.asm.Kj).apply(null,arguments)},po=n._free=function(){return(po=n._free=n.asm.Mj).apply(null,arguments)};function ho(){return(ho=n.asm.Nj).apply(null,arguments)}var fo=n._fflush=function(){return(fo=n._fflush=n.asm.Oj).apply(null,arguments)},mo=n.___getTypeName=function(){return(mo=n.___getTypeName=n.asm.Pj).apply(null,arguments)};function go(){return(go=n.asm.Rj).apply(null,arguments)}function yo(){return(yo=n.asm.Sj).apply(null,arguments)}function bo(){return(bo=n.asm.Tj).apply(null,arguments)}function vo(){return(vo=n.asm.Uj).apply(null,arguments)}function wo(){return(wo=n.asm.Vj).apply(null,arguments)}function xo(){return(xo=n.asm.Wj).apply(null,arguments)}function _o(){return(_o=n.asm.Xj).apply(null,arguments)}n.__embind_initialize_bindings=function(){return(n.__embind_initialize_bindings=n.asm.Qj).apply(null,arguments)},n.dynCall_viiiij=function(){return(n.dynCall_viiiij=n.asm.Yj).apply(null,arguments)},n.dynCall_viiij=function(){return(n.dynCall_viiij=n.asm.Zj).apply(null,arguments)},n.dynCall_vijiiii=function(){return(n.dynCall_vijiiii=n.asm._j).apply(null,arguments)};var ko=n.dynCall_j=function(){return(ko=n.dynCall_j=n.asm.$j).apply(null,arguments)},To=n.dynCall_ji=function(){return(To=n.dynCall_ji=n.asm.ak).apply(null,arguments)},So=n.dynCall_vij=function(){return(So=n.dynCall_vij=n.asm.bk).apply(null,arguments)},Eo=n.dynCall_iij=function(){return(Eo=n.dynCall_iij=n.asm.ck).apply(null,arguments)};n.dynCall_iijii=function(){return(n.dynCall_iijii=n.asm.dk).apply(null,arguments)},n.dynCall_vijii=function(){return(n.dynCall_vijii=n.asm.ek).apply(null,arguments)};var Io=n.dynCall_iiiij=function(){return(Io=n.dynCall_iiiij=n.asm.fk).apply(null,arguments)},Co=n.dynCall_vji=function(){return(Co=n.dynCall_vji=n.asm.gk).apply(null,arguments)},Ao=n.dynCall_jiji=function(){return(Ao=n.dynCall_jiji=n.asm.hk).apply(null,arguments)};n.dynCall_viij=function(){return(n.dynCall_viij=n.asm.ik).apply(null,arguments)};var No,Ro=n.dynCall_viijii=function(){return(Ro=n.dynCall_viijii=n.asm.jk).apply(null,arguments)},Fo=n.dynCall_iiiiij=function(){return(Fo=n.dynCall_iiiiij=n.asm.kk).apply(null,arguments)},Oo=n.dynCall_jiiii=function(){return(Oo=n.dynCall_jiiii=n.asm.lk).apply(null,arguments)};function Mo(){0<Re||(We(Se),0<Re||No||(No=!0,n.calledRun=!0,me))||(We(Ee),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),We(Ce))}return n.dynCall_iiiiijj=function(){return(n.dynCall_iiiiijj=n.asm.mk).apply(null,arguments)},n.dynCall_iiiiiijj=function(){return(n.dynCall_iiiiiijj=n.asm.nk).apply(null,arguments)},n.cwrap=Qa,Oe=function e(){No||Mo(),No||(Oe=e)},Mo(),e.ready});const s=o;function i(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}var u=function(){return u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},u.apply(this,arguments)};function l(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(s=0)),s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){s.label=i[1];break}if(6===i[0]&&s.label<a[1]){s.label=a[1],a=i;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(i);break}a[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function p(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var h=function(){function e(e,t,n){this.NB_BUFFERS=5,this._videoFrames=[],this._nbFramesDelay=0,this._videoElement=e,this._videoCanvas=document.createElement("canvas"),this._videoCanvas.style.display="none",this._videoCanvasContext=this._videoCanvas.getContext("2d",{willReadFrequently:!0}),null!=t&&(this._videoCanvas.width=t),null!=n&&(this._videoCanvas.height=n)}return e.prototype.getNbFramesDelay=function(){return this._nbFramesDelay},e.prototype.setNbFramesDelay=function(e){e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)},e.prototype.getVideoCanvas=function(){return this._videoCanvas},e.prototype.compare=function(e,t,n,r){var a=!0;return[1,50,100,1e3,2e3,3e3,5e3,9e3].forEach((function(o){o<n*r*3&&e.data[o]!=t.data[o]&&(a=!1)})),a},e.prototype.preProcessWithBuffer=function(e){for(var t=0;t<this._videoFrames.length;t++)if(this.compare(this._videoFrames[t],e,this._videoCanvas.width,this._videoCanvas.height))return!1;return this._videoFrames.length===this.NB_BUFFERS&&(this._videoFrames=this._videoFrames.slice(0,-1)),this._videoFrames=p([e],this._videoFrames,!0),!0},e.prototype.preProcess=function(){if(null==this._videoElement||0===this._videoElement.videoWidth||0===this._videoElement.videoHeight)return!1;this._videoCanvas.width===this._videoElement.videoWidth&&this._videoCanvas.height===this._videoElement.videoHeight||(this._videoFrames=[],this._videoCanvas.width=this._videoElement.videoWidth,this._videoCanvas.height=this._videoElement.videoHeight),this._videoCanvasContext.drawImage(this._videoElement,0,0,this._videoCanvas.width,this._videoCanvas.height);var e=this._videoCanvasContext.getImageData(0,0,this._videoCanvas.width,this._videoCanvas.height);return this._videoFrames.length===this.NB_BUFFERS&&(this._videoFrames=this._videoFrames.slice(0,-1)),this._videoFrames=p([e],this._videoFrames,!0),!0},e.prototype.postProcess=function(){if(this._nbFramesDelay>0&&this._videoFrames.length>0){var e=this._nbFramesDelay<this._videoFrames.length?this._videoFrames[this._nbFramesDelay]:this._videoFrames[this._videoFrames.length-1];this._videoCanvasContext.putImageData(e,0,0)}},e.prototype.getCameraFrame=function(){if(this._nbFramesDelay>0&&this._videoFrames.length>0)return this._nbFramesDelay<this._videoFrames.length?this._videoFrames[this._nbFramesDelay]:this._videoFrames[this._videoFrames.length-1]},e.prototype.updateDelay=function(e){e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)},e.prototype.getLastBuffer=function(){return this._videoFrames.length>0?this._videoFrames[0]:null},e.prototype.setOverlapingImage=function(e){this._videoCanvasContext.putImageData(e,10,10)},e}(),d=function(e,t){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},d(e,t)};function f(e,t){function n(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function m(e){return"function"==typeof e}var g=!1,y={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack,g=e},get useDeprecatedSynchronousErrorHandling(){return g}};function b(e){setTimeout((function(){throw e}),0)}var v={closed:!0,next:function(e){},error:function(e){if(y.useDeprecatedSynchronousErrorHandling)throw e;b(e)},complete:function(){}},w=Array.isArray||function(e){return e&&"number"==typeof e.length};function x(e){return null!==e&&"object"==typeof e}var _=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),k=_,T=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return e.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this,r=n._parentOrParents,a=n._ctorUnsubscribe,o=n._unsubscribe,s=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof e)r.remove(this);else if(null!==r)for(var i=0;i<r.length;++i)r[i].remove(this);if(m(o)){a&&(this._unsubscribe=void 0);try{o.call(this)}catch(e){t=e instanceof k?S(e.errors):[e]}}if(w(s)){i=-1;for(var u=s.length;++i<u;){var l=s[i];if(x(l))try{l.unsubscribe()}catch(e){t=t||[],e instanceof k?t=t.concat(S(e.errors)):t.push(e)}}}if(t)throw new k(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var a=n._parentOrParents;if(null===a)n._parentOrParents=this;else if(a instanceof e){if(a===this)return n;n._parentOrParents=[a,this]}else{if(-1!==a.indexOf(this))return n;a.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function S(e){return e.reduce((function(e,t){return e.concat(t instanceof k?t.errors:t)}),[])}var E="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),I=function(e){function t(n,r,a){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=v;break;case 1:if(!n){o.destination=v;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new C(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new C(o,n,r,a)}return o}return f(t,e),t.prototype[E]=function(){return this},t.create=function(e,n,r){var a=new t(e,n,r);return a.syncErrorThrowable=!1,a},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(T),C=function(e){function t(t,n,r,a){var o,s=e.call(this)||this;s._parentSubscriber=t;var i=s;return m(n)?o=n:n&&(o=n.next,r=n.error,a=n.complete,n!==v&&(m((i=Object.create(n)).unsubscribe)&&s.add(i.unsubscribe.bind(i)),i.unsubscribe=s.unsubscribe.bind(s))),s._context=i,s._next=o,s._error=r,s._complete=a,s}return f(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;y.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=y.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):b(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;b(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};y.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),y.useDeprecatedSynchronousErrorHandling)throw e;b(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!y.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return y.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):(b(t),!0)}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(I),A="function"==typeof Symbol&&Symbol.observable||"@@observable";function N(e){return e}var R=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,a=function(e,t,n){if(e){if(e instanceof I)return e;if(e[E])return e[E]()}return e||t||n?new I(e,t,n):new I(v)}(e,t,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||y.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),y.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){y.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,r=t.destination,a=t.isStopped;if(n||a)return!1;e=r&&r instanceof I?r:null}return!0}(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=F(t))((function(t,r){var a;a=n.subscribe((function(t){try{e(t)}catch(e){r(e),a&&a.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[A]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return 0===t.length?this:(0===(e=t).length?N:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=F(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function F(e){if(e||(e=y.Promise||Promise),!e)throw new Error("no Promise impl found");return e}var O=function(e){return function(t){for(var n=0,r=e.length;n<r&&!t.closed;n++)t.next(e[n]);t.complete()}},M="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator",$=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function D(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}var P=function(e){if(e&&"function"==typeof e[A])return r=e,function(e){var t=r[A]();if("function"!=typeof t.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return t.subscribe(e)};if($(e))return O(e);if(D(e))return n=e,function(e){return n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,b),e};if(e&&"function"==typeof e[M])return t=e,function(e){for(var n=t[M]();;){var r=void 0;try{r=n.next()}catch(t){return e.error(t),e}if(r.done){e.complete();break}if(e.next(r.value),e.closed)break}return"function"==typeof n.return&&e.add((function(){n.return&&n.return()})),e};var t,n,r,a=x(e)?"an invalid object":"'"+e+"'";throw new TypeError("You provided "+a+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")},L=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,n}return f(t,e),t.prototype._next=function(e){this.parent.notifyNext(e)},t.prototype._error=function(e){this.parent.notifyError(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},t}(I),B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.destination.complete()},t}(I);function U(e){return e&&"function"==typeof e.schedule}var W=function(e){function t(t,n,r){var a=e.call(this)||this;return a.parent=t,a.outerValue=n,a.outerIndex=r,a.index=0,a}return f(t,e),t.prototype._next=function(e){this.parent.notifyNext(this.outerValue,e,this.outerIndex,this.index++,this)},t.prototype._error=function(e){this.parent.notifyError(e,this),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},t}(I);function V(e,t,n,r,a){if(void 0===a&&(a=new W(e,n,r)),!a.closed)return t instanceof R?t.subscribe(a):P(t)(a)}var z=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.notifyNext=function(e,t,n,r,a){this.destination.next(t)},t.prototype.notifyError=function(e,t){this.destination.error(e)},t.prototype.notifyComplete=function(e){this.destination.complete()},t}(I);function j(e,t){return new R((function(n){var r=new T,a=0;return r.add(t.schedule((function(){a!==e.length?(n.next(e[a++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}function H(e,t){return t?j(e,t):new R(O(e))}var G={};function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=void 0,r=void 0;return U(e[e.length-1])&&(r=e.pop()),"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&w(e[0])&&(e=e[0]),H(e,r).lift(new q(n))}var q=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new Y(e,this.resultSelector))},e}(),Y=function(e){function t(t,n){var r=e.call(this,t)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return f(t,e),t.prototype._next=function(e){this.values.push(G),this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{this.active=t,this.toRespond=t;for(var n=0;n<t;n++){var r=e[n];this.add(V(this,r,void 0,n))}}},t.prototype.notifyComplete=function(e){0==(this.active-=1)&&this.destination.complete()},t.prototype.notifyNext=function(e,t,n){var r=this.values,a=r[n],o=this.toRespond?a===G?--this.toRespond:this.toRespond:0;r[n]=t,0===o&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},t.prototype._tryResultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(z);function X(e,t){return t?function(e,t){if(null!=e){if(function(e){return e&&"function"==typeof e[A]}(e))return function(e,t){return new R((function(n){var r=new T;return r.add(t.schedule((function(){var a=e[A]();r.add(a.subscribe({next:function(e){r.add(t.schedule((function(){return n.next(e)})))},error:function(e){r.add(t.schedule((function(){return n.error(e)})))},complete:function(){r.add(t.schedule((function(){return n.complete()})))}}))}))),r}))}(e,t);if(D(e))return function(e,t){return new R((function(n){var r=new T;return r.add(t.schedule((function(){return e.then((function(e){r.add(t.schedule((function(){n.next(e),r.add(t.schedule((function(){return n.complete()})))})))}),(function(e){r.add(t.schedule((function(){return n.error(e)})))}))}))),r}))}(e,t);if($(e))return j(e,t);if(function(e){return e&&"function"==typeof e[M]}(e)||"string"==typeof e)return function(e,t){if(!e)throw new Error("Iterable cannot be null");return new R((function(n){var r,a=new T;return a.add((function(){r&&"function"==typeof r.return&&r.return()})),a.add(t.schedule((function(){r=e[M](),a.add(t.schedule((function(){if(!n.closed){var e,t;try{var a=r.next();e=a.value,t=a.done}catch(e){return void n.error(e)}t?n.complete():(n.next(e),this.schedule())}})))}))),a}))}(e,t)}throw new TypeError((null!==e&&typeof e||e)+" is not observable")}(e,t):e instanceof R?e:new R(P(e))}function Q(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return U(n)?(e.pop(),j(e,n)):H(e)}function J(e,t){return function(n){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new Z(e,t))}}var Z=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new ee(e,this.project,this.thisArg))},e}(),ee=function(e){function t(t,n,r){var a=e.call(this,t)||this;return a.project=n,a.count=0,a.thisArg=r||a,a}return f(t,e),t.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(I),te=new R((function(e){return e.complete()}));function ne(e,t){return new R(t?function(n){return t.schedule(re,0,{error:e,subscriber:n})}:function(t){return t.error(e)})}function re(e){var t=e.error;e.subscriber.error(t)}function ae(e){return function(t){return t.lift(new oe(e))}}var oe=function(){function e(e){this.callback=e}return e.prototype.call=function(e,t){return t.subscribe(new se(e,this.callback))},e}(),se=function(e){function t(t,n){var r=e.call(this,t)||this;return r.add(new T(n)),r}return f(t,e),t}(I),ie=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),ue=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return f(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(T),le=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return f(t,e),t}(I),ce=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return f(t,e),t.prototype[E]=function(){return new le(this)},t.prototype.lift=function(e){var t=new pe(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new ie;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),a=0;a<n;a++)r[a].next(e)},t.prototype.error=function(e){if(this.closed)throw new ie;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),a=0;a<n;a++)r[a].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new ie;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(this.closed)throw new ie;return e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){if(this.closed)throw new ie;return this.hasError?(e.error(this.thrownError),T.EMPTY):this.isStopped?(e.complete(),T.EMPTY):(this.observers.push(e),new ue(this,e))},t.prototype.asObservable=function(){var e=new R;return e.source=this,e},t.create=function(e,t){return new pe(e,t)},t}(R),pe=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return f(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):T.EMPTY},t}(ce),he=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return f(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new ie;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(ce);function de(e){return void 0===e&&(e=-1),function(t){return t.lift(new fe(e,t))}}var fe=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new me(e,this.count,this.source))},e}(),me=function(e){function t(t,n,r){var a=e.call(this,t)||this;return a.count=n,a.source=r,a}return f(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return e.prototype.error.call(this,t);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},t}(I);function ge(e,t){return"function"==typeof t?function(n){return n.pipe(ge((function(n,r){return X(e(n,r)).pipe(J((function(e,a){return t(n,e,r,a)})))})))}:function(t){return t.lift(new ye(e))}}var ye=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new be(e,this.project))},e}(),be=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.index=0,r}return f(t,e),t.prototype._next=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this._innerSub(t)},t.prototype._innerSub=function(e){var t=this.innerSubscription;t&&t.unsubscribe();var n=new L(this),r=this.destination;r.add(n),this.innerSubscription=function(e,t){if(!t.closed){if(e instanceof R)return e.subscribe(t);var n;try{n=P(e)(t)}catch(e){t.error(e)}return n}}(e,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},t.prototype._complete=function(){var t=this.innerSubscription;t&&!t.closed||e.prototype._complete.call(this),this.unsubscribe()},t.prototype._unsubscribe=function(){this.innerSubscription=void 0},t.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&e.prototype._complete.call(this)},t.prototype.notifyNext=function(e){this.destination.next(e)},t}(B);function ve(){}function we(e,t,n){return function(r){return r.lift(new xe(e,t,n))}}var xe=function(){function e(e,t,n){this.nextOrObserver=e,this.error=t,this.complete=n}return e.prototype.call=function(e,t){return t.subscribe(new _e(e,this.nextOrObserver,this.error,this.complete))},e}(),_e=function(e){function t(t,n,r,a){var o=e.call(this,t)||this;return o._tapNext=ve,o._tapError=ve,o._tapComplete=ve,o._tapError=r||ve,o._tapComplete=a||ve,m(n)?(o._context=o,o._tapNext=n):n&&(o._context=n,o._tapNext=n.next||ve,o._tapError=n.error||ve,o._tapComplete=n.complete||ve),o}return f(t,e),t.prototype._next=function(e){try{this._tapNext.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.next(e)},t.prototype._error=function(e){try{this._tapError.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.error(e)},t.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()},t}(I);function ke(e){return new R((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?X(n):te).subscribe(t)}))}var Te=void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Se(){throw new Error("setTimeout has not been defined")}function Ee(){throw new Error("clearTimeout has not been defined")}var Ie=Se,Ce=Ee;function Ae(e){if(Ie===setTimeout)return setTimeout(e,0);if((Ie===Se||!Ie)&&setTimeout)return Ie=setTimeout,setTimeout(e,0);try{return Ie(e,0)}catch(t){try{return Ie.call(null,e,0)}catch(t){return Ie.call(this,e,0)}}}"function"==typeof Te.setTimeout&&(Ie=setTimeout),"function"==typeof Te.clearTimeout&&(Ce=clearTimeout);var Ne,Re=[],Fe=!1,Oe=-1;function Me(){Fe&&Ne&&(Fe=!1,Ne.length?Re=Ne.concat(Re):Oe=-1,Re.length&&$e())}function $e(){if(!Fe){var e=Ae(Me);Fe=!0;for(var t=Re.length;t;){for(Ne=Re,Re=[];++Oe<t;)Ne&&Ne[Oe].run();Oe=-1,t=Re.length}Ne=null,Fe=!1,function(e){if(Ce===clearTimeout)return clearTimeout(e);if((Ce===Ee||!Ce)&&clearTimeout)return Ce=clearTimeout,clearTimeout(e);try{Ce(e)}catch(t){try{return Ce.call(null,e)}catch(t){return Ce.call(this,e)}}}(e)}}function De(e,t){this.fun=e,this.array=t}function Pe(){}De.prototype.run=function(){this.fun.apply(null,this.array)};var Le=Pe,Be=Pe,Ue=Pe,We=Pe,Ve=Pe,ze=Pe,je=Pe,He=Te.performance||{},Ge=He.now||He.mozNow||He.msNow||He.oNow||He.webkitNow||function(){return(new Date).getTime()},Ke=new Date,qe={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];Re.push(new De(e,t)),1!==Re.length||Fe||Ae($e)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Le,addListener:Be,once:Ue,off:We,removeListener:Ve,removeAllListeners:ze,emit:je,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Ge.call(He),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ke)/1e3}},Ye=qe;class Xe{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class Qe{refCount(e){return Je("refCount")}incRef(e){return Je("incRef")}timerAvailable(){return!0}time(e){return Je("time")}read(e){return Je("read")}readSync(e){return Je("readSync")}readToGPU(e,t){return Je("readToGPU")}numDataIds(){return Je("numDataIds")}disposeData(e,t){return Je("disposeData")}write(e,t,n){return Je("write")}move(e,t,n,r,a){return Je("move")}createTensorFromGPUData(e,t,n){return Je("createTensorFromGPUData")}memory(){return Je("memory")}floatPrecision(){return Je("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return Je("dispose")}}function Je(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Ze(e,t,n){return Math.max(e,Math.min(t,n))}function et(e){return e%2==0?e:e+1}function tt(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function nt(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function rt(e,t,n=""){nt(st(e,t),(()=>n+` Shapes ${e} and ${t} must match`))}function at(e){nt(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function ot(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function st(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function it(e){return e%1==0}function ut(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function lt(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function ct(e,t=(e=>0),n,r){return new Promise(((a,o)=>{let s=0;const i=()=>{if(e())return void a();s++;const u=t(s);null!=n&&s>=n?o():null!=r?r(i,u):setTimeout(i,u)};i()}))}function pt(e,t){let n=1,r=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function ht(e,t){const n=t.length;return nt((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),nt(e.every((e=>it(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function dt(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,o=null==t||a?null:ht(t,e).sort();let s=0;for(let t=0;t<e.length;++t){if(null!=o){if(o[s]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==o[s]||o[s]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),o[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function ft(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function mt(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function gt(e,t){return!("complex64"===t||"float32"===t&&"complex64"!==e||"int32"===t&&"float32"!==e&&"complex64"!==e||"bool"===t&&"bool"===e)}function yt(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function bt(e){return"string"==typeof e||e instanceof String}function vt(e){return Array.isArray(e)?vt(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":bt(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function wt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function xt(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function _t(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function kt(e,t,n,r=!1){const a=new Array;if(1===t.length){const o=t[0]*(r?2:1);for(let t=0;t<o;t++)a[t]=n[e+t]}else{const o=t[0],s=t.slice(1),i=s.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<o;t++)a[t]=kt(e+t*i,s,n,r)}return a}function Tt(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return kt(0,e,t,n)}function St(e,t){const n=Et(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function Et(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function It(e){e.forEach((t=>{nt(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function Ct(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=n[t]*e[t];return r}function At(e,t,n){if(0===t)return[];if(1===t)return[e];const r=new Array(t);for(let t=0;t<r.length-1;++t)r[t]=Math.floor(e/n[t]),e-=r[t]*n[t];return r[r.length-1]=e,r}function Nt(e){return e&&e.then&&"function"==typeof e.then}const Rt="tfjsflags";class Ft{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Ot,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(Nt(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);Rt in e&&e[Rt].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)}))}}function Ot(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Mt(){return Dt}let $t,Dt=null;function Pt(){if(null==$t){let e;if("undefined"!=typeof window)e=window;else if(void 0!==Te)e=Te;else if(void 0!==Ye)e=Ye;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}$t=e}return $t}function Lt(e,t){const n=function(){const e=Pt();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Bt="Add",Ut="AddN",Wt="All",Vt="Any",zt="ArgMax",jt="AvgPool",Ht="BatchMatMul",Gt="BatchToSpaceND",Kt="Cast",qt="Ceil",Yt="ClipByValue",Xt="Concat",Qt="Conv2D",Jt="Conv2DBackpropInput",Zt="Cosh",en="Cumprod",tn="Cumsum",nn="CropAndResize",rn="DepthToSpace",an="DepthwiseConv2dNative",on="RealDiv",sn="Elu",un="Equal",ln="Exp",cn="ExpandDims",pn="Fill",hn="FlipLeftRight",dn="Floor",fn="FloorDiv",mn="FusedBatchNorm",gn="GatherV2",yn="GatherNd",bn="Greater",vn="GreaterEqual",wn="Identity",xn="IsNan",_n="LeakyRelu",kn="Less",Tn="LessEqual",Sn="LogicalAnd",En="LogicalNot",In="LogicalOr",Cn="Max",An="Maximum",Nn="MaxPool",Rn="Mean",Fn="Min",On="Minimum",Mn="MirrorPad",$n="Multiply",Dn="NotEqual",Pn="NonMaxSuppressionV3",Ln="NonMaxSuppressionV4",Bn="NonMaxSuppressionV5",Un="OnesLike",Wn="OneHot",Vn="Pack",zn="PadV2",jn="Prelu",Hn="Prod",Gn="Range",Kn="Reciprocal",qn="Relu",Yn="Reshape",Xn="ResizeNearestNeighbor",Qn="ResizeBilinear",Jn="Relu6",Zn="Reverse",er="Round",tr="Rsqrt",nr="ScatterNd",rr="Select",ar="Slice",or="Sigmoid",sr="Sqrt",ir="Sum",ur="SpaceToBatchND",lr="SplitV",cr="Softmax",pr="SparseFillEmptyRows",hr="SparseReshape",dr="SparseSegmentMean",fr="SparseSegmentSum",mr="SquaredDifference",gr="StridedSlice",yr="StringNGrams",br="StringSplit",vr="StringToHashBucketFast",wr="Sub",xr="Tanh",_r="Tile",kr="TopK",Tr="Transform",Sr="Transpose",Er="Unpack",Ir="ZerosLike",Cr="Step",Ar="FromPixels",Nr="RotateWithOffset",Rr="_FusedMatMul",Fr="FusedConv2D",Or="FusedDepthwiseConv2D";function Mr(...e){Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(...e)}const $r=Lt("kernelRegistry",(()=>new Map)),Dr=Lt("gradRegistry",(()=>new Map));function Pr(e,t){const n=Wr(e,t);return $r.get(n)}function Lr(e){return Dr.get(e)}function Br(e){const t=$r.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[o,s]=a,[i]=o.split("_");i===e&&n.push(s)}return n}function Ur(e){const{kernelName:t,backendName:n}=e,r=Wr(t,n);$r.has(r)&&Mr(`The kernel '${t}' for backend '${n}' is already registered`),$r.set(r,e)}function Wr(e,t){return`${t}_${e}`}var Vr=jr,zr=null;try{zr=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(i){}function jr(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Hr(e){return!0===(e&&e.__isLong__)}jr.prototype.__isLong__,Object.defineProperty(jr.prototype,"__isLong__",{value:!0}),jr.isLong=Hr;var Gr={},Kr={};function qr(e,t){var n,r,a;return t?(a=0<=(e>>>=0)&&e<256)&&(r=Kr[e])?r:(n=Xr(e,(0|e)<0?-1:0,!0),a&&(Kr[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(r=Gr[e])?r:(n=Xr(e,e<0?-1:0,!1),a&&(Gr[e]=n),n)}function Yr(e,t){if(isNaN(e))return t?oa:aa;if(t){if(e<0)return oa;if(e>=ta)return ca}else{if(e<=-na)return pa;if(e+1>=na)return la}return e<0?Yr(-e,t).neg():Xr(e%ea|0,e/ea|0,t)}function Xr(e,t,n){return new jr(e,t,n)}jr.fromInt=qr,jr.fromNumber=Yr,jr.fromBits=Xr;var Qr=Math.pow;function Jr(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return aa;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Jr(e.substring(1),t,n).neg();for(var a=Yr(Qr(n,8)),o=aa,s=0;s<e.length;s+=8){var i=Math.min(8,e.length-s),u=parseInt(e.substring(s,s+i),n);if(i<8){var l=Yr(Qr(n,i));o=o.mul(l).add(Yr(u))}else o=(o=o.mul(a)).add(Yr(u))}return o.unsigned=t,o}function Zr(e,t){return"number"==typeof e?Yr(e,t):"string"==typeof e?Jr(e,t):Xr(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}jr.fromString=Jr,jr.fromValue=Zr;var ea=4294967296,ta=ea*ea,na=ta/2,ra=qr(1<<24),aa=qr(0);jr.ZERO=aa;var oa=qr(0,!0);jr.UZERO=oa;var sa=qr(1);jr.ONE=sa;var ia=qr(1,!0);jr.UONE=ia;var ua=qr(-1);jr.NEG_ONE=ua;var la=Xr(-1,2147483647,!1);jr.MAX_VALUE=la;var ca=Xr(-1,-1,!0);jr.MAX_UNSIGNED_VALUE=ca;var pa=Xr(0,-2147483648,!1);jr.MIN_VALUE=pa;var ha=jr.prototype;ha.toInt=function(){return this.unsigned?this.low>>>0:this.low},ha.toNumber=function(){return this.unsigned?(this.high>>>0)*ea+(this.low>>>0):this.high*ea+(this.low>>>0)},ha.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(pa)){var t=Yr(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var a=Yr(Qr(e,6),this.unsigned),o=this,s="";;){var i=o.div(a),u=(o.sub(i.mul(a)).toInt()>>>0).toString(e);if((o=i).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},ha.getHighBits=function(){return this.high},ha.getHighBitsUnsigned=function(){return this.high>>>0},ha.getLowBits=function(){return this.low},ha.getLowBitsUnsigned=function(){return this.low>>>0},ha.getNumBitsAbs=function(){if(this.isNegative())return this.eq(pa)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},ha.isZero=function(){return 0===this.high&&0===this.low},ha.eqz=ha.isZero,ha.isNegative=function(){return!this.unsigned&&this.high<0},ha.isPositive=function(){return this.unsigned||this.high>=0},ha.isOdd=function(){return 1==(1&this.low)},ha.isEven=function(){return 0==(1&this.low)},ha.equals=function(e){return Hr(e)||(e=Zr(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},ha.eq=ha.equals,ha.notEquals=function(e){return!this.eq(e)},ha.neq=ha.notEquals,ha.ne=ha.notEquals,ha.lessThan=function(e){return this.comp(e)<0},ha.lt=ha.lessThan,ha.lessThanOrEqual=function(e){return this.comp(e)<=0},ha.lte=ha.lessThanOrEqual,ha.le=ha.lessThanOrEqual,ha.greaterThan=function(e){return this.comp(e)>0},ha.gt=ha.greaterThan,ha.greaterThanOrEqual=function(e){return this.comp(e)>=0},ha.gte=ha.greaterThanOrEqual,ha.ge=ha.greaterThanOrEqual,ha.compare=function(e){if(Hr(e)||(e=Zr(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?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},ha.comp=ha.compare,ha.negate=function(){return!this.unsigned&&this.eq(pa)?pa:this.not().add(sa)},ha.neg=ha.negate,ha.add=function(e){Hr(e)||(e=Zr(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,o=e.high>>>16,s=65535&e.high,i=e.low>>>16,u=0,l=0,c=0,p=0;return c+=(p+=a+(65535&e.low))>>>16,l+=(c+=r+i)>>>16,u+=(l+=n+s)>>>16,u+=t+o,Xr((c&=65535)<<16|(p&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},ha.subtract=function(e){return Hr(e)||(e=Zr(e)),this.add(e.neg())},ha.sub=ha.subtract,ha.multiply=function(e){if(this.isZero())return aa;if(Hr(e)||(e=Zr(e)),zr)return Xr(zr.mul(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned);if(e.isZero())return aa;if(this.eq(pa))return e.isOdd()?pa:aa;if(e.eq(pa))return this.isOdd()?pa:aa;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(ra)&&e.lt(ra))return Yr(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,o=e.high>>>16,s=65535&e.high,i=e.low>>>16,u=65535&e.low,l=0,c=0,p=0,h=0;return p+=(h+=a*u)>>>16,c+=(p+=r*u)>>>16,p&=65535,c+=(p+=a*i)>>>16,l+=(c+=n*u)>>>16,c&=65535,l+=(c+=r*i)>>>16,c&=65535,l+=(c+=a*s)>>>16,l+=t*u+n*i+r*s+a*o,Xr((p&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},ha.mul=ha.multiply,ha.divide=function(e){if(Hr(e)||(e=Zr(e)),e.isZero())throw Error("division by zero");var t,n,r;if(zr)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Xr((this.unsigned?zr.div_u:zr.div_s)(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?oa:aa;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return oa;if(e.gt(this.shru(1)))return ia;r=oa}else{if(this.eq(pa))return e.eq(sa)||e.eq(ua)?pa:e.eq(pa)?sa:(t=this.shr(1).div(e).shl(1)).eq(aa)?e.isNegative()?sa:ua:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(pa))return this.unsigned?oa:aa;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();r=aa}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),o=a<=48?1:Qr(2,a-48),s=Yr(t),i=s.mul(e);i.isNegative()||i.gt(n);)i=(s=Yr(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=sa),r=r.add(s),n=n.sub(i)}return r},ha.div=ha.divide,ha.modulo=function(e){return Hr(e)||(e=Zr(e)),zr?Xr((this.unsigned?zr.rem_u:zr.rem_s)(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},ha.mod=ha.modulo,ha.rem=ha.modulo,ha.not=function(){return Xr(~this.low,~this.high,this.unsigned)},ha.and=function(e){return Hr(e)||(e=Zr(e)),Xr(this.low&e.low,this.high&e.high,this.unsigned)},ha.or=function(e){return Hr(e)||(e=Zr(e)),Xr(this.low|e.low,this.high|e.high,this.unsigned)},ha.xor=function(e){return Hr(e)||(e=Zr(e)),Xr(this.low^e.low,this.high^e.high,this.unsigned)},ha.shiftLeft=function(e){return Hr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Xr(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Xr(0,this.low<<e-32,this.unsigned)},ha.shl=ha.shiftLeft,ha.shiftRight=function(e){return Hr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Xr(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Xr(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},ha.shr=ha.shiftRight,ha.shiftRightUnsigned=function(e){if(Hr(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?Xr(this.low>>>e|t<<32-e,t>>>e,this.unsigned):Xr(32===e?t:t>>>e-32,0,this.unsigned)},ha.shru=ha.shiftRightUnsigned,ha.shr_u=ha.shiftRightUnsigned,ha.toSigned=function(){return this.unsigned?Xr(this.low,this.high,!1):this},ha.toUnsigned=function(){return this.unsigned?this:Xr(this.low,this.high,!0)},ha.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},ha.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},ha.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},jr.fromBytes=function(e,t,n){return n?jr.fromBytesLE(e,t):jr.fromBytesBE(e,t)},jr.fromBytesLE=function(e,t){return new jr(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},jr.fromBytesBE=function(e,t){return new jr(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const da=Vr||i({__proto__:null,default:Vr},[Vr]);function fa(e){return da.fromString(e,!0,16)}const ma=fa("c3a5c85c97cb3127"),ga=fa("b492b66fbe98f273"),ya=fa("9ae16a3b2f90404f");function ba(e){return e.xor(e.shru(47))}function va(e,t,n){const r=e.slice(t,t+n);return da.fromBytes(Array.from(r),!0,!0)}function wa(e,t){return va(e,t,8)}function xa(e,t){return va(e,t,4)}function _a(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function ka(e,t,n=fa("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function Ta(e,t,n,r){return function(e,t,n,r,a,o){a=a.add(e),o=_a(o.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),o=o.add(_a(a,44)),[a.add(r),o.add(s)]}(wa(e,t),wa(e,t+8),wa(e,t+16),wa(e,t+24),n,r)}function Sa(e,t=e.length){const n=da.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=ya.add(2*t),r=wa(e,0).add(ya),a=wa(e,t-8);return ka(_a(a,37).mul(n).add(r),_a(r,25).add(a).mul(n),n)}if(t>=4){const n=ya.add(2*t);return ka(xa(e,0).shl(3).add(t),xa(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return ba(ya.mul(n).xor(ma.mul(r))).mul(ya)}return ya}(e,t):function(e,t=e.length){const n=ya.add(2*t),r=wa(e,0).mul(ga),a=wa(e,8),o=wa(e,t-8).mul(n),s=wa(e,t-16).mul(ya);return ka(_a(r.add(a),43).add(_a(o,30)).add(s),r.add(_a(a.add(ya),18)).add(o),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=ya.add(2*t),r=wa(e,0).mul(ya),a=wa(e,8),o=wa(e,t-8).mul(n),s=wa(e,t-16).mul(ya),i=_a(r.add(a),43).add(_a(o,30)).add(s),u=ka(i,r.add(_a(a.add(ya),18)).add(o),n),l=wa(e,16).mul(n),c=wa(e,24),p=i.add(wa(e,t-32)).mul(n),h=u.add(wa(e,t-24)).mul(n);return ka(_a(l.add(c),43).add(_a(p,30)).add(h),l.add(_a(c.add(r),18)).add(p),n)}(e,t);let r=n,a=n.mul(ga).add(113),o=ba(a.mul(ya).add(113)).mul(ya),s=[da.UZERO,da.UZERO],i=[da.UZERO,da.UZERO];r=r.mul(ya).add(wa(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=_a(r.add(a).add(s[0]).add(wa(e,u+8)),37).mul(ga),a=_a(a.add(s[1]).add(wa(e,u+48)),42).mul(ga),r=r.xor(i[1]),a=a.add(s[0]).add(wa(e,u+40)),o=_a(o.add(i[0]),33).mul(ga),s=Ta(e,u,s[1].mul(ga),r.add(i[0])),i=Ta(e,u+32,o.add(i[1]),a.add(wa(e,u+16))),[o,r]=[r,o],u+=64}while(u!==l);const p=ga.add(o.and(255).shl(1));return u=c,i[0]=i[0].add(t-1&63),s[0]=s[0].add(i[0]),i[0]=i[0].add(s[0]),r=_a(r.add(a).add(s[0]).add(wa(e,u+8)),37).mul(p),a=_a(a.add(s[1]).add(wa(e,u+48)),42).mul(p),r=r.xor(i[1].mul(9)),a=a.add(s[0].mul(9).add(wa(e,u+40))),o=_a(o.add(i[0]),33).mul(p),s=Ta(e,u,s[1].mul(p),r.add(i[0])),i=Ta(e,u+32,o.add(i[1]),a.add(wa(e,u+16))),[o,r]=[r,o],ka(ka(s[0],i[0],p).add(ba(a).mul(ma)).add(o),ka(s[1],i[1],p).add(r),p)}function Ea(e,t){return"string"===t?Aa(e):Ia([e],t)}function Ia(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Fa(e)),Mt().getBool("DEBUG")&&function(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function Ca(){return Mt().platform.now()}function Aa(e,t="utf-8"){return t=t||"utf-8",Mt().platform.encode(e,t)}function Na(e,t="utf-8"){return t=t||"utf-8",Mt().platform.decode(e,t)}function Ra(e){return Mt().platform.isTypedArray(e)}function Fa(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Nt(e)||null==e||Ra(e)&&n)t.push(e);else if(Array.isArray(e)||Ra(e))for(let r=0;r<e.length;++r)Fa(e[r],t,n);else{let r=-1;for(const t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(r=Math.max(r,Number(t)));for(let a=0;a<=r;a++)Fa(e[a],t,n)}return t}class Oa{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new $a)}profileKernel(e,t,n){let r;const a=()=>{r=n()};let o;const s=Ca();if(this.backendTimer.timerAvailable())o=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();o=Promise.resolve({kernelMs:Ca()-s})}if(Mt().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{Ma(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:o.then((e=>e.kernelMs)),extraInfo:o.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:o}=e;n.forEach((e=>{Promise.all([e.data(),r,o]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ma(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class $a{logKernelProfile(e,t,n,r,a,o){const s="number"==typeof r?lt(`${r}ms`,9):r.error,i=lt(e,25),u=t.rank,l=t.size,c=lt(t.shape.toString(),14);let p="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;p+=`${e}: ${a}D ${a>0?r:""} `}}console.log(`%c${i}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${o}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function Da(e,t,n,r){const a=_t(t),o=function(e,t,n,r){const a=ot(t),o=r[r.length-1],s=new Array(o).fill(0),i=t.length,u="complex64"===n?Ua(e):e;if(i>1)for(let e=0;e<a/o;e++){const t=e*o;for(let e=0;e<o;e++)s[e]=Math.max(s[e],Pa(u[t+e],0,n).length)}return s}(e,t,n,a),s=t.length,i=Ba(e,t,n,a,o),u=["Tensor"];return r&&(u.push(` dtype: ${n}`),u.push(` rank: ${s}`),u.push(` shape: [${t}]`),u.push(" values:")),u.push(i.map((e=>" "+e)).join("\n")),u.join("\n")}function Pa(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:bt(e)?`'${e}'`:"bool"===n?La(e):parseFloat(e.toFixed(7)).toString(),lt(r,t)}function La(e){return 0===e?"false":"true"}function Ba(e,t,n,r,a,o=!0){const s="complex64"===n?2:1,i=t[0],u=t.length;if(0===u)return"complex64"===n?[Pa(Ua(e)[0],0,n)]:"bool"===n?[La(e[0])]:[e[0].toString()];if(1===u){if(i>20){const t=3*s;let r=Array.from(e.slice(0,t)),o=Array.from(e.slice((i-3)*s,i*s));return"complex64"===n&&(r=Ua(r),o=Ua(o)),["["+r.map(((e,t)=>Pa(e,a[t],n))).join(", ")+", ..., "+o.map(((e,t)=>Pa(e,a[i-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ua(e):Array.from(e)).map(((e,t)=>Pa(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),p=r[0]*s,h=[];if(i>20){for(let t=0;t<3;t++){const r=t*p,o=r+p;h.push(...Ba(e.slice(r,o),l,n,c,a,!1))}h.push("...");for(let t=i-3;t<i;t++){const r=t*p,o=r+p;h.push(...Ba(e.slice(r,o),l,n,c,a,t===i-1))}}else for(let t=0;t<i;t++){const r=t*p,o=r+p;h.push(...Ba(e.slice(r,o),l,n,c,a,t===i-1))}const d=2===u?",":"";h[0]="["+(i>0?h[0]+d:"");for(let e=1;e<h.length-1;e++)h[e]=" "+h[e]+d;let f=",\n";for(let e=2;e<u;e++)f+="\n";return h[h.length-1]=" "+h[h.length-1]+"]"+(o?"":f),h}function Ua(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class Wa{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=ot(e),null!=n){const e=n.length;nt(e===this.size,(()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||mt(t,this.size),this.strides=_t(e)}set(e,...t){0===t.length&&(t=[0]),nt(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return Va().makeTensor(this.values,this.shape,this.dtype)}}let Va=null,za=null;class ja{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=ot(e),this.strides=_t(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return za.buffer(this.shape,this.dtype,e)}bufferSync(){return za.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Tt(this.shape,e,"complex64"===this.dtype)}arraySync(){return Tt(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=Va().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>Na(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),Va().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Va().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Na(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await Va().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Va().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return za.print(this,e)}clone(){return this.throwIfDisposed(),za.clone(this)}toString(e=!1){return Da(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),za.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Va().makeVariable(this,e,t,n)}}Object.defineProperty(ja,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),Lt("Tensor",(()=>ja));class Ha extends ja{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!st(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Va().disposeTensor(this),this.dataId=e.dataId,Va().incRef(this,null)}dispose(){Va().disposeVariable(this),this.isDisposedInternal=!0}}var Ga,Ka,qa,Ya,Xa;Object.defineProperty(Ha,Symbol.hasInstance,{value:e=>e instanceof ja&&null!=e.assign&&e.assign instanceof Function}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(Ga||(Ga={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Ka||(Ka={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(qa||(qa={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(Ya||(Ya={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(Xa||(Xa={}));const Qa={float32:Ya,int32:Ka,bool:qa,complex64:Xa};function Ja(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return Qa[e][t]}function Za(e,t){if(e.dtype===t.dtype)return[e,t];const n=Ja(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function eo(e){const t=[];return to(e,t,new Set),t}function to(e,t,n){if(null==e)return;if(e instanceof ja)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),to(r,t,n))}}function no(e){return null!=e.kernelName}class ro{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class ao{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new ro}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(Mr(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Oa(this.backendInstance),!0}setupRegisteredKernels(){Br(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){Br(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof Qe||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t<this.pendingBackendInitId||(this.registry[e]=n,this.pendingBackendInit=null,0)))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,Mr(`Initialization of backend ${e} failed`),Mr(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return Mr(`Initialization of backend ${e} failed`),Mr(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t),o=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,o),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun((()=>this.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return ao.nextTensorId++}nextVariableId(){return ao.nextVariableId++}clone(e){const t=so.runKernel(wn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return so.runKernel(Kt,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==Pr(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-o;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,o=this.state.numTensors;let s,i;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=no(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(no(e)){const{kernelName:t,inputs:a,attrs:o}=e;null==this.backendName&&this.backend;const u=Pr(t,this.backendName);nt(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();i=u.kernelFunc({inputs:a,attrs:o,backend:this.backend});const s=Array.isArray(i)?i:[i];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();i=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(i)?i:[i];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,p=no(e)?null:e.backwardsFunc;let h;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(h=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs):t=s()})),r&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:h.timeMs,extraInfo:h.extraInfo}),Array.isArray(i)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const r=Lr(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let o;r.saveAllInputs?(nt(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),o=Object.keys(t).map((e=>t[e]))):o=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return o.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&bt(e[0])&&(a=e.map((e=>Aa(e))));const o=r.write(a,t,n),s=new ja(t,n,o,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(o),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,o=new ja(r,a,n,this.nextTensorId());return this.trackTensor(o,t),o}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new Ha(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*yt(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Ha||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*yt(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,o){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},i=Lr(e);null!=i&&(r=i.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Et(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,o))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=eo(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(nt(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));nt(a instanceof ja,(()=>"The result y returned by f() must be a tensor."));const o=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const o=e[n],s=o.inputs;for(const e in s){const n=s[e];let i=!1;for(let e=0;e<t.length;e++)if(r[n.id]){o.outputs.forEach((e=>r[e.id]=!0)),i=!0,a[o.id]=!0;break}if(i)break}}const o={};o[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(o[n.outputs[e].id]){for(const e in r)o[r[e].id]=!0,s[n.id]=!0;break}}const i=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&s[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,i.push(t)}}return i}(this.state.activeTape,t,a);if(!r&&0===o.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[a.id]=null==n?function(e){const t=St(ot(e),"float32");return so.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const o=t[a],s=[];if(o.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==o.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const i=o.gradient(s);for(const t in o.inputs){if(!(t in i))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(i)}.`);const a=n((()=>i[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=o.inputs[t];if(!st(a.shape,s.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,o,(e=>this.tidy(e)),io);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return nt(wt(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;nt(t.every((e=>e instanceof ja)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),nt(n.value instanceof ja,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),nt(wt(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),o=Array.isArray(a)?a:[a];nt(o.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),nt(o.every((e=>e instanceof ja)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const s={};return o.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=Ca(),n=await this.backend.time(e);return n.wallMs=Ca()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new ro;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function oo(){const e=Pt();if(null==e._tfengine){const t=new Ft(e);e._tfengine=new ao(t)}var t;return t=e._tfengine.ENV,Dt=t,Va=()=>e._tfengine,e._tfengine}ao.nextTensorId=0,ao.nextVariableId=0;const so=oo();function io(e,t){const n={a:e,b:t};return so.runKernel(Bt,n)}function uo(e){if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function lo(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const co=Mt();co.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),co.registerFlag("IS_BROWSER",(()=>lo())),co.registerFlag("IS_NODE",(()=>void 0!==Ye&&void 0!==Ye.versions&&void 0!==Ye.versions.node)),co.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),co.registerFlag("PROD",(()=>!1)),co.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>co.getBool("DEBUG"))),co.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),co.registerFlag("IS_TEST",(()=>!1)),co.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),co.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),co.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),co.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1));var po=[],ho=[],fo="undefined"!=typeof Uint8Array?Uint8Array:Array,mo=!1;function go(){mo=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)po[t]=e[t],ho[e.charCodeAt(t)]=t;ho["-".charCodeAt(0)]=62,ho["_".charCodeAt(0)]=63}function yo(e,t,n){for(var r,a,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(po[(a=r)>>18&63]+po[a>>12&63]+po[a>>6&63]+po[63&a]);return o.join("")}function bo(e){var t;mo||go();for(var n=e.length,r=n%3,a="",o=[],s=16383,i=0,u=n-r;i<u;i+=s)o.push(yo(e,i,i+s>u?u:i+s));return 1===r?(t=e[n-1],a+=po[t>>2],a+=po[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=po[t>>10],a+=po[t>>4&63],a+=po[t<<2&63],a+="="),o.push(a),o.join("")}function vo(e,t,n,r,a){var o,s,i=8*a-r-1,u=(1<<i)-1,l=u>>1,c=-7,p=n?a-1:0,h=n?-1:1,d=e[t+p];for(p+=h,o=d&(1<<-c)-1,d>>=-c,c+=i;c>0;o=256*o+e[t+p],p+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+e[t+p],p+=h,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=l}return(d?-1:1)*s*Math.pow(2,o-r)}function wo(e,t,n,r,a,o){var s,i,u,l=8*o-a-1,c=(1<<l)-1,p=c>>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+p>=1?h/u:h*Math.pow(2,1-p))*u>=2&&(s++,u/=2),s+p>=c?(i=0,s=c):s+p>=1?(i=(t*u-1)*Math.pow(2,a),s+=p):(i=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+d]=255&i,d+=f,i/=256,a-=8);for(s=s<<a|i,l+=a;l>0;e[n+d]=255&s,d+=f,s/=256,l-=8);e[n+d-f]|=128*m}var xo={}.toString,_o=Array.isArray||function(e){return"[object Array]"==xo.call(e)};function ko(){return So.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function To(e,t){if(ko()<t)throw new RangeError("Invalid typed array length");return So.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=So.prototype:(null===e&&(e=new So(t)),e.length=t),e}function So(e,t,n){if(!(So.TYPED_ARRAY_SUPPORT||this instanceof So))return new So(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Co(this,e)}return Eo(this,e,t,n)}function Eo(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),So.TYPED_ARRAY_SUPPORT?(e=t).__proto__=So.prototype:e=Ao(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!So.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Fo(t,n),a=(e=To(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if(Ro(t)){var n=0|No(t.length);return 0===(e=To(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?To(e,0):Ao(e,t);if("Buffer"===t.type&&_o(t.data))return Ao(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Io(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Co(e,t){if(Io(t),e=To(e,t<0?0:0|No(t)),!So.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ao(e,t){var n=t.length<0?0:0|No(t.length);e=To(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function No(e){if(e>=ko())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ko().toString(16)+" bytes");return 0|e}function Ro(e){return!(null==e||!e._isBuffer)}function Fo(e,t){if(Ro(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return os(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ss(e).length;default:if(r)return os(e).length;t=(""+t).toLowerCase(),r=!0}}function Oo(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return qo(this,t,n);case"utf8":case"utf-8":return jo(this,t,n);case"ascii":return Go(this,t,n);case"latin1":case"binary":return Ko(this,t,n);case"base64":return zo(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yo(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Mo(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function $o(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=So.from(t,r)),Ro(t))return 0===t.length?-1:Do(e,t,n,r,a);if("number"==typeof t)return t&=255,So.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Do(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function Do(e,t,n,r,a){var o,s=1,i=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,i/=2,u/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var c=-1;for(o=n;o<i;o++)if(l(e,o)===l(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(n+u>i&&(n=i-u),o=n;o>=0;o--){for(var p=!0,h=0;h<u;h++)if(l(e,o+h)!==l(t,h)){p=!1;break}if(p)return o}return-1}function Po(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var i=parseInt(t.substr(2*s,2),16);if(isNaN(i))return s;e[n+s]=i}return s}function Lo(e,t,n,r){return is(os(t,e.length-n),e,n,r)}function Bo(e,t,n,r){return is(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Uo(e,t,n,r){return Bo(e,t,n,r)}function Wo(e,t,n,r){return is(ss(t),e,n,r)}function Vo(e,t,n,r){return is(function(e,t){for(var n,r,a,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,o.push(a),o.push(r);return o}(t,e.length-n),e,n,r)}function zo(e,t,n){return 0===t&&n===e.length?bo(e):bo(e.slice(t,n))}function jo(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var o,s,i,u,l=e[a],c=null,p=l>239?4:l>223?3:l>191?2:1;if(a+p<=n)switch(p){case 1:l<128&&(c=l);break;case 2:128==(192&(o=e[a+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=e[a+1],s=e[a+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[a+1],s=e[a+2],i=e[a+3],128==(192&o)&&128==(192&s)&&128==(192&i)&&(u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&i)>65535&&u<1114112&&(c=u)}null===c?(c=65533,p=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),a+=p}return function(e){var t=e.length;if(t<=Ho)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Ho));return n}(r)}So.TYPED_ARRAY_SUPPORT=void 0===Te.TYPED_ARRAY_SUPPORT||Te.TYPED_ARRAY_SUPPORT,ko(),So.poolSize=8192,So._augment=function(e){return e.__proto__=So.prototype,e},So.from=function(e,t,n){return Eo(null,e,t,n)},So.TYPED_ARRAY_SUPPORT&&(So.prototype.__proto__=Uint8Array.prototype,So.__proto__=Uint8Array),So.alloc=function(e,t,n){return function(e,t,n,r){return Io(t),t<=0?To(e,t):void 0!==n?"string"==typeof r?To(e,t).fill(n,r):To(e,t).fill(n):To(e,t)}(null,e,t,n)},So.allocUnsafe=function(e){return Co(null,e)},So.allocUnsafeSlow=function(e){return Co(null,e)},So.isBuffer=function(e){return null!=e&&(!!e._isBuffer||us(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&us(e.slice(0,0))}(e))},So.compare=function(e,t){if(!Ro(e)||!Ro(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,o=Math.min(n,r);a<o;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},So.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},So.concat=function(e,t){if(!_o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return So.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=So.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var o=e[n];if(!Ro(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,a),a+=o.length}return r},So.byteLength=Fo,So.prototype._isBuffer=!0,So.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Mo(this,t,t+1);return this},So.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Mo(this,t,t+3),Mo(this,t+1,t+2);return this},So.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Mo(this,t,t+7),Mo(this,t+1,t+6),Mo(this,t+2,t+5),Mo(this,t+3,t+4);return this},So.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?jo(this,0,e):Oo.apply(this,arguments)},So.prototype.equals=function(e){if(!Ro(e))throw new TypeError("Argument must be a Buffer");return this===e||0===So.compare(this,e)},So.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},So.prototype.compare=function(e,t,n,r,a){if(!Ro(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(a>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),i=Math.min(o,s),u=this.slice(r,a),l=e.slice(t,n),c=0;c<i;++c)if(u[c]!==l[c]){o=u[c],s=l[c];break}return o<s?-1:s<o?1:0},So.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},So.prototype.indexOf=function(e,t,n){return $o(this,e,t,n,!0)},So.prototype.lastIndexOf=function(e,t,n){return $o(this,e,t,n,!1)},So.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return Po(this,e,t,n);case"utf8":case"utf-8":return Lo(this,e,t,n);case"ascii":return Bo(this,e,t,n);case"latin1":case"binary":return Uo(this,e,t,n);case"base64":return Wo(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vo(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},So.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ho=4096;function Go(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Ko(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function qo(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",o=t;o<n;++o)a+=as(e[o]);return a}function Yo(e,t,n){for(var r=e.slice(t,n),a="",o=0;o<r.length;o+=2)a+=String.fromCharCode(r[o]+256*r[o+1]);return a}function Xo(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Qo(e,t,n,r,a,o){if(!Ro(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Jo(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,o=Math.min(e.length-n,2);a<o;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function Zo(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,o=Math.min(e.length-n,4);a<o;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function es(e,t,n,r,a,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ts(e,t,n,r,a){return a||es(e,0,n,4),wo(e,t,n,r,23,4),n+4}function ns(e,t,n,r,a){return a||es(e,0,n,8),wo(e,t,n,r,52,8),n+8}So.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),So.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=So.prototype;else{var a=t-e;n=new So(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n},So.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Xo(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r},So.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Xo(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},So.prototype.readUInt8=function(e,t){return t||Xo(e,1,this.length),this[e]},So.prototype.readUInt16LE=function(e,t){return t||Xo(e,2,this.length),this[e]|this[e+1]<<8},So.prototype.readUInt16BE=function(e,t){return t||Xo(e,2,this.length),this[e]<<8|this[e+1]},So.prototype.readUInt32LE=function(e,t){return t||Xo(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},So.prototype.readUInt32BE=function(e,t){return t||Xo(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},So.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Xo(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},So.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Xo(e,t,this.length);for(var r=t,a=1,o=this[e+--r];r>0&&(a*=256);)o+=this[e+--r]*a;return o>=(a*=128)&&(o-=Math.pow(2,8*t)),o},So.prototype.readInt8=function(e,t){return t||Xo(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},So.prototype.readInt16LE=function(e,t){t||Xo(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},So.prototype.readInt16BE=function(e,t){t||Xo(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},So.prototype.readInt32LE=function(e,t){return t||Xo(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},So.prototype.readInt32BE=function(e,t){return t||Xo(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},So.prototype.readFloatLE=function(e,t){return t||Xo(e,4,this.length),vo(this,e,!0,23,4)},So.prototype.readFloatBE=function(e,t){return t||Xo(e,4,this.length),vo(this,e,!1,23,4)},So.prototype.readDoubleLE=function(e,t){return t||Xo(e,8,this.length),vo(this,e,!0,52,8)},So.prototype.readDoubleBE=function(e,t){return t||Xo(e,8,this.length),vo(this,e,!1,52,8)},So.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Qo(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,o=0;for(this[t]=255&e;++o<n&&(a*=256);)this[t+o]=e/a&255;return t+n},So.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Qo(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,o=1;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+n},So.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,1,255,0),So.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},So.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,2,65535,0),So.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Jo(this,e,t,!0),t+2},So.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,2,65535,0),So.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Jo(this,e,t,!1),t+2},So.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,4,4294967295,0),So.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Zo(this,e,t,!0),t+4},So.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,4,4294967295,0),So.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Zo(this,e,t,!1),t+4},So.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Qo(this,e,t,n,a-1,-a)}var o=0,s=1,i=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===i&&0!==this[t+o-1]&&(i=1),this[t+o]=(e/s>>0)-i&255;return t+n},So.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Qo(this,e,t,n,a-1,-a)}var o=n-1,s=1,i=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===i&&0!==this[t+o+1]&&(i=1),this[t+o]=(e/s>>0)-i&255;return t+n},So.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,1,127,-128),So.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},So.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,2,32767,-32768),So.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Jo(this,e,t,!0),t+2},So.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,2,32767,-32768),So.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Jo(this,e,t,!1),t+2},So.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,4,2147483647,-2147483648),So.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Zo(this,e,t,!0),t+4},So.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Qo(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),So.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Zo(this,e,t,!1),t+4},So.prototype.writeFloatLE=function(e,t,n){return ts(this,e,t,!0,n)},So.prototype.writeFloatBE=function(e,t,n){return ts(this,e,t,!1,n)},So.prototype.writeDoubleLE=function(e,t,n){return ns(this,e,t,!0,n)},So.prototype.writeDoubleBE=function(e,t,n){return ns(this,e,t,!1,n)},So.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,o=r-n;if(this===e&&n<t&&t<r)for(a=o-1;a>=0;--a)e[a+t]=this[a+n];else if(o<1e3||!So.TYPED_ARRAY_SUPPORT)for(a=0;a<o;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},So.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!So.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=Ro(e)?e:os(new So(e,r).toString()),i=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%i]}return this};var rs=/[^+\/0-9A-Za-z-_]/g;function as(e){return e<16?"0"+e.toString(16):e.toString(16)}function os(e,t){var n;t=t||1/0;for(var r=e.length,a=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&o.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function ss(e){return function(e){var t,n,r,a,o,s;mo||go();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[i-2]?2:"="===e[i-1]?1:0,s=new fo(3*i/4-o),r=o>0?i-4:i;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)a=ho[e.charCodeAt(t)]<<18|ho[e.charCodeAt(t+1)]<<12|ho[e.charCodeAt(t+2)]<<6|ho[e.charCodeAt(t+3)],s[u++]=a>>16&255,s[u++]=a>>8&255,s[u++]=255&a;return 2===o?(a=ho[e.charCodeAt(t)]<<2|ho[e.charCodeAt(t+1)]>>4,s[u++]=255&a):1===o&&(a=ho[e.charCodeAt(t)]<<10|ho[e.charCodeAt(t+1)]<<4|ho[e.charCodeAt(t+2)]>>2,s[u++]=a>>8&255,s[u++]=255&a),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(rs,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function is(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function us(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function ls(e,t){let n=e;if(Ra(e))return"string"===t?[]:[e.length];if("object"==typeof e){if("texture"in e){const t=e.channels||"RGBA";return[e.height,e.width*t.length]}if("buffer"in e&&!(e.buffer instanceof ArrayBuffer))return[e.buffer.size/(null==t?4:yt(t))]}if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||Ra(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Mt().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&cs(e,r,[]),r}function cs(e,t,n){if(n=n||[],!Array.isArray(e)&&!Ra(e))return void nt(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));nt(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),nt(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t<e.length;++t)cs(e[t],r,n.concat(t))}function ps(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function hs(e,t,n,r="numeric"){if(e instanceof ja)return ps(r,e.dtype,t,n),e;let a=vt(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),ps(r,a,t,n),null==e||!Ra(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const o=ls(e,a);Ra(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ia(e,a):Fa(e,[],!0);return so.makeTensor(s,o,a)}function ds(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>hs(e,`${t}[${a}]`,n,r)))}const fs="__op";function ms(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=fs;const a=(...e)=>{so.startScope(n);try{const t=r(...e);return Nt(t)&&console.error("Cannot return a Promise inside of tidy."),so.endScope(t),t}catch(e){throw so.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const gs=ms({complex_:function(e,t){const n=hs(e,"real","complex"),r=hs(t,"imag","complex");rt(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return so.runKernel("Complex",a)}});function ys(e,t,n,r){if(null==r)r=vt(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if("object"==typeof e&&("texture"in e||"buffer"in e&&!(e.buffer instanceof ArrayBuffer))){if("float32"!==r&&"int32"!==r)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${r}.`);return so.backend.createTensorFromGPUData(e,t||n,r)}if(!Ra(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){It(t);const e=ot(t),r=ot(n);nt(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e<n.length;++e){const r=n[e],a=e!==n.length-1||r!==ot(t.slice(e));nt(n[e]===t[e]||!a,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return Ra(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ia(e,r):Fa(e,[],!0),so.makeTensor(e,t,r)}function bs(e,t,n){return ys(e,t,ls(e,n),n)}const vs={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};function ws(e,t){const n={};let r,a=0;for(const o of t){const t=o.name,s=o.dtype,i=o.shape,u=ot(i);let l;if("quantization"in o){const n=o.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n)||!("scale"in n))throw new Error(`Weight ${o.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==n.dtype)throw new Error(`Weight ${o.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==s)throw new Error(`Weight ${o.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${s}.`)}const i=vs[n.dtype],c=e.slice(a,a+u*i),p="uint8"===n.dtype?new Uint8Array(c):new Uint16Array(c);if("float32"===s)if("uint8"===n.dtype||"uint16"===n.dtype){l=new Float32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];l[e]=t*n.scale+n.min}}else{if("float16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);void 0===r&&(r=Rs()),l=r(p)}else{if("int32"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);l=new Int32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];l[e]=Math.round(t*n.scale+n.min)}}a+=u*i}else if("string"===s){const t=ot(o.shape);l=[];for(let n=0;n<t;n++){const t=new Uint32Array(e.slice(a,a+4))[0];a+=4;const n=new Uint8Array(e.slice(a,a+t));l.push(n),a+=t}}else{const r=vs[s],o=e.slice(a,a+u*r);if("float32"===s)l=new Float32Array(o);else if("int32"===s)l=new Int32Array(o);else if("bool"===s)l=new Uint8Array(o);else{if("complex64"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);{l=new Float32Array(o);const e=new Float32Array(l.length/2),r=new Float32Array(l.length/2);for(let t=0;t<e.length;t++)e[t]=l[2*t],r[t]=l[2*t+1];const a=bs(e,i,"float32"),s=bs(r,i,"float32");n[t]=gs(a,s),a.dispose(),s.dispose()}}a+=u*r}"complex64"!==s&&(n[t]=bs(l,i,s))}return n}function xs(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];e.forEach((e=>{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const _s=void 0!==So&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function ks(e){return _s?So.byteLength(e):new Blob([e]).size}function Ts(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function Ss(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Es(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(n.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}function Is(e,t,n){const r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=t,r.weightData=n}return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),r}async function Cs(e,t){let n,r;return null!=e.weightsManifest&&([n,r]=await t(e.weightsManifest)),Is(e,n,r)}function As(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:ks(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:ks(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Ns(e){const t=[];for(const n of e)t.push(...n.weights);return t}function Rs(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),o=new Uint32Array(a);for(let a=0;a<r.length;a++){const s=r[a],i=e[n[s>>10]+(1023&s)]+t[s>>10];o[a]=i}return new Float32Array(a)}}class Fs{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Fs.instance&&(Fs.instance=new Fs),Fs.instance}static registerSaveRouter(e){Fs.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Fs.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Fs.getHandlers(e,"save")}static getLoadHandlers(e,t){return Fs.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Fs.getInstance().loadRouters:Fs.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Os="tensorflowjs",Ms="models_store",$s="model_info_store";function Ds(){if(!Mt().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Ps(e){const t=e.result;t.createObjectStore(Ms,{keyPath:"modelPath"}),t.createObjectStore($s,{keyPath:"modelPath"})}class Ls{constructor(e){if(this.indexedDB=Ds(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(Os,1);r.onupgradeneeded=()=>Ps(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(Ms,"readonly"),r=t.objectStore(Ms).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=As(t),o=a.transaction($s,"readwrite");let s=o.objectStore($s);const i=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;i.onsuccess=()=>{u=a.transaction(Ms,"readwrite");const i=u.objectStore(Ms).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});i.onsuccess=()=>e({modelArtifactsInfo:r}),i.onerror=e=>{s=o.objectStore($s);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(i.error)),t.onerror=e=>(a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),o.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}Ls.URL_SCHEME="indexeddb://";const Bs=e=>{return Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ls.URL_SCHEME)?(t=e.slice(Ls.URL_SCHEME.length),new Ls(t)):null;var t};Fs.registerSaveRouter(Bs),Fs.registerLoadRouter(Bs);class Us{constructor(){this.indexedDB=Ds()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Os,1);n.onupgradeneeded=()=>Ps(n),n.onsuccess=()=>{const r=n.result,a=r.transaction($s,"readonly"),o=a.objectStore($s).getAll();o.onsuccess=()=>{const t={};for(const e of o.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},o.onerror=e=>(r.close(),t(o.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Ls.URL_SCHEME)?t.slice(Ls.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(Os,1);r.onupgradeneeded=()=>Ps(r),r.onsuccess=()=>{const a=r.result,o=a.transaction($s,"readwrite"),s=o.objectStore($s),i=s.get(e);let u;i.onsuccess=()=>{if(null==i.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),o=()=>{u=a.transaction(Ms,"readwrite");const r=u.objectStore(Ms).delete(e);r.onsuccess=()=>t(i.result.modelArtifactsInfo),r.onerror=e=>n(i.error)};r.onsuccess=o,r.onerror=e=>(o(),a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),o.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const Ws="/",Vs="tensorflowjs_models",zs="info",js="model_topology",Hs="weight_specs",Gs="weight_data",Ks="model_metadata";function qs(e){return{info:[Vs,e,zs].join(Ws),topology:[Vs,e,js].join(Ws),weightSpecs:[Vs,e,Hs].join(Ws),weightData:[Vs,e,Gs].join(Ws),modelMetadata:[Vs,e,Ks].join(Ws)}}function Ys(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Xs(e){const t=e.split(Ws);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Ws)}class Qs{constructor(e){if(!Mt().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=qs(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=As(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(_s)return So.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(e.weightData));const a={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(a)),{modelArtifactsInfo:r}}catch(e){throw Ys(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const o=this.LS.getItem(this.keys.weightData);if(null==o)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(_s){const t=So.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(o),t}}Qs.URL_SCHEME="localstorage://";const Js=e=>{return Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Qs.URL_SCHEME)?(t=e.slice(Qs.URL_SCHEME.length),new Qs(t)):null;var t};Fs.registerSaveRouter(Js),Fs.registerLoadRouter(Js);class Zs{constructor(){nt(Mt().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),nt("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=Vs+Ws,n=Ws+zs;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);a.startsWith(t)&&a.endsWith(n)&&(e[Xs(a)]=JSON.parse(this.LS.getItem(a)))}return e}async removeModel(e){var t;const n=qs(e=(t=e).startsWith(Qs.URL_SCHEME)?t.slice(Qs.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return Ys(n),r}}function ei(e){return new Promise((e=>setTimeout(e))).then(e)}class ti{constructor(e){if(!Mt().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(ti.URL_SCHEME)&&(e=e.slice(ti.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Es(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await ei((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await ei((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:As(e)}}}}ti.URL_SCHEME="downloads://";class ni{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const o=Cs(r,(e=>this.loadWeights(e)));e(o)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Ts(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>Ss(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=Ss(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function ri(e,t,n,r){!function(e){nt(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){nt(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),nt(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),nt(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((o=>(o.then((o=>{const s=n+ ++a/e.length*(r-n);return t(s),o})),o))))}async function ai(e,t){null==t&&(t={});const n=null==t.fetchFunc?Mt().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await ri(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await ri(a,t.onProgress,.5,1)}function oi(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),o={},s=null!=r?r.map((()=>!1)):[],i=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=vs[u]*ot(e.shape),c=()=>{a[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),i.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${i.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let h=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e<n;e++)r+=c[h+e].byteLength;const a=new ArrayBuffer(r),s=new Uint8Array(a);let i=0;for(let e=0;e<n;e++){const t=new Uint8Array(c[h+e]);s.set(t,i),i+=t.byteLength}o[e].forEach((e=>{const t=ws(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),h+=n})),p}}Fs.registerSaveRouter((e=>Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ti.URL_SCHEME)?function(e="model"){return new ti(e)}(e.slice(ti.URL_SCHEME.length)):null));class si{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(nt("function"==typeof t.fetchFunc,(()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")),this.fetch=t.fetchFunc):this.fetch=Mt().platform.fetch,nt(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&nt(2===e.length,(()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`)),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=Es(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:As(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Cs(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,o=Ns(e),s=[],i=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?i.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(i)),[o,Ts(await ai(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function ii(e){return null!=e.match(si.URL_SCHEME_REGEX)}si.URL_SCHEME_REGEX=/^https?:\/\//;const ui=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>ii(e))):ii(e),n)return li(e,t)}return null};function li(e,t){return new si(e,t)}Fs.registerSaveRouter(ui),Fs.registerLoadRouter(ui);class ci{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class pi{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class hi{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function di(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new ci(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new ci({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new ci({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}const fi="://";class mi{constructor(){this.managers={}}static getInstance(){return null==mi.instance&&(mi.instance=new mi),mi.instance}static registerManager(e,t){nt(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith(fi)&&(e=e.slice(0,e.indexOf(fi))),nt(e.length>0,(()=>"scheme must not be an empty string."));const n=mi.getInstance();nt(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=mi.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(mi.getInstance().managers)}}function gi(e){if(-1===e.indexOf(fi))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${mi.getSchemes().join(",")}`);return{scheme:e.split(fi)[0],path:e.split(fi)[1]}}async function yi(e,t,n=!1){nt(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=Fs.getLoadHandlers(e);nt(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),nt(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],o=Fs.getSaveHandlers(t);nt(o.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),nt(o.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=o[0],i=gi(e).scheme,u=gi(e).path,l=i===gi(e).scheme,c=await a.load();n&&l&&await mi.getManager(i).removeModel(u);const p=await s.save(c);return n&&!l&&await mi.getManager(i).removeModel(u),p.modelArtifactsInfo}var bi=Object.freeze({__proto__:null,browserFiles:function(e){return new ni(e)},browserHTTPRequest:function(e,t){return li(e,t)},concatenateArrayBuffers:Ts,decodeWeights:ws,encodeWeights:async function(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let o=0;o<a.length;++o){const s=a[o],i=Array.isArray(e)?e[o].tensor:e[s];if("float32"!==i.dtype&&"int32"!==i.dtype&&"bool"!==i.dtype&&"string"!==i.dtype&&"complex64"!==i.dtype)throw new Error(`Unsupported dtype in weight '${s}': ${i.dtype}`);const u={name:s,shape:i.shape,dtype:i.dtype};if("string"===i.dtype){const e=new Promise((async e=>{const t=await i.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e<t.length;e++){const n=t[e],o=new Uint8Array(new Uint32Array([n.length]).buffer);r.set(o,a),a+=4,r.set(n,a),a+=n.length}e(r)}));r.push(e)}else r.push(i.data());null!=t&&(u.group=t),n.push(u)}return{data:xs(await Promise.all(r)),specs:n}},fromMemory:function(e,t,n,r){return new hi(di(...arguments))},fromMemorySync:di,getLoadHandlers:(e,t)=>Fs.getLoadHandlers(e,t),getModelArtifactsForJSON:Cs,getModelArtifactsForJSONSync:Is,getModelArtifactsInfoForJSON:As,getSaveHandlers:e=>Fs.getSaveHandlers(e),getWeightSpecs:Ns,http:li,isHTTPScheme:ii,loadWeights:async function(e,t="",n,r){return oi((e=>ai(e,{requestInit:r})))(e,t,n)},registerLoadRouter:e=>Fs.registerLoadRouter(e),registerSaveRouter:e=>Fs.registerSaveRouter(e),weightsLoaderFactory:oi,withSaveHandler:function(e){return new pi(e)},withSaveHandlerSync:function(e){return new pi(e)},copyModel:async function(e,t){return yi(e,t,!1)},listModels:async function(){const e=mi.getSchemes(),t={};for(const n of e){const e=await mi.getManager(n).listModels();for(const r in e)t[n+fi+r]=e[r]}return t},moveModel:async function(e,t){return yi(e,t,!0)},removeModel:async function(e){const t=gi(e);return mi.getManager(t.scheme).removeModel(t.path)}});const vi=ms({cast_:function(e,t){const n=hs(e,"x","cast");if(!function(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const r={x:n},a={dtype:t};return so.runKernel(Kt,r,a)}}),wi=ms({matMul_:function(e,t,n=!1,r=!1){let a=hs(e,"a","matMul"),o=hs(t,"b","matMul");[a,o]=Za(a,o);const s={a,b:o},i={transposeA:n,transposeB:r};return so.runKernel(Ht,s,i)}}),xi=ms({oneHot_:function(e,t,n=1,r=0,a="int32"){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const o={indices:hs(e,"indices","oneHot","int32")},s={dtype:a,depth:t,onValue:n,offValue:r};return so.runKernel(Wn,o,s)}});function _i(){return so}function ki(e,t){return so.tidy(e,t)}function Ti(e){eo(e).forEach((e=>e.dispose()))}function Si(e){return so.keep(e)}function Ei(e){return so.setBackend(e)}function Ii(){return so.backendName}function Ci(e,t,n=1){return so.registerBackend(e,t,n)}const Ai=ms({imag_:function(e){const t={input:hs(e,"input","imag")};return so.runKernel("Imag",t)}}),Ni=ms({neg_:function(e){const t={x:hs(e,"x","neg")};return so.runKernel("Neg",t)}}),Ri=ms({real_:function(e){const t={input:hs(e,"input","real")};return so.runKernel("Real",t)}}),Fi=ms({transpose_:function(e,t,n){const r=hs(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),nt(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{nt(e>=0&&e<r.rank,(()=>"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},o={perm:t};return"complex64"===r.dtype?ki((()=>{let e=Ri(r),t=Ai(r);return e=so.runKernel(Sr,{x:e},o),t=so.runKernel(Sr,{x:t},o),n&&(t=Ni(t)),gs(e,t)})):so.runKernel(Sr,a,o)}});function Oi(e,t){const n=e.length,r=[];for(let a=0;a<n;a++){const o=n-1-a,s=e[o]||1;(t[t.length-1-a]||1)>1&&1===s&&r.unshift(o)}return r}function Mi(e,t){const n=[];for(let r=0;r<t.length;r++){const a=e[e.length-r-1],o=t.length-r-1,s=t[o];(null==a||1===a&&s>1)&&n.unshift(o)}return n}function $i(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a<r;a++){let r=e[e.length-a-1];null==r&&(r=1);let o=t[t.length-a-1];if(null==o&&(o=1),1===r)n.unshift(o);else if(1===o)n.unshift(r);else{if(r!==o)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);n.unshift(r)}}return n}function Di(e,t,n){if(at(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");const r=ls(e,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return ys(e,t,r,n)}let Pi;const Li=ms({fromPixels_:function(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,o=!1,s=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)o=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);i=!0}if(null!=Pr(Ar,so.backendName)){const n={pixels:e},r={numChannels:t};return so.runKernel(Ar,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(o||a||i){if(null==Pi)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");Pi=new OffscreenCanvas(1,1).getContext("2d")}else Pi=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Pi.canvas.width=u,Pi.canvas.height=l,Pi.drawImage(e,0,0,u,l),c=Pi.getImageData(0,0,u,l).data}if(4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n<e;n++)for(let e=0;e<t;++e)p[n*t+e]=c[4*n+e]}return Di(p,[l,u,t],"int32")}});function Bi(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===ot(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,o=a[a.length-1];let s=1;for(let e=0;e<a.length-1;++e)s*=a[e];const i=e.shape,u=a.slice();u.pop();let l=1;for(let e=o;e<n;++e)l*=i[e],u.push(i[e]);const c=[..._t(e.shape).map((e=>e/l)),1].slice(0,o);return[u,s,l,c]}function Ui(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank<a)throw new Error(o+` update.rank < ${a}. `);if(e.length<r+(n.rank-a))throw new Error(o+` Output shape length < ${r+(n.rank-a)}`);if(n.rank!==a+e.length-r)throw new Error(o+" update.rank != "+(a+e.length-r));for(let e=0;e<a;++e)if(n.shape[e]!==t.shape[e])throw new Error(o+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-a;++t)if(n.shape[t+a]!==e[t+r])throw new Error(o+` updates.shape[${t+a}] (${n.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function Wi(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}Ui(n,t,e)}function Vi(e,t,n){const r=t.shape.length,a=r>1?t.shape[r-1]:1,o=n.length;let s=1;for(let e=a;e<o;++e)s*=n[e];const i=a<1?1:a;return{sliceRank:a,numUpdates:ot(t.shape)/i,sliceSize:s,strides:[..._t(n.slice(0,a)),1],outputSize:ot(n)}}function zi(e,t,n){const r=e.shape.length;nt(r===t.length,(()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),nt(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a<r;++a)nt(t[a]+n[a]<=e.shape[a],(()=>`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function ji(e,t,n){const r=[];for(let a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function Hi(e,t,n,r){const a=[...e];for(let e=a.length;e<r.length;e++)a.push(1);for(let e=0;e<n;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function Gi(e,t,n){return n<=e?n:n-(t-1)}function Ki(e,t){const n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function qi(e,t,n,r,a){const o=[...a],s=Ki(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=0;else{const s=Gi(t,n,a);let i=r[s];e&1<<s&&(i=0),o[a]=i}return o}function Yi(e,t,n,r,a){const o=[...a],s=Ki(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=Number.MAX_SAFE_INTEGER;else{const s=Gi(t,n,a);let i=r[s];e&1<<s&&(i=Number.MAX_SAFE_INTEGER),o[a]=i}for(let e=0;e<o.length;e++){const t=a[e];o[e]<0&&(o[e]+=t),o[e]=Ze(0,o[e],a[e])}return o}function Xi(e,t,n){let r=e[t];return(n&1<<t||null==r)&&(r=1),r}function Qi(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=Ze(0,s,u-1),s}function Ji(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=i>0?Ze(0,s,u):Ze(-1,s,u-1),s}function Zi(e,t,n){let r=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){r=e;break}for(let a=r+1;a<n.length;a++)if(t[a]>0||n[a]!==e[a])return!1;return!0}function eu(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function tu(e,t,n){let r;const a=e.shape.length;let o;return r="number"==typeof t?[t,...new Array(a-1).fill(0)]:t.length<a?t.concat(new Array(a-t.length).fill(0)):t.slice(),r.forEach((e=>{nt(-1!==e,(()=>"slice() does not support negative begin indexing."))})),o=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.length<a?n.concat(new Array(a-n.length).fill(-1)):n,o=o.map(((t,n)=>t>=0?t:(nt(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,o]}function nu(e,t,n,r,a,o,s,i,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:o,ellipsisMask:s,newAxisMask:i,shrinkAxisMask:u};for(let e=0;e<p.dims;e++)c&&0!=(1<<e&i)&&p.numAddAxisAfterEllipsis++,1<<e&s&&(c=!0);c||(p.ellipsisMask|=1<<p.dims,p.dims++);const h={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(e,t){t.beginMask=0,t.endMask=0,t.shrinkAxisMask=0;let n=0;t.beginValid=null!=e.begin,t.endValid=null!=e.end,t.begin=new Array(t.dims),t.end=new Array(t.dims),t.strides=new Array(t.dims),t.finalShapeGatherIndices=[],t.finalShapeGatherIndicesSparse=[],t.inputShapeGatherIndicesSparse=new Array(t.dims);for(let r=0;r<e.dims;r++)if(1<<r&e.ellipsisMask){const a=Math.min(t.dims-(e.dims-r)+1+e.numAddAxisAfterEllipsis,t.dims);for(;n<a;n++)t.begin[n]=0,t.end[n]=0,t.strides[n]=1,t.beginMask|=1<<n,t.endMask|=1<<n,t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(-1),t.inputShapeGatherIndicesSparse[n]=r}else if(1<<r&e.newAxisMask)t.finalShapeGatherIndices.push(-2),t.finalShapeGatherIndicesSparse.push(-1);else{if(n===t.begin.length)throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);null!=e.begin&&(t.begin[n]=e.begin[r]),null!=e.end&&(t.end[n]=e.end[r]),t.strides[n]=e.strides[r],e.beginMask&1<<r&&(t.beginMask|=1<<n),e.endMask&1<<r&&(t.endMask|=1<<n),e.shrinkAxisMask&1<<r?(t.finalShapeGatherIndices.push(-1),t.finalShapeGatherIndicesSparse.push(-1),t.shrinkAxisMask|=1<<n):(t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(r)),t.inputShapeGatherIndicesSparse[n]=r,n++}}(p,h);let d=!0,f=!0,m=!0;const g=[],y=[];for(let t=0;t<e.length;++t){if(0===h.strides[t])throw Error(`strides[${t}] must be non-zero`);const n=!!(h.shrinkAxisMask&1<<t),r=e[t];if(-1===r){g.push(n?1:-1);continue}const a=[h.beginMask&1<<t,h.endMask&1<<t],o=[h.strides[t]>0?0:-1,h.strides[t]>0?r:r-1];if(n&&h.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===h.strides[t];const s=!!(h.beginMask&1<<t&&h.endMask&1<<t);if(h.beginValid&&h.endValid){if(n){const e=h.begin[t]<0?r+h.begin[t]:h.begin[t];if(h.begin[t]=e,h.end[t]=h.begin[t]+1,e<0||e>=r)throw Error(`slice index ${h.begin[t]} of dimension ${t} out of bounds.`)}else h.begin[t]=ru(h.begin[t],0,h.strides[t],r,a,o),h.end[t]=ru(h.end[t],1,h.strides[t],r,a,o);const e=1===h.strides[t]&&0===h.begin[t]&&h.end[t]===r;d=d&&e,f=f&&(0===t&&1===h.strides[t]||e)}else d=d&&1===h.strides[t]&&s,f=f&&(0===t&&1===h.strides[t]||s);let i,u=!1;if(h.beginValid&&h.endValid?(i=h.end[t]-h.begin[t],u=!0):n?(i=1,u=!0):s&&r>=0&&(i=h.strides[t]<0?-r:r,u=!0),u){let e;e=0===i||i<0!=h.strides[t]<0?0:Math.trunc(i/h.strides[t])+(i%h.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e<h.finalShapeGatherIndices.length;++e){const t=h.finalShapeGatherIndices[e];t>=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==h.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:d,sliceDim0:f,isSimpleSlice:m,begin:h.begin,end:h.end,strides:h.strides}}function ru(e,t,n,r,a,o){if(a[t])return n>0?o[t]:o[t+1&1];{const t=e<0?r+e:e;return t<o[0]?o[0]:t>o[1]?o[1]:t}}var au=Object.freeze({__proto__:null,assertParamsValid:zi,maskToAxes:function(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t},computeOutShape:ji,stridesWithElidedDims:Hi,getNormalizedAxes:function(e,t,n,r,a,o,s,i,u){const l=e.length;let c=new Array(l),p=new Array(l),h=new Array(l);if(t.length&&n>0){const u=t[0],l=n+1;c=qi(s,u,l,r,e),p=Yi(i,u,l,a,e),h=Hi(o,u,l,e)}else for(let t=0;t<l;t++)c[t]=Qi(s,r,o,e,t,u),p[t]=Ji(i,a,o,e,t,u),h[t]=Xi(o,t,u);return{begin:c,end:p,strides:h}},startIndicesWithElidedDims:qi,stopIndicesWithElidedDims:Yi,stridesForAxis:Xi,startForAxis:Qi,stopForAxis:Ji,isSliceContinous:Zi,computeFlatOffset:eu,parseSliceParams:tu,sliceInfo:nu});const ou=ms({add_:function(e,t){let n=hs(e,"a","add"),r=hs(t,"b","add");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel(Bt,a)}}),su=ms({floorDiv_:function(e,t){let n=hs(e,"a","floorDiv"),r=hs(t,"b","floorDiv");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel(fn,a)}}),iu=ms({div_:function(e,t){let n=hs(e,"a","div"),r=hs(t,"b","div");if([n,r]=Za(n,r),"int32"===n.dtype&&"int32"===r.dtype)return su(n,r);const a={a:n,b:r};return so.runKernel(on,a,{})}}),uu=ms({mul_:function(e,t){let n=hs(e,"a","mul"),r=hs(t,"b","mul");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel($n,a)}}),lu=ms({abs_:function(e){const t=hs(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return so.runKernel("ComplexAbs",e)}{const e={x:t};return so.runKernel("Abs",e)}}}),cu=ms({acos_:function(e){const t={x:hs(e,"x","acos")};return so.runKernel("Acos",t)}}),pu=ms({acosh_:function(e){const t={x:hs(e,"x","acosh")};return so.runKernel("Acosh",t)}}),hu=ms({addN_:function(e){nt(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),nt(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>hs(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!st(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return so.runKernel(Ut,r)}}),du=ms({all_:function(e,t=null,n=!1){const r={x:hs(e,"x","all","bool")},a={axis:t,keepDims:n};return so.runKernel(Wt,r,a)}}),fu=ms({any_:function(e,t=null,n=!1){const r={x:hs(e,"x","any","bool")},a={axis:t,keepDims:n};return so.runKernel(Vt,r,a)}}),mu=ms({argMax_:function(e,t=0){const n={x:hs(e,"x","argMax")},r={axis:t};return so.runKernel(zt,n,r)}}),gu=ms({argMin_:function(e,t=0){const n={x:hs(e,"x","argMin")},r={axis:t};return so.runKernel("ArgMin",n,r)}}),yu=ms({asin_:function(e){const t={x:hs(e,"x","asin")};return so.runKernel("Asin",t)}}),bu=ms({asinh_:function(e){const t={x:hs(e,"x","asinh")};return so.runKernel("Asinh",t)}}),vu=ms({atan_:function(e){const t={x:hs(e,"x","atan")};return so.runKernel("Atan",t)}}),wu=ms({atan2_:function(e,t){let n=hs(e,"a","atan2"),r=hs(t,"b","atan2");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel("Atan2",a)}}),xu=ms({atanh_:function(e){const t={x:hs(e,"x","atanh")};return so.runKernel("Atanh",t)}});function _u(e,t,n,r,a,o,s="channelsLast"){const[i,u]=Eu(t);let l;if("channelsLast"===s)l=[i,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[i,u,e[1],e[1]]}return ku(e,l,n,r,a,o,!1,s)}function ku(e,t,n,r,a,o,s=!1,i="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if("channelsLast"===i)[u,l,c,p]=e;else{if("channelsFirst"!==i)throw new Error(`Unknown dataFormat ${i}`);[u,p,l,c]=e}const[h,d,,f]=t,[m,g]=Eu(n),[y,b]=Eu(r),v=Cu(h,y),w=Cu(d,b),{padInfo:x,outHeight:_,outWidth:k}=function(e,t,n,r,a,o,s,i,u){let l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=Su(e,t,n));const o=e[1];return[Au((e[0]-t+2*r)/n+1,a),Au((o-t+2*r)/n+1,a)]}([t,n],o,r,e,i);c=a[0],p=a[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+o-t),i=Math.max(0,(p-1)*a+s-n),u=Math.floor(e/2),h=e-u,d=Math.floor(i/2);l={top:u,bottom:h,left:d,right:i-d,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-o+1)/r),p=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const h="channelsLast"===u?e[1][0]:e[2][0],d="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:h,bottom:d,left:f,right:m,type:0===h&&0===d&&0===f&&0===m?"VALID":"EXPLICIT"},c=Au((t-o+h+d)/r+1,i),p=Au((n-s+f+m)/a+1,i)}}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,m,g,v,w,o,i),T=s?f*p:f;let S;return"channelsFirst"===i?S=[u,T,_,k]:"channelsLast"===i&&(S=[u,_,k,T]),{batchSize:u,dataFormat:i,inHeight:l,inWidth:c,inChannels:p,outHeight:_,outWidth:k,outChannels:T,padInfo:x,strideHeight:m,strideWidth:g,filterHeight:h,filterWidth:d,effectiveFilterHeight:v,effectiveFilterWidth:w,dilationHeight:y,dilationWidth:b,inShape:e,outShape:S,filterShape:t}}function Tu(e,t,n,r,a,o=!1,s="channelsLast",i){let[u,l,c,p,h]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,p,h]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,h,l,c,p]=e}const[d,f,m,,g]=t,[y,b,v]=Iu(n),[w,x,_]=Iu(r),k=Cu(d,w),T=Cu(f,x),S=Cu(m,_),{padInfo:E,outDepth:I,outHeight:C,outWidth:A}=function(e,t,n,r,a,o,s,i,u,l,c){let p,h,d,f;if("valid"===e&&(e=0),"number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const m=function(e,t,n,r,a,o){null==a&&(a=Su(e,t[0],r[0]));const s=[0,0,0,1];for(let n=0;n<3;n++)e[n]+2*a>=t[n]&&(s[n]=Au((e[n]-t[n]+2*a)/r[n]+1,o));return s}([t,n,r,1],[i,u,l],0,[a,o,s],e,c);h=m[0],d=m[1],f=m[2]}else{if("same"!==e)throw Error(`Unknown padding parameter: ${e}`);{h=Math.ceil(t/a),d=Math.ceil(n/o),f=Math.ceil(r/s);const e=(h-1)*a+i-t,c=(d-1)*o+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),v=c-b,w=Math.floor(m/2);p={top:b,bottom:v,left:w,right:m-w,front:g,back:y,type:"SAME"}}}return{padInfo:p,outDepth:h,outHeight:d,outWidth:f}}(a,l,c,p,y,b,v,k,T,S,i),N=o?g*h:g;let R;return"channelsFirst"===s?R=[u,N,I,C,A]:"channelsLast"===s&&(R=[u,I,C,A,N]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:p,inChannels:h,outDepth:I,outHeight:C,outWidth:A,outChannels:N,padInfo:E,strideDepth:y,strideHeight:b,strideWidth:v,filterDepth:d,filterHeight:f,filterWidth:m,effectiveFilterDepth:k,effectiveFilterHeight:T,effectiveFilterWidth:S,dilationDepth:w,dilationHeight:x,dilationWidth:_,inShape:e,outShape:R,filterShape:t}}function Su(e,t,n,r=1){const a=Cu(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function Eu(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function Iu(e){return"number"==typeof e?[e,e,e]:e}function Cu(e,t){return t<=1?e:e+(e-1)*(t-1)}function Au(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function Nu(e){const[t,n,r]=Eu(e);return 1===t&&1===n&&1===r}function Ru(e,t){return Nu(e)||Nu(t)}function Fu(e){return Eu(e).every((e=>e>0))}function Ou(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function Mu(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)nt(it(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{nt(it(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const $u=ms({reshape_:function(e,t){const n={x:hs(e,"x","reshape","string_or_numeric")},r={shape:t};return so.runKernel(Yn,n,r)}}),Du=ms({avgPool_:function(e,t,n,r,a){const o=hs(e,"x","avgPool","float32");nt(Ru(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=o,i=!1;3===o.rank&&(i=!0,s=$u(o,[1,o.shape[0],o.shape[1],o.shape[2]])),nt(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),Mu("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=so.runKernel(jt,u,l);return c=vi(c,o.dtype),i?$u(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Pu=ms({avgPool3d_:function(e,t,n,r,a,o="NDHWC"){const s=hs(e,"x","avgPool3d","float32");let i=s,u=!1;4===s.rank&&(u=!0,i=$u(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===i.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`)),nt("NDHWC"===o,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`)),nt("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`)),Mu("avgPool3d",r,a);const l={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:o};let p=so.runKernel("AvgPool3D",l,c);return p=vi(p,i.dtype),u?$u(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),Lu=ms({clone_:function(e){const t={x:hs(e,"x","clone","string_or_numeric")};return so.runKernel(wn,t)}}),Bu=ms({concat_:function(e,t=0){nt(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=ds(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return Lu(n[0]);const r=n,a={axis:t};return so.runKernel(Xt,r,a)}}),Uu=ms({sigmoid_:function(e){const t={x:hs(e,"x","sigmoid","float32")};return so.runKernel(or,t)}}),Wu=ms({slice_:function(e,t,n){const r=hs(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},o={begin:t,size:n};return so.runKernel(ar,a,o)}}),Vu=ms({tanh_:function(e){const t={x:hs(e,"x","tanh","float32")};return so.runKernel(xr,t)}}),zu=ms({basicLSTMCell_:function(e,t,n,r,a,o){const s=hs(e,"forgetBias","basicLSTMCell"),i=hs(t,"lstmKernel","basicLSTMCell"),u=hs(n,"lstmBias","basicLSTMCell"),l=hs(r,"data","basicLSTMCell"),c=hs(a,"c","basicLSTMCell"),p=hs(o,"h","basicLSTMCell"),h=Bu([l,p],1),d=wi(h,i),f=ou(d,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=Wu(f,[0,0],y),v=Wu(f,[0,g],y),w=Wu(f,[0,2*g],y),x=Wu(f,[0,3*g],y),_=ou(uu(Uu(b),Vu(v)),uu(c,Uu(ou(s,w))));return[_,uu(Vu(_),Uu(x))]}}),ju=ms({batchToSpaceND_:function(e,t,n){const r=hs(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));nt(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),nt(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),nt(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const o={x:r},s={blockShape:t,crops:n};return so.runKernel(Gt,o,s)}}),Hu=ms({batchNorm_:function(e,t,n,r,a,o){null==o&&(o=.001);const s=hs(e,"x","batchNorm"),i=hs(t,"mean","batchNorm"),u=hs(n,"variance","batchNorm");let l,c;null!=a&&(l=hs(a,"scale","batchNorm")),null!=r&&(c=hs(r,"offset","batchNorm")),nt(i.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),nt(null==c||i.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),nt(null==l||i.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p=function(e){let t;return t=0===e.rank||1===e.rank?$u(e,[1,1,1,e.size]):2===e.rank?$u(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?$u(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),h={x:p,scale:l,offset:c,mean:i,variance:u},d={varianceEpsilon:o},f=so.runKernel(mn,h,d);return $u(f,s.shape)}}),Gu=ms({batchNorm2d_:function(e,t,n,r,a,o){const s=hs(e,"x","batchNorm"),i=hs(t,"mean","batchNorm"),u=hs(n,"variance","batchNorm");let l,c;return null!=a&&(l=hs(a,"scale","batchNorm")),null!=r&&(c=hs(r,"offset","batchNorm")),nt(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),nt(2===i.rank||1===i.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`)),nt(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),Hu(s,i,u,c,l,o)}}),Ku=ms({batchNorm3d_:function(e,t,n,r,a,o){const s=hs(e,"x","batchNorm"),i=hs(t,"mean","batchNorm"),u=hs(n,"variance","batchNorm");let l,c;return null!=a&&(l=hs(a,"scale","batchNorm")),null!=r&&(c=hs(r,"offset","batchNorm")),nt(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),nt(3===i.rank||1===i.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`)),nt(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),Hu(s,i,u,c,l,o)}}),qu=ms({batchNorm4d_:function(e,t,n,r,a,o){const s=hs(e,"x","batchNorm"),i=hs(t,"mean","batchNorm"),u=hs(n,"variance","batchNorm");let l,c;return null!=a&&(l=hs(a,"scale","batchNorm")),null!=r&&(c=hs(r,"offset","batchNorm")),nt(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),nt(4===i.rank||1===i.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`)),nt(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),Hu(s,i,u,c,l,o)}}),Yu=ms({bincount_:function(e,t,n){const r=hs(e,"x","bincount"),a=hs(t,"weights","bincount");nt("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),nt(n>=0,(()=>`size must be non-negative, but got ${n}.`)),nt(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const o={x:r,weights:a},s={size:n};return so.runKernel("Bincount",o,s)}}),Xu=ms({broadcastArgs_:function(e,t){const n=hs(e,"s0","broadcastArgs","int32"),r=hs(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return so.runKernel("BroadcastArgs",a)}}),Qu=ms({broadcastTo_:function(e,t){let n=hs(e,"broadcastTo","x");const r=n.shape;if(It(t),t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){const e=n.shape.slice();for(;e.length<t.length;)e.unshift(1);n=$u(n,e)}const a=n.shape,o=Array.from(t);for(let e=t.length-1;e>=0;e--)if(a[e]===t[e])o[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=o.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return Lu(n);const i={x:n},u={reps:o};return so.runKernel(_r,i,u)}});function Ju(e,t="float32",n){return t=t||"float32",It(e),new Wa(e,t,n)}const Zu=ms({ceil_:function(e){const t={x:hs(e,"x","ceil","float32")};return so.runKernel(qt,t)}});function el(e,t,n){It(e);const r={shape:e,value:t,dtype:n};return so.runKernel(pn,{},r)}const tl=ms({clipByValue_:function(e,t,n){const r=hs(e,"x","clipByValue");if(nt(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`)),t===n)return el(r.shape,t,r.dtype);const a={x:r},o={clipValueMin:t,clipValueMax:n};return so.runKernel(Yt,a,o)}}),nl=ms({concat1d_:function(e){return Bu(e,0)}}),rl=ms({concat2d_:function(e,t){return Bu(e,t)}}),al=ms({concat3d_:function(e,t){return Bu(e,t)}}),ol=ms({concat4d_:function(e,t){return Bu(e,t)}}),sl=ms({conv2d_:function(e,t,n,r,a="NHWC",o=[1,1],s){const i=hs(e,"x","conv2d","float32"),u=hs(t,"filter","conv2d","float32");let l=i,c=!1;3===i.rank&&(c=!0,l=$u(i,[1,i.shape[0],i.shape[1],i.shape[2]])),nt(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),nt(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),Mu("conv2d",r,s);const p="NHWC"===a?l.shape[3]:l.shape[1];nt(p===u.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`)),nt(Ru(n,o),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`)),nt(Fu(o),(()=>"Error in conv2D: Dilated rates should be larger than 0.")),nt(Fu(n),(()=>"Error in conv2D: Strides should be larger than 0."));const h={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:o,dimRoundingMode:s},f=so.runKernel(Qt,h,d);return c?$u(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),il=ms({conv1d_:function(e,t,n,r,a="NWC",o=1,s){const i=hs(e,"x","conv1d"),u=hs(t,"filter","conv1d");let l=i,c=!1;2===i.rank&&(c=!0,l=$u(i,[1,i.shape[0],i.shape[1]])),nt(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),nt(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),Mu("conv1d",r,s),nt(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),nt(Ru(n,o),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${o}'`)),nt(Fu(o),(()=>"Error in conv1D: Dilated rates should be larger than 0.")),nt(Fu(n),(()=>"Error in conv1D: Stride should be larger than 0.")),nt("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const p=$u(u,[1,u.shape[0],u.shape[1],u.shape[2]]),h=$u(l,[l.shape[0],1,l.shape[1],l.shape[2]]),d=sl(h,p,[1,n],r,"NHWC",[1,o],s);return $u(d,c?[d.shape[2],d.shape[3]]:[d.shape[0],d.shape[2],d.shape[3]])}}),ul=ms({conv2DBackpropInput_:function(e,t,n,r,a,o="NHWC",s){nt(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,u=t,l=!1;3===t.rank&&(l=!0,u=$u(t,[1,t.shape[0],t.shape[1],t.shape[2]]),i=[1,e[0],e[1],e[2]]),nt(4===i.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`)),nt(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),nt(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===o?i[3]:i[1],p="NHWC"===o?u.shape[3]:u.shape[1];nt(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),nt(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),Mu("conv2dDerInput",a,s);const h={dy:u,filter:n},d={strides:r,pad:a,dataFormat:o,dimRoundingMode:s,inputShape:i},f=so.runKernel(Jt,h,d);return l?$u(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),ll=ms({conv2dTranspose_:function(e,t,n,r,a,o){const s=hs(e,"x","conv2dTranspose"),i=hs(t,"filter","conv2dTranspose");return ul(n,s,i,r,a,"NHWC",o)}}),cl=ms({conv3d_:function(e,t,n,r,a="NDHWC",o=[1,1,1]){const s=hs(e,"x","conv3d"),i=hs(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=$u(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),nt(5===i.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`)),nt(u.shape[4]===i.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${i.shape[3]}.`)),nt(Ru(n,o),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`)),nt("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`)),nt(Fu(o),(()=>"Error in conv3D: Dilated rates should be larger than 0.")),nt(Fu(n),(()=>"Error in conv3D: Strides should be larger than 0."));const c={x:u,filter:i},p={strides:n,pad:r,dataFormat:a,dilations:o},h=so.runKernel("Conv3D",c,p);return l?$u(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),pl=ms({conv3DBackpropInput_:function(e,t,n,r,a){nt(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,s=t,i=!1;4===t.rank&&(i=!0,s=$u(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),o=[1,e[0],e[1],e[2],e[3]]);const u=o[4],l=s.shape[4];nt(5===o.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${o.length}.`)),nt(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),nt(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),nt(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),nt(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},p={pad:a,strides:r,inputShape:o},h=so.runKernel("Conv3DBackpropInputV2",c,p);return i?$u(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),hl=ms({conv3dTranspose_:function(e,t,n,r,a){const o=hs(e,"x","conv3dTranspose"),s=hs(t,"filter","conv3dTranspose");return pl(n,o,s,r,a)}}),dl=ms({cos_:function(e){const t={x:hs(e,"x","cos","float32")};return so.runKernel("Cos",t)}}),fl=ms({cosh_:function(e){const t={x:hs(e,"x","cosh","float32")};return so.runKernel(Zt,t)}}),ml=ms({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:hs(e,"x","cumprod")},o={axis:t,exclusive:n,reverse:r};return so.runKernel(en,a,o)}}),gl=ms({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:hs(e,"x","cumsum")},o={axis:t,exclusive:n,reverse:r};return so.runKernel(tn,a,o)}}),yl=ms({denseBincount_:function(e,t,n,r=!1){const a=hs(e,"x","denseBincount"),o=hs(t,"weights","denseBincount");nt("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),nt(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),nt(n>=0,(()=>`size must be non-negative, but got ${n}.`)),nt(o.size===a.size||0===o.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${o.shape}.`));const s={x:a,weights:o},i={size:n,binaryOutput:r};return so.runKernel("DenseBincount",s,i)}}),bl=ms({depthToSpace_:function(e,t,n="NHWC"){const r=hs(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],o="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];nt(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),nt(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),nt(o*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${o} and ${t} for depthToSpace with input shape\n ${r.shape}`)),nt(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const i={x:r},u={blockSize:t,dataFormat:n};return so.runKernel(rn,i,u)}}),vl=ms({depthwiseConv2d_:function(e,t,n,r,a="NHWC",o=[1,1],s){const i=hs(e,"x","depthwiseConv2d","float32"),u=hs(t,"filter","depthwiseConv2d","float32");let l=i,c=!1;3===i.rank&&(c=!0,l=$u(i,[1,i.shape[0],i.shape[1],i.shape[2]])),nt(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),nt(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`));const p="NHWC"===a?l.shape[3]:l.shape[1];nt(p===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${u.shape[2]}.`)),Mu("depthwiseConv2d",r,s);const h={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:o,dimRoundingMode:s},f=so.runKernel(an,h,d);return c?$u(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),wl=ms({diag_:function(e){const t={x:hs(e,"x","diag")};return so.runKernel("Diag",t)}}),xl=ms({dilation2d_:function(e,t,n,r,a=[1,1],o="NHWC"){const s=hs(e,"x","dilation2d"),i=hs(t,"filter","dilation2d");nt(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),nt(3===i.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`)),nt("NHWC"===o,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${o}`));let u=s,l=!1;3===s.rank&&(u=$u(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0),nt(u.shape[3]===i.shape[2],(()=>`Error in dilation2d: input and filter must have the same depth: ${u.shape[3]} vs ${i.shape[2]}`));const c={x:u,filter:i},p={strides:n,pad:r,dilations:a},h=so.runKernel("Dilation2D",c,p);return l?$u(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),_l=ms({equal_:function(e,t){let n=hs(e,"a","equal","string_or_numeric"),r=hs(t,"b","equal","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(un,a)}}),kl=ms({where_:function(e,t,n){const r=hs(t,"a","where"),a=hs(n,"b","where"),o=hs(e,"condition","where","bool"),s=$i($i(o.shape,r.shape),a.shape),i={condition:Qu(o,s),t:Qu(r,s),e:Qu(a,s)};return so.runKernel(rr,i)}}),Tl=ms({zerosLike_:function(e){const t={x:hs(e,"x","zerosLike")};return so.runKernel(Ir,t)}}),Sl=ms({divNoNan_:function(e,t){let n=hs(e,"a","div"),r=hs(t,"b","div");[n,r]=Za(n,r);const a=iu(n,r),o=Tl(a),s=_l(r,o);return kl(s,o,a)}}),El=ms({dot_:function(e,t){const n=hs(e,"t1","dot"),r=hs(t,"t2","dot");nt(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],o=1===r.rank?r.size:r.shape[0];if(nt(a===o,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${o}.`)),1===n.rank&&1===r.rank){const e=$u(n,[1,-1]),t=$u(r,[-1,1]),a=wi(e,t);return $u(a,[])}if(1===n.rank&&2===r.rank){const e=$u(n,[1,-1]),t=$u(r,[r.shape[0],r.shape[1]]),a=wi(e,t);return $u(a,[a.size])}if(2===n.rank&&1===r.rank){const e=$u(r,[-1,1]),t=wi(n,e);return $u(t,[t.size])}{const e=$u(r,[r.shape[0],r.shape[1]]);return wi(n,e)}}}),Il=ms({einsum_:function(e,...t){const n=t.map(((e,t)=>hs(e,`tensors${t}`,"einsum"))),r={equation:e};return so.runKernel("Einsum",n,r)}}),Cl=ms({elu_:function(e){const t={x:hs(e,"x","elu","float32")};return so.runKernel(sn,t)}}),Al=ms({erf_:function(e){let t=hs(e,"x","erf");nt("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=vi(t,"float32"));const n={x:t};return so.runKernel("Erf",n)}});function Nl(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function Rl(e,t,n){const r=e.length+t.length,a=[];let o=0,s=0;for(let i=0;i<r;i++)-1===n.indexOf(i)?a.push(e[o++]):a.push(t[s++]);return a}function Fl(e,t){const n=[],r=e.length;for(let a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);return[n,t.map((t=>e[t]))]}function Ol(e,t){return Rl(e,t.map((e=>1)),t)}function Ml(e,t,n){nt(Nl(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function $l(e,t){if(Nl(e,t))return null;const n=[];for(let r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((e=>n.push(e))),n}function Dl(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function Pl(e,t){const n=[];for(let r=t-e;r<t;++r)n.push(r);return n}const Ll=ms({max_:function(e,t=null,n=!1){const r={x:hs(e,"x","max")},a={reductionIndices:t,keepDims:n};return so.runKernel(Cn,r,a)}}),Bl=ms({min_:function(e,t=null,n=!1){const r={x:hs(e,"x","min")},a={axis:t,keepDims:n};return so.runKernel(Fn,r,a)}}),Ul=ms({pow_:function(e,t){let n=hs(e,"base","pow"),r=hs(t,"exp","pow");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel("Pow",a)}});function Wl(e,t){if((Ra(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&Ra(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return ys(e,[],[],t)}const Vl=ms({sqrt_:function(e){const t={x:hs(e,"x","sqrt","float32")};return so.runKernel(sr,t)}}),zl=ms({square_:function(e){const t=hs(e,"x","square");return so.runKernel("Square",{x:t},{})}}),jl=ms({sum_:function(e,t=null,n=!1){let r=hs(e,"x","sum");"bool"===r.dtype&&(r=vi(r,"int32"));const a={x:r},o={axis:t,keepDims:n};return so.runKernel(ir,a,o)}});function Hl(e,t,n=null){if(0===e.rank)return lu(e);if(1!==e.rank&&null===n)return Hl($u(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return jl(lu(e),n);if(t===1/0)return Ll(lu(e),n);if(t===-1/0)return Bl(lu(e),n);if("euclidean"===t||2===t)return Vl(jl(Ul(lu(e),Wl(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Ll(jl(lu(e),n[0]),n[1]-1);if(t===1/0)return Ll(jl(lu(e),n[1]),n[0]);if(t===-1/0)return Bl(jl(lu(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return Vl(jl(zl(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const Gl=ms({norm_:function(e,t="euclidean",n=null,r=!1){const a=Hl(e=hs(e,"x","norm"),t,n);let o=a.shape;if(r){const t=ht(n,e.shape);o=Ol(a.shape,t)}return $u(a,o)}}),Kl=ms({euclideanNorm_:function(e,t=null,n=!1){return Gl(e,"euclidean",t,n)}}),ql=ms({exp_:function(e){const t={x:hs(e,"x","exp")};return so.runKernel(ln,t)}}),Yl=ms({expandDims_:function(e,t=0){const n=hs(e,"x","expandDims","string_or_numeric");nt(t<=n.rank,(()=>"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return so.runKernel(cn,r,a)}}),Xl=ms({expm1_:function(e){const t={x:hs(e,"x","expm1")};return so.runKernel("Expm1",t)}}),Ql=ms({tile_:function(e,t){const n=hs(e,"x","tile","string_or_numeric");nt(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return so.runKernel(_r,r,a)}}),Jl=ms({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=Ju([e,t],r),o=e<=t?e:t;for(let e=0;e<o;++e)a.set(1,e,e);const s=$u(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return Ql(Yl(s,0),[n[0],1,1]);if(2===n.length)return Ql(Yl(Yl(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return Ql(Yl(Yl(Yl(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}}),Zl=ms({floor_:function(e){const t={x:hs(e,"x","floor","float32")};return so.runKernel(dn,t)}}),ec=ms({gather_:function(e,t,n=0,r=0){const a={x:hs(e,"x","gather"),indices:hs(t,"indices","gather","int32")},o={axis:n,batchDims:r};return so.runKernel(gn,a,o)}}),tc=ms({greater_:function(e,t){let n=hs(e,"a","greater","string_or_numeric"),r=hs(t,"b","greater","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(bn,a)}}),nc=ms({greaterEqual_:function(e,t){let n=hs(e,"a","greaterEqual","string_or_numeric"),r=hs(t,"b","greaterEqual","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(vn,a)}}),rc=ms({isFinite_:function(e){const t={x:hs(e,"x","isFinite")};return so.runKernel("IsFinite",t)}}),ac=ms({isInf_:function(e){const t={x:hs(e,"x","isInf")};return so.runKernel("IsInf",t)}}),oc=ms({isNaN_:function(e){const t={x:hs(e,"x","isNaN")};return so.runKernel(xn,t)}}),sc=ms({leakyRelu_:function(e,t=.2){const n={x:hs(e,"x","leakyRelu")},r={alpha:t};return so.runKernel(_n,n,r)}}),ic=ms({less_:function(e,t){let n=hs(e,"a","less","string_or_numeric"),r=hs(t,"b","less","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(kn,a)}}),uc=ms({lessEqual_:function(e,t){let n=hs(e,"a","lessEqual","string_or_numeric"),r=hs(t,"b","lessEqual","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(Tn,a)}}),lc=ms({localResponseNormalization_:function(e,t=5,n=1,r=1,a=.5){const o=hs(e,"x","localResponseNormalization");nt(4===o.rank||3===o.rank,(()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${o.rank}.`)),nt(it(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=o,i=!1;3===o.rank&&(i=!0,s=$u(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=so.runKernel("LRN",u,l);return i?$u(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),cc=ms({log_:function(e){const t={x:hs(e,"x","log","float32")};return so.runKernel("Log",t)}}),pc=ms({log1p_:function(e){const t={x:hs(e,"x","log1p")};return so.runKernel("Log1p",t)}});function hc(e){return so.customGrad(e)}const dc=ms({softplus_:function(e){const t={x:hs(e,"x","softplus")};return so.runKernel("Softplus",t)}}),fc=ms({logSigmoid_:function(e){const t=hs(e,"x","logSigmoid"),n=hc((e=>({value:Ni(dc(Ni(e))),gradFunc:t=>uu(t,Uu(Ni(e)))})));return n(t)}}),mc=ms({sub_:function(e,t){let n=hs(e,"a","sub"),r=hs(t,"b","sub");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel(wr,a)}}),gc=ms({logSoftmax_:function(e,t=-1){const n=hs(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);const r=hc(((e,n)=>{const r=Ll(e,t,!0),a=mc(e,r),o=mc(vi(a,"float32"),cc(jl(ql(a),t,!0)));return n([o]),{value:o,gradFunc:(e,n)=>{const[r]=n,a=ql(r);return mc(e,uu(jl(e,t,!0),a))}}}));return r(n)}}),yc=ms({logSumExp_:function(e,t=null,n=!1){const r=hs(e,"x","logSumExp"),a=ht(t,r.shape),o=Ll(r,a,!0),s=mc(r,o),i=ql(s),u=jl(i,a),l=cc(u),c=ou($u(o,l.shape),l);if(n){const e=Ol(c.shape,a);return $u(c,e)}return c}}),bc=ms({logicalAnd_:function(e,t){const n=hs(e,"a","logicalAnd","bool"),r=hs(t,"b","logicalAnd","bool");$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(Sn,a)}}),vc=ms({logicalNot_:function(e){const t={x:hs(e,"x","logicalNot","bool")};return so.runKernel(En,t)}}),wc=ms({logicalOr_:function(e,t){const n=hs(e,"a","logicalOr","bool"),r=hs(t,"b","logicalOr","bool");$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(In,a)}}),xc=ms({logicalXor_:function(e,t){const n=hs(e,"a","logicalXor","bool"),r=hs(t,"b","logicalXor","bool");return $i(n.shape,r.shape),bc(wc(e,t),vc(bc(e,t)))}}),_c=2147483648,kc=ms({searchSorted_:function(e,t,n="left"){const r=hs(e,"sortedSequence","searchSorted"),a=hs(t,"values","searchSorted"),o=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],i=$u(r,[-1,o]),u=$u(a,[-1,s]);if(i.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(i.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(ot(u.shape)>=_c)throw new Error("values tensor size must less than 2147483648");if(i.shape[1]>=_c)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${i.shape[1]}`);const l={sortedSequence:i,values:u},c={side:n};return so.runKernel("SearchSorted",l,c)}}),Tc=ms({maxPool_:function(e,t,n,r,a){const o=hs(e,"x","maxPool");let s=o,i=!1;3===o.rank&&(i=!0,s=$u(o,[1,o.shape[0],o.shape[1],o.shape[2]])),nt(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),nt(Ru(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),Mu("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=so.runKernel(Nn,u,l);return i?$u(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Sc=ms({maxPool3d_:function(e,t=[1,1,1],n,r,a,o="NDHWC"){const s=hs(e,"x","maxPool3d");let i=s,u=!1;4===s.rank&&(u=!0,i=$u(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===i.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`)),nt("NDHWC"===o,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`)),Mu("maxPool3d",r,a);const l={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:o},p=so.runKernel("MaxPool3D",l,c);return u?$u(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),Ec=ms({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const o={x:hs(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},i=so.runKernel("MaxPoolWithArgmax",o,s);return{result:i[0],indexes:i[1]}}}),Ic=ms({maximum_:function(e,t){let n=hs(e,"a","maximum"),r=hs(t,"b","maximum");[n,r]=Za(n,r),"bool"===n.dtype&&(n=vi(n,"int32"),r=vi(r,"int32")),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(An,a)}}),Cc=ms({mean_:function(e,t=null,n=!1){const r={x:hs(e,"x","mean")},a={axis:t,keepDims:n};return so.runKernel(Rn,r,a)}});function Ac(e,t="float32"){if(It(e),"complex64"===t){const t=Ac(e,"float32"),n=Ac(e,"float32");return gs(t,n)}const n=Et(ot(e),t);return so.makeTensor(n,e,t)}function Nc(e,t="float32"){if(It(e),"complex64"===t){const t=Nc(e,"float32"),n=Ac(e,"float32");return gs(t,n)}const n=St(ot(e),t);return so.makeTensor(n,e,t)}const Rc=ms({minimum_:function(e,t){let n=hs(e,"a","minimum"),r=hs(t,"b","minimum");[n,r]=Za(n,r),"bool"===n.dtype&&(n=vi(n,"int32"),r=vi(r,"int32")),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(On,a)}}),Fc=ms({mirrorPad_:function(e,t,n){nt("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=hs(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");nt(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e<r.rank;e++)nt(2===t[e].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),nt(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const o={paddings:t,mode:n},s={x:r};return so.runKernel(Mn,s,o)}}),Oc=ms({mod_:function(e,t){let n=hs(e,"a","mod"),r=hs(t,"b","mod");[n,r]=Za(n,r);const a={a:n,b:r};return so.runKernel("Mod",a)}}),Mc=ms({moments_:function(e,t=null,n=!1){const r=ht(t,(e=hs(e,"x","moments")).shape),a=Cc(e,r,n);let o=a.shape;n||(o=Ol(a.shape,r));const s=zl(mc(vi(e,"float32"),$u(a,o)));return{mean:a,variance:Cc(s,r,n)}}}),$c=ms({multiRNNCell_:function(e,t,n,r){const a=hs(t,"data","multiRNNCell"),o=ds(n,"c","multiRNNCell"),s=ds(r,"h","multiRNNCell");let i=a;const u=[];for(let t=0;t<e.length;t++){const n=e[t](i,o[t],s[t]);u.push(n[0]),u.push(n[1]),i=n[1]}const l=[],c=[];for(let e=0;e<u.length;e+=2)l.push(u[e]),c.push(u[e+1]);return[l,c]}}),Dc=ms({multinomial_:function(e,t,n,r=!1){const a=hs(e,"logits","multinomial"),o=a.size,s=a.rank;if(o<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${o}.`);if(s>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const i={logits:1===s?$u(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=so.runKernel("Multinomial",i,u);return 1===s?$u(l,[l.size]):l}}),Pc=ms({notEqual_:function(e,t){let n=hs(e,"a","notEqual","string_or_numeric"),r=hs(t,"b","notEqual","string_or_numeric");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(Dn,a)}}),Lc=ms({onesLike_:function(e){const t={x:hs(e,"x","onesLike")};return so.runKernel(Un,t)}}),Bc=ms({outerProduct_:function(e,t){const n=hs(e,"v1","outerProduct"),r=hs(t,"v2","outerProduct");nt(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=$u(n,[-1,1]),o=$u(r,[1,-1]);return wi(a,o)}}),Uc=ms({pad_:function(e,t,n=0){const r=hs(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},o={x:r};return so.runKernel(zn,o,a)}}),Wc=ms({pad1d_:function(e,t,n=0){return nt(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),Uc(e,[t],n)}}),Vc=ms({pad2d_:function(e,t,n=0){return nt(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),Uc(e,t,n)}}),zc=ms({pad3d_:function(e,t,n=0){return nt(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),Uc(e,t,n)}}),jc=ms({pad4d_:function(e,t,n=0){return nt(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),Uc(e,t,n)}}),Hc=ms({spaceToBatchND_:function(e,t,n){const r=hs(e,"x","spaceToBatchND");nt(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),nt(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),nt(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},o={blockShape:t,paddings:n};return so.runKernel(ur,a,o)}}),Gc=ms({pool_:function(e,t,n,r,a,o,s){null==a&&(a=[1,1]),null==o&&(o=1),0===r&&(r="valid");const i=hs(e,"x","maxPool");let u=i,l=!1;3===i.rank&&(l=!0,u=$u(i,[1,i.shape[0],i.shape[1],i.shape[2]])),nt(Ru(o,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${a}'`));const c=_u(u.shape,t,o,a,r),p=[c.dilationHeight,c.dilationWidth];let h;h="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))).map((e=>e-1)),r=n.map((e=>Math.floor(e/2))),a=n.map(((e,t)=>e-r[t]));return n.map(((e,t)=>[r[t],a[t]]))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];const d=1===p[0]&&1===p[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),o=e.concat(r,a),s=t.map(((e,t)=>(e-o[t]%e)%e)),i=a.map(((e,t)=>e+s[t]));return[t.map(((e,t)=>[r[t],i[t]])),t.map(((e,t)=>[0,s[t]]))]}([c.inHeight,c.inWidth],p,h),g=d?r:"valid",y=d?u:Hc(u,p,f),b=("avg"===n?()=>Du(y,t,o,g,s):()=>Tc(y,t,o,g,s))(),v=d?b:ju(b,p,m);return l?$u(v,[v.shape[1],v.shape[2],v.shape[3]]):v}}),Kc=ms({prelu_:function(e,t){const n={x:hs(e,"x","prelu"),alpha:hs(t,"alpha","prelu")};return so.runKernel(jn,n)}});function qc(e,t=!1){console.log(e.toString(t))}const Yc=ms({prod_:function(e,t=null,n=!1){let r=hs(e,"x","prod");"bool"===r.dtype&&(r=vi(r,"int32"));const a={x:r},o={axis:t,keepDims:n};return so.runKernel(Hn,a,o)}}),Xc=ms({raggedGather_:function(e,t,n,r){const a=e.map(((e,t)=>hs(e,`tensors${t}`,"raggedGather","int32"))),o={paramsNestedSplits:a,paramsDenseValues:hs(t,"paramsDenseValues","raggedGather"),indices:hs(n,"indices","raggedGather","int32")},s={outputRaggedRank:r},i=so.runKernel("RaggedGather",o,s);return{outputNestedSplits:i.slice(0,i.length-1),outputDenseValues:i[i.length-1]}}}),Qc=ms({raggedRange_:function(e,t,n){const r=hs(e,"starts","raggedRange"),a={starts:r,limits:hs(t,"limits","raggedRange",r.dtype),deltas:hs(n,"deltas","raggedRange",r.dtype)},o=so.runKernel("RaggedRange",a);return{rtNestedSplits:o[0],rtDenseValues:o[1]}}}),Jc=ms({raggedTensorToTensor_:function(e,t,n,r,a){const o=hs(e,"shape","raggedTensorToTensor","int32"),s=hs(t,"values","raggedTensorToTensor"),i=hs(n,"defaultValue","raggedTensorToTensor",s.dtype),u=r.map(((e,t)=>hs(e,`tensors${t}`,"raggedTensorToTensor","int32"))),l={shape:o,values:s,defaultValue:i,rowPartitionTensors:u},c={rowPartitionTypes:a};return so.runKernel("RaggedTensorToTensor",l,c)}}),Zc=ms({rand_:function(e,t,n){It(e);const r=ot(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e<r;e++)a[e]=t();return so.makeTensor(a,e,n)}});var ep="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function tp(e){var t={exports:{}};return e(t,t.exports),t.exports}var np=tp((function(e){!function(e,t,n){function r(e){var t=this,n=function(){var e=4022871197;return function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)}}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var n=new r(e),o=t&&t.state,s=n.next;return s.int32=function(){return 4294967296*n.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,o&&("object"==typeof o&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.alea=o}(0,e)})),rp=tp((function(e){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var n=new r(e),o=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,o&&("object"==typeof o&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.xor128=o}(0,e)})),ap=tp((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function o(e,t){var n=new r(e),o=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,o&&("object"==typeof o&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.xorwow=o}(0,e)})),op=tp((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var n=new r(e),o=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,o&&(o.x&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.xorshift7=o}(0,e)})),sp=tp((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,o=t.i;return t.w=r=r+1640531527|0,n=a[o+34&127],e=a[o=o+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[o]=n^e,t.i=o,n+(r^r>>>16)|0},function(e,t){var n,r,a,o,s,i=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,o=-32;o<u;++o)t&&(r^=t.charCodeAt((o+32)%t.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,a=0==(n=i[127&o]^=r+s)?a+1:0);for(a>=128&&(i[127&(t&&t.length||0)]=-1),a=127,o=512;o>0;--o)r=i[a+34&127],n=i[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,i[a]=r^n;e.w=s,e.X=i,e.i=a}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var n=new r(e),o=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,o&&(o.X&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.xor4096=o}(0,e)})),ip=tp((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var n=new r(e),o=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,o&&("object"==typeof o&&a(o,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=o:this.tychei=o}(0,e)})),up=function(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}(Object.freeze({__proto__:null,default:{}})),lp=tp((function(e){!function(t,n,r){var a,o=256,s="random",i=r.pow(o,6),u=r.pow(2,52),l=2*u,c=255;function p(e,c,p){var y=[],b=m(f((c=1==c?{entropy:!0}:c||{}).entropy?[e,g(n)]:null==e?function(){try{var e;return a&&(e=a.randomBytes)?e=e(o):(e=new Uint8Array(o),(t.crypto||t.msCrypto).getRandomValues(e)),g(e)}catch(e){var r=t.navigator,s=r&&r.plugins;return[+new Date,t,s,t.screen,g(n)]}}():e,3),y),v=new h(y),w=function(){for(var e=v.g(6),t=i,n=0;e<u;)e=(e+n)*o,t*=o,n=v.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|v.g(4)},w.quick=function(){return v.g(4)/4294967296},w.double=w,m(g(v.S),n),(c.pass||p||function(e,t,n,a){return a&&(a.S&&d(a,v),e.state=function(){return d(v,{})}),n?(r[s]=e,t):e})(w,b,"global"in c?c.global:this==r,c.state)}function h(e){var t,n=e.length,r=this,a=0,s=r.i=r.j=0,i=r.S=[];for(n||(e=[n++]);a<o;)i[a]=a++;for(a=0;a<o;a++)i[a]=i[s=c&s+e[a%n]+(t=i[a])],i[s]=t;(r.g=function(e){for(var t,n=0,a=r.i,s=r.j,i=r.S;e--;)t=i[a=c&a+1],n=n*o+i[c&(i[a]=i[s=c&s+t])+(i[s]=t)];return r.i=a,r.j=s,n})(o)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){var n,r=[],a=typeof e;if(t&&"object"==a)for(n in e)try{r.push(f(e[n],t-1))}catch(e){}return r.length?r:"string"==a?e:e+"\0"}function m(e,t){for(var n,r=e+"",a=0;a<r.length;)t[c&a]=c&(n^=19*t[c&a])+r.charCodeAt(a++);return g(t)}function g(e){return String.fromCharCode.apply(0,e)}if(m(r.random(),n),e.exports){e.exports=p;try{a=up}catch(e){}}else r["seed"+s]=p}("undefined"!=typeof self?self:ep,[],Math)}));lp.alea=np,lp.xor128=rp,lp.xorwow=ap,lp.xorshift7=op,lp.xor4096=sp,lp.tychei=ip;var cp=lp;class pp{constructor(e,t,n,r,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const o=a||Math.random();this.random=cp.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const e=this.nextVal;return this.nextVal=NaN,e}let e,t,n=!1;for(;!n;){let r,a,o;do{r=2*this.random()-1,a=2*this.random()-1,o=r*r+a*a}while(o>=1||0===o);const s=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class hp{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=cp.alea(a.toString()),this.randn=new pp(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,o;for(;;){do{r=this.randn.nextValue(),o=1+this.c*r}while(o<=0);if(o*=o*o,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-o+Math.log(o)),a=this.randu(),a<t||Math.log(a)<n)break}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class dp{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=cp.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const fp=ms({randomGamma_:function(e,t,n=1,r="float32",a){if(It(e),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const o=new hp(t,n,r,a),s=Ju(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),mp=ms({randomNormal_:function(e,t=0,n=1,r,a){if(It(e),null!=r&&"bool"===r)throw new Error(`Unsupported data type ${r}`);const o=new pp(t,n,r,!1,a),s=Ju(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),gp=ms({randomStandardNormal_:function(e,t,n){if(null!=t&&"bool"===t)throw new Error(`Unsupported data type ${t}`);return mp(e,0,1,t,n)}}),yp=ms({randomUniform_:function(e,t=0,n=1,r="float32",a){It(e);const o=Ju(e,r),s=new dp(t,n,null,a);for(let e=0;e<o.values.length;e++)o.values[e]=s.nextValue();return o.toTensor()}});function bp(e,t,n=1,r="float32"){if(0===n)throw new Error("Cannot have a step of zero");const a={start:e,stop:t,step:n,dtype:r};return so.runKernel(Gn,{},a)}const vp=ms({reciprocal_:function(e){const t={x:hs(e,"x","reciprocal")};return so.runKernel(Kn,t)}}),wp=ms({relu_:function(e){const t={x:hs(e,"x","relu")};return so.runKernel(qn,t)}}),xp=ms({relu6_:function(e){const t={x:hs(e,"x","relu6")};return so.runKernel(Jn,t)}}),_p=ms({reverse_:function(e,t){const n={x:hs(e,"x","reverse")},r={dims:t};return so.runKernel(Zn,n,r)}}),kp=ms({reverse1d_:function(e){const t=hs(e,"x","reverse");return nt(1===t.rank,(()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),_p(t,0)}}),Tp=ms({reverse2d_:function(e,t){const n=hs(e,"x","reverse");return nt(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),_p(n,t)}}),Sp=ms({reverse3d_:function(e,t){const n=hs(e,"x","reverse");return nt(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),_p(n,t)}}),Ep=ms({reverse4d_:function(e,t){const n=hs(e,"x","reverse");return nt(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),_p(n,t)}}),Ip=ms({round_:function(e){const t={x:hs(e,"x","round")};return so.runKernel(er,t)}}),Cp=ms({rsqrt_:function(e){const t={x:hs(e,"x","rsqrt","float32")};return so.runKernel(tr,t)}}),Ap=ms({selu_:function(e){const t={x:hs(e,"x","selu")};return so.runKernel("Selu",t)}}),Np=ms({separableConv2d_:function(e,t,n,r,a,o=[1,1],s="NHWC"){const i=hs(e,"x","separableConv2d"),u=hs(t,"depthwiseFilter","separableConv2d"),l=hs(n,"pointwiseFilter","separableConv2d");let c=i,p=!1;if(3===i.rank&&(p=!0,c=$u(i,[1,i.shape[0],i.shape[1],i.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");nt(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),nt(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),nt(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),nt(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),nt(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const h=u.shape[2],d=u.shape[3];nt(l.shape[2]===h*d,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${h*d}, but got ${l.shape[2]}.`));const f=vl(c,u,r,a,s,o),m=sl(f,l,1,"valid",s);return p?$u(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),Rp=ms({sign_:function(e){const t={x:hs(e,"x","sign")};return so.runKernel("Sign",t)}}),Fp=ms({sin_:function(e){const t={x:hs(e,"x","sin","float32")};return so.runKernel("Sin",t)}}),Op=ms({sinh_:function(e){const t={x:hs(e,"x","sinh")};return so.runKernel("Sinh",t)}}),Mp=ms({slice1d_:function(e,t,n){const r=hs(e,"x","slice1d");return nt(1===r.rank,(()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),Wu(r,[t],[n])}}),$p=ms({slice2d_:function(e,t,n){const r=hs(e,"x","slice2d");return nt(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),Wu(r,t,n)}}),Dp=ms({slice3d_:function(e,t,n){const r=hs(e,"x","slice3d");return nt(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),Wu(r,t,n)}}),Pp=ms({slice4d_:function(e,t,n){const r=hs(e,"x","slice4d");return nt(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),Wu(r,t,n)}}),Lp=ms({softmax_:function(e,t=-1){const n=hs(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);const r={logits:n},a={dim:t};return so.runKernel(cr,r,a)}}),Bp=ms({fft_:function(e){nt("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return so.runKernel("FFT",t)}}),Up=ms({ifft_:function(e){nt("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return so.runKernel("IFFT",t)}}),Wp=ms({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=$u(e,[n,t]);r=Up(a)}else{const a=[n,2*(t-1)],o=$u(Ri(e),[n,t]),s=$u(Ai(e),[n,t]),i=_p(Wu(o,[0,1],[n,t-2]),1),u=uu(_p(Wu(s,[0,1],[n,t-2]),1),Wl(-1)),l=Bu([o,i],1),c=Bu([s,u],1),p=$u(gs(l,c),[a[0],a[1]]);r=Up(p)}if(r=Ri(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=$u(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),Vp=ms({split_:function(e,t,n=0){const r={x:hs(e,"x","split")},a={numOrSizeSplits:t,axis:n};return so.runKernel(lr,r,a)}}),zp=ms({rfft_:function(e,t){nt("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t<n){const r=e.shape.map((e=>0)),o=e.shape.map((e=>e));o[e.shape.length-1]=t,a=Wu(e,r,o),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=Bu([e,Ac(r)],e.shape.length-1),n=t}else a=e;const o=Tl(a),s=$u(gs(a,o),[r,n]),i=Bp(s),u=Math.floor(n/2)+1,l=Ri(i),c=Ai(i),p=Vp(l,[u,n-u],l.shape.length-1),h=Vp(c,[u,n-u],c.shape.length-1),d=a.shape.slice();return d[a.shape.length-1]=u,$u(gs(p[0],h[0]),d)}}),jp=ms({squaredDifference_:function(e,t){let n=hs(e,"a","squaredDifference"),r=hs(t,"b","squaredDifference");[n,r]=Za(n,r),$i(n.shape,r.shape);const a={a:n,b:r};return so.runKernel(mr,a,{})}}),Hp=ms({squeeze_:function(e,t){const n=hs(e,"x","squeeze","string_or_numeric");return $u(n,dt(n.shape,t).newShape)}}),Gp=ms({stack_:function(e,t=0){const n=ds(e,"tensors","stack","string_or_numeric");nt(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&nt(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return so.runKernel(Vn,r,a)}}),Kp=ms({step_:function(e,t=0){const n={x:hs(e,"x","step")},r={alpha:t};return so.runKernel(Cr,n,r)}}),qp=ms({stridedSlice_:function(e,t,n,r,a=0,o=0,s=0,i=0,u=0){const l={x:hs(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:o,ellipsisMask:s,newAxisMask:i,shrinkAxisMask:u};return so.runKernel(gr,l,c)}}),Yp=ms({tan_:function(e){const t={x:hs(e,"x","tan","float32")};return so.runKernel("Tan",t)}});function Xp(e,t){at(e);const n=ls(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return ys(e,null,n,t)}function Qp(e,t,n){if(at(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=ls(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return ys(e,t,r,n)}const Jp=ms({topk_:function(e,t=1,n=!0){const r=hs(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const o={x:r},s={k:t,sorted:n},[i,u]=so.runKernel(kr,o,s);return{values:i,indices:u}}}),Zp=ms({truncatedNormal_:function(e,t=0,n=1,r,a){if(It(e),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const o=new pp(t,n,r,!0,a),s=Ju(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}}),eh=ms({unique_:function(e,t=0){const n=hs(e,"x","unique","string_or_numeric");nt(n.rank>0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[o,s]=so.runKernel("Unique",r,a);return{values:o,indices:s}}}),th=ms({unsortedSegmentSum_:function(e,t,n){const r=hs(e,"x","unsortedSegmentSum"),a=hs(t,"segmentIds","unsortedSegmentSum","int32");nt(it(n),(()=>"numSegments must be of dtype int"));const o={x:r,segmentIds:a},s={numSegments:n};return so.runKernel("UnsortedSegmentSum",o,s)}}),nh=ms({unstack_:function(e,t=0){const n=hs(e,"x","unstack","string_or_numeric");nt(t>=-n.shape.length&&t<n.shape.length,(()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return so.runKernel(Er,r,a)}});function rh(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const r=Ju(e,"int32"),a=Ju([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const o=r.indexToLoc(n[t]),s=t*e.length;a.values.set(o,s)}return a.toTensor()}const ah=async function(e){const t=hs(e,"condition","whereAsync","bool"),n=await t.data(),r=rh(t.shape,n);return e!==t&&t.dispose(),r},oh=ms({movingAverage_:function(e,t,n,r,a=!0){const o=hs(e,"v","movingAverage"),s=hs(t,"x","movingAverage"),i=hs(n,"decay","movingAverage");var u,l;l=s,nt((u=o).dtype===l.dtype,(()=>`The dtypes of the first(${u.dtype}) and second(${l.dtype}) input must match`)),nt(st(o.shape,s.shape),(()=>"Shape mismatch in v and x"));const c=Wl(1),p=mc(c,i);let h=uu(mc(s,o),p);if(a){nt(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=hs(r,"step","movingAverage");h=iu(h,mc(c,Ul(i,e)))}return ou(o,h)}}),sh=ms({scatterND_:function(e,t,n){It(n);const r=hs(e,"indices","scatterND","int32"),a=hs(t,"updates","scatterND");Wi(a,r,n);const o={indices:r,updates:a},s={shape:n};return so.runKernel(nr,o,s)}}),ih=ms({sparseToDense_:function(e,t,n,r=0){It(n);const a=hs(e,"sparseIndices","sparseToDense","int32"),o=hs(t,"sparseValues","sparseToDense","string_or_numeric"),s=hs(r,"defaultValue","sparseToDense",o.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,o=e.rank>1?e.shape[1]:1;if(n.length!==o)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${o}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,o,n,s);const i={sparseIndices:a,sparseValues:o,defaultValue:s},u={outputShape:n};return so.runKernel("SparseToDense",i,u)}}),uh=ms({gatherND_:function(e,t){const n=hs(t,"indices","gatherND","int32"),r={params:hs(e,"x","gatherND","string_or_numeric"),indices:n};return so.runKernel(yn,r)}}),lh=ms({dropout_:function(e,t,n,r){const a=hs(e,"x","dropout");if(nt("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),nt(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof ja?a.clone():a;const o=function(e,t){if(null==t)return e.shape.slice();if(st(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),s=1-t,i=iu(Zl(ou(yp(o,0,1,"float32",r),s)),s);return uu(a,i)}});function ch(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function ph(e,t,n){const r=1-e%2,a=new Float32Array(e);for(let o=0;o<e;++o){const s=2*Math.PI*o/(e+r-1);a[o]=t-n*Math.cos(s)}return Xp(a,"float32")}const hh=ms({conv2DBackpropFilter_:function(e,t,n,r,a,o="NHWC",s){let i=e;3===e.rank&&(i=$u(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=$u(t,[1,t.shape[0],t.shape[1],t.shape[2]])),nt(4===i.rank,(()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`)),nt(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),nt(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===o?i.shape[3]:i.shape[1],c="NHWC"===o?u.shape[3]:u.shape[1];nt(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),nt(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),Mu("conv2dDerFilter",a,s);const p={x:i,dy:u},h={strides:r,pad:a,dataFormat:o,dimRoundingMode:s,filterShape:n};return so.runKernel("Conv2DBackpropFilter",p,h)}});function dh(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return uu(e,Kp(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function fh(e,t){let n=t;const r=Mi(e.shape,t.shape);return r.length>0&&(n=jl(n,r)),$u(n,e.shape)}function mh(e,t,n,r){if("linear"===t)return e;if("relu"===t)return wp(e);if("elu"===t)return Cl(e);if("relu6"===t)return xp(e);if("prelu"===t)return Kc(e,n);if("leakyrelu"===t)return sc(e,r);if("sigmoid"===t)return Uu(e);throw new Error(`Unknown fused activation ${t}.`)}const gh=(e,t)=>!(e>0)||"linear"===t,yh=ms({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:o=[1,1],dimRoundingMode:s,bias:i,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===gh(so.state.gradientDepth,u)){nt("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=sl(e,t,n,r,a,o,s);return null!=i&&(p=ou(p,i)),mh(p,u,l,c)}const p=hs(e,"x","conv2d","float32"),h=hs(t,"filter","conv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=$u(p,[1,p.shape[0],p.shape[1],p.shape[2]])),nt(4===d.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`)),nt(4===h.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${h.rank}.`)),Mu("fused conv2d",r,s);const m="NHWC"===a?d.shape[3]:d.shape[1];nt(h.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${h.shape[2]}.`)),nt(Ru(n,o),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`));const g=ku(d.shape,h.shape,n,o,r,s);let y,b;if(null!=i&&(y=hs(i,"bias","fused conv2d"),[y]=Za(y,p),"NHWC"===a?$i(g.outShape,y.shape):(nt(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),nt(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(nt(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)nt(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{$i(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=hs(l,"prelu weights","fused conv2d")}const v=(e,t)=>{nt("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,i,l,c]=t,p=dh(e,l,u);nt(Nu(o),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`));const h=[ul(i.shape,p,s,n,r),hh(i,p,s.shape,n,r)];if(null!=c){const e=fh(c,p);h.push(e)}return h},w={x:d,filter:h,bias:y,preluActivationWeights:b},x={strides:n,pad:r,dataFormat:a,dilations:o,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==i){const e=hc(((e,t,n)=>{let r=so.runKernel(Fr,w,x);return n([t,e,r]),f&&(r=$u(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:v}}));return e(d,h)}{const e=hc(((e,t,n,r)=>{let a=so.runKernel(Fr,w,x);return r([t,e,a,n]),f&&(a=$u(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:v}}));return e(d,h,y)}}}),bh=ms({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,o=[1,1],s){let i=e;3===e.rank&&(i=$u(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=$u(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:i,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:o,filterShape:n};return so.runKernel("DepthwiseConv2dNativeBackpropFilter",l,c)}}),vh=ms({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,o=[1,1],s){let i=t,u=!1;3===t.rank&&(u=!0,i=$u(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:i,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:o,inputShape:e},p=so.runKernel("DepthwiseConv2dNativeBackpropInput",l,c);return u?$u(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),wh=ms({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:o=[1,1],dimRoundingMode:s,bias:i,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===gh(so.state.gradientDepth,u)){let p=vl(e,t,n,r,a,o,s);return null!=i&&(p=ou(p,i)),mh(p,u,l,c)}const p=hs(e,"x","depthwiseConv2d","float32"),h=hs(t,"filter","depthwiseConv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=$u(p,[1,p.shape[0],p.shape[1],p.shape[2]])),nt(4===d.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`)),nt(4===h.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${h.rank}.`)),nt(d.shape[3]===h.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${h.shape[2]}.`)),null==o&&(o=[1,1]),nt(Ru(n,o),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`)),Mu("fused depthwiseConv2d",r,s);const m=ku(d.shape,h.shape,n,o,r,s,!0);let g,y;null!=i&&(g=hs(i,"bias","fused conv2d"),[g]=Za(g,p),$i(m.outShape,g.shape)),null!=l&&(y=hs(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{nt(Nu(o),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[a,i,l,c]=t,p=dh(e,l,u),h=vh(i.shape,p,a,n,r,o,s),d=bh(i,p,a.shape,n,r,o,s);return null!=c?[h,d,fh(g,p)]:[h,d]},v={x:d,filter:h,bias:g,preluActivationWeights:y},w={strides:n,pad:r,dataFormat:a,dilations:o,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==i){const e=hc(((e,t,n)=>{let r=so.runKernel(Or,v,w);return n([t,e,r]),f&&(r=$u(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(d,h)}{const e=hc(((e,t,n,r)=>{let a=so.runKernel(Or,v,w);return r([t,e,a,n]),f&&(a=$u(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(d,h,g)}}}),xh=ms({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:o="linear",preluActivationWeights:s,leakyreluAlpha:i=.2}){if(!1===gh(so.state.gradientDepth,o)){let u=wi(e,t,n,r);return null!=a&&(u=ou(u,a)),mh(u,o,s,i)}let u=hs(e,"a","fused matMul"),l=hs(t,"b","fused matMul");[u,l]=Za(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],h=n?u.shape[u.rank-1]:u.shape[u.rank-2],d=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=ot(f),y=ot(m);nt(c===p,(()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=$i(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([h,d]),v=$u(u,n?[g,c,h]:[g,h,c]),w=$u(l,r?[y,d,p]:[y,p,d]);let x,_;null!=a&&(x=hs(a,"bias","fused matMul"),[x]=Za(x,u),$i(b,x.shape)),null!=s&&(_=hs(s,"prelu weights","fused matMul"));const k=(e,t)=>{const[s,i,u,l]=t,c=dh($u(e,u.shape),u,o);let p,h;return n||r?!n&&r?(p=wi(c,i,!1,!1),h=wi(c,s,!0,!1)):n&&!r?(p=wi(i,c,!1,!0),h=wi(s,c,!1,!1)):(p=wi(i,c,!0,!0),h=wi(c,s,!0,!0)):(p=wi(c,i,!1,!0),h=wi(s,c,!0,!1)),null!=a?[p,h,fh(l,c)]:[p,h]},T={a:v,b:w,bias:x,preluActivationWeights:_},S={transposeA:n,transposeB:r,activation:o,leakyreluAlpha:i};if(null==a){const e=hc(((e,t,n)=>{const r=so.runKernel(Rr,T,S);return n([e,t,r]),{value:$u(r,b),gradFunc:k}}));return e(v,w)}{const e=hc(((e,t,n,r)=>{const a=so.runKernel(Rr,T,S);return r([e,t,a,n]),{value:$u(a,b),gradFunc:k}}));return e(v,w,x)}}});var _h=Object.freeze({__proto__:null,conv2d:yh,depthwiseConv2d:wh,matMul:xh});const kh=ms({hammingWindow_:function(e){return ph(e,.54,.46)}}),Th=ms({hannWindow_:function(e){return ph(e,.5,.5)}}),Sh=ms({frame_:function(e,t,n,r=!1,a=0){let o=0;const s=[];for(;o+t<=e.size;)s.push(Wu(e,o,t)),o+=n;if(r)for(;o<e.size;){const r=o+t-e.size,i=Bu([Wu(e,o,t-r),el([r],a)]);s.push(i),o+=n}return 0===s.length?Qp([],[0,t]):$u(Bu(s),[s.length,t])}}),Eh=ms({stft_:function(e,t,n,r,a=Th){null==r&&(r=ch(t));const o=Sh(e,t,n),s=uu(o,a(t));return zp(s,r)}}),Ih=ms({cropAndResize_:function(e,t,n,r,a="bilinear",o=0){const s=hs(e,"image","cropAndResize"),i=hs(t,"boxes","cropAndResize","float32"),u=hs(n,"boxInd","cropAndResize","int32"),l=i.shape[0];nt(4===s.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),nt(2===i.rank&&4===i.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${i.shape}.`)),nt(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${i.shape}.`)),nt(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),nt(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),nt("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:i,boxInd:u},p={method:a,extrapolationValue:o,cropSize:r};return so.runKernel(nn,c,p)}}),Ch=ms({flipLeftRight_:function(e){const t=hs(e,"image","flipLeftRight","float32");nt(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return so.runKernel(hn,n,{})}}),Ah=ms({grayscaleToRGB_:function(e){const t=hs(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];nt(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),nt(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,Ql(t,a)}}),Nh=ms({rotateWithOffset_:function(e,t,n=0,r=.5){const a=hs(e,"image","rotateWithOffset","float32");nt(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const o={image:a},s={radians:t,fillValue:n,center:r};return so.runKernel(Nr,o,s)}});function Rh(e,t,n,r,a,o){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==o&&(o=0);const s=e.shape[0];return n=Math.min(n,s),nt(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),nt(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),nt(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),nt(1===t.rank,(()=>"scores must be a 1D tensor")),nt(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),nt(0<=o&&o<=1,(()=>`softNmsSigma must be in [0, 1], but was '${o}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:o}}const Fh=ms({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const o=hs(e,"boxes","nonMaxSuppression","float32"),s=hs(t,"scores","nonMaxSuppression","float32"),i=Rh(o,s,n,r,a),u={maxOutputSize:n=i.maxOutputSize,iouThreshold:r=i.iouThreshold,scoreThreshold:a=i.scoreThreshold};return so.runKernel(Pn,{boxes:o,scores:s},u)}});function Oh(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,o=0,s=!1;for(;r<a;){o=r+(a-r>>>1);const i=n(t,e[o]);i>0?r=o+1:(a=o,s=!i)}return s?r:-r-1}(e,t,n||Mh)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function Mh(e,t){return e>t?1:e<t?-1:0}function $h(e,t,n,r,a,o,s=!1,i=!1,u=!1){const l=[];for(let e=0;e<t.length;e++)t[e]>a&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(Lh);const c=o>0?-.5/o:0,p=[],h=[];for(;p.length<n&&l.length>0;){const t=l.pop(),{score:n,boxIndex:o,suppressBeginIndex:s}=t;if(n<a)break;let i=!1;for(let n=p.length-1;n>=s;--n){const s=Dh(e,o,p[n]);if(s>=r){i=!0;break}if(t.score=t.score*Ph(r,c,s),t.score<=a)break}t.suppressBeginIndex=p.length,i||(t.score===n?(p.push(o),h.push(t.score)):t.score>a&&Oh(l,t,Lh))}const d=p.length,f=n-d;i&&f>0&&(p.push(...new Array(f).fill(0)),h.push(...new Array(f).fill(0)));const m={selectedIndices:p};return s&&(m.selectedScores=h),u&&(m.validOutputs=d),m}function Dh(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),o=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),h=Math.max(a[1],a[3]),d=(i-o)*(u-s),f=(p-l)*(h-c);if(d<=0||f<=0)return 0;const m=Math.max(o,l),g=Math.max(s,c),y=Math.min(i,p),b=Math.min(u,h),v=Math.max(y-m,0)*Math.max(b-g,0);return v/(d+f-v)}function Ph(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function Lh(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const Bh=ms({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=0){const s=hs(e,"boxes","nonMaxSuppression"),i=hs(t,"scores","nonMaxSuppression"),u=Rh(s,i,n,r,a,o),l={boxes:s,scores:i},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:o=u.softNmsSigma},p=so.runKernel(Bn,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}}),Uh=ms({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=!1){const s=hs(e,"boxes","nonMaxSuppression"),i=hs(t,"scores","nonMaxSuppression"),u=Rh(s,i,n,r,a,null),l={boxes:s,scores:i},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:o},p=so.runKernel(Ln,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}}),Wh=ms({resizeBilinear_:function(e,t,n=!1,r=!1){const a=hs(e,"images","resizeBilinear");nt(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),nt(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),nt(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let o=a,s=!1;3===a.rank&&(s=!0,o=$u(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const i={images:o},u={alignCorners:n,halfPixelCenters:r,size:t},l=so.runKernel(Qn,i,u);return s?$u(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),Vh=ms({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=hs(e,"images","resizeNearestNeighbor");nt(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),nt(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),nt("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),nt(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let o=a,s=!1;3===a.rank&&(s=!0,o=$u(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const i={images:o},u={alignCorners:n,halfPixelCenters:r,size:t},l=so.runKernel(Xn,i,u);return s?$u(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),zh=ms({threshold_:function(e,t="binary",n=!1,r=.5){const a=hs(e,"image","threshold"),o=a.shape[0]*a.shape[1];let s,i,u,l,c=uu(Xp([r]),255);if(nt(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),nt(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),nt("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),nt("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,i,u]=Vp(a,[1,1,1],-1);const e=uu(s,.2989),t=uu(i,.587),n=uu(u,.114);l=ou(ou(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,o,s,i,u=Xp([-1]),l=Xp([0]),c=Xp([0]);for(let p=0;p<e.size-1;p++){n=Wu(e,0,p+1),r=Wu(e,p+1),s=iu(jl(n),t),i=iu(jl(r),t);const h=jl(uu(n,bp(0,n.size)));a=iu(h,jl(n));const d=el(r.shape,n.size),f=ou(bp(0,r.size),d),m=uu(r,f);o=iu(jl(m),jl(r));const g=mc(a,o),y=mc(a,o),b=uu(s,i);c=uu(uu(b,g),y);const v=tc(c,l);l=kl(v,c,l),u=kl(v,Xp([p]),u)}return u}(Yu(vi(Ip(l),"int32"),bs([]),256),o));const p=n?uc(l,c):tc(l,c);return vi(uu(p,255),"int32")}}),jh=ms({transform_:function(e,t,n="nearest",r="constant",a=0,o){const s=hs(e,"image","transform","float32"),i=hs(t,"transforms","transform","float32");nt(4===s.rank,(()=>`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),nt(2===i.rank&&(i.shape[0]===s.shape[0]||1===i.shape[0])&&8===i.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),nt(null==o||2===o.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${o}.`));const u={image:s,transforms:i},l={interpolation:n,fillMode:r,fillValue:a,outputShape:o};return so.runKernel(Tr,u,l)}}),Hh=ms({bandPart_:function(e,t,n){nt(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),nt(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=hs(e,"a","bandPart");nt(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[o,s]=r.shape.slice(-2);if(!(t<=o))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`);if(!(n<=s))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${s}).`);t<0&&(t=o),n<0&&(n=s);const i=$u(bp(0,o,1,"int32"),[-1,1]),u=bp(0,s,1,"int32"),l=mc(i,u),c=bc(uc(l,Wl(+t,"int32")),nc(l,Wl(-n,"int32"))),p=Ac([o,s],r.dtype);return $u(Gp(nh($u(r,[-1,o,s])).map((e=>kl(c,e,p)))),a)}}),Gh=ms({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,nt(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t<e.length;++t)nt(e[t].shape[0]===n,(()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=Vp(e,e.shape[0],0).map((e=>Hp(e,[0])));nt(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t<e.length;++t)n.push(so.tidy((()=>{let e=r[t];if(t>0)for(let r=0;r<t;++r){const t=uu(jl(uu(n[r],e)),n[r]);e=mc(e,t)}return iu(e,Gl(e,"euclidean"))})));return t?Gp(n,0):n}});function Kh(e,t=!1){return so.tidy((()=>{nt(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=Jl(n),o=Lu(e);const s=Qp([[1]],[1,1]);let i=Lu(s);const u=n>=r?r:n;for(let e=0;e<u;++e){const t=o,u=i,l=a;[i,o,a]=so.tidy((()=>{const t=Wu(o,[e,e],[n-e,1]),u=Gl(t),l=Wu(o,[e,e],[1,1]),c=kl(tc(l,0),Qp([[-1]]),Qp([[1]])),p=mc(l,uu(c,u)),h=iu(t,p);i=1===h.shape[0]?Lu(s):Bu([s,Wu(h,[1,0],[h.shape[0]-1,h.shape[1]])],0);const d=Ni(iu(wi(c,p),u)),f=Wu(o,[e,0],[n-e,r]),m=uu(d,i),g=Fi(i);if(0===e)o=mc(f,wi(m,wi(g,f)));else{const t=mc(f,wi(m,wi(g,f)));o=Bu([Wu(o,[0,0],[e,r]),t],0)}const y=Fi(m),b=Wu(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=mc(b,wi(wi(b,i),y));else{const t=mc(b,wi(wi(b,i),y));a=Bu([Wu(a,[0,0],[n,e]),t],1)}return[i,o,a]})),Ti([t,u,l])}return!t&&n>r&&(a=Wu(a,[0,0],[n,r]),o=Wu(o,[0,0],[r,r])),[a,o]}))}const qh=ms({qr_:function(e,t=!1){if(nt(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return Kh(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=nh($u(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],o=[];return r.forEach((e=>{const[n,r]=Kh(e,t);a.push(n),o.push(r)})),[$u(Gp(a,0),e.shape),$u(Gp(o,0),e.shape)]}}});var Yh;!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Yh||(Yh={}));const Xh=ms({computeWeightedLoss_:function(e,t,n=Yh.SUM_BY_NONZERO_WEIGHTS){const r=hs(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=hs(t,"weights","computeWeightedLoss"));const o=null==a?r:uu(r,a);if(n===Yh.NONE)return o;if(n===Yh.SUM)return jl(o);if(n===Yh.MEAN){if(null==a)return Cc(o);{const e=r.size/a.size,t=iu(jl(o),jl(a));return e>1?iu(t,Wl(e)):t}}if(n===Yh.SUM_BY_NONZERO_WEIGHTS){if(null==a)return iu(jl(o),Wl(r.size));{const e=uu(a,Nc(r.shape)),t=vi(jl(Pc(e,Wl(0))),"float32");return iu(jl(o),t)}}throw Error(`Unknown reduction: ${n}`)}}),Qh=ms({absoluteDifference_:function(e,t,n,r=Yh.SUM_BY_NONZERO_WEIGHTS){const a=hs(e,"labels","absoluteDifference"),o=hs(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=hs(n,"weights","absoluteDifference")),rt(a.shape,o.shape,"Error in absoluteDifference: ");const i=lu(mc(a,o));return Xh(i,s,r)}}),Jh=ms({cosineDistance_:function(e,t,n,r,a=Yh.SUM_BY_NONZERO_WEIGHTS){const o=hs(e,"labels","cosineDistance"),s=hs(t,"predictions","cosineDistance");let i=null;null!=r&&(i=hs(r,"weights","cosineDistance")),rt(o.shape,s.shape,"Error in cosineDistance: ");const u=Wl(1),l=mc(u,jl(uu(o,s),n,!0));return Xh(l,i,a)}}),Zh=ms({hingeLoss_:function(e,t,n,r=Yh.SUM_BY_NONZERO_WEIGHTS){let a=hs(e,"labels","hingeLoss");const o=hs(t,"predictions","hingeLoss");let s=null;null!=n&&(s=hs(n,"weights","hingeLoss")),rt(a.shape,o.shape,"Error in hingeLoss: ");const i=Wl(1);a=mc(uu(Wl(2),a),i);const u=wp(mc(i,uu(a,o)));return Xh(u,s,r)}}),ed=ms({huberLoss_:function(e,t,n,r=1,a=Yh.SUM_BY_NONZERO_WEIGHTS){const o=hs(e,"labels","huberLoss"),s=hs(t,"predictions","huberLoss");let i=null;null!=n&&(i=hs(n,"weights","huberLoss")),rt(o.shape,s.shape,"Error in huberLoss: ");const u=Wl(r),l=lu(mc(s,o)),c=Rc(l,u),p=mc(l,c),h=ou(uu(Wl(.5),zl(c)),uu(u,p));return Xh(h,i,a)}}),td=ms({logLoss_:function(e,t,n,r=1e-7,a=Yh.SUM_BY_NONZERO_WEIGHTS){const o=hs(e,"labels","logLoss"),s=hs(t,"predictions","logLoss");let i=null;null!=n&&(i=hs(n,"weights","logLoss")),rt(o.shape,s.shape,"Error in logLoss: ");const u=Wl(1),l=Wl(r),c=Ni(uu(o,cc(ou(s,l)))),p=uu(mc(u,o),cc(ou(mc(u,s),l))),h=mc(c,p);return Xh(h,i,a)}}),nd=ms({meanSquaredError_:function(e,t,n,r=Yh.SUM_BY_NONZERO_WEIGHTS){const a=hs(e,"labels","meanSquaredError"),o=hs(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=hs(n,"weights","meanSquaredError")),rt(a.shape,o.shape,"Error in meanSquaredError: ");const i=jp(a,o);return Xh(i,s,r)}}),rd=ms({sigmoidCrossEntropy_:function(e,t,n,r=0,a=Yh.SUM_BY_NONZERO_WEIGHTS){let o=hs(e,"multiClassLabels","sigmoidCrossEntropy");const s=hs(t,"logits","sigmoidCrossEntropy");let i=null;if(null!=n&&(i=hs(n,"weights","sigmoidCrossEntropy")),rt(o.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=Wl(r),t=Wl(1),n=Wl(.5);o=ou(uu(o,mc(t,e)),uu(n,e))}const u=function(e,t){const n=hs(e,"labels","sigmoidCrossEntropyWithLogits"),r=hs(t,"logits","sigmoidCrossEntropyWithLogits");rt(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=wp(r),o=uu(r,n),s=pc(ql(Ni(lu(r))));return ou(mc(a,o),s)}(o,s);return Xh(u,i,a)}}),ad=ms({softmaxCrossEntropy_:function(e,t,n,r=0,a=Yh.SUM_BY_NONZERO_WEIGHTS){let o=hs(e,"onehotLabels","softmaxCrossEntropy");const s=hs(t,"logits","softmaxCrossEntropy");let i=null;if(null!=n&&(i=hs(n,"weights","softmaxCrossEntropy")),rt(o.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=Wl(r),t=Wl(1),n=Wl(o.shape[1]);o=ou(uu(o,mc(t,e)),iu(e,n))}const u=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);const r=hc(((e,t,r)=>{const a=yc(t,[n],!0),o=mc(vi(t,"float32"),a);r([e,o]);const s=Ni(uu(o,e));return{value:jl(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,o=Ol(e.shape,[n]);return[uu($u(e,o),mc(vi(r,"float32"),ql(a))),uu($u(e,o),mc(ql(a),vi(r,"float32")))]}}}));return r(e,t)}(o,s);return Xh(u,i,a)}}),od=ms({sparseFillEmptyRows_:function(e,t,n,r){const a=hs(e,"indices","sparseFillEmptyRows","int32"),o=hs(t,"values","sparseFillEmptyRows"),s=hs(n,"denseShape","sparseFillEmptyRows","int32"),i=hs(r,"defaultValue","sparseFillEmptyRows",o.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==o.rank)throw new Error(`Values should be Tensor1D but received shape ${o.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==i.rank)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);const u={indices:a,values:o,denseShape:s,defaultValue:i},l=so.runKernel(pr,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),sd=ms({sparseReshape_:function(e,t,n){const r=hs(e,"inputIndices","sparseReshape","int32"),a=hs(t,"inputShape","sparseReshape","int32"),o=hs(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==o.rank)throw new Error(`New shape should be Tensor1D but received shape ${o.shape}`);const s={inputIndices:r,inputShape:a,newShape:o},i=so.runKernel(hr,s);return{outputIndices:i[0],outputShape:i[1]}}}),id=ms({sparseSegmentMean_:function(e,t,n){const r=hs(e,"data","sparseSegmentMean"),a=hs(t,"indices","sparseSegmentMean","int32"),o=hs(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==o.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${o.shape}`);const s={data:r,indices:a,segmentIds:o};return so.runKernel(dr,s)}}),ud=ms({sparseSegmentSum_:function(e,t,n){const r=hs(e,"data","sparseSegmentSum"),a=hs(t,"indices","sparseSegmentSum","int32"),o=hs(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==o.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${o.shape}`);const s={data:r,indices:a,segmentIds:o};return so.runKernel(fr,s)}}),ld=ms({stringNGrams_:function(e,t,n,r,a,o,s,i){const u=hs(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=hs(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:o,padWidth:s,preserveShortSequences:i},p={data:u,dataSplits:l},h=so.runKernel(yr,p,c);return{nGrams:h[0],nGramsSplits:h[1]}}}),cd={fft:Bp,ifft:Up,rfft:zp,irfft:Wp},pd={hammingWindow:kh,hannWindow:Th,frame:Sh,stft:Eh},hd={flipLeftRight:Ch,grayscaleToRGB:Ah,resizeNearestNeighbor:Vh,resizeBilinear:Wh,rotateWithOffset:Nh,cropAndResize:Ih,nonMaxSuppression:Fh,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const o=hs(e,"boxes","nonMaxSuppressionAsync"),s=hs(t,"scores","nonMaxSuppressionAsync"),i=Rh(o,s,n,r,a);n=i.maxOutputSize,r=i.iouThreshold,a=i.scoreThreshold;const u=await Promise.all([o.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:p}=function(e,t,n,r,a){return $h(e,t,n,r,a,0)}(l,c,n,r,a);return o!==e&&o.dispose(),s!==t&&s.dispose(),Xp(p,"int32")},nonMaxSuppressionWithScore:Bh,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=0){const s=hs(e,"boxes","nonMaxSuppressionAsync"),i=hs(t,"scores","nonMaxSuppressionAsync"),u=Rh(s,i,n,r,a,o);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,o=u.softNmsSigma;const l=await Promise.all([s.data(),i.data()]),c=l[0],p=l[1],{selectedIndices:h,selectedScores:d}=function(e,t,n,r,a,o){return $h(e,t,n,r,a,o,!0)}(c,p,n,r,a,o);return s!==e&&s.dispose(),i!==t&&i.dispose(),{selectedIndices:Xp(h,"int32"),selectedScores:Xp(d)}},nonMaxSuppressionPadded:Uh,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=!1){const s=hs(e,"boxes","nonMaxSuppressionAsync"),i=hs(t,"scores","nonMaxSuppressionAsync"),u=Rh(s,i,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[h,d]=await Promise.all([s.data(),i.data()]),{selectedIndices:f,validOutputs:m}=function(e,t,n,r,a,o){return $h(e,t,n,r,a,0,!1,o,!0)}(h,d,l,c,p,o);return s!==e&&s.dispose(),i!==t&&i.dispose(),{selectedIndices:Xp(f,"int32"),validOutputs:Wl(m,"int32")}},threshold:zh,transform:jh},dd={bandPart:Hh,gramSchmidt:Gh,qr:qh},fd={absoluteDifference:Qh,computeWeightedLoss:Xh,cosineDistance:Jh,hingeLoss:Zh,huberLoss:ed,logLoss:td,meanSquaredError:nd,sigmoidCrossEntropy:rd,softmaxCrossEntropy:ad},md={sparseFillEmptyRows:od,sparseReshape:sd,sparseSegmentMean:id,sparseSegmentSum:ud},gd={stringNGrams:ld,stringSplit:ms({stringSplit_:function(e,t,n=!0){const r=hs(e,"input","stringSplit","string"),a=hs(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const o={skipEmpty:n},s={input:r,delimiter:a},i=so.runKernel(br,s,o);return{indices:i[0],values:i[1],shape:i[2]}}}),stringToHashBucketFast:ms({stringToHashBucketFast_:function(e,t){const n=hs(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return so.runKernel(vr,a,r)}})},yd="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function bd(e,t){const n=e[0].length;e.forEach(((e,t)=>{nt(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),nt(t>=0&&t<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let o=0;o<n;o++)nt(o===t||e[o]===r[o],(()=>`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function vd(e,t){const n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var wd;function xd(e,t,n){let r=new Array;if(null==n&&null==t)return r;if(null==t)for(;r.length<e+n.length;)r.push(-1);else r=t.slice();if(null==n)return r;if(e+n.length!==r.length)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+n.length}, but shape.rank = ${r.length}`);for(let a=1;a<n.length;++a){const o=n[a],s=r[r.length-n.length+a],i=r[s];if(o>=0)if(i>=0){if(i!==o)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${o} but shape[${a+e}] = ${i}`)}else r[s]=o}return r}function _d(e){const t={FIRST_DIM_SIZE:wd.FIRST_DIM_SIZE,VALUE_ROWIDS:wd.VALUE_ROWIDS,ROW_LENGTHS:wd.ROW_LENGTHS,ROW_SPLITS:wd.ROW_SPLITS,ROW_LIMITS:wd.ROW_LIMITS,ROW_STARTS:wd.ROW_STARTS},n=[];for(const r of e){if(!(r in t))break;n.push(t[r])}return n}function kd(e){return 0===e.length?0:e[0]===wd.FIRST_DIM_SIZE?e.length-1:e.length}function Td(e,t){if(null==e||null==t)return;const n=e.length,r=t.length;if(n>=r)throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);for(let a=0;a<Math.min(n,r-1);++a){const n=e[a],r=t[a+1];if(n>=0&&r>=0&&1!==n&&n!==r)throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${n} but ragged tensor input.flatValues.shape[${a-e.length}] = ${r}`)}}function Sd(e){return e<=30?e:xt(e,Math.floor(Math.sqrt(e)))}function Ed(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function Id(e,t,n,r=!0){let a=[];if(r)a=a.concat(t.slice(0)),a.push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);const n=t.length;for(let r=0;r<n;++r)a=a.concat([e[r+1]/t[r],t[r]]);a=a.concat(e.slice(n+1))}return a}function Cd(e,t,n=!0){const r=[];if(n){r.push(t);for(let n=t+1;n<e;++n)n<=2*t?(r.push(n),r.push(n-(t+1))):r.push(n)}else{const n=[],a=[];for(let r=1;r<e;++r)r>=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function Ad(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n<e.length;++n)n<=t.length?r?a.push(t[n-1]*e[n]):a.push(e[n]/t[n-1]):a.push(e[n]);return a}function Nd(e,t){const n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function Rd(e,t,n){const r=e.slice(0,1);for(let a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}function Fd(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(wd||(wd={}));const Od=/->/g;function Md(e,t){const n=[];for(let r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function $d(e,t,n=0){let r=[];if("number"==typeof t)nt(e.shape[n]%t==0,(()=>"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{nt(t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0)<=1,(()=>"There should be only one negative value in split array."));const a=t.indexOf(-1);if(-1!==a){const r=t.reduce(((e,t)=>t>0?e+t:e));t[a]=e.shape[n]-r}nt(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Dd(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Pd(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function Ld(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Bd(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Ud(e,t){return`size ${e} must be non-negative, not ${t}`}function Wd(e,t){return`Input to reshape is a SparseTensor with ${ot(e)}\n dense values, but the requested shape requires a multiple of ${ot(t)}. inputShape=${e} outputShape= ${t}`}function Vd(e,t){return`Input to reshape is a tensor with ${ot(e)} dense values, but the requested shape has ${ot(t)}. inputShape=${e} outputShape=${t}`}function zd(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function jd(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function Hd(e,t,n,r){const a=t.shape.length,o=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>o)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${o}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let n=0;n<r;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const s=e.shape[n],i=[];let u=1,l=1,c=1;for(let t=0;t<r;++t)i.push(e.shape[t]),u*=e.shape[t];for(let t=r;t<n;t++)i.push(e.shape[t]),l*=e.shape[t];for(let e=r;e<a;e++)i.push(t.shape[e]);for(let t=n+1;t<o;t++)i.push(e.shape[t]),c*=e.shape[t];return{batchSize:u,sliceSize:c,outerSize:l,dimSize:s,outputShape:i}}var Gd=Object.freeze({__proto__:null,segOpComputeOptimalWindowSize:function(e,t){let n,r=!1;for(e<=30?(n=e,r=!0):n=xt(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=xt(e,n+1);return n},computeOutShape:function(e,t,n){const r=[],a=e.length;for(let o=0;o<a;o++)o!==t?r.push(e[o]):r.push(n);return r},collectGatherOpShapeInfo:Hd});function Kd(e){try{return e.map((e=>Na(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function qd(e){return e.map((e=>Aa(e)))}var Yd=Object.freeze({__proto__:null,slice_util:au,segment_util:Gd,fromUint8ToStringArray:Kd,fromStringArrayToUint8:qd,upcastType:Ja,axesAreInnerMostDims:Nl,combineLocations:Rl,computeOutAndReduceShapes:Fl,expandShapeToKeepDim:Ol,assertAxesAreInnerMostDims:Ml,getAxesPermutation:$l,getUndoAxesPermutation:Dl,getInnerMostAxes:Pl,getBroadcastDims:Oi,getReductionAxes:Mi,assertAndGetBroadcastShape:$i,assertParamsConsistent:bd,computeOutShape:vd,computeDilation2DInfo:function(e,t,n,r,a="NHWC",o){return ku(e,[...t,e[3]],n,o,r,null,null,Ou(a))},computePool2DInfo:_u,computePool3DInfo:function(e,t,n,r,a,o,s="NDHWC"){const[i,u,l]=Iu(t);let c,p;if("NDHWC"===s)p="channelsLast",c=[i,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);p="channelsFirst",c=[i,u,l,e[1],e[1]]}return Tu(e,c,n,r,a,!1,p,o)},computeConv2DInfo:ku,computeConv3DInfo:Tu,computeDefaultPad:Su,tupleValuesAreOne:Nu,eitherStridesOrDilationsAreOne:Ru,stridesOrDilationsArePositive:Fu,convertConv2DDataFormat:Ou,checkPadOnDimRoundingMode:Mu,getFusedDyActivation:dh,getFusedBiasGradient:fh,applyActivation:mh,shouldFuse:gh,get RowPartitionType(){return wd},combineRaggedTensorToTensorShapes:xd,getRowPartitionTypesHelper:_d,getRaggedRank:kd,validateDefaultValueShape:Td,PARALLELIZE_THRESHOLD:30,computeOptimalWindowSize:Sd,getImageCenter:Ed,getReshaped:Id,getPermuted:Cd,getReshapedPermuted:Ad,getSliceBeginCoords:Nd,getSliceSize:Rd,prepareAndValidate:Bi,validateUpdateShape:Ui,validateInput:Wi,calculateShapes:Vi,SELU_SCALEALPHA:1.7580993408473768,SELU_SCALE:1.0507009873554805,ERF_P:.3275911,ERF_A1:.254829592,ERF_A2:-.284496736,ERF_A3:1.421413741,ERF_A4:-1.453152027,ERF_A5:1.061405429,warn:Mr,log:function(...e){Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.log(...e)},mergeRealAndImagArrays:Fd,splitRealAndImagArrays:function(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}},complexWithEvenIndex:function(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}},complexWithOddIndex:function(e){const t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}},getComplexWithIndex:function(e,t){return{real:e[2*t],imag:e[2*t+1]}},assignToTypedArray:function(e,t,n,r){e[2*r]=t,e[2*r+1]=n},exponents:function(e,t){const n=new Float32Array(e/2),r=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){const o=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(o),r[a]=Math.sin(o)}return{real:n,imag:r}},exponent:function(e,t,n){const r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}},decodeEinsumEquation:function(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Od,"").length)/"->".length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");nt(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const o=r.split(","),s=o.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const i=[];for(let e=0;e<a.length;++e){const t=a[e];if(!o.some((e=>-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===i.indexOf(t)&&i.push(t)}for(let e=0;e<r.length;++e){const t=r[e];-1===i.indexOf(t)&&","!==t&&i.push(t)}const u=new Array(o.length);for(let e=0;e<s;++e){if(new Set(o[e].split("")).size!==o[e].length)throw new Error(`Found duplicate axes in input component ${o[e]}. Support for duplicate axes in input is not implemented yet.`);u[e]=[];for(let t=0;t<o[e].length;++t)u[e].push(i.indexOf(o[e][t]))}const l=i.length,c=[];for(let e=a.length;e<l;++e)c.push(e);return{allDims:i,summedDims:c,idDims:u}},getEinsumPermutation:function(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const r=[];for(let t=0;t<e;++t)-1===n[t]&&r.push(t);return n=n.filter((e=>-1!==e)),{permutationIndices:n,expandDims:r}},checkEinsumDimSizes:function(e,t,n){const r=new Array(e);for(let e=0;e<n.length;++e){const a=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===r[t[e][n]]?r[t[e][n]]=a[n]:nt(r[t[e][n]]===a[n],(()=>`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}},getEinsumComputePath:function(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;e<a;++e)r.push([]);const o=[];for(let e=0;e<n.length;++e){const a=Md(t,n[e]);for(const t of a)-1===o.indexOf(t)&&(r[e].push(t),o.push(t))}return{path:n,steps:r}},isIdentityPermutation:function(e){return e.every(((e,t)=>e===t))},prepareSplitSize:$d,getSparseFillEmptyRowsIndicesDenseShapeMismatch:Dd,getSparseFillEmptyRowsNegativeIndexErrorMessage:Pd,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:Ld,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:Bd,getSparseReshapeNegativeOutputDimErrorMessage:Ud,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:function(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"},getSparseReshapeInputOutputMultipleErrorMessage:Wd,getSparseReshapeInputOutputMismatchErrorMessage:Vd,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:function(){return"segment ids must be >= 0"},getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:function(){return"segment ids are not increasing"},getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:zd,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:jd});class Xd{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){"undefined"!=typeof window&&Mt().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(e=>{e.source===window&&e.data.name===this.messageName&&(e.stopPropagation(),(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0))}),!0))):setTimeout(e,t)}isTypedArray(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}}if(Mt().get("IS_BROWSER")){Mt().setPlatform("browser",new Xd);try{mi.registerManager(Qs.URL_SCHEME,new Zs)}catch(i){}try{mi.registerManager(Ls.URL_SCHEME,new Us)}catch(i){}}let Qd;var Jd,Zd;Mt().get("IS_NODE")&&!Mt().get("IS_BROWSER")&&Mt().setPlatform("node",new class{constructor(){this.util=n(345),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Mt().global.fetch?Mt().global.fetch(e,t):(null==Qd&&(Qd=n(683)),Qd(e,t))}now(){const e=Ye.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}),oo(),za={buffer:Ju,cast:vi,clone:Lu,print:qc},Mt().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(Jd||(Jd={})),function(e){var t;(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(Zd||(Zd={}));const ef={};function tf(e){return ef[e]}function nf(e,t,n,r,a){const o=t.inputParams[e];if(o&&void 0!==o.inputIndexStart){const e=o.inputIndexStart,s=0===o.inputIndexEnd?void 0:void 0===o.inputIndexEnd?e+1:o.inputIndexEnd;if("tensor"===o.type)return rf(t.inputNames[o.inputIndexStart],n,r,a);if("tensors"===o.type)return t.inputNames.slice(e,s).map((e=>rf(e,n,r,a)));const i=rf(t.inputNames.slice(e)[0],n,r,a),u=i.dataSync();return"number"===o.type?u[0]:Tt(i.shape,u)}const s=t.attrParams[e];return s&&s.value}function rf(e,t,n,r){const[a,o]=sf(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[of(a,e)]));return void 0!==s?t[of(a,s)][o]:void 0}function af(e,t){const[n,r,a]=sf(e);return[of(n,t&&t.currentContextId),r,a]}function of(e,t){return t?`${e}-${t}`:e}function sf(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function uf(e,t,n){let r=nf("pad",e,t,n);if("explicit"===r){r=nf("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function lf(e){return e.kept?e:Lu(e)}var cf=Object.freeze({__proto__:null,json:[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),pf=Object.freeze({__proto__:null,json:[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),hf=Object.freeze({__proto__:null,json:[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}]}),df=Object.freeze({__proto__:null,json:[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}]}),ff=Object.freeze({__proto__:null,json:[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]}),mf=Object.freeze({__proto__:null,json:[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),gf=Object.freeze({__proto__:null,json:[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}]}),yf=Object.freeze({__proto__:null,json:[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}]}),bf=Object.freeze({__proto__:null,json:[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}]}),vf=Object.freeze({__proto__:null,json:[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}]}),wf=Object.freeze({__proto__:null,json:[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),xf=Object.freeze({__proto__:null,json:[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}]}),_f=Object.freeze({__proto__:null,json:[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}]}),kf=Object.freeze({__proto__:null,json:[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}]}),Tf=Object.freeze({__proto__:null,json:[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}]}),Sf=Object.freeze({__proto__:null,json:[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}]}),Ef=Object.freeze({__proto__:null,json:[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}]}),If=Object.freeze({__proto__:null,json:[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}]}),Cf=Object.freeze({__proto__:null,json:[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}]});class Af{constructor(){const e=[].concat(...[cf,pf,hf,df,ff,mf,gf,yf,bf,vf,wf,xf,_f,kf,Tf,Sf,Ef,If,Cf].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}static get Instance(){return this._instance||(this._instance=new this)}transformGraph(e,t={}){const n=e.node,r=[],a=[],o=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||o.push(e[t.name]),e)),{});let i=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=af(e),o=s[r];if(null!=o.outputs){const e=o.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(o),o.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=af(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=af(e),n=s[t];n&&(n.signatureKey=l[e],i.push(n))})):i=r;let h={};null!=e.library&&null!=e.library.function&&(h=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const d={nodes:s,inputs:i,outputs:u,weights:a,placeholders:r,signature:t,functions:h};return o.length>0&&(d.initNodes=o),d}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=tf(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=Rf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Rf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=Wf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Wf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=Of(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=Of(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=Uf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Uf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=Ff(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Ff(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=zf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=zf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=Bf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Bf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=Vf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Vf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=Df(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Df(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=Pf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Pf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=$f(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=$f(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],o=[];e.signature.inputArg.forEach((e=>{const[t]=af(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Mf(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,o]=af(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(o);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=af(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,o.push(a))}));const i=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:o,weights:n,placeholders:[],signature:i}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function Nf(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Mt().global;if(void 0!==t.atob)return t.atob(e);if(void 0!==So)return new So(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function Rf(e,t,n,r=!1){const a=e[t];return null!=a?Nf(a.s,r):n}function Ff(e,t,n){const r=e[t];return r?r.b:n}function Of(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function Mf(e){switch("string"==typeof e&&(e=Jd[e]),e){case Jd.DT_FLOAT:case Jd.DT_HALF:return"float32";case Jd.DT_INT32:case Jd.DT_INT64:case Jd.DT_INT8:case Jd.DT_UINT8:return"int32";case Jd.DT_BOOL:return"bool";case Jd.DT_DOUBLE:return"float32";case Jd.DT_STRING:return"string";default:return null}}function $f(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function Df(e,t,n){const r=e[t];return r&&r.type?Mf(r.type):n}function Pf(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>Mf(e))):n}function Lf(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function Bf(e,t,n){const r=e[t];return r&&r.shape?Lf(r.shape):n}function Uf(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function Wf(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>Nf(e,r))):n}function Vf(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>Lf(e))):n}function zf(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class jf{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return rf(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return rf(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return Of(this.node.rawAttrs,e,t);if(null!=n.s)return Rf(this.node.rawAttrs,e,t);if(null!=n.b)return Ff(this.node.rawAttrs,e,t);if(null!=n.shape)return Bf(this.node.rawAttrs,e,t);if(null!=n.type)return Df(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return Uf(this.node.rawAttrs,e,t);if(null!=n.list.s)return Wf(this.node.rawAttrs,e,t);if(null!=n.list.shape)return Vf(this.node.rawAttrs,e,t);if(null!=n.list.b)return zf(this.node.rawAttrs,e,t);if(null!=n.list.type)return Pf(this.node.rawAttrs,e,t)}return t}}var Hf=Object.freeze({__proto__:null,abs:lu,acos:cu,acosh:pu,add:ou,addN:hu,all:du,any:fu,argMax:mu,argMin:gu,asin:yu,asinh:bu,atan:vu,atan2:wu,atanh:xu,avgPool:Du,avgPool3d:Pu,basicLSTMCell:zu,batchToSpaceND:ju,batchNorm:Hu,batchNorm2d:Gu,batchNorm3d:Ku,batchNorm4d:qu,bincount:Yu,broadcastArgs:Xu,broadcastTo:Qu,buffer:Ju,cast:vi,ceil:Zu,clipByValue:tl,clone:Lu,complex:gs,concat:Bu,concat1d:nl,concat2d:rl,concat3d:al,concat4d:ol,conv1d:il,conv2d:sl,conv2dTranspose:ll,conv3d:cl,conv3dTranspose:hl,cos:dl,cosh:fl,cumprod:ml,cumsum:gl,denseBincount:yl,depthToSpace:bl,depthwiseConv2d:vl,diag:wl,dilation2d:xl,div:iu,divNoNan:Sl,dot:El,einsum:Il,elu:Cl,equal:_l,erf:Al,euclideanNorm:Kl,exp:ql,expandDims:Yl,expm1:Xl,eye:Jl,fill:el,floor:Zl,floorDiv:su,gather:ec,greater:tc,greaterEqual:nc,imag:Ai,isFinite:rc,isInf:ac,isNaN:oc,leakyRelu:sc,less:ic,lessEqual:uc,linspace:function(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");const r={start:e,stop:t,num:n};return so.runKernel("LinSpace",{},r)},localResponseNormalization:lc,log:cc,log1p:pc,logSigmoid:fc,logSoftmax:gc,logSumExp:yc,logicalAnd:bc,logicalNot:vc,logicalOr:wc,logicalXor:xc,lowerBound:function(e,t){return kc(e,t,"left")},matMul:wi,max:Ll,maxPool:Tc,maxPool3d:Sc,maxPoolWithArgmax:Ec,maximum:Ic,mean:Cc,meshgrid:function(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=hs(e,"x","meshgrid",e instanceof ja?e.dtype:"float32");if(void 0===t)return[r];let a=hs(t,"y","meshgrid",t instanceof ja?t.dtype:"float32");const o=ot(r.shape),s=ot(a.shape);return"xy"===n?(r=$u(r,[1,-1]),a=$u(a,[-1,1]),[wi(Nc([s,1],r.dtype),r),wi(a,Nc([1,o],a.dtype))]):(r=$u(r,[-1,1]),a=$u(a,[1,-1]),[wi(r,Nc([1,s],r.dtype)),wi(Nc([o,1],a.dtype),a)])},min:Bl,minimum:Rc,mirrorPad:Fc,mod:Oc,moments:Mc,mul:uu,multiRNNCell:$c,multinomial:Dc,neg:Ni,notEqual:Pc,oneHot:xi,ones:Nc,onesLike:Lc,outerProduct:Bc,pad:Uc,pad1d:Wc,pad2d:Vc,pad3d:zc,pad4d:jc,pool:Gc,pow:Ul,prelu:Kc,print:qc,prod:Yc,raggedGather:Xc,raggedRange:Qc,raggedTensorToTensor:Jc,rand:Zc,randomGamma:fp,randomNormal:mp,randomStandardNormal:gp,randomUniform:yp,range:bp,real:Ri,reciprocal:vp,relu:wp,relu6:xp,reshape:$u,reverse:_p,reverse1d:kp,reverse2d:Tp,reverse3d:Sp,reverse4d:Ep,round:Ip,rsqrt:Cp,scalar:Wl,selu:Ap,separableConv2d:Np,setdiff1dAsync:async function(e,t){const n=hs(e,"x","setdiff1d"),r=hs(t,"y","setdiff1d");nt(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),nt(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),nt(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),o=await r.data(),s=new Set(o);let i=0;for(let e=0;e<a.length;e++)s.has(a[e])||i++;const u=new Wa([i],n.dtype),l=new Wa([i],"int32");for(let e=0,t=0;e<a.length;e++)s.has(a[e])||(u.values[t]=a[e],l.values[t]=e,t++);return[u.toTensor(),l.toTensor()]},sigmoid:Uu,sign:Rp,sin:Fp,sinh:Op,slice:Wu,slice1d:Mp,slice2d:$p,slice3d:Dp,slice4d:Pp,softmax:Lp,softplus:dc,spaceToBatchND:Hc,fft:Bp,ifft:Up,irfft:Wp,rfft:zp,split:Vp,sqrt:Vl,square:zl,squaredDifference:jp,squeeze:Hp,stack:Gp,step:Kp,stridedSlice:qp,sub:mc,sum:jl,tan:Yp,tanh:Vu,tensor:bs,tensor1d:Xp,tensor2d:Qp,tensor3d:Di,tensor4d:function(e,t,n){if(at(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=ls(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return ys(e,t,r,n)},tensor5d:function(e,t,n){if(at(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=ls(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return ys(e,t,r,n)},tensor6d:function(e,t,n){if(at(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=ls(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return ys(e,t=t||r,r,n)},tile:Ql,topk:Jp,truncatedNormal:Zp,unique:eh,unsortedSegmentSum:th,unstack:nh,upperBound:function(e,t){return kc(e,t,"right")},variable:function(e,t=!0,n,r){return so.makeVariable(e,t,n,r)},where:kl,whereAsync:ah,zeros:Ac,zerosLike:Tl,op:ms,OP_SCOPE_SUFFIX:fs,booleanMaskAsync:async function(e,t,n){const r=hs(e,"tensor","boolMask"),a=hs(t,"mask","boolMask","bool"),o=null==n?0:n,s=a.rank,i=r.shape;nt(s>0,(()=>"mask cannot be scalar")),rt(i.slice(o,o+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=o;e<o+s;e++)u*=i[e];const l=i.slice(0,o).concat([u],i.slice(o+s)),c=$u(r,l),p=$u(a,[-1]),h=await ah(p),d=Hp(h,[1]),f=ec(c,d,o);return e!==r&&r.dispose(),t!==a&&a.dispose(),d.dispose(),c.dispose(),p.dispose(),h.dispose(),f},transpose:Fi,norm:Gl,movingAverage:oh,scatterND:sh,searchSorted:kc,sparseToDense:ih,gatherND:uh,dropout:lh,enclosingPowerOfTwo:ch,cosineWindow:ph,inTopKAsync:async function(e,t,n=1){const r=hs(e,"predictions","inTopK"),a=hs(t,"targets","inTopK");nt(r.rank>1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),nt(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),rt(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const o=r.shape[r.shape.length-1];nt(n>0&&n<=o,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${o}), but got ${n}`));const s=await r.data(),i=await a.data(),[u,l]=[s.length/o,o],c=ft("bool",u);for(let e=0;e<u;e++){const t=e*l,r=s.subarray(t,t+l),a=[];for(let e=0;e<r.length;e++)a.push({value:r[e],index:e});a.sort(((e,t)=>t.value-e.value)),c[e]=0;for(let t=0;t<n;t++)if(a[t].index===i[e]){c[e]=1;break}}return e!==r&&r.dispose(),t!==a&&a.dispose(),bs(c,a.shape,"bool")},image:hd,linalg:dd,losses:fd,spectral:cd,fused:_h,signal:pd,sparse:md,string:gd});function Gf(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){nt(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;r<e.length;r++){const a=e[r],o=t[r];nt(a<0||o<0||a===o,(()=>n+` Shapes ${e} and ${t} must match`))}}}function Kf(e){return"number"!=typeof e&&!e.some((e=>e<0))}function qf(e,t,n){let r=Yf(e,n);const a=!Kf(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=Yf(e.shape,r)})),!Kf(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function Yf(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r<e.length;++r){const a=e[r],o=t[r];if(a>=0&&o>=0&&a!==o)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:o}return n}class Xf{constructor(e,t,n,r,a,o,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=o,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=Wl(0),Si(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),Gf(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,Si(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t<this.size();t++)e.push(t)}if(0===e.length)return bs([],[0].concat(this.elementShape));const n=this.readMany(e);return Gf(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),Gp(n,0)}concat(e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return bs([],[0].concat(this.elementShape));const t=[];for(let e=0;e<this.size();e++)t.push(e);const n=this.readMany(t);return Gf(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),Bu(n,0)}scatter(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const n=Math.max(...e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,nh(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,o=[];ki((()=>{t=$u(t,[1,n,a]);for(let n=0;n<e.length;++n){const s=[0,0===n?0:r[n-1],0],i=[1,e[n],a];o[n]=$u(Wu(t,s,i),this.elementShape)}return o}));const s=[];for(let t=0;t<e.length;t++)s[t]=t;this.writeMany(s,o)}}class Qf{constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach((e=>{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);Gf(t,e.shape,"TensorList shape mismatch: "),Si(e)})),this.idTensor=Wl(0),this.maxNumElements=r,Si(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Qf([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);Gf(e,this.elementShape,"TensorList shape mismatch: ");const r=qf(this.elementShape,this.tensors,e);return ki((()=>{const e=this.tensors.map((e=>$u(e,r)));return Gp(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=qf(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,Gf(r.shape,e,"TensorList shape mismatch: "),$u(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Gf(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Si(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new Qf([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;n<Math.min(this.tensors.length,e);++n)t.tensors[n]=this.tensors[n];return t}getItem(e,t,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);Gf(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=qf(this.elementShape,this.tensors,t);return $u(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);Gf(this.elementShape,t.shape,"TensorList shape mismatch: "),Si(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);Gf(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=qf(this.elementShape,this.tensors,n);return 0===e.length?bs([],[0].concat(r)):ki((()=>{const t=e.map((e=>$u(this.tensors[e],r)));return Gp(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Gf(this.elementShape,t,"TensorList shape mismatch: ");const n=qf(this.elementShape,this.tensors,t);return 0===this.size()?bs([],[0].concat(n)):ki((()=>{const e=this.tensors.map((e=>$u(e,n)));return Bu(e,0)}))}}function Jf(e,t,n){const[r,a]=nf("fusedOps",e,t,n),o="biasadd"===r,s=!o,i="prelu"===a,u="fusedbatchnorm"===r,l=nf("numArgs",e,t,n);if(o){if(i&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&o&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=nf("strides",e,t,n),p=uf(e,t,n),h=nf("dataFormat",e,t,n).toUpperCase(),d=nf("dilations",e,t,n);let[f,m]=nf("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:p,dataFormat:h,dilations:d,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:nf("leakyreluAlpha",e,t,n)}}function Zf(e,t,n){return{boxes:nf("boxes",e,t,n),scores:nf("scores",e,t,n),maxOutputSize:nf("maxOutputSize",e,t,n),iouThreshold:nf("iouThreshold",e,t,n),scoreThreshold:nf("scoreThreshold",e,t,n),softNmsSigma:nf("softNmsSigma",e,t,n)}}class em{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Wl(0),this.tensorMap=new Map,Si(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Wl(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),ki((()=>{const e=nh(t),r=n.length,a=e.length;nt(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t<r;t++){const r=n[t],a=e[t];Si(a),this.tensorMap.set(r,a)}return this.handle}))}async find(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return ki((()=>{const e=[];for(let r=0;r<n.length;r++){const a=n[r],o=this.findWithDefault(a,t);e.push(o)}return Gp(e)}))}findWithDefault(e,t){const n=this.tensorMap.get(e);return null!=n?n:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}function tm(e,t,n,r,a=ki){const o=((e,t,n)=>{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(nf("a",e,t,n),nf("b",e,t,n))];case"AddN":return[r.addN(nf("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(nf("a",e,t,n),nf("b",e,t,n))];case"Mul":return[r.mul(nf("a",e,t,n),nf("b",e,t,n))];case"RealDiv":case"Div":return[r.div(nf("a",e,t,n),nf("b",e,t,n))];case"DivNoNan":return[r.divNoNan(nf("a",e,t,n),nf("b",e,t,n))];case"FloorDiv":return[r.floorDiv(nf("a",e,t,n),nf("b",e,t,n))];case"Sub":return[r.sub(nf("a",e,t,n),nf("b",e,t,n))];case"Minimum":return[r.minimum(nf("a",e,t,n),nf("b",e,t,n))];case"Maximum":return[r.maximum(nf("a",e,t,n),nf("b",e,t,n))];case"Pow":return[r.pow(nf("a",e,t,n),nf("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(nf("a",e,t,n),nf("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(nf("x",e,t,n))];case"Acos":return[r.acos(nf("x",e,t,n))];case"Acosh":return[r.acosh(nf("x",e,t,n))];case"Asin":return[r.asin(nf("x",e,t,n))];case"Asinh":return[r.asinh(nf("x",e,t,n))];case"Atan":return[r.atan(nf("x",e,t,n))];case"Atan2":return[r.atan2(nf("x",e,t,n),nf("y",e,t,n))];case"Atanh":return[r.atanh(nf("x",e,t,n))];case"Ceil":return[r.ceil(nf("x",e,t,n))];case"Complex":return[r.complex(nf("real",e,t,n),nf("imag",e,t,n))];case"Cos":return[r.cos(nf("x",e,t,n))];case"Cosh":return[r.cosh(nf("x",e,t,n))];case"Elu":return[r.elu(nf("x",e,t,n))];case"Erf":return[r.erf(nf("x",e,t,n))];case"Exp":return[r.exp(nf("x",e,t,n))];case"Expm1":return[r.expm1(nf("x",e,t,n))];case"Floor":return[r.floor(nf("x",e,t,n))];case"Log":return[r.log(nf("x",e,t,n))];case"Log1p":return[r.log1p(nf("x",e,t,n))];case"Imag":return[r.imag(nf("x",e,t,n))];case"Neg":return[r.neg(nf("x",e,t,n))];case"Reciprocal":return[r.reciprocal(nf("x",e,t,n))];case"Real":return[r.real(nf("x",e,t,n))];case"Relu":return[r.relu(nf("x",e,t,n))];case"Round":return[r.round(nf("x",e,t,n))];case"Selu":return[r.selu(nf("x",e,t,n))];case"Sigmoid":return[r.sigmoid(nf("x",e,t,n))];case"Sin":return[r.sin(nf("x",e,t,n))];case"Sign":return[r.sign(nf("x",e,t,n))];case"Sinh":return[r.sinh(nf("x",e,t,n))];case"Softplus":return[r.softplus(nf("x",e,t,n))];case"Sqrt":return[r.sqrt(nf("x",e,t,n))];case"Square":return[r.square(nf("x",e,t,n))];case"Tanh":return[r.tanh(nf("x",e,t,n))];case"Tan":return[r.tan(nf("x",e,t,n))];case"ClipByValue":return[r.clipByValue(nf("x",e,t,n),nf("clipValueMin",e,t,n),nf("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(nf("x",e,t,n))];case"Rsqrt":return[r.rsqrt(rf(e.inputNames[0],t,n))];case"Prod":return[r.prod(nf("x",e,t,n),nf("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(nf("x",e,t,n),nf("alpha",e,t,n))];case"Prelu":return[r.prelu(nf("x",e,t,n),nf("alpha",e,t,n))];case"IsNan":return[r.isNaN(rf(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=nf("thenBranch",e,t,n),a=nf("elseBranch",e,t,n),o=nf("cond",e,t,n),s=nf("args",e,t,n);return(await o.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=nf("body",e,t,n),a=nf("cond",e,t,n),o=nf("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap),i=o.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||e.dispose()}));let l=o;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const o=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await o[0].data(),o.forEach((e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[lf(nf("pred",e,t,n))];case"Switch":{const r=nf("pred",e,t,n);let a=nf("data",e,t,n);return a.kept||(a=lf(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==rf(e,t,n)));return r?[lf(rf(r,t,n))]:void 0}case"Enter":{const r=nf("frameName",e,t,n),a=nf("tensor",e,t,n);return n.enterFrame(r),[lf(a)]}case"Exit":{const r=nf("tensor",e,t,n);return n.exitFrame(),[lf(r)]}case"NextIteration":{const r=nf("tensor",e,t,n);return n.nextIteration(),[lf(r)]}case"TensorArrayV3":{const r=nf("size",e,t,n),a=nf("dtype",e,t,n),o=nf("elementShape",e,t,n),s=nf("dynamicSize",e,t,n),i=nf("clearAfterRead",e,t,n),u=nf("identicalElementShapes",e,t,n),l=nf("name",e,t,n),c=new Xf(l,a,r,o,u,s,i);return n.addTensorArray(c),[c.idTensor,Wl(1)]}case"TensorArrayWriteV3":{const r=nf("tensorArrayId",e,t,n),a=nf("index",e,t,n),o=nf("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,o),[s.idTensor]}case"TensorArrayReadV3":{const r=nf("tensorArrayId",e,t,n),a=nf("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=nf("tensorArrayId",e,t,n),a=nf("indices",e,t,n),o=nf("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,o)]}case"TensorArrayScatterV3":{const r=nf("tensorArrayId",e,t,n),a=nf("indices",e,t,n),o=nf("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,o),[s.idTensor]}case"TensorArrayConcatV3":{const r=nf("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),o=nf("dtype",e,t,n);return[a.concat(o)]}case"TensorArraySplitV3":{const r=nf("tensorArrayId",e,t,n),a=nf("tensor",e,t,n),o=nf("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(o,a),[s.idTensor]}case"TensorArraySizeV3":{const r=nf("tensorArrayId",e,t,n);return[Wl(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=nf("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=nf("tensorListId",e,t,n),a=nf("index",e,t,n),o=nf("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,o),[s.idTensor]}case"TensorListGetItem":{const r=nf("tensorListId",e,t,n),a=nf("index",e,t,n),o=nf("elementShape",e,t,n),s=nf("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,o,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=nf("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const o=new Qf([],n,e.dtype,r),s=nh(e,0);return t.forEach(((e,t)=>{o.setItem(e,s[t])})),o}(nf("tensor",e,t,n),r,nf("elementShape",e,t,n),nf("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=nf("elementShape",e,t,n),a=nf("elementDType",e,t,n);let o;o="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=nf(o,e,t,n),i=function(e,t,n,r){return new Qf([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{const r=nf("tensorListId",e,t,n),a=nf("indices",e,t,n),o=nf("elementShape",e,t,n),s=nf("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,o)]}case"TensorListStack":{const r=nf("tensorListId",e,t,n),a=nf("elementShape",e,t,n),o=nf("elementDType",e,t,n),s=nf("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,o,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);Gf(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=nh(e);return new Qf(a,t,r)}(nf("tensor",e,t,n),nf("elementShape",e,t,n),nf("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=nf("tensorListId",e,t,n),a=n.getTensorList(r.id),o=nf("dtype",e,t,n),s=nf("elementShape",e,t,n);return[a.concat(o,s)]}case"TensorListPushBack":{const r=nf("tensorListId",e,t,n),a=nf("tensor",e,t,n),o=n.getTensorList(r.id);return o.pushBack(a),[o.idTensor]}case"TensorListPopBack":{const r=nf("tensorListId",e,t,n),a=nf("elementShape",e,t,n),o=nf("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,o)]}case"TensorListSplit":{const r=nf("tensor",e,t,n),a=nf("elementShape",e,t,n),o=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const o=Yf(e.shape.slice(1),n),s=0===r?0:e.size/r,i=ki((()=>{const n=[];e=$u(e,[1,r,s]);for(let r=0;r<t.length;++r){const i=[0,0===r?0:a[r-1],0],u=[1,t[r],s];n[r]=$u(Wu(e,i,u),o)}return e.dispose(),n})),u=new Qf([],n,e.dtype,t.length);for(let e=0;e<i.length;e++)u.setItem(e,i[e]);return u}(r,nf("lengths",e,t,n),a);return n.addTensorList(o),[o.idTensor]}case"TensorListLength":{const r=nf("tensorListId",e,t,n);return[Wl(n.getTensorList(r.id).size(),"int32")]}case"TensorListResize":{const r=nf("tensorListId",e,t,n),a=nf("size",e,t,n),o=n.getTensorList(r.id).resize(a);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"convolution":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Conv1D":{const a=nf("stride",e,t,n),o=nf("pad",e,t,n),s=nf("dataFormat",e,t,n).toUpperCase(),i=nf("dilation",e,t,n);return[r.conv1d(nf("x",e,t,n),nf("filter",e,t,n),a,o,s,i)]}case"Conv2D":{const a=nf("strides",e,t,n),o=uf(e,t,n),s=nf("dataFormat",e,t,n).toUpperCase(),i=nf("dilations",e,t,n);return[r.conv2d(nf("x",e,t,n),nf("filter",e,t,n),[a[1],a[2]],o,s,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=Jf(e,t,n);return[r.fused.conv2d({x:nf("x",e,t,n),filter:nf("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=Jf(e,t,n);return[r.fused.depthwiseConv2d({x:nf("x",e,t,n),filter:nf("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=nf("outputShape",e,t,n),o=nf("strides",e,t,n),s=uf(e,t,n);return[r.conv2dTranspose(nf("x",e,t,n),nf("filter",e,t,n),a,[o[1],o[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=nf("strides",e,t,n),o=uf(e,t,n),s=nf("dilations",e,t,n),i=nf("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(nf("input",e,t,n),nf("filter",e,t,n),[a[1],a[2]],o,i,[s[1],s[2]])]}case"Conv3D":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("dataFormat",e,t,n).toUpperCase(),i=nf("dilations",e,t,n);return[r.conv3d(nf("x",e,t,n),nf("filter",e,t,n),[a[1],a[2],a[3]],o,s,[i[1],i[2],i[3]])]}case"AvgPool":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("kernelSize",e,t,n);return[r.avgPool(nf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPool":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("kernelSize",e,t,n);return[r.maxPool(nf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPoolWithArgmax":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("kernelSize",e,t,n),i=nf("includeBatchInIndex",e,t,n),{result:u,indexes:l}=r.maxPoolWithArgmax(nf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o,i);return[u,l]}case"AvgPool3D":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("kernelSize",e,t,n);return[r.avgPool3d(nf("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"MaxPool3D":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("kernelSize",e,t,n);return[r.maxPool3d(nf("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"Dilation2D":{const a=nf("strides",e,t,n),o=nf("pad",e,t,n),s=nf("dilations",e,t,n),i=a[1],u=a[2],l=s[1],c=s[2];return[r.dilation2d(nf("x",e,t,n),nf("filter",e,t,n),[i,u],o,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Fill":{const a=nf("shape",e,t,n),o=nf("dtype",e,t,n),s=nf("value",e,t,n);return[r.fill(a,s,o)]}case"LinSpace":{const a=nf("start",e,t,n),o=nf("stop",e,t,n),s=nf("num",e,t,n);return[r.linspace(a,o,s)]}case"Multinomial":{const a=nf("logits",e,t,n),o=nf("numSamples",e,t,n),s=nf("seed",e,t,n);return[r.multinomial(a,o,s)]}case"OneHot":{const a=nf("indices",e,t,n),o=nf("depth",e,t,n),s=nf("onValue",e,t,n),i=nf("offValue",e,t,n),u=nf("dtype",e,t,n);return[r.oneHot(a,o,s,i,u)]}case"Ones":return[r.ones(nf("shape",e,t,n),nf("dtype",e,t,n))];case"OnesLike":return[r.onesLike(nf("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(nf("shape",e,t,n),nf("dtype",e,t,n),nf("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(nf("shape",e,t,n),nf("minval",e,t,n),nf("maxval",e,t,n),nf("dtype",e,t,n))];case"Range":{const a=nf("start",e,t,n),o=nf("stop",e,t,n),s=nf("step",e,t,n);return[r.range(a,o,s,nf("dtype",e,t,n))]}case"TruncatedNormal":{const a=nf("shape",e,t,n),o=nf("mean",e,t,n),s=nf("stdDev",e,t,n),i=nf("seed",e,t,n);return[r.truncatedNormal(a,o,s,nf("dtype",e,t,n),i)]}case"Zeros":return[r.zeros(nf("shape",e,t,n),nf("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(nf("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=Hf)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u,softNmsSigma:l}=Zf(e,t,n),c=await a.image.nonMaxSuppressionWithScoreAsync(r,o,s,i,u,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=Zf(e,t,n),l=nf("padToMaxOutputSize",e,t,n),c=await a.image.nonMaxSuppressionPaddedAsync(r,o,s,i,u,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=Zf(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,o,s,i,u)]}case"Where":{const r=a.cast(nf("condition",e,t,n),"bool"),o=[await a.whereAsync(r)];return r.dispose(),o}case"ListDiff":return a.setdiff1dAsync(nf("x",e,t,n),nf("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"LowerBound":{const a=nf("sortedSequence",e,t,n),o=nf("values",e,t,n);return[r.lowerBound(a,o)]}case"TopKV2":{const a=nf("x",e,t,n),o=nf("k",e,t,n),s=nf("sorted",e,t,n),i=r.topk(a,o,s);return[i.values,i.indices]}case"UpperBound":{const a=nf("sortedSequence",e,t,n),o=nf("values",e,t,n);return[r.upperBound(a,o)]}case"Unique":{const a=nf("x",e,t,n),o=r.unique(a);return[o.values,o.indices]}case"UniqueV2":{const a=nf("x",e,t,n),o=nf("axis",e,t,n),s=r.unique(a,o);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"ResizeBilinear":{const a=nf("images",e,t,n),o=nf("size",e,t,n),s=nf("alignCorners",e,t,n),i=nf("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[o[0],o[1]],s,i)]}case"ResizeNearestNeighbor":{const a=nf("images",e,t,n),o=nf("size",e,t,n),s=nf("alignCorners",e,t,n),i=nf("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[o[0],o[1]],s,i)]}case"CropAndResize":{const a=nf("image",e,t,n),o=nf("boxes",e,t,n),s=nf("boxInd",e,t,n),i=nf("cropSize",e,t,n),u=nf("method",e,t,n),l=nf("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,o,s,i,u,l)]}case"ImageProjectiveTransformV3":{const a=nf("images",e,t,n),o=nf("transforms",e,t,n),s=nf("outputShape",e,t,n),i=nf("fillValue",e,t,n),u=nf("interpolation",e,t,n),l=nf("fillMode",e,t,n);return[r.image.transform(a,o,u.toLowerCase(),l.toLowerCase(),i,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=nf("default",e,t,n);return[rf(e.name,t,n)||a];case"Placeholder":return[rf(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[lf(nf("x",e,t,n))];case"IdentityN":return nf("x",e,t,n).map((e=>lf(e)));case"Shape":return[r.tensor1d(nf("x",e,t,n).shape,"int32")];case"ShapeN":return nf("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(nf("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(nf("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const o=nf("x",e,t,n),s=nf("data",e,t,n),i=nf("message",e,t,n),u=nf("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(i);for(let e=0;e<s.length;e++)console.log(Array.prototype.slice.call(s[e].dataSync()).slice(0,u));return[o];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"logical":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Equal":return[r.equal(nf("a",e,t,n),nf("b",e,t,n))];case"NotEqual":return[r.notEqual(nf("a",e,t,n),nf("b",e,t,n))];case"Greater":return[r.greater(nf("a",e,t,n),nf("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(nf("a",e,t,n),nf("b",e,t,n))];case"Less":return[r.less(nf("a",e,t,n),nf("b",e,t,n))];case"LessEqual":return[r.lessEqual(nf("a",e,t,n),nf("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(nf("a",e,t,n),nf("b",e,t,n))];case"LogicalNot":return[r.logicalNot(nf("a",e,t,n))];case"LogicalOr":return[r.logicalOr(nf("a",e,t,n),nf("b",e,t,n))];case"Select":case"SelectV2":return[r.where(nf("condition",e,t,n),nf("a",e,t,n),nf("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(nf("a",e,t,n),nf("b",e,t,n),nf("transposeA",e,t,n),nf("transposeB",e,t,n))];case"Einsum":return[r.einsum(nf("equation",e,t,n),...nf("tensors",e,t,n))];case"Transpose":return[r.transpose(nf("x",e,t,n),nf("perm",e,t,n))];case"_FusedMatMul":const[a,o]=nf("fusedOps",e,t,n),s="biasadd"===a,i="prelu"===o,u=nf("numArgs",e,t,n),l=nf("leakyreluAlpha",e,t,n);if(s){if(i&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,p]=nf("args",e,t,n);return[r.fused.matMul({a:nf("a",e,t,n),b:nf("b",e,t,n),transposeA:nf("transposeA",e,t,n),transposeB:nf("transposeB",e,t,n),bias:c,activation:o,preluActivationWeights:p,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(nf("x",e,t,n),nf("axis",e,t,n),nf("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(nf("x",e,t,n),nf("mean",e,t,n),nf("variance",e,t,n),nf("offset",e,t,n),nf("scale",e,t,n),nf("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(nf("x",e,t,n),nf("radius",e,t,n),nf("bias",e,t,n),nf("alpha",e,t,n),nf("beta",e,t,n))];case"Softmax":return[r.softmax(nf("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(nf("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(nf("sparseIndices",e,t,n),nf("outputShape",e,t,n),nf("sparseValues",e,t,n),nf("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"ragged":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"RaggedGather":{const{outputNestedSplits:a,outputDenseValues:o}=r.raggedGather(nf("paramsNestedSplits",e,t,n),nf("paramsDenseValues",e,t,n),nf("indices",e,t,n),nf("outputRaggedRank",e,t,n));return a.concat(o)}case"RaggedRange":{const{rtNestedSplits:a,rtDenseValues:o}=r.raggedRange(nf("starts",e,t,n),nf("limits",e,t,n),nf("splits",e,t,n));return[a,o]}case"RaggedTensorToTensor":return[r.raggedTensorToTensor(nf("shape",e,t,n),nf("values",e,t,n),nf("defaultValue",e,t,n),nf("rowPartitionTensors",e,t,n),nf("rowPartitionTypes",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Max":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.max(nf("x",e,t,n),a,o)]}case"Mean":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.mean(nf("x",e,t,n),a,o)]}case"Min":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.min(nf("x",e,t,n),a,o)]}case"Sum":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.sum(nf("x",e,t,n),a,o)]}case"All":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.all(nf("x",e,t,n),a,o)]}case"Any":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.any(nf("x",e,t,n),a,o)]}case"ArgMax":{const a=nf("axis",e,t,n);return[r.argMax(nf("x",e,t,n),a)]}case"ArgMin":{const a=nf("axis",e,t,n);return[r.argMin(nf("x",e,t,n),a)]}case"Prod":{const a=nf("axis",e,t,n),o=nf("keepDims",e,t,n);return[r.prod(nf("x",e,t,n),a,o)]}case"Cumprod":{const a=nf("axis",e,t,n),o=nf("exclusive",e,t,n),s=nf("reverse",e,t,n);return[r.cumprod(nf("x",e,t,n),a,o,s)]}case"Cumsum":{const a=nf("axis",e,t,n),o=nf("exclusive",e,t,n),s=nf("reverse",e,t,n);return[r.cumsum(nf("x",e,t,n),a,o,s)]}case"Bincount":const a=nf("x",e,t,n),o=nf("weights",e,t,n),s=nf("size",e,t,n);return[r.bincount(a,o,s)];case"DenseBincount":{const a=nf("x",e,t,n),o=nf("weights",e,t,n),s=nf("size",e,t,n),i=nf("binaryOutput",e,t,n);return[r.denseBincount(a,o,s,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=nf("n",e,t,n),o=nf("axis",e,t,n);let s=nf("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,o)]}case"Gather":{const a=nf("x",e,t,n),o=nf("indices",e,t,n);return[r.gather(a,r.cast(o,"int32"),0)]}case"GatherV2":{const a=nf("axis",e,t,n),o=nf("batchDims",e,t,n),s=nf("x",e,t,n),i=nf("indices",e,t,n);return[r.gather(s,r.cast(i,"int32"),a,o)]}case"Reverse":{const a=nf("dims",e,t,n),o=[];for(let e=0;e<a.length;e++)a[e]&&o.push(e);const s=nf("x",e,t,n);return[r.reverse(s,o)]}case"ReverseV2":{const a=nf("axis",e,t,n),o=nf("x",e,t,n);return[r.reverse(o,a)]}case"Slice":{const a=nf("begin",e,t,n),o=nf("size",e,t,n);return[r.slice(nf("x",e,t,n),a,o)]}case"StridedSlice":{const a=nf("begin",e,t,n),o=nf("end",e,t,n),s=nf("strides",e,t,n),i=nf("beginMask",e,t,n),u=nf("endMask",e,t,n),l=nf("ellipsisMask",e,t,n),c=nf("newAxisMask",e,t,n),p=nf("shrinkAxisMask",e,t,n),h=nf("x",e,t,n);return[r.stridedSlice(h,a,o,s,i,u,l,c,p)]}case"Pack":return ki((()=>{const a=nf("axis",e,t,n),o=nf("tensors",e,t,n),s=o[0].shape,i=r.squeeze(o[0]).shape,u=o.map((e=>{const t=st(e.shape,s);if(!t&&!st(r.squeeze(e).shape,i))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=nf("axis",e,t,n),o=nf("tensor",e,t,n);return r.unstack(o,a)}case"Tile":{const a=nf("reps",e,t,n);return[r.tile(nf("x",e,t,n),a)]}case"Split":case"SplitV":{const a=nf("axis",e,t,n),o=nf("numOrSizeSplits",e,t,n),s=nf("x",e,t,n);return r.split(s,o,a)}case"ScatterNd":{const a=nf("indices",e,t,n),o=nf("values",e,t,n),s=nf("shape",e,t,n);return[r.scatterND(a,o,s)]}case"GatherNd":{const a=nf("x",e,t,n),o=nf("indices",e,t,n);return[r.gatherND(a,o)]}case"SparseToDense":{const a=nf("sparseIndices",e,t,n),o=nf("outputShape",e,t,n),s=nf("sparseValues",e,t,n),i=nf("defaultValue",e,t,n);return[r.sparseToDense(a,s,o,s.dtype===i.dtype?i:r.cast(i,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:o,emptyRowIndicator:s,reverseIndexMap:i}=r.sparse.sparseFillEmptyRows(nf("indices",e,t,n),nf("values",e,t,n),nf("denseShape",e,t,n),nf("defaultValue",e,t,n));return[a,o,s,i]}case"SparseReshape":{const{outputIndices:a,outputShape:o}=r.sparse.sparseReshape(nf("inputIndices",e,t,n),nf("inputShape",e,t,n),nf("newShape",e,t,n));return[a,o]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(nf("data",e,t,n),nf("indices",e,t,n),nf("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(nf("data",e,t,n),nf("indices",e,t,n),nf("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"FFT":return[r.fft(nf("x",e,t,n))];case"IFFT":return[r.ifft(nf("x",e,t,n))];case"RFFT":return[r.rfft(nf("x",e,t,n))];case"IRFFT":return[r.irfft(nf("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:o}=r.string.stringNGrams(nf("data",e,t,n),nf("dataSplits",e,t,n),nf("separator",e,t,n),nf("nGramWidths",e,t,n),nf("leftPad",e,t,n),nf("rightPad",e,t,n),nf("padWidth",e,t,n),nf("preserveShortSequences",e,t,n));return[a,o]}case"StringSplit":{const{indices:a,values:o,shape:s}=r.string.stringSplit(nf("input",e,t,n),nf("delimiter",e,t,n),nf("skipEmpty",e,t,n));return[a,o,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(nf("input",e,t,n),nf("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=Hf)=>{switch(e.op){case"Cast":return[r.cast(nf("x",e,t,n),nf("dtype",e,t,n))];case"ExpandDims":{const a=nf("axis",e,t,n);return[r.expandDims(nf("x",e,t,n),a)]}case"Squeeze":{const a=nf("axis",e,t,n);return[r.squeeze(nf("x",e,t,n),a)]}case"Reshape":return[r.reshape(nf("x",e,t,n),nf("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(nf("x",e,t,n),nf("padding",e,t,n),nf("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(nf("x",e,t,n),nf("padding",e,t,n),nf("constantValue",e,t,n))];case"SpaceToBatchND":{const a=nf("blockShape",e,t,n),o=nf("paddings",e,t,n);return[r.spaceToBatchND(nf("x",e,t,n),a,o)]}case"BatchToSpaceND":{const a=nf("blockShape",e,t,n),o=nf("crops",e,t,n);return[r.batchToSpaceND(nf("x",e,t,n),a,o)]}case"DepthToSpace":{const a=nf("blockSize",e,t,n),o=nf("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(nf("x",e,t,n),a,o)]}case"BroadcastTo":return[r.broadcastTo(nf("x",e,t,n),nf("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(nf("s0",e,t,n),nf("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=r.getHashTableHandleByName(e.name);if(null!=a)return[a];{const a=nf("keyDType",e,t,n),o=nf("valueDType",e,t,n),s=new em(a,o);return r.addHashTable(e.name,s),[s.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const a=nf("tableHandle",e,t,n,r),o=nf("keys",e,t,n),s=nf("values",e,t,n),i=r.getHashTableById(a.id);return[await i.import(o,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=nf("tableHandle",e,t,n,r),o=nf("keys",e,t,n),s=nf("defaultValue",e,t,n),i=r.getHashTableById(a.id);return[await i.find(o,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=nf("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const o=tf(e.op);if(o&&o.customExecutor)return o.customExecutor(new jf(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return Nt(o)?o.then((e=>[].concat(e))):[].concat(o)}class nm{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t<this.contexts.length-1;t++){const n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map((e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function rm(e,t,n,r){const a=new Set,o=[];let s=null,i=null;const u=new Set,l=Object.keys(e).map((e=>sf(e)[0]));let c=[];null!=r&&(c=r.map((e=>sf(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(im(e)||um(e)||lm(e))&&null==s&&(s=e,i=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):o.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:o,dynamicNode:s,syncInputs:i}}const am=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],om=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],sm=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function im(e){return am.indexOf(e.op)>=0}function um(e){return om.indexOf(e.op)>=0}function lm(e){return sm.indexOf(e.op)>=0}class cm{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new cm(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=rm(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:o}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${o}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,o=[],s=Object.keys(a).map((e=>sf(e)[0])).map((t=>e.nodes[t])),i=e.initNodes;s.forEach((e=>{r.has(e.name)&&o.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&o.push(e)})),null!=i&&i.forEach((e=>{r.has(e.name)&&o.push(e)}));const u=new Set,l=[];for(;o.length>0;){const e=o.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&o.push(e)}))}return l}(this.graph,this.weightMap,n)}cloneAndKeepTensor(e){if(null==e)return null;const t=e.clone();return Si(t),t}cloneTensorList(e){return e?e.map((e=>this.cloneAndKeepTensor(e))):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.cloneTensorList(t)])))}execute(e,t){this.disposeIntermediateTensors(),e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[sf(e)[0]])),a=t.map((e=>sf(e)[0]));let o=a.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const s=this.getCompilationKey(r,o);let i=this.compiledMap.get(s);null==i&&(i=this.compile(e,o),this.compiledMap.set(s,i));try{this.keepIntermediateTensors=Mt().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const u={},l={};return ki((()=>{const n=new nm(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach((t=>{const[n,a]=sf(t),o=[];o[a]=e[t],r[n]=o,this.keepIntermediateTensors&&(this.clonedTensorsMap[n]=this.cloneTensorList(o))}));const o=this.getFrozenTensorIds(r),s={};for(let e=0;e<i.length;e++){const t=i[e];if(!r[t.name]){const e=tm(t,r,n,this._resourceManager);if(Nt(e))throw new Error(`The execution of the op '${t.op}' returned a promise. Please use model.executeAsync() instead.`);r[t.name]=e,this.keepIntermediateTensors&&(this.clonedTensorsMap[t.name]=this.cloneTensorList(e)),this.checkTensorForDisposal(t.name,t,r,n,o,a,s)}}return null==this.parent&&n.dispose(o),t.map((e=>rf(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,o,s){"control"!==t.category&&-1===o.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const t=function(e,t,n){return t[of(e,n.currentContextId)]}(e.name,n,r);null!=t&&t.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const t=s[e.id];1===t?(e.dispose(),delete s[e.id]):null!=t&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((e=>{for(const t of e)t&&!t.isDisposed&&t.dispose()})),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,n=!1,r={},a={}){this.disposeIntermediateTensors(),n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=Mt().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const o=new nm(this.weightMap,r,a,this.functionExecutorMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const s=await this.executeWithControlFlow(e,o,t,n),i=t.map((e=>rf(e,s,o))),u=i.map((e=>e.id)),l=Object.keys(e).map((t=>e[t].id)),c=new Set([...u,...l,...this.weightIds]);return Object.values(s).forEach((e=>{e.forEach((e=>{!e||e.isDisposed||c.has(e.id)||e.dispose()}))})),null==this.parent&&o.dispose(c),i}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),o=a.map((e=>this.graph.nodes[sf(e)[0]])),s=n.map((e=>sf(e)[0]));let i=s.map((e=>this.graph.nodes[e]));0===i.length&&(i=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=rm(e,i,this.weightMap,this._initNodes),h=[...o,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),d=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=sf(t),a=[];a[r]=e[t],d[n]=a}));const f={},m=this.getFrozenTensorIds(d),g={};for(;h.length>0;){const e=this.processStack(o,h,t,d,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=i.filter((e=>!im(e)&&!rf(e.name,d,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return d}processStack(e,t,n,r,a,o,s,i,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&nf("isConstant",e.node,r,n)&&([c]=af(e.node.name,n)),null==r[e.node.name]){const p=tm(e.node,r,n,this._resourceManager);c||([c]=af(e.node.name,n));const h=n.currentContext;Nt(p)?l.push(p.then((l=>(r[c]=l,this.keepIntermediateTensors&&(this.clonedTensorsMap[c]=this.cloneTensorList(l)),n.currentContext=h,this.checkTensorForDisposal(c,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[c]=this.cloneTensorList(p)),this.checkTensorForDisposal(c,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,o){e.children.forEach((e=>{const[s]=af(e.name,n);!a[s]&&o.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!rf(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!rf(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=sf(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value;nt(e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t)),(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&nt(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){var t,n;const r={};for(const a in e){const o=null===(n=null===(t=this._signature)||void 0===t?void 0:t.inputs)||void 0===n?void 0:n[a];null!=o?r[o.name]=e[a]:r[a]=e[a]}return r}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=sf(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>{var t,n;const r=null===(n=null===(t=this._signature)||void 0===t?void 0:t.outputs)||void 0===n?void 0:n[e];return null!=r?r.name:e}),{})}checkOutputs(e){e.forEach((e=>{const[t]=sf(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class pm{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class hm{constructor(e,t={},n=bi){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new pm}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return Nt(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new cm(Af.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=Af.Instance.transformGraph(e.modelInitializer);this.initializer=new cm(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}addStructuredOutputNames(e){if(this.structuredOutputKeys){const t={};return(e instanceof ja?[e]:e).forEach(((e,n)=>t[this.structuredOutputKeys[n]]=e)),t}return e}predict(e,t){const n=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(n)}async predictAsync(e,t){const n=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(n)}normalizeInputs(e){var t;if(!(e instanceof ja||Array.isArray(e))){const n=null===(t=this.signature)||void 0===t?void 0:t.inputs;if(null!=n)for(const t in n){const r=n[t];null!=r.resourceId&&(e[t]=this.resourceIdToCapturedInput[r.resourceId])}return e}e=Array.isArray(e)?e:[e];const n=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+n!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-n} non-resource placeholders, while there are ${e.length} input tensors provided.`);let r=0;return this.inputNodes.reduce(((t,n)=>{var a,o,s;const i=null===(s=null===(o=null===(a=this.signature)||void 0===a?void 0:a.inputs)||void 0===o?void 0:o[n])||void 0===s?void 0:s.resourceId;return t[n]=null!=i?this.resourceIdToCapturedInput[i]:e[r++],t}),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){const t=this.initializerSignature.outputs,n=Object.keys(t);for(let r=0;r<n.length;r++){const a=t[n[r]];this.resourceIdToCapturedInput[a.resourceId]=e[r]}}}execute(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&Ti(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function dm(e,t={},n=bi){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}model.json?tfjs-format=file`}(e));const r=new hm(e,t,n);return await r.load(),r}function fm(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&nt("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const mm=rh;class gm extends Qe{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new Xe(this,_i())}nextDataId(){return gm.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Mt().get("IS_NODE")&&Mr("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&bt(n[0])){const a=n.map((e=>Aa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?Fd(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):function(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw new Error(`Unknown dtype ${t}`)}(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Na(e)));return Ju(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Ju(e.shape,e.dtype,t)}makeOutput(e,t,n){return _i().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Ca();return e(),{kernelMs:Ca()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){fm([e],"where");const t=this.readSync(e.dataId);return mm(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function ym(e){return(t,n,r,a,o)=>{const s=$i(t,n),i=s.length,u=_t(s),l=ft(o,ot(s)),c=t.length,p=n.length,h=_t(t),d=_t(n),f=Oi(t,s),m=Oi(n,s);if(f.length+m.length===0)for(let t=0;t<l.length;++t)l[t]=e(r[t%r.length],a[t%a.length]);else for(let t=0;t<l.length;++t){const n=At(t,i,u),o=n.slice(-c);f.forEach((e=>o[e]=0));const s=Ct(o,c,h),g=n.slice(-p);m.forEach((e=>g[e]=0));const y=Ct(g,p,d);l[t]=e(r[s],a[y])}return[l,s]}}function bm(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,i=n.makeTensorInfo(r.shape,"complex64");return n.data.get(i.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",o),imag:n.makeTensorInfo(a.shape,"float32",s)},i}function vm(e,t,n="float32"){if("complex64"===n)return bm({inputs:{real:vm(e,t,"float32"),imag:vm(e,t,"float32")},backend:e});const r=Et(ot(t),n);return e.makeTensorInfo(t,n,r)}function wm(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}gm.nextDataId=0;const xm={kernelName:wn,backendName:"cpu",kernelFunc:wm};function _m(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,o=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,o)}function km(e,t,n,r){if("int32"===r)return[t,"int32",Int32Array.from(e)];if("bool"===r){const r=Ia([0],n),[a,o]=ym(((e,t)=>e!==t?1:0))(t,[],e,r,"bool");return[o,"bool",a]}throw new Error(`Error in Cast: failed to cast ${n} to ${r}`)}function Tm(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:o}=r;if("complex64"===o){if("complex64"===a.dtype)return wm({inputs:{x:a},backend:n});const e=vm(n,a.shape,a.dtype),t=Tm({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=bm({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=_m({inputs:{input:a},backend:n}),t=Tm({inputs:{x:e},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(e),t}if(!gt(a.dtype,o)){const e=wm({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:o}}const s=n.data.get(a.dataId).values,[i,u,l]=km(s,a.shape,a.dtype,o);return n.makeTensorInfo(i,u,l)}const Sm={kernelName:Kt,backendName:"cpu",kernelFunc:Tm};function Em(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:o,b:s}=n,i=a;fm([o,s],e);const u=i.data.get(o.dataId).values,l=i.data.get(s.dataId).values,c="string"===o.dtype?Kd(u):u,p="string"===o.dtype?Kd(l):l,h=r||o.dtype,[d,f]=t(o.shape,s.shape,c,p,h);return i.makeTensorInfo(f,h,d)}:({inputs:e,backend:a})=>{const{a:o,b:s}=e,i=a;if("complex64"===o.dtype||"complex64"===s.dtype){const e=Tm({inputs:{x:o},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=i.data.get(r.dataId).values,l=i.data.get(a.dataId).values,c=Tm({inputs:{x:s},backend:i,attrs:{dtype:"complex64"}}),p=i.data.get(c.dataId),h=p.complexTensorInfos.real,d=p.complexTensorInfos.imag,f=i.data.get(h.dataId).values,m=i.data.get(d.dataId).values,[g,y,b]=n(o.shape,s.shape,u,l,f,m),v=i.makeTensorInfo(b,"float32",g),w=i.makeTensorInfo(b,"float32",y),x=bm({inputs:{real:v,imag:w},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(c),i.disposeIntermediateTensorInfo(v),i.disposeIntermediateTensorInfo(w),x}{const e=i.data.get(o.dataId).values,n=i.data.get(s.dataId).values,a=r||o.dtype,[u,l]=t(o.shape,s.shape,e,n,a);return i.makeTensorInfo(l,a,u)}}}function Im(e){return(t,n,r,a,o,s)=>{const i=$i(t,n),u=ot(i),l=i.length,c=_t(i),p=ft("float32",u),h=ft("float32",u),d=Oi(t,i),f=Oi(n,i),m=Fd(r,a),g=Fd(o,s),y=t.length,b=_t(t),v=n.length,w=_t(n);if(d.length+f.length===0)for(let t=0;t<p.length;t++){const n=t%m.length,r=t%g.length,a=e(m[2*n],m[2*n+1],g[2*r],g[2*r+1]);p[t]=a.real,h[t]=a.imag}else for(let t=0;t<p.length;t++){const n=At(t,l,c),r=n.slice(-y);d.forEach((e=>r[e]=0));const a=Ct(r,y,b),o=n.slice(-v);f.forEach((e=>o[e]=0));const s=Ct(o,v,w),i=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);p[t]=i.real,h[t]=i.imag}return[p,h,i]}}const Cm=ym(((e,t)=>e+t)),Am=Im(((e,t,n,r)=>({real:e+n,imag:t+r}))),Nm=Em(Bt,Cm,Am),Rm={kernelName:Bt,backendName:"cpu",kernelFunc:Nm};function Fm(e){return(t,n,r)=>{const a=ft(n,t.length);for(let n=0;n<t.length;++n)a[n]=e(t[n],r);return a}}function Om(e,t,n){return({inputs:r,attrs:a,backend:o})=>{const{x:s}=r;if(fm(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const i=o,u=i.data.get(s.dataId).values,l=ot(s.shape),c=n||s.dtype,p=mt(c,l);for(let e=0;e<l;++e)p[e]=t(u[e],a);return i.makeTensorInfo(s.shape,c,p)}}const Mm=Fm((e=>Math.ceil(e)));function $m(e,t,n,r){const a=mt(n,ot(t));if(r&&"string"!==n){let t=0;e.forEach((e=>{const n=ot(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const o="string"===n?Kd(e.vals):e.vals;let s=0;for(let n=0;n<e.shape[0];++n){const i=n*t[1]+r;for(let t=0;t<e.shape[1];++t)a[i+t]=o[s++]}r+=e.shape[1]}))}return a}const Dm=ym(((e,t)=>e===t?1:0)),Pm=Fm((e=>Math.exp(e))),Lm=(Bm=Pm,"float32",({inputs:e,attrs:t,backend:n})=>{const{x:r}=e;if(fm(r,"Exp"),"string"===r.dtype)throw new Error("unaryKernelFunc does not support string input/output");const a=n,o=a.data.get(r.dataId).values,s="float32",i=Bm(o,s,t);return a.makeTensorInfo(r.shape,s,i)});var Bm;const Um=Fm((e=>Math.expm1(e))),Wm=Fm((e=>Math.floor(e))),Vm=ym(((e,t)=>e>t?1:0)),zm=ym(((e,t)=>e>=t?1:0)),jm=ym(((e,t)=>e<t?1:0)),Hm=ym(((e,t)=>e<=t?1:0)),Gm=Fm((e=>Math.log(e)));function Km(e,t,n,r){const a=ft(r,ot(n));for(let n=0;n<a.length;++n){const r=n*t;let o=e[r];for(let n=0;n<t;++n){const t=e[r+n];(Number.isNaN(t)||t>o)&&(o=t)}a[n]=o}return a}const qm=ym(((e,t)=>Math.max(e,t))),Ym=ym(((e,t)=>Math.min(e,t))),Xm=ym(((e,t)=>e*t)),Qm=Im(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),Jm=Em($n,Xm,Qm),Zm={kernelName:$n,backendName:"cpu",kernelFunc:Jm},eg=ym(((e,t)=>e!==t?1:0));function tg(e,t,n,r,a){const o=t.length,s=ot(t),i=_t(t),u=_t(a),l=ft(n,ot(a));for(let t=0;t<s;++t){const n=At(t,o,i),a=new Array(n.length);for(let e=0;e<a.length;e++)a[e]=n[r[e]];l[Ct(a,o,u)]=e[t]}return l}function ng(e){const{inputs:t,attrs:n,backend:r}=e,{x:a}=t,{perm:o}=n;fm(a,"transpose");const s=a.shape.length,i=new Array(s);for(let e=0;e<i.length;e++)i[e]=a.shape[o[e]];const u=tg(r.data.get(a.dataId).values,a.shape,a.dtype,o,i);return{dataId:r.write(u,i,a.dtype),shape:i,dtype:a.dtype}}function rg(e,t){const n=e.slice(0,t);for(;n.length<t;)n.push(1);for(let r=t;r<e.length;r++)n[t-1]*=e[r];return n}var ag=wd;class og{constructor(e,t,n,r,a,o,s,i,u,l){this.shape=e,this.shapeShape=t,this.values=n,this.valuesShape=r,this.valuesDType=a,this.defaultValue=o,this.defaultValueShape=s,this.rowPartitionValues=i,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=_d(l),this.raggedRank=kd(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===ag.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===ag.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case ag.VALUE_ROWIDS:return og.getMaxWidthValueRowID(t);case ag.ROW_SPLITS:return og.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${ag[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(0===t||1===t)return 0;let n=0;for(let r=0;r<t-1;++r){const t=e[r+1]-e[r];t>n&&(n=t)}return n}static getMaxWidthValueRowID(e){const t=e.length;if(0===t)return 0;let n=0,r=e[0],a=0;for(let o=1;o<t;++o){const t=e[o];t!==r&&(r=t,a=Math.max(o-n,a),n=o)}return Math.max(t-n,a)}tensorShapeFromTensor(e,t,n=!0){if(0===t.length){if(-1===e[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return ig(e,n)}calculateOutputSize(e){const t=this.valuesShape;Td(this.defaultValueShape,t);const n=this.tensorShapeFromTensor(this.shape,this.shapeShape),r=xd(this.raggedRank,n,t);r[0]<0&&(r[0]=e);for(let e=1;e<=this.raggedRank;++e)r[e]<0&&(r[e]=this.getMaxWidth(e));return r}calculateFirstParentOutputIndex(e,t,n){const r=Math.min(e,n),a=[];let o=0;for(let e=0;e<r;++e,o+=t)a.push(o);for(let t=r;t<e;++t)a.push(-1);return nt(a.length===e,(()=>"Final length of result must be equal to firstDimension.")),a}calculateOutputIndexRowSplit(e,t,n,r){const a=e.length,o=[];for(let s=0;s<a-1;++s){const a=e[s+1]-e[s];let i=Math.min(r,a),u=t[s];-1===u&&(i=0);for(let e=0;e<i;++e)o.push(u),u+=n;for(let e=0;e<a-i;++e)o.push(-1)}if(a>0&&o.length!==e[a-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,n,r){const a=e.length,o=[];if(0===a)return[];let s=0,i=e[0];if(i>=t.length)throw new Error(`Got currentValueRowId=${i}, which is not less than ${t.length}`);let u=t[i];o.push(u);for(let l=1;l<a;++l){const a=e[l];if(a===i)u>=0&&(++s,s<r?u+=n:u=-1);else{if(s=0,i=a,a>=t.length)throw new Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);u=t[a]}o.push(u)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,n,r){const a=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case ag.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,n,r);case ag.ROW_SPLITS:if(a.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${a.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(a,t,n,r);default:throw new Error(`Unsupported partition type: ${ag[o]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case ag.FIRST_DIM_SIZE:return e[0];case ag.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case ag.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${ag[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let e=n.length-2;e>=0;--e)n[e]=n[e+1]*t[e+1];const r=ig(t,!1),a=mt(this.valuesDType,ot(r));if(n[0]*t[0]>0){let o=this.calculateFirstParentOutputIndex(e,n[0],t[0]);for(let e=1;e<=this.raggedRank;++e)o=this.calculateOutputIndex(e-1,o,n[e],t[e]);this.setOutput(this.raggedRank,o,a,r)}return[r,a]}setOutput(e,t,n,r){if(0===n.length)return;const a=this.values,o=n;let s=r.slice();s=s.slice(e+1);const i=ot(s),u=t.length;let l=this.defaultValue;if(l.length!==i&&1!==l.length){const e=this.defaultValueShape;ki((()=>{const t=$u(l,e),n=Qu(t,s);l=n.dataSync()}))}let c=0,p=0,h=0;for(let e=0;e<=u;++e){let r=e<u?t[e]:-1;if(r!==h){if(p<h){const e=a.subarray(c*i);sg(o.subarray(p*i),e,(h-p)*i)}if(e>=u){const e=n.length;r=Math.floor(e/i)}if(r>h)if(1===this.defaultValue.length)o.subarray(h*i,r*i).fill(this.defaultValue[0]),h=r;else for(;r>h;)sg(o.slice(h*i),l,i),++h;r<0?(c=e+1,p=h):(c=e,p=h,h=p+1)}else++h}}}function sg(e,t,n){for(let r=0;r<n;r++)e[r]=t[r]}function ig(e,t){const n=[];for(let r of e){if(r<0){if(!t)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}n.push(r)}return n}function ug(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return Et(0,r);const a=Et(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),a[0]=e;for(let e=1;e<a.length;e++)a[e]=a[e-1]+n;return a}const lg=Fm((e=>1/Math.sqrt(e))),cg=Fm((e=>1/(1+Math.exp(-e)))),pg=Om(or,(e=>1/(1+Math.exp(-e)))),hg={kernelName:or,backendName:"cpu",kernelFunc:pg};function dg(e,t,n,r,a){const o=Zi(r,t,n),s=ot(n),i=_t(r);if(o){const n=eu(t,i);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=Ju(r,a,"string"===a?Kd(e):e),l=Ju(n,a);for(let e=0;e<l.size;++e){const n=l.indexToLoc(e),r=n.map(((e,n)=>e+t[n]));l.set(u.get(...r),...n)}return"string"===a?qd(l.values):l.values}function fg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:o,size:s}=r;fm(a,"slice");const[i,u]=tu(a,o,s);zi(a,i,u);const l=dg(n.data.get(a.dataId).values,i,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const mg={kernelName:ar,backendName:"cpu",kernelFunc:fg},gg=Fm((e=>Math.sqrt(e))),yg=ym(((e,t)=>{const n=e-t;return n*n}));function bg(e,t,n,r){const a=Ju(e,t.dtype);for(let e=0;e<a.size;e++){const o=a.indexToLoc(e),s=new Array(o.length);for(let e=0;e<s.length;e++)s[e]=o[e]*n[e]+r[e];a.set(t.get(...s),...o)}return a}class vg{constructor(e,t,n,r,a,o){this.separator=Aa(e),this.nGramWidths=t,this.leftPad=Aa(n),this.rightPad=Aa(r),this.padWidth=a,this.preserveShort=o}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,o){for(let s=0;s<a;++s){const i=this.getPadWidth(o),u=Math.max(0,i-s),l=Math.max(0,i-(a-(s+1))),c=o-(u+l),p=t+(u>0?0:s-i);let h=0;h+=u*this.leftPad.length;for(let t=0;t<c;++t)h+=e[p+t].length;h+=l*this.rightPad.length,h+=(u+l+c-1)*this.separator.length,n[r+s]=new Uint8Array(h);const d=n[r+s];let f=0;const m=e=>e.forEach((e=>d[f++]=e));for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<c-1;++t)m(e[p+t]),m(this.separator);if(c>0){m(e[p+c-1]);for(let e=0;e<l;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<l-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){const n=e.length,r=t.length;if(r>0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a<r;++a){let r=t[a]>=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,o=mt("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)o[e]=0;return[e,o]}o[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),o[e]=o[e-1]+r}const s=new Array(o[a]);for(let n=0;n<a;++n){const r=t[n];let a=o[n];if(this.nGramWidths.forEach((o=>{const i=t[n+1]-t[n],u=this.getNumNGrams(i,o);this.createNGrams(e,r,s,a,u,o),a+=u})),this.preserveShort&&a===o[n]){const o=t[n+1]-t[n];if(0===o)continue;const i=o+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,i)}}return[s,o]}}function wg(e,t,n,r,a,o,s,i){return new vg(n,r,a,o,s,i).compute(e,t)}function xg(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)r.push(e.subarray(t,t+1));return}if(1===t.length){const a=t[0];let o=e.indexOf(a);for(;-1!==o;){const t=e.subarray(0,o);n&&0===t.length||r.push(t),o=(e=e.subarray(o+1)).indexOf(a)}return void(n&&0===e.length||r.push(e))}let a=0;for(let o=0;o<e.length+1;o++)if(o===e.length||-1!==t.indexOf(e[o])){const t=e.subarray(a,o);n&&0===t.length||r.push(t),a=o+1}}function _g(e,t,n){const r=e.length,a=[];let o=0,s=0;const i=new Array(r);for(let u=0;u<r;++u){const r=a.length;xg(e[u],t,n,a);const l=a.length-r;i[u]=l,o+=l,s=Math.max(s,l)}const u=mt("int32",2*o),l=new Array(o),c=[r,s];let p=0;for(let e=0;e<r;++e)for(let t=0;t<i[e];++t)u[2*p]=e,u[2*p+1]=t,l[p]=a[p],++p;return[u,l,c]}function kg(e,t){const n=mt("int32",e.length);for(let r=0;r<e.length;++r)n[r]=Sa(e[r]).modulo(t).getLowBitsUnsigned();return n}const Tg=ym(((e,t)=>e-t)),Sg=Im(((e,t,n,r)=>({real:e-n,imag:t-r}))),Eg=Em(wr,Tg,Sg),Ig={kernelName:wr,backendName:"cpu",kernelFunc:Eg},Cg=(e,t)=>{const n=t.value-e.value;return 0===n?e.index-t.index:n};function Ag(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,o=t-n+1,s=Math.log(a),i=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*i*(a-i)/a)*Math.sign(o-a/2);Ag(e,t,Math.max(n,Math.floor(t-o*i/a+u)),Math.min(r,Math.floor(t+(a-o)*i/a+u)))}const a=e[t];let o=n,s=r;for(tt(e,n,t),Cg(e[r],a)>0&&tt(e,n,r);o<s;){for(tt(e,o,s),o++,s--;Cg(e[o],a)<0;)o+=1;for(;Cg(e[s],a)>0;)s-=1}0===Cg(e[n],a)?tt(e,n,s):(s+=1,tt(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}var Ng=Object.freeze({__proto__:null,simpleAbsImpl:function(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t},addImpl:Cm,bincountImpl:function(e,t,n,r,a){const o=ot(r),s=Et(a,n);for(let n=0;n<e.length;n++){const r=e[n];if(r<0)throw new Error("Input x must be non-negative!");r>=a||(s[r]+=o>0?t[n]:1)}return s},bincountReduceImpl:function(e,t,n,r=!1){const a=e.shape[0],o=e.shape[1],s=Ju([a,n],t.dtype);for(let i=0;i<a;i++)for(let a=0;a<o;a++){const o=e.get(i,a);if(o<0)throw new Error("Input x must be non-negative!");o>=n||(r?s.set(1,i,o):t.size>0?s.set(s.get(i,o)+t.get(i,a),i,o):s.set(s.get(i,o)+1,i,o))}return s},castImpl:km,ceilImpl:Mm,concatImpl:$m,equalImpl:Dm,expImpl:Pm,expm1Impl:Um,floorImpl:Wm,gatherNdImpl:function(e,t,n,r,a,o,s,i,u){const l=Ju([r,o],n);for(let n=0;n<r;n++){const r=[];let c=0;for(let t=0;t<a;t++){const o=e[n*a+t];c+=o*s[t],r.push(o)}if(c<0||c>=u/o)throw new Error(`Invalid indices: ${r} does not index into ${i}`);for(let e=0;e<o;e++)l.values[n*o+e]=t.get(...t.indexToLoc(c*o+e))}return l},gatherV2Impl:function(e,t,n){const r=Ju(n,e.dtype);for(let n=0;n<r.size;++n){const a=r.indexToLoc(n).slice(),o=a[0],s=a[2],i=t.locToIndex([o,s]);a[2]=t.values[i];const u=e.locToIndex(a);0<=u&&u<e.values.length&&(r.values[n]=e.values[u])}return r},greaterImpl:Vm,greaterEqualImpl:zm,lessImpl:jm,lessEqualImpl:Hm,linSpaceImpl:function(e,t,n){const r=(t-e)/(n-1),a=Et(n,"float32");a[0]=e;for(let e=1;e<a.length;e++)a[e]=a[e-1]+r;return a},logImpl:Gm,maxImpl:Km,maximumImpl:qm,minimumImpl:Ym,multiplyImpl:Xm,negImpl:function(e,t,n){const r=Ea(-1,n);return Xm([],t,r,e,n)},notEqualImpl:eg,prodImpl:function(e,t,n,r){const[a,o]=Fl(e,r),s=Ja(t,"int32"),i=Et(ot(a),s),u=ot(o);for(let e=0;e<i.length;++e){const t=e*u;let r=1;for(let e=0;e<u;++e)r*=n[t+e];i[e]=r}return{outVals:i,outShape:a,outDtype:s}},raggedGatherImpl:function(e,t,n,r,a,o,s,i){if(0===e.length)throw new Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw new Error("Split tensors must not be scalars");if(function(e,t,n){e.forEach(((e,r)=>{if(e<0||e>=n){const a=At(r,t.length,_t(t)).join(",");throw new Error(`indices[${a}] = ${e} is not in [0, ${n})`)}}))}(o,s,t[0][0]-1),0===r.length)throw new Error("params.rank must be nonzero");const u=r[0],{outSplits:l,valueSlices:c,numValues:p}=function(e,t,n,r){const a=[];let o=0;const s=t.length-1+n.length,i=new Array(s).fill(null).map((()=>[0]));!function(e,t){for(let n=0;n<e.length;++n){const r=e[n],a=n===e.length-1?t:e[n+1].length;if(0===r.length)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(let e=1;e<r.length;++e)if(r[e-1]>r[e])throw new Error("Ragged splits must be sorted in ascending order")}}(n,r);let u=1;for(let e=0;e<t.length-1;++e){u*=t[e];const n=t[e+1];for(let t=1;t<u+1;++t)i[e].push(t*n)}for(let r=0;r<e.length;++r){let s=e[r],u=e[r]+1;for(let e=0;e<n.length;++e){const r=n[e],a=e+t.length-1;if(a>=0){const e=i[a],t=e[e.length-1]-r[s];for(let e=s;e<u;++e)i[a].push(r[e+1]+t)}s=r[s],u=r[u]}u!==s&&(a.push([s,u]),o+=u-s)}return{outSplits:i,valueSlices:a,numValues:o}}(o,s,e,u),h=function(e){const t=[];for(let n=0;n<e.length;++n){const r=mt("int32",e[n].length);t.push(r),e[n].forEach(((e,t)=>r[t]=e))}return t}(l),d=function(e,t,n,r,a){const o=t.slice();o[0]=a;const s=mt(n,ot(o)),i=e.length;return function(e,t,n,r,a,o){const s=rg(t,2)[1],i=rg(o,2)[1];let u=0;for(const t of n)for(let n=t[0];n<t[1];++n){for(let t=0;t<r;++t)a[u*i+t]=e[n*s+t];++u}}(e,t,r,0===i?0:i/t[0],s,o),[s,o]}(n,r,a,c,p);return[h,d[0],d[1]]},raggedRangeImpl:function(e,t,n,r,a,o,s){if(t.length>1)throw new Error("starts must be a scalar or vector");if(a.length>1)throw new Error("limits must be a scalar or vector");if(s.length>1)throw new Error("deltas must be a scalar or vector");const i=0===t.length,u=0===a.length,l=0===s.length,c=[];i||c.push(t[0]),u||c.push(a[0]),l||c.push(s[0]);for(let e=1;e<c.length;++e)if(c[e]!==c[e-1])throw new Error("starts, limits, and deltas must have the same shape");const p=0===c.length?1:c[0],h=mt("int32",p+1);h[0]=0;for(let t=0;t<p;++t){const n=i?e[0]:e[t],a=u?r[0]:r[t],s=l?o[0]:o[t];if(0===s)throw new Error("Requires delta != 0");let c;if(s>0&&a<n||s<0&&a>n)c=0;else if(c=Math.ceil(Math.abs((a-n)/s)),c>2147483647)throw new Error("Requires ((limit - start) / delta) <= 2147483647");h[t+1]=h[t]+c}const d=mt(n,h[p]);let f=0;for(let t=0;t<p;++t){const n=h[t+1]-h[t];let r=i?e[0]:e[t];const a=l?o[0]:o[t];for(let e=0;e<n;++e)d[f++]=r,r+=a}return[h,d]},raggedTensorToTensorImpl:function(e,t,n,r,a,o,s,i,u,l){return new og(e,t,n,r,a,o,s,i,u,l).compute()},rangeImpl:ug,rsqrtImpl:lg,scatterImpl:function(e,t,n,r,a,o,s,i,u,l){const c=[r/a,a],p=e.values,h=t.values;if(0===r)return Ju(n,t.dtype);const d=Ju(c,t.dtype);"string"==typeof u||"number"==typeof u?d.values.fill(u):"boolean"==typeof u&&d.values.fill(+u);for(let e=0;e<o;e++){const o=[];let u=0;for(let t=0;t<s;t++){const n=p[e*s+t];o.push(n),u+=n*i[t]}if(u<0||u>=r/a)throw new Error(`Invalid indices: ${o} does not index into ${n}`);for(let n=0;n<a;n++)l?d.values[u*a+n]+=h[e*a+n]:d.values[u*a+n]=0===t.rank?h[0]:h[e*a+n]}return d},sigmoidImpl:cg,sliceImpl:dg,sparseFillEmptyRowsImpl:function(e,t,n,r,a,o,s){const i=t[0],u=o[0],l=new Array(u),c=new Array(i),p=t[1];if(0===u){if(0!==i)throw new Error(Dd(i));return[mt(n,0),[0,p],mt(a,0),l,c]}let h=!0,d=0;const f=new Array(u).fill(0);for(let t=0;t<i;++t){const n=e[t*p];if(n<0)throw new Error(Pd(t,n));if(n>=u)throw new Error(Ld(t,n,u));++f[n],h=h&&n>=d,d=n}let m=!0;for(let e=0;e<u;++e){const t=0===f[e];l[e]=t,m=m&&!t,f[e]=Math.max(f[e],1),e>0&&(f[e]+=f[e-1])}if(m&&h){const t=e,n=r;for(let e=0;e<i;++e)c[e]=e;return[t,[i,p],n,l,c]}{const t=f[u-1],o=mt(n,t*p),h=mt(a,t),d=new Array(u).fill(0);for(let t=0;t<i;++t){const n=e[t*p],a=d[n],s=(0===n?0:f[n-1])+a;d[n]++;for(let n=0;n<p;++n)o[s*p+n]=e[t*p+n];h[s]=r[t],c[t]=s}for(let e=0;e<u;++e)if(0===d[e]){const t=0===e?0:f[e-1];o[t*p+0]=e;for(let e=1;e<p;++e)o[t*p+e]=0;h[t]=s}return[o,[t,p],h,l,c]}},sparseReshapeImpl:function(e,t,n,r,a){const o=ot(r),s=t[0],i=a.length,u=[];let l=1,c=-1;for(let e=0;e<i;++e){const t=a[e];if(-1===t){if(-1!==c)throw new Error(Bd(c,e));c=e,u.push(1)}else{if(t<0)throw new Error(Ud(e,t));l*=t,u.push(t)}}if(-1!==c){if(l<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");const e=Math.trunc(o/l);if(l*e!==o)throw new Error(Wd(r,u));u[c]=e}if(ot(u)!==o)throw new Error(Vd(r,u));const p=r.length,h=[];if(p>0){h[p-1]=1;for(let e=p-2;e>=0;--e)h[e]=h[e+1]*r[e+1]}const d=[];if(i>0){d[i-1]=1;for(let e=i-2;e>=0;--e)d[e]=d[e+1]*u[e+1]}const f=mt(n,s*i);for(let t=0;t<s;++t){let n=0;for(let r=0;r<p;++r)n+=e[t*p+r]*h[r];for(let e=0;e<i;++e)f[t*i+e]=Math.trunc(n/d[e]),n%=d[e]}return[f,[s,i],u]},sparseSegmentReductionImpl:function(e,t,n,r,a,o=!1,s=0){const i=r.length,u=[t[0],e.length/t[0]],l=u[1],c=i>0?a[i-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const p=t.slice();p[0]=c;const h=mt(n,p.reduce(((e,t)=>e*t),1));if(0===i)return c>0&&h.fill(s),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");let d=0,f=1,m=0,g=a[d];for(;;){let t=0;if(f<i){if(t=a[f],g===t){++f;continue}if(g>=t)throw new Error("segment ids are not increasing")}if(g<0||g>=c)throw new Error(zd(g,c));g>m&&h.fill(s,m*l,g*l);for(let t=d;t<f;++t){const n=r[t];if(n<0||n>=u[0])throw new Error(jd(t,r[t],u[0]));for(let t=0;t<l;t++)h[g*l+t]+=e[n*l+t]}if(o)for(let e=0;e<l;e++)h[g*l+e]/=f-d;if(d=f,++f,m=g+1,g=t,f>i)break}return m<c&&h.fill(s,m*l,c*l),[h,p]},sqrtImpl:gg,squaredDifferenceImpl:yg,stridedSliceImpl:bg,stringNGramsImpl:wg,stringSplitImpl:_g,stringToHashBucketFastImpl:kg,subImpl:Tg,tileImpl:function(e,t){const n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];const r=Ju(n,e.dtype);for(let t=0;t<r.values.length;++t){const n=r.indexToLoc(t),a=new Array(e.rank);for(let t=0;t<a.length;t++)a[t]=n[t]%e.shape[t];const o=e.locToIndex(a);r.values[t]=e.values[o]}return r},topKImpl:function(e,t,n,r,a){const o=t[t.length-1],[s,i]=[e.length/o,o],u=ft(n,s*r),l=ft("int32",s*r);for(let t=0;t<s;t++){const n=t*i,o=e.subarray(n,n+i);let s=new Array(o.length);o.forEach(((e,t)=>s[t]={value:e,index:t})),r<s.length&&(Ag(s,r),s=s.slice(0,r)),a&&s.sort(Cg);const c=t*r,p=u.subarray(c,c+r),h=l.subarray(c,c+r);for(let e=0;e<r;e++)p[e]=s[e].value,h[e]=s[e].index}const c=t.slice();return c[c.length-1]=r,[Ju(c,n,u),Ju(c,"int32",l)]},transposeImpl:tg,uniqueImpl:function(e,t,n,r){const a=ht(t,n)[0],o=[1,n[0],1];for(let e=0;e<a;e++)o[0]*=n[e];o[1]=n[a];for(let e=a+1;e<n.length;e++)o[2]*=n[e];const s={},i=new Int32Array(n[a]),u=new Wa(o,r,e),l=[],c=1===o[0]&&1===o[2];for(let t=0;t<n[a];t++){let n;if(c)n=e[t].toString();else{const e=[];for(let n=0;n<o[0];n++)for(let r=0;r<o[2];r++)e.push(u.get(n,t,r));n=e.join(",")}if(void 0!==s[n])i[t]=s[n];else{const e=Object.keys(s).length;s[n]=e,i[t]=e,l.push(t)}}const p=o.slice();p[1]=Object.keys(s).length;const h=new Wa(p,r);l.forEach(((e,t)=>{for(let n=0;n<o[0];n++)for(let r=0;r<o[2];r++)h.set(u.get(n,e,r),n,t,r)}));const d=n.slice();return d[a]=p[1],{outputValues:h.values,outputShape:d,indices:i}}});function Rg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:o}=r,s=ot(a.shape),i=pt(o,s),u=ot(i);nt(s===u,(()=>`The new shape (${i}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=i,t.shape=i}return{dataId:a.dataId,shape:i,dtype:a.dtype}}Ci("cpu",(()=>new gm),1);const Fg={kernelName:Yn,backendName:"cpu",kernelFunc:Rg},Og={kernelName:Qn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:o,halfPixelCenters:s,size:i}=r;fm(a,"resizeBilinear");const u=_t(a.shape),[l,c]=i,[p,h,d,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(ot([p,l,c,f])),y=[o&&l>1?h-1:h,o&&c>1?d-1:d],b=[o&&l>1?l-1:l,o&&c>1?c-1:c];let v=0;const w=y[0]/b[0],x=y[1]/b[1];for(let e=0;e<p;e++)for(let t=0;t<l;t++){let n;n=s?w*(t+.5)-.5:w*t;const r=Math.max(0,Math.floor(n)),a=n-r,o=Math.min(h-1,Math.ceil(n)),i=e*u[0]+r*u[1],l=e*u[0]+o*u[1];for(let e=0;e<c;e++){let t;t=s?x*(e+.5)-.5:x*e;const n=Math.max(0,Math.floor(t)),r=t-n,o=Math.min(d-1,Math.ceil(t)),c=i+n*u[2],p=l+n*u[2],h=i+o*u[2],y=l+o*u[2];for(let e=0;e<f;e++){const t=m[c+e],n=m[p+e],o=t+(m[h+e]-t)*r,s=o+(n+(m[y+e]-n)*r-o)*a;g[v++]=s}}}return n.makeTensorInfo([p,l,c,f],"float32",g)}},Mg=ym(((e,t)=>e/t)),$g=Em(on,Mg),Dg={kernelName:on,backendName:"cpu",kernelFunc:$g},Pg={kernelName:zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:o,constantValue:s}=r;fm(a,"pad");const i=o.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=o.map((e=>e[0])),l=n.data.get(a.dataId).values,c=ot(a.shape),p=a.shape.length,h=_t(a.shape),d=ot(i),f=i.length,m=_t(i),g=ft(a.dtype,d);0!==s&&g.fill(s);for(let e=0;e<c;e++)g[Ct(At(e,p,h).map(((e,t)=>e+u[t])),f,m)]=l[e];return{dataId:n.write(g,i,a.dtype),shape:i,dtype:a.dtype}}};function Lg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o}=t,{strides:s,pad:i,dataFormat:u,dilations:l,dimRoundingMode:c}=r;fm([a,o],"conv2d");const p=Ou(u),h=ku(a.shape,o.shape,s,l,i,c,!1,p),d=h.filterHeight,f=h.filterWidth,m=h.dilationHeight,g=h.dilationWidth,y=h.padInfo.left,b=h.padInfo.top,v="channelsLast"===h.dataFormat,w=new Wa(h.outShape,a.dtype),x=_t(a.shape),_=_t(o.shape),k=x[0],T=v?x[1]:x[2],S=v?x[2]:1,E=v?1:x[1],I=w.strides[0],C=v?w.strides[1]:w.strides[2],A=v?w.strides[2]:1,N=v?1:w.strides[1],R=n.data.get(a.dataId).values,F=n.data.get(o.dataId).values,O=w.values;for(let e=0;e<h.batchSize;++e){const t=e*k,n=e*I;for(let e=0;e<h.outHeight;++e){const r=n+e*C,a=e*h.strideHeight-b;for(let e=0;e<d;++e){const n=a+e*m;if(n<0||n>=h.inHeight)continue;const o=e*_[0],s=t+n*T;for(let e=0;e<h.outWidth;++e){const t=r+e*A,n=e*h.strideWidth-y;for(let e=0;e<f;++e){const r=n+e*g;if(r<0||r>=h.inWidth)continue;const a=s+r*S;let i=o+e*_[1];for(let e=0;e<h.inChannels;++e){const n=R[a+e*E];for(let e=0;e<h.outChannels;++e)O[t+e*N]+=n*F[i+e];i+=h.outChannels}}}}}}return n.makeTensorInfo(w.shape,w.dtype,O)}const Bg={kernelName:Qt,backendName:"cpu",kernelFunc:Lg},Ug=Om(sn,(e=>e>=0?e:Math.exp(e)-1)),Wg=ym(((e,t)=>e<0?t*e:e)),Vg=Om(qn,(e=>Math.max(0,e))),zg={kernelName:qn,backendName:"cpu",kernelFunc:Vg},jg=Om(Jn,(e=>Math.min(Math.max(0,e),6))),Hg={kernelName:Jn,backendName:"cpu",kernelFunc:jg};function Gg(e,t,n,r,a){if("linear"===n)return wm({inputs:{x:t},backend:e});if("relu"===n)return Vg({inputs:{x:t},backend:e});if("elu"===n)return Ug({inputs:{x:t},backend:e});if("relu6"===n)return jg({inputs:{x:t},backend:e});if("prelu"===n)return function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;fm([r,a],"prelu");const o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[i,u]=Wg(r.shape,a.shape,o,s,"float32");return n.makeTensorInfo(u,"float32",i)}({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:o}=r;fm([a],"leakyRelu");const s=ot(a.shape),i=n.data.get(a.dataId).values,u=ft("float32",s);for(let e=0;e<i.length;e++)u[e]=i[e]<0?o*i[e]:i[e];return n.makeTensorInfo(a.shape,"float32",u)}({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return pg({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}const Kg={kernelName:Fr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=r;let m=Lg({inputs:{x:a,filter:o},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=Rg({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=Nm({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=Nm({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(d){const e=m;if("NCHW"===c&&"prelu"===d&&1===i.shape.length&&1!==i.shape[0]){const e=Rg({inputs:{x:i},backend:n,attrs:{shape:[i.shape[0],1,1]}});m=Gg(n,m,d,e,f),n.disposeIntermediateTensorInfo(e)}else m=Gg(n,m,d,i,f);n.disposeIntermediateTensorInfo(e)}return m}};function qg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o}=t,{strides:s,pad:i,dilations:u,dimRoundingMode:l}=r;fm([a,o],"depthwiseConv2DNative");const c=_t(a.shape),p=_t(o.shape);let h=u;null==h&&(h=[1,1]),nt(Ru(s,h),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${h}'`));const d=ku(a.shape,o.shape,s,h,i,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=d,v=b.left,w=b.top,x=d.outChannels/d.inChannels,_=new Wa(d.outShape,a.dtype),k=n.data.get(a.dataId).values,T=n.data.get(o.dataId).values,S=_.values;for(let e=0;e<d.batchSize;++e){const t=e*c[0],n=e*_.strides[0];for(let e=0;e<d.outHeight;++e){const r=n+e*_.strides[1],a=e*d.strideHeight-w;for(let e=0;e<f;++e){const n=a+e*g;if(n<0||n>=d.inHeight)continue;const o=e*p[0],s=t+n*c[1];for(let e=0;e<d.outWidth;++e){const t=r+e*_.strides[2],n=e*d.strideWidth-v;for(let e=0;e<m;++e){const r=n+e*y;if(r<0||r>=d.inWidth)continue;const a=o+e*p[1],i=s+r*d.inChannels;let u=t,l=a;for(let e=0;e<d.inChannels;++e){const t=k[i+e];for(let e=0;e<x;++e)S[u+e]+=t*T[l+e];u+=x,l+=x}}}}}}return n.makeTensorInfo(_.shape,_.dtype,_.values)}const Yg={kernelName:an,backendName:"cpu",kernelFunc:qg},Xg={kernelName:Or,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=r;let m=qg({inputs:{x:a,filter:o},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(s){const e=m;m=Nm({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(d){const e=m;m=Gg(n,m,d,i,f),n.disposeIntermediateTensorInfo(e)}return m}},Qg={kernelName:ur,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,paddings:s}=r;fm([a],"spaceToBatchND");const i=ot(o),u=[[0,0]];u.push(...s);for(let e=1+o.length;e<a.shape.length;++e)u.push([0,0]);const l=Pg.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),c=Id(l.shape,o,i,!1),p=Cd(c.length,o.length,!1),h=Ad(l.shape,o,i,!1),d=Rg({inputs:{x:l},backend:n,attrs:{shape:c}}),f=ng({inputs:{x:d},backend:n,attrs:{perm:p}}),m=Rg({inputs:{x:f},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}},Jg={kernelName:Gt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,crops:s}=r;fm([a],"batchToSpaceND");const i=o.reduce(((e,t)=>e*t)),u=Id(a.shape,o,i),l=Cd(u.length,o.length),c=Ad(a.shape,o,i),p=Nd(s,o.length),h=Rd(c,s,o.length),d=Rg({inputs:{x:a},backend:n,attrs:{shape:u}}),f=ng({inputs:{x:d},backend:n,attrs:{perm:l}}),m=Rg({inputs:{x:f},backend:n,attrs:{shape:c}}),g=fg({inputs:{x:m},backend:n,attrs:{begin:p,size:h}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}},Zg={kernelName:gr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:o,end:s,strides:i,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:h}=r;fm(a,"stridedSlice");const{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=nu(a.shape,o,s,i,u,l,c,p,h);let x;if(m)x=Rg({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=ji(b,v,w),t=fg({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});x=Rg({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=bg(d,n.bufferSync(a),w,b);x=n.makeTensorInfo(f,e.dtype,e.values)}return x}};function ey(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,o=ht(a,t[0].shape)[0];bd(t.map((e=>e.shape)),o);let s=vd(t.map((e=>e.shape)),o);if(0===ot(s))return n.makeTensorInfo(s,t[0].dtype,[]);const i=t.filter((e=>ot(e.shape)>0));if(1===i.length)return wm({inputs:{x:i[0]},backend:n});if("complex64"===i[0].dtype){const e=i.map((e=>_m({inputs:{input:e},backend:n}))),t=i.map((e=>function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.imag,o=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,o)}({inputs:{input:e},backend:n}))),r=ey({inputs:e,backend:n,attrs:{axis:o}}),a=ey({inputs:t,backend:n,attrs:{axis:o}}),s=bm({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=i.map((e=>{const t=ot(e.shape.slice(o));return Rg({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=vd(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],p=$m(l,s,t[0].dtype,c),h=vd(i.map((e=>e.shape)),o),d=n.makeTensorInfo(h,t[0].dtype,p);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const ty={kernelName:Xt,backendName:"cpu",kernelFunc:ey};function ny(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:o}=r,s=a.shape.length,i=a.shape.slice();let u=o;return o<0&&(nt(-(s+1)<=o,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+o+1),i.splice(u,0,1),Rg({inputs:{x:a},backend:n,attrs:{shape:i}})}const ry={kernelName:Vn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return ny({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const o=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(o,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const i=[],u=ey({inputs:t.map((e=>{const t=ny({inputs:{input:e},backend:n,attrs:{dim:a}});return i.push(t),t})),backend:n,attrs:{axis:a}});return i.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}},ay={kernelName:Jt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:o}=t,{inputShape:s,strides:i,pad:u,dataFormat:l,dimRoundingMode:c}=r;fm([a,o],"conv2dBackpropInput");const p=_t(o.shape),h=_t(a.shape);let d=Ou(l);const f=ku(s,o.shape,i,1,u,c,!1,d),m=new Wa(f.inShape,"float32"),g=m.values,y=n.data.get(a.dataId).values,b=n.data.get(o.dataId).values,[v,w,x]=p,{batchSize:_,filterHeight:k,filterWidth:T,inChannels:S,inHeight:E,inWidth:I,outChannels:C,outHeight:A,outWidth:N,strideHeight:R,strideWidth:F}=f;d=f.dataFormat;const O=k-1-f.padInfo.top,M=T-1-f.padInfo.left,$="channelsLast"===d,D=m.strides[0],P=$?m.strides[1]:m.strides[2],L=$?m.strides[2]:1,B=$?1:m.strides[1],U=h[0],W=$?h[1]:h[2],V=$?h[2]:1,z=$?1:h[1];for(let e=0;e<_;++e)for(let t=0;t<S;++t)for(let n=0;n<E;++n){const r=n-O,a=Math.max(0,Math.ceil(r/R)),o=Math.min(A,(k+r)/R);for(let s=0;s<I;++s){const i=s-M,u=Math.max(0,Math.ceil(i/F)),l=Math.min(N,(T+i)/F);let c=0;for(let n=a;n<o;++n){const a=n*R-r;for(let r=u;r<l;++r){const o=U*e+W*n+V*r,s=v*(k-1-a)+w*(T-1-(r*F-i))+x*t;for(let e=0;e<C;++e)c+=y[o+z*e]*b[s+e]}}g[D*e+P*n+L*s+B*t]=c}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}},oy={kernelName:nn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:o,boxInd:s}=t,{cropSize:i,method:u,extrapolationValue:l}=r,[c,p,h,d]=a.shape,f=o.shape[0],[m,g]=i,y=Ju([f,m,g,d],"float32"),b=n.data.get(o.dataId).values,v=n.data.get(s.dataId).values,w=n.data.get(a.dataId).values,x=_t(a.shape),_=_t(y.shape);for(let e=0;e<f;e++){const t=4*e,n=b[t],r=b[t+1],a=b[t+2],o=b[t+3],s=v[e];if(s>=c)continue;const i=m>1?(a-n)*(p-1)/(m-1):0,f=g>1?(o-r)*(h-1)/(g-1):0;for(let t=0;t<m;t++){const c=m>1?n*(p-1)+t*i:.5*(n+a)*(p-1);if(c<0||c>p-1)for(let n=0;n<g;n++)for(let r=0;r<d;r++){const a=r+n*_[2]+t*_[1]+e*_[0];y.values[a]=l}else if("bilinear"===u){const n=Math.floor(c),a=Math.ceil(c),i=c-n;for(let u=0;u<g;u++){const c=g>1?r*(h-1)+u*f:.5*(r+o)*(h-1);if(c<0||c>h-1){for(let n=0;n<d;n++){const r=n+u*_[2]+t*_[1]+e*_[0];y.values[r]=l}continue}const p=Math.floor(c),m=Math.ceil(c),b=c-p;for(let r=0;r<d;r++){let o=r+p*x[2]+n*x[1]+s*x[0];const l=w[o];o=r+m*x[2]+n*x[1]+s*x[0];const c=w[o];o=r+p*x[2]+a*x[1]+s*x[0];const h=w[o];o=r+m*x[2]+a*x[1]+s*x[0];const d=l+(c-l)*b,f=h+(w[o]-h)*b;o=r+u*_[2]+t*_[1]+e*_[0],y.values[o]=d+(f-d)*i}}}else for(let n=0;n<g;++n){const a=g>1?r*(h-1)+n*f:.5*(r+o)*(h-1);if(a<0||a>h-1){for(let r=0;r<d;r++){const a=r+n*_[2]+t*_[1]+e*_[0];y.values[a]=l}continue}const i=Math.round(a),u=Math.round(c);for(let r=0;r<d;r++){const a=r+i*x[2]+u*x[1]+s*x[0],o=r+n*_[2]+t*_[1]+e*_[0];y.values[o]=w[a]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}},sy={kernelName:Zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:o}=r;fm(a,"reverse");const s=a.shape.length,i=ht(o,a.shape);if(0===s)return wm({inputs:{x:a},backend:n});const u=new Wa(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;e<u.size;e++){const t=u.indexToLoc(e),n=t.slice();i.forEach((e=>n[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},iy={kernelName:Er,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a.shape.length,i=a.shape[o],u=new Array(s-1);let l=0;for(let e=0;e<s;e++)e!==o&&(u[l++]=a.shape[e]);const c=new Array(s).fill(0),p=a.shape.slice();p[o]=1;const h=new Array(i);for(let e=0;e<h.length;e++){c[o]=e;const t=fg({inputs:{x:a},backend:n,attrs:{begin:c,size:p}});h[e]=Rg({inputs:{x:t},backend:n,attrs:{shape:u}}),n.disposeIntermediateTensorInfo(t)}return h}},uy={kernelName:zt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o}=r;fm(a,"argMax");let s=ht(o,a.shape);const i=$l(s,a.shape.length);let u=a;const l=[];null!=i&&(u=ng({inputs:{x:a},backend:n,attrs:{perm:i}}),l.push(u),s=Pl(s.length,u.shape.length)),s=[s[0]],Ml("argMax",s,u.shape.length);const[c,p]=Fl(u.shape,s),h=Et(ot(c),"int32"),d=ot(p),f=n.data.get(u.dataId).values;for(let e=0;e<h.length;++e){const t=e*d;let n=f[t],r=0;for(let e=0;e<d;++e){const a=f[t+e];a>n&&(n=a,r=e)}h[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",h)}};function ly(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,keepDims:s}=r;let i;fm(a,"sum"),i="bool"===a.dtype?Tm({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):wm({inputs:{x:a},backend:n});const u=i.shape.length,l=ht(o,i.shape),c=$l(l,u);let p=l,h=i;null!=c&&(h=ng({inputs:{x:i},backend:n,attrs:{perm:c}}),p=Pl(p.length,u)),Ml("sum",p,h.shape.length);const[d,f]=Fl(h.shape,p);let m=vm(n,d,Ja(h.dtype,"int32"));const g=ot(f),y=n.data.get(m.dataId).values,b=n.data.get(h.dataId).values;for(let e=0;e<y.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=b[t+e];y[e]=n}if(s){const e=m;m=Rg({inputs:{x:m},backend:n,attrs:{shape:Ol(m.shape,l)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(i),null!=c&&n.disposeIntermediateTensorInfo(h),m}const cy={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,keepDims:s}=r,i=ht(o,a.shape),u=ot(Fl(a.shape,i)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const p=Tm({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);const h=$g({inputs:{a:p,b:c},backend:n});l.push(h);const d=ly({inputs:{x:h},backend:n,attrs:{axis:o,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},py={kernelName:cr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:o}=r,s=a.shape.length;let i=o;if(-1===i&&(i=s-1),i!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${i}`);const u=ht([i],a.shape),l=function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:o,keepDims:s}=r,i=n;let u=a.shape;const l=u.length,c=ht(o,u);let p=c;const h=$l(p,l);let d=i.data.get(a.dataId).values;if(null!=h){const e=new Array(l);for(let t=0;t<e.length;t++)e[t]=u[h[t]];d=tg(d,u,a.dtype,h,e),p=Pl(p.length,l),u=e}fm(a,"max"),Ml("max",p,l);const[f,m]=Fl(u,p),g=Km(d,ot(m),f,a.dtype),y=i.write(g,f,a.dtype);let b=f;return s&&(b=Ol(f,c)),{dataId:y,shape:b,dtype:a.dtype}}({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=Ol(l.shape,u),p=Rg({inputs:{x:l},backend:n,attrs:{shape:c}}),h=Eg({inputs:{a,b:p},backend:n}),d=Lm({inputs:{x:h},backend:n}),f=ly({inputs:{x:d},backend:n,attrs:{axis:u,keepDims:!1}}),m=Rg({inputs:{x:f},backend:n,attrs:{shape:c}}),g=$g({inputs:{a:d,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}},hy=Om(Yt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e})),dy={kernelName:Yt,backendName:"cpu",kernelFunc:hy},fy={kernelName:jt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;fm(a,"avgPool");const{filterSize:o,strides:s,pad:i,dimRoundingMode:u}=r;nt(Ru(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=_u(a.shape,o,s,1,i,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&st(l.inShape,l.outShape))c=wm({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=_t(a.shape),r=function(e,t,n,r,a,o){const s=a.strideHeight,i=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,h=a.padInfo.top,d=a.padInfo.left,f=Number.POSITIVE_INFINITY,m=Ju(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],v=a.outShape[3];for(let t=0;t<a.batchSize;++t){const n=t*y,o=t*r[0];for(let t=0;t<a.inChannels;++t)for(let m=0;m<a.outHeight;++m){const y=m*s-h,w=Math.max(0,y),x=Math.min(a.inHeight,c+y),_=n+m*b;for(let n=0;n<a.outWidth;++n){const s=n*i-d,c=Math.max(0,s),h=Math.min(a.inWidth,p+s);let m=f,y=0,b=0;for(let n=w;n<x;n+=u){const a=o+n*r[1];for(let n=c;n<h;n+=l){const o=e[a+n*r[2]+t];y+=o,b++}if(isNaN(m))break}g[_+n*v+t]=y/b}}}return m}(e,a.shape,a.dtype,t,l);c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},my={kernelName:Ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:o}=t,{transposeA:s,transposeB:i}=r;fm([a,o],"matMul");const u=a.shape.length,l=o.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=i?o.shape[l-1]:o.shape[l-2],h=s?a.shape[u-1]:a.shape[u-2],d=i?o.shape[l-2]:o.shape[l-1],f=a.shape.slice(0,-2),m=o.shape.slice(0,-2),g=ot(f),y=ot(m),b=$i(a.shape.slice(0,-2),o.shape.slice(0,-2)).concat([h,d]);nt(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${o.shape} and transposeA=${s} and transposeB=${i} must match.`));const v=i?[y,d,p]:[y,p,d],w=Rg({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,h]:[g,h,c]}}),x=Rg({inputs:{x:o},backend:n,attrs:{shape:v}}),_=s?w.shape[1]:w.shape[2],k=s?w.shape[2]:w.shape[1],T=i?x.shape[1]:x.shape[2],S=Math.max(g,y),E=n.data.get(w.dataId).values,I=n.data.get(x.dataId).values,C=_t(w.shape),A=_t(x.shape),[N,R,F]=s?[C[0],1,C[1]]:[C[0],C[1],1],[O,M,$]=i?[1,A[1],A[0]]:[A[1],1,A[0]],D=k*T,P=Ju([S,k,T],w.dtype),L=P.values,B=n.blockSize;for(let e=0;e<S;e++){const t=e%g,n=e%y;for(let r=0;r<k;r+=B){const a=Math.min(r+B,k);for(let o=0;o<T;o+=B){const s=Math.min(o+B,T);for(let i=0;i<_;i+=B){const u=Math.min(i+B,_);for(let l=r;l<a;l++)for(let r=o;r<s;r++){let a=0;for(let e=i;e<u;e++)a+=E[t*N+l*R+e*F]*I[e*O+r*M+n*$];L[e*D+(l*T+r)]+=a}}}}}return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(x),n.makeTensorInfo(b,P.dtype,P.values)}},gy={},yy={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function by(e,t){if(!(e in gy)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete gy[e]}),!1),Mt().getBool("SOFTWARE_WEBGL_ENABLED")&&(yy.failIfMajorPerformanceCaveat=!1),1===e?n.getContext("webgl",yy)||n.getContext("experimental-webgl",yy):n.getContext("webgl2",yy)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;gy[e]=n}const n=gy[e];return null==n||n.isContextLost()?(delete gy[e],by(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),gy[e])}var vy,wy,xy;function _y(e,t){return[t,e]}function ky(e){const t=ot(e);return ut(Math.ceil(t/4))}function Ty(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function Sy(e,t){const n=e;let r,a,o,s,i,u,l,c,p,h;return 2===Mt().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,o=n.RGBA16F,s=n.RGBA32F,i=n.RED,l=4,c=1,p=n.HALF_FLOAT,h=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,o=e.RGBA,s=n.RGBA,i=e.RGBA,l=4,c=4,p=null!=t?t.HALF_FLOAT_OES:null,h=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:s,textureFormatFloat:i,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:h}}function Ey(e,t){const n=t();return Mt().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}(e,t))}(e),n}function Iy(e){return!!(Mt().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function Cy(e,t){return Dy(e,(()=>e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(vy||(vy={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(wy||(wy={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(xy||(xy={}));const Ay=/ERROR: [0-9]+:([0-9]+):/g;function Ny(e,t){const n=Ay.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),o=a.length.toString().length+2,s=a.map(((e,t)=>lt((t+1).toString(),o)+e));let i=0;for(let e=0;e<s.length;e++)i=Math.max(s[e].length,i);const u=s.slice(0,r-1),l=s.slice(r-1,r),c=s.slice(r);console.log(u.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${lt(l[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join("\n"))}function Ry(e,t){if(Ey(e,(()=>e.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function Fy(e,t,n,r,a,o,s){const i=e.getAttribLocation(t,n);return-1!==i&&(Ey(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),Ey(e,(()=>e.vertexAttribPointer(i,a,e.FLOAT,!1,o,s))),Ey(e,(()=>e.enableVertexAttribArray(i))),!0)}function Oy(e,t,n){Ey(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),Ey(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function My(e,t){Ey(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),Ey(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function $y(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}(e,t))}function Dy(e,t,n){const r=Ey(e,(()=>t()));if(null==r)throw new Error(n);return r}function Py(e,t=2){return ot(e.slice(0,e.length-t))}function Ly(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function By(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[Py(e),...Ly(e)]),t}function Uy(e){return e%2==0}function Wy(e,t){if(st(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(Uy(n)&&Uy(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&Uy(e[0])&&Uy(t[0])}let Vy,zy;function jy(e,t){return null!=e.getExtension(t)}function Hy(e){try{if(null!=by(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function Gy(e){const t=Sy(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}const Ky=Mt();function qy(){let e,t,n,r,a,o,s,i,u,l;return 2===Mt().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",o="outputColor",s="out vec4 outputColor;",i=Mt().getBool("WEBGL2_ISNAN_CUSTOM")?"\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ":"",u="",l="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",a="texture2D",o="gl_FragColor",s="",i="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",l="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:o,defineOutput:s,defineSpecialNaN:i,defineSpecialInf:u,defineRound:l}}function Yy(e,t,n="index"){const r=_t(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function Xy(e,t,n="index"){const r=_t(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function Qy(e){const t=_t(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}Ky.registerFlag("HAS_WEBGL",(()=>Ky.getNumber("WEBGL_VERSION")>0)),Ky.registerFlag("WEBGL_VERSION",(()=>Hy(2)?2:Hy(1)?1:0)),Ky.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),Ky.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===Ky.get("WEBGL_VERSION"))),Ky.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),Ky.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),Ky.registerFlag("WEBGL_PACK",(()=>Ky.getBool("HAS_WEBGL"))),Ky.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_CLIP",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_PACK_REDUCE",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_LAZILY_UNPACK",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_CONV_IM2COL",(()=>Ky.getBool("WEBGL_PACK"))),Ky.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==Vy){const t=by(e);Vy=t.getParameter(t.MAX_TEXTURE_SIZE)}return Vy}(Ky.getNumber("WEBGL_VERSION")))),Ky.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==zy){const t=by(e);zy=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,zy)}(Ky.getNumber("WEBGL_VERSION")))),Ky.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=Ky.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=by(e);return t=jy(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:jy(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),Ky.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>Ky.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!uo())),Ky.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=by(e);if(1===e){if(!jy(t,"OES_texture_float"))return!1}else if(!jy(t,"EXT_color_buffer_float"))return!1;return Gy(t)}(Ky.getNumber("WEBGL_VERSION")))),Ky.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!Ky.getBool("WEBGL_FORCE_F16_TEXTURES")&&Ky.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),Ky.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=by(e);if(1!==e){if(jy(t,"EXT_color_buffer_float"))return Gy(t);const e="EXT_color_buffer_half_float";if(jy(t,e)){const n=t.getExtension(e);return function(e,t){const n=Sy(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),o}(t,n)}return!1}return!!jy(t,"OES_texture_float")&&!!jy(t,"WEBGL_color_buffer_float")&&Gy(t)}(Ky.getNumber("WEBGL_VERSION")))),Ky.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=Ky.getNumber("WEBGL_VERSION"))&&null!=by(e).fenceSync;var e})),Ky.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>Ky.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),Ky.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),Ky.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>uo()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),Ky.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),Ky.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),Ky.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),Ky.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128)),Ky.registerFlag("WEBGL_EXP_CONV",(()=>!1)),Ky.registerFlag("SOFTWARE_WEBGL_ENABLED",(()=>Ky.getBool("IS_TEST"))),Ky.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",(()=>1/0)),Ky.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",(()=>!1)),Ky.registerFlag("WEBGL2_ISNAN_CUSTOM",(()=>!1)),Ky.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Jy="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:Zy}=Yd;function eb(e,t,n){const r=[];if(e.forEach((e=>{const t=ot(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=cb(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),o=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?nb(e,r):tb(e,r);const o=e.shapeInfo.logicalShape,s=t.logicalShape;return o.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",o=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,i=Zy(e.shapeInfo.logicalShape,t.logicalShape),u=lb(s),l=s-o;let c;const p=["x","y","z","w","u","v"];c=0===o?"":s<2&&i.length>=1?"coords = 0;":i.map((e=>`coords.${p[e+l]} = 0;`)).join("\n");let h="";h=s<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${p[t+l]}`)).join(", ");let d="return outputValue;";const f=1===ot(e.shapeInfo.logicalShape),m=1===ot(t.logicalShape);if(1!==o||f||m){if(f&&!m)d=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(i.length){const e=o-2,t=o-1;i.indexOf(e)>-1&&i.indexOf(t)>-1?d="return vec4(outputValue.x);":i.indexOf(e)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf(t)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${h});\n ${d}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",o=t.texShape,s=e.shapeInfo.texShape,i=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&i===u&&null==e.shapeInfo.flatOffset&&st(s,o))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=lb(u),c=Zy(e.shapeInfo.logicalShape,t.logicalShape),p=u-i;let h;const d=["x","y","z","w","u","v"];h=0===i?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${d[e+p]} = 0;`)).join("\n");let f="";return f=u<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${d[t+p]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${h}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,i=qy(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(i);let l,c,p=function(e){return`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${rb}\n ${ab}\n ${ob}\n `}(i);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(st(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),o=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${o};\n index -= b * ${o};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),o=a*Math.ceil(e[e.length-2]/2);let s=o,i="",u="b, r, c";for(let t=2;t<e.length-1;t++)s*=e[e.length-t-1],i=`\n int b${t} = index / ${s};\n index -= b${t} * ${s};\n `+i,u=`b${t}, `+u;return`\n ivec${e.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n ${i}\n\n int b = index / ${o};\n index -= b * ${o};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec${e.length}(${u});\n }\n `}(e,t,n)}}(t.logicalShape,s,n.enableShapeUniforms),c=function(e){return`\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n `}(i)):(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){return 1===t[0]?n?"\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `:1===t[1]?n?"\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n `}(0,t,n);case 2:return function(e,t,n){return st(e,t)?n?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `:1===e[1]?n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `:1===e[0]?n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `:n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${Xy(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n`;const r=Yy(["r","c","d"],e);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec3(r, c, d);\n }\n `}(e,t,n);case 4:return function(e,t,n){if(n)return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${Xy(["r","c","d","d2"],e)}\n return ivec4(r, c, d, d2);\n }\n `;const r=Yy(["r","c","d","d2"],e);return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec4(r, c, d, d2);\n }\n `}(e,t,n);case 5:return function(e,t){const n=Yy(["r","c","d","d2","d3"],e);return`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n `}(e,t);case 6:return function(e,t){const n=Yy(["r","c","d","d2","d3","d4"],e);return`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n `}(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}(t.logicalShape,s,n.enableShapeUniforms),c=function(e){return`\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n `}(i)),n.packedInputs&&(p+=sb),[p,u,c,a,l,o,n.userCode].join("\n")}function tb(e,t=!1){const n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${r}() {return ${n};}`;const[a,o]=e.shapeInfo.texShape;if(1===a&&1===o)return`\n float ${r}() {\n return sampleTexture(${n}, halfCR);\n }\n `;const s=ib(n);if(t)return`\n float ${r}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${s});\n return sampleTexture(${n}, uv);\n }\n `;const[i,u]=e.shapeInfo.texShape;return`\n float ${r}() {\n vec2 uv = uvFromFlat(${i}, ${u}, ${s});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`\n float ${r}(int index) {\n ${ub(e)}\n }\n `;const a=e.shapeInfo.texShape,o=a[0],s=a[1];if(1===s&&1===o)return`\n float ${r}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `;const i=ib(n);return 1===s?t?`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${o}.0);\n return sampleTexture(${n}, uv);\n }\n `:1===o?t?`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${i}) + 0.5) / ${s}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `:t?`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${i});\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${o}, ${s}, index + ${i});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape;if(null!=o&&st(n,o)){if(t)return`\n float ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `;const e=o[0];return`\n float ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${o[1]}.0, ${e}.0);\n return sampleTexture(${r}, uv);\n }\n `}const{newShape:s,keptDims:i}=dt(n),u=s;if(u.length<n.length){const n=["row","col"];return`\n ${tb(pb(e,u),t)}\n float ${a}(int row, int col) {\n return ${a}(${hb(n,i)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${ub(e)}\n }\n `;const l=o[0],c=o[1],p=ib(r);return 1===c?t?`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);\n return sampleTexture(${r}, uv);\n }\n `:1===l?t?`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);\n return sampleTexture(${r}, uv);\n }\n `:t?`\n float ${a}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r}Shape[1] + col + ${p};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${p};\n vec2 uv = uvFromFlat(${l}, ${c}, index);\n return sampleTexture(${r}, uv);\n }\n`}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[1]*n[2],s=n[2],{newShape:i,keptDims:u}=dt(n),l=i;if(l.length<n.length){const n=["row","col","depth"];return`\n ${tb(pb(e,l),t)}\n float ${a}(int row, int col, int depth) {\n return ${a}(${hb(n,u)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${o}, ${s}, 1)));\n ${ub(e)}\n }\n `;const c=e.shapeInfo.texShape,p=c[0],h=c[1],d=e.shapeInfo.flatOffset;if(h===o&&null==d)return t?`\n float ${a}(int row, int col, int depth) {\n int stride1 = ${r}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${s}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${h}.0, ${p}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(h===s&&null==d)return t?`\n float ${a}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}.0, ${p}.0);\n return sampleTexture(${r}, uv);\n }\n `;const f=ib(r);return t?`\n float ${a}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${r}Shape[1] * ${r}Shape[2];\n int stride1 = ${r}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${f};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${o} + col * ${s} + depth + ${f};\n vec2 uv = uvFromFlat(${p}, ${h}, index);\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 4:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[3],s=n[2]*o,i=n[1]*s,{newShape:u,keptDims:l}=dt(n);if(u.length<n.length){const n=["row","col","depth","depth2"];return`\n ${tb(pb(e,u),t)}\n float ${a}(int row, int col, int depth, int depth2) {\n return ${a}(${hb(n,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${i}, ${s}, ${o}, 1)));\n ${ub(e)}\n }\n `;const c=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,h=p[0],d=p[1],f=`int stride2 = ${r}Shape[3];`,m=`int stride1 = ${r}Shape[2] * stride2;`,g=`int stride0 = ${r}Shape[1] * stride1;`;if(d===i&&null==c)return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n ${f}\n ${m}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${s}, ${o}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(d===o&&null==c)return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1]*n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;const y=ib(r);return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${f}\n ${m}\n ${g}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${y});\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${i} + col * ${s} +\n depth * ${o} + depth2;\n vec2 uv = uvFromFlat(${h}, ${d}, index + ${y});\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 5:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[4],o=t[3]*a,s=t[2]*o,i=t[1]*s,{newShape:u,keptDims:l}=dt(t);if(u.length<t.length){const t=["row","col","depth","depth2","depth3"];return`\n ${tb(pb(e,u))}\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n return ${r}(${hb(t,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${i}, ${s}, ${o}, ${a})) +\n depth3;\n ${ub(e)}\n }\n `;const c=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,h=p[0],d=p[1];return d===i&&null==c?`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${s}, ${o}, ${a}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${n}, uv);\n }\n `:d===a&&null==c?`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]},\n ${t[2]*t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${i} + col * ${s} + depth * ${o} +\n depth2 * ${a} + depth3 + ${ib(n)};\n vec2 uv = uvFromFlat(${h}, ${d}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);case 6:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:a,keptDims:o}=dt(t);if(a.length<t.length){const t=["row","col","depth","depth2","depth3","depth4"];return`\n ${tb(pb(e,a))}\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${r}(${hb(t,o)});\n }\n `}const s=t[5],i=t[4]*s,u=t[3]*i,l=t[2]*u,c=t[1]*l;if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${c}, ${l}, ${u}, ${i})) +\n dot(\n vec2(depth3, depth4),\n vec2(${s}, 1)));\n ${ub(e)}\n }\n `;const p=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,d=h[0],f=h[1];return f===c&&null==p?`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${l}, ${u}, ${i}, ${s})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:f===s&&null==p?`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]*t[4]},\n ${t[2]*t[3]*t[4]},\n ${t[3]*t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${c} + col * ${l} + depth * ${u} +\n depth2 * ${i} + depth3 * ${s} + depth4 + ${ib(n)};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function nb(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return function(e){const t=e.name;return`\n vec4 ${"get"+t.charAt(0).toUpperCase()+t.slice(1)}() {\n return ${qy().texture2D}(${t}, halfCR);\n }\n `}(e);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,o=qy();if(t)return`\n vec4 ${r}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${o.texture2D}(${n}, uv);\n }\n `;const s=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return`\n vec4 ${r}(int index) {\n vec2 uv = packedUVfrom1D(\n ${s[0]}, ${s[1]}, index);\n return ${o.texture2D}(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape,s=o[0],i=o[1],u=qy();if(null!=o&&st(n,o))return t?`\n vec4 ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n\n return ${u.texture2D}(${r}, uv);\n }\n `:`\n vec4 ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${s}.0);\n\n return ${u.texture2D}(${r}, uv);\n }\n `;if(t)return`\n vec4 ${a}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `;const l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];return`\n vec4 ${a}(int row, int col) {\n vec2 uv = packedUVfrom2D(${Math.ceil(n[1]/2)}, ${l[0]}, ${l[1]}, row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape,s=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(1===n[0]){const r=[1,2],o=["b","row","col"];return`\n ${nb(pb(e,n.slice(1)),t)}\n vec4 ${a}(int b, int row, int col) {\n return ${a}(${hb(o,r)});\n }\n `}const i=qy();if(t)return`\n vec4 ${a}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${i.texture2D}(${r}, uv);\n }\n `;const u=s[0],l=s[1],c=Math.ceil(n[2]/2);return`\n vec4 ${a}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${u}, ${l}, ${c*Math.ceil(n[1]/2)}, ${c}, b, row, col);\n return ${i.texture2D}(${r}, uv);\n }\n `}(e,t);default:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=qy();if(t)return`\n vec4 ${r}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${a.texture2D}(${n}, uv);\n }\n `;const o=e.shapeInfo.logicalShape,s=o.length,i=e.shapeInfo.texShape,u=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],l=u[0],c=u[1],p=Math.ceil(o[s-1]/2);let h=p*Math.ceil(o[s-2]/2),d="int b, int row, int col",f=`b * ${h} + (row / 2) * ${p} + (col / 2)`;for(let e=2;e<s-1;e++)d=`int b${e}, `+d,h*=o[s-e-1],f=`b${e} * ${h} + `+f;return`\n vec4 ${r}(${d}) {\n int index = ${f};\n int texR = index / ${c};\n int texC = index - texR * ${c};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${l});\n return ${a.texture2D}(${n}, uv);\n }\n `}(e,t)}}const rb="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",ab="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",ob="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",sb="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function ib(e){return`offset${e}`}function ub(e){const t=e.name,n=ot(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n `}function lb(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function cb(e,t,n){const{newShape:r,keptDims:a}=dt(t),o=t.length,s=e&&3===o&&1===t[0],i=s?t.slice(1):r,u=!e&&o>1&&!st(t,n)&&r.length<o||s;return{useSqueezeShape:u,uniformShape:u?i:t,keptDims:a}}function pb(e,t){const n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function hb(e,t){return t.map((t=>e[t])).join(", ")}function db(e,t,n){const r={},a={},o={},s=[];let i,u,l,c=null,p=null;p=e.getUniformLocation(n,"NAN",!1),1===Mt().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const h=!1;for(let s=0;s<t.variableNames.length;s++){const i=t.variableNames[s];r[i]=e.getUniformLocation(n,i,h),r[`offset${i}`]=e.getUniformLocation(n,`offset${i}`,h),t.enableShapeUniforms&&(a[`${i}Shape`]=e.getUniformLocation(n,`${i}Shape`,h),o[`${i}TexShape`]=e.getUniformLocation(n,`${i}TexShape`,h))}return t.enableShapeUniforms&&(i=e.getUniformLocation(n,"outShape",h),l=e.getUniformLocation(n,"outShapeStrides",h),u=e.getUniformLocation(n,"outTexShape",h)),t.customUniforms&&t.customUniforms.forEach(((t,r)=>{s[r]=e.getUniformLocation(n,t.name,h)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:o,outShapeLocation:i,outShapeStridesLocation:l,outTexShapeLocation:u}}function fb(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const r=e.logicalShape,a=t[n],o=a.shape;if(!st(r,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${o} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,i=a.isUniform?null:a.texData.texShape;if(!st(s,i))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${i} must match`)}))}function mb(e){return Mt().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class gb{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=vy.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=qy();this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?Xy(["r","c","d"],e):Yy(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n `}}class yb{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=vy.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=qy();this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?Xy(["r","c","d"],e):Yy(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n `}}class bb{constructor(e){this.variableNames=["A"],this.outTexUsage=wy.DOWNLOAD;const t=qy();this.outputShape=e,this.userCode=`\n ${Jy}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class vb{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=wy.DOWNLOAD;const t=qy();this.outputShape=e,this.userCode=`\n ${Jy}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}}const wb={R:0,G:1,B:2,A:3};class xb{constructor(e,t=!1,n="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=qy();this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)");let o="";for(let e=0;e<n.length;e++){const t=n[e];o+=`\n if(offset == ${e}) {\n result = values[${wb[t]}];\n }`}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":Qy(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, ${n.length});\n\n flatIndex = idiv(flatIndex, ${n.length}, 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${r.texture2D}(A, uv);\n ${o}\n }\n ${r.output} = vec4(${a}, 0., 0., 0.);\n }\n `}}class _b{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=qy();this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const o=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${o}] = values[0];\n } else if (offset == 1) {\n result[${o}] = values[1];\n } else if (offset == 2) {\n result[${o}] = values[2];\n } else {\n result[${o}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":Qy(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${a};\n }\n `}}function kb(e,t,n,r,a,o){!function(e,t){const n=Mt().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return Dy(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),i=e.TEXTURE_2D;return Ey(e,(()=>e.bindTexture(i,s))),Ey(e,(()=>e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),Ey(e,(()=>e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),Ey(e,(()=>e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.NEAREST))),Ey(e,(()=>e.texParameteri(i,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Mt().getNumber("WEBGL_VERSION")?Ey(e,(()=>e.texImage2D(i,0,r,t,n,0,a,o,null))):Ey(e,(()=>e.texStorage2D(i,1,r,t,n))),Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function Tb(e){return e.internalFormatFloat}function Sb(e){return e.internalFormatHalfFloat}function Eb(e){return e.downloadTextureFormat}function Ib(e){return e.internalFormatPackedFloat}function Cb(e){return e.internalFormatPackedHalfFloat}class Ab{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=Mt().getNumber("WEBGL_VERSION");if(null!=e?(this.gl=e,function(e,t){gy[e]=t}(t,e)):this.gl=by(t),e=this.gl,2===Mt().getNumber("WEBGL_VERSION")){const t=e;this.createVertexArray=()=>Ey(t,(()=>t.createVertexArray())),this.bindVertexArray=e=>Ey(t,(()=>t.bindVertexArray(e))),this.deleteVertexArray=e=>Ey(t,(()=>t.deleteVertexArray(e))),this.getVertexArray=()=>Ey(t,(()=>t.getParameter(t.VERTEX_ARRAY_BINDING)))}else if(null!=e){const t=e.getExtension("OES_vertex_array_object");if(null==t)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>Ey(e,(()=>t.createVertexArrayOES())),this.bindVertexArray=n=>Ey(e,(()=>t.bindVertexArrayOES(n))),this.deleteVertexArray=n=>Ey(e,(()=>t.deleteVertexArrayOES(n))),this.getVertexArray=()=>Ey(e,(()=>e.getParameter(t.VERTEX_ARRAY_BINDING_OES)))}let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Mt().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=Cy(this.gl,e),jy(this.gl,t))this.textureHalfFloatExtension=Cy(this.gl,t);else if(Mt().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),jy(this.gl,r))this.colorBufferHalfFloatExtension=Cy(this.gl,r);else if(Mt().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",jy(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!jy(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=Dy(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return Ey(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),Ey(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=Dy(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return Ey(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),Ey(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return Dy(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=Sy(this.gl,this.textureHalfFloatExtension)}get debug(){return Mt().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;Ey(e,(()=>e.finish())),Ey(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),Ey(e,(()=>e.deleteFramebuffer(this.framebuffer))),Ey(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),Ey(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),Ey(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=_y(t,n);return kb(e,a,o,Tb(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=_y(t,n);return kb(e,a,o,Sb(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=_y(t,n);return kb(e,a,o,Eb(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Mt().getNumber("WEBGL_VERSION")?Ey(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):Ey(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Mt().getNumber("WEBGL_VERSION")?Ey(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):Ey(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,o){let s,i,u;Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),i=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),i=e.FLOAT,u=o.internalFormatPackedFloat),s.set(a),2===Mt().getNumber("WEBGL_VERSION")?Ey(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,i,s))):Ey(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,i,s))),Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=Ty(t,n);return kb(e,a,o,Cb(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=Ty(t,n);return kb(e,a,o,Ib(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(My(this.gl,this.framebuffer),this.outputTexture=null),Ey(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,o]=_y(t,n),s=new Uint8Array(t*n*4);return Ey(e,(()=>e.readPixels(0,0,a,o,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,o){return function(e,t,n,r,a,o,s,i){const u=e,l=new Float32Array(function(e,t){const[n,r]=Ty(e,t);return n*r*4}(o,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();Ey(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const o=16*t*n;return Ey(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,o,e.STREAM_READ))),Ey(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),Ey(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Mt().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return Ey(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=qy();return function(e,t){const n=Dy(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(Ey(e,(()=>e.shaderSource(n,t))),Ey(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return Dy(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);let r;return Ey(t,(()=>t.attachShader(n,this.vertexShader))),Ey(t,(()=>t.attachShader(n,e))),function(e,t){if(Ey(e,(()=>e.linkProgram(t))),!Mt().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),r=Object.assign(n,{vao:this.createVertexArray()}),this.bindVertexArray(r.vao),Ey(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer))),console.assert(function(e,t,n){return Ey(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),Fy(e,t,"clipSpacePos",n,3,20,0)&&Fy(e,t,"uv",n,2,20,12)}(t,r,this.vertexBuffer),"gpgpu_util.bindVertexProgramAttributeStreams not fully successful."),this.debug&&Ry(t,r),this.setProgram(r),r}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&(Ey(this.gl,(()=>this.gl.deleteProgram(e))),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&(this.bindVertexArray(this.program.vao),this.debug&&Ry(this.gl,this.program)),Ey(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return Dy(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),Ey(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),function(e,t,n,r){Ey(e,(()=>function(e,t,n){!function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)}(e,n),Ey(e,(()=>e.activeTexture(e.TEXTURE0+n))),Ey(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),Ey(e,(()=>e.uniform1i(n,r)))}(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=Ty(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&Ry(this.gl,this.program),$y(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const e=this.getVertexArray();console.assert(e===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}Ey(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),Ey(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=Cy(this.gl,2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await ct((()=>this.disposed||this.isQueryAvailable(e,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let n;"setTimeoutCustom"in Mt().platform&&(n=Mt().platform.setTimeoutCustom.bind(Mt().platform)),ct((()=>(this.pollItems(),0===this.itemsToPoll.length)),(()=>0),null,n)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Oy(this.gl,e,this.framebuffer),this.debug&&$y(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(Oy(this.gl,this.outputTexture,this.framebuffer),this.debug&&$y(this.gl)):My(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;Oy(r,e,this.framebuffer),this.debug&&$y(r),this.outputTexture=e,Ey(r,(()=>r.viewport(0,0,t,n))),Ey(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),Ey(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:Nb,bincountImpl:Rb,bincountReduceImpl:Fb,castImpl:Ob,ceilImpl:Mb,concatImpl:$b,equalImpl:Db,expImpl:Pb,expm1Impl:Lb,floorImpl:Bb,gatherNdImpl:Ub,gatherV2Impl:Wb,greaterImpl:Vb,greaterEqualImpl:zb,lessImpl:jb,lessEqualImpl:Hb,linSpaceImpl:Gb,logImpl:Kb,maxImpl:qb,maximumImpl:Yb,minimumImpl:Xb,multiplyImpl:Qb,negImpl:Jb,notEqualImpl:Zb,prodImpl:ev,raggedGatherImpl:tv,raggedRangeImpl:nv,raggedTensorToTensorImpl:rv,rangeImpl:av,rsqrtImpl:ov,scatterImpl:sv,sigmoidImpl:iv,simpleAbsImpl:uv,sliceImpl:lv,sparseFillEmptyRowsImpl:cv,sparseReshapeImpl:pv,sparseSegmentReductionImpl:hv,sqrtImpl:dv,stridedSliceImpl:fv,stringNGramsImpl:mv,stringSplitImpl:gv,stringToHashBucketFastImpl:yv,subImpl:bv,tileImpl:vv,topKImpl:wv,transposeImpl:xv,uniqueImpl:_v}=Ng;function kv(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function Tv(e,t){return 1===t?[e]:kv(e,t)}class Sv{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=mb(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=Tv("rc",this.rank),t=lb(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t<this.rank;t++)a=`${e[e.length-1-t]},`+a;t.push(a)}return t}getOutOfBoundsCondition(e){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n<this.rank;n++)t+=`${e[n]} >= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n<this.rank-1&&(t+="||");return t}getSetup(e){if(1===this.rank)return"";const t=e.slice(-2),n=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],r=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`\n int r = ${t[0]};\n int c = ${t[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class Ev{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):Yy(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":Qy(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class Iv{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=Av(t,n),a=Nv(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const o=Cv(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===xy.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===xy.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===xy.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===xy.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===xy.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=Av(n,r),o=Nv(t,a,r);o in this.freeTextures||(this.freeTextures[o]=[]);const s=Cv(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),i=Mt().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==i&&this._numBytesAllocated>i?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[o].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[o],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function Cv(e,t,n,r,a){const o=function(e,t){switch(e){case xy.PACKED_2X2_FLOAT32:return Ib(t);case xy.PACKED_2X2_FLOAT16:return Cb(t);case xy.UNPACKED_FLOAT32:return Tb(t);case xy.UNPACKED_FLOAT16:return Sb(t);case xy.PACKED_4X1_UNSIGNED_BYTE:return Eb(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=Ty(e[0],e[1]);s=t*n}else{const[t,n]=_y(e[0],e[1]);s=t*n}const i=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,o);return s*i}function Av(e,t){if(e===wy.UPLOAD)return xy.PACKED_2X2_FLOAT32;if(e===wy.RENDER||null==e)return function(e){return Mt().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?xy.PACKED_2X2_FLOAT32:xy.UNPACKED_FLOAT32:e?xy.PACKED_2X2_FLOAT16:xy.UNPACKED_FLOAT16}(t);if(e===wy.DOWNLOAD||e===wy.PIXELS)return xy.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Nv(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class Rv{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const Fv="if (isnan(x)) return x;",Ov="return abs(x);",Mv="return x;";class $v{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}class Dv{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length);const t=e.length,n=Tv("rc",t),r=lb(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),o=n.slice(-2),s=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 packedInput = getA(${a});\n\n setOutput(getChannel(packedInput, ${s}));\n }\n `}}const Pv=rh,Lv={},Bv=Mt().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");class Uv extends Qe{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!Mt().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(null!=e){if(e instanceof Ab)t=e;else{const n=by(Mt().getNumber("WEBGL_VERSION"),e);t=new Ab(n)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const e=by(Mt().getNumber("WEBGL_VERSION"));t=new Ab(e),this.binaryCache=((n=Mt().getNumber("WEBGL_VERSION"))in Lv||(Lv[n]={}),Lv[n]),this.gpgpuCreatedLocally=!0}var n;this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new Iv(this.gpgpu),this.numMBBeforeWarning=null==Mt().global.screen?1024:Mt().global.screen.height*Mt().global.screen.width*window.devicePixelRatio*600/1024/1024,this.texData=new Xe(this,_i())}nextDataId(){return Uv.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,n,r,a,o){const s=this.makeTensorInfo(t,n),i=this.texData.get(s.dataId);i.isPacked=!1,i.texture={texture:e,texShape:[r,a]},i.texShape=[r,a];const u=By(t),l=new xb(u,!1,o),c=this.runWebGLProgram(l,[s],n,[[r,a]]);return c.shape=t,i.texture=null,this.disposeIntermediateTensorInfo(s),c.dataId}write(e,t,n){if((Mt().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Mt().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:wy.UPLOAD,refCount:1}),r}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){this.texData.get(e).refCount++}decRef(e){this.texData.has(e)&&this.texData.get(e).refCount--}move(e,t,n,r,a){if(Mt().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:wy.UPLOAD,refCount:a})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:a,slice:o,shape:s,isPacked:i}=t;if(null!=o){let t;t=i?new $v(s,Mv):new Rv(s,Mv);const n=this.runWebGLProgram(t,[{dataId:e,shape:s,dtype:r}],r),a=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;const u=null!=this.activeTimers;let l,c;return u&&(l=Ca()),c="complex64"===r?Fd(this.readSync(a.real.dataId),this.readSync(a.imag.dataId)):this.getValuesFromTexture(e),u&&(this.downloadWaitMs+=Ca()-l),this.convertAndCacheOnCPU(e,c)}async read(e){if(this.pendingRead.has(e)){const t=this.pendingRead.get(e);return new Promise((e=>t.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:o,complexTensorInfos:s,isPacked:i}=t;if(null!=a){let t;t=i?new $v(r,Mv):new Rv(r,Mv);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:o}],o),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Mt().getBool("DEBUG")&&!Mt().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Mt().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==o&&Mt().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...ky(r))}if(this.pendingRead.set(e,[]),"complex64"!==o&&await this.gpgpu.createAndWaitForFence(),"complex64"===o){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=Fd(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=ot(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;Ey(e,(()=>e.deleteBuffer(c)))}const p=this.convertAndCacheOnCPU(e,l),h=this.pendingRead.get(e);return this.pendingRead.delete(e),h.forEach((e=>e(p))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&_i().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:o,dtype:s,isPacked:i,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=o){let n;n=i?new $v(a,Mv):new Rv(a,Mv);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),o=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),o}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=_i().makeTensorFromTensorInfo(l),p=this.texData.get(l.dataId);return Object.assign({tensorRef:c},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Na(e)));return Ju(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Ju(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t<e.length;t++){const n=e[t];if(!Iy(n)){if(Mt().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(e){const{shape:t,dtype:n,isPacked:r}=this.texData.get(e),a=ot(t);if(Mt().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(e),r=this.texData.get(n.dataId),o=this.gpgpu.downloadMatrixFromPackedTexture(r.texture.texture,...ky(t)).subarray(0,a);return this.disposeIntermediateTensorInfo(n),o}const o=Mt().getBool("WEBGL_PACK")&&!0===r,s=o?By(t):t,i=o?new vb(s):new bb(s),u=this.runWebGLProgram(i,[{shape:s,dtype:n,dataId:e}],"float32"),l=this.texData.get(u.dataId),c=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture.texture,l.texShape[0],l.texShape[1]).subarray(0,a);return this.disposeIntermediateTensorInfo(u),c}timerAvailable(){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=Fa(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),o=Fa(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=function(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:o[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Ca(),endMs:null}}endTimer(e){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Ca(),e)}async getQueryTime(e){if(Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:o,slice:s}=this.texData.get(e),i=s&&s.origDataId||e,u=this.dataRefCount.get(i);u>1?this.dataRefCount.set(i,u-1):(this.dataRefCount.delete(i),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,o)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=Bv){return Mt().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&ot(e.shape)<t))}getGPGPUContext(){return this.gpgpu}where(e){Mr("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return Pv(e.shape,t)}packedUnaryOp(e,t,n){const r=new $v(e.shape,t),a=this.compileAndRun(r,[e],n);return _i().makeTensorFromTensorInfo(a)}abs(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){const t=uv(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(Mt().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,Ov,e.dtype);const t=new Rv(e.shape,Ov),n=this.compileAndRun(t,[e]);return _i().makeTensorFromTensorInfo(n)}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&bt(n[0])){const a=n.map((e=>Aa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return _i().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new Dv(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new Sv(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[Py(e.shape),...Ly(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[Py(t),...Ly(t)],o=new Ev(a,n),s=[n],i=this.runWebGLProgram(o,[r],e.dtype,s,!0);return{dataId:i.dataId,shape:t,dtype:i.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:o}=n;null!=t&&nt(ot(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=By(a);let i;i=r?new yb(s):new gb(s);const u=[null!=t?t:ky(s)];return{dtype:o,shape:a,dataId:this.runWebGLProgram(i,[{shape:s,dtype:o,dataId:e}],o,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,o){const s=this.makeTensorInfo(e.outputShape,n),i=this.texData.get(s.dataId);if(e.packedOutput&&(i.isPacked=!0),e.outPackingScheme===vy.DENSE){const t=null!=o?o:ky(e.outputShape);i.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(i.usage=e.outTexUsage),0===ot(s.shape))return i.values=ft(s.dtype,0),s;const u=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&ot(t.shape)<=Mt().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!Wy(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:i,isUniform:!1},p=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const o=t.texData.texShape,{useSqueezeShape:s,uniformShape:i,keptDims:u}=cb(e.packedInputs,t.shape,o);let l="",c="",p="";if(1===i.length&&e.packedInputs){const e=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==i.length||e.packedInputs){if(i.length>2&&!e.packedInputs){const e=_t(i);p=`${e[0]===o[1]}_${e[e.length-1]===o[1]}`}}else c=`${i[0]>1}_${i[1]>1}`;const h=t.shape.length,d=2===i.length&&st(t.shape,o),f=1===ot(t.shape),m=Oi(t.shape,n.shape),g=!e.packedInputs&&h===n.shape.length&&st(o,n.texData.texShape),y=e.packedInputs||i.length>2?"":`${o[0]>1}_${o[1]>1}`;r+=`${h}_${g}_${s?u:""}_${i.length}_${f}_${m}_${d}_${l}_${c}_${p}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let o=e.constructor.name;return o+="_"+r+"_"+a+`${Mt().getNumber("WEBGL_VERSION")}`,o}(e,l,c),h=this.getAndSaveBinary(p,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),o=a.map((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},i=eb(a,s,t),u=function(e,t){const n=Dy(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(Ey(e,(()=>e.shaderSource(n,t))),Ey(e,(()=>e.compileShader(n))),Mt().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw Ny(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,i),l=e.createProgram(u);return Mt().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:i,webGLProgram:l,inShapeInfos:o,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:i,webGLProgram:l,inShapeInfos:o,outShapeInfo:s},db(e,t,l))}(this.gpgpu,e,l,c))),d=null!=this.activeTimers;let f;d&&(f=this.startTimer()),Mt().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(fb(t.inShapeInfos,n),fb([t.outShapeInfo],[r]));const o=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(o.texture,s[0],s[1]):e.setOutputMatrixTexture(o.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Mt().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],o=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],i=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(i){const{uniformShape:r}=cb(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(i,new Int32Array(r));break;case 2:e.gl.uniform2iv(i,new Int32Array(r));break;case 3:e.gl.uniform3iv(i,new Int32Array(r));break;case 4:e.gl.uniform4iv(i,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=o)if(n.isUniform)if(ot(n.shape)<2)e.gl.uniform1f(o,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(o,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,o,r)}));const i=t.outShapeLocation;if(i)switch(r.shape.length){case 1:e.gl.uniform1iv(i,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(i,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(i,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(i,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=_t(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const o=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(o,s);else if("vec2"===n.type)e.gl.uniform2fv(o,s);else if("vec3"===n.type)e.gl.uniform3fv(o,s);else if("vec4"===n.type)e.gl.uniform4fv(o,s);else if("int"===n.type)e.gl.uniform1iv(o,s);else if("ivec2"===n.type)e.gl.uniform2iv(o,s);else if("ivec3"===n.type)e.gl.uniform3iv(o,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(o,s)}})),e.executeProgram()}(this.gpgpu,h,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),d&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Mt().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=Ca();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Mt().getBool("WEBGL_LAZILY_UNPACK")&&i.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Mt().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=ki((()=>{if(!Mt().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Mt().getBool("DEBUG");Mt().set("DEBUG",!1);const t=this.abs(Wl(1e-8)).dataSync()[0];if(Mt().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:o,usage:s,isPacked:i}=t;if(null!=o)return;const u=null!=this.activeTimers;let l;u&&(l=Ca());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Mt().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=Mt().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(r===1/0&&Mt().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=n/2),t&&(n*=2,r*=2,e=e.map(((t,n)=>n>=e.length-2?et(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=dt(e);e=t.newShape}let a=ot(e),o=null;e.length<=1&&a<=n?o=[1,a]:2===e.length&&e[0]<=n&&e[1]<=n?o=e:3===e.length&&e[0]*e[1]<=n&&e[2]<=n?o=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=n&&e[1]*e[2]<=n?o=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n?o=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n&&(o=[e[0],e[1]*e[2]*e[3]]);const s=null!=o&&Math.max(...o)>r&&Math.min(...o)<=(t?2:1)&&Math.min(...o)>0;if(null==o||s)if(t){const t=Py(e);let n=2,r=2;e.length&&([n,r]=Ly(e)),a=t*(n/2)*(r/2),o=ut(a).map((e=>2*e))}else o=ut(a);return o}(n,i),t.texShape=c),null!=a){const e=By(n);let o,s=c[1],p=c[0];const h=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!i&&h||([s,p]=Ty(c[0],c[1])),o=i?new _b(e,h):new xb(e,h);const d=h?[p,s]:c,f=this.makeTensorInfo(d,r),m=this.texData.get(f.dataId);m.usage=h?wy.PIXELS:wy.UPLOAD,m.texShape=d,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,p,a);const g=[[p,s]],y=!0,b=this.runWebGLProgram(o,[f],r,g,y),v=this.texData.get(b.dataId);t.texShape=v.texShape,t.isPacked=v.isPacked,t.usage=v.usage,Mt().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=v.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=Ca()-l)}else{const e=this.acquireTexture(c,s,r,i);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t<n.length;++t)n[t]=Math.round(e[t]);return n}throw new Error(`Unknown dtype ${t}`)}(t,r)),n.values}acquireTexture(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*yt(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await new Promise((e=>yd((()=>e())))),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw Ny(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:o,inTexShapesLocations:s,outShapeLocation:i,outShapeStridesLocation:u,outTexShapeLocation:l}=db(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=o,e.inTexShapesLocations=s,e.outShapeLocation=i,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,n){e.channels=e.channels||"RGBA";const{texture:r,height:a,width:o,channels:s}=e,i=_i().backend;if(!i.gpgpu.gl.isTexture(r))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const u=i.writeTexture(r,t,n,a,o,s);return _i().makeTensorFromDataId(u,t,n,i)}}Uv.nextDataId=0,lo()&&Ci("webgl",(()=>new Uv),2);class Wv{constructor(e){this.variableNames=["A"];const t=qy(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}class Vv{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=qy(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}}const zv={kernelName:Ar,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:o}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,i="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,o];if(i||s){const e=Mt().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=jv&&e===Hv||(Hv=e,jv=document.createElement("canvas").getContext("2d",{willReadFrequently:Hv})),jv.canvas.width=u,jv.canvas.height=l,jv.drawImage(a,0,0,u,l),a=jv.canvas}const h=n.makeTensorInfo(c,"int32");n.texData.get(h.dataId).usage=wy.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(h.dataId),a);const d=Mt().getBool("WEBGL_PACK")?new Vv(p):new Wv(p),f=n.runWebGLProgram(d,[h],"int32");return n.disposeData(h.dataId),f}};let jv,Hv=Mt().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function Gv(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:o}=r,s=n,i=ot(a.shape),u=pt(o,i),l=ot(u);nt(i===l,(()=>`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||Wy(a.shape,u)||null!==c.texture&&Wy(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[Py(e.shape),...Ly(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},o=[Py(t),...Ly(t)],s=new Ev(o,r),i=[r],u=n.runWebGLProgram(s,[a],e.dtype,i,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const Kv={kernelName:Yn,backendName:"webgl",kernelFunc:Gv};function qv(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:o}=t,s=o.shape.length,i=o.shape.slice();let u=a;return a<0&&(nt(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),i.splice(u,0,1),Gv({inputs:{x:o},backend:r,attrs:{shape:i}})}const Yv={kernelName:cn,backendName:"webgl",kernelFunc:qv};class Xv{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${i}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}class Qv{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${i}.0,\n ${i}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const Jv={kernelName:Qn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:o,halfPixelCenters:s,size:i}=r,[u,l]=i,c=Mt().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Qv(a.shape,u,l,o,s):new Xv(a.shape,u,l,o,s);return n.runWebGLProgram(c,[a],"float32")}};function Zv(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const ew={kernelName:wn,backendName:"webgl",kernelFunc:Zv};function tw(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,o=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(o.dataId),i=Zv({inputs:{x:r},backend:n}),u=Zv({inputs:{x:a},backend:n});return s.complexTensorInfos={real:i,imag:u},o}class nw{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=$i(t,n),this.enableShapeUniforms=mb(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}class rw{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=$i(t,n);const a=this.outputShape.length;this.enableShapeUniforms=mb(a);let o="";if(r)if(0===a||1===ot(this.outputShape))o="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(o=`\n ${lb(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?o+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":o+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=Tv("coords",a);this.enableShapeUniforms?o+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:o+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${o}\n\n setOutput(result);\n }\n `}}const aw="if (isnan(x)) return x;";function ow({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:o})=>{const{x:s}=a,i=o,u=r||s.dtype;if(i.shouldExecuteOnCPU([s])&&null!=n){const e=i.texData.get(s.dataId),t=n(e.values,u);return i.makeTensorInfo(s.shape,u,t)}let l;return l=Mt().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new $v(s.shape,t):new Rv(s.shape,e),i.runWebGLProgram(l,[s],u)}}function sw({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:o}){return({inputs:s,backend:i})=>{const{a:u,b:l}=s,c=i;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},o={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new nw(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,o],Ja(n.dtype,r.dtype))})),o=tw({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),o}const p=o||Ja(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?Kd(e):e,r="string"===u.dtype?Kd(t):t,[o,s]=a(u.shape,l.shape,n,r,p),i=c.makeTensorInfo(s,p);return c.texData.get(i.dataId).values=o,i}let h;return h=Mt().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new rw(t,u.shape,l.shape,n):new nw(e,u.shape,l.shape),c.runWebGLProgram(h,[u,l],p)}}function iw(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?"\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n":"return (a < 0.) ? b * a : a;";if("leakyrelu"===e)return t?"\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n":"return (a < 0.) ? b * a : a;";if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}const uw=sw({opSnippet:"return float(a != b);",cpuKernelImpl:Zb,dtype:"bool"});function lw(e){const{inputs:t,backend:n}=e,{input:r}=t;return Zv({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const cw={kernelName:Kt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:o}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===o.dtype)return Zv({inputs:{x:o},backend:r});const t=Ac(o.shape),n=e({inputs:{x:o},backend:r,attrs:{dtype:"float32"}}),a=tw({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===o.dtype){const t=lw({inputs:{input:o},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!gt(o.dtype,s)){const e=Zv({inputs:{x:o},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if(r.shouldExecuteOnCPU([o])){const e=r.texData.get(o.dataId).values,[t,n,a]=Ob(e,o.shape,o.dtype,s);return r.makeTensorInfo(t,n,a)}if("int32"===s)return function(e,t){const n=new Rv(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(o,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",ft("bool",1)),t=uw({inputs:{a:o,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${o.dtype} to ${s}`)}},pw=sw({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),hw={kernelName:on,backendName:"webgl",kernelFunc:pw};class dw{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=lb(r),o=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${o});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${i}));\n }\n }\n `:`\n int start = ${o};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class fw{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=lb(r),o=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),i=Tv("rc",r),u=Tv("source",r),l=`${i[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${i[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${i[r-2]} += 1;\n if(${i[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${i[r-1]} += 1;\n if(${l}) {`],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let d="";for(let e=0,t=1===r?2:4;e<t;e++)d+=`\n ${p[e]}\n if (${h}) {\n result[${e}] = float(value);\n } else {\n ${a} source = rc - start;\n result[${e}] = getChannel(getX(${u.join()}), ${c});\n }\n `;d+=1===r?"} ":"}}",this.userCode=`\n const ${a} start = ${a}(${o});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}class mw{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}const gw=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:o,constantValue:s}=r;if(0===ot(a.shape)){const e=o.map(((e,t)=>e[0]+a.shape[t]+e[1]));return function(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:o}=n;if(o=o||vt(a),"string"===o){const e=mt(o,ot(r));return e.fill(a),t.makeTensorInfo(r,o,e)}{const e=new mw(r,a),n=[[a]];return t.runWebGLProgram(e,[],o,n)}}({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const i=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new fw(a.shape,o,s):new dw(a.shape,o,s),u=[[s]];return n.runWebGLProgram(i,[a],a.dtype,u)},yw={kernelName:zn,backendName:"webgl",kernelFunc:gw};class bw{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,s=e.padInfo.left,i=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,h=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let v="",w="";n&&(v=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,w="result = activation(result);");const x=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${v}\n\n const ivec2 strides = ivec2(${i}, ${u});\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${d}) *\n getW(wR, wC, ${d}, d2);\n } else {\n dotProd +=\n getX(batch, ${d}, xR, xC) *\n getW(wR, wC, ${d}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2),\n getW(wR, wC, ${d} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1),\n getX(batch, xR, xC, ${d} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC),\n getX(batch, ${d} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${x}\n ${w}\n setOutput(result);\n }\n `}}class vw{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=mb(this.outputShape.length);const o=e.padInfo.left,s=e.strideWidth,i=e.dilationWidth,u=e.filterHeight,l=e.filterWidth,c=l;let p="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<l;e++)p+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;p+=`\n for (int r = 0; r < ${u}; r++) {\n for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {\n `;for(let e=0;e<l;e++)p+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;p+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let t=0;t<(c+1)/2;t++){const n=2*t;if(p+=`\n xC = xCCorner + ${n*i};\n `,1===s){if(n<l&&(o%2==1?(p+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `,p+=1===i&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):p+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `,n+1<l)){const e=o%2==0?et(i):i;i%2==0&&o%2==1||i%2!=0&&o%2!=1?(p+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n `,p+=i>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n+1} = vec4(previous.zw, xTexelC${n+1}.xy);\n } else {\n xC${n+1} = vec4(0.0, 0.0, xTexelC${n+1}.xy);\n }\n `:`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.xy);\n `):p+=1===e?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n+1} = xTexelC${n+1};\n `}}else n<l&&(o%2==1?(p+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `,n+1<l&&(p+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+1}.xy, final.xy);\n `)):(p+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+1}.xy);\n `,n+1<l&&(p+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `)));n<l&&(p+=`\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `,n+1<l&&(p+=`\n wTexel = getW(r, ${n+1}, d1, d2);\n dotProd += xC${n+1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n+1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `))}p+="\n }\n ",p+="\n }\n ",p+="\n }\n ";let h="",d="";n&&(h=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,d="result = activation(result);");const f=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${h}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${p}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${f}\n ${d}\n setOutput(result);\n }\n `}}class ww{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=mb(this.outputShape.length);const{dataFormat:n}=t,r=qy(),a="channelsLast"===n,o=a?1:2,s=a?2:3,i=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${i}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${o}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}class xw{constructor(e,t,n,r=!1,a=!1,o=!1,s=null,i=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=mb(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",h=a?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=i?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",v="rc.x";e[0]<t[0]?b=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(v=`imod(rc.x, ${t[0]})`),this.userCode=`\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${c}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = ${b};\n int batchB = ${v};\n for (int i = 0; i < ${c}; i++) {\n vec4 a = getMatrixA(batchA, ${p});\n vec4 b = getMatrixB(batchB, ${h});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${d[0]} * ${f[0]});\n result += (${d[1]} * ${f[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${y}\n\n ${g}\n\n setOutput(result);\n }\n `}}class _w{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=$i(t,n),this.userCode=`\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n `}}const kw="return a * b;";function Tw(e){const{inputs:t,backend:n}=e,{a:r,b:a}=t,o=Ja(r.dtype,a.dtype);if("complex64"===r.dtype){const e=n.texData.get(r.dataId),t=n.texData.get(a.dataId),o=new _w("return areal * breal - aimag * bimag;",r.shape,a.shape),s=new _w("return areal * bimag + aimag * breal;",r.shape,a.shape),i=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:r.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:a.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:a.shape}],u=n.runWebGLProgram(o,i,"float32"),l=n.runWebGLProgram(s,i,"float32"),c=tw({inputs:{real:u,imag:l},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),c}if(n.shouldExecuteOnCPU([r,a])){const e=n.texData.get(r.dataId),t=n.texData.get(a.dataId),[s,i]=Qb(r.shape,a.shape,e.values,t.values,o),u=n.makeTensorInfo(i,o);return n.texData.get(u.dataId).values=s,u}let s;return s=Mt().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new rw(kw,r.shape,a.shape):new nw(kw,r.shape,a.shape),n.runWebGLProgram(s,[r,a],o)}const Sw={kernelName:$n,backendName:"webgl",kernelFunc:Tw};class Ew{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:o}=e;this.outputShape=[r,o];const s=4*Math.floor(n/4),i=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${it(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===i}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===i}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===i}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class Iw{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:o}=e;this.outputShape=[r,o];let s="0.0",i="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",i="min"):"max"===t&&(s="-1.0 / 1e-20",i="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");const l=4*Math.floor(n/4),c=n%4;let p=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${i}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${i}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,h="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",h="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",h="bvec4");let d="";a%n>0&&(d=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${d}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${s});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===c}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===c}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function Cw(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=Sd(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let o=e;for(let s=0;s<a.length;s++){const{inSize:i,windowSize:u,outSize:l}=a[s];let c,p;c="mean"===n?0===s?new Ew({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:l},i):new Ew({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:l}):new Iw({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:l},n),p=o,o=r.runWebGLProgram(c,[o],t),p.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(p)}return o}class Aw{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;const r=lb(this.rank),a=function(e){const t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t<e.length;t++)r[e[t]]=n[t];return r.join()}(t);this.userCode=`\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${a}));\n }\n `}}class Nw{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=lb(this.rank),a=kv("rc",this.rank),o=new Array(this.rank);for(let e=0;e<t.length;e++)o[t[e]]=a[e];const s=`vec2(${o.slice(-2).join()})`,i=`++${a[this.rank-1]} < ${n[this.rank-1]}`,u=`getChannel(getA(${o.join()}), ${s})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${u};\n if(${i}) {\n result[1] = ${u};\n }\n --${a[this.rank-1]};\n if(++${a[this.rank-2]} < ${n[this.rank-2]}) {\n result[2] = ${u};\n if(${i}) {\n result[3] = ${u};\n }\n }\n setOutput(result);\n }\n `}}function Rw(e,t,n){const r=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Nw(e.shape,t):new Aw(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function Fw(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,keepDims:s}=r;return function(e,t,n,r){const a=t,o=e.shape.length,s=ht(a,e.shape);let i=s;const u=$l(i,o),l=null!=u;let c=e;l&&(c=Rw(e,u,r),i=Pl(i.length,o)),Ml("sum",i,o);const[p,h]=Fl(c.shape,i);let d=p;n&&(d=Ol(p,s));const f=ot(h),m=Gv({inputs:{x:c},attrs:{shape:[ot(e.shape)/f,f]},backend:r}),g=Cw(m,Ja(e.dtype,"int32"),"sum",r),y=Gv({inputs:{x:g},attrs:{shape:d},backend:r});return r.disposeIntermediateTensorInfo(m),r.disposeIntermediateTensorInfo(g),l&&r.disposeIntermediateTensorInfo(c),y}(a,o,s,n)}function Ow(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{perm:o}=r,s=n,i=a.shape.length,u=new Array(i);for(let e=0;e<u.length;e++)u[e]=a.shape[o[e]];let l;if(s.shouldExecuteOnCPU([a])){const e=s.texData.get(a.dataId).values,t=xv(e,a.shape,a.dtype,o,u);l=s.makeTensorInfo(u,a.dtype),s.texData.get(l.dataId).values=t}else l=Rw(a,o,s);return l}function Mw({a:e,b:t,transposeA:n,transposeB:r,backend:a,bias:o=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:u=null}){const l=e.shape.length,c=t.shape.length,p=n?e.shape[l-2]:e.shape[l-1],h=r?t.shape[c-1]:t.shape[c-2],d=n?e.shape[l-1]:e.shape[l-2],f=r?t.shape[c-2]:t.shape[c-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),y=ot(m),b=ot(g),v=$i(e.shape.slice(0,-2),t.shape.slice(0,-2)).concat([d,f]);nt(p===h,(()=>`Error in matMul: inner shapes (${p}) and (${h}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const w=n?[y,p,d]:[y,d,p],x=r?[b,f,h]:[b,h,f],_=Gv({inputs:{x:e},backend:a,attrs:{shape:w}}),k=Gv({inputs:{x:t},backend:a,attrs:{shape:x}}),T=[_,k],S=Math.max(y,b),E=n?_.shape[1]:_.shape[2],I=null!=o,C=null!=s,A="leakyrelu"===u,N=null!=u?iw(u,!0):null;let R;if((1===d||1===f)&&E>1e3&&!1===(I||C||A||null!=N)){let e=_,t=k;n&&(e=Ow({inputs:{x:_},backend:a,attrs:{perm:[0,2,1]}}),T.push(e)),r&&(t=Ow({inputs:{x:k},backend:a,attrs:{perm:[0,2,1]}}),T.push(t));const o=1===f;let s=e;1!==f&&(s=Gv({inputs:{x:e},backend:a,attrs:{shape:[S,E,1]}}),T.push(s));const i=1===f?2:1;let u=t;o&&(u=Gv({inputs:{x:t},backend:a,attrs:{shape:[S,1,E]}}),T.push(u));const l=Tw({inputs:{a:s,b:u},backend:a});R=Fw({inputs:{x:l},backend:a,attrs:{axis:i,keepDims:!0}}),T.push(l)}else{const u=Ja(e.dtype,t.dtype),l=new xw(w,x,[S,d,f],n,r,I,N,C,A),c=[_,k];if(null!=o&&c.push(o),C&&c.push(s),A){const e=a.makeTensorInfo([],"float32",Ea(i,"float32"));c.push(e),T.push(e)}R=a.runWebGLProgram(l,c,u)}const F=Gv({inputs:{x:R},backend:a,attrs:{shape:v}});T.push(R);for(const e of T)a.disposeIntermediateTensorInfo(e);return F}function $w(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function Dw({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:s=0,activation:i=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,p=u[0]*u[1]*u[2],h=n.outChannels,d="channelsLast"===n.dataFormat;let f;const m=[];if(null!=o){const e=$w(o.shape,d);null!=e&&(o=Gv({inputs:{x:o},backend:r,attrs:{shape:e}}),m.push(o))}if(null!=a){const e=$w(a.shape,d);null!=e&&(a=Gv({inputs:{x:a},backend:r,attrs:{shape:e}}),m.push(a))}if((1!==p&&1!==h||!(c>1e3))&&l.isPacked&&d&&null!=l.texture&&u[2]%2!=0&&st(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),p={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},h=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,nt(Wy(l.shape,p.shape),(()=>`packed reshape ${l.shape} to ${p.shape} isn't free`));const d=Gv({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(d);const g=Mw({a:p,b:d,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:i,preluActivationWeights:o,leakyreluAlpha:s}),y=r.texData.get(g.dataId);nt(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=h,y.shape=n.outShape,f=Zv({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=n.outHeight*n.outWidth,l=Gv({inputs:{x:e},backend:r,attrs:{shape:d?[n.batchSize,u,n.inChannels]:[n.batchSize,n.inChannels,u]}}),c=Gv({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=Mw({a:d?l:c,b:d?c:l,transposeA:!d,transposeB:!1,backend:r,bias:a,activation:i,preluActivationWeights:o,leakyreluAlpha:s});f=Gv({inputs:{x:p},backend:r,attrs:{shape:n.outShape}}),m.push(l),m.push(c),m.push(p)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function Pw({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:s=0,activation:i=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:h,dataFormat:d}=n,f="channelsLast"===d,m=u*l*c,g=h*p,y=[n.batchSize,m,g],b=[];if(null!=o){const e=$w(o.shape,f);null!=e&&(o=Gv({inputs:{x:o},backend:r,attrs:{shape:e}}),b.push(o))}if(null!=a){const e=$w(a.shape,f);null!=e&&(a=Gv({inputs:{x:a},backend:r,attrs:{shape:e}}),b.push(a))}const v=Gv({inputs:{x:t},backend:r,attrs:{shape:[1,m,ot(t.shape)/m]}});b.push(v);const w=new ww(y,n),x=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],_=r.runWebGLProgram(w,[e],"float32",x),k=Gv({inputs:{x:_},backend:r,attrs:{shape:y}});b.push(_),b.push(k);const T=null!=a,S=null!=o,E="leakyrelu"===i,I=i?iw(i,!0):null,C=new xw(f?k.shape:v.shape,f?v.shape:k.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,T,I,S,E),A=f?[k,v]:[v,k];if(a&&A.push(a),S&&A.push(o),E){const e=r.makeTensorInfo([],"float32",Ea(s,"float32"));A.push(e),b.push(e)}const N=r.runWebGLProgram(C,A,"float32"),R=Gv({inputs:{x:N},backend:r,attrs:{shape:n.outShape}});b.push(N);for(const e of b)r.disposeIntermediateTensorInfo(e);return R}const Lw={kernelName:Qt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o}=t,{strides:s,pad:i,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=Ou(u),h=ku(a.shape,o.shape,s,l,i,c,!1,p);let d;if(1!==h.filterHeight||1!==h.filterWidth||1!==h.dilationHeight||1!==h.dilationWidth||1!==h.strideHeight||1!==h.strideWidth||"SAME"!==h.padInfo.type&&"VALID"!==h.padInfo.type)if(h.strideWidth<=2&&"channelsLast"===p&&Mt().getBool("WEBGL_EXP_CONV")){const e=new vw(h),t=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];d=n.runWebGLProgram(e,[a,o],"float32",t)}else if(Mt().getBool("WEBGL_CONV_IM2COL"))d=Pw({x:a,filter:o,convInfo:h,backend:n});else{const e=new bw(h);d=n.runWebGLProgram(e,[a,o],"float32")}else d=Dw({x:a,filter:o,convInfo:h,backend:n});const f=Gv({inputs:{x:d},backend:n,attrs:{shape:h.outShape}});return n.disposeIntermediateTensorInfo(d),f}},Bw={kernelName:Fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=r,m=Ou(c),g=ku(a.shape,o.shape,u,p,l,h,!1,m);let y;const b=[],v=null!=s,w=null!=i,x="leakyrelu"===d,_=()=>{const e=[a,o],t=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=Gv({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(v&&e.push(t(s,c)),w&&e.push(t(i,c)),x){const t=n.makeTensorInfo([],"float32",Ea(f,"float32"));e.push(t),b.push(t)}return e};if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(g.strideWidth<=2&&"channelsLast"===m&&Mt().getBool("WEBGL_EXP_CONV")){const e=d?iw(d,!0):null,t=new vw(g,v,e,w,x),r=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],a=_();y=n.runWebGLProgram(t,a,"float32",r)}else if(Mt().getBool("WEBGL_CONV_IM2COL"))y=Pw({x:a,filter:o,convInfo:g,backend:n,bias:s,activation:d,preluActivationWeights:i,leakyreluAlpha:f});else{const e=d?iw(d,!1):null,t=new bw(g,v,e,w,x),r=_();y=n.runWebGLProgram(t,r,"float32")}else y=Dw({x:a,filter:o,convInfo:g,backend:n,bias:s,activation:d,preluActivationWeights:i,leakyreluAlpha:f});const k=Gv({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),k}};class Uw{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=mb(this.outputShape.length);const o=e.filterHeight,s=e.filterWidth,i=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${i};\n int q = d2 - d1 * ${i};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${o}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n `}}class Ww{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=mb(this.outputShape.length);const o=e.outChannels/e.inChannels,s=e.padInfo.left,i=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let h="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<c;e++)h+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;h+=`\n for (int r = 0; r < ${l}; r++) {\n `;for(let e=0;e<c;e++)h+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;h+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let e=0;e<(p+1)/2;e++){const t=2*e;if(h+=`\n xC = xCCorner + ${t*u};\n `,1===i){if(t<c&&(s%2==1?(h+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,h+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):h+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1<c)){const e=s%2==0?et(u):u;u%2==0&&s%2==1||u%2!=0&&s%2!=1?(h+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,h+=u>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${t+1} = vec4(previous.zw, xTexelC${t+1}.xy);\n } else {\n xC${t+1} = vec4(0.0, 0.0, xTexelC${t+1}.xy);\n }\n `:`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):h+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t<c&&(s%2==1?(h+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1<c&&(h+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(h+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1<c&&(h+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `)));t<c&&(h+=`\n wTexel = getW(r, ${t}, d1, q);\n dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz);\n `,t+1<c&&(h+=`\n wTexel = getW(r, ${t+1}, d1, q);\n dotProd += xC${t+1} * vec4(wTexel.xz, wTexel.xz);\n `))}h+="\n }\n ",h+="\n }\n ";let d="",f="";n&&(d=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,f="result = activation(result);");const m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${h}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${f}\n setOutput(result);\n }\n `}}const Vw={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:h,leakyreluAlpha:d}=r,f=[];let m=c;null==m&&(m=[1,1]),nt(Ru(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=ku(a.shape,o.shape,u,m,l,p,!0),y=Mt().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=h?iw(h,y):null,v=[a,o],w=null!=s,x=null!=i,_="leakyrelu"===h;if(w&&v.push(s),x&&v.push(i),_){const e=n.makeTensorInfo([],"float32",Ea(d,"float32"));v.push(e),f.push(e)}let k;k=y?new Ww(g,w,b,x,_):new Uw(g,w,b,x,_);const T=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(k,v,"float32",T);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),S}},zw="return a + b;",jw=sw({opSnippet:zw,packedOpSnippet:zw,supportsComplex:!0,cpuKernelImpl:Nb}),Hw={kernelName:Bt,backendName:"webgl",kernelFunc:jw},Gw={kernelName:ur,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,paddings:s}=r;nt(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const i=o.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+o.length;e<a.shape.length;++e)u.push([0,0]);const l=[],c=gw({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),p=Id(c.shape,o,i,!1),h=Cd(p.length,o.length,!1),d=Ad(c.shape,o,i,!1),f=Gv({inputs:{x:c},backend:n,attrs:{shape:p}}),m=Ow({inputs:{x:f},backend:n,attrs:{perm:h}}),g=Gv({inputs:{x:m},backend:n,attrs:{shape:d}});return l.push(c),l.push(f),l.push(m),l.forEach((e=>n.disposeIntermediateTensorInfo(e))),g}},Kw={kernelName:an,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:o}=t,{strides:s,pad:i,dilations:u,dimRoundingMode:l}=r;let c=u;null==c&&(c=[1,1]),nt(Ru(s,c),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const p=ku(a.shape,o.shape,s,c,i,l,!0);let h;h=Mt().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new Ww(p):new Uw(p);const d=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(h,[a,o],"float32",d)}};class qw{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=lb(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return Yw.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${Yw[t]} = start[${t}] + coords.${Yw[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const Yw=["x","y","z","w","u","v"];class Xw{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=lb(this.rank),n=Tv("coords",this.rank),r=Tv("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,o=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${o};\n --${r[this.rank-1]};\n }\n `,i=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${r[this.rank-2]};\n result.z = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${o};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${i}\n setOutput(result);\n }\n `}}function Qw(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:o,size:s}=r,[i,u]=tu(a,o,s);if(zi(a,i,u),0===ot(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=lv(e.values,i,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=Zi(a.shape,i,u);if(l||!c){const e=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Xw(u):new qw(u),t=[i];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),o=r.makeTensorInfo(n,e.dtype),s=r.texData.get(o.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let i=eu(t,_t(e.shape));a.slice&&(i+=a.slice.flatOffset),s.slice={flatOffset:i,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),o}(a,i,u,n)}const Jw={kernelName:ar,backendName:"webgl",kernelFunc:Qw},Zw={kernelName:Gt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,crops:s}=r;nt(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const i=o.reduce(((e,t)=>e*t)),u=Id(a.shape,o,i),l=Cd(u.length,o.length),c=Ad(a.shape,o,i),p=Nd(s,o.length),h=Rd(c,s,o.length),d=[],f=Gv({inputs:{x:a},backend:n,attrs:{shape:u}}),m=Ow({inputs:{x:f},backend:n,attrs:{perm:l}}),g=Gv({inputs:{x:m},backend:n,attrs:{shape:c}}),y=Qw({inputs:{x:g},backend:n,attrs:{begin:p,size:h}});return d.push(f),d.push(m),d.push(g),d.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},ex=ow({opSnippet:Fv+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),tx={kernelName:Jn,backendName:"webgl",kernelFunc:ex};class nx{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=lb(n.length),o=lb(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${o} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const rx={kernelName:gr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:o,end:s,strides:i,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:h}=r,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=nu(a.shape,o,s,i,u,l,c,p,h);let x;if(m)x=Gv({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=ji(b,v,w),t=Qw({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});x=Gv({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=Ju(a.shape,a.dtype,e),r=fv(d,t,w,b);x=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new nx(b,w,d);x=n.runWebGLProgram(e,[a],a.dtype)}const _=Gv({inputs:{x},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(x),_}};class ax{constructor(e){this.outputShape=[],this.outputShape=vd(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];const n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){const r=t[e-1];n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${r}));`)}const r=t.length,a=t[t.length-1];n.push(`else setOutput(getT${r}(yR, yC-${a}));`),this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n `}}class ox{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=vd(e,t);const n=this.outputShape,r=n.length,a=lb(r),o=Tv("coords",r),s=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map(((e,t)=>`T${t}`));const i=new Array(e.length-1);i[0]=e[0][t];for(let n=1;n<i.length;n++)i[n]=i[n-1]+e[n][t];const u=s[t],l=s.slice(-2),c=s.join();let p=`if (${u} < ${i[0]}) {\n return getChannel(\n getT0(${c}), vec2(${l.join()}));\n }`;for(let e=1;e<i.length;e++){const t=i[e-1];p+=`\n if (${u} < ${i[e]} && ${u} >= ${i[e-1]}) {\n return getChannel(\n getT${e}(${sx(s,u,t)}),\n vec2(${sx(l,u,t)}));\n }`}const h=i.length,d=i[i.length-1];p+=`\n return getChannel(\n getT${h}(${sx(s,u,d)}),\n vec2(${sx(l,u,d)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${p}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${o}), 0., 0., 0.);\n\n ${o[r-1]} = ${o[r-1]} + 1;\n if (${o[r-1]} < ${n[r-1]}) {\n result.g = getValue(${o});\n }\n\n ${o[r-2]} = ${o[r-2]} + 1;\n if (${o[r-2]} < ${n[r-2]}) {\n result.a = getValue(${o});\n }\n\n ${o[r-1]} = ${o[r-1]} - 1;\n if (${o[r-2]} < ${n[r-2]} &&\n ${o[r-1]} < ${n[r-1]}) {\n result.b = getValue(${o});\n }\n setOutput(result);\n }\n `}}function sx(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function ix(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>lw({inputs:{input:e},backend:n}))),a=e.map((e=>function(e){const{inputs:t,backend:n}=e,{input:r}=t;return Zv({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}({inputs:{input:e},backend:n}))),o=ix(r,t,n),s=ix(a,t,n),i=tw({inputs:{real:o,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),i}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=ot(e.shape.slice(t));return Gv({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),o=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=vd(a.map((e=>e.shape)),1),i=1===a[0].shape[0],u=$b(o,s,r,i),l=vd(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const o=e.filter((e=>ot(e.shape)>0)),s=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&o[0].shape.length>1;if(1===o.length){const t=s?new Rv(e[0].shape,Mv):new $v(e[0].shape,Mv);return n.runWebGLProgram(t,e,r)}const i=Mt().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(o.length>i){const e=[];for(let r=0;r<o.length;r+=i){const a=o.slice(r,r+i);e.push(ix(a,t,n))}const r=ix(e,t,n);for(const t of e)n.disposeIntermediateTensorInfo(t);return r}if(s){const e=new ox(o.map((e=>e.shape)),t);return n.runWebGLProgram(e,o,r)}const{tensors2D:u,outShape:l}=function(e,t,n){const r=vd(e.map((e=>e.shape)),t),a=e.map((e=>Gv({inputs:{x:e},attrs:{shape:[-1,ot(e.shape.slice(t))]},backend:n})));return{tensors2D:a,outShape:r}}(o,t,n),c=new ax(u.map((e=>e.shape))),p=n.runWebGLProgram(c,u,r);u.forEach((e=>n.disposeIntermediateTensorInfo(e)));const h=Gv({inputs:{x:p},attrs:{shape:l},backend:n});return n.disposeIntermediateTensorInfo(p),h}function ux(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,o=ht(a,t[0].shape)[0];bd(t.map((e=>e.shape)),o);const s=vd(t.map((e=>e.shape)),o);if(0===ot(s))return n.makeTensorInfo(s,t[0].dtype,[]);const i=t.filter((e=>ot(e.shape)>0));return 1===i.length?Zv({inputs:{x:i[0]},backend:n}):ix(i,o,n)}const lx={kernelName:Xt,backendName:"webgl",kernelFunc:ux},cx={kernelName:Vn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return qv({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const o=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(o,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const i=[],u=ux({inputs:t.map((e=>{const t=qv({inputs:{input:e},backend:n,attrs:{dim:a}});return i.push(t),t})),backend:n,attrs:{axis:a}});return i.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class px{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,i=n-1-e.padInfo.left,u=o?1:2,l=o?2:3,c=o?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${i});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${o}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const hx={kernelName:Jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:o}=t,{inputShape:s,strides:i,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=Ou(l),h=ku(s,o.shape,i,1,u,c,!1,p),d=new px(h);return n.runWebGLProgram(d,[a,o],"float32")}},dx=ow({opSnippet:Fv+"\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),fx={kernelName:qn,backendName:"webgl",kernelFunc:dx},mx=ow({opSnippet:aw+"\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:iv}),gx={kernelName:or,backendName:"webgl",kernelFunc:mx};class yx{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,s,i,u]=e,[l]=t,[c,p]=n;this.outputShape=[l,c,p,u];const h="bilinear"===r?1:0,[d,f]=[s-1+".0",i-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[b,v,w]=p>1?[""+(i-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${o}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${v};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${d} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${w};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${h} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}const bx={kernelName:nn,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:o,boxInd:s}=t,{cropSize:i,method:u,extrapolationValue:l}=r,c=new yx(a.shape,o.shape,i,u,l);return n.runWebGLProgram(c,[a,o,s],"float32")}};class vx{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=lb(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class wx{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=Tv("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,o=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=lb(n);function i(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,n)));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${a}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return i(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",i(e)}(r.slice())};\n }\n if(${o}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",i(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",i(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const xx={kernelName:Zn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:o}=r,s=a.shape.length,i=ht(o,a.shape);if(0===s)return Zv({inputs:{x:a},backend:n});const u=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wx(a.shape,i):new vx(a.shape,i);return n.runWebGLProgram(u,[a],a.dtype)}},_x="return a - b;",kx=sw({opSnippet:_x,packedOpSnippet:_x,supportsComplex:!0,cpuKernelImpl:bv}),Tx={kernelName:wr,backendName:"webgl",kernelFunc:kx},Sx={kernelName:Er,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a,i=s.shape.length,u=a.shape[o],l=new Array(i-1);let c=0;for(let e=0;e<i;e++)e!==o&&(l[c++]=s.shape[e]);const p=[],h=new Array(i).fill(0),d=s.shape.slice();d[o]=1;const f=new Array(u);for(let e=0;e<f.length;e++){h[o]=e;const t=Qw({inputs:{x:s},backend:n,attrs:{begin:h,size:d}}),r=Gv({inputs:{x:t},backend:n,attrs:{shape:l}});f[e]=r,p.push(t)}return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),f}};class Ex{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:o}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,o];const s="max"===t?">":"<",i=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${i};\n float candidate = getA(batch, inIdx);\n if (candidate ${s} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}class Ix{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,nt(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],o=Math.ceil(a/t);this.outputShape=e.slice(0,-1),o>1&&this.outputShape.push(o),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,i=s.length,u=lb(i),l=Tv("coords",i);let c,p;if(1===o){p=i+1;const e=lb(p);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[i-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[i-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[i-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[i-2]};`}else p=i,c=`\n ${u} sourceLocR = coords;\n ++${l[i-1]};\n ${u} sourceLocG = coords;\n ++${l[i-2]};\n ${u} sourceLocA = coords;\n --${l[i-1]};\n ${u} sourceLocB = coords;\n --${l[i-2]};`;const h=["x","y","z","w","u","v"].slice(0,p),d="."+h[p-1],f=h.map((e=>"int "+e)),m=Tv("sourceLocR",p-1).concat("inIdx.r"),g=Tv("sourceLocG",p-1).concat("inIdx.g"),y=Tv("sourceLocB",p-1).concat("inIdx.b"),b=Tv("sourceLocA",p-1).concat("inIdx.a"),v="max"===n?"greaterThan":"lessThan",w=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,x=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,_=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${h.join()}),\n vec2(${h.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${h.join()}),\n vec2(${h.slice(-2).join()}));\n }\n ${_}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[i-1]} < ${s[i-1]-1};\n bool hasNextRow = ${l[i-2]} < ${s[i-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n sourceLocB${d}, sourceLocA${d}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${x};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${w}\n vec4 candidate = ${x};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}function Cx(e,t,n,r=null){let a=t.shape[0],o=t.shape[1];null!=r&&(a=r.shape[0],o=r.shape[1]);const s=Sd(o),i={windowSize:s,inSize:o,batchSize:a,outSize:Math.ceil(o/s)},u=new Ex(i,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const p=Cx(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function Ax(e,t,n,r=null){const a=null!=r?r.shape:t.shape,o=Sd(a[a.length-1]),s=new Ix(a,o,n,null==r),i=null==r?[t]:[t,r],u=e.runWebGLProgram(s,i,"int32");if(u.shape.length===t.shape.length){const r=Ax(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function Nx(e,t,n,r){const a=[n];if(Ml("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Mt().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],o=e.texData.get(t.dataId);let s=t;null!==o&&o.isPacked&&(s=e.unpackTensor(t),n.push(s));const[i,u]=Fl(s.shape,a),l=ot(u),c=Gv({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const p=Cx(e,c,r);n.push(p);const h=Gv({inputs:{x:p},backend:e,attrs:{shape:i}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),h}return Ax(e,t,r)}const Rx={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o}=r;let s=ht(o,a.shape);const i=$l(s,a.shape.length);let u=a;const l=[];null!=i&&(u=Ow({inputs:{x:a},backend:n,attrs:{perm:i}}),l.push(u),s=Pl(s.length,u.shape.length)),Ml("argMax",[s[0]],u.shape.length);const c=Nx(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},Fx={kernelName:Rn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:o}=t,s=n,i=r.shape.length,u=ht(o,r.shape);let l=u;const c=$l(l,i),p=null!=c,h=s.shouldExecuteOnCPU([r]),d=[];let f=r;if(p){if(h){const e=s.texData.get(f.dataId).values,t=new Array(i);for(let e=0;e<t.length;e++)t[e]=r.shape[c[e]];const n=xv(e,r.shape,r.dtype,c,t);f=s.makeTensorInfo(t,r.dtype),s.texData.get(f.dataId).values=n}else f=Rw(r,c,s);d.push(f),l=Pl(l.length,i)}Ml("sum",l,i);const[m,g]=Fl(f.shape,l);let y=m;a&&(y=Ol(m,u));const b=function(e,t,n,r){const a=ot(t),o=Gv({inputs:{x:e},attrs:{shape:[ot(e.shape)/a,a]},backend:r}),s=Cw(o,"float32","mean",r),i=Gv({inputs:{x:s},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),i}(f,g,y,s);for(const e of d)s.disposeIntermediateTensorInfo(e);return b}},Ox=ow({opSnippet:aw+"\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:Pb,dtype:"float32"}),Mx={kernelName:cr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:o}=r,s=ht([o],a.shape),i=function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:o,keepDims:s}=r,i=a.shape.length,u=ht(o,a.shape);let l=u;const c=$l(l,i),p=null!=c,h=n.shouldExecuteOnCPU([a]);let d=a;if(p){if(h){const e=n.texData.get(d.dataId).values,t=new Array(i);for(let e=0;e<t.length;e++)t[e]=a.shape[c[e]];const r=xv(e,a.shape,a.dtype,c,t);d=n.makeTensorInfo(t,a.dtype),n.texData.get(d.dataId).values=r}else d=Rw(a,c,n);l=Pl(l.length,i)}Ml("max",l,i);const[f,m]=Fl(d.shape,l);let g,y=f;if(s&&(y=Ol(f,u)),h){const e=n.texData.get(d.dataId).values,t=qb(e,ot(m),y,a.dtype);g=n.makeTensorInfo(y,a.dtype),n.texData.get(g.dataId).values=t}else g=function(e,t,n,r){const a=ot(t),o=Gv({inputs:{x:e},attrs:{shape:[ot(e.shape)/a,a]},backend:r}),s=Cw(o,e.dtype,"max",r),i=Gv({inputs:{x:s},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),i}(d,m,y,n);return p&&n.disposeIntermediateTensorInfo(d),g}({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=Ol(i.shape,s),l=Gv({inputs:{x:i},backend:n,attrs:{shape:u}}),c=kx({inputs:{a,b:l},backend:n}),p=Ox({inputs:{x:c},backend:n}),h=Fw({inputs:{x:p},backend:n,attrs:{axis:s,keepDims:!1}}),d=Gv({inputs:{x:h},backend:n,attrs:{shape:u}}),f=pw({inputs:{a:p,b:d},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),f}};class $x{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}class Dx{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const Px={kernelName:Yt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:o,clipValueMax:s}=r;let i;i=Mt().getBool("WEBGL_PACK_CLIP")?new Dx(a.shape):new $x(a.shape);const u=[[o],[s]];return n.runWebGLProgram(i,[a],a.dtype,u)}};class Lx{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,s=e.strideHeight,i=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=e.padInfo.top,d=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${i});\n const ivec2 pads = ivec2(${h}, ${d});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / max(count, 1.0)");const v=4*Math.floor(o/4),w=o%4,x=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${i});\n const ivec2 pads = ivec2(${h}, ${d});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${x}\n }\n\n int xC = xCCorner + ${v};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${x}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${x}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${x}\n }\n }\n setOutput(${b});\n }\n `}}const Bx={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;!function(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&nt("complex64"!==e.dtype,(()=>"avgPool does not support complex64 tensors in the WebGL backend."))}))}(a);const{filterSize:o,strides:s,pad:i,dimRoundingMode:u}=r;nt(Ru(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=_u(a.shape,o,s,1,i,u);if(1===l.filterWidth&&1===l.filterHeight&&st(l.inShape,l.outShape))return Zv({inputs:{x:a},backend:n});const c=new Lx(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},Ux={kernelName:Ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:o}=t,{transposeA:s,transposeB:i}=r;return Mw({a,b:o,transposeA:s,transposeB:i,backend:n})}},Wx={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:o,bias:s,preluActivationWeights:i}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return Mw({a,b:o,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:i,leakyreluAlpha:p,activation:c})}};Ur(Fg),Ur(Og),Ur(Sm),Ur(Dg),Ur(Pg),Ur(Bg),Ur(Kg),Ur(Xg),Ur(Rm),Ur(Qg),Ur(Yg),Ur(Jg),Ur(Zm),Ur(Hg),Ur(Zg),Ur(ry),Ur(ay),Ur(zg),Ur(hg),Ur(xm),Ur(oy),Ur(sy),Ur(ty),Ur(Ig),Ur(iy),Ur(uy),Ur(cy),Ur(mg),Ur(py),Ur(dy),Ur(fy),Ur(my),Ur(zv),Ur(Kv),Ur(Yv),Ur(Jv),Ur(cw),Ur(hw),Ur(yw),Ur(Lw),Ur(Bw),Ur(Vw),Ur(Hw),Ur(Gw),Ur(Kw),Ur(Zw),Ur(Sw),Ur(tx),Ur(rx),Ur(cx),Ur(hx),Ur(fx),Ur(gx),Ur(ew),Ur(bx),Ur(xx),Ur(lx),Ur(Tx),Ur(Sx),Ur(Rx),Ur(Fx),Ur(Jw),Ur(Mx),Ur(Px),Ur(Bx),Ur(Ux),Ur(Wx);var Vx={filename:""};function zx(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){var n=e[0];if(w(n))return jx(n,null);if(x(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return jx(r.map((function(e){return n[e]})),r)}}if("function"==typeof e[e.length-1]){var a=e.pop();return jx(e=1===e.length&&w(e[0])?e[0]:e,null).pipe(J((function(e){return a.apply(void 0,e)})))}return jx(e,null)}function jx(e,t){return new R((function(n){var r=e.length;if(0!==r)for(var a=new Array(r),o=0,s=0,i=function(i){var u=X(e[i]),l=!1;n.add(u.subscribe({next:function(e){l||(l=!0,s++),a[i]=e},error:function(e){return n.error(e)},complete:function(){++o!==r&&l||(s===r&&n.next(t?t.reduce((function(e,t,n){return e[t]=a[n],e}),{}):a),n.complete())}}))},u=0;u<r;u++)i(u);else n.complete()}))}var Hx="undefined"!=typeof window&&window,Gx="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,Kx=Hx||void 0!==Te&&Te||Gx;function qx(e,t){return void 0===t&&(t=null),new t_({method:"GET",url:e,headers:t})}function Yx(e,t,n){return new t_({method:"POST",url:e,body:t,headers:n})}function Xx(e,t){return new t_({method:"DELETE",url:e,headers:t})}function Qx(e,t,n){return new t_({method:"PUT",url:e,body:t,headers:n})}function Jx(e,t,n){return new t_({method:"PATCH",url:e,body:t,headers:n})}var Zx=J((function(e,t){return e.response}));function e_(e,t){return Zx(new t_({method:"GET",url:e,responseType:"json",headers:t}))}var t_=function(e){function t(t){var n=e.call(this)||this,r={async:!0,createXHR:function(){return this.crossDomain?function(){if(Kx.XMLHttpRequest)return new Kx.XMLHttpRequest;if(Kx.XDomainRequest)return new Kx.XDomainRequest;throw new Error("CORS is not supported by your browser")}():function(){if(Kx.XMLHttpRequest)return new Kx.XMLHttpRequest;var e=void 0;try{for(var t=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],n=0;n<3;n++)try{if(e=t[n],new Kx.ActiveXObject(e))break}catch(e){}return new Kx.ActiveXObject(e)}catch(e){throw new Error("XMLHttpRequest is not supported by your browser")}}()},crossDomain:!0,withCredentials:!1,headers:{},method:"GET",responseType:"json",timeout:0};if("string"==typeof t)r.url=t;else for(var a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);return n.request=r,n}var n;return f(t,e),t.prototype._subscribe=function(e){return new n_(e,this.request)},t.create=((n=function(e){return new t(e)}).get=qx,n.post=Yx,n.delete=Xx,n.put=Qx,n.patch=Jx,n.getJSON=e_,n),t}(R),n_=function(e){function t(t,n){var r=e.call(this,t)||this;r.request=n,r.done=!1;var a=n.headers=n.headers||{};return n.crossDomain||r.getHeader(a,"X-Requested-With")||(a["X-Requested-With"]="XMLHttpRequest"),r.getHeader(a,"Content-Type")||Kx.FormData&&n.body instanceof Kx.FormData||void 0===n.body||(a["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8"),n.body=r.serializeBody(n.body,r.getHeader(n.headers,"Content-Type")),r.send(),r}return f(t,e),t.prototype.next=function(e){this.done=!0;var t,n=this,r=n.xhr,a=n.request,o=n.destination;try{t=new r_(e,r,a)}catch(e){return o.error(e)}o.next(t)},t.prototype.send=function(){var e=this.request,t=this.request,n=t.user,r=t.method,a=t.url,o=t.async,s=t.password,i=t.headers,u=t.body;try{var l=this.xhr=e.createXHR();this.setupEvents(l,e),n?l.open(r,a,o,n,s):l.open(r,a,o),o&&(l.timeout=e.timeout,l.responseType=e.responseType),"withCredentials"in l&&(l.withCredentials=!!e.withCredentials),this.setHeaders(l,i),u?l.send(u):l.send()}catch(e){this.error(e)}},t.prototype.serializeBody=function(e,t){if(!e||"string"==typeof e)return e;if(Kx.FormData&&e instanceof Kx.FormData)return e;if(t){var n=t.indexOf(";");-1!==n&&(t=t.substring(0,n))}switch(t){case"application/x-www-form-urlencoded":return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&");case"application/json":return JSON.stringify(e);default:return e}},t.prototype.setHeaders=function(e,t){for(var n in t)t.hasOwnProperty(n)&&e.setRequestHeader(n,t[n])},t.prototype.getHeader=function(e,t){for(var n in e)if(n.toLowerCase()===t.toLowerCase())return e[n]},t.prototype.setupEvents=function(e,t){var n,r,a=t.progressSubscriber;function o(e){var t,n=o,r=n.subscriber,a=n.progressSubscriber,s=n.request;a&&a.error(e);try{t=new s_(this,s)}catch(e){t=e}r.error(t)}function s(e){}function i(e){var t=i,n=t.subscriber,r=t.progressSubscriber,a=t.request;if(4===this.readyState){var o=1223===this.status?204:this.status,s="text"===this.responseType?this.response||this.responseText:this.response;if(0===o&&(o=s?200:0),o<400)r&&r.complete(),n.next(e),n.complete();else{r&&r.error(e);var u=void 0;try{u=new a_("ajax error "+o,this,a)}catch(e){u=e}n.error(u)}}}e.ontimeout=o,o.request=t,o.subscriber=this,o.progressSubscriber=a,e.upload&&"withCredentials"in e&&(a&&(n=function(e){n.progressSubscriber.next(e)},Kx.XDomainRequest?e.onprogress=n:e.upload.onprogress=n,n.progressSubscriber=a),r=function(e){var t,n=r,a=n.progressSubscriber,o=n.subscriber,s=n.request;a&&a.error(e);try{t=new a_("ajax error",this,s)}catch(e){t=e}o.error(t)},e.onerror=r,r.request=t,r.subscriber=this,r.progressSubscriber=a),e.onreadystatechange=s,s.subscriber=this,s.progressSubscriber=a,s.request=t,e.onload=i,i.subscriber=this,i.progressSubscriber=a,i.request=t},t.prototype.unsubscribe=function(){var t=this.done,n=this.xhr;!t&&n&&4!==n.readyState&&"function"==typeof n.abort&&n.abort(),e.prototype.unsubscribe.call(this)},t}(I),r_=function(e,t,n){this.originalEvent=e,this.xhr=t,this.request=n,this.status=t.status,this.responseType=t.responseType||n.responseType,this.response=o_(this.responseType,t)},a_=function(){function e(e,t,n){return Error.call(this),this.message=e,this.name="AjaxError",this.xhr=t,this.request=n,this.status=t.status,this.responseType=t.responseType||n.responseType,this.response=o_(this.responseType,t),this}return e.prototype=Object.create(Error.prototype),e}();function o_(e,t){switch(e){case"json":return function(e){return"response"in e?e.responseType?e.response:JSON.parse(e.response||e.responseText||"null"):JSON.parse(e.responseText||"null")}(t);case"xml":return t.responseXML;default:return"response"in t?t.response:t.responseText}}var s_=function(e,t){return a_.call(this,"ajax timeout",e,t),this.name="AjaxTimeoutError",this},i_=t_.create,u_=Uint8Array,l_=Uint16Array,c_=Uint32Array,p_=new u_([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),h_=new u_([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),d_=new u_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f_=function(e,t){for(var n=new l_(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var a=new c_(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)a[o]=o-n[r]<<5|r;return[n,a]},m_=f_(p_,2),g_=m_[0],y_=m_[1];g_[28]=258,y_[258]=28;for(var b_=f_(h_,0)[0],v_=new l_(32768),w_=0;w_<32768;++w_){var x_=(43690&w_)>>>1|(21845&w_)<<1;x_=(61680&(x_=(52428&x_)>>>2|(13107&x_)<<2))>>>4|(3855&x_)<<4,v_[w_]=((65280&x_)>>>8|(255&x_)<<8)>>>1}var __=function(e,t,n){for(var r=e.length,a=0,o=new l_(t);a<r;++a)++o[e[a]-1];var s,i=new l_(t);for(a=0;a<t;++a)i[a]=i[a-1]+o[a-1]<<1;if(n){s=new l_(1<<t);var u=15-t;for(a=0;a<r;++a)if(e[a])for(var l=a<<4|e[a],c=t-e[a],p=i[e[a]-1]++<<c,h=p|(1<<c)-1;p<=h;++p)s[v_[p]>>>u]=l}else for(s=new l_(r),a=0;a<r;++a)e[a]&&(s[a]=v_[i[e[a]-1]++]>>>15-e[a]);return s},k_=new u_(288);for(w_=0;w_<144;++w_)k_[w_]=8;for(w_=144;w_<256;++w_)k_[w_]=9;for(w_=256;w_<280;++w_)k_[w_]=7;for(w_=280;w_<288;++w_)k_[w_]=8;var T_=new u_(32);for(w_=0;w_<32;++w_)T_[w_]=5;var S_=__(k_,9,1),E_=__(T_,5,1),I_=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},C_=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},A_=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},N_=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof l_?l_:e instanceof c_?c_:u_)(n-t);return r.set(e.subarray(t,n)),r},R_=new u_(0),F_=function(e,t){return e[t]|e[t+1]<<8},O_=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},M_=function(e,t){return O_(e,t)+4294967296*O_(e,t+4)};function $_(e,t){return function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new u_(0);var a=!t||n,o=!n||n.i;n||(n={}),t||(t=new u_(3*r));var s,i=function(e){var n=t.length;if(e>n){var r=new u_(Math.max(2*n,e));r.set(t),t=r}},u=n.f||0,l=n.p||0,c=n.b||0,p=n.l,h=n.d,d=n.m,f=n.n,m=8*r;do{if(!p){n.f=u=C_(e,l,1);var g=C_(e,l+1,3);if(l+=3,!g){var y=e[(C=((s=l)/8|0)+(7&s&&1)+4)-4]|e[C-3]<<8,b=C+y;if(b>r){if(o)throw"unexpected EOF";break}a&&i(c+y),t.set(e.subarray(C,b),c),n.b=c+=y,n.p=l=8*b;continue}if(1==g)p=S_,h=E_,d=9,f=5;else{if(2!=g)throw"invalid block type";var v=C_(e,l,31)+257,w=C_(e,l+10,15)+4,x=v+C_(e,l+5,31)+1;l+=14;for(var _=new u_(x),k=new u_(19),T=0;T<w;++T)k[d_[T]]=C_(e,l+3*T,7);l+=3*w;var S=I_(k),E=(1<<S)-1,I=__(k,S,1);for(T=0;T<x;){var C,A=I[C_(e,l,E)];if(l+=15&A,(C=A>>>4)<16)_[T++]=C;else{var N=0,R=0;for(16==C?(R=3+C_(e,l,3),l+=2,N=_[T-1]):17==C?(R=3+C_(e,l,7),l+=3):18==C&&(R=11+C_(e,l,127),l+=7);R--;)_[T++]=N}}var F=_.subarray(0,v),O=_.subarray(v);d=I_(F),f=I_(O),p=__(F,d,1),h=__(O,f,1)}if(l>m){if(o)throw"unexpected EOF";break}}a&&i(c+131072);for(var M=(1<<d)-1,$=(1<<f)-1,D=l;;D=l){var P=(N=p[A_(e,l)&M])>>>4;if((l+=15&N)>m){if(o)throw"unexpected EOF";break}if(!N)throw"invalid length/literal";if(P<256)t[c++]=P;else{if(256==P){D=l,p=null;break}var L=P-254;if(P>264){var B=p_[T=P-257];L=C_(e,l,(1<<B)-1)+g_[T],l+=B}var U=h[A_(e,l)&$],W=U>>>4;if(!U)throw"invalid distance";if(l+=15&U,O=b_[W],W>3&&(B=h_[W],O+=A_(e,l)&(1<<B)-1,l+=B),l>m){if(o)throw"unexpected EOF";break}a&&i(c+131072);for(var V=c+L;c<V;c+=4)t[c]=t[c-O],t[c+1]=t[c+1-O],t[c+2]=t[c+2-O],t[c+3]=t[c+3-O];c=V}}n.l=p,n.p=D,n.b=c,p&&(u=1,n.m=d,n.d=h,n.n=f)}while(!u);return c==t.length?t:N_(t,0,c)}(e,t)}var D_="undefined"!=typeof TextDecoder&&new TextDecoder;try{D_.decode(R_,{stream:!0})}catch(i){}function P_(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(D_)return D_.decode(e);var a=function(e){for(var t="",n=0;;){var r=e[n++],a=(r>127)+(r>223)+(r>239);if(n+a>e.length)return[t,N_(e,n-1)];a?3==a?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&a?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}}(e),o=a[0];if(a[1].length)throw"invalid utf-8 data";return o}var L_=function(e,t){return t+30+F_(e,t+26)+F_(e,t+28)},B_=function(e,t,n){var r=F_(e,t+28),a=P_(e.subarray(t+46,t+46+r),!(2048&F_(e,t+8))),o=t+46+r,s=O_(e,t+20),i=n&&4294967295==s?U_(e,o):[s,O_(e,t+24),O_(e,t+42)],u=i[0],l=i[1],c=i[2];return[F_(e,t+10),u,l,a,o+F_(e,t+30)+F_(e,t+32),c]},U_=function(e,t){for(;1!=F_(e,t);t+=4+F_(e,t+2));return[M_(e,t+12),M_(e,t+4),M_(e,t+20)]};function W_(e){for(var t={},n=e.length-22;101010256!=O_(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=F_(e,n+8);if(!r)return{};var a=O_(e,n+16),o=4294967295==a;if(o){if(n=O_(e,n-12),101075792!=O_(e,n))throw"invalid zip file";r=O_(e,n+32),a=O_(e,n+48)}for(var s=0;s<r;++s){var i=B_(e,a,o),u=i[0],l=i[1],c=i[2],p=i[3],h=i[4],d=i[5],f=L_(e,d);if(a=h,u){if(8!=u)throw"unknown compression type "+u;t[p]=$_(e.subarray(f,f+l),new u_(c))}else t[p]=N_(e,f,f+l)}return t}function V_(e){if(e)for(var t=0;t<e.length;t++)e[t]=~e[t];return e}var z_=function(){function e(e,t){this.jsonModel=e,this.weights=t}return e.prototype.load=function(){return l(this,void 0,void 0,(function(){var e,t,n,r;return c(this,(function(a){switch(a.label){case 0:return e={modelTopology:this.jsonModel.modelTopology,format:this.jsonModel.format,generatedBy:this.jsonModel.generatedBy,convertedBy:this.jsonModel.convertedBy},null==this.jsonModel.weightsManifest?[3,2]:[4,this.loadWeights()];case 1:t=a.sent(),n=t[0],r=t[1],e.weightSpecs=n,e.weightData=r,a.label=2;case 2:return null!=this.jsonModel.trainingConfig&&(e.trainingConfig=this.jsonModel.trainingConfig),null!=this.jsonModel.userDefinedMetadata&&(e.userDefinedMetadata=this.jsonModel.userDefinedMetadata),[2,e]}}))}))},e.prototype.loadWeights=function(){return l(this,void 0,void 0,(function(){var e,t,n,r,a,o,s,i;return c(this,(function(u){for(e=[],t=[],n=0,r=this.jsonModel.weightsManifest;n<r.length;n++){for(a=r[n],o=0,s=a.paths;o<s.length;o++){if(i=s[o],!this.weights[i])throw new Error("Error loading weights: cannot find ".concat(i));e.push(this.weights[i])}t.push.apply(t,a.weights)}return[2,[t,this.toArrayBuffer(e)]]}))}))},e.prototype.toArrayBuffer=function(e){if(Array.isArray(e)){for(var t=0,n=0,r=e;n<r.length;n++)t+=r[n].length;for(var a=new ArrayBuffer(t),o=new Uint8Array(a),s=0,i=0,u=e;i<u.length;i++)s+=u[i].copy(o,s);return a}return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)},e}(),j_=[],H_=[],G_="undefined"!=typeof Uint8Array?Uint8Array:Array,K_=!1;function q_(){K_=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)j_[t]=e[t],H_[e.charCodeAt(t)]=t;H_["-".charCodeAt(0)]=62,H_["_".charCodeAt(0)]=63}function Y_(e,t,n){for(var r,a,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(j_[(a=r)>>18&63]+j_[a>>12&63]+j_[a>>6&63]+j_[63&a]);return o.join("")}function X_(e){var t;K_||q_();for(var n=e.length,r=n%3,a="",o=[],s=16383,i=0,u=n-r;i<u;i+=s)o.push(Y_(e,i,i+s>u?u:i+s));return 1===r?(t=e[n-1],a+=j_[t>>2],a+=j_[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=j_[t>>10],a+=j_[t>>4&63],a+=j_[t<<2&63],a+="="),o.push(a),o.join("")}function Q_(e,t,n,r,a){var o,s,i=8*a-r-1,u=(1<<i)-1,l=u>>1,c=-7,p=n?a-1:0,h=n?-1:1,d=e[t+p];for(p+=h,o=d&(1<<-c)-1,d>>=-c,c+=i;c>0;o=256*o+e[t+p],p+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+e[t+p],p+=h,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=l}return(d?-1:1)*s*Math.pow(2,o-r)}function J_(e,t,n,r,a,o){var s,i,u,l=8*o-a-1,c=(1<<l)-1,p=c>>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+p>=1?h/u:h*Math.pow(2,1-p))*u>=2&&(s++,u/=2),s+p>=c?(i=0,s=c):s+p>=1?(i=(t*u-1)*Math.pow(2,a),s+=p):(i=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+d]=255&i,d+=f,i/=256,a-=8);for(s=s<<a|i,l+=a;l>0;e[n+d]=255&s,d+=f,s/=256,l-=8);e[n+d-f]|=128*m}var Z_={}.toString,ek=Array.isArray||function(e){return"[object Array]"==Z_.call(e)};function tk(){return rk.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function nk(e,t){if(tk()<t)throw new RangeError("Invalid typed array length");return rk.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=rk.prototype:(null===e&&(e=new rk(t)),e.length=t),e}function rk(e,t,n){if(!(rk.TYPED_ARRAY_SUPPORT||this instanceof rk))return new rk(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return sk(this,e)}return ak(this,e,t,n)}function ak(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),rk.TYPED_ARRAY_SUPPORT?(e=t).__proto__=rk.prototype:e=ik(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!rk.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|ck(t,n),a=(e=nk(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if(lk(t)){var n=0|uk(t.length);return 0===(e=nk(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?nk(e,0):ik(e,t);if("Buffer"===t.type&&ek(t.data))return ik(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ok(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function sk(e,t){if(ok(t),e=nk(e,t<0?0:0|uk(t)),!rk.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function ik(e,t){var n=t.length<0?0:0|uk(t.length);e=nk(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function uk(e){if(e>=tk())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+tk().toString(16)+" bytes");return 0|e}function lk(e){return!(null==e||!e._isBuffer)}function ck(e,t){if(lk(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Pk(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Lk(e).length;default:if(r)return Pk(e).length;t=(""+t).toLowerCase(),r=!0}}function pk(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ek(this,t,n);case"utf8":case"utf-8":return _k(this,t,n);case"ascii":return Tk(this,t,n);case"latin1":case"binary":return Sk(this,t,n);case"base64":return xk(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ik(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function hk(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function dk(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=rk.from(t,r)),lk(t))return 0===t.length?-1:fk(e,t,n,r,a);if("number"==typeof t)return t&=255,rk.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):fk(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function fk(e,t,n,r,a){var o,s=1,i=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,i/=2,u/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var c=-1;for(o=n;o<i;o++)if(l(e,o)===l(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(n+u>i&&(n=i-u),o=n;o>=0;o--){for(var p=!0,h=0;h<u;h++)if(l(e,o+h)!==l(t,h)){p=!1;break}if(p)return o}return-1}function mk(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var i=parseInt(t.substr(2*s,2),16);if(isNaN(i))return s;e[n+s]=i}return s}function gk(e,t,n,r){return Bk(Pk(t,e.length-n),e,n,r)}function yk(e,t,n,r){return Bk(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function bk(e,t,n,r){return yk(e,t,n,r)}function vk(e,t,n,r){return Bk(Lk(t),e,n,r)}function wk(e,t,n,r){return Bk(function(e,t){for(var n,r,a,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,o.push(a),o.push(r);return o}(t,e.length-n),e,n,r)}function xk(e,t,n){return 0===t&&n===e.length?X_(e):X_(e.slice(t,n))}function _k(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var o,s,i,u,l=e[a],c=null,p=l>239?4:l>223?3:l>191?2:1;if(a+p<=n)switch(p){case 1:l<128&&(c=l);break;case 2:128==(192&(o=e[a+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=e[a+1],s=e[a+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[a+1],s=e[a+2],i=e[a+3],128==(192&o)&&128==(192&s)&&128==(192&i)&&(u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&i)>65535&&u<1114112&&(c=u)}null===c?(c=65533,p=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),a+=p}return function(e){var t=e.length;if(t<=kk)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=kk));return n}(r)}rk.TYPED_ARRAY_SUPPORT=void 0===Te.TYPED_ARRAY_SUPPORT||Te.TYPED_ARRAY_SUPPORT,tk(),rk.poolSize=8192,rk._augment=function(e){return e.__proto__=rk.prototype,e},rk.from=function(e,t,n){return ak(null,e,t,n)},rk.TYPED_ARRAY_SUPPORT&&(rk.prototype.__proto__=Uint8Array.prototype,rk.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&rk[Symbol.species]),rk.alloc=function(e,t,n){return function(e,t,n,r){return ok(t),t<=0?nk(e,t):void 0!==n?"string"==typeof r?nk(e,t).fill(n,r):nk(e,t).fill(n):nk(e,t)}(null,e,t,n)},rk.allocUnsafe=function(e){return sk(null,e)},rk.allocUnsafeSlow=function(e){return sk(null,e)},rk.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Uk(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Uk(e.slice(0,0))}(e))},rk.compare=function(e,t){if(!lk(e)||!lk(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,o=Math.min(n,r);a<o;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},rk.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},rk.concat=function(e,t){if(!ek(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return rk.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=rk.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var o=e[n];if(!lk(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,a),a+=o.length}return r},rk.byteLength=ck,rk.prototype._isBuffer=!0,rk.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)hk(this,t,t+1);return this},rk.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)hk(this,t,t+3),hk(this,t+1,t+2);return this},rk.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)hk(this,t,t+7),hk(this,t+1,t+6),hk(this,t+2,t+5),hk(this,t+3,t+4);return this},rk.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?_k(this,0,e):pk.apply(this,arguments)},rk.prototype.equals=function(e){if(!lk(e))throw new TypeError("Argument must be a Buffer");return this===e||0===rk.compare(this,e)},rk.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},rk.prototype.compare=function(e,t,n,r,a){if(!lk(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(a>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),i=Math.min(o,s),u=this.slice(r,a),l=e.slice(t,n),c=0;c<i;++c)if(u[c]!==l[c]){o=u[c],s=l[c];break}return o<s?-1:s<o?1:0},rk.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},rk.prototype.indexOf=function(e,t,n){return dk(this,e,t,n,!0)},rk.prototype.lastIndexOf=function(e,t,n){return dk(this,e,t,n,!1)},rk.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return mk(this,e,t,n);case"utf8":case"utf-8":return gk(this,e,t,n);case"ascii":return yk(this,e,t,n);case"latin1":case"binary":return bk(this,e,t,n);case"base64":return vk(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wk(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},rk.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var kk=4096;function Tk(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Sk(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function Ek(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",o=t;o<n;++o)a+=Dk(e[o]);return a}function Ik(e,t,n){for(var r=e.slice(t,n),a="",o=0;o<r.length;o+=2)a+=String.fromCharCode(r[o]+256*r[o+1]);return a}function Ck(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Ak(e,t,n,r,a,o){if(!lk(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Nk(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,o=Math.min(e.length-n,2);a<o;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function Rk(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,o=Math.min(e.length-n,4);a<o;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function Fk(e,t,n,r,a,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ok(e,t,n,r,a){return a||Fk(e,0,n,4),J_(e,t,n,r,23,4),n+4}function Mk(e,t,n,r,a){return a||Fk(e,0,n,8),J_(e,t,n,r,52,8),n+8}rk.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),rk.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=rk.prototype;else{var a=t-e;n=new rk(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n},rk.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Ck(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r},rk.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Ck(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},rk.prototype.readUInt8=function(e,t){return t||Ck(e,1,this.length),this[e]},rk.prototype.readUInt16LE=function(e,t){return t||Ck(e,2,this.length),this[e]|this[e+1]<<8},rk.prototype.readUInt16BE=function(e,t){return t||Ck(e,2,this.length),this[e]<<8|this[e+1]},rk.prototype.readUInt32LE=function(e,t){return t||Ck(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},rk.prototype.readUInt32BE=function(e,t){return t||Ck(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},rk.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Ck(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},rk.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Ck(e,t,this.length);for(var r=t,a=1,o=this[e+--r];r>0&&(a*=256);)o+=this[e+--r]*a;return o>=(a*=128)&&(o-=Math.pow(2,8*t)),o},rk.prototype.readInt8=function(e,t){return t||Ck(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},rk.prototype.readInt16LE=function(e,t){t||Ck(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},rk.prototype.readInt16BE=function(e,t){t||Ck(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},rk.prototype.readInt32LE=function(e,t){return t||Ck(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},rk.prototype.readInt32BE=function(e,t){return t||Ck(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},rk.prototype.readFloatLE=function(e,t){return t||Ck(e,4,this.length),Q_(this,e,!0,23,4)},rk.prototype.readFloatBE=function(e,t){return t||Ck(e,4,this.length),Q_(this,e,!1,23,4)},rk.prototype.readDoubleLE=function(e,t){return t||Ck(e,8,this.length),Q_(this,e,!0,52,8)},rk.prototype.readDoubleBE=function(e,t){return t||Ck(e,8,this.length),Q_(this,e,!1,52,8)},rk.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ak(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,o=0;for(this[t]=255&e;++o<n&&(a*=256);)this[t+o]=e/a&255;return t+n},rk.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Ak(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,o=1;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+n},rk.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,1,255,0),rk.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},rk.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,2,65535,0),rk.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Nk(this,e,t,!0),t+2},rk.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,2,65535,0),rk.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Nk(this,e,t,!1),t+2},rk.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,4,4294967295,0),rk.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Rk(this,e,t,!0),t+4},rk.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,4,4294967295,0),rk.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Rk(this,e,t,!1),t+4},rk.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Ak(this,e,t,n,a-1,-a)}var o=0,s=1,i=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===i&&0!==this[t+o-1]&&(i=1),this[t+o]=(e/s>>0)-i&255;return t+n},rk.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Ak(this,e,t,n,a-1,-a)}var o=n-1,s=1,i=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===i&&0!==this[t+o+1]&&(i=1),this[t+o]=(e/s>>0)-i&255;return t+n},rk.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,1,127,-128),rk.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},rk.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,2,32767,-32768),rk.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Nk(this,e,t,!0),t+2},rk.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,2,32767,-32768),rk.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Nk(this,e,t,!1),t+2},rk.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,4,2147483647,-2147483648),rk.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Rk(this,e,t,!0),t+4},rk.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Ak(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),rk.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Rk(this,e,t,!1),t+4},rk.prototype.writeFloatLE=function(e,t,n){return Ok(this,e,t,!0,n)},rk.prototype.writeFloatBE=function(e,t,n){return Ok(this,e,t,!1,n)},rk.prototype.writeDoubleLE=function(e,t,n){return Mk(this,e,t,!0,n)},rk.prototype.writeDoubleBE=function(e,t,n){return Mk(this,e,t,!1,n)},rk.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,o=r-n;if(this===e&&n<t&&t<r)for(a=o-1;a>=0;--a)e[a+t]=this[a+n];else if(o<1e3||!rk.TYPED_ARRAY_SUPPORT)for(a=0;a<o;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},rk.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!rk.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=lk(e)?e:Pk(new rk(e,r).toString()),i=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%i]}return this};var $k=/[^+\/0-9A-Za-z-_]/g;function Dk(e){return e<16?"0"+e.toString(16):e.toString(16)}function Pk(e,t){var n;t=t||1/0;for(var r=e.length,a=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&o.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Lk(e){return function(e){var t,n,r,a,o,s;K_||q_();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[i-2]?2:"="===e[i-1]?1:0,s=new G_(3*i/4-o),r=o>0?i-4:i;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)a=H_[e.charCodeAt(t)]<<18|H_[e.charCodeAt(t+1)]<<12|H_[e.charCodeAt(t+2)]<<6|H_[e.charCodeAt(t+3)],s[u++]=a>>16&255,s[u++]=a>>8&255,s[u++]=255&a;return 2===o?(a=H_[e.charCodeAt(t)]<<2|H_[e.charCodeAt(t+1)]>>4,s[u++]=255&a):1===o&&(a=H_[e.charCodeAt(t)]<<10|H_[e.charCodeAt(t+1)]<<4|H_[e.charCodeAt(t+2)]>>2,s[u++]=a>>8&255,s[u++]=255&a),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace($k,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Bk(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function Uk(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Wk(e,t){var n=new he(0),r=new he(0),a=new he(0),o=new he(0),s=K([n,r,a,o]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})));if("string"==typeof e){var i=function(e,t){return i_({url:e,method:"GET",responseType:"arraybuffer",async:!0,progressSubscriber:new I((function(e){return t.next(e.loaded/e.total)}),(function(e){}),(function(){return t.next(1)}))}).pipe(de(2))}(e,n).pipe(ge((function(e){return Vk(e.response)})),ge((function(e){return zk(e,t,r).pipe(J((function(t){return{jszip:e,config:t}})))})),ge((function(e){var t=e.jszip,n=e.config;return jk(t,n,a).pipe(J((function(e){return{jszip:t,config:n,jsonModel:e}})))})),ge((function(e){var t=e.jszip,n=e.config,r=e.jsonModel;return Hk(t,r,o).pipe(J((function(e){return{config:n,jsonModel:r,weights:e}})))})),ge((function(e){var t=e.config,n=e.jsonModel,r=e.weights;return X(dm(new z_(n,r))).pipe(J((function(e){return{config:t,graphModel:e}})))})));return{model$:i,progress$:s}}return i=Vk(e).pipe(ge((function(e){return zk(e,t,r).pipe(J((function(t){return{jszip:e,config:t}})))})),ge((function(e){var t=e.jszip,n=e.config;return jk(t,n,a).pipe(J((function(e){return{jszip:t,config:n,jsonModel:e}})))})),ge((function(e){var t=e.jszip,n=e.config,r=e.jsonModel;return Hk(t,r,o).pipe(J((function(e){return{config:n,jsonModel:r,weights:e}})))})),ge((function(e){var t=e.config,n=e.jsonModel,r=e.weights;return X(dm(new z_(n,r))).pipe(J((function(e){return{config:t,graphModel:e}})))}))),{model$:i,progress$:s}}function Vk(e){return Q(W_(new Uint8Array(e)))}function zk(e,t,n){return e[t]||(t=t.substring(0,t.lastIndexOf("."))+".json",e[t])?ke((function(){return n.next(1),t.includes(".bin")?Q(JSON.parse(P_(V_(e[t])))):Q(JSON.parse(P_(e[t])))})):ne("Unable to retrieve model config: ".concat(t," is missing"))}function jk(e,t,n){return t?e[t.filename]?ke((function(){return n.next(1),Q(JSON.parse(P_(V_(e[t.filename]))))})):ne("Error extracting model: ".concat(t.filename," is missing")):ne("Invalid model config")}function Hk(e,t,n){if(!t)return ne("Unable to extract weights: model is undefined");if(!t.weightsManifest)return n.next(1),Q({});for(var r=0,a=0,o=t.weightsManifest;a<o.length;a++){var s=o[a];r+=s.paths.length}for(var i=new Array(r).fill(0),u={},l=0,c=0,p=t.weightsManifest;c<p.length;c++)for(var h=function(t){if(!e[t])return{value:ne("Error extracting weight: ".concat(t," is missing"))};u[t]=ke((function(){var a=e[t];return i[l]=1,n.next(i.reduce((function(e,t){return e+t}),0)/r),Q(V_(rk.from(a,a.byteOffset,a.byteLength)))})),l++},d=0,f=(s=p[c]).paths;d<f.length;d++){var m=h(f[d]);if("object"==typeof m)return m.value}return zx(u)}Dt.set("DEPRECATION_WARNINGS_ENABLED",!1),Dt.global.Math=Math,Dt.global.Float32Array=Float32Array,Mt().set("WEBGL_FORCE_F16_TEXTURES",!0);var Gk,Kk,qk,Yk=function(){function e(){this._initialized=!1}return e.prototype.getWidth=function(){return this._modelConfig?this._modelConfig.inWidth:0},e.prototype.getHeight=function(){return this._modelConfig?this._modelConfig.inHeight:0},e.prototype.isInitialized=function(){return this._initialized},e.prototype.getOutput=function(){return this._cnnOutputData},e.prototype.initialize=function(e,t,n){return l(this,void 0,void 0,(function(){var r,a,o,s,i=this;return c(this,(function(l){switch(l.label){case 0:if(null==e)throw"Invalid parameter";return this.release(),this._videoManager=e,this._config=t?u(u({},Vx),t):Vx,r=Wk(this._config.filename,"config.json"),a=r.model$,o=r.progress$,s=o.pipe(J((function(e){return n&&n(e)}))).subscribe(),[4,a.pipe(J((function(e){var t=e.config,n=e.graphModel;i._modelConfig=t,i._model=n;var r=Ac([1,i._modelConfig.inHeight,i._modelConfig.inWidth,i._modelConfig.inChannels]),a=i._model.predict(r,{batchSize:1,verbose:!0});Array.isArray(a)?a.forEach((function(e){e.dispose()})):a.dispose(),i._cnnOutput=Ac([1,i._modelConfig.inHeight,i._modelConfig.inWidth,1]),r.dispose(),i._initialized=!0})),ae((function(){return s.unsubscribe()}))).toPromise()];case 1:return l.sent(),[2]}}))}))},e.prototype.processSync=function(){var e;if(this._initialized){var t=this._videoManager.getLastBuffer();if(null!=t){var n,r=Li(t),a=hd.resizeBilinear(r,[this._modelConfig.inHeight,this._modelConfig.inWidth]),o=vi(a,"float32"),s=$u(o,[1,this._modelConfig.inHeight,this._modelConfig.inWidth,3]),i=Wl(255);if(4==this._modelConfig.inChannels){var u=$u(this._cnnOutput,[1,this._modelConfig.inHeight,this._modelConfig.inWidth,1]),l=iu(s,i);n=Bu([l,u],3),l.dispose(),u.dispose()}else n=iu(s,i);var c,p=this._model.predict(n);c=Array.isArray(p)?p[2]:p,null===(e=this._cnnOutput)||void 0===e||e.dispose();var h=c.shape;if(h&&h[3]>1){var d=Lp(c);this._cnnOutput=Wu(d,[0,0,0,1],[-1,-1,-1,1]),d.dispose(),this._cnnOutputData=this._cnnOutput.dataSync()}else this._cnnOutput=tl(c,0,1),this._cnnOutputData=this._cnnOutput.dataSync();Array.isArray(p)?p.forEach((function(e){e.dispose()})):p.dispose(),r.dispose(),a.dispose(),o.dispose(),s.dispose(),i.dispose(),n.dispose()}else console.error("No video frame to process")}else console.error("Foot must be initialized to track")},e.prototype.release=function(){var e,t;null===(e=this._cnnOutput)||void 0===e||e.dispose(),null===(t=this._model)||void 0===t||t.dispose(),this._initialized=!1},e}(),Xk=(Gk="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,r;t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){n=e,r=t}));var a=Object.assign({},t),o="./this.program",s="";"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),Gk&&(s=Gk),s=0!==s.indexOf("blob:")?s.substr(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var i,u=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);Object.assign(t,a),a=null,t.thisProgram&&(o=t.thisProgram),t.wasmBinary&&(i=t.wasmBinary),t.noExitRuntime,"object"!=typeof WebAssembly&&O("no native wasm support detected");var c,p,h,d,f,m,g,y,b=!1,v="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function w(e,t){for(var n=t+NaN,r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&v)return v.decode(e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var s=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|s:(7&a)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n}function x(e){return e?w(h,e):""}function _(e,t,n,r){if(!(0<r))return 0;var a=n;r=n+r-1;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),127>=s){if(n>=r)break;t[n++]=s}else{if(2047>=s){if(n+1>=r)break;t[n++]=192|s>>6}else{if(65535>=s){if(n+2>=r)break;t[n++]=224|s>>12}else{if(n+3>=r)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63}t[n++]=128|s>>6&63}t[n++]=128|63&s}}return t[n]=0,n-a}function k(){var e=c.buffer;t.HEAP8=p=new Int8Array(e),t.HEAP16=d=new Int16Array(e),t.HEAP32=f=new Int32Array(e),t.HEAPU8=h=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=m=new Uint32Array(e),t.HEAPF32=g=new Float32Array(e),t.HEAPF64=y=new Float64Array(e)}var T=[],S=[],E=[];function I(){var e=t.preRun.shift();T.unshift(e)}var C,A,N,R=0,F=null;function O(e){throw t.onAbort&&t.onAbort(e),l(e="Aborted("+e+")"),b=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),r(e),e}function M(e){return e.startsWith("data:application/octet-stream;base64,")}if(!M(C="libxzimgPoseEstimation.wasm")){var $=C;C=t.locateFile?t.locateFile($,s):s+$}function D(e){try{if(e==C&&i)return new Uint8Array(i);throw"both async and sync fetching of the wasm failed"}catch(e){O(e)}}function P(e,t,n){return function(e){return i||"function"!=typeof fetch?Promise.resolve().then((function(){return D(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return D(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){l("failed to asynchronously prepare wasm: "+e),O(e)}))}function L(e){for(;0<e.length;)e.shift()(t)}function B(e){this.F=e-24,this.ta=function(e){m[this.F+4>>2]=e},this.oa=function(e){m[this.F+8>>2]=e},this.pa=function(){f[this.F>>2]=0},this.ma=function(){p[this.F+12>>0]=0},this.qa=function(){p[this.F+13>>0]=0},this.I=function(e,t){this.la(),this.ta(e),this.oa(t),this.pa(),this.ma(),this.qa()},this.la=function(){m[this.F+16>>2]=0}}var U=(e,t)=>{for(var n=0,r=e.length-1;0<=r;r--){var a=e[r];"."===a?e.splice(r,1):".."===a?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift("..");return e},W=e=>{var t="/"===e.charAt(0),n="/"===e.substr(-1);return(e=U(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},V=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."},z=e=>{if("/"===e)return"/";var t=(e=(e=W(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)};function j(){for(var e="",t=!1,n=arguments.length-1;-1<=n&&!t;n--){if("string"!=typeof(t=0<=n?arguments[n]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=U(e.split("/").filter((e=>!!e)),!t).join("/"))||"."}function H(e,t){for(var n=0,r=0;r<e.length;++r){var a=e.charCodeAt(r);127>=a?n++:2047>=a?n+=2:55296<=a&&57343>=a?(n+=4,++r):n+=3}return e=_(e,n=Array(n+1),0,n.length),t&&(n.length=e),n}var G=[];function K(e,t){G[e]={input:[],m:[],J:t},xe(e,J)}var q,Y,X,Q,J={open:function(e){var t=G[e.node.P];if(!t)throw new ue(43);e.l=t,e.seekable=!1},close:function(e){e.l.J.M(e.l)},M:function(e){e.l.J.M(e.l)},read:function(e,t,n,r){if(!e.l||!e.l.J.ca)throw new ue(60);for(var a=0,o=0;o<r;o++){try{var s=e.l.J.ca(e.l)}catch(e){throw new ue(29)}if(void 0===s&&0===a)throw new ue(6);if(null==s)break;a++,t[n+o]=s}return a&&(e.node.timestamp=Date.now()),a},write:function(e,t,n,r){if(!e.l||!e.l.J.V)throw new ue(60);try{for(var a=0;a<r;a++)e.l.J.V(e.l,t[n+a])}catch(e){throw new ue(29)}return r&&(e.node.timestamp=Date.now()),a}},Z={ca:function(e){if(!e.input.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n"),!t)return null;e.input=H(t,!0)}return e.input.shift()},V:function(e,t){null===t||10===t?(u(w(e.m,0)),e.m=[]):0!=t&&e.m.push(t)},M:function(e){e.m&&0<e.m.length&&(u(w(e.m,0)),e.m=[])}},ee={V:function(e,t){null===t||10===t?(l(w(e.m,0)),e.m=[]):0!=t&&e.m.push(t)},M:function(e){e.m&&0<e.m.length&&(l(w(e.m,0)),e.m=[])}},te={o:null,v:function(){return te.createNode(null,"/",16895,0)},createNode:function(e,t,n,r){if(24576==(61440&n)||4096==(61440&n))throw new ue(63);return te.o||(te.o={dir:{node:{B:te.h.B,s:te.h.s,K:te.h.K,N:te.h.N,ha:te.h.ha,ja:te.h.ja,ia:te.h.ia,ga:te.h.ga,R:te.h.R},stream:{D:te.i.D}},file:{node:{B:te.h.B,s:te.h.s},stream:{D:te.i.D,read:te.i.read,write:te.i.write,Y:te.i.Y,da:te.i.da,fa:te.i.fa}},link:{node:{B:te.h.B,s:te.h.s,L:te.h.L},stream:{}},Z:{node:{B:te.h.B,s:te.h.s},stream:we}}),16384==(61440&(n=fe(e,t,n,r)).mode)?(n.h=te.o.dir.node,n.i=te.o.dir.stream,n.g={}):32768==(61440&n.mode)?(n.h=te.o.file.node,n.i=te.o.file.stream,n.j=0,n.g=null):40960==(61440&n.mode)?(n.h=te.o.link.node,n.i=te.o.link.stream):8192==(61440&n.mode)&&(n.h=te.o.Z.node,n.i=te.o.Z.stream),n.timestamp=Date.now(),e&&(e.g[t]=n,e.timestamp=n.timestamp),n},Ga:function(e){return e.g?e.g.subarray?e.g.subarray(0,e.j):new Uint8Array(e.g):new Uint8Array(0)},$:function(e,t){var n=e.g?e.g.length:0;n>=t||(t=Math.max(t,n*(1048576>n?2:1.125)>>>0),0!=n&&(t=Math.max(t,256)),n=e.g,e.g=new Uint8Array(t),0<e.j&&e.g.set(n.subarray(0,e.j),0))},ua:function(e,t){if(e.j!=t)if(0==t)e.g=null,e.j=0;else{var n=e.g;e.g=new Uint8Array(t),n&&e.g.set(n.subarray(0,Math.min(t,e.j))),e.j=t}},h:{B:function(e){var t={};return t.Fa=8192==(61440&e.mode)?e.id:1,t.Ia=e.id,t.mode=e.mode,t.Ka=1,t.uid=0,t.Ha=0,t.P=e.P,16384==(61440&e.mode)?t.size=4096:32768==(61440&e.mode)?t.size=e.j:40960==(61440&e.mode)?t.size=e.link.length:t.size=0,t.Ca=new Date(e.timestamp),t.Ja=new Date(e.timestamp),t.Ea=new Date(e.timestamp),t.ka=4096,t.Da=Math.ceil(t.size/t.ka),t},s:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&te.ua(e,t.size)},K:function(){throw le[44]},N:function(e,t,n,r){return te.createNode(e,t,n,r)},ha:function(e,t,n){if(16384==(61440&e.mode)){try{var r=de(t,n)}catch(e){}if(r)for(var a in r.g)throw new ue(55)}delete e.parent.g[e.name],e.parent.timestamp=Date.now(),e.name=n,t.g[n]=e,t.timestamp=e.parent.timestamp,e.parent=t},ja:function(e,t){delete e.g[t],e.timestamp=Date.now()},ia:function(e,t){var n,r=de(e,t);for(n in r.g)throw new ue(55);delete e.g[t],e.timestamp=Date.now()},ga:function(e){var t,n=[".",".."];for(t in e.g)e.g.hasOwnProperty(t)&&n.push(t);return n},R:function(e,t,n){return(e=te.createNode(e,t,41471,0)).link=n,e},L:function(e){if(40960!=(61440&e.mode))throw new ue(28);return e.link}},i:{read:function(e,t,n,r,a){var o=e.node.g;if(a>=e.node.j)return 0;if(8<(e=Math.min(e.node.j-a,r))&&o.subarray)t.set(o.subarray(a,a+e),n);else for(r=0;r<e;r++)t[n+r]=o[a+r];return e},write:function(e,t,n,r,a,o){if(t.buffer===p.buffer&&(o=!1),!r)return 0;if((e=e.node).timestamp=Date.now(),t.subarray&&(!e.g||e.g.subarray)){if(o)return e.g=t.subarray(n,n+r),e.j=r;if(0===e.j&&0===a)return e.g=t.slice(n,n+r),e.j=r;if(a+r<=e.j)return e.g.set(t.subarray(n,n+r),a),r}if(te.$(e,a+r),e.g.subarray&&t.subarray)e.g.set(t.subarray(n,n+r),a);else for(o=0;o<r;o++)e.g[a+o]=t[n+o];return e.j=Math.max(e.j,a+r),r},D:function(e,t,n){if(1===n?t+=e.position:2===n&&32768==(61440&e.node.mode)&&(t+=e.node.j),0>t)throw new ue(28);return t},Y:function(e,t,n){te.$(e.node,t+n),e.node.j=Math.max(e.node.j,t+n)},da:function(e,t,n,r,a){if(32768!=(61440&e.node.mode))throw new ue(43);if(e=e.node.g,2&a||e.buffer!==p.buffer){if((0<n||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):Array.prototype.slice.call(e,n,n+t)),n=!0,O(),!(t=void 0))throw new ue(48);p.set(e,t)}else n=!1,t=e.byteOffset;return{F:t,Ba:n}},fa:function(e,t,n,r){return te.i.write(e,t,0,r,n,!1),0}}},ne=null,re={},ae=[],oe=1,se=null,ie=!0,ue=null,le={},ce=(e,t={})=>{if(!(e=j(e)))return{path:"",node:null};if(8<(t=Object.assign({ba:!0,W:0},t)).W)throw new ue(32);e=e.split("/").filter((e=>!!e));for(var n=ne,r="/",a=0;a<e.length;a++){var o=a===e.length-1;if(o&&t.parent)break;if(n=de(n,e[a]),r=W(r+"/"+e[a]),n.O&&(!o||o&&t.ba)&&(n=n.O.root),!o||t.aa)for(o=0;40960==(61440&n.mode);)if(n=Ee(r),r=j(V(r),n),n=ce(r,{W:t.W+1}).node,40<o++)throw new ue(32)}return{path:r,node:n}},pe=e=>{for(var t;;){if(e===e.parent)return e=e.v.ea,t?"/"!==e[e.length-1]?e+"/"+t:e+t:e;t=t?e.name+"/"+t:e.name,e=e.parent}},he=(e,t)=>{for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%se.length},de=(e,t)=>{var n;if(n=(n=ye(e,"x"))?n:e.h.K?0:2)throw new ue(n,e);for(n=se[he(e.id,t)];n;n=n.sa){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return e.h.K(e,t)},fe=(e,t,n,r)=>(e=new Ve(e,t,n,r),t=he(e.parent.id,e.name),e.sa=se[t],se[t]=e),me={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},ge=e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},ye=(e,t)=>ie?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2,be=(e,t)=>{try{return de(e,t),20}catch(e){}return ye(e,"wx")},ve=(e,t)=>(X||((X=function(){this.I={}}).prototype={},Object.defineProperties(X.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},flags:{get:function(){return this.I.flags},set:function(e){this.I.flags=e}},position:{get:function(){return this.I.position},set:function(e){this.I.position=e}}})),e=Object.assign(new X,e),t=((e=0)=>{for(;4096>=e;e++)if(!ae[e])return e;throw new ue(33)})(t),e.A=t,ae[t]=e),we={open:e=>{e.i=re[e.node.P].i,e.i.open&&e.i.open(e)},D:()=>{throw new ue(70)}},xe=(e,t)=>{re[e]={i:t}},_e=(e,t)=>{var n="/"===t,r=!t;if(n&&ne)throw new ue(10);if(!n&&!r){var a=ce(t,{ba:!1});if(t=a.path,(a=a.node).O)throw new ue(10);if(16384!=(61440&a.mode))throw new ue(54)}t={type:e,La:{},ea:t,ra:[]},(e=e.v(t)).v=t,t.root=e,n?ne=e:a&&(a.O=t,a.v&&a.v.ra.push(t))},ke=(e,t,n)=>{var r=ce(e,{parent:!0}).node;if(!(e=z(e))||"."===e||".."===e)throw new ue(28);var a=be(r,e);if(a)throw new ue(a);if(!r.h.N)throw new ue(63);return r.h.N(r,e,t,n)},Te=(e,t,n)=>{void 0===n&&(n=t,t=438),ke(e,8192|t,n)},Se=(e,t)=>{if(!j(e))throw new ue(44);var n=ce(t,{parent:!0}).node;if(!n)throw new ue(44);t=z(t);var r=be(n,t);if(r)throw new ue(r);if(!n.h.R)throw new ue(63);n.h.R(n,t,e)},Ee=e=>{if(!(e=ce(e).node))throw new ue(44);if(!e.h.L)throw new ue(28);return j(pe(e.parent),e.h.L(e))},Ie=(e,n,r)=>{if(""===e)throw new ue(44);if("string"==typeof n){var a=me[n];if(void 0===a)throw Error("Unknown file open mode: "+n);n=a}if(r=64&n?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var o=e;else{e=W(e);try{o=ce(e,{aa:!(131072&n)}).node}catch(e){}}if(a=!1,64&n)if(o){if(128&n)throw new ue(20)}else o=ke(e,r,0),a=!0;if(!o)throw new ue(44);if(8192==(61440&o.mode)&&(n&=-513),65536&n&&16384!=(61440&o.mode))throw new ue(54);if(!a&&(r=o?40960==(61440&o.mode)?32:16384==(61440&o.mode)&&("r"!==ge(n)||512&n)?31:ye(o,ge(n)):44))throw new ue(r);if(512&n&&!a){if(!(r="string"==typeof(r=o)?ce(r,{aa:!0}).node:r).h.s)throw new ue(63);if(16384==(61440&r.mode))throw new ue(31);if(32768!=(61440&r.mode))throw new ue(28);if(a=ye(r,"w"))throw new ue(a);r.h.s(r,{size:0,timestamp:Date.now()})}return n&=-131713,(o=ve({node:o,path:pe(o),flags:n,seekable:!0,position:0,i:o.i,Aa:[],error:!1})).i.open&&o.i.open(o),!t.logReadFiles||1&n||(Q||(Q={}),e in Q||(Q[e]=1)),o},Ce=(e,t,n)=>{if(null===e.A)throw new ue(8);if(!e.seekable||!e.i.D)throw new ue(70);if(0!=n&&1!=n&&2!=n)throw new ue(28);e.position=e.i.D(e,t,n),e.Aa=[]},Ae=()=>{ue||((ue=function(e,t){this.name="ErrnoError",this.node=t,this.va=function(e){this.C=e},this.va(e),this.message="FS error"}).prototype=Error(),ue.prototype.constructor=ue,[44].forEach((e=>{le[e]=new ue(e),le[e].stack="<generic error, no stack>"})))},Ne=(e,t,n)=>{e=W("/dev/"+e);var r=((e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n})(!!t,!!n);Y||(Y=64);var a=Y++<<8|0;xe(a,{open:e=>{e.seekable=!1},close:()=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,n,r,a)=>{for(var o=0,s=0;s<a;s++){try{var i=t()}catch(e){throw new ue(29)}if(void 0===i&&0===o)throw new ue(6);if(null==i)break;o++,n[r+s]=i}return o&&(e.node.timestamp=Date.now()),o},write:(e,t,r,a)=>{for(var o=0;o<a;o++)try{n(t[r+o])}catch(e){throw new ue(29)}return a&&(e.node.timestamp=Date.now()),o}}),Te(e,r,a)},Re={},Fe=void 0;function Oe(){return f[(Fe+=4)-4>>2]}function Me(e){if(!(e=ae[e]))throw new ue(8);return e}var $e,De={};function Pe(){if(!$e){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:o||"./this.program"};for(e in De)void 0===De[e]?delete t[e]:t[e]=De[e];var n=[];for(e in t)n.push(e+"="+t[e]);$e=n}return $e}function Le(e){return 0==e%4&&(0!=e%100||0==e%400)}var Be=[31,29,31,30,31,30,31,31,30,31,30,31],Ue=[31,28,31,30,31,30,31,31,30,31,30,31];function We(e,n,r,a){var o={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);t=qe(n),_(e,h,t,n)}return t},array:e=>{var t=qe(e.length);return p.set(e,t),t}};e=t["_"+e];var s,i=[],u=0;if(a)for(var l=0;l<a.length;l++){var c=o[r[l]];c?(0===u&&(u=Ge()),i[l]=c(a[l])):i[l]=a[l]}return s=r=e.apply(null,i),0!==u&&Ke(u),"string"===n?x(s):"boolean"===n?!!s:s}function Ve(e,t,n,r){e||(e=this),this.parent=e,this.v=e.v,this.O=null,this.id=oe++,this.name=t,this.mode=n,this.h={},this.i={},this.P=r}Object.defineProperties(Ve.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}}}),Ae(),se=Array(4096),_e(te,"/"),ke("/tmp",16895,0),ke("/home",16895,0),ke("/home/web_user",16895,0),(()=>{ke("/dev",16895,0),xe(259,{read:()=>0,write:(e,t,n,r)=>r}),Te("/dev/null",259),K(1280,Z),K(1536,ee),Te("/dev/tty",1280),Te("/dev/tty1",1536);var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>O("randomDevice")}();Ne("random",e),Ne("urandom",e),ke("/dev/shm",16895,0),ke("/dev/shm/tmp",16895,0)})(),(()=>{ke("/proc",16895,0);var e=ke("/proc/self",16895,0);ke("/proc/self/fd",16895,0),_e({v:()=>{var t=fe(e,"fd",16895,73);return t.h={K:(e,t)=>{var n=ae[+t];if(!n)throw new ue(8);return(e={parent:null,v:{ea:"fake"},h:{L:()=>n.path}}).parent=e}},t}},"/proc/self/fd")})();var ze,je={__assert_fail:function(e,t,n,r){O("Assertion failed: "+x(e)+", at: "+[t?x(t):"unknown filename",n,r?x(r):"unknown function"])},__cxa_throw:function(e,t,n){throw new B(e).I(t,n),e},__syscall_fcntl64:function(e,t,n){Fe=n;try{var r=Me(e);switch(t){case 0:var a=Oe();return 0>a?-28:ve(r,a).A;case 1:case 2:case 6:case 7:return 0;case 3:return r.flags;case 4:return a=Oe(),r.flags|=a,0;case 5:return a=Oe(),d[a+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return f[He()>>2]=28,-1}}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},__syscall_ioctl:function(e,t,n){Fe=n;try{var r=Me(e);switch(t){case 21509:case 21505:case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:case 21523:case 21524:return r.l?0:-59;case 21519:if(!r.l)return-59;var a=Oe();return f[a>>2]=0;case 21520:return r.l?-28:-59;case 21531:if(e=a=Oe(),!r.i.na)throw new ue(59);return r.i.na(r,t,e);default:return-28}}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},__syscall_openat:function(e,t,n,r){Fe=r;try{var a=t=x(t);if("/"===a.charAt(0))t=a;else{var o=-100===e?"/":Me(e).path;if(0==a.length)throw new ue(44);t=W(o+"/"+a)}var s=r?Oe():0;return Ie(t,n,s).A}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},abort:function(){O("")},emscripten_memcpy_big:function(e,t,n){h.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=h.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math,o=a.min;r=Math.max(e,r),r+=(65536-r%65536)%65536;e:{var s=c.buffer;try{c.grow(o.call(a,2147483648,r)-s.byteLength+65535>>>16),k();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},environ_get:function(e,t){var n=0;return Pe().forEach((function(r,a){var o=t+n;for(a=m[e+4*a>>2]=o,o=0;o<r.length;++o)p[a++>>0]=r.charCodeAt(o);p[a>>0]=0,n+=r.length+1})),0},environ_sizes_get:function(e,t){var n=Pe();m[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),m[t>>2]=r,0},fd_close:function(e){try{var t=Me(e);if(null===t.A)throw new ue(8);t.U&&(t.U=null);try{t.i.close&&t.i.close(t)}catch(e){throw e}finally{ae[t.A]=null}return t.A=null,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_read:function(e,t,n,r){try{e:{var a=Me(e);e=t;for(var o,s=t=0;s<n;s++){var i=m[e>>2],u=m[e+4>>2];e+=8;var l=a,c=i,h=u,d=o,f=p;if(0>h||0>d)throw new ue(28);if(null===l.A)throw new ue(8);if(1==(2097155&l.flags))throw new ue(8);if(16384==(61440&l.node.mode))throw new ue(31);if(!l.i.read)throw new ue(28);var g=void 0!==d;if(g){if(!l.seekable)throw new ue(70)}else d=l.position;var y=l.i.read(l,f,c,h,d);g||(l.position+=y);var b=y;if(0>b){var v=-1;break e}if(t+=b,b<u)break;void 0!==o&&(o+=b)}v=t}return m[r>>2]=v,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_seek:function(e,t,n,r,a){try{if(t=n+2097152>>>0<4194305-!!t?(t>>>0)+4294967296*n:NaN,isNaN(t))return 61;var o=Me(e);return Ce(o,t,r),N=[o.position>>>0,(A=o.position,1<=+Math.abs(A)?0<A?(0|Math.min(+Math.floor(A/4294967296),4294967295))>>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)],f[a>>2]=N[0],f[a+4>>2]=N[1],o.U&&0===t&&0===r&&(o.U=null),0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_write:function(e,t,n,r){try{e:{var a=Me(e);e=t;for(var o,s=t=0;s<n;s++){var i=m[e>>2],u=m[e+4>>2];e+=8;var l=a,c=i,h=u,d=o,f=p;if(0>h||0>d)throw new ue(28);if(null===l.A)throw new ue(8);if(0==(2097155&l.flags))throw new ue(8);if(16384==(61440&l.node.mode))throw new ue(31);if(!l.i.write)throw new ue(28);l.seekable&&1024&l.flags&&Ce(l,0,2);var g=void 0!==d;if(g){if(!l.seekable)throw new ue(70)}else d=l.position;var y=l.i.write(l,f,c,h,d,void 0);g||(l.position+=y);var b=y;if(0>b){var v=-1;break e}t+=b,void 0!==o&&(o+=b)}v=t}return m[r>>2]=v,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},strftime_l:function(e,t,n,r){return function(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function o(e,t){return a(e,t,"0")}function s(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function i(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){var t=e.G;for(e=new Date(new Date(e.H+1900,0,1).getTime());0<t;){var n=e.getMonth(),r=(Le(e.getFullYear())?Be:Ue)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return n=new Date(e.getFullYear()+1,0,4),t=i(new Date(e.getFullYear(),0,4)),n=i(n),0>=s(t,e)?0>=s(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=f[r+40>>2];for(var c in r={ya:f[r>>2],xa:f[r+4>>2],S:f[r+8>>2],X:f[r+12>>2],T:f[r+16>>2],H:f[r+20>>2],u:f[r+24>>2],G:f[r+28>>2],Ma:f[r+32>>2],wa:f[r+36>>2],za:l?x(l):""},n=x(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),l[c]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(c in l={"%a":function(e){return h[e.u].substring(0,3)},"%A":function(e){return h[e.u]},"%b":function(e){return d[e.T].substring(0,3)},"%B":function(e){return d[e.T]},"%C":function(e){return o((e.H+1900)/100|0,2)},"%d":function(e){return o(e.X,2)},"%e":function(e){return a(e.X,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return o(e.S,2)},"%I":function(e){return 0==(e=e.S)?e=12:12<e&&(e-=12),o(e,2)},"%j":function(e){for(var t=0,n=0;n<=e.T-1;t+=(Le(e.H+1900)?Be:Ue)[n++]);return o(e.X+t,3)},"%m":function(e){return o(e.T+1,2)},"%M":function(e){return o(e.xa,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.S&&12>e.S?"AM":"PM"},"%S":function(e){return o(e.ya,2)},"%t":function(){return"\t"},"%u":function(e){return e.u||7},"%U":function(e){return o(Math.floor((e.G+7-e.u)/7),2)},"%V":function(e){var t=Math.floor((e.G+7-(e.u+6)%7)/7);if(2>=(e.u+371-e.G-2)%7&&t++,t)53==t&&(4==(n=(e.u+371-e.G)%7)||3==n&&Le(e.H)||(t=1));else{t=52;var n=(e.u+7-e.G-1)%7;(4==n||5==n&&Le(e.H%400-1))&&t++}return o(t,2)},"%w":function(e){return e.u},"%W":function(e){return o(Math.floor((e.G+7-(e.u+6)%7)/7),2)},"%y":function(e){return(e.H+1900).toString().substring(2)},"%Y":function(e){return e.H+1900},"%z":function(e){var t=0<=(e=e.wa);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.za},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return(c=H(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(p.set(c,e),c.length-1)}(e,t,n,r)}};function He(){return(He=t.asm.__errno_location).apply(null,arguments)}function Ge(){return(Ge=t.asm.stackSave).apply(null,arguments)}function Ke(){return(Ke=t.asm.stackRestore).apply(null,arguments)}function qe(){return(qe=t.asm.stackAlloc).apply(null,arguments)}function Ye(){function e(){if(!ze&&(ze=!0,t.calledRun=!0,!b)){if(t.noFSInit||q||(q=!0,Ae(),t.stdin=t.stdin,t.stdout=t.stdout,t.stderr=t.stderr,t.stdin?Ne("stdin",t.stdin):Se("/dev/tty","/dev/stdin"),t.stdout?Ne("stdout",null,t.stdout):Se("/dev/tty","/dev/stdout"),t.stderr?Ne("stderr",null,t.stderr):Se("/dev/tty1","/dev/stderr"),Ie("/dev/stdin",0),Ie("/dev/stdout",1),Ie("/dev/stderr",1)),ie=!1,L(S),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var e=t.postRun.shift();E.unshift(e)}L(E)}}if(!(0<R)){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)I();L(T),0<R||(t.setStatus?(t.setStatus("Running..."),setTimeout((function(){setTimeout((function(){t.setStatus("")}),1),e()}),1)):e())}}if(function(){function e(e){if(e=e.exports,t.asm=e,c=t.asm.memory,k(),S.unshift(t.asm.__wasm_call_ctors),R--,t.monitorRunDependencies&&t.monitorRunDependencies(R),0==R&&F){var n=F;F=null,n()}return e}var n={env:je,wasi_snapshot_preview1:je};if(R++,t.monitorRunDependencies&&t.monitorRunDependencies(R),t.instantiateWasm)try{return t.instantiateWasm(n,e)}catch(e){l("Module.instantiateWasm callback failed with error: "+e),r(e)}(function(e,t){var n=C;return i||"function"!=typeof WebAssembly.instantiateStreaming||M(n)||"function"!=typeof fetch?P(n,e,t):fetch(n,{credentials:"same-origin"}).then((function(r){return WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return l("wasm streaming compile failed: "+r),l("falling back to ArrayBuffer instantiation"),P(n,e,t)}))}))})(n,(function(t){e(t.instance)})).catch(r)}(),t._malloc=function(){return(t._malloc=t.asm.malloc).apply(null,arguments)},t._free=function(){return(t._free=t.asm.free).apply(null,arguments)},t._xzimgInitializeCamera=function(){return(t._xzimgInitializeCamera=t.asm.xzimgInitializeCamera).apply(null,arguments)},t._xzimgPoseEstimationInitializeFacePose=function(){return(t._xzimgPoseEstimationInitializeFacePose=t.asm.xzimgPoseEstimationInitializeFacePose).apply(null,arguments)},t._xzimgPoseEstimationInitialize=function(){return(t._xzimgPoseEstimationInitialize=t.asm.xzimgPoseEstimationInitialize).apply(null,arguments)},t._xzimgPoseEstimationRelease=function(){return(t._xzimgPoseEstimationRelease=t.asm.xzimgPoseEstimationRelease).apply(null,arguments)},t._xzimgPoseEstimationPrepareCrop=function(){return(t._xzimgPoseEstimationPrepareCrop=t.asm.xzimgPoseEstimationPrepareCrop).apply(null,arguments)},t._xzimgPoseEstimationEstimateFacePose=function(){return(t._xzimgPoseEstimationEstimateFacePose=t.asm.xzimgPoseEstimationEstimateFacePose).apply(null,arguments)},t._xzimgGetHeatmapsLocations=function(){return(t._xzimgGetHeatmapsLocations=t.asm.xzimgGetHeatmapsLocations).apply(null,arguments)},t._xzimgEstimateRigidPose=function(){return(t._xzimgEstimateRigidPose=t.asm.xzimgEstimateRigidPose).apply(null,arguments)},t._xzimgEstimateGetSimilarity=function(){return(t._xzimgEstimateGetSimilarity=t.asm.xzimgEstimateGetSimilarity).apply(null,arguments)},t._xzimgWarpAffine=function(){return(t._xzimgWarpAffine=t.asm.xzimgWarpAffine).apply(null,arguments)},t._xzimgMatchRecKeypsInit=function(){return(t._xzimgMatchRecKeypsInit=t.asm.xzimgMatchRecKeypsInit).apply(null,arguments)},t._xzimgMatchRecKeyps=function(){return(t._xzimgMatchRecKeyps=t.asm.xzimgMatchRecKeyps).apply(null,arguments)},t._xzimgEstimateInitNonRigidPose=function(){return(t._xzimgEstimateInitNonRigidPose=t.asm.xzimgEstimateInitNonRigidPose).apply(null,arguments)},t._xzimgEstimateNonRigidPose=function(){return(t._xzimgEstimateNonRigidPose=t.asm.xzimgEstimateNonRigidPose).apply(null,arguments)},t._xzimgEstimateBodyNonRigidPose=function(){return(t._xzimgEstimateBodyNonRigidPose=t.asm.xzimgEstimateBodyNonRigidPose).apply(null,arguments)},t._xzimgEstimateNonRigidPoseBase=function(){return(t._xzimgEstimateNonRigidPoseBase=t.asm.xzimgEstimateNonRigidPoseBase).apply(null,arguments)},t._xzimgEstimateGetNumVertices=function(){return(t._xzimgEstimateGetNumVertices=t.asm.xzimgEstimateGetNumVertices).apply(null,arguments)},t._xzimgEstimateGetDenseVertices=function(){return(t._xzimgEstimateGetDenseVertices=t.asm.xzimgEstimateGetDenseVertices).apply(null,arguments)},t.dynCall_jiji=function(){return(t.dynCall_jiji=t.asm.dynCall_jiji).apply(null,arguments)},t.dynCall_viijii=function(){return(t.dynCall_viijii=t.asm.dynCall_viijii).apply(null,arguments)},t.dynCall_iiiiij=function(){return(t.dynCall_iiiiij=t.asm.dynCall_iiiiij).apply(null,arguments)},t.dynCall_iiiiijj=function(){return(t.dynCall_iiiiijj=t.asm.dynCall_iiiiijj).apply(null,arguments)},t.dynCall_iiiiiijj=function(){return(t.dynCall_iiiiiijj=t.asm.dynCall_iiiiiijj).apply(null,arguments)},t.ccall=We,t.cwrap=function(e,n,r,a){var o=!r||r.every((e=>"number"===e||"boolean"===e));return"string"!==n&&o&&!a?t["_"+e]:function(){return We(e,n,r,arguments)}},t.setValue=function(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":p[e>>0]=t;break;case"i16":d[e>>1]=t;break;case"i32":f[e>>2]=t;break;case"i64":N=[t>>>0,(A=t,1<=+Math.abs(A)?0<A?(0|Math.min(+Math.floor(A/4294967296),4294967295))>>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)],f[e>>2]=N[0],f[e+4>>2]=N[1];break;case"float":g[e>>2]=t;break;case"double":y[e>>3]=t;break;case"*":m[e>>2]=t;break;default:O("invalid type for setValue: "+n)}},t.getValue=function(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return p[e>>0];case"i16":return d[e>>1];case"i32":case"i64":return f[e>>2];case"float":return g[e>>2];case"double":return y[e>>3];case"*":return m[e>>2];default:O("invalid type for getValue: "+t)}},F=function e(){ze||Ye(),ze||(F=e)},t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);0<t.preInit.length;)t.preInit.pop()();return Ye(),e.ready});let Qk;!function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"}(Kk||(Kk={})),function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"}(qk||(qk={}));const Jk={kernelName:Rr,backendName:"wasm",setupFunc:function(e){Qk=e.wasm.cwrap(Rr,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:o,bias:s,preluActivationWeights:i}=t;if("float32"!==a.dtype||"float32"!==o.dtype)throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");const{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r,h=n.dataIdMap.get(a.dataId).id,d=n.dataIdMap.get(o.dataId).id;let f=0;if(null!=s){const e=n.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${e.shape.length}.`);f=e.id}const m=null==i?0:n.dataIdMap.get(i.dataId).id,g=qk[c];if(null==g)throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);const y=u?a.shape[2]:a.shape[1],b=l?o.shape[1]:o.shape[2],v=$i(a.shape.slice(0,-2),o.shape.slice(0,-2)),w=n.makeOutput([...v,y,b],a.dtype),x=n.dataIdMap.get(w.dataId).id,_=new Uint8Array(new Int32Array(a.shape).buffer),k=new Uint8Array(new Int32Array(o.shape).buffer);return Qk(h,_,a.shape.length,d,k,o.shape.length,u,l,g,f,m,p||0,x),w}};function Zk(e,t){let n;return{kernelName:e,backendName:"wasm",setupFunc:function(t){n=t.wasm.cwrap(e,null,["number","number","number"])},kernelFunc:function(e){const{backend:r,inputs:{x:a}}=e,o=r.dataIdMap.get(a.dataId).id,s=r.makeOutput(a.shape,t||a.dtype),i=r.dataIdMap.get(s.dataId).id;return 0===ot(s.shape)||n(o,Kk[a.dtype],i),s}}}const eT=Zk("Abs");function tT(e,t,n){let r;return{kernelName:e,backendName:"wasm",setupFunc:function(t){r=t.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:a}=e,{a:o,b:s}=a,i=t.dataIdMap.get(o.dataId).id,u=t.dataIdMap.get(s.dataId).id,l=null!=n?n:o.dtype,c=$i(o.shape,s.shape),p=t.makeOutput(c,l);if(0===ot(c))return p;const h=new Uint8Array(new Int32Array(o.shape).buffer),d=new Uint8Array(new Int32Array(s.shape).buffer),f=t.dataIdMap.get(p.dataId).id;return r(i,h,o.shape.length,u,d,s.shape.length,Kk[o.dtype],f),p}}}const nT=tT(Bt);let rT;const aT={kernelName:Ut,backendName:"wasm",setupFunc:function(e){rT=e.wasm.cwrap(Ut,null,["array","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,r=n.makeOutput(t[0].shape,t[0].dtype);if(0===ot(r.shape))return r;const a=t.map((e=>n.dataIdMap.get(e.dataId).id)),o=new Uint8Array(new Int32Array(a).buffer),s=n.dataIdMap.get(r.dataId).id;return rT(o,a.length,Kk[r.dtype],s),r}};function oT(e){const{inputs:{x:t},backend:n}=e;if("string"===t.dtype)return bs(n.readSync(t.dataId),t.shape,t.dtype);const r=n.makeOutput(t.shape,t.dtype),a=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(r).set(a),r}const sT={kernelName:wn,backendName:"wasm",kernelFunc:oT};let iT;function uT(e){const{inputs:t,backend:n,attrs:r}=e,[a,o]=function(e,t){const n=[],r=[];for(let a=0;a<e.length;++a)1!==e[a]&&n.push(e[a]),1!==e[t[a]]&&r.push(t[a]);for(let e=0;e<r.length;++e){let t=-1;for(let n=0;n<r.length;++n)r[n]>=e&&(-1===t||r[t]>r[n])&&(t=n);r[t]=e}return[n,r]}(t.x.shape,r.perm);let s=!0;for(let e=0;e<o.length;e++)o[e]!==e&&(s=!1);const i=function(e,t){const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];return n}(t.x.shape,r.perm),u={dataId:t.x.dataId,shape:a,dtype:t.x.dtype};if(s){const e=oT({inputs:t,backend:n});return e.shape=i,e}const l=n.makeOutput(i,u.dtype),c=n.dataIdMap.get(u.dataId).id,p=n.dataIdMap.get(l.dataId).id,h=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(u.shape).buffer);return iT(c,d,u.shape.length,Kk[u.dtype],p,h,o.length),l}const lT={kernelName:Sr,backendName:"wasm",kernelFunc:uT,setupFunc:function(e){iT=e.wasm.cwrap(Sr,null,["number","array","number","number","number","array","number"])}};function cT(e,t,n){const r=e.shape,a=e.shape.length,o=ht(t,r);let s=o;const i=$l(s,a);let u=null,l=!1;if(null!=i){const t=new Array(a);for(let e=0;e<t.length;e++)t[e]=r[i[e]];s=Pl(s.length,a),u=uT({inputs:{x:e},attrs:{perm:i},backend:n});const o=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(u.dataId).id!==o&&(l=!0)}return{transposed:u,originalAxes:o,axes:s,inputWasTransposed:l}}let pT;const hT={kernelName:Wt,backendName:"wasm",setupFunc:function(e){pT=e.wasm.cwrap(Wt,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n;let i=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:p,inputWasTransposed:h}=cT(s,a,t);h&&(u=l,i=t.dataIdMap.get(l.dataId).id),Ml("all",c,u.shape.length);const[d,f]=Fl(u.shape,c),m=ot(f),g=t.makeOutput(d,s.dtype);if(0!==ot(u.shape)){const e=t.dataIdMap.get(g.dataId).id;pT(i,m,e)}if(h&&t.disposeData(l.dataId),o){const e=Ol(g.shape,p);g.shape=e}return g}};let dT;const fT={kernelName:Vt,backendName:"wasm",setupFunc:function(e){dT=e.wasm.cwrap(Vt,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n;let i=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:p,inputWasTransposed:h}=cT(s,a,t);h&&(u=l,i=t.dataIdMap.get(l.dataId).id),Ml("any",c,u.shape.length);const[d,f]=Fl(u.shape,c),m=ot(f),g=t.makeOutput(d,s.dtype);if(0!==ot(u.shape)){const e=t.dataIdMap.get(g.dataId).id;dT(i,m,e)}if(h&&t.disposeData(l.dataId),o){const e=Ol(g.shape,p);g.shape=e}return g}};let mT;const gT={kernelName:zt,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a}=r,{x:o}=n,s=t.dataIdMap.get(o.dataId).id;let i=s,u=o;const{transposed:l,axes:c,inputWasTransposed:p}=cT(o,a,t);if(p){const e=t.dataIdMap.get(l.dataId).id;e!==s&&(u=l,i=e)}const h=u.shape.slice(0,-1),d=t.makeOutput(h,"int32"),f=t.dataIdMap.get(d.dataId).id,m=ot(d.shape),g=u.shape[c[0]];return mT(i,Kk[u.dtype],m,g,f),p&&t.disposeData(l.dataId),d},setupFunc:function(e){mT=e.wasm.cwrap(zt,null,["number","number","number","number","number"])}};let yT;const bT={kernelName:jt,backendName:"wasm",setupFunc:function(e){yT=e.wasm.cwrap(jt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,o=r.dataIdMap.get(a.dataId).id,{filterSize:s,strides:i,pad:u,dimRoundingMode:l}=n,c=_u(a.shape,s,i,1,u,l),p=c.filterHeight,h=c.filterWidth,d=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.strideHeight,b=c.strideWidth,v=c.inChannels;if("channelsLast"!==c.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);if(1!==c.dilationWidth||1!==c.dilationHeight)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${c.dilationHeight}, ${c.dilationWidth}].`);const w=r.makeOutput(c.outShape,"float32"),x=r.dataIdMap.get(w.dataId).id;return yT(o,a.shape[0],a.shape[1],a.shape[2],p,h,d,f,m,g,y,b,v,x),w}};function vT(e){const{inputs:t,attrs:n}=e,{x:r}=t,{shape:a}=n,o=ot(r.shape),s=pt(a,o);return nt(o===ot(s),(()=>`new shape: ${s}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`)),e.backend.incRef(r.dataId),{dataId:r.dataId,shape:s,dtype:r.dtype}}const wT={kernelName:Yn,backendName:"wasm",kernelFunc:vT};let xT;const _T={kernelName:Ht,backendName:"wasm",setupFunc:function(e){xT=e.wasm.cwrap(Ht,null,["number","array","number","number","array","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:o}=t,{transposeA:s,transposeB:i}=r;if("float32"!==a.dtype||"float32"!==o.dtype)throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");const u=a.shape.length,l=o.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=i?o.shape[l-1]:o.shape[l-2],h=s?a.shape[u-1]:a.shape[u-2],d=i?o.shape[l-2]:o.shape[l-1],f=a.shape.slice(0,-2),m=o.shape.slice(0,-2),g=ot(f),y=ot(m),b=$i(a.shape.slice(0,-2),o.shape.slice(0,-2)).concat([h,d]);nt(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${o.shape} and transposeA=${s} and transposeB=${i} must match.`));const v=i?[y,d,p]:[y,p,d],w=vT({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,h]:[g,h,c]}}),x=vT({inputs:{x:o},backend:n,attrs:{shape:v}}),_=n.dataIdMap.get(w.dataId).id,k=n.dataIdMap.get(x.dataId).id,T=s?w.shape[2]:w.shape[1],S=i?x.shape[1]:x.shape[2],E=Math.max(g,y),I=n.makeOutput([E,T,S],w.dtype),C=n.dataIdMap.get(I.dataId).id,A=new Uint8Array(new Int32Array(w.shape).buffer),N=new Uint8Array(new Int32Array(x.shape).buffer);return xT(_,A,w.shape.length,k,N,x.shape.length,s,i,C),n.disposeData(w.dataId),n.disposeData(x.dataId),I.shape=b,I}};function kT(e){const{inputs:{x:t},attrs:{begin:n,size:r},backend:a}=e,[o,s]=tu(t,n,r),i=Zi(t.shape,o,s),u=a.readSync(t.dataId),l=a.makeOutput(s,t.dtype),c=_t(t.shape),p=a.dataIdMap.get(l.dataId);if(i){const e=eu(o,c);return"string"===t.dtype?p.stringBytes=u.slice(e,e+ot(s)):a.typedArrayFromHeap(l).set(u.subarray(e,e+ot(s))),l}if("string"===t.dtype){const e=dg(u,o,s,t.shape,t.dtype);return p.stringBytes=e,l}const h=a.typedArrayFromHeap(l),d=t.shape.length;if(2===d)!function(e,t,n,r,a){let o=0;const s=r[0],i=r[1],u=s+a[0];for(let r=s;r<u;r++){const s=r*t+i;n.set(e.subarray(s,s+a[1]),o),o+=a[1]}}(u,c[0],h,o,s);else if(3===d)!function(e,t,n,r,a,o){let s=0;const i=a[0],u=a[1],l=a[2],c=i+o[0],p=u+o[1];for(let a=i;a<c;a++)for(let i=u;i<p;i++){const u=a*t+i*n+l;r.set(e.subarray(u,u+o[2]),s),s+=o[2]}}(u,c[0],c[1],h,o,s);else if(4===d)!function(e,t,n,r,a,o,s){let i=0;const u=o[0],l=o[1],c=o[2],p=u+s[0],h=l+s[1],d=c+s[2],f=o[3];for(let o=u;o<p;o++)for(let u=l;u<h;u++)for(let l=c;l<d;l++){const c=o*t+u*n+l*r+f;a.set(e.subarray(c,c+s[3]),i),i+=s[3]}}(u,c[0],c[1],c[2],h,o,s);else{const e=dg(u,o,s,t.shape,t.dtype);h.set(e)}return l}const TT={kernelName:ar,backendName:"wasm",kernelFunc:kT},ST={kernelName:Gt,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,crops:s}=r,i=o.reduce(((e,t)=>e*t)),u=Id(a.shape,o,i),l=Cd(u.length,o.length),c=Ad(a.shape,o,i),p=Nd(s,o.length),h=Rd(c,s,o.length),d=vT({inputs:{x:a},backend:n,attrs:{shape:u}}),f=uT({inputs:{x:d},backend:n,attrs:{perm:l}}),m=kT({inputs:{x:vT({inputs:{x:f},backend:n,attrs:{shape:c}})},backend:n,attrs:{begin:p,size:h}});return n.disposeData(d.dataId),n.disposeData(f.dataId),n.disposeData(d.dataId),m}};function ET(e){const{inputs:{x:t},attrs:{dtype:n},backend:r}=e,a=r.makeOutput(t.shape,n),o=r.typedArrayFromHeap(t);return r.typedArrayFromHeap(a).set(o),a}const IT={kernelName:Kt,backendName:"wasm",kernelFunc:ET},CT=Zk(qt);let AT;const NT={kernelName:Yt,backendName:"wasm",setupFunc:function(e){AT=e.wasm.cwrap(Yt,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:o,clipValueMax:s}=r,i=n.dataIdMap.get(a.dataId).id,u=n.makeOutput(a.shape,a.dtype),l=n.dataIdMap.get(u.dataId).id;return AT(i,o,s,l),u}};function RT(e){const{inputs:t,backend:n}=e,r=ht(e.attrs.axis,t[0].shape)[0];bd(t.map((e=>e.shape)),r);let a=vd(t.map((e=>e.shape)),r);const o=t.filter((e=>ot(e.shape)>0));if(1===o.length)return oT({inputs:{x:o[0]},backend:n});const s=n.makeOutput(a,t[0].dtype);if(0===ot(a))return s;if("string"===o[0].dtype){const e=o.map((e=>{const t=ot(e.shape.slice(r));return vT({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),i=e.map((e=>({vals:n.readSync(e.dataId),shape:e.shape})));a=vd(e.map((e=>e.shape)),1);const u=1===e[0].shape[0],l=$m(i,a,t[0].dtype,u),c=vd(o.map((e=>e.shape)),r);return s.shape=c,n.dataIdMap.get(s.dataId).stringBytes=qd(l),e.forEach((e=>n.disposeData(e.dataId))),s}const i=ot(o[0].shape.slice(0,r));let u=0;const l=o.map((e=>{const t=ot(e.shape.slice(r));return u+=t,t})),c=o.map((e=>n.typedArrayFromHeap(e))),p=n.typedArrayFromHeap(s);for(let e=0;e<i;e++){let t=e*u;for(let n=0;n<c.length;n++){const r=l[n],a=e*r,o=c[n].subarray(a,a+r);p.set(o,t),t+=r}}return s}const FT={kernelName:Xt,backendName:"wasm",kernelFunc:RT};let OT;const MT={kernelName:Qt,backendName:"wasm",setupFunc:function(e){OT=e.wasm.cwrap(Qt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:o}=t,s=r.dataIdMap.get(a.dataId).id,i=r.dataIdMap.get(o.dataId).id,{strides:u,dilations:l,pad:c,dimRoundingMode:p,dataFormat:h}=n,d=Ou(h),f=ku(a.shape,o.shape,u,l,c,p,!1,d),m=f.filterHeight,g=f.filterWidth,y=f.padInfo.top,b=f.padInfo.right,v=f.padInfo.bottom,w=f.padInfo.left,x=f.dilationHeight,_=f.dilationWidth,k=f.strideHeight,T=f.strideWidth,S=f.inChannels,E=f.outChannels,I="SAME"===f.padInfo.type?1:0;if("channelsLast"!==f.dataFormat)throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);const C=r.makeOutput(f.outShape,"float32"),A=r.dataIdMap.get(C.dataId).id;return OT(s,a.shape[0],a.shape[1],a.shape[2],i,m,g,y,b,v,w,I,x,_,k,T,S,E,A),C}};let $T;const DT={kernelName:Jt,backendName:"wasm",setupFunc:function(e){$T=e.wasm.cwrap(Jt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{dy:a,filter:o}=n,{strides:s,pad:i,dataFormat:u,dimRoundingMode:l,inputShape:c}=r,p=Ou(u),h=ku(c,o.shape,s,1,i,l,!1,p),{batchSize:d,filterHeight:f,filterWidth:m,inChannels:g,inHeight:y,inWidth:b,outChannels:v,outHeight:w,outWidth:x,strideHeight:_,strideWidth:k}=h,T=f-1-h.padInfo.top,S=m-1-h.padInfo.left,E="channelsLast"===h.dataFormat,I=_t(h.inShape),C=_t(a.shape),[A,N,R]=_t(o.shape),F=I[0],O=E?I[1]:I[2],M=E?I[2]:1,$=E?1:I[1],D=C[0],P=E?C[1]:C[2],L=E?C[2]:1,B=E?1:C[1],U=t.makeOutput(h.inShape,"float32"),W=t.dataIdMap.get(U.dataId).id,V=t.dataIdMap.get(a.dataId).id,z=t.dataIdMap.get(o.dataId).id;return $T(V,z,d,f,m,y,b,g,w,x,v,_,k,T,S,A,N,R,F,O,M,$,D,P,L,B,W),U}},PT=Zk("Cos"),LT=Zk(Zt);var BT;let UT;!function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"}(BT||(BT={}));const WT={kernelName:nn,backendName:"wasm",setupFunc:function(e){UT=e.wasm.cwrap(nn,null,["number","number","number","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{method:a,extrapolationValue:o,cropSize:s}=r,{image:i,boxes:u,boxInd:l}=n,c=u.shape[0],[p,h]=s,d=[c,p,h,i.shape[3]];let f,m=t.dataIdMap.get(i.dataId);"float32"!==i.dtype&&(f=ET({backend:t,inputs:{x:i},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(f.dataId));const g=m.id,y=t.dataIdMap.get(u.dataId).id,b=t.dataIdMap.get(l.dataId).id,v=t.makeOutput(d,"float32"),w=t.dataIdMap.get(v.dataId).id,x=new Uint8Array(new Int32Array(i.shape).buffer);return UT(g,y,b,c,x,p,h,BT[a],o,w),null!=f&&t.disposeData(f.dataId),v}};let VT;const zT={kernelName:en,backendName:"wasm",setupFunc:function(e){VT=e.wasm.cwrap(en,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,exclusive:s,reverse:i}=r,u=a.shape.length;nt("float32"===a.dtype||"int32"===a.dtype,(()=>`cumprod does not support ${a.dtype} tensors in the WASM backend`));const l=$l([o],u);let c=a;null!==l&&(c=uT({inputs:{x:a},attrs:{perm:l},backend:n}));const p=Pl(1,u)[0];Ml("cumprod",[p],u);const h=n.makeOutput(c.shape,c.dtype),d=c.shape[p],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(h.dataId).id;VT(f,s?1:0,i?1:0,d,m,Kk[a.dtype]);let g=h;return null!==l&&(g=uT({inputs:{x:h},attrs:{perm:Dl(l)},backend:n}),n.disposeData(c.dataId),n.disposeData(h.dataId)),g}};let jT;const HT={kernelName:tn,backendName:"wasm",setupFunc:function(e){jT=e.wasm.cwrap(tn,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,exclusive:s,reverse:i}=r,u=a.shape.length;nt("float32"===a.dtype||"int32"===a.dtype,(()=>`cumsum does not support ${a.dtype} tensors in the WASM backend`));const l=$l([o],u);let c=a;null!==l&&(c=uT({inputs:{x:a},attrs:{perm:l},backend:n}));const p=Pl(1,u)[0];Ml("cumsum",[p],u);const h=n.makeOutput(c.shape,c.dtype),d=c.shape[p],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(h.dataId).id;jT(f,s?1:0,i?1:0,d,m,Kk[a.dtype]);let g=h;return null!==l&&(g=uT({inputs:{x:h},attrs:{perm:Dl(l)},backend:n}),n.disposeData(c.dataId),n.disposeData(h.dataId)),g}};let GT;const KT={kernelName:rn,backendName:"wasm",setupFunc:function(e){GT=e.wasm.cwrap(rn,null,["number","number","number","array","number","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{blockSize:o,dataFormat:s}=r,i=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*o,l=("NHWC"===s?a.shape[2]:a.shape[3])*o,c=("NHWC"===s?a.shape[3]:a.shape[1])/(o*o),p="NHWC"===s?[i,u,l,c]:[i,c,u,l],h=t.makeOutput(p,"float32"),d=t.dataIdMap.get(a.dataId).id,f=new Uint8Array(new Int32Array(_t(a.shape)).buffer),m=new Uint8Array(new Int32Array(p).buffer),g=new Uint8Array(new Int32Array(_t(p)).buffer),y=t.dataIdMap.get(h.dataId).id;return GT(d,o,"NHWC"===s?1:0,f,a.shape.length-1,m,g,p.length,y),h}};let qT;const YT={kernelName:an,backendName:"wasm",setupFunc:function(e){qT=e.wasm.cwrap(an,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:o}=t,s=r.dataIdMap.get(a.dataId).id,i=r.dataIdMap.get(o.dataId).id,{strides:u,dilations:l,pad:c,dimRoundingMode:p}=n,h=null==l?[1,1]:l,d=ku(a.shape,o.shape,u,h,c,p,!0),f=d.filterHeight,m=d.filterWidth,g=d.padInfo.top,y=d.padInfo.right,b=d.padInfo.bottom,v=d.padInfo.left,w=d.dilationHeight,x=d.dilationWidth,_=d.strideHeight,k=d.strideWidth,T=d.inChannels,S=d.outChannels,E="SAME"===d.padInfo.type?1:0;if("channelsLast"!==d.dataFormat)throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${d.dataFormat}'. Please use 'channelsLast'.`);const I=r.makeOutput(d.outShape,"float32"),C=r.dataIdMap.get(I.dataId).id;return qT(s,a.shape[0],a.shape[1],a.shape[2],i,f,m,g,y,b,v,E,w,x,_,k,T,S,C),I}},XT=Zk(sn),QT=tT(un,0,"bool"),JT=Zk(ln,"float32");function ZT(e){const{inputs:t,attrs:n,backend:r}=e,{input:a}=t,{dim:o}=n,s=a.shape.length,i=a.shape.slice();let u=o;return o<0&&(nt(-(s+1)<=o,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+o+1),i.splice(u,0,1),vT({inputs:{x:a},backend:r,attrs:{shape:i}})}const eS={kernelName:cn,backendName:"wasm",kernelFunc:ZT};function tS(e){const{attrs:{shape:t,value:n,dtype:r},backend:a}=e,o=a.makeOutput(t,r);return a.typedArrayFromHeap(o).fill(n),o}const nS={kernelName:pn,backendName:"wasm",kernelFunc:tS};let rS;const aS={kernelName:hn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{image:r}=t,a=n.makeOutput(r.shape,r.dtype),o=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id,[i,u,l,c]=r.shape;return rS(o,i,u,l,c,s),a},setupFunc:function(e){rS=e.wasm.cwrap(hn,null,["number","number","number","number","number","number"])}},oS=Zk(dn),sS=tT(fn);let iS;const uS={kernelName:mn,backendName:"wasm",setupFunc:function(e){iS=e.wasm.cwrap(mn,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{varianceEpsilon:a}=r,{x:o,mean:s,variance:i,offset:u,scale:l}=n,c=t.dataIdMap.get(o.dataId).id,p=t.dataIdMap.get(s.dataId).id,h=t.dataIdMap.get(i.dataId).id,d=null!=u?t.dataIdMap.get(u.dataId).id:0,f=null!=l?t.dataIdMap.get(l.dataId).id:0,m=t.makeOutput(o.shape,o.dtype);if(0===ot(o.shape))return m;const g=t.dataIdMap.get(m.dataId).id;return iS(c,p,h,d,f,a,g),m}};let lS;const cS={kernelName:Fr,backendName:"wasm",setupFunc:function(e){lS=e.wasm.cwrap(Fr,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dilations:c,dataFormat:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=n,m=ku(a.shape,o.shape,u,c,l,h),g=qk[d];if(null==g)throw new Error(`${d} activation not yet supported for FusedConv2D in the wasm backend.`);const y=r.dataIdMap.get(a.dataId).id,b=r.dataIdMap.get(o.dataId).id,v=m.outChannels;let w=0;if(null!=s){const e=r.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==v)throw new Error(`FusedConv2D bias shape (${e.shape}) does not match the number of output channels (${v})`);w=e.id}const x=m.filterHeight,_=m.filterWidth,k=m.padInfo.top,T=m.padInfo.right,S=m.padInfo.bottom,E=m.padInfo.left,I=m.dilationHeight,C=m.dilationWidth,A=m.strideHeight,N=m.strideWidth,R=m.inChannels,F="SAME"===m.padInfo.type?1:0,O=m.batchSize,M=m.inHeight,$=m.inWidth;if("NHWC"!==p)throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${p}'. Please use 'NHWC'.`);const D=r.makeOutput(m.outShape,"float32"),P=r.dataIdMap.get(D.dataId).id,L=null==i?0:r.dataIdMap.get(i.dataId).id;return lS(y,O,M,$,b,x,_,w,k,T,S,E,F,I,C,A,N,R,v,g,L,f||0,P),D}};let pS;const hS={kernelName:Or,backendName:"wasm",setupFunc:function(e){pS=e.wasm.cwrap(Or,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:o,bias:s,preluActivationWeights:i}=t,{strides:u,pad:l,dilations:c,dataFormat:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=n,m=ku(a.shape,o.shape,u,c,l,h,!0),g=qk[d];if(null==g)throw new Error(`${d} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);const y=r.dataIdMap.get(a.dataId).id,b=r.dataIdMap.get(o.dataId).id,v=m.outChannels;let w=0;if(null!=s){const e=r.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==v)throw new Error(`FusedDepthwiseConv2D bias shape (${e.shape}) does not match the number of output channels (${v})`);w=e.id}const x=m.filterHeight,_=m.filterWidth,k=m.padInfo.top,T=m.padInfo.right,S=m.padInfo.bottom,E=m.padInfo.left,I=m.dilationHeight,C=m.dilationWidth,A=m.strideHeight,N=m.strideWidth,R=m.inChannels,F="SAME"===m.padInfo.type?1:0,O=m.batchSize,M=m.inHeight,$=m.inWidth;if("NHWC"!==p)throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${p}'. Please use 'NHWC'.`);const D=r.makeOutput(m.outShape,"float32"),P=r.dataIdMap.get(D.dataId).id,L=null==i?0:r.dataIdMap.get(i.dataId).id;return pS(y,O,M,$,b,x,_,w,k,T,S,E,F,I,C,A,N,R,v,g,L,f||0,P),D}};let dS;const fS={kernelName:yn,backendName:"wasm",setupFunc:function(e){dS=e.wasm.cwrap(yn,null,["number","number","number","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{params:r,indices:a}=n,[o,s,i,u]=Bi(r,a),l=t.makeOutput(o,r.dtype);if(0===s)return l;const c=a.shape,p=c[c.length-1],h=t.dataIdMap.get(r.dataId).id,d=t.dataIdMap.get(a.dataId).id,f=new Uint8Array(new Int32Array(u).buffer),m=t.dataIdMap.get(l.dataId).id;return dS(h,Kk[r.dtype],d,s,p,i,f,m),l}};let mS;const gS={kernelName:gn,backendName:"wasm",setupFunc:function(e){mS=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a,indices:o}=n,{axis:s,batchDims:i}=r,u=ht(s,a.shape)[0],l=t.readSync(o.dataId),c=a.shape[u];for(let e=0;e<l.length;++e){const t=l[e];nt(t<=c-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}const p=Hd(a,o,u,i),h=vT({inputs:{x:a},attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]},backend:t}),d=ot(o.shape),f=vT({inputs:{x:o},attrs:{shape:[p.batchSize,d/p.batchSize]},backend:t}),m=[p.batchSize,p.outerSize,d/p.batchSize,p.sliceSize],g=t.makeOutput(m,a.dtype);if(0===ot(a.shape))return g;const y=h.shape.length-1,b=t.dataIdMap.get(h.dataId).id,v=t.dataIdMap.get(f.dataId).id,w=t.dataIdMap.get(g.dataId).id,x=new Uint8Array(new Int32Array(_t(h.shape)).buffer),_=new Uint8Array(new Int32Array(_t(m)).buffer);return mS(b,Kk[a.dtype],x,y,v,p.batchSize,_,w),t.disposeData(h.dataId),t.disposeData(f.dataId),g.shape=p.outputShape,g}},yS=tT(bn,0,"bool"),bS=tT(vn,0,"bool"),vS=Zk(xn,"bool");let wS;const xS={kernelName:_n,backendName:"wasm",setupFunc:function(e){wS=e.wasm.cwrap(_n,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:{x:t},attrs:{alpha:n},backend:r}=e,a=r.dataIdMap.get(t.dataId).id,o=r.makeOutput(t.shape,"float32");if(0!==ot(t.shape)){const e=r.dataIdMap.get(o.dataId).id;wS(a,Kk[t.dtype],n,e)}return o}},_S=tT(kn,0,"bool"),kS=tT(Tn,0,"bool"),TS=Zk("Log"),SS=tT(Sn,0,"bool"),ES=Zk(En),IS=tT(In,0,"bool"),CS=tT("LogicalXor",0,"bool");let AS;const NS={kernelName:Cn,backendName:"wasm",setupFunc:function(e){AS=e.wasm.cwrap(Cn,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{reductionIndices:a,keepDims:o}=r,{x:s}=n;let i=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:p,inputWasTransposed:h}=cT(s,a,t);h&&(u=l,i=t.dataIdMap.get(l.dataId).id),Ml("max",c,u.shape.length);const[d,f]=Fl(u.shape,c),m=ot(f),g=t.makeOutput(d,s.dtype);if(0!==ot(u.shape)){const e=t.dataIdMap.get(g.dataId).id;AS(i,Kk[s.dtype],m,e)}if(h&&t.disposeData(l.dataId),o){const e=Ol(g.shape,p);g.shape=e}return g}},RS=tT(An);let FS;const OS={kernelName:Nn,backendName:"wasm",setupFunc:function(e){FS=e.wasm.cwrap(Nn,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,o=r.dataIdMap.get(a.dataId).id;nt("float32"===a.dtype,(()=>`Error in MaxPool: only float32 input is supported. Got ${a.dtype}.`));const{filterSize:s,strides:i,pad:u,dimRoundingMode:l}=n,c=_u(a.shape,s,i,1,u,l),p=c.filterHeight,h=c.filterWidth,d=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.dilationHeight,b=c.dilationWidth,v=c.strideHeight,w=c.strideWidth,x=c.inChannels,_=c.outChannels;if("channelsLast"!==c.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);const k=r.makeOutput(c.outShape,"float32"),T=r.dataIdMap.get(k.dataId).id;return FS(o,a.shape[0],a.shape[1],a.shape[2],p,h,d,f,m,g,y,b,v,w,x,_,T),k}};let MS;const $S={kernelName:Rn,backendName:"wasm",setupFunc:function(e){MS=e.wasm.cwrap(Rn,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n,i=t.dataIdMap.get(s.dataId).id;let u=i,l=s;const{transposed:c,axes:p,originalAxes:h,inputWasTransposed:d}=cT(s,a,t);let f=p;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==i&&(l=c,u=e,f=Pl(f.length,l.shape.length))}Ml("mean",f,l.shape.length);const[m,g]=Fl(l.shape,f),y=ot(g);let b=l;"float32"!==l.dtype&&(b=ET({backend:t,inputs:{x:l},attrs:{dtype:"float32"}}),u=t.dataIdMap.get(b.dataId).id);const v=t.makeOutput(m,"float32");if(0!==ot(l.shape)){const e=t.dataIdMap.get(v.dataId).id;MS(u,y,e)}if(d&&t.disposeData(c.dataId),o){const e=Ol(v.shape,h);v.shape=e}return"float32"!==l.dtype&&t.disposeData(b.dataId),v}};let DS;const PS={kernelName:Fn,backendName:"wasm",setupFunc:function(e){DS=e.wasm.cwrap(Fn,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n,i=t.dataIdMap.get(s.dataId).id;let u=i,l=s;const{transposed:c,axes:p,originalAxes:h,inputWasTransposed:d}=cT(s,a,t);if(d){const e=t.dataIdMap.get(c.dataId).id;e!==i&&(l=c,u=e)}Ml("min",p,l.shape.length);const[f,m]=Fl(l.shape,p),g=ot(m),y=t.makeOutput(f,l.dtype);if(0!==ot(l.shape)){const e=t.dataIdMap.get(y.dataId).id;DS(u,Kk[s.dtype],g,e)}if(d&&t.disposeData(c.dataId),o){const e=Ol(y.shape,h);y.shape=e}return y}},LS=tT(On);var BS;let US;!function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"}(BS||(BS={}));const WS={kernelName:Mn,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:r,mode:a}}=e,o=r.map(((e,n)=>e[0]+t.shape[n]+e[1])),s=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(o,t.dtype),u=n.dataIdMap.get(i.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map((e=>e[0])),p=r.map((e=>e[1])),h=new Uint8Array(new Int32Array(c).buffer),d=new Uint8Array(new Int32Array(p).buffer);return US(s,l,t.shape.length,Kk[t.dtype],h,d,BS[a],u),i},setupFunc:function(e){US=e.wasm.cwrap(Mn,null,["number","array","number","number","array","array","number","number"])}},VS=tT($n),zS=Zk("Neg");function jS(e,t){const n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),r=n[0],a=n[1],o=n[2],s=n[3];return e.wasm._free(t),{pSelectedIndices:r,selectedSize:a,pSelectedScores:o,pValidOutputs:s}}let HS;const GS={kernelName:Pn,backendName:"wasm",setupFunc:function(e){HS=e.wasm.cwrap(Pn,"number",["number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s}=r,{boxes:i,scores:u}=n,l=t.dataIdMap.get(i.dataId).id,c=t.dataIdMap.get(u.dataId).id,p=HS(l,c,o,a,s),{pSelectedIndices:h,selectedSize:d,pSelectedScores:f,pValidOutputs:m}=jS(t,p);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([d],"int32",h)}};let KS;const qS={kernelName:Ln,backendName:"wasm",setupFunc:function(e){KS=e.wasm.cwrap(Ln,"number",["number","number","number","number","number","bool"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s,padToMaxOutputSize:i}=r,{boxes:u,scores:l}=n,c=t.dataIdMap.get(u.dataId).id,p=t.dataIdMap.get(l.dataId).id,h=KS(c,p,o,a,s,i),{pSelectedIndices:d,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=jS(t,h);return t.wasm._free(m),[t.makeOutput([f],"int32",d),t.makeOutput([],"int32",g)]}};let YS;const XS={kernelName:Bn,backendName:"wasm",setupFunc:function(e){YS=e.wasm.cwrap(Bn,"number",["number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:o,scoreThreshold:s,softNmsSigma:i}=r,{boxes:u,scores:l}=n,c=t.dataIdMap.get(u.dataId).id,p=t.dataIdMap.get(l.dataId).id,h=YS(c,p,o,a,s,i),{pSelectedIndices:d,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=jS(t,h);return t.wasm._free(g),[t.makeOutput([f],"int32",d),t.makeOutput([f],"float32",m)]}},QS=tT(Dn,0,"bool");let JS;const ZS={kernelName:Wn,backendName:"wasm",setupFunc:function(e){JS=e.wasm.cwrap(Wn,null,["number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{dtype:o,depth:s,onValue:i,offValue:u}=r,l=n.makeOutput([...a.shape,s],o),c=n.dataIdMap.get(l.dataId).id,p=n.dataIdMap.get(a.dataId).id;return JS(p,s,i,u,c),l}},eE={kernelName:Un,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(1),r}},tE={kernelName:Vn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return ZT({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const o=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(o,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const i=[],u=RT({inputs:t.map((e=>{const t=ZT({inputs:{input:e},backend:n,attrs:{dim:a}});return i.push(t),t})),backend:n,attrs:{axis:a}});return i.forEach((e=>n.disposeData(e.dataId))),u}};let nE;const rE={kernelName:zn,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:r,constantValue:a}}=e,o=r.map(((e,n)=>e[0]+t.shape[n]+e[1]));if(0===ot(t.shape))return tS({backend:n,attrs:{shape:o,value:a,dtype:t.dtype}});const s=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(o,t.dtype),u=n.dataIdMap.get(i.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map((e=>e[0])),p=r.map((e=>e[1])),h=new Uint8Array(new Int32Array(c).buffer),d=new Uint8Array(new Int32Array(p).buffer);return nE(s,l,t.shape.length,Kk[t.dtype],h,d,a,u),i},setupFunc:function(e){nE=e.wasm.cwrap(zn,null,["number","array","number","number","array","array","number","number"])}},aE=tT("Pow");let oE;const sE={kernelName:jn,backendName:"wasm",setupFunc:function(e){oE=e.wasm.cwrap(jn,null,["number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,o=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id;let i=o;const u=r;let l=u;"float32"!==u.dtype&&(l=ET({backend:n,inputs:{x:r},attrs:{dtype:"float32"}}),i=n.dataIdMap.get(l.dataId).id);const c=n.makeOutput(r.shape,"float32"),p=n.dataIdMap.get(c.dataId).id;return oE(i,s,p),"float32"!==u.dtype&&n.disposeData(l.dataId),c}};let iE;const uE={kernelName:Hn,backendName:"wasm",setupFunc:function(e){iE=e.wasm.cwrap(Hn,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n,i=t.dataIdMap.get(s.dataId).id;let u=i,l=s;const{transposed:c,axes:p,originalAxes:h,inputWasTransposed:d}=cT(s,a,t);let f=p;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==i&&(l=c,u=e,f=Pl(f.length,l.shape.length))}Ml("prod",f,l.shape.length);const[m,g]=Fl(l.shape,f),y=ot(g),b=t.makeOutput(m,l.dtype);if(0!==ot(l.shape)){const e=t.dataIdMap.get(b.dataId).id;iE(u,y,Kk[b.dtype],e)}if(d&&t.disposeData(c.dataId),o){const e=Ol(b.shape,h);b.shape=e}return b}},lE={kernelName:Gn,backendName:"wasm",kernelFunc:e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:o,dtype:s}=n,i=ug(r,a,o,s),u=t.makeOutput([i.length],s);return t.typedArrayFromHeap(u).set(i),u}},cE=tT(on),pE=Zk(Kn),hE=Zk(qn),dE=Zk(Jn);let fE;const mE={kernelName:Qn,backendName:"wasm",setupFunc:function(e){fE=e.wasm.cwrap(Qn,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:o,halfPixelCenters:s,size:i}=r,[u,l]=i,[c,p,h,d]=a.shape,f=[c,u,l,d];let m,g=t.dataIdMap.get(a.dataId);"float32"!==g.dtype&&(m=ET({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),g=t.dataIdMap.get(m.dataId));const y=g.id,b=t.makeOutput(f,"float32");if(0===ot(a.shape))return b;const v=t.dataIdMap.get(b.dataId).id;return fE(y,c,p,h,d,u,l,o?1:0,s?1:0,v),null!=m&&t.disposeData(m.dataId),b}};let gE;const yE={kernelName:Xn,backendName:"wasm",setupFunc:function(e){gE=e.wasm.cwrap(Xn,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:o,halfPixelCenters:s,size:i}=r,[u,l]=i,[c,p,h,d]=a.shape,f=[c,u,l,d],m=t.makeOutput(f,"float32");if(0===ot(a.shape))return m;let g,y=t.dataIdMap.get(a.dataId);"float32"!==y.dtype&&(g=ET({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),y=t.dataIdMap.get(g.dataId));const b=y.id,v=t.dataIdMap.get(m.dataId).id;return gE(b,c,p,h,d,u,l,o?1:0,s?1:0,v),null!=g&&t.disposeData(g.dataId),m}};let bE;const vE={kernelName:Zn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:o}=r,s=ht(o,a.shape);if(0===a.shape.length)return oT({inputs:{x:a},backend:n});const i=n.makeOutput(a.shape,a.dtype),u=n.dataIdMap.get(a.dataId).id,l=n.dataIdMap.get(i.dataId).id,c=new Uint8Array(new Int32Array(s).buffer),p=new Uint8Array(new Int32Array(a.shape).buffer);bE(u,c,s.length,p,a.shape.length,l);const h=vT({inputs:{x:i},attrs:{shape:a.shape},backend:n});return n.disposeData(i.dataId),h},setupFunc:function(e){bE=e.wasm.cwrap(Zn,null,["number","array","number","array","number","number"])}};let wE;const xE={kernelName:Nr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a}=t,{radians:o,fillValue:s,center:i}=r,u=n.makeOutput(a.shape,a.dtype),l=n.dataIdMap.get(a.dataId).id,c=n.dataIdMap.get(u.dataId).id,[p,h,d,f]=a.shape,[m,g]=Ed(i,h,d),y="number"==typeof s?[s,s,s,0===s?0:255]:[...s,255],b=new Uint8Array(new Int32Array(y).buffer);return wE(l,p,h,d,f,o,m,g,b,y.length,c),u},setupFunc:function(e){wE=e.wasm.cwrap(Nr,null,["number","number","number","number","number","number","number","number","array","number","number"])}},_E=Zk(er),kE=Zk(tr);let TE;const SE={kernelName:nr,backendName:"wasm",setupFunc:function(e){TE=e.wasm.cwrap(nr,null,["number","number","number","number","number","number","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{indices:a,updates:o}=n,{shape:s}=r,i=t.makeOutput(s,o.dtype);if(0===ot(s))return i;const{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:h}=Vi(0,a,s),d=t.dataIdMap.get(a.dataId).id,f=t.dataIdMap.get(o.dataId).id,m=new Uint8Array(new Int32Array(p).buffer),g=t.dataIdMap.get(i.dataId).id;return TE(d,f,Kk[o.dtype],u,l,c,m,h,g),i}};let EE;const IE={kernelName:rr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:o}=t,s=n.dataIdMap.get(r.dataId).id,i=n.dataIdMap.get(a.dataId).id,u=n.dataIdMap.get(o.dataId).id,l=n.makeOutput(a.shape,a.dtype),c=n.dataIdMap.get(l.dataId).id,p=r.shape.length,h=a.shape.length,d=0===p||p>1||1===h?1:ot(a.shape.slice(1));return EE(s,i,u,d,c),l},setupFunc:function(e){EE=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}};let CE;const AE={kernelName:"Sigmoid",backendName:"wasm",setupFunc:function(e){CE=e.wasm.cwrap(or,null,["number","number"])},kernelFunc:function(e){const{backend:t,inputs:{x:n}}=e,r=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),o=t.dataIdMap.get(a.dataId).id;return 0===ot(a.shape)||CE(r,o),a}},NE=Zk("Sin");let RE;const FE={kernelName:cr,backendName:"wasm",setupFunc:function(e){RE=e.wasm.cwrap(cr,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:{logits:n},attrs:{dim:r}}=e,a=t.dataIdMap.get(n.dataId).id,o=t.makeOutput(n.shape,n.dtype),s=t.dataIdMap.get(o.dataId).id,i=n.shape[r],u=ot(n.shape)/i;return 0===ot(o.shape)||RE(a,s,i,u),o}},OE={kernelName:ur,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:o,paddings:s}=r,i=ot(o),u=[[0,0]];u.push(...s);for(let e=1+o.length;e<a.shape.length;++e)u.push([0,0]);const l=rE.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),c=Id(l.shape,o,i,!1),p=Cd(c.length,o.length,!1),h=Ad(l.shape,o,i,!1),d=vT({inputs:{x:l},backend:n,attrs:{shape:c}}),f=uT({inputs:{x:d},backend:n,attrs:{perm:p}}),m=vT({inputs:{x:f},backend:n,attrs:{shape:h}});return n.disposeData(l.dataId),n.disposeData(d.dataId),n.disposeData(f.dataId),m}};let ME;const $E={kernelName:pr,backendName:"wasm",setupFunc:function(e){ME=e.wasm.cwrap("SparseFillEmptyRows","number",["number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{indices:r,values:a,denseShape:o,defaultValue:s}=n,i=r.shape[0],u=r.shape[1],l=t.readSync(o.dataId)[0],c=[i+l,u],p=t.dataIdMap.get(r.dataId).id,h=t.dataIdMap.get(a.dataId).id,d=t.dataIdMap.get(s.dataId).id,f=t.makeOutput(c,r.dtype),m=t.dataIdMap.get(f.dataId).id,g=t.makeOutput(c.slice(0,1),a.dtype),y=t.dataIdMap.get(g.dataId).id,b=t.makeOutput([l],"bool"),v=t.dataIdMap.get(b.dataId).id,w=t.makeOutput([i],r.dtype),x=t.dataIdMap.get(w.dataId).id,_=t.makeOutput([4],"int32"),k=t.dataIdMap.get(_.dataId).id,T=ME(p,h,Kk[a.dtype],i,l,u,d,m,y,v,x,k),S=t.readSync(_.dataId);let E;switch(S[0]){case 1:E=Dd(S[1]);break;case 2:E=Pd(S[1],S[2]);break;case 3:E=Ld(S[1],S[2],S[3]);break;default:E=""}if(t.disposeData(_.dataId),E)throw t.disposeData(f.dataId),t.disposeData(g.dataId),t.disposeData(b.dataId),t.disposeData(w.dataId),new Error(E);let I=f,C=g;return T!==c[0]&&(I=kT({inputs:{x:f},attrs:{begin:0,size:[T,u]},backend:t}),C=kT({inputs:{x:g},attrs:{begin:0,size:T},backend:t}),t.disposeData(f.dataId),t.disposeData(g.dataId)),[I,C,b,w]}};let DE;const PE={kernelName:hr,backendName:"wasm",setupFunc:function(e){DE=e.wasm.cwrap(hr,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{inputIndices:r,inputShape:a,newShape:o}=n;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const s=t.dataIdMap.get(r.dataId).id,i=t.dataIdMap.get(a.dataId).id,u=t.dataIdMap.get(o.dataId).id,l=r.shape[0],c=ot(o.shape),p=t.makeOutput([l,c],r.dtype),h=t.dataIdMap.get(p.dataId).id,d=t.makeOutput([c],o.dtype),f=t.dataIdMap.get(d.dataId).id,m=t.makeOutput([3],"int32"),g=t.dataIdMap.get(m.dataId).id;DE(s,i,u,l,h,f,g);const y=t.readSync(m.dataId);let b;switch(y[0]){case 0:b=Bd(y[1],y[2]);break;case 1:b=Ud(y[1],y[2]);break;case 2:b="reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";break;case 3:b=Wd(Array.from(t.readSync(a.dataId)),Array.from(t.readSync(d.dataId)));break;case 4:b=Vd(Array.from(t.readSync(a.dataId)),Array.from(t.readSync(d.dataId)));break;default:b=""}if(t.disposeData(m.dataId),b)throw t.disposeData(p.dataId),t.disposeData(d.dataId),new Error(b);return[p,d]}};let LE;function BE(e){LE=e.wasm.cwrap("SparseSegmentReduction",null,["number","number","number","number","number","number","number","number","number"])}function UE(e,t){const{backend:n,inputs:r}=e,{data:a,indices:o,segmentIds:s}=r,i=o.shape[0],u=n.readSync(s.dataId,i-1,i)[0],l=i>0?u+1:0;if(l<0)throw new Error("segment ids must be >= 0");const c=a.shape.slice();c[0]=l;const p=n.dataIdMap.get(a.dataId).id,h=n.dataIdMap.get(o.dataId).id,d=n.dataIdMap.get(s.dataId).id,f=n.makeOutput(c,a.dtype),m=n.dataIdMap.get(f.dataId).id,g=n.makeOutput([4],"int32"),y=n.dataIdMap.get(g.dataId).id;LE(p,Kk[a.dtype],a.shape[0],h,d,m,y,t,0);const b=n.readSync(g.dataId);let v;switch(b[0]){case 0:v="segment ids must be >= 0";break;case 1:v="segment ids are not increasing";break;case 2:v=zd(b[1],b[2]);break;case 3:v=jd(b[1],b[2],b[3]);break;default:v=""}if(n.disposeData(g.dataId),v)throw n.disposeData(f.dataId),new Error(v);return f}const WE={kernelName:dr,backendName:"wasm",setupFunc:BE,kernelFunc:function(e){return UE(e,!0)}},VE={kernelName:fr,backendName:"wasm",setupFunc:BE,kernelFunc:function(e){return UE(e,!1)}},zE={kernelName:lr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a}=t,{numOrSizeSplits:o,axis:s}=n,i=ht(s,a.shape)[0],u=$d(a,o,i),l=new Array(a.shape.length).fill(0),c=a.shape.slice();return u.map((e=>{const t=[...c];t[i]=e;const n=kT({inputs:{x:a},attrs:{begin:l,size:t},backend:r});return l[i]+=e,n}))}},jE=Zk(sr),HE=Zk("Square"),GE=tT(mr);let KE;const qE={kernelName:Cr,backendName:"wasm",setupFunc:function(e){KE=e.wasm.cwrap(Cr,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{alpha:a}=r,{x:o}=n,s=t.dataIdMap.get(o.dataId).id,i=t.makeOutput(o.shape,o.dtype),u=t.dataIdMap.get(i.dataId).id;return KE(s,a,Kk[o.dtype],u),i}};let YE;const XE={kernelName:gr,backendName:"wasm",setupFunc:function(e){YE=e.wasm.cwrap(gr,null,["number","array","number","array","array","array","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{begin:o,end:s,strides:i,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:h}=r,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=nu(a.shape,o,s,i,u,l,c,p,h);let x;if(m)x=vT({inputs:{x:a},backend:t,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=ji(b,v,w),n=kT({inputs:{x:a},backend:t,attrs:{begin:b,size:e}});x=vT({inputs:{x:n},backend:t,attrs:{shape:f}}),t.disposeData(n.dataId)}else{const e=t.makeOutput(d,"float32"),n=t.dataIdMap.get(a.dataId).id,r=new Uint8Array(new Int32Array(_t(a.shape)).buffer),o=new Uint8Array(new Int32Array(b).buffer),s=new Uint8Array(new Int32Array(v).buffer),i=new Uint8Array(new Int32Array(w).buffer),u=new Uint8Array(new Int32Array(d).buffer),l=new Uint8Array(new Int32Array(_t(d)).buffer),c=t.dataIdMap.get(e.dataId).id;YE(n,r,a.shape.length,o,s,i,u,l,d.length,c),x=vT({inputs:{x:e},backend:t,attrs:{shape:f}}),t.disposeData(e.dataId)}return x}},QE={kernelName:yr,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{data:a,dataSplits:o}=n,{separator:s,nGramWidths:i,leftPad:u,rightPad:l,padWidth:c,preserveShortSequences:p}=r,h=t.readSync(a.dataId),d=t.readSync(o.dataId),[f,m]=wg(h,d,s,i,u,l,c,p),g=t.makeOutput([f.length],"string");t.dataIdMap.get(g.dataId).stringBytes=f;const y=t.makeOutput(o.shape,"int32");return t.typedArrayFromHeap(y).set(m),[g,y]}},JE={kernelName:br,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a,delimiter:o}=n,{skipEmpty:s}=r,i=t.readSync(a.dataId),u=t.readSync(o.dataId),[l,c,p]=_g(i,u[0],s),h=c.length,d=t.makeOutput([h,2],"int32");t.typedArrayFromHeap(d).set(l);const f=t.makeOutput([h],"string");t.dataIdMap.get(f.dataId).stringBytes=c;const m=t.makeOutput([2],"int32");return t.typedArrayFromHeap(m).set(p),[d,f,m]}},ZE={kernelName:vr,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a}=n,{numBuckets:o}=r,s=kg(t.readSync(a.dataId),o),i=t.makeOutput(a.shape,"int32");return t.typedArrayFromHeap(i).set(s),i}},eI=tT(wr);let tI;const nI={kernelName:ir,backendName:"wasm",setupFunc:function(e){tI=e.wasm.cwrap(ir,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:o}=r,{x:s}=n,i=t.dataIdMap.get(s.dataId).id;let u=i,l=s;const{transposed:c,axes:p,originalAxes:h,inputWasTransposed:d}=cT(s,a,t);let f=p;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==i&&(l=c,u=e,f=Pl(f.length,l.shape.length))}Ml("sum",f,l.shape.length);const[m,g]=Fl(l.shape,f),y=ot(g),b=t.makeOutput(m,l.dtype);if(0!==ot(l.shape)){const e=t.dataIdMap.get(b.dataId).id;tI(u,y,Kk[b.dtype],e)}if(d&&t.disposeData(c.dataId),o){const e=Ol(b.shape,h);b.shape=e}return b}},rI=Zk("Tan"),aI=Zk(xr);let oI;const sI={kernelName:_r,backendName:"wasm",setupFunc:function(e){oI=e.wasm.cwrap(_r,null,["number","array","number","array","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,o=n.dataIdMap.get(a.dataId).id,{reps:s}=r,i=new Array(a.shape.length);for(let e=0;e<i.length;e++)i[e]=a.shape[e]*s[e];const u=new Uint8Array(new Int32Array(a.shape).buffer),l=new Uint8Array(new Int32Array(i).buffer),c=n.makeOutput(i,a.dtype),p=n.dataIdMap.get(c.dataId).id;return oI(o,u,a.shape.length,l,i.length,Kk[c.dtype],p),c}};let iI;const uI={kernelName:kr,backendName:"wasm",setupFunc:function(e){iI=e.wasm.cwrap(kr,null,["number","array","number","number","number","bool","number","number"])},kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{k:a,sorted:o}=n,s=t.dataIdMap.get(r.dataId).id,i=new Uint8Array(new Int32Array(r.shape).buffer),u=r.shape.slice();u[u.length-1]=a;const l=t.makeOutput(u,r.dtype),c=t.dataIdMap.get(l.dataId).id,p=t.makeOutput(u,"int32"),h=t.dataIdMap.get(p.dataId).id;return iI(s,i,r.shape.length,Kk[r.dtype],a,o,c,h),[l,p]}};let lI;const cI={kernelName:Tr,backendName:"wasm",setupFunc:function(e){lI=e.wasm.cwrap(Tr,null,["number","number","bool","number","number","number","number","number","number","array","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{image:a,transforms:o}=n,{interpolation:s,fillMode:i,fillValue:u,outputShape:l}=r,[c,p,h,d]=a.shape,[f,m]=null!=l?l:[p,h],g=[c,f,m,d],y=new Uint8Array(new Int32Array(_t(a.shape)).buffer),b=new Uint8Array(new Int32Array(_t(g)).buffer),v=t.makeOutput(g,a.dtype),w=t.dataIdMap.get(v.dataId).id,x=t.dataIdMap.get(a.dataId).id,_=t.dataIdMap.get(o.dataId).id,k="nearest"===s?1:2;let T;switch(i){case"constant":default:T=1;break;case"reflect":T=2;break;case"wrap":T=3;break;case"nearest":T=4}return lI(x,_,o.shape[0]>1,c,f,m,d,h,p,y,a.shape.length-1,b,g.length-1,k,T,u,w),v}},pI={kernelName:Er,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a.shape[o],i=a.shape.length,u=new Array(i-1);let l=0;for(let e=0;e<i;e++)e!==o&&(u[l++]=a.shape[e]);const c=new Array(s),p=new Array(i).fill(0),h=a.shape.slice();h[o]=1;for(let e=0;e<c.length;e++)p[o]=e,c[e]=kT({inputs:{x:a},attrs:{begin:p,size:h},backend:n});return c.map((({dataId:e,dtype:t})=>({dataId:e,dtype:t,shape:u})))}},hI={kernelName:Ir,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}},dI=[Jk,eT,nT,aT,hT,fT,gT,bT,_T,ST,IT,CT,NT,FT,MT,DT,PT,LT,WT,zT,HT,KT,YT,XT,QT,JT,eS,nS,aS,oS,sS,uS,cS,hS,fS,gS,yS,bS,sT,vS,xS,_S,kS,TS,SS,ES,IS,CS,NS,RS,OS,$S,PS,LS,WS,VS,zS,GS,qS,XS,QS,ZS,eE,tE,rE,aE,sE,uE,lE,cE,pE,hE,dE,wT,mE,yE,vE,xE,_E,kE,SE,IE,AE,NE,TT,FE,OE,$E,PE,WE,VE,zE,jE,HE,GE,qE,XE,QE,JE,ZE,eI,nI,rI,aI,sI,uI,cI,lT,pI,hI];for(const e of dI)Ur(e);const fI=Mt();fI.registerFlag("WASM_HAS_SIMD_SUPPORT",(async()=>{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,9,1,7,0,65,0,253,15,26,11]))}catch(e){return!1}})),fI.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",(async()=>{if(fI.get("IS_NODE"))return!1;try{return(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(e){return!1}}));var mI=tp((function(e,t){var n=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return e=e||"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out",function(t){function n(){return C.buffer!=F&&W(C.buffer),M}function r(){return C.buffer!=F&&W(C.buffer),$}function a(){return C.buffer!=F&&W(C.buffer),D}function o(){return C.buffer!=F&&W(C.buffer),P}var s,i,u,l=void 0!==(t=t||{})?t:{};l.ready=new Promise((function(e,t){s=e,i=t})),void 0!==Ye&&Ye.listeners&&(u={uncaughtException:Ye.listeners("uncaughtException"),unhandledRejection:Ye.listeners("unhandledRejection")});var c,p,h,d=Object.assign({},l),f=(e,t)=>{throw t},m="object"==typeof window,g="function"==typeof importScripts,y="object"==typeof Ye&&"object"==typeof Ye.versions&&"string"==typeof Ye.versions.node,b=l.ENVIRONMENT_IS_PTHREAD||!1,v="";function w(e){return l.locateFile?l.locateFile(e,v):v+e}if(y){var x=up,_=up;let e;v=g?_.dirname(v)+"/":"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/",c=(e,t)=>(e=ee(e)?new URL(e):_.normalize(e),x.readFileSync(e,t?void 0:"utf8")),h=e=>{var t=c(e,!0);return t.buffer||(t=new Uint8Array(t)),t},p=(e,t,n)=>{e=ee(e)?new URL(e):_.normalize(e),x.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},Ye.argv.length>1&&Ye.argv[1].replace(/\\/g,"/"),Ye.argv.slice(2),Ye.on("uncaughtException",(function(e){if(!(e instanceof re))throw e})),Ye.on("unhandledRejection",(function(e){throw e})),f=(e,t)=>{if(K())throw Ye.exitCode=e,t;!function(e){e instanceof re||I("exiting due to exception: "+e)}(t),Ye.exit(e)},l.inspect=function(){return"[Emscripten Module object]"};try{e=up}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}ep.Worker=e.Worker}else(m||g)&&(g?v=self.location.href:"undefined"!=typeof document&&document.currentScript&&(v=document.currentScript.src),void 0!==e&&e&&(v=e),v=0!==v.indexOf("blob:")?v.substr(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1):"",y||(c=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},g&&(h=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)}));y&&"undefined"==typeof performance&&(ep.performance=up.performance);var k=console.log.bind(console),T=console.warn.bind(console);y&&(k=e=>x.writeSync(1,e+"\n"),T=e=>x.writeSync(2,e+"\n"));var S,E=l.print||k,I=l.printErr||T;Object.assign(l,d),d=null,l.arguments&&l.arguments,l.thisProgram&&l.thisProgram,l.quit&&(f=l.quit),l.wasmBinary&&(S=l.wasmBinary);var C,A,N=l.noExitRuntime||!0;"object"!=typeof WebAssembly&&J("no native wasm support detected");var R,F,O,M,$,D,P,L=!1,B="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,n){for(var r=t+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&B)return B.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,a):e.subarray(t,a));for(var o="";t<a;){var s=e[t++];if(128&s){var i=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|i<<6|u:(7&s)<<18|i<<12|u<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var l=s-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&s)<<6|i)}else o+=String.fromCharCode(s)}return o}function W(e){F=e,l.HEAP8=O=new Int8Array(e),l.HEAP16=new Int16Array(e),l.HEAP32=$=new Int32Array(e),l.HEAPU8=M=new Uint8Array(e),l.HEAPU16=new Uint16Array(e),l.HEAPU32=D=new Uint32Array(e),l.HEAPF32=new Float32Array(e),l.HEAPF64=P=new Float64Array(e)}b&&(F=l.buffer);var V,z=l.INITIAL_MEMORY||16777216;if(b)C=l.wasmMemory,F=l.buffer;else if(l.wasmMemory)C=l.wasmMemory;else if(!((C=new WebAssembly.Memory({initial:z/65536,maximum:32768,shared:!0})).buffer instanceof SharedArrayBuffer))throw I("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&&I("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");C&&(F=C.buffer),z=F.byteLength,W(F);var j=[],H=[],G=[];function K(){return N}function q(){b||le(H)}var Y,X=0,Q=null;function J(e){l.onAbort&&l.onAbort(e),I(e="Aborted("+e+")"),L=!0,R=1,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw i(t),t}function Z(e){return e.startsWith("data:application/octet-stream;base64,")}function ee(e){return e.startsWith("file://")}function te(e){try{if(e==Y&&S)return new Uint8Array(S);if(h)return h(e);throw"both async and sync fetching of the wasm failed"}catch(e){J(e)}}Z(Y="tfjs-backend-wasm-threaded-simd.wasm")||(Y=w(Y));var ne={};function re(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function ae(e){var t=ue.pthreads[e];t||J(void 0),ue.returnWorkerToPool(t)}function oe(e){var t=ue.getNewWorker();if(!t)return 6;ue.runningWorkers.push(t),ue.pthreads[e.pthread_ptr]=t,t.pthread_ptr=e.pthread_ptr;var n={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return t.runPthread=()=>{y&&t.ref(),t.postMessage(n,e.transferList),delete t.runPthread},t.loaded&&t.runPthread(),0}function se(e){if(b)return ye(1,1,e);R=e,K()||(ue.terminateAllThreads(),l.onExit&&l.onExit(e),L=!0),f(e,new re(e))}var ie=function(e,t){if(R=e,!t&&b)throw ce(e),"unwind";se(e)},ue={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init:function(){b?ue.initWorker():ue.initMainThread()},initMainThread:function(){for(var e=8;e--;)ue.allocateUnusedWorker()},initWorker:function(){N=!1},setExitStatus:function(e){R=e},terminateAllThreads:function(){for(var e of Object.values(ue.pthreads))ue.returnWorkerToPool(e);for(var e of ue.unusedWorkers)e.terminate();ue.unusedWorkers=[]},returnWorkerToPool:function(e){var t=e.pthread_ptr;delete ue.pthreads[t],ue.unusedWorkers.push(e),ue.runningWorkers.splice(ue.runningWorkers.indexOf(e),1),e.pthread_ptr=0,y&&e.unref(),De(t)},receiveObjectTransfer:function(e){},threadInitTLS:function(){ue.tlsInitFunctions.forEach((e=>e()))},loadWasmModuleToWorker:function(t,n){t.onmessage=e=>{var r,a=e.data,o=a.cmd;if(t.pthread_ptr&&(ue.currentProxiedOperationCallerThread=t.pthread_ptr),a.targetThread&&a.targetThread!=Ae()){var s=ue.pthreads[a.targetThread];return s?s.postMessage(a,a.transferList):I('Internal error! Worker sent a message "'+o+'" to target pthread '+a.targetThread+", but that thread no longer exists!"),void(ue.currentProxiedOperationCallerThread=void 0)}"processProxyingQueue"===o?me(a.queue):"spawnThread"===o?oe(a):"cleanupThread"===o?ae(a.thread):"killThread"===o?function(e){var t=ue.pthreads[e];delete ue.pthreads[e],t.terminate(),De(e),ue.runningWorkers.splice(ue.runningWorkers.indexOf(t),1),t.pthread_ptr=0}(a.thread):"cancelThread"===o?(r=a.thread,ue.pthreads[r].postMessage({cmd:"cancel"})):"loaded"===o?(t.loaded=!0,y&&t.unref(),n&&n(t),t.runPthread&&t.runPthread()):"print"===o?E("Thread "+a.threadId+": "+a.text):"printErr"===o?I("Thread "+a.threadId+": "+a.text):"alert"===o?alert("Thread "+a.threadId+": "+a.text):"setimmediate"===a.target?t.postMessage(a):"callHandler"===o?l[a.handler](...a.args):o&&I("worker sent an unknown command "+o),ue.currentProxiedOperationCallerThread=void 0},t.onerror=e=>{throw I("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},y&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){})));var r=[];for(var a of["onExit","onAbort","print","printErr"])l.hasOwnProperty(a)&&r.push(a);t.postMessage({cmd:"load",handlers:r,urlOrBlob:l.mainScriptUrlOrBlob||e,wasmMemory:C,wasmModule:A})},allocateUnusedWorker:function(){var e,t=w("tfjs-backend-wasm-threaded-simd.worker.js");e=new Worker(t),ue.unusedWorkers.push(e)},getNewWorker:function(){return 0==ue.unusedWorkers.length&&(ue.allocateUnusedWorker(),ue.loadWasmModuleToWorker(ue.unusedWorkers[0])),ue.unusedWorkers.pop()}};function le(e){for(;e.length>0;)e.shift()(l)}function ce(e){if(b)return ye(2,0,e);try{ie(e)}catch(e){!function(e){if(e instanceof re||"unwind"==e)return R;f(1,e)}(e)}}l.PThread=ue,l.establishStackSpace=function(){var e=Ae(),t=r()[e+52>>2],n=r()[e+56>>2];Le(t,t-n),Ue(t)};var pe,he=[];function de(e,t,n,r){return b?ye(3,1,e,t,n,r):fe(e,t,n,r)}function fe(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return I("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];if(b&&0===a.length)return de(e,t,n,r);var o={startRoutine:n,pthread_ptr:e,arg:r,transferList:a};return b?(o.cmd="spawnThread",postMessage(o,a),0):oe(o)}function me(e){Atomics.store(r(),e>>2,1),Ae()&&$e(e),Atomics.compareExchange(r(),e>>2,1,0)}function ge(e){ge.shown||(ge.shown={}),ge.shown[e]||(ge.shown[e]=1,y&&(e="warning: "+e),I(e))}function ye(e,t){var n=arguments.length-2,r=arguments;return function(e){var t=Be(),n=e();return Ue(t),n}((()=>{for(var a=n,s=We(8*a),i=s>>3,u=0;u<n;u++){var l=r[2+u];o()[i+u]=l}return Re(e,a,s,t)}))}l.invokeEntryPoint=function(e,t){var n,r,a=((r=he[n=e])||(n>=he.length&&(he.length=n+1),he[n]=r=V.get(n)),r)(t);K()?ue.setExitStatus(a):Pe(a)},l.executeNotifiedProxyingQueue=me,pe=y?()=>{var e=Ye.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.timeOrigin+performance.now();var be=[];function ve(e){try{return C.grow(e-F.byteLength+65535>>>16),W(C.buffer),1}catch(e){}}function we(e){return b?ye(4,1,e):52}function xe(e,t,n,r,a){return b?ye(5,1,e,t,n,r,a):70}var _e=[null,[],[]];function ke(e,t){var n=_e[e];0===t||10===t?((1===e?E:I)(U(n,0)),n.length=0):n.push(t)}function Te(e,t,r,o){if(b)return ye(6,1,e,t,r,o);for(var s=0,i=0;i<r;i++){var u=a()[t>>2],l=a()[t+4>>2];t+=8;for(var c=0;c<l;c++)ke(e,n()[u+c]);s+=l}return a()[o>>2]=s,0}function Se(e){return l["_"+e]}function Ee(e,t,r,a,o){var s={string:e=>{var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);!function(e,t,r){!function(e,t,n,r){if(!(r>0))return 0;for(var a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,n(),t,r)}(e,t=We(r),r)}return t},array:e=>{var t=We(e.length);return function(e,t){(C.buffer!=F&&W(C.buffer),O).set(e,t)}(e,t),t}},i=Se(e),u=[],l=0;if(a)for(var c=0;c<a.length;c++){var p=s[r[c]];p?(0===l&&(l=Be()),u[c]=p(a[c])):u[c]=a[c]}return function(e){return 0!==l&&Ue(l),function(e){return"string"===t?(r=e)?U(n(),r,void 0):"":"boolean"===t?Boolean(e):e;var r}(e)}(i.apply(null,u))}ue.init();var Ie=[null,se,ce,de,we,xe,Te],Ce={__emscripten_init_main_thread_js:function(e){Ne(e,!g,1,!m),ue.threadInitTLS()},__emscripten_thread_cleanup:function(e){b?postMessage({cmd:"cleanupThread",thread:e}):ae(e)},__pthread_create_js:fe,_emscripten_default_pthread_stack_size:function(){return 65536},_emscripten_get_now_is_monotonic:function(){return!0},_emscripten_notify_task_queue:function(e,t,n,r){if(e==t)setTimeout((()=>me(r)));else if(b)postMessage({targetThread:e,cmd:"processProxyingQueue",queue:r});else{var a=ue.pthreads[e];if(!a)return;a.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},_emscripten_set_offscreencanvas_size:function(e,t,n){return-1},abort:function(){J("")},emscripten_check_blocking_allowed:function(){y||g||ge("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},emscripten_date_now:function(){return Date.now()},emscripten_get_heap_max:function(){return 2147483648},emscripten_get_now:pe,emscripten_memcpy_big:function(e,t,r){n().copyWithin(e,t,t+r)},emscripten_num_logical_cores:function(){return y?up.cpus().length:navigator.hardwareConcurrency},emscripten_receive_on_main_thread_js:function(e,t,n){be.length=t;for(var r=n>>3,a=0;a<t;a++)be[a]=o()[r+a];return(e<0?ne[-e-1]:Ie[e]).apply(null,be)},emscripten_resize_heap:function(e){var t=n().length;if((e>>>=0)<=t)return!1;var r=2147483648;if(e>r)return!1;let a=(e,t)=>e+(t-e%t)%t;for(var o=1;o<=4;o*=2){var s=t*(1+.2/o);if(s=Math.min(s,e+100663296),ve(Math.min(r,a(Math.max(e,s),65536))))return!0}return!1},emscripten_unwind_to_js_event_loop:function(){throw"unwind"},exit:ie,fd_close:we,fd_seek:xe,fd_write:Te,memory:C||l.wasmMemory};!function(){var e={env:Ce,wasi_snapshot_preview1:Ce};function t(e,t){var n,r,a=e.exports;if(l.asm=a,n=l.asm._emscripten_tls_init,ue.tlsInitFunctions.push(n),V=l.asm.__indirect_function_table,r=l.asm.__wasm_call_ctors,H.unshift(r),A=t,!b){var o=ue.unusedWorkers.length;ue.unusedWorkers.forEach((function(e){ue.loadWasmModuleToWorker(e,(function(){--o||function(e){if(X--,l.monitorRunDependencies&&l.monitorRunDependencies(X),0==X&&Q){var t=Q;Q=null,t()}}()}))}))}}function n(e){t(e.instance,e.module)}function r(t){return function(){if(!S&&(m||g)){if("function"==typeof fetch&&!ee(Y))return fetch(Y,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Y+"'";return e.arrayBuffer()})).catch((function(){return te(Y)}));if(p)return new Promise((function(e,t){p(Y,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return te(Y)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){I("failed to asynchronously prepare wasm: "+e),J(e)}))}if(b||(X++,l.monitorRunDependencies&&l.monitorRunDependencies(X)),l.instantiateWasm)try{return l.instantiateWasm(e,t)}catch(e){I("Module.instantiateWasm callback failed with error: "+e),i(e)}(S||"function"!=typeof WebAssembly.instantiateStreaming||Z(Y)||ee(Y)||y||"function"!=typeof fetch?r(n):fetch(Y,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return I("wasm streaming compile failed: "+e),I("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(i)}(),l.___wasm_call_ctors=function(){return(l.___wasm_call_ctors=l.asm.__wasm_call_ctors).apply(null,arguments)},l._init=function(){return(l._init=l.asm.init).apply(null,arguments)},l._init_with_threads_count=function(){return(l._init_with_threads_count=l.asm.init_with_threads_count).apply(null,arguments)},l._get_threads_count=function(){return(l._get_threads_count=l.asm.get_threads_count).apply(null,arguments)},l._register_tensor=function(){return(l._register_tensor=l.asm.register_tensor).apply(null,arguments)},l._dispose_data=function(){return(l._dispose_data=l.asm.dispose_data).apply(null,arguments)},l._dispose=function(){return(l._dispose=l.asm.dispose).apply(null,arguments)},l._Abs=function(){return(l._Abs=l.asm.Abs).apply(null,arguments)},l._Add=function(){return(l._Add=l.asm.Add).apply(null,arguments)},l._AddN=function(){return(l._AddN=l.asm.AddN).apply(null,arguments)},l._All=function(){return(l._All=l.asm.All).apply(null,arguments)},l._Any=function(){return(l._Any=l.asm.Any).apply(null,arguments)},l._ArgMax=function(){return(l._ArgMax=l.asm.ArgMax).apply(null,arguments)},l._AvgPool=function(){return(l._AvgPool=l.asm.AvgPool).apply(null,arguments)},l._BatchMatMul=function(){return(l._BatchMatMul=l.asm.BatchMatMul).apply(null,arguments)},l._Ceil=function(){return(l._Ceil=l.asm.Ceil).apply(null,arguments)},l._ClipByValue=function(){return(l._ClipByValue=l.asm.ClipByValue).apply(null,arguments)},l._Conv2D=function(){return(l._Conv2D=l.asm.Conv2D).apply(null,arguments)},l._Conv2DBackpropInput=function(){return(l._Conv2DBackpropInput=l.asm.Conv2DBackpropInput).apply(null,arguments)},l._Cos=function(){return(l._Cos=l.asm.Cos).apply(null,arguments)},l._Cosh=function(){return(l._Cosh=l.asm.Cosh).apply(null,arguments)},l._CropAndResize=function(){return(l._CropAndResize=l.asm.CropAndResize).apply(null,arguments)},l._Cumprod=function(){return(l._Cumprod=l.asm.Cumprod).apply(null,arguments)},l._Cumsum=function(){return(l._Cumsum=l.asm.Cumsum).apply(null,arguments)},l._DepthToSpace=function(){return(l._DepthToSpace=l.asm.DepthToSpace).apply(null,arguments)},l._DepthwiseConv2dNative=function(){return(l._DepthwiseConv2dNative=l.asm.DepthwiseConv2dNative).apply(null,arguments)},l._Elu=function(){return(l._Elu=l.asm.Elu).apply(null,arguments)},l._Equal=function(){return(l._Equal=l.asm.Equal).apply(null,arguments)},l._Exp=function(){return(l._Exp=l.asm.Exp).apply(null,arguments)},l._FlipLeftRight=function(){return(l._FlipLeftRight=l.asm.FlipLeftRight).apply(null,arguments)},l._Floor=function(){return(l._Floor=l.asm.Floor).apply(null,arguments)},l._FloorDiv=function(){return(l._FloorDiv=l.asm.FloorDiv).apply(null,arguments)},l._FusedBatchNorm=function(){return(l._FusedBatchNorm=l.asm.FusedBatchNorm).apply(null,arguments)},l._FusedConv2D=function(){return(l._FusedConv2D=l.asm.FusedConv2D).apply(null,arguments)},l._FusedDepthwiseConv2D=function(){return(l._FusedDepthwiseConv2D=l.asm.FusedDepthwiseConv2D).apply(null,arguments)},l._Gather=function(){return(l._Gather=l.asm.Gather).apply(null,arguments)},l._GatherNd=function(){return(l._GatherNd=l.asm.GatherNd).apply(null,arguments)},l._Greater=function(){return(l._Greater=l.asm.Greater).apply(null,arguments)},l._GreaterEqual=function(){return(l._GreaterEqual=l.asm.GreaterEqual).apply(null,arguments)},l._IsNan=function(){return(l._IsNan=l.asm.IsNan).apply(null,arguments)},l._LeakyRelu=function(){return(l._LeakyRelu=l.asm.LeakyRelu).apply(null,arguments)},l._Less=function(){return(l._Less=l.asm.Less).apply(null,arguments)},l._LessEqual=function(){return(l._LessEqual=l.asm.LessEqual).apply(null,arguments)},l._Log=function(){return(l._Log=l.asm.Log).apply(null,arguments)},l._LogicalAnd=function(){return(l._LogicalAnd=l.asm.LogicalAnd).apply(null,arguments)},l._LogicalNot=function(){return(l._LogicalNot=l.asm.LogicalNot).apply(null,arguments)},l._LogicalOr=function(){return(l._LogicalOr=l.asm.LogicalOr).apply(null,arguments)},l._LogicalXor=function(){return(l._LogicalXor=l.asm.LogicalXor).apply(null,arguments)},l._Max=function(){return(l._Max=l.asm.Max).apply(null,arguments)},l._MaxPool=function(){return(l._MaxPool=l.asm.MaxPool).apply(null,arguments)},l._Maximum=function(){return(l._Maximum=l.asm.Maximum).apply(null,arguments)},l._Mean=function(){return(l._Mean=l.asm.Mean).apply(null,arguments)},l._Min=function(){return(l._Min=l.asm.Min).apply(null,arguments)},l._Minimum=function(){return(l._Minimum=l.asm.Minimum).apply(null,arguments)},l._MirrorPad=function(){return(l._MirrorPad=l.asm.MirrorPad).apply(null,arguments)},l._Multiply=function(){return(l._Multiply=l.asm.Multiply).apply(null,arguments)},l._Neg=function(){return(l._Neg=l.asm.Neg).apply(null,arguments)},l._NonMaxSuppressionV3=function(){return(l._NonMaxSuppressionV3=l.asm.NonMaxSuppressionV3).apply(null,arguments)},l._NonMaxSuppressionV4=function(){return(l._NonMaxSuppressionV4=l.asm.NonMaxSuppressionV4).apply(null,arguments)},l._NonMaxSuppressionV5=function(){return(l._NonMaxSuppressionV5=l.asm.NonMaxSuppressionV5).apply(null,arguments)},l._NotEqual=function(){return(l._NotEqual=l.asm.NotEqual).apply(null,arguments)},l._OneHot=function(){return(l._OneHot=l.asm.OneHot).apply(null,arguments)},l._PadV2=function(){return(l._PadV2=l.asm.PadV2).apply(null,arguments)},l._Pow=function(){return(l._Pow=l.asm.Pow).apply(null,arguments)},l._Prelu=function(){return(l._Prelu=l.asm.Prelu).apply(null,arguments)},l._Prod=function(){return(l._Prod=l.asm.Prod).apply(null,arguments)},l._RealDiv=function(){return(l._RealDiv=l.asm.RealDiv).apply(null,arguments)},l._Reciprocal=function(){return(l._Reciprocal=l.asm.Reciprocal).apply(null,arguments)},l._Relu=function(){return(l._Relu=l.asm.Relu).apply(null,arguments)},l._Relu6=function(){return(l._Relu6=l.asm.Relu6).apply(null,arguments)},l._ResizeBilinear=function(){return(l._ResizeBilinear=l.asm.ResizeBilinear).apply(null,arguments)},l._ResizeNearestNeighbor=function(){return(l._ResizeNearestNeighbor=l.asm.ResizeNearestNeighbor).apply(null,arguments)},l._Reverse=function(){return(l._Reverse=l.asm.Reverse).apply(null,arguments)},l._RotateWithOffset=function(){return(l._RotateWithOffset=l.asm.RotateWithOffset).apply(null,arguments)},l._Round=function(){return(l._Round=l.asm.Round).apply(null,arguments)},l._Rsqrt=function(){return(l._Rsqrt=l.asm.Rsqrt).apply(null,arguments)},l._ScatterNd=function(){return(l._ScatterNd=l.asm.ScatterNd).apply(null,arguments)},l._SelectV2=function(){return(l._SelectV2=l.asm.SelectV2).apply(null,arguments)},l._Sigmoid=function(){return(l._Sigmoid=l.asm.Sigmoid).apply(null,arguments)},l._Sin=function(){return(l._Sin=l.asm.Sin).apply(null,arguments)},l._Softmax=function(){return(l._Softmax=l.asm.Softmax).apply(null,arguments)},l._SparseFillEmptyRows=function(){return(l._SparseFillEmptyRows=l.asm.SparseFillEmptyRows).apply(null,arguments)},l._SparseReshape=function(){return(l._SparseReshape=l.asm.SparseReshape).apply(null,arguments)},l._SparseSegmentReduction=function(){return(l._SparseSegmentReduction=l.asm.SparseSegmentReduction).apply(null,arguments)},l._Sqrt=function(){return(l._Sqrt=l.asm.Sqrt).apply(null,arguments)},l._Square=function(){return(l._Square=l.asm.Square).apply(null,arguments)},l._SquaredDifference=function(){return(l._SquaredDifference=l.asm.SquaredDifference).apply(null,arguments)},l._Step=function(){return(l._Step=l.asm.Step).apply(null,arguments)},l._StridedSlice=function(){return(l._StridedSlice=l.asm.StridedSlice).apply(null,arguments)},l._Sub=function(){return(l._Sub=l.asm.Sub).apply(null,arguments)},l._Sum=function(){return(l._Sum=l.asm.Sum).apply(null,arguments)},l._Tan=function(){return(l._Tan=l.asm.Tan).apply(null,arguments)},l._Tanh=function(){return(l._Tanh=l.asm.Tanh).apply(null,arguments)},l._Tile=function(){return(l._Tile=l.asm.Tile).apply(null,arguments)},l._TopK=function(){return(l._TopK=l.asm.TopK).apply(null,arguments)},l._Transform=function(){return(l._Transform=l.asm.Transform).apply(null,arguments)},l._Transpose=function(){return(l._Transpose=l.asm.Transpose).apply(null,arguments)},l.__FusedMatMul=function(){return(l.__FusedMatMul=l.asm._FusedMatMul).apply(null,arguments)},l._malloc=function(){return(l._malloc=l.asm.malloc).apply(null,arguments)},l._free=function(){return(l._free=l.asm.free).apply(null,arguments)},l.__emscripten_tls_init=function(){return(l.__emscripten_tls_init=l.asm._emscripten_tls_init).apply(null,arguments)};var Ae=l._pthread_self=function(){return(Ae=l._pthread_self=l.asm.pthread_self).apply(null,arguments)};l.___errno_location=function(){return(l.___errno_location=l.asm.__errno_location).apply(null,arguments)};var Ne=l.__emscripten_thread_init=function(){return(Ne=l.__emscripten_thread_init=l.asm._emscripten_thread_init).apply(null,arguments)};l.__emscripten_thread_crashed=function(){return(l.__emscripten_thread_crashed=l.asm._emscripten_thread_crashed).apply(null,arguments)},l._emscripten_main_thread_process_queued_calls=function(){return(l._emscripten_main_thread_process_queued_calls=l.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},l._emscripten_main_browser_thread_id=function(){return(l._emscripten_main_browser_thread_id=l.asm.emscripten_main_browser_thread_id).apply(null,arguments)};var Re=l._emscripten_run_in_main_runtime_thread_js=function(){return(Re=l._emscripten_run_in_main_runtime_thread_js=l.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)};l._emscripten_dispatch_to_thread_=function(){return(l._emscripten_dispatch_to_thread_=l.asm.emscripten_dispatch_to_thread_).apply(null,arguments)};var Fe,Oe,Me,$e=l.__emscripten_proxy_execute_task_queue=function(){return($e=l.__emscripten_proxy_execute_task_queue=l.asm._emscripten_proxy_execute_task_queue).apply(null,arguments)},De=l.__emscripten_thread_free_data=function(){return(De=l.__emscripten_thread_free_data=l.asm._emscripten_thread_free_data).apply(null,arguments)},Pe=l.__emscripten_thread_exit=function(){return(Pe=l.__emscripten_thread_exit=l.asm._emscripten_thread_exit).apply(null,arguments)},Le=l._emscripten_stack_set_limits=function(){return(Le=l._emscripten_stack_set_limits=l.asm.emscripten_stack_set_limits).apply(null,arguments)},Be=l.stackSave=function(){return(Be=l.stackSave=l.asm.stackSave).apply(null,arguments)},Ue=l.stackRestore=function(){return(Ue=l.stackRestore=l.asm.stackRestore).apply(null,arguments)},We=l.stackAlloc=function(){return(We=l.stackAlloc=l.asm.stackAlloc).apply(null,arguments)};function Ve(e){if(!(X>0)){if(b)return s(l),q(),void startWorker(l);!function(){if(l.preRun)for("function"==typeof l.preRun&&(l.preRun=[l.preRun]);l.preRun.length;)e=l.preRun.shift(),j.unshift(e);var e;le(j)}(),X>0||(l.setStatus?(l.setStatus("Running..."),setTimeout((function(){setTimeout((function(){l.setStatus("")}),1),t()}),1)):t())}function t(){Fe||(Fe=!0,l.calledRun=!0,L||(q(),s(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),function(){if(!b){if(l.postRun)for("function"==typeof l.postRun&&(l.postRun=[l.postRun]);l.postRun.length;)e=l.postRun.shift(),G.unshift(e);var e;le(G)}}()))}}if(l.dynCall_iijjiiii=function(){return(l.dynCall_iijjiiii=l.asm.dynCall_iijjiiii).apply(null,arguments)},l.dynCall_jiji=function(){return(l.dynCall_jiji=l.asm.dynCall_jiji).apply(null,arguments)},l.keepRuntimeAlive=K,l.wasmMemory=C,l.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?Se(e):function(){return Ee(e,t,n,arguments)}},l.ExitStatus=re,l.PThread=ue,Q=function e(){Fe||Ve(),Fe||(Q=e)},l.preInit)for("function"==typeof l.preInit&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();if(Ve(),u&&(Oe={uncaughtException:Ye.listeners("uncaughtException").filter((function(e){return!u.uncaughtException.indexOf(e)>-1})),unhandledRejection:Ye.listeners("unhandledRejection").filter((function(e){return!u.unhandledRejection.indexOf(e)>-1}))}),"undefined"!=typeof WasmBackendModule)Me=WasmBackendModule;else{if(void 0===t)throw new Error("Could not find wasm module in post.js");Me=t}if(Oe){var ze=Me._dispose;Me._dispose=function(){ze(),Oe.uncaughtException.forEach((function(e){Ye.removeListener("uncaughtException",e)})),Oe.unhandledRejection.forEach((function(e){Ye.removeListener("unhandledRejection",e)}))}}return t.ready}})();e.exports=n})),gI=i({__proto__:null,default:mI},[mI]),yI=tp((function(e,t){var n=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return e=e||"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out",function(t){var n,r,a,o=void 0!==(t=t||{})?t:{};o.ready=new Promise((function(e,t){n=e,r=t})),void 0!==Ye&&Ye.listeners&&(a={uncaughtException:Ye.listeners("uncaughtException"),unhandledRejection:Ye.listeners("unhandledRejection")});var s,i,u,l=Object.assign({},o),c="object"==typeof window,p="function"==typeof importScripts,h="object"==typeof Ye&&"object"==typeof Ye.versions&&"string"==typeof Ye.versions.node,d="";if(h){var f=up,m=up;d=p?m.dirname(d)+"/":"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/",s=(e,t)=>(e=P(e)?new URL(e):m.normalize(e),f.readFileSync(e,t?void 0:"utf8")),u=e=>{var t=s(e,!0);return t.buffer||(t=new Uint8Array(t)),t},i=(e,t,n)=>{e=P(e)?new URL(e):m.normalize(e),f.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},Ye.argv.length>1&&Ye.argv[1].replace(/\\/g,"/"),Ye.argv.slice(2),Ye.on("uncaughtException",(function(e){if(!(e instanceof B))throw e})),Ye.on("unhandledRejection",(function(e){throw e})),o.inspect=function(){return"[Emscripten Module object]"}}else(c||p)&&(p?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),e&&(d=e),d=0!==d.indexOf("blob:")?d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):"",s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},p&&(u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),i=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var g,y,b=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,l),l=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(g=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&$("no native wasm support detected");var w,x,_,k,T=!1,S="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function E(e,t,n){for(var r=t+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&S)return S.decode(e.subarray(t,a));for(var o="";t<a;){var s=e[t++];if(128&s){var i=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|i<<6|u:(7&s)<<18|i<<12|u<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var l=s-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&s)<<6|i)}else o+=String.fromCharCode(s)}return o}function I(e){w=e,o.HEAP8=x=new Int8Array(e),o.HEAP16=new Int16Array(e),o.HEAP32=new Int32Array(e),o.HEAPU8=_=new Uint8Array(e),o.HEAPU16=new Uint16Array(e),o.HEAPU32=k=new Uint32Array(e),o.HEAPF32=new Float32Array(e),o.HEAPF64=new Float64Array(e)}o.INITIAL_MEMORY;var C,A,N=[],R=[],F=[],O=0,M=null;function $(e){o.onAbort&&o.onAbort(e),v(e="Aborted("+e+")"),T=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function D(e){return e.startsWith("data:application/octet-stream;base64,")}function P(e){return e.startsWith("file://")}function L(e){try{if(e==C&&g)return new Uint8Array(g);if(u)return u(e);throw"both async and sync fetching of the wasm failed"}catch(e){$(e)}}function B(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function U(e){for(;e.length>0;)e.shift()(o)}function W(e){try{return y.grow(e-w.byteLength+65535>>>16),I(y.buffer),1}catch(e){}}D(C="tfjs-backend-wasm.wasm")||(A=C,C=o.locateFile?o.locateFile(A,d):d+A);var V=[null,[],[]];function z(e,t){var n=V[e];0===t||10===t?((1===e?b:v)(E(n,0)),n.length=0):n.push(t)}function j(e){return o["_"+e]}function H(e,t,n,r,a){var o={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var a=n+r-1,o=0;o<e.length;++o){var s=e.charCodeAt(o);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,_,t,n)}(e,t=J(n),n)}return t},array:e=>{var t=J(e.length);return function(e,t){x.set(e,t)}(e,t),t}},s=j(e),i=[],u=0;if(r)for(var l=0;l<r.length;l++){var c=o[n[l]];c?(0===u&&(u=X()),i[l]=c(r[l])):i[l]=r[l]}return function(e){return 0!==u&&Q(u),function(e){return"string"===t?(n=e)?E(_,n,void 0):"":"boolean"===t?Boolean(e):e;var n}(e)}(s.apply(null,i))}var G={abort:function(){$("")},emscripten_get_heap_max:function(){return 2147483648},emscripten_memcpy_big:function(e,t,n){_.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=_.length,n=2147483648;if((e>>>=0)>n)return!1;let r=(e,t)=>e+(t-e%t)%t;for(var a=1;a<=4;a*=2){var o=t*(1+.2/a);if(o=Math.min(o,e+100663296),W(Math.min(n,r(Math.max(e,o),65536))))return!0}return!1},fd_close:function(e){return 52},fd_seek:function(e,t,n,r,a){return 70},fd_write:function(e,t,n,r){for(var a=0,o=0;o<n;o++){var s=k[t>>2],i=k[t+4>>2];t+=8;for(var u=0;u<i;u++)z(e,_[s+u]);a+=i}return k[r>>2]=a,0}};!function(){var e={env:G,wasi_snapshot_preview1:G};function t(e,t){var n,r=e.exports;o.asm=r,I((y=o.asm.memory).buffer),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,R.unshift(n),function(e){if(O--,o.monitorRunDependencies&&o.monitorRunDependencies(O),0==O&&M){var t=M;M=null,t()}}()}function n(e){t(e.instance)}function a(t){return function(){if(!g&&(c||p)){if("function"==typeof fetch&&!P(C))return fetch(C,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+C+"'";return e.arrayBuffer()})).catch((function(){return L(C)}));if(i)return new Promise((function(e,t){i(C,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return L(C)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){v("failed to asynchronously prepare wasm: "+e),$(e)}))}if(O++,o.monitorRunDependencies&&o.monitorRunDependencies(O),o.instantiateWasm)try{return o.instantiateWasm(e,t)}catch(e){v("Module.instantiateWasm callback failed with error: "+e),r(e)}(g||"function"!=typeof WebAssembly.instantiateStreaming||D(C)||P(C)||h||"function"!=typeof fetch?a(n):fetch(C,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return v("wasm streaming compile failed: "+e),v("falling back to ArrayBuffer instantiation"),a(n)}))}))).catch(r)}(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.__wasm_call_ctors).apply(null,arguments)},o._init=function(){return(o._init=o.asm.init).apply(null,arguments)},o._init_with_threads_count=function(){return(o._init_with_threads_count=o.asm.init_with_threads_count).apply(null,arguments)},o._get_threads_count=function(){return(o._get_threads_count=o.asm.get_threads_count).apply(null,arguments)},o._register_tensor=function(){return(o._register_tensor=o.asm.register_tensor).apply(null,arguments)},o._dispose_data=function(){return(o._dispose_data=o.asm.dispose_data).apply(null,arguments)},o._dispose=function(){return(o._dispose=o.asm.dispose).apply(null,arguments)},o._Abs=function(){return(o._Abs=o.asm.Abs).apply(null,arguments)},o._Add=function(){return(o._Add=o.asm.Add).apply(null,arguments)},o._AddN=function(){return(o._AddN=o.asm.AddN).apply(null,arguments)},o._All=function(){return(o._All=o.asm.All).apply(null,arguments)},o._Any=function(){return(o._Any=o.asm.Any).apply(null,arguments)},o._ArgMax=function(){return(o._ArgMax=o.asm.ArgMax).apply(null,arguments)},o._AvgPool=function(){return(o._AvgPool=o.asm.AvgPool).apply(null,arguments)},o._BatchMatMul=function(){return(o._BatchMatMul=o.asm.BatchMatMul).apply(null,arguments)},o._Ceil=function(){return(o._Ceil=o.asm.Ceil).apply(null,arguments)},o._ClipByValue=function(){return(o._ClipByValue=o.asm.ClipByValue).apply(null,arguments)},o._Conv2D=function(){return(o._Conv2D=o.asm.Conv2D).apply(null,arguments)},o._Conv2DBackpropInput=function(){return(o._Conv2DBackpropInput=o.asm.Conv2DBackpropInput).apply(null,arguments)},o._Cos=function(){return(o._Cos=o.asm.Cos).apply(null,arguments)},o._Cosh=function(){return(o._Cosh=o.asm.Cosh).apply(null,arguments)},o._CropAndResize=function(){return(o._CropAndResize=o.asm.CropAndResize).apply(null,arguments)},o._Cumprod=function(){return(o._Cumprod=o.asm.Cumprod).apply(null,arguments)},o._Cumsum=function(){return(o._Cumsum=o.asm.Cumsum).apply(null,arguments)},o._DepthToSpace=function(){return(o._DepthToSpace=o.asm.DepthToSpace).apply(null,arguments)},o._DepthwiseConv2dNative=function(){return(o._DepthwiseConv2dNative=o.asm.DepthwiseConv2dNative).apply(null,arguments)},o._Elu=function(){return(o._Elu=o.asm.Elu).apply(null,arguments)},o._Equal=function(){return(o._Equal=o.asm.Equal).apply(null,arguments)},o._Exp=function(){return(o._Exp=o.asm.Exp).apply(null,arguments)},o._FlipLeftRight=function(){return(o._FlipLeftRight=o.asm.FlipLeftRight).apply(null,arguments)},o._Floor=function(){return(o._Floor=o.asm.Floor).apply(null,arguments)},o._FloorDiv=function(){return(o._FloorDiv=o.asm.FloorDiv).apply(null,arguments)},o._FusedBatchNorm=function(){return(o._FusedBatchNorm=o.asm.FusedBatchNorm).apply(null,arguments)},o._FusedConv2D=function(){return(o._FusedConv2D=o.asm.FusedConv2D).apply(null,arguments)},o._FusedDepthwiseConv2D=function(){return(o._FusedDepthwiseConv2D=o.asm.FusedDepthwiseConv2D).apply(null,arguments)},o._Gather=function(){return(o._Gather=o.asm.Gather).apply(null,arguments)},o._GatherNd=function(){return(o._GatherNd=o.asm.GatherNd).apply(null,arguments)},o._Greater=function(){return(o._Greater=o.asm.Greater).apply(null,arguments)},o._GreaterEqual=function(){return(o._GreaterEqual=o.asm.GreaterEqual).apply(null,arguments)},o._IsNan=function(){return(o._IsNan=o.asm.IsNan).apply(null,arguments)},o._LeakyRelu=function(){return(o._LeakyRelu=o.asm.LeakyRelu).apply(null,arguments)},o._Less=function(){return(o._Less=o.asm.Less).apply(null,arguments)},o._LessEqual=function(){return(o._LessEqual=o.asm.LessEqual).apply(null,arguments)},o._Log=function(){return(o._Log=o.asm.Log).apply(null,arguments)},o._LogicalAnd=function(){return(o._LogicalAnd=o.asm.LogicalAnd).apply(null,arguments)},o._LogicalNot=function(){return(o._LogicalNot=o.asm.LogicalNot).apply(null,arguments)},o._LogicalOr=function(){return(o._LogicalOr=o.asm.LogicalOr).apply(null,arguments)},o._LogicalXor=function(){return(o._LogicalXor=o.asm.LogicalXor).apply(null,arguments)},o._Max=function(){return(o._Max=o.asm.Max).apply(null,arguments)},o._MaxPool=function(){return(o._MaxPool=o.asm.MaxPool).apply(null,arguments)},o._Maximum=function(){return(o._Maximum=o.asm.Maximum).apply(null,arguments)},o._Mean=function(){return(o._Mean=o.asm.Mean).apply(null,arguments)},o._Min=function(){return(o._Min=o.asm.Min).apply(null,arguments)},o._Minimum=function(){return(o._Minimum=o.asm.Minimum).apply(null,arguments)},o._MirrorPad=function(){return(o._MirrorPad=o.asm.MirrorPad).apply(null,arguments)},o._Multiply=function(){return(o._Multiply=o.asm.Multiply).apply(null,arguments)},o._Neg=function(){return(o._Neg=o.asm.Neg).apply(null,arguments)},o._NonMaxSuppressionV3=function(){return(o._NonMaxSuppressionV3=o.asm.NonMaxSuppressionV3).apply(null,arguments)},o._NonMaxSuppressionV4=function(){return(o._NonMaxSuppressionV4=o.asm.NonMaxSuppressionV4).apply(null,arguments)},o._NonMaxSuppressionV5=function(){return(o._NonMaxSuppressionV5=o.asm.NonMaxSuppressionV5).apply(null,arguments)},o._NotEqual=function(){return(o._NotEqual=o.asm.NotEqual).apply(null,arguments)},o._OneHot=function(){return(o._OneHot=o.asm.OneHot).apply(null,arguments)},o._PadV2=function(){return(o._PadV2=o.asm.PadV2).apply(null,arguments)},o._Pow=function(){return(o._Pow=o.asm.Pow).apply(null,arguments)},o._Prelu=function(){return(o._Prelu=o.asm.Prelu).apply(null,arguments)},o._Prod=function(){return(o._Prod=o.asm.Prod).apply(null,arguments)},o._RealDiv=function(){return(o._RealDiv=o.asm.RealDiv).apply(null,arguments)},o._Reciprocal=function(){return(o._Reciprocal=o.asm.Reciprocal).apply(null,arguments)},o._Relu=function(){return(o._Relu=o.asm.Relu).apply(null,arguments)},o._Relu6=function(){return(o._Relu6=o.asm.Relu6).apply(null,arguments)},o._ResizeBilinear=function(){return(o._ResizeBilinear=o.asm.ResizeBilinear).apply(null,arguments)},o._ResizeNearestNeighbor=function(){return(o._ResizeNearestNeighbor=o.asm.ResizeNearestNeighbor).apply(null,arguments)},o._Reverse=function(){return(o._Reverse=o.asm.Reverse).apply(null,arguments)},o._RotateWithOffset=function(){return(o._RotateWithOffset=o.asm.RotateWithOffset).apply(null,arguments)},o._Round=function(){return(o._Round=o.asm.Round).apply(null,arguments)},o._Rsqrt=function(){return(o._Rsqrt=o.asm.Rsqrt).apply(null,arguments)},o._ScatterNd=function(){return(o._ScatterNd=o.asm.ScatterNd).apply(null,arguments)},o._SelectV2=function(){return(o._SelectV2=o.asm.SelectV2).apply(null,arguments)},o._Sigmoid=function(){return(o._Sigmoid=o.asm.Sigmoid).apply(null,arguments)},o._Sin=function(){return(o._Sin=o.asm.Sin).apply(null,arguments)},o._Softmax=function(){return(o._Softmax=o.asm.Softmax).apply(null,arguments)},o._SparseFillEmptyRows=function(){return(o._SparseFillEmptyRows=o.asm.SparseFillEmptyRows).apply(null,arguments)},o._SparseReshape=function(){return(o._SparseReshape=o.asm.SparseReshape).apply(null,arguments)},o._SparseSegmentReduction=function(){return(o._SparseSegmentReduction=o.asm.SparseSegmentReduction).apply(null,arguments)},o._Sqrt=function(){return(o._Sqrt=o.asm.Sqrt).apply(null,arguments)},o._Square=function(){return(o._Square=o.asm.Square).apply(null,arguments)},o._SquaredDifference=function(){return(o._SquaredDifference=o.asm.SquaredDifference).apply(null,arguments)},o._Step=function(){return(o._Step=o.asm.Step).apply(null,arguments)},o._StridedSlice=function(){return(o._StridedSlice=o.asm.StridedSlice).apply(null,arguments)},o._Sub=function(){return(o._Sub=o.asm.Sub).apply(null,arguments)},o._Sum=function(){return(o._Sum=o.asm.Sum).apply(null,arguments)},o._Tan=function(){return(o._Tan=o.asm.Tan).apply(null,arguments)},o._Tanh=function(){return(o._Tanh=o.asm.Tanh).apply(null,arguments)},o._Tile=function(){return(o._Tile=o.asm.Tile).apply(null,arguments)},o._TopK=function(){return(o._TopK=o.asm.TopK).apply(null,arguments)},o._Transform=function(){return(o._Transform=o.asm.Transform).apply(null,arguments)},o._Transpose=function(){return(o._Transpose=o.asm.Transpose).apply(null,arguments)},o.__FusedMatMul=function(){return(o.__FusedMatMul=o.asm._FusedMatMul).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},o.___errno_location=function(){return(o.___errno_location=o.asm.__errno_location).apply(null,arguments)};var K,q,Y,X=o.stackSave=function(){return(X=o.stackSave=o.asm.stackSave).apply(null,arguments)},Q=o.stackRestore=function(){return(Q=o.stackRestore=o.asm.stackRestore).apply(null,arguments)},J=o.stackAlloc=function(){return(J=o.stackAlloc=o.asm.stackAlloc).apply(null,arguments)};function Z(e){function t(){K||(K=!0,o.calledRun=!0,T||(U(R),n(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),F.unshift(e);var e;U(F)}()))}O>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),N.unshift(e);var e;U(N)}(),O>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.dynCall_iijjiiii=function(){return(o.dynCall_iijjiiii=o.asm.dynCall_iijjiiii).apply(null,arguments)},o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.dynCall_jiji).apply(null,arguments)},o.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?j(e):function(){return H(e,t,n,arguments)}},M=function e(){K||Z(),K||(M=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();if(Z(),a&&(q={uncaughtException:Ye.listeners("uncaughtException").filter((function(e){return!a.uncaughtException.indexOf(e)>-1})),unhandledRejection:Ye.listeners("unhandledRejection").filter((function(e){return!a.unhandledRejection.indexOf(e)>-1}))}),void 0!==t)Y=t;else{if("undefined"==typeof WasmBackendModuleThreadedSimd)throw new Error("Could not find wasm module in post.js");Y=WasmBackendModuleThreadedSimd}if(q){var ee=Y._dispose;Y._dispose=function(){ee(),q.uncaughtException.forEach((function(e){Ye.removeListener("uncaughtException",e)})),q.unhandledRejection.forEach((function(e){Ye.removeListener("unhandledRejection",e)}))}}return t.ready}})();e.exports=n}));const bI=mI||gI,vI=yI||i({__proto__:null,default:yI},[yI]);class wI extends Qe{constructor(e){super(),this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(CI),AI=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new Xe(this,_i())}write(e,t,n){const r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){const t=Ca();return e(),{kernelMs:Ca()-t}}move(e,t,n,r,a){const o=this.dataIdNextNumber++;if("string"===r){const s=t;return void this.dataIdMap.set(e,{id:o,stringBytes:s,shape:n,dtype:r,memoryOffset:null,refCount:a})}const s=ot(n),i=s*yt(r),u=this.wasm._malloc(i);this.dataIdMap.set(e,{id:o,memoryOffset:u,shape:n,dtype:r,refCount:a}),this.wasm.tfjs.registerTensor(o,s,u),null!=t&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,i),u)}async read(e){return this.readSync(e)}readSync(e,t,n){const{memoryOffset:r,dtype:a,shape:o,stringBytes:s}=this.dataIdMap.get(e);if("string"===a)return null!=t&&0!==t||!(null==n||n>=s.length)?s.slice(t,n):s;t=t||0,n=n||ot(o);const i=yt(a);return function(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}(this.wasm.HEAPU8.slice(r+t*i,r+n*i).buffer,a)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){const n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){const t=this.dataIdMap.get(e);null!=t&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let r;if(null==n)r=this.write(null,e,t);else{const a=this.dataIdNextNumber++;r={id:a},this.dataIdMap.set(r,{id:a,memoryOffset:n,shape:e,dtype:t,refCount:1});const o=ot(e);this.wasm.tfjs.registerTensor(a,o,n)}return{dataId:r,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){const r=this.wasm.HEAPU8.buffer,{memoryOffset:a}=this.dataIdMap.get(n),o=ot(e);switch(t){case"float32":return new Float32Array(r,a,o);case"int32":return new Int32Array(r,a,o);case"bool":return new Uint8Array(r,a,o);default:throw new Error(`Unknown dtype ${t}`)}}}function xI(e,t,n){let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),null!=TI&&null!=TI[r]?TI[r]:n+r}const _I=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"];let kI=null,TI={},SI=!1,EI=!1;function II(e,t=!1){if(SI)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if("string"==typeof e)kI=e;else{TI=e;const t=_I.filter((e=>null==TI[e]));if(t.length>0)throw new Error(`There were no entries found for the following binaries: ${t.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}EI=t}let CI=-1,AI=null;Ci("wasm",(async()=>{const{wasm:e}=await async function(){const[e,t]=await Promise.all([Mt().getAsync("WASM_HAS_SIMD_SUPPORT"),Mt().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise(((n,r)=>{const a={locateFile:(n,r)=>{if(n.endsWith(".worker.js")){const e='"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"})};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};'.replace(/\n/g,"\\n"),t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}return n.endsWith(".wasm")?xI(e,t,null!=kI?kI:r):r+n}};EI&&(a.instantiateWasm=function(e){return(t,n)=>(function(e,t){return Mt().platform.fetch(e,{credentials:"same-origin"})}(e).then((r=>{r.ok||t.env.a(`failed to load wasm binary file at '${e}'`),r.arrayBuffer().then((e=>{WebAssembly.instantiate(e,t).then((e=>{n(e.instance,e.module)}))}))})),{})}(xI(e,t,null!=kI?kI:"")));let o,s=!1;a.onAbort=()=>{s||SI||(SI=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"}))},t&&e?(a.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+bI.toString()],{type:"text/javascript"}),o=bI(a)):o=vI(a),o.then((e=>{s=!0,SI=!1,e.tfjs={init:e.cwrap("init",null,[]),initWithThreadsCount:e.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:e.cwrap("get_threads_count","number",[]),registerTensor:e.cwrap("register_tensor",null,["number","number","number"]),disposeData:e.cwrap("dispose_data",null,["number"]),dispose:e.cwrap("dispose",null,[])},n({wasm:e})})).catch(r)}))}();return new wI(e)}),2);var NI={modelFilename:"",featuresFilename:"",objFilename:"",fovY:50,detectScoreThs:.2,trackScoreThs:.4,footToDetect:"RIGHT_FOOT",filteringLevel:2,filteringShift:.5,validTrackedKeypThs:.2,trackedNumKeypsThs:3,activeIds:new Int32Array};function RI(e){return!!(void 0===e.outputNames||e.outputNames.length<1||e.outputNames.includes("heatmaps"))}function FI(e,t){for(var n=1e4,r=1e4,a=-1e4,o=-1e4,s=0;s<t;s++){var i=e[s],u=e[t+s];i>a&&(a=i),u>o&&(o=u),i<n&&(n=i),u<r&&(r=u)}return[Math.floor(n),Math.floor(a+1),Math.floor(r),Math.floor(o+1)]}function OI(e,t,n){for(var r=1e4,a=1e4,o=-1e4,s=-1e4,i=0;i<n;i++)if(t[i]>0){var u=e[i],l=e[n+i];u>o&&(o=u),l>s&&(s=l),u<r&&(r=u),l<a&&(a=l)}return[Math.floor(r),Math.floor(o+1),Math.floor(a),Math.floor(s+1)]}function MI(e,t){void 0===t&&(t=.1);for(var n=e.length,r=0,a=0,o=new Int32Array(n),s=0;s<n;s++)e[s]>t?(a+=1,o[s]=1,r+=e[s]):o[s]=0;return a>0?r/=a:r=0,{globalScore:r,visibilty:o,totalVisible:a}}function $I(e,t){void 0===t&&(t=.1);for(var n=e.length,r=new Int32Array(n),a=0;a<n;a++)e[a]>t?r[a]=1:r[a]=0;return r}function DI(e,t,n,r){for(var a=new Uint8ClampedArray(e*t*4),o=e*t,s=0;s<o;s++){var i=s*n,u=4*s;a[u+0]=1*r[i+0],a[u+1]=1*r[i+1],a[u+2]=1*r[i+2],a[u+3]=255}return new ImageData(a,t,e)}function PI(e,t,n,r){var a=Float32Array.from(e),o=e.length/2;if(n)for(var s=0;s<o;s++)a[s+o]=r-1-a[s+o];for(s=0;s<o;s++){var i=a[s],u=a[s+o];a[s]=t[0]*i+t[1]*u+t[2],a[s+o]=t[3]*i+t[4]*u+t[5]}return a}function LI(e,t){if("UPPER-BODY"==e){if(15==t)return[13,14]}else if("FULL-BODY"==e){if(19==t)return[17,18]}else if("FACE"==e){if(68==t)return[36,45];if(19==t)return[8,13];if(21==t)return[10,15]}else{if(5==t)return[1,2];if(14==t)return[1,7];if(20==t)return[2,12];if(7==t)return[0,6];if(19==t)return[10,15];if(9==t)return[1,6];if(23==t)return[0,14];if(181==t)return[30,163];if(21==t)return[0,9];if(10==t)return[7,8];if(8==t)return[5,6];if(11==t)return[7,8]}return console.time("==> (E) Incorrect number of vertices"),[0,1]}function BI(e,t){var n=t.length/2,r=LI(e,n),a=r[0],o=r[1],s=[t[a],t[a+n]],i=[t[o],t[o+n]],u=[(s[0]+i[0])/2,(s[1]+i[1])/2],l=-Math.atan2(s[1]-i[1],i[0]-s[0]);return[u[0],u[1],l]}var UI,WI=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(e){return Math.sqrt((e.x-this.x)*(e.x-this.x)+(e.y-this.y)*(e.y-this.y))},e}(),VI=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.CreateFromPoints=function(t,n){return new e(n.x-t.x,n.y-t.y)},e}(),zI=function(){function e(e,t,n,r){this.x=e,this.y=t,this.w=n,this.h=r}return e.prototype.Centre=function(){return new WI(this.x+this.w/2,this.y+this.h/2)},e.prototype.isPointInside=function(e){return e.x>=this.x&&e.x>=this.x&&e.x<this.x+this.w&&e.y<this.y+this.h},e}();function jI(e,t,n,r,a){void 0===a&&(a=.5);for(var o=e.length/2,s=OI(e,t,o),i=Math.max(s[1]-s[0],s[3]-s[2])/6,u=0;u<o;u++)if(t[u]<=0&&r[u]>0)e[u]=n[u],e[u+o]=n[u+o];else if(t[u]>0&&r[u]<=0);else if(t[u]>0&&r[u]>0){var l=Math.sqrt((n[u]-e[u])*(n[u]-e[u])+(n[u+o]-e[u+o])*(n[u+o]-e[u+o])),c=(1-a)*Math.exp(-.5*l*l/i);e[u]=c*n[u]+(1-c)*e[u],e[u+o]=c*n[u+o]+(1-c)*e[u+o]}return e}function HI(e,t){e.length;var n=function(e,t){var n=e.length/2,r=qI(n,t),a=r[0],o=r[1],s=[e[a],e[a+n]],i=[e[o],e[o+n]],u=[(s[0]+i[0])/2,(s[1]+i[1])/2],l=-Math.atan2(s[1]-i[1],i[0]-s[0]),c=Math.sqrt((s[0]-i[0])*(s[0]-i[0])+(s[1]-i[1])*(s[1]-i[1]));return[u[0],u[1],l,c]}(e,t),r=n[0],a=n[1],o=n[2],s=n[3],i=[Math.cos(o),Math.sin(o)],u=[-i[1],i[0]],l=s/1,c=s/2;return[r+i[0]*l+u[0]*c,a+i[1]*l+u[1]*c,r+i[0]*l-u[0]*c,a+i[1]*l-u[1]*c,r-i[0]*l-u[0]*c,a-i[1]*l-u[1]*c,r-i[0]*l+u[0]*c,a-i[1]*l+u[1]*c]}function GI(e,t,n){if(void 0===n&&(n=.1),6==e.length){for(var r=0,a=new Int32Array(3),o=0,s="RIGHT_FOOT"==t?3:0,i=s;i<s+3;i++)r+=e[i],e[i]>n&&(o+=1,a[i]=1);return{globalScore:r/=3,visibilty:a,totalVisible:o}}return MI(e,n)}function KI(e,t,n,r){var a=Float32Array.from(e),o=e.length/2;if(n)for(var s=0;s<o;s++)a[s+o]=r-1-a[s+o];for(s=0;s<o;s++){var i=a[s],u=a[s+o];a[s]=t[0]*i+t[1]*u+t[2],a[s+o]=t[3]*i+t[4]*u+t[5]}return a}function qI(e,t){if(void 0===t&&(t="face"),"face"==t){if(5==e)return[0,1];if(19==e)return[6,11];if(21==e)return[17,20];if(51==e)return[19,28];if(68==e)return[36,45];if(16==e)return[6,9]}return"eye"==t?[0,1]:6==e&&"RIGHT_FOOT"==t?[3,5]:6==e&&"LEFT_FOOT"==t?[0,2]:18!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?13!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?593!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?200!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?(console.error("no type or number of feature match"),[0,1]):[115,167]:[210,78]:[0,6]:[0,9]}function YI(e,t){var n=e.length/2,r=qI(n,t),a=r[0],o=r[1],s=[e[a],e[a+n]],i=[e[o],e[o+n]],u=[(s[0]+i[0])/2,(s[1]+i[1])/2],l=-Math.atan2(s[1]-i[1],i[0]-s[0]);return[u[0],u[1],l]}function XI(e,t,n){for(var r=n[0],a=n[1],o=n[2],s=n[3],i=n[4],u=n[5],l=e.width,c=e.height,p=4*e.width,h=t.width,d=t.height,f=4*t.width,m=0;m<d;m++)for(var g=a*m+o,y=i*m+u,b=m*f,v=0;v<h;v++){var w=4*v,x=Math.floor(g),_=Math.floor(y),k=g-x,T=y-_,S=void 0,E=void 0;if(x>0&&x<l-1&&_>0&&_<c-1){for(var I=_*p+4*x,C=0;C<3;C++,I++){var A=e.data[I];S=A+k*(e.data[I+4]-A),E=e.data[I+p]+k*(e.data[I+p+4]-e.data[I+p]),t.data[b+w+C]=S+T*(E-S)}t.data[b+w+3]=255}else{for(C=0;C<3;C++)t.data[b+w+C]=0;t.data[b+w+3]=255}g+=r,y+=s}return t}function QI(e,t,n,r,a,o){var s,i,u=e.length/2,l=0,c=0,p=0;6==u?(c=(s=YI(e,o))[0],l=s[1],p=s[2],FI("RIGHT_FOOT"==o?[e[3],e[4],e[5],e[3+u],e[4+u],e[5+u]]:[e[0],e[1],e[2],e[0+u],e[1+u],e[2+u]],3)):(c=(i=YI(e,o))[0],l=i[1],p=i[2],OI(e,t,u));var h=Math.cos(p),d=Math.sin(p),f=qI(u,o),m=f[0],g=f[1],y=[e[m],e[m+u]],b=[e[g],e[g+u]],v=Math.sqrt((y[0]-b[0])*(y[0]-b[0])+(y[1]-b[1])*(y[1]-b[1])),w=(v+=.5*v)/Math.max(r,n),x=(n-1)/2,_=(r-1)/2,k=c-(h*w*x-d*w*_),T=l-(d*w*x+h*w*_);if(null!=a){var S=Math.sqrt((k-a[2])*(k-a[2])+(T-a[5])*(T-a[5])),E=1;S>20&&(E=.1),S>=10&&S<=20&&(E=1-.09*(S-5)),k=(1-E)*k+E*a[2],T=(1-E)*T+E*a[5],p=Math.abs(p-a[6])>1?(1-E)*p-E*a[6]:(1-E)*p+E*a[6],w=(1-E)*w+E*a[7],h=Math.cos(p),d=Math.sin(p)}return[h*w,-d*w,k,d*w,h*w,T,p,w]}function JI(e,t){var n=t.length,r=e._malloc(4*n),a=r/4;return e.HEAPF32.subarray(a,a+n).set(t),r}function ZI(e,t){var n=e._malloc(4*t.length);return e.HEAPF32.set(t,n/4),n}function eC(e,t,n){var r=new Float32Array(n),a=t/4;return r.set(e.HEAPF32.subarray(a,a+n)),r.slice()}function tC(e,t,n){var r=new Uint32Array(t.data.buffer),a=r.length,o=n/4;e.HEAPU32.subarray(o,o+a).set(r)}function nC(e,t,n,r){var a=e._malloc(28);return e.setValue(a,n,"i32"),e.setValue(a+4,r,"i32"),e.setValue(a+8,t,"i32"),e.setValue(a+12,0,"i32"),e.setValue(a+16,4,"i32"),e.setValue(a+20,0,"i32"),e.setValue(a+24,0,"i32"),a}function rC(e,t,n,r,a){var o=e.cwrap("xzimgMatchRecKeyps","number",["number","number","number","number","number"]),s=r.length/2;tC(e,t,n);for(var i=nC(e,n,t.width,t.height),u=ZI(e,r),l=ZI(e,r.slice()),c=e._malloc(4*s),p=0;p<s;p++)e.setValue(c+4*p,1,"float"),a.length>p&&0==a[p]&&e.setValue(c+4*p,-1,"float");var h=e._malloc(16);o(i,u,l,s,c,h);var d=eC(e,c,s),f=eC(e,l,r.length),m=eC(e,h,4);for(p=0;p<s;p++)0==d[p]&&(f[p]=r[p],f[p+s]=r[p+s]);return e._free(i),e._free(u),e._free(l),e._free(c),e._free(h),[f,m,d]}function aC(e,t,n,r){var a=ZI(e,t),o=ZI(e,n),s=e._malloc(16);e.cwrap("xzimgEstimateGetSimilarity","number",["number","number","number","number"])(a,o,t.length/2,s);var i=eC(e,s,4);return e._free(a),e._free(o),e._free(s),i}function oC(e,t,n){void 0===n&&(n=null);for(var r=new Float32Array(2),a=e.length/2,o=0,s=0;s<a;s++)(null==n||n[s]>0)&&(r[0]+=t[s]-e[s],r[1]+=t[s+a]-e[s+a],o+=1);return o>0&&(r[0]/=o,r[1]/=o),r}function sC(e,t,n){var r,a,o,s,i;void 0===n&&(n=!0);var u=n?1:2;return r=function(e,t,n,r,a){void 0===a&&(a=1);var o=new Float32Array(r).fill(0),s=new Float32Array(2*r);if(1==a)for(var i=t*n,u=0;u<i;u++)for(var l=0;l<r;l++)(h=e[u*r+l])>o[l]&&(o[l]=h,s[l]=u%n,s[r+l]=Math.floor(u/n));else{var c=n*a;for(u=a;u<t;u+=a,c+=n*a)for(var p=a;p<n;p+=a)for(l=0;l<r;l++){var h;(h=e[(c+p)*r+l])>o[l]&&(o[l]=h,s[l]=p,s[r+l]=u)}}return[s,o]}(e,t[1],t[2],t[3],u),o=r[0],i=r[1],n?(a=function(e,t,n,r,a){for(var o=[-r*a-a,-r*a,-r*a+a,-a,0,a,r*a-a,r*a,r*a+a],s=new Float32Array(a),i=new Float32Array(2*a),u=0;u<a;u++){var l=t[u],c=t[a+u];i[u]=l,i[a+u]=c;var p=c*r*a+l*a+u,h=0;h=0;for(var d=0;d<9;d++)h+=e[p+o[d]];h/=9,s[u]=h;var f=Math.min(l+2,r-1),m=Math.max(l-2,0),g=Math.min(c+2,n-1),y=Math.max(c-2,0),b=0,v=0,w=c*r*a+m*a+u,x=c*r*a+f*a+u;for(d=0;d<9;d++)b+=e[w+o[d]],v+=e[x+o[d]];var _=2*(2*h-((b/=9)+(v/=9)));if(Math.abs(_)>1e-5){var k=2*(v-b)/_;i[u]+=k}var T=0,S=0,E=y*r*a+l*a+u,I=g*r*a+l*a+u;for(d=0;d<9;d++)T+=e[E+o[d]],S+=e[I+o[d]];_=2*(2*h-((T/=9)+(S/=9))),Math.abs(_)>1e-5&&(k=2*(S-T)/_,i[a+u]+=k)}return[i,s]}(e,o,t[1],t[2],t[3]),s=a[0],i=a[1]):s=o,[s,i]}function iC(e,t,n,r,a,o){var s=e.cwrap("xzimgGetHeatmapsLocations","number",["number","number","number","number","number","number","number","number"]),i=t[1]*t[2]*t[3],u=r/4;return e.HEAPF32.subarray(u,u+i).set(n),s(r,t[1],t[2],t[3],0,2,a,o),[new Float32Array(e.HEAPF32.buffer,a,2*t[3]),new Float32Array(e.HEAPF32.buffer,o,t[3])]}function uC(e,t){var n=new he(0),r=n.asObservable();if("string"==typeof e)return{model$:a=i_({url:e,method:"GET",responseType:"text",async:!0,progressSubscriber:new I((function(e){return n.next(e.loaded/e.total)}),(function(e){}),(function(){return n.next(1)}))}).pipe(de(2),J((function(e){return lC(e.response,t)}))),progress$:r};var a=ke((function(){return n.next(1),Q(lC(function(e){var t,n,r="",a=0,o=new Uint8Array(e);for(a=0;a<o.length;a++)if(o[a]<128)r+=String.fromCharCode(o[a]);else{o[a]<224?(t=(63&o[a])<<6,n=a+1):o[a]<240?(t=(31&o[a])<<12,n=a+2):o[a]<248?(t=(15&o[a])<<18,n=a+3):o[a]<252?(t=(7&o[a])<<24,n=a+4):(t=(3&o[a])<<30,n=a+5);do{t|=(127&o[++a])<<6*(n-a)}while(a!=n);r+=String.fromCharCode(t)}return r}(e),t))}));return{model$:a,progress$:r}}function lC(e,t){var n,r,a,o,s={vertices:new Float32Array,uvs:new Float32Array,faces:new Uint16Array},i=e.match(/^v\s+(-?\d+(?:\.\d+)?\s+){2}-?\d+(?:\.\d+)?$/gm);if(i){var u=i.map((function(e){var t=e.split(" ");return t.shift(),t.map((function(e){return+e}))})),l=(n=[]).concat.apply(n,u);s.vertices=new Float32Array(l)}var c=e.match(/^vt( -?\d+(\.\d+)?){2}$/gm);if(c){var p=c.map((function(e){var t=e.split(" ");return t.shift(),t.map((function(e){return+e}))})),h=(r=[]).concat.apply(r,p);s.uvs=new Float32Array(h)}var d=e.match(/^f( \d+\/\d*\/\d*){3}$/gm);if(d){var f=d.map((function(e){var t=e.split(" ");return t.shift(),[+t[0].split("/")[0]-1,+t[1].split("/")[0]-1,+t[2].split("/")[0]-1]})),m=(a=[]).concat.apply(a,f);if(s.faces=new Uint16Array(m),t){var g=d.map((function(e){var t=e.split(" ");return t.shift(),[+t[0].split("/")[1]-1,+t[1].split("/")[1]-1,+t[2].split("/")[1]-1]})),y=new Uint16Array((o=[]).concat.apply(o,g)),b=s.uvs;s.uvs=new Float32Array(b.length);for(var v=0;v<y.length;v++){var w=y[v],x=b[2*w],_=b[2*w+1],k=s.faces[v];s.uvs[2*k]=x,s.uvs[2*k+1]=_}}}if(t){for(v=0;v<s.faces.length;v+=3){var T=s.faces[v];s.faces[v]=s.faces[v+1],s.faces[v+1]=T}for(v=0;v<s.vertices.length;v+=3)s.vertices[v]=-s.vertices[v]}return s}!function(e){e.Detection="DETECTION",e.Detected="DETECTED",e.Tracking="TRACKING"}(UI||(UI={}));var cC,pC=function(){function e(e,t){this._trackingState=UI.Detection,this._type=0,this._R=Float32Array.from(e),this._t=Float32Array.from(t),this._trackingState=UI.Detection}return e.prototype.setTrackingState=function(e){this._trackingState=e},e.prototype.getTrackingState=function(){return this._trackingState},e.prototype.isDetected=function(){return this._trackingState==UI.Tracking},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e},enumerable:!1,configurable:!0}),e.prototype.setRt=function(e,t){this._R=e.slice(0),this._t=t.slice(0)},e.prototype.setR=function(e){this._R=e.slice(0)},e.prototype.R=function(){return this._R},e.prototype.t=function(){return this._t},e.prototype.getPosition=function(){return[this._t[0],this._t[1],this._t[2]]},e.prototype.getRotation=function(){return[[this._R[0],this._R[1],this._R[2]],[this._R[3],this._R[4],this._R[5]],[this._R[6],this._R[7],this._R[8]]]},e.prototype.getRot=function(){return this._R},e.prototype.updateRotation=function(e){this._R=Float32Array.from(e)},e.prototype.translate=function(e,t,n){this._t[0]+=e,this._t[1]+=t,this._t[2]+=n},e.prototype.reset=function(){this._R=new Float32Array([1,0,0,0,-1,0,0,0,-1]),this._t=new Float32Array([0,0,0])},e.prototype.det=function(){return this._R[0]*(this._R[4]*this._R[8]-this._R[7]*this._R[5])-this._R[3]*(this._R[1]*this._R[8]-this._R[7]*this._R[2])+this._R[6]*(this._R[1]*this._R[5]-this._R[4]*this._R[2])},e.convert3x3Mat=function(e){return new Float32Array([e[0][0],e[0][1],e[0][2],e[1][0],e[1][1],e[1][2],e[2][0],e[2][1],e[2][2]])},e.convert3x3Mat_t=function(e){return new Float32Array([e[0][0],e[1][0],e[2][0],e[0][1],e[1][1],e[2][1],e[0][2],e[1][3],e[2][2]])},e.getQuatFromRotMat=function(e){var t=new Float32Array(4);return t[0]=Math.sqrt(Math.max(0,1+e[0]+e[4]+e[8]))/2,t[1]=Math.sqrt(Math.max(0,1+e[0]-e[4]-e[8]))/2,t[2]=Math.sqrt(Math.max(0,1-e[0]+e[4]-e[8]))/2,t[3]=Math.sqrt(Math.max(0,1-e[0]-e[4]+e[8]))/2,t[1]=e[7]-e[5]<0?-Math.abs(t[1]):Math.abs(t[1]),t[2]=e[2]-e[6]<0?-Math.abs(t[2]):Math.abs(t[2]),t[3]=e[3]-e[1]<0?-Math.abs(t[3]):Math.abs(t[3]),t},e.getRotMatFromQuat=function(e){var t=new Float32Array(9);return t[0]=1-2*e[2]*e[2]-2*e[3]*e[3],t[1]=2*e[1]*e[2]-2*e[3]*e[0],t[2]=2*e[1]*e[3]+2*e[2]*e[0],t[3]=2*e[1]*e[2]+2*e[3]*e[0],t[4]=1-2*e[1]*e[1]-2*e[3]*e[3],t[5]=2*e[2]*e[3]-2*e[1]*e[0],t[6]=2*e[1]*e[3]-2*e[2]*e[0],t[7]=2*e[2]*e[3]+2*e[1]*e[0],t[8]=1-2*e[1]*e[1]-2*e[2]*e[2],t},e.slerp=function(e,t,n){var r,a,o=new Float32Array(4),s=e[1]*t[1]+e[2]*t[2]+e[3]*t[3]+e[0]*t[0],i=Math.abs(s);if(i>=.99999)r=1-n,a=n;else{var u=Math.acos(i),l=Math.sin(u);r=Math.sin((1-n)*u)/l,a=Math.sin(n*u)/l}return s<0&&(a=-a),o[1]=r*e[1]+a*t[1],o[2]=r*e[2]+a*t[2],o[3]=r*e[3]+a*t[3],o[0]=r*e[0]+a*t[0],o},e.getCameraMat=function(e,t,n){var r=n/2/Math.tan(e*Math.PI/180/2),a=r,o=(t-1)/2,s=(n-1)/2,i=new Float32Array(9);return i[0]=a,i[2]=o,i[4]=r,i[5]=s,i[8]=1,i},e.getCameraParams=function(e,t,n){var r=n/2/Math.tan(e*Math.PI/180/2);return[r,r,(t-1)/2,(n-1)/2]},e.MatMultVec=function(e,t){var n=new Float32Array(3);return n[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],n[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2],n[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2],n},e.MatMult=function(e,t){var n=new Float32Array(9);return n[0]=e[0]*t[0]+e[1]*t[3]+e[2]*t[6],n[1]=e[0]*t[1]+e[1]*t[4]+e[2]*t[7],n[2]=e[0]*t[2]+e[1]*t[5]+e[2]*t[8],n[3]=e[3]*t[0]+e[4]*t[3]+e[5]*t[6],n[4]=e[3]*t[1]+e[4]*t[4]+e[5]*t[7],n[5]=e[3]*t[2]+e[4]*t[5]+e[5]*t[8],n[6]=e[6]*t[0]+e[7]*t[3]+e[8]*t[6],n[7]=e[6]*t[1]+e[7]*t[4]+e[8]*t[7],n[8]=e[6]*t[2]+e[7]*t[5]+e[8]*t[8],n},e.prototype.project=function(t,n){for(var r=new Float32Array(t.length/3*2),a=0;a<t.length/3;a++){var o=e.MatMultVec(this._R,new Float32Array([t[3*a],t[3*a+1],t[3*a+2]])),s=new Float32Array(3);s[0]=o[0]+this._t[0],s[1]=o[1]+this._t[1],s[2]=o[2]+this._t[2];var i=n[6]*s[0]+n[7]*s[1]+n[8]*s[2];r[2*a]=(n[0]*s[0]+n[1]*s[1]+n[2]*s[2])/i,r[2*a+1]=(n[3]*s[0]+n[4]*s[1]+n[5]*s[2])/i}return r},e.prototype.transform=function(t,n){for(var r=new Float32Array(t.length/3*2),a=0;a<t.length/3;a++){var o=e.MatMultVec(this._R,new Float32Array([t[3*a],t[3*a+1],t[3*a+2]]));r[3*a+0]=o[0]+this._t[0],r[3*a+1]=o[1]+this._t[1],r[3*a+2]=o[2]+this._t[2]}return r},e}(),hC=function(){function e(e){this.NB_BUFFERS=6,this._poses=[],this._nbFramesDelay=0,this._interpolation=0,this._filteringLevel=2,this._filterThreshold=-1,e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=this._nbFramesDelay:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)}return e.prototype.setNbFramesDelay=function(e){this._nbFramesDelay=e},e.prototype.setInterpolation=function(e){this._interpolation=e},e.prototype.setFilteringLevel=function(e){this._filteringLevel=e},e.prototype.setFilterThreshold=function(e){this._filterThreshold=e},e.prototype.reset=function(){this._poses=[]},e.prototype.setPose=function(e){this._poses.length===this.NB_BUFFERS&&(this._poses=this._poses.slice(0,-1)),this._poses=p([e],this._poses,!0)},e.prototype.getPose=function(){return this._poses.length>0?this._nbFramesDelay<this._poses.length?this._poses[this._nbFramesDelay]:this._poses[this._poses.length-1]:null},e.prototype.getInterpolatedPoseAtDelay=function(e){if(e>0&&e+1<this._poses.length){var t=this._poses[e-1],n=this._poses[e],r=this._poses[e+1];if(t.getTrackingState()!==UI.Tracking||r.getTrackingState()!==UI.Tracking)return n;for(var a=pC.getQuatFromRotMat(t.R()),o=pC.getQuatFromRotMat(r.R()),s=pC.slerp(a,o,.5),i=pC.getRotMatFromQuat(s),u=t.t(),l=r.t(),c=new Float32Array(3),p=0;p<3;p++)c[p]=.5*u[p]+.5*l[p];var h=new pC(i,c);return h.setTrackingState(n.getTrackingState()),h.type=n.type,h}return this._poses.length>0?this.getPose():this.getLastPose()},e.prototype.dst=function(e,t){return Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])+(e[2]-t[2])*(e[2]-t[2]))},e.prototype.mvts=function(e,t,n){return(this.dst(e,t)+this.dst(t,n))/2},e.prototype.getInterpolatedPose=function(){if(1==this._filteringLevel)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);if(2==this._filteringLevel){var e=this.getInterpolatedPoseAtDelay(this._nbFramesDelay-1),t=this.getInterpolatedPoseAtDelay(this._nbFramesDelay+1);if(null==e||null==t)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);if(e.getTrackingState()!==UI.Tracking||t.getTrackingState()!==UI.Tracking)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);var n=this._poses[this._nbFramesDelay],r=e.t(),a=t.t();if(this._filterThreshold>0){var o=this.dst(r,n.t()),s=this.dst(a,n.t());if(o>this._filterThreshold||s>this._filterThreshold)return n}for(var i=pC.getQuatFromRotMat(e.R()),u=pC.getQuatFromRotMat(t.R()),l=pC.slerp(i,u,this._interpolation),c=pC.getRotMatFromQuat(l),p=new Float32Array(3),h=0;h<3;h++)p[h]=(1-this._interpolation)*r[h]+this._interpolation*a[h];var d=new pC(c,p);return d.setTrackingState(n.getTrackingState()),d.type=n.type,d}return this.getLastPose()},e.prototype.updateDelay=function(e){e!=this._nbFramesDelay&&(e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS))},e.prototype.getLastPose=function(){return this._poses.length>0?this._poses[0]:null},e}();!function(e){e.Left="LEFT_FOOT",e.Right="RIGHT_FOOT",e.Both="BOTH_FOOT",e.Single="SINGLE_FOOT"}(cC||(cC={}));var dC,fC="config.bin",mC=function(){function e(){this._initialized=!1,this._currentWidth=0,this._currentHeight=0,this._trackingState=UI.Detection,this._useWasmForHeatmaps=!1,this._float_size=4,this._bufferHeatmaps=null,this._bufferKeypsDet=null,this._bufferFeatureScores=null,this._bufKeyps3D_R=null,this._bufKeyps3D_L=null,this._footToDetect=cC.Right,this._leftFootState=UI.Detection,this._rightFootState=UI.Detection,this._bufferKeypsTrack_L=null,this._bufferKeypsTrack_R=null,this._bufferHeatmaps_L=null,this._bufferHeatmaps_R=null,this._fastMovements_L=!1,this._fastMovements_R=!1,this._cnnOutputDataInvMask=null,this._trackHasHeatmaps=!0,this._debug=!1,this._debugInitialized=!1,this._reproj_t=15,this._reproj_fast_t=30,this._isDetected=!1}return e.prototype.getDebugImage=function(){return this._debugInitialized?this._debugImage:null},e.prototype.isDetected=function(){return this._isDetected},e.prototype.getPosition=function(e){void 0===e&&(e=cC.Right);var t=null;return(t=e==cC.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose())?t.getPosition():null},e.prototype.getRotation=function(e){void 0===e&&(e=cC.Right);var t=null;return(t=e==cC.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose())?t.getRotation():null},e.prototype.getPose=function(e){return void 0===e&&(e=cC.Right),e==cC.Right?this._pose_L:this._pose_R},e.prototype.getInterpolatedPose=function(e){return void 0===e&&(e=cC.Right),e==cC.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose()},e.prototype.isInitialized=function(){return this._initialized},e.prototype.initialize=function(e,t,n){var r,a,o,s;return l(this,void 0,void 0,(function(){var i,l,p,h,d,f,m,g,y,b,v,w,x=this;return c(this,(function(c){switch(c.label){case 0:if(null==e)throw"Invalid parameter";return(null===(r=null==t?void 0:t.wasmBackend)||void 0===r?void 0:r.enable)?(II({"tfjs-backend-wasm.wasm":null===(a=t.wasmBackend)||void 0===a?void 0:a.tfjsBackendWasmPath,"tfjs-backend-wasm-simd.wasm":null===(o=t.wasmBackend)||void 0===o?void 0:o.tfjsBackendWasmSimdPath,"tfjs-backend-wasm-threaded-simd.wasm":null===(s=t.wasmBackend)||void 0===s?void 0:s.tfjsBackendWasmThreadedPath}),[4,Ei("wasm")]):[3,2];case 1:c.sent(),c.label=2;case 2:return this.release(),this._videoManager=e,this._config=t?u(u({},NI),t):NI,"BOTH"!==this._config.footToDetect&&"BOTH_FEET"!==this._config.footToDetect||(this._footToDetect=cC.Both),this._poseManager_R=new hC(this._videoManager.getNbFramesDelay()),this._poseManager_R.setInterpolation(this._config.filteringShift),this._poseManager_R.setFilteringLevel(this._config.filteringLevel),this._poseManager_R.setFilterThreshold(.1),this._poseManager_L=new hC(this._videoManager.getNbFramesDelay()),this._poseManager_L.setInterpolation(this._config.filteringShift),this._poseManager_L.setFilteringLevel(this._config.filteringLevel),this._poseManager_L.setFilterThreshold(.1),i=new he(0),l=X(Xk({locateFile:function(e,t){return x._config.poseEstimationWasmFilename||t+e}})).pipe(we((function(){return i.next(1)}))),p=Wk(this._config.modelFilename,fC),h=p.model$,d=p.progress$,f=Wk(this._config.featuresFilename,fC),m=f.model$,g=f.progress$,y=uC(this._config.objFilename,!1),b=y.model$,v=y.progress$,w=K([i,d,g,v]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})),J((function(e){return n&&n(e)}))).subscribe(),[4,zx({poseModule:l,model:h,features:m,footObjModel:b}).pipe(J((function(e){var t;x._poseModule=e.poseModule,x._footObjModel=e.footObjModel,x._tfFootDetector=e.model.graphModel,x._footDetectorConfig=e.model.config,x._tfFootFeatures=e.features.graphModel,x._footFeaturesConfig=e.features.config,x._activeIds=x._config.activeIds,console.log(x._footFeaturesConfig),console.log(e.model.config),console.log(e.features.config),console.log("(DEBUG) XZIMG BACKEND",Ii());var n=Ac([1,x._footDetectorConfig.inHeight,x._footDetectorConfig.inWidth,3]),r=x._tfFootDetector.predict(n);x._footDetectorShape=r.shape,r.dataSync(),r.dispose(),n.dispose();var a=x._footDetectorConfig.outChannels;n=Ac([1,x._footFeaturesConfig.inHeight,x._footFeaturesConfig.inWidth,3]),(r=x._tfFootFeatures.predict(n))instanceof Array?r.forEach((function(e){return e.dispose()})):r.dispose(),n.dispose(),n=Ac([2,x._footFeaturesConfig.inHeight,x._footFeaturesConfig.inWidth,3]),(r=x._tfFootFeatures.predict(n))instanceof Array?r.forEach((function(e){return e.dispose()})):r.dispose(),n.dispose();var o=x._footFeaturesConfig.outChannels;if(x._footFeaturesConfig.outputNames&&x._footFeaturesConfig.numOutputs&&x._footFeaturesConfig.numOutputs>1)for(var s=0,i=0,u=x._footFeaturesConfig.outputNames;i<u.length;i++){var l=u[i];"heatmaps"==l?o=x._footFeaturesConfig.outputDims[3*s+2]:"coordinates"==l&&(o=x._footFeaturesConfig.outputDims[3*s+2]/2),s+=1}if(t=function(e,t){var n=Array.from(Array(t).keys());13==t&&(n=[54,210,295,415,416,425,463,582,644,721,726,730,813]),18==t&&(n=[54,210,295,406,415,416,417,423,425,463,518,582,644,657,721,726,730,813]);for(var r=n.length,a=new Float32Array(3*r),o=0;o<r;o++){var s=n[o];a[3*o]=e[3*s],a[3*o+1]=e[3*s+1],a[3*o+2]=e[3*s+2]}var i=new Float32Array(3*r);for(o=0;o<r;o++)i[3*o]=-a[3*o],i[3*o+1]=a[3*o+1],i[3*o+2]=a[3*o+2];return[a,i]}(x._footObjModel.vertices,o),x._rightKeyps3D=t[0],x._leftKeyps3D=t[1],x._bufKeyps3D_R=x._poseModule._malloc(x._rightKeyps3D.length*x._float_size),x._poseModule.HEAPF32.set(x._rightKeyps3D,x._bufKeyps3D_R/4),x._bufKeyps3D_L=x._poseModule._malloc(x._leftKeyps3D.length*x._float_size),x._poseModule.HEAPF32.set(x._leftKeyps3D,x._bufKeyps3D_L/4),x._footDetectorConfig.outWidth>1&&x._footDetectorConfig.outHeight>1){var c=a*x._footDetectorConfig.outWidth*x._footDetectorConfig.outHeight;x._bufferHeatmaps=x._poseModule._malloc(c*x._float_size)}x._footFeaturesConfig.outWidth>1&&x._footFeaturesConfig.outHeight>1&&(c=o*x._footFeaturesConfig.outWidth*x._footFeaturesConfig.outHeight,x._bufferHeatmaps_L=x._poseModule._malloc(c*x._float_size),x._bufferHeatmaps_R=x._poseModule._malloc(c*x._float_size)),x._bufferKeypsDet=x._poseModule._malloc(2*a*x._float_size),x._bufferKeypsTrack_L=x._poseModule._malloc(2*o*x._float_size),x._bufferKeypsTrack_R=x._poseModule._malloc(2*o*x._float_size),x._bufferFeatureScores=x._poseModule._malloc(o*x._float_size),x._pose_R=new pC(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),x._pose_L=new pC(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),x._trackHasHeatmaps=RI(x._footFeaturesConfig),x._initialized=!0})),ae((function(){return w.unsubscribe()}))).toPromise()];case 3:return c.sent(),[2]}}))}))},e.prototype.release=function(){this._initialized&&(this._poseModule._free(this._bufferHeatmaps),this._bufferHeatmaps_L&&this._poseModule._free(this._bufferHeatmaps_L),this._bufferHeatmaps_R&&this._poseModule._free(this._bufferHeatmaps_R),this._bufferKeypsDet&&this._poseModule._free(this._bufferKeypsDet),this._poseModule._free(this._bufferKeypsTrack_L),this._poseModule._free(this._bufferKeypsTrack_R),this._poseModule._free(this._bufferFeatureScores),this._poseModule._free(this._bufKeyps3D_R),this._poseModule._free(this._bufKeyps3D_L),this._hptrImageBuffer&&this._poseModule._free(this._hptrImageBuffer))},e.prototype.trackSync=function(e){var t;if(this._initialized){var n=this._videoManager.getVideoCanvas();n.width===this._currentWidth&&n.height===this._currentHeight||(this._currentWidth=n.width,this._currentHeight=n.height,t=pC.getCameraParams(this._config.fovY,this._currentWidth,this._currentHeight),this._fx=t[0],this._fy=t[1],this._cx=t[2],this._cy=t[3],this._poseModule.cwrap("xzimgInitializeCamera","number",["number","number","number"])(this._config.fovY,this._currentWidth,this._currentHeight)),this._poseManager_L.setNbFramesDelay(this._videoManager.getNbFramesDelay()),this._poseManager_R.setNbFramesDelay(this._videoManager.getNbFramesDelay());var r=e;null==e&&(r=this._videoManager.getLastBuffer()),null!=r?this.trackBothFeetSync(r):console.error("No video frame to process")}else console.error("Foot must be initialized to track")},e.prototype.trackBothFeetSync=function(e){var t=-1;if(this._rightFootState!=UI.Detection&&this._leftFootState!=UI.Detection){var n=this.trackBothFeetFeaturesSync(e,this._leftFootState,this._rightFootState,this._leftFootState==UI.Detected?this._initShape:this._leftFootRecShape,this._rightFootState==UI.Detected?this._initShape:this._rightFootRecShape,this._leftFootVis,this._rightFootVis,this._leftFootOcclusions,this._rightFootOcclusions),r=GI(n.scores_R,"RIGHT_FOOT",this._config.validTrackedKeypThs);this._rightFootRecShape=n.refinedFeatures_R,this._rightFootOcclusions=n.occlusions_R,this._rightFootVis=r.visibilty;var a=GI(n.scores_L,"LEFT_FOOT",this._config.validTrackedKeypThs);this._leftFootRecShape=n.refinedFeatures_L,this._leftFootOcclusions=n.occlusions_L,this._leftFootVis=a.visibilty;var o=this._config.trackScoreThs,s=this._reproj_t;this._fastMovements_R&&(s=this._reproj_fast_t);var i=this._rightFootRecShape.length/2,u=qI(i,"RIGHT_FOOT"),l=new zI(0,0,e.width,e.height),c=new WI((this._rightFootRecShape[u[0]]+this._rightFootRecShape[u[1]])/2,(this._rightFootRecShape[u[0]+i]+this._rightFootRecShape[u[1]+i])/2);l.isPointInside(c)&&this._rightFootVis[u[0]]&&this._rightFootVis[u[1]]&&r.globalScore>=o&&r.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._rightFootState,"RIGHT_FOOT"),this._rightFootState=UI.Tracking,t>s&&(this._rightFootState=UI.Detection)):this._rightFootState=UI.Detection,o=this._config.trackScoreThs,this._fastMovements_L&&(o=.1),s=this._reproj_t,this._fastMovements_L&&(s=this._reproj_fast_t),u=qI(i,"LEFT_FOOT");var p=new WI((this._leftFootRecShape[u[0]]+this._leftFootRecShape[u[1]])/2,(this._leftFootRecShape[u[0]+i]+this._leftFootRecShape[u[1]+i])/2);l.isPointInside(p)&&this._leftFootVis[u[0]]&&this._leftFootVis[u[1]]&&a.globalScore>=o&&a.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._leftFootState,"LEFT_FOOT"),this._leftFootState=UI.Tracking,t>s&&(this._leftFootState=UI.Detection)):this._leftFootState=UI.Detection,this._leftFootState==UI.Tracking&&this._rightFootState==UI.Tracking&&this.bothFeetSamePlace()&&(this._leftFootState=UI.Detection,this._rightFootState=UI.Detection)}else if(this._rightFootState!==UI.Detection&&this._leftFootState===UI.Detection){var h=this.trackFootFeaturesSync(e,this._rightFootState,this._rightFootState==UI.Detected?this._initShape:this._rightFootRecShape,this._rightFootVis,this._rightFootOcclusions,"RIGHT_FOOT");this._rightFootRecShape=h.refinedFeatures,this._rightFootOcclusions=h.occlusions,r=GI(h.scores,"RIGHT_FOOT",this._config.validTrackedKeypThs),this._rightFootVis=r.visibilty,o=this._config.trackScoreThs,s=this._reproj_t,this._fastMovements_R&&(s=this._reproj_fast_t),u=qI(this._rightFootRecShape.length/2,"RIGHT_FOOT"),this._rightFootVis[u[0]]&&this._rightFootVis[u[1]]&&r.globalScore>=o&&r.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._rightFootState,"RIGHT_FOOT"),this._rightFootState=UI.Tracking,t>s&&(this._rightFootState=UI.Detection)):this._rightFootState=UI.Detection;var d=this.detectFeetSync(e);this._initShape=d.refinedFeatures,a=GI(d.scores,"LEFT_FOOT",this._config.detectScoreThs),r=GI(d.scores,"RIGHT_FOOT",this._config.detectScoreThs);var f=!1;if(!this._fastMovements_R&&null!=this._cnnOutputDataInvMask){var m=sC(this._cnnOutputDataInvMask,this._footDetectorShape,!1);m[0];var g=GI(v=m[1],"LEFT_FOOT",this._config.detectScoreThs),y=GI(v,"RIGHT_FOOT",this._config.detectScoreThs);r.globalScore>a.globalScore&&r.globalScore>y.globalScore+.1&&g.globalScore>y.globalScore&&(f=!0)}f&&r.globalScore>this._config.detectScoreThs?(this.invertFoot(),this._rightFootRecShape=d.refinedFeatures,this._rightFootState=UI.Detected):a.globalScore>=this._config.detectScoreThs&&(this._leftFootRecShape=d.refinedFeatures,this._leftFootState=UI.Detected)}else if(this._leftFootState!==UI.Detection&&this._rightFootState===UI.Detection){var b=this.trackFootFeaturesSync(e,this._leftFootState,this._leftFootState==UI.Detected?this._initShape:this._leftFootRecShape,this._leftFootVis,this._leftFootOcclusions,"LEFT_FOOT");if(this._leftFootRecShape=b.refinedFeatures,this._leftFootOcclusions=b.occlusions,a=GI(b.scores,"LEFT_FOOT",this._config.validTrackedKeypThs),this._leftFootVis=a.visibilty,o=this._config.trackScoreThs,s=this._reproj_t,this._fastMovements_L&&(s=this._reproj_fast_t),u=qI(this._leftFootRecShape.length/2,"LEFT_FOOT"),a.globalScore>=o?(t=this.computePoseSync(this._leftFootState,"LEFT_FOOT"),this._leftFootState=UI.Tracking,t>s&&(this._leftFootState=UI.Detection)):this._leftFootState=UI.Detection,d=this.detectFeetSync(e),this._initShape=d.refinedFeatures,r=GI(d.scores,"RIGHT_FOOT",this._config.detectScoreThs),a=GI(d.scores,"LEFT_FOOT",this._config.detectScoreThs),f=!1,!this._fastMovements_L&&null!=this._cnnOutputDataInvMask){var v,w=sC(this._cnnOutputDataInvMask,this._footDetectorShape,!1);w[0],g=GI(v=w[1],"LEFT_FOOT",this._config.detectScoreThs),y=GI(v,"RIGHT_FOOT",this._config.detectScoreThs),a.globalScore>r.globalScore&&a.globalScore>g.globalScore+.1&&y.globalScore>g.globalScore&&(f=!0)}f&&a.globalScore>this._config.detectScoreThs?(this.invertFoot(),this._leftFootRecShape=d.refinedFeatures,this._leftFootState=UI.Detected):r.globalScore>=this._config.detectScoreThs&&(this._rightFootRecShape=d.refinedFeatures,this._rightFootState=UI.Detected)}else if(this._leftFootState===UI.Detection||this._rightFootState===UI.Detection){var x=this.detectFeetSync(e);if(this._initShape=x.refinedFeatures,a=GI(x.scores,"LEFT_FOOT",this._config.detectScoreThs),r=GI(x.scores,"RIGHT_FOOT",this._config.detectScoreThs),a.globalScore>=this._config.detectScoreThs&&(this._leftFootState=UI.Detected),r.globalScore>=this._config.detectScoreThs&&(this._rightFootState=UI.Detected),this._rightFootState!=UI.Detection&&this._leftFootState!=UI.Detection&&this.bothFeetSamePlaceInit()&&(this._rightFootState==UI.Detected?this._rightFootState=UI.Detection:this._leftFootState=UI.Detection),this._leftFootState==UI.Detected||this._rightFootState==UI.Detected){this._fastMovements_L=!0,this._fastMovements_R=!0;var _=this._poseModule.cwrap("xzimgMatchRecKeypsInit","number",["number"]);null==this._hptrImageBuffer&&(this._hptrImageBuffer=this._poseModule._malloc(e.width*e.height*4)),tC(this._poseModule,e,this._hptrImageBuffer);var k=nC(this._poseModule,this._hptrImageBuffer,e.width,e.height);_(k),this._poseModule._free(k)}}this._leftFootState===UI.Detection&&(this._pose_L=new pC(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0]))),this._rightFootState==UI.Detection&&(this._pose_R=new pC(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0]))),this._pose_R.setTrackingState(this._rightFootState),this._pose_R.type=0,this._poseManager_R.setPose(this._pose_R),this._pose_L.setTrackingState(this._leftFootState),this._pose_L.type=1,this._poseManager_L.setPose(this._pose_L)},e.prototype.detectFeetSync=function(e){var t,n,r,a,o=function(e,t){var n,r;return{crop:e>t?[(r=0)/t,(n=(e-t)/2)/e,1,(e-n)/e]:[(r=(t-e)/2)/t,(n=0)/e,(t-r)/t,1],deltaY:r,deltaX:n}}(this._currentWidth,this._currentHeight),s=o.crop,i=o.deltaY,u=o.deltaX,l=Li(e),c=vi(l,"float32"),p=$u(c,[1,this._currentHeight,this._currentWidth,3]),h=hd.cropAndResize(p,[s],[0],[this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth]),d=Wl(255),f=iu(h,d),m=null;if(this._footToDetect==cC.Both&&(this._leftFootState===UI.Tracking||this._rightFootState===UI.Tracking)){var g=function(e,t,n,r,a,o,s,i){for(var u=e.length/2,l=new Float32Array(2*u),c=0;c<u;c++)l[c]=(e[c]-a)/s,l[c+u]=(e[c+u]-r)/o;for(var p=HI(l,i),h=p[0],d=p[1],f=p[2]-h,m=p[3]-d,g=p[6]-h,y=p[7]-d,b=f*f+m*m,v=g*g+y*y,w=new Float32Array(n*t),x=0;x<t;x++)for(var _=0;_<n;_++){var k=_-h,T=x-d,S=k*f+T*m,E=k*g+T*y;S>0&&E>0&&S<b&&E<v||(w[x*n+_]=1)}return w}(this._leftFootState===UI.Tracking?this._leftFootRecShape:this._rightFootRecShape,this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth,i,u,(this._currentHeight-2*i)/this._footDetectorConfig.inWidth,(this._currentWidth-2*u)/this._footDetectorConfig.inHeight,this._leftFootState===UI.Tracking?"LEFT_FOOT":"RIGHT_FOOT"),y=Xp(g,"float32");m=$u(y,[1,this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth,1]),y.dispose()}var b=this._tfFootDetector.predict(f);if(null!=m){var v=mc(1,m),w=uu(b,v);this._cnnOutputDataInvMask=w.dataSync(),v.dispose(),w.dispose();var x=uu(b,m);b.dispose(),b=x,m.dispose()}var _,k,T=null!==(n=null==b?void 0:b.shape[3])&&void 0!==n?n:this._footDetectorConfig.outChannels,S=null!==(r=null==b?void 0:b.shape[1])&&void 0!==r?r:this._footDetectorConfig.outHeight,E=null!==(a=null==b?void 0:b.shape[2])&&void 0!==a?a:this._footDetectorConfig.outWidth;_=(t=sC(b.dataSync(),[1,S,E,T],!1))[0],k=t[1];var I=this._bufferKeypsDet/4;this._poseModule.HEAPF32.subarray(I,I+2*T).set(_),l.dispose(),c.dispose(),d.dispose(),h.dispose(),f.dispose(),p.dispose(),b.dispose();var C=Math.min(this._currentWidth,this._currentHeight),A=C/this._footDetectorConfig.inWidth,N=C/this._footDetectorConfig.inHeight;return this._simToImage_Det=function(e,t,n,r){var a=new Float32Array(6);return a[0]=r,a[1]=0,a[2]=t,a[3]=0,a[4]=n,a[5]=e,a}(i,u,N,A),{refinedFeatures:KI(_,this._simToImage_Det,!1,b.shape[1]),scores:k}},e.prototype.trackFootFeaturesSync=function(e,t,n,r,a,o){var s,i,u,l,c="LEFT_FOOT"==o?this._simToImage_L:this._simToImage_R;if(t!=UI.Detected){var p=Int32Array.from(r);this._activeIds.length>0&&(p.forEach((function(e,t){p[t]=0})),this._activeIds.forEach((function(e){p[e]=1})),r.forEach((function(e,t){0==e&&(p[t]=0)})),a&&a.forEach((function(e,t){e>0&&(r[t]=0)}))),i=(s=rC(this._poseModule,e,this._hptrImageBuffer,n,p))[0],u=s[1],l=s[2],Math.sqrt(u[2]*u[2]+u[3]*u[3])>10?"LEFT_FOOT"==o?this._fastMovements_L=!0:this._fastMovements_R=!0:"LEFT_FOOT"==o?this._fastMovements_L=!1:this._fastMovements_R=!1;var h=oC(n,i,l);"LEFT_FOOT"==o?this._pose_L.translate(h[0]*this._pose_L.t()[2]/this._fx,h[1]*this._pose_L.t()[2]/this._fy,0):"RIGHT_FOOT"==o&&this._pose_R.translate(h[0]*this._pose_R.t()[2]/this._fx,h[1]*this._pose_R.t()[2]/this._fy,0);for(var d=i.length/2,f=0;f<d;f++)i[f]=n[f]+h[0],i[f+d]=n[f+d]+h[1]}else i=n;c=QI(i,r,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,o);var m=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);m=XI(e,m,c),this._debug&&(this._debugInitialized=!0,this._debugImage=m,DI(this._footFeaturesConfig.inHeight,this._footFeaturesConfig.inWidth,4,m));var g=this.detectKeypointsSync([m],[o]),y=KI(g.coordinates[0],c,"LEFT_FOOT"==o,this._footFeaturesConfig.outHeight);return"LEFT_FOOT"==o?this._simToImage_L=c:this._simToImage_R=c,{refinedFeatures:y,scores:g.scores[0],occlusions:g.occlusions[0]}},e.prototype.detectKeypointsSync=function(e,t){for(var n=[],r=[],a=[],o=[],s=0,i=null,u=0,l=e;u<l.length;u++){var c=l[u],p=Li(c);o.push(p);var h=vi(p,"float32");o.push(h);var d=$u(h,[1,this._footFeaturesConfig.inHeight,this._footFeaturesConfig.inWidth,3]);o.push(d);var f=Wl(255),m=iu(d,f);o.push(m),"LEFT_FOOT"==t[s]&&(m=_p(m,1),o.push(m)),i?(i=Bu([i,m]),o.push(i)):i=m,s+=1}if(null!=i){var g=[];if(this._footFeaturesConfig.numOutputs&&1!=this._footFeaturesConfig.numOutputs)for(var y=0,b=g=this._tfFootFeatures.predict(i);y<b.length;y++){var v=b[y];o.push(v)}else{var w=this._tfFootFeatures.predict(i);o.push(w),g.push(w)}for(var x=0,_=0,k=g;_<k.length;_++){w=k[_];for(var T=[],S=[],E=0,I=nh(w,0);E<I.length;E++){var C=I[E];o.push(C);var A=Yl(C,0);o.push(A),T.push(C.dataSync()),S.push(A.shape)}if(this._footFeaturesConfig.outputNames&&"heatmaps"!=this._footFeaturesConfig.outputNames[x]){if(this._footFeaturesConfig.outputNames&&"coordinates"==this._footFeaturesConfig.outputNames[x])for(L=0;L<T.length;L++){for(var N=S[L][1]/2,R=new Float32Array(2*N),F=this._footFeaturesConfig.inHeight/2,O=this._footFeaturesConfig.inWidth/2,M=0;M<N;M++)R[M]=(T[L][M]+1)*O,R[M+N]=(T[L][M+N]+1)*F;n.push(R)}else if(this._footFeaturesConfig.outputNames&&"scores"==this._footFeaturesConfig.outputNames[x])for(L=0;L<T.length;L++){var $=S[L][1],D=new Float32Array($);for(M=0;M<$;M++)D[M]=1/(1+Math.exp(-T[L][M]));r.push(D)}else if(this._footFeaturesConfig.outputNames&&"occlusions"==this._footFeaturesConfig.outputNames[x])for(L=0;L<T.length;L++){$=S[L][1];var P=new Float32Array($);for(M=0;M<$;M++)P[M]=1/(1+Math.exp(-T[L][M]));a.push(P)}}else for(var L=0;L<T.length;L++){var B;B=this._useWasmForHeatmaps?iC(this._poseModule,S[L],T[L],"LEFT_FOOT"==t[L]?this._bufferHeatmaps_L:this._bufferHeatmaps_R,"LEFT_FOOT"==t[L]?this._bufferKeypsTrack_L:this._bufferKeypsTrack_R,this._bufferFeatureScores):sC(T[L],S[L],!1),n.push(B[0]),r.push(B[1]);var U=S[L][1]*S[L][2]*S[L][3],W="LEFT_FOOT"==t[L]?this._bufferHeatmaps_L/4:this._bufferHeatmaps_R/4;this._poseModule.HEAPF32.subarray(W,W+U).set(T[L])}x+=1}for(L=0;L<n.length;L++)N=n[L].length,W="LEFT_FOOT"==t[L]?this._bufferKeypsTrack_L/4:this._bufferKeypsTrack_R/4,this._poseModule.HEAPF32.subarray(W,W+2*N).set(n[L])}return o.forEach((function(e){return e.dispose()})),{coordinates:n,scores:r,occlusions:a}},e.prototype.trackBothFeetFeaturesSync=function(e,t,n,r,a,o,s,i,u){var l,c,p;if(t!=UI.Detected&&n!=UI.Detected){var h=r.length/2,d=new Int32Array(2*h);d.set(o),d.set(s,h);var f=null;i&&u&&((f=new Float32Array(2*h)).set(i),f.set(u,h));var m=Int32Array.from(d);this._activeIds.length>0&&(m.forEach((function(e,t){m[t]=0})),this._activeIds.forEach((function(e){m[e]=1,m[e+h]=1})),d.forEach((function(e,t){0==e&&(m[t]=0)})),f&&f.forEach((function(e,t){e>0&&(d[t]=0)})));var g=rC(this._poseModule,e,this._hptrImageBuffer,function(e,t){for(var n=e.length/2,r=t.length/2,a=n+r,o=new Float32Array(e.length+t.length),s=0;s<n;s++)o[s]=e[s],o[s+a]=e[s+n];for(s=0;s<r;s++)o[s+n]=t[s],o[s+a+n]=t[s+r];return o}(r,a),m),y=g[0];g[1];var b=g[2];l=function(e,t,n){var r=new Float32Array(2*t),a=new Float32Array(2*n),o=e.length/2;t+n!=o&&console.log("ERROR (separateShapes): shapes not correct dims");for(var s=0;s<t;s++)r[s]=e[s],r[s+t]=e[s+o];for(s=0;s<n;s++)a[s]=e[s+t],a[s+n]=e[s+o+t];return[r,a]}(y,h,h),c=l[0],p=l[1];var v=b.slice(0,h),w=b.slice(h,2*h),x=aC(this._poseModule,r,c),_=aC(this._poseModule,a,p);Math.sqrt(x[2]*x[2]+x[3]*x[3])>10?this._fastMovements_L=!0:this._fastMovements_L=!1,Math.sqrt(_[2]*_[2]+_[3]*_[3])>10?this._fastMovements_R=!0:this._fastMovements_R=!1;var k=oC(r,c,v);this._pose_L.translate(k[0]*this._pose_L.t()[2]/this._fx,k[1]*this._pose_L.t()[2]/this._fy,0);var T=oC(a,p,w);this._pose_R.translate(T[0]*this._pose_R.t()[2]/this._fx,T[1]*this._pose_R.t()[2]/this._fy,0);for(var S=p.length/2,E=0;E<S;E++)p[E]=a[E]+T[0],p[E+S]=a[E+S]+T[1],c[E]=r[E]+k[0],c[E+S]=r[E+S]+k[1]}else c=r,p=a;this._simToImage_L=QI(c,o,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,"LEFT_FOOT");var I=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);I=XI(e,I,this._simToImage_L),this._simToImage_R=QI(p,s,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,"RIGHT_FOOT");var C=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);C=XI(e,C,this._simToImage_R);var A=this.detectKeypointsSync([I,C],["LEFT_FOOT","RIGHT_FOOT"]),N=KI(A.coordinates[0],this._simToImage_L,!0,this._footFeaturesConfig.outHeight),R=KI(A.coordinates[1],this._simToImage_R,!1,this._footFeaturesConfig.outHeight);return t!=UI.Detected&&(N=jI(N,$I(A.scores[0],this._config.validTrackedKeypThs),c,o,.2)),n!=UI.Detected&&(R=jI(R,$I(A.scores[1],this._config.validTrackedKeypThs),p,s,.2)),{refinedFeatures_L:N,refinedFeatures_R:R,scores_L:A.scores[0],scores_R:A.scores[1],occlusions_L:A.occlusions[0],occlusions_R:A.occlusions[1]}},e.prototype.computePoseSync=function(e,t){var n=this,r=-1,a=this._poseModule.cwrap("xzimgEstimateRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number","number"]);if(e==UI.Detected||e==UI.Tracking){var o=1;e==UI.Detected&&(o=0);var s=1;this._trackHasHeatmaps&&(s=3);var i=3;"LEFT_FOOT"!=t||this._fastMovements_L||(i=1),"RIGHT_FOOT"!=t||this._fastMovements_R||(i=1);var u=new Float32Array(18);"LEFT_FOOT"==t?(u.set(this._pose_L.R()),u.set(this._pose_L.t(),9)):(u.set(this._pose_R.R()),u.set(this._pose_R.t(),9));var l=JI(this._poseModule,u),c="LEFT_FOOT"==t?this._simToImage_L:this._simToImage_R,p=Float32Array.from([1,0,0,0,1,0]);this._trackHasHeatmaps&&(p=Float32Array.from(c.slice(0,6)),"LEFT_FOOT"==t&&(p[2]+=p[1]*(this._footFeaturesConfig.outWidth-1),p[5]+=p[4]*(this._footFeaturesConfig.outHeight-1),p[1]=-p[1],p[4]=-p[4]));var h=JI(this._poseModule,p),d=null,f=null,m=new Float32Array(2*this._activeIds.length),g=new Float32Array(3*this._activeIds.length),y="LEFT_FOOT"==t?this._leftFootRecShape:this._rightFootRecShape,b="LEFT_FOOT"==t?this._leftKeyps3D:this._rightKeyps3D,v=y.length/2;this._activeIds.length>0?(this._activeIds.forEach((function(e,t){m[t]=y[e],m[t+n._activeIds.length]=y[e+v]})),d=JI(this._poseModule,m),this._activeIds.forEach((function(e,t){g[3*t]=b[3*e],g[3*t+1]=b[3*e+1],g[3*t+2]=b[3*e+2]})),f=JI(this._poseModule,g),v=this._activeIds.length):(d=this._trackHasHeatmaps?"LEFT_FOOT"==t?this._bufferKeypsTrack_L:this._bufferKeypsTrack_R:JI(this._poseModule,y),f=JI(this._poseModule,"LEFT_FOOT"==t?this._leftKeyps3D:this._rightKeyps3D)),-1==(r=a("LEFT_FOOT"==t?this._bufferHeatmaps_L:this._bufferHeatmaps_R,this._footFeaturesConfig.outHeight,this._footFeaturesConfig.outWidth,v,0,h,d,f,o,s,i,l))&&(r=1e4),"LEFT_FOOT"==t?this._pose_L=new pC(new Float32Array(this._poseModule.HEAPF32.buffer,l,9),new Float32Array(this._poseModule.HEAPF32.buffer,l+9*this._float_size,3)):this._pose_R=new pC(new Float32Array(this._poseModule.HEAPF32.buffer,l,9),new Float32Array(this._poseModule.HEAPF32.buffer,l+9*this._float_size,3)),h&&this._poseModule._free(h),d&&!this._trackHasHeatmaps&&this._poseModule._free(d),f&&this._activeIds.length>0&&this._poseModule._free(f)}return r},e.prototype.invertFoot=function(){var e,t,n,r,a,o,s;e=[this._rightFootRecShape,this._leftFootRecShape],this._rightFootRecShape=e[0],this._rightFootRecShape=e[1],t=[this._pose_L,this._pose_R],this._pose_R=t[0],this._pose_L=t[1],n=[this._poseManager_L,this._poseManager_R],this._poseManager_R=n[0],this._poseManager_L=n[1],r=[this._simToImage_R,this._simToImage_L],this._simToImage_L=r[0],this._simToImage_R=r[1],a=[this._rightFootState,this._leftFootState],this._leftFootState=a[0],this._rightFootState=a[1],o=[this._rightFootVis,this._leftFootVis],this._leftFootVis=o[0],this._rightFootVis=o[1],s=[this._bufferHeatmaps_L,this._bufferHeatmaps_R],this._bufferHeatmaps_R=s[0],this._bufferHeatmaps_L=s[1]},e.prototype.dst=function(e,t,n,r){return Math.sqrt((e-n)*(e-n)+(t-r)*(t-r))},e.prototype.bothFeetSamePlaceInit=function(){var e=this._initShape.length/2,t=0;return t+=this.dst(this._initShape[0],this._initShape[e],this._initShape[4],this._initShape[4+e]),t+=this.dst(this._initShape[1],this._initShape[1+e],this._initShape[3],this._initShape[3+e]),(t+=this.dst(this._initShape[2],this._initShape[2+e],this._initShape[5],this._initShape[5+e]))/3<this.dst(this._initShape[0],this._initShape[e],this._initShape[2],this._initShape[2+e])/5},e.prototype.bothFeetSamePlace=function(){var e=HI(this._leftFootRecShape,"LEFT_FOOT"),t=e[0],n=e[1],r=e[2],a=e[3],o=e[4],s=e[5],i=e[6],u=e[7],l=HI(this._rightFootRecShape,"RIGHT_FOOT"),c=l[0],p=l[1],h=l[2],d=l[3],f=l[4],m=l[5],g=l[6],y=l[7],b=this.dst(t,n,i,u)/8;return this.dst(t,n,c,p)<b&&this.dst(r,a,h,d)<b&&this.dst(o,s,f,m)<b&&this.dst(i,u,g,y)<b},e.prototype.getKeypoints_L=function(){return this._leftFootRecShape},e.prototype.getKeypoints_R=function(){return this._rightFootRecShape},e.prototype.getScores_L=function(){return this._leftFootVis},e.prototype.getScores_R=function(){return this._rightFootVis},e.prototype.getOcclusion_L=function(){return this._leftFootOcclusions},e.prototype.getOcclusion_R=function(){return this._rightFootOcclusions},e}(),gC={modelFilename:"",featuresFilename:"",objFilename:"",fovY:50,detectScoreThs:.2,trackScoreThs:.4,geometryToDetect:"LAMBORGHINI",filteringLevel:2,filteringShift:.5,validDetectedKeypThs:.2,validTrackedKeypThs:.2,detectNumKeypsThs:3,trackedNumKeypsThs:3,normMode:"",reprojThs:25,activeIds:new Int32Array,computePose:!0,useWasm:!0},yC=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(e){return Math.sqrt((e.x-this.x)*(e.x-this.x)+(e.y-this.y)*(e.y-this.y))},e}();function bC(e){return e==dC.UpperBody||e==dC.FullBody}!function(e){e.Lamborghini="LAMBORGHINI",e.Horse="HORSE",e.WatsonCan="WATSON-CAN",e.MartellBottle="MARTELL-BOTTLE",e.Necklace="NECKLACE",e.Wrist="WRIST",e.Hand="HAND",e.UpperBody="UPPER-BODY",e.FullBody="FULL-BODY",e.CanKivisense="CAN-KIVISENSE",e.ToyTruck="TOY-TRUCK",e.Chivas="CHIVAS",e.ChivasLarge="CHIVAS-LARGE",e.Lion="LION",e.Bartender="BARTENDER",e.Wcbottle="WCBOTTLE",e.EQA="EQA",e.Face="FACE"}(dC||(dC={}));var vC,wC,xC="config.json",_C=function(){function e(){this._initialized=!1,this._nonRigidInitialized=!1,this._currentWidth=0,this._currentHeight=0,this._trackingState=UI.Detection,this._denseVertices=new Float32Array(0),this._geometryType=dC.Lamborghini,this._resetPose=!1,this._float_size=4,this._int_size=4,this._bufferHeatmaps=null,this._bufferKeypsDet=null,this._bufferFeatureScores=null,this._bufInOutPose=null,this._bufKeyps3D=null,this._bufMirroredKeyps3D=null,this._bufferKeypsTrack=null,this._bufferPdmModel=null,this._bufDenseVertices3D=null,this._reprojError=0,this._hptrImageBuffer=null,this._fastMvt=!1,this._mirrored=!1,this._debug=!0,this._debugInitialized=!1}return e.prototype.getDebugImage=function(){return this._debugInitialized?this._debugImage:null},e.prototype.isDetected=function(){return this._trackingState===UI.Tracking},e.prototype.getStatus=function(){return this._trackingState},e.prototype.getPosition=function(){var e=this._poseManager.getInterpolatedPose();return e?e.getPosition():null},e.prototype.getRotation=function(){var e=this._poseManager.getInterpolatedPose();return e?e.getRotation():null},e.prototype.getPose=function(){return this._pose},e.prototype.getVisibility=function(){return this._visibility},e.prototype.getKeypoints=function(){return this._keyps2D},e.prototype.getReprojKeypoints=function(){return this._reprojKeyps2D},e.prototype.getKeypoints3D=function(){return this._keyps3D},e.prototype.getDenseKeypoints3D=function(){return this._denseVertices},e.prototype.getInterpolatedPose=function(){return this._poseManager.getInterpolatedPose()},e.prototype.isInitialized=function(){return this._initialized},e.prototype.isMirrored=function(){return this._mirrored},e.prototype.getReprojError=function(){return this._reprojError},e.prototype.initialize=function(e,t,n){var r,a,o,s,i;return l(this,void 0,void 0,(function(){var l,p,h,d,f,m,g,y,b,v,w,x,_,k,T,S,E,C=this;return c(this,(function(c){switch(c.label){case 0:if(null==e)throw"Invalid parameter";return this._config=t?u(u({},gC),t):gC,(null===(r=null==t?void 0:t.wasmBackend)||void 0===r?void 0:r.enable)?(II({"tfjs-backend-wasm.wasm":null===(a=t.wasmBackend)||void 0===a?void 0:a.tfjsBackendWasmPath,"tfjs-backend-wasm-simd.wasm":null===(o=t.wasmBackend)||void 0===o?void 0:o.tfjsBackendWasmSimdPath,"tfjs-backend-wasm-threaded-simd.wasm":null===(s=t.wasmBackend)||void 0===s?void 0:s.tfjsBackendWasmThreadedPath}),[4,Ei("wasm")]):[3,2];case 1:c.sent(),c.label=2;case 2:return this.release(),this._videoManager=e,this._poseManager=new hC(this._videoManager.getNbFramesDelay()),this._poseManager.setInterpolation(this._config.filteringShift),this._poseManager.setFilteringLevel(this._config.filteringLevel),this._geometryType=function(e){if(e){if("LAMBORGHINI"===e)return dC.Lamborghini;if("HORSE"===e)return dC.Horse;if("WATSON-CAN"===e)return dC.WatsonCan;if("MARTELL-BOTTLE"===e)return dC.MartellBottle;if("NECKLACE"===e)return dC.Necklace;if("WRIST"===e)return dC.Wrist;if("HAND"===e)return dC.Hand;if("UPPER-BODY"===e)return dC.UpperBody;if("FULL-BODY"===e)return dC.FullBody;if("CAN-KIVISENSE"===e)return dC.CanKivisense;if("TOY-TRUCK"===e)return dC.ToyTruck;if("CHIVAS"===e)return dC.Chivas;if("CHIVAS-LARGE"===e)return dC.ChivasLarge;if("LION"===e)return dC.Lion;if("BARTENDER"===e)return dC.Bartender;if("WCBOTTLE"===e)return dC.Wcbottle;if("EQA"===e)return dC.EQA;if("FACE"===e)return dC.Face}return dC.Lamborghini}(this._config.geometryToDetect),l=new he(0),p=X(Xk({locateFile:function(e,t){return C._config.poseEstimationWasmFilename||t+e}})).pipe(we((function(){return l.next(1)}))),h=Wk(this._config.modelFilename,xC),d=h.model$,f=h.progress$,m=Wk(this._config.featuresFilename,xC),g=m.model$,y=m.progress$,b=uC(this._config.objFilename,!1),v=b.model$,w=b.progress$,x=new he(0),k="upper-body-pdm",this._config.pdmContainer?(T=this._config.pdmContainer,"string"==typeof this._config.pdmContainer&&(S=null===(i=this._config.pdmContainer)||void 0===i?void 0:i.replace(/\\/g,"/"),k=null==S?void 0:S.substring(S.lastIndexOf("/")+1,S.lastIndexOf("."))),_=function(e,t,n){return"string"==typeof e?i_({url:e,method:"GET",responseType:"arraybuffer",async:!0,progressSubscriber:new I((function(e){return n.next(.5*e.loaded/e.total)}),(function(e){}),(function(){return n.next(.5)}))}).pipe(de(2),ge((function(e){return Q(W_(new Uint8Array(e.response)))})),ge((function(r){return r[t]?(n.next(1),Q(r[t])):ne("File ".concat(t," not found in ").concat(e))}))):Q(W_(new Uint8Array(e))).pipe(ge((function(e){return e[t]?(n.next(1),Q(e[t])):ne("File ".concat(t," not found"))})))}(T,this._config.pdmName?this._config.pdmName:k+".bin",x)):(x.next(1),_=Q(null)),E=K([l,f,x,y,w]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})),J((function(e){return n&&n(e)}))).subscribe(),[4,zx({poseModule:p,detectorModel:d,pdmModel:_,trackerModel:g,geometryObjModel:v}).pipe(J((function(e){var t;C._poseModule=e.poseModule,C._geometryObjModel=e.geometryObjModel,C._tfKeypointsDetector=e.detectorModel.graphModel,C._detectorConfig=e.detectorModel.config,C._tfKeypointsTracker=e.trackerModel.graphModel,C._trackerConfig=e.trackerModel.config;var n=Ac([1,C._detectorConfig.inHeight,C._detectorConfig.inWidth,3]),r=C._tfKeypointsDetector.predict(n);C._detectorOutDims=r.shape,r.dispose(),C._detectorConfig.inHeight===C._trackerConfig.inHeight&&C._detectorConfig.inWidth===C._trackerConfig.inWidth||(n.dispose(),n=Ac([1,C._trackerConfig.inHeight,C._trackerConfig.inWidth,3])),(r=C._tfKeypointsTracker.predict(n))instanceof Array?(r.forEach((function(e){return e.dispose()})),C._trackerOutDims=[1,C._trackerConfig.outHeight,C._trackerConfig.outWidth,C._trackerConfig.outChannels]):(C._trackerOutDims=r.shape,r.dispose()),n.dispose(),C._debug&&(console.log(C._detectorConfig),console.log(C._trackerConfig),console.log("(DEBUG) XZIMG BACKEND",Ii()),console.log("_trackerOutDims",C._trackerOutDims)),C._activeIds=C._config.activeIds,C._trackHasHeatmaps=RI(C._trackerConfig),t=function(e,t){if("NECKLACE"==t)return[n=new Float32Array([-1.982586,1.762905,-1.256474,-1.4803,.73489,-.059477,-.863695,.091572,.505433,-179e-6,-.518833,.632376,.863894,.089272,.503284,1.479377,.729931,-.063135,1.981941,1.7644,-1.255762]),new Float32Array([-1.982586,1.762905,-1.256474,1.981941,1.7644,-1.255762])];if("CAN-KIVISENSE"==t)return[n=new Float32Array([.11749199777841568,.3616040050983429,-.5216580033302307,.3387719988822937,.1726129949092865,-.5216580033302307,.059477999806404114,-.37553098797798157,-.5216580033302307,-.1752689927816391,-.3439840078353882,.5761319994926453,.3802120089530945,-0,-.3024890124797821,.3387719988822937,-.1726129949092865,-.3024890124797821,-.1726129949092865,-.3387719988822937,-.3024890124797821,-.3616029918193817,-.11749199777841568,-.3024890124797821,-.11749199777841568,.3616040050983429,-.3024890124797821,.3802120089530945,-0,-.08331900089979172,.22348299622535706,-.3075979948043823,-.08331900089979172,-.3075979948043823,-.22348299622535706,-.08331900089979172,.37553098797798157,-.059477999806404114,.1358499974012375,-0,-.3802120089530945,.1358499974012375,-.37553098797798157,-.059477999806404114,.1358499974012375,.059477999806404114,.37553098797798157,.1358499974012375,.3616040050983429,.11749199777841568,.3550190031528473,-.3616029918193817,-.11749199777841568,.3550190031528473,-.3616029918193817,.11749199777841568,.3550190031528473,-.11749199777841568,.3616029918193817,.3550190031528473]),new Float32Array([0,0,-.5991089940071106,0,-0,.6023629903793335])];if("TOY-TRUCK"==t)return[n=new Float32Array([-.11474676430225372,.06819115579128265,.12616248428821564,-3.9706208099232754e-7,-.14720511436462402,.28020843863487244,5.515660461696825e-8,-.3098587989807129,.08606547862291336,-.18071073293685913,-.27267926931381226,-.012890318408608437,3.1216436013892235e-7,.39625027775764465,.03189631924033165,.23052667081356049,.24702677130699158,.002463694429025054,.1103515625,.2759860157966614,.15902937948703766,.18071091175079346,-.27267909049987793,-.012890467420220375,-.23046159744262695,-.11318685114383698,.0017448731232434511,.23046180605888367,-.1131867840886116,.0017446735873818398,-.1103513240814209,.275985985994339,.15902943909168243,.22978469729423523,.383583128452301,-.09141343832015991,-.22978472709655762,.38358309864997864,-.09141325950622559,-.23052656650543213,.247026726603508,.002463878598064184,.11429085582494736,.06870604306459427,.12790152430534363,.11895161867141724,-.05556913837790489,.37969091534614563,.11927806586027145,.1806230992078781,.373945027589798,-.1189512312412262,-.05556917190551758,.3796910345554352,-.11927773058414459,.18062305450439453,.3739452064037323]),new Float32Array([5.515660461696825e-8,-.3098587989807129,.08606547862291336,3.1216436013892235e-7,.39625027775764465,.03189631924033165])];if("CHIVAS"==t)return[n=new Float32Array([-3.1930644239785977e-10,-15140265077207005e-22,5.86190128326416,0,-.9621832966804504,1.9865937232971191,1.1873104572296143,-.9285097718238831,.9833493232727051,1.1932897567749023,-.9253148436546326,-1.3412771224975586,0,.9153332114219666,2.9489502906799316,-1.5160919427871704,.8744217157363892,.3604915142059326,-3.4059355336069075e-9,.9318456053733826,.3808324337005615,0,.9403911828994751,1.5472331047058105,.8038088083267212,-.9315917491912842,-.4920954704284668,1.5160919427871704,.8744216561317444,.3604915142059326,-2.058072090148926,-.06387438625097275,-2.1172304153442383,2.0580718517303467,-.06387437880039215,-2.1172304153442383,1.1926252841949463,.9239217042922974,-.5218658447265625,-4.4702903601034905e-9,-.9262475371360779,2.8632278442382812,-.02674211747944355,-1.5987444257348216e-8,-3.3316898345947266,-1.3472687005996704,-.9158325791358948,.9859023094177246,1.6359063386917114,-.8202042579650879,-2.4852395057678223,-1.6359063386917114,-.8202041983604431,-2.4852395057678223,-1.2821598052978516,-.9170172810554504,-1.34637451171875,-1.2809302806854248,-.9167184233665466,-.529242992401123,-2.0578272342681885,-.06386483460664749,1.5451469421386719,1.6359063386917114,.8202039003372192,-2.485239267349243,-1.5809047222137451,.8463804721832275,-2.4669992923736572,.7743757367134094,-.04055686667561531,3.7609105110168457,-1.099993348121643,.9303679466247559,-1.3362138271331787,1.0999937057495117,.9303681254386902,-1.3362138271331787,-1.2809303998947144,.9167175889015198,-.529242753982544,-.7743757367134094,-.040556877851486206,3.760910987854004,2.0578272342681885,-.06386483460664749,1.5451469421386719]),new Float32Array([-.02674211747944355,-1.5987444257348216e-8,-3.3316898345947266,-3.1930644239785977e-10,-15140265077207005e-22,5.86190128326416])];if("CHIVAS-LARGE"==t)return[n=new Float32Array([-.7353339195251465,-9.039938504429301e-7,2.8790359497070312,.7353339195251465,-9.039938504429301e-7,2.8790359497070312,-1.0241641998291016,-1.0241650342941284,2.1618540287017822,1.1196224689483643,-.9188478589057922,2.1618540287017822,.14197710156440735,-1.4414118528366089,2.1618540287017822,-.14197710156440735,1.4414103031158447,2.1618545055389404,-.5879112482070923,.057907234877347946,4.713740348815918,.5879112482070923,.057907234877347946,4.713740348815918,.06999345868825912,.0023226356133818626,-2.3130407333374023,0,-.07499408721923828,6.051614284515381,.0008376236073672771,1.707755446434021,-1.6613836288452148,-1.3236799240112305,1.0878145694732666,-.10835576057434082,-1.086346983909607,-1.323068618774414,-.10257232189178467,1.3245174884796143,1.0878145694732666,-.10835576057434082,1.2116090059280396,-1.2100292444229126,-.10835611820220947,.8094201683998108,1.5145108699798584,.6681584119796753,-.953505277633667,1.427893042564392,.6681584119796753,-1.0888724327087402,-1.3264672756195068,.6710498332977295,1.2140388488769531,-1.2132492065429688,.6681579351425171,.49678289890289307,-1.6338136196136475,-.8848701119422913,.00010470295092090964,1.7187724113464355,1.0564154386520386,1.0838285684585571,-1.3177416324615479,-1.2731270790100098,1.0838285684585571,1.3218059539794922,-1.2731266021728516,-1.0823626518249512,1.3218059539794922,-1.2731266021728516,-.9479852914810181,-1.4177916049957275,-1.2630056142807007,.3440423905849457,-.6436600685119629,3.901371479034424,-.46299880743026733,-.5641732215881348,3.901371479034424]),new Float32Array([.06999345868825912,.0023226356133818626,-2.3130407333374023,0,-.07499408721923828,6.051614284515381])];if("LION"==t)return[n=new Float32Array([-.0022359604481607676,-.951945424079895,2.026939868927002,-.448139488697052,-.6012729406356812,-1.6381982564926147,-.5041450262069702,.4640916585922241,-1.7428531646728516,.5572898387908936,.4562094509601593,-1.7489975690841675,.4558115005493164,-.6014943718910217,-1.639726161956787,-.5527711510658264,-.9193709492683411,3.0056838989257812,.5723921656608582,-.9076480865478516,3.0084033012390137,.5884838104248047,.0083160400390625,1.280758261680603,-.6188563108444214,-.009009452536702156,1.2967206239700317,.030467068776488304,.4174400866031647,-.521793007850647,-1.5193467140197754,.0034290971234440804,-.37409281730651855,1.5193467140197754,.0034290971234440804,-.37409281730651855,.012890640646219254,-.8310151696205139,2.4351325035095215,1.5662710666656494,.9279237985610962,3.319540500640869,-1.5894092321395874,.8687598705291748,3.289144515991211,.3409583568572998,-.5160142183303833,1.274591088294983,-.3600188195705414,-.5107225775718689,1.2790225744247437,-1.097593903541565,.11527538299560547,-1.0057109594345093,1.1363357305526733,-.5465875864028931,-.971623957157135,.8704371452331543,.5547775626182556,.3597971200942993,3.982757734721787e-10,.5748654007911682,.7409988641738892,1.0960721969604492,.12153985351324081,-.9948496222496033,-1.1377226114273071,-.5433639287948608,-.9926916360855103,-.8704371452331543,.5547775626182556,.3597968816757202,0,-.5633412003517151,-.9722840189933777,0,-.5655208826065063,.37440025806427]),new Float32Array([.012890640646219254,-.8310151696205139,2.4351325035095215,0,-.5633412003517151,-.9722840189933777])];if("BARTENDER"==t)return[n=new Float32Array([-.20026133954524994,-.9737697839736938,2.17860746383667,.19603070616722107,-.9857503771781921,2.1616086959838867,.3260974586009979,.7099164128303528,.10108458995819092,-.37390175461769104,-.42527586221694946,1.0039399862289429,.3709491193294525,-.42527586221694946,1.0039399862289429,8438758959528059e-20,-1.101210594177246,1.7955349683761597,2949934116831766e-31,-.04326578229665756,-.5318827629089355,.4412812888622284,-.2815903127193451,-1.3385579586029053,.45793405175209045,.37141913175582886,-1.6536355018615723,-.4412812888622284,-.2815903127193451,-1.3385579586029053,-.45793405175209045,.37141913175582886,-1.6536355018615723,6788047923913078e-31,-.8192819952964783,.4206336736679077,-.9793461561203003,-.015334106981754303,1.7865675687789917,.9793461561203003,-.015334106981754303,1.7865675687789917,1.4873708486557007,.04833114147186279,-.3768104314804077,.4768085777759552,.1994880586862564,.9495226144790649,.7653667330741882,-.3627835810184479,.15018165111541748,.308129221200943,-.6489158868789673,.557608962059021,-.0002116243413183838,.49473923444747925,1.0336977243423462,-.5404940247535706,.19043265283107758,.8128713369369507,-.7657899260520935,-.3627835810184479,.15018165111541748,1.4484371035905497e-7,.3663712441921234,3.387472629547119,-1.2087160348892212,-.6443189978599548,3.0043344497680664,1.2087161540985107,-.6443195343017578,3.0043344497680664,6141737432960813e-31,-.8464082479476929,.10243535041809082,-.3249528408050537,.7104986310005188,.10016584396362305,-.303207665681839,-.9462416172027588,.5075775384902954,-.37667226791381836,-1.0658020973205566,.9869986772537231]),new Float32Array([2949934116831766e-31,-.04326578229665756,-.5318827629089355,1.4484371035905497e-7,.3663712441921234,3.387472629547119])];if("WCBOTTLE"==t)return[n=new Float32Array([-.013366899453103542,-2.9939471346551727e-7,-2.511009931564331,.6493963599205017,-.7673797011375427,-2.4501447677612305,.7540126442909241,.6627629399299622,-2.4501450061798096,-.9611459970474243,-.36033540964126587,-2.4501450061798096,.1477278769016266,.9964179992675781,1.9307010173797607,-.9568377137184143,-.35869666934013367,1.9307011365890503,-.01336702425032854,3.722930728145002e-7,2.314748764038086,.9344120025634766,.3603347837924957,.22589847445487976,-.027811311185359955,1.0138630867004395,1.6714674234390259,-.9710267186164856,.3331884741783142,1.0331839323043823,.627266526222229,.7859488129615784,1.035000205039978,-.6761305332183838,.7673797011375427,.22936050593852997,-.02781102992594242,1.0138623714447021,-1.587138056755066,-.027811311185359955,1.0138630867004395,.45858100056648254,-.9372201561927795,-.4008185565471649,-.006537972949445248,.5878132581710815,-.8109326958656311,-.27440735697746277,-.3465554714202881,-.9576587677001953,1.3840690851211548,.34696754813194275,-.9477792978286743,-.5884990096092224,-.8841753602027893,-.519440233707428,-.5891181230545044,-.346555233001709,-.9576594829559326,.418072372674942]),new Float32Array([-.013366899453103542,-2.9939471346551727e-7,-2.511009931564331,-.01336702425032854,3.722930728145002e-7,2.314748764038086])];if("EQA"==t)return[n=new Float32Array([-3.7749502658843994,-.9271571040153503,.04594746232032776,-3.777569055557251,.92264324426651,.04048970341682434,-3.7703702449798584,-1.2227396965026855,-.9106809496879578,-3.7990496158599854,1.1855655908584595,-.9073726534843445,3.811656951904297,1.3718937635421753,-.7763562798500061,3.8001205921173096,-1.3779062032699585,-.7809855341911316,-.4568534791469574,-1.0891674757003784,1.2122516632080078,-.4568534791469574,1.08638596534729,1.2122514247894287,2.6531293392181396,-.925976037979126,1.2379950284957886,2.648271083831787,.9270637631416321,1.2376376390457153,3.459774971008301,-1.3973642587661743,.466232568025589,3.459774971008301,1.3945828676223755,.46623218059539795,-.9480692744255066,.0011375703616067767,1.0669147968292236,-4.019203186035156,-.0013908070977777243,-.24615326523780823,3.3231399059295654,-.0013906551757827401,1.151373267173767,3.907538652420044,-.0012724152766168118,.11990431696176529,.35528019070625305,-1.5870187282562256,.2603841722011566,.5474950671195984,-1.151407241821289,1.2155274152755737,-1.341339349746704,-1.5719798803329468,-.9050094485282898,-1.420742154121399,-1.4566854238510132,.4212491512298584,.35528019070625305,1.5842370986938477,.2603837251663208,.5482162833213806,1.1495895385742188,1.2244428396224976,-1.341339349746704,1.5691980123519897,-.9050098657608032,-1.420742154121399,1.4539037942886353,.42124876379966736,2.0402863025665283,-1.592824101448059,.3434940576553345,1.582544207572937,-1.5713834762573242,-.836898148059845,2.047945737838745,1.584236979484558,.3409099578857422,1.582544207572937,1.5686016082763672,-.8368985652923584]),new Float32Array([-4.019203186035156,-.0013908070977777243,-.24615326523780823,3.907538652420044,-.0012724152766168118,.11990431696176529])];if("FACE"==t)return[n=new Float32Array([-9.037608623504639,2.355806514620781,-8.28516685962677,-8.81279444694519,-.11831151321530342,-7.542072296142578,-8.38990831375122,-2.418052017688751,-7.253487825393677,8.400188446044922,-2.424757957458496,-7.240226984024048,8.831642150878906,-.11823836714029312,-7.535887956619263,9.061289668083191,2.362936556339264,-8.284585356712341,-1.901270106434822,6.1033472418785095,1.311941035091877,1.9072290509939194,6.117302238941193,1.3117250353097916,-.0015033446252346039,4.03810042142868,1.5223239958286285,.0047621168196201324,2.571689784526825,2.513868987560272,.004333397373557091,1.2499050498008728,3.5467670559883118,-.0007506050169467926,-.2351544015109539,4.379635065793991,-1.5987120568752289,-1.6273340582847595,1.7652730643749237,.013800747692584991,-1.9495649933815002,2.5874924659729004,1.6161270439624786,-1.629391998052597,1.7741851210594177,-5.2972798347473145,3.732409954071045,-.8603600263595581,-2.2803800106048584,3.479170083999634,-.39132800698280334,2.189579963684082,3.4696600437164307,-.3517009913921356,5.284249782562256,3.7591500282287598,-.8421319723129272]),new Float32Array([])];if("HAND"==t){for(var n,r=((n=new Float32Array([3.57,6.02,0,6.68,8.76,.75,8.51,9.69,.75,10.68,6.14,0,13.29,5.55,.01,10.19,4.74,0,12.84,4.16,.01,9.27,3.56,0,11.75,2.81,.01,8.04,2.58,0,9.9,1.71,.01]))[21]+n[24])/2,a=(n[22]+n[25])/2,o=(n[23]+n[26])/2,s=0;s<n.length/3;s++)n[3*s]-=r,n[3*s+1]-=a,n[3*s+2]-=o;return[n,new Float32Array([9.27,3.56,0,11.75,2.81,-.01])]}var i=[],u=[];"LAMBORGHINI"==t?i=[85,131,198,203,320,391,401,404,791,886,891,1008,1075,1085]:"HORSE"==t?i=[12,15,264,352,360,845,1119,1316,1498,1872,2065,3146,4269,4273,4590,4593,7671,8034,8756,9119]:"WATSON-CAN"==t?(i=[335,1290,1330,2591,2669,2700,2822,3488,3613,5569,5574,5613,5639,5679,5685],u=[871,482]):"MARTELL-BOTTLE"==t?(i=[11,24,38,83,85,151,182,200,207,222,893,1646,1971,2013,2221,2229,2271,2309,2376,2444,2459,2725,2787,2792],u=[24,893]):"NECKLACE"==t?(i=[670,42,48,551,160,155,762],u=[640,762]):"CAN-KIVISENSE"==t?(i=[38,53,89,981,1006,1009,1019,1024,1034,1046,1052,1062,1087,1096,1105,1117,1124,1144,1148,1154],u=[1914,2725]):"TOY-TRUCK"==t?(i=[],u=[]):"WRIST"==t&&(i=[2,15,24,33,42,56,65,74,83,92,213,321,338,360,393,416,472,481,487,576,622,746,804,838,896,905,913,922,931,940,949,958,977,986,996,1005,1010,1019,1028,1037,1046,1055,1077,1086,1092,1101,1164,1173,1182,1267,1311,1321,1323,1346,1354,1372,1428,1451,1460,1468,1478,1503,1513,1554,1588,1597,1605,1641,1649,1692,1709,1735,1738,1762,1772,1789,1793,1819,1840,1850,1876,1894,1899,1921,1926,1935,1948,1953,1962,1971,1980,1989,2002,2007,2016,2025,2038,2056,2061,2083,2170,2435,2459,2513,2530,2594,2674,2718,2745,2748,2753,2772,2775,2791,2797,2803,2899,2905,2947,3003,3034,3084,3093,3109,3112,3128,3129,3136,3168,3175,3205,3208,3305,3323,3324,3331,3365,3368,3371,3374,3378,3386,3389,3392,3395,3398,3414,3418,3434,3437,3440,3443,3446,3462,3496,3509,3512,3689,3690,3691,3692,3693,3747,3748,3760,3764,3777,3778,3782,3783,3784,3787,3788,3792,3793,3797,3799,3800,3804,3805,3809],u=[]);var l=i.length,c=new Float32Array(3*l);i.forEach((function(t,n){c[3*n]=e[3*t],c[3*n+1]=e[3*t+1],c[3*n+2]=e[3*t+2]}));var p=new Float32Array(3*u.length);return u.forEach((function(t,n){p[3*n]=e[3*t],p[3*n+1]=e[3*t+1],p[3*n+2]=e[3*t+2]})),[c,p]}(C._geometryObjModel.vertices,C._geometryType),C._keypsVts=t[0],C._refKeypsVts=t[1];var a=Math.max(C._detectorOutDims[1]*C._detectorOutDims[2]*C._detectorOutDims[3]);C._trackHasHeatmaps&&(a=Math.max(C._detectorOutDims[1]*C._detectorOutDims[2]*C._detectorOutDims[3],C._trackerOutDims[1]*C._trackerOutDims[2]*C._trackerOutDims[3]));var o=Math.max(C._detectorOutDims[3],C._trackerOutDims[3]);if(C._bufferHeatmaps=C._poseModule._malloc(a*C._float_size),C._bufferKeypsDet=C._poseModule._malloc(2*C._detectorOutDims[3]*C._float_size),C._bufferKeypsTrack=C._poseModule._malloc(2*C._trackerOutDims[3]*C._float_size),C._bufferFeatureScores=C._poseModule._malloc(o*C._float_size),C._bufInOutPose=C._poseModule._malloc(21*C._float_size),e.pdmModel){var s=new Uint8Array(e.pdmModel);C._bufferPdmModel=C._poseModule._malloc(s.byteLength),C._poseModule.HEAPU8.set(s,C._bufferPdmModel);var i={rigid_pose:0,num_iterations:1,filter_strength:5,reg_w:10,fovy_d:50,width:640,height:480,num_features:C._geometryType==dC.Face?C._trackerOutDims[3]:-1,modelContent:C._bufferPdmModel,modelContentSize:s.byteLength,modelEncoding:C._geometryType==dC.Face?2:1},u=C._poseModule._malloc(44);C._poseModule.setValue(u+0,i.rigid_pose,"i32"),C._poseModule.setValue(u+4,i.num_iterations,"i32"),C._poseModule.setValue(u+8,i.filter_strength,"i32"),C._poseModule.setValue(u+12,i.reg_w,"float"),C._poseModule.setValue(u+16,i.fovy_d,"float"),C._poseModule.setValue(u+20,i.width,"i32"),C._poseModule.setValue(u+24,i.height,"i32"),C._poseModule.setValue(u+28,i.num_features,"i32"),C._poseModule.setValue(u+32,i.modelContent,"*"),C._poseModule.setValue(u+36,i.modelContentSize,"i32"),C._poseModule.setValue(u+40,i.modelEncoding,"i32");var l=C._poseModule.cwrap("xzimgPoseEstimationInitialize","number",["number"])(u);C._debug&&console.log("PDM initialisation: ",l),C._poseModule._free(u),C._poseModule._free(C._bufferPdmModel),C._nonRigidInitialized=!0}else if(null==C._bufKeyps3D){C._bufKeyps3D=C._poseModule._malloc(C._keypsVts.length*C._float_size),C._poseModule.HEAPF32.set(C._keypsVts,C._bufKeyps3D/4);var c=Array.from(C._keypsVts);c.forEach((function(e,t){t%3==0&&(c[t]=-c[t])})),C._bufMirroredKeyps3D=C._poseModule._malloc(c.length*C._float_size),C._poseModule.HEAPF32.set(C._keypsVts,C._bufMirroredKeyps3D/4)}C._initialized=!0})),ae((function(){return E.unsubscribe()}))).toPromise()];case 3:return c.sent(),[2]}}))}))},e.prototype.release=function(){this._initialized&&(this._tfKeypointsDetector.dispose(),this._tfKeypointsTracker.dispose(),null!=this._bufferHeatmaps&&this._poseModule._free(this._bufferHeatmaps),this._bufferHeatmaps=null,null!=this._bufferKeypsDet&&this._poseModule._free(this._bufferKeypsDet),this._bufferKeypsDet=null,null!=this._bufferKeypsTrack&&this._poseModule._free(this._bufferKeypsTrack),this._bufferKeypsTrack=null,null!=this._bufferFeatureScores&&this._poseModule._free(this._bufferFeatureScores),this._bufferFeatureScores=null,null!=this._bufInOutPose&&this._poseModule._free(this._bufInOutPose),this._bufInOutPose=null,null!=this._bufKeyps3D&&this._poseModule._free(this._bufKeyps3D),this._bufKeyps3D=null,null!=this._bufMirroredKeyps3D&&this._poseModule._free(this._bufMirroredKeyps3D),this._bufMirroredKeyps3D=null,null!=this._hptrImageBuffer&&this._poseModule._free(this._hptrImageBuffer),this._hptrImageBuffer=null,this._bufDenseVertices3D&&this._poseModule._free(this._bufDenseVertices3D),this._bufDenseVertices3D=null,this._poseModule.cwrap("xzimgPoseEstimationRelease")(),this._currentWidth=0,this._currentHeight=0,this._initialized=!1,this._nonRigidInitialized=!1,this._trackingState=UI.Detection)},e.prototype.trackSync=function(e){var t;if(this._initialized){var n=this._videoManager.getVideoCanvas();n.width===this._currentWidth&&n.height===this._currentHeight||(this._currentWidth=n.width,this._currentHeight=n.height,t=pC.getCameraParams(this._config.fovY,this._currentWidth,this._currentHeight),this._fx=t[0],this._fy=t[1],this._cx=t[2],this._cy=t[3],this._poseModule.cwrap("xzimgInitializeCamera","number",["number","number","number"])(this._config.fovY,this._currentWidth,this._currentHeight)),this._poseManager.setNbFramesDelay(this._videoManager.getNbFramesDelay());var r=e;null==e&&(r=this._videoManager.getLastBuffer()),null!=r?this.trackGeometrySync(r):console.error("No video frame to process")}else console.error("Geometry must be initialized to track")},e.prototype.trackGeometrySync=function(e){var t,n,r=bC(this._geometryType)||this._geometryType==dC.Wrist||this._geometryType==dC.Hand||this._geometryType==dC.Face;if(this._trackingState===UI.Detection){var a=this._poseModule.cwrap("xzimgMatchRecKeypsInit","number",["number"]);null==this._hptrImageBuffer&&(this._hptrImageBuffer=this._poseModule._malloc(e.width*e.height*4)),tC(this._poseModule,e,this._hptrImageBuffer);var o=nC(this._poseModule,this._hptrImageBuffer,e.width,e.height);a(o),this._poseModule._free(o);var s=this.detectGeometrySync(e),i=s.refinedFeatures,u=s.scores;this._keyps2D=i;var l=MI(u,this._config.validDetectedKeypThs);if(this._visibility=l.visibilty,this._trackingState=UI.Detection,l.totalVisible>=this._config.detectNumKeypsThs&&l.globalScore>=this._config.detectScoreThs){if(this._geometryType==dC.Wrist){this._mirrored=!1;var c=(t=this._keyps2D,n=l.visibilty,(9==t.length/2?n[0]&&n[1]?VI.CreateFromPoints(new WI(t[0],t[9]),new WI(t[1],t[10])):VI.CreateFromPoints(new WI(t[1],t[10]),new WI(t[6],t[15])):VI.CreateFromPoints(new WI(t[30],t[211]),new WI(t[163],t[344]))).x>0?"left":"right");this._mirrored="left"==c}r?this._trackingState=UI.Detected:(this._reprojError=this.computePoseSync(this._trackingState,this._geometryType),this._reprojError>0&&this._reprojError<this._config.reprojThs&&(this._trackingState=UI.Detected))}}else{var p=this.trackGeometryFeaturesSync(e,this._trackingState,this._keyps2D,this._visibility,this._geometryType);this._keyps2D=p.imageFilteredKeyps,this._cropKeyps2D=p.cropKeyps,l=MI(p.scores,this._config.validTrackedKeypThs),this._visibility=l.visibilty;var h=LI(this._geometryType,this._keyps2D.length/2);this._visibility[h[0]]&&this._visibility[h[1]]&&l.totalVisible>=this._config.trackedNumKeypsThs&&l.globalScore>=this._config.trackScoreThs?this._config.computePose?(this._reprojError=this.computePoseSync(this._trackingState,this._geometryType),this._reprojError<=0||this._reprojError>this._config.reprojThs?this._trackingState=UI.Detection:this._trackingState=UI.Tracking):this._trackingState=UI.Tracking:this._trackingState=UI.Detection}(this._trackingState===UI.Detection||this._trackingState===UI.Detected&&r)&&(this._pose=new pC(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),this._pose.setTrackingState(UI.Detection)),this._pose.setTrackingState(this._trackingState),this._poseManager.setPose(this._pose)},e.prototype.detectGeometrySync=function(e){var t,n,r,a=function(e,t){var n,r;return{crop:e>t?[(r=0)/t,(n=(e-t)/2)/e,1,(e-n)/e]:[(r=(t-e)/2)/t,(n=0)/e,(t-r)/t,1],deltaY:r,deltaX:n}}(this._currentWidth,this._currentHeight),o=a.crop,s=a.deltaY,i=a.deltaX,u=Li(e),l=vi(u,"float32"),c=$u(l,[1,this._currentHeight,this._currentWidth,3]),p=hd.cropAndResize(c,[o],[0],[this._detectorConfig.inHeight,this._detectorConfig.inWidth]),h=Wl(255),d=iu(p,h),f=this._tfKeypointsDetector.predict(d),m=f.dataSync(),g=this._poseModule.cwrap("xzimgGetHeatmapsLocations","number",["number","number","number","number","number","number","number","number"]),y=null!==(t=null==f?void 0:f.shape[3])&&void 0!==t?t:this._detectorConfig.outChannels,b=null!==(n=null==f?void 0:f.shape[1])&&void 0!==n?n:this._detectorConfig.outHeight,v=null!==(r=null==f?void 0:f.shape[2])&&void 0!==r?r:this._detectorConfig.outWidth,w=y*b*v,x=this._bufferHeatmaps/4;this._poseModule.HEAPF32.subarray(x,x+w).set(m),g(this._bufferHeatmaps,b,v,y,0,1,this._bufferKeypsDet,this._bufferFeatureScores);var _=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufferKeypsDet,2*y),k=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufferFeatureScores,y);u.dispose(),l.dispose(),h.dispose(),p.dispose(),d.dispose(),c.dispose(),f.dispose();var T=Math.min(this._currentWidth,this._currentHeight),S=T/this._detectorConfig.inWidth,E=T/this._detectorConfig.inHeight;return this._simCropToImage=function(e,t,n,r){var a=new Float32Array(6);return a[0]=r,a[1]=0,a[2]=t,a[3]=0,a[4]=n,a[5]=e,a}(s,i,E,S),{refinedFeatures:PI(_,this._simCropToImage,!1,f.shape[1]),scores:k}},e.prototype.trackGeometryFeaturesSync=function(e,t,n,r,a){var o,s,i,u,l=Int32Array.from(r);this._activeIds.length>0&&(l.forEach((function(e,t){l[t]=0})),this._activeIds.forEach((function(e){l[e]=1})),r.forEach((function(e,t){0==e&&(l[t]=0)})));var c,p,h=new Float32Array([0,0]);if(t!=UI.Detected){if(s=(o=rC(this._poseModule,e,this._hptrImageBuffer,n,l))[0],i=o[1],u=o[2],Math.sqrt(i[2]*i[2]+i[3]*i[3])>10?this._fastMvt=!0:this._fastMvt=!1,a==dC.FullBody?[7,8,9,10,13,14,15,16].forEach((function(e){u[e]=0})):a==dC.UpperBody?[7,8,9,10].forEach((function(e){u[e]=0})):a==dC.Necklace?[1,2,3,4,5].forEach((function(e){u[e]=0})):this._activeIds.length>0&&this._activeIds.forEach((function(e){u[e]=0})),h=function(e,t,n,r,a,o,s){void 0===a&&(a=null);for(var i=new Float32Array(2),u=n.length/2,l=0,c=0;c<u;c++)(null==a||a[c]>0)&&(i[0]+=r[c]-n[c],i[1]+=r[c+u]-n[c+u],l+=1);l>0&&(i[0]/=l,i[1]/=l);var p=t/4,h=new Float32Array(18);return h.set(e.HEAPF32.subarray(p,p+18)),h[9]+=i[0]*h[11]/o,h[10]+=i[1]*h[11]/s,e.HEAPF32.set(h,t/4),i}(this._poseModule,this._bufInOutPose,n,s,u,this._fx,this._fy),a==dC.Necklace)for(var d=s.length/2,f=0;f<d;f++)s[f]=n[f]+h[0],s[f+d]=n[f+d]+h[1]}else s=n;if("WATSON-CAN"==a||"CAN-KIVISENSE"==a||"TOY-TRUCK"==a||"CHIVAS"==a||"CHIVAS-LARGE"==a||"LION"==a||"BARTENDER"==a||"WCBOTTLE"==a||"EQA"==a||"MARTELL-BOTTLE"==a){var m=this._pose.project(this._refKeypsVts,pC.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));c=-Math.atan2(m[1]-m[3],m[2]-m[0]),"EQA"==a&&(c=0);var g=this._pose.project(this._keypsVts,pC.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));for(p=new Float32Array(g.length),f=0;f<p.length/2;f++)p[f]=g[2*f],p[f+p.length/2]=g[2*f+1]}var y=Float32Array.from(n),b=s.length/2;for(f=0;f<b;f++)y[f]+=h[0],y[f+b]+=h[1];bC(a)?this._simCropToImage=function(e,t,n,r,a){var o,s,i,u=t.length/2,l=Array(5),c=new Array(5);if(7==u)l[0]=n[0]>0?1:0,c[0]=new yC(t[0],t[u]),l[1]=n[3]>0&&n[4]>0?1:0,c[1]=new yC((t[3]+t[4])/2,(t[3+u]+t[4+u])/2),l[2]=n[5]>0&&n[6]>0?1:0,c[2]=new yC((t[5]+t[6])/2,(t[5+u]+t[6+u])/2),l[3]=n[1]>0?1:0,c[3]=new yC(t[1],t[1+u]),l[4]=n[2]>0?1:0,c[4]=new yC(t[2],t[2+u]);else{var p=15==u?13:17,h=15==u?14:18;l[0]=n[0]>0?1:0,c[0]=new yC(t[0],t[u]),l[1]=n[p]>=0?1:0,c[1]=new yC(t[p],t[p+u]),l[2]=n[h]>=0?1:0,c[2]=new yC(t[h],t[h+u]),l[3]=n[1]>0?1:0,c[3]=new yC(t[1],t[1+u]),l[4]=n[2]>0?1:0,c[4]=new yC(t[2],t[2+u])}if("FULL-BODY"==e)if(l[1]>0&&l[2]>0)o=c[2],s=-Math.atan2(c[2].y-c[1].y,c[1].x-c[2].x),s+=Math.PI/2,i=2*c[2].Dist(c[1])*2.35;else if(l[0]>0&&l[1]>0)(o=c[1]).y+=2.24*(c[1].y-c[0].y),s=-Math.atan2(c[1].y-c[0].y,c[0].x-c[1].x),s+=Math.PI/2,i=2*c[0].Dist(c[1])*5.3;else if(l[0]>0&&l[2]>0)o=c[2],s=-Math.atan2(c[2].y-c[0].y,c[0].x-c[2].x),s+=Math.PI/2,i=2*c[0].Dist(c[2])*1.64;else{if(!(l[0]>0&&l[3]>0&&l[4]>0))return 0;var d=c[3].Dist(c[4]);(o=c[0]).y+=3*d,s=-Math.atan2(c[4].y-c[3].y,c[3].x-c[4].x),i=2*d*14}else if(console.log(l),l[1]>0&&l[2]>0)o=c[1],s=-Math.atan2(c[2].y-c[1].y,c[1].x-c[2].x),s+=Math.PI/2,i=2*c[2].Dist(c[1])*1.2;else if(l[0]>0&&l[1]>0)o=c[1],s=-Math.atan2(c[1].y-c[0].y,c[0].x-c[1].x),s+=Math.PI/2,i=2*c[0].Dist(c[1])*2.6;else if(l[0]>0&&l[2]>0)o=new yC(c[2].x+.75*(c[0].x-c[2].x),c[2].y+.75*(c[0].y-c[2].y)),s=-Math.atan2(c[2].y-c[0].y,c[0].x-c[2].x),s+=Math.PI/2,i=2*c[0].Dist(c[2])*.8;else{if(!(l[0]>0&&l[3]>0&&l[4]>0))return 0;d=c[3].Dist(c[4]),(o=c[0]).y+=5.5*d,s=-Math.atan2(c[4].y-c[3].y,c[3].x-c[4].x),i=2*d*11}for(var f=0,m=0;m<u;m++){var g=new yC(t[m],t[m+u]).Dist(o);n[m]>0&&g>f&&(f=g)}i=Math.max(i,2*f);var y=Math.cos(s),b=Math.sin(s),v=(i+.1*i)/Math.max(r[0],r[1]),w=(r[1]-1)/2,x=(r[0]-1)/2,_=o.x-(y*v*w-b*v*x),k=o.y-(b*v*w+y*v*x);if(null!=a){var T=.8;v=(1-T)*v+T*a[7],_=(1-T)*_+T*a[2],k=(1-T)*k+T*a[5],s=(1-T)*s+T*a[6],y=Math.cos(s),b=Math.sin(s)}return[y*v,-b*v,_,b*v,y*v,k,s,v]}(a,void 0===p?s:p,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==UI.Detected||this._fastMvt?null:this._simCropToImage):a==dC.Face?this._simCropToImage=function(e,t,n,r,a){var o=e.length/2,s=OI(e,t,o),i=new WI((s[0]+s[1])/2,(s[2]+s[3])/2),u=0,l=0,c=.35;if(19==o||21==o){var p=[15,16,17,18];21==o&&(p=[17,18,19,20]),0!=t[17]&&0!=t[20]||(p=[18,19]),0!=t[18]&&0!=t[19]||(p=[17,20]),i=new WI(0,0),p.forEach((function(t){i.x+=e[t],i.y+=e[t+o]})),i.x/=p.length,i.y/=p.length;var h=new WI(e[8],e[8+o]),d=new WI(e[13],e[13+o]);21==o&&(h=new WI(e[10],e[10+o]),d=new WI(e[15],e[15+o])),l=1.57075-Math.atan2(d.y-h.y,h.x-d.x);for(var f=0;f<o;f++){var m=new WI(e[f],e[f+o]).Dist(i);t[f]>0&&m>u&&(u=m)}u*=2,c=.2}else{var g=27,y=62,b=66;22==o&&(g=9,y=18,b=20),24==o&&(g=9,y=20,b=22);var v=void 0;5==o?(v=new WI(.5*(e[0]+e[1]),.5*(e[0+o]+e[1+o])),y=3,b=4):v=new WI(e[g],e[g+o]);var w=new WI(.5*(e[y]+e[b]),.5*(e[y+o]+e[b+o]));if(l=1.57075-Math.atan2(w.y-v.y,v.x-w.x),u=s[1]-s[0],a&&"face_center"==a){i=new WI((v.x+w.x)/2,(v.y+w.y)/2);var x=0;for(f=0;f<o;f++)m=new WI(e[f],e[f+o]).Dist(i),t[f]>0&&m>x&&(x=m);u=2*x}5==o&&(u=2*(s[1]-s[0])),22==o&&(c=.15)}var _=new zI(i.x-u/2,i.y-u/2,u,u),k=Math.cos(l),T=Math.sin(l),S=(_.w+c*_.w)/Math.max(n[0],n[1]),E=n[1]/2,I=n[0]/2,C=i.x-(k*S*E-T*S*I),A=i.y-(T*S*E+k*S*I);if(null!=r){var N=.8;C=N*C+(1-N)*r[2],A=N*A+(1-N)*r[5],S=.3*S+.7*r[7],Math.abs(l-r[6])<1&&(l=.3*l+.7*r[6]),k=Math.cos(l),T=Math.sin(l)}return[k*S,-T*S,C,T*S,k*S,A,l,S]}(void 0===p?y:p,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==UI.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):a==dC.Wrist?this._simCropToImage=function(e,t,n,r,a){var o=e.length/2,s=OI(e,t,o),i=BI("WRIST",e),u=i[0],l=i[1],c=i[2],p=Math.max(s[1]-s[0],s[3]-s[2]);u=(s[1]+s[0])/2,l=(s[3]+s[2])/2,9==o&&!t[0]&&t[1]&&t[6]&&(u=e[1],l=e[10],p=2*Math.sqrt(Math.pow(e[6]-u,2)+Math.pow(e[15]-u,2)));var h=Math.cos(c),d=Math.sin(c),f=(p+=.7*p)/Math.max(n[0],n[1]),m=n[1]/2,g=n[0]/2,y=u-(h*f*m-d*f*g),b=l-(d*f*m+h*f*g);return null!=r&&(y=.5*y+.5*r[2],b=.5*b+.5*r[5],f=.5*f+.5*r[7],h=Math.cos(c),d=Math.sin(c)),[h*f,-d*f,y,d*f,h*f,b,c,f]}(void 0===p?s:p,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==UI.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):a==dC.Hand?this._simCropToImage=function(e,t,n,r,a){var o=e.length/2,s=OI(e,t,o),i=Math.max(s[1]-s[0],s[3]-s[2]),u=BI("HAND",e),l=u[0],c=u[1],p=u[2];if(9==o)t[3]&&t[6]&&(l=.5*(e[3]+e[6]),c=.5*(e[3+o]+e[6+o]),t[1]&&(i=2*Math.sqrt(Math.pow(e[1]-l,2)+Math.pow(e[1+o]-l,2))));else{var h=LI("HAND",o),d=h[0],f=h[1],m=new WI(e[d],e[d+o]),g=new WI(e[f],e[f+o]);if(i=5*m.Dist(g),t[0]){var y=new WI(e[0],e[0+o]),b=2*m.Dist(y);i=Math.max(i,b)}l=m.x,c=m.y}var v=Math.cos(p),w=Math.sin(p),x=(i+=.2*i)/Math.max(n[0],n[1]),_=n[1]/2,k=n[0]/2,T=l-(v*x*_-w*x*k),S=c-(w*x*_+v*x*k);if(null!=r){var E=.9;T=E*T+(1-E)*r[2],S=E*S+(1-E)*r[5],x=.3*x+.7*r[7],Math.abs(p-r[6])<1&&(p=.3*p+.7*r[6]),v=Math.cos(p),w=Math.sin(p)}return[v*x,-w*x,T,w*x,v*x,S,p,x]}(void 0===p?s:p,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==UI.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):this._simCropToImage=function(e,t,n,r,a,o){var s,i,u=e.length/2;void 0===o&&((s=BI(a,e))[0],s[1],o=s[2]),i=FI(e,u);var l=Math.cos(o),c=Math.sin(o),p=Math.sqrt((i[1]-i[0])*(i[1]-i[0])+(i[3]-i[2])*(i[3]-i[2])),h=.3;"NECKLACE"==a&&(h=.5),"MARTEL-BOTTLE"==a&&(h=.2),"EQA"==a&&(h=.2),"BARTENDER"==a&&(h=.2);var d=(p+=h*p)/Math.max(n,t),f=(t-1)/2,m=(n-1)/2,g=(i[0]+i[1])/2-(l*d*f-c*d*m),y=(i[2]+i[3])/2-(c*d*f+l*d*m);if(null!=r){if("NECKLACE"==a){var b=.9;g=b*g+(1-b)*r[2],y=b*y+(1-b)*r[5],d=.3*d+.7*r[7],Math.abs(o-r[6])<1&&(o=.3*o+.7*r[6])}else{var v=Math.sqrt((g-r[2])*(g-r[2])+(y-r[5])*(y-r[5])),w=1;v>20&&(w=.1),v>=10&&v<=20&&(w=1-.09*(v-5)),g=(1-w)*g+w*r[2],y=(1-w)*y+w*r[5],o=Math.abs(o-r[6])>1?(1-w)*o-w*r[6]:(1-w)*o+w*r[6],d=(1-w)*d+w*r[7]}l=Math.cos(o),c=Math.sin(o)}return[l*d,-c*d,g,c*d,l*d,y,o,d]}(void 0===p?s:p,this._trackerConfig.inWidth,this._trackerConfig.inHeight,t==UI.Detected||this._fastMvt?null:this._simCropToImage,a,c);var v=new ImageData(this._trackerConfig.inWidth,this._trackerConfig.inHeight);v=function(e,t,n){for(var r=n[0],a=n[1],o=n[2],s=n[3],i=n[4],u=n[5],l=e.width,c=e.height,p=4*e.width,h=t.width,d=t.height,f=4*t.width,m=0;m<d;m++)for(var g=a*m+o,y=i*m+u,b=m*f,v=0;v<h;v++){var w=4*v,x=Math.floor(g),_=Math.floor(y),k=g-x,T=y-_,S=void 0,E=void 0;if(x>0&&x<l-1&&_>0&&_<c-1){for(var I=_*p+4*x,C=0;C<3;C++,I++){var A=e.data[I];S=A+k*(e.data[I+4]-A),E=e.data[I+p]+k*(e.data[I+p+4]-e.data[I+p]),t.data[b+w+C]=S+T*(E-S)}t.data[b+w+3]=255}else{for(C=0;C<3;C++)t.data[b+w+C]=0;t.data[b+w+3]=255}g+=r,y+=s}return t}(e,v,this._simCropToImage),this._debug&&(this._debugInitialized=!0,this._debugImage=v,DI(this._trackerConfig.inHeight,this._trackerConfig.inWidth,4,v));var w=function(e,t,n,r,a,o,s,i){for(var u=[],l=[],c=[],p=[],h=0,d=null,f=0,m=s;f<m.length;f++){var g=Li(m[f]);p.push(g);var y=vi(g,"float32");p.push(y);var b=$u(y,[1,t.inHeight,t.inWidth,3]);p.push(b);var v=Wl(255),w=iu(b,v);p.push(w),i[h]&&(w=_p(w,1),p.push(w)),d?(d=Bu([d,w]),p.push(d)):d=w,h+=1}if(null!=d){var x=[];if(t.numOutputs&&1!=t.numOutputs)for(var _=0,k=x=e.predict(d);_<k.length;_++){var T=k[_];p.push(T)}else{var S=e.predict(d);p.push(S),x.push(S)}for(var E=0,I=0,C=x;I<C.length;I++){S=C[I];for(var A=[],N=[],R=0,F=nh(S,0);R<F.length;R++){var O=F[R];p.push(O);var M=Yl(O,0);p.push(M),A.push(O.dataSync()),N.push(M.shape)}if(t.outputNames&&"heatmaps"!=t.outputNames[E]){if(t.outputNames&&"coordinates"==t.outputNames[E])for(z=0;z<A.length;z++){for(var $=N[z][1]/2,D=new Float32Array(2*$),P=t.inHeight/2,L=t.inWidth/2,B=0;B<$;B++)D[B]=(A[z][B]+1)*L,D[B+$]=(A[z][B+$]+1)*P;u.push(D)}else if(t.outputNames&&"scores"==t.outputNames[E])for(z=0;z<A.length;z++){var U=N[z][1],W=new Float32Array(U);for(B=0;B<U;B++)W[B]=1/(1+Math.exp(-A[z][B]));l.push(W)}else if(t.outputNames&&"occlusions"==t.outputNames[E])for(z=0;z<A.length;z++){U=N[z][1];var V=new Float32Array(U);for(B=0;B<U;B++)V[B]=1/(1+Math.exp(-A[z][B]));c.push(V)}}else for(var z=0;z<A.length;z++){var j;j=n?iC(n,N[z],A[z],r[z],a[z],o[z]):sC(A[z],N[z],!1),u.push(j[0]),l.push(j[1])}E+=1}}return p.forEach((function(e){return e.dispose()})),{coordinates:u,scores:l,occlusions:c}}(this._tfKeypointsTracker,this._trackerConfig,this._poseModule,[this._bufferHeatmaps],[this._bufferKeypsTrack],[this._bufferFeatureScores],[v],[this._mirrored]),x=PI(w.coordinates[0],this._simCropToImage,this._mirrored,this._trackerConfig.outHeight);if(t!=UI.Detected){var _=$I(w.scores[0],this._config.validTrackedKeypThs);if(a==dC.Face&&!this._nonRigidInitialized){var k=this._pose.project(this._keypsVts,pC.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight)),T=x.length/2;for(f=0;f<T;f++)0==_[f]&&(_[f]=1,x[f]=k[2*f],x[f+T]=k[2*f+1])}x=jI(x,_,s,r,.1)}return{imageFilteredKeyps:x,cropKeyps:w.coordinates[0],scores:w.scores[0]}},e.prototype.computePoseSync=function(e,t){return this._nonRigidInitialized&&(bC(t)||t==dC.Wrist||t==dC.Face)?this.computeNonRigidPoseSync(e,t):this.computeRigidPoseSync(e,t)},e.prototype.computeRigidPoseSync=function(e,t){var n=this,r=-1,a=this._poseModule.cwrap("xzimgEstimateRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number","number"]);if(e==UI.Detection){var o=0,s=0,i=t==dC.Necklace?3:0,u=1,l=[1,0,0,0,1,0],c=(h=this._poseModule._malloc(6*this._float_size))/4,p=this._poseModule.HEAPF32.subarray(c,c+6);return this._trackHasHeatmaps?p.set(this._simCropToImage.slice(0,6)):p.set(l),r=a(this._bufferHeatmaps,this._detectorOutDims[1],this._detectorOutDims[2],this._detectorOutDims[3],o,h,this._bufferKeypsDet,this._mirrored?this._bufMirroredKeyps3D:this._bufKeyps3D,s,i,u,this._bufInOutPose),this._pose=new pC(new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3)),r}if(e==UI.Detected||e==UI.Tracking){o=0,s=e!=UI.Tracking||this._resetPose?0:1,this._resetPose=!1,i=t==dC.Hand||t==dC.Necklace||t==dC.Lamborghini?3:1,u=t==dC.Hand||t==dC.Necklace||t==dC.Lamborghini?3:1,c=(h=this._poseModule._malloc(6*this._float_size))/4;var h,d=this._poseModule.HEAPF32.subarray(c,c+6);this._trackHasHeatmaps&&3==i?d.set(this._simCropToImage.slice(0,6)):(l=[1,0,0,0,1,0],d.set(l));var f=null,m=null,g=new Float32Array(2*this._activeIds.length),y=new Float32Array(3*this._activeIds.length),b=this._keyps2D.length/2;this._activeIds.length>0?(this._activeIds.forEach((function(e,t){g[t]=n._keyps2D[e],g[t+n._activeIds.length]=n._keyps2D[e+b]})),c=(f=this._poseModule._malloc(this._activeIds.length*this._float_size*2))/4,(d=this._poseModule.HEAPF32.subarray(c,c+2*this._activeIds.length)).set(g),this._activeIds.forEach((function(e,t){y[3*t]=n._keypsVts[3*e],n._mirrored&&(y[3*t]=-y[3*t]),y[3*t+1]=n._keypsVts[3*e+1],y[3*t+2]=n._keypsVts[3*e+2]})),c=(m=this._poseModule._malloc(this._activeIds.length*this._float_size*3))/4,(d=this._poseModule.HEAPF32.subarray(c,c+3*this._activeIds.length)).set(y),b=this._activeIds.length):(c=(f=this._poseModule._malloc(this._keyps2D.length*this._float_size))/4,(d=this._poseModule.HEAPF32.subarray(c,c+this._keyps2D.length)).set(this._keyps2D),2!=i&&3!=i||d.set(this._cropKeyps2D),m=this._mirrored?this._bufMirroredKeyps3D:this._bufKeyps3D),r=a(2==i||3==i?this._bufferHeatmaps:null,this._trackerOutDims[1],this._trackerOutDims[2],b,o,h,f,m,s,i,u,this._bufInOutPose);var v=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),w=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3);this._pose=new pC(v,w);var x=this._pose.project(this._keypsVts,pC.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));this._reprojKeyps2D=new Float32Array(x.length);for(var _=0;_<x.length/2;_++)this._reprojKeyps2D[_]=x[2*_],this._reprojKeyps2D[_+this._reprojKeyps2D.length/2]=x[2*_+1];if(t==dC.Necklace){var k=this._pose.getRot();k[5]>.35&&(console.log(k[2],k[5],k[8]),k[2]=0,k[5]=0,k[8]=-1,this._pose.updateRotation(k))}return this._keyps3D=this._pose.transform(this._keypsVts),f&&this._poseModule._free(f),m&&this._activeIds.length>0&&this._poseModule._free(m),h&&this._poseModule._free(h),r}return-1},e.prototype.computeNonRigidPoseSync=function(e,t){var n;n=bC(t)?this._poseModule.cwrap("xzimgEstimateBodyNonRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number"]):this._poseModule.cwrap("xzimgEstimateNonRigidPoseBase","number",["number","number","number","number","number","number","number","number","number","number","number"]);var r,a=e==UI.Detected?1:0,o=this._trackerOutDims[3],s=(r=this._poseModule._malloc(this._keyps2D.length*this._float_size))/4;this._poseModule.HEAPF32.subarray(s,s+this._keyps2D.length).set(this._keyps2D);var i=this._poseModule._malloc(o*this._int_size),u=i/4;this._poseModule.HEAPF32.subarray(u,u+o).set(this._visibility),null==this._bufKeyps3D&&(this._bufKeyps3D=this._poseModule._malloc(o*this._float_size*3));var l=1e3;t==dC.Face&&(l=10),t==dC.Wrist&&(l=100);var c=n(a,r,o,i,1,l,this._config.reprojThs,.5,.75,.95,this._bufInOutPose,this._bufKeyps3D),p=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),h=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3);this._pose=new pC(p,h),this._keyps3D=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufKeyps3D,3*o),this._poseModule._free(r),this._poseModule._free(i);var d=this._poseModule.cwrap("xzimgEstimateGetNumVertices","number"),f=this._poseModule.cwrap("xzimgEstimateGetDenseVertices","number"),m=d();return m>0&&(null==this._bufDenseVertices3D&&(this._bufDenseVertices3D=this._poseModule._malloc(m*this._float_size*3)),f(this._bufDenseVertices3D),this._denseVertices=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufDenseVertices3D,3*m)),c},e}(),kC=(vC=function(e,t){return vC=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},vC(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}vC(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),TC=function(e){function t(t){var n=e.call(this,t)||this;return n.name="SwitchEffectCanceled",n}return kC(t,e),t}(Error);!function(e){e[e.Bool=0]="Bool",e[e.Int=1]="Int",e[e.Double=2]="Double",e[e.String=3]="String"}(wC||(wC={}));var SC,EC=function(){function e(e){this.module=e}return e.prototype.hasVar=function(e,t){return this.module.hasVar(e,t)},e.prototype.getVarType=function(e,t){return this.module.getVarType(e,t)},e.prototype.getBoolVar=function(e,t){return this.module.getBoolVar(e,t)},e.prototype.getIntVar=function(e,t){return this.module.getIntVar(e,t)},e.prototype.getDoubleVar=function(e,t){return this.module.getDoubleVar(e,t)},e.prototype.getStringVar=function(e,t){return void 0===t&&(t=0),this.module.getStringVar(e,t)},e.prototype.setBoolVar=function(e,t,n){return this.module.setBoolVar(e,t,n)},e.prototype.setIntVar=function(e,t,n){return this.module.setIntVar(e,t,n)},e.prototype.setDoubleVar=function(e,t,n){return this.module.setDoubleVar(e,t,n)},e.prototype.setStringVar=function(e,t,n){return this.module.setStringVar(e,t,n)},e.prototype.deleteVar=function(e,t){return this.module.deleteVar(e,t)},e.prototype.clearVars=function(e){return this.module.clearVars(e)},e}();function IC(e,t,n,r){e.width=t*r,e.height=n*r}var CC,AC=function(){var e=parseFloat(SC.computedStyle.width||"0"),t=parseFloat(SC.computedStyle.height||"0"),n=window.devicePixelRatio;e===SC.cssWidth&&t===SC.cssHeight&&n===SC.devicePixelRatio||(SC.cssWidth=e,SC.cssHeight=t,SC.devicePixelRatio=n,IC(SC.canvas,e,t,n))},NC=function(){SC.canvas.style.width="100%",SC.canvas.style.height="100%"},RC=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))},FC=function(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}},OC="https://cdn.jsdelivr.net/npm/deepar@".concat(a,"/"),MC={video:{facingMode:"user",frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}},$C="DEFAULT_SLOT";function DC(e){return e.additionalOptions&&e.additionalOptions.segmentationConfig&&e.additionalOptions.segmentationConfig.modelPath?e.additionalOptions.segmentationConfig.modelPath:e.rootPath?e.rootPath+"models/segmentation/segmentation-160x160-opt.bin":null}function PC(e){return e.additionalOptions&&e.additionalOptions.faceTrackingConfig&&e.additionalOptions.faceTrackingConfig.modelPath?e.additionalOptions.faceTrackingConfig.modelPath:e.rootPath?e.rootPath+"models/face/models-68-extreme.bin":null}function LC(e){var t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/foot/foot-model.obj",t.detectorPath=e.rootPath+"models/foot/foot-detection-96x96x6.bin",t.trackerPath=e.rootPath+"models/foot/foot-tracker-96x96x18-test.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.footTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.footTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.footTrackingConfig.detectorPath),e.additionalOptions.footTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.footTrackingConfig.trackerPath),e.additionalOptions.footTrackingConfig.objPath&&(t.objPath=e.additionalOptions.footTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function BC(e){var t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/wrist/wrist-base-2.obj",t.detectorPath=e.rootPath+"models/wrist/wrist-det-9.bin",t.trackerPath=e.rootPath+"models/wrist/wrist-track.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.wristTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.wristTrackingConfig.detectorPath),e.additionalOptions.wristTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.wristTrackingConfig.trackerPath),e.additionalOptions.wristTrackingConfig.objPath&&(t.objPath=e.additionalOptions.wristTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function UC(e){var t={backgroundBlurPath:"",backgroundReplacementPath:""};return e.rootPath&&(t.backgroundBlurPath=e.rootPath+"effects/background_blur.deepar",t.backgroundReplacementPath=e.rootPath+"effects/background_replacement.deepar"),t}function WC(e,t){return!(!e.additionalOptions||!e.additionalOptions.hint)&&("string"==typeof e.additionalOptions.hint?e.additionalOptions.hint===t:!!Array.isArray(e.additionalOptions.hint)&&e.additionalOptions.hint.some((function(e){return e===t})))}function VC(){return"mediaDevices"in navigator&&"getUserMedia"in navigator.mediaDevices}var zC=!1;function jC(t){var n,r,a;return RC(this,void 0,void 0,(function(){var o,i,u,l,c,p,d,f,m,g,y,b=this;return FC(this,(function(v){switch(v.label){case 0:if(zC)throw new Error("DeepAR is already initialized. You cannot have multiple instances of DeepAR object. Call DeepAR.shutdown() first.");if(!t.canvas&&!t.targetElement)throw new Error("No targetElement or canvas provided.");if(t.canvas&&t.targetElement)throw new Error("targetElement and canvas cannot be both provided at the same time. Use one or the other. targetElement is preferred.");if(t.canvas){if(!(t.canvas instanceof HTMLCanvasElement))throw new Error("The given canvas parameter is not an HTMLCanvasElement object.")}else{if(!(t.targetElement instanceof HTMLElement))throw new Error("The given targetElement parameter is not an HTMLElement object.");t.canvas=function(e){if(SC)throw new Error("Canvas is already created. Call invalidate() first.");var t=document.createElement("canvas");e.append(t),t.style.display="block",t.style.maxWidth="100%",t.style.maxHeight="100%";var n=getComputedStyle(e);return IC(t,(SC={computedStyle:n,cssWidth:parseFloat(n.width||"0"),cssHeight:parseFloat(n.height||"0"),devicePixelRatio:window.devicePixelRatio||1,targetElement:e,canvas:t}).cssWidth,SC.cssHeight,SC.devicePixelRatio),t}(t.targetElement)}if(t.rootPath=(w=t.rootPath)?w.endsWith("/")?w:w+"/":OC,t.rootPath!=OC&&console.warn("Using non-default root path (".concat(t.rootPath,"). Root path is used to fetch additional DeepAR files like ML models for face tracking. Root path must be the root directory of a DeepAR SDK downloaded from the https://developer.deepar.ai/downloads. The file structure must not be changed! It is also important that the version of the root path SDK and version of the running DeepAR SDK are the same.")),o={licenseKey:t.licenseKey,canvasWidth:t.canvas.width,canvasHeight:t.canvas.height,canvas:t.canvas,faceTrackingModelPath:PC(t),segmentationModel:DC(t),footTrackingConfig:LC(t),wristTrackingConfig:BC(t),embeddedEffectConfig:UC(t),apiObject:{onInitialize:function(){}},initializeML:{faceModelsPredownload:WC(t,"faceModelsPredownload"),segmentationModelsPredownload:WC(t,"segmentationModelsPredownload"),footModelsPredownload:WC(t,"footModelsPredownload"),segmentationInit:WC(t,"segmentationInit"),footInit:WC(t,"footInit")},xzimg:{Segmentation:Yk,VideoManager:h,Foot:mC,Geometry:_C},customErrors:e,locateFile:function(e,n){return t.additionalOptions&&t.additionalOptions.deeparWasmPath?t.additionalOptions.deeparWasmPath:t.rootPath?t.rootPath+"wasm/deepar.wasm":n+e}},i=!0,u=MC,l=!0,t.additionalOptions&&t.additionalOptions.cameraConfig&&(t.additionalOptions.cameraConfig.disableDefaultCamera&&(l=!1),t.additionalOptions.cameraConfig.facingMode&&"environment"==t.additionalOptions.cameraConfig.facingMode&&(u.video.facingMode="environment",i=!1)),l){if(!VC())throw new Error("No camera available!");null===(a=null===(r=null===(n=null==t?void 0:t.additionalOptions)||void 0===n?void 0:n.cameraConfig)||void 0===r?void 0:r.cameraPermissionAsked)||void 0===a||a.call(r),c=navigator.mediaDevices.getUserMedia(u)}return p=!1,t.effect&&(p=!0,d=fetch(t.effect)),[4,s(o)];case 1:if((f=v.sent()).initializeDeepAR(),zC=!0,f.startLoop(),t.targetElement&&(f.addPreRenderListener(AC),f.addPostRenderListener(NC)),m=new GC(f),g=[],l&&g.push(RC(b,void 0,void 0,(function(){var e,n,r,a;return FC(this,(function(o){switch(o.label){case 0:return(CC=document.createElement("video")).playsInline=!0,e=CC,[4,c];case 1:return e.srcObject=o.sent(),null===(a=null===(r=null===(n=null==t?void 0:t.additionalOptions)||void 0===n?void 0:n.cameraConfig)||void 0===r?void 0:r.cameraPermissionGranted)||void 0===a||a.call(r),[2,new Promise((function(e){CC.onloadedmetadata=function(){CC.play().then((function(){f.setVideoElement(CC,i),e()}))}}))]}}))}))),p&&g.push(RC(b,void 0,void 0,(function(){var e,n,r;return FC(this,(function(a){switch(a.label){case 0:return[4,d];case 1:if((e=a.sent()).ok)return[3,2];throw new Error("Failed to fetch ".concat(t.effect,". HTTP status: ").concat(e.status," (").concat(e.statusText,")."));case 2:return r=(n=m).switchEffect,[4,e.arrayBuffer()];case 3:return[4,r.apply(n,[a.sent()])];case 4:a.sent(),a.label=5;case 5:return[2]}}))}))),!(g.length>0))return[3,5];v.label=2;case 2:return v.trys.push([2,4,,5]),[4,Promise.all(g)];case 3:return v.sent(),[3,5];case 4:throw y=v.sent(),m.shutdown(),y;case 5:return[2,m]}var w}))}))}var HC,GC=function(){function e(e){this.module=null,this.callbacks={},e.apiObject=this.callbacks,this.module=e,this.ScriptingAPI=new EC(e)}return e.prototype.switchEffect=function(e,t){return RC(this,void 0,void 0,(function(){var n,r,a,o,s,i,u=this;return FC(this,(function(l){switch(l.label){case 0:if(t&&(n="face"in t&&"number"==typeof t.face,r="slot"in t&&"string"==typeof t.slot,n&&!r))throw new Error("Slot is not defined. When using switchEffect with a face parameter, you need to specify the slot also.");if(a=(null==t?void 0:t.face)?t.face:0,o=(null==t?void 0:t.slot)?t.slot:$C,a<0||a>3)throw new Error("Face value is ".concat(a," but should be 0, 1, 2 or 3"));return"string"!=typeof e?[3,3]:[4,fetch(e)];case 1:if(!(i=l.sent()).ok)throw new Error("Failed to fetch ".concat(e,". HTTP status: ").concat(i.status," (").concat(i.statusText,")."));return[4,i.arrayBuffer()];case 2:return s=l.sent(),[3,4];case 3:if(!(e instanceof ArrayBuffer))throw new Error("The first parameter in switchEffect is not string or ArrayBuffer.");s=e,l.label=4;case 4:return[2,new Promise((function(e,t){u.module.switchEffectByteArray(a,o,new Uint8Array(s),e,t)}))]}}))}))},e.prototype.clearEffect=function(e){this.module.clearEffect(e||$C)},e.prototype.takeScreenshot=function(){return RC(this,void 0,void 0,(function(){var e=this;return FC(this,(function(t){return[2,new Promise((function(t){e.module.takeScreenshot(t)}))]}))}))},e.prototype.startVideoRecording=function(e){this.module.startVideoRecording(e||{})},e.prototype.finishVideoRecording=function(){return RC(this,void 0,void 0,(function(){var e=this;return FC(this,(function(t){return[2,new Promise((function(t){e.module.finishVideoRecording(t)}))]}))}))},e.prototype.startCamera=function(e){return RC(this,void 0,void 0,(function(){var t=this;return FC(this,(function(n){if(!VC())throw new Error("No camera available!");return[2,new Promise((function(n,r){var a,o;t.module.startCamera(null===(a=null==e?void 0:e.mirror)||void 0===a||a,null!==(o=null==e?void 0:e.mediaStreamConstraints)&&void 0!==o?o:MC,n,r,null==e?void 0:e.cameraPermissionAsked,null==e?void 0:e.cameraPermissionGranted),t.module.startLoop()}))]}))}))},e.prototype.stopCamera=function(){this.stopVideo()},e.prototype.stopVideo=function(){CC&&(CC.srcObject.getTracks().forEach((function(e){e.stop()})),CC=null),this.module.stopVideo()},e.prototype.setVideoElement=function(e,t){if(!e)throw new Error("No video element provided.");this.stopVideo(),this.module.setVideoElement(e,t),this.module.startLoop()},e.prototype.shutdown=function(){this.module.shutdown(),zC=!1,SC&&(SC.canvas.remove(),SC=null),this.module=void 0},e.prototype.processFrame=function(e,t,n,r){this.module.processFrameRawPixels(e,t,n,r)},e.prototype.processImage=function(e){var t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});t.width=e.width,t.height=e.height,n.drawImage(e,0,0);var r=n.getImageData(0,0,t.width,t.height),a=new Uint8Array(r.data.buffer);this.processFrame(a,e.width,e.height,!1)},e.prototype.setPaused=function(e){e?this.module.endLoop():this.module.startLoop()},e.prototype.changeParameterFloat=function(e,t,n,r){this.module.changeParameterFloat(e,null==t?"":t,n,r)},e.prototype.changeParameterBool=function(e,t,n,r){this.module.changeParameterBool(e,null==t?"":t,n,r)},e.prototype.changeParameterVector=function(e,t,n,r,a,o,s){this.module.changeParameterVector(e,null==t?"":t,n,r,a,o,s)},e.prototype.changeParameterTexture=function(e,t,n,r){var a=this,o=new Image;o.onload=function(){var r=document.createElement("canvas"),s=r.getContext("2d",{willReadFrequently:!0});r.width=o.width,r.height=o.height,s.drawImage(o,0,0);var i=s.getImageData(0,0,r.width,r.height),u=new Uint8Array(i.data.buffer),l=a.module._malloc(u.length);a.module.HEAPU8.set(u,l),a.module.changeParameterTexture(e,null==t?"":t,n,l,u.length,r.width,r.height)},o.src=r},e.prototype.fireTrigger=function(e){this.module.fireTrigger(e)},e.prototype.touchOccurred=function(e){e.x/=this.module.canvasWidth,e.y/=this.module.canvasHeight,this.module.touchOccurred(e)},e.prototype.setFaceDetectionSensitivity=function(e){this.module.setFaceDetectionSensitivity(e)},e.prototype.setOffscreenRenderingEnabled=function(e){this.module.setOffscreenRenderingEnabled(e)},e.prototype.setFps=function(e){this.module.setFps(e)},e.prototype.initializeFootTracking=function(){this.module.initializeFootTracking()},e.prototype.isFootTrackingInitialized=function(){return this.module.isFootTrackingInitialized()},e.prototype.initializeSegmentation=function(){this.module.initializeSegmentation()},e.prototype.isSegmentationInitialized=function(){return this.module.isSegmentationInitialized()},e.prototype.isWristTrackingInitialized=function(){return this.module.isWristTrackingInitialized()},e.prototype.showStats=function(e){this.module.showStats(e)},e.prototype.simulatePhysics=function(e){this.module.simulatePhysics(e)},e.prototype.moveGameObject=function(e,t){this.module.moveGameObject(e,t)},e.prototype.muteSound=function(e){null==e?(console.warn("muteSound called without arguments, assuming you meant to say muteSound(true)"),console.trace(),this.module.muteSound(!0)):this.module.muteSound(e)},e.prototype.backgroundBlur=function(e,t){return RC(this,void 0,void 0,(function(){var n=this;return FC(this,(function(r){if(e&&!t)throw new Error("backgroundBlur expected second argument: blur strength, a integer number in range 1-10");return[2,new Promise((function(r,a){n.module.backgroundBlur(e,t,r,a)}))]}))}))},e.prototype.backgroundReplacement=function(e,t){return RC(this,void 0,void 0,(function(){var n=this;return FC(this,(function(r){if(e&&!t)throw new Error("backgroundReplacement expected second argument: url of the image to be used as the background");return[2,new Promise((function(r,a){n.module.backgroundReplacement(e,t,r,a)}))]}))}))},e.prototype.enableAutoframing=function(e){this.module._enableAutoframing(e)},e.prototype.getConsoleLogs=function(){return this.module.getConsoleLogs()},e.prototype.pushConsoleLog=function(e,t){return this.module.pushConsoleLog(e,t)},e.prototype.showColliders=function(e){this.module.showColliders(e)},e.prototype.setZoom=function(e){this.module._setZoom(e)},e}();!function(e){e[e.Start=0]="Start",e[e.Move=1]="Move",e[e.End=2]="End"}(HC||(HC={}))})(),r})()));
|
|
1
|
+
/*! For license information please see deepar.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepar=t():e.deepar=t()}(self,(()=>(()=>{var e={92:e=>{"use strict";var t=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,o=Math.pow,s=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,c=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},l=(e,t,n)=>(c(e,t,"read from private field"),n?n.call(e):t.get(e)),u=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},f=(e,t,n,i)=>(c(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),d=(e,t,n)=>(c(e,t,"access private method"),n),h={};((t,n)=>{for(var i in n)e(t,i,{get:n[i],enumerable:!0})})(h,{ArrayBufferTarget:()=>re,FileSystemWritableFileStreamTarget:()=>oe,Muxer:()=>nt,StreamTarget:()=>ae});var m,p,g,v,b,k,w,y=new Uint8Array(8),P=new DataView(y.buffer),S=e=>[(e%256+256)%256],T=e=>(P.setUint16(0,e,!1),[y[0],y[1]]),E=e=>(P.setUint32(0,e,!1),[y[1],y[2],y[3]]),x=e=>(P.setUint32(0,e,!1),[y[0],y[1],y[2],y[3]]),C=e=>(P.setUint8(0,e),P.setUint8(1,e<<8),[y[0],y[1]]),O=e=>(P.setUint16(0,e,!1),P.setUint16(2,e<<16,!1),[y[0],y[1],y[2],y[3]]),A=(e,t=!1)=>{let n=Array(e.length).fill(null).map(((t,n)=>e.charCodeAt(n)));return t&&n.push(0),n},j=e=>e&&e[e.length-1],F=(e,t,n=!0)=>{let i=e*t;return n?Math.round(i):i},M=[65536,0,0,0,65536,0,0,0,1073741824].map(x),I=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),B=(e,t,n,i,r)=>I(e,[S(t),E(n),null!=i?i:[]],r),W=(e,t)=>{let n=F(Math.max(0,...t.filter((e=>e.samples.length>0)).map((e=>j(e.samples).timestamp+j(e.samples).duration))),Qe),i=Math.max(...t.map((e=>e.id)))+1;return B("mvhd",0,0,[x(e),x(e),x(Qe),x(n),O(1),C(1),Array(10).fill(0),M,Array(24).fill(0),x(i)])},_=(e,t)=>{let n=j(e.samples),i=F(n?n.timestamp+n.duration:0,Qe);return B("tkhd",0,3,[x(t),x(t),x(e.id),x(0),x(i),Array(8).fill(0),T(0),T(0),C("audio"===e.info.type?1:0),T(0),M,O("video"===e.info.type?e.info.width:0),O("video"===e.info.type?e.info.height:0)])},D=(e,t)=>I("mdia",null,[R(e,t),L("video"===e.info.type?"vide":"soun"),V(e)]),R=(e,t)=>{let n=j(e.samples),i=F(n?n.timestamp+n.duration:0,e.timescale);return B("mdhd",0,0,[x(t),x(t),x(e.timescale),x(i),T(21956),T(0)])},L=e=>B("hdlr",0,0,[A("mhlr"),A(e),x(0),x(0),x(0),A("mp4-muxer-hdlr")]),V=e=>I("minf",null,["video"===e.info.type?U():z(),G(),$(e)]),U=()=>B("vmhd",0,1,[T(0),T(0),T(0),T(0)]),z=()=>B("smhd",0,0,[T(0),T(0)]),G=()=>I("dinf",null,[H()]),H=()=>B("dref",0,0,[x(1)],[N()]),N=()=>B("url ",0,1),$=e=>I("stbl",null,[Y(e),Z(e),ee(e),te(e),ne(e),ie(e)]),Y=e=>B("stsd",0,0,[x(1)],["video"===e.info.type?K("avc"===e.info.codec?"avc1":"hvc1",e,"avc"===e.info.codec?X(e):q(e)):J("mp4a",e,Q(e))]),K=(e,t,n)=>I(e,[Array(6).fill(0),T(1),T(0),T(0),Array(12).fill(0),T(t.info.width),T(t.info.height),x(4718592),x(4718592),x(0),T(1),Array(32).fill(0),T(24),(65535,P.setInt16(0,65535,!1),[y[0],y[1]])],[n]),X=e=>e.codecPrivate&&I("avcC",[...e.codecPrivate]),q=e=>e.codecPrivate&&I("hvcC",[...e.codecPrivate]),J=(e,t,n)=>I(e,[Array(6).fill(0),T(1),T(0),T(0),x(0),T(t.info.numberOfChannels),T(16),T(0),T(0),O(t.info.sampleRate)],[n]),Q=e=>B("esds",0,0,[x(58753152),S(32+e.codecPrivate.byteLength),T(1),S(0),x(75530368),S(18+e.codecPrivate.byteLength),S(64),S(21),E(0),x(130071),x(130071),x(92307584),S(e.codecPrivate.byteLength),...e.codecPrivate,x(109084800),S(1),S(2)]),Z=e=>B("stts",0,0,[x(e.timeToSampleTable.length),e.timeToSampleTable.map((e=>[x(e.sampleCount),x(e.sampleDelta)]))]),ee=e=>{if(e.samples.every((e=>"key"===e.type)))return null;let t=[...e.samples.entries()].filter((([,e])=>"key"===e.type));return B("stss",0,0,[x(t.length),t.map((([e])=>x(e+1)))])},te=e=>B("stsc",0,0,[x(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map((e=>[x(e.firstChunk),x(e.samplesPerChunk),x(1)]))]),ne=e=>B("stsz",0,0,[x(0),x(e.samples.length),e.samples.map((e=>x(e.size)))]),ie=e=>e.writtenChunks.length>0&&j(e.writtenChunks).offset>=o(2,32)?B("co64",0,0,[x(e.writtenChunks.length),e.writtenChunks.map((e=>{return t=e.offset,P.setUint32(0,Math.floor(t/o(2,32)),!1),P.setUint32(4,t,!1),[y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7]];var t}))]):B("stco",0,0,[x(e.writtenChunks.length),e.writtenChunks.map((e=>x(e.offset)))]),re=class{constructor(){this.buffer=null}},ae=class{constructor(e,t,n){this.onData=e,this.onDone=t,this.options=n}},oe=class{constructor(e,t){this.stream=e,this.options=t}},se=class{constructor(){this.pos=0,u(this,m,new Uint8Array(8)),u(this,p,new DataView(l(this,m).buffer)),this.offsets=new WeakMap}seek(e){this.pos=e}writeU32(e){l(this,p).setUint32(0,e,!1),this.write(l(this,m).subarray(0,4))}writeU64(e){l(this,p).setUint32(0,Math.floor(e/o(2,32)),!1),l(this,p).setUint32(4,e,!1),this.write(l(this,m).subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)l(this,p).setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.write(l(this,m));e.length%8!=0&&this.write(l(this,m).subarray(0,e.length%8))}writeBox(e){var t,n;if(this.offsets.set(e,this.pos),e.contents&&!e.children)this.writeBoxHeader(e,null!=(t=e.size)?t:e.contents.byteLength+8),this.write(e.contents);else{let t=this.pos;if(this.writeBoxHeader(e,0),e.contents&&this.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let i=this.pos,r=null!=(n=e.size)?n:i-t;this.seek(t),this.writeBoxHeader(e,r),this.seek(i)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}patchBox(e){let t=this.pos;this.seek(this.offsets.get(e)),this.writeBox(e),this.seek(t)}};m=new WeakMap,p=new WeakMap;var ce,le,ue=class extends se{constructor(e){super(),u(this,k),u(this,g,void 0),u(this,v,new ArrayBuffer(o(2,16))),u(this,b,new Uint8Array(l(this,v))),f(this,g,e)}write(e){d(this,k,w).call(this,this.pos+e.byteLength),l(this,b).set(e,this.pos),this.pos+=e.byteLength}finalize(){d(this,k,w).call(this,this.pos),l(this,g).buffer=l(this,v).slice(0,this.pos)}};g=new WeakMap,v=new WeakMap,b=new WeakMap,k=new WeakSet,w=function(e){let t=l(this,v).byteLength;for(;t<e;)t*=2;if(t===l(this,v).byteLength)return;let n=new ArrayBuffer(t),i=new Uint8Array(n);i.set(l(this,b),0),f(this,v,n),f(this,b,i)};var fe=class extends se{constructor(e){super(),u(this,ce,void 0),u(this,le,[]),f(this,ce,e)}write(e){l(this,le).push({data:e.slice(),start:this.pos}),this.pos+=e.byteLength}flush(){if(0===l(this,le).length)return;let e=[],t=[...l(this,le)].sort(((e,t)=>e.start-t.start));e.push({start:t[0].start,size:t[0].data.byteLength});for(let n=1;n<t.length;n++){let i=e[e.length-1],r=t[n];r.start<=i.start+i.size?i.size=Math.max(i.size,r.start+r.data.byteLength-i.start):e.push({start:r.start,size:r.data.byteLength})}for(let t of e){t.data=new Uint8Array(t.size);for(let e of l(this,le))t.start<=e.start&&e.start<t.start+t.size&&t.data.set(e.data,e.start-t.start);l(this,ce).onData(t.data,t.start)}l(this,le).length=0}finalize(){var e,t;null==(t=(e=l(this,ce)).onDone)||t.call(e)}};ce=new WeakMap,le=new WeakMap;var de,he,me,pe,ge,ve,be,ke,we,ye,Pe,Se=o(2,24),Te=class extends se{constructor(e){var t,n;if(super(),u(this,pe),u(this,ve),u(this,ke),u(this,ye),u(this,de,void 0),u(this,he,void 0),u(this,me,[]),f(this,de,e),f(this,he,null!=(n=null==(t=e.options)?void 0:t.chunkSize)?n:Se),!Number.isInteger(l(this,he))||l(this,he)<o(2,10))throw new Error("Invalid StreamTarget options: chunkSize must be an integer not smaller than 1024.")}write(e){d(this,pe,ge).call(this,e,this.pos),d(this,ye,Pe).call(this),this.pos+=e.byteLength}finalize(){var e,t;d(this,ye,Pe).call(this,!0),null==(t=(e=l(this,de)).onDone)||t.call(e)}};de=new WeakMap,he=new WeakMap,me=new WeakMap,pe=new WeakSet,ge=function(e,t){let n=l(this,me).findIndex((e=>e.start<=t&&t<e.start+l(this,he)));-1===n&&(n=d(this,ke,we).call(this,t));let i=l(this,me)[n],r=t-i.start,a=e.subarray(0,Math.min(l(this,he)-r,e.byteLength));i.data.set(a,r);let o={start:r,end:r+a.byteLength};if(d(this,ve,be).call(this,i,o),0===i.written[0].start&&i.written[0].end===l(this,he)&&(i.shouldFlush=!0),l(this,me).length>2){for(let e=0;e<l(this,me).length-1;e++)l(this,me)[e].shouldFlush=!0;d(this,ye,Pe).call(this)}a.byteLength<e.byteLength&&d(this,pe,ge).call(this,e.subarray(a.byteLength),t+a.byteLength)},ve=new WeakSet,be=function(e,t){let n=0,i=e.written.length-1,r=-1;for(;n<=i;){let a=Math.floor(n+(i-n+1)/2);e.written[a].start<=t.start?(n=a+1,r=a):i=a-1}for(e.written.splice(r+1,0,t),(-1===r||e.written[r].end<t.start)&&r++;r<e.written.length-1&&e.written[r].end>=e.written[r+1].start;)e.written[r].end=Math.max(e.written[r].end,e.written[r+1].end),e.written.splice(r+1,1)},ke=new WeakSet,we=function(e){let t={start:Math.floor(e/l(this,he))*l(this,he),data:new Uint8Array(l(this,he)),written:[],shouldFlush:!1};return l(this,me).push(t),l(this,me).sort(((e,t)=>e.start-t.start)),l(this,me).indexOf(t)},ye=new WeakSet,Pe=function(e=!1){for(let t=0;t<l(this,me).length;t++){let n=l(this,me)[t];if(n.shouldFlush||e){for(let e of n.written)l(this,de).onData(n.data.subarray(e.start,e.end),n.start+e.start);l(this,me).splice(t--,1)}}};var Ee,xe,Ce,Oe,Ae,je,Fe,Me,Ie,Be,We,_e,De,Re,Le,Ve,Ue,ze,Ge,He,Ne,$e,Ye,Ke,Xe,qe,Je=class extends Te{constructor(e){var t;super(new ae(((t,n)=>e.stream.write({type:"write",data:t,position:n})),void 0,{chunkSize:null==(t=e.options)?void 0:t.chunkSize}))}},Qe=1e3,Ze=["avc","hevc"],et=["aac"],tt=["strict","offset"],nt=class{constructor(e){var t;if(u(this,Me),u(this,Be),u(this,_e),u(this,Re),u(this,Ve),u(this,ze),u(this,He),u(this,$e),u(this,Ke),u(this,Ee,void 0),u(this,xe,void 0),u(this,Ce,void 0),u(this,Oe,null),u(this,Ae,null),u(this,je,Math.floor(Date.now()/1e3)+2082844800),u(this,Fe,!1),d(this,Me,Ie).call(this,e),this.target=e.target,f(this,Ee,((e,t)=>{for(var n in t||={})r.call(t,n)&&s(e,n,t[n]);if(i)for(var n of i(t))a.call(t,n)&&s(e,n,t[n]);return e})({firstTimestampBehavior:"strict"},e)),e.target instanceof re)f(this,xe,new ue(e.target));else if(e.target instanceof ae)f(this,xe,(null==(t=e.target.options)?void 0:t.chunked)?new Te(e.target):new fe(e.target));else{if(!(e.target instanceof oe))throw new Error(`Invalid target: ${e.target}`);f(this,xe,new Je(e.target))}d(this,Be,We).call(this),d(this,_e,De).call(this)}addVideoChunk(e,t,n){let i=new Uint8Array(e.byteLength);e.copyTo(i),this.addVideoChunkRaw(i,e.type,null!=n?n:e.timestamp,e.duration,t)}addVideoChunkRaw(e,t,n,i,r){if(d(this,Ke,Xe).call(this),!l(this,Ee).video)throw new Error("No video track declared.");d(this,Ve,Ue).call(this,l(this,Oe),e,t,n,i,r)}addAudioChunk(e,t,n){let i=new Uint8Array(e.byteLength);e.copyTo(i),this.addAudioChunkRaw(i,e.type,null!=n?n:e.timestamp,e.duration,t)}addAudioChunkRaw(e,t,n,i,r){if(d(this,Ke,Xe).call(this),!l(this,Ee).audio)throw new Error("No audio track declared.");d(this,Ve,Ue).call(this,l(this,Ae),e,t,n,i,r)}finalize(){l(this,Oe)&&d(this,He,Ne).call(this,l(this,Oe)),l(this,Ae)&&d(this,He,Ne).call(this,l(this,Ae));let e=l(this,xe).offsets.get(l(this,Ce)),t=l(this,xe).pos-e;l(this,Ce).size=t,l(this,xe).patchBox(l(this,Ce));let n=(i=[l(this,Oe),l(this,Ae)].filter(Boolean),r=l(this,je),I("moov",null,[W(r,i),...i.map((e=>((e,t)=>I("trak",null,[_(e,t),D(e,t)]))(e,r)))]));var i,r;l(this,xe).writeBox(n),d(this,$e,Ye).call(this),l(this,xe).finalize(),f(this,Fe,!0)}};return Ee=new WeakMap,xe=new WeakMap,Ce=new WeakMap,Oe=new WeakMap,Ae=new WeakMap,je=new WeakMap,Fe=new WeakMap,Me=new WeakSet,Ie=function(e){if(e.video&&!Ze.includes(e.video.codec))throw new Error(`Unsupported video codec: ${e.video.codec}`);if(e.audio&&!et.includes(e.audio.codec))throw new Error(`Unsupported audio codec: ${e.audio.codec}`);if(e.firstTimestampBehavior&&!tt.includes(e.firstTimestampBehavior))throw new Error(`Invalid first timestamp behavior: ${e.firstTimestampBehavior}`)},Be=new WeakSet,We=function(){var e;let t="hevc"===(null==(e=l(this,Ee).video)?void 0:e.codec);l(this,xe).writeBox((e=>I("ftyp",e?[A("isom"),x(0),A("iso4"),A("hvc1")]:[A("isom"),x(0),A("isom"),A("avc1"),A("mp41")]))(t)),f(this,Ce,{type:"mdat",largeSize:!0}),l(this,xe).writeBox(l(this,Ce)),d(this,$e,Ye).call(this)},_e=new WeakSet,De=function(){if(l(this,Ee).video&&f(this,Oe,{id:1,info:{type:"video",codec:l(this,Ee).video.codec,width:l(this,Ee).video.width,height:l(this,Ee).video.height},timescale:720,codecPrivate:new Uint8Array(0),samples:[],writtenChunks:[],currentChunk:null,firstTimestamp:void 0,lastTimestamp:-1,timeToSampleTable:[],lastTimescaleUnits:null,compactlyCodedChunkTable:[]}),l(this,Ee).audio){let e=d(this,Re,Le).call(this,2,l(this,Ee).audio.sampleRate,l(this,Ee).audio.numberOfChannels);f(this,Ae,{id:l(this,Ee).video?2:1,info:{type:"audio",codec:l(this,Ee).audio.codec,numberOfChannels:l(this,Ee).audio.numberOfChannels,sampleRate:l(this,Ee).audio.sampleRate},timescale:l(this,Ee).audio.sampleRate,codecPrivate:e,samples:[],writtenChunks:[],currentChunk:null,firstTimestamp:void 0,lastTimestamp:-1,timeToSampleTable:[],lastTimescaleUnits:null,compactlyCodedChunkTable:[]})}},Re=new WeakSet,Le=function(e,t,n){let i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(t),r=n,a="";a+=e.toString(2).padStart(5,"0"),a+=i.toString(2).padStart(4,"0"),15===i&&(a+=t.toString(2).padStart(24,"0")),a+=r.toString(2).padStart(4,"0");let o=8*Math.ceil(a.length/8);a=a.padEnd(o,"0");let s=new Uint8Array(a.length/8);for(let e=0;e<a.length;e+=8)s[e/8]=parseInt(a.slice(e,e+8),2);return s},Ve=new WeakSet,Ue=function(e,t,n,i,r,a){var o;let s=i/1e6,c=r/1e6;if(void 0===e.firstTimestamp&&(e.firstTimestamp=s),s=d(this,ze,Ge).call(this,s,e),e.lastTimestamp=s,(!e.currentChunk||s-e.currentChunk.startTimestamp>=.5)&&(e.currentChunk&&d(this,He,Ne).call(this,e),e.currentChunk={startTimestamp:s,sampleData:[],sampleCount:0}),e.currentChunk.sampleData.push(t),e.currentChunk.sampleCount++,(null==(o=null==a?void 0:a.decoderConfig)?void 0:o.description)&&(e.codecPrivate=new Uint8Array(a.decoderConfig.description)),e.samples.push({timestamp:s,duration:c,size:t.byteLength,type:n}),null!==e.lastTimescaleUnits){let t=F(s,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);e.lastTimescaleUnits+=n;let i=j(e.timeToSampleTable);1===i.sampleCount?(i.sampleDelta=n,i.sampleCount++):i.sampleDelta===n?i.sampleCount++:(i.sampleCount--,e.timeToSampleTable.push({sampleCount:2,sampleDelta:n}))}else e.lastTimescaleUnits=0,e.timeToSampleTable.push({sampleCount:1,sampleDelta:F(c,e.timescale)})},ze=new WeakSet,Ge=function(e,t){if("strict"===l(this,Ee).firstTimestampBehavior&&-1===t.lastTimestamp&&0!==e)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received ${e}). Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of the document, which is probably what you want.\n\nIf you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.\n`);if("offset"===l(this,Ee).firstTimestampBehavior&&(e-=t.firstTimestamp),e<t.lastTimestamp)throw new Error(`Timestamps must be monotonically increasing (went from ${1e6*t.lastTimestamp} to ${1e6*e}).`);return e},He=new WeakSet,Ne=function(e){if(e.currentChunk){e.currentChunk.offset=l(this,xe).pos;for(let t of e.currentChunk.sampleData)l(this,xe).write(t);e.currentChunk.sampleData=null,0!==e.compactlyCodedChunkTable.length&&j(e.compactlyCodedChunkTable).samplesPerChunk===e.currentChunk.sampleCount||e.compactlyCodedChunkTable.push({firstChunk:e.writtenChunks.length+1,samplesPerChunk:e.currentChunk.sampleCount}),e.writtenChunks.push(e.currentChunk),d(this,$e,Ye).call(this)}},$e=new WeakSet,Ye=function(){l(this,xe)instanceof fe&&l(this,xe).flush()},Ke=new WeakSet,Xe=function(){if(l(this,Fe))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")},qe=h,((i,a,o,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let o of n(a))r.call(i,o)||undefined===o||e(i,o,{get:()=>a[o],enumerable:!(s=t(a,o))||s.enumerable});return i})(e({},"__esModule",{value:!0}),qe)})();"object"==typeof e.exports&&(e.exports.Muxer=t.Muxer,e.exports.ArrayBufferTarget=t.ArrayBufferTarget,e.exports.StreamTarget=t.StreamTarget,e.exports.FileSystemWritableFileStreamTarget=t.FileSystemWritableFileStreamTarget)},795:function(e,t,n){var i;e=n.nmd(e),function(){"use strict";var r={function:!0,object:!0},a=r[typeof window]&&window||this,o=r[typeof t]&&t,s=r.object&&e&&!e.nodeType&&e,c=o&&s&&"object"==typeof n.g&&n.g;!c||c.global!==c&&c.window!==c&&c.self!==c||(a=c);var l=Math.pow(2,53)-1,u=/\bOpera/,f=Object.prototype,d=f.hasOwnProperty,h=f.toString;function m(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function p(e){return e=w(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:m(e)}function g(e,t){for(var n in e)d.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?m(e):h.call(e).slice(8,-1)}function b(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function k(e,t){var n=null;return function(e,t){var n=-1,i=e?e.length:0;if("number"==typeof i&&i>-1&&i<=l)for(;++n<i;)t(e[n],n);else g(e,t)}(e,(function(i,r){n=t(n,i,r,e)})),n}function w(e){return String(e).replace(/^ +| +$/g,"")}var y=function e(t){var n=a,i=t&&"object"==typeof t&&"String"!=v(t);i&&(n=t,t=null);var r=n.navigator||{},o=r.userAgent||"";t||(t=o);var s,c,l,f,d,m=i?!!r.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(h.toString()),y="Object",P=i?y:"ScriptBridgingProxyObject",S=i?y:"Environment",T=i&&n.java?"JavaPackage":v(n.java),E=i?y:"RuntimeObject",x=/\bJava/.test(T)&&n.java,C=x&&v(n.environment)==S,O=x?"a":"α",A=x?"b":"β",j=n.document||{},F=n.operamini||n.opera,M=u.test(M=i&&F?F["[[Class]]"]:v(F))?M:F=null,I=t,B=[],W=null,_=t==o,D=_&&F&&"function"==typeof F.version&&F.version(),R=k([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||b(n))+"\\b","i").exec(t)&&(n.label||n)})),L=k(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"],(function(e,n){return e||RegExp("\\b"+(n.pattern||b(n))+"\\b","i").exec(t)&&(n.label||n)})),V=G([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),U=k({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}},(function(e,n,i){return e||(n[V]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(V)]||RegExp("\\b"+b(i)+"(?:\\b|\\w*\\d)","i").exec(t))&&i})),z=k(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "],(function(e,n){var i=n.pattern||b(n);return!e&&(e=RegExp("\\b"+i+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var i={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),p(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,i,n.label||n)),e}));function G(e){return k(e,(function(e,n){var i=n.pattern||b(n);return!e&&(e=RegExp("\\b"+i+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+i+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+i+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(i,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=p(e[0].replace(RegExp(i,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function H(e){return k(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(R&&(R=[R]),/\bAndroid\b/.test(z)&&!V&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(V=w(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),U&&!V?V=G([U]):U&&V&&(V=V.replace(RegExp("^("+b(U)+")[-_.\\s]","i"),U+" ").replace(RegExp("^("+b(U)+")[-_.]?(\\w)","i"),U+" $2")),(s=/\bGoogle TV\b/.exec(V))&&(V=s[0]),/\bSimulator\b/i.test(t)&&(V=(V?V+" ":"")+"Simulator"),"Opera Mini"==L&&/\bOPiOS\b/.test(t)&&B.push("running in Turbo/Uncompressed mode"),"IE"==L&&/\blike iPhone OS\b/.test(t)?(U=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,V=s.product):/^iP/.test(V)?(L||(L="Safari"),z="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==L&&/^Linux\b/i.test(z)?z="Kubuntu":U&&"Google"!=U&&(/Chrome/.test(L)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(V))||/\bAndroid\b/.test(z)&&/^Chrome/.test(L)&&/\bVersion\//i.test(t)?(L="Android Browser",z=/\bAndroid\b/.test(z)?z:"Android"):"Silk"==L?(/\bMobi/i.test(t)||(z="Android",B.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&B.unshift("accelerated")):"UC Browser"==L&&/\bUCWEB\b/.test(t)?B.push("speed mode"):"PaleMoon"==L&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?B.push("identifying as Firefox "+s[1]):"Firefox"==L&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(z||(z="Firefox OS"),V||(V=s[1])):!L||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(L))?(L&&!V&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(L=null),(s=V||U||z)&&(V||U||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(z))&&(L=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(z)?z:s)+" Browser")):"Electron"==L&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&B.push("Chromium "+s),D||(D=H(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",b(L),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==R&&parseFloat(D)>3?"WebKit":/\bOpera\b/.test(L)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(R)&&"WebKit"||!R&&/\bMSIE\b/i.test(t)&&("Mac OS"==z?"Tasman":"Trident")||"WebKit"==R&&/\bPlayStation\b(?! Vita\b)/i.test(L)&&"NetFront")&&(R=[s]),"IE"==L&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(L+=" Mobile",z="Windows Phone "+(/\+$/.test(s)?s:s+".x"),B.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(L="IE Mobile",z="Windows Phone 8.x",B.unshift("desktop mode"),D||(D=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=L&&"Trident"==R&&(s=/\brv:([\d.]+)/.exec(t))&&(L&&B.push("identifying as "+L+(D?" "+D:"")),L="IE",D=s[1]),_){if(f="global",d=null!=(l=n)?typeof l[f]:"number",/^(?:boolean|number|string|undefined)$/.test(d)||"object"==d&&!l[f])v(s=n.runtime)==P?(L="Adobe AIR",z=s.flash.system.Capabilities.os):v(s=n.phantom)==E?(L="PhantomJS",D=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof j.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(D=[D,j.documentMode],(s=+s[1]+4)!=D[1]&&(B.push("IE "+D[1]+" mode"),R&&(R[1]=""),D[1]=s),D="IE"==L?String(D[1].toFixed(1)):D[0]):"number"==typeof j.documentMode&&/^(?:Chrome|Firefox)\b/.test(L)&&(B.push("masking as "+L+" "+D),L="IE",D="11.0",R=["Trident"],z="Windows");else if(x&&(I=(s=x.lang.System).getProperty("os.arch"),z=z||s.getProperty("os.name")+" "+s.getProperty("os.version")),C){try{D=n.require("ringo/engine").version.join("."),L="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(L="Narwhal",z||(z=s[0].os||null))}L||(L="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(s=n.process)&&("object"==typeof s.versions&&("string"==typeof s.versions.electron?(B.push("Node "+s.versions.node),L="Electron",D=s.versions.electron):"string"==typeof s.versions.nw&&(B.push("Chromium "+D,"Node "+s.versions.node),L="NW.js",D=s.versions.nw)),L||(L="Node.js",I=s.arch,z=s.platform,D=(D=/[\d.]+/.exec(s.version))?D[0]:null));z=z&&p(z)}if(D&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(D)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(_&&r.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(W=/b/i.test(s)?"beta":"alpha",D=D.replace(RegExp(s+"\\+?$"),"")+("beta"==W?A:O)+(/\d+\+?/.exec(s)||"")),"Fennec"==L||"Firefox"==L&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(z))L="Firefox Mobile";else if("Maxthon"==L&&D)D=D.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(V))"Xbox 360"==V&&(z=null),"Xbox 360"==V&&/\bIEMobile\b/.test(t)&&B.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(L)&&(!L||V||/Browser|Mobi/.test(L))||"Windows CE"!=z&&!/Mobi/i.test(t))if("IE"==L&&_)try{null===n.external&&B.unshift("platform preview")}catch(e){B.unshift("embedded")}else(/\bBlackBerry\b/.test(V)||/\bBB10\b/.test(t))&&(s=(RegExp(V.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||D)?(z=((s=[s,/BB10/.test(t)])[1]?(V=null,U="BlackBerry"):"Device Software")+" "+s[0],D=null):this!=g&&"Wii"!=V&&(_&&F||/Opera/.test(L)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==L&&/\bOS X (?:\d+\.){2,}/.test(z)||"IE"==L&&(z&&!/^Win/.test(z)&&D>5.5||/\bWindows XP\b/.test(z)&&D>8||8==D&&!/\bTrident\b/.test(t)))&&!u.test(s=e.call(g,t.replace(u,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),u.test(L)?(/\bIE\b/.test(s)&&"Mac OS"==z&&(z=null),s="identify"+s):(s="mask"+s,L=M?p(M.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(z=null),_||(D=null)),R=["Presto"],B.push(s));else L+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==L&&"+"==s[1].slice(-1)?(L="WebKit Nightly",W="alpha",D=s[1].slice(0,-1)):D!=s[1]&&D!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(D=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==R&&(R=["Blink"]),_&&(m||s[1])?(R&&(R[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=R?"27":"28")):(R&&(R[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),R&&(R[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==L&&(!D||parseInt(D)>45)?D=s:"Chrome"==L&&/\bHeadlessChrome/i.test(t)&&B.unshift("headless")),"Opera"==L&&(s=/\bzbov|zvav$/.exec(z))?(L+=" ",B.unshift("desktop mode"),"zvav"==s?(L+="Mini",D=null):L+="Mobile",z=z.replace(RegExp(" *"+s+"$"),"")):"Safari"==L&&/\bChrome\b/.exec(R&&R[1])?(B.unshift("desktop mode"),L="Chrome Mobile",D=null,/\bOS X\b/.test(z)?(U="Apple",z="iOS 4.3+"):z=null):/\bSRWare Iron\b/.test(L)&&!D&&(D=H("Chrome")),D&&0==D.indexOf(s=/[\d.]+$/.exec(z))&&t.indexOf("/"+s+"-")>-1&&(z=w(z.replace(s,""))),z&&-1!=z.indexOf(L)&&!RegExp(L+" OS").test(z)&&(z=z.replace(RegExp(" *"+b(L)+" *"),"")),R&&!/\b(?:Avant|Nook)\b/.test(L)&&(/Browser|Lunascape|Maxthon/.test(L)||"Safari"!=L&&/^iOS/.test(z)&&/\bSafari\b/.test(R[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(L)&&R[1])&&(s=R[R.length-1])&&B.push(s),B.length&&(B=["("+B.join("; ")+")"]),U&&V&&V.indexOf(U)<0&&B.push("on "+U),V&&B.push((/^on /.test(B[B.length-1])?"":"on ")+V),z&&(s=/ ([\d.+]+)$/.exec(z),c=s&&"/"==z.charAt(z.length-s[0].length-1),z={architecture:32,family:s&&!c?z.replace(s[0],""):z,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(I))&&!/\bi686\b/i.test(I)?(z&&(z.architecture=64,z.family=z.family.replace(RegExp(" *"+s),"")),L&&(/\bWOW64\b/i.test(t)||_&&/\w(?:86|32)$/.test(r.cpuClass||r.platform)&&!/\bWin64; x64\b/i.test(t))&&B.unshift("32-bit")):z&&/^OS X/.test(z.family)&&"Chrome"==L&&parseFloat(D)>=39&&(z.architecture=64),t||(t=null);var N={};return N.description=t,N.layout=R&&R[0],N.manufacturer=U,N.name=L,N.prerelease=W,N.product=V,N.ua=t,N.version=L&&D,N.os=z||{architecture:null,family:null,version:null,toString:function(){return"null"}},N.parse=e,N.toString=function(){return this.description||""},N.version&&B.unshift(D),N.name&&B.unshift(L),z&&L&&(z!=String(z).split(" ")[0]||z!=L.split(" ")[0]&&!V)&&B.push(V?"("+z+")":"on "+z),B.length&&(N.description=B.join(" ")),N}();a.platform=y,void 0===(i=function(){return y}.call(t,n,t,e))||(e.exports=i)}.call(this)}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var a=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var i={};return(()=>{"use strict";n.r(i),n.d(i,{ARTouchType:()=>b,DeepAR:()=>_,ScriptingAPI:()=>h,VarType:()=>u,errors:()=>e,initialize:()=>W,version:()=>t});var e={};n.r(e),n.d(e,{SwitchEffectCanceled:()=>d});const t="5.4.0-chromeExtension";var r;const a=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,i;t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){n=e,i=t}));let a=null;const o=[];function s(){for(const e of o)e()}function c(){for(const e of o)e()}t.addPreRenderListener=function(e){o.push(e)},t.addPostRenderListener=function(e){o.push(e)};var l=null,u=null;let f=!1;const d=new ImageData(640,360);d.Ml=!0;let h,m,p,g,v,b,k,w,y,P,S,T,E,x,C,O,A,j,F=!1,M=null,I=null,B=null,W=null,_=null;function D(e){const n=t.Hk.length;return t.Hk[n]=e,n}t.Hk=[null],t.preinitializedWebGLContext=t.canvas.getContext("webgl2",{alpha:!1,antialias:!0,powerPreference:"high-performance"}),t.process=function(){};let R=new class{get Rk(){switch(this.type){case"Timer":return this.$k;case"RAF":return this.Zk;case"Oscillator":return this.Yk}}constructor(){this.Yk=this.Zk=this.$k=!1,this.type="RAF",this.al=1e3/33}add(e){this.Lk=e}start(){switch(this.type){case"Timer":if(!this.$k){this.$k=!0;const e=()=>{setTimeout((()=>{this.Lk&&this.Lk(),this.$k&&e()}),this.al)};e()}break;case"RAF":if(!this.Zk){this.Zk=!0;const e=t=>{requestAnimationFrame((n=>{n-t<=this.al?this.Zk&&e(t):this.Lk&&(this.Lk(),e(n))}))};e(-this.al-10)}break;case"Oscillator":if(!this.Yk){a=a||new AudioContext,this.Yk=!0;const e=a.createGain();let t;e.gain.value=0,e.connect(a.destination);const n=()=>{this.Lk&&this.Lk(),t&&t.disconnect(),this.ll=t=a.createOscillator(),t.connect(e),this.Yk&&(t.onended=n,t.start(),t.stop(a.currentTime+this.al/1e3))};n()}}}stop(){switch(this.type){case"Timer":this.$k=!1;break;case"RAF":this.Zk=!1;break;case"Oscillator":this.Yk=!1,this.ll&&(this.ll.onended=null,this.ll=void 0)}}};function L(){var e=t.Hk[0];if(e&&e.readyState===e.HAVE_ENOUGH_DATA)t._processFrameVideo(0,$),F=!0;else if(!F||0<Object.entries(G).length||null!=H||null!=N){e=h||d;var n=t._malloc(e.data.length);if(!n)return;oe.set(e.data,n),t._processFrameRawPixels(n,e.width,e.height,e.Ml),F=!0,t._free(n)}s(),e=t.canvas.width,n=t.canvas.height,t.canvasWidth===e&&t.canvasHeight===n||(t.canvasWidth=e,t.canvasHeight=n,ka(e,n)),t._render(),c(),t.apiObject.__deeparRendered&&t.apiObject.__deeparRendered(cr),t.apiObject.__deeparRendered2&&t.apiObject.__deeparRendered2(cr)}function V(){L()}t.setFps=function(e){R.al=1e3/e},R.add(V),t.startLoop=function(){R.add(V),R.start()},t.endLoop=function(){R.Lk=void 0,R.stop()};var U=!1,z=null;t.takeScreenshot=function(e){if(U)throw Error("The last call to takeScreenshot is not finished yet. Wait for the screenshot to finish.");U=!0,z=e;try{ba(),R.Rk||(s(),t._render(),c())}catch(e){throw U=!1,z=null,e}},t.processFrameRawPixels=function(e,n,i,r){var a=t._malloc(e.length);a&&(oe.set(e,a),t._processFrameRawPixels(a,n,i,r),h=new ImageData(new Uint8ClampedArray(e),n,i),h.Ml=r,F=!0,R.Rk||(s(),t._render(),c()),t._free(a))},t.initializeFootTracking=function(){Wr(),ya()},t.isFootTrackingInitialized=function(){return _r()},t.initializeSegmentation=function(){f?Gr():br()},t.isSegmentationInitialized=function(){return f?Hr():!!pr},t.isWristTrackingInitialized=function(){return Zr()};let G={},H=null,N=null;t.switchEffectByteArray=function(e,n,i,r,a){if(!M)throw Error("Error in internal API: __switchEffect is null!");const o=t._malloc(i.length);if(!o)throw Error("Cannot allocate buffer for switch effect.");oe.set(i,o),G[n]&&G[n].error&&G[n].error(new t.customErrors.SwitchEffectCanceled(`Switch effect canceled by another switch effect to the same slot: ${n}.`)),G[n]={Qk:r,error:a};try{M(n,o,i.length,e),F=!1,R.Rk||L()}catch(e){throw delete G[n],e}},t.hasVar=function(e,t){return m(e,t)},t.getVarType=function(e,t){if(p(e,t))return w(e,t);throw Error("Variable named '"+e+"' does not exist.")},t.getBoolVar=function(e,t){if(g(e,t))return y(e,t);throw Error("Variable named '"+e+"' does not exist or is not a boolean.")},t.getIntVar=function(e,t){if(v(e,t))return P(e,t);throw Error("Variable named '"+e+"' does not exist or is not an integer.")},t.getDoubleVar=function(e,t){if(b(e,t))return S(e,t);throw Error("Variable named '"+e+"' does not exist or is not a double.")},t.getStringVar=function(e,t){if(k(e,t))return T(e,t);throw Error("Variable named '"+e+"' does not exist or is not a string.")},t.setBoolVar=function(e,t,n){return E(e,t,n)},t.setIntVar=function(e,t,n){return x(e,t,n)},t.setDoubleVar=function(e,t,n){return C(e,t,n)},t.setStringVar=function(e,t,n){return O(e,t,n)},t.deleteVar=function(e,t){return A(e,t)},t.clearVars=function(e){return j(e)},t.clearEffect=function(e){G[e]&&G[e].error&&(G[e].error(new t.customErrors.SwitchEffectCanceled(`Switch effect canceled by the call to clearEffect() on the same slot: ${e}.`)),delete G[e]),I&&(I(e),R.Rk||L())},t.moveGameObject=function(e,t){B&&(B(e,t),R.Rk||L())};let $=!0;t.setMirror=function(e){$=!!e};let Y=!1;t.startCamera=function(e,n,i,r,a,o){t.stopVideo(),$=!!e;let s=document.createElement("video");s.setAttribute("playsinline","playsinline"),t.Hk[0]=s,n=n||!0,a&&a(),navigator.mediaDevices.getUserMedia({video:n}).then((function(e){o&&o(),s.srcObject=e,s.onloadedmetadata=()=>{s.play().then((()=>{i&&i()}))},Y=!0})).catch((e=>{r&&r(e),console.error(`${e.name}: ${e.message}`)}))},t.shutdown=function(){t.stopVideo(),va(),t.um()},t.setVideoElement=function(e,n){t.stopVideo(),$=!!n,t.Hk[0]=e},t.stopVideo=function(){t.Hk[0]&&(Y&&(t.Hk[0].srcObject.getTracks().forEach((e=>{e.stop()})),t.Hk[0].srcObject=null,Y=!1),t.Hk[0]=null)},t.touchOccurred=function(e){wa(e.x,e.y,e.type)},t.setOffscreenRenderingEnabled=function(e){!function(e){var t=R;if(t.type!==e){var n=t.$k|t.Yk|t.Zk;t.stop(),t.type=e,n&&t.start()}}(e?"Oscillator":"RAF")},t.backgroundReplacement=function(e,t,n,i){if(e){N&&N.error&&N.error(""),N={Qk:n,error:i};var r=new Image;r.onload=()=>{const t=document.createElement("canvas");var n=t.getContext("2d",{Jn:!0});t.width=r.width,t.height=r.height,n.drawImage(r,0,0),n=n.getImageData(0,0,t.width,t.height),n=new Uint8Array(n.data.buffer);const i=Pa(n.length);oe.set(n,i);try{_(e,i,n.length,t.width,t.height),F=!1,R.Rk||L()}catch(e){throw N=null,e}},r.src=t}else _(!1,null,0,0,0),n()},t.backgroundBlur=function(e,t,n,i){if(e){H&&H.error&&H.error(""),H={Qk:n,error:i};try{W(e,t),F=!1,R.Rk||L()}catch(e){throw H=null,e}}else W(!1,0),n()},t.lm=function(e,n,i,r){if(t.apiObject.onFaceTracked){var a=[];for(let u=0;u<r;u++){let r={detected:!1,translation:[],rotation:[],poseMatrix:[],landmarks:[],landmarks2d:[],faceRect:[]};var o=n+u*i,s=o+e.translationOffset;let f=o+e.rotationOffset;var c=o+e.poseMatrixOffset,l=o+e.landmarksOffset;let d=o+e.landmarks2DOffset,h=o+e.faceRectOffset;for(r.detected=!!t.HEAP32[o/Float32Array.BYTES_PER_ELEMENT],o=0;3>o;o++)r.translation.push(t.HEAPF32[s/Float32Array.BYTES_PER_ELEMENT+o]),r.rotation.push(t.HEAPF32[f/Float32Array.BYTES_PER_ELEMENT+o]);for(s=0;16>s;s++)r.poseMatrix.push(t.HEAPF32[c/Float32Array.BYTES_PER_ELEMENT+s]);for(c=0;204>c;c++)r.landmarks.push(t.HEAPF32[l/Float32Array.BYTES_PER_ELEMENT+c]),136>c&&r.landmarks2d.push(t.HEAPF32[d/Float32Array.BYTES_PER_ELEMENT+c]);for(l=0;4>l;l++)r.faceRect.push(t.HEAPF32[h/Float32Array.BYTES_PER_ELEMENT+l]);a.push(r)}t.apiObject.onFaceTracked(a)}},t.rn=function(){t.apiObject.onVideoStarted&&t.apiObject.onVideoStarted()},t.qm=function(){t.apiObject.onInitialize&&t.apiObject.onInitialize()},t.mm=function(e){t.apiObject.onFaceVisibilityChanged&&t.apiObject.onFaceVisibilityChanged(e)},t.pm=function(e){t.apiObject.onImageVisibilityChanged&&t.apiObject.onImageVisibilityChanged(e)},t.qn=function(){t.apiObject.onCameraPermissionGranted&&t.apiObject.onCameraPermissionGranted()},t.pn=function(){t.apiObject.onCameraPermissionDenied&&t.apiObject.onCameraPermissionDenied()},t.on=function(){t.apiObject.onCameraPermissionAsked&&t.apiObject.onCameraPermissionAsked()},t.sm=function(e,t,n){const i=document.createElement("canvas"),r=i.getContext("2d");i.width=t,i.height=n;const a=r.getImageData(0,0,i.width,i.height),o=a.data;for(let i=0;i<n;i++)for(let r=0;r<t;r++){const a=4*((n-i-1)*t+r),s=4*(i*t+r);o[s]=oe[e+a+2],o[s+1]=oe[e+a+1],o[s+2]=oe[e+a+0],o[s+3]=oe[e+a+3]}r.putImageData(a,0,0),U?(U=!1,z(i.toDataURL("image/png")),z=null):console.error("DeepAR screenshot taken but no registered callback.")},t.gm=function(e){t.apiObject.onAnimationTransitionedToState&&t.apiObject.onAnimationTransitionedToState(e)},t.km=function(e,t){"Error"===e?console.error(t):"Debug"===e?console.debug(t):"Info"===e?console.info(t):"Warning"===e?console.warn(t):console.log(t)},t.jm=function(e){G[e]&&G[e].Qk&&G[e].Qk(),delete G[e]},t.im=function(){N&&N.Qk&&N.Qk(),N={}},t.hm=function(){H&&H.Qk&&H.Qk(),H={}},t.rm=function(e){t.apiObject.onNumberOfFacesVisibleChanged&&t.apiObject.onNumberOfFacesVisibleChanged(e)},t.um=function(){t.apiObject.onShutdown&&t.apiObject.onShutdown()},t.om=function(){t.apiObject.onFootTrackingInitialized&&t.apiObject.onFootTrackingInitialized()},t.tm=function(){t.apiObject.onSegmentationInitialized&&t.apiObject.onSegmentationInitialized()},t.nm=function(e,n){t.apiObject.onFeetTracked&&t.apiObject.onFeetTracked(e,n)},t.wm=function(){t.apiObject.onWristTrackingInitialized&&t.apiObject.onWristTrackingInitialized()},t.vm=function(e){t.apiObject.onWristTracked&&t.apiObject.onWristTracked(e)},t.noInitialRun=!0,t.initializeDeepAR=function(){t.initializeML&&(t.initializeML.useXzimgWebSegmentation&&(f=!0),t.initializeML.faceModelsPredownload&&q("face"),t.initializeML.segmentationInit&&(f?Gr():br()),t.initializeML.footInit&&Wr(),t.initializeML.segmentationModelsPredownload&&q("segmentationXzimg"),t.initializeML.footModelsPredownload&&(q("footDetector"),q("footTracker"),q("footObj")),t.initializeML.rigidFaceInit&&(q("rigidFaceDetector"),q("rigidFaceTracker"))),M=oa("switchEffect",null,["string","number","number","number"]),I=oa("clearEffect",null,["string"]),B=oa("moveGameObject",null,["string","string"]),W=oa("backgroundBlur",null,["boolean","number"]),_=oa("backgroundReplacement",null,["boolean","number","number","number","number"]),m=oa("hasVar","boolean",["string","string"]),p=oa("getVarTypeStatus","boolean",["string","string"]),g=oa("getBoolVarStatus","boolean",["string","string"]),v=oa("getIntVarStatus","boolean",["string","string"]),b=oa("getDoubleVarStatus","boolean",["string","string"]),k=oa("getStringVarStatus","boolean",["string","string"]),w=oa("getVarType","int",["string","string"]),y=oa("getBoolVar","boolean",["string","string"]),P=oa("getIntVar","int",["string","string"]),S=oa("getDoubleVar","number",["string","string"]),T=oa("getStringVar","string",["string","string"]),E=oa("setBoolVar","boolean",["string","boolean","string"]),x=oa("setIntVar","boolean",["string","int","string"]),C=oa("setDoubleVar","boolean",["string","number","string"]),O=oa("setStringVar","boolean",["string","string","string"]),A=oa("deleteVar","boolean",["string","string"]),j=oa("clearVars","boolean",["string"]),t.pushConsoleLog=oa("pushConsoleLog","boolean",["string","int"]),t.changeParameterFloat=oa("changeParameterFloat",null,["string","string","string","number"]),t.changeParameterVector=oa("changeParameterVector",null,"string string string number number number number".split(" ")),t.changeParameterBool=oa("changeParameterBool",null,["string","string","string","boolean"]),t.changeParameterTexture=oa("changeParameterTexture",null,"string string string number number number number".split(" ")),t.fireTrigger=oa("fireTrigger",null,["string"]),t.setFaceDetectionSensitivity=oa("setFaceDetectionSensitivity",null,["number"]),t.showStats=oa("showStats",null,["number"]),t.simulatePhysics=oa("simulatePhysics",null,["number"]),t.showColliders=oa("showColliders",null,["number"]),t.setLicenseKey=oa("setLicenseKey",null,["string"]),t.muteSound=oa("muteSound",null,["boolean"]),t.setLicenseKey(t.licenseKey),pa(t.canvasWidth,t.canvasHeight,t.initializeML&&t.initializeML.rigidFaceInit,f)};let K={};function X(e,t,n){K[e]={path:t,nl:!1,data:null,ml:!1,bl:[],Jl:n,Ul:function(n){n&&this.bl.push(n),this.data?this.bl.forEach((e=>{e.Qk(this.data)})):this.nl||(this.ml&&this.bl.forEach((e=>{e.error()})),this.path||(console.error(`The ${e} model was requested but the path to it is not defined.`),this.ml=!0,this.bl.forEach((e=>{e.error()}))),this.nl=!0,fetch(this.path).then((n=>{n.ok?n.arrayBuffer().then((n=>{this.data=n,this.nl=!1,this.ml=!0,async function(e){return e=await crypto.subtle.digest("SHA-256",e),Array.from(new Uint8Array(e)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(n).then((n=>{this.Jl.some((e=>e===n))||console.warn(`The loaded ${e} model (${t}) does not pass the validity check. DeepAR may not function as expected or it might crash. Expected digests: ${this.Jl} but got this digest ${n}.`)})),this.bl.forEach((e=>{e.Qk(n)}))})).catch((t=>{console.error(t),console.error(`Error downloading the ${e} model (${this.path}), could not resolve the array buffer`),this.bl.forEach((e=>{e.error()}))})):(this.nl=!1,this.ml=!0,console.error(`Error downloading the ${e} model (${this.path}), response status = ${n.status}. Effects using ${e} will not work properly or at all.`),this.bl.forEach((e=>{e.error()})))})))},Em:function(){return this.data?this.data:this.ml||this.nl?null:void this.Ul()},Dm:async function(){return new Promise(((e,t)=>{this.Ul({Qk:e,error:t})}))}}}function q(e){if(!K[e])throw Error(`No ML model with name ${e}.`);return K[e].Em()}function J(e){if(!K[e])throw Error(`No ML model with name ${e}.`);return K[e].Dm()}X("face",t.faceTrackingModelPath,["d77b98c4cbe7f514b541ff79f79503bf23bc8f2b27046c8c785f2d89d2c3a44b"]),X("rigidFaceDetector",t.rigidFaceTrackingConfig.detectorPath,["8270514ae788bc6ee67db086c9400581d17a78c18de38c878f1148dcc3a8e480"]),X("rigidFaceTracker",t.rigidFaceTrackingConfig.trackerPath,["83ed5dae95a107733811b1ff3bfcce1cd94b9e652c52a8c9317156294f3c9c9a"]),X("segmentationXzimg",t.segmentationConfig.modelPath,["373cb9dd1fbf3972245665a81607ec7d33078ee0dae380c9d9e8bc03034dc09a"]),X("segmentationMediaPipe",t.segmentationConfig.mediaPipeConfig.modelPath,["191ac9529ae506ee0beefa6b2c945a172dab9d07d1e802a290a4e4038226658b","490e9ea734313e0de10fa0cd9e3c6133e36ea4db2b7a49bde9ef019f72796b8e"]),X("footDetector",t.footTrackingConfig.detectorPath,["2c6d4af14fbe42bdc37fba53526429ac7453e19971a4a070e64bae6460872ac3"]),X("footTracker",t.footTrackingConfig.trackerPath,["ddfc598f45ae5e5a8169518a9daecedc556df623cb3a1d676e7de0f85f14f337","f0ec050f034b9ade54711705213d2dd336b76452a7d81bd17ba2505a5293438a"]),X("footObj",t.footTrackingConfig.objPath,["689ec395dc4382e15af1304405546fcdcb677044d61bf73db0b2d6c163be35f2"]),X("wristDetector",t.wristTrackingConfig.detectorPath,["b4c14a6f4b7bed1bc1cb313bbad5e877c7958c25b8e47d12583404f9a611d7ff"]),X("wristTracker",t.wristTrackingConfig.trackerPath,["5f2e644d8217fe47f15c823e8419085e2544140706e88b453615749e7c5b7918"]),X("wristObj",t.wristTrackingConfig.objPath,["5c763303cac33e377bbfbc3bd13475c0b99ca6412f9774ecc7a65fe72ac01732"]),X("background_replacement.deepar",t.embeddedEffectConfig.backgroundReplacementPath,["40e3ea2148e50af361eabc79a27b7d5b5c1ad04c4d9c0b48a296acd29054f3c9"]),X("background_blur.deepar",t.embeddedEffectConfig.backgroundBlurPath,["27018fc27e24a68a5f7022ac270d17734967e2c2c650630b9b8ade1e0198d684"]);var Q=Object.assign({},t),Z="";"undefined"!=typeof document&&document.currentScript&&(Z=document.currentScript.src),r&&(Z=r),Z=0!==Z.indexOf("blob:")?Z.substr(0,Z.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var ee=console.log.bind(console),te=console.warn.bind(console);Object.assign(t,Q),Q=null;var ne=!1;"object"!=typeof WebAssembly&&Me("no native wasm support detected");var ie,re,ae,oe,se,ce,le,ue,fe,de,he=!1,me="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function pe(e,t,n){var i=t+n;for(n=t;e[n]&&!(n>=i);)++n;if(16<n-t&&e.buffer&&me)return me.decode(e.subarray(t,n));for(i="";t<n;){var r=e[t++];if(128&r){var a=63&e[t++];if(192==(224&r))i+=String.fromCharCode((31&r)<<6|a);else{var o=63&e[t++];65536>(r=224==(240&r)?(15&r)<<12|a<<6|o:(7&r)<<18|a<<12|o<<6|63&e[t++])?i+=String.fromCharCode(r):(r-=65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}}else i+=String.fromCharCode(r)}return i}function ge(e,t){return e?pe(oe,e,t):""}function ve(e,t,n,i){if(!(0<i))return 0;var r=n;i=n+i-1;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a)),127>=o){if(n>=i)break;t[n++]=o}else{if(2047>=o){if(n+1>=i)break;t[n++]=192|o>>6}else{if(65535>=o){if(n+2>=i)break;t[n++]=224|o>>12}else{if(n+3>=i)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63}t[n++]=128|o>>6&63}t[n++]=128|63&o}}return t[n]=0,n-r}function be(e,t,n){return ve(e,oe,t,n)}function ke(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);127>=i?t++:2047>=i?t+=2:55296<=i&&57343>=i?(t+=4,++n):t+=3}return t}function we(){var e=ie.buffer;t.HEAP8=ae=new Int8Array(e),t.HEAP16=se=new Int16Array(e),t.HEAP32=le=new Int32Array(e),t.HEAPU8=oe=new Uint8Array(e),t.HEAPU16=ce=new Uint16Array(e),t.HEAPU32=ue=new Uint32Array(e),t.HEAPF32=fe=new Float32Array(e),t.HEAPF64=de=new Float64Array(e)}var ye,Pe,Se=[],Te=[],Ee=[],xe=[],Ce=!1,Oe=0,Ae=0,je=null,Fe=null;function Me(e){throw te(e="Aborted("+e+")"),he=!0,re=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),i(e),e}function Ie(e){return e.startsWith("data:application/octet-stream;base64,")}if(!Ie(Pe="deepar.wasm")){var Be=Pe;Pe=t.locateFile?t.locateFile(Be,Z):Z+Be}function We(){try{throw"both async and sync fetching of the wasm failed"}catch(e){Me(e)}}function _e(e,t,n){return function(e){return"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return We()})):Promise.resolve().then((function(){return We()}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){te("failed to asynchronously prepare wasm: "+e),Me(e)}))}var De={979896:(e,t,n,i,r,a)=>{var o=document.createElement("canvas"),s=o.getContext("2d");o.width=t,o.height=n,e=new Uint8ClampedArray(oe.subarray(e,e+o.width*o.height*4)),e=new ImageData(e,o.width,o.height),s.putImageData(e,0,0),e=(s=document.createElement("canvas")).getContext("2d"),s.width=r,s.height=a,e.drawImage(o,0,0,s.width,s.height),r=e.getImageData(0,0,s.width,s.height),r=new Uint8Array(r.data.buffer),oe.set(r,i)},980750:(e,t,n,i,r,a)=>{var o=document.createElement("canvas"),s=o.getContext("2d");o.width=t,o.height=n,e=new Uint8ClampedArray(oe.subarray(e,e+o.width*o.height*4)),e=new ImageData(e,o.width,o.height),s.putImageData(e,0,0),e=(s=document.createElement("canvas")).getContext("2d"),s.width=r,s.height=a,e.drawImage(o,0,0,s.width,s.height),r=e.getImageData(0,0,s.width,s.height),r=new Uint8Array(r.data.buffer),oe.set(r,i)},981604:()=>{console.log("License key not valid")},981641:()=>{t.qm()},981665:(e,n,i)=>{t.sm(e,n,i)},981708:e=>{t.rm(e)},981755:e=>{t.jm(ge(e))},981799:(e,n,i,r,a,o,s,c,l)=>{t.lm({translationOffset:e,rotationOffset:n,poseMatrixOffset:i,landmarksOffset:r,landmarks2DOffset:a,faceRectOffset:o},s,c,l)},981983:(e,n)=>{t.km(ge(e),ge(n))},982040:()=>{t.hm()},982078:()=>{t.im()},982123:()=>{t.om()},982164:()=>{t.wm()},982206:(e,n)=>{t.nm({detected:!!e},{detected:!!n})},982277:(e,n)=>{t.vm({detected:!!e,isLeft:!!n})},982342:()=>{t.tm()},982383:e=>{t.mm(!!e)},982424:e=>{t.pm(!!e)},982468:(e,n)=>{e=ge(e,n),t.gm(e)},982549:()=>{alert("DeepAR license not valid")},982583:()=>{t.endLoop()},982604:()=>{let e=q("face");if(!e)return 0;e=new Uint8Array(e);var t=Pa(e.length);return oe.set(e,t),t},982813:()=>{var e=Xi,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},982967:()=>{var e=qi,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983126:()=>{var e=Ji,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983292:()=>{var e=Zi,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983455:()=>{var e=er,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983623:()=>{var e=Qi,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983788:()=>{var e=tr,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},983950:()=>{var e=nr,t=ke(e)+1,n=Pa(t);return be(e,n,t),n},984111:()=>{var e=ir,t=ke(e)+1,n=Pa(t);return be(e,n,t),n}};function Re(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Le(e){for(;0<e.length;)e.shift()(t)}var Ve=[],Ue=0,ze=0;function Ge(e){return ye.get(e)}function He(e){this.ol=e,this.Fk=e-24,this.am=function(e){ue[this.Fk+4>>2]=e},this.Lk=function(){return ue[this.Fk+4>>2]},this.Yl=function(e){ue[this.Fk+8>>2]=e},this.Gm=function(){return ue[this.Fk+8>>2]},this.$l=function(){le[this.Fk>>2]=0},this.Dl=function(e){ae[this.Fk+12>>0]=e?1:0},this.$k=function(){return 0!=ae[this.Fk+12>>0]},this.El=function(e){ae[this.Fk+13>>0]=e?1:0},this.Ll=function(){return 0!=ae[this.Fk+13>>0]},this.ll=function(e,t){this.Rk(0),this.am(e),this.Yl(t),this.$l(),this.Dl(!1),this.El(!1)},this.Yk=function(){le[this.Fk>>2]+=1},this.Rm=function(){var e=le[this.Fk>>2];return le[this.Fk>>2]=e-1,1===e},this.Rk=function(e){ue[this.Fk+16>>2]=e},this.Zk=function(){return ue[this.Fk+16>>2]},this.al=function(){if(Ia(this.Lk()))return ue[this.ol>>2];var e=this.Zk();return 0!==e?e:this.ol}}function Ne(){var e=ze;if(!e)return Ta(0),0;var t=new He(e);t.Rk(e);var n=t.Lk();if(!n)return Ta(0),e;for(var i=0;i<arguments.length;i++){var r=arguments[i];if(0===r||r===n)break;if(Ma(r,n,t.Fk+16))return Ta(r),e}return Ta(n),e}var $e={};function Ye(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Ke(e){return this.fromWireType(le[e>>2])}var Xe={},qe={},Je={};function Qe(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?"_"+e:e}function Ze(e,t){return{[e=Qe(e)]:function(){return t.apply(this,arguments)}}[e]}function et(e){var t=Error,n=Ze(e,(function(t){this.name=e,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var tt=void 0;function nt(e){throw new tt(e)}function it(e,t,n){function i(t){(t=n(t)).length!==e.length&&nt("Mismatched type converter count");for(var i=0;i<e.length;++i)lt(e[i],t[i])}e.forEach((function(e){Je[e]=t}));var r=Array(t.length),a=[],o=0;t.forEach(((e,t)=>{qe.hasOwnProperty(e)?r[t]=qe[e]:(a.push(e),Xe.hasOwnProperty(e)||(Xe[e]=[]),Xe[e].push((()=>{r[t]=qe[e],++o===a.length&&i(r)})))})),0===a.length&&i(r)}function rt(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var at=void 0;function ot(e){for(var t="";oe[e];)t+=at[oe[e++]];return t}var st=void 0;function ct(e){throw new st(e)}function lt(e,t,n={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var i=t.name;if(e||ct('type "'+i+'" must have a positive integer typeid pointer'),qe.hasOwnProperty(e)){if(n.Lm)return;ct("Cannot register type '"+i+"' twice")}qe[e]=t,delete Je[e],Xe.hasOwnProperty(e)&&(t=Xe[e],delete Xe[e],t.forEach((e=>e())))}function ut(e){ct(e.Ek.Ik.Gk.name+" instance already deleted")}var ft=!1;function dt(){}function ht(e){--e.count.value,0===e.count.value&&(e.Nk?e.Pk.Xk(e.Nk):e.Ik.Gk.Xk(e.Fk))}function mt(e,t,n){return t===n?e:void 0===n.Sk||null===(e=mt(e,t,n.Sk))?null:n.zm(e)}var pt={},gt=[];function vt(){for(;gt.length;){var e=gt.pop();e.Ek.jl=!1,e.delete()}}var bt=void 0,kt={};function wt(e,t){return t.Ik&&t.Fk||nt("makeClassHandle requires ptr and ptrType"),!!t.Pk!=!!t.Nk&&nt("Both smartPtrType and smartPtr must be specified"),t.count={value:1},yt(Object.create(e,{Ek:{value:t}}))}function yt(e){return"undefined"==typeof FinalizationRegistry?(yt=e=>e,e):(ft=new FinalizationRegistry((e=>{ht(e.Ek)})),dt=e=>{ft.unregister(e)},(yt=e=>{var t=e.Ek;return t.Nk&&ft.register(e,{Ek:t},e),e})(e))}function Pt(){}function St(e,t,n){if(void 0===e[t].Kk){var i=e[t];e[t]=function(){return e[t].Kk.hasOwnProperty(arguments.length)||ct("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].Kk+")!"),e[t].Kk[arguments.length].apply(this,arguments)},e[t].Kk=[],e[t].Kk[i.rl]=i}}function Tt(e,n,i){t.hasOwnProperty(e)?((void 0===i||void 0!==t[e].Kk&&void 0!==t[e].Kk[i])&&ct("Cannot register public name '"+e+"' twice"),St(t,e,e),t.hasOwnProperty(i)&&ct("Cannot register multiple overloads of a function with the same number of arguments ("+i+")!"),t[e].Kk[i]=n):(t[e]=n,void 0!==i&&(t[e].En=i))}function Et(e,t,n,i,r,a,o,s){this.name=e,this.constructor=t,this.kl=n,this.Xk=i,this.Sk=r,this.Cm=a,this.ql=o,this.zm=s,this.Om=[]}function xt(e,t,n){for(;t!==n;)t.ql||ct("Expected null or instance of "+n.name+", got an instance of "+t.name),e=t.ql(e),t=t.Sk;return e}function Ct(e,t){return null===t?(this.zl&&ct("null is not a valid "+this.name),0):(t.Ek||ct('Cannot pass "'+Nt(t)+'" as a '+this.name),t.Ek.Fk||ct("Cannot pass deleted object as a pointer of type "+this.name),xt(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk))}function Ot(e,t){if(null===t){if(this.zl&&ct("null is not a valid "+this.name),this.tl){var n=this.Bl();return null!==e&&e.push(this.Xk,n),n}return 0}if(t.Ek||ct('Cannot pass "'+Nt(t)+'" as a '+this.name),t.Ek.Fk||ct("Cannot pass deleted object as a pointer of type "+this.name),!this.sl&&t.Ek.Ik.sl&&ct("Cannot convert argument of type "+(t.Ek.Pk?t.Ek.Pk.name:t.Ek.Ik.name)+" to parameter type "+this.name),n=xt(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk),this.tl)switch(void 0===t.Ek.Nk&&ct("Passing raw pointer to smart pointer is illegal"),this.Vm){case 0:t.Ek.Pk===this?n=t.Ek.Nk:ct("Cannot convert argument of type "+(t.Ek.Pk?t.Ek.Pk.name:t.Ek.Ik.name)+" to parameter type "+this.name);break;case 1:n=t.Ek.Nk;break;case 2:if(t.Ek.Pk===this)n=t.Ek.Nk;else{var i=t.clone();n=this.Qm(n,zt((function(){i.delete()}))),null!==e&&e.push(this.Xk,n)}break;default:ct("Unsupporting sharing policy")}return n}function At(e,t){return null===t?(this.zl&&ct("null is not a valid "+this.name),0):(t.Ek||ct('Cannot pass "'+Nt(t)+'" as a '+this.name),t.Ek.Fk||ct("Cannot pass deleted object as a pointer of type "+this.name),t.Ek.Ik.sl&&ct("Cannot convert argument of type "+t.Ek.Ik.name+" to parameter type "+this.name),xt(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk))}function jt(e,t,n,i){this.name=e,this.Gk=t,this.zl=n,this.sl=i,this.tl=!1,this.Xk=this.Qm=this.Bl=this.Pl=this.Vm=this.Nm=void 0,void 0!==t.Sk?this.toWireType=Ot:(this.toWireType=i?Ct:At,this.Ok=null)}function Ft(e,n,i){t.hasOwnProperty(e)||nt("Replacing nonexistant public symbol"),void 0!==t[e].Kk&&void 0!==i?t[e].Kk[i]=n:(t[e]=n,t[e].rl=i)}function Mt(e,n,i){return e.includes("j")?(e=t["dynCall_"+e],n=i&&i.length?e.apply(null,[n].concat(i)):e.call(null,n)):n=Ge(n).apply(null,i),n}function It(e,t){var n=(e=ot(e)).includes("j")?function(e,t){var n=[];return function(){return n.length=0,Object.assign(n,arguments),Mt(e,t,n)}}(e,t):Ge(t);return"function"!=typeof n&&ct("unknown function pointer with signature "+e+": "+t),n}var Bt=void 0;function Wt(e){var t=ot(e=xa(e));return Sa(e),t}function _t(e,t){var n=[],i={};throw t.forEach((function e(t){i[t]||qe[t]||(Je[t]?Je[t].forEach(e):(n.push(t),i[t]=!0))})),new Bt(e+": "+n.map(Wt).join([", "]))}function Dt(e,t){for(var n=[],i=0;i<e;i++)n.push(ue[t+4*i>>2]);return n}function Rt(e,t,n,i,r){var a=t.length;2>a&&ct("argTypes array size mismatch! Must at least get return value and 'this' types!");var o=null!==t[1]&&null!==n,s=!1;for(n=1;n<t.length;++n)if(null!==t[n]&&void 0===t[n].Ok){s=!0;break}var c="void"!==t[0].name,l=a-2,u=Array(l),f=[],d=[];return function(){if(arguments.length!==l&&ct("function "+e+" called with "+arguments.length+" arguments, expected "+l+" args!"),d.length=0,f.length=o?2:1,f[0]=r,o){var n=t[1].toWireType(d,this);f[1]=n}for(var a=0;a<l;++a)u[a]=t[a+2].toWireType(d,arguments[a]),f.push(u[a]);if(a=i.apply(null,f),s)Ye(d);else for(var h=o?1:2;h<t.length;h++){var m=1===h?n:u[h-2];null!==t[h].Ok&&t[h].Ok(m)}return c?t[0].fromWireType(a):void 0}}var Lt=[],Vt=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ut(e){4<e&&0==--Vt[e].Cl&&(Vt[e]=void 0,Lt.push(e))}var zt=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=Lt.length?Lt.pop():Vt.length;return Vt[t]={Cl:1,value:e},t}};function Gt(e,t,n){switch(t){case 0:return function(e){return this.fromWireType((n?ae:oe)[e])};case 1:return function(e){return this.fromWireType((n?se:ce)[e>>1])};case 2:return function(e){return this.fromWireType((n?le:ue)[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Ht(e,t){var n=qe[e];return void 0===n&&ct(t+" has unknown type "+Wt(e)),n}function Nt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function $t(e,t){switch(t){case 2:return function(e){return this.fromWireType(fe[e>>2])};case 3:return function(e){return this.fromWireType(de[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Yt(e,t,n){switch(t){case 0:return n?function(e){return ae[e]}:function(e){return oe[e]};case 1:return n?function(e){return se[e>>1]}:function(e){return ce[e>>1]};case 2:return n?function(e){return le[e>>2]}:function(e){return ue[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Kt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Xt(e,t){for(var n=e>>1,i=n+t/2;!(n>=i)&&ce[n];)++n;if(32<(n<<=1)-e&&Kt)return Kt.decode(oe.subarray(e,n));for(n="",i=0;!(i>=t/2);++i){var r=se[e+2*i>>1];if(0==r)break;n+=String.fromCharCode(r)}return n}function qt(e,t,n){if(void 0===n&&(n=2147483647),2>n)return 0;var i=t;n=(n-=2)<2*e.length?n/2:e.length;for(var r=0;r<n;++r)se[t>>1]=e.charCodeAt(r),t+=2;return se[t>>1]=0,t-i}function Jt(e){return 2*e.length}function Qt(e,t){for(var n=0,i="";!(n>=t/4);){var r=le[e+4*n>>2];if(0==r)break;++n,65536<=r?(r-=65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r)):i+=String.fromCharCode(r)}return i}function Zt(e,t,n){if(void 0===n&&(n=2147483647),4>n)return 0;var i=t;n=i+n-4;for(var r=0;r<e.length;++r){var a=e.charCodeAt(r);if(55296<=a&&57343>=a&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++r)),le[t>>2]=a,(t+=4)+4>n)break}return le[t>>2]=0,t-i}function en(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);55296<=i&&57343>=i&&++n,t+=4}return t}function tn(e){return 0==e%4&&(0!=e%100||0==e%400)}var nn,rn=[0,31,60,91,121,152,182,213,244,274,305,335],an=[0,31,59,90,120,151,181,212,243,273,304,334];function on(e){return(tn(e.getFullYear())?rn:an)[e.getMonth()]+e.getDate()-1}function sn(e){var t=ke(e)+1,n=Pa(t);return n&&ve(e,ae,n,t),n}function cn(e,t){if(Pn=e,Sn=t,yn)if(bn||(Oe+=1,bn=!0),0==e)kn=function(){var e=0|Math.max(0,pn+t-nn());setTimeout(gn,e)};else if(1==e)kn=function(){Wn(gn)};else if(2==e){if("undefined"==typeof setImmediate){var n=[];addEventListener("message",(e=>{"setimmediate"!==e.data&&"setimmediate"!==e.data.target||(e.stopPropagation(),n.shift()())}),!0),setImmediate=function(e){n.push(e),postMessage("setimmediate","*")}}kn=function(){setImmediate(gn)}}}function ln(e){throw re=e,ne||0<Oe||(Ca(),Le(Ee),Ea(0),Yi[1].length&&Ki(1,10),Yi[2].length&&Ki(2,10),Ce=!0),re=e,ne||0<Oe||(he=!0),new Re(e)}function un(e){if(!(e instanceof Re||"unwind"==e))throw e}function fn(){if(!(ne||0<Oe))try{ln(re)}catch(e){un(e)}}function dn(e){if(!Ce&&!he)try{e(),fn()}catch(e){un(e)}}function hn(e){mn||(mn={}),mn[e]||(mn[e]=1,te(e))}nn=()=>performance.now();var mn,pn,gn,vn,bn=!1,kn=null,wn=0,yn=null,Pn=0,Sn=0,Tn=0,En=[],xn={},Cn=!1,On=!1,An=[];var jn=!1,Fn=void 0,Mn=void 0;function In(){return!!Cn&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){}).apply(document,[]),!0)}var Bn=0;function Wn(e){if("function"==typeof requestAnimationFrame)requestAnimationFrame(e);else{var t=Date.now();if(0===Bn)Bn=t+1e3/60;else for(;t+2>=Bn;)Bn+=1e3/60;setTimeout(e,Math.max(Bn-t,0))}}function _n(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}var Dn=[];function Rn(){var e=t.canvas;Dn.forEach((function(t){t(e.width,e.height)}))}function Ln(e,n,i){n&&i?(e.an=n,e.Km=i):(n=e.an,i=e.Km);var r=n,a=i;if(t.forcedAspectRatio&&0<t.forcedAspectRatio&&(r/a<t.forcedAspectRatio?r=Math.round(a*t.forcedAspectRatio):a=Math.round(r/t.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e.parentNode&&"undefined"!=typeof screen){var o=Math.min(screen.width/r,screen.height/a);r=Math.round(r*o),a=Math.round(a*o)}Mn?(e.width!=r&&(e.width=r),e.height!=a&&(e.height=a),void 0!==e.style&&(e.style.removeProperty("width"),e.style.removeProperty("height"))):(e.width!=n&&(e.width=n),e.height!=i&&(e.height=i),void 0!==e.style&&(r!=n||a!=i?(e.style.setProperty("width",r+"px","important"),e.style.setProperty("height",a+"px","important")):(e.style.removeProperty("width"),e.style.removeProperty("height"))))}var Vn,Un,zn,Gn,Hn,Nn=!1,$n=0,Yn=0,Kn=0,Xn={alpha:!1,depth:!1,stencil:!1,antialias:!1},qn={},Jn=1,Qn=[],Zn=[],ei=[],ti=[],ni=[],ii=[],ri=[],ai=[],oi=[],si=[],ci=[],li=[],ui={},fi={};function di(e){vi||(vi=e)}function hi(e){for(var t=Jn++,n=e.length;n<t;n++)e[n]=null;return t}function mi(e,t,n){for(var i="",r=0;r<e;++r){var a=n?le[n+4*r>>2]:-1;i+=ge(le[t+4*r>>2],0>a?void 0:a)}return i}function pi(e,n){if(t.preinitializedWebGLContext){var i=t.preinitializedWebGLContext;n.Al=Number(i.getParameter(i.VERSION).match(/^WebGL (\d+).\d+/)[1])}else e.Lk||(e.Lk=e.getContext,e.getContext=function(t,n){return"webgl"==t==(n=e.Lk(t,n))instanceof WebGLRenderingContext?n:null}),i=e.getContext("webgl2",n);return i?function(e,t){var n=hi(ai),i={xn:n,attributes:t,version:t.Al,il:e};return e.canvas&&(e.canvas.Xl=i),ai[n]=i,(void 0===t.Am||t.Am)&&function(e){if(e||(e=bi),!e.Mm){e.Mm=!0;var t=e.il;t.un=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),t.An=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(t.Mk=t.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!t.Mk)&&(t.Mk=t.getExtension("EXT_disjoint_timer_query")),t.Cn=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach((function(e){e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}(i),n}(i,n):0}function gi(e){bi=ai[e],t.dl=la=bi&&bi.il}var vi,bi,ki={},wi=[];function yi(e,t,n){var i;for(wi.length=0,n>>=2;i=oe[t++];)n+=105!=i&n,wi.push(105==i?le[n]:de[n++>>1]),++n;return De[e].apply(null,wi)}var Pi={},Si=0,Ti=[];function Ei(e,t,n,i){la.drawElements(e,t,n,i)}function xi(e,t,n,i){for(var r=0;r<e;r++){var a=la[n](),o=a&&hi(i);a?(a.name=o,i[o]=a):di(1282),le[t+4*r>>2]=o}}function Ci(e,t,n,i,r,a,o,s){t=Zn[t],(e=la[e](t,n))&&(i=s&&be(e.name,s,i),r&&(le[r>>2]=i),a&&(le[a>>2]=e.size),o&&(le[o>>2]=e.type))}function Oi(e,t){ue[e>>2]=t,ue[e+4>>2]=(t-ue[e>>2])/4294967296}function Ai(e,t,n){if(t){var i=void 0;switch(e){case 36346:i=1;break;case 36344:return void(0!=n&&1!=n&&di(1280));case 34814:case 36345:i=0;break;case 34466:var r=la.getParameter(34467);i=r?r.length:0;break;case 33309:if(2>bi.version)return void di(1282);i=2*(la.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>bi.version)return void di(1280);i=33307==e?3:0}if(void 0===i)switch(r=la.getParameter(e),typeof r){case"number":i=r;break;case"boolean":i=r?1:0;break;case"string":return void di(1280);case"object":if(null===r)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:i=0;break;default:return void di(1280)}else{if(r instanceof Float32Array||r instanceof Uint32Array||r instanceof Int32Array||r instanceof Array){for(e=0;e<r.length;++e)switch(n){case 0:le[t+4*e>>2]=r[e];break;case 2:fe[t+4*e>>2]=r[e];break;case 4:ae[t+e>>0]=r[e]?1:0}return}try{i=0|r.name}catch(t){return di(1280),void te("GL_INVALID_ENUM in glGet"+n+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+t+")")}}break;default:return di(1280),void te("GL_INVALID_ENUM in glGet"+n+"v: Native code calling glGet"+n+"v("+e+") and it returns "+r+" of type "+typeof r+"!")}switch(n){case 1:Oi(t,i);break;case 0:le[t>>2]=i;break;case 2:fe[t>>2]=i;break;case 4:ae[t>>0]=i?1:0}}else di(1281)}function ji(e,t,n,i){if(n){switch(typeof(t=la.getIndexedParameter(e,t))){case"boolean":e=t?1:0;break;case"number":e=t;break;case"object":if(null===t)switch(e){case 35983:case 35368:e=0;break;default:return void di(1280)}else{if(!(t instanceof WebGLBuffer))return void di(1280);e=0|t.name}break;default:return void di(1280)}switch(i){case 1:Oi(n,e);break;case 0:le[n>>2]=e;break;case 2:fe[n>>2]=e;break;case 4:ae[n>>0]=e?1:0;break;default:throw"internal emscriptenWebGLGetIndexed() error, bad type: "+i}}else di(1281)}function Fi(e){var t=ke(e)+1,n=Pa(t);return be(e,n,t),n}function Mi(e){return"]"==e.slice(-1)&&e.lastIndexOf("[")}function Ii(e){var t,n=e.hl,i=e.yl;if(!n)for(e.hl=n={},e.Vl={},t=0;t<la.getProgramParameter(e,35718);++t){var r=la.getActiveUniform(e,t),a=r.name;r=r.size;var o=Mi(a);o=0<o?a.slice(0,o):a;var s=e.xl;for(e.xl+=r,i[o]=[r,s],a=0;a<r;++a)n[s]=a,e.Vl[s++]=o}}function Bi(e){var t=la.Hl;if(t){var n=t.hl[e];return"number"==typeof n&&(t.hl[e]=n=la.getUniformLocation(t,t.Vl[e]+(0<n?"["+n+"]":""))),n}di(1282)}function Wi(e,t,n,i){if(n)if(Ii(e=Zn[e]),"number"==typeof(e=la.getUniform(e,Bi(t)))||"boolean"==typeof e)switch(i){case 0:le[n>>2]=e;break;case 2:fe[n>>2]=e}else for(t=0;t<e.length;t++)switch(i){case 0:le[n+4*t>>2]=e[t];break;case 2:fe[n+4*t>>2]=e[t]}else di(1281)}function _i(e,t,n,i){if(n)if(e=la.getVertexAttrib(e,t),34975==t)le[n>>2]=e&&e.name;else if("number"==typeof e||"boolean"==typeof e)switch(i){case 0:le[n>>2]=e;break;case 2:fe[n>>2]=e;break;case 5:le[n>>2]=Math.fround(e)}else for(t=0;t<e.length;t++)switch(i){case 0:le[n+4*t>>2]=e[t];break;case 2:fe[n+4*t>>2]=e[t];break;case 5:le[n+4*t>>2]=Math.fround(e[t])}else di(1281)}function Di(e){return 0==(e-=5120)?ae:1==e?oe:2==e?se:4==e?le:6==e?fe:5==e||28922==e||28520==e||30779==e||30782==e?ue:ce}function Ri(e){return 31-Math.clz32(e.BYTES_PER_ELEMENT)}function Li(e,t){if(0>=e)return e;var n=32>=t?Math.abs(1<<t-1):Math.pow(2,t-1);return e>=n&&(32>=t||e>n)&&(e=-2*n+e),e}function Vi(e,t){return 0<=e?e:32>=t?2*Math.abs(1<<t-1)+e:Math.pow(2,t)+e}function Ui(e){for(var t=e;oe[t];)++t;return t-e}function zi(e,t){var n=Array(ke(e)+1);return e=ve(e,n,0,n.length),t&&(n.length=e),n}function Gi(e){if(!e||!e.callee||!e.callee.name)return[null,"",""];var t,n=e.callee.name,i="(",r=!0;for(t in e){var a=e[t];r||(i+=", "),r=!1,i="number"==typeof a||"string"==typeof a?i+a:i+"("+typeof a+")"}return i+=")",r&&(i=""),[e=(e=e.callee.caller)?e.arguments:[],n,i]}var Hi={};function Ni(){if(!$i){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(e in Hi)void 0===Hi[e]?delete t[e]:t[e]=Hi[e];var n=[];for(e in t)n.push(e+"="+t[e]);$i=n}return $i}var $i,Yi=[null,[],[]];function Ki(e,t){var n=Yi[e];0===t||10===t?((1===e?ee:te)(pe(n,0)),n.length=0):n.push(t)}var Xi=null,qi=null,Ji=null,Qi=null,Zi=null,er=null,tr=null,nr=null,ir=null,rr=null,ar=null,or={},sr=!1,cr=null,lr=null,ur=0,fr=null,dr=-1,hr=-1,mr=null,pr=null,gr=!1;function vr(e,t){pr?pr.segmentForVideo(e,performance.now(),(e=>{0<e.confidenceMasks.length&&fe.set(e.confidenceMasks[0].getAsFloat32Array(),t>>2)})):console.error("Trying to use mediaPipe segment but it is not initialized.")}async function br(){if(!pr&&!gr){console.log("DeepAR MediaPipe segmentation initialize started"),gr=!0,u||(u=await t.dynamicImports.mediaPipe()),mr||(mr=await u.FilesetResolver.forVisionTasks(t.segmentationConfig.mediaPipeConfig.wasmBasePath));var e=q("segmentationMediaPipe");e||(e=await J("segmentationMediaPipe")),pr=await u.ImageSegmenter.createFromOptions(mr,{runningMode:"VIDEO",baseOptions:{modelAssetBuffer:new Uint8Array(e)},outputConfidenceMasks:!0}),gr=!1,console.log("DeepAR MediaPipe segmentation initialized")}}var kr=!1,wr=null,yr=null,Pr=null,Sr=null,Tr=null;function Er(e){if(!kr&&null!=wr&&wr.isInitialized()){var t=yr.getVideoCanvas();t.width=e.width,t.height=e.height,yr.preProcessWithBuffer(e);try{wr.trackSync()}catch(e){return console.log(e),void(Pr=!1)}null!=(e=wr.getInterpolatedPose())&&wr.isDetected()?(Tr=e.t(),Sr=e.R(),Pr=!0):Pr=!1}}var xr=!1,Cr=null,Or=null,Ar=null,jr=null,Fr=null,Mr=null,Ir=null,Br=null;async function Wr(){if(l||(l=await t.dynamicImports.xzimg()),null==Cr&&(Cr=new l.Foot),null==Or&&(Or=new l.VideoManager(null)),!Cr.isInitialized()&&!xr){xr=!0,console.log("DeepAR FootTracking initialize started.");var e,n=q("footDetector");n||(e=J("footDetector"));var i,r=q("footTracker");r||(i=J("footTracker"));var a,o=q("footObj");o||(a=J("footObj")),n||(n=await e),r||(r=await i),o||(o=await a),await Cr.initialize(Or,{poseEstimationWasmFilename:t.footTrackingConfig.poseEstimationWasmPath,modelFilename:n,featuresFilename:r,objFilename:o,fovY:50,detectScoreThs:.25,validTrackedKeypThs:.3,trackScoreThs:.3,footToDetect:"BOTH",wasmBackend:{enable:!0,tfjsBackendWasmPath:t.footTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:t.footTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:t.footTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),xr=!1,console.log("DeepAR FootTracking initialized!")}}function _r(){return null!=Cr&&Cr.isInitialized()}function Dr(e){if(!xr&&null!=Cr&&Cr.isInitialized()){var t=Or.getVideoCanvas();t.width=e.width,t.height=e.height,Or.preProcessWithBuffer(e);try{Cr.trackSync()}catch(e){return console.log(e),void(Br=Fr=!1)}e=Cr.getInterpolatedPose("LEFT_FOOT"),t=Cr.getInterpolatedPose("RIGHT_FOOT"),null!=e&&e.isDetected()?(Ar=e.t(),jr=e.R(),Fr=!0):Fr=!1,null!=t&&t.isDetected()?(Mr=t.t(),Ir=t.R(),Br=!0):Br=!1}}var Rr=null,Lr=null,Vr=null,Ur=!1;function zr(e,t){if(Rr.isInitialized()){var n=Lr.getVideoCanvas();n.width=e.width,n.height=e.height,Lr.preProcessWithBuffer(e),Rr.processSync(),Vr=Rr.getOutput(),Lr.postProcess(),fe.set(Vr,t>>2)}}async function Gr(){if(l||(l=await t.dynamicImports.xzimg()),null==Rr&&(Rr=new l.Segmentation),null==Lr&&(Lr=new l.VideoManager(null)),!Rr.isInitialized()&&!Ur){console.log("DeepAR segmentation initialize started"),Ur=!0;var e=q("segmentationXzimg");e||(e=await J("segmentationXzimg")),await Rr.initialize(Lr,{filename:e}),Ur=!1,console.log("DeepAR segmentation initialized")}}function Hr(){return null!=Rr&&Rr.isInitialized()}var Nr=!1,$r=null,Yr=null,Kr=null,Xr=null,qr=null,Jr=0,Qr=0;function Zr(){return null!=$r&&$r.isInitialized()}function ea(e){if(Zr()){var t=Yr.getVideoCanvas();t.width=e.width,t.height=e.height,Yr.preProcessWithBuffer(e);try{$r.trackSync()}catch(e){return console.log(e),void(Kr=!1)}e=!1,$r.isDetected()?(++Jr>Qr&&(e=!0),(Kr=e)&&(e=$r.getInterpolatedPose(),Xr=e.t(),qr=e.R())):(Jr=0,Kr=!1)}}function ta(e,t){for(var n=0,i=0;i<=t;n+=e[i++]);return n}var na=[31,29,31,30,31,30,31,31,30,31,30,31],ia=[31,28,31,30,31,30,31,31,30,31,30,31];function ra(e,t){for(e=new Date(e.getTime());0<t;){var n=e.getMonth(),i=(tn(e.getFullYear())?na:ia)[n];if(!(t>i-e.getDate())){e.setDate(e.getDate()+t);break}t-=i-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function aa(e,t,n,i){function r(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function a(e,t){return r(e,t,"0")}function o(e,t){function n(e){return 0>e?-1:0<e?1:0}var i;return 0===(i=n(e.getFullYear()-t.getFullYear()))&&0===(i=n(e.getMonth()-t.getMonth()))&&(i=n(e.getDate()-t.getDate())),i}function s(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function c(e){e=ra(new Date(e.gl+1900,0,1),e.fl);var t=new Date(e.getFullYear()+1,0,4),n=s(new Date(e.getFullYear(),0,4));return t=s(t),0>=o(n,e)?0>=o(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=le[i+40>>2];for(var u in i={Ym:le[i>>2],Xm:le[i+4>>2],vl:le[i+8>>2],Fl:le[i+12>>2],wl:le[i+16>>2],gl:le[i+20>>2],Tk:le[i+24>>2],fl:le[i+28>>2],In:le[i+32>>2],Wm:le[i+36>>2],Zm:l?ge(l):""},n=ge(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(u,"g"),l[u]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(u in l={"%a":function(e){return f[e.Tk].substring(0,3)},"%A":function(e){return f[e.Tk]},"%b":function(e){return d[e.wl].substring(0,3)},"%B":function(e){return d[e.wl]},"%C":function(e){return a((e.gl+1900)/100|0,2)},"%d":function(e){return a(e.Fl,2)},"%e":function(e){return r(e.Fl,2," ")},"%g":function(e){return c(e).toString().substring(2)},"%G":function(e){return c(e)},"%H":function(e){return a(e.vl,2)},"%I":function(e){return 0==(e=e.vl)?e=12:12<e&&(e-=12),a(e,2)},"%j":function(e){return a(e.Fl+ta(tn(e.gl+1900)?na:ia,e.wl-1),3)},"%m":function(e){return a(e.wl+1,2)},"%M":function(e){return a(e.Xm,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.vl&&12>e.vl?"AM":"PM"},"%S":function(e){return a(e.Ym,2)},"%t":function(){return"\t"},"%u":function(e){return e.Tk||7},"%U":function(e){return a(Math.floor((e.fl+7-e.Tk)/7),2)},"%V":function(e){var t=Math.floor((e.fl+7-(e.Tk+6)%7)/7);if(2>=(e.Tk+371-e.fl-2)%7&&t++,t)53==t&&(4==(n=(e.Tk+371-e.fl)%7)||3==n&&tn(e.gl)||(t=1));else{t=52;var n=(e.Tk+7-e.fl-1)%7;(4==n||5==n&&tn(e.gl%400-1))&&t++}return a(t,2)},"%w":function(e){return e.Tk},"%W":function(e){return a(Math.floor((e.fl+7-(e.Tk+6)%7)/7),2)},"%y":function(e){return(e.gl+1900).toString().substring(2)},"%Y":function(e){return e.gl+1900},"%z":function(e){var t=0<=(e=e.Wm);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Zm},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(u)&&(n=n.replace(new RegExp(u,"g"),l[u](i)));return(u=zi(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(ae.set(u,e),u.length-1)}function oa(e,n,i,r){var a=!i||i.every((e=>"number"===e||"boolean"===e));return"string"!==n&&a&&!r?t["_"+e]:function(){return function(e,n,i,r){var a={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);be(e,t=Fa(n),n)}return t},array:e=>{var t=Fa(e.length);return ae.set(e,t),t}};e=t["_"+e];var o,s=[],c=0;if(r)for(var l=0;l<r.length;l++){var u=a[i[l]];u?(0===c&&(c=Aa()),s[l]=u(r[l])):s[l]=r[l]}return o=i=e.apply(null,s),0!==c&&ja(c),"string"===n?ge(o):"boolean"===n?!!o:o}(e,n,i,arguments)}}tt=t.InternalError=et("InternalError");for(var sa=Array(256),ca=0;256>ca;++ca)sa[ca]=String.fromCharCode(ca);at=sa,st=t.BindingError=et("BindingError"),Pt.prototype.isAliasOf=function(e){if(!(this instanceof Pt&&e instanceof Pt))return!1;var t=this.Ek.Ik.Gk,n=this.Ek.Fk,i=e.Ek.Ik.Gk;for(e=e.Ek.Fk;t.Sk;)n=t.ql(n),t=t.Sk;for(;i.Sk;)e=i.ql(e),i=i.Sk;return t===i&&n===e},Pt.prototype.clone=function(){if(this.Ek.Fk||ut(this),this.Ek.pl)return this.Ek.count.value+=1,this;var e=yt,t=Object,n=t.create,i=Object.getPrototypeOf(this),r=this.Ek;return(e=e(n.call(t,i,{Ek:{value:{count:r.count,jl:r.jl,pl:r.pl,Fk:r.Fk,Ik:r.Ik,Nk:r.Nk,Pk:r.Pk}}}))).Ek.count.value+=1,e.Ek.jl=!1,e},Pt.prototype.delete=function(){this.Ek.Fk||ut(this),this.Ek.jl&&!this.Ek.pl&&ct("Object already scheduled for deletion"),dt(this),ht(this.Ek),this.Ek.pl||(this.Ek.Nk=void 0,this.Ek.Fk=void 0)},Pt.prototype.isDeleted=function(){return!this.Ek.Fk},Pt.prototype.deleteLater=function(){return this.Ek.Fk||ut(this),this.Ek.jl&&!this.Ek.pl&&ct("Object already scheduled for deletion"),gt.push(this),1===gt.length&&bt&&bt(vt),this.Ek.jl=!0,this},t.getInheritedInstanceCount=function(){return Object.keys(kt).length},t.getLiveInheritedInstances=function(){var e,t=[];for(e in kt)kt.hasOwnProperty(e)&&t.push(kt[e]);return t},t.flushPendingDeletes=vt,t.setDelayFunction=function(e){bt=e,gt.length&&bt&&bt(vt)},jt.prototype.Fm=function(e){return this.Pl&&(e=this.Pl(e)),e},jt.prototype.Il=function(e){this.Xk&&this.Xk(e)},jt.prototype.argPackAdvance=8,jt.prototype.readValueFromPointer=Ke,jt.prototype.deleteObject=function(e){null!==e&&e.delete()},jt.prototype.fromWireType=function(e){function t(){return this.tl?wt(this.Gk.kl,{Ik:this.Nm,Fk:n,Pk:this,Nk:e}):wt(this.Gk.kl,{Ik:this,Fk:e})}var n=this.Fm(e);if(!n)return this.Il(e),null;var i=function(e,t){for(void 0===t&&ct("ptr should not be undefined");e.Sk;)t=e.ql(t),e=e.Sk;return kt[t]}(this.Gk,n);if(void 0!==i)return 0===i.Ek.count.value?(i.Ek.Fk=n,i.Ek.Nk=e,i.clone()):(i=i.clone(),this.Il(e),i);if(i=this.Gk.Cm(n),!(i=pt[i]))return t.call(this);i=this.sl?i.ym:i.pointerType;var r=mt(n,this.Gk,i.Gk);return null===r?t.call(this):this.tl?wt(i.Gk.kl,{Ik:i,Fk:r,Pk:this,Nk:e}):wt(i.Gk.kl,{Ik:i,Fk:r})},Bt=t.UnboundTypeError=et("UnboundTypeError"),t.count_emval_handles=function(){for(var e=0,t=5;t<Vt.length;++t)void 0!==Vt[t]&&++e;return e},t.get_first_emval=function(){for(var e=5;e<Vt.length;++e)if(void 0!==Vt[e])return Vt[e];return null},t.requestFullscreen=function(e,n){!function(e,n){function i(){Cn=!1;var e=r.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(r.exitFullscreen=In,Fn&&r.requestPointerLock(),Cn=!0,Mn?("undefined"!=typeof SDL&&(le[SDL.screen>>2]=8388608|ue[SDL.screen>>2]),Ln(t.canvas),Rn()):Ln(r)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e),Mn?("undefined"!=typeof SDL&&(le[SDL.screen>>2]=-8388609&ue[SDL.screen>>2]),Ln(t.canvas),Rn()):Ln(r)),t.onFullScreen&&t.onFullScreen(Cn),t.onFullscreen&&t.onFullscreen(Cn)}void 0===(Fn=e)&&(Fn=!0),void 0===(Mn=n)&&(Mn=!1);var r=t.canvas;jn||(jn=!0,document.addEventListener("fullscreenchange",i,!1),document.addEventListener("mozfullscreenchange",i,!1),document.addEventListener("webkitfullscreenchange",i,!1),document.addEventListener("MSFullscreenChange",i,!1));var a=document.createElement("div");r.parentNode.insertBefore(a,r),a.appendChild(r),a.requestFullscreen=a.requestFullscreen||a.mozRequestFullScreen||a.msRequestFullscreen||(a.webkitRequestFullscreen?()=>a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):null)||(a.webkitRequestFullScreen?()=>a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):null),a.requestFullscreen()}(e,n)},t.requestAnimationFrame=function(e){Wn(e)},t.setCanvasSize=function(e,n,i){Ln(t.canvas,e,n),i||Rn()},t.pauseMainLoop=function(){kn=null,wn++},t.resumeMainLoop=function(){wn++;var e=Pn,n=Sn,i=yn;yn=null,function(e){function n(){return!(i<wn&&(--Oe,fn(),1))}!yn||Me("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."),yn=e;var i=wn;bn=!1,gn=function(){if(!he)if(0<En.length){var i=Date.now(),r=En.shift();if(r.wn(r.sn),vn){var a=vn,o=0==a%1?a-1:Math.floor(a);vn=r.tn?o:(8*a+(o+.5))/9}ee('main loop blocker "'+r.name+'" took '+(Date.now()-i)+" ms"),t.setStatus&&(i=t.statusMessage||"Please wait...",a=xn.vn,(r=vn)?r<a?t.setStatus(i+" ("+(a-r)+"/"+a+")"):t.setStatus(i):t.setStatus("")),n()&&setTimeout(gn,0)}else n()&&(Tn=Tn+1|0,1==Pn&&1<Sn&&0!=Tn%Sn?kn():(0==Pn&&(pn=nn()),he||t.preMainLoop&&!1===t.preMainLoop()||(dn(e),t.postMainLoop&&t.postMainLoop()),n()&&("object"==typeof SDL&&SDL.audio&&SDL.audio.Pm&&SDL.audio.Pm(),kn())))}}(i),cn(e,n),kn()},t.getUserMedia=function(){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(void 0)},t.createContext=function(e,n,i,r){return function(e,n,i,r){if(n&&t.dl&&e==t.canvas)return t.dl;var a;if(n){var o={antialias:!1,alpha:!1,Al:2};if(r)for(var s in r)o[s]=r[s];if(void 0!==ki&&(a=pi(e,o)))var c=ai[a].il}else c=e.getContext("2d");return c?(i&&(n||void 0===la||Me("cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),t.dl=c,n&&gi(a),t.$m=n,An.forEach((function(e){e()})),function(){function e(){On=document.pointerLockElement===t.canvas||document.mozPointerLockElement===t.canvas||document.webkitPointerLockElement===t.canvas||document.msPointerLockElement===t.canvas}if(t.preloadPlugins||(t.preloadPlugins=[]),!Vn){Vn=!0;try{Un=!0}catch(e){Un=!1,te("warning: no blob constructor, cannot create blobs with mimetypes")}zn="undefined"!=typeof MozBlobBuilder?MozBlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:Un?null:te("warning: no BlobBuilder"),Gn="undefined"!=typeof window?window.URL?window.URL:window.webkitURL:void 0,t.Nl||void 0!==Gn||(te("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),t.Nl=!0),t.preloadPlugins.push({canHandle:function(e){return!t.Nl&&/\.(jpg|jpeg|png|bmp)$/i.test(e)},handle:function(e,t,n,i){var r=null;if(Un)try{(r=new Blob([e],{type:_n(t)})).size!==e.length&&(r=new Blob([new Uint8Array(e).buffer],{type:_n(t)}))}catch(e){hn("Blob constructor present but fails: "+e+"; falling back to blob builder")}r||((r=new zn).append(new Uint8Array(e).buffer),r=r.getBlob());var a=Gn.createObjectURL(r),o=new Image;o.onload=()=>{o.complete||Me("Image "+t+" could not be decoded");var i=document.createElement("canvas");i.width=o.width,i.height=o.height,i.getContext("2d").drawImage(o,0,0),Gn.revokeObjectURL(a),n&&n(e)},o.onerror=()=>{ee("Image "+a+" could not be decoded"),i&&i()},o.src=a}}),t.preloadPlugins.push({canHandle:function(e){return!t.Dn&&e.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},handle:function(e,t,n,i){function r(){o||(o=!0,n&&n(e))}function a(){o||(o=!0,new Audio,i&&i())}var o=!1;if(!Un)return a();try{var s=new Blob([e],{type:_n(t)})}catch(e){return a()}s=Gn.createObjectURL(s);var c=new Audio;c.addEventListener("canplaythrough",(()=>r()),!1),c.onerror=function(){if(!o){te("warning: browser could not fully decode audio "+t+", trying slower base64 approach");for(var n="",i=0,a=0,s=0;s<e.length;s++)for(i=i<<8|e[s],a+=8;6<=a;){var l=i>>a-6&63;a-=6,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[l]}2==a?(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&i)<<4],n+="=="):4==a&&(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&i)<<2],n+="="),c.src="data:audio/x-"+t.substr(-3)+";base64,"+n,r()}},c.src=s,function(e){Oe+=1,setTimeout((function(){--Oe,dn(e)}),1e4)}((function(){r()}))}});var n=t.canvas;n&&(n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock||n.webkitRequestPointerLock||n.msRequestPointerLock||(()=>{}),n.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||(()=>{}),n.exitPointerLock=n.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",e,!1),document.addEventListener("mozpointerlockchange",e,!1),document.addEventListener("webkitpointerlockchange",e,!1),document.addEventListener("mspointerlockchange",e,!1),t.elementPointerLock&&n.addEventListener("click",(e=>{!On&&t.canvas.requestPointerLock&&(t.canvas.requestPointerLock(),e.preventDefault())}),!1))}}()),c):null}(e,n,i,r)};for(var la,ua=0;32>ua;++ua)Ti.push(Array(ua));(cr=document.createElement("canvas")).style.display="none",lr=cr.getContext("2d",{willReadFrequently:!0,desynchronized:!0,alpha:!1});e:{if(!window.AudioContext){if(!window.webkitAudioContext){console.error("Audio playback is not supported!");break e}window.AudioContext=window.webkitAudioContext}rr=new AudioContext,(ar=rr.createGain()).connect(rr.destination),sr=!0}var fa,da,ha,ma={l:function(e,t,n,i){Me("Assertion failed: "+ge(e)+", at: "+[t?ge(t):"unknown filename",n,i?ge(i):"unknown function"])},m:function(e){return(e=new He(e)).$k()||(e.Dl(!0),Ue--),e.El(!1),Ve.push(e),e.Yk(),e.al()},w:function(){Oa(0);var e=Ve.pop();if(e.Rm()&&!e.Ll()){var t=e.Gm();t&&Ge(t)(e.ol),ga(e.ol)}ze=0},a:Ne,c:Ne,f:Ne,ba:Ne,mb:function(){var e=Ve.pop();e||Me("no exception to throw");var t=e.ol;throw e.Ll()||(Ve.push(e),e.El(!0),e.Dl(!1),Ue++),ze=t,t},I:function(e,t,n){throw new He(e).ll(t,n),ze=e,Ue++,e},tc:function(){return Ue},e:function(e){throw ze||(ze=e),e},Ia:function(){return 0},Ac:function(){return 0},Bc:function(){},Mh:function(e){var t=$e[e];delete $e[e];var n=t.Bl,i=t.Xk,r=t.Kl;it([e],r.map((e=>e.Jm)).concat(r.map((e=>e.Tm))),(e=>{var a={};return r.forEach(((t,n)=>{var i=e[n],o=t.Hm,s=t.Im,c=e[n+r.length],l=t.Sm,u=t.Um;a[t.Bm]={read:e=>i.fromWireType(o(s,e)),write:(e,t)=>{var n=[];l(u,e,c.toWireType(n,t)),Ye(n)}}})),[{name:t.name,fromWireType:function(e){var t,n={};for(t in a)n[t]=a[t].read(e);return i(e),n},toWireType:function(e,t){for(var r in a)if(!(r in t))throw new TypeError('Missing field: "'+r+'"');var o=n();for(r in a)a[r].write(o,t[r]);return null!==e&&e.push(i,o),o},argPackAdvance:8,readValueFromPointer:Ke,Ok:i}]}))},hc:function(){},ei:function(e,t,n,i,r){var a=rt(n);lt(e,{name:t=ot(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:r},argPackAdvance:8,readValueFromPointer:function(e){if(1===n)var i=ae;else if(2===n)i=se;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+t);i=le}return this.fromWireType(i[e>>a])},Ok:null})},gh:function(e,t,n,i,r,a,o,s,c,l,u,f,d){u=ot(u),a=It(r,a),s&&(s=It(o,s)),l&&(l=It(c,l)),d=It(f,d);var h=Qe(u);Tt(h,(function(){_t("Cannot construct "+u+" due to unbound types",[i])})),it([e,t,n],i?[i]:[],(function(t){if(t=t[0],i)var n=t.Gk,r=n.kl;else r=Pt.prototype;t=Ze(h,(function(){if(Object.getPrototypeOf(this)!==o)throw new st("Use 'new' to construct "+u);if(void 0===c.cl)throw new st(u+" has no accessible constructor");var e=c.cl[arguments.length];if(void 0===e)throw new st("Tried to invoke ctor of "+u+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(c.cl).toString()+") parameters instead!");return e.apply(this,arguments)}));var o=Object.create(r,{constructor:{value:t}});t.prototype=o;var c=new Et(u,t,o,d,n,a,s,l);n=new jt(u,c,!0,!1),r=new jt(u+"*",c,!1,!1);var f=new jt(u+" const*",c,!1,!0);return pt[e]={pointerType:r,ym:f},Ft(h,t),[n,r,f]}))},Xg:function(e,t,n,i,r,a){0<t||Me();var o=Dt(t,n);r=It(i,r),it([],[e],(function(e){var n="constructor "+(e=e[0]).name;if(void 0===e.Gk.cl&&(e.Gk.cl=[]),void 0!==e.Gk.cl[t-1])throw new st("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.Gk.cl[t-1]=()=>{_t("Cannot construct "+e.name+" due to unbound types",o)},it([],o,(function(i){return i.splice(1,0,null),e.Gk.cl[t-1]=Rt(n,i,null,r,a),[]})),[]}))},_:function(e,t,n,i,r,a,o,s){var c=Dt(n,i);t=ot(t),a=It(r,a),it([],[e],(function(e){function i(){_t("Cannot call "+r+" due to unbound types",c)}var r=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.Gk.Om.push(t);var l=e.Gk.kl,u=l[t];return void 0===u||void 0===u.Kk&&u.className!==e.name&&u.rl===n-2?(i.rl=n-2,i.className=e.name,l[t]=i):(St(l,t,r),l[t].Kk[n-2]=i),it([],c,(function(i){return i=Rt(r,i,e,a,o),void 0===l[t].Kk?(i.rl=n-2,l[t]=i):l[t].Kk[n-2]=i,[]})),[]}))},di:function(e,t){lt(e,{name:t=ot(t),fromWireType:function(e){e||ct("Cannot use deleted val. handle = "+e);var t=Vt[e].value;return Ut(e),t},toWireType:function(e,t){return zt(t)},argPackAdvance:8,readValueFromPointer:Ke,Ok:null})},ji:function(e,t,n,i){function r(){}n=rt(n),t=ot(t),r.values={},lt(e,{name:t,constructor:r,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:Gt(t,n,i),Ok:null}),Tt(t,r)},sa:function(e,t,n){var i=Ht(e,"enum");t=ot(t),e=i.constructor,i=Object.create(i.constructor.prototype,{value:{value:n},constructor:{value:Ze(i.name+"_"+t,(function(){}))}}),e.values[n]=i,e[t]=i},La:function(e,t,n){n=rt(n),lt(e,{name:t=ot(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:$t(t,n),Ok:null})},Bh:function(e,t,n,i,r,a){var o=Dt(t,n);e=ot(e),r=It(i,r),Tt(e,(function(){_t("Cannot call "+e+" due to unbound types",o)}),t-1),it([],o,(function(n){return Ft(e,Rt(e,[n[0],null].concat(n.slice(1)),null,r,a),t-1),[]}))},O:function(e,t,n,i,r){t=ot(t),-1===r&&(r=4294967295),r=rt(n);var a=e=>e;if(0===i){var o=32-8*n;a=e=>e<<o>>>o}n=t.includes("unsigned")?function(e,t){return t>>>0}:function(e,t){return t},lt(e,{name:t,fromWireType:a,toWireType:n,argPackAdvance:8,readValueFromPointer:Yt(t,r,0!==i),Ok:null})},G:function(e,t,n){function i(e){e>>=2;var t=ue;return new r(t.buffer,t[e+1],t[e])}var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];lt(e,{name:n=ot(n),fromWireType:i,argPackAdvance:8,readValueFromPointer:i},{Lm:!0})},Ka:function(e,t){var n="std::string"===(t=ot(t));lt(e,{name:t,fromWireType:function(e){var t=ue[e>>2],i=e+4;if(n)for(var r=i,a=0;a<=t;++a){var o=i+a;if(a==t||0==oe[o]){if(r=ge(r,o-r),void 0===s)var s=r;else s+=String.fromCharCode(0),s+=r;r=o+1}}else{for(s=Array(t),a=0;a<t;++a)s[a]=String.fromCharCode(oe[i+a]);s=s.join("")}return Sa(e),s},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var i,r="string"==typeof t;r||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||ct("Cannot pass non-string to std::string"),i=n&&r?ke(t):t.length;var a=Pa(4+i+1),o=a+4;if(ue[a>>2]=i,n&&r)be(t,o,i+1);else if(r)for(r=0;r<i;++r){var s=t.charCodeAt(r);255<s&&(Sa(o),ct("String has UTF-16 code units that do not fit in 8 bits")),oe[o+r]=s}else for(r=0;r<i;++r)oe[o+r]=t[r];return null!==e&&e.push(Sa,a),a},argPackAdvance:8,readValueFromPointer:Ke,Ok:function(e){Sa(e)}})},ra:function(e,t,n){if(n=ot(n),2===t)var i=Xt,r=qt,a=Jt,o=()=>ce,s=1;else 4===t&&(i=Qt,r=Zt,a=en,o=()=>ue,s=2);lt(e,{name:n,fromWireType:function(e){for(var n,r=ue[e>>2],a=o(),c=e+4,l=0;l<=r;++l){var u=e+4+l*t;l!=r&&0!=a[u>>s]||(c=i(c,u-c),void 0===n?n=c:(n+=String.fromCharCode(0),n+=c),c=u+t)}return Sa(e),n},toWireType:function(e,i){"string"!=typeof i&&ct("Cannot pass non-string to C++ string type "+n);var o=a(i),c=Pa(4+o+t);return ue[c>>2]=o>>s,r(i,c+4,o+t),null!==e&&e.push(Sa,c),c},argPackAdvance:8,readValueFromPointer:Ke,Ok:function(e){Sa(e)}})},Xh:function(e,t,n,i,r,a){$e[e]={name:ot(t),Bl:It(n,i),Xk:It(r,a),Kl:[]}},Ja:function(e,t,n,i,r,a,o,s,c,l){$e[e].Kl.push({Bm:ot(t),Jm:n,Hm:It(i,r),Im:a,Tm:o,Sm:It(s,c),Um:l})},fi:function(e,t){lt(e,{yn:!0,name:t=ot(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Cc:function(){return!0},uc:function(){throw 1/0},gg:Ut,rg:function(e){4<e&&(Vt[e].Cl+=1)},Cg:function(e,t){return e=(e=Ht(e,"_emval_take_value")).readValueFromPointer(t),zt(e)},Ec:function(e,t){e=new Date(1e3*(ue[e>>2]+4294967296*le[e+4>>2])),le[t>>2]=e.getUTCSeconds(),le[t+4>>2]=e.getUTCMinutes(),le[t+8>>2]=e.getUTCHours(),le[t+12>>2]=e.getUTCDate(),le[t+16>>2]=e.getUTCMonth(),le[t+20>>2]=e.getUTCFullYear()-1900,le[t+24>>2]=e.getUTCDay(),le[t+28>>2]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Fc:function(e,t){e=new Date(1e3*(ue[e>>2]+4294967296*le[e+4>>2])),le[t>>2]=e.getSeconds(),le[t+4>>2]=e.getMinutes(),le[t+8>>2]=e.getHours(),le[t+12>>2]=e.getDate(),le[t+16>>2]=e.getMonth(),le[t+20>>2]=e.getFullYear()-1900,le[t+24>>2]=e.getDay(),le[t+28>>2]=0|on(e),le[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset(),i=new Date(e.getFullYear(),0,1).getTimezoneOffset();le[t+32>>2]=0|(n!=i&&e.getTimezoneOffset()==Math.min(i,n))},Gc:function(e){var t=new Date(le[e+20>>2]+1900,le[e+16>>2],le[e+12>>2],le[e+8>>2],le[e+4>>2],le[e>>2],0),n=le[e+32>>2],i=t.getTimezoneOffset(),r=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=new Date(t.getFullYear(),0,1).getTimezoneOffset(),o=Math.min(a,r);return 0>n?le[e+32>>2]=Number(r!=a&&o==i):0<n!=(o==i)&&(r=Math.max(a,r),t.setTime(t.getTime()+6e4*((0<n?o:r)-i))),le[e+24>>2]=t.getDay(),le[e+28>>2]=0|on(t),le[e>>2]=t.getSeconds(),le[e+4>>2]=t.getMinutes(),le[e+8>>2]=t.getHours(),le[e+12>>2]=t.getDate(),le[e+16>>2]=t.getMonth(),le[e+20>>2]=t.getYear(),t.getTime()/1e3|0},Hc:function(e,t,n){function i(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}var r=(new Date).getFullYear(),a=new Date(r,0,1),o=new Date(r,6,1);r=a.getTimezoneOffset();var s=o.getTimezoneOffset();ue[e>>2]=60*Math.max(r,s),le[t>>2]=Number(r!=s),e=i(a),t=i(o),e=sn(e),t=sn(t),s<r?(ue[n>>2]=e,ue[n+4>>2]=t):(ue[n>>2]=t,ue[n+4>>2]=e)},N:function(){Me("")},Le:function(e){function t(e,i){var r=n();return(t=function(e){return r[e-126]})(e,i)}function n(){var e='1622448FwHHkL;3580437iFskTa;jtiiU;hostname;NTLlh;4FiMkcw;vAmev;chrome;2061824xbyuIE;{}.constru;charCodeAt;650365DMaCYo;ctor("retu;242177QkfeEY;return (fu;runtime;3080rvIxLr;21816dvsUMq;rn this")(;eanCS;location;264170XmkpEM;document;domain;9bLcYaP'.split(";");return(n=function(){return e})()}var i=t;!function(e,n){var i=t;for(e=e();;)try{if(parseInt(i(143))+parseInt(i(126))/2*(parseInt(i(129))/3)+parseInt(i(135))/4*(-parseInt(i(141))/5)+parseInt(i(130))/6+parseInt(i(131))/7+-parseInt(i(138))/8+parseInt(i(147))/9*(-parseInt(i(146))/10)===285938)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(n);var r=function(){var e=t,n={NTLlh:function(e,t){return e(t)},jtiiU:function(e,t){return e+t},eanCS:e(144)+"nction() ",vAmev:e(139)+e(142)+e(148)+" )"};try{var i=n[e(134)](Function,n[e(132)](n[e(149)],n[e(136)])+");")()}catch(e){i=window}return i}();return r.document[i(128)]?r[i(127)].domain[i(140)](e):r[i(150)][i(133)]?r[i(150)][i(133)].charCodeAt(e):r[i(137)][i(145)].id?r[i(137)][i(145)].id.charCodeAt(e):void 0},Ri:function(e,t,n,i,r){if(62e3!=e)n=0;else{if(t)for(;;){if(12321==(e=le[t>>2]))Xn.alpha=0<le[t+4>>2];else if(12325==e)Xn.depth=0<le[t+4>>2];else if(12326==e)Xn.stencil=0<le[t+4>>2];else if(12337==e)e=le[t+4>>2],Xn.antialias=0<e;else if(12338==e)e=le[t+4>>2],Xn.antialias=1==e;else if(12544==e)Xn.zn=12547!=le[t+4>>2];else if(12344==e)break;t+=8}n&&i||r?(r&&(le[r>>2]=1),n&&0<i&&(le[n>>2]=62002),n=1):n=0}return n},hb:function(e,n,i,r){if(62e3!=e)return 0;for(e=1;;){if(12440!=(n=le[r>>2])){if(12344==n)break;return 0}e=le[r+4>>2],r+=8}return 2>e||3<e?0:(Xn.Al=e-1,Xn.Bn=0,0!=(Hn=pi(t.canvas,Xn))?(gi(Hn),t.$m=!0,An.forEach((function(e){e()})),gi(null),62004):0)},ib:function(e,t){return 62e3!=e||62002!=t?0:62006},gb:function(e,t){return 62e3!=e||62004!=t?0:(bi===ai[e=Hn]&&(bi=null),"object"==typeof JSEvents&&JSEvents.Gn(ai[e].il.canvas),ai[e]&&ai[e].il.canvas&&(ai[e].il.canvas.Xl=void 0),ai[e]=null,$n==t&&($n=0),1)},fb:function(e,t){return 62e3!=e?0:(62006!=t||(Yn==t&&(Yn=0),Kn==t&&(Kn=0)),1)},Ti:function(){return 62e3},Si:function(e,t,n){return 62e3!=e?0:(t&&(le[t>>2]=1),n&&(le[n>>2]=4),Nn=!0,1)},R:function(e,t,n,i){return 62e3!=e||0!=i&&62004!=i||0!=n&&62006!=n||0!=t&&62006!=t?0:(gi(i?Hn:null),$n=i,Kn=t,Yn=n,1)},la:function(e,t){if(62e3!=e)return 0;if(qn[t])return qn[t];switch(t){case 12371:e=sn("Emscripten");break;case 12372:e=sn("1.4 Emscripten EGL");break;case 12373:e=sn("");break;case 12429:e=sn("OpenGL_ES");break;default:return 0}return qn[t]=e},eb:function(){return Nn&&t.dl&&!t.dl.isContextLost()?1:0},db:function(e,t){return 62e3!=e?0:(0==t?cn(0,0):cn(1,t),1)},Qi:function(e){return 62e3!=e?0:(Kn=Yn=$n=0,Nn=!1,1)},u:yi,hd:yi,qc:function(e,t,n,i,r,a,o,s){function c(){if(o){var e=0;if(u.statusText){var t=ke(u.statusText)+1;e=Fa(t),be(u.statusText,e,t)}Ge(o)(f,i,u.status,e)}}var l=ge(e);e=ge(t),n=ge(n);var u=new XMLHttpRequest;u.open(e,l,!0),u.responseType="arraybuffer";var f=function(){var e=Si;return Si++,e}();return u.onload=function(){if(200<=u.status&&300>u.status||0===u.status&&"http"!=l.substr(0,4).toLowerCase()){var e=new Uint8Array(u.response),t=Pa(e.length);oe.set(e,t),a&&Ge(a)(f,i,t,e.length),r&&Sa(t)}else c();delete Pi[f]},u.onerror=function(){c(),delete Pi[f]},u.onprogress=function(e){s&&Ge(s)(f,i,e.loaded,e.lengthComputable||void 0===e.lengthComputable?e.total:0)},u.onabort=function(){delete Pi[f]},"POST"==e?(u.setRequestHeader("Content-type","application/x-www-form-urlencoded"),u.send(n)):u.send(null),Pi[f]=u,f},qa:function(){return Date.now()},Nf:function(e){ne=!1,Oe=0,ln(e)},wc:function(){return 2147483648},ma:nn,Jh:function(e){la.activeTexture(e)},Ih:function(e,t){la.attachShader(Zn[e],ii[t])},Be:function(e,t){la.beginQuery(e,oi[t])},$h:function(e,t){la.Mk.beginQueryEXT(e,oi[t])},he:function(e){la.beginTransformFeedback(e)},Hh:function(e,t,n){la.bindAttribLocation(Zn[e],t,ge(n))},Gh:function(e,t){35051==e?la.el=t:35052==e&&(la.Jk=t),la.bindBuffer(e,Qn[t])},ee:function(e,t,n){la.bindBufferBase(e,t,Qn[n])},fe:function(e,t,n,i,r){la.bindBufferRange(e,t,Qn[n],i,r)},Fh:function(e,t){la.bindFramebuffer(e,ei[t])},Eh:function(e,t){la.bindRenderbuffer(e,ti[t])},ld:function(e,t){la.bindSampler(e,si[t])},Dh:function(e,t){la.bindTexture(e,ni[t])},cd:function(e,t){la.bindTransformFeedback(e,ci[t])},me:function(e){la.bindVertexArray(ri[e])},Sh:function(e){la.bindVertexArray(ri[e])},Ch:function(e,t,n,i){la.blendColor(e,t,n,i)},Ah:function(e){la.blendEquation(e)},zh:function(e,t){la.blendEquationSeparate(e,t)},yh:function(e,t){la.blendFunc(e,t)},xh:function(e,t,n,i){la.blendFuncSeparate(e,t,n,i)},pe:function(e,t,n,i,r,a,o,s,c,l){la.blitFramebuffer(e,t,n,i,r,a,o,s,c,l)},wh:function(e,t,n,i){n&&t?la.bufferData(e,oe,i,n,t):la.bufferData(e,t,i)},vh:function(e,t,n,i){n&&la.bufferSubData(e,t,oe,i,n)},uh:function(e){return la.checkFramebufferStatus(e)},th:function(e){la.clear(e)},Jd:function(e,t,n,i){la.clearBufferfi(e,t,n,i)},Kd:function(e,t,n){la.clearBufferfv(e,t,fe,n>>2)},Md:function(e,t,n){la.clearBufferiv(e,t,le,n>>2)},Ld:function(e,t,n){la.clearBufferuiv(e,t,ue,n>>2)},sh:function(e,t,n,i){la.clearColor(e,t,n,i)},rh:function(e){la.clearDepth(e)},qh:function(e){la.clearStencil(e)},ud:function(e,t,n,i){return la.clientWaitSync(li[e],t,(n>>>0)+4294967296*i)},ph:function(e,t,n,i){la.colorMask(!!e,!!t,!!n,!!i)},oh:function(e){la.compileShader(ii[e])},nh:function(e,t,n,i,r,a,o,s){la.Jk||!o?la.compressedTexImage2D(e,t,n,i,r,a,o,s):la.compressedTexImage2D(e,t,n,i,r,a,oe,s,o)},Ge:function(e,t,n,i,r,a,o,s,c){la.Jk?la.compressedTexImage3D(e,t,n,i,r,a,o,s,c):la.compressedTexImage3D(e,t,n,i,r,a,o,oe,c,s)},mh:function(e,t,n,i,r,a,o,s,c){la.Jk||!s?la.compressedTexSubImage2D(e,t,n,i,r,a,o,s,c):la.compressedTexSubImage2D(e,t,n,i,r,a,o,oe,c,s)},Fe:function(e,t,n,i,r,a,o,s,c,l,u){la.Jk?la.compressedTexSubImage3D(e,t,n,i,r,a,o,s,c,l,u):la.compressedTexSubImage3D(e,t,n,i,r,a,o,s,c,oe,u,l)},Hd:function(e,t,n,i,r){la.copyBufferSubData(e,t,n,i,r)},lh:function(e,t,n,i,r,a,o,s){la.copyTexImage2D(e,t,n,i,r,a,o,s)},kh:function(e,t,n,i,r,a,o,s){la.copyTexSubImage2D(e,t,n,i,r,a,o,s)},He:function(e,t,n,i,r,a,o,s,c){la.copyTexSubImage3D(e,t,n,i,r,a,o,s,c)},jh:function(){var e=hi(Zn),t=la.createProgram();return t.name=e,t.Wk=t.Uk=t.Vk=0,t.xl=1,Zn[e]=t,e},ih:function(e){var t=hi(ii);return ii[t]=la.createShader(e),t},hh:function(e){la.cullFace(e)},fh:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=Qn[i];r&&(la.deleteBuffer(r),r.name=0,Qn[i]=null,i==la.el&&(la.el=0),i==la.Jk&&(la.Jk=0))}},eh:function(e,t){for(var n=0;n<e;++n){var i=le[t+4*n>>2],r=ei[i];r&&(la.deleteFramebuffer(r),r.name=0,ei[i]=null)}},dh:function(e){if(e){var t=Zn[e];t?(la.deleteProgram(t),t.name=0,Zn[e]=null):di(1281)}},De:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=oi[i];r&&(la.deleteQuery(r),oi[i]=null)}},bi:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=oi[i];r&&(la.Mk.deleteQueryEXT(r),oi[i]=null)}},ch:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=ti[i];r&&(la.deleteRenderbuffer(r),r.name=0,ti[i]=null)}},nd:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=si[i];r&&(la.deleteSampler(r),r.name=0,si[i]=null)}},bh:function(e){if(e){var t=ii[e];t?(la.deleteShader(t),ii[e]=null):di(1281)}},vd:function(e){if(e){var t=li[e];t?(la.deleteSync(t),t.name=0,li[e]=null):di(1281)}},ah:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=ni[i];r&&(la.deleteTexture(r),r.name=0,ni[i]=null)}},bd:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=ci[i];r&&(la.deleteTransformFeedback(r),r.name=0,ci[i]=null)}},le:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2];la.deleteVertexArray(ri[i]),ri[i]=null}},Rh:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2];la.deleteVertexArray(ri[i]),ri[i]=null}},$g:function(e){la.depthFunc(e)},_g:function(e){la.depthMask(!!e)},Zg:function(e,t){la.depthRange(e,t)},Yg:function(e,t){la.detachShader(Zn[e],ii[t])},Wg:function(e){la.disable(e)},Vg:function(e){la.disableVertexAttribArray(e)},Ug:function(e,t,n){la.drawArrays(e,t,n)},zd:function(e,t,n,i){la.drawArraysInstanced(e,t,n,i)},Nh:function(e,t,n,i){la.drawArraysInstanced(e,t,n,i)},Lc:function(e,t,n,i){la.drawArraysInstanced(e,t,n,i)},Qe:function(e,t,n,i){la.drawArraysInstanced(e,t,n,i)},Mc:function(e,t,n,i){la.drawArraysInstanced(e,t,n,i)},we:function(e,t){for(var n=Ti[e],i=0;i<e;i++)n[i]=le[t+4*i>>2];la.drawBuffers(n)},Oe:function(e,t){for(var n=Ti[e],i=0;i<e;i++)n[i]=le[t+4*i>>2];la.drawBuffers(n)},Oh:function(e,t){for(var n=Ti[e],i=0;i<e;i++)n[i]=le[t+4*i>>2];la.drawBuffers(n)},Tg:function(e,t,n,i){la.drawElements(e,t,n,i)},yd:function(e,t,n,i,r){la.drawElementsInstanced(e,t,n,i,r)},Lh:function(e,t,n,i,r){la.drawElementsInstanced(e,t,n,i,r)},Jc:function(e,t,n,i,r){la.drawElementsInstanced(e,t,n,i,r)},Kc:function(e,t,n,i,r){la.drawElementsInstanced(e,t,n,i,r)},Pe:function(e,t,n,i,r){la.drawElementsInstanced(e,t,n,i,r)},Me:function(e,t,n,i,r,a){Ei(e,i,r,a)},Sg:function(e){la.enable(e)},Rg:function(e){la.enableVertexAttribArray(e)},Ae:function(e){la.endQuery(e)},_h:function(e){la.Mk.endQueryEXT(e)},ge:function(){la.endTransformFeedback()},xd:function(e,t){return(e=la.fenceSync(e,t))?(t=hi(li),e.name=t,li[t]=e,t):0},Qg:function(){la.finish()},Pg:function(){la.flush()},Og:function(e,t,n,i){la.framebufferRenderbuffer(e,t,n,ti[i])},Ng:function(e,t,n,i,r){la.framebufferTexture2D(e,t,n,ni[i],r)},ne:function(e,t,n,i,r){la.framebufferTextureLayer(e,t,ni[n],i,r)},Mg:function(e){la.frontFace(e)},Lg:function(e,t){xi(e,t,"createBuffer",Qn)},Jg:function(e,t){xi(e,t,"createFramebuffer",ei)},Ee:function(e,t){xi(e,t,"createQuery",oi)},ci:function(e,t){for(var n=0;n<e;n++){var i=la.Mk.createQueryEXT();if(!i){for(di(1282);n<e;)le[t+4*n++>>2]=0;break}var r=hi(oi);i.name=r,oi[r]=i,le[t+4*n>>2]=r}},Ig:function(e,t){xi(e,t,"createRenderbuffer",ti)},od:function(e,t){xi(e,t,"createSampler",si)},Hg:function(e,t){xi(e,t,"createTexture",ni)},ad:function(e,t){xi(e,t,"createTransformFeedback",ci)},ke:function(e,t){xi(e,t,"createVertexArray",ri)},Qh:function(e,t){xi(e,t,"createVertexArray",ri)},Kg:function(e){la.generateMipmap(e)},Gg:function(e,t,n,i,r,a,o){Ci("getActiveAttrib",e,t,n,i,r,a,o)},Fg:function(e,t,n,i,r,a,o){Ci("getActiveUniform",e,t,n,i,r,a,o)},Bd:function(e,t,n,i,r){e=Zn[e],(e=la.getActiveUniformBlockName(e,t))&&(r&&0<n?(n=be(e,r,n),i&&(le[i>>2]=n)):i&&(le[i>>2]=0))},Dd:function(e,t,n,i){if(i){if(e=Zn[e],35393==n)n=la.getActiveUniformBlockName(e,t),le[i>>2]=n.length+1;else if(null!==(e=la.getActiveUniformBlockParameter(e,t,n)))if(35395==n)for(n=0;n<e.length;n++)le[i+4*n>>2]=e[n];else le[i>>2]=e}else di(1281)},Fd:function(e,t,n,i,r){if(r)if(0<t&&0==n)di(1281);else{e=Zn[e];for(var a=[],o=0;o<t;o++)a.push(le[n+4*o>>2]);if(e=la.getActiveUniforms(e,a,i))for(t=e.length,o=0;o<t;o++)le[r+4*o>>2]=e[o]}else di(1281)},Eg:function(e,t,n,i){var r=(e=la.getAttachedShaders(Zn[e])).length;for(r>t&&(r=t),le[n>>2]=r,t=0;t<r;++t)le[i+4*t>>2]=ii.indexOf(e[t])},Dg:function(e,t){return la.getAttribLocation(Zn[e],ge(t))},Bg:function(e,t){Ai(e,t,4)},pd:function(e,t,n){n?Oi(n,la.getBufferParameter(e,t)):di(1281)},Ag:function(e,t,n){n?le[n>>2]=la.getBufferParameter(e,t):di(1281)},zg:function(){var e=la.getError()||vi;return vi=0,e},yg:function(e,t){Ai(e,t,2)},Vd:function(e,t){return la.getFragDataLocation(Zn[e],ge(t))},xg:function(e,t,n,i){((e=la.getFramebufferAttachmentParameter(e,t,n))instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=0|e.name),le[i>>2]=e},qd:function(e,t,n){ji(e,t,n,1)},sd:function(e,t){Ai(e,t,1)},ie:function(e,t,n){ji(e,t,n,0)},wg:function(e,t){Ai(e,t,0)},Qc:function(e,t,n,i,r){if(0>i)di(1281);else if(r){if(null!==(e=la.getInternalformatParameter(e,t,n)))for(t=0;t<e.length&&t<i;++t)le[r+4*t>>2]=e[t]}else di(1281)},Xc:function(){di(1282)},ug:function(e,t,n,i){null===(e=la.getProgramInfoLog(Zn[e]))&&(e="(unknown error)"),t=0<t&&i?be(e,i,t):0,n&&(le[n>>2]=t)},vg:function(e,t,n){if(n)if(e>=Jn)di(1281);else if(e=Zn[e],35716==t)null===(e=la.getProgramInfoLog(e))&&(e="(unknown error)"),le[n>>2]=e.length+1;else if(35719==t){if(!e.Wk)for(t=0;t<la.getProgramParameter(e,35718);++t)e.Wk=Math.max(e.Wk,la.getActiveUniform(e,t).name.length+1);le[n>>2]=e.Wk}else if(35722==t){if(!e.Uk)for(t=0;t<la.getProgramParameter(e,35721);++t)e.Uk=Math.max(e.Uk,la.getActiveAttrib(e,t).name.length+1);le[n>>2]=e.Uk}else if(35381==t){if(!e.Vk)for(t=0;t<la.getProgramParameter(e,35382);++t)e.Vk=Math.max(e.Vk,la.getActiveUniformBlockName(e,t).length+1);le[n>>2]=e.Vk}else le[n>>2]=la.getProgramParameter(e,t);else di(1281)},Uh:function(e,t,n){n?(e=oi[e],Oi(n,"boolean"==typeof(t=2>bi.version?la.Mk.getQueryObjectEXT(e,t):la.getQueryParameter(e,t))?t?1:0:t)):di(1281)},Wh:function(e,t,n){var i;n?(i="boolean"==typeof(e=la.Mk.getQueryObjectEXT(oi[e],t))?e?1:0:e,le[n>>2]=i):di(1281)},Th:function(e,t,n){n?(e=oi[e],Oi(n,"boolean"==typeof(t=2>bi.version?la.Mk.getQueryObjectEXT(e,t):la.getQueryParameter(e,t))?t?1:0:t)):di(1281)},xe:function(e,t,n){var i;n?(i="boolean"==typeof(e=la.getQueryParameter(oi[e],t))?e?1:0:e,le[n>>2]=i):di(1281)},Vh:function(e,t,n){var i;n?(i="boolean"==typeof(e=la.Mk.getQueryObjectEXT(oi[e],t))?e?1:0:e,le[n>>2]=i):di(1281)},ye:function(e,t,n){n?le[n>>2]=la.getQuery(e,t):di(1281)},Yh:function(e,t,n){n?le[n>>2]=la.Mk.getQueryEXT(e,t):di(1281)},tg:function(e,t,n){n?le[n>>2]=la.getRenderbufferParameter(e,t):di(1281)},ed:function(e,t,n){n?fe[n>>2]=la.getSamplerParameter(si[e],t):di(1281)},fd:function(e,t,n){n?le[n>>2]=la.getSamplerParameter(si[e],t):di(1281)},qg:function(e,t,n,i){null===(e=la.getShaderInfoLog(ii[e]))&&(e="(unknown error)"),t=0<t&&i?be(e,i,t):0,n&&(le[n>>2]=t)},pg:function(e,t,n,i){e=la.getShaderPrecisionFormat(e,t),le[n>>2]=e.rangeMin,le[n+4>>2]=e.rangeMax,le[i>>2]=e.precision},og:function(e,t,n,i){(e=la.getShaderSource(ii[e]))&&(t=0<t&&i?be(e,i,t):0,n&&(le[n>>2]=t))},sg:function(e,t,n){n?35716==t?(null===(e=la.getShaderInfoLog(ii[e]))&&(e="(unknown error)"),le[n>>2]=e?e.length+1:0):35720==t?(e=la.getShaderSource(ii[e]),le[n>>2]=e?e.length+1:0):le[n>>2]=la.getShaderParameter(ii[e],t):di(1281)},ng:function(e){var t=ui[e];if(!t){switch(e){case 7939:t=Fi((t=(t=la.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e})))).join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=la.getParameter(e))||di(1280),t=t&&Fi(t);break;case 7938:t=Fi("OpenGL ES 3.0 ("+la.getParameter(7938)+")");break;case 35724:var n=(t=la.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Fi(t);break;default:di(1280)}ui[e]=t}return t},Id:function(e,t){if(2>bi.version)return di(1282),0;var n=fi[e];return n?0>t||t>=n.length?(di(1281),0):n[t]:7939===e?(n=(n=(n=la.getSupportedExtensions()||[]).concat(n.map((function(e){return"GL_"+e})))).map((function(e){return Fi(e)})),n=fi[e]=n,0>t||t>=n.length?(di(1281),0):n[t]):(di(1280),0)},rd:function(e,t,n,i,r){0>n?di(1281):r?null!==(e=la.getSyncParameter(li[e],t))&&(le[r>>2]=e,i&&(le[i>>2]=1)):di(1281)},mg:function(e,t,n){n?fe[n>>2]=la.getTexParameter(e,t):di(1281)},lg:function(e,t,n){n?le[n>>2]=la.getTexParameter(e,t):di(1281)},ce:function(e,t,n,i,r,a,o){e=Zn[e],(e=la.getTransformFeedbackVarying(e,t))&&(o&&0<n?(n=be(e.name,o,n),i&&(le[i>>2]=n)):i&&(le[i>>2]=0),r&&(le[r>>2]=e.size),a&&(le[a>>2]=e.type))},Ed:function(e,t){return la.getUniformBlockIndex(Zn[e],ge(t))},Gd:function(e,t,n,i){if(i)if(0<t&&(0==n||0==i))di(1281);else{e=Zn[e];for(var r=[],a=0;a<t;a++)r.push(ge(le[n+4*a>>2]));if(e=la.getUniformIndices(e,r))for(t=e.length,a=0;a<t;a++)le[i+4*a>>2]=e[a]}else di(1281)},ig:function(e,t){if(t=ge(t),e=Zn[e]){Ii(e);var n=e.hl,i=0,r=t,a=Mi(t);if(0<a&&(i=parseInt(t.slice(a+1))>>>0,r=t.slice(0,a)),(r=e.yl[r])&&i<r[0]&&(n[i+=r[1]]=n[i]||la.getUniformLocation(e,t)))return i}else di(1281);return-1},kg:function(e,t,n){Wi(e,t,n,2)},jg:function(e,t,n){Wi(e,t,n,0)},Wd:function(e,t,n){Wi(e,t,n,0)},ae:function(e,t,n){_i(e,t,n,0)},$d:function(e,t,n){_i(e,t,n,0)},eg:function(e,t,n){n?le[n>>2]=la.getVertexAttribOffset(e,t):di(1281)},hg:function(e,t,n){_i(e,t,n,2)},fg:function(e,t,n){_i(e,t,n,5)},dg:function(e,t){la.hint(e,t)},Uc:function(e,t,n){for(var i=Ti[t],r=0;r<t;r++)i[r]=le[n+4*r>>2];la.invalidateFramebuffer(e,i)},Tc:function(e,t,n,i,r,a,o){for(var s=Ti[t],c=0;c<t;c++)s[c]=le[n+4*c>>2];la.invalidateSubFramebuffer(e,s,i,r,a,o)},cg:function(e){return(e=Qn[e])?la.isBuffer(e):0},bg:function(e){return la.isEnabled(e)},ag:function(e){return(e=ei[e])?la.isFramebuffer(e):0},$f:function(e){return(e=Zn[e])?la.isProgram(e):0},Ce:function(e){return(e=oi[e])?la.isQuery(e):0},ai:function(e){return(e=oi[e])?la.Mk.isQueryEXT(e):0},_f:function(e){return(e=ti[e])?la.isRenderbuffer(e):0},md:function(e){return(e=si[e])?la.isSampler(e):0},Zf:function(e){return(e=ii[e])?la.isShader(e):0},wd:function(e){return la.isSync(li[e])},Yf:function(e){return(e=ni[e])?la.isTexture(e):0},$c:function(e){return la.isTransformFeedback(ci[e])},je:function(e){return(e=ri[e])?la.isVertexArray(e):0},Ph:function(e){return(e=ri[e])?la.isVertexArray(e):0},Xf:function(e){la.lineWidth(e)},Wf:function(e){e=Zn[e],la.linkProgram(e),e.hl=0,e.yl={}},_c:function(){la.pauseTransformFeedback()},Vf:function(e,t){la.pixelStorei(e,t)},Uf:function(e,t){la.polygonOffset(e,t)},Wc:function(){di(1280)},Vc:function(){di(1280)},Zh:function(e,t){la.Mk.queryCounterEXT(oi[e],t)},Ne:function(e){la.readBuffer(e)},Tf:function(e,t,n,i,r,a,o){if(la.el)la.readPixels(e,t,n,i,r,a,o);else{var s=Di(a);la.readPixels(e,t,n,i,r,a,s,o>>Ri(s))}},Sf:function(){},Rf:function(e,t,n,i){la.renderbufferStorage(e,t,n,i)},oe:function(e,t,n,i,r){la.renderbufferStorageMultisample(e,t,n,i,r)},Zc:function(){la.resumeTransformFeedback()},Qf:function(e,t){la.sampleCoverage(e,!!t)},id:function(e,t,n){la.samplerParameterf(si[e],t,n)},gd:function(e,t,n){la.samplerParameterf(si[e],t,fe[n>>2])},kd:function(e,t,n){la.samplerParameteri(si[e],t,n)},jd:function(e,t,n){la.samplerParameteri(si[e],t,le[n>>2])},Pf:function(e,t,n,i){la.scissor(e,t,n,i)},Of:function(){di(1280)},Mf:function(e,t,n,i){t=mi(t,n,i),la.shaderSource(ii[e],t)},Lf:function(e,t,n){la.stencilFunc(e,t,n)},Kf:function(e,t,n,i){la.stencilFuncSeparate(e,t,n,i)},Jf:function(e){la.stencilMask(e)},If:function(e,t){la.stencilMaskSeparate(e,t)},Hf:function(e,t,n){la.stencilOp(e,t,n)},Gf:function(e,t,n,i){la.stencilOpSeparate(e,t,n,i)},Ff:function(e,t,n,i,r,a,o,s,c){if(la.Jk)la.texImage2D(e,t,n,i,r,a,o,s,c);else if(c){var l=Di(s);la.texImage2D(e,t,n,i,r,a,o,s,l,c>>Ri(l))}else la.texImage2D(e,t,n,i,r,a,o,s,null)},Je:function(e,t,n,i,r,a,o,s,c,l){if(la.Jk)la.texImage3D(e,t,n,i,r,a,o,s,c,l);else if(l){var u=Di(c);la.texImage3D(e,t,n,i,r,a,o,s,c,u,l>>Ri(u))}else la.texImage3D(e,t,n,i,r,a,o,s,c,null)},Ef:function(e,t,n){la.texParameterf(e,t,n)},Df:function(e,t,n){la.texParameterf(e,t,fe[n>>2])},Bf:function(e,t,n){la.texParameteri(e,t,n)},Af:function(e,t,n){la.texParameteri(e,t,le[n>>2])},Sc:function(e,t,n,i,r){la.texStorage2D(e,t,n,i,r)},Rc:function(e,t,n,i,r,a){la.texStorage3D(e,t,n,i,r,a)},zf:function(e,t,n,i,r,a,o,s,c){if(la.Jk)la.texSubImage2D(e,t,n,i,r,a,o,s,c);else if(c){var l=Di(s);la.texSubImage2D(e,t,n,i,r,a,o,s,l,c>>Ri(l))}else la.texSubImage2D(e,t,n,i,r,a,o,s,null)},Ie:function(e,t,n,i,r,a,o,s,c,l,u){if(la.Jk)la.texSubImage3D(e,t,n,i,r,a,o,s,c,l,u);else if(u){var f=Di(l);la.texSubImage3D(e,t,n,i,r,a,o,s,c,l,f,u>>Ri(f))}else la.texSubImage3D(e,t,n,i,r,a,o,s,c,l,null)},de:function(e,t,n,i){e=Zn[e];for(var r=[],a=0;a<t;a++)r.push(ge(le[n+4*a>>2]));la.transformFeedbackVaryings(e,r,i)},yf:function(e,t){la.uniform1f(Bi(e),t)},xf:function(e,t,n){t&&la.uniform1fv(Bi(e),fe,n>>2,t)},wf:function(e,t){la.uniform1i(Bi(e),t)},vf:function(e,t,n){t&&la.uniform1iv(Bi(e),le,n>>2,t)},Ud:function(e,t){la.uniform1ui(Bi(e),t)},Qd:function(e,t,n){t&&la.uniform1uiv(Bi(e),ue,n>>2,t)},uf:function(e,t,n){la.uniform2f(Bi(e),t,n)},tf:function(e,t,n){t&&la.uniform2fv(Bi(e),fe,n>>2,2*t)},sf:function(e,t,n){la.uniform2i(Bi(e),t,n)},qf:function(e,t,n){t&&la.uniform2iv(Bi(e),le,n>>2,2*t)},Td:function(e,t,n){la.uniform2ui(Bi(e),t,n)},Pd:function(e,t,n){t&&la.uniform2uiv(Bi(e),ue,n>>2,2*t)},pf:function(e,t,n,i){la.uniform3f(Bi(e),t,n,i)},of:function(e,t,n){t&&la.uniform3fv(Bi(e),fe,n>>2,3*t)},nf:function(e,t,n,i){la.uniform3i(Bi(e),t,n,i)},mf:function(e,t,n){t&&la.uniform3iv(Bi(e),le,n>>2,3*t)},Sd:function(e,t,n,i){la.uniform3ui(Bi(e),t,n,i)},Od:function(e,t,n){t&&la.uniform3uiv(Bi(e),ue,n>>2,3*t)},lf:function(e,t,n,i,r){la.uniform4f(Bi(e),t,n,i,r)},kf:function(e,t,n){t&&la.uniform4fv(Bi(e),fe,n>>2,4*t)},jf:function(e,t,n,i,r){la.uniform4i(Bi(e),t,n,i,r)},hf:function(e,t,n){t&&la.uniform4iv(Bi(e),le,n>>2,4*t)},Rd:function(e,t,n,i,r){la.uniform4ui(Bi(e),t,n,i,r)},Nd:function(e,t,n){t&&la.uniform4uiv(Bi(e),ue,n>>2,4*t)},Ad:function(e,t,n){e=Zn[e],la.uniformBlockBinding(e,t,n)},gf:function(e,t,n,i){t&&la.uniformMatrix2fv(Bi(e),!!n,fe,i>>2,4*t)},ve:function(e,t,n,i){t&&la.uniformMatrix2x3fv(Bi(e),!!n,fe,i>>2,6*t)},te:function(e,t,n,i){t&&la.uniformMatrix2x4fv(Bi(e),!!n,fe,i>>2,8*t)},ef:function(e,t,n,i){t&&la.uniformMatrix3fv(Bi(e),!!n,fe,i>>2,9*t)},ue:function(e,t,n,i){t&&la.uniformMatrix3x2fv(Bi(e),!!n,fe,i>>2,6*t)},re:function(e,t,n,i){t&&la.uniformMatrix3x4fv(Bi(e),!!n,fe,i>>2,12*t)},df:function(e,t,n,i){t&&la.uniformMatrix4fv(Bi(e),!!n,fe,i>>2,16*t)},se:function(e,t,n,i){t&&la.uniformMatrix4x2fv(Bi(e),!!n,fe,i>>2,8*t)},qe:function(e,t,n,i){t&&la.uniformMatrix4x3fv(Bi(e),!!n,fe,i>>2,12*t)},cf:function(e){e=Zn[e],la.useProgram(e),la.Hl=e},bf:function(e){la.validateProgram(Zn[e])},af:function(e,t){la.vertexAttrib1f(e,t)},$e:function(e,t){la.vertexAttrib1f(e,fe[t>>2])},_e:function(e,t,n){la.vertexAttrib2f(e,t,n)},Ze:function(e,t){la.vertexAttrib2f(e,fe[t>>2],fe[t+4>>2])},Ye:function(e,t,n,i){la.vertexAttrib3f(e,t,n,i)},Xe:function(e,t){la.vertexAttrib3f(e,fe[t>>2],fe[t+4>>2],fe[t+8>>2])},Ve:function(e,t,n,i,r){la.vertexAttrib4f(e,t,n,i,r)},Ue:function(e,t){la.vertexAttrib4f(e,fe[t>>2],fe[t+4>>2],fe[t+8>>2],fe[t+12>>2])},dd:function(e,t){la.vertexAttribDivisor(e,t)},Kh:function(e,t){la.vertexAttribDivisor(e,t)},Oc:function(e,t){la.vertexAttribDivisor(e,t)},Re:function(e,t){la.vertexAttribDivisor(e,t)},Pc:function(e,t){la.vertexAttribDivisor(e,t)},_d:function(e,t,n,i,r){la.vertexAttribI4i(e,t,n,i,r)},Yd:function(e,t){la.vertexAttribI4i(e,le[t>>2],le[t+4>>2],le[t+8>>2],le[t+12>>2])},Zd:function(e,t,n,i,r){la.vertexAttribI4ui(e,t,n,i,r)},Xd:function(e,t){la.vertexAttribI4ui(e,ue[t>>2],ue[t+4>>2],ue[t+8>>2],ue[t+12>>2])},be:function(e,t,n,i,r){la.vertexAttribIPointer(e,t,n,i,r)},Te:function(e,t,n,i,r,a){la.vertexAttribPointer(e,t,n,!!i,r,a)},Se:function(e,t,n,i){la.viewport(e,t,n,i)},td:function(e,t,n,i){la.waitSync(li[e],t,(n>>>0)+4294967296*i)},jb:function(e,t,n){t=function(e,t){function n(e){var t=a;return("double"===e||"i64"===e)&&7&t&&(t+=4),a=t,"double"===e?(e=de[a>>3],a+=8):"i64"==e?(e=[le[a>>2],le[a+4>>2]],a+=8):(e=le[a>>2],a+=4),e}for(var i,r,a=t,o=[];;){var s=e;if(0===(i=ae[e>>0]))break;if(r=ae[e+1>>0],37==i){var c=!1,l=t=!1,u=!1,f=!1;e:for(;;){switch(r){case 43:c=!0;break;case 45:t=!0;break;case 35:l=!0;break;case 48:if(u)break e;u=!0;break;case 32:f=!0;break;default:break e}e++,r=ae[e+1>>0]}var d=0;if(42==r)d=n("i32"),e++,r=ae[e+1>>0];else for(;48<=r&&57>=r;)d=10*d+(r-48),e++,r=ae[e+1>>0];var h=!1,m=-1;if(46==r){if(m=0,h=!0,e++,42==(r=ae[e+1>>0]))m=n("i32"),e++;else for(;!(48>(r=ae[e+1>>0])||57<r);)m=10*m+(r-48),e++;r=ae[e+1>>0]}switch(0>m&&(m=6,h=!1),String.fromCharCode(r)){case"h":if(104==(r=ae[e+2>>0])){e++;var p=1}else p=2;break;case"l":108==(r=ae[e+2>>0])?(e++,p=8):p=4;break;case"L":case"q":case"j":p=8;break;case"z":case"t":case"I":p=4;break;default:p=null}switch(p&&e++,r=ae[e+1>>0],String.fromCharCode(r)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":s=100==r||105==r,i=n("i"+8*(p=p||4)),8==p&&(i=117==r?(i[0]>>>0)+4294967296*(i[1]>>>0):(i[0]>>>0)+4294967296*i[1]),4>=p&&(i=(s?Li:Vi)(i&Math.pow(256,p)-1,8*p));var g=Math.abs(i);if(s="",100==r||105==r)var v=Li(i,8*p).toString(10);else if(117==r)v=Vi(i,8*p).toString(10),i=Math.abs(i);else if(111==r)v=(l?"0":"")+g.toString(8);else if(120==r||88==r){if(s=l&&0!=i?"0x":"",0>i){for(i=-i,v=(g-1).toString(16),g=[],l=0;l<v.length;l++)g.push((15-parseInt(v[l],16)).toString(16));for(v=g.join("");v.length<2*p;)v="f"+v}else v=g.toString(16);88==r&&(s=s.toUpperCase(),v=v.toUpperCase())}else 112==r&&(0===g?v="(nil)":(s="0x",v=g.toString(16)));if(h)for(;v.length<m;)v="0"+v;for(0<=i&&(c?s="+"+s:f&&(s=" "+s)),"-"==v.charAt(0)&&(s="-"+s,v=v.substr(1));s.length+v.length<d;)t?v+=" ":u?v="0"+v:s=" "+s;(v=s+v).split("").forEach((function(e){o.push(e.charCodeAt(0))}));break;case"f":case"F":case"e":case"E":case"g":case"G":if(i=n("double"),isNaN(i))v="nan",u=!1;else if(isFinite(i)){if(h=!1,p=Math.min(m,20),103!=r&&71!=r||(h=!0,(m=m||1)>(p=parseInt(i.toExponential(p).split("e")[1],10))&&-4<=p?(r=(103==r?"f":"F").charCodeAt(0),m-=p+1):(r=(103==r?"e":"E").charCodeAt(0),m--),p=Math.min(m,20)),101==r||69==r?(v=i.toExponential(p),/[eE][-+]\d$/.test(v)&&(v=v.slice(0,-1)+"0"+v.slice(-1))):102!=r&&70!=r||(v=i.toFixed(p),0===i&&(0>i||0===i&&-1/0==1/i)&&(v="-"+v)),s=v.split("e"),h&&!l)for(;1<s[0].length&&s[0].includes(".")&&("0"==s[0].slice(-1)||"."==s[0].slice(-1));)s[0]=s[0].slice(0,-1);else for(l&&-1==v.indexOf(".")&&(s[0]+=".");m>p++;)s[0]+="0";v=s[0]+(1<s.length?"e"+s[1]:""),69==r&&(v=v.toUpperCase()),0<=i&&(c?v="+"+v:f&&(v=" "+v))}else v=(0>i?"-":"")+"inf",u=!1;for(;v.length<d;)v=t?v+" ":!u||"-"!=v[0]&&"+"!=v[0]?(u?"0":" ")+v:v[0]+"0"+v.slice(1);97>r&&(v=v.toUpperCase()),v.split("").forEach((function(e){o.push(e.charCodeAt(0))}));break;case"s":if(u=(c=n("i8*"))?Ui(c):6,h&&(u=Math.min(u,m)),!t)for(;u<d--;)o.push(32);if(c)for(l=0;l<u;l++)o.push(oe[c++>>0]);else o=o.concat(zi("(null)".substr(0,u),!0));if(t)for(;u<d--;)o.push(32);break;case"c":for(t&&o.push(n("i8"));0<--d;)o.push(32);t||o.push(n("i8"));break;case"n":t=n("i32*"),le[t>>2]=o.length;break;case"%":o.push(i);break;default:for(l=s;l<e+2;l++)o.push(ae[l>>0])}e+=2}else o.push(i),e+=1}return o}(t,n),t=pe(t,0),24&e&&(t=t.replace(/\s+$/,""),t+=(0<t.length?"\n":"")+function(e){e:{var t=Error();if(!t.stack){try{throw Error()}catch(e){t=e}if(!t.stack){t="(no stack trace available)";break e}}t=t.stack.toString()}t=t.slice(t.indexOf("\n",Math.max(t.lastIndexOf("_emscripten_log"),t.lastIndexOf("_emscripten_get_callstack")))+1),32&e&&hn("EM_LOG_DEMANGLE is deprecated; ignoring"),8&e&&"undefined"==typeof emscripten_source_map&&(hn('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.'),e=8^e|16);var n=null;if(128&e)for(n=Gi(arguments);n[1].includes("_emscripten_");)n=Gi(n[0]);var i=t.split("\n");t="";var r,a=RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),o=RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),s=RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(r in i){var c,l=i[r];if((c=s.exec(l))&&5==c.length){l=c[1];var u=c[2],f=c[3];c=c[4]}else{if((c=a.exec(l))||(c=o.exec(l)),!(c&&4<=c.length)){t+=l+"\n";continue}l=c[1],u=c[2],f=c[3],c=0|c[4]}var d=!1;if(8&e){var h=emscripten_source_map.Fn({line:f,xm:c});(d=h&&h.source)&&(64&e&&(h.source=h.source.substring(h.source.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=" at "+l+" ("+h.source+":"+h.line+":"+h.xm+")\n")}(16&e||!d)&&(64&e&&(u=u.substring(u.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=(d?" = "+l:" at "+l)+" ("+u+":"+f+":"+c+")\n"),128&e&&n[0]&&(n[1]==l&&0<n[2].length&&(t=t.replace(/\s+$/,""),t+=" with values: "+n[1]+n[2]+"\n"),n=Gi(n[0]))}return t.replace(/\s+$/,"")}(e)),1&e?4&e?console.error(t):2&e?console.warn(t):512&e?console.info(t):256&e?console.debug(t):console.log(t):6&e?te(t):ee(t)},Ic:function(e,t,n){oe.copyWithin(e,t,t+n)},vc:function(e){var t=oe.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var i=t*(1+.2/n);i=Math.min(i,e+100663296);var r=Math,a=r.min;i=Math.max(e,i),i+=(65536-i%65536)%65536;e:{var o=ie.buffer;try{ie.grow(a.call(r,2147483648,i)-o.byteLength+65535>>>16),we();var s=1;break e}catch(e){}s=void 0}if(s)return!0}return!1},Pi:function(e,n){Ln(t.canvas,e,n),Rn()},xc:function(e,t){var n=0;return Ni().forEach((function(i,r){var a=t+n;for(r=ue[e+4*r>>2]=a,a=0;a<i.length;++a)ae[r++>>0]=i.charCodeAt(a);ae[r>>0]=0,n+=i.length+1})),0},yc:function(e,t){var n=Ni();ue[e>>2]=n.length;var i=0;return n.forEach((function(e){i+=e.length+1})),ue[t>>2]=i,0},ii:ln,Ga:function(){return 52},zc:function(){return 52},gc:function(){return 70},Ha:function(e,t,n,i){for(var r=0,a=0;a<n;a++){var o=ue[t>>2],s=ue[t+4>>2];t+=8;for(var c=0;c<s;c++)Ki(e,oe[o+c]);r+=s}return ue[i>>2]=r,0},Nc:async function(e,t){var n=q("background_blur.deepar");n||(n=await J("background_blur.deepar")),n=new Uint8Array(n);var i=Pa(n.length);oe.set(n,i),Mt("vii",e,[t,i])},Yc:async function(e,t){var n=q("background_replacement.deepar");n||(n=await J("background_replacement.deepar")),n=new Uint8Array(n);var i=Pa(n.length);oe.set(n,i),Mt("vii",e,[t,i])},rc:function e(t,n){e.Ol||(e.Ol=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>Me("randomDevice")}());for(var i=0;i<n;i++)ae[t+i>>0]=e.Ol();return 0},Wa:function(e){la.activeTexture(e)},cb:function(e,t){la.attachShader(Zn[e],ii[t])},C:function(e,t){35051==e?la.el=t:35052==e&&(la.Jk=t),la.bindBuffer(e,Qn[t])},x:function(e,t){la.bindFramebuffer(e,ei[t])},U:function(e,t){la.bindRenderbuffer(e,ti[t])},B:function(e,t){la.bindTexture(e,ni[t])},ti:function(e,t,n,i){la.blendColor(e,t,n,i)},ui:function(e,t){la.blendEquationSeparate(e,t)},vi:function(e,t,n,i){la.blendFuncSeparate(e,t,n,i)},Ma:function(e,t,n,i){n&&t?la.bufferData(e,oe,i,n,t):la.bufferData(e,t,i)},Pa:function(e,t,n,i){n&&la.bufferSubData(e,t,oe,i,n)},fa:function(e){return la.checkFramebufferStatus(e)},pi:function(e){la.clear(e)},Oa:function(e,t,n,i){la.clearColor(e,t,n,i)},ri:function(e){la.clearDepth(e)},qi:function(e){la.clearStencil(e)},ea:function(e,t,n,i){la.colorMask(!!e,!!t,!!n,!!i)},yi:function(e){la.compileShader(ii[e])},Ui:function(e,t,n,i,r,a,o,s){la.Jk||!o?la.compressedTexImage2D(e,t,n,i,r,a,o,s):la.compressedTexImage2D(e,t,n,i,r,a,oe,s,o)},Ei:function(e,t,n,i,r,a,o,s,c){la.Jk||!s?la.compressedTexSubImage2D(e,t,n,i,r,a,o,s,c):la.compressedTexSubImage2D(e,t,n,i,r,a,o,oe,c,s)},Mi:function(){var e=hi(Zn),t=la.createProgram();return t.name=e,t.Wk=t.Uk=t.Vk=0,t.xl=1,Zn[e]=t,e},Ai:function(e){var t=hi(ii);return ii[t]=la.createShader(e),t},Qa:function(e){la.cullFace(e)},ja:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=Qn[i];r&&(la.deleteBuffer(r),r.name=0,Qn[i]=null,i==la.el&&(la.el=0),i==la.Jk&&(la.Jk=0))}},wa:function(e,t){for(var n=0;n<e;++n){var i=le[t+4*n>>2],r=ei[i];r&&(la.deleteFramebuffer(r),r.name=0,ei[i]=null)}},bb:function(e){if(e){var t=Zn[e];t?(la.deleteProgram(t),t.name=0,Zn[e]=null):di(1281)}},ya:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=ti[i];r&&(la.deleteRenderbuffer(r),r.name=0,ti[i]=null)}},Ua:function(e){if(e){var t=ii[e];t?(la.deleteShader(t),ii[e]=null):di(1281)}},Bi:function(e){if(e){var t=li[e];t?(la.deleteSync(t),t.name=0,li[e]=null):di(1281)}},T:function(e,t){for(var n=0;n<e;n++){var i=le[t+4*n>>2],r=ni[i];r&&(la.deleteTexture(r),r.name=0,ni[i]=null)}},aa:function(e){la.depthFunc(e)},ua:function(e){la.depthMask(!!e)},ab:function(e,t){la.detachShader(Zn[e],ii[t])},y:function(e){la.disable(e)},_a:function(e){la.disableVertexAttribArray(e)},oi:function(e,t,n){la.drawArrays(e,t,n)},ki:Ei,H:function(e){la.enable(e)},Za:function(e){la.enableVertexAttribArray(e)},si:function(){la.flush()},xa:function(e,t,n,i){la.framebufferRenderbuffer(e,t,n,ti[i])},ga:function(e,t,n,i,r){la.framebufferTexture2D(e,t,n,ni[i],r)},Na:function(e,t){xi(e,t,"createBuffer",Qn)},ha:function(e,t){xi(e,t,"createFramebuffer",ei)},za:function(e,t){xi(e,t,"createRenderbuffer",ti)},Z:function(e,t){xi(e,t,"createTexture",ni)},Va:function(e){la.generateMipmap(e)},Ji:function(e,t,n,i,r,a,o){Ci("getActiveAttrib",e,t,n,i,r,a,o)},Ii:function(e,t,n,i,r,a,o){Ci("getActiveUniform",e,t,n,i,r,a,o)},$a:function(e,t){return la.getAttribLocation(Zn[e],ge(t))},z:function(){var e=la.getError()||vi;return vi=0,e},Ni:function(e,t){Ai(e,t,2)},X:function(e,t){Ai(e,t,0)},Ki:function(e,t,n,i){null===(e=la.getProgramInfoLog(Zn[e]))&&(e="(unknown error)"),t=0<t&&i?be(e,i,t):0,n&&(le[n>>2]=t)},V:function(e,t,n){if(n)if(e>=Jn)di(1281);else if(e=Zn[e],35716==t)null===(e=la.getProgramInfoLog(e))&&(e="(unknown error)"),le[n>>2]=e.length+1;else if(35719==t){if(!e.Wk)for(t=0;t<la.getProgramParameter(e,35718);++t)e.Wk=Math.max(e.Wk,la.getActiveUniform(e,t).name.length+1);le[n>>2]=e.Wk}else if(35722==t){if(!e.Uk)for(t=0;t<la.getProgramParameter(e,35721);++t)e.Uk=Math.max(e.Uk,la.getActiveAttrib(e,t).name.length+1);le[n>>2]=e.Uk}else if(35381==t){if(!e.Vk)for(t=0;t<la.getProgramParameter(e,35382);++t)e.Vk=Math.max(e.Vk,la.getActiveUniformBlockName(e,t).length+1);le[n>>2]=e.Vk}else le[n>>2]=la.getProgramParameter(e,t);else di(1281)},wi:function(e,t,n,i){null===(e=la.getShaderInfoLog(ii[e]))&&(e="(unknown error)"),t=0<t&&i?be(e,i,t):0,n&&(le[n>>2]=t)},xi:function(e,t,n){n?35716==t?(null===(e=la.getShaderInfoLog(ii[e]))&&(e="(unknown error)"),le[n>>2]=e?e.length+1:0):35720==t?(e=la.getShaderSource(ii[e]),le[n>>2]=e?e.length+1:0):le[n>>2]=la.getShaderParameter(ii[e],t):di(1281)},W:function(e){var t=ui[e];if(!t){switch(e){case 7939:t=Fi((t=(t=la.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e})))).join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=la.getParameter(e))||di(1280),t=t&&Fi(t);break;case 7938:t=Fi("OpenGL ES 3.0 ("+la.getParameter(7938)+")");break;case 35724:var n=(t=la.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Fi(t);break;default:di(1280)}ui[e]=t}return t},Hi:function(e,t){if(t=ge(t),e=Zn[e]){Ii(e);var n=e.hl,i=0,r=t,a=Mi(t);if(0<a&&(i=parseInt(t.slice(a+1))>>>0,r=t.slice(0,a)),(r=e.yl[r])&&i<r[0]&&(n[i+=r[1]]=n[i]||la.getUniformLocation(e,t)))return i}else di(1281);return-1},Ci:function(e){return la.isSync(li[e])},Li:function(e){e=Zn[e],la.linkProgram(e),e.hl=0,e.yl={}},ia:function(e,t){la.pixelStorei(e,t)},ta:function(e,t,n,i,r,a,o){if(la.el)la.readPixels(e,t,n,i,r,a,o);else{var s=Di(a);la.readPixels(e,t,n,i,r,a,s,o>>Ri(s))}},Xa:function(e,t,n,i){la.renderbufferStorage(e,t,n,i)},va:function(e,t,n,i){la.scissor(e,t,n,i)},zi:function(e,t,n,i){t=mi(t,n,i),la.shaderSource(ii[e],t)},Sa:function(e,t,n,i){la.stencilFuncSeparate(e,t,n,i)},Ra:function(e,t,n,i){la.stencilOpSeparate(e,t,n,i)},Oi:function(e,t,n,i,r,a,o,s,c){if(la.Jk)la.texImage2D(e,t,n,i,r,a,o,s,c);else if(c){var l=Di(s);la.texImage2D(e,t,n,i,r,a,o,s,l,c>>Ri(l))}else la.texImage2D(e,t,n,i,r,a,o,s,null)},Fi:function(e,t,n){la.texParameterf(e,t,n)},Gi:function(e,t,n){la.texParameterf(e,t,fe[n>>2])},J:function(e,t,n){la.texParameteri(e,t,n)},Di:function(e,t,n,i,r,a,o,s,c){if(la.Jk)la.texSubImage2D(e,t,n,i,r,a,o,s,c);else if(c){var l=Di(s);la.texSubImage2D(e,t,n,i,r,a,o,s,l,c>>Ri(l))}else la.texSubImage2D(e,t,n,i,r,a,o,s,null)},li:function(e,t){la.uniform1i(Bi(e),t)},ni:function(e,t,n){t&&la.uniform1iv(Bi(e),le,n>>2,t)},$:function(e,t,n){t&&la.uniform4fv(Bi(e),fe,n>>2,4*t)},mi:function(e,t,n,i){t&&la.uniformMatrix3fv(Bi(e),!!n,fe,i>>2,9*t)},M:function(e,t,n,i){t&&la.uniformMatrix4fv(Bi(e),!!n,fe,i>>2,16*t)},ka:function(e){e=Zn[e],la.useProgram(e),la.Hl=e},Ya:function(e,t,n,i,r,a){la.vertexAttribPointer(e,t,n,!!i,r,a)},Ta:function(e,t,n,i){la.viewport(e,t,n,i)},ic:function(e,t,n,i){la.waitSync(li[e],t,(n>>>0)+4294967296*i)},v:function(e,t,n){var i=Aa();try{return Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},lb:function(e,t,n,i){var r=Aa();try{return Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},Aa:function(e,t){var n=Aa();try{return Ge(e)(t)}catch(e){if(ja(n),e!==e+0)throw e;Oa(1,0)}},Ea:function(e,t,n,i){var r=Aa();try{return Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},s:function(e){var t=Aa();try{return Ge(e)()}catch(e){if(ja(t),e!==e+0)throw e;Oa(1,0)}},j:function(e,t){var n=Aa();try{return Ge(e)(t)}catch(e){if(ja(n),e!==e+0)throw e;Oa(1,0)}},K:function(e,t,n){var i=Aa();try{return Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},P:function(e,t,n){var i=Aa();try{return Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},Vi:function(e,t,n,i,r){var a=Aa();try{return Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},kb:function(e,t,n,i,r,a,o,s,c,l,u,f,d,h){var m=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c,l,u,f,d,h)}catch(e){if(ja(m),e!==e+0)throw e;Oa(1,0)}},_i:function(e,t,n,i,r){var a=Aa();try{return Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},b:function(e,t,n){var i=Aa();try{return Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},h:function(e,t,n,i){var r=Aa();try{return Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},Wi:function(e,t,n,i,r,a,o,s,c){var l=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c)}catch(e){if(ja(l),e!==e+0)throw e;Oa(1,0)}},p:function(e,t,n,i,r){var a=Aa();try{return Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},Fa:function(e,t,n,i,r,a){var o=Aa();try{return Ge(e)(t,n,i,r,a)}catch(e){if(ja(o),e!==e+0)throw e;Oa(1,0)}},Xi:function(e,t,n,i,r,a,o,s,c,l){var u=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c,l)}catch(e){if(ja(u),e!==e+0)throw e;Oa(1,0)}},D:function(e,t,n,i,r,a){var o=Aa();try{return Ge(e)(t,n,i,r,a)}catch(e){if(ja(o),e!==e+0)throw e;Oa(1,0)}},q:function(e,t,n,i,r,a,o){var s=Aa();try{return Ge(e)(t,n,i,r,a,o)}catch(e){if(ja(s),e!==e+0)throw e;Oa(1,0)}},L:function(e,t,n,i,r,a,o,s){var c=Aa();try{return Ge(e)(t,n,i,r,a,o,s)}catch(e){if(ja(c),e!==e+0)throw e;Oa(1,0)}},Da:function(e,t,n,i,r,a,o,s,c){var l=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c)}catch(e){if(ja(l),e!==e+0)throw e;Oa(1,0)}},Ca:function(e,t,n,i,r,a,o,s,c,l){var u=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c,l)}catch(e){if(ja(u),e!==e+0)throw e;Oa(1,0)}},da:function(e,t,n,i,r,a,o,s,c,l,u,f){var d=Aa();try{return Ge(e)(t,n,i,r,a,o,s,c,l,u,f)}catch(e){if(ja(d),e!==e+0)throw e;Oa(1,0)}},ec:function(e,t,n,i,r,a,o){var s=Aa();try{return Ga(e,t,n,i,r,a,o)}catch(e){if(ja(s),e!==e+0)throw e;Oa(1,0)}},lc:function(e,t,n,i,r,a){var o=Aa();try{return Ra(e,t,n,i,r,a)}catch(e){if(ja(o),e!==e+0)throw e;Oa(1,0)}},jc:function(e,t,n,i){var r=Aa();try{return Da(e,t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},pc:function(e){var t=Aa();try{return Ba(e)}catch(e){if(ja(t),e!==e+0)throw e;Oa(1,0)}},oc:function(e,t){var n=Aa();try{return Wa(e,t)}catch(e){if(ja(n),e!==e+0)throw e;Oa(1,0)}},dc:function(e,t,n,i,r){var a=Aa();try{return Ha(e,t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},mc:function(e,t,n,i,r){var a=Aa();try{return Va(e,t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},k:function(e){var t=Aa();try{Ge(e)()}catch(e){if(ja(t),e!==e+0)throw e;Oa(1,0)}},i:function(e,t){var n=Aa();try{Ge(e)(t)}catch(e){if(ja(n),e!==e+0)throw e;Oa(1,0)}},E:function(e,t,n){var i=Aa();try{Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},na:function(e,t,n){var i=Aa();try{Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},Zi:function(e,t,n,i){var r=Aa();try{Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},d:function(e,t,n){var i=Aa();try{Ge(e)(t,n)}catch(e){if(ja(i),e!==e+0)throw e;Oa(1,0)}},rb:function(e,t,n,i){var r=Aa();try{Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},ob:function(e,t,n,i,r){var a=Aa();try{Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},A:function(e,t,n,i,r,a,o){var s=Aa();try{Ge(e)(t,n,i,r,a,o)}catch(e){if(ja(s),e!==e+0)throw e;Oa(1,0)}},Y:function(e,t,n,i,r){var a=Aa();try{Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},g:function(e,t,n,i){var r=Aa();try{Ge(e)(t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},o:function(e,t,n,i,r){var a=Aa();try{Ge(e)(t,n,i,r)}catch(e){if(ja(a),e!==e+0)throw e;Oa(1,0)}},Yi:function(e,t,n,i,r,a){var o=Aa();try{Ge(e)(t,n,i,r,a)}catch(e){if(ja(o),e!==e+0)throw e;Oa(1,0)}},r:function(e,t,n,i,r,a){var o=Aa();try{Ge(e)(t,n,i,r,a)}catch(e){if(ja(o),e!==e+0)throw e;Oa(1,0)}},t:function(e,t,n,i,r,a,o){var s=Aa();try{Ge(e)(t,n,i,r,a,o)}catch(e){if(ja(s),e!==e+0)throw e;Oa(1,0)}},F:function(e,t,n,i,r,a,o,s){var c=Aa();try{Ge(e)(t,n,i,r,a,o,s)}catch(e){if(ja(c),e!==e+0)throw e;Oa(1,0)}},Q:function(e,t,n,i,r,a,o,s,c){var l=Aa();try{Ge(e)(t,n,i,r,a,o,s,c)}catch(e){if(ja(l),e!==e+0)throw e;Oa(1,0)}},_b:function(e,t,n,i,r,a,o,s,c,l){var u=Aa();try{Ge(e)(t,n,i,r,a,o,s,c,l)}catch(e){if(ja(u),e!==e+0)throw e;Oa(1,0)}},S:function(e,t,n,i,r,a,o,s,c,l,u){var f=Aa();try{Ge(e)(t,n,i,r,a,o,s,c,l,u)}catch(e){if(ja(f),e!==e+0)throw e;Oa(1,0)}},nb:function(e,t,n,i,r,a,o,s,c,l,u,f,d){var h=Aa();try{Ge(e)(t,n,i,r,a,o,s,c,l,u,f,d)}catch(e){if(ja(h),e!==e+0)throw e;Oa(1,0)}},ca:function(e,t,n,i,r,a,o,s,c,l,u,f,d,h,m,p){var g=Aa();try{Ge(e)(t,n,i,r,a,o,s,c,l,u,f,d,h,m,p)}catch(e){if(ja(g),e!==e+0)throw e;Oa(1,0)}},fc:function(e,t,n,i,r,a,o){var s=Aa();try{za(e,t,n,i,r,a,o)}catch(e){if(ja(s),e!==e+0)throw e;Oa(1,0)}},nc:function(e,t,n,i){var r=Aa();try{_a(e,t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},kc:function(e,t,n,i){var r=Aa();try{La(e,t,n,i)}catch(e){if(ja(r),e!==e+0)throw e;Oa(1,0)}},Dc:function(){let e=window.localStorage.getItem("k39d");e||(e=function(){let e=(new Date).getTime(),t=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){let i=16*Math.random();return 0<e?(i=(e+i)%16|0,e=Math.floor(e/16)):(i=(t+i)%16|0,t=Math.floor(t/16)),("x"===n?i:3&i|8).toString(16)}))}(),window.localStorage.setItem("k39d",e));let t=document.title;t&&0!==t.length||(t="No title");let n=navigator.vendor;n&&0!==n.length||(n="N/A");let i=navigator.platform;i&&0!==i.length||(i="N/A"),Xi=e,qi=navigator.userAgent,Ji=window.screen.width+"x"+window.screen.height,Qi=t,Zi=document.domain,er="1.0.0",tr=n,ir=nr=i},bj:function(){return-1},cj:function(){return-1},aj:function(e,n){if(!(e=t.Hk[e]))throw Error("Image is null.");vr(e,n)},$i:function(e,t,n,i){vr(e=new ImageData(new Uint8ClampedArray(oe.subarray(e,e+t*n*4)),t,n),i)},dj:function(){return!1},ub:br,tb:function(){return!!pr},ff:function(e,t){if(sr){var n=rr.createBufferSource();n.connect(ar),n.buffer=or[e].Rl,n.loop=t,n.start(0),or[e].ul=n,or[e].Tl=!0}},rf:async function(e,t,n){if(sr){or[e]={ul:null,Rl:null,Sl:!1,Hn:!1};var i=new ArrayBuffer(n);new Uint8Array(i).set(oe.subarray(t,t+n)),or[e].Rl=await rr.decodeAudioData(i),or[e].Sl=!0}},We:function(e){sr&&(or[e].ul.stop(),or[e].Tl=!1,or[e].ul.currentTime=0)},Cf:function(e){return!!sr&&or[e].Sl},Ke:function(e){sr&&(or[e].Tl&&or[e].ul.stop(),delete or[e])},ze:function(e){sr&&ar.gain.setValueAtTime(e,rr.currentTime)},sb:function(e){t.Hk[e]=null},qb:function(e,n,i){const r=(e=t.Hk[e]).canvas;return(e.Gl||dr!==n||hr!==i)&&(cr.width===n&&cr.height===i||(cr.width=n,cr.height=i),lr.drawImage(r,0,0,r.width,r.height,0,0,n,i),fr=lr.getImageData(0,0,n,i),dr=n,hr=i,e.Gl=!1),D(fr)},pb:function(e,n){if(!(e=t.Hk[e]))throw Error("Image data does not exist.");oe.set(e.data,n)},ac:function(){if(!ur){const e=document.createElement("canvas"),t=e.getContext("2d",{alpha:!1,desynchronized:!0});ur=D({canvas:e,dl:t,Gl:!0})}return ur},bc:function(e){return t.Hk[e].videoHeight},cc:function(e){return t.Hk[e].videoWidth},Cd:function(e,n){if(({canvas:e}=t.Hk[e]),n=ni[n],!bi||!n)return-1;la.bindTexture(la.TEXTURE_2D,n),la.texImage2D(la.TEXTURE_2D,0,la.RGBA,la.RGBA,la.UNSIGNED_BYTE,e)},$b:function(e,n){const i=(e=t.Hk[e]).canvas,r=e.dl;n=t.Hk[n],i.width===n.videoWidth&&i.height===n.videoHeight||(i.width=n.videoWidth,i.height=n.videoHeight),r.drawImage(n,0,0),e.Gl=!0},Ub:function(e){fe.set(Tr,e>>2)},Tb:function(e){fe.set(Sr,e>>2)},Yb:async function(){if(console.log("Rigid face tracking init called"),l||(l=await t.dynamicImports.xzimg()),null==wr&&(wr=new l.Geometry),null==yr&&(yr=new l.VideoManager(null)).setNbFramesDelay(0),!wr.isInitialized()&&!kr){kr=!0;var e,n=q("rigidFaceDetector");n||(e=J("rigidFaceDetector"));var i,r=q("rigidFaceTracker");r||(i=J("rigidFaceTracker")),n||(n=await e),r||(r=await i),await wr.initialize(yr,{poseEstimationWasmFilename:t.rigidFaceTrackingConfig.poseEstimationWasmPath,modelFilename:n,featuresFilename:r,fovY:50,geometryToDetect:"FACE",normMode:"eye_center",detectScoreThs:.2,trackScoreThs:.2,filteringShift:.2,filteringLevel:1,computePose:!0,wasmBackend:{enable:!0,tfjsBackendWasmPath:t.rigidFaceTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:t.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:t.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),kr=!1,console.log("DeepAR FaceTracking initialized!")}},Vb:function(){return Pr},pa:function(){return null!=wr&&wr.isInitialized()},Zb:function(){return kr},Xb:function(e){if(!(e=t.Hk[e]))throw Error("No image data.");Er(e)},Wb:function(e,t,n){Er(e=new ImageData(new Uint8ClampedArray(oe.subarray(e,e+t*n*4)),t,n))},Nb:function(e){fe.set(Ar,e>>2)},Mb:function(e){fe.set(jr,e>>2)},Kb:function(e){fe.set(Mr,e>>2)},Jb:function(e){fe.set(Ir,e>>2)},Rb:Wr,oa:_r,Sb:function(){return xr},Ob:function(){return Fr},Lb:function(){return Br},Qb:function(e){if(!(e=t.Hk[e]))throw Error("No image data.");Dr(e)},Pb:function(e,t,n){Dr(e=new ImageData(new Uint8ClampedArray(oe.subarray(e,e+t*n*4)),t,n))},xb:function(){return Rr.getHeight()},yb:function(){return Rr.getWidth()},wb:function(e,n){if(!(e=t.Hk[e]))throw Error("Image is null.");zr(e,n)},vb:function(e,t,n,i){zr(e=new ImageData(new Uint8ClampedArray(oe.subarray(e,e+t*n*4)),t,n),i)},zb:function(){return!0},Bb:Gr,Ab:Hr,Db:function(e){fe.set(Xr,e>>2)},Fb:function(e){fe.set(qr,e>>2)},Cb:async function(e,n){if(!Nr&&(l||(l=await t.dynamicImports.xzimg()),null==$r&&($r=new l.Geometry),null==Yr&&(Yr=new l.VideoManager(null),Qr=n,Yr.setNbFramesDelay(Qr)),!$r.isInitialized())){var i;Nr=!0,console.log("DeepAR WristTracking initialize started."),(n=q("wristDetector"))||(i=J("wristDetector"));var r,a=q("wristTracker");a||(r=J("wristTracker"));var o,s=q("wristObj");s||(o=J("wristObj")),n||(n=await i),a||(a=await r),s||(s=await o),await $r.initialize(Yr,{geometryToDetect:"WRIST",poseEstimationWasmFilename:t.wristTrackingConfig.poseEstimationWasmPath,modelFilename:n,featuresFilename:a,objFilename:s,fovY:e,detectScoreThs:.3,trackScoreThs:.4,validTrackedKeypThs:.4,filteringShift:.5,trackedNumKeypsThs:50,reprojThs:50,activeIds:[44,46,47,65,66,78,108,110,111,113,114,115,123,127,130,136,139,140,142,143,145,148,151,153,158,160,166,170,171,174,175,177,178],wasmBackend:{enable:!0,tfjsBackendWasmPath:t.wristTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:t.wristTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:t.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),Nr=!1,console.log("DeepAR WristTracking initialized!")}},Ba:Zr,Eb:function(){return $r.isMirrored()},Gb:function(){return Kr},Ib:function(e){if(!(e=t.Hk[e]))throw Error("No image data.");ea(e)},Hb:function(e,t,n){ea(e=new ImageData(new Uint8ClampedArray(oe.subarray(e,e+t*n*4)),t,n))},n:function(e){return e},hi:aa,sc:function(e,t,n,i){return aa(e,t,n,i)},gi:function(e,t,n){for(var i=ge(t),r=0;25>r;++r)i=i.replace(new RegExp("\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[r],"g"),"\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[r]);for(var a in t={"%A":"%a","%B":"%b","%c":"%a %b %d %H:%M:%S %Y","%D":"%m\\/%d\\/%y","%e":"%d","%F":"%Y-%m-%d","%h":"%b","%R":"%H\\:%M","%r":"%I\\:%M\\:%S\\s%p","%T":"%H\\:%M\\:%S","%x":"%m\\/%d\\/(?:%y|%Y)","%X":"%H\\:%M\\:%S"})i=i.replace(a,t[a]);r={"%a":"(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)","%b":"(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)","%C":"\\d\\d","%d":"0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31","%H":"\\d(?!\\d)|[0,1]\\d|20|21|22|23","%I":"\\d(?!\\d)|0\\d|10|11|12","%j":"00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d","%m":"0[1-9]|[1-9](?!\\d)|10|11|12","%M":"0\\d|\\d(?!\\d)|[1-5]\\d","%n":"\\s","%p":"AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.","%S":"0\\d|\\d(?!\\d)|[1-5]\\d|60","%U":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%W":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%w":"[0-6]","%y":"\\d\\d","%Y":"\\d\\d\\d\\d","%%":"%","%t":"\\s"};var o={fn:0,en:1,jn:2,bn:3,kn:4,hn:5,gn:6,cn:7,nn:8,mn:9,ln:10,dn:11};for(var s in a={cm:0,Zl:1,em:2,fm:3,dm:4,Wl:5,bm:6},t={Zl:0,em:1,fm:2,dm:3,Wl:4,bm:5,cm:6},r)i=i.replace(s,"("+s+r[s]+")");var c=[];for(r=i.indexOf("%");0<=r;r=i.indexOf("%"))c.push(i[r+1]),i=i.replace(new RegExp("\\%"+i[r+1],"g"),"");var l=new RegExp("^"+i,"i").exec(ge(e));if(l){if(s=function(){function e(e,t,n){return"number"!=typeof e||isNaN(e)?t:e>=t?e<=n?e:n:t}return{year:e(le[n+20>>2]+1900,1970,9999),month:e(le[n+16>>2],0,11),day:e(le[n+12>>2],1,31),hour:e(le[n+8>>2],0,23),min:e(le[n+4>>2],0,59),Ql:e(le[n>>2],0,59)}}(),(i=(r=e=>{if(0<=(e=c.indexOf(e)))return l[e+1]})("S"))&&(s.Ql=parseInt(i)),(i=r("M"))&&(s.min=parseInt(i)),i=r("H"))s.hour=parseInt(i);else if(i=r("I")){var u=parseInt(i);(i=r("p"))&&(u+="P"===i.toUpperCase()[0]?12:0),s.hour=u}if((i=r("Y"))?s.year=parseInt(i):(i=r("y"))&&(u=parseInt(i),u=(i=r("C"))?u+100*parseInt(i):u+(69>u?2e3:1900),s.year=u),(i=r("m"))?s.month=parseInt(i)-1:(i=r("b"))&&(s.month=o[i.substring(0,3).toUpperCase()]||0),i=r("d"))s.day=parseInt(i);else if(i=r("j"))for(a=parseInt(i),t=tn(s.year),o=0;12>o;++o)a<=(i=ta(t?na:ia,o-1))+(t?na:ia)[o]&&(s.day=a-i);else(i=r("a"))&&(o=i.substring(0,3).toUpperCase(),(i=r("U"))?(a=a[o],t=parseInt(i),a=0===(o=new Date(s.year,0,1)).getDay()?ra(o,a+7*(t-1)):ra(o,7-o.getDay()+a+7*(t-1)),s.day=a.getDate(),s.month=a.getMonth()):(i=r("W"))&&(a=t[o],t=parseInt(i),a=1===(o=new Date(s.year,0,1)).getDay()?ra(o,a+7*(t-1)):ra(o,7-o.getDay()+1+a+7*(t-1)),s.day=a.getDate(),s.month=a.getMonth()));return s=new Date(s.year,s.month,s.day,s.hour,s.min,s.Ql,0),le[n>>2]=s.getSeconds(),le[n+4>>2]=s.getMinutes(),le[n+8>>2]=s.getHours(),le[n+12>>2]=s.getDate(),le[n+16>>2]=s.getMonth(),le[n+20>>2]=s.getFullYear()-1900,le[n+24>>2]=s.getDay(),le[n+28>>2]=ta(tn(s.getFullYear())?na:ia,s.getMonth()-1)+s.getDate()-1,le[n+32>>2]=0,e+zi(l[0]).length-1}return 0}};Ae++,(fa={a:ma},da=function(e){t.asm=e.instance.exports,ie=t.asm.ej,we(),ye=t.asm.$j,Te.unshift(t.asm.fj),0==--Ae&&(null!==je&&(clearInterval(je),je=null),Fe&&(e=Fe,Fe=null,e()))},ha=Pe,"function"!=typeof WebAssembly.instantiateStreaming||Ie(ha)||"function"!=typeof fetch?_e(ha,fa,da):fetch(ha,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,fa).then(da,(function(e){return te("wasm streaming compile failed: "+e),te("falling back to ArrayBuffer instantiation"),_e(ha,fa,da)}))}))).catch(i);var pa=t._initialize=function(){return(pa=t._initialize=t.asm.gj).apply(null,arguments)};function ga(){return(ga=t.asm.mj).apply(null,arguments)}t._setLicenseKey=function(){return(t._setLicenseKey=t.asm.hj).apply(null,arguments)},t._hasVar=function(){return(t._hasVar=t.asm.ij).apply(null,arguments)},t._getVarTypeStatus=function(){return(t._getVarTypeStatus=t.asm.jj).apply(null,arguments)},t._getVarType=function(){return(t._getVarType=t.asm.kj).apply(null,arguments)},t._getBoolVarStatus=function(){return(t._getBoolVarStatus=t.asm.lj).apply(null,arguments)},t._getBoolVar=function(){return(t._getBoolVar=t.asm.nj).apply(null,arguments)},t._getIntVarStatus=function(){return(t._getIntVarStatus=t.asm.oj).apply(null,arguments)},t._getIntVar=function(){return(t._getIntVar=t.asm.pj).apply(null,arguments)},t._getDoubleVarStatus=function(){return(t._getDoubleVarStatus=t.asm.qj).apply(null,arguments)},t._getDoubleVar=function(){return(t._getDoubleVar=t.asm.rj).apply(null,arguments)},t._getStringVarStatus=function(){return(t._getStringVarStatus=t.asm.sj).apply(null,arguments)},t._getStringVar=function(){return(t._getStringVar=t.asm.tj).apply(null,arguments)},t._setBoolVar=function(){return(t._setBoolVar=t.asm.uj).apply(null,arguments)},t._setIntVar=function(){return(t._setIntVar=t.asm.vj).apply(null,arguments)},t._setDoubleVar=function(){return(t._setDoubleVar=t.asm.wj).apply(null,arguments)},t._setStringVar=function(){return(t._setStringVar=t.asm.xj).apply(null,arguments)},t._deleteVar=function(){return(t._deleteVar=t.asm.yj).apply(null,arguments)},t._clearVars=function(){return(t._clearVars=t.asm.zj).apply(null,arguments)};var va=t._shutdownEngine=function(){return(va=t._shutdownEngine=t.asm.Aj).apply(null,arguments)};t._processFrameVideo=function(){return(t._processFrameVideo=t.asm.Bj).apply(null,arguments)},t._processFrameRawPixels=function(){return(t._processFrameRawPixels=t.asm.Cj).apply(null,arguments)};var ba=t._takeScreenshot=function(){return(ba=t._takeScreenshot=t.asm.Dj).apply(null,arguments)};t._switchEffect=function(){return(t._switchEffect=t.asm.Ej).apply(null,arguments)},t._clearEffect=function(){return(t._clearEffect=t.asm.Fj).apply(null,arguments)},t._showStats=function(){return(t._showStats=t.asm.Gj).apply(null,arguments)},t._simulatePhysics=function(){return(t._simulatePhysics=t.asm.Hj).apply(null,arguments)},t._showColliders=function(){return(t._showColliders=t.asm.Ij).apply(null,arguments)},t._render=function(){return(t._render=t.asm.Jj).apply(null,arguments)},t._fireTrigger=function(){return(t._fireTrigger=t.asm.Kj).apply(null,arguments)},t._setFaceDetectionSensitivity=function(){return(t._setFaceDetectionSensitivity=t.asm.Lj).apply(null,arguments)},t._changeParameterFloat=function(){return(t._changeParameterFloat=t.asm.Mj).apply(null,arguments)},t._changeParameterBool=function(){return(t._changeParameterBool=t.asm.Nj).apply(null,arguments)},t._changeParameterVector=function(){return(t._changeParameterVector=t.asm.Oj).apply(null,arguments)},t._changeParameterTexture=function(){return(t._changeParameterTexture=t.asm.Pj).apply(null,arguments)};var ka=t._reset=function(){return(ka=t._reset=t.asm.Qj).apply(null,arguments)};t._moveGameObject=function(){return(t._moveGameObject=t.asm.Rj).apply(null,arguments)};var wa=t._touchOccurred=function(){return(wa=t._touchOccurred=t.asm.Sj).apply(null,arguments)};t._pushConsoleLog=function(){return(t._pushConsoleLog=t.asm.Tj).apply(null,arguments)},t._enableAutoframing=function(){return(t._enableAutoframing=t.asm.Uj).apply(null,arguments)},t._muteSound=function(){return(t._muteSound=t.asm.Vj).apply(null,arguments)},t._backgroundBlur=function(){return(t._backgroundBlur=t.asm.Wj).apply(null,arguments)},t._backgroundReplacement=function(){return(t._backgroundReplacement=t.asm.Xj).apply(null,arguments)};var ya=t._initializeFootTracking=function(){return(ya=t._initializeFootTracking=t.asm.Yj).apply(null,arguments)};t._setZoom=function(){return(t._setZoom=t.asm.Zj).apply(null,arguments)};var Pa=t._malloc=function(){return(Pa=t._malloc=t.asm._j).apply(null,arguments)},Sa=t._free=function(){return(Sa=t._free=t.asm.ak).apply(null,arguments)};function Ta(){return(Ta=t.asm.bk).apply(null,arguments)}var Ea=t._fflush=function(){return(Ea=t._fflush=t.asm.ck).apply(null,arguments)},xa=t.___getTypeName=function(){return(xa=t.___getTypeName=t.asm.dk).apply(null,arguments)};function Ca(){return(Ca=t.asm.fk).apply(null,arguments)}function Oa(){return(Oa=t.asm.gk).apply(null,arguments)}function Aa(){return(Aa=t.asm.hk).apply(null,arguments)}function ja(){return(ja=t.asm.ik).apply(null,arguments)}function Fa(){return(Fa=t.asm.jk).apply(null,arguments)}function Ma(){return(Ma=t.asm.kk).apply(null,arguments)}function Ia(){return(Ia=t.asm.lk).apply(null,arguments)}t.__embind_initialize_bindings=function(){return(t.__embind_initialize_bindings=t.asm.ek).apply(null,arguments)},t.dynCall_viiiij=function(){return(t.dynCall_viiiij=t.asm.mk).apply(null,arguments)},t.dynCall_viiij=function(){return(t.dynCall_viiij=t.asm.nk).apply(null,arguments)},t.dynCall_vijiiii=function(){return(t.dynCall_vijiiii=t.asm.ok).apply(null,arguments)};var Ba=t.dynCall_j=function(){return(Ba=t.dynCall_j=t.asm.pk).apply(null,arguments)},Wa=t.dynCall_ji=function(){return(Wa=t.dynCall_ji=t.asm.qk).apply(null,arguments)},_a=t.dynCall_vij=function(){return(_a=t.dynCall_vij=t.asm.rk).apply(null,arguments)},Da=t.dynCall_iij=function(){return(Da=t.dynCall_iij=t.asm.sk).apply(null,arguments)};t.dynCall_iijii=function(){return(t.dynCall_iijii=t.asm.tk).apply(null,arguments)},t.dynCall_vijii=function(){return(t.dynCall_vijii=t.asm.uk).apply(null,arguments)};var Ra=t.dynCall_iiiij=function(){return(Ra=t.dynCall_iiiij=t.asm.vk).apply(null,arguments)},La=t.dynCall_vji=function(){return(La=t.dynCall_vji=t.asm.wk).apply(null,arguments)},Va=t.dynCall_jiji=function(){return(Va=t.dynCall_jiji=t.asm.xk).apply(null,arguments)};t.dynCall_viij=function(){return(t.dynCall_viij=t.asm.yk).apply(null,arguments)};var Ua,za=t.dynCall_viijii=function(){return(za=t.dynCall_viijii=t.asm.zk).apply(null,arguments)},Ga=t.dynCall_iiiiij=function(){return(Ga=t.dynCall_iiiiij=t.asm.Ak).apply(null,arguments)},Ha=t.dynCall_jiiii=function(){return(Ha=t.dynCall_jiiii=t.asm.Bk).apply(null,arguments)};function Na(){0<Ae||(Le(Se),0<Ae||Ua||(Ua=!0,t.calledRun=!0,he))||(Le(Te),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),Le(xe))}return t.dynCall_iiiiijj=function(){return(t.dynCall_iiiiijj=t.asm.Ck).apply(null,arguments)},t.dynCall_iiiiiijj=function(){return(t.dynCall_iiiiiijj=t.asm.Dk).apply(null,arguments)},t.cwrap=oa,Fe=function e(){Ua||Na(),Ua||(Fe=e)},Na(),e.ready});var o=n(92),s=function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};const c={isRecording:!1,muxer:null,videoEncoder:null,audioEncoder:null,audioTrack:null};let l={isRecording:!1,mediaRecorder:null,chunks:[],mimeType:""};var u,f=n(795);class d extends Error{constructor(e){super(e),this.name="SwitchEffectCanceled"}}!function(e){e[e.Bool=0]="Bool",e[e.Int=1]="Int",e[e.Double=2]="Double",e[e.String=3]="String"}(u||(u={}));class h{constructor(e){this.module=e}hasVar(e,t){return this.module.hasVar(e,t)}getVarType(e,t){return this.module.getVarType(e,t)}getBoolVar(e,t){return this.module.getBoolVar(e,t)}getIntVar(e,t){return this.module.getIntVar(e,t)}getDoubleVar(e,t){return this.module.getDoubleVar(e,t)}getStringVar(e,t=0){return this.module.getStringVar(e,t)}setBoolVar(e,t,n){return this.module.setBoolVar(e,t,n)}setIntVar(e,t,n){return this.module.setIntVar(e,t,n)}setDoubleVar(e,t,n){return this.module.setDoubleVar(e,t,n)}setStringVar(e,t,n){return this.module.setStringVar(e,t,n)}deleteVar(e,t){return this.module.deleteVar(e,t)}clearVars(e){return this.module.clearVars(e)}}let m;function p(e,t,n,i){e.width=t*i,e.height=n*i}const g=()=>{const e=parseFloat(m.computedStyle.width||"0"),t=parseFloat(m.computedStyle.height||"0"),n=window.devicePixelRatio;e===m.cssWidth&&t===m.cssHeight&&n===m.devicePixelRatio||(m.cssWidth=e,m.cssHeight=t,m.devicePixelRatio=n,p(m.canvas,e,t,n))},v=()=>{m.canvas.style.width="100%",m.canvas.style.height="100%"};var b;!function(e){e[e.Start=0]="Start",e[e.Move=1]="Move",e[e.End=2]="End"}(b||(b={}));class k{constructor(e,t){this.canvasListeners=[],this.touchOccurring=!1,this.touchListeners=[],this.canvas=e,this.touchListeners.push(t),this.registerCanvasListener("mousedown",(e=>{this.touchOccurring||(this.touchOccurred(this.touchInfo(e,b.Start)),this.touchOccurring=!0)})),this.registerCanvasListener("touchstart",(e=>{this.touchOccurring||(this.touchOccurred(this.touchInfo(e,b.Start)),this.touchOccurring=!0)})),this.registerCanvasListener("mousemove",(e=>{this.touchOccurring&&this.touchOccurred(this.touchInfo(e,b.Move))})),this.registerCanvasListener("touchmove",(e=>{this.touchOccurring&&(e.preventDefault(),this.touchOccurred(this.touchInfo(e,b.Move)))})),this.registerCanvasListener("mouseup",(e=>{this.touchOccurring&&(this.touchOccurred(this.touchInfo(e,b.End)),this.touchOccurring=!1)})),this.registerCanvasListener("mouseout",(e=>{this.touchOccurring&&(this.touchOccurred(this.touchInfo(e,b.End)),this.touchOccurring=!1)})),this.registerCanvasListener("touchend",(e=>{this.touchOccurring&&(this.touchOccurred(this.touchInfo(e,b.End)),this.touchOccurring=!1)}))}cleanUpCanvasListeners(){this.canvasListeners.forEach((({type:e,listener:t})=>{this.canvas.removeEventListener(e,t)})),this.canvasListeners=[]}addTouchListener(e){this.touchListeners.push(e)}touchOccurred(e){for(const t of this.touchListeners)t(e)}registerCanvasListener(e,t){this.canvas.addEventListener(e,t),this.canvasListeners.push({type:e,listener:t})}touchInfo(e,t){const n=this.canvas.getBoundingClientRect(),i=this.canvas.width/n.width,r=this.canvas.height/n.height;return e instanceof MouseEvent?{x:(e.clientX-n.left)*i,y:(e.clientY-n.top)*r,touchType:t}:{x:(e.touches[0].clientX-n.left)*i,y:(e.touches[0].clientY-n.top)*r,touchType:t}}}var w=function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function o(e){try{c(i.next(e))}catch(e){a(e)}}function s(e){try{c(i.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((i=i.apply(e,t||[])).next())}))};const y=`https://cdn.jsdelivr.net/npm/deepar@${t}/`,P={video:{facingMode:"user",frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}},S="DEFAULT_SLOT";let T;function E(e){var t,n,i,r,a,o,s,c;let l;return l={modelPath:null,mediaPipeConfig:{wasmBasePath:null,modelPath:null}},e.rootPath&&(l.modelPath=e.rootPath+"models/segmentation/segmentation-160x160-opt.bin",l.mediaPipeConfig.modelPath=e.rootPath+"mediaPipe/segmentation/models/selfie_segmenter.tflite",l.mediaPipeConfig.wasmBasePath=e.rootPath+"mediaPipe/segmentation/wasm"),(null===(n=null===(t=null==e?void 0:e.additionalOptions)||void 0===t?void 0:t.segmentationConfig)||void 0===n?void 0:n.modelPath)&&(l.modelPath=e.additionalOptions.segmentationConfig.modelPath),(null===(a=null===(r=null===(i=null==e?void 0:e.additionalOptions)||void 0===i?void 0:i.segmentationConfig)||void 0===r?void 0:r.mediaPipeConfig)||void 0===a?void 0:a.modelPath)&&(l.mediaPipeConfig.modelPath=e.additionalOptions.segmentationConfig.mediaPipeConfig.modelPath),(null===(c=null===(s=null===(o=null==e?void 0:e.additionalOptions)||void 0===o?void 0:o.segmentationConfig)||void 0===s?void 0:s.mediaPipeConfig)||void 0===c?void 0:c.wasmBasePath)&&(l.mediaPipeConfig.wasmBasePath=e.additionalOptions.segmentationConfig.mediaPipeConfig.wasmBasePath),l}function x(e){return e.additionalOptions&&e.additionalOptions.faceTrackingConfig&&e.additionalOptions.faceTrackingConfig.modelPath?e.additionalOptions.faceTrackingConfig.modelPath:e.rootPath?e.rootPath+"models/face/models-68-extreme.bin":null}function C(e){let t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.detectorPath=e.rootPath+"models/face-cnn/face-det.bin",t.trackerPath=e.rootPath+"models/face-cnn/face-track-19.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.rigidFaceTrackingConfig&&(e.additionalOptions.rigidFaceTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.rigidFaceTrackingConfig.poseEstimationWasmPath),e.additionalOptions.rigidFaceTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.rigidFaceTrackingConfig.detectorPath),e.additionalOptions.rigidFaceTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.rigidFaceTrackingConfig.trackerPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function O(e){let t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/foot/foot-model.obj",t.detectorPath=e.rootPath+"models/foot/foot-detection-96x96x6.bin",t.trackerPath=e.rootPath+"models/foot/foot-tracker-96x96x18-test.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.footTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.footTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.footTrackingConfig.detectorPath),e.additionalOptions.footTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.footTrackingConfig.trackerPath),e.additionalOptions.footTrackingConfig.objPath&&(t.objPath=e.additionalOptions.footTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function A(e){let t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/wrist/wrist-base-2.obj",t.detectorPath=e.rootPath+"models/wrist/wrist-det-9.bin",t.trackerPath=e.rootPath+"models/wrist/wrist-track.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.wristTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.wristTrackingConfig.detectorPath),e.additionalOptions.wristTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.wristTrackingConfig.trackerPath),e.additionalOptions.wristTrackingConfig.objPath&&(t.objPath=e.additionalOptions.wristTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function j(e){var t,n,i,r;let a={backgroundBlurPath:"",backgroundReplacementPath:""};return e.rootPath&&(a.backgroundBlurPath=e.rootPath+"effects/background_blur.deepar",a.backgroundReplacementPath=e.rootPath+"effects/background_replacement.deepar"),(null===(n=null===(t=null==e?void 0:e.additionalOptions)||void 0===t?void 0:t.embeddedEffectsConfig)||void 0===n?void 0:n.backgroundBlurPath)&&(a.backgroundBlurPath=e.additionalOptions.embeddedEffectsConfig.backgroundBlurPath),(null===(r=null===(i=null==e?void 0:e.additionalOptions)||void 0===i?void 0:i.embeddedEffectsConfig)||void 0===r?void 0:r.backgroundReplacementPath)&&(a.backgroundReplacementPath=e.additionalOptions.embeddedEffectsConfig.backgroundReplacementPath),a}function F(e,t){return!(!e.additionalOptions||!e.additionalOptions.hint)&&("string"==typeof e.additionalOptions.hint?e.additionalOptions.hint===t:!!Array.isArray(e.additionalOptions.hint)&&e.additionalOptions.hint.some((e=>e===t)))}function M(){return"mediaDevices"in navigator&&"getUserMedia"in navigator.mediaDevices}function I(e){return w(this,void 0,void 0,(function*(){try{return yield import(e)}catch(t){try{return yield import("/"+e)}catch(n){throw console.error(`Failed to import DeepAR dynamic module ${e}. Some features might not work properly.`),t}}}))}let B=!1;function W(t){var n,i,r;return w(this,void 0,void 0,(function*(){if(B)throw new Error("DeepAR is already initialized. You cannot have multiple instances of DeepAR object. Call DeepAR.shutdown() first.");if(t.licenseKey){if("string"!=typeof t.licenseKey)throw new Error("Given licenseKey parameter is not a string.")}else{if(!t.licenceKey)throw new Error("No licenseKey parameter is passed in. You need to se the licenseKey string.");if("string"!=typeof t.licenceKey)throw new Error("Given licenseKey parameter is not a string.");t.licenseKey=t.licenceKey}if(!t.canvas&&!t.previewElement)throw new Error("No previewElement or canvas provided.");if(t.canvas&&t.previewElement)throw new Error("previewElement and canvas cannot be both provided at the same time. Use one or the other. previewElement is preferred.");if(t.canvas){if(!(t.canvas instanceof HTMLCanvasElement))throw new Error("The provided previewElement parameter is not a valid HTMLElement object. Please ensure you're passing an instance of an HTMLElement, such as a <div>, <span>, <p>, <a>, etc.")}else{if(!(t.previewElement instanceof HTMLElement))throw new Error("The given previewElement parameter is not an HTMLElement object.");t.canvas=function(e){if(m)throw new Error("Canvas is already created. Call invalidate() first.");const t=document.createElement("canvas");t.style.display="block",t.style.maxWidth="100%",t.style.maxHeight="100%";const n=getComputedStyle(e);return m={computedStyle:n,cssWidth:parseFloat(n.width||"0"),cssHeight:parseFloat(n.height||"0"),devicePixelRatio:window.devicePixelRatio||1,previewElement:e,canvas:t},p(t,m.cssWidth,m.cssHeight,m.devicePixelRatio),e.append(t),t}(t.previewElement)}var o;t.rootPath=(o=t.rootPath)?o.endsWith("/")?o:o+"/":y,t.rootPath!=y&&console.warn(`Using non-default root path (${t.rootPath}). Root path is used to fetch additional DeepAR files like ML models for face tracking. Root path must be the root directory of a DeepAR SDK downloaded from the https://developer.deepar.ai/downloads. The file structure must not be changed! It is also important that the version of the root path SDK and version of the running DeepAR SDK are the same.`);const s=function(e){var t,n,i,r;let a={xzimgPath:"",mediaPipePath:""};return e.rootPath&&(a.xzimgPath=e.rootPath+"js/dynamicModules/xzimg.esm.js",a.mediaPipePath=e.rootPath+"js/dynamicModules/mediaPipe.esm.js"),(null===(n=null===(t=null==e?void 0:e.additionalOptions)||void 0===t?void 0:t.dynamicModulesConfig)||void 0===n?void 0:n.xzimgPath)&&(a.xzimgPath=e.additionalOptions.dynamicModulesConfig.xzimgPath),(null===(r=null===(i=null==e?void 0:e.additionalOptions)||void 0===i?void 0:i.dynamicModulesConfig)||void 0===r?void 0:r.mediaPipePath)&&(a.mediaPipePath=e.additionalOptions.dynamicModulesConfig.mediaPipePath),a}(t);let c,l={licenseKey:t.licenseKey,canvasWidth:t.canvas.width,canvasHeight:t.canvas.height,canvas:t.canvas,faceTrackingModelPath:x(t),segmentationConfig:E(t),rigidFaceTrackingConfig:C(t),footTrackingConfig:O(t),wristTrackingConfig:A(t),embeddedEffectConfig:j(t),apiObject:{onInitialize:function(){}},initializeML:{faceModelsPredownload:F(t,"faceModelsPredownload"),segmentationModelsPredownload:F(t,"segmentationModelsPredownload"),footModelsPredownload:F(t,"footModelsPredownload"),segmentationInit:F(t,"segmentationInit"),footInit:F(t,"footInit"),rigidFaceInit:F(t,"rigidFaceTrackingInit"),useXzimgWebSegmentation:F(t,"useXzimgWebSegmentation")},dynamicImports:{xzimg:()=>I(s.xzimgPath),mediaPipe:()=>I(s.mediaPipePath)},customErrors:e,locateFile:(e,n)=>t.additionalOptions&&t.additionalOptions.deeparWasmPath?t.additionalOptions.deeparWasmPath:t.rootPath?t.rootPath+"wasm/deepar.wasm":n+e},u=!0,f=P,d=!0;if(t.additionalOptions&&t.additionalOptions.cameraConfig&&(t.additionalOptions.cameraConfig.disableDefaultCamera&&(d=!1),t.additionalOptions.cameraConfig.facingMode&&"environment"==t.additionalOptions.cameraConfig.facingMode&&(f.video.facingMode="environment",u=!1)),d){if(!M())throw new Error("No camera available!");null===(r=null===(i=null===(n=null==t?void 0:t.additionalOptions)||void 0===n?void 0:n.cameraConfig)||void 0===i?void 0:i.cameraPermissionAsked)||void 0===r||r.call(i),c=navigator.mediaDevices.getUserMedia(f)}let h,b=!1;t.effect&&(b=!0,h=fetch(t.effect));let k=yield a(l);k.initializeDeepAR(),B=!0,k.startLoop(),t.previewElement&&(k.addPreRenderListener(g),k.addPostRenderListener(v));const S=new _(k);let W=[];if(d&&W.push((()=>w(this,void 0,void 0,(function*(){var e,n,i;return T=document.createElement("video"),T.setAttribute("playsinline","playsinline"),T.srcObject=yield c,null===(i=null===(n=null===(e=null==t?void 0:t.additionalOptions)||void 0===e?void 0:e.cameraConfig)||void 0===n?void 0:n.cameraPermissionGranted)||void 0===i||i.call(n),new Promise((e=>{T.onloadedmetadata=()=>{T.play().then((()=>{k.setVideoElement(T,u),e()}))}}))})))()),b&&W.push((()=>w(this,void 0,void 0,(function*(){const e=yield h;if(!e.ok)throw new Error(`Failed to fetch ${t.effect}. HTTP status: ${e.status} (${e.statusText}).`);yield S.switchEffect(yield e.arrayBuffer())})))()),W.length>0)try{yield Promise.all(W)}catch(e){throw S.shutdown(),e}return S}))}class _{constructor(e){this.module=null,this.callbacks={},e.apiObject=this.callbacks,this.module=e,this.ScriptingAPI=new h(e),this.canvasTouchHelper=new k(e.canvas,(e=>this.touchOccurred(e)))}switchEffect(e,t){return w(this,void 0,void 0,(function*(){if(t){const e="face"in t&&"number"==typeof t.face,n="slot"in t&&"string"==typeof t.slot;if(e&&!n)throw new Error("Slot is not defined. When using switchEffect with a face parameter, you need to specify the slot also.")}const n=(null==t?void 0:t.face)?t.face:0,i=(null==t?void 0:t.slot)?t.slot:S;if(n<0||n>3)throw new Error(`Face value is ${n} but should be 0, 1, 2 or 3`);let r;if("string"==typeof e){const t=yield fetch(e);if(!t.ok)throw new Error(`Failed to fetch ${e}. HTTP status: ${t.status} (${t.statusText}).`);r=yield t.arrayBuffer()}else{if(!(e instanceof ArrayBuffer))throw new Error("The first parameter in switchEffect is not string or ArrayBuffer.");r=e}return new Promise(((e,t)=>{this.module.switchEffectByteArray(n,i,new Uint8Array(r),e,t)}))}))}clearEffect(e){this.module.clearEffect(e||S)}takeScreenshot(){return w(this,void 0,void 0,(function*(){return new Promise((e=>{this.module.takeScreenshot(e)}))}))}startVideoRecording(e){var t,n,i,r,a,u;return w(this,void 0,void 0,(function*(){const d=f.name.toLowerCase(),h={recordAudio:null!==(t=null==e?void 0:e.recordAudio)&&void 0!==t&&t,audioTrack:null!==(n=null==e?void 0:e.audioTrack)&&void 0!==n?n:void 0,audioSampleRate:48e3,audioBitRate:null!==(i=null==e?void 0:e.audioBitRate)&&void 0!==i?i:128e3,videoBitRate:null!==(r=null==e?void 0:e.videoBitRate)&&void 0!==r?r:4e6,videoFrameRate:null!==(a=null==e?void 0:e.videoFrameRate)&&void 0!==a?a:30,mimeType:"firefox"===d?"video/webm":"video/mp4"};if(!h.audioTrack&&h.recordAudio){let e=yield navigator.mediaDevices.getUserMedia({video:!1,audio:!0});h.audioTrack=e.getAudioTracks()[0]}"firefox"!==d&&(h.audioTrack?h.audioSampleRate=null!==(u=null==e?void 0:e.audioSampleRate)&&void 0!==u?u:h.audioTrack.getCapabilities().sampleRate.max:h.audioSampleRate=void 0),"safari"===d||"firefox"===d||"iOS"===f.os.family?function(e,t){if(l.isRecording)throw new Error("Video recording already started!");l.isRecording=!0,l.mimeType=t.mimeType;const n={videoBitsPerSecond:t.videoBitRate,mimeType:t.mimeType};let i=e.captureStream();t.audioTrack&&(i.addTrack(t.audioTrack),n.audioBitsPerSecond=t.audioBitRate),l.mediaRecorder=new MediaRecorder(i,n),l.mediaRecorder.ondataavailable=function(e){l.chunks.push(e.data)},l.mediaRecorder.start()}(this.module.canvas,h):("Android"===f.os.family&&h.audioTrack&&console.warn("Sound recording is currently not supported on Android"),yield function(e,t,n){return s(this,void 0,void 0,(function*(){if(!("VideoEncoder"in window))throw new Error("VideoEncoder API not available in this browser.");if("undefined"==typeof AudioEncoder&&n.audioTrack)throw new Error("Audio can't be recorded because AudioEncoder is not supported. Turn off audio recording and try again.");let i=e.width,r=e.height;const a=960;if(i>r){let e=1;i>a&&(e=a/i,i=a,r=Math.round(r*e))}else if(r>i){let e=1;r>a&&(e=a/r,r=a,i=Math.round(i*e))}if(i=i%2==0?i:i-1,r=r%2==0?r:r-1,c.audioTrack=n.audioTrack,c.muxer=new o.Muxer({target:new o.ArrayBufferTarget,video:{codec:"avc",width:i,height:r},audio:c.audioTrack?{codec:"aac",sampleRate:n.audioSampleRate,numberOfChannels:1}:void 0,firstTimestampBehavior:"offset"}),c.audioTrack){c.audioEncoder=new AudioEncoder({output:(e,t)=>c.muxer.addAudioChunk(e,t),error:e=>console.error(e)});const e={codec:"mp4a.40.2",numberOfChannels:1,sampleRate:n.audioSampleRate,bitrate:n.audioBitRate};c.audioEncoder.configure(e);let t=new MediaStreamTrackProcessor({track:c.audioTrack}),i=new WritableStream({write(e){c.isRecording&&(c.audioEncoder.encode(e),e.close())}});t.readable.pipeTo(i)}const s={error:e=>{console.error(e)},output:(e,t)=>{c.muxer.addVideoChunk(e,t)}},l={codec:"avc1.4d002a",width:i,height:r,bitrate:n.videoBitRate,framerate:n.videoFrameRate},{supported:u}=yield VideoEncoder.isConfigSupported(l);if(!u)throw console.log("config:"),console.log(l),new Error("Encoder config not supported.");c.videoEncoder=new VideoEncoder(s),c.videoEncoder.configure(l),console.log(`Video resolution will be ${i}x${r}.`);let f=performance.now(),d=e,h=0,m=0;c.isRecording=!0,t.__deeparRendered2=function(){const e=performance.now(),t=e-f;if(f=e,c.isRecording){const e=m+1e3*t,n=new VideoFrame(d,{timestamp:e});h++,m=e;const i=h%300==0;c.videoEncoder.encode(n,{keyFrame:i}),n.close()}}}))}(this.module.canvas,this.callbacks,h))}))}finishVideoRecording(){return w(this,void 0,void 0,(function*(){let e;const t=f.name.toLowerCase();return e="safari"===t||"firefox"===t||"iOS"===f.os.family?yield function(){if(!l.isRecording)throw new Error("Video recording not started!");return new Promise((e=>{l.mediaRecorder.onstop=function(t){e(new Blob(l.chunks,{type:l.mimeType})),l.chunks=[],l.isRecording=!1},l.mediaRecorder.stop()}))}():yield function(e){var t;return s(this,void 0,void 0,(function*(){if(!c.isRecording)throw new Error("Cannot finish video recording because recording was not started!");c.isRecording=!1,null===(t=c.audioTrack)||void 0===t||t.stop(),yield c.videoEncoder.flush(),c.audioEncoder&&(yield c.audioEncoder.flush()),c.muxer.finalize(),e.__deeparRendered2=void 0;const n=new Blob([c.muxer.target.buffer],{type:"video/mp4"});return c.muxer=null,c.videoEncoder=null,c.audioEncoder=null,c.audioTrack=null,n}))}(this.callbacks),e}))}backgroundBlur(e,t){return w(this,void 0,void 0,(function*(){if(e&&!t)throw new Error("backgroundBlur expected second argument: blur strength, a integer number in range 1-10");return new Promise(((n,i)=>{this.module.backgroundBlur(e,t,n,i)}))}))}backgroundReplacement(e,t){return w(this,void 0,void 0,(function*(){if(e&&!t)throw new Error("backgroundReplacement expected second argument: url of the image to be used as the background");return new Promise(((n,i)=>{this.module.backgroundReplacement(e,t,n,i)}))}))}startCamera(e){return w(this,void 0,void 0,(function*(){if(!M())throw new Error("No camera available!");return new Promise(((t,n)=>{var i,r;this.module.startCamera(null===(i=null==e?void 0:e.mirror)||void 0===i||i,null!==(r=null==e?void 0:e.mediaStreamConstraints)&&void 0!==r?r:P,t,n,null==e?void 0:e.cameraPermissionAsked,null==e?void 0:e.cameraPermissionGranted),this.module.startLoop()}))}))}stopCamera(){this.stopVideo()}stopVideo(){T&&(T.srcObject.getTracks().forEach((e=>{e.stop()})),T=null),this.module.stopVideo()}setVideoElement(e,t){if(!e)throw new Error("No video element provided.");this.stopVideo(),this.module.setVideoElement(e,t),this.module.startLoop()}shutdown(){this.canvasTouchHelper.cleanUpCanvasListeners(),this.module.shutdown(),m&&(m.canvas.remove(),m=null),B=!1,this.module=void 0}muteSound(e){null==e?(console.warn("muteSound called without arguments, assuming you meant to say muteSound(true)"),console.trace(),this.module.muteSound(!0)):this.module.muteSound(e)}processFrame(e,t,n,i){this.module.processFrameRawPixels(e,t,n,i)}processImage(e){const t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});t.width=e.width,t.height=e.height,n.drawImage(e,0,0);const i=n.getImageData(0,0,t.width,t.height),r=new Uint8Array(i.data.buffer);this.processFrame(r,e.width,e.height,!1)}setPaused(e){e?this.module.endLoop():this.module.startLoop()}changeParameterFloat(e,t,n,i){this.module.changeParameterFloat(e,null==t?"":t,n,i)}changeParameterBool(e,t,n,i){this.module.changeParameterBool(e,null==t?"":t,n,i)}changeParameterVector(e,t,n,i,r,a,o){this.module.changeParameterVector(e,null==t?"":t,n,i,r,a,o)}changeParameterTexture(e,t,n,i){const r=new Image;r.onload=()=>{const i=document.createElement("canvas"),a=i.getContext("2d",{willReadFrequently:!0});i.width=r.width,i.height=r.height,a.drawImage(r,0,0);const o=a.getImageData(0,0,i.width,i.height),s=new Uint8Array(o.data.buffer),c=this.module._malloc(s.length);this.module.HEAPU8.set(s,c),this.module.changeParameterTexture(e,null==t?"":t,n,c,s.length,i.width,i.height)},r.src=i}fireTrigger(e){this.module.fireTrigger(e)}setFaceDetectionSensitivity(e){this.module.setFaceDetectionSensitivity(e)}setOffscreenRenderingEnabled(e){this.module.setOffscreenRenderingEnabled(e)}getCanvas(){return this.module.canvas}setFps(e){this.module.setFps(e)}initializeFootTracking(){this.module.initializeFootTracking()}isFootTrackingInitialized(){return this.module.isFootTrackingInitialized()}initializeSegmentation(){this.module.initializeSegmentation()}isSegmentationInitialized(){return this.module.isSegmentationInitialized()}isWristTrackingInitialized(){return this.module.isWristTrackingInitialized()}showStats(e){this.module.showStats(e)}simulatePhysics(e){this.module.simulatePhysics(e)}moveGameObject(e,t){this.module.moveGameObject(e,t)}touchOccurred(e){e.x/=this.module.canvasWidth,e.y/=this.module.canvasHeight,this.module.touchOccurred(e)}enableAutoframing(e){this.module._enableAutoframing(e)}getConsoleLogs(){return this.module.getConsoleLogs()}pushConsoleLog(e,t){return this.module.pushConsoleLog(e,t)}showColliders(e){this.module.showColliders(e)}setZoom(e){this.module._setZoom(e)}}})(),i})()));
|