/* Face-API homepage: author: ' */ var E$=Object.defineProperty;var A$=(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 nb=(e,t)=>{for(var n in t)E$(e,n,{get:t[n],enumerable:!0})};var ze={};nb(ze,{Abs:()=>Il,Acos:()=>Sl,Acosh:()=>Nl,AdadeltaOptimizer:()=>cf,AdagradOptimizer:()=>df,AdamOptimizer:()=>hf,AdamaxOptimizer:()=>mf,Add:()=>ds,AddN:()=>xi,All:()=>Tl,Any:()=>Cl,ArgMax:()=>vi,ArgMin:()=>lc,Asin:()=>_l,Asinh:()=>El,Atan:()=>Al,Atan2:()=>Fl,Atanh:()=>$l,AvgPool:()=>wi,AvgPool3D:()=>uc,AvgPool3DGrad:()=>nm,AvgPoolGrad:()=>tm,BackendWasm:()=>RE,BatchMatMul:()=>ki,BatchToSpaceND:()=>Dl,Bincount:()=>am,BroadcastArgs:()=>rm,BroadcastTo:()=>lI,Callback:()=>cN,CallbackList:()=>f2,Cast:()=>Ii,Ceil:()=>Si,ClipByValue:()=>hs,Complex:()=>sm,ComplexAbs:()=>pc,Concat:()=>Rl,Conv2D:()=>Ni,Conv2DBackpropFilter:()=>im,Conv2DBackpropInput:()=>Ti,Conv3D:()=>cc,Conv3DBackpropFilterV2:()=>om,Conv3DBackpropInputV2:()=>lm,Cos:()=>Ci,Cosh:()=>_i,CropAndResize:()=>Pl,Cumprod:()=>Ml,Cumsum:()=>Ei,CustomCallback:()=>y2,DataStorage:()=>Zh,DenseBincount:()=>um,DepthToSpace:()=>Ol,DepthwiseConv2dNative:()=>Ai,DepthwiseConv2dNativeBackpropFilter:()=>pm,DepthwiseConv2dNativeBackpropInput:()=>cm,Diag:()=>dm,Dilation2D:()=>dc,Dilation2DBackpropFilter:()=>Nh,Dilation2DBackpropInput:()=>Sh,ENV:()=>wx,EarlyStopping:()=>dN,Einsum:()=>hm,Elu:()=>Fi,EluGrad:()=>mm,Environment:()=>iI,Equal:()=>zl,Erf:()=>Ll,Exp:()=>Di,ExpandDims:()=>Bl,Expm1:()=>Wl,FFT:()=>fm,Fill:()=>hc,FlipLeftRight:()=>Vl,Floor:()=>Ri,FloorDiv:()=>Mi,FromPixels:()=>Th,FusedBatchNorm:()=>Pi,FusedConv2D:()=>ni,FusedDepthwiseConv2D:()=>ai,GPGPUContext:()=>xh,GatherNd:()=>Gl,GatherV2:()=>Ul,GraphModel:()=>PN,Greater:()=>Hl,GreaterEqual:()=>Oi,History:()=>g2,IFFT:()=>gm,Identity:()=>Li,Imag:()=>ym,InputSpec:()=>Bt,IsFinite:()=>jl,IsInf:()=>ql,IsNan:()=>Kl,KernelBackend:()=>oc,LRN:()=>gc,LRNGrad:()=>xm,LayerVariable:()=>l2,LayersModel:()=>Tr,LeakyRelu:()=>zi,Less:()=>Xl,LessEqual:()=>Yl,LinSpace:()=>bm,Log:()=>Bi,Log1p:()=>Jl,LogSoftmax:()=>uI,LogicalAnd:()=>Zl,LogicalNot:()=>mc,LogicalOr:()=>fc,MathBackendWebGL:()=>zf,Max:()=>Wi,MaxPool:()=>Ui,MaxPool3D:()=>yc,MaxPool3DGrad:()=>wm,MaxPoolGrad:()=>vm,MaxPoolWithArgmax:()=>km,Maximum:()=>Vi,Mean:()=>Gi,Min:()=>Hi,Minimum:()=>ji,MirrorPad:()=>qi,Mod:()=>Ql,MomentumOptimizer:()=>ff,Multinomial:()=>Im,Multiply:()=>Ki,Neg:()=>eu,NonMaxSuppressionV3:()=>nu,NonMaxSuppressionV4:()=>au,NonMaxSuppressionV5:()=>ru,NotEqual:()=>tu,OP_SCOPE_SUFFIX:()=>xI,OneHot:()=>Xi,OnesLike:()=>su,Optimizer:()=>Ar,OptimizerConstructors:()=>Hr,Pack:()=>iu,PadV2:()=>Yi,Pool:()=>NF,Pow:()=>Ji,Prelu:()=>Zi,Prod:()=>Qi,RMSPropOptimizer:()=>gf,RNN:()=>fr,Range:()=>bc,Rank:()=>vb,Real:()=>Sm,RealDiv:()=>$i,Reciprocal:()=>ou,Reduction:()=>kn,Relu:()=>eo,Relu6:()=>no,Reshape:()=>lu,ResizeBilinear:()=>to,ResizeBilinearGrad:()=>Tm,ResizeNearestNeighbor:()=>xc,ResizeNearestNeighborGrad:()=>Nm,Reverse:()=>ao,RotateWithOffset:()=>Su,Round:()=>ro,Rsqrt:()=>so,SGDOptimizer:()=>Bc,ScatterNd:()=>uu,Select:()=>pu,Selu:()=>cu,Sequential:()=>gl,Sigmoid:()=>oo,Sign:()=>mu,Sin:()=>io,Sinh:()=>hu,Slice:()=>du,Softmax:()=>po,Softplus:()=>fu,SpaceToBatchND:()=>gu,SparseFillEmptyRows:()=>vc,SparseReshape:()=>bu,SparseSegmentMean:()=>wc,SparseSegmentSum:()=>kc,SparseToDense:()=>Cm,SplitV:()=>yu,Sqrt:()=>lo,Square:()=>Ic,SquaredDifference:()=>co,Step:()=>fs,StridedSlice:()=>xu,StringNGrams:()=>_m,StringSplit:()=>Em,StringToHashBucketFast:()=>Am,Sub:()=>ho,Sum:()=>uo,SymbolicTensor:()=>Ua,Tan:()=>mo,Tanh:()=>fo,Tensor:()=>Ae,TensorBuffer:()=>jt,Tile:()=>ms,TopK:()=>vu,Transform:()=>wu,Transpose:()=>go,Unique:()=>$m,Unpack:()=>ku,UnsortedSegmentSum:()=>Sc,Variable:()=>ts,ZerosLike:()=>Iu,_FusedMatMul:()=>ti,abs:()=>zt,acos:()=>Ox,acosh:()=>Lx,add:()=>J,addN:()=>ZI,all:()=>Om,any:()=>Xp,argMax:()=>ii,argMin:()=>zx,asin:()=>Bx,asinh:()=>Wx,atan:()=>Vx,atan2:()=>Ux,atanh:()=>Gx,avgPool:()=>fa,avgPool3d:()=>jx,backend:()=>JI,backend_util:()=>_,basicLSTMCell:()=>yM,batchNorm:()=>Cr,batchNorm2d:()=>nS,batchNorm3d:()=>aS,batchNorm4d:()=>rS,batchToSpaceND:()=>$c,bincount:()=>qx,booleanMaskAsync:()=>I3,broadcastArgs:()=>sS,broadcastTo:()=>il,broadcast_util:()=>Nu,browser:()=>yo,buffer:()=>He,callbacks:()=>e6,cast:()=>oe,ceil:()=>Kx,clipByValue:()=>nn,clone:()=>Nr,complex:()=>ns,concat:()=>Qe,concat1d:()=>iS,concat2d:()=>oS,concat3d:()=>lS,concat4d:()=>uS,constraints:()=>c2,conv1d:()=>Lm,conv2d:()=>Rt,conv2dTranspose:()=>zm,conv3d:()=>Yx,conv3dTranspose:()=>cS,copyRegisteredKernels:()=>EF,cos:()=>Fc,cosh:()=>Bm,cosineWindow:()=>kv,cumprod:()=>Yp,cumsum:()=>Wm,customGrad:()=>ur,data:()=>ON,denseBincount:()=>dS,deprecationWarn:()=>Px,depthToSpace:()=>Jx,depthwiseConv2d:()=>bs,deregisterOp:()=>a6,device_util:()=>_c,diag:()=>KM,dilation2d:()=>Zx,disableDeprecationWarnings:()=>ER,dispose:()=>Re,disposeVariables:()=>AR,div:()=>fe,divNoNan:()=>Qx,dot:()=>hS,dropout:()=>RS,einsum:()=>mS,elu:()=>Tu,enableDebugMode:()=>_R,enableProdMode:()=>CR,enclosingPowerOfTwo:()=>MS,engine:()=>ar,env:()=>X,equal:()=>Qn,erf:()=>ev,exp:()=>gn,expandDims:()=>mn,expm1:()=>tv,eye:()=>nv,fft:()=>Lc,fill:()=>Cn,findBackend:()=>OR,findBackendFactory:()=>LR,floor:()=>Cu,floorDiv:()=>Pm,forceHalfFloat:()=>n_,fused:()=>rs,gather:()=>li,gatherND:()=>DS,gather_util:()=>Ax,getBackend:()=>MR,getGradient:()=>bb,getKernel:()=>Ch,getKernelsForBackend:()=>_h,getThreadsCount:()=>sue,gpgpu_util:()=>RC,grad:()=>IP,grads:()=>SP,greater:()=>Gn,greaterEqual:()=>xs,ifft:()=>hl,imag:()=>Vm,image:()=>Ln,inTopKAsync:()=>R3,initializers:()=>d2,input:()=>$2,io:()=>Qt,irfft:()=>nf,isFinite:()=>fS,isInf:()=>gS,isNaN:()=>av,keep:()=>en,kernel_impls:()=>mr,layers:()=>h2,leakyRelu:()=>Dc,less:()=>Um,lessEqual:()=>vs,linalg:()=>HS,linspace:()=>yS,loadGraphModel:()=>iH,loadLayersModel:()=>pU,localResponseNormalization:()=>rv,log:()=>ea,log1p:()=>Rc,logSigmoid:()=>xS,logSoftmax:()=>Hm,logSumExp:()=>ov,logicalAnd:()=>Ta,logicalNot:()=>Mc,logicalOr:()=>jm,logicalXor:()=>IS,losses:()=>gz,matMul:()=>De,math:()=>DI,max:()=>Sa,maxPool:()=>Pt,maxPool3d:()=>lv,maxPoolWithArgmax:()=>SS,maximum:()=>hr,mean:()=>Et,memory:()=>$h,meshgrid:()=>jP,metrics:()=>lN,min:()=>Jp,minimum:()=>_u,mirrorPad:()=>uv,mod:()=>pv,model:()=>lU,models:()=>uN,moments:()=>qm,movingAverage:()=>T3,mul:()=>z,multiRNNCell:()=>eO,multinomial:()=>NS,neg:()=>St,nextFrame:()=>Nv,norm:()=>sf,notEqual:()=>pi,oneHot:()=>cl,ones:()=>Jn,onesLike:()=>ta,op:()=>B,outerProduct:()=>sO,pad:()=>ga,pad1d:()=>lO,pad2d:()=>pO,pad3d:()=>dO,pad4d:()=>mO,pool:()=>TS,pow:()=>_r,prelu:()=>Oc,print:()=>EI,prod:()=>Km,profile:()=>$R,rand:()=>IO,randomGamma:()=>CO,randomNormal:()=>CS,randomUniform:()=>Eu,range:()=>dl,ready:()=>RR,real:()=>Zp,reciprocal:()=>hv,registerBackend:()=>Mm,registerCallbackConstructor:()=>cU,registerGradient:()=>pI,registerKernel:()=>Nc,registerOp:()=>n6,regularizers:()=>pN,relu:()=>Xe,relu6:()=>Xm,removeBackend:()=>PR,reshape:()=>W,reverse:()=>na,reverse1d:()=>PO,reverse2d:()=>LO,reverse3d:()=>BO,reverse4d:()=>VO,rfft:()=>zc,round:()=>Ym,rsqrt:()=>Jm,scalar:()=>we,scatterND:()=>FS,scatter_util:()=>$x,selu:()=>Zm,separableConv2d:()=>xo,sequential:()=>uU,serialization:()=>se,setBackend:()=>DR,setPlatform:()=>zR,setThreadsCount:()=>rue,setWasmPath:()=>nue,setWasmPaths:()=>aue,setWebGLContext:()=>rC,setdiff1dAsync:()=>_S,sigmoid:()=>ha,sign:()=>mv,signal:()=>fz,sin:()=>Qm,sinh:()=>ef,slice:()=>Ge,slice1d:()=>tf,slice2d:()=>fv,slice3d:()=>Au,slice4d:()=>Qp,slice_util:()=>qt,softmax:()=>Ja,softplus:()=>bo,spaceToBatchND:()=>Pc,sparse:()=>Fp,sparseToDense:()=>wv,spectral:()=>mz,split:()=>zn,sqrt:()=>ln,square:()=>lt,squaredDifference:()=>af,squeeze:()=>pr,stack:()=>Mt,step:()=>$u,stridedSlice:()=>gv,string:()=>dh,sub:()=>ce,sum:()=>be,sumOutType:()=>Dm,tan:()=>yv,tanh:()=>oi,tensor:()=>Zn,tensor1d:()=>qe,tensor2d:()=>Ha,tensor3d:()=>Rm,tensor4d:()=>Za,tensor5d:()=>m3,tensor6d:()=>f3,tensor_util:()=>Ga,test_util:()=>KI,tidy:()=>O,tile:()=>On,time:()=>FR,topk:()=>bv,train:()=>Us,transpose:()=>$e,truncatedNormal:()=>rf,unique:()=>Dh,unregisterGradient:()=>_F,unregisterKernel:()=>CF,unsortedSegmentSum:()=>xv,unstack:()=>mt,upcastType:()=>ma,util:()=>k,valueAndGrad:()=>NP,valueAndGrads:()=>TP,variable:()=>ES,variableGrads:()=>bS,version:()=>gue,version_converter:()=>oH,version_core:()=>TR,version_layers:()=>qv,version_wasm:()=>iue,version_webgl:()=>g9,webgl:()=>y9,webgl_util:()=>aC,where:()=>fn,whereAsync:()=>vv,zeros:()=>kt,zerosLike:()=>Ke});var $$=Object.create,gx=Object.defineProperty,F$=Object.getOwnPropertyDescriptor,D$=Object.getOwnPropertyNames,R$=Object.getPrototypeOf,M$=Object.prototype.hasOwnProperty,ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Me=(e,t)=>{for(var n in t)gx(e,n,{get:t[n],enumerable:!0})},P$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D$(t))!M$.call(e,r)&&r!==n&&gx(e,r,{get:()=>t[r],enumerable:!(a=F$(t,r))||a.enumerable});return e},yi=(e,t,n)=>(n=e!=null?$$(R$(e)):{},P$(t||!e||!e.__esModule?gx(n,"default",{value:e,enumerable:!0}):n,e)),O$=ft((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,V){this.low=S|0,this.high=M|0,this.unsigned=!!V}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 V,j,q;return M?(S>>>=0,(q=0<=S&&S<256)&&(j=i[S],j)?j:(V=u(S,(S|0)<0?-1:0,!0),q&&(i[S]=V),V)):(S|=0,(q=-128<=S&&S<128)&&(j=s[S],j)?j:(V=u(S,S<0?-1:0,!1),q&&(s[S]=V),V))}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,V){return new a(S,M,V)}a.fromBits=u;var p=Math.pow;function d(S,M,V){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof M=="number"?(V=M,M=!1):M=!!M,V=V||10,V<2||360)throw Error("interior hyphen");if(j===0)return d(S.substring(1),M,V).neg();for(var q=l(p(V,8)),K=x,Q=0;Q>>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,Z=re.toString(S);if(K=ee,K.isZero())return Z+Q;for(;Z.length<6;)Z="0"+Z;Q=""+Z+Q}},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(),V=S.isNegative();return M&&!V?-1:!M&&V?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,V=this.high&65535,j=this.low>>>16,q=this.low&65535,K=S.high>>>16,Q=S.high&65535,ee=S.low>>>16,re=S.low&65535,Z=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+=V+Q,Z+=ie>>>16,ie&=65535,Z+=M+K,Z&=65535,u(ae<<16|le,Z<<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 V=this.high>>>16,j=this.high&65535,q=this.low>>>16,K=this.low&65535,Q=S.high>>>16,ee=S.high&65535,re=S.low>>>16,Z=S.low&65535,ie=0,ae=0,le=0,ue=0;return ue+=K*Z,le+=ue>>>16,ue&=65535,le+=q*Z,ae+=le>>>16,le&=65535,le+=K*re,ae+=le>>>16,le&=65535,ae+=j*Z,ie+=ae>>>16,ae&=65535,ae+=q*re,ie+=ae>>>16,ae&=65535,ae+=K*ee,ie+=ae>>>16,ae&=65535,ie+=V*Z+j*re+q*ee+K*Q,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 V,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 V=K.div(S).shl(1),V.eq(x)?S.isNegative()?w:C:(j=this.sub(S.mul(V)),q=V.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);){V=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Q=Math.ceil(Math.log(V)/Math.LN2),ee=Q<=48?1:p(2,Q-48),re=l(V),Z=re.mul(S);Z.isNegative()||Z.gt(j);)V-=ee,re=l(V,this.unsigned),Z=re.mul(S);re.isZero()&&(re=w),q=q.add(re),j=j.sub(Z)}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 V=this.low;return u(V>>>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,V){return V?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)}}),L$=ft(()=>{}),z$=ft(()=>{}),B$=ft((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)}),W$=ft((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)}),V$=ft((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)}),U$=ft((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)}),G$=ft((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)}),H$=ft((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=ft(()=>{}),j$=ft((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,V=0;S=d;)S/=2,M/=2,V>>>=1;return(S+V)/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,V,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),V?(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=B$(),a=W$(),r=V$(),s=U$(),i=G$(),o=H$(),l=j$();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),q$=ft((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)}),K$=ft((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)}),X$=ft((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)}),Y$=ft((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$=ft((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)}),Z$=ft((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)}),Q$=ft((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,V=0;S=d;)S/=2,M/=2,V>>>=1;return(S+V)/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,V,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),V?(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=q$(),a=K$(),r=X$(),s=Y$(),i=J$(),o=Z$(),l=Q$();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),Xk=ft(()=>{}),yx=ft(()=>{}),wh=ft(()=>{}),eF=ft(()=>{}),tF=ft(()=>{}),nF=ft(()=>{}),aF=ft((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&&Ra(Te.buffer),xd}function i(){return Te.buffer!=bn&&Ra(Te.buffer),vd}function o(){return Te.buffer!=bn&&Ra(Te.buffer),mp}function l(){return Te.buffer!=bn&&Ra(Te.buffer),wd}function u(){return Te.buffer!=bn&&Ra(Te.buffer),kd}function p(){return Te.buffer!=bn&&Ra(Te.buffer),Id}function d(){return Te.buffer!=bn&&Ra(Te.buffer),Sd}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 V(N){N instanceof Sp||Z("exiting due to exception: "+N)}var j,q,K;if(T){w?E=wh().dirname(E)+"/":E=__dirname+"/",K=()=>{q||(j=yx(),q=wh())},P=function(D,U){return K(),D=q.normalize(D),j.readFileSync(D,U?void 0:"utf8")},S=D=>{var U=P(D,!0);return U.buffer||(U=new Uint8Array(U)),U},F=(D,U,Y)=>{K(),D=q.normalize(D),j.readFile(D,function(pe,he){pe?Y(pe):U(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 Sp))throw D}),process.on("unhandledRejection",function(D){throw D}),x=(D,U)=>{if(Ms())throw process.exitCode=D,U;V(U),process.exit(D)},c.inspect=function(){return"[Emscripten Module object]"};let N;try{N=eF()}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,U)=>{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}U()},Y.onerror=U,Y.send(null)}),M=N=>document.title=N);T&&typeof performance=="undefined"&&(global.performance=tF().performance);var Q=console.log.bind(console),ee=console.warn.bind(console);T&&(K(),Q=N=>j.writeSync(1,N+` `),ee=N=>j.writeSync(2,N+` `));var re=c.print||Q,Z=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,Z(N))}function le(N,D){if(typeof WebAssembly.Function=="function"){for(var U={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:D[0]=="v"?[]:[U[D[0]]]},pe=1;pe{Ee=N},Be=Atomics.load,je=Atomics.store,st=Atomics.compareExchange,et;c.wasmBinary&&(et=c.wasmBinary);var tt=c.noExitRuntime||!0;typeof WebAssembly!="object"&&Bo("no native wasm support detected");var Te,gt,ct=!1,yn;function Yt(N,D){N||Bo(D)}function Dn(N){var D=c["_"+N];return D}function Ut(N,D,U,Y,pe){var he={string:function(la){var Yo=0;if(la!=null&&la!==0){var y1=(la.length<<2)+1;Yo=Xo(y1),Ds(la,Yo,y1)}return Yo},array:function(la){var Yo=Xo(la.length);return xr(la,Yo),Yo}};function ve(la){return D==="string"?ia(la):D==="boolean"?Boolean(la):la}var Ce=Dn(N),_t=[],La=0;if(Y)for(var za=0;za(U.buffer instanceof SharedArrayBuffer&&(U=new Uint8Array(U)),D.decode.call(D,U))}var Gt=typeof TextDecoder!="undefined"?new Rn("utf8"):void 0;function sa(N,D,U){for(var Y=D+U,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|La&1023)}}return he}function ia(N,D){return N?sa(i(),N,D):""}function Br(N,D,U,Y){if(!(Y>0))return 0;for(var pe=U,he=U+Y-1,ve=0;ve=55296&&Ce<=57343){var _t=N.charCodeAt(++ve);Ce=65536+((Ce&1023)<<10)|_t&1023}if(Ce<=127){if(U>=he)break;D[U++]=Ce}else if(Ce<=2047){if(U+1>=he)break;D[U++]=192|Ce>>6,D[U++]=128|Ce&63}else if(Ce<=65535){if(U+2>=he)break;D[U++]=224|Ce>>12,D[U++]=128|Ce>>6&63,D[U++]=128|Ce&63}else{if(U+3>=he)break;D[U++]=240|Ce>>18,D[U++]=128|Ce>>12&63,D[U++]=128|Ce>>6&63,D[U++]=128|Ce&63}}return D[U]=0,U-pe}function Ds(N,D,U){return Br(N,i(),D,U)}function bd(N){for(var D=0,U=0;U=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|N.charCodeAt(++U)&1023),Y<=127?++D:Y<=2047?D+=2:Y<=65535?D+=3:D+=4}return D}var Wr=typeof TextDecoder!="undefined"?new Rn("utf-16le"):void 0;function xr(N,D){s().set(N,D)}function hp(N,D,U){for(var Y=0;Y>0]=N.charCodeAt(Y);U||(s()[D>>0]=0)}function Lo(N,D){return N%D>0&&(N+=D-N%D),N}var bn,xd,vd,mp,wd,kd,J0,Id,Sd;C&&(bn=c.buffer);function Ra(N){bn=N,c.HEAP8=xd=new Int8Array(N),c.HEAP16=mp=new Int16Array(N),c.HEAP32=kd=new Int32Array(N),c.HEAPU8=vd=new Uint8Array(N),c.HEAPU16=wd=new Uint16Array(N),c.HEAPU32=J0=new Uint32Array(N),c.HEAPF32=Id=new Float32Array(N),c.HEAPF64=Sd=new Float64Array(N)}var Nd=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:Nd/65536,maximum:32768,shared:!0}),!(Te.buffer instanceof SharedArrayBuffer))throw Z("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),Nd=bn.byteLength,Ra(bn);var oa,zo=[],Vr=[],Ng=[],Td=[],Rs=!1,Tg=!1,Cd=0;function Ms(){return tt||Cd>0}function xn(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)Z0(c.preRun.shift());$d(zo)}function fp(){Rs=!0,!C&&$d(Vr)}function Cg(){C||(_e.terminateAllThreads(),Tg=!0)}function _g(){if(!C){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)gp(c.postRun.shift());$d(Td)}}function Z0(N){zo.unshift(N)}function Q0(N){Vr.unshift(N)}function gp(N){Td.unshift(N)}var Ur=0,_d=null,Ma=null;function yp(N){Ur++,c.monitorRunDependencies&&c.monitorRunDependencies(Ur)}function e1(N){if(Ur--,c.monitorRunDependencies&&c.monitorRunDependencies(Ur),Ur==0&&(_d!==null&&(clearInterval(_d),_d=null),Ma)){var D=Ma;Ma=null,D()}}c.preloadedImages={},c.preloadedAudios={};function Bo(N){C?postMessage({cmd:"onAbort",arg:N}):c.onAbort&&c.onAbort(N),N="Aborted("+N+")",Z(N),ct=!0,yn=1,N+=". Build with -s ASSERTIONS=1 for more info.";var D=new WebAssembly.RuntimeError(N);throw m(D),D}var Eg="data:application/octet-stream;base64,";function bp(N){return N.startsWith(Eg)}function Ed(N){return N.startsWith("file://")}var vn;vn="tfjs-backend-wasm-threaded-simd.wasm",bp(vn)||(vn=$(vn));function Ad(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){Bo(D)}}function Wo(){if(!et&&(v||w)){if(typeof fetch=="function"&&!Ed(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 Ad(vn)});if(F)return new Promise(function(N,D){F(vn,function(U){N(new Uint8Array(U))},D)})}return Promise.resolve().then(function(){return Ad(vn)})}function Ag(){var N={env:Ud,wasi_snapshot_preview1:Ud};function D(ve,Ce){var _t=ve.exports;if(c.asm=_t,Og(c.asm.emscripten_tls_init),oa=c.asm.__indirect_function_table,Q0(c.asm.__wasm_call_ctors),gt=Ce,!C){var La=_e.unusedWorkers.length;_e.unusedWorkers.forEach(function(za){_e.loadWasmModuleToWorker(za,function(){--La||e1("wasm-instantiate")})})}}C||yp("wasm-instantiate");function U(ve){D(ve.instance,ve.module)}function Y(ve){return Wo().then(function(Ce){return WebAssembly.instantiate(Ce,N)}).then(function(Ce){return Ce}).then(ve,function(Ce){Z("failed to asynchronously prepare wasm: "+Ce),Bo(Ce)})}function pe(){return!et&&typeof WebAssembly.instantiateStreaming=="function"&&!bp(vn)&&!Ed(vn)&&typeof fetch=="function"?fetch(vn,{credentials:"same-origin"}).then(function(ve){var Ce=WebAssembly.instantiateStreaming(ve,N);return Ce.then(U,function(_t){return Z("wasm streaming compile failed: "+_t),Z("falling back to ArrayBuffer instantiation"),Y(U)})}):Y(U)}if(c.instantiateWasm)try{var he=c.instantiateWasm(N,D);return he}catch(ve){return Z("Module.instantiateWasm callback failed with error: "+ve),!1}return pe().catch(m),{}}var t1,n1,$g={};function $d(N){for(;N.length>0;){var D=N.shift();if(typeof D=="function"){D(c);continue}var U=D.func;typeof U=="number"?D.arg===void 0?Uo(U)():Uo(U)(D.arg):U(D.arg===void 0?null:D.arg)}}function Vo(N){var D=eb(),U=N();return Kd(D),U}function PA(N){return N}function a1(N){var D=/\b_Z[\w\d_]+/g;return N.replace(D,function(U){var Y=U;return U===Y?U:Y+" ["+U+"]"})}function Fg(N){u()[N>>2]=0;var D=_e.pthreads[N];delete _e.pthreads[N],D.worker.terminate(),Qy(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 Fd(N){var D=_e.pthreads[N];if(D){u()[N>>2]=0;var U=D.worker;_e.returnWorkerToPool(U)}}function Dd(N){N$(N)}function Rg(N){if(N instanceof Sp||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()[g1>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in _e.tlsInitFunctions)_e.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=U=>{var Y=U.data,pe=Y.cmd;if(N.pthread&&(_e.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=qd()){var he=_e.pthreads[Y.targetThread];he?he.worker.postMessage(Y,Y.transferList):Z('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"?c1():pe==="spawnThread"?Md(Y):pe==="cleanupThread"?Fd(Y.thread):pe==="killThread"?Fg(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"?Z("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):Z("worker sent an unknown command "+pe),_e.currentProxiedOperationCallerThread=void 0},N.onerror=U=>{var Y="worker sent an error!";throw Z(Y+" "+U.filename+":"+U.lineno+": "+U.message),U},T&&(N.on("message",function(U){N.onmessage({data:U})}),N.on("error",function(U){N.onerror(U)}),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=qd(),D=u()[N+44>>2],U=u()[N+48>>2],Y=D-U;f1(D,Y),Kd(D)}c.establishStackSpace=Mg;function Rd(N){if(C)return Ls(1,0,N);try{Dd(N)}catch(D){Rg(D)}}var Ps=[];function Uo(N){var D=Ps[N];return D||(N>=Ps.length&&(Ps.length=N+1),Ps[N]=D=oa.get(N)),D}function Pg(N,D){return Uo(N)(D)}c.invokeEntryPoint=Pg;function r1(){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 Og(N,D,U){_e.tlsInitFunctions.push(N)}function s1(N,D){oa.set(N,D),Ps[N]=D}var Os;T?Os=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:C?Os=()=>performance.now()-c.__performance_now_clock_drift:Os=()=>performance.now();var Lg=!0;function zg(N){return u()[p1()>>2]=N,N}function Bg(N,D){var U;if(N===0)U=Date.now();else if((N===1||N===4)&&Lg)U=Os();else return zg(28),-1;return u()[D>>2]=U/1e3|0,u()[D+4>>2]=U%1e3*1e3*1e3|0,0}function Wg(N,D){return Bg(N,D)}function Vg(N){d1(N,!w,1,!v),_e.threadInit()}function Ug(N){C?postMessage({cmd:"cleanupThread",thread:N}):Fd(N)}function Md(N){var D=_e.getNewWorker();if(!D)return 6;_e.runningWorkers.push(D);var U=_e.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=U;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 Gg(N,D,U,Y){if(typeof SharedArrayBuffer=="undefined")return Z("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var pe=[],he=0;if(C&&(pe.length===0||he))return h1(687865856,N,D,U,Y);if(he)return he;var ve={startRoutine:U,pthread_ptr:N,arg:Y,transferList:pe};return C?(ve.cmd="spawnThread",postMessage(ve,pe),0):Md(ve)}function Hg(){return 2097152}function jg(N,D){if(N==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(C)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var U=_e.pthreads[N],Y=U&&U.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function qg(){Bo("")}function Kg(){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 Pd(){return 2147483648}function Xg(N,D,U){i().copyWithin(N,D,D+U)}function Yg(){return T?nF().cpus().length:navigator.hardwareConcurrency}function Ls(N,D){var U=arguments.length-2,Y=arguments;return Vo(function(){for(var pe=U,he=Xo(pe*8),ve=he>>3,Ce=0;Ce>3,pe=0;pe>>16),Ra(Te.buffer),1}catch(D){}}function Qg(N){var D=i().length;if(N=N>>>0,N<=D)return!1;var U=Pd();if(N>U)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(U,Lo(Math.max(N,pe),65536)),ve=Zg(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||(Ng.push(Ve.removeAllEventListeners),Ve.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,U){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,U))return}Ve.deferredCalls.push({targetFunction:N,precedence:D,argsList:U}),Ve.deferredCalls.sort(function(ve,Ce){return ve.precedence>2]=U,u()[he+4>>2]=Y,u()[he+8>>2]=pe,Zy(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 ey(N){var D=bd(N)+1,U=Jy(D);return Ds(N,U,D),U}function ty(N,D,U,Y){Vo(function(){var pe=Xo(12),he=0;D&&(he=ey(D)),u()[pe>>2]=he,u()[pe+4>>2]=U,u()[pe+8>>2]=Y,Zy(N,657457152,0,he,pe)})}function ny(N,D,U,Y){D=D?ia(D):"",ty(N,D,U,Y)}function ay(N){return N>2?ia(N):N}var ry=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function sy(N){N=ay(N);var D=ry[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return D}function vp(N){return sy(N)}function Od(N,D,U){var Y=vp(N);if(!Y)return-4;if(Y.canvasSharedPtr&&(u()[Y.canvasSharedPtr>>2]=D,u()[Y.canvasSharedPtr+4>>2]=U),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=U,pe&&Y.GLctxObject.GLctx.viewport(0,0,D,U)}else if(Y.canvasSharedPtr){var ve=u()[Y.canvasSharedPtr+8>>2];return ny(ve,N,D,U),1}else return-4;return 0}function Ld(N,D,U){return C?Ls(2,1,N,D,U):Od(N,D,U)}function iy(N,D,U){var Y=vp(N);return Y?Od(N,D,U):Ld(N,D,U)}function oy(){throw"unwind"}function ly(N){var D=N.getExtension("ANGLE_instanced_arrays");if(D)return N.vertexAttribDivisor=function(U,Y){D.vertexAttribDivisorANGLE(U,Y)},N.drawArraysInstanced=function(U,Y,pe,he){D.drawArraysInstancedANGLE(U,Y,pe,he)},N.drawElementsInstanced=function(U,Y,pe,he,ve){D.drawElementsInstancedANGLE(U,Y,pe,he,ve)},1}function uy(N){var D=N.getExtension("OES_vertex_array_object");if(D)return N.createVertexArray=function(){return D.createVertexArrayOES()},N.deleteVertexArray=function(U){D.deleteVertexArrayOES(U)},N.bindVertexArray=function(U){D.bindVertexArrayOES(U)},N.isVertexArray=function(U){return D.isVertexArrayOES(U)},1}function py(N){var D=N.getExtension("WEBGL_draw_buffers");if(D)return N.drawBuffers=function(U,Y){D.drawBuffersWEBGL(U,Y)},1}function cy(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++,U=N.length;U>2]:-1;pe+=ia(u()[U+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 U=N.getContext("webgl",D);if(!U)return 0;var Y=Ct.registerContext(U,D);return Y},registerContext:function(N,D){var U=Jy(8);u()[U+4>>2]=qd();var Y={handle:U,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Y),Ct.contexts[U]=Y,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&&Ct.initExtensions(Y),U},makeContextCurrent:function(N){return Ct.currentContext=Ct.contexts[N],c.ctx=Vd=Ct.currentContext&&Ct.currentContext.GLctx,!(N&&!Vd)},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),u1(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;ly(D),uy(D),py(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),cy(D);var U=D.getSupportedExtensions()||[];U.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&D.getExtension(Y)})}}},dy=["default","low-power","high-performance"];function hy(N,D){var U=D>>2,Y=u()[U+6],pe={alpha:!!u()[U+0],depth:!!u()[U+1],stencil:!!u()[U+2],antialias:!!u()[U+3],premultipliedAlpha:!!u()[U+4],preserveDrawingBuffer:!!u()[U+5],powerPreference:dy[Y],failIfMajorPerformanceCaveat:!!u()[U+7],majorVersion:u()[U+8],minorVersion:u()[U+9],enableExtensionsByDefault:u()[U+10],explicitSwapControl:u()[U+11],proxyContextToMainThread:u()[U+12],renderViaOffscreenBackBuffer:u()[U+13]},he=vp(N);if(!he||pe.explicitSwapControl)return 0;var ve=Ct.createContext(he,pe);return ve}function my(N,D){return hy(N,D)}var Go={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var U=Go.buffers[N];D===0||D===10?((N===1?re:Z)(sa(U,0)),U.length=0):U.push(D)},varargs:void 0,get:function(){Go.varargs+=4;var N=u()[Go.varargs-4>>2];return N},getStr:function(N){var D=ia(N);return D},get64:function(N,D){return N}};function zd(N){return C?Ls(3,1,N):0}function Bd(N,D,U,Y,pe){if(C)return Ls(4,1,N,D,U,Y,pe)}function Wd(N,D,U,Y){if(C)return Ls(5,1,N,D,U,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 fy(N){Fe(N)}_e.init();var Vd,gy=[null,Rd,Ld,zd,Bd,Wd],i1=!1,Ud={__clock_gettime:Wg,__emscripten_init_main_thread_js:Vg,__emscripten_thread_cleanup:Ug,__pthread_create_js:Gg,_emscripten_default_pthread_stack_size:Hg,_emscripten_notify_thread_queue:jg,abort:qg,emscripten_check_blocking_allowed:Kg,emscripten_get_heap_max:Pd,emscripten_get_now:Os,emscripten_memcpy_big:Xg,emscripten_num_logical_cores:Yg,emscripten_receive_on_main_thread_js:Jg,emscripten_resize_heap:Qg,emscripten_set_canvas_element_size:iy,emscripten_unwind_to_js_event_loop:oy,emscripten_webgl_create_context:my,exit:Dd,fd_close:zd,fd_seek:Bd,fd_write:Wd,memory:Te||c.wasmMemory,setTempRet0:fy},o1=Ag(),yy=c.___wasm_call_ctors=function(){return(yy=c.___wasm_call_ctors=c.asm.__wasm_call_ctors).apply(null,arguments)},by=c._init=function(){return(by=c._init=c.asm.init).apply(null,arguments)},xy=c._init_with_threads_count=function(){return(xy=c._init_with_threads_count=c.asm.init_with_threads_count).apply(null,arguments)},vy=c._get_threads_count=function(){return(vy=c._get_threads_count=c.asm.get_threads_count).apply(null,arguments)},wy=c._register_tensor=function(){return(wy=c._register_tensor=c.asm.register_tensor).apply(null,arguments)},ky=c._dispose_data=function(){return(ky=c._dispose_data=c.asm.dispose_data).apply(null,arguments)},Iy=c._dispose=function(){return(Iy=c._dispose=c.asm.dispose).apply(null,arguments)},Sy=c._Abs=function(){return(Sy=c._Abs=c.asm.Abs).apply(null,arguments)},Ny=c._Add=function(){return(Ny=c._Add=c.asm.Add).apply(null,arguments)},Ty=c._AddN=function(){return(Ty=c._AddN=c.asm.AddN).apply(null,arguments)},Cy=c._All=function(){return(Cy=c._All=c.asm.All).apply(null,arguments)},_y=c._Any=function(){return(_y=c._Any=c.asm.Any).apply(null,arguments)},Ey=c._ArgMax=function(){return(Ey=c._ArgMax=c.asm.ArgMax).apply(null,arguments)},Ay=c._AvgPool=function(){return(Ay=c._AvgPool=c.asm.AvgPool).apply(null,arguments)},$y=c._BatchMatMul=function(){return($y=c._BatchMatMul=c.asm.BatchMatMul).apply(null,arguments)},Fy=c._Ceil=function(){return(Fy=c._Ceil=c.asm.Ceil).apply(null,arguments)},Dy=c._ClipByValue=function(){return(Dy=c._ClipByValue=c.asm.ClipByValue).apply(null,arguments)},Ry=c._Conv2D=function(){return(Ry=c._Conv2D=c.asm.Conv2D).apply(null,arguments)},My=c._Conv2DBackpropInput=function(){return(My=c._Conv2DBackpropInput=c.asm.Conv2DBackpropInput).apply(null,arguments)},Py=c._Cos=function(){return(Py=c._Cos=c.asm.Cos).apply(null,arguments)},Oy=c._Cosh=function(){return(Oy=c._Cosh=c.asm.Cosh).apply(null,arguments)},Ly=c._CropAndResize=function(){return(Ly=c._CropAndResize=c.asm.CropAndResize).apply(null,arguments)},zy=c._Cumprod=function(){return(zy=c._Cumprod=c.asm.Cumprod).apply(null,arguments)},By=c._Cumsum=function(){return(By=c._Cumsum=c.asm.Cumsum).apply(null,arguments)},Wy=c._DepthToSpace=function(){return(Wy=c._DepthToSpace=c.asm.DepthToSpace).apply(null,arguments)},Vy=c._DepthwiseConv2dNative=function(){return(Vy=c._DepthwiseConv2dNative=c.asm.DepthwiseConv2dNative).apply(null,arguments)},Uy=c._Elu=function(){return(Uy=c._Elu=c.asm.Elu).apply(null,arguments)},Gy=c._Equal=function(){return(Gy=c._Equal=c.asm.Equal).apply(null,arguments)},Hy=c._Exp=function(){return(Hy=c._Exp=c.asm.Exp).apply(null,arguments)},jy=c._FlipLeftRight=function(){return(jy=c._FlipLeftRight=c.asm.FlipLeftRight).apply(null,arguments)},Gd=c._Floor=function(){return(Gd=c._Floor=c.asm.Floor).apply(null,arguments)},Hd=c._FloorDiv=function(){return(Hd=c._FloorDiv=c.asm.FloorDiv).apply(null,arguments)},wp=c._FusedBatchNorm=function(){return(wp=c._FusedBatchNorm=c.asm.FusedBatchNorm).apply(null,arguments)},qy=c._FusedConv2D=function(){return(qy=c._FusedConv2D=c.asm.FusedConv2D).apply(null,arguments)},Ky=c._FusedDepthwiseConv2D=function(){return(Ky=c._FusedDepthwiseConv2D=c.asm.FusedDepthwiseConv2D).apply(null,arguments)},Ho=c._Gather=function(){return(Ho=c._Gather=c.asm.Gather).apply(null,arguments)},kp=c._GatherNd=function(){return(kp=c._GatherNd=c.asm.GatherNd).apply(null,arguments)},Ip=c._Greater=function(){return(Ip=c._Greater=c.asm.Greater).apply(null,arguments)},l1=c._GreaterEqual=function(){return(l1=c._GreaterEqual=c.asm.GreaterEqual).apply(null,arguments)},jo=c._LeakyRelu=function(){return(jo=c._LeakyRelu=c.asm.LeakyRelu).apply(null,arguments)},qo=c._Less=function(){return(qo=c._Less=c.asm.Less).apply(null,arguments)},Xy=c._LessEqual=function(){return(Xy=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)},Ze=c._Maximum=function(){return(Ze=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)},We=c._Minimum=function(){return(We=c._Minimum=c.asm.Minimum).apply(null,arguments)},Lt=c._MirrorPad=function(){return(Lt=c._MirrorPad=c.asm.MirrorPad).apply(null,arguments)},Pa=c._Multiply=function(){return(Pa=c._Multiply=c.asm.Multiply).apply(null,arguments)},Oa=c._Neg=function(){return(Oa=c._Neg=c.asm.Neg).apply(null,arguments)},Ko=c._NonMaxSuppressionV3=function(){return(Ko=c._NonMaxSuppressionV3=c.asm.NonMaxSuppressionV3).apply(null,arguments)},zs=c._NonMaxSuppressionV4=function(){return(zs=c._NonMaxSuppressionV4=c.asm.NonMaxSuppressionV4).apply(null,arguments)},Yy=c._NonMaxSuppressionV5=function(){return(Yy=c._NonMaxSuppressionV5=c.asm.NonMaxSuppressionV5).apply(null,arguments)},Mn=c._NotEqual=function(){return(Mn=c._NotEqual=c.asm.NotEqual).apply(null,arguments)},Gr=c._OneHot=function(){return(Gr=c._OneHot=c.asm.OneHot).apply(null,arguments)},jd=c._PadV2=function(){return(jd=c._PadV2=c.asm.PadV2).apply(null,arguments)},OA=c._Pow=function(){return(OA=c._Pow=c.asm.Pow).apply(null,arguments)},LA=c._Prelu=function(){return(LA=c._Prelu=c.asm.Prelu).apply(null,arguments)},zA=c._Prod=function(){return(zA=c._Prod=c.asm.Prod).apply(null,arguments)},BA=c._RealDiv=function(){return(BA=c._RealDiv=c.asm.RealDiv).apply(null,arguments)},WA=c._Relu=function(){return(WA=c._Relu=c.asm.Relu).apply(null,arguments)},VA=c._Relu6=function(){return(VA=c._Relu6=c.asm.Relu6).apply(null,arguments)},UA=c._ResizeBilinear=function(){return(UA=c._ResizeBilinear=c.asm.ResizeBilinear).apply(null,arguments)},GA=c._Reverse=function(){return(GA=c._Reverse=c.asm.Reverse).apply(null,arguments)},HA=c._RotateWithOffset=function(){return(HA=c._RotateWithOffset=c.asm.RotateWithOffset).apply(null,arguments)},jA=c._Round=function(){return(jA=c._Round=c.asm.Round).apply(null,arguments)},qA=c._Rsqrt=function(){return(qA=c._Rsqrt=c.asm.Rsqrt).apply(null,arguments)},KA=c._ScatterNd=function(){return(KA=c._ScatterNd=c.asm.ScatterNd).apply(null,arguments)},XA=c._SelectV2=function(){return(XA=c._SelectV2=c.asm.SelectV2).apply(null,arguments)},YA=c._Sigmoid=function(){return(YA=c._Sigmoid=c.asm.Sigmoid).apply(null,arguments)},JA=c._Sin=function(){return(JA=c._Sin=c.asm.Sin).apply(null,arguments)},ZA=c._Softmax=function(){return(ZA=c._Softmax=c.asm.Softmax).apply(null,arguments)},QA=c._SparseFillEmptyRows=function(){return(QA=c._SparseFillEmptyRows=c.asm.SparseFillEmptyRows).apply(null,arguments)},e$=c._SparseReshape=function(){return(e$=c._SparseReshape=c.asm.SparseReshape).apply(null,arguments)},t$=c._SparseSegmentReduction=function(){return(t$=c._SparseSegmentReduction=c.asm.SparseSegmentReduction).apply(null,arguments)},n$=c._Sqrt=function(){return(n$=c._Sqrt=c.asm.Sqrt).apply(null,arguments)},a$=c._Square=function(){return(a$=c._Square=c.asm.Square).apply(null,arguments)},r$=c._SquaredDifference=function(){return(r$=c._SquaredDifference=c.asm.SquaredDifference).apply(null,arguments)},s$=c._Step=function(){return(s$=c._Step=c.asm.Step).apply(null,arguments)},i$=c._StridedSlice=function(){return(i$=c._StridedSlice=c.asm.StridedSlice).apply(null,arguments)},o$=c._Sub=function(){return(o$=c._Sub=c.asm.Sub).apply(null,arguments)},l$=c._Sum=function(){return(l$=c._Sum=c.asm.Sum).apply(null,arguments)},u$=c._Tan=function(){return(u$=c._Tan=c.asm.Tan).apply(null,arguments)},p$=c._Tanh=function(){return(p$=c._Tanh=c.asm.Tanh).apply(null,arguments)},c$=c._Tile=function(){return(c$=c._Tile=c.asm.Tile).apply(null,arguments)},d$=c._TopK=function(){return(d$=c._TopK=c.asm.TopK).apply(null,arguments)},h$=c._Transform=function(){return(h$=c._Transform=c.asm.Transform).apply(null,arguments)},m$=c._Transpose=function(){return(m$=c._Transpose=c.asm.Transpose).apply(null,arguments)},f$=c.__FusedMatMul=function(){return(f$=c.__FusedMatMul=c.asm._FusedMatMul).apply(null,arguments)},Jy=c._malloc=function(){return(Jy=c._malloc=c.asm.malloc).apply(null,arguments)},u1=c._free=function(){return(u1=c._free=c.asm.free).apply(null,arguments)},g$=c._emscripten_tls_init=function(){return(g$=c._emscripten_tls_init=c.asm.emscripten_tls_init).apply(null,arguments)},p1=c.___errno_location=function(){return(p1=c.___errno_location=c.asm.__errno_location).apply(null,arguments)},qd=c._pthread_self=function(){return(qd=c._pthread_self=c.asm.pthread_self).apply(null,arguments)},c1=c._emscripten_main_thread_process_queued_calls=function(){return(c1=c._emscripten_main_thread_process_queued_calls=c.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},y$=c.__emscripten_thread_crashed=function(){return(y$=c.__emscripten_thread_crashed=c.asm._emscripten_thread_crashed).apply(null,arguments)},d1=c.__emscripten_thread_init=function(){return(d1=c.__emscripten_thread_init=c.asm._emscripten_thread_init).apply(null,arguments)},b$=c._emscripten_current_thread_process_queued_calls=function(){return(b$=c._emscripten_current_thread_process_queued_calls=c.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},x$=c._emscripten_main_browser_thread_id=function(){return(x$=c._emscripten_main_browser_thread_id=c.asm.emscripten_main_browser_thread_id).apply(null,arguments)},v$=c._emscripten_sync_run_in_main_thread_2=function(){return(v$=c._emscripten_sync_run_in_main_thread_2=c.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},h1=c._emscripten_sync_run_in_main_thread_4=function(){return(h1=c._emscripten_sync_run_in_main_thread_4=c.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},m1=c._emscripten_run_in_main_runtime_thread_js=function(){return(m1=c._emscripten_run_in_main_runtime_thread_js=c.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},Zy=c._emscripten_dispatch_to_thread_=function(){return(Zy=c._emscripten_dispatch_to_thread_=c.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},Qy=c.__emscripten_thread_free_data=function(){return(Qy=c.__emscripten_thread_free_data=c.asm._emscripten_thread_free_data).apply(null,arguments)},w$=c.__emscripten_thread_exit=function(){return(w$=c.__emscripten_thread_exit=c.asm._emscripten_thread_exit).apply(null,arguments)},k$=c._memalign=function(){return(k$=c._memalign=c.asm.memalign).apply(null,arguments)},f1=c._emscripten_stack_set_limits=function(){return(f1=c._emscripten_stack_set_limits=c.asm.emscripten_stack_set_limits).apply(null,arguments)},eb=c.stackSave=function(){return(eb=c.stackSave=c.asm.stackSave).apply(null,arguments)},Kd=c.stackRestore=function(){return(Kd=c.stackRestore=c.asm.stackRestore).apply(null,arguments)},Xo=c.stackAlloc=function(){return(Xo=c.stackAlloc=c.asm.stackAlloc).apply(null,arguments)},I$=c.dynCall_iijjiiii=function(){return(I$=c.dynCall_iijjiiii=c.asm.dynCall_iijjiiii).apply(null,arguments)},S$=c.dynCall_jiji=function(){return(S$=c.dynCall_jiji=c.asm.dynCall_jiji).apply(null,arguments)},g1=c.__emscripten_allow_main_runtime_queued_calls=21464;c.cwrap=Jt,c.keepRuntimeAlive=Ms,c.PThread=_e,c.PThread=_e,c.wasmMemory=Te,c.ExitStatus=Sp;var Xd;function Sp(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Ma=function N(){Xd||tb(),Xd||(Ma=N)};function tb(N){if(N=N||y,Ur>0)return;if(C){h(c),fp(),postMessage({cmd:"loaded"});return}if(xn(),Ur>0)return;function D(){Xd||(Xd=!0,c.calledRun=!0,!ct&&(fp(),h(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),_g()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),D()},1)):D()}c.run=tb;function N$(N,D){if(yn=N,!D&&C)throw Rd(N),"unwind";Ms()||Cg(),T$(N)}function T$(N){yn=N,Ms()||(_e.terminateAllThreads(),c.onExit&&c.onExit(N),ct=!0),x(N,new Sp(N))}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();tb();var Yd;f&&(Yd={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 Jd;if(typeof WasmBackendModule!="undefined")Jd=WasmBackendModule;else if(typeof r!="undefined")Jd=r;else throw new Error("Could not find wasm module in post.js");if(Yd){var C$=Jd._dispose;Jd._dispose=function(){C$(),Yd.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Yd.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)}),rF=ft((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 kp||F("exiting due to exception: "+G)}var C,E,$;f?(m?g=wh().dirname(g)+"/":g=__dirname+"/",$=()=>{E||(C=yx(),E=wh())},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,Ze){Se?de(Se):te(Ze.buffer)})},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),p=process.argv.slice(2),process.on("uncaughtException",function(G){if(!(G instanceof kp))throw G}),process.on("unhandledRejection",function(G){throw G}),c=(G,te)=>{if(mp())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 V(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]]]},Ze=1;Ze{ee=G},Z;s.wasmBinary&&(Z=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Rs("no native wasm support detected");var ae,le=!1,ue;function ke(G,te){G||Rs(te)}function ye(G){var te=s["_"+G];return te}function Ie(G,te,de,Se,Ze){var nt={string:function(Mn){var Gr=0;if(Mn!=null&&Mn!==0){var jd=(Mn.length<<2)+1;Gr=wp(jd),tt(Mn,Gr,jd)}return Gr},array:function(Mn){var Gr=wp(Mn.length);return ct(Mn,Gr),Gr}};function Ue(Mn){return te==="string"?st(Mn):te==="boolean"?Boolean(Mn):Mn}var We=ye(G),Lt=[],Pa=0;if(Se)for(var Oa=0;Oa=Se);)++Ze;if(Ze-te>16&&G.subarray&&Be)return Be.decode(G.subarray(te,Ze));for(var nt="";te>10,56320|Pa&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 Ze=de,nt=de+Se-1,Ue=0;Ue=55296&&We<=57343){var Lt=G.charCodeAt(++Ue);We=65536+((We&1023)<<10)|Lt&1023}if(We<=127){if(de>=nt)break;te[de++]=We}else if(We<=2047){if(de+1>=nt)break;te[de++]=192|We>>6,te[de++]=128|We&63}else if(We<=65535){if(de+2>=nt)break;te[de++]=224|We>>12,te[de++]=128|We>>6&63,te[de++]=128|We&63}else{if(de+3>=nt)break;te[de++]=240|We>>18,te[de++]=128|We>>12&63,te[de++]=128|We>>6&63,te[de++]=128|We&63}}return te[de]=0,de-Ze}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 ct(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 Dn,Ut,Jt,Da,Rn,Gt,sa,ia,Br;function Ds(G){Dn=G,s.HEAP8=Ut=new Int8Array(G),s.HEAP16=Da=new Int16Array(G),s.HEAP32=Gt=new Int32Array(G),s.HEAPU8=Jt=new Uint8Array(G),s.HEAPU16=Rn=new Uint16Array(G),s.HEAPU32=sa=new Uint32Array(G),s.HEAPF32=ia=new Float32Array(G),s.HEAPF64=Br=new Float64Array(G)}var bd=s.INITIAL_MEMORY||16777216,Wr,xr=[],hp=[],Lo=[],bn=!1,xd=!1,vd=0;function mp(){return ie||vd>0}function wd(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)Sd(s.preRun.shift());gp(xr)}function kd(){bn=!0,gp(hp)}function J0(){xd=!0}function Id(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Nd(s.postRun.shift());gp(Lo)}function Sd(G){xr.unshift(G)}function Ra(G){hp.unshift(G)}function Nd(G){Lo.unshift(G)}var oa=0,zo=null,Vr=null;function Ng(G){oa++,s.monitorRunDependencies&&s.monitorRunDependencies(oa)}function Td(G){if(oa--,s.monitorRunDependencies&&s.monitorRunDependencies(oa),oa==0&&(zo!==null&&(clearInterval(zo),zo=null),Vr)){var te=Vr;Vr=null,te()}}s.preloadedImages={},s.preloadedAudios={};function Rs(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 Tg="data:application/octet-stream;base64,";function Cd(G){return G.startsWith(Tg)}function Ms(G){return G.startsWith("file://")}var xn;xn="tfjs-backend-wasm.wasm",Cd(xn)||(xn=y(xn));function fp(G){try{if(G==xn&&Z)return new Uint8Array(Z);if(v)return v(G);throw"both async and sync fetching of the wasm failed"}catch(te){Rs(te)}}function Cg(){if(!Z&&(h||m)){if(typeof fetch=="function"&&!Ms(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 fp(xn)});if(x)return new Promise(function(G,te){x(xn,function(de){G(new Uint8Array(de))},te)})}return Promise.resolve().then(function(){return fp(xn)})}function _g(){var G={env:Vo,wasi_snapshot_preview1:Vo};function te(Ue,We){var Lt=Ue.exports;s.asm=Lt,ae=s.asm.memory,Ds(ae.buffer),Wr=s.asm.__indirect_function_table,Ra(s.asm.__wasm_call_ctors),Td("wasm-instantiate")}Ng("wasm-instantiate");function de(Ue){te(Ue.instance)}function Se(Ue){return Cg().then(function(We){return WebAssembly.instantiate(We,G)}).then(function(We){return We}).then(Ue,function(We){F("failed to asynchronously prepare wasm: "+We),Rs(We)})}function Ze(){return!Z&&typeof WebAssembly.instantiateStreaming=="function"&&!Cd(xn)&&!Ms(xn)&&typeof fetch=="function"?fetch(xn,{credentials:"same-origin"}).then(function(Ue){var We=WebAssembly.instantiateStreaming(Ue,G);return We.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 Ze().catch(o),{}}var Z0,Q0;function gp(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?yp(de)():yp(de)(te.arg):de(te.arg===void 0?null:te.arg)}}function Ur(G){return G}function _d(G){var te=/\b_Z[\w\d_]+/g;return G.replace(te,function(de){var Se=de;return de===Se?de:Se+" ["+de+"]"})}var Ma=[];function yp(G){var te=Ma[G];return te||(G>=Ma.length&&(Ma.length=G+1),Ma[G]=te=Wr.get(G)),te}function e1(){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 Bo(G,te){Wr.set(G,te),Ma[G]=te}function Eg(){Rs("")}function bp(){return 2147483648}function Ed(G,te,de){Jt.copyWithin(G,te,te+de)}function vn(G){try{return ae.grow(G-Dn.byteLength+65535>>>16),Ds(ae.buffer),1}catch(te){}}function Ad(G){var te=Jt.length;G=G>>>0;var de=bp();if(G>de)return!1;for(var Se=1;Se<=4;Se*=2){var Ze=te*(1+.2/Se);Ze=Math.min(Ze,G+100663296);var nt=Math.min(de,Yt(Math.max(G,Ze),65536)),Ue=vn(nt);if(Ue)return!0}return!1}var Wo={mappings:{},buffers:[null,[],[]],printChar:function(G,te){var de=Wo.buffers[G];te===0||te===10?((G===1?P:F)(je(de,0)),de.length=0):de.push(te)},varargs:void 0,get:function(){Wo.varargs+=4;var G=Gt[Wo.varargs-4>>2];return G},getStr:function(G){var te=st(G);return te},get64:function(G,te){return G}};function Ag(G){return 0}function t1(G,te,de,Se,Ze){}function n1(G,te,de,Se){for(var Ze=0,nt=0;nt>2],We=Gt[te+4>>2];te+=8;for(var Lt=0;Lt>2]=Ze,0}function $g(G){re(G)}var $d=!1,Vo={abort:Eg,emscripten_get_heap_max:bp,emscripten_memcpy_big:Ed,emscripten_resize_heap:Ad,fd_close:Ag,fd_seek:t1,fd_write:n1,setTempRet0:$g},PA=_g(),a1=s.___wasm_call_ctors=function(){return(a1=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},Fg=s._init=function(){return(Fg=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)},Fd=s._get_threads_count=function(){return(Fd=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},Dd=s._register_tensor=function(){return(Dd=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},Rg=s._dispose_data=function(){return(Rg=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)},Rd=s._Add=function(){return(Rd=s._Add=s.asm.Add).apply(null,arguments)},Ps=s._AddN=function(){return(Ps=s._AddN=s.asm.AddN).apply(null,arguments)},Uo=s._All=function(){return(Uo=s._All=s.asm.All).apply(null,arguments)},Pg=s._Any=function(){return(Pg=s._Any=s.asm.Any).apply(null,arguments)},r1=s._ArgMax=function(){return(r1=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},Og=s._AvgPool=function(){return(Og=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},s1=s._BatchMatMul=function(){return(s1=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},Os=s._Ceil=function(){return(Os=s._Ceil=s.asm.Ceil).apply(null,arguments)},Lg=s._ClipByValue=function(){return(Lg=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},zg=s._Conv2D=function(){return(zg=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},Bg=s._Conv2DBackpropInput=function(){return(Bg=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},Wg=s._Cos=function(){return(Wg=s._Cos=s.asm.Cos).apply(null,arguments)},Vg=s._Cosh=function(){return(Vg=s._Cosh=s.asm.Cosh).apply(null,arguments)},Ug=s._CropAndResize=function(){return(Ug=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},Md=s._Cumprod=function(){return(Md=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Gg=s._Cumsum=function(){return(Gg=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},Hg=s._DepthToSpace=function(){return(Hg=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},jg=s._DepthwiseConv2dNative=function(){return(jg=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},qg=s._Elu=function(){return(qg=s._Elu=s.asm.Elu).apply(null,arguments)},Kg=s._Equal=function(){return(Kg=s._Equal=s.asm.Equal).apply(null,arguments)},Pd=s._Exp=function(){return(Pd=s._Exp=s.asm.Exp).apply(null,arguments)},Xg=s._FlipLeftRight=function(){return(Xg=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},Yg=s._Floor=function(){return(Yg=s._Floor=s.asm.Floor).apply(null,arguments)},Ls=s._FloorDiv=function(){return(Ls=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},xp=s._FusedBatchNorm=function(){return(xp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},Jg=s._FusedConv2D=function(){return(Jg=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},Zg=s._FusedDepthwiseConv2D=function(){return(Zg=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},Qg=s._Gather=function(){return(Qg=s._Gather=s.asm.Gather).apply(null,arguments)},Ve=s._GatherNd=function(){return(Ve=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},ey=s._Greater=function(){return(ey=s._Greater=s.asm.Greater).apply(null,arguments)},ty=s._GreaterEqual=function(){return(ty=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},ny=s._LeakyRelu=function(){return(ny=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},ay=s._Less=function(){return(ay=s._Less=s.asm.Less).apply(null,arguments)},ry=s._LessEqual=function(){return(ry=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},sy=s._Log=function(){return(sy=s._Log=s.asm.Log).apply(null,arguments)},vp=s._LogicalAnd=function(){return(vp=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Od=s._Max=function(){return(Od=s._Max=s.asm.Max).apply(null,arguments)},Ld=s._MaxPool=function(){return(Ld=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},iy=s._Maximum=function(){return(iy=s._Maximum=s.asm.Maximum).apply(null,arguments)},oy=s._Mean=function(){return(oy=s._Mean=s.asm.Mean).apply(null,arguments)},ly=s._Min=function(){return(ly=s._Min=s.asm.Min).apply(null,arguments)},uy=s._Minimum=function(){return(uy=s._Minimum=s.asm.Minimum).apply(null,arguments)},py=s._MirrorPad=function(){return(py=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},cy=s._Multiply=function(){return(cy=s._Multiply=s.asm.Multiply).apply(null,arguments)},Ct=s._Neg=function(){return(Ct=s._Neg=s.asm.Neg).apply(null,arguments)},dy=s._NonMaxSuppressionV3=function(){return(dy=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},hy=s._NonMaxSuppressionV4=function(){return(hy=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},my=s._NonMaxSuppressionV5=function(){return(my=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Go=s._NotEqual=function(){return(Go=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},zd=s._OneHot=function(){return(zd=s._OneHot=s.asm.OneHot).apply(null,arguments)},Bd=s._PadV2=function(){return(Bd=s._PadV2=s.asm.PadV2).apply(null,arguments)},Wd=s._Pow=function(){return(Wd=s._Pow=s.asm.Pow).apply(null,arguments)},fy=s._Prelu=function(){return(fy=s._Prelu=s.asm.Prelu).apply(null,arguments)},Vd=s._Prod=function(){return(Vd=s._Prod=s.asm.Prod).apply(null,arguments)},gy=s._RealDiv=function(){return(gy=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},i1=s._Relu=function(){return(i1=s._Relu=s.asm.Relu).apply(null,arguments)},Ud=s._Relu6=function(){return(Ud=s._Relu6=s.asm.Relu6).apply(null,arguments)},o1=s._ResizeBilinear=function(){return(o1=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},yy=s._Reverse=function(){return(yy=s._Reverse=s.asm.Reverse).apply(null,arguments)},by=s._RotateWithOffset=function(){return(by=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},xy=s._Round=function(){return(xy=s._Round=s.asm.Round).apply(null,arguments)},vy=s._Rsqrt=function(){return(vy=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},wy=s._ScatterNd=function(){return(wy=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},ky=s._SelectV2=function(){return(ky=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},Iy=s._Sigmoid=function(){return(Iy=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},Sy=s._Sin=function(){return(Sy=s._Sin=s.asm.Sin).apply(null,arguments)},Ny=s._Softmax=function(){return(Ny=s._Softmax=s.asm.Softmax).apply(null,arguments)},Ty=s._SparseFillEmptyRows=function(){return(Ty=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},Cy=s._SparseReshape=function(){return(Cy=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},_y=s._SparseSegmentReduction=function(){return(_y=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},Ey=s._Sqrt=function(){return(Ey=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},Ay=s._Square=function(){return(Ay=s._Square=s.asm.Square).apply(null,arguments)},$y=s._SquaredDifference=function(){return($y=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},Fy=s._Step=function(){return(Fy=s._Step=s.asm.Step).apply(null,arguments)},Dy=s._StridedSlice=function(){return(Dy=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},Ry=s._Sub=function(){return(Ry=s._Sub=s.asm.Sub).apply(null,arguments)},My=s._Sum=function(){return(My=s._Sum=s.asm.Sum).apply(null,arguments)},Py=s._Tan=function(){return(Py=s._Tan=s.asm.Tan).apply(null,arguments)},Oy=s._Tanh=function(){return(Oy=s._Tanh=s.asm.Tanh).apply(null,arguments)},Ly=s._Tile=function(){return(Ly=s._Tile=s.asm.Tile).apply(null,arguments)},zy=s._TopK=function(){return(zy=s._TopK=s.asm.TopK).apply(null,arguments)},By=s._Transform=function(){return(By=s._Transform=s.asm.Transform).apply(null,arguments)},Wy=s._Transpose=function(){return(Wy=s._Transpose=s.asm.Transpose).apply(null,arguments)},Vy=s.__FusedMatMul=function(){return(Vy=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},Uy=s._malloc=function(){return(Uy=s._malloc=s.asm.malloc).apply(null,arguments)},Gy=s._free=function(){return(Gy=s._free=s.asm.free).apply(null,arguments)},Hy=s.___errno_location=function(){return(Hy=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},jy=s._emscripten_main_thread_process_queued_calls=function(){return(jy=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Gd=s.stackSave=function(){return(Gd=s.stackSave=s.asm.stackSave).apply(null,arguments)},Hd=s.stackRestore=function(){return(Hd=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},wp=s.stackAlloc=function(){return(wp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},qy=s.dynCall_iijjiiii=function(){return(qy=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},Ky=s.dynCall_jiji=function(){return(Ky=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Ee;var Ho;function kp(G){this.name="ExitStatus",this.message="Program terminated with exit("+G+")",this.status=G}Vr=function G(){Ho||Ip(),Ho||(Vr=G)};function Ip(G){if(G=G||p,oa>0||(wd(),oa>0))return;function te(){Ho||(Ho=!0,s.calledRun=!0,!le&&(kd(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),Id()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),te()},1)):te()}s.run=Ip;function l1(G){ue=G,mp()||(s.onExit&&s.onExit(G),le=!0),c(G,new kp(G))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();Ip();var jo;l&&(jo={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 qo;if(typeof r!="undefined")qo=r;else if(typeof WasmBackendModuleThreadedSimd!="undefined")qo=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(jo){var Xy=qo._dispose;qo._dispose=function(){Xy(),jo.uncaughtException.forEach(function(G){process.removeListener("uncaughtException",G)}),jo.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)}),Zh=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}},oc=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--,kh(e,t,n)}function sF(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--,kh(e,n,a),kh(t,n,a)}function Gp(e,t,n){return Math.max(e,Math.min(t,n))}function iF(e){return e%2===0?e:e+1}function kh(e,t,n){let a=e[t];e[t]=e[n],e[n]=a}function oF(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function bi(e){R(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function ei(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||hn(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 fF(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 Ca(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=>ll(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:Ca(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 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 throw new Error(`Unknown data type ${e}`);return n}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 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 Kr(e){return typeof e=="string"||e instanceof String}function aI(e){return typeof e=="boolean"}function rI(e){return typeof e=="number"}function Qh(e){return Array.isArray(e)?Qh(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":rI(e)?"float32":Kr(e)?"string":aI(e)?"bool":"float32"}function es(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Ih(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 bx(e,t){let n=em(e,t);for(let a=0;aa*r,1);if(t==null||t==="float32")return al(e,new Float32Array(n));if(t==="int32")return al(e,new Int32Array(n));if(t==="bool")return al(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function xx(e){e.forEach(t=>{R(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function bF(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]=kF(n,a)})}};function vF(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...a)=>(wF(t,a[0],a[1]),a.join("="))),t}function wF(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function kF(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 wx}var wx=null;function IF(e){wx=e}var ab;function oI(){if(ab==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");ab=e}return ab}function SF(){let e=oI();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function kx(e,t){let n=SF();if(n.has(e))return n.get(e);{let a=t();return n.set(e,a),n.get(e)}}var Il="Abs",Sl="Acos",Nl="Acosh",ds="Add",xi="AddN",Tl="All",Cl="Any",vi="ArgMax",lc="ArgMin",_l="Asin",El="Asinh",Al="Atan",$l="Atanh",Fl="Atan2",wi="AvgPool",tm="AvgPoolGrad",uc="AvgPool3D",nm="AvgPool3DGrad",ki="BatchMatMul",Dl="BatchToSpaceND",am="Bincount",lI="BroadcastTo",rm="BroadcastArgs",Ii="Cast",Si="Ceil",hs="ClipByValue",sm="Complex",pc="ComplexAbs",Rl="Concat",Ni="Conv2D",im="Conv2DBackpropFilter",Ti="Conv2DBackpropInput",cc="Conv3D",om="Conv3DBackpropFilterV2",lm="Conv3DBackpropInputV2",Ci="Cos",_i="Cosh",Ml="Cumprod",Ei="Cumsum",Pl="CropAndResize",um="DenseBincount",Ol="DepthToSpace",Ai="DepthwiseConv2dNative",pm="DepthwiseConv2dNativeBackpropFilter",cm="DepthwiseConv2dNativeBackpropInput",dm="Diag",dc="Dilation2D",Sh="Dilation2DBackpropInput",Nh="Dilation2DBackpropFilter",$i="RealDiv",hm="Einsum",Fi="Elu",mm="EluGrad",Ll="Erf",zl="Equal",Di="Exp",Bl="ExpandDims",Wl="Expm1",fm="FFT",hc="Fill",Vl="FlipLeftRight",Ri="Floor",Mi="FloorDiv",Pi="FusedBatchNorm",Ul="GatherV2",Gl="GatherNd",Hl="Greater",Oi="GreaterEqual",Li="Identity",gm="IFFT",ym="Imag",jl="IsFinite",ql="IsInf",Kl="IsNan",zi="LeakyRelu",Xl="Less",Yl="LessEqual",bm="LinSpace",Bi="Log",Jl="Log1p",Zl="LogicalAnd",mc="LogicalNot",fc="LogicalOr",uI="LogSoftmax",gc="LRN",xm="LRNGrad",Wi="Max",Vi="Maximum",Ui="MaxPool",vm="MaxPoolGrad",yc="MaxPool3D",wm="MaxPool3DGrad",km="MaxPoolWithArgmax",Gi="Mean",Hi="Min",ji="Minimum",qi="MirrorPad",Ql="Mod",Im="Multinomial",Ki="Multiply",eu="Neg",tu="NotEqual",nu="NonMaxSuppressionV3",au="NonMaxSuppressionV4",ru="NonMaxSuppressionV5",su="OnesLike",Xi="OneHot",iu="Pack",Yi="PadV2",NF="Pool",Ji="Pow",Zi="Prelu",Qi="Prod",bc="Range",Sm="Real",ou="Reciprocal",eo="Relu",lu="Reshape",xc="ResizeNearestNeighbor",Nm="ResizeNearestNeighborGrad",to="ResizeBilinear",Tm="ResizeBilinearGrad",no="Relu6",ao="Reverse",ro="Round",so="Rsqrt",uu="ScatterNd",pu="Select",cu="Selu",du="Slice",io="Sin",hu="Sinh",mu="Sign",oo="Sigmoid",fu="Softplus",lo="Sqrt",uo="Sum",gu="SpaceToBatchND",yu="SplitV",po="Softmax",vc="SparseFillEmptyRows",bu="SparseReshape",wc="SparseSegmentMean",kc="SparseSegmentSum",Cm="SparseToDense",co="SquaredDifference",Ic="Square",xu="StridedSlice",_m="StringNGrams",Em="StringSplit",Am="StringToHashBucketFast",ho="Sub",mo="Tan",fo="Tanh",ms="Tile",vu="TopK",wu="Transform",go="Transpose",$m="Unique",ku="Unpack",Sc="UnsortedSegmentSum",Iu="ZerosLike",fs="Step",Th="FromPixels",Su="RotateWithOffset",ti="_FusedMatMul",ni="FusedConv2D",ai="FusedDepthwiseConv2D";function qr(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.warn(...e)}function TF(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.log(...e)}var ul=kx("kernelRegistry",()=>new Map),Hp=kx("gradRegistry",()=>new Map);function Ch(e,t){let n=Ix(e,t);return ul.get(n)}function bb(e){return Hp.get(e)}function _h(e){let t=ul.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 Nc(e){let{kernelName:t,backendName:n}=e,a=Ix(t,n);ul.has(a)&&qr(`The kernel '${t}' for backend '${n}' is already registered`),ul.set(a,e)}function pI(e){let{kernelName:t}=e;Hp.has(t)&&X().getBool("DEBUG")&&qr(`Overriding the gradient for '${t}'`),Hp.set(t,e)}function CF(e,t){let n=Ix(e,t);if(!ul.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);ul.delete(n)}function _F(e){if(!Hp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Hp.delete(e)}function EF(e,t){_h(e).forEach(n=>{let a=Object.assign({},n,{backendName:t});Nc(a)})}function Ix(e,t){return`${t}_${e}`}var k={};Me(k,{arraysEqual:()=>cs,assert:()=>R,assertNonNegativeIntegerDimensions:()=>xx,assertNonNull:()=>bi,assertShapesMatch:()=>Nn,bytesFromStringArray:()=>nI,bytesPerElement:()=>yb,checkConversionForErrors:()=>eI,clamp:()=>Gp,computeStrides:()=>kl,createScalarValue:()=>MF,createShuffledIndices:()=>hF,decodeString:()=>Eh,distSquared:()=>uF,encodeString:()=>Cc,fetch:()=>OF,fingerPrint64:()=>RF,flatten:()=>ei,getArrayFromDType:()=>Qk,getTypedArrayFromDType:()=>Zk,hasEncodingLoss:()=>gF,hexToLong:()=>Tc,indexToLoc:()=>xF,inferDtype:()=>Qh,inferFromImplicitShape:()=>fF,isBoolean:()=>aI,isFunction:()=>es,isInt:()=>ll,isNumber:()=>rI,isPromise:()=>vx,isScalarShape:()=>pF,isString:()=>Kr,isTypedArray:()=>hn,isValidDtype:()=>tI,locToIndex:()=>bF,makeOnesTypedArray:()=>bx,makeZerosNestedTypedArray:()=>yF,makeZerosTypedArray:()=>em,nearestDivisor:()=>Ih,nearestLargerEven:()=>iF,now:()=>jp,parseAxisParam:()=>Ca,randUniform:()=>lF,repeatedTry:()=>mF,rightPad:()=>Bp,shuffle:()=>Yk,shuffleCombo:()=>sF,sizeFromShape:()=>xt,sizeToSquarishShape:()=>dF,squeezeShape:()=>Jk,sum:()=>oF,swap:()=>kh,tanh:()=>cF,toNestedArray:()=>al,toTypedArray:()=>Fm});var x1=yi(O$()),Gs=x1.default||x1;function Tc(e){return Gs.fromString(e,!0,16)}var cI=Tc("c3a5c85c97cb3127"),Vs=Tc("b492b66fbe98f273"),wn=Tc("9ae16a3b2f90404f");function xb(e){return e.xor(e.shru(47))}function dI(e,t,n){let a=e.slice(t,t+n);return Gs.fromBytes(Array.from(a),!0,!0)}function yt(e,t){return dI(e,t,8)}function v1(e,t){return dI(e,t,4)}function Zt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Jr(e,t,n=Tc("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 AF(e,t,n,a,r,s){r=r.add(e),s=Zt(s.add(r).add(a),21);let i=r;return r=r.add(t),r=r.add(n),s=s.add(Zt(r,44)),[r.add(a),s.add(i)]}function Qd(e,t,n,a){return AF(yt(e,t),yt(e,t+8),yt(e,t+16),yt(e,t+24),n,a)}function $F(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=Zt(r,37).mul(n).add(a),i=Zt(a,25).add(r).mul(n);return Jr(s,i,n)}if(t>=4){let n=wn.add(t*2),a=v1(e,0);return Jr(a.shl(3).add(t),v1(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 xb(wn.mul(s).xor(cI.mul(i))).mul(wn)}return wn}function FF(e,t=e.length){let n=wn.add(t*2),a=yt(e,0).mul(Vs),r=yt(e,8),s=yt(e,t-8).mul(n),i=yt(e,t-16).mul(wn);return Jr(Zt(a.add(r),43).add(Zt(s,30)).add(i),a.add(Zt(r.add(wn),18)).add(s),n)}function DF(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=Zt(a.add(r),43).add(Zt(s,30)).add(i),l=Jr(o,a.add(Zt(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 Jr(Zt(u.add(p),43).add(Zt(d,30)).add(c),u.add(Zt(p.add(a),18)).add(d),n)}function RF(e,t=e.length){let n=Gs.fromNumber(81,!0);if(t<=32)return t<=16?$F(e,t):FF(e,t);if(t<=64)return DF(e,t);let a=n,r=n.mul(Vs).add(113),s=xb(r.mul(wn).add(113)).mul(wn),i=[Gs.UZERO,Gs.UZERO],o=[Gs.UZERO,Gs.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=Zt(a.add(r).add(i[0]).add(yt(e,l+8)),37).mul(Vs),r=Zt(r.add(i[1]).add(yt(e,l+48)),42).mul(Vs),a=a.xor(o[1]),r=r.add(i[0]).add(yt(e,l+40)),s=Zt(s.add(o[0]),33).mul(Vs),i=Qd(e,l,i[1].mul(Vs),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=Vs.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=Zt(a.add(r).add(i[0]).add(yt(e,l+8)),37).mul(d),r=Zt(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=Zt(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],Jr(Jr(i[0],o[0],d).add(xb(r).mul(cI)).add(s),Jr(i[1],o[1],d).add(a),d)}function MF(e,t){return t==="string"?Cc(e):Fm([e],t)}function PF(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Fm(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=ei(e)),X().getBool("DEBUG")&&eI(e,t),PF(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=jp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(r);else{r();for(let o of a)o.dataSync();s=Promise.resolve({kernelMs:jp()-i})}if(X().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{zF(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 zF(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 WF(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(!cs(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 w1=20,Tp=3,rb=7;function UF(e,t,n,a){let r=kl(t),s=GF(e,t,n,r),i=t.length,o=ph(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 GF(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"?$p(e):e;if(o>1)for(let u=0;uw1){let g=Tp*i,y=Array.from(e.slice(0,g)),b=Array.from(e.slice((o-Tp)*i,o*i));return n==="complex64"&&(y=$p(y),b=$p(b)),["["+y.map((x,v)=>Ap(x,r[v],n)).join(", ")+", ..., "+b.map((x,v)=>Ap(x,r[o-Tp+v],n)).join(", ")+"]"]}let f=n==="complex64"?$p(e):Array.from(e);return["["+f.map((g,y)=>Ap(g,r[y],n)).join(", ")+"]"]}let u=t.slice(1),p=a.slice(1),d=a[0]*i,c=[];if(o>w1){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||Qk(t,this.size),this.strides=kl(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;aEh(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(),Ba().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=Ba().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Eh(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 Ba().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Ba().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return el.print(this,e)}clone(){return this.throwIfDisposed(),el.clone(this)}toString(e=!1){let t=this.dataSync();return UF(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),el.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Ba().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 kx("Tensor",()=>Ae)}ne();var ts=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(!cs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Ba().disposeTensor(this),this.dataId=e.dataId,Ba().incRef(this,null)}dispose(){Ba().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(ts,Symbol.hasInstance,{value:e=>e instanceof Ae&&e.assign!=null&&e.assign instanceof Function});var Ga={};Me(Ga,{assertTypesMatch:()=>mI,getTensorsInContainer:()=>Sx,isTensorInList:()=>YF,makeTypesMatch:()=>$t});var vb;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(vb||(vb={}));var wb;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(wb||(wb={}));var kb;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(kb||(kb={}));var Ib;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(Ib||(Ib={}));var Sb;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(Sb||(Sb={}));var XF={float32:Ib,int32:wb,bool:kb,complex64:Sb};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 XF[e][t]}function Dm(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 YF(e,t){return t.some(n=>n.id===e.id)}function Sx(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 sb(e){return e.kernelName!=null}var k1=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()}},qp=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new k1}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){_h(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 oc)&&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 qp.nextTensorId++}nextVariableId(){return qp.nextVariableId++}clone(e){let t=L.runKernel(Li,{x:e}),n={x:e},a=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return L.runKernel(Ii,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,Ch(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=sb(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(sb(e)){let{kernelName:h,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=Ch(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=sb(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=bb(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"&&Kr(e[0])&&(r=e.map(o=>Cc(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 ts(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*yb(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 ts||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*yb(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=bb(e);o!=null&&(a=o.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((u,p)=>{if(u==null){let d=n[p],c=em(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=Sx(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=WF(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?ZF(r.shape):n,VF(i,s,l=>this.tidy(l),QF);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(es(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(es(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=jp(),n=await this.backend.time(e);return n.wallMs=jp()-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 k1;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}};qp.nextTensorId=0;qp.nextVariableId=0;function ZF(e){let t=bx(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 qp(t)}return IF(e._tfengine.ENV),jF(()=>e._tfengine),e._tfengine}var L=gI();function QF(e,t){let n={a:e,b:t};return L.runKernel(ds,n)}var _c={};Me(_c,{isBrowser:()=>yI,isMobile:()=>nD,mockIsMobile:()=>tD});function eD(){return typeof navigator!="undefined"&&navigator!=null}var Nb;function tD(e){Nb=e}function nD(e){if(Nb!==void 0)return Nb;if(e||eD()){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 Na=X();Na.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.")});Na.registerFlag("IS_BROWSER",()=>yI());Na.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Na.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Na.registerFlag("PROD",()=>!1);Na.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Na.getBool("DEBUG"));Na.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Na.registerFlag("IS_TEST",()=>!1);Na.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Na.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Na.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function lr(e,t){let n=e;if(hn(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let a=[];for(;Array.isArray(n)||hn(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)&&!hn(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),I1(a,r,t,n),e==null||!hn(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);!hn(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Fm(e,r):ei(e,[],!0);return L.makeTensor(i,s,r)}function Kp(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 B(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 vx(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 aD(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(sm,r)}var ns=B({complex_:aD});function gs(e,t,n,a){if(a==null&&(a=Qh(e)),a==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!hn(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){xx(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!hn(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=a!=="string"?Fm(e,a):ei(e,[],!0),L.makeTensor(e,t,a)}function Zn(e,t,n){let a=lr(e,n);return gs(e,t,a,n)}var Tb={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Ah=4;async function rD(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)+Ah*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 Nx=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function S1(e){return Nx?Buffer.byteLength(e):new Blob([e]).size}function iD(e){if(Nx)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 N1(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 Cx(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 Ec(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:S1(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:S1(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function lD(){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 uD(){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 pD(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function cD(){let e=lD(),t=uD(),n=pD();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}},dD=e=>Dt.registerSaveRouter(e),hD=e=>Dt.registerLoadRouter(e),mD=e=>Dt.getSaveHandlers(e),fD=(e,t)=>Dt.getLoadHandlers(e,t),Cb="tensorflowjs",_b=1,Ks="models_store",Xr="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 Eb(e){let t=e.result;t.createObjectStore(Ks,{keyPath:"modelPath"}),t.createObjectStore(Xr,{keyPath:"modelPath"})}var ri=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(Cb,_b);r.onupgradeneeded=()=>Eb(r),r.onsuccess=()=>{let s=r.result;if(t==null){let i=s.transaction(Ks,"readonly"),o=i.objectStore(Ks).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=Ec(t),o=s.transaction(Xr,"readwrite"),l=o.objectStore(Xr),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),p;u.onsuccess=()=>{p=s.transaction(Ks,"readwrite");let d=p.objectStore(Ks).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=c=>{l=o.objectStore(Xr);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)})}};ri.URL_SCHEME="indexeddb://";var II=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ri.URL_SCHEME)?gD(e.slice(ri.URL_SCHEME.length)):null;Dt.registerSaveRouter(II);Dt.registerLoadRouter(II);function gD(e){return new ri(e)}function yD(e){return e.startsWith(ri.URL_SCHEME)?e.slice(ri.URL_SCHEME.length):e}var bD=class{constructor(){this.indexedDB=kI()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(Cb,_b);n.onupgradeneeded=()=>Eb(n),n.onsuccess=()=>{let a=n.result,r=a.transaction(Xr,"readonly"),s=r.objectStore(Xr).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=yD(e),new Promise((t,n)=>{let a=this.indexedDB.open(Cb,_b);a.onupgradeneeded=()=>Eb(a),a.onsuccess=()=>{let r=a.result,s=r.transaction(Xr,"readwrite"),i=s.objectStore(Xr),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(Ks,"readwrite");let d=l.objectStore(Ks).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)})}},Ir="/",tl="tensorflowjs_models",SI="info",xD="model_topology",vD="weight_specs",wD="weight_data",kD="model_metadata";function NI(e){return{info:[tl,e,SI].join(Ir),topology:[tl,e,xD].join(Ir),weightSpecs:[tl,e,vD].join(Ir),weightData:[tl,e,wD].join(Ir),modelMetadata:[tl,e,kD].join(Ir)}}function TI(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function ID(e){let t=e.split(Ir);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Ir)}function SD(e){return e.startsWith(si.URL_SCHEME)?e.slice(si.URL_SCHEME.length):e}var si=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=Ec(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,iD(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=oD(s),t}};si.URL_SCHEME="localstorage://";var CI=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(si.URL_SCHEME)?ND(e.slice(si.URL_SCHEME.length)):null;Dt.registerSaveRouter(CI);Dt.registerLoadRouter(CI);function ND(e){return new si(e)}var TD=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=tl+Ir,n=Ir+SI;for(let a=0;a"scheme must not be undefined or null."),e.endsWith(rl)&&(e=e.slice(0,e.indexOf(rl))),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 ch(e){if(e.indexOf(rl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${pa.getSchemes().join(",")}`);return{scheme:e.split(rl)[0],path:e.split(rl)[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=ch(e).scheme,l=ch(e).path,u=o===ch(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 CD(){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+rl+r;t[s]=a[r]}}return t}async function _D(e){let t=ch(e);return pa.getManager(t.scheme).removeModel(t.path)}async function ED(e,t){return _I(e,t,!1)}async function AD(e,t){return _I(e,t,!0)}var $D=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 $D);try{pa.registerManager(si.URL_SCHEME,new TD)}catch(e){}try{pa.registerManager(ri.URL_SCHEME,new bD)}catch(e){}}var FD={importFetch:()=>L$()},ib,DD=class{constructor(){this.util=z$(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(ib==null&&(ib=FD.importFetch()),ib(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 DD);function He(e,t="float32",n){return t=t||"float32",xx(e),new jt(e,t,n)}function RD(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(Ii,a,r)}var oe=B({cast_:RD});function MD(e){let t={x:A(e,"x","clone","string_or_numeric")};return L.runKernel(Li,t)}var Nr=B({clone_:MD});function EI(e,t=!1){console.log(e.toString(t))}gI();var PD={buffer:He,cast:oe,clone:Nr,print:EI};qF(PD);var Qt={};Me(Qt,{browserFiles:()=>UD,browserHTTPRequest:()=>KD,concatenateArrayBuffers:()=>Tx,copyModel:()=>ED,decodeWeights:()=>vI,encodeWeights:()=>rD,fromMemory:()=>YD,getLoadHandlers:()=>fD,getModelArtifactsForJSON:()=>Cx,getModelArtifactsInfoForJSON:()=>Ec,getSaveHandlers:()=>mD,http:()=>Ex,isHTTPScheme:()=>Ab,listModels:()=>CD,loadWeights:()=>GD,moveModel:()=>AD,registerLoadRouter:()=>hD,registerSaveRouter:()=>dD,removeModel:()=>_D,weightsLoaderFactory:()=>$I,withSaveHandler:()=>JD});var OD="model",LD=".json",zD=".weights.bin";function T1(e){return new Promise(t=>setTimeout(t)).then(e)}var pl=class{constructor(e){if(!X().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(pl.URL_SCHEME)&&(e=e.slice(pl.URL_SCHEME.length)),(e==null||e.length===0)&&(e=OD),this.modelJsonFileName=e+LD,this.weightDataFileName=e+zD}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 T1(()=>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 T1(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Ec(e)}}}};pl.URL_SCHEME="downloads://";var BD=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=Cx(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,Tx(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=>N1(r.name)),a={};for(let r of e)r.paths.forEach(s=>{let i=N1(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}},WD=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(pl.URL_SCHEME)?VD(e.slice(pl.URL_SCHEME.length)):null;Dt.registerSaveRouter(WD);function VD(e="model"){return new pl(e)}function UD(e){return new BD(e)}function C1(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 C1(a,t.onProgress,r,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await C1(i,t.onProgress,o,l)}async function GD(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=Tb[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 HD="application/octet-stream",jD="application/json",_x=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:jD}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:HD}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Ec(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 Cx(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=qD(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,Tx(l)]}};_x.URL_SCHEME_REGEX=/^https?:\/\//;function qD(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function Ab(e){return e.match(_x.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=>Ab(a)):n=Ab(e),n)return Ex(e,t)}return null};Dt.registerSaveRouter(FI);Dt.registerLoadRouter(FI);function Ex(e,t){return new _x(e,t)}function KD(e,t){return Ex(e,t)}var ob=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},XD=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function YD(e,t,n,a){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new ob(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 ob({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 ob({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:a}))}function JD(e){return new XD(e)}var DI={};Me(DI,{confusionMatrix:()=>nR});function ZD(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(ki,i,o)}var De=B({matMul_:ZD});function QD(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(Xi,r,s)}var cl=B({oneHot_:QD});function eR(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(go,a,r)}var $e=B({transpose_:eR});function tR(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=cl(oe(a,"int32"),n),i=cl(oe(r,"int32"),n),o=$e(s),l=De(o,i);return oe(l,"int32")}var nR=B({confusionMatrix_:tR}),Nu={};Me(Nu,{assertAndGetBroadcastShape:()=>ht,getBroadcastDims:()=>RI,getReductionAxes:()=>Wt});function RI(e,t){let n=e.length,a=[];for(let r=0;r1&&i===1&&a.unshift(s)}return a}function Wt(e,t){let n=[];for(let a=0;a1)&&n.unshift(s)}return n}function ht(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;ruR,fromPixelsAsync:()=>oR,toPixels:()=>lR});function Rm(e,t,n){if(bi(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 gs(e,t,a,n)}var Bs;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