/* Human homepage: author: ' */ var Human=(()=>{var Jc=Object.defineProperty;var aR=Object.getOwnPropertyDescriptor;var sR=Object.getOwnPropertyNames;var iR=Object.prototype.hasOwnProperty;var oR=(e,t,r)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var vs=(e,t)=>{for(var r in t)Jc(e,r,{get:t[r],enumerable:!0})},lR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of sR(t))!iR.call(e,a)&&a!==r&&Jc(e,a,{get:()=>t[a],enumerable:!(n=aR(t,a))||n.enumerable});return e};var uR=e=>lR(Jc({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>(oR(e,typeof t!="symbol"?t+"":t,r),r),Ub=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var vp=(e,t,r)=>(Ub(e,t,"read from private field"),r?r.call(e):t.get(e)),wp=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},kp=(e,t,r,n)=>(Ub(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var fAe={};vs(fAe,{Human:()=>vb,default:()=>vb,defaults:()=>ws,draw:()=>fb,env:()=>he,match:()=>bb,models:()=>C1});function se(...e){let t=new Date,r=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(r,"Human:",...e)}function Gb(e,t){let r=e.endsWith("/")?"":"/",a=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${r}${t}`;if(!a.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: expecting json file: ${a}`);return a}var oe=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function pg(e,t,r="config",n=[]){for(let a of Object.keys(t))if(typeof t[a]=="object")pg(e[a],t[a],a,n);else{let s=e&&typeof e[a]!="undefined";s||n.push({reason:"unknown property",where:`${r}.${a} = ${t[a]}`});let i=e&&typeof e[a]==typeof t[a];s&&!i&&n.push({reason:"property type mismatch",where:`${r}.${a} = ${t[a]}`,expected:typeof e[a]})}return t.debug&&r==="config"&&n.length>0&&se("invalid configuration",n),n}function Gt(...e){let t=r=>r&&typeof r=="object";return e.reduce((r,n)=>(Object.keys(n||{}).forEach(a=>{let s=r[a],i=n[a];Array.isArray(s)&&Array.isArray(i)?r[a]=s.concat(...i):t(s)&&t(i)?r[a]=Gt(s,i):r[a]=i}),r),{})}var ws={backend:"",modelBasePath:"",cacheModels:!0,wasmPath:"",wasmPlatformFetch:!1,debug:!0,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!1,deallocate:!1,filter:{enabled:!0,equalization:!1,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,mask:!1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json",keepInvalid:!1},attention:{enabled:!1,modelPath:"facemesh-attention.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"},liveness:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"liveness.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:1e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handlandmark-full.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:2e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var Ue={};vs(Ue,{Abs:()=>Uo,Acos:()=>ju,Acosh:()=>Hu,AdadeltaOptimizer:()=>rm,AdagradOptimizer:()=>nm,AdamOptimizer:()=>am,AdamaxOptimizer:()=>sm,Add:()=>Ja,AddN:()=>Ks,All:()=>qu,Any:()=>Xu,ArgMax:()=>Zs,ArgMin:()=>Ku,Asin:()=>Zu,Asinh:()=>Yu,Atan:()=>Ju,Atan2:()=>ed,Atanh:()=>Qu,AvgPool:()=>Ys,AvgPool3D:()=>nh,AvgPool3DGrad:()=>uf,AvgPoolGrad:()=>lf,BackendWasm:()=>TC,BatchMatMul:()=>Js,BatchToSpaceND:()=>Go,Bincount:()=>df,BroadcastArgs:()=>pf,BroadcastTo:()=>q7,Callback:()=>T8,CallbackList:()=>Tw,Cast:()=>Qs,Ceil:()=>ei,ClipByValue:()=>Qa,Complex:()=>ah,ComplexAbs:()=>sh,Concat:()=>jo,Conv2D:()=>ti,Conv2DBackpropFilter:()=>hf,Conv2DBackpropInput:()=>ri,Conv3D:()=>ih,Conv3DBackpropFilterV2:()=>cf,Conv3DBackpropInputV2:()=>ff,Cos:()=>ni,Cosh:()=>ai,CropAndResize:()=>qo,Cumprod:()=>Ho,Cumsum:()=>si,CustomCallback:()=>Ew,DataStorage:()=>rh,DenseBincount:()=>mf,DepthToSpace:()=>Xo,DepthwiseConv2dNative:()=>ii,DepthwiseConv2dNativeBackpropFilter:()=>gf,DepthwiseConv2dNativeBackpropInput:()=>yf,Diag:()=>Af,Dilation2D:()=>oh,Dilation2DBackpropFilter:()=>T0,Dilation2DBackpropInput:()=>C0,ENV:()=>ba,EarlyStopping:()=>N8,Einsum:()=>lh,Elu:()=>li,EluGrad:()=>xf,Environment:()=>j7,Equal:()=>Ko,Erf:()=>td,Exp:()=>ui,ExpandDims:()=>Zo,Expm1:()=>Yo,FFT:()=>bf,Fill:()=>rd,FlipLeftRight:()=>Jo,Floor:()=>di,FloorDiv:()=>pi,FromPixels:()=>Gp,FusedBatchNorm:()=>hi,FusedConv2D:()=>Ps,FusedDepthwiseConv2D:()=>Os,GPGPUContext:()=>Cu,GatherNd:()=>el,GatherV2:()=>Qo,GraphModel:()=>Vh,Greater:()=>tl,GreaterEqual:()=>ci,History:()=>Nw,IFFT:()=>vf,Identity:()=>fi,Imag:()=>uh,InputSpec:()=>Zt,IsFinite:()=>nd,IsInf:()=>ad,IsNan:()=>sd,KernelBackend:()=>Uu,LRN:()=>dh,LRNGrad:()=>kf,LayerVariable:()=>Aw,LayersModel:()=>Ka,LeakyRelu:()=>mi,Less:()=>rl,LessEqual:()=>nl,LinSpace:()=>wf,Log:()=>gi,Log1p:()=>id,LogSoftmax:()=>K7,LogicalAnd:()=>al,LogicalNot:()=>sl,LogicalOr:()=>od,LogicalXor:()=>X7,LowerBound:()=>e$,MathBackendCPU:()=>dA,MathBackendWebGL:()=>Hh,Max:()=>yi,MaxPool:()=>xi,MaxPool3D:()=>ph,MaxPool3DGrad:()=>Sf,MaxPoolGrad:()=>If,MaxPoolWithArgmax:()=>Cf,Maximum:()=>Ai,Mean:()=>bi,Min:()=>vi,Minimum:()=>wi,MirrorPad:()=>ki,Mod:()=>ld,MomentumOptimizer:()=>im,Multinomial:()=>Tf,Multiply:()=>Ii,Neg:()=>il,NonMaxSuppressionV3:()=>ll,NonMaxSuppressionV4:()=>ud,NonMaxSuppressionV5:()=>ul,NotEqual:()=>ol,OP_SCOPE_SUFFIX:()=>d6,OneHot:()=>pl,OnesLike:()=>dl,Optimizer:()=>ns,OptimizerConstructors:()=>Is,Pack:()=>hl,PadV2:()=>Si,Pool:()=>t$,Pow:()=>Ci,Prelu:()=>Ti,Prod:()=>Ni,RMSPropOptimizer:()=>om,RNN:()=>as,Range:()=>dd,Rank:()=>e6,Real:()=>hh,RealDiv:()=>oi,Reciprocal:()=>pd,Reduction:()=>rw,Relu:()=>Ei,Relu6:()=>$i,Reshape:()=>cl,ResizeBilinear:()=>Ri,ResizeBilinearGrad:()=>Ef,ResizeNearestNeighbor:()=>hd,ResizeNearestNeighborGrad:()=>Nf,Reverse:()=>fl,RotateWithOffset:()=>Nl,Round:()=>ml,Rsqrt:()=>Mi,SGDOptimizer:()=>Mh,ScatterNd:()=>gl,SearchSorted:()=>Rf,Select:()=>yl,Selu:()=>cd,Sequential:()=>vm,Sigmoid:()=>_i,Sign:()=>fd,Sin:()=>Fi,Sinh:()=>xl,Slice:()=>Al,Softmax:()=>zi,Softplus:()=>md,SpaceToBatchND:()=>bl,SparseFillEmptyRows:()=>ch,SparseReshape:()=>gd,SparseSegmentMean:()=>fh,SparseSegmentSum:()=>mh,SparseToDense:()=>gh,SplitV:()=>vl,Sqrt:()=>Pi,Square:()=>yd,SquaredDifference:()=>Di,Step:()=>Wi,StridedSlice:()=>wl,StringNGrams:()=>yh,StringSplit:()=>$f,StringToHashBucketFast:()=>Mf,Sub:()=>Li,Sum:()=>Oi,SymbolicTensor:()=>pa,Tan:()=>kl,Tanh:()=>Bi,Tensor:()=>nt,TensorBuffer:()=>ir,Tile:()=>es,TopK:()=>Il,Transform:()=>Sl,Transpose:()=>$a,Unique:()=>Ff,Unpack:()=>Cl,UnsortedSegmentSum:()=>Ah,UpperBound:()=>r$,Variable:()=>qp,ZerosLike:()=>Tl,_FusedMatMul:()=>_s,abs:()=>ar,acos:()=>j6,acosh:()=>H6,add:()=>le,addN:()=>Pf,all:()=>Zy,any:()=>F0,argMax:()=>$n,argMin:()=>q6,asin:()=>X6,asinh:()=>K6,atan:()=>Z6,atan2:()=>Y6,atanh:()=>J6,avgPool:()=>Of,avgPool3d:()=>Jy,backend:()=>Dn,backend_util:()=>C,basicLSTMCell:()=>qF,batchNorm:()=>$u,batchNorm2d:()=>rv,batchNorm3d:()=>nv,batchNorm4d:()=>av,batchToSpaceND:()=>zf,bincount:()=>Qy,booleanMaskAsync:()=>iz,broadcastArgs:()=>sv,broadcastTo:()=>Lp,broadcast_util:()=>Rl,browser:()=>Ln,buffer:()=>De,callbacks:()=>zj,cast:()=>me,ceil:()=>iv,clipByValue:()=>fn,clone:()=>Vr,complex:()=>Za,concat:()=>St,concat1d:()=>ov,concat2d:()=>xd,concat3d:()=>lv,concat4d:()=>uv,constraints:()=>kw,conv1d:()=>e3,conv2d:()=>Ds,conv2dTranspose:()=>r3,conv3d:()=>n3,conv3dTranspose:()=>pv,copyRegisteredKernels:()=>i$,cos:()=>Df,cosh:()=>a3,cosineWindow:()=>N3,cumprod:()=>P0,cumsum:()=>s3,customGrad:()=>Pa,data:()=>Q8,denseBincount:()=>hv,deprecationWarn:()=>By,depthToSpace:()=>cv,depthwiseConv2d:()=>Th,deregisterOp:()=>Bj,device_util:()=>wh,diag:()=>I_,dilation2d:()=>fv,disableDeprecationWarnings:()=>_M,dispose:()=>te,disposeVariables:()=>PM,div:()=>pe,divNoNan:()=>mv,dot:()=>$_,dropout:()=>qv,einsum:()=>gv,elu:()=>Nh,enableDebugMode:()=>FM,enableProdMode:()=>Ly,enclosingPowerOfTwo:()=>Xv,engine:()=>Xt,env:()=>Z,equal:()=>Mn,erf:()=>yv,euclideanNorm:()=>wv,exp:()=>Fn,expandDims:()=>Kt,expm1:()=>kv,eye:()=>l3,fft:()=>Kf,fill:()=>bd,findBackend:()=>Vy,findBackendFactory:()=>LM,floor:()=>Eh,floorDiv:()=>Sh,forceHalfFloat:()=>bI,fused:()=>Ws,gather:()=>Mu,gatherND:()=>Hv,gather_util:()=>Uy,getBackend:()=>Hr,getGradient:()=>Tg,getKernel:()=>N0,getKernelsForBackend:()=>Fa,getThreadsCount:()=>u3e,gpgpu_util:()=>Y9,grad:()=>pP,grads:()=>hP,greater:()=>gn,greaterEqual:()=>$l,ifft:()=>Zp,imag:()=>Ih,image:()=>Ie,inTopKAsync:()=>gz,initializers:()=>Iw,input:()=>Uw,io:()=>Cr,irfft:()=>I3,isFinite:()=>tP,isInf:()=>nP,isNaN:()=>Iv,keep:()=>mr,kernel_impls:()=>Kn,layers:()=>Sw,leakyRelu:()=>Bf,less:()=>u3,lessEqual:()=>Ml,linalg:()=>nw,linspace:()=>Sv,loadGraphModel:()=>UH,loadGraphModelSync:()=>GH,loadLayersModel:()=>XU,localResponseNormalization:()=>Cv,log:()=>_n,log1p:()=>Wf,logSigmoid:()=>yP,logSoftmax:()=>d3,logSumExp:()=>Nv,logicalAnd:()=>ga,logicalNot:()=>Uf,logicalOr:()=>p3,logicalXor:()=>SP,losses:()=>eL,lowerBound:()=>Ev,matMul:()=>Ye,math:()=>C6,max:()=>yr,maxPool:()=>Gf,maxPool3d:()=>c3,maxPoolWithArgmax:()=>Rv,maximum:()=>ts,mean:()=>Vt,memory:()=>M0,meshgrid:()=>MP,metrics:()=>I8,min:()=>Ls,minimum:()=>Rh,mirrorPad:()=>$v,mod:()=>wd,model:()=>HU,models:()=>S8,moments:()=>jf,movingAverage:()=>lz,mul:()=>L,multiRNNCell:()=>DP,multinomial:()=>Mv,neg:()=>Mt,nextFrame:()=>$3,norm:()=>Lf,notEqual:()=>Fu,oneHot:()=>Kp,ones:()=>cn,onesLike:()=>Pn,op:()=>W,outerProduct:()=>UP,pad:()=>Xn,pad1d:()=>HP,pad2d:()=>XP,pad3d:()=>ZP,pad4d:()=>JP,pool:()=>nO,pow:()=>Bs,prelu:()=>qf,print:()=>b6,prod:()=>f3,profile:()=>OM,rand:()=>oO,randomGamma:()=>pO,randomNormal:()=>Fv,randomUniform:()=>kd,range:()=>_u,ready:()=>Ad,real:()=>Eu,reciprocal:()=>_v,registerBackend:()=>El,registerCallbackConstructor:()=>KU,registerGradient:()=>Z7,registerKernel:()=>qn,registerOp:()=>Lj,regularizers:()=>C8,relu:()=>Da,relu6:()=>y3,removeBackend:()=>DM,reshape:()=>U,reverse:()=>On,reverse1d:()=>xO,reverse2d:()=>vO,reverse3d:()=>kO,reverse4d:()=>SO,rfft:()=>Zf,round:()=>A3,rsqrt:()=>x3,scalar:()=>Se,scatterND:()=>jv,scatter_util:()=>Gy,searchSorted:()=>h3,selu:()=>b3,separableConv2d:()=>Pv,sequential:()=>qU,serialization:()=>ue,setBackend:()=>Wy,setPlatform:()=>BM,setThreadsCount:()=>l3e,setWasmPath:()=>o3e,setWasmPaths:()=>jA,setWebGLContext:()=>Mm,setdiff1dAsync:()=>Ov,shared:()=>Rm,sigmoid:()=>Tr,sign:()=>zv,signal:()=>QD,sin:()=>v3,sinh:()=>w3,slice:()=>_e,slice1d:()=>Xf,slice2d:()=>k3,slice3d:()=>Fl,slice4d:()=>_o,slice_util:()=>Dt,softmax:()=>Id,softplus:()=>vd,spaceToBatchND:()=>Hf,sparse:()=>Rp,sparseToDense:()=>T3,spectral:()=>JD,split:()=>Yt,sqrt:()=>Er,square:()=>bt,squaredDifference:()=>S3,squeeze:()=>et,stack:()=>ur,step:()=>$h,stridedSlice:()=>Dv,string:()=>c0,sub:()=>ce,sum:()=>ke,sumOutType:()=>vh,tan:()=>Lv,tanh:()=>Ru,tensor:()=>ft,tensor1d:()=>Nt,tensor2d:()=>ca,tensor3d:()=>N6,tensor4d:()=>ZO,tensor5d:()=>YO,tensor6d:()=>JO,tensor_util:()=>ha,test_util:()=>V6,tidy:()=>X,tile:()=>jn,time:()=>zM,topk:()=>Bv,train:()=>yo,transpose:()=>tt,truncatedNormal:()=>Yf,unique:()=>Bg,unregisterGradient:()=>s$,unregisterKernel:()=>a$,unsortedSegmentSum:()=>Wv,unstack:()=>an,upcastType:()=>Nr,upperBound:()=>Vv,util:()=>v,valueAndGrad:()=>cP,valueAndGrads:()=>fP,variable:()=>Uv,variableGrads:()=>Tv,version:()=>rc,version_converter:()=>HH,version_core:()=>Ky,version_cpu:()=>MX,version_layers:()=>e5,version_wasm:()=>d3e,version_webgl:()=>lre,webgl:()=>ure,webgl_util:()=>v9,webgpu:()=>wS,where:()=>Ur,whereAsync:()=>C3,zeros:()=>Ot,zerosLike:()=>at});var dR=Object.create,nf=Object.defineProperty,pR=Object.getOwnPropertyDescriptor,F7=Object.getOwnPropertyNames,hR=Object.getPrototypeOf,cR=Object.prototype.hasOwnProperty,fR=e=>nf(e,"__esModule",{value:!0}),dr=(e,t)=>function(){return t||(0,e[F7(e)[0]])((t={exports:{}}).exports,t),t.exports},Be=(e,t)=>{for(var r in t)nf(e,r,{get:t[r],enumerable:!0})},mR=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of F7(t))!cR.call(e,a)&&(r||a!=="default")&&nf(e,a,{get:()=>t[a],enumerable:!(n=pR(t,a))||n.enumerable});return e},Wo=(e,t)=>mR(fR(nf(e!=null?dR(hR(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),gR=dr({"src/node_modules/long/src/long.js"(e,t){t.exports=n;var r=null;try{r=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(S){}function n(S,P,z){this.low=S|0,this.high=P|0,this.unsigned=!!z}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0});function a(S){return(S&&S.__isLong__)===!0}n.isLong=a;var s={},i={};function o(S,P){var z,j,K;return P?(S>>>=0,(K=0<=S&&S<256)&&(j=i[S],j)?j:(z=u(S,(S|0)<0?-1:0,!0),K&&(i[S]=z),z)):(S|=0,(K=-128<=S&&S<128)&&(j=s[S],j)?j:(z=u(S,S<0?-1:0,!1),K&&(s[S]=z),z))}n.fromInt=o;function l(S,P){if(isNaN(S))return P?b:x;if(P){if(S<0)return b;if(S>=g)return R}else{if(S<=-y)return O;if(S+1>=y)return E}return S<0?l(-S,P).neg():u(S%f|0,S/f|0,P)}n.fromNumber=l;function u(S,P,z){return new n(S,P,z)}n.fromBits=u;var d=Math.pow;function h(S,P,z){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof P=="number"?(z=P,P=!1):P=!!P,z=z||10,z<2||360)throw Error("interior hyphen");if(j===0)return h(S.substring(1),P,z).neg();for(var K=l(d(z,8)),D=x,Y=0;Y>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},$.toString=function(S){if(S=S||10,S<2||36>>0,Q=re.toString(S);if(D=V,D.isZero())return Q+Y;for(;Q.length<6;)Q="0"+Q;Y=""+Q+Y}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,P=31;P>0&&(S&1<=0},$.isOdd=function(){return(this.low&1)===1},$.isEven=function(){return(this.low&1)===0},$.equals=function(S){return a(S)||(S=p(S)),this.unsigned!==S.unsigned&&this.high>>>31===1&&S.high>>>31===1?!1:this.high===S.high&&this.low===S.low},$.eq=$.equals,$.notEquals=function(S){return!this.eq(S)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(S){return this.comp(S)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(S){return this.comp(S)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(S){return this.comp(S)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(S){return this.comp(S)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(S){if(a(S)||(S=p(S)),this.eq(S))return 0;var P=this.isNegative(),z=S.isNegative();return P&&!z?-1:!P&&z?1:this.unsigned?S.high>>>0>this.high>>>0||S.high===this.high&&S.low>>>0>this.low>>>0?-1:1:this.sub(S).isNegative()?-1:1},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(w)},$.neg=$.negate,$.add=function(S){a(S)||(S=p(S));var P=this.high>>>16,z=this.high&65535,j=this.low>>>16,K=this.low&65535,D=S.high>>>16,Y=S.high&65535,V=S.low>>>16,re=S.low&65535,Q=0,ie=0,J=0,ae=0;return ae+=K+re,J+=ae>>>16,ae&=65535,J+=j+V,ie+=J>>>16,J&=65535,ie+=z+Y,Q+=ie>>>16,ie&=65535,Q+=P+D,Q&=65535,u(J<<16|ae,Q<<16|ie,this.unsigned)},$.subtract=function(S){return a(S)||(S=p(S)),this.add(S.neg())},$.sub=$.subtract,$.multiply=function(S){if(this.isZero())return x;if(a(S)||(S=p(S)),r){var P=r.mul(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(O))return S.isOdd()?O:x;if(S.eq(O))return this.isOdd()?O:x;if(this.isNegative())return S.isNegative()?this.neg().mul(S.neg()):this.neg().mul(S).neg();if(S.isNegative())return this.mul(S.neg()).neg();if(this.lt(A)&&S.lt(A))return l(this.toNumber()*S.toNumber(),this.unsigned);var z=this.high>>>16,j=this.high&65535,K=this.low>>>16,D=this.low&65535,Y=S.high>>>16,V=S.high&65535,re=S.low>>>16,Q=S.low&65535,ie=0,J=0,ae=0,de=0;return de+=D*Q,ae+=de>>>16,de&=65535,ae+=K*Q,J+=ae>>>16,ae&=65535,ae+=D*re,J+=ae>>>16,ae&=65535,J+=j*Q,ie+=J>>>16,J&=65535,J+=K*re,ie+=J>>>16,J&=65535,J+=D*V,ie+=J>>>16,J&=65535,ie+=z*Q+j*re+K*V+D*Y,ie&=65535,u(ae<<16|de,ie<<16|J,this.unsigned)},$.mul=$.multiply,$.divide=function(S){if(a(S)||(S=p(S)),S.isZero())throw Error("division by zero");if(r){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var P=(this.unsigned?r.div_u:r.div_s)(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var z,j,K;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return b;if(S.gt(this.shru(1)))return I;K=b}else{if(this.eq(O)){if(S.eq(w)||S.eq(T))return O;if(S.eq(O))return w;var D=this.shr(1);return z=D.div(S).shl(1),z.eq(x)?S.isNegative()?w:T:(j=this.sub(S.mul(z)),K=z.add(j.div(S)),K)}else if(S.eq(O))return this.unsigned?b:x;if(this.isNegative())return S.isNegative()?this.neg().div(S.neg()):this.neg().div(S).neg();if(S.isNegative())return this.div(S.neg()).neg();K=x}for(j=this;j.gte(S);){z=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Y=Math.ceil(Math.log(z)/Math.LN2),V=Y<=48?1:d(2,Y-48),re=l(z),Q=re.mul(S);Q.isNegative()||Q.gt(j);)z-=V,re=l(z,this.unsigned),Q=re.mul(S);re.isZero()&&(re=w),K=K.add(re),j=j.sub(Q)}return K},$.div=$.divide,$.modulo=function(S){if(a(S)||(S=p(S)),r){var P=(this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,S.low,S.high);return u(P,r.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return u(~this.low,~this.high,this.unsigned)},$.and=function(S){return a(S)||(S=p(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},$.or=function(S){return a(S)||(S=p(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},$.xor=function(S){return a(S)||(S=p(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},$.shiftLeft=function(S){return a(S)&&(S=S.toInt()),(S&=63)===0?this:S<32?u(this.low<>>32-S,this.unsigned):u(0,this.low<>>S|this.high<<32-S,this.high>>S,this.unsigned):u(this.high>>S-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(S){if(a(S)&&(S=S.toInt()),S&=63,S===0)return this;var P=this.high;if(S<32){var z=this.low;return u(z>>>S|P<<32-S,P>>>S,this.unsigned)}else return S===32?u(P,0,this.unsigned):u(P>>>S-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},$.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var S=this.high,P=this.low;return[P&255,P>>>8&255,P>>>16&255,P>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},$.toBytesBE=function(){var S=this.high,P=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,P>>>24,P>>>16&255,P>>>8&255,P&255]},n.fromBytes=function(S,P,z){return z?n.fromBytesLE(S,P):n.fromBytesBE(S,P)},n.fromBytesLE=function(S,P){return new n(S[0]|S[1]<<8|S[2]<<16|S[3]<<24,S[4]|S[5]<<8|S[6]<<16|S[7]<<24,P)},n.fromBytesBE=function(S,P){return new n(S[4]<<24|S[5]<<16|S[6]<<8|S[7],S[0]<<24|S[1]<<16|S[2]<<8|S[3],P)}}}),yR=dr({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),AR=dr({"(disabled):util"(){}}),xR=dr({"src/node_modules/seedrandom/lib/alea.js"(e,t){(function(r,n,a){function s(u){var d=this,h=l();d.next=function(){var p=2091639*d.s0+d.c*23283064365386963e-26;return d.s0=d.s1,d.s1=d.s2,d.s2=p-(d.c=p|0)},d.c=1,d.s0=h(" "),d.s1=h(" "),d.s2=h(" "),d.s0-=h(u),d.s0<0&&(d.s0+=1),d.s1-=h(u),d.s1<0&&(d.s1+=1),d.s2-=h(u),d.s2<0&&(d.s2+=1),h=null}function i(u,d){return d.c=u.c,d.s0=u.s0,d.s1=u.s1,d.s2=u.s2,d}function o(u,d){var h=new s(u),p=d&&d.state,c=h.next;return c.int32=function(){return h.next()*4294967296|0},c.double=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.quick=c,p&&(typeof p=="object"&&i(p,h),c.state=function(){return i(h,{})}),c}function l(){var u=4022871197,d=function(h){h=String(h);for(var p=0;p>>0,c-=u,c*=u,u=c>>>0,c-=u,u+=c*4294967296}return(u>>>0)*23283064365386963e-26};return d}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),bR=dr({"src/node_modules/seedrandom/lib/xor128.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var p=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^p^p>>>8},l===(l|0)?u.x=l:d+=l;for(var h=0;h>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),vR=dr({"src/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.next=function(){var p=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(p^p<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:d+=l;for(var h=0;h>>4),u.next()}function i(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function o(l,u){var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),wR=dr({"src/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(r,n,a){function s(l){var u=this;u.next=function(){var h=u.x,p=u.i,c,m,f;return c=h[p],c^=c>>>7,m=c^c<<24,c=h[p+1&7],m^=c^c>>>10,c=h[p+3&7],m^=c^c>>>3,c=h[p+4&7],m^=c^c<<7,c=h[p+7&7],c=c^c<<13,m^=c^c<<9,h[p]=m,u.i=p+1&7,m};function d(h,p){var c,m,f=[];if(p===(p|0))m=f[0]=p;else for(p=""+p,c=0;c0;--c)h.next()}d(u,l)}function i(l,u){return u.x=l.x.slice(),u.i=l.i,u}function o(l,u){l==null&&(l=+new Date);var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(h.x&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),kR=dr({"src/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(r,n,a){function s(l){var u=this;u.next=function(){var h=u.w,p=u.X,c=u.i,m,f;return u.w=h=h+1640531527|0,f=p[c+34&127],m=p[c=c+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=p[c]=f^m,u.i=c,f+(h^h>>>16)|0};function d(h,p){var c,m,f,g,y,A=[],x=128;for(p===(p|0)?(m=p,p=null):(p=p+"\0",m=0,x=Math.max(x,p.length)),f=0,g=-32;g>>15,m^=m<<4,m^=m>>>13,g>=0&&(y=y+1640531527|0,c=A[g&127]^=m+y,f=c==0?f+1:0);for(f>=128&&(A[(p&&p.length||0)&127]=-1),f=127,g=4*128;g>0;--g)m=A[f+34&127],c=A[f=f+1&127],m^=m<<13,c^=c<<17,m^=m>>>15,c^=c>>>12,A[f]=m^c;h.w=y,h.X=A,h.i=f}d(u,l)}function i(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function o(l,u){l==null&&(l=+new Date);var d=new s(l),h=u&&u.state,p=function(){return(d.next()>>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(h.X&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),IR=dr({"src/node_modules/seedrandom/lib/tychei.js"(e,t){(function(r,n,a){function s(l){var u=this,d="";u.next=function(){var p=u.b,c=u.c,m=u.d,f=u.a;return p=p<<25^p>>>7^c,c=c-m|0,m=m<<24^m>>>8^f,f=f-p|0,u.b=p=p<<20^p>>>12^c,u.c=c=c-m|0,u.d=m<<16^c>>>16^f,u.a=f-p|0},u.a=0,u.b=0,u.c=-1640531527,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):d+=l;for(var h=0;h>>0)/4294967296};return p.double=function(){do var c=d.next()>>>11,m=(d.next()>>>0)/4294967296,f=(c+m)/(1<<21);while(f===0);return f},p.int32=d.next,p.quick=p,h&&(typeof h=="object"&&i(h,d),p.state=function(){return i(d,{})}),p}n&&n.exports?n.exports=o:a&&a.amd?a(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),SR=dr({"(disabled):crypto"(){}}),CR=dr({"src/node_modules/seedrandom/seedrandom.js"(e,t){(function(r,n,a){var s=256,i=6,o=52,l="random",u=a.pow(s,i),d=a.pow(2,o),h=d*2,p=s-1,c;function m(w,I,T){var E=[];I=I==!0?{entropy:!0}:I||{};var R=A(y(I.entropy?[w,b(n)]:w==null?x():w,3),E),O=new f(E),$=function(){for(var S=O.g(i),P=u,z=0;S=h;)S/=2,P/=2,z>>>=1;return(S+z)/P};return $.int32=function(){return O.g(4)|0},$.quick=function(){return O.g(4)/4294967296},$.double=$,A(b(O.S),n),(I.pass||T||function(S,P,z,j){return j&&(j.S&&g(j,O),S.state=function(){return g(O,{})}),z?(a[l]=S,P):S})($,R,"global"in I?I.global:this==a,I.state)}function f(w){var I,T=w.length,E=this,R=0,O=E.i=E.j=0,$=E.S=[];for(T||(w=[T++]);R{var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(n=n||__filename),function(a){a=a||{};function s(){return Fe.buffer!=Or&&ra(Fe.buffer),yc}function i(){return Fe.buffer!=Or&&ra(Fe.buffer),Ac}function o(){return Fe.buffer!=Or&&ra(Fe.buffer),dp}function l(){return Fe.buffer!=Or&&ra(Fe.buffer),xc}function u(){return Fe.buffer!=Or&&ra(Fe.buffer),bc}function d(){return Fe.buffer!=Or&&ra(Fe.buffer),vc}function h(){return Fe.buffer!=Or&&ra(Fe.buffer),wc}var p=typeof a!="undefined"?a:{},c,m;p.ready=new Promise(function(N,F){c=N,m=F});var f;typeof process!="undefined"&&process.listeners&&(f={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},p),y=[],A="./this.program",x=(N,F)=>{throw F},b=typeof window=="object",w=typeof importScripts=="function",I=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",T=p.ENVIRONMENT_IS_PTHREAD||!1,E="";function R(N){return p.locateFile?p.locateFile(N,E):E+N}var O,$,S,P;function z(N){N instanceof xp||Q("exiting due to exception: "+N)}var j,K,D;if(I){w?E=k0().dirname(E)+"/":E=__dirname+"/",D=()=>{K||(j=Cy(),K=k0())},O=function(F,G){return D(),F=K.normalize(F),j.readFileSync(F,G?void 0:"utf8")},S=F=>{var G=O(F,!0);return G.buffer||(G=new Uint8Array(G)),G},$=(F,G,ee)=>{D(),F=K.normalize(F),j.readFile(F,function(ge,xe){ge?ee(ge):G(xe.buffer)})},process.argv.length>1&&(A=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(F){if(!(F instanceof xp))throw F}),process.on("unhandledRejection",function(F){throw F}),x=(F,G)=>{if(lo())throw process.exitCode=F,G;z(G),process.exit(F)},p.inspect=function(){return"[Emscripten Module object]"};let N;try{N=TR()}catch(F){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),F}global.Worker=N.Worker}else(b||w)&&(w?E=self.location.href:typeof document!="undefined"&&document.currentScript&&(E=document.currentScript.src),typeof n!="undefined"&&n&&(E=n),E.indexOf("blob:")!==0?E=E.substr(0,E.replace(/[?#].*/,"").lastIndexOf("/")+1):E="",I||(O=N=>{var F=new XMLHttpRequest;return F.open("GET",N,!1),F.send(null),F.responseText},w&&(S=N=>{var F=new XMLHttpRequest;return F.open("GET",N,!1),F.responseType="arraybuffer",F.send(null),new Uint8Array(F.response)}),$=(N,F,G)=>{var ee=new XMLHttpRequest;ee.open("GET",N,!0),ee.responseType="arraybuffer",ee.onload=()=>{if(ee.status==200||ee.status==0&&ee.response){F(ee.response);return}G()},ee.onerror=G,ee.send(null)}),P=N=>document.title=N);I&&typeof performance=="undefined"&&(global.performance=NR().performance);var Y=console.log.bind(console),V=console.warn.bind(console);I&&(D(),Y=N=>j.writeSync(1,N+` `),V=N=>j.writeSync(2,N+` `));var re=p.print||Y,Q=p.printErr||V;Object.assign(p,g),g=null,p.arguments&&(y=p.arguments),p.thisProgram&&(A=p.thisProgram),p.quit&&(x=p.quit);var ie=4;function J(N){J.shown||(J.shown={}),J.shown[N]||(J.shown[N]=1,Q(N))}function ae(N,F){if(typeof WebAssembly.Function=="function"){for(var G={i:"i32",j:"i64",f:"f32",d:"f64"},ee={parameters:[],results:F[0]=="v"?[]:[G[F[0]]]},ge=1;ge{$e=N},We=Atomics.load,Ke=Atomics.store,ot=Atomics.compareExchange,pt;p.wasmBinary&&(pt=p.wasmBinary);var ht=p.noExitRuntime||!0;typeof WebAssembly!="object"&&tu("no native wasm support detected");var Fe,wt,xt=!1,Pr;function hr(N,F){N||tu(F)}function Qr(N){var F=p["_"+N];return F}function rr(N,F,G,ee,ge){var xe={string:function(Cn){var pu=0;if(Cn!=null&&Cn!==0){var Vb=(Cn.length<<2)+1;pu=du(Vb),io(Cn,pu,Vb)}return pu},array:function(Cn){var pu=du(Cn.length);return Ua(Cn,pu),pu}};function Te(Cn){return F==="string"?In(Cn):F==="boolean"?Boolean(Cn):Cn}var Pe=Qr(N),Pt=[],ia=0;if(ee)for(var oa=0;oa(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),F.decode.call(F,G))}var nr=typeof TextDecoder!="undefined"?new en("utf8"):void 0;function kn(N,F,G){for(var ee=F+G,ge=F;N[ge]&&!(ge>=ee);)++ge;if(ge-F>16&&N.subarray&&nr)return nr.decode(N.subarray(F,ge));for(var xe="";F>10,56320|ia&1023)}}return xe}function In(N,F){return N?kn(i(),N,F):""}function gs(N,F,G,ee){if(!(ee>0))return 0;for(var ge=G,xe=G+ee-1,Te=0;Te=55296&&Pe<=57343){var Pt=N.charCodeAt(++Te);Pe=65536+((Pe&1023)<<10)|Pt&1023}if(Pe<=127){if(G>=xe)break;F[G++]=Pe}else if(Pe<=2047){if(G+1>=xe)break;F[G++]=192|Pe>>6,F[G++]=128|Pe&63}else if(Pe<=65535){if(G+2>=xe)break;F[G++]=224|Pe>>12,F[G++]=128|Pe>>6&63,F[G++]=128|Pe&63}else{if(G+3>=xe)break;F[G++]=240|Pe>>18,F[G++]=128|Pe>>12&63,F[G++]=128|Pe>>6&63,F[G++]=128|Pe&63}}return F[G]=0,G-ge}function io(N,F,G){return gs(N,i(),F,G)}function gc(N){for(var F=0,G=0;G=55296&&ee<=57343&&(ee=65536+((ee&1023)<<10)|N.charCodeAt(++G)&1023),ee<=127?++F:ee<=2047?F+=2:ee<=65535?F+=3:F+=4}return F}var ys=typeof TextDecoder!="undefined"?new en("utf-16le"):void 0;function Ua(N,F){s().set(N,F)}function up(N,F,G){for(var ee=0;ee>0]=N.charCodeAt(ee);G||(s()[F>>0]=0)}function Ql(N,F){return N%F>0&&(N+=F-N%F),N}var Or,yc,Ac,dp,xc,bc,wb,vc,wc;T&&(Or=p.buffer);function ra(N){Or=N,p.HEAP8=yc=new Int8Array(N),p.HEAP16=dp=new Int16Array(N),p.HEAP32=bc=new Int32Array(N),p.HEAPU8=Ac=new Uint8Array(N),p.HEAPU16=xc=new Uint16Array(N),p.HEAPU32=wb=new Uint32Array(N),p.HEAPF32=vc=new Float32Array(N),p.HEAPF64=wc=new Float64Array(N)}var kc=p.INITIAL_MEMORY||16777216;if(T)Fe=p.wasmMemory,Or=p.buffer;else if(p.wasmMemory)Fe=p.wasmMemory;else if(Fe=new WebAssembly.Memory({initial:kc/65536,maximum:32768,shared:!0}),!(Fe.buffer instanceof SharedArrayBuffer))throw Q("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"),I&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Fe&&(Or=Fe.buffer),kc=Or.byteLength,ra(Or);var Sn,eu=[],As=[],$1=[],Ic=[],oo=!1,M1=!1,Sc=0;function lo(){return ht||Sc>0}function zr(){if(p.preRun)for(typeof p.preRun=="function"&&(p.preRun=[p.preRun]);p.preRun.length;)kb(p.preRun.shift());Rc(eu)}function pp(){oo=!0,!T&&Rc(As)}function F1(){T||(Oe.terminateAllThreads(),M1=!0)}function _1(){if(!T){if(p.postRun)for(typeof p.postRun=="function"&&(p.postRun=[p.postRun]);p.postRun.length;)hp(p.postRun.shift());Rc(Ic)}}function kb(N){eu.unshift(N)}function Ib(N){As.unshift(N)}function hp(N){Ic.unshift(N)}var xs=0,Cc=null,na=null;function cp(N){xs++,p.monitorRunDependencies&&p.monitorRunDependencies(xs)}function Sb(N){if(xs--,p.monitorRunDependencies&&p.monitorRunDependencies(xs),xs==0&&(Cc!==null&&(clearInterval(Cc),Cc=null),na)){var F=na;na=null,F()}}p.preloadedImages={},p.preloadedAudios={};function tu(N){T?postMessage({cmd:"onAbort",arg:N}):p.onAbort&&p.onAbort(N),N="Aborted("+N+")",Q(N),xt=!0,Pr=1,N+=". Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(N);throw m(F),F}var P1="data:application/octet-stream;base64,";function Tc(N){return N.startsWith(P1)}function Nc(N){return N.startsWith("file://")}var Dr;Dr="tfjs-backend-wasm-threaded-simd.wasm",Tc(Dr)||(Dr=R(Dr));function Ec(N){try{if(N==Dr&&pt)return new Uint8Array(pt);if(S)return S(N);throw"both async and sync fetching of the wasm failed"}catch(F){tu(F)}}function ru(){if(!pt&&(b||w)){if(typeof fetch=="function"&&!Nc(Dr))return fetch(Dr,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+Dr+"'";return N.arrayBuffer()}).catch(function(){return Ec(Dr)});if($)return new Promise(function(N,F){$(Dr,function(G){N(new Uint8Array(G))},F)})}return Promise.resolve().then(function(){return Ec(Dr)})}function O1(){var N={env:Vc,wasi_snapshot_preview1:Vc};function F(Te,Pe){var Pt=Te.exports;if(p.asm=Pt,U1(p.asm.emscripten_tls_init),Sn=p.asm.__indirect_function_table,Ib(p.asm.__wasm_call_ctors),wt=Pe,!T){var ia=Oe.unusedWorkers.length;Oe.unusedWorkers.forEach(function(oa){Oe.loadWasmModuleToWorker(oa,function(){--ia||Sb("wasm-instantiate")})})}}T||cp("wasm-instantiate");function G(Te){F(Te.instance,Te.module)}function ee(Te){return ru().then(function(Pe){return WebAssembly.instantiate(Pe,N)}).then(function(Pe){return Pe}).then(Te,function(Pe){Q("failed to asynchronously prepare wasm: "+Pe),tu(Pe)})}function ge(){return!pt&&typeof WebAssembly.instantiateStreaming=="function"&&!Tc(Dr)&&!Nc(Dr)&&typeof fetch=="function"?fetch(Dr,{credentials:"same-origin"}).then(function(Te){var Pe=WebAssembly.instantiateStreaming(Te,N);return Pe.then(G,function(Pt){return Q("wasm streaming compile failed: "+Pt),Q("falling back to ArrayBuffer instantiation"),ee(G)})}):ee(G)}if(p.instantiateWasm)try{var xe=p.instantiateWasm(N,F);return xe}catch(Te){return Q("Module.instantiateWasm callback failed with error: "+Te),!1}return ge().catch(m),{}}var Cb,Tb,z1={};function Rc(N){for(;N.length>0;){var F=N.shift();if(typeof F=="function"){F(p);continue}var G=F.func;typeof G=="number"?F.arg===void 0?au(G)():au(G)(F.arg):G(F.arg===void 0?null:F.arg)}}function nu(N){var F=ug(),G=N();return qc(F),G}function pE(N){return N}function Nb(N){var F=/\b_Z[\w\d_]+/g;return N.replace(F,function(G){var ee=G;return G===ee?G:ee+" ["+G+"]"})}function D1(N){u()[N>>2]=0;var F=Oe.pthreads[N];delete Oe.pthreads[N],F.worker.terminate(),lg(N),Oe.runningWorkers.splice(Oe.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function L1(N){var F=Oe.pthreads[N];F.worker.postMessage({cmd:"cancel"})}function $c(N){var F=Oe.pthreads[N];if(F){u()[N>>2]=0;var G=F.worker;Oe.returnWorkerToPool(G)}}function Mc(N){eR(N)}function B1(N){if(N instanceof xp||N=="unwind")return Pr;x(1,N)}var Oe={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){T?Oe.initWorker():Oe.initMainThread()},initMainThread:function(){for(var N=8,F=0;F>2]=0;try{N()}finally{u()[Wb>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in Oe.tlsInitFunctions)Oe.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,F){N.onmessage=G=>{var ee=G.data,ge=ee.cmd;if(N.pthread&&(Oe.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),ee.targetThread&&ee.targetThread!=Hc()){var xe=Oe.pthreads[ee.targetThread];xe?xe.worker.postMessage(ee,ee.transferList):Q('Internal error! Worker sent a message "'+ge+'" to target pthread '+ee.targetThread+", but that thread no longer exists!"),Oe.currentProxiedOperationCallerThread=void 0;return}ge==="processQueuedMainThreadWork"?Ob():ge==="spawnThread"?_c(ee):ge==="cleanupThread"?$c(ee.thread):ge==="killThread"?D1(ee.thread):ge==="cancelThread"?L1(ee.thread):ge==="loaded"?(N.loaded=!0,F&&F(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):ge==="print"?re("Thread "+ee.threadId+": "+ee.text):ge==="printErr"?Q("Thread "+ee.threadId+": "+ee.text):ge==="alert"?alert("Thread "+ee.threadId+": "+ee.text):ee.target==="setimmediate"?N.postMessage(ee):ge==="onAbort"?p.onAbort&&p.onAbort(ee.arg):Q("worker sent an unknown command "+ge),Oe.currentProxiedOperationCallerThread=void 0},N.onerror=G=>{var ee="worker sent an error!";throw Q(ee+" "+G.filename+":"+G.lineno+": "+G.message),G},I&&(N.on("message",function(G){N.onmessage({data:G})}),N.on("error",function(G){N.onerror(G)}),N.on("detachedExit",function(){})),N.postMessage({cmd:"load",urlOrBlob:p.mainScriptUrlOrBlob||n,wasmMemory:Fe,wasmModule:wt})},allocateUnusedWorker:function(){var N=R("tfjs-backend-wasm-threaded-simd.worker.js");Oe.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return Oe.unusedWorkers.length==0&&(Oe.allocateUnusedWorker(),Oe.loadWasmModuleToWorker(Oe.unusedWorkers[0])),Oe.unusedWorkers.pop()}};function W1(){var N=Hc(),F=u()[N+44>>2],G=u()[N+48>>2],ee=F-G;Bb(F,ee),qc(F)}p.establishStackSpace=W1;function Fc(N){if(T)return ho(1,0,N);try{Mc(N)}catch(F){B1(F)}}var uo=[];function au(N){var F=uo[N];return F||(N>=uo.length&&(uo.length=N+1),uo[N]=F=Sn.get(N)),F}function V1(N,F){return au(N)(F)}p.invokeEntryPoint=V1;function Eb(){var N=new Error;if(!N.stack){try{throw new Error}catch(F){N=F}if(!N.stack)return"(no stack trace available)"}return N.stack.toString()}function U1(N,F,G){Oe.tlsInitFunctions.push(N)}function Rb(N,F){Sn.set(N,F),uo[N]=F}var po;I?po=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:T?po=()=>performance.now()-p.__performance_now_clock_drift:po=()=>performance.now();var G1=!0;function j1(N){return u()[Pb()>>2]=N,N}function H1(N,F){var G;if(N===0)G=Date.now();else if((N===1||N===4)&&G1)G=po();else return j1(28),-1;return u()[F>>2]=G/1e3|0,u()[F+4>>2]=G%1e3*1e3*1e3|0,0}function q1(N,F){return H1(N,F)}function X1(N){zb(N,!w,1,!b),Oe.threadInit()}function K1(N){T?postMessage({cmd:"cleanupThread",thread:N}):$c(N)}function _c(N){var F=Oe.getNewWorker();if(!F)return 6;Oe.runningWorkers.push(F);var G=Oe.pthreads[N.pthread_ptr]={worker:F,threadInfoStruct:N.pthread_ptr};F.pthread=G;var ee={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return F.runPthread=()=>{ee.time=performance.now(),F.postMessage(ee,N.transferList)},F.loaded&&(F.runPthread(),delete F.runPthread),0}function Z1(N,F,G,ee){if(typeof SharedArrayBuffer=="undefined")return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ge=[],xe=0;if(T&&(ge.length===0||xe))return Db(687865856,N,F,G,ee);if(xe)return xe;var Te={startRoutine:G,pthread_ptr:N,arg:ee,transferList:ge};return T?(Te.cmd="spawnThread",postMessage(Te,ge),0):_c(Te)}function Y1(){return 2097152}function J1(N,F){if(N==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(T)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var G=Oe.pthreads[N],ee=G&&G.worker;if(!ee)return;ee.postMessage({cmd:"processThreadQueue"})}return 1}function Q1(){tu("")}function e2(){I||w||J("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Pc(){return 2147483648}function t2(N,F,G){i().copyWithin(N,F,F+G)}function r2(){return I?ER().cpus().length:navigator.hardwareConcurrency}function ho(N,F){var G=arguments.length-2,ee=arguments;return nu(function(){for(var ge=G,xe=du(ge*8),Te=xe>>3,Pe=0;Pe>3,ge=0;ge>>16),ra(Fe.buffer),1}catch(F){}}function s2(N){var F=i().length;if(N=N>>>0,N<=F)return!1;var G=Pc();if(N>G)return!1;for(var ee=1;ee<=4;ee*=2){var ge=F*(1+.2/ee);ge=Math.min(ge,N+100663296);var xe=Math.min(G,Ql(Math.max(N,ge),65536)),Te=a2(xe);if(Te)return!0}return!1}var Xe={inEventHandler:0,removeAllEventListeners:function(){for(var N=Xe.eventHandlers.length-1;N>=0;--N)Xe._removeHandler(N);Xe.eventHandlers=[],Xe.deferredCalls=[]},registerRemoveEventListeners:function(){Xe.removeEventListenersRegistered||($1.push(Xe.removeAllEventListeners),Xe.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,F,G){function ee(Te,Pe){if(Te.length!=Pe.length)return!1;for(var Pt in Te)if(Te[Pt]!=Pe[Pt])return!1;return!0}for(var ge in Xe.deferredCalls){var xe=Xe.deferredCalls[ge];if(xe.targetFunction==N&&ee(xe.argsList,G))return}Xe.deferredCalls.push({targetFunction:N,precedence:F,argsList:G}),Xe.deferredCalls.sort(function(Te,Pe){return Te.precedence>2]=G,u()[xe+4>>2]=ee,u()[xe+8>>2]=ge,og(N,637534208,F,ee,xe)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return Oe.currentProxiedOperationCallerThread;default:return N}},getNodeNameForTarget:function(N){return N?N==window?"#window":N==screen?"#screen":N&&N.nodeName?N.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function i2(N){var F=gc(N)+1,G=ig(F);return io(N,G,F),G}function o2(N,F,G,ee){nu(function(){var ge=du(12),xe=0;F&&(xe=i2(F)),u()[ge>>2]=xe,u()[ge+4>>2]=G,u()[ge+8>>2]=ee,og(N,657457152,0,xe,ge)})}function l2(N,F,G,ee){F=F?In(F):"",o2(N,F,G,ee)}function u2(N){return N>2?In(N):N}var d2=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function p2(N){N=u2(N);var F=d2[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return F}function mp(N){return p2(N)}function Oc(N,F,G){var ee=mp(N);if(!ee)return-4;if(ee.canvasSharedPtr&&(u()[ee.canvasSharedPtr>>2]=F,u()[ee.canvasSharedPtr+4>>2]=G),ee.offscreenCanvas||!ee.controlTransferredOffscreen){ee.offscreenCanvas&&(ee=ee.offscreenCanvas);var ge=!1;if(ee.GLctxObject&&ee.GLctxObject.GLctx){var xe=ee.GLctxObject.GLctx.getParameter(2978);ge=xe[0]===0&&xe[1]===0&&xe[2]===ee.width&&xe[3]===ee.height}ee.width=F,ee.height=G,ge&&ee.GLctxObject.GLctx.viewport(0,0,F,G)}else if(ee.canvasSharedPtr){var Te=u()[ee.canvasSharedPtr+8>>2];return l2(Te,N,F,G),1}else return-4;return 0}function zc(N,F,G){return T?ho(2,1,N,F,G):Oc(N,F,G)}function h2(N,F,G){var ee=mp(N);return ee?Oc(N,F,G):zc(N,F,G)}function c2(){throw"unwind"}function f2(N){var F=N.getExtension("ANGLE_instanced_arrays");if(F)return N.vertexAttribDivisor=function(G,ee){F.vertexAttribDivisorANGLE(G,ee)},N.drawArraysInstanced=function(G,ee,ge,xe){F.drawArraysInstancedANGLE(G,ee,ge,xe)},N.drawElementsInstanced=function(G,ee,ge,xe,Te){F.drawElementsInstancedANGLE(G,ee,ge,xe,Te)},1}function m2(N){var F=N.getExtension("OES_vertex_array_object");if(F)return N.createVertexArray=function(){return F.createVertexArrayOES()},N.deleteVertexArray=function(G){F.deleteVertexArrayOES(G)},N.bindVertexArray=function(G){F.bindVertexArrayOES(G)},N.isVertexArray=function(G){return F.isVertexArrayOES(G)},1}function g2(N){var F=N.getExtension("WEBGL_draw_buffers");if(F)return N.drawBuffers=function(G,ee){F.drawBuffersWEBGL(G,ee)},1}function y2(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var _t={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){_t.lastError||(_t.lastError=N)},getNewId:function(N){for(var F=_t.counter++,G=N.length;G>2]:-1;ge+=In(u()[G+xe*4>>2],Te<0?void 0:Te)}return ge},createContext:function(N,F){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(ge,xe){var Te=N.getContextSafariWebGL2Fixed(ge,xe);return ge=="webgl"==Te instanceof WebGLRenderingContext?Te:null});var G=N.getContext("webgl",F);if(!G)return 0;var ee=_t.registerContext(G,F);return ee},registerContext:function(N,F){var G=ig(8);u()[G+4>>2]=Hc();var ee={handle:G,attributes:F,version:F.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=ee),_t.contexts[G]=ee,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&_t.initExtensions(ee),G},makeContextCurrent:function(N){return _t.currentContext=_t.contexts[N],p.ctx=Wc=_t.currentContext&&_t.currentContext.GLctx,!(N&&!Wc)},getContext:function(N){return _t.contexts[N]},deleteContext:function(N){_t.currentContext===_t.contexts[N]&&(_t.currentContext=null),typeof Xe=="object"&&Xe.removeAllHandlersOnTarget(_t.contexts[N].GLctx.canvas),_t.contexts[N]&&_t.contexts[N].GLctx.canvas&&(_t.contexts[N].GLctx.canvas.GLctxObject=void 0),_b(_t.contexts[N].handle),_t.contexts[N]=null},initExtensions:function(N){if(N||(N=_t.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var F=N.GLctx;f2(F),m2(F),g2(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),y2(F);var G=F.getSupportedExtensions()||[];G.forEach(function(ee){!ee.includes("lose_context")&&!ee.includes("debug")&&F.getExtension(ee)})}}},A2=["default","low-power","high-performance"];function x2(N,F){var G=F>>2,ee=u()[G+6],ge={alpha:!!u()[G+0],depth:!!u()[G+1],stencil:!!u()[G+2],antialias:!!u()[G+3],premultipliedAlpha:!!u()[G+4],preserveDrawingBuffer:!!u()[G+5],powerPreference:A2[ee],failIfMajorPerformanceCaveat:!!u()[G+7],majorVersion:u()[G+8],minorVersion:u()[G+9],enableExtensionsByDefault:u()[G+10],explicitSwapControl:u()[G+11],proxyContextToMainThread:u()[G+12],renderViaOffscreenBackBuffer:u()[G+13]},xe=mp(N);if(!xe||ge.explicitSwapControl)return 0;var Te=_t.createContext(xe,ge);return Te}function b2(N,F){return x2(N,F)}var su={mappings:{},buffers:[null,[],[]],printChar:function(N,F){var G=su.buffers[N];F===0||F===10?((N===1?re:Q)(kn(G,0)),G.length=0):G.push(F)},varargs:void 0,get:function(){su.varargs+=4;var N=u()[su.varargs-4>>2];return N},getStr:function(N){var F=In(N);return F},get64:function(N,F){return N}};function Dc(N){return T?ho(3,1,N):0}function Lc(N,F,G,ee,ge){if(T)return ho(4,1,N,F,G,ee,ge)}function Bc(N,F,G,ee){if(T)return ho(5,1,N,F,G,ee);for(var ge=0,xe=0;xe>2],Pe=u()[F+4>>2];F+=8;for(var Pt=0;Pt>2]=ge,0}function v2(N){ze(N)}Oe.init();var Wc,w2=[null,Fc,zc,Dc,Lc,Bc],$b=!1,Vc={__clock_gettime:q1,__emscripten_init_main_thread_js:X1,__emscripten_thread_cleanup:K1,__pthread_create_js:Z1,_emscripten_default_pthread_stack_size:Y1,_emscripten_notify_thread_queue:J1,abort:Q1,emscripten_check_blocking_allowed:e2,emscripten_get_heap_max:Pc,emscripten_get_now:po,emscripten_memcpy_big:t2,emscripten_num_logical_cores:r2,emscripten_receive_on_main_thread_js:n2,emscripten_resize_heap:s2,emscripten_set_canvas_element_size:h2,emscripten_unwind_to_js_event_loop:c2,emscripten_webgl_create_context:b2,exit:Mc,fd_close:Dc,fd_seek:Lc,fd_write:Bc,memory:Fe||p.wasmMemory,setTempRet0:v2},Mb=O1(),k2=p.___wasm_call_ctors=function(){return(k2=p.___wasm_call_ctors=p.asm.__wasm_call_ctors).apply(null,arguments)},I2=p._init=function(){return(I2=p._init=p.asm.init).apply(null,arguments)},S2=p._init_with_threads_count=function(){return(S2=p._init_with_threads_count=p.asm.init_with_threads_count).apply(null,arguments)},C2=p._get_threads_count=function(){return(C2=p._get_threads_count=p.asm.get_threads_count).apply(null,arguments)},T2=p._register_tensor=function(){return(T2=p._register_tensor=p.asm.register_tensor).apply(null,arguments)},N2=p._dispose_data=function(){return(N2=p._dispose_data=p.asm.dispose_data).apply(null,arguments)},E2=p._dispose=function(){return(E2=p._dispose=p.asm.dispose).apply(null,arguments)},R2=p._Abs=function(){return(R2=p._Abs=p.asm.Abs).apply(null,arguments)},$2=p._Add=function(){return($2=p._Add=p.asm.Add).apply(null,arguments)},M2=p._AddN=function(){return(M2=p._AddN=p.asm.AddN).apply(null,arguments)},F2=p._All=function(){return(F2=p._All=p.asm.All).apply(null,arguments)},_2=p._Any=function(){return(_2=p._Any=p.asm.Any).apply(null,arguments)},P2=p._ArgMax=function(){return(P2=p._ArgMax=p.asm.ArgMax).apply(null,arguments)},O2=p._AvgPool=function(){return(O2=p._AvgPool=p.asm.AvgPool).apply(null,arguments)},z2=p._BatchMatMul=function(){return(z2=p._BatchMatMul=p.asm.BatchMatMul).apply(null,arguments)},D2=p._Ceil=function(){return(D2=p._Ceil=p.asm.Ceil).apply(null,arguments)},L2=p._ClipByValue=function(){return(L2=p._ClipByValue=p.asm.ClipByValue).apply(null,arguments)},B2=p._Conv2D=function(){return(B2=p._Conv2D=p.asm.Conv2D).apply(null,arguments)},W2=p._Conv2DBackpropInput=function(){return(W2=p._Conv2DBackpropInput=p.asm.Conv2DBackpropInput).apply(null,arguments)},V2=p._Cos=function(){return(V2=p._Cos=p.asm.Cos).apply(null,arguments)},U2=p._Cosh=function(){return(U2=p._Cosh=p.asm.Cosh).apply(null,arguments)},G2=p._CropAndResize=function(){return(G2=p._CropAndResize=p.asm.CropAndResize).apply(null,arguments)},j2=p._Cumprod=function(){return(j2=p._Cumprod=p.asm.Cumprod).apply(null,arguments)},H2=p._Cumsum=function(){return(H2=p._Cumsum=p.asm.Cumsum).apply(null,arguments)},q2=p._DepthToSpace=function(){return(q2=p._DepthToSpace=p.asm.DepthToSpace).apply(null,arguments)},X2=p._DepthwiseConv2dNative=function(){return(X2=p._DepthwiseConv2dNative=p.asm.DepthwiseConv2dNative).apply(null,arguments)},K2=p._Elu=function(){return(K2=p._Elu=p.asm.Elu).apply(null,arguments)},Z2=p._Equal=function(){return(Z2=p._Equal=p.asm.Equal).apply(null,arguments)},Y2=p._Exp=function(){return(Y2=p._Exp=p.asm.Exp).apply(null,arguments)},J2=p._FlipLeftRight=function(){return(J2=p._FlipLeftRight=p.asm.FlipLeftRight).apply(null,arguments)},Q2=p._Floor=function(){return(Q2=p._Floor=p.asm.Floor).apply(null,arguments)},eg=p._FloorDiv=function(){return(eg=p._FloorDiv=p.asm.FloorDiv).apply(null,arguments)},tg=p._FusedBatchNorm=function(){return(tg=p._FusedBatchNorm=p.asm.FusedBatchNorm).apply(null,arguments)},Uc=p._FusedConv2D=function(){return(Uc=p._FusedConv2D=p.asm.FusedConv2D).apply(null,arguments)},Gc=p._FusedDepthwiseConv2D=function(){return(Gc=p._FusedDepthwiseConv2D=p.asm.FusedDepthwiseConv2D).apply(null,arguments)},gp=p._Gather=function(){return(gp=p._Gather=p.asm.Gather).apply(null,arguments)},rg=p._GatherNd=function(){return(rg=p._GatherNd=p.asm.GatherNd).apply(null,arguments)},ng=p._Greater=function(){return(ng=p._Greater=p.asm.Greater).apply(null,arguments)},iu=p._GreaterEqual=function(){return(iu=p._GreaterEqual=p.asm.GreaterEqual).apply(null,arguments)},yp=p._LeakyRelu=function(){return(yp=p._LeakyRelu=p.asm.LeakyRelu).apply(null,arguments)},Ap=p._Less=function(){return(Ap=p._Less=p.asm.Less).apply(null,arguments)},Fb=p._LessEqual=function(){return(Fb=p._LessEqual=p.asm.LessEqual).apply(null,arguments)},ou=p._Log=function(){return(ou=p._Log=p.asm.Log).apply(null,arguments)},lu=p._LogicalAnd=function(){return(lu=p._LogicalAnd=p.asm.LogicalAnd).apply(null,arguments)},ag=p._LogicalNot=function(){return(ag=p._LogicalNot=p.asm.LogicalNot).apply(null,arguments)},H=p._LogicalOr=function(){return(H=p._LogicalOr=p.asm.LogicalOr).apply(null,arguments)},ne=p._LogicalXor=function(){return(ne=p._LogicalXor=p.asm.LogicalXor).apply(null,arguments)},ye=p._Max=function(){return(ye=p._Max=p.asm.Max).apply(null,arguments)},Re=p._MaxPool=function(){return(Re=p._MaxPool=p.asm.MaxPool).apply(null,arguments)},lt=p._Maximum=function(){return(lt=p._Maximum=p.asm.Maximum).apply(null,arguments)},ct=p._Mean=function(){return(ct=p._Mean=p.asm.Mean).apply(null,arguments)},Ze=p._Min=function(){return(Ze=p._Min=p.asm.Min).apply(null,arguments)},He=p._Minimum=function(){return(He=p._Minimum=p.asm.Minimum).apply(null,arguments)},qt=p._MirrorPad=function(){return(qt=p._MirrorPad=p.asm.MirrorPad).apply(null,arguments)},aa=p._Multiply=function(){return(aa=p._Multiply=p.asm.Multiply).apply(null,arguments)},sa=p._Neg=function(){return(sa=p._Neg=p.asm.Neg).apply(null,arguments)},uu=p._NonMaxSuppressionV3=function(){return(uu=p._NonMaxSuppressionV3=p.asm.NonMaxSuppressionV3).apply(null,arguments)},co=p._NonMaxSuppressionV4=function(){return(co=p._NonMaxSuppressionV4=p.asm.NonMaxSuppressionV4).apply(null,arguments)},sg=p._NonMaxSuppressionV5=function(){return(sg=p._NonMaxSuppressionV5=p.asm.NonMaxSuppressionV5).apply(null,arguments)},tn=p._NotEqual=function(){return(tn=p._NotEqual=p.asm.NotEqual).apply(null,arguments)},bs=p._OneHot=function(){return(bs=p._OneHot=p.asm.OneHot).apply(null,arguments)},jc=p._PadV2=function(){return(jc=p._PadV2=p.asm.PadV2).apply(null,arguments)},hE=p._Pow=function(){return(hE=p._Pow=p.asm.Pow).apply(null,arguments)},cE=p._Prelu=function(){return(cE=p._Prelu=p.asm.Prelu).apply(null,arguments)},fE=p._Prod=function(){return(fE=p._Prod=p.asm.Prod).apply(null,arguments)},mE=p._RealDiv=function(){return(mE=p._RealDiv=p.asm.RealDiv).apply(null,arguments)},gE=p._Relu=function(){return(gE=p._Relu=p.asm.Relu).apply(null,arguments)},yE=p._Relu6=function(){return(yE=p._Relu6=p.asm.Relu6).apply(null,arguments)},AE=p._ResizeBilinear=function(){return(AE=p._ResizeBilinear=p.asm.ResizeBilinear).apply(null,arguments)},xE=p._Reverse=function(){return(xE=p._Reverse=p.asm.Reverse).apply(null,arguments)},bE=p._RotateWithOffset=function(){return(bE=p._RotateWithOffset=p.asm.RotateWithOffset).apply(null,arguments)},vE=p._Round=function(){return(vE=p._Round=p.asm.Round).apply(null,arguments)},wE=p._Rsqrt=function(){return(wE=p._Rsqrt=p.asm.Rsqrt).apply(null,arguments)},kE=p._ScatterNd=function(){return(kE=p._ScatterNd=p.asm.ScatterNd).apply(null,arguments)},IE=p._SelectV2=function(){return(IE=p._SelectV2=p.asm.SelectV2).apply(null,arguments)},SE=p._Sigmoid=function(){return(SE=p._Sigmoid=p.asm.Sigmoid).apply(null,arguments)},CE=p._Sin=function(){return(CE=p._Sin=p.asm.Sin).apply(null,arguments)},TE=p._Softmax=function(){return(TE=p._Softmax=p.asm.Softmax).apply(null,arguments)},NE=p._SparseFillEmptyRows=function(){return(NE=p._SparseFillEmptyRows=p.asm.SparseFillEmptyRows).apply(null,arguments)},EE=p._SparseReshape=function(){return(EE=p._SparseReshape=p.asm.SparseReshape).apply(null,arguments)},RE=p._SparseSegmentReduction=function(){return(RE=p._SparseSegmentReduction=p.asm.SparseSegmentReduction).apply(null,arguments)},$E=p._Sqrt=function(){return($E=p._Sqrt=p.asm.Sqrt).apply(null,arguments)},ME=p._Square=function(){return(ME=p._Square=p.asm.Square).apply(null,arguments)},FE=p._SquaredDifference=function(){return(FE=p._SquaredDifference=p.asm.SquaredDifference).apply(null,arguments)},_E=p._Step=function(){return(_E=p._Step=p.asm.Step).apply(null,arguments)},PE=p._StridedSlice=function(){return(PE=p._StridedSlice=p.asm.StridedSlice).apply(null,arguments)},OE=p._Sub=function(){return(OE=p._Sub=p.asm.Sub).apply(null,arguments)},zE=p._Sum=function(){return(zE=p._Sum=p.asm.Sum).apply(null,arguments)},DE=p._Tan=function(){return(DE=p._Tan=p.asm.Tan).apply(null,arguments)},LE=p._Tanh=function(){return(LE=p._Tanh=p.asm.Tanh).apply(null,arguments)},BE=p._Tile=function(){return(BE=p._Tile=p.asm.Tile).apply(null,arguments)},WE=p._TopK=function(){return(WE=p._TopK=p.asm.TopK).apply(null,arguments)},VE=p._Transform=function(){return(VE=p._Transform=p.asm.Transform).apply(null,arguments)},UE=p._Transpose=function(){return(UE=p._Transpose=p.asm.Transpose).apply(null,arguments)},GE=p.__FusedMatMul=function(){return(GE=p.__FusedMatMul=p.asm._FusedMatMul).apply(null,arguments)},ig=p._malloc=function(){return(ig=p._malloc=p.asm.malloc).apply(null,arguments)},_b=p._free=function(){return(_b=p._free=p.asm.free).apply(null,arguments)},jE=p._emscripten_tls_init=function(){return(jE=p._emscripten_tls_init=p.asm.emscripten_tls_init).apply(null,arguments)},Pb=p.___errno_location=function(){return(Pb=p.___errno_location=p.asm.__errno_location).apply(null,arguments)},Hc=p._pthread_self=function(){return(Hc=p._pthread_self=p.asm.pthread_self).apply(null,arguments)},Ob=p._emscripten_main_thread_process_queued_calls=function(){return(Ob=p._emscripten_main_thread_process_queued_calls=p.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},HE=p.__emscripten_thread_crashed=function(){return(HE=p.__emscripten_thread_crashed=p.asm._emscripten_thread_crashed).apply(null,arguments)},zb=p.__emscripten_thread_init=function(){return(zb=p.__emscripten_thread_init=p.asm._emscripten_thread_init).apply(null,arguments)},qE=p._emscripten_current_thread_process_queued_calls=function(){return(qE=p._emscripten_current_thread_process_queued_calls=p.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},XE=p._emscripten_main_browser_thread_id=function(){return(XE=p._emscripten_main_browser_thread_id=p.asm.emscripten_main_browser_thread_id).apply(null,arguments)},KE=p._emscripten_sync_run_in_main_thread_2=function(){return(KE=p._emscripten_sync_run_in_main_thread_2=p.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},Db=p._emscripten_sync_run_in_main_thread_4=function(){return(Db=p._emscripten_sync_run_in_main_thread_4=p.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},Lb=p._emscripten_run_in_main_runtime_thread_js=function(){return(Lb=p._emscripten_run_in_main_runtime_thread_js=p.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},og=p._emscripten_dispatch_to_thread_=function(){return(og=p._emscripten_dispatch_to_thread_=p.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},lg=p.__emscripten_thread_free_data=function(){return(lg=p.__emscripten_thread_free_data=p.asm._emscripten_thread_free_data).apply(null,arguments)},ZE=p.__emscripten_thread_exit=function(){return(ZE=p.__emscripten_thread_exit=p.asm._emscripten_thread_exit).apply(null,arguments)},YE=p._memalign=function(){return(YE=p._memalign=p.asm.memalign).apply(null,arguments)},Bb=p._emscripten_stack_set_limits=function(){return(Bb=p._emscripten_stack_set_limits=p.asm.emscripten_stack_set_limits).apply(null,arguments)},ug=p.stackSave=function(){return(ug=p.stackSave=p.asm.stackSave).apply(null,arguments)},qc=p.stackRestore=function(){return(qc=p.stackRestore=p.asm.stackRestore).apply(null,arguments)},du=p.stackAlloc=function(){return(du=p.stackAlloc=p.asm.stackAlloc).apply(null,arguments)},JE=p.dynCall_iijjiiii=function(){return(JE=p.dynCall_iijjiiii=p.asm.dynCall_iijjiiii).apply(null,arguments)},QE=p.dynCall_jiji=function(){return(QE=p.dynCall_jiji=p.asm.dynCall_jiji).apply(null,arguments)},Wb=p.__emscripten_allow_main_runtime_queued_calls=21664;p.cwrap=cr,p.keepRuntimeAlive=lo,p.PThread=Oe,p.PThread=Oe,p.wasmMemory=Fe,p.ExitStatus=xp;var Xc;function xp(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}na=function N(){Xc||dg(),Xc||(na=N)};function dg(N){if(N=N||y,xs>0)return;if(T){c(p),pp(),postMessage({cmd:"loaded"});return}if(zr(),xs>0)return;function F(){Xc||(Xc=!0,p.calledRun=!0,!xt&&(pp(),c(p),p.onRuntimeInitialized&&p.onRuntimeInitialized(),_1()))}p.setStatus?(p.setStatus("Running..."),setTimeout(function(){setTimeout(function(){p.setStatus("")},1),F()},1)):F()}p.run=dg;function eR(N,F){if(Pr=N,!F&&T)throw Fc(N),"unwind";lo()||F1(),tR(N)}function tR(N){Pr=N,lo()||(Oe.terminateAllThreads(),p.onExit&&p.onExit(N),xt=!0),x(N,new xp(N))}if(p.preInit)for(typeof p.preInit=="function"&&(p.preInit=[p.preInit]);p.preInit.length>0;)p.preInit.pop()();dg();var Kc;f&&(Kc={uncaughtException:process.listeners("uncaughtException").filter(function(N){return!f.uncaughtException.indexOf(N)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(N){return!f.unhandledRejection.indexOf(N)>-1})});var Zc;if(typeof WasmBackendModule!="undefined")Zc=WasmBackendModule;else if(typeof a!="undefined")Zc=a;else throw new Error("Could not find wasm module in post.js");if(Kc){var rR=Zc._dispose;Zc._dispose=function(){rR(),Kc.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Kc.unhandledRejection.forEach(function(N){process.removeListener("unhandledRejection",N)})}}return a.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=r:typeof define=="function"&&define.amd?define([],function(){return r}):typeof e=="object"&&(e.WasmBackendModuleThreadedSimd=r)}}),$R=dr({"src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var r=(()=>{var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(n=n||__filename),function(a){a=a||{};var s=typeof a!="undefined"?a:{},i,o;s.ready=new Promise(function(H,ne){i=H,o=ne});var l;typeof process!="undefined"&&process.listeners&&(l={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var u=Object.assign({},s),d=[],h="./this.program",p=(H,ne)=>{throw ne},c=typeof window=="object",m=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function y(H){return s.locateFile?s.locateFile(H,g):g+H}var A,x,b,w;function I(H){H instanceof yp||$("exiting due to exception: "+H)}var T,E,R;f?(m?g=k0().dirname(g)+"/":g=__dirname+"/",R=()=>{E||(T=Cy(),E=k0())},A=function(H,ne){return R(),H=E.normalize(H),T.readFileSync(H,ne?void 0:"utf8")},b=H=>{var ne=A(H,!0);return ne.buffer||(ne=new Uint8Array(ne)),ne},x=(H,ne,ye)=>{R(),H=E.normalize(H),T.readFile(H,function(Re,lt){Re?ye(Re):ne(lt.buffer)})},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),d=process.argv.slice(2),process.on("uncaughtException",function(H){if(!(H instanceof yp))throw H}),process.on("unhandledRejection",function(H){throw H}),p=(H,ne)=>{if(dp())throw process.exitCode=H,ne;I(ne),process.exit(H)},s.inspect=function(){return"[Emscripten Module object]"}):(c||m)&&(m?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),n&&(g=n),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",A=H=>{var ne=new XMLHttpRequest;return ne.open("GET",H,!1),ne.send(null),ne.responseText},m&&(b=H=>{var ne=new XMLHttpRequest;return ne.open("GET",H,!1),ne.responseType="arraybuffer",ne.send(null),new Uint8Array(ne.response)}),x=(H,ne,ye)=>{var Re=new XMLHttpRequest;Re.open("GET",H,!0),Re.responseType="arraybuffer",Re.onload=()=>{if(Re.status==200||Re.status==0&&Re.response){ne(Re.response);return}ye()},Re.onerror=ye,Re.send(null)},w=H=>document.title=H);var O=s.print||console.log.bind(console),$=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(d=s.arguments),s.thisProgram&&(h=s.thisProgram),s.quit&&(p=s.quit);var S=4;function P(H){P.shown||(P.shown={}),P.shown[H]||(P.shown[H]=1,$(H))}function z(H,ne){if(typeof WebAssembly.Function=="function"){for(var ye={i:"i32",j:"i64",f:"f32",d:"f64"},Re={parameters:[],results:ne[0]=="v"?[]:[ye[ne[0]]]},lt=1;lt{V=H},Q;s.wasmBinary&&(Q=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&oo("no native wasm support detected");var J,ae=!1,de;function be(H,ne){H||oo(ne)}function ve(H){var ne=s["_"+H];return ne}function Ee(H,ne,ye,Re,lt){var ct={string:function(tn){var bs=0;if(tn!=null&&tn!==0){var jc=(tn.length<<2)+1;bs=gp(jc),ht(tn,bs,jc)}return bs},array:function(tn){var bs=gp(tn.length);return xt(tn,bs),bs}};function Ze(tn){return ne==="string"?ot(tn):ne==="boolean"?Boolean(tn):tn}var He=ve(H),qt=[],aa=0;if(Re)for(var sa=0;sa=Re);)++lt;if(lt-ne>16&&H.subarray&&We)return We.decode(H.subarray(ne,lt));for(var ct="";ne>10,56320|aa&1023)}}return ct}function ot(H,ne){return H?Ke(cr,H,ne):""}function pt(H,ne,ye,Re){if(!(Re>0))return 0;for(var lt=ye,ct=ye+Re-1,Ze=0;Ze=55296&&He<=57343){var qt=H.charCodeAt(++Ze);He=65536+((He&1023)<<10)|qt&1023}if(He<=127){if(ye>=ct)break;ne[ye++]=He}else if(He<=2047){if(ye+1>=ct)break;ne[ye++]=192|He>>6,ne[ye++]=128|He&63}else if(He<=65535){if(ye+2>=ct)break;ne[ye++]=224|He>>12,ne[ye++]=128|He>>6&63,ne[ye++]=128|He&63}else{if(ye+3>=ct)break;ne[ye++]=240|He>>18,ne[ye++]=128|He>>12&63,ne[ye++]=128|He>>6&63,ne[ye++]=128|He&63}}return ne[ye]=0,ye-lt}function ht(H,ne,ye){return pt(H,cr,ne,ye)}function Fe(H){for(var ne=0,ye=0;ye=55296&&Re<=57343&&(Re=65536+((Re&1023)<<10)|H.charCodeAt(++ye)&1023),Re<=127?++ne:Re<=2047?ne+=2:Re<=65535?ne+=3:ne+=4}return ne}var wt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function xt(H,ne){rr.set(H,ne)}function Pr(H,ne,ye){for(var Re=0;Re>0]=H.charCodeAt(Re);ye||(rr[ne>>0]=0)}function hr(H,ne){return H%ne>0&&(H+=ne-H%ne),H}var Qr,rr,cr,ta,en,nr,kn,In,gs;function io(H){Qr=H,s.HEAP8=rr=new Int8Array(H),s.HEAP16=ta=new Int16Array(H),s.HEAP32=nr=new Int32Array(H),s.HEAPU8=cr=new Uint8Array(H),s.HEAPU16=en=new Uint16Array(H),s.HEAPU32=kn=new Uint32Array(H),s.HEAPF32=In=new Float32Array(H),s.HEAPF64=gs=new Float64Array(H)}var gc=s.INITIAL_MEMORY||16777216,ys,Ua=[],up=[],Ql=[],Or=!1,yc=!1,Ac=0;function dp(){return ie||Ac>0}function xc(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)wc(s.preRun.shift());hp(Ua)}function bc(){Or=!0,hp(up)}function wb(){yc=!0}function vc(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)kc(s.postRun.shift());hp(Ql)}function wc(H){Ua.unshift(H)}function ra(H){up.unshift(H)}function kc(H){Ql.unshift(H)}var Sn=0,eu=null,As=null;function $1(H){Sn++,s.monitorRunDependencies&&s.monitorRunDependencies(Sn)}function Ic(H){if(Sn--,s.monitorRunDependencies&&s.monitorRunDependencies(Sn),Sn==0&&(eu!==null&&(clearInterval(eu),eu=null),As)){var ne=As;As=null,ne()}}s.preloadedImages={},s.preloadedAudios={};function oo(H){s.onAbort&&s.onAbort(H),H="Aborted("+H+")",$(H),ae=!0,de=1,H+=". Build with -s ASSERTIONS=1 for more info.";var ne=new WebAssembly.RuntimeError(H);throw o(ne),ne}var M1="data:application/octet-stream;base64,";function Sc(H){return H.startsWith(M1)}function lo(H){return H.startsWith("file://")}var zr;zr="tfjs-backend-wasm.wasm",Sc(zr)||(zr=y(zr));function pp(H){try{if(H==zr&&Q)return new Uint8Array(Q);if(b)return b(H);throw"both async and sync fetching of the wasm failed"}catch(ne){oo(ne)}}function F1(){if(!Q&&(c||m)){if(typeof fetch=="function"&&!lo(zr))return fetch(zr,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+zr+"'";return H.arrayBuffer()}).catch(function(){return pp(zr)});if(x)return new Promise(function(H,ne){x(zr,function(ye){H(new Uint8Array(ye))},ne)})}return Promise.resolve().then(function(){return pp(zr)})}function _1(){var H={env:nu,wasi_snapshot_preview1:nu};function ne(Ze,He){var qt=Ze.exports;s.asm=qt,J=s.asm.memory,io(J.buffer),ys=s.asm.__indirect_function_table,ra(s.asm.__wasm_call_ctors),Ic("wasm-instantiate")}$1("wasm-instantiate");function ye(Ze){ne(Ze.instance)}function Re(Ze){return F1().then(function(He){return WebAssembly.instantiate(He,H)}).then(function(He){return He}).then(Ze,function(He){$("failed to asynchronously prepare wasm: "+He),oo(He)})}function lt(){return!Q&&typeof WebAssembly.instantiateStreaming=="function"&&!Sc(zr)&&!lo(zr)&&typeof fetch=="function"?fetch(zr,{credentials:"same-origin"}).then(function(Ze){var He=WebAssembly.instantiateStreaming(Ze,H);return He.then(ye,function(qt){return $("wasm streaming compile failed: "+qt),$("falling back to ArrayBuffer instantiation"),Re(ye)})}):Re(ye)}if(s.instantiateWasm)try{var ct=s.instantiateWasm(H,ne);return ct}catch(Ze){return $("Module.instantiateWasm callback failed with error: "+Ze),!1}return lt().catch(o),{}}var kb,Ib;function hp(H){for(;H.length>0;){var ne=H.shift();if(typeof ne=="function"){ne(s);continue}var ye=ne.func;typeof ye=="number"?ne.arg===void 0?cp(ye)():cp(ye)(ne.arg):ye(ne.arg===void 0?null:ne.arg)}}function xs(H){return H}function Cc(H){var ne=/\b_Z[\w\d_]+/g;return H.replace(ne,function(ye){var Re=ye;return ye===Re?ye:Re+" ["+ye+"]"})}var na=[];function cp(H){var ne=na[H];return ne||(H>=na.length&&(na.length=H+1),na[H]=ne=ys.get(H)),ne}function Sb(){var H=new Error;if(!H.stack){try{throw new Error}catch(ne){H=ne}if(!H.stack)return"(no stack trace available)"}return H.stack.toString()}function tu(H,ne){ys.set(H,ne),na[H]=ne}function P1(){oo("")}function Tc(H,ne,ye){cr.copyWithin(H,ne,ne+ye)}function Nc(){return 2147483648}function Dr(H){try{return J.grow(H-Qr.byteLength+65535>>>16),io(J.buffer),1}catch(ne){}}function Ec(H){var ne=cr.length;H=H>>>0;var ye=Nc();if(H>ye)return!1;for(var Re=1;Re<=4;Re*=2){var lt=ne*(1+.2/Re);lt=Math.min(lt,H+100663296);var ct=Math.min(ye,hr(Math.max(H,lt),65536)),Ze=Dr(ct);if(Ze)return!0}return!1}var ru={mappings:{},buffers:[null,[],[]],printChar:function(H,ne){var ye=ru.buffers[H];ne===0||ne===10?((H===1?O:$)(Ke(ye,0)),ye.length=0):ye.push(ne)},varargs:void 0,get:function(){ru.varargs+=4;var H=nr[ru.varargs-4>>2];return H},getStr:function(H){var ne=ot(H);return ne},get64:function(H,ne){return H}};function O1(H){return 0}function Cb(H,ne,ye,Re,lt){}function Tb(H,ne,ye,Re){for(var lt=0,ct=0;ct>2],He=nr[ne+4>>2];ne+=8;for(var qt=0;qt>2]=lt,0}function z1(H){re(H)}var Rc=!1,nu={abort:P1,emscripten_memcpy_big:Tc,emscripten_resize_heap:Ec,fd_close:O1,fd_seek:Cb,fd_write:Tb,setTempRet0:z1},pE=_1(),Nb=s.___wasm_call_ctors=function(){return(Nb=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},D1=s._init=function(){return(D1=s._init=s.asm.init).apply(null,arguments)},L1=s._init_with_threads_count=function(){return(L1=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},$c=s._get_threads_count=function(){return($c=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},Mc=s._register_tensor=function(){return(Mc=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},B1=s._dispose_data=function(){return(B1=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},Oe=s._dispose=function(){return(Oe=s._dispose=s.asm.dispose).apply(null,arguments)},W1=s._Abs=function(){return(W1=s._Abs=s.asm.Abs).apply(null,arguments)},Fc=s._Add=function(){return(Fc=s._Add=s.asm.Add).apply(null,arguments)},uo=s._AddN=function(){return(uo=s._AddN=s.asm.AddN).apply(null,arguments)},au=s._All=function(){return(au=s._All=s.asm.All).apply(null,arguments)},V1=s._Any=function(){return(V1=s._Any=s.asm.Any).apply(null,arguments)},Eb=s._ArgMax=function(){return(Eb=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},U1=s._AvgPool=function(){return(U1=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},Rb=s._BatchMatMul=function(){return(Rb=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},po=s._Ceil=function(){return(po=s._Ceil=s.asm.Ceil).apply(null,arguments)},G1=s._ClipByValue=function(){return(G1=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},j1=s._Conv2D=function(){return(j1=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},H1=s._Conv2DBackpropInput=function(){return(H1=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},q1=s._Cos=function(){return(q1=s._Cos=s.asm.Cos).apply(null,arguments)},X1=s._Cosh=function(){return(X1=s._Cosh=s.asm.Cosh).apply(null,arguments)},K1=s._CropAndResize=function(){return(K1=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},_c=s._Cumprod=function(){return(_c=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Z1=s._Cumsum=function(){return(Z1=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},Y1=s._DepthToSpace=function(){return(Y1=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},J1=s._DepthwiseConv2dNative=function(){return(J1=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Q1=s._Elu=function(){return(Q1=s._Elu=s.asm.Elu).apply(null,arguments)},e2=s._Equal=function(){return(e2=s._Equal=s.asm.Equal).apply(null,arguments)},Pc=s._Exp=function(){return(Pc=s._Exp=s.asm.Exp).apply(null,arguments)},t2=s._FlipLeftRight=function(){return(t2=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},r2=s._Floor=function(){return(r2=s._Floor=s.asm.Floor).apply(null,arguments)},ho=s._FloorDiv=function(){return(ho=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},fp=s._FusedBatchNorm=function(){return(fp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},n2=s._FusedConv2D=function(){return(n2=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},a2=s._FusedDepthwiseConv2D=function(){return(a2=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},s2=s._Gather=function(){return(s2=s._Gather=s.asm.Gather).apply(null,arguments)},Xe=s._GatherNd=function(){return(Xe=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},i2=s._Greater=function(){return(i2=s._Greater=s.asm.Greater).apply(null,arguments)},o2=s._GreaterEqual=function(){return(o2=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},l2=s._LeakyRelu=function(){return(l2=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},u2=s._Less=function(){return(u2=s._Less=s.asm.Less).apply(null,arguments)},d2=s._LessEqual=function(){return(d2=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},p2=s._Log=function(){return(p2=s._Log=s.asm.Log).apply(null,arguments)},mp=s._LogicalAnd=function(){return(mp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Oc=s._LogicalNot=function(){return(Oc=s._LogicalNot=s.asm.LogicalNot).apply(null,arguments)},zc=s._LogicalOr=function(){return(zc=s._LogicalOr=s.asm.LogicalOr).apply(null,arguments)},h2=s._LogicalXor=function(){return(h2=s._LogicalXor=s.asm.LogicalXor).apply(null,arguments)},c2=s._Max=function(){return(c2=s._Max=s.asm.Max).apply(null,arguments)},f2=s._MaxPool=function(){return(f2=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},m2=s._Maximum=function(){return(m2=s._Maximum=s.asm.Maximum).apply(null,arguments)},g2=s._Mean=function(){return(g2=s._Mean=s.asm.Mean).apply(null,arguments)},y2=s._Min=function(){return(y2=s._Min=s.asm.Min).apply(null,arguments)},_t=s._Minimum=function(){return(_t=s._Minimum=s.asm.Minimum).apply(null,arguments)},A2=s._MirrorPad=function(){return(A2=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},x2=s._Multiply=function(){return(x2=s._Multiply=s.asm.Multiply).apply(null,arguments)},b2=s._Neg=function(){return(b2=s._Neg=s.asm.Neg).apply(null,arguments)},su=s._NonMaxSuppressionV3=function(){return(su=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},Dc=s._NonMaxSuppressionV4=function(){return(Dc=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},Lc=s._NonMaxSuppressionV5=function(){return(Lc=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Bc=s._NotEqual=function(){return(Bc=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},v2=s._OneHot=function(){return(v2=s._OneHot=s.asm.OneHot).apply(null,arguments)},Wc=s._PadV2=function(){return(Wc=s._PadV2=s.asm.PadV2).apply(null,arguments)},w2=s._Pow=function(){return(w2=s._Pow=s.asm.Pow).apply(null,arguments)},$b=s._Prelu=function(){return($b=s._Prelu=s.asm.Prelu).apply(null,arguments)},Vc=s._Prod=function(){return(Vc=s._Prod=s.asm.Prod).apply(null,arguments)},Mb=s._RealDiv=function(){return(Mb=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},k2=s._Relu=function(){return(k2=s._Relu=s.asm.Relu).apply(null,arguments)},I2=s._Relu6=function(){return(I2=s._Relu6=s.asm.Relu6).apply(null,arguments)},S2=s._ResizeBilinear=function(){return(S2=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},C2=s._Reverse=function(){return(C2=s._Reverse=s.asm.Reverse).apply(null,arguments)},T2=s._RotateWithOffset=function(){return(T2=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},N2=s._Round=function(){return(N2=s._Round=s.asm.Round).apply(null,arguments)},E2=s._Rsqrt=function(){return(E2=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},R2=s._ScatterNd=function(){return(R2=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},$2=s._SelectV2=function(){return($2=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},M2=s._Sigmoid=function(){return(M2=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},F2=s._Sin=function(){return(F2=s._Sin=s.asm.Sin).apply(null,arguments)},_2=s._Softmax=function(){return(_2=s._Softmax=s.asm.Softmax).apply(null,arguments)},P2=s._SparseFillEmptyRows=function(){return(P2=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},O2=s._SparseReshape=function(){return(O2=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},z2=s._SparseSegmentReduction=function(){return(z2=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},D2=s._Sqrt=function(){return(D2=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},L2=s._Square=function(){return(L2=s._Square=s.asm.Square).apply(null,arguments)},B2=s._SquaredDifference=function(){return(B2=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},W2=s._Step=function(){return(W2=s._Step=s.asm.Step).apply(null,arguments)},V2=s._StridedSlice=function(){return(V2=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},U2=s._Sub=function(){return(U2=s._Sub=s.asm.Sub).apply(null,arguments)},G2=s._Sum=function(){return(G2=s._Sum=s.asm.Sum).apply(null,arguments)},j2=s._Tan=function(){return(j2=s._Tan=s.asm.Tan).apply(null,arguments)},H2=s._Tanh=function(){return(H2=s._Tanh=s.asm.Tanh).apply(null,arguments)},q2=s._Tile=function(){return(q2=s._Tile=s.asm.Tile).apply(null,arguments)},X2=s._TopK=function(){return(X2=s._TopK=s.asm.TopK).apply(null,arguments)},K2=s._Transform=function(){return(K2=s._Transform=s.asm.Transform).apply(null,arguments)},Z2=s._Transpose=function(){return(Z2=s._Transpose=s.asm.Transpose).apply(null,arguments)},Y2=s.__FusedMatMul=function(){return(Y2=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},J2=s._malloc=function(){return(J2=s._malloc=s.asm.malloc).apply(null,arguments)},Q2=s._free=function(){return(Q2=s._free=s.asm.free).apply(null,arguments)},eg=s.___errno_location=function(){return(eg=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},tg=s._emscripten_main_thread_process_queued_calls=function(){return(tg=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Uc=s.stackSave=function(){return(Uc=s.stackSave=s.asm.stackSave).apply(null,arguments)},Gc=s.stackRestore=function(){return(Gc=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},gp=s.stackAlloc=function(){return(gp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},rg=s.dynCall_iijjiiii=function(){return(rg=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},ng=s.dynCall_jiji=function(){return(ng=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=$e;var iu;function yp(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}As=function H(){iu||Ap(),iu||(As=H)};function Ap(H){if(H=H||d,Sn>0||(xc(),Sn>0))return;function ne(){iu||(iu=!0,s.calledRun=!0,!ae&&(bc(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),vc()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),ne()},1)):ne()}s.run=Ap;function Fb(H){de=H,dp()||(s.onExit&&s.onExit(H),ae=!0),p(H,new yp(H))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();Ap();var ou;l&&(ou={uncaughtException:process.listeners("uncaughtException").filter(function(H){return!l.uncaughtException.indexOf(H)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(H){return!l.unhandledRejection.indexOf(H)>-1})});var lu;if(typeof a!="undefined")lu=a;else if(typeof WasmBackendModuleThreadedSimd!="undefined")lu=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(ou){var ag=lu._dispose;lu._dispose=function(){ag(),ou.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),ou.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}return a.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=r:typeof define=="function"&&define.amd?define([],function(){return r}):typeof e=="object"&&(e.WasmBackendModule=r)}}),MR=1e-7,FR=1e-4,rh=class{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}},Uu=class{refCount(e){return Tn("refCount")}incRef(e){return Tn("incRef")}timerAvailable(){return!0}time(e){return Tn("time")}read(e){return Tn("read")}readSync(e){return Tn("readSync")}readToGPU(e,t){return Tn("readToGPU")}numDataIds(){return Tn("numDataIds")}disposeData(e,t){return Tn("disposeData")}write(e,t,r){return Tn("write")}move(e,t,r,n,a){return Tn("move")}memory(){return Tn("memory")}floatPrecision(){return Tn("floatPrecision")}epsilon(){return this.floatPrecision()===32?MR:FR}dispose(){return Tn("dispose")}};function Tn(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 P7(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,t--,I0(e,t,r)}function _R(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let r=e.length,n=0;for(;r>0;)n=Math.random()*r|0,r--,I0(e,r,n),I0(t,r,n)}function Up(e,t,r){return Math.max(e,Math.min(t,r))}function PR(e){return e%2===0?e:e+1}function I0(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function OR(e){let t=0;for(let r=0;rr+` Shapes ${e} and ${t} must match`)}function Vo(e){_(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Ro(e,t=[],r=!1){if(t==null&&(t=[]),Array.isArray(e)||Sr(e)&&!r)for(let n=0;n0,r){return new Promise((n,a)=>{let s=0,i=()=>{if(e()){n();return}s++;let o=t(s);if(r!=null&&s>=r){a();return}setTimeout(i,o)};i()})}function GR(e,t){let r=1,n=-1;for(let s=0;s=0)r*=e[s];else if(e[s]===-1){if(n!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${s}`);n=s}else if(e[s]<0)throw Error(`Shapes can not be < 0. Found ${e[s]} at dim ${s}`);if(n===-1){if(t>0&&t!==r)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(r===0)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%r!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${r}`);let a=e.slice();return a[n]=t/r,a}function Hn(e,t){let r=t.length;return e=e==null?t.map((n,a)=>a):[].concat(e),_(e.every(n=>n>=-r&&n`All values in axis param must be in range [-${r}, ${r}) but got axis ${e}`),_(e.every(n=>Tu(n)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(n=>n<0?r+n:n)}function O7(e,t){let r=[],n=[],a=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||a?null:Hn(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(r.push(e[o]),n.push(o)),s[i]<=o&&i++}e[o]!==1&&(r.push(e[o]),n.push(o))}return{newShape:r,keptDims:n}}function z7(e,t){let r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return r}function D7(e,t){let r=null;if(e==null||e==="float32")r=new Float32Array(t);else if(e==="int32")r=new Int32Array(t);else if(e==="bool")r=new Uint8Array(t);else if(e==="string")r=new Array(t);else throw new Error(`Unknown data type ${e}`);return r}function L7(e,t){for(let r=0;rt+=r.length),t}function Ts(e){return typeof e=="string"||e instanceof String}function V7(e){return typeof e=="boolean"}function U7(e){return typeof e=="number"}function sf(e){return Array.isArray(e)?sf(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":U7(e)?"float32":Ts(e)?"string":V7(e)?"bool":"float32"}function Fs(e){return!!(e&&e.constructor&&e.call&&e.apply)}function S0(e,t){for(let r=t;r=0;--n)r[n]=r[n+1]*e[n+1];return r}function G7(e,t,r,n=!1){let a=new Array;if(t.length===1){let s=t[0]*(n?2:1);for(let i=0;il*u)*(n?2:1);for(let l=0;la*s)*(r?2:1);if(n===0)return[];if(n!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${r?" for a complex tensor":""}.`);return G7(0,e,t,r)}function Ty(e,t){let r=of(e,t);for(let n=0;nn*a,1);if(t==null||t==="float32")return wu(e,new Float32Array(r));if(t==="int32")return wu(e,new Int32Array(r));if(t==="bool")return wu(e,new Uint8Array(r));throw new Error(`Unknown data type ${t}`)}function Ny(e){e.forEach(t=>{_(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function qR(e,t,r){if(t===0)return 0;if(t===1)return e[0];let n=e[e.length-1];for(let a=0;a{let[r,n]=t.split(":");this.urlFlags[r]=YR(r,n)})}};function KR(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(r,...n)=>(ZR(t,n[0],n[1]),n.join("="))),t}function ZR(e,t,r){e[decodeURIComponent(t)]=decodeURIComponent(r||"")}function YR(e,t){if(t=t.toLowerCase(),t==="true"||t==="false")return t==="true";if(`${+t}`===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function Z(){return ba}var ba=null;function JR(e){ba=e}var hg;function H7(){if(hg==null){let e;if(typeof window!="undefined")e=window;else if(typeof global!="undefined")e=global;else if(typeof process!="undefined")e=process;else if(typeof self!="undefined")e=self;else throw new Error("Could not find a global object");hg=e}return hg}function QR(){let e=H7();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function Ry(e,t){let r=QR();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}var Uo="Abs",ju="Acos",Hu="Acosh",Ja="Add",Ks="AddN",qu="All",Xu="Any",Zs="ArgMax",Ku="ArgMin",Zu="Asin",Yu="Asinh",Ju="Atan",Qu="Atanh",ed="Atan2",Ys="AvgPool",lf="AvgPoolGrad",nh="AvgPool3D",uf="AvgPool3DGrad",Js="BatchMatMul",Go="BatchToSpaceND",df="Bincount",q7="BroadcastTo",pf="BroadcastArgs",Qs="Cast",ei="Ceil",Qa="ClipByValue",ah="Complex",sh="ComplexAbs",jo="Concat",ti="Conv2D",hf="Conv2DBackpropFilter",ri="Conv2DBackpropInput",ih="Conv3D",cf="Conv3DBackpropFilterV2",ff="Conv3DBackpropInputV2",ni="Cos",ai="Cosh",Ho="Cumprod",si="Cumsum",qo="CropAndResize",mf="DenseBincount",Xo="DepthToSpace",ii="DepthwiseConv2dNative",gf="DepthwiseConv2dNativeBackpropFilter",yf="DepthwiseConv2dNativeBackpropInput",Af="Diag",oh="Dilation2D",C0="Dilation2DBackpropInput",T0="Dilation2DBackpropFilter",oi="RealDiv",lh="Einsum",li="Elu",xf="EluGrad",td="Erf",Ko="Equal",ui="Exp",Zo="ExpandDims",Yo="Expm1",bf="FFT",rd="Fill",Jo="FlipLeftRight",di="Floor",pi="FloorDiv",hi="FusedBatchNorm",Qo="GatherV2",el="GatherNd",tl="Greater",ci="GreaterEqual",fi="Identity",vf="IFFT",uh="Imag",nd="IsFinite",ad="IsInf",sd="IsNan",mi="LeakyRelu",rl="Less",nl="LessEqual",wf="LinSpace",gi="Log",id="Log1p",al="LogicalAnd",sl="LogicalNot",od="LogicalOr",X7="LogicalXor",K7="LogSoftmax",e$="LowerBound",dh="LRN",kf="LRNGrad",yi="Max",Ai="Maximum",xi="MaxPool",If="MaxPoolGrad",ph="MaxPool3D",Sf="MaxPool3DGrad",Cf="MaxPoolWithArgmax",bi="Mean",vi="Min",wi="Minimum",ki="MirrorPad",ld="Mod",Tf="Multinomial",Ii="Multiply",il="Neg",ol="NotEqual",ll="NonMaxSuppressionV3",ud="NonMaxSuppressionV4",ul="NonMaxSuppressionV5",dl="OnesLike",pl="OneHot",hl="Pack",Si="PadV2",t$="Pool",Ci="Pow",Ti="Prelu",Ni="Prod",dd="Range",hh="Real",pd="Reciprocal",Ei="Relu",cl="Reshape",hd="ResizeNearestNeighbor",Nf="ResizeNearestNeighborGrad",Ri="ResizeBilinear",Ef="ResizeBilinearGrad",$i="Relu6",fl="Reverse",ml="Round",Mi="Rsqrt",gl="ScatterNd",Rf="SearchSorted",yl="Select",cd="Selu",Al="Slice",Fi="Sin",xl="Sinh",fd="Sign",_i="Sigmoid",md="Softplus",Pi="Sqrt",Oi="Sum",bl="SpaceToBatchND",vl="SplitV",zi="Softmax",ch="SparseFillEmptyRows",gd="SparseReshape",fh="SparseSegmentMean",mh="SparseSegmentSum",gh="SparseToDense",Di="SquaredDifference",yd="Square",wl="StridedSlice",yh="StringNGrams",$f="StringSplit",Mf="StringToHashBucketFast",Li="Sub",kl="Tan",Bi="Tanh",es="Tile",Il="TopK",Sl="Transform",$a="Transpose",Ff="Unique",Cl="Unpack",Ah="UnsortedSegmentSum",r$="UpperBound",Tl="ZerosLike",Wi="Step",Gp="FromPixels",Nl="RotateWithOffset",_s="_FusedMatMul",Ps="FusedConv2D",Os="FusedDepthwiseConv2D";function Cs(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.warn(...e)}function n$(...e){Z().getBool("IS_TEST")||Z().getBool("PROD")||console.log(...e)}var Nu=Ry("kernelRegistry",()=>new Map),jp=Ry("gradRegistry",()=>new Map);function N0(e,t){let r=$y(e,t);return Nu.get(r)}function Tg(e){return jp.get(e)}function Fa(e){let t=Nu.entries(),r=[];for(;;){let{done:n,value:a}=t.next();if(n)break;let[s,i]=a,[o]=s.split("_");o===e&&r.push(i)}return r}function qn(e){let{kernelName:t,backendName:r}=e,n=$y(t,r);Nu.has(n)&&Cs(`The kernel '${t}' for backend '${r}' is already registered`),Nu.set(n,e)}function Z7(e){let{kernelName:t}=e;jp.has(t)&&Z().getBool("DEBUG")&&Cs(`Overriding the gradient for '${t}'`),jp.set(t,e)}function a$(e,t){let r=$y(e,t);if(!Nu.has(r))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Nu.delete(r)}function s$(e){if(!jp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);jp.delete(e)}function i$(e,t){Fa(e).forEach(r=>{let n=Object.assign({},r,{backendName:t});qn(n)})}function $y(e,t){return`${t}_${e}`}var v={};Be(v,{arraysEqual:()=>Xs,assert:()=>_,assertNonNegativeIntegerDimensions:()=>Ny,assertNonNull:()=>Vo,assertShapesMatch:()=>jr,bytesFromStringArray:()=>W7,bytesPerElement:()=>Cg,checkConversionForErrors:()=>L7,clamp:()=>Up,computeStrides:()=>Gu,createScalarValue:()=>h$,createShuffledIndices:()=>VR,decodeString:()=>E0,distSquared:()=>DR,encodeString:()=>bh,fetch:()=>f$,fingerPrint64:()=>p$,flatten:()=>Ro,getArrayFromDType:()=>D7,getTypedArrayFromDType:()=>z7,hasEncodingLoss:()=>jR,hexToLong:()=>xh,indexToLoc:()=>XR,inferDtype:()=>sf,inferFromImplicitShape:()=>GR,isBoolean:()=>V7,isFunction:()=>Fs,isInt:()=>Tu,isNumber:()=>U7,isPromise:()=>Ey,isScalarShape:()=>LR,isString:()=>Ts,isTypedArray:()=>Sr,isValidDtype:()=>B7,locToIndex:()=>qR,makeOnesTypedArray:()=>Ty,makeZerosNestedTypedArray:()=>HR,makeZerosTypedArray:()=>of,nearestDivisor:()=>S0,nearestLargerEven:()=>PR,now:()=>Hp,parseAxisParam:()=>Hn,randUniform:()=>zR,repeatedTry:()=>UR,rightPad:()=>Dp,shuffle:()=>P7,shuffleCombo:()=>_R,sizeFromShape:()=>It,sizeToSquarishShape:()=>WR,squeezeShape:()=>O7,sum:()=>OR,swap:()=>I0,tanh:()=>BR,toNestedArray:()=>wu,toTypedArray:()=>_f});var Hb=Wo(gR()),xo=Hb.default||Hb;function xh(e){return xo.fromString(e,!0,16)}var Y7=xh("c3a5c85c97cb3127"),go=xh("b492b66fbe98f273"),Lr=xh("9ae16a3b2f90404f");function Ng(e){return e.xor(e.shru(47))}function J7(e,t,r){let n=e.slice(t,t+r);return xo.fromBytes(Array.from(n),!0,!0)}function kt(e,t){return J7(e,t,8)}function qb(e,t){return J7(e,t,4)}function fr(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Es(e,t,r=xh("9ddfea08eb382d69")){let n=e.xor(t).mul(r);n=n.xor(n.shru(47));let a=t.xor(n).mul(r);return a=a.xor(a.shru(47)),a=a.mul(r),a}function o$(e,t,r,n,a,s){a=a.add(e),s=fr(s.add(a).add(n),21);let i=a;return a=a.add(t),a=a.add(r),s=s.add(fr(a,44)),[a.add(n),s.add(i)]}function Qc(e,t,r,n){return o$(kt(e,t),kt(e,t+8),kt(e,t+16),kt(e,t+24),r,n)}function l$(e,t=e.length){if(t>=8){let r=Lr.add(t*2),n=kt(e,0).add(Lr),a=kt(e,t-8),s=fr(a,37).mul(r).add(n),i=fr(n,25).add(a).mul(r);return Es(s,i,r)}if(t>=4){let r=Lr.add(t*2),n=qb(e,0);return Es(n.shl(3).add(t),qb(e,t-4),r)}if(t>0){let r=e[0],n=e[t>>1],a=e[t-1],s=r+(n<<8),i=t+(a<<2);return Ng(Lr.mul(s).xor(Y7.mul(i))).mul(Lr)}return Lr}function u$(e,t=e.length){let r=Lr.add(t*2),n=kt(e,0).mul(go),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Lr);return Es(fr(n.add(a),43).add(fr(s,30)).add(i),n.add(fr(a.add(Lr),18)).add(s),r)}function d$(e,t=e.length){let r=Lr.add(t*2),n=kt(e,0).mul(Lr),a=kt(e,8),s=kt(e,t-8).mul(r),i=kt(e,t-16).mul(Lr),o=fr(n.add(a),43).add(fr(s,30)).add(i),l=Es(o,n.add(fr(a.add(Lr),18)).add(s),r),u=kt(e,16).mul(r),d=kt(e,24),h=o.add(kt(e,t-32)).mul(r),p=l.add(kt(e,t-24)).mul(r);return Es(fr(u.add(d),43).add(fr(h,30)).add(p),u.add(fr(d.add(n),18)).add(h),r)}function p$(e,t=e.length){let r=xo.fromNumber(81,!0);if(t<=32)return t<=16?l$(e,t):u$(e,t);if(t<=64)return d$(e,t);let n=r,a=r.mul(go).add(113),s=Ng(a.mul(Lr).add(113)).mul(Lr),i=[xo.UZERO,xo.UZERO],o=[xo.UZERO,xo.UZERO];n=n.mul(Lr).add(kt(e,0));let l=0,u=(t-1>>6)*64,d=u+(t-1&63)-63;do n=fr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(go),a=fr(a.add(i[1]).add(kt(e,l+48)),42).mul(go),n=n.xor(o[1]),a=a.add(i[0]).add(kt(e,l+40)),s=fr(s.add(o[0]),33).mul(go),i=Qc(e,l,i[1].mul(go),n.add(o[0])),o=Qc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],l+=64;while(l!==u);let h=go.add(s.and(255).shl(1));return l=d,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),n=fr(n.add(a).add(i[0]).add(kt(e,l+8)),37).mul(h),a=fr(a.add(i[1]).add(kt(e,l+48)),42).mul(h),n=n.xor(o[1].mul(9)),a=a.add(i[0].mul(9).add(kt(e,l+40))),s=fr(s.add(o[0]),33).mul(h),i=Qc(e,l,i[1].mul(h),n.add(o[0])),o=Qc(e,l+32,s.add(o[1]),a.add(kt(e,l+16))),[s,n]=[n,s],Es(Es(i[0],o[0],h).add(Ng(a).mul(Y7)).add(s),Es(i[1],o[1],h).add(n),h)}function h$(e,t){return t==="string"?bh(e):_f([e],t)}function c$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function _f(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Ro(e)),Z().getBool("DEBUG")&&L7(e,t),c$(e,t))return e;if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool"){let r=new Uint8Array(e.length);for(let n=0;n{n=r()},s,i=Hp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(a);else{a();for(let o of n)o.dataSync();s=Promise.resolve({kernelMs:Hp()-i})}if(Z().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{g$(u,l.dtype,e)})}return{kernelName:e,outputs:n,inputs:t,timeMs:s.then(o=>o.kernelMs),extraInfo:s.then(o=>o.getExtraProfileInfo!=null?o.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:r,timeMs:n,inputs:a,extraInfo:s}=e;r.forEach(i=>{Promise.all([i.data(),n,s]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],a,o[2])})})}};function g$(e,t,r){if(t!=="float32")return!1;for(let n=0;n0?m:""} `}}console.log(`%c${o} %c${i} %c${l}D ${d} %c${u} %c${h} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function A$(e,t,r){let n={},a={};for(let l=0;ln[f.id]=!0),c=!0,a[u.id]=!0;break}if(c)break}}let s={};s[r.id]=!0;let i={};for(let l=e.length-1;l>=0;l--){let u=e[l],d=u.inputs;for(let h=0;h=0;a--){let s=t[a],i=[];if(s.outputs.forEach(l=>{let u=e[l.id];u!=null?i.push(u):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let o=s.gradient(i);for(let l in s.inputs){if(!(l in o))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(o)}.`);let u=r(()=>o[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let d=s.inputs[l];if(!Xs(u.shape,d.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${d.shape}'`);if(e[d.id]==null)e[d.id]=u;else{let h=e[d.id];e[d.id]=n(h,u),h.dispose()}}}}var Xb=20,Ip=3,cg=7;function b$(e,t,r,n){let a=Gu(t),s=v$(e,t,r,a),i=t.length,o=p0(e,t,r,a,s),l=["Tensor"];return n&&(l.push(` dtype: ${r}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map(u=>" "+u).join(` `)),l.join(` `)}function v$(e,t,r,n){let a=It(t),s=n[n.length-1],i=new Array(s).fill(0),o=t.length,l=r==="complex64"?Ep(e):e;if(o>1)for(let u=0;uXb){let g=Ip*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-Ip)*i,o*i));return r==="complex64"&&(y=Ep(y),A=Ep(A)),["["+y.map((x,b)=>Np(x,a[b],r)).join(", ")+", ..., "+A.map((x,b)=>Np(x,a[o-Ip+b],r)).join(", ")+"]"]}let f=r==="complex64"?Ep(e):Array.from(e);return["["+f.map((g,y)=>Np(g,a[y],r)).join(", ")+"]"]}let u=t.slice(1),d=n.slice(1),h=n[0]*i,p=[];if(o>Xb){for(let f=0;f`Length of values '${n}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")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=r||D7(t,this.size),this.strides=Gu(e)}set(e,...t){t.length===0&&(t=[0]),_(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let r=this.locToIndex(t);this.values[r]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let n of e){if(n<0||n>=this.shape[t]){let a=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(a)}t++}let r=e[e.length-1];for(let n=0;nE0(r))}catch(r){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(),la().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=la().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>E0(t))}catch(t){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();let e=await la().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(la().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Au.print(this,e)}clone(){return this.throwIfDisposed(),Au.clone(this)}toString(e=!1){let t=this.dataSync();return b$(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Au.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),la().makeVariable(this,e,t,r)}};Object.defineProperty(nt,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function C$(){return Ry("Tensor",()=>nt)}C$();var qp=class extends nt{constructor(e,t,r,n){super(e.shape,e.dtype,e.dataId,n),this.trainable=t,this.name=r}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(!Xs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);la().disposeTensor(this),this.dataId=e.dataId,la().incRef(this,null)}dispose(){la().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(qp,Symbol.hasInstance,{value:e=>e instanceof nt&&e.assign!=null&&e.assign instanceof Function});var ha={};Be(ha,{assertTypesMatch:()=>s6,getTensorsInContainer:()=>My,isTensorInList:()=>N$,makeTypesMatch:()=>Lt});var e6=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(e6||{}),t6=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(t6||{}),r6=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(r6||{}),n6=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(n6||{}),a6=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(a6||{}),T$={float32:n6,int32:t6,bool:r6,complex64:a6};function Nr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return T$[e][t]}function vh(e){return Nr(e,"int32")}function Lt(e,t){if(e.dtype===t.dtype)return[e,t];let r=Nr(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function s6(e,t){_(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function N$(e,t){return t.some(r=>r.id===e.id)}function My(e){let t=[];return i6(e,t,new Set),t}function i6(e,t,r){if(e==null)return;if(e instanceof nt){t.push(e);return}if(!E$(e))return;let n=e;for(let a in n){let s=n[a];r.has(s)||(r.add(s),i6(s,t,r))}}function E$(e){return Array.isArray(e)||typeof e=="object"}function fg(e){return e.kernelName!=null}var Kb=class{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(let e in this.registeredVariables)this.registeredVariables[e].dispose()}},Eg=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Kb}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Fa(e).forEach(t=>{t.disposeFunc!=null&&t.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let r=t.factory();if(r&&!(r instanceof Uu)&&typeof r.then=="function"){let n=++this.pendingBackendInitId,a=r.then(s=>n(nthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(r),()=>this.endScope(n),()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n))}scopedRun(e,t,r){e();try{let n=r();return t(),n}catch(n){throw t(),n}}nextTensorId(){return Eg.nextTensorId++}nextVariableId(){return Eg.nextVariableId++}clone(e){let t=B.runKernel(fi,{x:e}),r={x:e},n=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return B.runKernel(Qs,o,l)}}),a=[];return this.addTapeNode(this.state.activeScope.name,r,[t],n,a,{}),t}runKernel(e,t,r){if(this.backendName==null&&this.backend,N0(e,this.backendName)==null)throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){let n=this.backend.numDataIds(),a=0;r.forEach(o=>{a+=o.dtype==="complex64"?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=n-t-a-s;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,r=[],n=this.isTapeOn(),a=this.state.numBytes,s=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,l=fg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(fg(e)){let{kernelName:c,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=N0(c,this.backendName);_(g!=null,()=>`Cannot find registered kernel '${c}' for backend '${this.backendName}'`),i=()=>{let y=this.backend.numDataIds();o=g.kernelFunc({inputs:m,attrs:f,backend:this.backend});let A=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,y,A);let x=A.map(b=>b.rank!=null?b:this.makeTensorFromTensorInfo(b));if(n){let b=this.getTensorsForGradient(c,m,x);r=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:c}=e,m=f=>{!n||(r=f.map(g=>this.keep(this.clone(g))))};i=()=>{let f=this.backend.numDataIds();o=this.tidy(()=>c(this.backend,m));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,f,g),g}}let{inputs:u,attrs:d}=e,h=fg(e)?null:e.backwardsFunc,p;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(p=this.profiler.profileKernel(l,u,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),n&&this.addTapeNode(l,u,t,h,r,d),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(c=>u[c]!=null?u[c].shape:null),outputShapes:t.map(c=>c.shape),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(e,t,r){let n=Tg(e);if(n!=null){let a=n.inputsToSave||[],s=n.outputsToSave||[],i;n.saveAllInputs?(_(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=a.map(l=>t[l]);let o=r.filter((l,u)=>s[u]);return i.concat(o)}return[]}makeTensor(e,t,r,n){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",n=n||this.backend;let a=e;r==="string"&&Ts(e[0])&&(a=e.map(o=>bh(o)));let s=n.write(a,t,r),i=new nt(t,r,s,this.nextTensorId());if(this.trackTensor(i,n),r==="string"){let o=this.state.tensorInfo.get(s),l=W7(a);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,r,n){r=r||"float32";let a={dataId:e,shape:t,dtype:r};return this.makeTensorFromTensorInfo(a,n)}makeTensorFromTensorInfo(e,t){let{dataId:r,shape:n,dtype:a}=e,s=new nt(n,a,r,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,r,n){r=r||this.nextVariableId().toString(),n!=null&&n!==e.dtype&&(e=e.cast(n));let a=new qp(e,t,r,this.nextTensorId());if(this.state.registeredVariables[a.name]!=null)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++,e.dtype==="string"&&this.state.numStringTensors++;let r=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(r=e.size*Cg(e.dtype)),this.state.numBytes+=r,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:r})),e instanceof qp||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;let t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){let r=e.size*Cg(e.dtype);this.state.numBytes-=r}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(let e in this.state.registeredVariables){let t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){let 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,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;let t=this.state.numBytes,r=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(n=>n.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r;for(let n of this.state.activeProfile.kernels)n.kernelTimeMs=await n.kernelTimeMs,n.extraInfo=await n.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,r,n,a,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:a},o=Tg(e);o!=null&&(n=o.gradFunc),n!=null&&(i.gradient=l=>(l=l.map((u,d)=>{if(u==null){let h=r[d],p=of(h.size,h.dtype);return this.makeTensor(p,h.shape,h.dtype)}return u}),n(l.length>1?l:l[0],a,s))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=My(e),r=new Set(t.map(a=>a.id));for(let a=0;a{!a.kept&&a.scopeId===n.id&&this.track(a)})}gradients(e,t,r,n=!1){if(_(t.length>0,()=>"gradients() received an empty list of xs."),r!=null&&r.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);let a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));_(a instanceof nt,()=>"The result y returned by f() must be a tensor.");let s=A$(this.state.activeTape,t,a);if(!n&&s.length===0&&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",()=>{let i={};i[a.id]=r==null?R$(a.shape):r,x$(i,s,l=>this.tidy(l),$$);let o=t.map(l=>i[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let u of l.saved)u.dispose()}),this.state.activeTape=null),{value:a,grads:o}})}customGrad(e){return _(Fs(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{_(t.every(i=>i instanceof nt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let r,n={};t.forEach((i,o)=>{n[o]=i});let a=(i,o)=>(r=e(...t,o),_(r.value instanceof nt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),_(Fs(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),s=(i,o)=>{let l=r.gradFunc(i,o),u=Array.isArray(l)?l:[l];_(u.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(...)."),_(u.every(h=>h instanceof nt),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let d={};return u.forEach((h,p)=>{d[p]=()=>h}),d};return this.runKernelFunc({forwardFunc:a,backwardsFunc:s,inputs:n})}}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){let t=Hp(),r=await this.backend.time(e);return r.wallMs=Hp()-t,r}track(e){return this.state.activeScope!=null&&(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 Kb;for(let e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}},Fy=Eg;Fy.nextTensorId=0;Fy.nextVariableId=0;function R$(e){let t=Ty(It(e),"float32");return B.makeTensor(t,e,"float32")}function o6(){let e=H7();if(e._tfengine==null){let t=new j7(e);e._tfengine=new Fy(t)}return JR(e._tfengine.ENV),k$(()=>e._tfengine),e._tfengine}var B=o6();function $$(e,t){let r={a:e,b:t};return B.runKernel(Ja,r)}var wh={};Be(wh,{isBrowser:()=>l6,isMobile:()=>_$,mockIsMobile:()=>F$});function M$(){return typeof navigator!="undefined"&&navigator!=null}var Rg;function F$(e){Rg=e}function _$(e){if(Rg!==void 0)return Rg;if(e||M$()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let r=e;return r.userAgentData&&r.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 l6(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Rn=Z();Rn.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.")});Rn.registerFlag("IS_BROWSER",()=>l6());Rn.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Rn.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Rn.registerFlag("PROD",()=>!1);Rn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Rn.getBool("DEBUG"));Rn.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Rn.registerFlag("IS_TEST",()=>!1);Rn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Rn.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Rn.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);Rn.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY",()=>!1);function _a(e,t){let r=e;if(Sr(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||Sr(r)&&t!=="string";)n.push(r.length),r=r[0];return Array.isArray(e)&&Z().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&u6(e,n,[]),n}function u6(e,t,r){if(r=r||[],!Array.isArray(e)&&!Sr(e)){_(t.length===0,()=>`Element arr[${r.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}_(t.length>0,()=>`Element arr[${r.join("][")}] should be a primitive, but is an array of ${e.length} elements`),_(e.length===t[0],()=>`Element arr[${r.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let n=t.slice(1);for(let a=0;a=0&&(a=n),Zb(n,a,t,r),e==null||!Sr(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let o=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${r}' must be a Tensor or TensorLike, but got '${o}'`)}let s=_a(e,a);!Sr(e)&&!Array.isArray(e)&&(e=[e]);let i=a!=="string"?_f(e,a):Ro(e,[],!0);return B.makeTensor(i,s,a)}function Xp(e,t,r,n="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${r} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,s)=>M(a,`${t}[${s}]`,r,n))}var d6="__op";function W(e){let t=Object.keys(e);if(t.length!==1)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 r=t[0],n=e[r];r.endsWith("_")&&(r=r.substring(0,r.length-1)),r=r+d6;let a=(...s)=>{B.startScope(r);try{let i=n(...s);return Ey(i)&&console.error("Cannot return a Promise inside of tidy."),B.endScope(i),i}catch(i){throw B.endScope(null),i}};return Object.defineProperty(a,"name",{value:r,configurable:!0}),a}function P$(e,t){let r=M(e,"real","complex"),n=M(t,"imag","complex");jr(r.shape,n.shape,`real and imag shapes, ${r.shape} and ${n.shape}, must match in call to tf.complex().`);let a={real:r,imag:n};return B.runKernel(ah,a)}var Za=W({complex_:P$});function Vi(e,t,r,n){if(n==null&&(n=sf(e)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Sr(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string")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(t!=null){Ny(t);let a=It(t),s=It(r);_(a===s,()=>`Based on the provided shape, [${t}], the tensor should have ${a} values but has ${s}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${r}) does not match the provided shape (${t}). `)}}return!Sr(e)&&!Array.isArray(e)&&(e=[e]),t=t||r,e=n!=="string"?_f(e,n):Ro(e,[],!0),B.makeTensor(e,t,n)}function ft(e,t,r){let n=_a(e,r);return Vi(e,t,n,r)}var $g={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},R0=4;async function O$(e,t){let r=[],n=[],a=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let p=await l.bytes(),c=p.reduce((g,y)=>g+y.length,0)+R0*p.length,m=new Uint8Array(c),f=0;for(let g=0;g{if(t+=s.byteLength,r.push(s.byteLength===s.buffer.byteLength?s:new s.constructor(s)),!(s instanceof Float32Array||s instanceof Int32Array||s instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`)});let n=new Uint8Array(t),a=0;return r.forEach(s=>{n.set(new Uint8Array(s.buffer),a),a+=s.byteLength}),n.buffer}var _y=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Yb(e){return _y?Buffer.byteLength(e):new Blob([e]).size}function D$(e){if(_y)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),r="";for(let n=0,a=t.length;n{t+=a.byteLength});let r=new Uint8Array(t),n=0;return e.forEach(a=>{r.set(new Uint8Array(a),n),n+=a.byteLength}),r.buffer}function Jb(e){let t="/";for(e=e.trim();e.endsWith(t);)e=e.slice(0,e.length-1);let r=e.split(t);return r[r.length-1]}function h6(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),e.trainingConfig!=null&&(r.trainingConfig=e.trainingConfig),r}async function Oy(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(e.trainingConfig!=null&&(r.trainingConfig=e.trainingConfig),e.weightsManifest!=null){let[n,a]=await t(e.weightsManifest);r.weightSpecs=n,r.weightData=a}return e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),r}function kh(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:e.modelTopology==null?0:Yb(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:Yb(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function B$(){let e=r=>{let n=r<<13,a=0;for(;(n&8388608)===0;)a-=8388608,n<<=1;return n&=-8388609,a+=947912704,n|a},t=new Uint32Array(2048);t[0]=0;for(let r=1;r<1024;r++)t[r]=e(r);for(let r=1024;r<2048;r++)t[r]=939524096+(r-1024<<13);return t}function W$(){let 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}function V$(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function U$(){let e=B$(),t=W$(),r=V$();return n=>{let a=new ArrayBuffer(4*n.length),s=new Uint32Array(a);for(let i=0;i>10]+(o&1023)]+t[o>>10];s[i]=l}return new Float32Array(a)}}var Wt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Wt.instance==null&&(Wt.instance=new Wt),Wt.instance}static registerSaveRouter(e){Wt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Wt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Wt.getHandlers(e,"save")}static getLoadHandlers(e,t){return Wt.getHandlers(e,"load",t)}static getHandlers(e,t,r){let n=[];return(t==="load"?Wt.getInstance().loadRouters:Wt.getInstance().saveRouters).forEach(a=>{let s=a(e,r);s!==null&&n.push(s)}),n}},G$=e=>Wt.registerSaveRouter(e),j$=e=>Wt.registerLoadRouter(e),H$=e=>Wt.getSaveHandlers(e),q$=(e,t)=>Wt.getLoadHandlers(e,t),Mg="tensorflowjs",Fg=1,ko="models_store",Ns="model_info_store";function c6(){if(!Z().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let e=typeof window=="undefined"?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(t==null)throw new Error("The current browser does not appear to support IndexedDB.");return t}function _g(e){let t=e.result;t.createObjectStore(ko,{keyPath:"modelPath"}),t.createObjectStore(Ns,{keyPath:"modelPath"})}var $o=class{constructor(e){if(this.indexedDB=c6(),e==null||!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((r,n)=>{let a=this.indexedDB.open(Mg,Fg);a.onupgradeneeded=()=>_g(a),a.onsuccess=()=>{let s=a.result;if(t==null){let i=s.transaction(ko,"readonly"),o=i.objectStore(ko).get(this.modelPath);o.onsuccess=()=>{if(o.result==null)return s.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));r(o.result.modelArtifacts)},o.onerror=l=>(s.close(),n(o.error)),i.oncomplete=()=>s.close()}else{let i=kh(t),o=s.transaction(Ns,"readwrite"),l=o.objectStore(Ns),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),d;u.onsuccess=()=>{d=s.transaction(ko,"readwrite");let h=d.objectStore(ko).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});h.onsuccess=()=>r({modelArtifactsInfo:i}),h.onerror=p=>{l=o.objectStore(Ns);let c=l.delete(this.modelPath);c.onsuccess=()=>(s.close(),n(h.error)),c.onerror=m=>(s.close(),n(h.error))}},u.onerror=h=>(s.close(),n(u.error)),o.oncomplete=()=>{d==null?s.close():d.oncomplete=()=>s.close()}}},a.onerror=s=>n(a.error)})}};$o.URL_SCHEME="indexeddb://";var f6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith($o.URL_SCHEME)?X$(e.slice($o.URL_SCHEME.length)):null;Wt.registerSaveRouter(f6);Wt.registerLoadRouter(f6);function X$(e){return new $o(e)}function K$(e){return e.startsWith($o.URL_SCHEME)?e.slice($o.URL_SCHEME.length):e}var Z$=class{constructor(){this.indexedDB=c6()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(Mg,Fg);r.onupgradeneeded=()=>_g(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(Ns,"readonly"),s=a.objectStore(Ns).getAll();s.onsuccess=()=>{let i={};for(let o of s.result)i[o.modelPath]=o.modelArtifactsInfo;e(i)},s.onerror=i=>(n.close(),t(s.error)),a.oncomplete=()=>n.close()},r.onerror=n=>t(r.error)})}async removeModel(e){return e=K$(e),new Promise((t,r)=>{let n=this.indexedDB.open(Mg,Fg);n.onupgradeneeded=()=>_g(n),n.onsuccess=()=>{let a=n.result,s=a.transaction(Ns,"readwrite"),i=s.objectStore(Ns),o=i.get(e),l;o.onsuccess=()=>{if(o.result==null)return a.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=i.delete(e),d=()=>{l=a.transaction(ko,"readwrite");let h=l.objectStore(ko).delete(e);h.onsuccess=()=>t(o.result.modelArtifactsInfo),h.onerror=p=>r(o.error)};u.onsuccess=d,u.onerror=h=>(d(),a.close(),r(o.error))}},o.onerror=u=>(a.close(),r(o.error)),s.oncomplete=()=>{l==null?a.close():l.oncomplete=()=>a.close()}},n.onerror=a=>r(n.error)})}},qa="/",xu="tensorflowjs_models",m6="info",Y$="model_topology",J$="weight_specs",Q$="weight_data",eM="model_metadata";function g6(e){return{info:[xu,e,m6].join(qa),topology:[xu,e,Y$].join(qa),weightSpecs:[xu,e,J$].join(qa),weightData:[xu,e,Q$].join(qa),modelMetadata:[xu,e,eM].join(qa)}}function y6(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function tM(e){let t=e.split(qa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(qa)}function rM(e){return e.startsWith(Mo.URL_SCHEME)?e.slice(Mo.URL_SCHEME.length):e}var Mo=class{constructor(e){if(!Z().getBool("IS_BROWSER")||typeof window=="undefined"||typeof window.localStorage=="undefined")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=g6(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.");{let t=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),n=kh(e);try{this.LS.setItem(this.keys.info,JSON.stringify(n)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,D$(e.weightData));let a={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(a)),{modelArtifactsInfo:n}}catch(a){throw y6(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=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let t={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(r==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;let n=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(n==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=n;let a=this.LS.getItem(this.keys.modelMetadata);if(a!=null){let i=JSON.parse(a);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}let s=this.LS.getItem(this.keys.weightData);if(s==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=L$(s),t}};Mo.URL_SCHEME="localstorage://";var A6=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Mo.URL_SCHEME)?nM(e.slice(Mo.URL_SCHEME.length)):null;Wt.registerSaveRouter(A6);Wt.registerLoadRouter(A6);function nM(e){return new Mo(e)}var aM=class{constructor(){_(Z().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),_(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=xu+qa,r=qa+m6;for(let n=0;n"scheme must not be undefined or null."),e.endsWith(ku)&&(e=e.slice(0,e.indexOf(ku))),_(e.length>0,()=>"scheme must not be an empty string.");let r=Nn.getInstance();_(r.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){let t=this.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}};function h0(e){if(e.indexOf(ku)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Nn.getSchemes().join(",")}`);return{scheme:e.split(ku)[0],path:e.split(ku)[1]}}async function x6(e,t,r=!1){_(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=Wt.getLoadHandlers(e);_(n.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),_(n.length<2,()=>`Copying failed because more than one (${n.length}) load handlers for source URL ${e}.`);let a=n[0],s=Wt.getSaveHandlers(t);_(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),_(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],o=h0(e).scheme,l=h0(e).path,u=o===h0(e).scheme,d=await a.load();r&&u&&await Nn.getManager(o).removeModel(l);let h=await i.save(d);return r&&!u&&await Nn.getManager(o).removeModel(l),h.modelArtifactsInfo}async function sM(){let e=Nn.getSchemes(),t={};for(let r of e){let n=await Nn.getManager(r).listModels();for(let a in n){let s=r+ku+a;t[s]=n[a]}}return t}async function iM(e){let t=h0(e);return Nn.getManager(t.scheme).removeModel(t.path)}async function oM(e,t){return x6(e,t,!1)}async function lM(e,t){return x6(e,t,!0)}var uM=class{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}};if(Z().get("IS_BROWSER")){Z().setPlatform("browser",new uM);try{Nn.registerManager(Mo.URL_SCHEME,new aM)}catch(e){}try{Nn.registerManager($o.URL_SCHEME,new Z$)}catch(e){}}var dM={importFetch:()=>yR()},mg,pM=class{constructor(){this.util=AR(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Z().global.fetch!=null?Z().global.fetch(e,t):(mg==null&&(mg=dM.importFetch()),mg(e,t))}now(){let e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?"":new this.util.TextDecoder(t).decode(e)}};Z().get("IS_NODE")&&!Z().get("IS_BROWSER")&&Z().setPlatform("node",new pM);function De(e,t="float32",r){return t=t||"float32",Ny(e),new ir(e,t,r)}function hM(e,t){let r=M(e,"x","cast");if(!B7(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&r.dtype!=="string"||t!=="string"&&r.dtype==="string")throw new Error("Only strings can be casted to strings");let n={x:r},a={dtype:t};return B.runKernel(Qs,n,a)}var me=W({cast_:hM});function cM(e){let t={x:M(e,"x","clone","string_or_numeric")};return B.runKernel(fi,t)}var Vr=W({clone_:cM});function b6(e,t=!1){console.log(e.toString(t))}o6();var fM={buffer:De,cast:me,clone:Vr,print:b6};I$(fM);var Cr={};Be(Cr,{browserFiles:()=>vM,browserHTTPRequest:()=>CM,concatenateArrayBuffers:()=>Py,copyModel:()=>oM,decodeWeights:()=>p6,encodeWeights:()=>O$,fromMemory:()=>NM,fromMemorySync:()=>S6,getLoadHandlers:()=>q$,getModelArtifactsForJSON:()=>Oy,getModelArtifactsInfoForJSON:()=>kh,getSaveHandlers:()=>H$,http:()=>Dy,isHTTPScheme:()=>Og,listModels:()=>sM,loadWeights:()=>wM,moveModel:()=>lM,registerLoadRouter:()=>j$,registerSaveRouter:()=>G$,removeModel:()=>iM,weightsLoaderFactory:()=>w6,withSaveHandler:()=>EM,withSaveHandlerSync:()=>RM});var mM="model",gM=".json",yM=".weights.bin";function Qb(e){return new Promise(t=>setTimeout(t)).then(e)}var Pg=class{constructor(e){if(!Z().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Pg.URL_SCHEME)&&(e=e.slice(Pg.URL_SCHEME.length)),(e==null||e.length===0)&&(e=mM),this.modelJsonFileName=e+gM,this.weightDataFileName=e+yM}async save(e){if(typeof document=="undefined")throw new Error("Browser downloads are not supported in this environment since `document` is not present");let 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.");{let r=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],n=h6(e,r),a=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),s=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=a,await Qb(()=>s.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let i=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;i.download=this.weightDataFileName,i.href=t,await Qb(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:kh(e)}}}},$0=Pg;$0.URL_SCHEME="downloads://";var AM=class{constructor(e){if(e==null||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)=>{let r=new FileReader;r.onload=n=>{let a=JSON.parse(n.target.result),s=a.modelTopology;if(s==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(a.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:s});return}let i=Oy(a,o=>this.loadWeights(o));e(i)},r.onerror=n=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),r.readAsText(this.jsonFile)})}loadWeights(e){let t=[],r=[];for(let s of e)t.push(...s.weights),r.push(...s.paths);let n=this.checkManifestAndWeightFiles(e),a=r.map(s=>this.loadWeightsFile(s,n[s]));return Promise.all(a).then(s=>[t,Py(s)])}loadWeightsFile(e,t){return new Promise((r,n)=>{let a=new FileReader;a.onload=s=>{let i=s.target.result;r(i)},a.onerror=s=>n(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],r=this.weightsFiles.map(a=>Jb(a.name)),n={};for(let a of e)a.paths.forEach(s=>{let i=Jb(s);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),r.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);n[s]=this.weightsFiles[r.indexOf(i)]});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 n}},xM=e=>Z().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith($0.URL_SCHEME)?bM(e.slice($0.URL_SCHEME.length)):null;Wt.registerSaveRouter(xM);function bM(e="model"){return new $0(e)}function vM(e){return new AM(e)}function e4(e,t,r,n){i(e),r=r==null?0:r,n=n==null?1:n,o(r,n);let a=0,s=l=>(l.then(u=>{let d=r+ ++a/e.length*(n-r);return t(d),u}),l);function i(l){_(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function o(l,u){_(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),_(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),_(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(s))}async function v6(e,t){t==null&&(t={});let r=t.fetchFunc==null?Z().platform.fetch:t.fetchFunc,n=e.map(u=>r(u,t.requestInit,{isBinary:!0})),a=0,s=.5,i=(t.onProgress==null?await Promise.all(n):await e4(n,t.onProgress,a,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await e4(i,t.onProgress,o,l)}async function wM(e,t="",r,n){return w6(a=>v6(a,{requestInit:n}))(e,t,r)}function w6(e){return async(t,r="",n)=>{let a=t.map(()=>!1),s={},i=n!=null?n.map(()=>!1):[],o=[];if(t.forEach((c,m)=>{let f=0;c.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=$g[y]*It(g.shape),x=()=>{a[m]=!0,s[m]==null&&(s[m]=[]),s[m].push({manifestEntry:g,groupOffset:f,sizeBytes:A})};n!=null?n.forEach((b,w)=>{b===g.name&&(x(),i[w]=!0)}):x(),o.push(g.name),f+=A})}),!i.every(c=>c)){let c=n.filter((m,f)=>!i[f]);throw new Error(`Could not find weights in manifest with names: ${c.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=a.reduce((c,m,f)=>(m&&c.push(f),c),[]),u=[];l.forEach(c=>{t[c].paths.forEach(m=>{let f=r+(r.endsWith("/")?"":"/")+m;u.push(f)})});let d=await e(u),h={},p=0;return l.forEach(c=>{let m=t[c].paths.length,f=0;for(let x=0;x{let b=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),w=p6(b,[x.manifestEntry]);for(let I in w)h[I]=w[I]}),p+=m}),h}}var kM="application/octet-stream",IM="application/json",zy=class{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(_(typeof t.fetchFunc=="function",()=>"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=Z().platform.fetch,_(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&_(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)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.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],n=h6(e,r);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:IM}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:kM}),"model.weights.bin");let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:kh(e),responses:[a]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.status}.`)}async load(){let 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(a){let s=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?s+=" 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.":s+=" Please make sure the server is serving valid JSON for this request.",new Error(s)}let r=t.modelTopology,n=t.weightsManifest;if(r==null&&n==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Oy(t,a=>this.loadWeights(a))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[r,n]=SM(t),a=this.weightPathPrefix||r,s=[];for(let u of e)s.push(...u.weights);let i=[],o=[];for(let u of e)for(let d of u.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(d)):i.push(a+d+n);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await v6(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Py(l)]}};zy.URL_SCHEME_REGEX=/^https?:\/\//;function SM(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?"),n=e.substring(0,t),a=r>t?e.substring(r):"";return[n+"/",a]}function Og(e){return e.match(zy.URL_SCHEME_REGEX)!=null}var k6=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let r=!0;if(Array.isArray(e)?r=e.every(n=>Og(n)):r=Og(e),r)return Dy(e,t)}return null};Wt.registerSaveRouter(k6);Wt.registerLoadRouter(k6);function Dy(e,t){return new zy(e,t)}function CM(e,t){return Dy(e,t)}var gg=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},I6=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},TM=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function NM(e,t,r,n){let a=arguments;return new TM(S6(...a))}function S6(e,t,r,n){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new gg(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 gg({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 gg({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n}))}function EM(e){return new I6(e)}function RM(e){return new I6(e)}var C6={};Be(C6,{confusionMatrix:()=>HM});function $M(e,t,r=!1,n=!1){let a=M(e,"a","matMul"),s=M(t,"b","matMul");[a,s]=Lt(a,s);let i={a,b:s},o={transposeA:r,transposeB:n};return B.runKernel(Js,i,o)}var Ye=W({matMul_:$M});function MM(e,t,r=1,n=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:M(e,"indices","oneHot","int32")},s={depth:t,onValue:r,offValue:n};return B.runKernel(pl,a,s)}var Kp=W({oneHot_:MM});function Ly(){Z().set("PROD",!0)}function FM(){Z().set("DEBUG",!0)}function _M(){Z().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function By(e){Z().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}S$(By);function PM(){B.disposeVariables()}function Xt(){return B}function M0(){return B.memory()}function OM(e){return B.profile(e)}function X(e,t){return B.tidy(e,t)}function te(e){My(e).forEach(t=>t.dispose())}function mr(e){return B.keep(e)}function zM(e){return B.time(e)}function Wy(e){return B.setBackend(e)}function Ad(){return B.ready()}function Hr(){return B.backendName}function DM(e){B.removeBackend(e)}function Vy(e){return B.findBackend(e)}function LM(e){return B.findBackendFactory(e)}function El(e,t,r=1){return B.registerBackend(e,t,r)}function Dn(){return B.backend}function BM(e,t){Z().setPlatform(e,t)}function WM(e){let t={input:M(e,"input","imag")};return B.runKernel(uh,t)}var Ih=W({imag_:WM});function VM(e){let t={x:M(e,"x","neg")};return B.runKernel(il,t)}var Mt=W({neg_:VM});function UM(e){let t={input:M(e,"input","real")};return B.runKernel(hh,t)}var Eu=W({real_:UM});function GM(e,t,r){let n=M(e,"x","transpose");if(t==null&&(t=n.shape.map((i,o)=>o).reverse()),_(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(i=>{_(i>=0&&i`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let a={x:n},s={perm:t};return n.dtype==="complex64"?X(()=>{let i=Eu(n),o=Ih(n);return i=B.runKernel($a,{x:i},s),o=B.runKernel($a,{x:o},s),r&&(o=Mt(o)),Za(i,o)}):B.runKernel($a,a,s)}var tt=W({transpose_:GM});function jM(e,t,r){let n=M(e,"labels","confusionMatrix"),a=M(t,"predictions","confusionMatrix");_(r==null||r>0&&Number.isInteger(r),()=>`If provided, numClasses must be a positive integer, but got ${r}`),_(n.rank===1,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),_(a.rank===1,()=>`Expected the rank of predictions to be 1, but got ${a.rank}`),_(n.shape[0]===a.shape[0],()=>`Mismatch in the number of examples: ${n.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`),_(r>0&&Number.isInteger(r),()=>`numClasses is required to be a positive integer, but got ${r}`);let s=Kp(me(n,"int32"),r),i=Kp(me(a,"int32"),r),o=tt(s),l=Ye(o,i);return me(l,"int32")}var HM=W({confusionMatrix_:jM}),Rl={};Be(Rl,{assertAndGetBroadcastShape:()=>At,getBroadcastDims:()=>T6,getReductionAxes:()=>Jt});function T6(e,t){let r=e.length,n=[];for(let a=0;a1&&i===1&&n.unshift(s)}return n}function Jt(e,t){let r=[];for(let n=0;n1)&&r.unshift(s)}return r}function At(e,t){let r=[],n=Math.max(e.length,t.length);for(let a=0;aQM,fromPixelsAsync:()=>YM,toPixels:()=>JM});function N6(e,t,r){if(Vo(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=_a(e,r);if(n.length!==3&&n.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(n.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Vi(e,t,n,r)}var fo;function E6(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(e==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let r=!1,n=!1,a=!1,s=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)r=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)n=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)a=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)s=!0;else if(e.getContext!=null)i=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)o=!0;else 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}`);if(a&&a&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the