/* Face-API homepage: author: ' */ var PA=Object.defineProperty;var OA=(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 ob=(e,t)=>{for(var n in t)PA(e,n,{get:t[n],enumerable:!0})};var ze={};ob(ze,{Abs:()=>Tl,Acos:()=>_l,Acosh:()=>Cl,AdadeltaOptimizer:()=>gf,AdagradOptimizer:()=>yf,AdamOptimizer:()=>bf,AdamaxOptimizer:()=>xf,Add:()=>hs,AddN:()=>vi,All:()=>El,Any:()=>Fl,ArgMax:()=>wi,ArgMin:()=>cc,Asin:()=>Al,Asinh:()=>$l,Atan:()=>Dl,Atan2:()=>Ml,Atanh:()=>Rl,AvgPool:()=>ki,AvgPool3D:()=>dc,AvgPool3DGrad:()=>lm,AvgPoolGrad:()=>om,BackendWasm:()=>WE,BatchMatMul:()=>Ii,BatchToSpaceND:()=>Pl,Bincount:()=>um,BroadcastArgs:()=>pm,BroadcastTo:()=>dI,Callback:()=>xN,CallbackList:()=>I2,Cast:()=>Si,Ceil:()=>Ni,ClipByValue:()=>ms,Complex:()=>cm,ComplexAbs:()=>hc,Concat:()=>Ol,Conv2D:()=>Ti,Conv2DBackpropFilter:()=>dm,Conv2DBackpropInput:()=>_i,Conv3D:()=>mc,Conv3DBackpropFilterV2:()=>hm,Conv3DBackpropInputV2:()=>mm,Cos:()=>Ci,Cosh:()=>Ei,CropAndResize:()=>zl,Cumprod:()=>Ll,Cumsum:()=>Fi,CustomCallback:()=>N2,DataStorage:()=>rm,DenseBincount:()=>fm,DepthToSpace:()=>Bl,DepthwiseConv2dNative:()=>Ai,DepthwiseConv2dNativeBackpropFilter:()=>gm,DepthwiseConv2dNativeBackpropInput:()=>ym,Diag:()=>bm,Dilation2D:()=>fc,Dilation2DBackpropFilter:()=>Fh,Dilation2DBackpropInput:()=>Eh,ENV:()=>Tx,EarlyStopping:()=>vN,Einsum:()=>xm,Elu:()=>Di,EluGrad:()=>vm,Environment:()=>pI,Equal:()=>Vl,Erf:()=>Wl,Exp:()=>Ri,ExpandDims:()=>Ul,Expm1:()=>Gl,FFT:()=>wm,Fill:()=>gc,FlipLeftRight:()=>Hl,Floor:()=>Mi,FloorDiv:()=>Pi,FromPixels:()=>Ah,FusedBatchNorm:()=>Oi,FusedConv2D:()=>ai,FusedDepthwiseConv2D:()=>ri,GPGPUContext:()=>Sh,GatherNd:()=>ql,GatherV2:()=>jl,GraphModel:()=>o0,Greater:()=>Kl,GreaterEqual:()=>Li,History:()=>S2,IFFT:()=>km,Identity:()=>zi,Imag:()=>Im,InputSpec:()=>Bt,IsFinite:()=>Xl,IsInf:()=>Yl,IsNan:()=>Ql,KernelBackend:()=>pc,LRN:()=>xc,LRNGrad:()=>Nm,LayerVariable:()=>g2,LayersModel:()=>_r,LeakyRelu:()=>Bi,Less:()=>Jl,LessEqual:()=>Zl,LinSpace:()=>Sm,Log:()=>Wi,Log1p:()=>eu,LogSoftmax:()=>hI,LogicalAnd:()=>tu,LogicalNot:()=>yc,LogicalOr:()=>bc,LowerBound:()=>$$,MathBackendWebGL:()=>Gf,Max:()=>Vi,MaxPool:()=>Gi,MaxPool3D:()=>vc,MaxPool3DGrad:()=>_m,MaxPoolGrad:()=>Tm,MaxPoolWithArgmax:()=>Cm,Maximum:()=>Ui,Mean:()=>Hi,Min:()=>ji,Minimum:()=>qi,MirrorPad:()=>Ki,Mod:()=>nu,MomentumOptimizer:()=>vf,Multinomial:()=>Em,Multiply:()=>Xi,Neg:()=>au,NonMaxSuppressionV3:()=>su,NonMaxSuppressionV4:()=>iu,NonMaxSuppressionV5:()=>ou,NotEqual:()=>ru,OP_SCOPE_SUFFIX:()=>II,OneHot:()=>Yi,OnesLike:()=>lu,Optimizer:()=>$r,OptimizerConstructors:()=>qr,Pack:()=>uu,PadV2:()=>Qi,Pool:()=>D$,Pow:()=>Ji,Prelu:()=>Zi,Prod:()=>eo,RMSPropOptimizer:()=>wf,RNN:()=>fr,Range:()=>wc,Rank:()=>Nb,Real:()=>Fm,RealDiv:()=>$i,Reciprocal:()=>pu,Reduction:()=>kn,Relu:()=>to,Relu6:()=>ao,Reshape:()=>cu,ResizeBilinear:()=>no,ResizeBilinearGrad:()=>$m,ResizeNearestNeighbor:()=>kc,ResizeNearestNeighborGrad:()=>Am,Reverse:()=>ro,RotateWithOffset:()=>_u,Round:()=>so,Rsqrt:()=>io,SGDOptimizer:()=>Hc,ScatterNd:()=>du,SearchSorted:()=>Dm,Select:()=>hu,Selu:()=>mu,Sequential:()=>bl,Sigmoid:()=>lo,Sign:()=>yu,Sin:()=>oo,Sinh:()=>gu,Slice:()=>fu,Softmax:()=>co,Softplus:()=>bu,SpaceToBatchND:()=>xu,SparseFillEmptyRows:()=>Ic,SparseReshape:()=>wu,SparseSegmentMean:()=>Sc,SparseSegmentSum:()=>Nc,SparseToDense:()=>Rm,SplitV:()=>vu,Sqrt:()=>uo,Square:()=>Tc,SquaredDifference:()=>ho,Step:()=>gs,StridedSlice:()=>ku,StringNGrams:()=>Mm,StringSplit:()=>Pm,StringToHashBucketFast:()=>Om,Sub:()=>mo,Sum:()=>po,SymbolicTensor:()=>Ua,Tan:()=>fo,Tanh:()=>go,Tensor:()=>Fe,TensorBuffer:()=>qt,Tile:()=>fs,TopK:()=>Iu,Transform:()=>Su,Transpose:()=>Nr,Unique:()=>Lm,Unpack:()=>Nu,UnsortedSegmentSum:()=>_c,UpperBound:()=>R$,Variable:()=>as,ZerosLike:()=>Tu,_FusedMatMul:()=>ni,abs:()=>zt,acos:()=>Vx,acosh:()=>Ux,add:()=>J,addN:()=>rS,all:()=>Gm,any:()=>Jp,argMax:()=>oi,argMin:()=>Gx,asin:()=>Hx,asinh:()=>jx,atan:()=>qx,atan2:()=>Kx,atanh:()=>Xx,avgPool:()=>fa,avgPool3d:()=>Qx,backend:()=>BI,backend_util:()=>C,basicLSTMCell:()=>FM,batchNorm:()=>Er,batchNorm2d:()=>lS,batchNorm3d:()=>uS,batchNorm4d:()=>pS,batchToSpaceND:()=>Mc,bincount:()=>Jx,booleanMaskAsync:()=>P3,broadcastArgs:()=>cS,broadcastTo:()=>ol,broadcast_util:()=>Cu,browser:()=>yo,buffer:()=>Ve,callbacks:()=>d6,cast:()=>oe,ceil:()=>Zx,clipByValue:()=>an,clone:()=>Tr,complex:()=>Cr,concat:()=>Ze,concat1d:()=>dS,concat2d:()=>hS,concat3d:()=>mS,concat4d:()=>fS,constraints:()=>x2,conv1d:()=>Hm,conv2d:()=>Rt,conv2dTranspose:()=>jm,conv3d:()=>tv,conv3dTranspose:()=>yS,copyRegisteredKernels:()=>L$,cos:()=>Pc,cosh:()=>qm,cosineWindow:()=>Ev,cumprod:()=>Zp,cumsum:()=>Km,customGrad:()=>ur,data:()=>GN,denseBincount:()=>bS,deprecationWarn:()=>Mx,depthToSpace:()=>nv,depthwiseConv2d:()=>xs,deregisterOp:()=>f6,device_util:()=>Ac,diag:()=>oP,dilation2d:()=>av,disableDeprecationWarnings:()=>dR,dispose:()=>Re,disposeVariables:()=>hR,div:()=>fe,divNoNan:()=>rv,dot:()=>xS,dropout:()=>VS,einsum:()=>vS,elu:()=>Eu,enableDebugMode:()=>cR,enableProdMode:()=>pR,enclosingPowerOfTwo:()=>US,engine:()=>ar,env:()=>X,equal:()=>Jn,erf:()=>sv,euclideanNorm:()=>lv,exp:()=>gn,expandDims:()=>mn,expm1:()=>uv,eye:()=>pv,fft:()=>Uc,fill:()=>_n,findBackend:()=>vR,findBackendFactory:()=>wR,floor:()=>Fu,floorDiv:()=>Um,forceHalfFloat:()=>lC,fused:()=>ss,gather:()=>pi,gatherND:()=>WS,gather_util:()=>Px,getBackend:()=>bR,getGradient:()=>Ib,getKernel:()=>$h,getKernelsForBackend:()=>Dh,getThreadsCount:()=>Cue,gpgpu_util:()=>B_,grad:()=>HP,grads:()=>jP,greater:()=>Un,greaterEqual:()=>vs,ifft:()=>fl,imag:()=>Dc,image:()=>Ln,inTopKAsync:()=>j3,initializers:()=>v2,input:()=>z2,io:()=>en,irfft:()=>uf,isFinite:()=>NS,isInf:()=>TS,isNaN:()=>cv,keep:()=>tn,kernel_impls:()=>mr,layers:()=>w2,leakyRelu:()=>Lc,less:()=>Xm,lessEqual:()=>ws,linalg:()=>ZS,linspace:()=>_S,loadGraphModel:()=>bH,loadGraphModelSync:()=>xH,loadLayersModel:()=>kU,localResponseNormalization:()=>dv,log:()=>Zn,log1p:()=>zc,logSigmoid:()=>ES,logSoftmax:()=>Qm,logSumExp:()=>hv,logicalAnd:()=>Ta,logicalNot:()=>Bc,logicalOr:()=>Jm,logicalXor:()=>FS,losses:()=>Cz,lowerBound:()=>AS,matMul:()=>De,math:()=>zI,max:()=>Sa,maxPool:()=>Pt,maxPool3d:()=>fv,maxPoolWithArgmax:()=>$S,maximum:()=>hr,mean:()=>Et,memory:()=>Ph,meshgrid:()=>pO,metrics:()=>gN,min:()=>ec,minimum:()=>Au,mirrorPad:()=>gv,mod:()=>yv,model:()=>vU,models:()=>yN,moments:()=>Zm,movingAverage:()=>L3,mul:()=>B,multiRNNCell:()=>gO,multinomial:()=>DS,neg:()=>wt,nextFrame:()=>$v,norm:()=>Oc,notEqual:()=>ci,oneHot:()=>dl,ones:()=>Yn,onesLike:()=>ea,op:()=>z,outerProduct:()=>wO,pad:()=>ga,pad1d:()=>SO,pad2d:()=>TO,pad3d:()=>CO,pad4d:()=>FO,pool:()=>RS,pow:()=>Fr,prelu:()=>Vc,print:()=>DI,prod:()=>ef,profile:()=>mR,rand:()=>LO,randomGamma:()=>VO,randomNormal:()=>MS,randomUniform:()=>$u,range:()=>ml,ready:()=>yR,real:()=>hl,reciprocal:()=>vv,registerBackend:()=>Wm,registerCallbackConstructor:()=>IU,registerGradient:()=>mI,registerKernel:()=>Cc,registerOp:()=>m6,regularizers:()=>bN,relu:()=>Xe,relu6:()=>tf,removeBackend:()=>xR,reshape:()=>W,reverse:()=>ta,reverse1d:()=>YO,reverse2d:()=>JO,reverse3d:()=>e3,reverse4d:()=>n3,rfft:()=>Gc,round:()=>nf,rsqrt:()=>af,scalar:()=>we,scatterND:()=>BS,scatter_util:()=>Ox,searchSorted:()=>mv,selu:()=>rf,separableConv2d:()=>xo,sequential:()=>wU,serialization:()=>se,setBackend:()=>gR,setPlatform:()=>kR,setThreadsCount:()=>_ue,setWasmPath:()=>Nue,setWasmPaths:()=>Tue,setWebGLContext:()=>p_,setdiff1dAsync:()=>PS,sigmoid:()=>ha,sign:()=>wv,signal:()=>_z,sin:()=>sf,sinh:()=>of,slice:()=>He,slice1d:()=>lf,slice2d:()=>kv,slice3d:()=>Du,slice4d:()=>tc,slice_util:()=>Kt,softmax:()=>Qa,softplus:()=>bo,spaceToBatchND:()=>Wc,sparse:()=>Mp,sparseToDense:()=>Cv,spectral:()=>Tz,split:()=>zn,sqrt:()=>un,square:()=>lt,squaredDifference:()=>pf,squeeze:()=>pr,stack:()=>Mt,step:()=>Ru,stridedSlice:()=>Iv,string:()=>yh,sub:()=>ce,sum:()=>be,sumOutType:()=>Bm,tan:()=>Sv,tanh:()=>li,tensor:()=>Qn,tensor1d:()=>qe,tensor2d:()=>Ha,tensor3d:()=>Vm,tensor4d:()=>Ja,tensor5d:()=>_3,tensor6d:()=>C3,tensor_util:()=>Ga,test_util:()=>tS,tidy:()=>O,tile:()=>On,time:()=>fR,topk:()=>Nv,train:()=>Gs,transpose:()=>Ae,truncatedNormal:()=>cf,unique:()=>Lh,unregisterGradient:()=>O$,unregisterKernel:()=>P$,unsortedSegmentSum:()=>Tv,unstack:()=>ht,upcastType:()=>ma,upperBound:()=>OS,util:()=>w,valueAndGrad:()=>qP,valueAndGrads:()=>KP,variable:()=>LS,variableGrads:()=>CS,version:()=>zue,version_converter:()=>wH,version_core:()=>JR,version_layers:()=>ew,version_wasm:()=>Eue,version_webgl:()=>P9,webgl:()=>O9,webgl_util:()=>u_,where:()=>fn,whereAsync:()=>_v,zeros:()=>St,zerosLike:()=>Ke});var LA=Object.create,wx=Object.defineProperty,zA=Object.getOwnPropertyDescriptor,BA=Object.getOwnPropertyNames,WA=Object.getPrototypeOf,VA=Object.prototype.hasOwnProperty,ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Me=(e,t)=>{for(var n in t)wx(e,n,{get:t[n],enumerable:!0})},UA=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of BA(t))!VA.call(e,r)&&r!==n&&wx(e,r,{get:()=>t[r],enumerable:!(a=zA(t,r))||a.enumerable});return e},bi=(e,t,n)=>(n=e!=null?LA(WA(e)):{},UA(t||!e||!e.__esModule?wx(n,"default",{value:e,enumerable:!0}):n,e)),GA=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,P,V){this.low=S|0,this.high=P|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,P){var V,j,q;return P?(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,P){if(isNaN(S))return P?v:x;if(P){if(S<0)return v;if(S>=g)return A}else{if(S<=-y)return M;if(S+1>=y)return E}return S<0?l(-S,P).neg():u(S%f|0,S/f|0,P)}a.fromNumber=l;function u(S,P,V){return new a(S,P,V)}a.fromBits=u;var p=Math.pow;function d(S,P,V){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof P=="number"?(V=P,P=!1):P=!!P,V=V||10,V<2||360)throw Error("interior hyphen");if(j===0)return d(S.substring(1),P,V).neg();for(var q=l(p(V,8)),K=x,Z=0;Z>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},$.toString=function(S){if(S=S||10,S<2||36>>0,Y=re.toString(S);if(K=ee,K.isZero())return Y+Z;for(;Y.length<6;)Y="0"+Y;Z=""+Y+Z}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,P=31;P>0&&(S&1<=0},$.isOdd=function(){return(this.low&1)===1},$.isEven=function(){return(this.low&1)===0},$.equals=function(S){return 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},$.eq=$.equals,$.notEquals=function(S){return!this.eq(S)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(S){return this.comp(S)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(S){return this.comp(S)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(S){return this.comp(S)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(S){return this.comp(S)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(S){if(r(S)||(S=c(S)),this.eq(S))return 0;var P=this.isNegative(),V=S.isNegative();return P&&!V?-1:!P&&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},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(k)},$.neg=$.negate,$.add=function(S){r(S)||(S=c(S));var P=this.high>>>16,V=this.high&65535,j=this.low>>>16,q=this.low&65535,K=S.high>>>16,Z=S.high&65535,ee=S.low>>>16,re=S.low&65535,Y=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+Z,Y+=ie>>>16,ie&=65535,Y+=P+K,Y&=65535,u(ae<<16|le,Y<<16|ie,this.unsigned)},$.subtract=function(S){return r(S)||(S=c(S)),this.add(S.neg())},$.sub=$.subtract,$.multiply=function(S){if(this.isZero())return x;if(r(S)||(S=c(S)),n){var P=n.mul(this.low,this.high,S.low,S.high);return u(P,n.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(M))return S.isOdd()?M:x;if(S.eq(M))return this.isOdd()?M: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,Z=S.high>>>16,ee=S.high&65535,re=S.low>>>16,Y=S.low&65535,ie=0,ae=0,le=0,ue=0;return ue+=K*Y,le+=ue>>>16,ue&=65535,le+=q*Y,ae+=le>>>16,le&=65535,le+=K*re,ae+=le>>>16,le&=65535,ae+=j*Y,ie+=ae>>>16,ae&=65535,ae+=q*re,ie+=ae>>>16,ae&=65535,ae+=K*ee,ie+=ae>>>16,ae&=65535,ie+=V*Y+j*re+q*ee+K*Z,ie&=65535,u(le<<16|ue,ie<<16|ae,this.unsigned)},$.mul=$.multiply,$.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 P=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,S.low,S.high);return u(P,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(M)){if(S.eq(k)||S.eq(_))return M;if(S.eq(M))return k;var K=this.shr(1);return V=K.div(S).shl(1),V.eq(x)?S.isNegative()?k:_:(j=this.sub(S.mul(V)),q=V.add(j.div(S)),q)}else if(S.eq(M))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 Z=Math.ceil(Math.log(V)/Math.LN2),ee=Z<=48?1:p(2,Z-48),re=l(V),Y=re.mul(S);Y.isNegative()||Y.gt(j);)V-=ee,re=l(V,this.unsigned),Y=re.mul(S);re.isZero()&&(re=k),q=q.add(re),j=j.sub(Y)}return q},$.div=$.divide,$.modulo=function(S){if(r(S)||(S=c(S)),n){var P=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,S.low,S.high);return u(P,n.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return u(~this.low,~this.high,this.unsigned)},$.and=function(S){return r(S)||(S=c(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},$.or=function(S){return r(S)||(S=c(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},$.xor=function(S){return r(S)||(S=c(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},$.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)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(S){if(r(S)&&(S=S.toInt()),S&=63,S===0)return this;var P=this.high;if(S<32){var V=this.low;return u(V>>>S|P<<32-S,P>>>S,this.unsigned)}else return S===32?u(P,0,this.unsigned):u(P>>>S-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},$.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var S=this.high,P=this.low;return[P&255,P>>>8&255,P>>>16&255,P>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},$.toBytesBE=function(){var S=this.high,P=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,P>>>24,P>>>16&255,P>>>8&255,P&255]},a.fromBytes=function(S,P,V){return V?a.fromBytesLE(S,P):a.fromBytesBE(S,P)},a.fromBytesLE=function(S,P){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,P)},a.fromBytesBE=function(S,P){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],P)}}),HA=ft(()=>{}),jA=ft(()=>{}),qA=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)}),KA=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)}),XA=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)}),YA=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)}),QA=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)}),JA=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)}),Yk=ft(()=>{}),ZA=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(k,T,_){var E=[];T=T==!0?{entropy:!0}:T||{};var A=b(y(T.entropy?[k,v(n)]:k==null?x():k,3),E),M=new f(E),$=function(){for(var S=M.g(i),P=u,V=0;S=d;)S/=2,P/=2,V>>>=1;return(S+V)/P};return $.int32=function(){return M.g(4)|0},$.quick=function(){return M.g(4)/4294967296},$.double=$,b(v(M.S),n),(T.pass||_||function(S,P,V,j){return j&&(j.S&&g(j,M),S.state=function(){return g(M,{})}),V?(a[l]=S,P):S})($,A,"global"in T?T.global:this==a,T.state)}a["seed"+l]=m;function f(k){var T,_=k.length,E=this,A=0,M=E.i=E.j=0,$=E.S=[];for(_||(k=[_++]);A{var n=qA(),a=KA(),r=XA(),s=YA(),i=QA(),o=JA(),l=ZA();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),e$=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)}),t$=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)}),n$=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)}),a$=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)}),r$=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)}),s$=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)}),i$=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(k,T,_){var E=[];T=T==!0?{entropy:!0}:T||{};var A=b(y(T.entropy?[k,v(a)]:k==null?x():k,3),E),M=new f(E),$=function(){for(var S=M.g(i),P=u,V=0;S=d;)S/=2,P/=2,V>>>=1;return(S+V)/P};return $.int32=function(){return M.g(4)|0},$.quick=function(){return M.g(4)/4294967296},$.double=$,b(v(M.S),a),(T.pass||_||function(S,P,V,j){return j&&(j.S&&g(j,M),S.state=function(){return g(M,{})}),V?(r[l]=S,P):S})($,A,"global"in T?T.global:this==r,T.state)}function f(k){var T,_=k.length,E=this,A=0,M=E.i=E.j=0,$=E.S=[];for(_||(k=[_++]);A{var n=e$(),a=t$(),r=n$(),s=a$(),i=r$(),o=s$(),l=i$();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),Zk=ft(()=>{}),kx=ft(()=>{}),Th=ft(()=>{}),o$=ft(()=>{}),l$=ft(()=>{}),u$=ft(()=>{}),p$=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),Id}function i(){return Te.buffer!=bn&&Ra(Te.buffer),Sd}function o(){return Te.buffer!=bn&&Ra(Te.buffer),yp}function l(){return Te.buffer!=bn&&Ra(Te.buffer),Nd}function u(){return Te.buffer!=bn&&Ra(Te.buffer),Td}function p(){return Te.buffer!=bn&&Ra(Te.buffer),_d}function d(){return Te.buffer!=bn&&Ra(Te.buffer),Cd}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",k=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",_=c.ENVIRONMENT_IS_PTHREAD||!1,E="";function A(N){return c.locateFile?c.locateFile(N,E):E+N}var M,$,S,P;function V(N){N instanceof _p||Y("exiting due to exception: "+N)}var j,q,K;if(T){k?E=Th().dirname(E)+"/":E=__dirname+"/",K=()=>{q||(j=kx(),q=Th())},M=function(D,U){return K(),D=q.normalize(D),j.readFileSync(D,U?void 0:"utf8")},S=D=>{var U=M(D,!0);return U.buffer||(U=new Uint8Array(U)),U},$=(D,U,Q)=>{K(),D=q.normalize(D),j.readFile(D,function(pe,he){pe?Q(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 _p))throw D}),process.on("unhandledRejection",function(D){throw D}),x=(D,U)=>{if(Ps())throw process.exitCode=D,U;V(U),process.exit(D)},c.inspect=function(){return"[Emscripten Module object]"};let N;try{N=o$()}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||k)&&(k?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||(M=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.send(null),D.responseText},k&&(S=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),$=(N,D,U)=>{var Q=new XMLHttpRequest;Q.open("GET",N,!0),Q.responseType="arraybuffer",Q.onload=()=>{if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}U()},Q.onerror=U,Q.send(null)}),P=N=>document.title=N);T&&typeof performance=="undefined"&&(global.performance=l$().performance);var Z=console.log.bind(console),ee=console.warn.bind(console);T&&(K(),Z=N=>j.writeSync(1,N+` `),ee=N=>j.writeSync(2,N+` `));var re=c.print||Z,Y=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,Y(N))}function le(N,D){if(typeof WebAssembly.Function=="function"){for(var U={i:"i32",j:"i64",f:"f32",d:"f64"},Q={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 Qt(N,D){N||Bo(D)}function Dn(N){var D=c["_"+N];return D}function Gt(N,D,U,Q,pe){var he={string:function(la){var Yo=0;if(la!=null&&la!==0){var S1=(la.length<<2)+1;Yo=Xo(S1),Rs(la,Yo,S1)}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 _e=Dn(N),Ct=[],La=0;if(Q)for(var za=0;za(U.buffer instanceof SharedArrayBuffer&&(U=new Uint8Array(U)),D.decode.call(D,U))}var Ht=typeof TextDecoder!="undefined"?new Rn("utf8"):void 0;function sa(N,D,U){for(var Q=D+U,pe=D;N[pe]&&!(pe>=Q);)++pe;if(pe-D>16&&N.subarray&&Ht)return Ht.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 Vr(N,D,U,Q){if(!(Q>0))return 0;for(var pe=U,he=U+Q-1,ve=0;ve=55296&&_e<=57343){var Ct=N.charCodeAt(++ve);_e=65536+((_e&1023)<<10)|Ct&1023}if(_e<=127){if(U>=he)break;D[U++]=_e}else if(_e<=2047){if(U+1>=he)break;D[U++]=192|_e>>6,D[U++]=128|_e&63}else if(_e<=65535){if(U+2>=he)break;D[U++]=224|_e>>12,D[U++]=128|_e>>6&63,D[U++]=128|_e&63}else{if(U+3>=he)break;D[U++]=240|_e>>18,D[U++]=128|_e>>12&63,D[U++]=128|_e>>6&63,D[U++]=128|_e&63}}return D[U]=0,U-pe}function Rs(N,D,U){return Vr(N,i(),D,U)}function kd(N){for(var D=0,U=0;U=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|N.charCodeAt(++U)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}var Ur=typeof TextDecoder!="undefined"?new Rn("utf-16le"):void 0;function xr(N,D){s().set(N,D)}function gp(N,D,U){for(var Q=0;Q>0]=N.charCodeAt(Q);U||(s()[D>>0]=0)}function Lo(N,D){return N%D>0&&(N+=D-N%D),N}var bn,Id,Sd,yp,Nd,Td,r1,_d,Cd;_&&(bn=c.buffer);function Ra(N){bn=N,c.HEAP8=Id=new Int8Array(N),c.HEAP16=yp=new Int16Array(N),c.HEAP32=Td=new Int32Array(N),c.HEAPU8=Sd=new Uint8Array(N),c.HEAPU16=Nd=new Uint16Array(N),c.HEAPU32=r1=new Uint32Array(N),c.HEAPF32=_d=new Float32Array(N),c.HEAPF64=Cd=new Float64Array(N)}var Ed=c.INITIAL_MEMORY||16777216;if(_)Te=c.wasmMemory,bn=c.buffer;else if(c.wasmMemory)Te=c.wasmMemory;else if(Te=new WebAssembly.Memory({initial:Ed/65536,maximum:32768,shared:!0}),!(Te.buffer instanceof SharedArrayBuffer))throw Y("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),Ed=bn.byteLength,Ra(bn);var oa,zo=[],Gr=[],Fg=[],Fd=[],Ms=!1,Ag=!1,Ad=0;function Ps(){return tt||Ad>0}function xn(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)s1(c.preRun.shift());Md(zo)}function bp(){Ms=!0,!_&&Md(Gr)}function $g(){_||(Ce.terminateAllThreads(),Ag=!0)}function Dg(){if(!_){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)xp(c.postRun.shift());Md(Fd)}}function s1(N){zo.unshift(N)}function i1(N){Gr.unshift(N)}function xp(N){Fd.unshift(N)}var Hr=0,$d=null,Ma=null;function vp(N){Hr++,c.monitorRunDependencies&&c.monitorRunDependencies(Hr)}function o1(N){if(Hr--,c.monitorRunDependencies&&c.monitorRunDependencies(Hr),Hr==0&&($d!==null&&(clearInterval($d),$d=null),Ma)){var D=Ma;Ma=null,D()}}c.preloadedImages={},c.preloadedAudios={};function Bo(N){_?postMessage({cmd:"onAbort",arg:N}):c.onAbort&&c.onAbort(N),N="Aborted("+N+")",Y(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 Rg="data:application/octet-stream;base64,";function wp(N){return N.startsWith(Rg)}function Dd(N){return N.startsWith("file://")}var vn;vn="tfjs-backend-wasm-threaded-simd.wasm",wp(vn)||(vn=A(vn));function Rd(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||k)){if(typeof fetch=="function"&&!Dd(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 Rd(vn)});if($)return new Promise(function(N,D){$(vn,function(U){N(new Uint8Array(U))},D)})}return Promise.resolve().then(function(){return Rd(vn)})}function Mg(){var N={env:qd,wasi_snapshot_preview1:qd};function D(ve,_e){var Ct=ve.exports;if(c.asm=Ct,Vg(c.asm.emscripten_tls_init),oa=c.asm.__indirect_function_table,i1(c.asm.__wasm_call_ctors),gt=_e,!_){var La=Ce.unusedWorkers.length;Ce.unusedWorkers.forEach(function(za){Ce.loadWasmModuleToWorker(za,function(){--La||o1("wasm-instantiate")})})}}_||vp("wasm-instantiate");function U(ve){D(ve.instance,ve.module)}function Q(ve){return Wo().then(function(_e){return WebAssembly.instantiate(_e,N)}).then(function(_e){return _e}).then(ve,function(_e){Y("failed to asynchronously prepare wasm: "+_e),Bo(_e)})}function pe(){return!et&&typeof WebAssembly.instantiateStreaming=="function"&&!wp(vn)&&!Dd(vn)&&typeof fetch=="function"?fetch(vn,{credentials:"same-origin"}).then(function(ve){var _e=WebAssembly.instantiateStreaming(ve,N);return _e.then(U,function(Ct){return Y("wasm streaming compile failed: "+Ct),Y("falling back to ArrayBuffer instantiation"),Q(U)})}):Q(U)}if(c.instantiateWasm)try{var he=c.instantiateWasm(N,D);return he}catch(ve){return Y("Module.instantiateWasm callback failed with error: "+ve),!1}return pe().catch(m),{}}var l1,u1,Pg={};function Md(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=sb(),U=N();return Jd(D),U}function UF(N){return N}function p1(N){var D=/\b_Z[\w\d_]+/g;return N.replace(D,function(U){var Q=U;return U===Q?U:Q+" ["+U+"]"})}function Og(N){u()[N>>2]=0;var D=Ce.pthreads[N];delete Ce.pthreads[N],D.worker.terminate(),rb(N),Ce.runningWorkers.splice(Ce.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function Lg(N){var D=Ce.pthreads[N];D.worker.postMessage({cmd:"cancel"})}function Pd(N){var D=Ce.pthreads[N];if(D){u()[N>>2]=0;var U=D.worker;Ce.returnWorkerToPool(U)}}function Od(N){$A(N)}function zg(N){if(N instanceof _p||N=="unwind")return yn;x(1,N)}var Ce={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){_?Ce.initWorker():Ce.initMainThread()},initMainThread:function(){for(var N=8,D=0;D>2]=0;try{N()}finally{u()[I1>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in Ce.tlsInitFunctions)Ce.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=U=>{var Q=U.data,pe=Q.cmd;if(N.pthread&&(Ce.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Q.targetThread&&Q.targetThread!=Qd()){var he=Ce.pthreads[Q.targetThread];he?he.worker.postMessage(Q,Q.transferList):Y('Internal error! Worker sent a message "'+pe+'" to target pthread '+Q.targetThread+", but that thread no longer exists!"),Ce.currentProxiedOperationCallerThread=void 0;return}pe==="processQueuedMainThreadWork"?b1():pe==="spawnThread"?zd(Q):pe==="cleanupThread"?Pd(Q.thread):pe==="killThread"?Og(Q.thread):pe==="cancelThread"?Lg(Q.thread):pe==="loaded"?(N.loaded=!0,D&&D(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):pe==="print"?re("Thread "+Q.threadId+": "+Q.text):pe==="printErr"?Y("Thread "+Q.threadId+": "+Q.text):pe==="alert"?alert("Thread "+Q.threadId+": "+Q.text):Q.target==="setimmediate"?N.postMessage(Q):pe==="onAbort"?c.onAbort&&c.onAbort(Q.arg):Y("worker sent an unknown command "+pe),Ce.currentProxiedOperationCallerThread=void 0},N.onerror=U=>{var Q="worker sent an error!";throw Y(Q+" "+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=A("tfjs-backend-wasm-threaded-simd.worker.js");Ce.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return Ce.unusedWorkers.length==0&&(Ce.allocateUnusedWorker(),Ce.loadWasmModuleToWorker(Ce.unusedWorkers[0])),Ce.unusedWorkers.pop()}};function Bg(){var N=Qd(),D=u()[N+44>>2],U=u()[N+48>>2],Q=D-U;k1(D,Q),Jd(D)}c.establishStackSpace=Bg;function Ld(N){if(_)return zs(1,0,N);try{Od(N)}catch(D){zg(D)}}var Os=[];function Uo(N){var D=Os[N];return D||(N>=Os.length&&(Os.length=N+1),Os[N]=D=oa.get(N)),D}function Wg(N,D){return Uo(N)(D)}c.invokeEntryPoint=Wg;function c1(){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 Vg(N,D,U){Ce.tlsInitFunctions.push(N)}function d1(N,D){oa.set(N,D),Os[N]=D}var Ls;T?Ls=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:_?Ls=()=>performance.now()-c.__performance_now_clock_drift:Ls=()=>performance.now();var Ug=!0;function Gg(N){return u()[y1()>>2]=N,N}function Hg(N,D){var U;if(N===0)U=Date.now();else if((N===1||N===4)&&Ug)U=Ls();else return Gg(28),-1;return u()[D>>2]=U/1e3|0,u()[D+4>>2]=U%1e3*1e3*1e3|0,0}function jg(N,D){return Hg(N,D)}function qg(N){x1(N,!k,1,!v),Ce.threadInit()}function Kg(N){_?postMessage({cmd:"cleanupThread",thread:N}):Pd(N)}function zd(N){var D=Ce.getNewWorker();if(!D)return 6;Ce.runningWorkers.push(D);var U=Ce.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=U;var Q={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return D.runPthread=()=>{Q.time=performance.now(),D.postMessage(Q,N.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function Xg(N,D,U,Q){if(typeof SharedArrayBuffer=="undefined")return Y("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var pe=[],he=0;if(_&&(pe.length===0||he))return v1(687865856,N,D,U,Q);if(he)return he;var ve={startRoutine:U,pthread_ptr:N,arg:Q,transferList:pe};return _?(ve.cmd="spawnThread",postMessage(ve,pe),0):zd(ve)}function Yg(){return 2097152}function Qg(N,D){if(N==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(_)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var U=Ce.pthreads[N],Q=U&&U.worker;if(!Q)return;Q.postMessage({cmd:"processThreadQueue"})}return 1}function Jg(){Bo("")}function Zg(){T||k||ae("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Bd(){return 2147483648}function ey(N,D,U){i().copyWithin(N,D,D+U)}function ty(){return T?u$().cpus().length:navigator.hardwareConcurrency}function zs(N,D){var U=arguments.length-2,Q=arguments;return Vo(function(){for(var pe=U,he=Xo(pe*8),ve=he>>3,_e=0;_e>3,pe=0;pe>>16),Ra(Te.buffer),1}catch(D){}}function ry(N){var D=i().length;if(N=N>>>0,N<=D)return!1;var U=Bd();if(N>U)return!1;for(var Q=1;Q<=4;Q*=2){var pe=D*(1+.2/Q);pe=Math.min(pe,N+100663296);var he=Math.min(U,Lo(Math.max(N,pe),65536)),ve=ay(he);if(ve)return!0}return!1}var Ue={inEventHandler:0,removeAllEventListeners:function(){for(var N=Ue.eventHandlers.length-1;N>=0;--N)Ue._removeHandler(N);Ue.eventHandlers=[],Ue.deferredCalls=[]},registerRemoveEventListeners:function(){Ue.removeEventListenersRegistered||(Fg.push(Ue.removeAllEventListeners),Ue.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,U){function Q(ve,_e){if(ve.length!=_e.length)return!1;for(var Ct in ve)if(ve[Ct]!=_e[Ct])return!1;return!0}for(var pe in Ue.deferredCalls){var he=Ue.deferredCalls[pe];if(he.targetFunction==N&&Q(he.argsList,U))return}Ue.deferredCalls.push({targetFunction:N,precedence:D,argsList:U}),Ue.deferredCalls.sort(function(ve,_e){return ve.precedence<_e.precedence})},removeDeferredCalls:function(N){for(var D=0;D>2]=U,u()[he+4>>2]=Q,u()[he+8>>2]=pe,ab(N,637534208,D,Q,he)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return Ce.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 sy(N){var D=kd(N)+1,U=nb(D);return Rs(N,U,D),U}function iy(N,D,U,Q){Vo(function(){var pe=Xo(12),he=0;D&&(he=sy(D)),u()[pe>>2]=he,u()[pe+4>>2]=U,u()[pe+8>>2]=Q,ab(N,657457152,0,he,pe)})}function oy(N,D,U,Q){D=D?ia(D):"",iy(N,D,U,Q)}function ly(N){return N>2?ia(N):N}var uy=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function py(N){N=ly(N);var D=uy[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return D}function Ip(N){return py(N)}function Wd(N,D,U){var Q=Ip(N);if(!Q)return-4;if(Q.canvasSharedPtr&&(u()[Q.canvasSharedPtr>>2]=D,u()[Q.canvasSharedPtr+4>>2]=U),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var pe=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var he=Q.GLctxObject.GLctx.getParameter(2978);pe=he[0]===0&&he[1]===0&&he[2]===Q.width&&he[3]===Q.height}Q.width=D,Q.height=U,pe&&Q.GLctxObject.GLctx.viewport(0,0,D,U)}else if(Q.canvasSharedPtr){var ve=u()[Q.canvasSharedPtr+8>>2];return oy(ve,N,D,U),1}else return-4;return 0}function Vd(N,D,U){return _?zs(2,1,N,D,U):Wd(N,D,U)}function cy(N,D,U){var Q=Ip(N);return Q?Wd(N,D,U):Vd(N,D,U)}function dy(){throw"unwind"}function hy(N){var D=N.getExtension("ANGLE_instanced_arrays");if(D)return N.vertexAttribDivisor=function(U,Q){D.vertexAttribDivisorANGLE(U,Q)},N.drawArraysInstanced=function(U,Q,pe,he){D.drawArraysInstancedANGLE(U,Q,pe,he)},N.drawElementsInstanced=function(U,Q,pe,he,ve){D.drawElementsInstancedANGLE(U,Q,pe,he,ve)},1}function my(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 fy(N){var D=N.getExtension("WEBGL_draw_buffers");if(D)return N.drawBuffers=function(U,Q){D.drawBuffersWEBGL(U,Q)},1}function gy(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var _t={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){_t.lastError||(_t.lastError=N)},getNewId:function(N){for(var D=_t.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 Q=_t.registerContext(U,D);return Q},registerContext:function(N,D){var U=nb(8);u()[U+4>>2]=Qd();var Q={handle:U,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Q),_t.contexts[U]=Q,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&&_t.initExtensions(Q),U},makeContextCurrent:function(N){return _t.currentContext=_t.contexts[N],c.ctx=jd=_t.currentContext&&_t.currentContext.GLctx,!(N&&!jd)},getContext:function(N){return _t.contexts[N]},deleteContext:function(N){_t.currentContext===_t.contexts[N]&&(_t.currentContext=null),typeof Ue=="object"&&Ue.removeAllHandlersOnTarget(_t.contexts[N].GLctx.canvas),_t.contexts[N]&&_t.contexts[N].GLctx.canvas&&(_t.contexts[N].GLctx.canvas.GLctxObject=void 0),g1(_t.contexts[N].handle),_t.contexts[N]=null},initExtensions:function(N){if(N||(N=_t.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var D=N.GLctx;hy(D),my(D),fy(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),gy(D);var U=D.getSupportedExtensions()||[];U.forEach(function(Q){!Q.includes("lose_context")&&!Q.includes("debug")&&D.getExtension(Q)})}}},yy=["default","low-power","high-performance"];function by(N,D){var U=D>>2,Q=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:yy[Q],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=Ip(N);if(!he||pe.explicitSwapControl)return 0;var ve=_t.createContext(he,pe);return ve}function xy(N,D){return by(N,D)}var Go={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var U=Go.buffers[N];D===0||D===10?((N===1?re:Y)(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 Ud(N){return _?zs(3,1,N):0}function Gd(N,D,U,Q,pe){if(_)return zs(4,1,N,D,U,Q,pe)}function Hd(N,D,U,Q){if(_)return zs(5,1,N,D,U,Q);for(var pe=0,he=0;he>2],_e=u()[D+4>>2];D+=8;for(var Ct=0;Ct<_e;Ct++)Go.printChar(N,i()[ve+Ct]);pe+=_e}return u()[Q>>2]=pe,0}function vy(N){$e(N)}Ce.init();var jd,wy=[null,Ld,Vd,Ud,Gd,Hd],h1=!1,qd={__clock_gettime:jg,__emscripten_init_main_thread_js:qg,__emscripten_thread_cleanup:Kg,__pthread_create_js:Xg,_emscripten_default_pthread_stack_size:Yg,_emscripten_notify_thread_queue:Qg,abort:Jg,emscripten_check_blocking_allowed:Zg,emscripten_get_heap_max:Bd,emscripten_get_now:Ls,emscripten_memcpy_big:ey,emscripten_num_logical_cores:ty,emscripten_receive_on_main_thread_js:ny,emscripten_resize_heap:ry,emscripten_set_canvas_element_size:cy,emscripten_unwind_to_js_event_loop:dy,emscripten_webgl_create_context:xy,exit:Od,fd_close:Ud,fd_seek:Gd,fd_write:Hd,memory:Te||c.wasmMemory,setTempRet0:vy},m1=Mg(),ky=c.___wasm_call_ctors=function(){return(ky=c.___wasm_call_ctors=c.asm.__wasm_call_ctors).apply(null,arguments)},Iy=c._init=function(){return(Iy=c._init=c.asm.init).apply(null,arguments)},Sy=c._init_with_threads_count=function(){return(Sy=c._init_with_threads_count=c.asm.init_with_threads_count).apply(null,arguments)},Ny=c._get_threads_count=function(){return(Ny=c._get_threads_count=c.asm.get_threads_count).apply(null,arguments)},Ty=c._register_tensor=function(){return(Ty=c._register_tensor=c.asm.register_tensor).apply(null,arguments)},_y=c._dispose_data=function(){return(_y=c._dispose_data=c.asm.dispose_data).apply(null,arguments)},Cy=c._dispose=function(){return(Cy=c._dispose=c.asm.dispose).apply(null,arguments)},Ey=c._Abs=function(){return(Ey=c._Abs=c.asm.Abs).apply(null,arguments)},Fy=c._Add=function(){return(Fy=c._Add=c.asm.Add).apply(null,arguments)},Ay=c._AddN=function(){return(Ay=c._AddN=c.asm.AddN).apply(null,arguments)},$y=c._All=function(){return($y=c._All=c.asm.All).apply(null,arguments)},Dy=c._Any=function(){return(Dy=c._Any=c.asm.Any).apply(null,arguments)},Ry=c._ArgMax=function(){return(Ry=c._ArgMax=c.asm.ArgMax).apply(null,arguments)},My=c._AvgPool=function(){return(My=c._AvgPool=c.asm.AvgPool).apply(null,arguments)},Py=c._BatchMatMul=function(){return(Py=c._BatchMatMul=c.asm.BatchMatMul).apply(null,arguments)},Oy=c._Ceil=function(){return(Oy=c._Ceil=c.asm.Ceil).apply(null,arguments)},Ly=c._ClipByValue=function(){return(Ly=c._ClipByValue=c.asm.ClipByValue).apply(null,arguments)},zy=c._Conv2D=function(){return(zy=c._Conv2D=c.asm.Conv2D).apply(null,arguments)},By=c._Conv2DBackpropInput=function(){return(By=c._Conv2DBackpropInput=c.asm.Conv2DBackpropInput).apply(null,arguments)},Wy=c._Cos=function(){return(Wy=c._Cos=c.asm.Cos).apply(null,arguments)},Vy=c._Cosh=function(){return(Vy=c._Cosh=c.asm.Cosh).apply(null,arguments)},Uy=c._CropAndResize=function(){return(Uy=c._CropAndResize=c.asm.CropAndResize).apply(null,arguments)},Gy=c._Cumprod=function(){return(Gy=c._Cumprod=c.asm.Cumprod).apply(null,arguments)},Hy=c._Cumsum=function(){return(Hy=c._Cumsum=c.asm.Cumsum).apply(null,arguments)},jy=c._DepthToSpace=function(){return(jy=c._DepthToSpace=c.asm.DepthToSpace).apply(null,arguments)},qy=c._DepthwiseConv2dNative=function(){return(qy=c._DepthwiseConv2dNative=c.asm.DepthwiseConv2dNative).apply(null,arguments)},Ky=c._Elu=function(){return(Ky=c._Elu=c.asm.Elu).apply(null,arguments)},Xy=c._Equal=function(){return(Xy=c._Equal=c.asm.Equal).apply(null,arguments)},Yy=c._Exp=function(){return(Yy=c._Exp=c.asm.Exp).apply(null,arguments)},Qy=c._FlipLeftRight=function(){return(Qy=c._FlipLeftRight=c.asm.FlipLeftRight).apply(null,arguments)},Kd=c._Floor=function(){return(Kd=c._Floor=c.asm.Floor).apply(null,arguments)},Xd=c._FloorDiv=function(){return(Xd=c._FloorDiv=c.asm.FloorDiv).apply(null,arguments)},Sp=c._FusedBatchNorm=function(){return(Sp=c._FusedBatchNorm=c.asm.FusedBatchNorm).apply(null,arguments)},Jy=c._FusedConv2D=function(){return(Jy=c._FusedConv2D=c.asm.FusedConv2D).apply(null,arguments)},Zy=c._FusedDepthwiseConv2D=function(){return(Zy=c._FusedDepthwiseConv2D=c.asm.FusedDepthwiseConv2D).apply(null,arguments)},Ho=c._Gather=function(){return(Ho=c._Gather=c.asm.Gather).apply(null,arguments)},Np=c._GatherNd=function(){return(Np=c._GatherNd=c.asm.GatherNd).apply(null,arguments)},Tp=c._Greater=function(){return(Tp=c._Greater=c.asm.Greater).apply(null,arguments)},f1=c._GreaterEqual=function(){return(f1=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)},eb=c._LessEqual=function(){return(eb=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)},Je=c._Maximum=function(){return(Je=c._Maximum=c.asm.Maximum).apply(null,arguments)},nt=c._Mean=function(){return(nt=c._Mean=c.asm.Mean).apply(null,arguments)},Ge=c._Min=function(){return(Ge=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)},Bs=c._NonMaxSuppressionV4=function(){return(Bs=c._NonMaxSuppressionV4=c.asm.NonMaxSuppressionV4).apply(null,arguments)},tb=c._NonMaxSuppressionV5=function(){return(tb=c._NonMaxSuppressionV5=c.asm.NonMaxSuppressionV5).apply(null,arguments)},Mn=c._NotEqual=function(){return(Mn=c._NotEqual=c.asm.NotEqual).apply(null,arguments)},jr=c._OneHot=function(){return(jr=c._OneHot=c.asm.OneHot).apply(null,arguments)},Yd=c._PadV2=function(){return(Yd=c._PadV2=c.asm.PadV2).apply(null,arguments)},GF=c._Pow=function(){return(GF=c._Pow=c.asm.Pow).apply(null,arguments)},HF=c._Prelu=function(){return(HF=c._Prelu=c.asm.Prelu).apply(null,arguments)},jF=c._Prod=function(){return(jF=c._Prod=c.asm.Prod).apply(null,arguments)},qF=c._RealDiv=function(){return(qF=c._RealDiv=c.asm.RealDiv).apply(null,arguments)},KF=c._Relu=function(){return(KF=c._Relu=c.asm.Relu).apply(null,arguments)},XF=c._Relu6=function(){return(XF=c._Relu6=c.asm.Relu6).apply(null,arguments)},YF=c._ResizeBilinear=function(){return(YF=c._ResizeBilinear=c.asm.ResizeBilinear).apply(null,arguments)},QF=c._Reverse=function(){return(QF=c._Reverse=c.asm.Reverse).apply(null,arguments)},JF=c._RotateWithOffset=function(){return(JF=c._RotateWithOffset=c.asm.RotateWithOffset).apply(null,arguments)},ZF=c._Round=function(){return(ZF=c._Round=c.asm.Round).apply(null,arguments)},eA=c._Rsqrt=function(){return(eA=c._Rsqrt=c.asm.Rsqrt).apply(null,arguments)},tA=c._ScatterNd=function(){return(tA=c._ScatterNd=c.asm.ScatterNd).apply(null,arguments)},nA=c._SelectV2=function(){return(nA=c._SelectV2=c.asm.SelectV2).apply(null,arguments)},aA=c._Sigmoid=function(){return(aA=c._Sigmoid=c.asm.Sigmoid).apply(null,arguments)},rA=c._Sin=function(){return(rA=c._Sin=c.asm.Sin).apply(null,arguments)},sA=c._Softmax=function(){return(sA=c._Softmax=c.asm.Softmax).apply(null,arguments)},iA=c._SparseFillEmptyRows=function(){return(iA=c._SparseFillEmptyRows=c.asm.SparseFillEmptyRows).apply(null,arguments)},oA=c._SparseReshape=function(){return(oA=c._SparseReshape=c.asm.SparseReshape).apply(null,arguments)},lA=c._SparseSegmentReduction=function(){return(lA=c._SparseSegmentReduction=c.asm.SparseSegmentReduction).apply(null,arguments)},uA=c._Sqrt=function(){return(uA=c._Sqrt=c.asm.Sqrt).apply(null,arguments)},pA=c._Square=function(){return(pA=c._Square=c.asm.Square).apply(null,arguments)},cA=c._SquaredDifference=function(){return(cA=c._SquaredDifference=c.asm.SquaredDifference).apply(null,arguments)},dA=c._Step=function(){return(dA=c._Step=c.asm.Step).apply(null,arguments)},hA=c._StridedSlice=function(){return(hA=c._StridedSlice=c.asm.StridedSlice).apply(null,arguments)},mA=c._Sub=function(){return(mA=c._Sub=c.asm.Sub).apply(null,arguments)},fA=c._Sum=function(){return(fA=c._Sum=c.asm.Sum).apply(null,arguments)},gA=c._Tan=function(){return(gA=c._Tan=c.asm.Tan).apply(null,arguments)},yA=c._Tanh=function(){return(yA=c._Tanh=c.asm.Tanh).apply(null,arguments)},bA=c._Tile=function(){return(bA=c._Tile=c.asm.Tile).apply(null,arguments)},xA=c._TopK=function(){return(xA=c._TopK=c.asm.TopK).apply(null,arguments)},vA=c._Transform=function(){return(vA=c._Transform=c.asm.Transform).apply(null,arguments)},wA=c._Transpose=function(){return(wA=c._Transpose=c.asm.Transpose).apply(null,arguments)},kA=c.__FusedMatMul=function(){return(kA=c.__FusedMatMul=c.asm._FusedMatMul).apply(null,arguments)},nb=c._malloc=function(){return(nb=c._malloc=c.asm.malloc).apply(null,arguments)},g1=c._free=function(){return(g1=c._free=c.asm.free).apply(null,arguments)},IA=c._emscripten_tls_init=function(){return(IA=c._emscripten_tls_init=c.asm.emscripten_tls_init).apply(null,arguments)},y1=c.___errno_location=function(){return(y1=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)},b1=c._emscripten_main_thread_process_queued_calls=function(){return(b1=c._emscripten_main_thread_process_queued_calls=c.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},SA=c.__emscripten_thread_crashed=function(){return(SA=c.__emscripten_thread_crashed=c.asm._emscripten_thread_crashed).apply(null,arguments)},x1=c.__emscripten_thread_init=function(){return(x1=c.__emscripten_thread_init=c.asm._emscripten_thread_init).apply(null,arguments)},NA=c._emscripten_current_thread_process_queued_calls=function(){return(NA=c._emscripten_current_thread_process_queued_calls=c.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},TA=c._emscripten_main_browser_thread_id=function(){return(TA=c._emscripten_main_browser_thread_id=c.asm.emscripten_main_browser_thread_id).apply(null,arguments)},_A=c._emscripten_sync_run_in_main_thread_2=function(){return(_A=c._emscripten_sync_run_in_main_thread_2=c.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},v1=c._emscripten_sync_run_in_main_thread_4=function(){return(v1=c._emscripten_sync_run_in_main_thread_4=c.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},w1=c._emscripten_run_in_main_runtime_thread_js=function(){return(w1=c._emscripten_run_in_main_runtime_thread_js=c.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},ab=c._emscripten_dispatch_to_thread_=function(){return(ab=c._emscripten_dispatch_to_thread_=c.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},rb=c.__emscripten_thread_free_data=function(){return(rb=c.__emscripten_thread_free_data=c.asm._emscripten_thread_free_data).apply(null,arguments)},CA=c.__emscripten_thread_exit=function(){return(CA=c.__emscripten_thread_exit=c.asm._emscripten_thread_exit).apply(null,arguments)},EA=c._memalign=function(){return(EA=c._memalign=c.asm.memalign).apply(null,arguments)},k1=c._emscripten_stack_set_limits=function(){return(k1=c._emscripten_stack_set_limits=c.asm.emscripten_stack_set_limits).apply(null,arguments)},sb=c.stackSave=function(){return(sb=c.stackSave=c.asm.stackSave).apply(null,arguments)},Jd=c.stackRestore=function(){return(Jd=c.stackRestore=c.asm.stackRestore).apply(null,arguments)},Xo=c.stackAlloc=function(){return(Xo=c.stackAlloc=c.asm.stackAlloc).apply(null,arguments)},FA=c.dynCall_iijjiiii=function(){return(FA=c.dynCall_iijjiiii=c.asm.dynCall_iijjiiii).apply(null,arguments)},AA=c.dynCall_jiji=function(){return(AA=c.dynCall_jiji=c.asm.dynCall_jiji).apply(null,arguments)},I1=c.__emscripten_allow_main_runtime_queued_calls=21464;c.cwrap=Jt,c.keepRuntimeAlive=Ps,c.PThread=Ce,c.PThread=Ce,c.wasmMemory=Te,c.ExitStatus=_p;var Zd;function _p(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Ma=function N(){Zd||ib(),Zd||(Ma=N)};function ib(N){if(N=N||y,Hr>0)return;if(_){h(c),bp(),postMessage({cmd:"loaded"});return}if(xn(),Hr>0)return;function D(){Zd||(Zd=!0,c.calledRun=!0,!ct&&(bp(),h(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),Dg()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),D()},1)):D()}c.run=ib;function $A(N,D){if(yn=N,!D&&_)throw Ld(N),"unwind";Ps()||$g(),DA(N)}function DA(N){yn=N,Ps()||(Ce.terminateAllThreads(),c.onExit&&c.onExit(N),ct=!0),x(N,new _p(N))}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();ib();var eh;f&&(eh={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 th;if(typeof WasmBackendModule!="undefined")th=WasmBackendModule;else if(typeof r!="undefined")th=r;else throw new Error("Could not find wasm module in post.js");if(eh){var RA=th._dispose;th._dispose=function(){RA(),eh.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),eh.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)}),c$=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,k;function T(G){G instanceof Np||$("exiting due to exception: "+G)}var _,E,A;f?(m?g=Th().dirname(g)+"/":g=__dirname+"/",A=()=>{E||(_=kx(),E=Th())},b=function(G,te){return A(),G=E.normalize(G),_.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)=>{A(),G=E.normalize(G),_.readFile(G,function(Se,Je){Se?de(Se):te(Je.buffer)})},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),p=process.argv.slice(2),process.on("uncaughtException",function(G){if(!(G instanceof Np))throw G}),process.on("unhandledRejection",function(G){throw G}),c=(G,te)=>{if(yp())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)},k=G=>document.title=G);var M=s.print||console.log.bind(console),$=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 P(G){P.shown||(P.shown={}),P.shown[G]||(P.shown[G]=1,$(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]]]},Je=1;Je{ee=G},Y;s.wasmBinary&&(Y=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Ms("no native wasm support detected");var ae,le=!1,ue;function ke(G,te){G||Ms(te)}function ye(G){var te=s["_"+G];return te}function Ie(G,te,de,Se,Je){var nt={string:function(Mn){var jr=0;if(Mn!=null&&Mn!==0){var Yd=(Mn.length<<2)+1;jr=Sp(Yd),tt(Mn,jr,Yd)}return jr},array:function(Mn){var jr=Sp(Mn.length);return ct(Mn,jr),jr}};function Ge(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);)++Je;if(Je-te>16&&G.subarray&&Be)return Be.decode(G.subarray(te,Je));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 Je=de,nt=de+Se-1,Ge=0;Ge=55296&&We<=57343){var Lt=G.charCodeAt(++Ge);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-Je}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){Gt.set(G,te)}function yn(G,te,de){for(var Se=0;Se>0]=G.charCodeAt(Se);de||(Gt[te>>0]=0)}function Qt(G,te){return G%te>0&&(G+=te-G%te),G}var Dn,Gt,Jt,Da,Rn,Ht,sa,ia,Vr;function Rs(G){Dn=G,s.HEAP8=Gt=new Int8Array(G),s.HEAP16=Da=new Int16Array(G),s.HEAP32=Ht=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=Vr=new Float64Array(G)}var kd=s.INITIAL_MEMORY||16777216,Ur,xr=[],gp=[],Lo=[],bn=!1,Id=!1,Sd=0;function yp(){return ie||Sd>0}function Nd(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)Cd(s.preRun.shift());xp(xr)}function Td(){bn=!0,xp(gp)}function r1(){Id=!0}function _d(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Ed(s.postRun.shift());xp(Lo)}function Cd(G){xr.unshift(G)}function Ra(G){gp.unshift(G)}function Ed(G){Lo.unshift(G)}var oa=0,zo=null,Gr=null;function Fg(G){oa++,s.monitorRunDependencies&&s.monitorRunDependencies(oa)}function Fd(G){if(oa--,s.monitorRunDependencies&&s.monitorRunDependencies(oa),oa==0&&(zo!==null&&(clearInterval(zo),zo=null),Gr)){var te=Gr;Gr=null,te()}}s.preloadedImages={},s.preloadedAudios={};function Ms(G){s.onAbort&&s.onAbort(G),G="Aborted("+G+")",$(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 Ag="data:application/octet-stream;base64,";function Ad(G){return G.startsWith(Ag)}function Ps(G){return G.startsWith("file://")}var xn;xn="tfjs-backend-wasm.wasm",Ad(xn)||(xn=y(xn));function bp(G){try{if(G==xn&&Y)return new Uint8Array(Y);if(v)return v(G);throw"both async and sync fetching of the wasm failed"}catch(te){Ms(te)}}function $g(){if(!Y&&(h||m)){if(typeof fetch=="function"&&!Ps(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 bp(xn)});if(x)return new Promise(function(G,te){x(xn,function(de){G(new Uint8Array(de))},te)})}return Promise.resolve().then(function(){return bp(xn)})}function Dg(){var G={env:Vo,wasi_snapshot_preview1:Vo};function te(Ge,We){var Lt=Ge.exports;s.asm=Lt,ae=s.asm.memory,Rs(ae.buffer),Ur=s.asm.__indirect_function_table,Ra(s.asm.__wasm_call_ctors),Fd("wasm-instantiate")}Fg("wasm-instantiate");function de(Ge){te(Ge.instance)}function Se(Ge){return $g().then(function(We){return WebAssembly.instantiate(We,G)}).then(function(We){return We}).then(Ge,function(We){$("failed to asynchronously prepare wasm: "+We),Ms(We)})}function Je(){return!Y&&typeof WebAssembly.instantiateStreaming=="function"&&!Ad(xn)&&!Ps(xn)&&typeof fetch=="function"?fetch(xn,{credentials:"same-origin"}).then(function(Ge){var We=WebAssembly.instantiateStreaming(Ge,G);return We.then(de,function(Lt){return $("wasm streaming compile failed: "+Lt),$("falling back to ArrayBuffer instantiation"),Se(de)})}):Se(de)}if(s.instantiateWasm)try{var nt=s.instantiateWasm(G,te);return nt}catch(Ge){return $("Module.instantiateWasm callback failed with error: "+Ge),!1}return Je().catch(o),{}}var s1,i1;function xp(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?vp(de)():vp(de)(te.arg):de(te.arg===void 0?null:te.arg)}}function Hr(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 vp(G){var te=Ma[G];return te||(G>=Ma.length&&(Ma.length=G+1),Ma[G]=te=Ur.get(G)),te}function o1(){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){Ur.set(G,te),Ma[G]=te}function Rg(){Ms("")}function wp(){return 2147483648}function Dd(G,te,de){Jt.copyWithin(G,te,te+de)}function vn(G){try{return ae.grow(G-Dn.byteLength+65535>>>16),Rs(ae.buffer),1}catch(te){}}function Rd(G){var te=Jt.length;G=G>>>0;var de=wp();if(G>de)return!1;for(var Se=1;Se<=4;Se*=2){var Je=te*(1+.2/Se);Je=Math.min(Je,G+100663296);var nt=Math.min(de,Qt(Math.max(G,Je),65536)),Ge=vn(nt);if(Ge)return!0}return!1}var Wo={mappings:{},buffers:[null,[],[]],printChar:function(G,te){var de=Wo.buffers[G];te===0||te===10?((G===1?M:$)(je(de,0)),de.length=0):de.push(te)},varargs:void 0,get:function(){Wo.varargs+=4;var G=Ht[Wo.varargs-4>>2];return G},getStr:function(G){var te=st(G);return te},get64:function(G,te){return G}};function Mg(G){return 0}function l1(G,te,de,Se,Je){}function u1(G,te,de,Se){for(var Je=0,nt=0;nt>2],We=Ht[te+4>>2];te+=8;for(var Lt=0;Lt>2]=Je,0}function Pg(G){re(G)}var Md=!1,Vo={abort:Rg,emscripten_get_heap_max:wp,emscripten_memcpy_big:Dd,emscripten_resize_heap:Rd,fd_close:Mg,fd_seek:l1,fd_write:u1,setTempRet0:Pg},UF=Dg(),p1=s.___wasm_call_ctors=function(){return(p1=s.___wasm_call_ctors=s.asm.__wasm_call_ctors).apply(null,arguments)},Og=s._init=function(){return(Og=s._init=s.asm.init).apply(null,arguments)},Lg=s._init_with_threads_count=function(){return(Lg=s._init_with_threads_count=s.asm.init_with_threads_count).apply(null,arguments)},Pd=s._get_threads_count=function(){return(Pd=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},Od=s._register_tensor=function(){return(Od=s._register_tensor=s.asm.register_tensor).apply(null,arguments)},zg=s._dispose_data=function(){return(zg=s._dispose_data=s.asm.dispose_data).apply(null,arguments)},Ce=s._dispose=function(){return(Ce=s._dispose=s.asm.dispose).apply(null,arguments)},Bg=s._Abs=function(){return(Bg=s._Abs=s.asm.Abs).apply(null,arguments)},Ld=s._Add=function(){return(Ld=s._Add=s.asm.Add).apply(null,arguments)},Os=s._AddN=function(){return(Os=s._AddN=s.asm.AddN).apply(null,arguments)},Uo=s._All=function(){return(Uo=s._All=s.asm.All).apply(null,arguments)},Wg=s._Any=function(){return(Wg=s._Any=s.asm.Any).apply(null,arguments)},c1=s._ArgMax=function(){return(c1=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},Vg=s._AvgPool=function(){return(Vg=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},d1=s._BatchMatMul=function(){return(d1=s._BatchMatMul=s.asm.BatchMatMul).apply(null,arguments)},Ls=s._Ceil=function(){return(Ls=s._Ceil=s.asm.Ceil).apply(null,arguments)},Ug=s._ClipByValue=function(){return(Ug=s._ClipByValue=s.asm.ClipByValue).apply(null,arguments)},Gg=s._Conv2D=function(){return(Gg=s._Conv2D=s.asm.Conv2D).apply(null,arguments)},Hg=s._Conv2DBackpropInput=function(){return(Hg=s._Conv2DBackpropInput=s.asm.Conv2DBackpropInput).apply(null,arguments)},jg=s._Cos=function(){return(jg=s._Cos=s.asm.Cos).apply(null,arguments)},qg=s._Cosh=function(){return(qg=s._Cosh=s.asm.Cosh).apply(null,arguments)},Kg=s._CropAndResize=function(){return(Kg=s._CropAndResize=s.asm.CropAndResize).apply(null,arguments)},zd=s._Cumprod=function(){return(zd=s._Cumprod=s.asm.Cumprod).apply(null,arguments)},Xg=s._Cumsum=function(){return(Xg=s._Cumsum=s.asm.Cumsum).apply(null,arguments)},Yg=s._DepthToSpace=function(){return(Yg=s._DepthToSpace=s.asm.DepthToSpace).apply(null,arguments)},Qg=s._DepthwiseConv2dNative=function(){return(Qg=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Jg=s._Elu=function(){return(Jg=s._Elu=s.asm.Elu).apply(null,arguments)},Zg=s._Equal=function(){return(Zg=s._Equal=s.asm.Equal).apply(null,arguments)},Bd=s._Exp=function(){return(Bd=s._Exp=s.asm.Exp).apply(null,arguments)},ey=s._FlipLeftRight=function(){return(ey=s._FlipLeftRight=s.asm.FlipLeftRight).apply(null,arguments)},ty=s._Floor=function(){return(ty=s._Floor=s.asm.Floor).apply(null,arguments)},zs=s._FloorDiv=function(){return(zs=s._FloorDiv=s.asm.FloorDiv).apply(null,arguments)},kp=s._FusedBatchNorm=function(){return(kp=s._FusedBatchNorm=s.asm.FusedBatchNorm).apply(null,arguments)},ny=s._FusedConv2D=function(){return(ny=s._FusedConv2D=s.asm.FusedConv2D).apply(null,arguments)},ay=s._FusedDepthwiseConv2D=function(){return(ay=s._FusedDepthwiseConv2D=s.asm.FusedDepthwiseConv2D).apply(null,arguments)},ry=s._Gather=function(){return(ry=s._Gather=s.asm.Gather).apply(null,arguments)},Ue=s._GatherNd=function(){return(Ue=s._GatherNd=s.asm.GatherNd).apply(null,arguments)},sy=s._Greater=function(){return(sy=s._Greater=s.asm.Greater).apply(null,arguments)},iy=s._GreaterEqual=function(){return(iy=s._GreaterEqual=s.asm.GreaterEqual).apply(null,arguments)},oy=s._LeakyRelu=function(){return(oy=s._LeakyRelu=s.asm.LeakyRelu).apply(null,arguments)},ly=s._Less=function(){return(ly=s._Less=s.asm.Less).apply(null,arguments)},uy=s._LessEqual=function(){return(uy=s._LessEqual=s.asm.LessEqual).apply(null,arguments)},py=s._Log=function(){return(py=s._Log=s.asm.Log).apply(null,arguments)},Ip=s._LogicalAnd=function(){return(Ip=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Wd=s._Max=function(){return(Wd=s._Max=s.asm.Max).apply(null,arguments)},Vd=s._MaxPool=function(){return(Vd=s._MaxPool=s.asm.MaxPool).apply(null,arguments)},cy=s._Maximum=function(){return(cy=s._Maximum=s.asm.Maximum).apply(null,arguments)},dy=s._Mean=function(){return(dy=s._Mean=s.asm.Mean).apply(null,arguments)},hy=s._Min=function(){return(hy=s._Min=s.asm.Min).apply(null,arguments)},my=s._Minimum=function(){return(my=s._Minimum=s.asm.Minimum).apply(null,arguments)},fy=s._MirrorPad=function(){return(fy=s._MirrorPad=s.asm.MirrorPad).apply(null,arguments)},gy=s._Multiply=function(){return(gy=s._Multiply=s.asm.Multiply).apply(null,arguments)},_t=s._Neg=function(){return(_t=s._Neg=s.asm.Neg).apply(null,arguments)},yy=s._NonMaxSuppressionV3=function(){return(yy=s._NonMaxSuppressionV3=s.asm.NonMaxSuppressionV3).apply(null,arguments)},by=s._NonMaxSuppressionV4=function(){return(by=s._NonMaxSuppressionV4=s.asm.NonMaxSuppressionV4).apply(null,arguments)},xy=s._NonMaxSuppressionV5=function(){return(xy=s._NonMaxSuppressionV5=s.asm.NonMaxSuppressionV5).apply(null,arguments)},Go=s._NotEqual=function(){return(Go=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},Ud=s._OneHot=function(){return(Ud=s._OneHot=s.asm.OneHot).apply(null,arguments)},Gd=s._PadV2=function(){return(Gd=s._PadV2=s.asm.PadV2).apply(null,arguments)},Hd=s._Pow=function(){return(Hd=s._Pow=s.asm.Pow).apply(null,arguments)},vy=s._Prelu=function(){return(vy=s._Prelu=s.asm.Prelu).apply(null,arguments)},jd=s._Prod=function(){return(jd=s._Prod=s.asm.Prod).apply(null,arguments)},wy=s._RealDiv=function(){return(wy=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},h1=s._Relu=function(){return(h1=s._Relu=s.asm.Relu).apply(null,arguments)},qd=s._Relu6=function(){return(qd=s._Relu6=s.asm.Relu6).apply(null,arguments)},m1=s._ResizeBilinear=function(){return(m1=s._ResizeBilinear=s.asm.ResizeBilinear).apply(null,arguments)},ky=s._Reverse=function(){return(ky=s._Reverse=s.asm.Reverse).apply(null,arguments)},Iy=s._RotateWithOffset=function(){return(Iy=s._RotateWithOffset=s.asm.RotateWithOffset).apply(null,arguments)},Sy=s._Round=function(){return(Sy=s._Round=s.asm.Round).apply(null,arguments)},Ny=s._Rsqrt=function(){return(Ny=s._Rsqrt=s.asm.Rsqrt).apply(null,arguments)},Ty=s._ScatterNd=function(){return(Ty=s._ScatterNd=s.asm.ScatterNd).apply(null,arguments)},_y=s._SelectV2=function(){return(_y=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},Cy=s._Sigmoid=function(){return(Cy=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},Ey=s._Sin=function(){return(Ey=s._Sin=s.asm.Sin).apply(null,arguments)},Fy=s._Softmax=function(){return(Fy=s._Softmax=s.asm.Softmax).apply(null,arguments)},Ay=s._SparseFillEmptyRows=function(){return(Ay=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},$y=s._SparseReshape=function(){return($y=s._SparseReshape=s.asm.SparseReshape).apply(null,arguments)},Dy=s._SparseSegmentReduction=function(){return(Dy=s._SparseSegmentReduction=s.asm.SparseSegmentReduction).apply(null,arguments)},Ry=s._Sqrt=function(){return(Ry=s._Sqrt=s.asm.Sqrt).apply(null,arguments)},My=s._Square=function(){return(My=s._Square=s.asm.Square).apply(null,arguments)},Py=s._SquaredDifference=function(){return(Py=s._SquaredDifference=s.asm.SquaredDifference).apply(null,arguments)},Oy=s._Step=function(){return(Oy=s._Step=s.asm.Step).apply(null,arguments)},Ly=s._StridedSlice=function(){return(Ly=s._StridedSlice=s.asm.StridedSlice).apply(null,arguments)},zy=s._Sub=function(){return(zy=s._Sub=s.asm.Sub).apply(null,arguments)},By=s._Sum=function(){return(By=s._Sum=s.asm.Sum).apply(null,arguments)},Wy=s._Tan=function(){return(Wy=s._Tan=s.asm.Tan).apply(null,arguments)},Vy=s._Tanh=function(){return(Vy=s._Tanh=s.asm.Tanh).apply(null,arguments)},Uy=s._Tile=function(){return(Uy=s._Tile=s.asm.Tile).apply(null,arguments)},Gy=s._TopK=function(){return(Gy=s._TopK=s.asm.TopK).apply(null,arguments)},Hy=s._Transform=function(){return(Hy=s._Transform=s.asm.Transform).apply(null,arguments)},jy=s._Transpose=function(){return(jy=s._Transpose=s.asm.Transpose).apply(null,arguments)},qy=s.__FusedMatMul=function(){return(qy=s.__FusedMatMul=s.asm._FusedMatMul).apply(null,arguments)},Ky=s._malloc=function(){return(Ky=s._malloc=s.asm.malloc).apply(null,arguments)},Xy=s._free=function(){return(Xy=s._free=s.asm.free).apply(null,arguments)},Yy=s.___errno_location=function(){return(Yy=s.___errno_location=s.asm.__errno_location).apply(null,arguments)},Qy=s._emscripten_main_thread_process_queued_calls=function(){return(Qy=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Kd=s.stackSave=function(){return(Kd=s.stackSave=s.asm.stackSave).apply(null,arguments)},Xd=s.stackRestore=function(){return(Xd=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},Sp=s.stackAlloc=function(){return(Sp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},Jy=s.dynCall_iijjiiii=function(){return(Jy=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},Zy=s.dynCall_jiji=function(){return(Zy=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Ee;var Ho;function Np(G){this.name="ExitStatus",this.message="Program terminated with exit("+G+")",this.status=G}Gr=function G(){Ho||Tp(),Ho||(Gr=G)};function Tp(G){if(G=G||p,oa>0||(Nd(),oa>0))return;function te(){Ho||(Ho=!0,s.calledRun=!0,!le&&(Td(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),_d()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),te()},1)):te()}s.run=Tp;function f1(G){ue=G,yp()||(s.onExit&&s.onExit(G),le=!0),c(G,new Np(G))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();Tp();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 eb=qo._dispose;qo._dispose=function(){eb(),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)}),rm=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}},pc=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 eI(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,_h(e,t,n)}function d$(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--,_h(e,n,a),_h(t,n,a)}function qp(e,t,n){return Math.max(e,Math.min(t,n))}function h$(e){return e%2===0?e:e+1}function _h(e,t,n){let a=e[t];e[t]=e[n],e[n]=a}function m$(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function xi(e){R(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function ti(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 k$(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 _a(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=>ul(a)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(a=>a<0?n+a:a)}function tI(e,t){let n=[],a=[],r=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||r?null:_a(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 nI(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 aI(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 rI(e,t){for(let n=0;nt+=n.length),t}function Yr(e){return typeof e=="string"||e instanceof String}function oI(e){return typeof e=="boolean"}function lI(e){return typeof e=="number"}function sm(e){return Array.isArray(e)?sm(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":lI(e)?"float32":Yr(e)?"string":oI(e)?"bool":"float32"}function ns(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Ch(e,t){for(let n=t;n=0;--a)n[a]=n[a+1]*e[a+1];return n}function uI(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 uI(0,e,t,n)}function Ix(e,t){let n=im(e,t);for(let a=0;aa*r,1);if(t==null||t==="float32")return rl(e,new Float32Array(n));if(t==="int32")return rl(e,new Int32Array(n));if(t==="bool")return rl(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function Sx(e){e.forEach(t=>{R(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function N$(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]=E$(n,a)})}};function _$(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...a)=>(C$(t,a[0],a[1]),a.join("="))),t}function C$(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function E$(e,t){if(t=t.toLowerCase(),t==="true"||t==="false")return t==="true";if(`${+t}`===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function X(){return Tx}var Tx=null;function F$(e){Tx=e}var lb;function cI(){if(lb==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");lb=e}return lb}function A$(){let e=cI();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function _x(e,t){let n=A$();if(n.has(e))return n.get(e);{let a=t();return n.set(e,a),n.get(e)}}var Tl="Abs",_l="Acos",Cl="Acosh",hs="Add",vi="AddN",El="All",Fl="Any",wi="ArgMax",cc="ArgMin",Al="Asin",$l="Asinh",Dl="Atan",Rl="Atanh",Ml="Atan2",ki="AvgPool",om="AvgPoolGrad",dc="AvgPool3D",lm="AvgPool3DGrad",Ii="BatchMatMul",Pl="BatchToSpaceND",um="Bincount",dI="BroadcastTo",pm="BroadcastArgs",Si="Cast",Ni="Ceil",ms="ClipByValue",cm="Complex",hc="ComplexAbs",Ol="Concat",Ti="Conv2D",dm="Conv2DBackpropFilter",_i="Conv2DBackpropInput",mc="Conv3D",hm="Conv3DBackpropFilterV2",mm="Conv3DBackpropInputV2",Ci="Cos",Ei="Cosh",Ll="Cumprod",Fi="Cumsum",zl="CropAndResize",fm="DenseBincount",Bl="DepthToSpace",Ai="DepthwiseConv2dNative",gm="DepthwiseConv2dNativeBackpropFilter",ym="DepthwiseConv2dNativeBackpropInput",bm="Diag",fc="Dilation2D",Eh="Dilation2DBackpropInput",Fh="Dilation2DBackpropFilter",$i="RealDiv",xm="Einsum",Di="Elu",vm="EluGrad",Wl="Erf",Vl="Equal",Ri="Exp",Ul="ExpandDims",Gl="Expm1",wm="FFT",gc="Fill",Hl="FlipLeftRight",Mi="Floor",Pi="FloorDiv",Oi="FusedBatchNorm",jl="GatherV2",ql="GatherNd",Kl="Greater",Li="GreaterEqual",zi="Identity",km="IFFT",Im="Imag",Xl="IsFinite",Yl="IsInf",Ql="IsNan",Bi="LeakyRelu",Jl="Less",Zl="LessEqual",Sm="LinSpace",Wi="Log",eu="Log1p",tu="LogicalAnd",yc="LogicalNot",bc="LogicalOr",hI="LogSoftmax",$$="LowerBound",xc="LRN",Nm="LRNGrad",Vi="Max",Ui="Maximum",Gi="MaxPool",Tm="MaxPoolGrad",vc="MaxPool3D",_m="MaxPool3DGrad",Cm="MaxPoolWithArgmax",Hi="Mean",ji="Min",qi="Minimum",Ki="MirrorPad",nu="Mod",Em="Multinomial",Xi="Multiply",au="Neg",ru="NotEqual",su="NonMaxSuppressionV3",iu="NonMaxSuppressionV4",ou="NonMaxSuppressionV5",lu="OnesLike",Yi="OneHot",uu="Pack",Qi="PadV2",D$="Pool",Ji="Pow",Zi="Prelu",eo="Prod",wc="Range",Fm="Real",pu="Reciprocal",to="Relu",cu="Reshape",kc="ResizeNearestNeighbor",Am="ResizeNearestNeighborGrad",no="ResizeBilinear",$m="ResizeBilinearGrad",ao="Relu6",ro="Reverse",so="Round",io="Rsqrt",du="ScatterNd",Dm="SearchSorted",hu="Select",mu="Selu",fu="Slice",oo="Sin",gu="Sinh",yu="Sign",lo="Sigmoid",bu="Softplus",uo="Sqrt",po="Sum",xu="SpaceToBatchND",vu="SplitV",co="Softmax",Ic="SparseFillEmptyRows",wu="SparseReshape",Sc="SparseSegmentMean",Nc="SparseSegmentSum",Rm="SparseToDense",ho="SquaredDifference",Tc="Square",ku="StridedSlice",Mm="StringNGrams",Pm="StringSplit",Om="StringToHashBucketFast",mo="Sub",fo="Tan",go="Tanh",fs="Tile",Iu="TopK",Su="Transform",Nr="Transpose",Lm="Unique",Nu="Unpack",_c="UnsortedSegmentSum",R$="UpperBound",Tu="ZerosLike",gs="Step",Ah="FromPixels",_u="RotateWithOffset",ni="_FusedMatMul",ai="FusedConv2D",ri="FusedDepthwiseConv2D";function Xr(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.warn(...e)}function M$(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.log(...e)}var pl=_x("kernelRegistry",()=>new Map),Kp=_x("gradRegistry",()=>new Map);function $h(e,t){let n=Cx(e,t);return pl.get(n)}function Ib(e){return Kp.get(e)}function Dh(e){let t=pl.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 Cc(e){let{kernelName:t,backendName:n}=e,a=Cx(t,n);pl.has(a)&&Xr(`The kernel '${t}' for backend '${n}' is already registered`),pl.set(a,e)}function mI(e){let{kernelName:t}=e;Kp.has(t)&&X().getBool("DEBUG")&&Xr(`Overriding the gradient for '${t}'`),Kp.set(t,e)}function P$(e,t){let n=Cx(e,t);if(!pl.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);pl.delete(n)}function O$(e){if(!Kp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Kp.delete(e)}function L$(e,t){Dh(e).forEach(n=>{let a=Object.assign({},n,{backendName:t});Cc(a)})}function Cx(e,t){return`${t}_${e}`}var w={};Me(w,{arraysEqual:()=>ds,assert:()=>R,assertNonNegativeIntegerDimensions:()=>Sx,assertNonNull:()=>xi,assertShapesMatch:()=>Nn,bytesFromStringArray:()=>iI,bytesPerElement:()=>kb,checkConversionForErrors:()=>rI,clamp:()=>qp,computeStrides:()=>Nl,createScalarValue:()=>G$,createShuffledIndices:()=>v$,decodeString:()=>Rh,distSquared:()=>g$,encodeString:()=>Fc,fetch:()=>j$,fingerPrint64:()=>U$,flatten:()=>ti,getArrayFromDType:()=>aI,getTypedArrayFromDType:()=>nI,hasEncodingLoss:()=>I$,hexToLong:()=>Ec,indexToLoc:()=>T$,inferDtype:()=>sm,inferFromImplicitShape:()=>k$,isBoolean:()=>oI,isFunction:()=>ns,isInt:()=>ul,isNumber:()=>lI,isPromise:()=>Nx,isScalarShape:()=>y$,isString:()=>Yr,isTypedArray:()=>hn,isValidDtype:()=>sI,locToIndex:()=>N$,makeOnesTypedArray:()=>Ix,makeZerosNestedTypedArray:()=>S$,makeZerosTypedArray:()=>im,nearestDivisor:()=>Ch,nearestLargerEven:()=>h$,now:()=>Xp,parseAxisParam:()=>_a,randUniform:()=>f$,repeatedTry:()=>w$,rightPad:()=>Up,shuffle:()=>eI,shuffleCombo:()=>d$,sizeFromShape:()=>bt,sizeToSquarishShape:()=>x$,squeezeShape:()=>tI,sum:()=>m$,swap:()=>_h,tanh:()=>b$,toNestedArray:()=>rl,toTypedArray:()=>zm});var T1=bi(GA()),Hs=T1.default||T1;function Ec(e){return Hs.fromString(e,!0,16)}var fI=Ec("c3a5c85c97cb3127"),Us=Ec("b492b66fbe98f273"),wn=Ec("9ae16a3b2f90404f");function Sb(e){return e.xor(e.shru(47))}function gI(e,t,n){let a=e.slice(t,t+n);return Hs.fromBytes(Array.from(a),!0,!0)}function yt(e,t){return gI(e,t,8)}function _1(e,t){return gI(e,t,4)}function Zt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Zr(e,t,n=Ec("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 z$(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 ah(e,t,n,a){return z$(yt(e,t),yt(e,t+8),yt(e,t+16),yt(e,t+24),n,a)}function B$(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 Zr(s,i,n)}if(t>=4){let n=wn.add(t*2),a=_1(e,0);return Zr(a.shl(3).add(t),_1(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 Sb(wn.mul(s).xor(fI.mul(i))).mul(wn)}return wn}function W$(e,t=e.length){let n=wn.add(t*2),a=yt(e,0).mul(Us),r=yt(e,8),s=yt(e,t-8).mul(n),i=yt(e,t-16).mul(wn);return Zr(Zt(a.add(r),43).add(Zt(s,30)).add(i),a.add(Zt(r.add(wn),18)).add(s),n)}function V$(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=Zr(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 Zr(Zt(u.add(p),43).add(Zt(d,30)).add(c),u.add(Zt(p.add(a),18)).add(d),n)}function U$(e,t=e.length){let n=Hs.fromNumber(81,!0);if(t<=32)return t<=16?B$(e,t):W$(e,t);if(t<=64)return V$(e,t);let a=n,r=n.mul(Us).add(113),s=Sb(r.mul(wn).add(113)).mul(wn),i=[Hs.UZERO,Hs.UZERO],o=[Hs.UZERO,Hs.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(Us),r=Zt(r.add(i[1]).add(yt(e,l+48)),42).mul(Us),a=a.xor(o[1]),r=r.add(i[0]).add(yt(e,l+40)),s=Zt(s.add(o[0]),33).mul(Us),i=ah(e,l,i[1].mul(Us),a.add(o[0])),o=ah(e,l+32,s.add(o[1]),r.add(yt(e,l+16))),[s,a]=[a,s],l+=64;while(l!==u);let d=Us.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=ah(e,l,i[1].mul(d),a.add(o[0])),o=ah(e,l+32,s.add(o[1]),r.add(yt(e,l+16))),[s,a]=[a,s],Zr(Zr(i[0],o[0],d).add(Sb(r).mul(fI)).add(s),Zr(i[1],o[1],d).add(a),d)}function G$(e,t){return t==="string"?Fc(e):zm([e],t)}function H$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function zm(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=ti(e)),X().getBool("DEBUG")&&rI(e,t),H$(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=Xp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(r);else{r();for(let o of a)o.dataSync();s=Promise.resolve({kernelMs:Xp()-i})}if(X().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{K$(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 K$(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 Y$(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(!ds(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 C1=20,Ep=3,ub=7;function J$(e,t,n,a){let r=Nl(t),s=Z$(e,t,n,r),i=t.length,o=fh(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 Z$(e,t,n,a){let r=bt(t),s=a[a.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?Rp(e):e;if(o>1)for(let u=0;uC1){let g=Ep*i,y=Array.from(e.slice(0,g)),b=Array.from(e.slice((o-Ep)*i,o*i));return n==="complex64"&&(y=Rp(y),b=Rp(b)),["["+y.map((x,v)=>Dp(x,r[v],n)).join(", ")+", ..., "+b.map((x,v)=>Dp(x,r[o-Ep+v],n)).join(", ")+"]"]}let f=n==="complex64"?Rp(e):Array.from(e);return["["+f.map((g,y)=>Dp(g,r[y],n)).join(", ")+"]"]}let u=t.slice(1),p=a.slice(1),d=a[0]*i,c=[];if(o>C1){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||aI(t,this.size),this.strides=Nl(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;aRh(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=>Rh(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 J$(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(Fe,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ne(){return _x("Tensor",()=>Fe)}ne();var as=class extends Fe{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(!ds(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(as,Symbol.hasInstance,{value:e=>e instanceof Fe&&e.assign!=null&&e.assign instanceof Function});var Ga={};Me(Ga,{assertTypesMatch:()=>bI,getTensorsInContainer:()=>Ex,isTensorInList:()=>sD,makeTypesMatch:()=>At});var Nb;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Nb||(Nb={}));var Tb;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(Tb||(Tb={}));var _b;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(_b||(_b={}));var Cb;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(Cb||(Cb={}));var Eb;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(Eb||(Eb={}));var rD={float32:Cb,int32:Tb,bool:_b,complex64:Eb};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 rD[e][t]}function Bm(e){return ma(e,"int32")}function At(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 bI(e,t){R(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function sD(e,t){return t.some(n=>n.id===e.id)}function Ex(e){let t=[];return xI(e,t,new Set),t}function xI(e,t,n){if(e==null)return;if(e instanceof Fe){t.push(e);return}if(!iD(e))return;let a=e;for(let r in a){let s=a[r];n.has(s)||(n.add(s),xI(s,t,n))}}function iD(e){return Array.isArray(e)||typeof e=="object"}function pb(e){return e.kernelName!=null}var E1=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()}},Yp=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new E1}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){Dh(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 pc)&&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 Yp.nextTensorId++}nextVariableId(){return Yp.nextVariableId++}clone(e){let t=L.runKernel(zi,{x:e}),n={x:e},a=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return L.runKernel(Si,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,$h(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=pb(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(pb(e)){let{kernelName:h,inputs:m,attrs:f}=e;this.backendName==null&&this.backend;let g=$h(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=>v.rank!=null?v:this.makeTensorFromTensorInfo(v));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=pb(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=Ib(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"&&Yr(e[0])&&(r=e.map(o=>Fc(o)));let s=a.write(r,t,n),i=new Fe(t,n,s,this.nextTensorId());if(this.trackTensor(i,a),n==="string"){let o=this.state.tensorInfo.get(s),l=iI(r);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,n,a){n=n||"float32";let r={dataId:e,shape:t,dtype:n};return this.makeTensorFromTensorInfo(r,a)}makeTensorFromTensorInfo(e,t){let{dataId:n,shape:a,dtype:r}=e,s=new Fe(a,r,n,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),a!=null&&a!==e.dtype&&(e=e.cast(a));let r=new as(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*kb(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 as||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*kb(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=Ib(e);o!=null&&(a=o.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((u,p)=>{if(u==null){let d=n[p],c=im(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=Ex(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 Fe,()=>"The result y returned by f() must be a tensor.");let s=Y$(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?oD(r.shape):n,Q$(i,s,l=>this.tidy(l),lD);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(ns(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{R(t.every(i=>i instanceof Fe),()=>"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 Fe,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),R(ns(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 Fe),()=>"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=Xp(),n=await this.backend.time(e);return n.wallMs=Xp()-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 E1;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}};Yp.nextTensorId=0;Yp.nextVariableId=0;function oD(e){let t=Ix(bt(e),"float32");return L.makeTensor(t,e,"float32")}function vI(){let e=cI();if(e._tfengine==null){let t=new pI(e);e._tfengine=new Yp(t)}return F$(e._tfengine.ENV),tD(()=>e._tfengine),e._tfengine}var L=vI();function lD(e,t){let n={a:e,b:t};return L.runKernel(hs,n)}var Ac={};Me(Ac,{isBrowser:()=>wI,isMobile:()=>cD,mockIsMobile:()=>pD});function uD(){return typeof navigator!="undefined"&&navigator!=null}var Fb;function pD(e){Fb=e}function cD(e){if(Fb!==void 0)return Fb;if(e||uD()){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 wI(){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",()=>wI());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")&&kI(e,a,[]),a}function kI(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),F1(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"?zm(e,r):ti(e,[],!0);return L.makeTensor(i,s,r)}function Qp(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)=>F(r,`${t}[${s}]`,n,a))}var II="__op";function z(e){let t=Object.keys(e);if(t.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0],a=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+II;let r=(...s)=>{L.startScope(n);try{let i=a(...s);return Nx(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 dD(e,t){let n=F(e,"real","complex"),a=F(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(cm,r)}var Cr=z({complex_:dD});function ys(e,t,n,a){if(a==null&&(a=sm(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){Sx(t);let r=bt(t),s=bt(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"?zm(e,a):ti(e,[],!0),L.makeTensor(e,t,a)}function Qn(e,t,n){let a=lr(e,n);return ys(e,t,a,n)}var Ab={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Mh=4;async function hD(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)+Mh*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 Fx=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function A1(e){return Fx?Buffer.byteLength(e):new Blob([e]).size}function fD(e){if(Fx)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 $1(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 NI(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 $x(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 $c(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:A1(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:A1(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function yD(){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 bD(){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 xD(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function vD(){let e=yD(),t=bD(),n=xD();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}},wD=e=>Dt.registerSaveRouter(e),kD=e=>Dt.registerLoadRouter(e),ID=e=>Dt.getSaveHandlers(e),SD=(e,t)=>Dt.getLoadHandlers(e,t),$b="tensorflowjs",Db=1,Xs="models_store",Qr="model_info_store";function TI(){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 Rb(e){let t=e.result;t.createObjectStore(Xs,{keyPath:"modelPath"}),t.createObjectStore(Qr,{keyPath:"modelPath"})}var si=class{constructor(e){if(this.indexedDB=TI(),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($b,Db);r.onupgradeneeded=()=>Rb(r),r.onsuccess=()=>{let s=r.result;if(t==null){let i=s.transaction(Xs,"readonly"),o=i.objectStore(Xs).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=$c(t),o=s.transaction(Qr,"readwrite"),l=o.objectStore(Qr),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),p;u.onsuccess=()=>{p=s.transaction(Xs,"readwrite");let d=p.objectStore(Xs).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=c=>{l=o.objectStore(Qr);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)})}};si.URL_SCHEME="indexeddb://";var _I=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(si.URL_SCHEME)?ND(e.slice(si.URL_SCHEME.length)):null;Dt.registerSaveRouter(_I);Dt.registerLoadRouter(_I);function ND(e){return new si(e)}function TD(e){return e.startsWith(si.URL_SCHEME)?e.slice(si.URL_SCHEME.length):e}var _D=class{constructor(){this.indexedDB=TI()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open($b,Db);n.onupgradeneeded=()=>Rb(n),n.onsuccess=()=>{let a=n.result,r=a.transaction(Qr,"readonly"),s=r.objectStore(Qr).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=TD(e),new Promise((t,n)=>{let a=this.indexedDB.open($b,Db);a.onupgradeneeded=()=>Rb(a),a.onsuccess=()=>{let r=a.result,s=r.transaction(Qr,"readwrite"),i=s.objectStore(Qr),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(Xs,"readwrite");let d=l.objectStore(Xs).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",CI="info",CD="model_topology",ED="weight_specs",FD="weight_data",AD="model_metadata";function EI(e){return{info:[tl,e,CI].join(Ir),topology:[tl,e,CD].join(Ir),weightSpecs:[tl,e,ED].join(Ir),weightData:[tl,e,FD].join(Ir),modelMetadata:[tl,e,AD].join(Ir)}}function FI(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function $D(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 DD(e){return e.startsWith(ii.URL_SCHEME)?e.slice(ii.URL_SCHEME.length):e}var ii=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=EI(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=$c(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,fD(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 FI(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=gD(s),t}};ii.URL_SCHEME="localstorage://";var AI=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ii.URL_SCHEME)?RD(e.slice(ii.URL_SCHEME.length)):null;Dt.registerSaveRouter(AI);Dt.registerLoadRouter(AI);function RD(e){return new ii(e)}var MD=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+CI;for(let a=0;a"scheme must not be undefined or null."),e.endsWith(sl)&&(e=e.slice(0,e.indexOf(sl))),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 gh(e){if(e.indexOf(sl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${pa.getSchemes().join(",")}`);return{scheme:e.split(sl)[0],path:e.split(sl)[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=gh(e).scheme,l=gh(e).path,u=o===gh(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 PD(){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+sl+r;t[s]=a[r]}}return t}async function OD(e){let t=gh(e);return pa.getManager(t.scheme).removeModel(t.path)}async function LD(e,t){return $I(e,t,!1)}async function zD(e,t){return $I(e,t,!0)}var BD=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 BD);try{pa.registerManager(ii.URL_SCHEME,new MD)}catch(e){}try{pa.registerManager(si.URL_SCHEME,new _D)}catch(e){}}var WD={importFetch:()=>HA()},cb,VD=class{constructor(){this.util=jA(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(cb==null&&(cb=WD.importFetch()),cb(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 VD);function Ve(e,t="float32",n){return t=t||"float32",Sx(e),new qt(e,t,n)}function UD(e,t){let n=F(e,"x","cast");if(!sI(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(Si,a,r)}var oe=z({cast_:UD});function GD(e){let t={x:F(e,"x","clone","string_or_numeric")};return L.runKernel(zi,t)}var Tr=z({clone_:GD});function DI(e,t=!1){console.log(e.toString(t))}vI();var HD={buffer:Ve,cast:oe,clone:Tr,print:DI};nD(HD);var en={};Me(en,{browserFiles:()=>JD,browserHTTPRequest:()=>aR,concatenateArrayBuffers:()=>Ax,copyModel:()=>LD,decodeWeights:()=>SI,encodeWeights:()=>hD,fromMemory:()=>sR,fromMemorySync:()=>LI,getLoadHandlers:()=>SD,getModelArtifactsForJSON:()=>$x,getModelArtifactsInfoForJSON:()=>$c,getSaveHandlers:()=>ID,http:()=>Rx,isHTTPScheme:()=>Mb,listModels:()=>PD,loadWeights:()=>ZD,moveModel:()=>zD,registerLoadRouter:()=>kD,registerSaveRouter:()=>wD,removeModel:()=>OD,weightsLoaderFactory:()=>MI,withSaveHandler:()=>iR,withSaveHandlerSync:()=>oR});var jD="model",qD=".json",KD=".weights.bin";function D1(e){return new Promise(t=>setTimeout(t)).then(e)}var cl=class{constructor(e){if(!X().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(cl.URL_SCHEME)&&(e=e.slice(cl.URL_SCHEME.length)),(e==null||e.length===0)&&(e=jD),this.modelJsonFileName=e+qD,this.weightDataFileName=e+KD}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=NI(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 D1(()=>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 D1(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:$c(e)}}}};cl.URL_SCHEME="downloads://";var XD=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=$x(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,Ax(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=>$1(r.name)),a={};for(let r of e)r.paths.forEach(s=>{let i=$1(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}},YD=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(cl.URL_SCHEME)?QD(e.slice(cl.URL_SCHEME.length)):null;Dt.registerSaveRouter(YD);function QD(e="model"){return new cl(e)}function JD(e){return new XD(e)}function R1(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 RI(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 R1(a,t.onProgress,r,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await R1(i,t.onProgress,o,l)}async function ZD(e,t="",n,a){return MI(r=>RI(r,{requestInit:a}))(e,t,n)}function MI(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=Ab[y]*bt(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,k)=>{v===g.name&&(x(),i[k]=!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),k=SI(v,[x.manifestEntry]);for(let T in k)d[T]=k[T]}),c+=m}),d}}var eR="application/octet-stream",tR="application/json",Dx=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=NI(e,n);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:tR}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:eR}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:$c(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 $x(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=nR(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 RI(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Ax(l)]}};Dx.URL_SCHEME_REGEX=/^https?:\/\//;function nR(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function Mb(e){return e.match(Dx.URL_SCHEME_REGEX)!=null}var PI=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(a=>Mb(a)):n=Mb(e),n)return Rx(e,t)}return null};Dt.registerSaveRouter(PI);Dt.registerLoadRouter(PI);function Rx(e,t){return new Dx(e,t)}function aR(e,t){return Rx(e,t)}var db=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},OI=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},rR=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function sR(e,t,n,a){let r=arguments;return new rR(LI(...r))}function LI(e,t,n,a){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new db(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 db({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 db({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:a}))}function iR(e){return new OI(e)}function oR(e){return new OI(e)}var zI={};Me(zI,{confusionMatrix:()=>CR});function lR(e,t,n=!1,a=!1){let r=F(e,"a","matMul"),s=F(t,"b","matMul");[r,s]=At(r,s);let i={a:r,b:s},o={transposeA:n,transposeB:a};return L.runKernel(Ii,i,o)}var De=z({matMul_:lR});function uR(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:F(e,"indices","oneHot","int32")},s={depth:t,onValue:n,offValue:a};return L.runKernel(Yi,r,s)}var dl=z({oneHot_:uR});function pR(){X().set("PROD",!0)}function cR(){X().set("DEBUG",!0)}function dR(){X().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Mx(e){X().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}aD(Mx);function hR(){L.disposeVariables()}function ar(){return L}function Ph(){return L.memory()}function mR(e){return L.profile(e)}function O(e,t){return L.tidy(e,t)}function Re(e){Ex(e).forEach(t=>t.dispose())}function tn(e){return L.keep(e)}function fR(e){return L.time(e)}function gR(e){return L.setBackend(e)}function yR(){return L.ready()}function bR(){return L.backendName}function xR(e){L.removeBackend(e)}function vR(e){return L.findBackend(e)}function wR(e){return L.findBackendFactory(e)}function Wm(e,t,n=1){return L.registerBackend(e,t,n)}function BI(){return L.backend}function kR(e,t){X().setPlatform(e,t)}function IR(e){let t={input:F(e,"input","imag")};return L.runKernel(Im,t)}var Dc=z({imag_:IR});function SR(e){let t={x:F(e,"x","neg")};return L.runKernel(au,t)}var wt=z({neg_:SR});function NR(e){let t={input:F(e,"input","real")};return L.runKernel(Fm,t)}var hl=z({real_:NR});function TR(e,t,n){let a=F(e,"x","transpose");if(t==null&&(t=a.shape.map((i,o)=>o).reverse()),R(a.rank===t.length,()=>`Error in transpose: rank of input ${a.rank} must match length of perm ${t}.`),t.forEach(i=>{R(i>=0&&i`All entries in 'perm' must be between 0 and ${a.rank-1} but got ${t}`)}),a.rank<=1)return a.clone();let r={x:a},s={perm:t};return a.dtype==="complex64"?O(()=>{let i=hl(a),o=Dc(a);return i=L.runKernel(Nr,{x:i},s),o=L.runKernel(Nr,{x:o},s),n&&(o=wt(o)),Cr(i,o)}):L.runKernel(Nr,r,s)}var Ae=z({transpose_:TR});function _R(e,t,n){let a=F(e,"labels","confusionMatrix"),r=F(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=dl(oe(a,"int32"),n),i=dl(oe(r,"int32"),n),o=Ae(s),l=De(o,i);return oe(l,"int32")}var CR=z({confusionMatrix_:_R}),Cu={};Me(Cu,{assertAndGetBroadcastShape:()=>ut,getBroadcastDims:()=>WI,getReductionAxes:()=>Vt});function WI(e,t){let n=e.length,a=[];for(let r=0;r1&&i===1&&a.unshift(s)}return a}function Vt(e,t){let n=[];for(let a=0;a1)&&n.unshift(s)}return n}function ut(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;rMR,fromPixelsAsync:()=>DR,toPixels:()=>RR});function Vm(e,t,n){if(xi(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 ys(e,t,a,n)}var Ws;function VI(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