/* Face-API homepage: author: ' */ var S$=Object.defineProperty;var N$=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var My=(e,t)=>{for(var n in t)S$(e,n,{get:t[n],enumerable:!0})};var Le={};My(Le,{Abs:()=>fl,Acos:()=>gl,Acosh:()=>yl,AdadeltaOptimizer:()=>nf,AdagradOptimizer:()=>af,AdamOptimizer:()=>rf,AdamaxOptimizer:()=>sf,Add:()=>us,AddN:()=>ci,All:()=>bl,Any:()=>xl,ArgMax:()=>di,ArgMin:()=>Xp,Asin:()=>vl,Asinh:()=>wl,Atan:()=>kl,Atan2:()=>Sl,Atanh:()=>Il,AvgPool:()=>hi,AvgPool3D:()=>Yp,AvgPool3DGrad:()=>Kh,AvgPoolGrad:()=>qh,BackendWasm:()=>DE,BatchMatMul:()=>mi,BatchToSpaceND:()=>Nl,Bincount:()=>Xh,BroadcastArgs:()=>Yh,BroadcastTo:()=>lI,Callback:()=>pN,CallbackList:()=>m2,Cast:()=>fi,Ceil:()=>gi,ClipByValue:()=>ps,Complex:()=>Jh,ComplexAbs:()=>Jp,Concat:()=>Tl,Conv2D:()=>yi,Conv2DBackpropFilter:()=>Qh,Conv2DBackpropInput:()=>bi,Conv3D:()=>Qp,Conv3DBackpropFilterV2:()=>Zh,Conv3DBackpropInputV2:()=>em,Cos:()=>xi,Cosh:()=>vi,CropAndResize:()=>_l,Cumprod:()=>Cl,Cumsum:()=>wi,CustomCallback:()=>g2,DataStorage:()=>Gh,DenseBincount:()=>tm,DepthToSpace:()=>El,DepthwiseConv2dNative:()=>ki,DepthwiseConv2dNativeBackpropFilter:()=>nm,DepthwiseConv2dNativeBackpropInput:()=>am,Diag:()=>rm,Dilation2D:()=>Zp,Dilation2DBackpropFilter:()=>xh,Dilation2DBackpropInput:()=>bh,ENV:()=>tx,EarlyStopping:()=>cN,Einsum:()=>sm,Elu:()=>Si,EluGrad:()=>im,Environment:()=>iI,Equal:()=>$l,Erf:()=>Al,Exp:()=>Ni,ExpandDims:()=>Fl,Expm1:()=>Dl,FFT:()=>om,Fill:()=>ec,FlipLeftRight:()=>Rl,Floor:()=>Ti,FloorDiv:()=>Ci,FromPixels:()=>vh,FusedBatchNorm:()=>_i,FusedConv2D:()=>Ks,FusedDepthwiseConv2D:()=>Xs,GPGPUContext:()=>hh,GatherNd:()=>Pl,GatherV2:()=>Ml,GraphModel:()=>MN,Greater:()=>Ol,GreaterEqual:()=>Ei,History:()=>f2,IFFT:()=>lm,Identity:()=>Ai,Imag:()=>um,InputSpec:()=>Wt,IsFinite:()=>Ll,IsInf:()=>zl,IsNan:()=>Wl,KernelBackend:()=>Kp,LRN:()=>ac,LRNGrad:()=>cm,LayerVariable:()=>p2,LayersModel:()=>Nr,LeakyRelu:()=>$i,Less:()=>Bl,LessEqual:()=>Vl,LinSpace:()=>pm,Log:()=>Fi,Log1p:()=>Ul,LogSoftmax:()=>uI,LogicalAnd:()=>Gl,LogicalNot:()=>tc,LogicalOr:()=>nc,MathBackendWebGL:()=>$f,Max:()=>Di,MaxPool:()=>Mi,MaxPool3D:()=>rc,MaxPool3DGrad:()=>hm,MaxPoolGrad:()=>dm,MaxPoolWithArgmax:()=>mm,Maximum:()=>Ri,Mean:()=>Pi,Min:()=>Oi,Minimum:()=>Li,MirrorPad:()=>zi,Mod:()=>Hl,MomentumOptimizer:()=>of,Multinomial:()=>fm,Multiply:()=>Wi,Neg:()=>jl,NonMaxSuppressionV3:()=>Kl,NonMaxSuppressionV4:()=>Xl,NonMaxSuppressionV5:()=>Yl,NotEqual:()=>ql,OP_SCOPE_SUFFIX:()=>xI,OneHot:()=>Bi,OnesLike:()=>Jl,Optimizer:()=>Er,OptimizerConstructors:()=>Vr,Pack:()=>Ql,PadV2:()=>Vi,Pool:()=>vF,Pow:()=>Ui,Prelu:()=>Gi,Prod:()=>Zl,RMSPropOptimizer:()=>lf,RNN:()=>fr,Range:()=>sc,Rank:()=>eb,Real:()=>gm,RealDiv:()=>Ii,Reciprocal:()=>eu,Reduction:()=>kn,Relu:()=>Hi,Relu6:()=>qi,Reshape:()=>tu,ResizeBilinear:()=>ji,ResizeBilinearGrad:()=>bm,ResizeNearestNeighbor:()=>ic,ResizeNearestNeighborGrad:()=>ym,Reverse:()=>Ki,RotateWithOffset:()=>yu,Round:()=>Xi,Rsqrt:()=>Yi,SGDOptimizer:()=>Cc,ScatterNd:()=>nu,Select:()=>au,Selu:()=>ru,Sequential:()=>ul,Sigmoid:()=>Qi,Sign:()=>ou,Sin:()=>Ji,Sinh:()=>iu,Slice:()=>su,Softmax:()=>to,Softplus:()=>lu,SpaceToBatchND:()=>uu,SparseFillEmptyRows:()=>oc,SparseReshape:()=>cu,SparseSegmentMean:()=>lc,SparseSegmentSum:()=>uc,SparseToDense:()=>xm,SplitV:()=>pu,Sqrt:()=>Zi,Square:()=>pc,SquaredDifference:()=>no,Step:()=>ds,StridedSlice:()=>du,StringNGrams:()=>vm,StringSplit:()=>wm,StringToHashBucketFast:()=>km,Sub:()=>ao,Sum:()=>eo,SymbolicTensor:()=>Ba,Tan:()=>ro,Tanh:()=>so,Tensor:()=>Ae,TensorBuffer:()=>jt,Tile:()=>cs,TopK:()=>hu,Transform:()=>mu,Transpose:()=>io,Unique:()=>Im,Unpack:()=>fu,UnsortedSegmentSum:()=>cc,Variable:()=>Qr,ZerosLike:()=>gu,_FusedMatMul:()=>qs,abs:()=>zt,acos:()=>yx,acosh:()=>bx,add:()=>J,addN:()=>QI,all:()=>Em,any:()=>Op,argMax:()=>Qs,argMin:()=>xx,asin:()=>vx,asinh:()=>wx,atan:()=>kx,atan2:()=>Ix,atanh:()=>Sx,avgPool:()=>fa,avgPool3d:()=>Tx,backend:()=>JI,backend_util:()=>_,basicLSTMCell:()=>dM,batchNorm:()=>Tr,batchNorm2d:()=>nS,batchNorm3d:()=>aS,batchNorm4d:()=>rS,batchToSpaceND:()=>bc,bincount:()=>Cx,booleanMaskAsync:()=>b3,broadcastArgs:()=>sS,broadcastTo:()=>Zo,broadcast_util:()=>bu,browser:()=>oo,buffer:()=>He,callbacks:()=>GG,cast:()=>oe,ceil:()=>_x,clipByValue:()=>nn,clone:()=>Sr,complex:()=>Zr,concat:()=>Ze,concat1d:()=>iS,concat2d:()=>oS,concat3d:()=>lS,concat4d:()=>uS,constraints:()=>JS,conv1d:()=>Am,conv2d:()=>Rt,conv2dTranspose:()=>$m,conv3d:()=>Ax,conv3dTranspose:()=>cS,copyRegisteredKernels:()=>SF,cos:()=>xc,cosh:()=>Fm,cosineWindow:()=>av,cumprod:()=>$x,cumsum:()=>Dm,customGrad:()=>ur,data:()=>PN,denseBincount:()=>dS,deprecationWarn:()=>gx,depthToSpace:()=>Fx,depthwiseConv2d:()=>fs,deregisterOp:()=>qG,device_util:()=>fc,diag:()=>UM,dilation2d:()=>Dx,disableDeprecationWarnings:()=>SR,dispose:()=>De,disposeVariables:()=>NR,div:()=>fe,divNoNan:()=>Rx,dot:()=>hS,dropout:()=>RS,einsum:()=>mS,elu:()=>xu,enableDebugMode:()=>IR,enableProdMode:()=>kR,enclosingPowerOfTwo:()=>MS,engine:()=>ar,env:()=>X,equal:()=>Zn,erf:()=>Mx,exp:()=>fn,expandDims:()=>hn,expm1:()=>Px,eye:()=>Ox,fft:()=>Nc,fill:()=>Cn,findBackend:()=>FR,findBackendFactory:()=>DR,floor:()=>vu,floorDiv:()=>_m,forceHalfFloat:()=>t_,fused:()=>ts,gather:()=>ei,gatherND:()=>DS,gather_util:()=>px,getBackend:()=>AR,getGradient:()=>Qy,getKernel:()=>wh,getKernelsForBackend:()=>kh,getThreadsCount:()=>Xle,gpgpu_util:()=>DC,grad:()=>bP,grads:()=>xP,greater:()=>Un,greaterEqual:()=>gs,ifft:()=>il,imag:()=>Rm,image:()=>On,inTopKAsync:()=>E3,initializers:()=>t2,input:()=>A2,io:()=>Zt,irfft:()=>Km,isFinite:()=>fS,isInf:()=>gS,isNaN:()=>Lx,keep:()=>en,kernel_impls:()=>mr,layers:()=>l2,leakyRelu:()=>vc,less:()=>Mm,lessEqual:()=>ys,linalg:()=>HS,linspace:()=>yS,loadGraphModel:()=>Y6,loadLayersModel:()=>eU,localResponseNormalization:()=>zx,log:()=>ea,log1p:()=>wc,logSigmoid:()=>xS,logSoftmax:()=>Om,logSumExp:()=>Vx,logicalAnd:()=>Na,logicalNot:()=>kc,logicalOr:()=>Lm,logicalXor:()=>IS,losses:()=>cz,matMul:()=>Fe,math:()=>DI,max:()=>Ia,maxPool:()=>Pt,maxPool3d:()=>Ux,maxPoolWithArgmax:()=>SS,maximum:()=>hr,mean:()=>Et,memory:()=>Nh,meshgrid:()=>BP,metrics:()=>oN,min:()=>Lp,minimum:()=>wu,mirrorPad:()=>Gx,mod:()=>Hx,model:()=>QV,models:()=>lN,moments:()=>zm,movingAverage:()=>w3,mul:()=>W,multiRNNCell:()=>XP,multinomial:()=>NS,neg:()=>It,nextFrame:()=>iv,norm:()=>Jm,notEqual:()=>ni,oneHot:()=>rl,ones:()=>Jn,onesLike:()=>ta,op:()=>z,outerProduct:()=>eO,pad:()=>ga,pad1d:()=>aO,pad2d:()=>sO,pad3d:()=>oO,pad4d:()=>uO,pool:()=>TS,pow:()=>Cr,prelu:()=>Sc,print:()=>EI,prod:()=>Wm,profile:()=>TR,rand:()=>bO,randomGamma:()=>kO,randomNormal:()=>CS,randomUniform:()=>ku,range:()=>sl,ready:()=>ER,real:()=>zp,reciprocal:()=>Kx,registerBackend:()=>Cm,registerCallbackConstructor:()=>tU,registerGradient:()=>pI,registerKernel:()=>dc,registerOp:()=>jG,regularizers:()=>uN,relu:()=>Xe,relu6:()=>Bm,removeBackend:()=>$R,reshape:()=>B,reverse:()=>na,reverse1d:()=>$O,reverse2d:()=>DO,reverse3d:()=>MO,reverse4d:()=>OO,rfft:()=>Tc,round:()=>Vm,rsqrt:()=>Um,scalar:()=>ke,scatterND:()=>FS,scatter_util:()=>cx,selu:()=>Gm,separableConv2d:()=>uo,sequential:()=>ZV,serialization:()=>se,setBackend:()=>_R,setPlatform:()=>RR,setThreadsCount:()=>Kle,setWasmPath:()=>jle,setWasmPaths:()=>qle,setWebGLContext:()=>aC,setdiff1dAsync:()=>_S,sigmoid:()=>ha,sign:()=>Xx,signal:()=>pz,sin:()=>Hm,sinh:()=>jm,slice:()=>Ge,slice1d:()=>qm,slice2d:()=>Yx,slice3d:()=>Iu,slice4d:()=>Wp,slice_util:()=>qt,softmax:()=>Xa,softplus:()=>lo,spaceToBatchND:()=>Ic,sparse:()=>vp,sparseToDense:()=>nv,spectral:()=>uz,split:()=>Ln,sqrt:()=>ln,square:()=>lt,squaredDifference:()=>Xm,squeeze:()=>pr,stack:()=>Mt,step:()=>Su,stridedSlice:()=>Jx,string:()=>ih,sub:()=>ce,sum:()=>be,sumOutType:()=>Nm,tan:()=>Qx,tanh:()=>Zs,tensor:()=>Qn,tensor1d:()=>qe,tensor2d:()=>Ua,tensor3d:()=>Tm,tensor4d:()=>Ya,tensor5d:()=>u3,tensor6d:()=>p3,tensor_util:()=>Va,test_util:()=>KI,tidy:()=>O,tile:()=>Pn,time:()=>CR,topk:()=>Zx,train:()=>Ms,transpose:()=>Me,truncatedNormal:()=>Ym,unique:()=>Ch,unregisterGradient:()=>IF,unregisterKernel:()=>kF,unsortedSegmentSum:()=>ev,unstack:()=>ht,upcastType:()=>ma,util:()=>k,valueAndGrad:()=>vP,valueAndGrads:()=>wP,variable:()=>ES,variableGrads:()=>bS,version:()=>iue,version_converter:()=>J6,version_core:()=>wR,version_layers:()=>_v,version_wasm:()=>Yle,version_webgl:()=>i9,webgl:()=>o9,webgl_util:()=>nC,where:()=>mn,whereAsync:()=>tv,zeros:()=>wt,zerosLike:()=>Ke});var T$=Object.create,Yb=Object.defineProperty,C$=Object.getOwnPropertyDescriptor,_$=Object.getOwnPropertyNames,E$=Object.getPrototypeOf,A$=Object.prototype.hasOwnProperty,mt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Re=(e,t)=>{for(var n in t)Yb(e,n,{get:t[n],enumerable:!0})},$$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of _$(t))!A$.call(e,r)&&r!==n&&Yb(e,r,{get:()=>t[r],enumerable:!(a=C$(t,r))||a.enumerable});return e},ui=(e,t,n)=>(n=e!=null?T$(E$(e)):{},$$(t||!e||!e.__esModule?Yb(n,"default",{value:e,enumerable:!0}):n,e)),F$=mt((e,t)=>{t.exports=a;var n=null;try{n=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 a(S,M,U){this.low=S|0,this.high=M|0,this.unsigned=!!U}a.prototype.__isLong__,Object.defineProperty(a.prototype,"__isLong__",{value:!0});function r(S){return(S&&S.__isLong__)===!0}a.isLong=r;var s={},i={};function o(S,M){var U,j,q;return M?(S>>>=0,(q=0<=S&&S<256)&&(j=i[S],j)?j:(U=u(S,(S|0)<0?-1:0,!0),q&&(i[S]=U),U)):(S|=0,(q=-128<=S&&S<128)&&(j=s[S],j)?j:(U=u(S,S<0?-1:0,!1),q&&(s[S]=U),U))}a.fromInt=o;function l(S,M){if(isNaN(S))return M?v:x;if(M){if(S<0)return v;if(S>=g)return $}else{if(S<=-y)return P;if(S+1>=y)return E}return S<0?l(-S,M).neg():u(S%f|0,S/f|0,M)}a.fromNumber=l;function u(S,M,U){return new a(S,M,U)}a.fromBits=u;var p=Math.pow;function d(S,M,U){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof M=="number"?(U=M,M=!1):M=!!M,U=U||10,U<2||360)throw Error("interior hyphen");if(j===0)return d(S.substring(1),M,U).neg();for(var q=l(p(U,8)),K=x,Z=0;Z>>0:this.low},F.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},F.toString=function(S){if(S=S||10,S<2||36>>0,Q=re.toString(S);if(K=ee,K.isZero())return Q+Z;for(;Q.length<6;)Q="0"+Q;Z=""+Q+Z}},F.getHighBits=function(){return this.high},F.getHighBitsUnsigned=function(){return this.high>>>0},F.getLowBits=function(){return this.low},F.getLowBitsUnsigned=function(){return this.low>>>0},F.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,M=31;M>0&&(S&1<=0},F.isOdd=function(){return(this.low&1)===1},F.isEven=function(){return(this.low&1)===0},F.equals=function(S){return r(S)||(S=c(S)),this.unsigned!==S.unsigned&&this.high>>>31===1&&S.high>>>31===1?!1:this.high===S.high&&this.low===S.low},F.eq=F.equals,F.notEquals=function(S){return!this.eq(S)},F.neq=F.notEquals,F.ne=F.notEquals,F.lessThan=function(S){return this.comp(S)<0},F.lt=F.lessThan,F.lessThanOrEqual=function(S){return this.comp(S)<=0},F.lte=F.lessThanOrEqual,F.le=F.lessThanOrEqual,F.greaterThan=function(S){return this.comp(S)>0},F.gt=F.greaterThan,F.greaterThanOrEqual=function(S){return this.comp(S)>=0},F.gte=F.greaterThanOrEqual,F.ge=F.greaterThanOrEqual,F.compare=function(S){if(r(S)||(S=c(S)),this.eq(S))return 0;var M=this.isNegative(),U=S.isNegative();return M&&!U?-1:!M&&U?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},F.comp=F.compare,F.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(w)},F.neg=F.negate,F.add=function(S){r(S)||(S=c(S));var M=this.high>>>16,U=this.high&65535,j=this.low>>>16,q=this.low&65535,K=S.high>>>16,Z=S.high&65535,ee=S.low>>>16,re=S.low&65535,Q=0,ie=0,ae=0,le=0;return le+=q+re,ae+=le>>>16,le&=65535,ae+=j+ee,ie+=ae>>>16,ae&=65535,ie+=U+Z,Q+=ie>>>16,ie&=65535,Q+=M+K,Q&=65535,u(ae<<16|le,Q<<16|ie,this.unsigned)},F.subtract=function(S){return r(S)||(S=c(S)),this.add(S.neg())},F.sub=F.subtract,F.multiply=function(S){if(this.isZero())return x;if(r(S)||(S=c(S)),n){var M=n.mul(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(P))return S.isOdd()?P:x;if(S.eq(P))return this.isOdd()?P: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(b)&&S.lt(b))return l(this.toNumber()*S.toNumber(),this.unsigned);var U=this.high>>>16,j=this.high&65535,q=this.low>>>16,K=this.low&65535,Z=S.high>>>16,ee=S.high&65535,re=S.low>>>16,Q=S.low&65535,ie=0,ae=0,le=0,ue=0;return ue+=K*Q,le+=ue>>>16,ue&=65535,le+=q*Q,ae+=le>>>16,le&=65535,le+=K*re,ae+=le>>>16,le&=65535,ae+=j*Q,ie+=ae>>>16,ae&=65535,ae+=q*re,ie+=ae>>>16,ae&=65535,ae+=K*ee,ie+=ae>>>16,ae&=65535,ie+=U*Q+j*re+q*ee+K*Z,ie&=65535,u(le<<16|ue,ie<<16|ae,this.unsigned)},F.mul=F.multiply,F.divide=function(S){if(r(S)||(S=c(S)),S.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var M=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?v:x;var U,j,q;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return v;if(S.gt(this.shru(1)))return T;q=v}else{if(this.eq(P)){if(S.eq(w)||S.eq(C))return P;if(S.eq(P))return w;var K=this.shr(1);return U=K.div(S).shl(1),U.eq(x)?S.isNegative()?w:C:(j=this.sub(S.mul(U)),q=U.add(j.div(S)),q)}else if(S.eq(P))return this.unsigned?v: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();q=x}for(j=this;j.gte(S);){U=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Z=Math.ceil(Math.log(U)/Math.LN2),ee=Z<=48?1:p(2,Z-48),re=l(U),Q=re.mul(S);Q.isNegative()||Q.gt(j);)U-=ee,re=l(U,this.unsigned),Q=re.mul(S);re.isZero()&&(re=w),q=q.add(re),j=j.sub(Q)}return q},F.div=F.divide,F.modulo=function(S){if(r(S)||(S=c(S)),n){var M=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},F.mod=F.modulo,F.rem=F.modulo,F.not=function(){return u(~this.low,~this.high,this.unsigned)},F.and=function(S){return r(S)||(S=c(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},F.or=function(S){return r(S)||(S=c(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},F.xor=function(S){return r(S)||(S=c(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},F.shiftLeft=function(S){return r(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)},F.shr=F.shiftRight,F.shiftRightUnsigned=function(S){if(r(S)&&(S=S.toInt()),S&=63,S===0)return this;var M=this.high;if(S<32){var U=this.low;return u(U>>>S|M<<32-S,M>>>S,this.unsigned)}else return S===32?u(M,0,this.unsigned):u(M>>>S-32,0,this.unsigned)},F.shru=F.shiftRightUnsigned,F.shr_u=F.shiftRightUnsigned,F.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},F.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},F.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},F.toBytesLE=function(){var S=this.high,M=this.low;return[M&255,M>>>8&255,M>>>16&255,M>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},F.toBytesBE=function(){var S=this.high,M=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,M>>>24,M>>>16&255,M>>>8&255,M&255]},a.fromBytes=function(S,M,U){return U?a.fromBytesLE(S,M):a.fromBytesBE(S,M)},a.fromBytesLE=function(S,M){return new a(S[0]|S[1]<<8|S[2]<<16|S[3]<<24,S[4]|S[5]<<8|S[6]<<16|S[7]<<24,M)},a.fromBytesBE=function(S,M){return new a(S[4]<<24|S[5]<<16|S[6]<<8|S[7],S[0]<<24|S[1]<<16|S[2]<<8|S[3],M)}}),D$=mt(()=>{}),R$=mt(()=>{}),M$=mt((e,t)=>{(function(n,a,r){function s(u){var p=this,d=l();p.next=function(){var c=2091639*p.s0+p.c*23283064365386963e-26;return p.s0=p.s1,p.s1=p.s2,p.s2=c-(p.c=c|0)},p.c=1,p.s0=d(" "),p.s1=d(" "),p.s2=d(" "),p.s0-=d(u),p.s0<0&&(p.s0+=1),p.s1-=d(u),p.s1<0&&(p.s1+=1),p.s2-=d(u),p.s2<0&&(p.s2+=1),d=null}function i(u,p){return p.c=u.c,p.s0=u.s0,p.s1=u.s1,p.s2=u.s2,p}function o(u,p){var d=new s(u),c=p&&p.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&i(c,d),h.state=function(){return i(d,{})}),h}function l(){var u=4022871197,p=function(d){d=d.toString();for(var c=0;c>>0,h-=u,h*=u,u=h>>>0,h-=u,u+=h*4294967296}return(u>>>0)*23283064365386963e-26};return p}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),P$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var c=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^c^c>>>8},l===(l|0)?u.x=l:p+=l;for(var d=0;d>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),O$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.next=function(){var c=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^(c^c<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:p+=l;for(var d=0;d>>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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),L$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this;u.next=function(){var d=u.x,c=u.i,h,m,f;return h=d[c],h^=h>>>7,m=h^h<<24,h=d[c+1&7],m^=h^h>>>10,h=d[c+3&7],m^=h^h>>>3,h=d[c+4&7],m^=h^h<<7,h=d[c+7&7],h=h^h<<13,m^=h^h<<9,d[c]=m,u.i=c+1&7,m};function p(d,c){var h,m,f=[];if(c===(c|0))m=f[0]=c;else for(c=""+c,h=0;h0;--h)d.next()}p(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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(d.x&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),z$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this;u.next=function(){var d=u.w,c=u.X,h=u.i,m,f;return u.w=d=d+1640531527|0,f=c[h+34&127],m=c[h=h+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=c[h]=f^m,u.i=h,f+(d^d>>>16)|0};function p(d,c){var h,m,f,g,y,b=[],x=128;for(c===(c|0)?(m=c,c=null):(c=c+"\0",m=0,x=Math.max(x,c.length)),f=0,g=-32;g>>15,m^=m<<4,m^=m>>>13,g>=0&&(y=y+1640531527|0,h=b[g&127]^=m+y,f=h==0?f+1:0);for(f>=128&&(b[(c&&c.length||0)&127]=-1),f=127,g=4*128;g>0;--g)m=b[f+34&127],h=b[f=f+1&127],m^=m<<13,h^=h<<17,m^=m>>>15,h^=h>>>12,b[f]=m^h;d.w=y,d.X=b,d.i=f}p(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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(d.X&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),W$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.next=function(){var c=u.b,h=u.c,m=u.d,f=u.a;return c=c<<25^c>>>7^h,h=h-m|0,m=m<<24^m>>>8^f,f=f-c|0,u.b=c=c<<20^c>>>12^h,u.c=h=h-m|0,u.d=m<<16^h>>>16^f,u.a=f-c|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):p+=l;for(var d=0;d>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),jk=mt(()=>{}),B$=mt((e,t)=>{(function(n,a){var r=this,s=256,i=6,o=52,l="random",u=a.pow(s,i),p=a.pow(2,o),d=p*2,c=s-1,h;function m(w,T,C){var E=[];T=T==!0?{entropy:!0}:T||{};var $=b(y(T.entropy?[w,v(n)]:w==null?x():w,3),E),P=new f(E),F=function(){for(var S=P.g(i),M=u,U=0;S=d;)S/=2,M/=2,U>>>=1;return(S+U)/M};return F.int32=function(){return P.g(4)|0},F.quick=function(){return P.g(4)/4294967296},F.double=F,b(v(P.S),n),(T.pass||C||function(S,M,U,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),U?(a[l]=S,M):S})(F,$,"global"in T?T.global:this==a,T.state)}a["seed"+l]=m;function f(w){var T,C=w.length,E=this,$=0,P=E.i=E.j=0,F=E.S=[];for(C||(w=[C++]);${var n=M$(),a=P$(),r=O$(),s=L$(),i=z$(),o=W$(),l=B$();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),V$=mt((e,t)=>{(function(n,a,r){function s(u){var p=this,d=l();p.next=function(){var c=2091639*p.s0+p.c*23283064365386963e-26;return p.s0=p.s1,p.s1=p.s2,p.s2=c-(p.c=c|0)},p.c=1,p.s0=d(" "),p.s1=d(" "),p.s2=d(" "),p.s0-=d(u),p.s0<0&&(p.s0+=1),p.s1-=d(u),p.s1<0&&(p.s1+=1),p.s2-=d(u),p.s2<0&&(p.s2+=1),d=null}function i(u,p){return p.c=u.c,p.s0=u.s0,p.s1=u.s1,p.s2=u.s2,p}function o(u,p){var d=new s(u),c=p&&p.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&i(c,d),h.state=function(){return i(d,{})}),h}function l(){var u=4022871197,p=function(d){d=String(d);for(var c=0;c>>0,h-=u,h*=u,u=h>>>0,h-=u,u+=h*4294967296}return(u>>>0)*23283064365386963e-26};return p}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),U$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var c=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^c^c>>>8},l===(l|0)?u.x=l:p+=l;for(var d=0;d>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),G$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.next=function(){var c=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^(c^c<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:p+=l;for(var d=0;d>>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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),H$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this;u.next=function(){var d=u.x,c=u.i,h,m,f;return h=d[c],h^=h>>>7,m=h^h<<24,h=d[c+1&7],m^=h^h>>>10,h=d[c+3&7],m^=h^h>>>3,h=d[c+4&7],m^=h^h<<7,h=d[c+7&7],h=h^h<<13,m^=h^h<<9,d[c]=m,u.i=c+1&7,m};function p(d,c){var h,m,f=[];if(c===(c|0))m=f[0]=c;else for(c=""+c,h=0;h0;--h)d.next()}p(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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(d.x&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),j$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this;u.next=function(){var d=u.w,c=u.X,h=u.i,m,f;return u.w=d=d+1640531527|0,f=c[h+34&127],m=c[h=h+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=c[h]=f^m,u.i=h,f+(d^d>>>16)|0};function p(d,c){var h,m,f,g,y,b=[],x=128;for(c===(c|0)?(m=c,c=null):(c=c+"\0",m=0,x=Math.max(x,c.length)),f=0,g=-32;g>>15,m^=m<<4,m^=m>>>13,g>=0&&(y=y+1640531527|0,h=b[g&127]^=m+y,f=h==0?f+1:0);for(f>=128&&(b[(c&&c.length||0)&127]=-1),f=127,g=4*128;g>0;--g)m=b[f+34&127],h=b[f=f+1&127],m^=m<<13,h^=h<<17,m^=m>>>15,h^=h>>>12,b[f]=m^h;d.w=y,d.X=b,d.i=f}p(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 p=new s(l),d=u&&u.state,c=function(){return(p.next()>>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(d.X&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),q$=mt((e,t)=>{(function(n,a,r){function s(l){var u=this,p="";u.next=function(){var c=u.b,h=u.c,m=u.d,f=u.a;return c=c<<25^c>>>7^h,h=h-m|0,m=m<<24^m>>>8^f,f=f-c|0,u.b=c=c<<20^c>>>12^h,u.c=h=h-m|0,u.d=m<<16^h>>>16^f,u.a=f-c|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):p+=l;for(var d=0;d>>0)/4294967296};return c.double=function(){do var h=p.next()>>>11,m=(p.next()>>>0)/4294967296,f=(h+m)/(1<<21);while(f===0);return f},c.int32=p.next,c.quick=c,d&&(typeof d=="object"&&i(d,p),c.state=function(){return i(p,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),K$=mt((e,t)=>{(function(n,a,r){var s=256,i=6,o=52,l="random",u=r.pow(s,i),p=r.pow(2,o),d=p*2,c=s-1,h;function m(w,T,C){var E=[];T=T==!0?{entropy:!0}:T||{};var $=b(y(T.entropy?[w,v(a)]:w==null?x():w,3),E),P=new f(E),F=function(){for(var S=P.g(i),M=u,U=0;S=d;)S/=2,M/=2,U>>>=1;return(S+U)/M};return F.int32=function(){return P.g(4)|0},F.quick=function(){return P.g(4)/4294967296},F.double=F,b(v(P.S),a),(T.pass||C||function(S,M,U,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),U?(r[l]=S,M):S})(F,$,"global"in T?T.global:this==r,T.state)}function f(w){var T,C=w.length,E=this,$=0,P=E.i=E.j=0,F=E.S=[];for(C||(w=[C++]);${var n=V$(),a=U$(),r=G$(),s=H$(),i=j$(),o=q$(),l=K$();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),Xk=mt(()=>{}),Jb=mt(()=>{}),fh=mt(()=>{}),X$=mt(()=>{}),Y$=mt(()=>{}),J$=mt(()=>{}),Q$=mt((e,t)=>{var n=(()=>{var a=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(a=a||__filename),function(r){r=r||{};function s(){return Te.buffer!=bn&&Fa(Te.buffer),hd}function i(){return Te.buffer!=bn&&Fa(Te.buffer),md}function o(){return Te.buffer!=bn&&Fa(Te.buffer),np}function l(){return Te.buffer!=bn&&Fa(Te.buffer),fd}function u(){return Te.buffer!=bn&&Fa(Te.buffer),gd}function p(){return Te.buffer!=bn&&Fa(Te.buffer),yd}function d(){return Te.buffer!=bn&&Fa(Te.buffer),bd}var c=typeof r!="undefined"?r:{},h,m;c.ready=new Promise(function(N,D){h=N,m=D});var f;typeof process!="undefined"&&process.listeners&&(f={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},c),y=[],b="./this.program",x=(N,D)=>{throw D},v=typeof window=="object",w=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",C=c.ENVIRONMENT_IS_PTHREAD||!1,E="";function $(N){return c.locateFile?c.locateFile(N,E):E+N}var P,F,S,M;function U(N){N instanceof dp||Q("exiting due to exception: "+N)}var j,q,K;if(T){w?E=fh().dirname(E)+"/":E=__dirname+"/",K=()=>{q||(j=Jb(),q=fh())},P=function(D,V){return K(),D=q.normalize(D),j.readFileSync(D,V?void 0:"utf8")},S=D=>{var V=P(D,!0);return V.buffer||(V=new Uint8Array(V)),V},F=(D,V,Y)=>{K(),D=q.normalize(D),j.readFile(D,function(pe,he){pe?Y(pe):V(he.buffer)})},process.argv.length>1&&(b=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(D){if(!(D instanceof dp))throw D}),process.on("unhandledRejection",function(D){throw D}),x=(D,V)=>{if(Cs())throw process.exitCode=D,V;U(V),process.exit(D)},c.inspect=function(){return"[Emscripten Module object]"};let N;try{N=X$()}catch(D){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),D}global.Worker=N.Worker}else(v||w)&&(w?E=self.location.href:typeof document!="undefined"&&document.currentScript&&(E=document.currentScript.src),typeof a!="undefined"&&a&&(E=a),E.indexOf("blob:")!==0?E=E.substr(0,E.replace(/[?#].*/,"").lastIndexOf("/")+1):E="",T||(P=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.send(null),D.responseText},w&&(S=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),F=(N,D,V)=>{var Y=new XMLHttpRequest;Y.open("GET",N,!0),Y.responseType="arraybuffer",Y.onload=()=>{if(Y.status==200||Y.status==0&&Y.response){D(Y.response);return}V()},Y.onerror=V,Y.send(null)}),M=N=>document.title=N);T&&typeof performance=="undefined"&&(global.performance=Y$().performance);var Z=console.log.bind(console),ee=console.warn.bind(console);T&&(K(),Z=N=>j.writeSync(1,N+` `),ee=N=>j.writeSync(2,N+` `));var re=c.print||Z,Q=c.printErr||ee;Object.assign(c,g),g=null,c.arguments&&(y=c.arguments),c.thisProgram&&(b=c.thisProgram),c.quit&&(x=c.quit);var ie=4;function ae(N){ae.shown||(ae.shown={}),ae.shown[N]||(ae.shown[N]=1,Q(N))}function le(N,D){if(typeof WebAssembly.Function=="function"){for(var V={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:D[0]=="v"?[]:[V[D[0]]]},pe=1;pe{Ee=N},We=Atomics.load,je=Atomics.store,st=Atomics.compareExchange,et;c.wasmBinary&&(et=c.wasmBinary);var tt=c.noExitRuntime||!0;typeof WebAssembly!="object"&&Do("no native wasm support detected");var Te,gt,pt=!1,yn;function Yt(N,D){N||Do(D)}function Fn(N){var D=c["_"+N];return D}function Ut(N,D,V,Y,pe){var he={string:function(la){var Uo=0;if(la!=null&&la!==0){var g1=(la.length<<2)+1;Uo=Vo(g1),Ns(la,Uo,g1)}return Uo},array:function(la){var Uo=Vo(la.length);return br(la,Uo),Uo}};function ve(la){return D==="string"?ia(la):D==="boolean"?Boolean(la):la}var Ce=Fn(N),_t=[],Pa=0;if(Y)for(var Oa=0;Oa(V.buffer instanceof SharedArrayBuffer&&(V=new Uint8Array(V)),D.decode.call(D,V))}var Gt=typeof TextDecoder!="undefined"?new Dn("utf8"):void 0;function sa(N,D,V){for(var Y=D+V,pe=D;N[pe]&&!(pe>=Y);)++pe;if(pe-D>16&&N.subarray&&Gt)return Gt.decode(N.subarray(D,pe));for(var he="";D>10,56320|Pa&1023)}}return he}function ia(N,D){return N?sa(i(),N,D):""}function Or(N,D,V,Y){if(!(Y>0))return 0;for(var pe=V,he=V+Y-1,ve=0;ve=55296&&Ce<=57343){var _t=N.charCodeAt(++ve);Ce=65536+((Ce&1023)<<10)|_t&1023}if(Ce<=127){if(V>=he)break;D[V++]=Ce}else if(Ce<=2047){if(V+1>=he)break;D[V++]=192|Ce>>6,D[V++]=128|Ce&63}else if(Ce<=65535){if(V+2>=he)break;D[V++]=224|Ce>>12,D[V++]=128|Ce>>6&63,D[V++]=128|Ce&63}else{if(V+3>=he)break;D[V++]=240|Ce>>18,D[V++]=128|Ce>>12&63,D[V++]=128|Ce>>6&63,D[V++]=128|Ce&63}}return D[V]=0,V-pe}function Ns(N,D,V){return Or(N,i(),D,V)}function dd(N){for(var D=0,V=0;V=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|N.charCodeAt(++V)&1023),Y<=127?++D:Y<=2047?D+=2:Y<=65535?D+=3:D+=4}return D}var Lr=typeof TextDecoder!="undefined"?new Dn("utf-16le"):void 0;function br(N,D){s().set(N,D)}function tp(N,D,V){for(var Y=0;Y>0]=N.charCodeAt(Y);V||(s()[D>>0]=0)}function $o(N,D){return N%D>0&&(N+=D-N%D),N}var bn,hd,md,np,fd,gd,Y0,yd,bd;C&&(bn=c.buffer);function Fa(N){bn=N,c.HEAP8=hd=new Int8Array(N),c.HEAP16=np=new Int16Array(N),c.HEAP32=gd=new Int32Array(N),c.HEAPU8=md=new Uint8Array(N),c.HEAPU16=fd=new Uint16Array(N),c.HEAPU32=Y0=new Uint32Array(N),c.HEAPF32=yd=new Float32Array(N),c.HEAPF64=bd=new Float64Array(N)}var xd=c.INITIAL_MEMORY||16777216;if(C)Te=c.wasmMemory,bn=c.buffer;else if(c.wasmMemory)Te=c.wasmMemory;else if(Te=new WebAssembly.Memory({initial:xd/65536,maximum:32768,shared:!0}),!(Te.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"),T&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Te&&(bn=Te.buffer),xd=bn.byteLength,Fa(bn);var oa,Fo=[],zr=[],rg=[],vd=[],Ts=!1,sg=!1,wd=0;function Cs(){return tt||wd>0}function xn(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)J0(c.preRun.shift());Nd(Fo)}function ap(){Ts=!0,!C&&Nd(zr)}function ig(){C||(_e.terminateAllThreads(),sg=!0)}function og(){if(!C){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)rp(c.postRun.shift());Nd(vd)}}function J0(N){Fo.unshift(N)}function Q0(N){zr.unshift(N)}function rp(N){vd.unshift(N)}var Wr=0,kd=null,Da=null;function sp(N){Wr++,c.monitorRunDependencies&&c.monitorRunDependencies(Wr)}function Z0(N){if(Wr--,c.monitorRunDependencies&&c.monitorRunDependencies(Wr),Wr==0&&(kd!==null&&(clearInterval(kd),kd=null),Da)){var D=Da;Da=null,D()}}c.preloadedImages={},c.preloadedAudios={};function Do(N){C?postMessage({cmd:"onAbort",arg:N}):c.onAbort&&c.onAbort(N),N="Aborted("+N+")",Q(N),pt=!0,yn=1,N+=". Build with -s ASSERTIONS=1 for more info.";var D=new WebAssembly.RuntimeError(N);throw m(D),D}var lg="data:application/octet-stream;base64,";function ip(N){return N.startsWith(lg)}function Id(N){return N.startsWith("file://")}var vn;vn="tfjs-backend-wasm-threaded-simd.wasm",ip(vn)||(vn=$(vn));function Sd(N){try{if(N==vn&&et)return new Uint8Array(et);if(S)return S(N);throw"both async and sync fetching of the wasm failed"}catch(D){Do(D)}}function Ro(){if(!et&&(v||w)){if(typeof fetch=="function"&&!Id(vn))return fetch(vn,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+vn+"'";return N.arrayBuffer()}).catch(function(){return Sd(vn)});if(F)return new Promise(function(N,D){F(vn,function(V){N(new Uint8Array(V))},D)})}return Promise.resolve().then(function(){return Sd(vn)})}function ug(){var N={env:Od,wasi_snapshot_preview1:Od};function D(ve,Ce){var _t=ve.exports;if(c.asm=_t,gg(c.asm.emscripten_tls_init),oa=c.asm.__indirect_function_table,Q0(c.asm.__wasm_call_ctors),gt=Ce,!C){var Pa=_e.unusedWorkers.length;_e.unusedWorkers.forEach(function(Oa){_e.loadWasmModuleToWorker(Oa,function(){--Pa||Z0("wasm-instantiate")})})}}C||sp("wasm-instantiate");function V(ve){D(ve.instance,ve.module)}function Y(ve){return Ro().then(function(Ce){return WebAssembly.instantiate(Ce,N)}).then(function(Ce){return Ce}).then(ve,function(Ce){Q("failed to asynchronously prepare wasm: "+Ce),Do(Ce)})}function pe(){return!et&&typeof WebAssembly.instantiateStreaming=="function"&&!ip(vn)&&!Id(vn)&&typeof fetch=="function"?fetch(vn,{credentials:"same-origin"}).then(function(ve){var Ce=WebAssembly.instantiateStreaming(ve,N);return Ce.then(V,function(_t){return Q("wasm streaming compile failed: "+_t),Q("falling back to ArrayBuffer instantiation"),Y(V)})}):Y(V)}if(c.instantiateWasm)try{var he=c.instantiateWasm(N,D);return he}catch(ve){return Q("Module.instantiateWasm callback failed with error: "+ve),!1}return pe().catch(m),{}}var e1,t1,pg={};function Nd(N){for(;N.length>0;){var D=N.shift();if(typeof D=="function"){D(c);continue}var V=D.func;typeof V=="number"?D.arg===void 0?Po(V)():Po(V)(D.arg):V(D.arg===void 0?null:D.arg)}}function Mo(N){var D=Dy(),V=N();return Vd(D),V}function $A(N){return N}function n1(N){var D=/\b_Z[\w\d_]+/g;return N.replace(D,function(V){var Y=V;return V===Y?V:Y+" ["+V+"]"})}function cg(N){u()[N>>2]=0;var D=_e.pthreads[N];delete _e.pthreads[N],D.worker.terminate(),Fy(N),_e.runningWorkers.splice(_e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function dg(N){var D=_e.pthreads[N];D.worker.postMessage({cmd:"cancel"})}function Td(N){var D=_e.pthreads[N];if(D){u()[N>>2]=0;var V=D.worker;_e.returnWorkerToPool(V)}}function Cd(N){v$(N)}function hg(N){if(N instanceof dp||N=="unwind")return yn;x(1,N)}var _e={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){C?_e.initWorker():_e.initMainThread()},initMainThread:function(){for(var N=8,D=0;D>2]=0;try{N()}finally{u()[f1>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in _e.tlsInitFunctions)_e.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=V=>{var Y=V.data,pe=Y.cmd;if(N.pthread&&(_e.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=Bd()){var he=_e.pthreads[Y.targetThread];he?he.worker.postMessage(Y,Y.transferList):Q('Internal error! Worker sent a message "'+pe+'" to target pthread '+Y.targetThread+", but that thread no longer exists!"),_e.currentProxiedOperationCallerThread=void 0;return}pe==="processQueuedMainThreadWork"?p1():pe==="spawnThread"?Ed(Y):pe==="cleanupThread"?Td(Y.thread):pe==="killThread"?cg(Y.thread):pe==="cancelThread"?dg(Y.thread):pe==="loaded"?(N.loaded=!0,D&&D(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):pe==="print"?re("Thread "+Y.threadId+": "+Y.text):pe==="printErr"?Q("Thread "+Y.threadId+": "+Y.text):pe==="alert"?alert("Thread "+Y.threadId+": "+Y.text):Y.target==="setimmediate"?N.postMessage(Y):pe==="onAbort"?c.onAbort&&c.onAbort(Y.arg):Q("worker sent an unknown command "+pe),_e.currentProxiedOperationCallerThread=void 0},N.onerror=V=>{var Y="worker sent an error!";throw Q(Y+" "+V.filename+":"+V.lineno+": "+V.message),V},T&&(N.on("message",function(V){N.onmessage({data:V})}),N.on("error",function(V){N.onerror(V)}),N.on("detachedExit",function(){})),N.postMessage({cmd:"load",urlOrBlob:c.mainScriptUrlOrBlob||a,wasmMemory:Te,wasmModule:gt})},allocateUnusedWorker:function(){var N=$("tfjs-backend-wasm-threaded-simd.worker.js");_e.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return _e.unusedWorkers.length==0&&(_e.allocateUnusedWorker(),_e.loadWasmModuleToWorker(_e.unusedWorkers[0])),_e.unusedWorkers.pop()}};function mg(){var N=Bd(),D=u()[N+44>>2],V=u()[N+48>>2],Y=D-V;m1(D,Y),Vd(D)}c.establishStackSpace=mg;function _d(N){if(C)return As(1,0,N);try{Cd(N)}catch(D){hg(D)}}var _s=[];function Po(N){var D=_s[N];return D||(N>=_s.length&&(_s.length=N+1),_s[N]=D=oa.get(N)),D}function fg(N,D){return Po(N)(D)}c.invokeEntryPoint=fg;function a1(){var N=new Error;if(!N.stack){try{throw new Error}catch(D){N=D}if(!N.stack)return"(no stack trace available)"}return N.stack.toString()}function gg(N,D,V){_e.tlsInitFunctions.push(N)}function r1(N,D){oa.set(N,D),_s[N]=D}var Es;T?Es=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:C?Es=()=>performance.now()-c.__performance_now_clock_drift:Es=()=>performance.now();var yg=!0;function bg(N){return u()[u1()>>2]=N,N}function xg(N,D){var V;if(N===0)V=Date.now();else if((N===1||N===4)&&yg)V=Es();else return bg(28),-1;return u()[D>>2]=V/1e3|0,u()[D+4>>2]=V%1e3*1e3*1e3|0,0}function vg(N,D){return xg(N,D)}function wg(N){c1(N,!w,1,!v),_e.threadInit()}function kg(N){C?postMessage({cmd:"cleanupThread",thread:N}):Td(N)}function Ed(N){var D=_e.getNewWorker();if(!D)return 6;_e.runningWorkers.push(D);var V=_e.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=V;var Y={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return D.runPthread=()=>{Y.time=performance.now(),D.postMessage(Y,N.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function Ig(N,D,V,Y){if(typeof SharedArrayBuffer=="undefined")return Q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var pe=[],he=0;if(C&&(pe.length===0||he))return d1(687865856,N,D,V,Y);if(he)return he;var ve={startRoutine:V,pthread_ptr:N,arg:Y,transferList:pe};return C?(ve.cmd="spawnThread",postMessage(ve,pe),0):Ed(ve)}function Sg(){return 2097152}function Ng(N,D){if(N==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(C)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var V=_e.pthreads[N],Y=V&&V.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function Tg(){Do("")}function Cg(){T||w||ae("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Ad(){return 2147483648}function _g(N,D,V){i().copyWithin(N,D,D+V)}function Eg(){return T?J$().cpus().length:navigator.hardwareConcurrency}function As(N,D){var V=arguments.length-2,Y=arguments;return Mo(function(){for(var pe=V,he=Vo(pe*8),ve=he>>3,Ce=0;Ce>3,pe=0;pe>>16),Fa(Te.buffer),1}catch(D){}}function Fg(N){var D=i().length;if(N=N>>>0,N<=D)return!1;var V=Ad();if(N>V)return!1;for(var Y=1;Y<=4;Y*=2){var pe=D*(1+.2/Y);pe=Math.min(pe,N+100663296);var he=Math.min(V,$o(Math.max(N,pe),65536)),ve=$g(he);if(ve)return!0}return!1}var Ve={inEventHandler:0,removeAllEventListeners:function(){for(var N=Ve.eventHandlers.length-1;N>=0;--N)Ve._removeHandler(N);Ve.eventHandlers=[],Ve.deferredCalls=[]},registerRemoveEventListeners:function(){Ve.removeEventListenersRegistered||(rg.push(Ve.removeAllEventListeners),Ve.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,V){function Y(ve,Ce){if(ve.length!=Ce.length)return!1;for(var _t in ve)if(ve[_t]!=Ce[_t])return!1;return!0}for(var pe in Ve.deferredCalls){var he=Ve.deferredCalls[pe];if(he.targetFunction==N&&Y(he.argsList,V))return}Ve.deferredCalls.push({targetFunction:N,precedence:D,argsList:V}),Ve.deferredCalls.sort(function(ve,Ce){return ve.precedence>2]=V,u()[he+4>>2]=Y,u()[he+8>>2]=pe,$y(N,637534208,D,Y,he)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return _e.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 Dg(N){var D=dd(N)+1,V=Ay(D);return Ns(N,V,D),V}function Rg(N,D,V,Y){Mo(function(){var pe=Vo(12),he=0;D&&(he=Dg(D)),u()[pe>>2]=he,u()[pe+4>>2]=V,u()[pe+8>>2]=Y,$y(N,657457152,0,he,pe)})}function Mg(N,D,V,Y){D=D?ia(D):"",Rg(N,D,V,Y)}function Pg(N){return N>2?ia(N):N}var Og=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Lg(N){N=Pg(N);var D=Og[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return D}function lp(N){return Lg(N)}function $d(N,D,V){var Y=lp(N);if(!Y)return-4;if(Y.canvasSharedPtr&&(u()[Y.canvasSharedPtr>>2]=D,u()[Y.canvasSharedPtr+4>>2]=V),Y.offscreenCanvas||!Y.controlTransferredOffscreen){Y.offscreenCanvas&&(Y=Y.offscreenCanvas);var pe=!1;if(Y.GLctxObject&&Y.GLctxObject.GLctx){var he=Y.GLctxObject.GLctx.getParameter(2978);pe=he[0]===0&&he[1]===0&&he[2]===Y.width&&he[3]===Y.height}Y.width=D,Y.height=V,pe&&Y.GLctxObject.GLctx.viewport(0,0,D,V)}else if(Y.canvasSharedPtr){var ve=u()[Y.canvasSharedPtr+8>>2];return Mg(ve,N,D,V),1}else return-4;return 0}function Fd(N,D,V){return C?As(2,1,N,D,V):$d(N,D,V)}function zg(N,D,V){var Y=lp(N);return Y?$d(N,D,V):Fd(N,D,V)}function Wg(){throw"unwind"}function Bg(N){var D=N.getExtension("ANGLE_instanced_arrays");if(D)return N.vertexAttribDivisor=function(V,Y){D.vertexAttribDivisorANGLE(V,Y)},N.drawArraysInstanced=function(V,Y,pe,he){D.drawArraysInstancedANGLE(V,Y,pe,he)},N.drawElementsInstanced=function(V,Y,pe,he,ve){D.drawElementsInstancedANGLE(V,Y,pe,he,ve)},1}function Vg(N){var D=N.getExtension("OES_vertex_array_object");if(D)return N.createVertexArray=function(){return D.createVertexArrayOES()},N.deleteVertexArray=function(V){D.deleteVertexArrayOES(V)},N.bindVertexArray=function(V){D.bindVertexArrayOES(V)},N.isVertexArray=function(V){return D.isVertexArrayOES(V)},1}function Ug(N){var D=N.getExtension("WEBGL_draw_buffers");if(D)return N.drawBuffers=function(V,Y){D.drawBuffersWEBGL(V,Y)},1}function Gg(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var Ct={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){Ct.lastError||(Ct.lastError=N)},getNewId:function(N){for(var D=Ct.counter++,V=N.length;V>2]:-1;pe+=ia(u()[V+he*4>>2],ve<0?void 0:ve)}return pe},createContext:function(N,D){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(pe,he){var ve=N.getContextSafariWebGL2Fixed(pe,he);return pe=="webgl"==ve instanceof WebGLRenderingContext?ve:null});var V=N.getContext("webgl",D);if(!V)return 0;var Y=Ct.registerContext(V,D);return Y},registerContext:function(N,D){var V=Ay(8);u()[V+4>>2]=Bd();var Y={handle:V,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Y),Ct.contexts[V]=Y,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&&Ct.initExtensions(Y),V},makeContextCurrent:function(N){return Ct.currentContext=Ct.contexts[N],c.ctx=Pd=Ct.currentContext&&Ct.currentContext.GLctx,!(N&&!Pd)},getContext:function(N){return Ct.contexts[N]},deleteContext:function(N){Ct.currentContext===Ct.contexts[N]&&(Ct.currentContext=null),typeof Ve=="object"&&Ve.removeAllHandlersOnTarget(Ct.contexts[N].GLctx.canvas),Ct.contexts[N]&&Ct.contexts[N].GLctx.canvas&&(Ct.contexts[N].GLctx.canvas.GLctxObject=void 0),l1(Ct.contexts[N].handle),Ct.contexts[N]=null},initExtensions:function(N){if(N||(N=Ct.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var D=N.GLctx;Bg(D),Vg(D),Ug(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),Gg(D);var V=D.getSupportedExtensions()||[];V.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&D.getExtension(Y)})}}},Hg=["default","low-power","high-performance"];function jg(N,D){var V=D>>2,Y=u()[V+6],pe={alpha:!!u()[V+0],depth:!!u()[V+1],stencil:!!u()[V+2],antialias:!!u()[V+3],premultipliedAlpha:!!u()[V+4],preserveDrawingBuffer:!!u()[V+5],powerPreference:Hg[Y],failIfMajorPerformanceCaveat:!!u()[V+7],majorVersion:u()[V+8],minorVersion:u()[V+9],enableExtensionsByDefault:u()[V+10],explicitSwapControl:u()[V+11],proxyContextToMainThread:u()[V+12],renderViaOffscreenBackBuffer:u()[V+13]},he=lp(N);if(!he||pe.explicitSwapControl)return 0;var ve=Ct.createContext(he,pe);return ve}function qg(N,D){return jg(N,D)}var Oo={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var V=Oo.buffers[N];D===0||D===10?((N===1?re:Q)(sa(V,0)),V.length=0):V.push(D)},varargs:void 0,get:function(){Oo.varargs+=4;var N=u()[Oo.varargs-4>>2];return N},getStr:function(N){var D=ia(N);return D},get64:function(N,D){return N}};function Dd(N){return C?As(3,1,N):0}function Rd(N,D,V,Y,pe){if(C)return As(4,1,N,D,V,Y,pe)}function Md(N,D,V,Y){if(C)return As(5,1,N,D,V,Y);for(var pe=0,he=0;he>2],Ce=u()[D+4>>2];D+=8;for(var _t=0;_t>2]=pe,0}function Kg(N){$e(N)}_e.init();var Pd,Xg=[null,_d,Fd,Dd,Rd,Md],s1=!1,Od={__clock_gettime:vg,__emscripten_init_main_thread_js:wg,__emscripten_thread_cleanup:kg,__pthread_create_js:Ig,_emscripten_default_pthread_stack_size:Sg,_emscripten_notify_thread_queue:Ng,abort:Tg,emscripten_check_blocking_allowed:Cg,emscripten_get_heap_max:Ad,emscripten_get_now:Es,emscripten_memcpy_big:_g,emscripten_num_logical_cores:Eg,emscripten_receive_on_main_thread_js:Ag,emscripten_resize_heap:Fg,emscripten_set_canvas_element_size:zg,emscripten_unwind_to_js_event_loop:Wg,emscripten_webgl_create_context:qg,exit:Cd,fd_close:Dd,fd_seek:Rd,fd_write:Md,memory:Te||c.wasmMemory,setTempRet0:Kg},i1=ug(),Yg=c.___wasm_call_ctors=function(){return(Yg=c.___wasm_call_ctors=c.asm.__wasm_call_ctors).apply(null,arguments)},Jg=c._init=function(){return(Jg=c._init=c.asm.init).apply(null,arguments)},Qg=c._init_with_threads_count=function(){return(Qg=c._init_with_threads_count=c.asm.init_with_threads_count).apply(null,arguments)},Zg=c._get_threads_count=function(){return(Zg=c._get_threads_count=c.asm.get_threads_count).apply(null,arguments)},ey=c._register_tensor=function(){return(ey=c._register_tensor=c.asm.register_tensor).apply(null,arguments)},ty=c._dispose_data=function(){return(ty=c._dispose_data=c.asm.dispose_data).apply(null,arguments)},ny=c._dispose=function(){return(ny=c._dispose=c.asm.dispose).apply(null,arguments)},ay=c._Abs=function(){return(ay=c._Abs=c.asm.Abs).apply(null,arguments)},ry=c._Add=function(){return(ry=c._Add=c.asm.Add).apply(null,arguments)},sy=c._AddN=function(){return(sy=c._AddN=c.asm.AddN).apply(null,arguments)},iy=c._All=function(){return(iy=c._All=c.asm.All).apply(null,arguments)},oy=c._Any=function(){return(oy=c._Any=c.asm.Any).apply(null,arguments)},ly=c._ArgMax=function(){return(ly=c._ArgMax=c.asm.ArgMax).apply(null,arguments)},uy=c._AvgPool=function(){return(uy=c._AvgPool=c.asm.AvgPool).apply(null,arguments)},py=c._BatchMatMul=function(){return(py=c._BatchMatMul=c.asm.BatchMatMul).apply(null,arguments)},cy=c._Ceil=function(){return(cy=c._Ceil=c.asm.Ceil).apply(null,arguments)},dy=c._ClipByValue=function(){return(dy=c._ClipByValue=c.asm.ClipByValue).apply(null,arguments)},hy=c._Conv2D=function(){return(hy=c._Conv2D=c.asm.Conv2D).apply(null,arguments)},my=c._Conv2DBackpropInput=function(){return(my=c._Conv2DBackpropInput=c.asm.Conv2DBackpropInput).apply(null,arguments)},fy=c._Cos=function(){return(fy=c._Cos=c.asm.Cos).apply(null,arguments)},gy=c._Cosh=function(){return(gy=c._Cosh=c.asm.Cosh).apply(null,arguments)},yy=c._CropAndResize=function(){return(yy=c._CropAndResize=c.asm.CropAndResize).apply(null,arguments)},by=c._Cumprod=function(){return(by=c._Cumprod=c.asm.Cumprod).apply(null,arguments)},xy=c._Cumsum=function(){return(xy=c._Cumsum=c.asm.Cumsum).apply(null,arguments)},vy=c._DepthToSpace=function(){return(vy=c._DepthToSpace=c.asm.DepthToSpace).apply(null,arguments)},wy=c._DepthwiseConv2dNative=function(){return(wy=c._DepthwiseConv2dNative=c.asm.DepthwiseConv2dNative).apply(null,arguments)},ky=c._Elu=function(){return(ky=c._Elu=c.asm.Elu).apply(null,arguments)},Iy=c._Equal=function(){return(Iy=c._Equal=c.asm.Equal).apply(null,arguments)},Sy=c._Exp=function(){return(Sy=c._Exp=c.asm.Exp).apply(null,arguments)},Ny=c._FlipLeftRight=function(){return(Ny=c._FlipLeftRight=c.asm.FlipLeftRight).apply(null,arguments)},Ld=c._Floor=function(){return(Ld=c._Floor=c.asm.Floor).apply(null,arguments)},zd=c._FloorDiv=function(){return(zd=c._FloorDiv=c.asm.FloorDiv).apply(null,arguments)},up=c._FusedBatchNorm=function(){return(up=c._FusedBatchNorm=c.asm.FusedBatchNorm).apply(null,arguments)},Ty=c._FusedConv2D=function(){return(Ty=c._FusedConv2D=c.asm.FusedConv2D).apply(null,arguments)},Cy=c._FusedDepthwiseConv2D=function(){return(Cy=c._FusedDepthwiseConv2D=c.asm.FusedDepthwiseConv2D).apply(null,arguments)},Lo=c._Gather=function(){return(Lo=c._Gather=c.asm.Gather).apply(null,arguments)},pp=c._GatherNd=function(){return(pp=c._GatherNd=c.asm.GatherNd).apply(null,arguments)},cp=c._Greater=function(){return(cp=c._Greater=c.asm.Greater).apply(null,arguments)},o1=c._GreaterEqual=function(){return(o1=c._GreaterEqual=c.asm.GreaterEqual).apply(null,arguments)},zo=c._LeakyRelu=function(){return(zo=c._LeakyRelu=c.asm.LeakyRelu).apply(null,arguments)},Wo=c._Less=function(){return(Wo=c._Less=c.asm.Less).apply(null,arguments)},_y=c._LessEqual=function(){return(_y=c._LessEqual=c.asm.LessEqual).apply(null,arguments)},G=c._Log=function(){return(G=c._Log=c.asm.Log).apply(null,arguments)},te=c._LogicalAnd=function(){return(te=c._LogicalAnd=c.asm.LogicalAnd).apply(null,arguments)},de=c._Max=function(){return(de=c._Max=c.asm.Max).apply(null,arguments)},Se=c._MaxPool=function(){return(Se=c._MaxPool=c.asm.MaxPool).apply(null,arguments)},Qe=c._Maximum=function(){return(Qe=c._Maximum=c.asm.Maximum).apply(null,arguments)},nt=c._Mean=function(){return(nt=c._Mean=c.asm.Mean).apply(null,arguments)},Ue=c._Min=function(){return(Ue=c._Min=c.asm.Min).apply(null,arguments)},Be=c._Minimum=function(){return(Be=c._Minimum=c.asm.Minimum).apply(null,arguments)},Lt=c._MirrorPad=function(){return(Lt=c._MirrorPad=c.asm.MirrorPad).apply(null,arguments)},Ra=c._Multiply=function(){return(Ra=c._Multiply=c.asm.Multiply).apply(null,arguments)},Ma=c._Neg=function(){return(Ma=c._Neg=c.asm.Neg).apply(null,arguments)},Bo=c._NonMaxSuppressionV3=function(){return(Bo=c._NonMaxSuppressionV3=c.asm.NonMaxSuppressionV3).apply(null,arguments)},$s=c._NonMaxSuppressionV4=function(){return($s=c._NonMaxSuppressionV4=c.asm.NonMaxSuppressionV4).apply(null,arguments)},Ey=c._NonMaxSuppressionV5=function(){return(Ey=c._NonMaxSuppressionV5=c.asm.NonMaxSuppressionV5).apply(null,arguments)},Rn=c._NotEqual=function(){return(Rn=c._NotEqual=c.asm.NotEqual).apply(null,arguments)},Br=c._OneHot=function(){return(Br=c._OneHot=c.asm.OneHot).apply(null,arguments)},Wd=c._PadV2=function(){return(Wd=c._PadV2=c.asm.PadV2).apply(null,arguments)},FA=c._Pow=function(){return(FA=c._Pow=c.asm.Pow).apply(null,arguments)},DA=c._Prelu=function(){return(DA=c._Prelu=c.asm.Prelu).apply(null,arguments)},RA=c._Prod=function(){return(RA=c._Prod=c.asm.Prod).apply(null,arguments)},MA=c._RealDiv=function(){return(MA=c._RealDiv=c.asm.RealDiv).apply(null,arguments)},PA=c._Relu=function(){return(PA=c._Relu=c.asm.Relu).apply(null,arguments)},OA=c._Relu6=function(){return(OA=c._Relu6=c.asm.Relu6).apply(null,arguments)},LA=c._ResizeBilinear=function(){return(LA=c._ResizeBilinear=c.asm.ResizeBilinear).apply(null,arguments)},zA=c._Reverse=function(){return(zA=c._Reverse=c.asm.Reverse).apply(null,arguments)},WA=c._RotateWithOffset=function(){return(WA=c._RotateWithOffset=c.asm.RotateWithOffset).apply(null,arguments)},BA=c._Round=function(){return(BA=c._Round=c.asm.Round).apply(null,arguments)},VA=c._Rsqrt=function(){return(VA=c._Rsqrt=c.asm.Rsqrt).apply(null,arguments)},UA=c._ScatterNd=function(){return(UA=c._ScatterNd=c.asm.ScatterNd).apply(null,arguments)},GA=c._SelectV2=function(){return(GA=c._SelectV2=c.asm.SelectV2).apply(null,arguments)},HA=c._Sigmoid=function(){return(HA=c._Sigmoid=c.asm.Sigmoid).apply(null,arguments)},jA=c._Sin=function(){return(jA=c._Sin=c.asm.Sin).apply(null,arguments)},qA=c._Softmax=function(){return(qA=c._Softmax=c.asm.Softmax).apply(null,arguments)},KA=c._SparseFillEmptyRows=function(){return(KA=c._SparseFillEmptyRows=c.asm.SparseFillEmptyRows).apply(null,arguments)},XA=c._SparseReshape=function(){return(XA=c._SparseReshape=c.asm.SparseReshape).apply(null,arguments)},YA=c._SparseSegmentReduction=function(){return(YA=c._SparseSegmentReduction=c.asm.SparseSegmentReduction).apply(null,arguments)},JA=c._Sqrt=function(){return(JA=c._Sqrt=c.asm.Sqrt).apply(null,arguments)},QA=c._Square=function(){return(QA=c._Square=c.asm.Square).apply(null,arguments)},ZA=c._SquaredDifference=function(){return(ZA=c._SquaredDifference=c.asm.SquaredDifference).apply(null,arguments)},e$=c._Step=function(){return(e$=c._Step=c.asm.Step).apply(null,arguments)},t$=c._StridedSlice=function(){return(t$=c._StridedSlice=c.asm.StridedSlice).apply(null,arguments)},n$=c._Sub=function(){return(n$=c._Sub=c.asm.Sub).apply(null,arguments)},a$=c._Sum=function(){return(a$=c._Sum=c.asm.Sum).apply(null,arguments)},r$=c._Tan=function(){return(r$=c._Tan=c.asm.Tan).apply(null,arguments)},s$=c._Tanh=function(){return(s$=c._Tanh=c.asm.Tanh).apply(null,arguments)},i$=c._Tile=function(){return(i$=c._Tile=c.asm.Tile).apply(null,arguments)},o$=c._TopK=function(){return(o$=c._TopK=c.asm.TopK).apply(null,arguments)},l$=c._Transform=function(){return(l$=c._Transform=c.asm.Transform).apply(null,arguments)},u$=c._Transpose=function(){return(u$=c._Transpose=c.asm.Transpose).apply(null,arguments)},p$=c.__FusedMatMul=function(){return(p$=c.__FusedMatMul=c.asm._FusedMatMul).apply(null,arguments)},Ay=c._malloc=function(){return(Ay=c._malloc=c.asm.malloc).apply(null,arguments)},l1=c._free=function(){return(l1=c._free=c.asm.free).apply(null,arguments)},c$=c._emscripten_tls_init=function(){return(c$=c._emscripten_tls_init=c.asm.emscripten_tls_init).apply(null,arguments)},u1=c.___errno_location=function(){return(u1=c.___errno_location=c.asm.__errno_location).apply(null,arguments)},Bd=c._pthread_self=function(){return(Bd=c._pthread_self=c.asm.pthread_self).apply(null,arguments)},p1=c._emscripten_main_thread_process_queued_calls=function(){return(p1=c._emscripten_main_thread_process_queued_calls=c.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},d$=c.__emscripten_thread_crashed=function(){return(d$=c.__emscripten_thread_crashed=c.asm._emscripten_thread_crashed).apply(null,arguments)},c1=c.__emscripten_thread_init=function(){return(c1=c.__emscripten_thread_init=c.asm._emscripten_thread_init).apply(null,arguments)},h$=c._emscripten_current_thread_process_queued_calls=function(){return(h$=c._emscripten_current_thread_process_queued_calls=c.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},m$=c._emscripten_main_browser_thread_id=function(){return(m$=c._emscripten_main_browser_thread_id=c.asm.emscripten_main_browser_thread_id).apply(null,arguments)},f$=c._emscripten_sync_run_in_main_thread_2=function(){return(f$=c._emscripten_sync_run_in_main_thread_2=c.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},d1=c._emscripten_sync_run_in_main_thread_4=function(){return(d1=c._emscripten_sync_run_in_main_thread_4=c.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},h1=c._emscripten_run_in_main_runtime_thread_js=function(){return(h1=c._emscripten_run_in_main_runtime_thread_js=c.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},$y=c._emscripten_dispatch_to_thread_=function(){return($y=c._emscripten_dispatch_to_thread_=c.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},Fy=c.__emscripten_thread_free_data=function(){return(Fy=c.__emscripten_thread_free_data=c.asm._emscripten_thread_free_data).apply(null,arguments)},g$=c.__emscripten_thread_exit=function(){return(g$=c.__emscripten_thread_exit=c.asm._emscripten_thread_exit).apply(null,arguments)},y$=c._memalign=function(){return(y$=c._memalign=c.asm.memalign).apply(null,arguments)},m1=c._emscripten_stack_set_limits=function(){return(m1=c._emscripten_stack_set_limits=c.asm.emscripten_stack_set_limits).apply(null,arguments)},Dy=c.stackSave=function(){return(Dy=c.stackSave=c.asm.stackSave).apply(null,arguments)},Vd=c.stackRestore=function(){return(Vd=c.stackRestore=c.asm.stackRestore).apply(null,arguments)},Vo=c.stackAlloc=function(){return(Vo=c.stackAlloc=c.asm.stackAlloc).apply(null,arguments)},b$=c.dynCall_iijjiiii=function(){return(b$=c.dynCall_iijjiiii=c.asm.dynCall_iijjiiii).apply(null,arguments)},x$=c.dynCall_jiji=function(){return(x$=c.dynCall_jiji=c.asm.dynCall_jiji).apply(null,arguments)},f1=c.__emscripten_allow_main_runtime_queued_calls=21464;c.cwrap=Jt,c.keepRuntimeAlive=Cs,c.PThread=_e,c.PThread=_e,c.wasmMemory=Te,c.ExitStatus=dp;var Ud;function dp(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Da=function N(){Ud||Ry(),Ud||(Da=N)};function Ry(N){if(N=N||y,Wr>0)return;if(C){h(c),ap(),postMessage({cmd:"loaded"});return}if(xn(),Wr>0)return;function D(){Ud||(Ud=!0,c.calledRun=!0,!pt&&(ap(),h(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),og()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),D()},1)):D()}c.run=Ry;function v$(N,D){if(yn=N,!D&&C)throw _d(N),"unwind";Cs()||ig(),w$(N)}function w$(N){yn=N,Cs()||(_e.terminateAllThreads(),c.onExit&&c.onExit(N),pt=!0),x(N,new dp(N))}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();Ry();var Gd;f&&(Gd={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 Hd;if(typeof WasmBackendModule!="undefined")Hd=WasmBackendModule;else if(typeof r!="undefined")Hd=r;else throw new Error("Could not find wasm module in post.js");if(Gd){var k$=Hd._dispose;Hd._dispose=function(){k$(),Gd.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Gd.unhandledRejection.forEach(function(N){process.removeListener("unhandledRejection",N)})}}return r.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModuleThreadedSimd=n)}),Z$=mt((e,t)=>{var n=(()=>{var a=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(a=a||__filename),function(r){r=r||{};var s=typeof r!="undefined"?r:{},i,o;s.ready=new Promise(function(G,te){i=G,o=te});var l;typeof process!="undefined"&&process.listeners&&(l={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var u=Object.assign({},s),p=[],d="./this.program",c=(G,te)=>{throw te},h=typeof window=="object",m=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function y(G){return s.locateFile?s.locateFile(G,g):g+G}var b,x,v,w;function T(G){G instanceof pp||F("exiting due to exception: "+G)}var C,E,$;f?(m?g=fh().dirname(g)+"/":g=__dirname+"/",$=()=>{E||(C=Jb(),E=fh())},b=function(G,te){return $(),G=E.normalize(G),C.readFileSync(G,te?void 0:"utf8")},v=G=>{var te=b(G,!0);return te.buffer||(te=new Uint8Array(te)),te},x=(G,te,de)=>{$(),G=E.normalize(G),C.readFile(G,function(Se,Qe){Se?de(Se):te(Qe.buffer)})},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),p=process.argv.slice(2),process.on("uncaughtException",function(G){if(!(G instanceof pp))throw G}),process.on("unhandledRejection",function(G){throw G}),c=(G,te)=>{if(np())throw process.exitCode=G,te;T(te),process.exit(G)},s.inspect=function(){return"[Emscripten Module object]"}):(h||m)&&(m?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),a&&(g=a),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",b=G=>{var te=new XMLHttpRequest;return te.open("GET",G,!1),te.send(null),te.responseText},m&&(v=G=>{var te=new XMLHttpRequest;return te.open("GET",G,!1),te.responseType="arraybuffer",te.send(null),new Uint8Array(te.response)}),x=(G,te,de)=>{var Se=new XMLHttpRequest;Se.open("GET",G,!0),Se.responseType="arraybuffer",Se.onload=()=>{if(Se.status==200||Se.status==0&&Se.response){te(Se.response);return}de()},Se.onerror=de,Se.send(null)},w=G=>document.title=G);var P=s.print||console.log.bind(console),F=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(p=s.arguments),s.thisProgram&&(d=s.thisProgram),s.quit&&(c=s.quit);var S=4;function M(G){M.shown||(M.shown={}),M.shown[G]||(M.shown[G]=1,F(G))}function U(G,te){if(typeof WebAssembly.Function=="function"){for(var de={i:"i32",j:"i64",f:"f32",d:"f64"},Se={parameters:[],results:te[0]=="v"?[]:[de[te[0]]]},Qe=1;Qe{ee=G},Q;s.wasmBinary&&(Q=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Ts("no native wasm support detected");var ae,le=!1,ue;function we(G,te){G||Ts(te)}function ye(G){var te=s["_"+G];return te}function Ie(G,te,de,Se,Qe){var nt={string:function(Rn){var Br=0;if(Rn!=null&&Rn!==0){var Wd=(Rn.length<<2)+1;Br=up(Wd),tt(Rn,Br,Wd)}return Br},array:function(Rn){var Br=up(Rn.length);return pt(Rn,Br),Br}};function Ue(Rn){return te==="string"?st(Rn):te==="boolean"?Boolean(Rn):Rn}var Be=ye(G),Lt=[],Ra=0;if(Se)for(var Ma=0;Ma=Se);)++Qe;if(Qe-te>16&&G.subarray&&We)return We.decode(G.subarray(te,Qe));for(var nt="";te>10,56320|Ra&1023)}}return nt}function st(G,te){return G?je(Jt,G,te):""}function et(G,te,de,Se){if(!(Se>0))return 0;for(var Qe=de,nt=de+Se-1,Ue=0;Ue=55296&&Be<=57343){var Lt=G.charCodeAt(++Ue);Be=65536+((Be&1023)<<10)|Lt&1023}if(Be<=127){if(de>=nt)break;te[de++]=Be}else if(Be<=2047){if(de+1>=nt)break;te[de++]=192|Be>>6,te[de++]=128|Be&63}else if(Be<=65535){if(de+2>=nt)break;te[de++]=224|Be>>12,te[de++]=128|Be>>6&63,te[de++]=128|Be&63}else{if(de+3>=nt)break;te[de++]=240|Be>>18,te[de++]=128|Be>>12&63,te[de++]=128|Be>>6&63,te[de++]=128|Be&63}}return te[de]=0,de-Qe}function tt(G,te,de){return et(G,Jt,te,de)}function Te(G){for(var te=0,de=0;de=55296&&Se<=57343&&(Se=65536+((Se&1023)<<10)|G.charCodeAt(++de)&1023),Se<=127?++te:Se<=2047?te+=2:Se<=65535?te+=3:te+=4}return te}var gt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function pt(G,te){Ut.set(G,te)}function yn(G,te,de){for(var Se=0;Se>0]=G.charCodeAt(Se);de||(Ut[te>>0]=0)}function Yt(G,te){return G%te>0&&(G+=te-G%te),G}var Fn,Ut,Jt,$a,Dn,Gt,sa,ia,Or;function Ns(G){Fn=G,s.HEAP8=Ut=new Int8Array(G),s.HEAP16=$a=new Int16Array(G),s.HEAP32=Gt=new Int32Array(G),s.HEAPU8=Jt=new Uint8Array(G),s.HEAPU16=Dn=new Uint16Array(G),s.HEAPU32=sa=new Uint32Array(G),s.HEAPF32=ia=new Float32Array(G),s.HEAPF64=Or=new Float64Array(G)}var dd=s.INITIAL_MEMORY||16777216,Lr,br=[],tp=[],$o=[],bn=!1,hd=!1,md=0;function np(){return ie||md>0}function fd(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)bd(s.preRun.shift());rp(br)}function gd(){bn=!0,rp(tp)}function Y0(){hd=!0}function yd(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)xd(s.postRun.shift());rp($o)}function bd(G){br.unshift(G)}function Fa(G){tp.unshift(G)}function xd(G){$o.unshift(G)}var oa=0,Fo=null,zr=null;function rg(G){oa++,s.monitorRunDependencies&&s.monitorRunDependencies(oa)}function vd(G){if(oa--,s.monitorRunDependencies&&s.monitorRunDependencies(oa),oa==0&&(Fo!==null&&(clearInterval(Fo),Fo=null),zr)){var te=zr;zr=null,te()}}s.preloadedImages={},s.preloadedAudios={};function Ts(G){s.onAbort&&s.onAbort(G),G="Aborted("+G+")",F(G),le=!0,ue=1,G+=". Build with -s ASSERTIONS=1 for more info.";var te=new WebAssembly.RuntimeError(G);throw o(te),te}var sg="data:application/octet-stream;base64,";function wd(G){return G.startsWith(sg)}function Cs(G){return G.startsWith("file://")}var xn;xn="tfjs-backend-wasm.wasm",wd(xn)||(xn=y(xn));function ap(G){try{if(G==xn&&Q)return new Uint8Array(Q);if(v)return v(G);throw"both async and sync fetching of the wasm failed"}catch(te){Ts(te)}}function ig(){if(!Q&&(h||m)){if(typeof fetch=="function"&&!Cs(xn))return fetch(xn,{credentials:"same-origin"}).then(function(G){if(!G.ok)throw"failed to load wasm binary file at '"+xn+"'";return G.arrayBuffer()}).catch(function(){return ap(xn)});if(x)return new Promise(function(G,te){x(xn,function(de){G(new Uint8Array(de))},te)})}return Promise.resolve().then(function(){return ap(xn)})}function og(){var G={env:Mo,wasi_snapshot_preview1:Mo};function te(Ue,Be){var Lt=Ue.exports;s.asm=Lt,ae=s.asm.memory,Ns(ae.buffer),Lr=s.asm.__indirect_function_table,Fa(s.asm.__wasm_call_ctors),vd("wasm-instantiate")}rg("wasm-instantiate");function de(Ue){te(Ue.instance)}function Se(Ue){return ig().then(function(Be){return WebAssembly.instantiate(Be,G)}).then(function(Be){return Be}).then(Ue,function(Be){F("failed to asynchronously prepare wasm: "+Be),Ts(Be)})}function Qe(){return!Q&&typeof WebAssembly.instantiateStreaming=="function"&&!wd(xn)&&!Cs(xn)&&typeof fetch=="function"?fetch(xn,{credentials:"same-origin"}).then(function(Ue){var Be=WebAssembly.instantiateStreaming(Ue,G);return Be.then(de,function(Lt){return F("wasm streaming compile failed: "+Lt),F("falling back to ArrayBuffer instantiation"),Se(de)})}):Se(de)}if(s.instantiateWasm)try{var nt=s.instantiateWasm(G,te);return nt}catch(Ue){return F("Module.instantiateWasm callback failed with error: "+Ue),!1}return Qe().catch(o),{}}var J0,Q0;function rp(G){for(;G.length>0;){var te=G.shift();if(typeof te=="function"){te(s);continue}var de=te.func;typeof de=="number"?te.arg===void 0?sp(de)():sp(de)(te.arg):de(te.arg===void 0?null:te.arg)}}function Wr(G){return G}function kd(G){var te=/\b_Z[\w\d_]+/g;return G.replace(te,function(de){var Se=de;return de===Se?de:Se+" ["+de+"]"})}var Da=[];function sp(G){var te=Da[G];return te||(G>=Da.length&&(Da.length=G+1),Da[G]=te=Lr.get(G)),te}function Z0(){var G=new Error;if(!G.stack){try{throw new Error}catch(te){G=te}if(!G.stack)return"(no stack trace available)"}return G.stack.toString()}function Do(G,te){Lr.set(G,te),Da[G]=te}function lg(){Ts("")}function ip(){return 2147483648}function Id(G,te,de){Jt.copyWithin(G,te,te+de)}function vn(G){try{return ae.grow(G-Fn.byteLength+65535>>>16),Ns(ae.buffer),1}catch(te){}}function Sd(G){var te=Jt.length;G=G>>>0;var de=ip();if(G>de)return!1;for(var Se=1;Se<=4;Se*=2){var Qe=te*(1+.2/Se);Qe=Math.min(Qe,G+100663296);var nt=Math.min(de,Yt(Math.max(G,Qe),65536)),Ue=vn(nt);if(Ue)return!0}return!1}var Ro={mappings:{},buffers:[null,[],[]],printChar:function(G,te){var de=Ro.buffers[G];te===0||te===10?((G===1?P:F)(je(de,0)),de.length=0):de.push(te)},varargs:void 0,get:function(){Ro.varargs+=4;var G=Gt[Ro.varargs-4>>2];return G},getStr:function(G){var te=st(G);return te},get64:function(G,te){return G}};function ug(G){return 0}function e1(G,te,de,Se,Qe){}function t1(G,te,de,Se){for(var Qe=0,nt=0;nt>2],Be=Gt[te+4>>2];te+=8;for(var Lt=0;Lt>2]=Qe,0}function pg(G){re(G)}var Nd=!1,Mo={abort:lg,emscripten_get_heap_max:ip,emscripten_memcpy_big:Id,emscripten_resize_heap:Sd,fd_close:ug,fd_seek:e1,fd_write:t1,setTempRet0:pg},$A=og(),n1=s.___wasm_call_ctors=function(){return(n1=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},cg=s._init=function(){return(cg=s._init=s.asm.init).apply(null,arguments)},dg=s._init_with_threads_count=function(){return(dg=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},Td=s._get_threads_count=function(){return(Td=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},Cd=s._register_tensor=function(){return(Cd=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},hg=s._dispose_data=function(){return(hg=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},_e=s._dispose=function(){return(_e=s._dispose=s.asm.dispose).apply(null,arguments)},mg=s._Abs=function(){return(mg=s._Abs=s.asm.Abs).apply(null,arguments)},_d=s._Add=function(){return(_d=s._Add=s.asm.Add).apply(null,arguments)},_s=s._AddN=function(){return(_s=s._AddN=s.asm.AddN).apply(null,arguments)},Po=s._All=function(){return(Po=s._All=s.asm.All).apply(null,arguments)},fg=s._Any=function(){return(fg=s._Any=s.asm.Any).apply(null,arguments)},a1=s._ArgMax=function(){return(a1=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},gg=s._AvgPool=function(){return(gg=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},r1=s._BatchMatMul=function(){return(r1=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},Es=s._Ceil=function(){return(Es=s._Ceil=s.asm.Ceil).apply(null,arguments)},yg=s._ClipByValue=function(){return(yg=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},bg=s._Conv2D=function(){return(bg=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},xg=s._Conv2DBackpropInput=function(){return(xg=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},vg=s._Cos=function(){return(vg=s._Cos=s.asm.Cos).apply(null,arguments)},wg=s._Cosh=function(){return(wg=s._Cosh=s.asm.Cosh).apply(null,arguments)},kg=s._CropAndResize=function(){return(kg=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},Ed=s._Cumprod=function(){return(Ed=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Ig=s._Cumsum=function(){return(Ig=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},Sg=s._DepthToSpace=function(){return(Sg=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},Ng=s._DepthwiseConv2dNative=function(){return(Ng=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Tg=s._Elu=function(){return(Tg=s._Elu=s.asm.Elu).apply(null,arguments)},Cg=s._Equal=function(){return(Cg=s._Equal=s.asm.Equal).apply(null,arguments)},Ad=s._Exp=function(){return(Ad=s._Exp=s.asm.Exp).apply(null,arguments)},_g=s._FlipLeftRight=function(){return(_g=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},Eg=s._Floor=function(){return(Eg=s._Floor=s.asm.Floor).apply(null,arguments)},As=s._FloorDiv=function(){return(As=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},op=s._FusedBatchNorm=function(){return(op=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},Ag=s._FusedConv2D=function(){return(Ag=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},$g=s._FusedDepthwiseConv2D=function(){return($g=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},Fg=s._Gather=function(){return(Fg=s._Gather=s.asm.Gather).apply(null,arguments)},Ve=s._GatherNd=function(){return(Ve=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},Dg=s._Greater=function(){return(Dg=s._Greater=s.asm.Greater).apply(null,arguments)},Rg=s._GreaterEqual=function(){return(Rg=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},Mg=s._LeakyRelu=function(){return(Mg=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},Pg=s._Less=function(){return(Pg=s._Less=s.asm.Less).apply(null,arguments)},Og=s._LessEqual=function(){return(Og=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},Lg=s._Log=function(){return(Lg=s._Log=s.asm.Log).apply(null,arguments)},lp=s._LogicalAnd=function(){return(lp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},$d=s._Max=function(){return($d=s._Max=s.asm.Max).apply(null,arguments)},Fd=s._MaxPool=function(){return(Fd=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},zg=s._Maximum=function(){return(zg=s._Maximum=s.asm.Maximum).apply(null,arguments)},Wg=s._Mean=function(){return(Wg=s._Mean=s.asm.Mean).apply(null,arguments)},Bg=s._Min=function(){return(Bg=s._Min=s.asm.Min).apply(null,arguments)},Vg=s._Minimum=function(){return(Vg=s._Minimum=s.asm.Minimum).apply(null,arguments)},Ug=s._MirrorPad=function(){return(Ug=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},Gg=s._Multiply=function(){return(Gg=s._Multiply=s.asm.Multiply).apply(null,arguments)},Ct=s._Neg=function(){return(Ct=s._Neg=s.asm.Neg).apply(null,arguments)},Hg=s._NonMaxSuppressionV3=function(){return(Hg=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},jg=s._NonMaxSuppressionV4=function(){return(jg=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},qg=s._NonMaxSuppressionV5=function(){return(qg=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Oo=s._NotEqual=function(){return(Oo=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},Dd=s._OneHot=function(){return(Dd=s._OneHot=s.asm.OneHot).apply(null,arguments)},Rd=s._PadV2=function(){return(Rd=s._PadV2=s.asm.PadV2).apply(null,arguments)},Md=s._Pow=function(){return(Md=s._Pow=s.asm.Pow).apply(null,arguments)},Kg=s._Prelu=function(){return(Kg=s._Prelu=s.asm.Prelu).apply(null,arguments)},Pd=s._Prod=function(){return(Pd=s._Prod=s.asm.Prod).apply(null,arguments)},Xg=s._RealDiv=function(){return(Xg=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},s1=s._Relu=function(){return(s1=s._Relu=s.asm.Relu).apply(null,arguments)},Od=s._Relu6=function(){return(Od=s._Relu6=s.asm.Relu6).apply(null,arguments)},i1=s._ResizeBilinear=function(){return(i1=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},Yg=s._Reverse=function(){return(Yg=s._Reverse=s.asm.Reverse).apply(null,arguments)},Jg=s._RotateWithOffset=function(){return(Jg=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},Qg=s._Round=function(){return(Qg=s._Round=s.asm.Round).apply(null,arguments)},Zg=s._Rsqrt=function(){return(Zg=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},ey=s._ScatterNd=function(){return(ey=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},ty=s._SelectV2=function(){return(ty=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},ny=s._Sigmoid=function(){return(ny=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},ay=s._Sin=function(){return(ay=s._Sin=s.asm.Sin).apply(null,arguments)},ry=s._Softmax=function(){return(ry=s._Softmax=s.asm.Softmax).apply(null,arguments)},sy=s._SparseFillEmptyRows=function(){return(sy=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},iy=s._SparseReshape=function(){return(iy=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},oy=s._SparseSegmentReduction=function(){return(oy=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},ly=s._Sqrt=function(){return(ly=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},uy=s._Square=function(){return(uy=s._Square=s.asm.Square).apply(null,arguments)},py=s._SquaredDifference=function(){return(py=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},cy=s._Step=function(){return(cy=s._Step=s.asm.Step).apply(null,arguments)},dy=s._StridedSlice=function(){return(dy=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},hy=s._Sub=function(){return(hy=s._Sub=s.asm.Sub).apply(null,arguments)},my=s._Sum=function(){return(my=s._Sum=s.asm.Sum).apply(null,arguments)},fy=s._Tan=function(){return(fy=s._Tan=s.asm.Tan).apply(null,arguments)},gy=s._Tanh=function(){return(gy=s._Tanh=s.asm.Tanh).apply(null,arguments)},yy=s._Tile=function(){return(yy=s._Tile=s.asm.Tile).apply(null,arguments)},by=s._TopK=function(){return(by=s._TopK=s.asm.TopK).apply(null,arguments)},xy=s._Transform=function(){return(xy=s._Transform=s.asm.Transform).apply(null,arguments)},vy=s._Transpose=function(){return(vy=s._Transpose=s.asm.Transpose).apply(null,arguments)},wy=s.__FusedMatMul=function(){return(wy=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},ky=s._malloc=function(){return(ky=s._malloc=s.asm.malloc).apply(null,arguments)},Iy=s._free=function(){return(Iy=s._free=s.asm.free).apply(null,arguments)},Sy=s.___errno_location=function(){return(Sy=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},Ny=s._emscripten_main_thread_process_queued_calls=function(){return(Ny=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Ld=s.stackSave=function(){return(Ld=s.stackSave=s.asm.stackSave).apply(null,arguments)},zd=s.stackRestore=function(){return(zd=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},up=s.stackAlloc=function(){return(up=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},Ty=s.dynCall_iijjiiii=function(){return(Ty=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},Cy=s.dynCall_jiji=function(){return(Cy=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Ee;var Lo;function pp(G){this.name="ExitStatus",this.message="Program terminated with exit("+G+")",this.status=G}zr=function G(){Lo||cp(),Lo||(zr=G)};function cp(G){if(G=G||p,oa>0||(fd(),oa>0))return;function te(){Lo||(Lo=!0,s.calledRun=!0,!le&&(gd(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),yd()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),te()},1)):te()}s.run=cp;function o1(G){ue=G,np()||(s.onExit&&s.onExit(G),le=!0),c(G,new pp(G))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();cp();var zo;l&&(zo={uncaughtException:process.listeners("uncaughtException").filter(function(G){return!l.uncaughtException.indexOf(G)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(G){return!l.unhandledRejection.indexOf(G)>-1})});var Wo;if(typeof r!="undefined")Wo=r;else if(typeof WasmBackendModuleThreadedSimd!="undefined")Wo=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(zo){var _y=Wo._dispose;Wo._dispose=function(){_y(),zo.uncaughtException.forEach(function(G){process.removeListener("uncaughtException",G)}),zo.unhandledRejection.forEach(function(G){process.removeListener("unhandledRejection",G)})}}return r.ready}})();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModule=n)}),Gh=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}},Kp=class{refCount(e){return ua("refCount")}incRef(e){return ua("incRef")}timerAvailable(){return!0}time(e){return ua("time")}read(e){return ua("read")}readSync(e){return ua("readSync")}readToGPU(e,t){return ua("readToGPU")}numDataIds(){return ua("numDataIds")}disposeData(e,t){return ua("disposeData")}write(e,t,n){return ua("write")}move(e,t,n,a,r){return ua("move")}memory(){return ua("memory")}floatPrecision(){return ua("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return ua("dispose")}};function ua(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 Yk(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,gh(e,t,n)}function eF(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 n=e.length,a=0;for(;n>0;)a=Math.random()*n|0,n--,gh(e,n,a),gh(t,n,a)}function Fp(e,t,n){return Math.max(e,Math.min(t,n))}function tF(e){return e%2===0?e:e+1}function gh(e,t,n){let a=e[t];e[t]=e[n],e[n]=a}function nF(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function pi(e){R(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function js(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||dn(e)&&!n)for(let a=0;a0,n){return new Promise((a,r)=>{let s=0,i=()=>{if(e()){a();return}s++;let o=t(s);if(n!=null&&s>=n){r();return}setTimeout(i,o)};i()})}function pF(e,t){let n=1,a=-1;for(let s=0;s=0)n*=e[s];else if(e[s]===-1){if(a!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${a} and dim ${s}`);a=s}else if(e[s]<0)throw Error(`Shapes can not be < 0. Found ${e[s]} at dim ${s}`);if(a===-1){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(n===0)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);let r=e.slice();return r[a]=t/n,r}function Ta(e,t){let n=t.length;return e=e==null?t.map((a,r)=>r):[].concat(e),R(e.every(a=>a>=-n&&a`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),R(e.every(a=>tl(a)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(a=>a<0?n+a:a)}function Jk(e,t){let n=[],a=[],r=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||r?null:Ta(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(n.push(e[o]),a.push(o)),s[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),a.push(o))}return{newShape:n,keptDims:a}}function Qk(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return n}function Zk(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else if(e==="string")n=new Array(t);else throw new Error(`Unknown data type ${e}`);return n}function eI(e,t){for(let n=0;nt+=n.length),t}function Hr(e){return typeof e=="string"||e instanceof String}function aI(e){return typeof e=="boolean"}function rI(e){return typeof e=="number"}function Hh(e){return Array.isArray(e)?Hh(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":rI(e)?"float32":Hr(e)?"string":aI(e)?"bool":"float32"}function Jr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function yh(e,t){for(let n=t;n=0;--a)n[a]=n[a+1]*e[a+1];return n}function sI(e,t,n,a=!1){let r=new Array;if(t.length===1){let s=t[0]*(a?2:1);for(let i=0;il*u)*(a?2:1);for(let l=0;lr*s)*(n?2:1);if(a===0)return[];if(a!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return sI(0,e,t,n)}function Qb(e,t){let n=jh(e,t);for(let a=0;aa*r,1);if(t==null||t==="float32")return Yo(e,new Float32Array(n));if(t==="int32")return Yo(e,new Int32Array(n));if(t==="bool")return Yo(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function Zb(e){e.forEach(t=>{R(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function hF(e,t,n){if(t===0)return 0;if(t===1)return e[0];let a=e[e.length-1];for(let r=0;r{let[n,a]=t.split(":");this.urlFlags[n]=yF(n,a)})}};function fF(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...a)=>(gF(t,a[0],a[1]),a.join("="))),t}function gF(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function yF(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 X(){return tx}var tx=null;function bF(e){tx=e}var Py;function oI(){if(Py==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");Py=e}return Py}function xF(){let e=oI();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function nx(e,t){let n=xF();if(n.has(e))return n.get(e);{let a=t();return n.set(e,a),n.get(e)}}var fl="Abs",gl="Acos",yl="Acosh",us="Add",ci="AddN",bl="All",xl="Any",di="ArgMax",Xp="ArgMin",vl="Asin",wl="Asinh",kl="Atan",Il="Atanh",Sl="Atan2",hi="AvgPool",qh="AvgPoolGrad",Yp="AvgPool3D",Kh="AvgPool3DGrad",mi="BatchMatMul",Nl="BatchToSpaceND",Xh="Bincount",lI="BroadcastTo",Yh="BroadcastArgs",fi="Cast",gi="Ceil",ps="ClipByValue",Jh="Complex",Jp="ComplexAbs",Tl="Concat",yi="Conv2D",Qh="Conv2DBackpropFilter",bi="Conv2DBackpropInput",Qp="Conv3D",Zh="Conv3DBackpropFilterV2",em="Conv3DBackpropInputV2",xi="Cos",vi="Cosh",Cl="Cumprod",wi="Cumsum",_l="CropAndResize",tm="DenseBincount",El="DepthToSpace",ki="DepthwiseConv2dNative",nm="DepthwiseConv2dNativeBackpropFilter",am="DepthwiseConv2dNativeBackpropInput",rm="Diag",Zp="Dilation2D",bh="Dilation2DBackpropInput",xh="Dilation2DBackpropFilter",Ii="RealDiv",sm="Einsum",Si="Elu",im="EluGrad",Al="Erf",$l="Equal",Ni="Exp",Fl="ExpandDims",Dl="Expm1",om="FFT",ec="Fill",Rl="FlipLeftRight",Ti="Floor",Ci="FloorDiv",_i="FusedBatchNorm",Ml="GatherV2",Pl="GatherNd",Ol="Greater",Ei="GreaterEqual",Ai="Identity",lm="IFFT",um="Imag",Ll="IsFinite",zl="IsInf",Wl="IsNan",$i="LeakyRelu",Bl="Less",Vl="LessEqual",pm="LinSpace",Fi="Log",Ul="Log1p",Gl="LogicalAnd",tc="LogicalNot",nc="LogicalOr",uI="LogSoftmax",ac="LRN",cm="LRNGrad",Di="Max",Ri="Maximum",Mi="MaxPool",dm="MaxPoolGrad",rc="MaxPool3D",hm="MaxPool3DGrad",mm="MaxPoolWithArgmax",Pi="Mean",Oi="Min",Li="Minimum",zi="MirrorPad",Hl="Mod",fm="Multinomial",Wi="Multiply",jl="Neg",ql="NotEqual",Kl="NonMaxSuppressionV3",Xl="NonMaxSuppressionV4",Yl="NonMaxSuppressionV5",Jl="OnesLike",Bi="OneHot",Ql="Pack",Vi="PadV2",vF="Pool",Ui="Pow",Gi="Prelu",Zl="Prod",sc="Range",gm="Real",eu="Reciprocal",Hi="Relu",tu="Reshape",ic="ResizeNearestNeighbor",ym="ResizeNearestNeighborGrad",ji="ResizeBilinear",bm="ResizeBilinearGrad",qi="Relu6",Ki="Reverse",Xi="Round",Yi="Rsqrt",nu="ScatterNd",au="Select",ru="Selu",su="Slice",Ji="Sin",iu="Sinh",ou="Sign",Qi="Sigmoid",lu="Softplus",Zi="Sqrt",eo="Sum",uu="SpaceToBatchND",pu="SplitV",to="Softmax",oc="SparseFillEmptyRows",cu="SparseReshape",lc="SparseSegmentMean",uc="SparseSegmentSum",xm="SparseToDense",no="SquaredDifference",pc="Square",du="StridedSlice",vm="StringNGrams",wm="StringSplit",km="StringToHashBucketFast",ao="Sub",ro="Tan",so="Tanh",cs="Tile",hu="TopK",mu="Transform",io="Transpose",Im="Unique",fu="Unpack",cc="UnsortedSegmentSum",gu="ZerosLike",ds="Step",vh="FromPixels",yu="RotateWithOffset",qs="_FusedMatMul",Ks="FusedConv2D",Xs="FusedDepthwiseConv2D";function Gr(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.warn(...e)}function wF(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.log(...e)}var nl=nx("kernelRegistry",()=>new Map),Dp=nx("gradRegistry",()=>new Map);function wh(e,t){let n=ax(e,t);return nl.get(n)}function Qy(e){return Dp.get(e)}function kh(e){let t=nl.entries(),n=[];for(;;){let{done:a,value:r}=t.next();if(a)break;let[s,i]=r,[o]=s.split("_");o===e&&n.push(i)}return n}function dc(e){let{kernelName:t,backendName:n}=e,a=ax(t,n);nl.has(a)&&Gr(`The kernel '${t}' for backend '${n}' is already registered`),nl.set(a,e)}function pI(e){let{kernelName:t}=e;Dp.has(t)&&X().getBool("DEBUG")&&Gr(`Overriding the gradient for '${t}'`),Dp.set(t,e)}function kF(e,t){let n=ax(e,t);if(!nl.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);nl.delete(n)}function IF(e){if(!Dp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Dp.delete(e)}function SF(e,t){kh(e).forEach(n=>{let a=Object.assign({},n,{backendName:t});dc(a)})}function ax(e,t){return`${t}_${e}`}var k={};Re(k,{arraysEqual:()=>ls,assert:()=>R,assertNonNegativeIntegerDimensions:()=>Zb,assertNonNull:()=>pi,assertShapesMatch:()=>Nn,bytesFromStringArray:()=>nI,bytesPerElement:()=>Jy,checkConversionForErrors:()=>eI,clamp:()=>Fp,computeStrides:()=>ml,createScalarValue:()=>AF,createShuffledIndices:()=>lF,decodeString:()=>Ih,distSquared:()=>rF,encodeString:()=>mc,fetch:()=>FF,fingerPrint64:()=>EF,flatten:()=>js,getArrayFromDType:()=>Zk,getTypedArrayFromDType:()=>Qk,hasEncodingLoss:()=>cF,hexToLong:()=>hc,indexToLoc:()=>mF,inferDtype:()=>Hh,inferFromImplicitShape:()=>pF,isBoolean:()=>aI,isFunction:()=>Jr,isInt:()=>tl,isNumber:()=>rI,isPromise:()=>ex,isScalarShape:()=>sF,isString:()=>Hr,isTypedArray:()=>dn,isValidDtype:()=>tI,locToIndex:()=>hF,makeOnesTypedArray:()=>Qb,makeZerosNestedTypedArray:()=>dF,makeZerosTypedArray:()=>jh,nearestDivisor:()=>yh,nearestLargerEven:()=>tF,now:()=>Rp,parseAxisParam:()=>Ta,randUniform:()=>aF,repeatedTry:()=>uF,rightPad:()=>_p,shuffle:()=>Yk,shuffleCombo:()=>eF,sizeFromShape:()=>xt,sizeToSquarishShape:()=>oF,squeezeShape:()=>Jk,sum:()=>nF,swap:()=>gh,tanh:()=>iF,toNestedArray:()=>Yo,toTypedArray:()=>Sm});var b1=ui(F$()),Ps=b1.default||b1;function hc(e){return Ps.fromString(e,!0,16)}var cI=hc("c3a5c85c97cb3127"),Rs=hc("b492b66fbe98f273"),wn=hc("9ae16a3b2f90404f");function Zy(e){return e.xor(e.shru(47))}function dI(e,t,n){let a=e.slice(t,t+n);return Ps.fromBytes(Array.from(a),!0,!0)}function yt(e,t){return dI(e,t,8)}function x1(e,t){return dI(e,t,4)}function Qt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Kr(e,t,n=hc("9ddfea08eb382d69")){let a=e.xor(t).mul(n);a=a.xor(a.shru(47));let r=t.xor(a).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function NF(e,t,n,a,r,s){r=r.add(e),s=Qt(s.add(r).add(a),21);let i=r;return r=r.add(t),r=r.add(n),s=s.add(Qt(r,44)),[r.add(a),s.add(i)]}function qd(e,t,n,a){return NF(yt(e,t),yt(e,t+8),yt(e,t+16),yt(e,t+24),n,a)}function TF(e,t=e.length){if(t>=8){let n=wn.add(t*2),a=yt(e,0).add(wn),r=yt(e,t-8),s=Qt(r,37).mul(n).add(a),i=Qt(a,25).add(r).mul(n);return Kr(s,i,n)}if(t>=4){let n=wn.add(t*2),a=x1(e,0);return Kr(a.shl(3).add(t),x1(e,t-4),n)}if(t>0){let n=e[0],a=e[t>>1],r=e[t-1],s=n+(a<<8),i=t+(r<<2);return Zy(wn.mul(s).xor(cI.mul(i))).mul(wn)}return wn}function CF(e,t=e.length){let n=wn.add(t*2),a=yt(e,0).mul(Rs),r=yt(e,8),s=yt(e,t-8).mul(n),i=yt(e,t-16).mul(wn);return Kr(Qt(a.add(r),43).add(Qt(s,30)).add(i),a.add(Qt(r.add(wn),18)).add(s),n)}function _F(e,t=e.length){let n=wn.add(t*2),a=yt(e,0).mul(wn),r=yt(e,8),s=yt(e,t-8).mul(n),i=yt(e,t-16).mul(wn),o=Qt(a.add(r),43).add(Qt(s,30)).add(i),l=Kr(o,a.add(Qt(r.add(wn),18)).add(s),n),u=yt(e,16).mul(n),p=yt(e,24),d=o.add(yt(e,t-32)).mul(n),c=l.add(yt(e,t-24)).mul(n);return Kr(Qt(u.add(p),43).add(Qt(d,30)).add(c),u.add(Qt(p.add(a),18)).add(d),n)}function EF(e,t=e.length){let n=Ps.fromNumber(81,!0);if(t<=32)return t<=16?TF(e,t):CF(e,t);if(t<=64)return _F(e,t);let a=n,r=n.mul(Rs).add(113),s=Zy(r.mul(wn).add(113)).mul(wn),i=[Ps.UZERO,Ps.UZERO],o=[Ps.UZERO,Ps.UZERO];a=a.mul(wn).add(yt(e,0));let l=0,u=(t-1>>6)*64,p=u+(t-1&63)-63;do a=Qt(a.add(r).add(i[0]).add(yt(e,l+8)),37).mul(Rs),r=Qt(r.add(i[1]).add(yt(e,l+48)),42).mul(Rs),a=a.xor(o[1]),r=r.add(i[0]).add(yt(e,l+40)),s=Qt(s.add(o[0]),33).mul(Rs),i=qd(e,l,i[1].mul(Rs),a.add(o[0])),o=qd(e,l+32,s.add(o[1]),r.add(yt(e,l+16))),[s,a]=[a,s],l+=64;while(l!==u);let d=Rs.add(s.and(255).shl(1));return l=p,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),a=Qt(a.add(r).add(i[0]).add(yt(e,l+8)),37).mul(d),r=Qt(r.add(i[1]).add(yt(e,l+48)),42).mul(d),a=a.xor(o[1].mul(9)),r=r.add(i[0].mul(9).add(yt(e,l+40))),s=Qt(s.add(o[0]),33).mul(d),i=qd(e,l,i[1].mul(d),a.add(o[0])),o=qd(e,l+32,s.add(o[1]),r.add(yt(e,l+16))),[s,a]=[a,s],Kr(Kr(i[0],o[0],d).add(Zy(r).mul(cI)).add(s),Kr(i[1],o[1],d).add(a),d)}function AF(e,t){return t==="string"?mc(e):Sm([e],t)}function $F(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Sm(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=js(e)),X().getBool("DEBUG")&&eI(e,t),$F(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 n=new Uint8Array(e.length);for(let a=0;a{a=n()},s,i=Rp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(r);else{r();for(let o of a)o.dataSync();s=Promise.resolve({kernelMs:Rp()-i})}if(X().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{RF(u,l.dtype,e)})}return{kernelName:e,outputs:a,inputs:t,timeMs:s.then(o=>o.kernelMs),extraInfo:s.then(o=>o.getExtraProfileInfo!=null?o.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:a,inputs:r,extraInfo:s}=e;n.forEach(i=>{Promise.all([i.data(),a,s]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function RF(e,t,n){if(t!=="float32")return!1;for(let a=0;a0?m:""} `}}console.log(`%c${o} %c${i} %c${l}D ${p} %c${u} %c${d} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function PF(e,t,n){let a={},r={};for(let l=0;la[f.id]=!0),h=!0,r[u.id]=!0;break}if(h)break}}let s={};s[n.id]=!0;let i={};for(let l=e.length-1;l>=0;l--){let u=e[l],p=u.inputs;for(let d=0;d=0;r--){let s=t[r],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=n(()=>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 p=s.inputs[l];if(!ls(u.shape,p.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 '${p.shape}'`);if(e[p.id]==null)e[p.id]=u;else{let d=e[p.id];e[p.id]=a(d,u),d.dispose()}}}}var v1=20,mp=3,Oy=7;function LF(e,t,n,a){let r=ml(t),s=zF(e,t,n,r),i=t.length,o=rh(e,t,n,r,s),l=["Tensor"];return a&&(l.push(` dtype: ${n}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map(u=>" "+u).join(` `)),l.join(` `)}function zF(e,t,n,a){let r=xt(t),s=a[a.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?xp(e):e;if(o>1)for(let u=0;uv1){let g=mp*i,y=Array.from(e.slice(0,g)),b=Array.from(e.slice((o-mp)*i,o*i));return n==="complex64"&&(y=xp(y),b=xp(b)),["["+y.map((x,v)=>bp(x,r[v],n)).join(", ")+", ..., "+b.map((x,v)=>bp(x,r[o-mp+v],n)).join(", ")+"]"]}let f=n==="complex64"?xp(e):Array.from(e);return["["+f.map((g,y)=>bp(g,r[y],n)).join(", ")+"]"]}let u=t.slice(1),p=a.slice(1),d=a[0]*i,c=[];if(o>v1){for(let f=0;f`Length of values '${a}' 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=n||Zk(t,this.size),this.strides=ml(e)}set(e,...t){t.length===0&&(t=[0]),R(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let a of e){if(a<0||a>=this.shape[t]){let r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let n=e[e.length-1];for(let a=0;aIh(n))}catch(n){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=>Ih(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 qo.print(this,e)}clone(){return this.throwIfDisposed(),qo.clone(this)}toString(e=!1){let t=this.dataSync();return LF(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),qo.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),La().makeVariable(this,e,t,n)}};Object.defineProperty(Ae,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ne(){return nx("Tensor",()=>Ae)}ne();var Qr=class extends Ae{constructor(e,t,n,a){super(e.shape,e.dtype,e.dataId,a);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!ls(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(Qr,Symbol.hasInstance,{value:e=>e instanceof Ae&&e.assign!=null&&e.assign instanceof Function});var Va={};Re(Va,{assertTypesMatch:()=>mI,getTensorsInContainer:()=>rx,isTensorInList:()=>HF,makeTypesMatch:()=>$t});var eb;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(eb||(eb={}));var tb;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(tb||(tb={}));var nb;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(nb||(nb={}));var ab;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(ab||(ab={}));var rb;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(rb||(rb={}));var GF={float32:ab,int32:tb,bool:nb,complex64:rb};function ma(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return GF[e][t]}function Nm(e){return ma(e,"int32")}function $t(e,t){if(e.dtype===t.dtype)return[e,t];let n=ma(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function mI(e,t){R(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function HF(e,t){return t.some(n=>n.id===e.id)}function rx(e){let t=[];return fI(e,t,new Set),t}function fI(e,t,n){if(e==null)return;if(e instanceof Ae){t.push(e);return}if(!jF(e))return;let a=e;for(let r in a){let s=a[r];n.has(s)||(n.add(s),fI(s,t,n))}}function jF(e){return Array.isArray(e)||typeof e=="object"}function Ly(e){return e.kernelName!=null}var w1=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()}},Mp=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new w1}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){kh(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 n=t.factory();if(n&&!(n instanceof Kp)&&typeof n.then=="function"){let a=++this.pendingBackendInitId,r=n.then(s=>a(athis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(n),()=>this.endScope(a),()=>(a=t(),a instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),a))}scopedRun(e,t,n){e();try{let a=n();return t(),a}catch(a){throw t(),a}}nextTensorId(){return Mp.nextTensorId++}nextVariableId(){return Mp.nextVariableId++}clone(e){let t=L.runKernel(Ai,{x:e}),n={x:e},a=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return L.runKernel(fi,o,l)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],a,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,wh(e,this.backendName)==null)throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){let a=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype==="complex64"?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=a-t-r-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,n=[],a=this.isTapeOn(),r=this.state.numBytes,s=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,l=Ly(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Ly(e)){let{kernelName:h,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=wh(h,this.backendName);R(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let y=this.backend.numDataIds();o=g.kernelFunc({inputs:m,attrs:f,backend:this.backend});let b=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,y,b);let x=b.map(v=>{if(v.rank!=null)return v;let{dataId:w,shape:T,dtype:C}=v;return this.makeTensorFromDataId(w,T,C)});if(a){let v=this.getTensorsForGradient(h,m,x);n=this.saveTensorsForBackwardMode(v)}return x}}else{let{forwardFunc:h}=e,m=f=>{!a||(n=f.map(g=>this.keep(this.clone(g))))};i=()=>{let f=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,m));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,f,g),g}}let{inputs:u,attrs:p}=e,d=Ly(e)?null:e.backwardsFunc,c;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(c=this.profiler.profileKernel(l,u,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(c),t=c.outputs)}),a&&this.addTapeNode(l,u,t,d,n,p),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(h=>u[h]!=null?u[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:c.timeMs,extraInfo:c.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(e,t,n){let a=Qy(e);if(a!=null){let r=a.inputsToSave||[],s=a.outputsToSave||[],i;a.saveAllInputs?(R(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=r.map(l=>t[l]);let o=n.filter((l,u)=>s[u]);return i.concat(o)}return[]}makeTensor(e,t,n,a){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",a=a||this.backend;let r=e;n==="string"&&Hr(e[0])&&(r=e.map(o=>mc(o)));let s=a.write(r,t,n),i=new Ae(t,n,s,this.nextTensorId());if(this.trackTensor(i,a),n==="string"){let o=this.state.tensorInfo.get(s),l=nI(r);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,n,a){n=n||"float32";let r=new Ae(t,n,e,this.nextTensorId());return this.trackTensor(r,a),r}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),a!=null&&a!==e.dtype&&(e=e.cast(a));let r=new Qr(e,t,n,this.nextTensorId());if(this.state.registeredVariables[r.name]!=null)throw new Error(`Variable with name ${r.name} was already registered`);return this.state.registeredVariables[r.name]=r,this.incRef(r,this.backend),r}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let n=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(n=e.size*Jy(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Qr||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 n=e.size*Jy(e.dtype);this.state.numBytes-=n}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,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(a=>a.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let a of this.state.activeProfile.kernels)a.kernelTimeMs=await a.kernelTimeMs,a.extraInfo=await a.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,a,r,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},o=Qy(e);o!=null&&(a=o.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((u,p)=>{if(u==null){let d=n[p],c=jh(d.size,d.dtype);return this.makeTensor(c,d.shape,d.dtype)}return u}),a(l.length>1?l:l[0],r,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=rx(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===a.id&&this.track(r)})}gradients(e,t,n,a=!1){if(R(t.length>0,()=>"gradients() received an empty list of xs."),n!=null&&n.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);let r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));R(r instanceof Ae,()=>"The result y returned by f() must be a tensor.");let s=PF(this.state.activeTape,t,r);if(!a&&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[r.id]=n==null?qF(r.shape):n,OF(i,s,l=>this.tidy(l),KF);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:r,grads:o}})}customGrad(e){return R(Jr(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{R(t.every(i=>i instanceof Ae),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,a={};t.forEach((i,o)=>{a[o]=i});let r=(i,o)=>(n=e(...t,o),R(n.value instanceof Ae,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),R(Jr(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),s=(i,o)=>{let l=n.gradFunc(i,o),u=Array.isArray(l)?l:[l];R(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(...)."),R(u.every(d=>d instanceof Ae),()=>"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 p={};return u.forEach((d,c)=>{p[c]=()=>d}),p};return this.runKernelFunc({forwardFunc:r,backwardsFunc:s,inputs:a})}}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=Rp(),n=await this.backend.time(e);return n.wallMs=Rp()-t,n}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 w1;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}};Mp.nextTensorId=0;Mp.nextVariableId=0;function qF(e){let t=Qb(xt(e),"float32");return L.makeTensor(t,e,"float32")}function gI(){let e=oI();if(e._tfengine==null){let t=new iI(e);e._tfengine=new Mp(t)}return bF(e._tfengine.ENV),BF(()=>e._tfengine),e._tfengine}var L=gI();function KF(e,t){let n={a:e,b:t};return L.runKernel(us,n)}var fc={};Re(fc,{isBrowser:()=>yI,isMobile:()=>JF,mockIsMobile:()=>YF});function XF(){return typeof navigator!="undefined"&&navigator!=null}var sb;function YF(e){sb=e}function JF(e){if(sb!==void 0)return sb;if(e||XF()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let n=e;return n.userAgentData&&n.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 yI(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Sa=X();Sa.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.")});Sa.registerFlag("IS_BROWSER",()=>yI());Sa.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Sa.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Sa.registerFlag("PROD",()=>!1);Sa.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Sa.getBool("DEBUG"));Sa.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Sa.registerFlag("IS_TEST",()=>!1);Sa.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Sa.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Sa.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function lr(e,t){let n=e;if(dn(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let a=[];for(;Array.isArray(n)||dn(n)&&t!=="string";)a.push(n.length),n=n[0];return Array.isArray(e)&&X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&bI(e,a,[]),a}function bI(e,t,n){if(n=n||[],!Array.isArray(e)&&!dn(e)){R(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}R(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),R(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let a=t.slice(1);for(let r=0;r=0&&(r=a),k1(a,r,t,n),e==null||!dn(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 '${n}' must be a Tensor or TensorLike, but got '${o}'`)}let s=lr(e,r);!dn(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Sm(e,r):js(e,[],!0);return L.makeTensor(i,s,r)}function Pp(e,t,n,a="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((r,s)=>A(r,`${t}[${s}]`,n,a))}var xI="__op";function z(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 n=t[0],a=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+xI;let r=(...s)=>{L.startScope(n);try{let i=a(...s);return ex(i)&&console.error("Cannot return a Promise inside of tidy."),L.endScope(i),i}catch(i){throw L.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function QF(e,t){let n=A(e,"real","complex"),a=A(t,"imag","complex");Nn(n.shape,a.shape,`real and imag shapes, ${n.shape} and ${a.shape}, must match in call to tf.complex().`);let r={real:n,imag:a};return L.runKernel(Jh,r)}var Zr=z({complex_:QF});function hs(e,t,n,a){if(a==null&&(a=Hh(e)),a==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!dn(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){Zb(t);let r=xt(t),s=xt(n);R(r===s,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${s}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!dn(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=a!=="string"?Sm(e,a):js(e,[],!0),L.makeTensor(e,t,a)}function Qn(e,t,n){let a=lr(e,n);return hs(e,t,a,n)}var ib={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Sh=4;async function ZF(e,t){let n=[],a=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let c=await l.bytes(),h=c.reduce((g,y)=>g+y.length,0)+Sh*c.length,m=new Uint8Array(h),f=0;for(let g=0;g{if(t+=s.byteLength,n.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 a=new Uint8Array(t),r=0;return n.forEach(s=>{a.set(new Uint8Array(s.buffer),r),r+=s.byteLength}),a.buffer}var sx=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function I1(e){return sx?Buffer.byteLength(e):new Blob([e]).size}function tD(e){if(sx)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let a=0,r=t.length;a{t+=r.byteLength});let n=new Uint8Array(t),a=0;return e.forEach(r=>{n.set(new Uint8Array(r),a),a+=r.byteLength}),n.buffer}function S1(e){let t="/";for(e=e.trim();e.endsWith(t);)e=e.slice(0,e.length-1);let n=e.split(t);return n[n.length-1]}function wI(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),n}async function ox(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),e.weightsManifest!=null){let[a,r]=await t(e.weightsManifest);n.weightSpecs=a,n.weightData=r}return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),n}function gc(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:I1(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:I1(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function aD(){let e=n=>{let a=n<<13,r=0;for(;(a&8388608)===0;)r-=8388608,a<<=1;return a&=-8388609,r+=947912704,a|r},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let n=1024;n<2048;n++)t[n]=939524096+(n-1024<<13);return t}function rD(){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 sD(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function iD(){let e=aD(),t=rD(),n=sD();return a=>{let r=new ArrayBuffer(4*a.length),s=new Uint32Array(r);for(let i=0;i>10]+(o&1023)]+t[o>>10];s[i]=l}return new Float32Array(r)}}var Dt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Dt.instance==null&&(Dt.instance=new Dt),Dt.instance}static registerSaveRouter(e){Dt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Dt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Dt.getHandlers(e,"save")}static getLoadHandlers(e,t){return Dt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let a=[];return(t==="load"?Dt.getInstance().loadRouters:Dt.getInstance().saveRouters).forEach(r=>{let s=r(e,n);s!==null&&a.push(s)}),a}},oD=e=>Dt.registerSaveRouter(e),lD=e=>Dt.registerLoadRouter(e),uD=e=>Dt.getSaveHandlers(e),pD=(e,t)=>Dt.getLoadHandlers(e,t),ob="tensorflowjs",lb=1,Ws="models_store",jr="model_info_store";function kI(){if(!X().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 ub(e){let t=e.result;t.createObjectStore(Ws,{keyPath:"modelPath"}),t.createObjectStore(jr,{keyPath:"modelPath"})}var Ys=class{constructor(e){if(this.indexedDB=kI(),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((n,a)=>{let r=this.indexedDB.open(ob,lb);r.onupgradeneeded=()=>ub(r),r.onsuccess=()=>{let s=r.result;if(t==null){let i=s.transaction(Ws,"readonly"),o=i.objectStore(Ws).get(this.modelPath);o.onsuccess=()=>{if(o.result==null)return s.close(),a(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(o.result.modelArtifacts)},o.onerror=l=>(s.close(),a(o.error)),i.oncomplete=()=>s.close()}else{let i=gc(t),o=s.transaction(jr,"readwrite"),l=o.objectStore(jr),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),p;u.onsuccess=()=>{p=s.transaction(Ws,"readwrite");let d=p.objectStore(Ws).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=c=>{l=o.objectStore(jr);let h=l.delete(this.modelPath);h.onsuccess=()=>(s.close(),a(d.error)),h.onerror=m=>(s.close(),a(d.error))}},u.onerror=d=>(s.close(),a(u.error)),o.oncomplete=()=>{p==null?s.close():p.oncomplete=()=>s.close()}}},r.onerror=s=>a(r.error)})}};Ys.URL_SCHEME="indexeddb://";var II=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ys.URL_SCHEME)?cD(e.slice(Ys.URL_SCHEME.length)):null;Dt.registerSaveRouter(II);Dt.registerLoadRouter(II);function cD(e){return new Ys(e)}function dD(e){return e.startsWith(Ys.URL_SCHEME)?e.slice(Ys.URL_SCHEME.length):e}var hD=class{constructor(){this.indexedDB=kI()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(ob,lb);n.onupgradeneeded=()=>ub(n),n.onsuccess=()=>{let a=n.result,r=a.transaction(jr,"readonly"),s=r.objectStore(jr).getAll();s.onsuccess=()=>{let i={};for(let o of s.result)i[o.modelPath]=o.modelArtifactsInfo;e(i)},s.onerror=i=>(a.close(),t(s.error)),r.oncomplete=()=>a.close()},n.onerror=a=>t(n.error)})}async removeModel(e){return e=dD(e),new Promise((t,n)=>{let a=this.indexedDB.open(ob,lb);a.onupgradeneeded=()=>ub(a),a.onsuccess=()=>{let r=a.result,s=r.transaction(jr,"readwrite"),i=s.objectStore(jr),o=i.get(e),l;o.onsuccess=()=>{if(o.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=i.delete(e),p=()=>{l=r.transaction(Ws,"readwrite");let d=l.objectStore(Ws).delete(e);d.onsuccess=()=>t(o.result.modelArtifactsInfo),d.onerror=c=>n(o.error)};u.onsuccess=p,u.onerror=d=>(p(),r.close(),n(o.error))}},o.onerror=u=>(r.close(),n(o.error)),s.oncomplete=()=>{l==null?r.close():l.oncomplete=()=>r.close()}},a.onerror=r=>n(a.error)})}},kr="/",Ko="tensorflowjs_models",SI="info",mD="model_topology",fD="weight_specs",gD="weight_data",yD="model_metadata";function NI(e){return{info:[Ko,e,SI].join(kr),topology:[Ko,e,mD].join(kr),weightSpecs:[Ko,e,fD].join(kr),weightData:[Ko,e,gD].join(kr),modelMetadata:[Ko,e,yD].join(kr)}}function TI(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function bD(e){let t=e.split(kr);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(kr)}function xD(e){return e.startsWith(Js.URL_SCHEME)?e.slice(Js.URL_SCHEME.length):e}var Js=class{constructor(e){if(!X().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=NI(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),n=JSON.stringify(e.weightSpecs),a=gc(e);try{this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,tD(e.weightData));let r={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(r)),{modelArtifactsInfo:a}}catch(r){throw TI(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=${a.modelTopologyBytes}, weightSpecsBytes=${a.weightSpecsBytes}, weightDataBytes=${a.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={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(n==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;let a=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(a==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=a;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let i=JSON.parse(r);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=nD(s),t}};Js.URL_SCHEME="localstorage://";var CI=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Js.URL_SCHEME)?vD(e.slice(Js.URL_SCHEME.length)):null;Dt.registerSaveRouter(CI);Dt.registerLoadRouter(CI);function vD(e){return new Js(e)}var wD=class{constructor(){R(X().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),R(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Ko+kr,n=kr+SI;for(let a=0;a"scheme must not be undefined or null."),e.endsWith(Jo)&&(e=e.slice(0,e.indexOf(Jo))),R(e.length>0,()=>"scheme must not be an empty string.");let n=pa.getInstance();R(n.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),n.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 sh(e){if(e.indexOf(Jo)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${pa.getSchemes().join(",")}`);return{scheme:e.split(Jo)[0],path:e.split(Jo)[1]}}async function _I(e,t,n=!1){R(e!==t,()=>`Old path and new path are the same: '${e}'`);let a=Dt.getLoadHandlers(e);R(a.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),R(a.length<2,()=>`Copying failed because more than one (${a.length}) load handlers for source URL ${e}.`);let r=a[0],s=Dt.getSaveHandlers(t);R(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),R(s.length<2,()=>`Copying failed because more than one (${a.length}) save handlers for destination URL ${t}.`);let i=s[0],o=sh(e).scheme,l=sh(e).path,u=o===sh(e).scheme,p=await r.load();n&&u&&await pa.getManager(o).removeModel(l);let d=await i.save(p);return n&&!u&&await pa.getManager(o).removeModel(l),d.modelArtifactsInfo}async function kD(){let e=pa.getSchemes(),t={};for(let n of e){let a=await pa.getManager(n).listModels();for(let r in a){let s=n+Jo+r;t[s]=a[r]}}return t}async function ID(e){let t=sh(e);return pa.getManager(t.scheme).removeModel(t.path)}async function SD(e,t){return _I(e,t,!1)}async function ND(e,t){return _I(e,t,!0)}var TD=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(X().get("IS_BROWSER")){X().setPlatform("browser",new TD);try{pa.registerManager(Js.URL_SCHEME,new wD)}catch(e){}try{pa.registerManager(Ys.URL_SCHEME,new hD)}catch(e){}}var CD={importFetch:()=>D$()},zy,_D=class{constructor(){this.util=R$(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(zy==null&&(zy=CD.importFetch()),zy(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)}};X().get("IS_NODE")&&!X().get("IS_BROWSER")&&X().setPlatform("node",new _D);function He(e,t="float32",n){return t=t||"float32",Zb(e),new jt(e,t,n)}function ED(e,t){let n=A(e,"x","cast");if(!tI(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&n.dtype!=="string"||t!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");let a={x:n},r={dtype:t};return L.runKernel(fi,a,r)}var oe=z({cast_:ED});function AD(e){let t={x:A(e,"x","clone","string_or_numeric")};return L.runKernel(Ai,t)}var Sr=z({clone_:AD});function EI(e,t=!1){console.log(e.toString(t))}gI();var $D={buffer:He,cast:oe,clone:Sr,print:EI};VF($D);var Zt={};Re(Zt,{browserFiles:()=>LD,browserHTTPRequest:()=>UD,concatenateArrayBuffers:()=>ix,copyModel:()=>SD,decodeWeights:()=>vI,encodeWeights:()=>ZF,fromMemory:()=>HD,getLoadHandlers:()=>pD,getModelArtifactsForJSON:()=>ox,getModelArtifactsInfoForJSON:()=>gc,getSaveHandlers:()=>uD,http:()=>ux,isHTTPScheme:()=>pb,listModels:()=>kD,loadWeights:()=>zD,moveModel:()=>ND,registerLoadRouter:()=>lD,registerSaveRouter:()=>oD,removeModel:()=>ID,weightsLoaderFactory:()=>$I,withSaveHandler:()=>jD});var FD="model",DD=".json",RD=".weights.bin";function N1(e){return new Promise(t=>setTimeout(t)).then(e)}var al=class{constructor(e){if(!X().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(al.URL_SCHEME)&&(e=e.slice(al.URL_SCHEME.length)),(e==null||e.length===0)&&(e=FD),this.modelJsonFileName=e+DD,this.weightDataFileName=e+RD}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 n=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],a=wI(e,n),r=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),s=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=r,await N1(()=>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 N1(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:gc(e)}}}};al.URL_SCHEME="downloads://";var MD=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 n=new FileReader;n.onload=a=>{let r=JSON.parse(a.target.result),s=r.modelTopology;if(s==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(r.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=ox(r,o=>this.loadWeights(o));e(i)},n.onerror=a=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)})}loadWeights(e){let t=[],n=[];for(let s of e)t.push(...s.weights),n.push(...s.paths);let a=this.checkManifestAndWeightFiles(e),r=n.map(s=>this.loadWeightsFile(s,a[s]));return Promise.all(r).then(s=>[t,ix(s)])}loadWeightsFile(e,t){return new Promise((n,a)=>{let r=new FileReader;r.onload=s=>{let i=s.target.result;n(i)},r.onerror=s=>a(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>S1(r.name)),a={};for(let r of e)r.paths.forEach(s=>{let i=S1(s);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),n.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);a[s]=this.weightsFiles[n.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 a}},PD=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(al.URL_SCHEME)?OD(e.slice(al.URL_SCHEME.length)):null;Dt.registerSaveRouter(PD);function OD(e="model"){return new al(e)}function LD(e){return new MD(e)}function T1(e,t,n,a){i(e),n=n==null?0:n,a=a==null?1:a,o(n,a);let r=0,s=l=>(l.then(u=>{let p=n+ ++r/e.length*(a-n);return t(p),u}),l);function i(l){R(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function o(l,u){R(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),R(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),R(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(s))}async function AI(e,t){t==null&&(t={});let n=t.fetchFunc==null?X().platform.fetch:t.fetchFunc,a=e.map(u=>n(u,t.requestInit,{isBinary:!0})),r=0,s=.5,i=(t.onProgress==null?await Promise.all(a):await T1(a,t.onProgress,r,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await T1(i,t.onProgress,o,l)}async function zD(e,t="",n,a){return $I(r=>AI(r,{requestInit:a}))(e,t,n)}function $I(e){return async(t,n="",a)=>{let r=t.map(()=>!1),s={},i=a!=null?a.map(()=>!1):[],o=[];if(t.forEach((h,m)=>{let f=0;h.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,b=ib[y]*xt(g.shape),x=()=>{r[m]=!0,s[m]==null&&(s[m]=[]),s[m].push({manifestEntry:g,groupOffset:f,sizeBytes:b})};a!=null?a.forEach((v,w)=>{v===g.name&&(x(),i[w]=!0)}):x(),o.push(g.name),f+=b})}),!i.every(h=>h)){let h=a.filter((m,f)=>!i[f]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=r.reduce((h,m,f)=>(m&&h.push(f),h),[]),u=[];l.forEach(h=>{t[h].paths.forEach(m=>{let f=n+(n.endsWith("/")?"":"/")+m;u.push(f)})});let p=await e(u),d={},c=0;return l.forEach(h=>{let m=t[h].paths.length,f=0;for(let x=0;x{let v=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),w=vI(v,[x.manifestEntry]);for(let T in w)d[T]=w[T]}),c+=m}),d}}var WD="application/octet-stream",BD="application/json",lx=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?(R(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=X().platform.fetch,R(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&R(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 n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],a=wI(e,n);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:BD}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:WD}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:gc(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.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(r){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 n=t.modelTopology,a=t.weightsManifest;if(n==null&&a==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return ox(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=VD(t),r=this.weightPathPrefix||n,s=[];for(let u of e)s.push(...u.weights);let i=[],o=[];for(let u of e)for(let p of u.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(p)):i.push(r+p+a);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await AI(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,ix(l)]}};lx.URL_SCHEME_REGEX=/^https?:\/\//;function VD(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function pb(e){return e.match(lx.URL_SCHEME_REGEX)!=null}var FI=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(a=>pb(a)):n=pb(e),n)return ux(e,t)}return null};Dt.registerSaveRouter(FI);Dt.registerLoadRouter(FI);function ux(e,t){return new lx(e,t)}function UD(e,t){return ux(e,t)}var Wy=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},GD=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function HD(e,t,n,a){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new Wy(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 Wy({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 Wy({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:a}))}function jD(e){return new GD(e)}var DI={};Re(DI,{confusionMatrix:()=>JD});function qD(e,t,n=!1,a=!1){let r=A(e,"a","matMul"),s=A(t,"b","matMul");[r,s]=$t(r,s);let i={a:r,b:s},o={transposeA:n,transposeB:a};return L.runKernel(mi,i,o)}var Fe=z({matMul_:qD});function KD(e,t,n=1,a=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let r={indices:A(e,"indices","oneHot","int32")},s={depth:t,onValue:n,offValue:a};return L.runKernel(Bi,r,s)}var rl=z({oneHot_:KD});function XD(e,t){let n=A(e,"x","transpose");if(t==null&&(t=n.shape.map((s,i)=>i).reverse()),R(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(s=>{R(s>=0&&s`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},r={perm:t};return L.runKernel(io,a,r)}var Me=z({transpose_:XD});function YD(e,t,n){let a=A(e,"labels","confusionMatrix"),r=A(t,"predictions","confusionMatrix");R(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),R(a.rank===1,()=>`Expected the rank of labels to be 1, but got ${a.rank}`),R(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),R(a.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${a.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),R(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let s=rl(oe(a,"int32"),n),i=rl(oe(r,"int32"),n),o=Me(s),l=Fe(o,i);return oe(l,"int32")}var JD=z({confusionMatrix_:YD}),bu={};Re(bu,{assertAndGetBroadcastShape:()=>dt,getBroadcastDims:()=>RI,getReductionAxes:()=>Bt});function RI(e,t){let n=e.length,a=[];for(let r=0;r1&&i===1&&a.unshift(s)}return a}function Bt(e,t){let n=[];for(let a=0;a1)&&n.unshift(s)}return n}function dt(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;rrR,fromPixelsAsync:()=>nR,toPixels:()=>aR});function Tm(e,t,n){if(pi(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let a=lr(e,n);if(a.length!==3&&a.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return hs(e,t,a,n)}var Fs;function MI(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 n=!1,a=!1,r=!1,s=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)a=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)r=!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(r&&r&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the