/* Face-API homepage: author: ' */ var faceapi=(()=>{var ob=Object.defineProperty;var M$=Object.getOwnPropertyDescriptor;var P$=Object.getOwnPropertyNames;var O$=Object.prototype.hasOwnProperty;var L$=(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 dh=(e,t)=>{for(var n in t)ob(e,n,{get:t[n],enumerable:!0})},z$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P$(t))!O$.call(e,r)&&r!==n&&ob(e,r,{get:()=>t[r],enumerable:!(a=M$(t,r))||a.enumerable});return e};var W$=e=>z$(ob({},"__esModule",{value:!0}),e);var Cpe={};dh(Cpe,{AgeGenderNet:()=>vd,BoundingBox:()=>Eo,Box:()=>lt,ComposableTask:()=>wa,ComputeAllFaceDescriptorsTask:()=>Ur,ComputeFaceDescriptorsTaskBase:()=>Sd,ComputeSingleFaceDescriptorTask:()=>Gr,DetectAllFaceLandmarksTask:()=>Td,DetectAllFacesTask:()=>yp,DetectFaceLandmarksTaskBase:()=>Nd,DetectFacesTaskBase:()=>_d,DetectSingleFaceLandmarksTask:()=>Cd,DetectSingleFaceTask:()=>Ed,Dimensions:()=>yn,FACE_EXPRESSION_LABELS:()=>i1,FaceDetection:()=>bt,FaceDetectionNet:()=>h1,FaceExpressionNet:()=>xd,FaceExpressions:()=>Wr,FaceLandmark68Net:()=>Lo,FaceLandmark68TinyNet:()=>wd,FaceLandmarkNet:()=>p1,FaceLandmarks:()=>ra,FaceLandmarks5:()=>j0,FaceLandmarks68:()=>$o,FaceMatch:()=>ap,FaceMatcher:()=>Ad,FaceRecognitionNet:()=>zo,Gender:()=>vg,LabeledBox:()=>rp,LabeledFaceDescriptors:()=>xr,NetInput:()=>wr,NeuralNetwork:()=>on,ObjectDetection:()=>Or,Point:()=>Me,PredictedBox:()=>q0,Rect:()=>Ao,SsdMobilenetv1:()=>Es,SsdMobilenetv1Options:()=>va,TinyFaceDetector:()=>Go,TinyFaceDetectorOptions:()=>Id,TinyYolov2:()=>Vo,TinyYolov2Options:()=>ar,allFaces:()=>Spe,allFacesSsdMobilenetv1:()=>WA,allFacesTinyYolov2:()=>Ipe,awaitMediaLoaded:()=>e1,bufferToImage:()=>t1,computeFaceDescriptor:()=>upe,createCanvas:()=>Mo,createCanvasFromMedia:()=>fd,createFaceDetectionNet:()=>npe,createFaceRecognitionNet:()=>Hue,createSsdMobilenetv1:()=>NA,createTinyFaceDetector:()=>Npe,createTinyYolov2:()=>spe,detectAllFaces:()=>Eg,detectFaceLandmarks:()=>LA,detectFaceLandmarksTiny:()=>lpe,detectLandmarks:()=>wpe,detectSingleFace:()=>kpe,draw:()=>l1,env:()=>et,euclideanDistance:()=>g1,extendWithAge:()=>Sg,extendWithFaceDescriptor:()=>Ig,extendWithFaceDetection:()=>Fo,extendWithFaceExpressions:()=>gg,extendWithFaceLandmarks:()=>hp,extendWithGender:()=>Ng,extractFaceTensors:()=>op,extractFaces:()=>ip,fetchImage:()=>$ue,fetchJson:()=>r1,fetchNetWeights:()=>Fue,fetchOrThrow:()=>zr,fetchVideo:()=>Due,getContext2dOrThrow:()=>qn,getMediaDimensions:()=>Ro,imageTensorToCanvas:()=>n1,imageToSquare:()=>a1,inverseSigmoid:()=>Sue,iou:()=>V0,isMediaElement:()=>lg,isMediaLoaded:()=>md,isWithAge:()=>jue,isWithFaceDetection:()=>vr,isWithFaceExpressions:()=>o1,isWithFaceLandmarks:()=>Oo,isWithGender:()=>que,loadAgeGenderModel:()=>bpe,loadFaceDetectionModel:()=>xpe,loadFaceExpressionModel:()=>ype,loadFaceLandmarkModel:()=>mpe,loadFaceLandmarkTinyModel:()=>fpe,loadFaceRecognitionModel:()=>gpe,loadSsdMobilenetv1Model:()=>zA,loadTinyFaceDetectorModel:()=>dpe,loadTinyYolov2Model:()=>hpe,loadWeightMap:()=>s1,locateFaces:()=>vpe,matchDimensions:()=>Rue,minBbox:()=>U0,nets:()=>tt,nonMaxSuppression:()=>G0,normalize:()=>tr,padToSquare:()=>H0,predictAgeAndGender:()=>cpe,recognizeFaceExpressions:()=>ppe,resizeResults:()=>BA,resolveInput:()=>Do,shuffleArray:()=>Iue,sigmoid:()=>cd,ssdMobilenetv1:()=>OA,tf:()=>Le,tinyFaceDetector:()=>ipe,tinyYolov2:()=>ope,toNetInput:()=>xt,utils:()=>B0,validateConfig:()=>m1,version:()=>Tpe});var Le={};dh(Le,{Abs:()=>Dl,Acos:()=>Rl,Acosh:()=>Ml,AdadeltaOptimizer:()=>If,AdagradOptimizer:()=>Sf,AdamOptimizer:()=>Nf,AdamaxOptimizer:()=>Tf,Add:()=>ys,AddN:()=>vi,All:()=>Pl,Any:()=>Ol,ArgMax:()=>wi,ArgMin:()=>dc,Asin:()=>Ll,Asinh:()=>zl,Atan:()=>Wl,Atan2:()=>Vl,Atanh:()=>Bl,AvgPool:()=>ki,AvgPool3D:()=>hc,AvgPool3DGrad:()=>mm,AvgPoolGrad:()=>hm,BackendWasm:()=>eA,BatchMatMul:()=>Ii,BatchToSpaceND:()=>Ul,Bincount:()=>fm,BroadcastArgs:()=>gm,BroadcastTo:()=>EI,Callback:()=>$N,CallbackList:()=>M2,Cast:()=>Si,Ceil:()=>Ni,ClipByValue:()=>bs,Complex:()=>ym,ComplexAbs:()=>mc,Concat:()=>Gl,Conv2D:()=>Ti,Conv2DBackpropFilter:()=>bm,Conv2DBackpropInput:()=>Ci,Conv3D:()=>fc,Conv3DBackpropFilterV2:()=>xm,Conv3DBackpropInputV2:()=>vm,Cos:()=>_i,Cosh:()=>Ei,CropAndResize:()=>jl,Cumprod:()=>Hl,Cumsum:()=>Ai,CustomCallback:()=>O2,DataStorage:()=>pm,DenseBincount:()=>wm,DepthToSpace:()=>ql,DepthwiseConv2dNative:()=>$i,DepthwiseConv2dNativeBackpropFilter:()=>km,DepthwiseConv2dNativeBackpropInput:()=>Im,Diag:()=>Sm,Dilation2D:()=>gc,Dilation2DBackpropFilter:()=>zh,Dilation2DBackpropInput:()=>Lh,ENV:()=>Cx,EarlyStopping:()=>FN,Einsum:()=>Nm,Elu:()=>Di,EluGrad:()=>Tm,Environment:()=>CI,Equal:()=>Xl,Erf:()=>Kl,Exp:()=>Ri,ExpandDims:()=>Yl,Expm1:()=>Jl,FFT:()=>Cm,Fill:()=>yc,FlipLeftRight:()=>Zl,Floor:()=>Mi,FloorDiv:()=>Pi,FromPixels:()=>Wh,FusedBatchNorm:()=>Oi,FusedConv2D:()=>ai,FusedDepthwiseConv2D:()=>ri,GPGPUContext:()=>Dh,GatherNd:()=>eu,GatherV2:()=>Ql,GraphModel:()=>nT,Greater:()=>tu,GreaterEqual:()=>Li,History:()=>P2,IFFT:()=>_m,Identity:()=>zi,Imag:()=>Em,InputSpec:()=>Wt,IsFinite:()=>nu,IsInf:()=>au,IsNan:()=>ru,KernelBackend:()=>cc,LRN:()=>vc,LRNGrad:()=>$m,LayerVariable:()=>$2,LayersModel:()=>Er,LeakyRelu:()=>Wi,Less:()=>su,LessEqual:()=>iu,LinSpace:()=>Am,Log:()=>Bi,Log1p:()=>ou,LogSoftmax:()=>AI,LogicalAnd:()=>lu,LogicalNot:()=>bc,LogicalOr:()=>xc,MathBackendWebGL:()=>Jf,Max:()=>Vi,MaxPool:()=>Gi,MaxPool3D:()=>wc,MaxPool3DGrad:()=>Dm,MaxPoolGrad:()=>Fm,MaxPoolWithArgmax:()=>Rm,Maximum:()=>Ui,Mean:()=>Hi,Min:()=>ji,Minimum:()=>qi,MirrorPad:()=>Ki,Mod:()=>uu,MomentumOptimizer:()=>Cf,Multinomial:()=>Mm,Multiply:()=>Xi,Neg:()=>pu,NonMaxSuppressionV3:()=>du,NonMaxSuppressionV4:()=>hu,NonMaxSuppressionV5:()=>mu,NotEqual:()=>cu,OP_SCOPE_SUFFIX:()=>WI,OneHot:()=>Yi,OnesLike:()=>fu,Optimizer:()=>Dr,OptimizerConstructors:()=>Yr,Pack:()=>gu,PadV2:()=>Ji,Pool:()=>MF,Pow:()=>Zi,Prelu:()=>Qi,Prod:()=>yu,RMSPropOptimizer:()=>_f,RNN:()=>yr,Range:()=>kc,Rank:()=>Tb,Real:()=>Pm,RealDiv:()=>Fi,Reciprocal:()=>bu,Reduction:()=>In,Relu:()=>eo,Relu6:()=>no,Reshape:()=>xu,ResizeBilinear:()=>to,ResizeBilinearGrad:()=>Lm,ResizeNearestNeighbor:()=>Ic,ResizeNearestNeighborGrad:()=>Om,Reverse:()=>ao,RotateWithOffset:()=>Mu,Round:()=>ro,Rsqrt:()=>so,SGDOptimizer:()=>Gc,ScatterNd:()=>vu,Select:()=>wu,Selu:()=>ku,Sequential:()=>Cl,Sigmoid:()=>oo,Sign:()=>Nu,Sin:()=>io,Sinh:()=>Su,Slice:()=>Iu,Softmax:()=>po,Softplus:()=>Tu,SpaceToBatchND:()=>Cu,SparseFillEmptyRows:()=>Sc,SparseReshape:()=>Eu,SparseSegmentMean:()=>Nc,SparseSegmentSum:()=>Tc,SparseToDense:()=>zm,SplitV:()=>_u,Sqrt:()=>lo,Square:()=>Cc,SquaredDifference:()=>co,Step:()=>vs,StridedSlice:()=>Au,StringNGrams:()=>Wm,StringSplit:()=>Bm,StringToHashBucketFast:()=>Vm,Sub:()=>ho,Sum:()=>uo,SymbolicTensor:()=>Ua,Tan:()=>mo,Tanh:()=>fo,Tensor:()=>Ae,TensorBuffer:()=>jt,Tile:()=>xs,TopK:()=>$u,Transform:()=>Fu,Transpose:()=>go,Unique:()=>Um,Unpack:()=>Du,UnsortedSegmentSum:()=>_c,Variable:()=>is,ZerosLike:()=>Ru,_FusedMatMul:()=>ni,abs:()=>zt,acos:()=>Ux,acosh:()=>Gx,add:()=>J,addN:()=>xS,all:()=>Xm,any:()=>ec,argMax:()=>oi,argMin:()=>Hx,asin:()=>jx,asinh:()=>qx,atan:()=>Kx,atan2:()=>Xx,atanh:()=>Yx,avgPool:()=>ga,avgPool3d:()=>Zx,backend:()=>bS,backend_util:()=>_,basicLSTMCell:()=>CM,batchNorm:()=>Ar,batchNorm2d:()=>IS,batchNorm3d:()=>SS,batchNorm4d:()=>NS,batchToSpaceND:()=>Mc,bincount:()=>Qx,booleanMaskAsync:()=>D3,broadcastArgs:()=>TS,broadcastTo:()=>yl,broadcast_util:()=>Pu,browser:()=>yo,buffer:()=>He,callbacks:()=>s6,cast:()=>oe,ceil:()=>ev,clipByValue:()=>nn,clone:()=>_r,complex:()=>os,concat:()=>Qe,concat1d:()=>CS,concat2d:()=>_S,concat3d:()=>ES,concat4d:()=>AS,constraints:()=>b2,conv1d:()=>Ym,conv2d:()=>Rt,conv2dTranspose:()=>Jm,conv3d:()=>nv,conv3dTranspose:()=>FS,copyRegisteredKernels:()=>zF,cos:()=>Pc,cosh:()=>Zm,cosineWindow:()=>Ev,cumprod:()=>av,cumsum:()=>Qm,customGrad:()=>cr,data:()=>aT,denseBincount:()=>DS,deprecationWarn:()=>Vx,depthToSpace:()=>rv,depthwiseConv2d:()=>Is,deregisterOp:()=>l6,device_util:()=>Fc,diag:()=>rP,dilation2d:()=>sv,disableDeprecationWarnings:()=>zR,dispose:()=>De,disposeVariables:()=>WR,div:()=>fe,divNoNan:()=>iv,dot:()=>RS,dropout:()=>t2,einsum:()=>MS,elu:()=>Ou,enableDebugMode:()=>LR,enableProdMode:()=>OR,enclosingPowerOfTwo:()=>n2,engine:()=>sr,env:()=>X,equal:()=>ea,erf:()=>ov,exp:()=>gn,expandDims:()=>mn,expm1:()=>lv,eye:()=>uv,fft:()=>Vc,fill:()=>_n,findBackend:()=>qR,findBackendFactory:()=>KR,floor:()=>Lu,floorDiv:()=>Km,forceHalfFloat:()=>k_,fused:()=>us,gather:()=>ui,gatherND:()=>e2,gather_util:()=>Px,getBackend:()=>HR,getGradient:()=>Sb,getKernel:()=>Bh,getKernelsForBackend:()=>Vh,getThreadsCount:()=>pue,gpgpu_util:()=>e_,grad:()=>DP,grads:()=>RP,greater:()=>Gn,greaterEqual:()=>Ss,ifft:()=>Sl,imag:()=>ef,image:()=>Ln,inTopKAsync:()=>G3,initializers:()=>k2,input:()=>J2,io:()=>Qt,irfft:()=>ff,isFinite:()=>PS,isInf:()=>OS,isNaN:()=>pv,keep:()=>en,kernel_impls:()=>gr,layers:()=>E2,leakyRelu:()=>Oc,less:()=>tf,lessEqual:()=>Ns,linalg:()=>d2,linspace:()=>LS,loadGraphModel:()=>cH,loadLayersModel:()=>fU,localResponseNormalization:()=>cv,log:()=>ta,log1p:()=>Lc,logSigmoid:()=>WS,logSoftmax:()=>af,logSumExp:()=>mv,logicalAnd:()=>_a,logicalNot:()=>zc,logicalOr:()=>rf,logicalXor:()=>GS,losses:()=>Tz,matMul:()=>Fe,math:()=>eS,max:()=>Ta,maxPool:()=>Pt,maxPool3d:()=>fv,maxPoolWithArgmax:()=>HS,maximum:()=>fr,mean:()=>Et,memory:()=>Hh,meshgrid:()=>nO,metrics:()=>_N,min:()=>tc,minimum:()=>zu,mirrorPad:()=>gv,mod:()=>yv,model:()=>hU,models:()=>EN,moments:()=>sf,movingAverage:()=>P3,mul:()=>W,multiRNNCell:()=>pO,multinomial:()=>jS,neg:()=>St,nextFrame:()=>Fv,norm:()=>bf,notEqual:()=>ci,oneHot:()=>kl,ones:()=>Zn,onesLike:()=>na,op:()=>z,outerProduct:()=>fO,pad:()=>ya,pad1d:()=>bO,pad2d:()=>vO,pad3d:()=>kO,pad4d:()=>SO,pool:()=>qS,pow:()=>$r,prelu:()=>Bc,print:()=>YI,prod:()=>of,profile:()=>BR,rand:()=>DO,randomGamma:()=>OO,randomNormal:()=>KS,randomUniform:()=>Wu,range:()=>Il,ready:()=>GR,real:()=>nc,reciprocal:()=>vv,registerBackend:()=>qm,registerCallbackConstructor:()=>gU,registerGradient:()=>$I,registerKernel:()=>Ec,registerOp:()=>o6,regularizers:()=>AN,relu:()=>Xe,relu6:()=>lf,removeBackend:()=>jR,reshape:()=>V,reverse:()=>aa,reverse1d:()=>jO,reverse2d:()=>KO,reverse3d:()=>YO,reverse4d:()=>ZO,rfft:()=>Uc,round:()=>uf,rsqrt:()=>pf,scalar:()=>ke,scatterND:()=>QS,scatter_util:()=>Ox,selu:()=>cf,separableConv2d:()=>xo,sequential:()=>mU,serialization:()=>se,setBackend:()=>UR,setPlatform:()=>XR,setThreadsCount:()=>uue,setWasmPath:()=>oue,setWasmPaths:()=>lue,setWebGLContext:()=>SC,setdiff1dAsync:()=>XS,sigmoid:()=>ma,sign:()=>wv,signal:()=>Nz,sin:()=>df,sinh:()=>hf,slice:()=>Ge,slice1d:()=>mf,slice2d:()=>kv,slice3d:()=>Bu,slice4d:()=>ac,slice_util:()=>qt,softmax:()=>Ja,softplus:()=>bo,spaceToBatchND:()=>Wc,sparse:()=>Op,sparseToDense:()=>_v,spectral:()=>Sz,split:()=>zn,sqrt:()=>un,square:()=>ut,squaredDifference:()=>gf,squeeze:()=>dr,stack:()=>Mt,step:()=>Vu,stridedSlice:()=>Iv,string:()=>Th,sub:()=>ce,sum:()=>be,sumOutType:()=>Hm,tan:()=>Sv,tanh:()=>li,tensor:()=>Qn,tensor1d:()=>qe,tensor2d:()=>Ha,tensor3d:()=>jm,tensor4d:()=>Za,tensor5d:()=>S3,tensor6d:()=>N3,tensor_util:()=>Ga,test_util:()=>fS,tidy:()=>O,tile:()=>On,time:()=>VR,topk:()=>Nv,train:()=>Gs,transpose:()=>Pe,truncatedNormal:()=>yf,unique:()=>qh,unregisterGradient:()=>LF,unregisterKernel:()=>OF,unsortedSegmentSum:()=>Tv,unstack:()=>mt,upcastType:()=>fa,util:()=>k,valueAndGrad:()=>MP,valueAndGrads:()=>PP,variable:()=>YS,variableGrads:()=>zS,version:()=>wue,version_converter:()=>dH,version_core:()=>PR,version_layers:()=>ew,version_wasm:()=>cue,version_webgl:()=>w9,webgl:()=>k9,webgl_util:()=>IC,where:()=>fn,whereAsync:()=>Cv,zeros:()=>kt,zerosLike:()=>Ke});var B$=Object.create,kx=Object.defineProperty,V$=Object.getOwnPropertyDescriptor,U$=Object.getOwnPropertyNames,G$=Object.getPrototypeOf,H$=Object.prototype.hasOwnProperty,ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Re=(e,t)=>{for(var n in t)kx(e,n,{get:t[n],enumerable:!0})},j$=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of U$(t))!H$.call(e,r)&&r!==n&&kx(e,r,{get:()=>t[r],enumerable:!(a=V$(t,r))||a.enumerable});return e},bi=(e,t,n)=>(n=e!=null?B$(G$(e)):{},j$(t||!e||!e.__esModule?kx(n,"default",{value:e,enumerable:!0}):n,e)),q$=ft((e,t)=>{t.exports=a;var n=null;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(S){}function a(S,M,B){this.low=S|0,this.high=M|0,this.unsigned=!!B}a.prototype.__isLong__,Object.defineProperty(a.prototype,"__isLong__",{value:!0});function r(S){return(S&&S.__isLong__)===!0}a.isLong=r;var s={},i={};function o(S,M){var B,j,q;return M?(S>>>=0,(q=0<=S&&S<256)&&(j=i[S],j)?j:(B=u(S,(S|0)<0?-1:0,!0),q&&(i[S]=B),B)):(S|=0,(q=-128<=S&&S<128)&&(j=s[S],j)?j:(B=u(S,S<0?-1:0,!1),q&&(s[S]=B),B))}a.fromInt=o;function l(S,M){if(isNaN(S))return M?v:x;if(M){if(S<0)return v;if(S>=g)return $}else{if(S<=-y)return P;if(S+1>=y)return E}return S<0?l(-S,M).neg():u(S%f|0,S/f|0,M)}a.fromNumber=l;function u(S,M,B){return new a(S,M,B)}a.fromBits=u;var p=Math.pow;function d(S,M,B){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof M=="number"?(B=M,M=!1):M=!!M,B=B||10,B<2||360)throw Error("interior hyphen");if(j===0)return d(S.substring(1),M,B).neg();for(var q=l(p(B,8)),K=x,Q=0;Q>>0:this.low},F.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},F.toString=function(S){if(S=S||10,S<2||36>>0,Z=re.toString(S);if(K=ee,K.isZero())return Z+Q;for(;Z.length<6;)Z="0"+Z;Q=""+Z+Q}},F.getHighBits=function(){return this.high},F.getHighBitsUnsigned=function(){return this.high>>>0},F.getLowBits=function(){return this.low},F.getLowBitsUnsigned=function(){return this.low>>>0},F.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,M=31;M>0&&(S&1<=0},F.isOdd=function(){return(this.low&1)===1},F.isEven=function(){return(this.low&1)===0},F.equals=function(S){return r(S)||(S=c(S)),this.unsigned!==S.unsigned&&this.high>>>31===1&&S.high>>>31===1?!1:this.high===S.high&&this.low===S.low},F.eq=F.equals,F.notEquals=function(S){return!this.eq(S)},F.neq=F.notEquals,F.ne=F.notEquals,F.lessThan=function(S){return this.comp(S)<0},F.lt=F.lessThan,F.lessThanOrEqual=function(S){return this.comp(S)<=0},F.lte=F.lessThanOrEqual,F.le=F.lessThanOrEqual,F.greaterThan=function(S){return this.comp(S)>0},F.gt=F.greaterThan,F.greaterThanOrEqual=function(S){return this.comp(S)>=0},F.gte=F.greaterThanOrEqual,F.ge=F.greaterThanOrEqual,F.compare=function(S){if(r(S)||(S=c(S)),this.eq(S))return 0;var M=this.isNegative(),B=S.isNegative();return M&&!B?-1:!M&&B?1:this.unsigned?S.high>>>0>this.high>>>0||S.high===this.high&&S.low>>>0>this.low>>>0?-1:1:this.sub(S).isNegative()?-1:1},F.comp=F.compare,F.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(w)},F.neg=F.negate,F.add=function(S){r(S)||(S=c(S));var M=this.high>>>16,B=this.high&65535,j=this.low>>>16,q=this.low&65535,K=S.high>>>16,Q=S.high&65535,ee=S.low>>>16,re=S.low&65535,Z=0,ie=0,ae=0,le=0;return le+=q+re,ae+=le>>>16,le&=65535,ae+=j+ee,ie+=ae>>>16,ae&=65535,ie+=B+Q,Z+=ie>>>16,ie&=65535,Z+=M+K,Z&=65535,u(ae<<16|le,Z<<16|ie,this.unsigned)},F.subtract=function(S){return r(S)||(S=c(S)),this.add(S.neg())},F.sub=F.subtract,F.multiply=function(S){if(this.isZero())return x;if(r(S)||(S=c(S)),n){var M=n.mul(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(P))return S.isOdd()?P:x;if(S.eq(P))return this.isOdd()?P:x;if(this.isNegative())return S.isNegative()?this.neg().mul(S.neg()):this.neg().mul(S).neg();if(S.isNegative())return this.mul(S.neg()).neg();if(this.lt(b)&&S.lt(b))return l(this.toNumber()*S.toNumber(),this.unsigned);var B=this.high>>>16,j=this.high&65535,q=this.low>>>16,K=this.low&65535,Q=S.high>>>16,ee=S.high&65535,re=S.low>>>16,Z=S.low&65535,ie=0,ae=0,le=0,ue=0;return ue+=K*Z,le+=ue>>>16,ue&=65535,le+=q*Z,ae+=le>>>16,le&=65535,le+=K*re,ae+=le>>>16,le&=65535,ae+=j*Z,ie+=ae>>>16,ae&=65535,ae+=q*re,ie+=ae>>>16,ae&=65535,ae+=K*ee,ie+=ae>>>16,ae&=65535,ie+=B*Z+j*re+q*ee+K*Q,ie&=65535,u(le<<16|ue,ie<<16|ae,this.unsigned)},F.mul=F.multiply,F.divide=function(S){if(r(S)||(S=c(S)),S.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var M=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?v:x;var B,j,q;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return v;if(S.gt(this.shru(1)))return T;q=v}else{if(this.eq(P)){if(S.eq(w)||S.eq(C))return P;if(S.eq(P))return w;var K=this.shr(1);return B=K.div(S).shl(1),B.eq(x)?S.isNegative()?w:C:(j=this.sub(S.mul(B)),q=B.add(j.div(S)),q)}else if(S.eq(P))return this.unsigned?v:x;if(this.isNegative())return S.isNegative()?this.neg().div(S.neg()):this.neg().div(S).neg();if(S.isNegative())return this.div(S.neg()).neg();q=x}for(j=this;j.gte(S);){B=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var Q=Math.ceil(Math.log(B)/Math.LN2),ee=Q<=48?1:p(2,Q-48),re=l(B),Z=re.mul(S);Z.isNegative()||Z.gt(j);)B-=ee,re=l(B,this.unsigned),Z=re.mul(S);re.isZero()&&(re=w),q=q.add(re),j=j.sub(Z)}return q},F.div=F.divide,F.modulo=function(S){if(r(S)||(S=c(S)),n){var M=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,S.low,S.high);return u(M,n.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},F.mod=F.modulo,F.rem=F.modulo,F.not=function(){return u(~this.low,~this.high,this.unsigned)},F.and=function(S){return r(S)||(S=c(S)),u(this.low&S.low,this.high&S.high,this.unsigned)},F.or=function(S){return r(S)||(S=c(S)),u(this.low|S.low,this.high|S.high,this.unsigned)},F.xor=function(S){return r(S)||(S=c(S)),u(this.low^S.low,this.high^S.high,this.unsigned)},F.shiftLeft=function(S){return r(S)&&(S=S.toInt()),(S&=63)===0?this:S<32?u(this.low<>>32-S,this.unsigned):u(0,this.low<>>S|this.high<<32-S,this.high>>S,this.unsigned):u(this.high>>S-32,this.high>=0?0:-1,this.unsigned)},F.shr=F.shiftRight,F.shiftRightUnsigned=function(S){if(r(S)&&(S=S.toInt()),S&=63,S===0)return this;var M=this.high;if(S<32){var B=this.low;return u(B>>>S|M<<32-S,M>>>S,this.unsigned)}else return S===32?u(M,0,this.unsigned):u(M>>>S-32,0,this.unsigned)},F.shru=F.shiftRightUnsigned,F.shr_u=F.shiftRightUnsigned,F.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},F.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},F.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},F.toBytesLE=function(){var S=this.high,M=this.low;return[M&255,M>>>8&255,M>>>16&255,M>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},F.toBytesBE=function(){var S=this.high,M=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,M>>>24,M>>>16&255,M>>>8&255,M&255]},a.fromBytes=function(S,M,B){return B?a.fromBytesLE(S,M):a.fromBytesBE(S,M)},a.fromBytesLE=function(S,M){return new a(S[0]|S[1]<<8|S[2]<<16|S[3]<<24,S[4]|S[5]<<8|S[6]<<16|S[7]<<24,M)},a.fromBytesBE=function(S,M){return new a(S[4]<<24|S[5]<<16|S[6]<<8|S[7],S[0]<<24|S[1]<<16|S[2]<<8|S[3],M)}}),K$=ft(()=>{}),X$=ft(()=>{}),Y$=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)}),J$=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)}),Z$=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)}),Q$=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)}),eF=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)}),tF=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)}),hI=ft(()=>{}),nF=ft((e,t)=>{(function(n,a){var r=this,s=256,i=6,o=52,l="random",u=a.pow(s,i),p=a.pow(2,o),d=p*2,c=s-1,h;function m(w,T,C){var E=[];T=T==!0?{entropy:!0}:T||{};var $=b(y(T.entropy?[w,v(n)]:w==null?x():w,3),E),P=new f(E),F=function(){for(var S=P.g(i),M=u,B=0;S=d;)S/=2,M/=2,B>>>=1;return(S+B)/M};return F.int32=function(){return P.g(4)|0},F.quick=function(){return P.g(4)/4294967296},F.double=F,b(v(P.S),n),(T.pass||C||function(S,M,B,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),B?(a[l]=S,M):S})(F,$,"global"in T?T.global:this==a,T.state)}a["seed"+l]=m;function f(w){var T,C=w.length,E=this,$=0,P=E.i=E.j=0,F=E.S=[];for(C||(w=[C++]);${var n=Y$(),a=J$(),r=Z$(),s=Q$(),i=eF(),o=tF(),l=nF();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),aF=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)}),rF=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)}),sF=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)}),iF=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)}),oF=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)}),lF=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)}),uF=ft((e,t)=>{(function(n,a,r){var s=256,i=6,o=52,l="random",u=r.pow(s,i),p=r.pow(2,o),d=p*2,c=s-1,h;function m(w,T,C){var E=[];T=T==!0?{entropy:!0}:T||{};var $=b(y(T.entropy?[w,v(a)]:w==null?x():w,3),E),P=new f(E),F=function(){for(var S=P.g(i),M=u,B=0;S=d;)S/=2,M/=2,B>>>=1;return(S+B)/M};return F.int32=function(){return P.g(4)|0},F.quick=function(){return P.g(4)/4294967296},F.double=F,b(v(P.S),a),(T.pass||C||function(S,M,B,j){return j&&(j.S&&g(j,P),S.state=function(){return g(P,{})}),B?(r[l]=S,M):S})(F,$,"global"in T?T.global:this==r,T.state)}function f(w){var T,C=w.length,E=this,$=0,P=E.i=E.j=0,F=E.S=[];for(C||(w=[C++]);${var n=aF(),a=rF(),r=sF(),s=iF(),i=oF(),o=lF(),l=uF();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),gI=ft(()=>{}),Ix=ft(()=>{}),Mh=ft(()=>{}),pF=ft(()=>{}),cF=ft(()=>{}),dF=ft(()=>{}),hF=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!=xn&&Ra(Te.buffer),Fd}function i(){return Te.buffer!=xn&&Ra(Te.buffer),Dd}function o(){return Te.buffer!=xn&&Ra(Te.buffer),xp}function l(){return Te.buffer!=xn&&Ra(Te.buffer),Rd}function u(){return Te.buffer!=xn&&Ra(Te.buffer),Md}function p(){return Te.buffer!=xn&&Ra(Te.buffer),Pd}function d(){return Te.buffer!=xn&&Ra(Te.buffer),Od}var c=typeof r!="undefined"?r:{},h,m;c.ready=new Promise(function(N,D){h=N,m=D});var f;typeof process!="undefined"&&process.listeners&&(f={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},c),y=[],b="./this.program",x=(N,D)=>{throw D},v=typeof window=="object",w=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",C=c.ENVIRONMENT_IS_PTHREAD||!1,E="";function $(N){return c.locateFile?c.locateFile(N,E):E+N}var P,F,S,M;function B(N){N instanceof Ep||Z("exiting due to exception: "+N)}var j,q,K;if(T){w?E=Mh().dirname(E)+"/":E=__dirname+"/",K=()=>{q||(j=Ix(),q=Mh())},P=function(D,U){return K(),D=q.normalize(D),j.readFileSync(D,U?void 0:"utf8")},S=D=>{var U=P(D,!0);return U.buffer||(U=new Uint8Array(U)),U},F=(D,U,Y)=>{K(),D=q.normalize(D),j.readFile(D,function(pe,he){pe?Y(pe):U(he.buffer)})},process.argv.length>1&&(b=process.argv[1].replace(/\\/g,"/")),y=process.argv.slice(2),process.on("uncaughtException",function(D){if(!(D instanceof Ep))throw D}),process.on("unhandledRejection",function(D){throw D}),x=(D,U)=>{if(Ps())throw process.exitCode=D,U;B(U),process.exit(D)},c.inspect=function(){return"[Emscripten Module object]"};let N;try{N=pF()}catch(D){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),D}global.Worker=N.Worker}else(v||w)&&(w?E=self.location.href:typeof document!="undefined"&&document.currentScript&&(E=document.currentScript.src),typeof a!="undefined"&&a&&(E=a),E.indexOf("blob:")!==0?E=E.substr(0,E.replace(/[?#].*/,"").lastIndexOf("/")+1):E="",T||(P=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.send(null),D.responseText},w&&(S=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),F=(N,D,U)=>{var Y=new XMLHttpRequest;Y.open("GET",N,!0),Y.responseType="arraybuffer",Y.onload=()=>{if(Y.status==200||Y.status==0&&Y.response){D(Y.response);return}U()},Y.onerror=U,Y.send(null)}),M=N=>document.title=N);T&&typeof performance=="undefined"&&(global.performance=cF().performance);var Q=console.log.bind(console),ee=console.warn.bind(console);T&&(K(),Q=N=>j.writeSync(1,N+` `),ee=N=>j.writeSync(2,N+` `));var re=c.print||Q,Z=c.printErr||ee;Object.assign(c,g),g=null,c.arguments&&(y=c.arguments),c.thisProgram&&(b=c.thisProgram),c.quit&&(x=c.quit);var ie=4;function ae(N){ae.shown||(ae.shown={}),ae.shown[N]||(ae.shown[N]=1,Z(N))}function le(N,D){if(typeof WebAssembly.Function=="function"){for(var U={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:D[0]=="v"?[]:[U[D[0]]]},pe=1;pe{Ee=N},We=Atomics.load,je=Atomics.store,st=Atomics.compareExchange,nt;c.wasmBinary&&(nt=c.wasmBinary);var at=c.noExitRuntime||!0;typeof WebAssembly!="object"&&Jo("no native wasm support detected");var Te,gt,ct=!1,bn;function Yt(N,D){N||Jo(D)}function Dn(N){var D=c["_"+N];return D}function Ut(N,D,U,Y,pe){var he={string:function(ua){var ol=0;if(ua!=null&&ua!==0){var O1=(ua.length<<2)+1;ol=il(O1),Rs(ua,ol,O1)}return ol},array:function(ua){var ol=il(ua.length);return kr(ua,ol),ol}};function ve(ua){return D==="string"?oa(ua):D==="boolean"?Boolean(ua):ua}var Ce=Dn(N),_t=[],La=0;if(Y)for(var za=0;za(U.buffer instanceof SharedArrayBuffer&&(U=new Uint8Array(U)),D.decode.call(D,U))}var Gt=typeof TextDecoder!="undefined"?new Rn("utf8"):void 0;function ia(N,D,U){for(var Y=D+U,pe=D;N[pe]&&!(pe>=Y);)++pe;if(pe-D>16&&N.subarray&&Gt)return Gt.decode(N.subarray(D,pe));for(var he="";D>10,56320|La&1023)}}return he}function oa(N,D){return N?ia(i(),N,D):""}function Hr(N,D,U,Y){if(!(Y>0))return 0;for(var pe=U,he=U+Y-1,ve=0;ve=55296&&Ce<=57343){var _t=N.charCodeAt(++ve);Ce=65536+((Ce&1023)<<10)|_t&1023}if(Ce<=127){if(U>=he)break;D[U++]=Ce}else if(Ce<=2047){if(U+1>=he)break;D[U++]=192|Ce>>6,D[U++]=128|Ce&63}else if(Ce<=65535){if(U+2>=he)break;D[U++]=224|Ce>>12,D[U++]=128|Ce>>6&63,D[U++]=128|Ce&63}else{if(U+3>=he)break;D[U++]=240|Ce>>18,D[U++]=128|Ce>>12&63,D[U++]=128|Ce>>6&63,D[U++]=128|Ce&63}}return D[U]=0,U-pe}function Rs(N,D,U){return Hr(N,i(),D,U)}function $d(N){for(var D=0,U=0;U=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|N.charCodeAt(++U)&1023),Y<=127?++D:Y<=2047?D+=2:Y<=65535?D+=3:D+=4}return D}var jr=typeof TextDecoder!="undefined"?new Rn("utf-16le"):void 0;function kr(N,D){s().set(N,D)}function bp(N,D,U){for(var Y=0;Y>0]=N.charCodeAt(Y);U||(s()[D>>0]=0)}function Xo(N,D){return N%D>0&&(N+=D-N%D),N}var xn,Fd,Dd,xp,Rd,Md,y1,Pd,Od;C&&(xn=c.buffer);function Ra(N){xn=N,c.HEAP8=Fd=new Int8Array(N),c.HEAP16=xp=new Int16Array(N),c.HEAP32=Md=new Int32Array(N),c.HEAPU8=Dd=new Uint8Array(N),c.HEAPU16=Rd=new Uint16Array(N),c.HEAPU32=y1=new Uint32Array(N),c.HEAPF32=Pd=new Float32Array(N),c.HEAPF64=Od=new Float64Array(N)}var Ld=c.INITIAL_MEMORY||16777216;if(C)Te=c.wasmMemory,xn=c.buffer;else if(c.wasmMemory)Te=c.wasmMemory;else if(Te=new WebAssembly.Memory({initial:Ld/65536,maximum:32768,shared:!0}),!(Te.buffer instanceof SharedArrayBuffer))throw Z("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),T&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Te&&(xn=Te.buffer),Ld=xn.byteLength,Ra(xn);var la,Yo=[],qr=[],Ag=[],zd=[],Ms=!1,$g=!1,Wd=0;function Ps(){return at||Wd>0}function vn(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)b1(c.preRun.shift());Gd(Yo)}function vp(){Ms=!0,!C&&Gd(qr)}function Fg(){C||(_e.terminateAllThreads(),$g=!0)}function Dg(){if(!C){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)wp(c.postRun.shift());Gd(zd)}}function b1(N){Yo.unshift(N)}function x1(N){qr.unshift(N)}function wp(N){zd.unshift(N)}var Kr=0,Bd=null,Ma=null;function kp(N){Kr++,c.monitorRunDependencies&&c.monitorRunDependencies(Kr)}function v1(N){if(Kr--,c.monitorRunDependencies&&c.monitorRunDependencies(Kr),Kr==0&&(Bd!==null&&(clearInterval(Bd),Bd=null),Ma)){var D=Ma;Ma=null,D()}}c.preloadedImages={},c.preloadedAudios={};function Jo(N){C?postMessage({cmd:"onAbort",arg:N}):c.onAbort&&c.onAbort(N),N="Aborted("+N+")",Z(N),ct=!0,bn=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 Ip(N){return N.startsWith(Rg)}function Vd(N){return N.startsWith("file://")}var wn;wn="tfjs-backend-wasm-threaded-simd.wasm",Ip(wn)||(wn=$(wn));function Ud(N){try{if(N==wn&&nt)return new Uint8Array(nt);if(S)return S(N);throw"both async and sync fetching of the wasm failed"}catch(D){Jo(D)}}function Zo(){if(!nt&&(v||w)){if(typeof fetch=="function"&&!Vd(wn))return fetch(wn,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+wn+"'";return N.arrayBuffer()}).catch(function(){return Ud(wn)});if(F)return new Promise(function(N,D){F(wn,function(U){N(new Uint8Array(U))},D)})}return Promise.resolve().then(function(){return Ud(wn)})}function Mg(){var N={env:nh,wasi_snapshot_preview1:nh};function D(ve,Ce){var _t=ve.exports;if(c.asm=_t,Vg(c.asm.emscripten_tls_init),la=c.asm.__indirect_function_table,x1(c.asm.__wasm_call_ctors),gt=Ce,!C){var La=_e.unusedWorkers.length;_e.unusedWorkers.forEach(function(za){_e.loadWasmModuleToWorker(za,function(){--La||v1("wasm-instantiate")})})}}C||kp("wasm-instantiate");function U(ve){D(ve.instance,ve.module)}function Y(ve){return Zo().then(function(Ce){return WebAssembly.instantiate(Ce,N)}).then(function(Ce){return Ce}).then(ve,function(Ce){Z("failed to asynchronously prepare wasm: "+Ce),Jo(Ce)})}function pe(){return!nt&&typeof WebAssembly.instantiateStreaming=="function"&&!Ip(wn)&&!Vd(wn)&&typeof fetch=="function"?fetch(wn,{credentials:"same-origin"}).then(function(ve){var Ce=WebAssembly.instantiateStreaming(ve,N);return Ce.then(U,function(_t){return Z("wasm streaming compile failed: "+_t),Z("falling back to ArrayBuffer instantiation"),Y(U)})}):Y(U)}if(c.instantiateWasm)try{var he=c.instantiateWasm(N,D);return he}catch(ve){return Z("Module.instantiateWasm callback failed with error: "+ve),!1}return pe().catch(m),{}}var w1,k1,Pg={};function Gd(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?el(U)():el(U)(D.arg):U(D.arg===void 0?null:D.arg)}}function Qo(N){var D=sb(),U=N();return oh(D),U}function VA(N){return N}function I1(N){var D=/\b_Z[\w\d_]+/g;return N.replace(D,function(U){var Y=U;return U===Y?U:Y+" ["+U+"]"})}function Og(N){u()[N>>2]=0;var D=_e.pthreads[N];delete _e.pthreads[N],D.worker.terminate(),rb(N),_e.runningWorkers.splice(_e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function Lg(N){var D=_e.pthreads[N];D.worker.postMessage({cmd:"cancel"})}function Hd(N){var D=_e.pthreads[N];if(D){u()[N>>2]=0;var U=D.worker;_e.returnWorkerToPool(U)}}function jd(N){$$(N)}function zg(N){if(N instanceof Ep||N=="unwind")return bn;x(1,N)}var _e={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){C?_e.initWorker():_e.initMainThread()},initMainThread:function(){for(var N=8,D=0;D>2]=0;try{N()}finally{u()[P1>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in _e.tlsInitFunctions)_e.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=U=>{var Y=U.data,pe=Y.cmd;if(N.pthread&&(_e.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=ih()){var he=_e.pthreads[Y.targetThread];he?he.worker.postMessage(Y,Y.transferList):Z('Internal error! Worker sent a message "'+pe+'" to target pthread '+Y.targetThread+", but that thread no longer exists!"),_e.currentProxiedOperationCallerThread=void 0;return}pe==="processQueuedMainThreadWork"?$1():pe==="spawnThread"?Kd(Y):pe==="cleanupThread"?Hd(Y.thread):pe==="killThread"?Og(Y.thread):pe==="cancelThread"?Lg(Y.thread):pe==="loaded"?(N.loaded=!0,D&&D(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):pe==="print"?re("Thread "+Y.threadId+": "+Y.text):pe==="printErr"?Z("Thread "+Y.threadId+": "+Y.text):pe==="alert"?alert("Thread "+Y.threadId+": "+Y.text):Y.target==="setimmediate"?N.postMessage(Y):pe==="onAbort"?c.onAbort&&c.onAbort(Y.arg):Z("worker sent an unknown command "+pe),_e.currentProxiedOperationCallerThread=void 0},N.onerror=U=>{var Y="worker sent an error!";throw Z(Y+" "+U.filename+":"+U.lineno+": "+U.message),U},T&&(N.on("message",function(U){N.onmessage({data:U})}),N.on("error",function(U){N.onerror(U)}),N.on("detachedExit",function(){})),N.postMessage({cmd:"load",urlOrBlob:c.mainScriptUrlOrBlob||a,wasmMemory:Te,wasmModule:gt})},allocateUnusedWorker:function(){var N=$("tfjs-backend-wasm-threaded-simd.worker.js");_e.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return _e.unusedWorkers.length==0&&(_e.allocateUnusedWorker(),_e.loadWasmModuleToWorker(_e.unusedWorkers[0])),_e.unusedWorkers.pop()}};function Wg(){var N=ih(),D=u()[N+44>>2],U=u()[N+48>>2],Y=D-U;M1(D,Y),oh(D)}c.establishStackSpace=Wg;function qd(N){if(C)return zs(1,0,N);try{jd(N)}catch(D){zg(D)}}var Os=[];function el(N){var D=Os[N];return D||(N>=Os.length&&(Os.length=N+1),Os[N]=D=la.get(N)),D}function Bg(N,D){return el(N)(D)}c.invokeEntryPoint=Bg;function S1(){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){_e.tlsInitFunctions.push(N)}function N1(N,D){la.set(N,D),Os[N]=D}var Ls;T?Ls=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:C?Ls=()=>performance.now()-c.__performance_now_clock_drift:Ls=()=>performance.now();var Ug=!0;function Gg(N){return u()[A1()>>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){F1(N,!w,1,!v),_e.threadInit()}function Kg(N){C?postMessage({cmd:"cleanupThread",thread:N}):Hd(N)}function Kd(N){var D=_e.getNewWorker();if(!D)return 6;_e.runningWorkers.push(D);var U=_e.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=U;var Y={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return D.runPthread=()=>{Y.time=performance.now(),D.postMessage(Y,N.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function Xg(N,D,U,Y){if(typeof SharedArrayBuffer=="undefined")return Z("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var pe=[],he=0;if(C&&(pe.length===0||he))return D1(687865856,N,D,U,Y);if(he)return he;var ve={startRoutine:U,pthread_ptr:N,arg:Y,transferList:pe};return C?(ve.cmd="spawnThread",postMessage(ve,pe),0):Kd(ve)}function Yg(){return 2097152}function Jg(N,D){if(N==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(C)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var U=_e.pthreads[N],Y=U&&U.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function Zg(){Jo("")}function Qg(){T||w||ae("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Xd(){return 2147483648}function ey(N,D,U){i().copyWithin(N,D,D+U)}function ty(){return T?dF().cpus().length:navigator.hardwareConcurrency}function zs(N,D){var U=arguments.length-2,Y=arguments;return Qo(function(){for(var pe=U,he=il(pe*8),ve=he>>3,Ce=0;Ce>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=Xd();if(N>U)return!1;for(var Y=1;Y<=4;Y*=2){var pe=D*(1+.2/Y);pe=Math.min(pe,N+100663296);var he=Math.min(U,Xo(Math.max(N,pe),65536)),ve=ay(he);if(ve)return!0}return!1}var Ve={inEventHandler:0,removeAllEventListeners:function(){for(var N=Ve.eventHandlers.length-1;N>=0;--N)Ve._removeHandler(N);Ve.eventHandlers=[],Ve.deferredCalls=[]},registerRemoveEventListeners:function(){Ve.removeEventListenersRegistered||(Ag.push(Ve.removeAllEventListeners),Ve.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,U){function Y(ve,Ce){if(ve.length!=Ce.length)return!1;for(var _t in ve)if(ve[_t]!=Ce[_t])return!1;return!0}for(var pe in Ve.deferredCalls){var he=Ve.deferredCalls[pe];if(he.targetFunction==N&&Y(he.argsList,U))return}Ve.deferredCalls.push({targetFunction:N,precedence:D,argsList:U}),Ve.deferredCalls.sort(function(ve,Ce){return ve.precedence>2]=U,u()[he+4>>2]=Y,u()[he+8>>2]=pe,ab(N,637534208,D,Y,he)})},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return _e.currentProxiedOperationCallerThread;default:return N}},getNodeNameForTarget:function(N){return N?N==window?"#window":N==screen?"#screen":N&&N.nodeName?N.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function sy(N){var D=$d(N)+1,U=nb(D);return Rs(N,U,D),U}function iy(N,D,U,Y){Qo(function(){var pe=il(12),he=0;D&&(he=sy(D)),u()[pe>>2]=he,u()[pe+4>>2]=U,u()[pe+8>>2]=Y,ab(N,657457152,0,he,pe)})}function oy(N,D,U,Y){D=D?oa(D):"",iy(N,D,U,Y)}function ly(N){return N>2?oa(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 Np(N){return py(N)}function Yd(N,D,U){var Y=Np(N);if(!Y)return-4;if(Y.canvasSharedPtr&&(u()[Y.canvasSharedPtr>>2]=D,u()[Y.canvasSharedPtr+4>>2]=U),Y.offscreenCanvas||!Y.controlTransferredOffscreen){Y.offscreenCanvas&&(Y=Y.offscreenCanvas);var pe=!1;if(Y.GLctxObject&&Y.GLctxObject.GLctx){var he=Y.GLctxObject.GLctx.getParameter(2978);pe=he[0]===0&&he[1]===0&&he[2]===Y.width&&he[3]===Y.height}Y.width=D,Y.height=U,pe&&Y.GLctxObject.GLctx.viewport(0,0,D,U)}else if(Y.canvasSharedPtr){var ve=u()[Y.canvasSharedPtr+8>>2];return oy(ve,N,D,U),1}else return-4;return 0}function Jd(N,D,U){return C?zs(2,1,N,D,U):Yd(N,D,U)}function cy(N,D,U){var Y=Np(N);return Y?Yd(N,D,U):Jd(N,D,U)}function dy(){throw"unwind"}function hy(N){var D=N.getExtension("ANGLE_instanced_arrays");if(D)return N.vertexAttribDivisor=function(U,Y){D.vertexAttribDivisorANGLE(U,Y)},N.drawArraysInstanced=function(U,Y,pe,he){D.drawArraysInstancedANGLE(U,Y,pe,he)},N.drawElementsInstanced=function(U,Y,pe,he,ve){D.drawElementsInstancedANGLE(U,Y,pe,he,ve)},1}function 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,Y){D.drawBuffersWEBGL(U,Y)},1}function gy(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var Ct={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(N){Ct.lastError||(Ct.lastError=N)},getNewId:function(N){for(var D=Ct.counter++,U=N.length;U>2]:-1;pe+=oa(u()[U+he*4>>2],ve<0?void 0:ve)}return pe},createContext:function(N,D){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(pe,he){var ve=N.getContextSafariWebGL2Fixed(pe,he);return pe=="webgl"==ve instanceof WebGLRenderingContext?ve:null});var U=N.getContext("webgl",D);if(!U)return 0;var Y=Ct.registerContext(U,D);return Y},registerContext:function(N,D){var U=nb(8);u()[U+4>>2]=ih();var Y={handle:U,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Y),Ct.contexts[U]=Y,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&&Ct.initExtensions(Y),U},makeContextCurrent:function(N){return Ct.currentContext=Ct.contexts[N],c.ctx=th=Ct.currentContext&&Ct.currentContext.GLctx,!(N&&!th)},getContext:function(N){return Ct.contexts[N]},deleteContext:function(N){Ct.currentContext===Ct.contexts[N]&&(Ct.currentContext=null),typeof Ve=="object"&&Ve.removeAllHandlersOnTarget(Ct.contexts[N].GLctx.canvas),Ct.contexts[N]&&Ct.contexts[N].GLctx.canvas&&(Ct.contexts[N].GLctx.canvas.GLctxObject=void 0),E1(Ct.contexts[N].handle),Ct.contexts[N]=null},initExtensions:function(N){if(N||(N=Ct.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var D=N.GLctx;hy(D),my(D),fy(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),gy(D);var U=D.getSupportedExtensions()||[];U.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&D.getExtension(Y)})}}},yy=["default","low-power","high-performance"];function by(N,D){var U=D>>2,Y=u()[U+6],pe={alpha:!!u()[U+0],depth:!!u()[U+1],stencil:!!u()[U+2],antialias:!!u()[U+3],premultipliedAlpha:!!u()[U+4],preserveDrawingBuffer:!!u()[U+5],powerPreference:yy[Y],failIfMajorPerformanceCaveat:!!u()[U+7],majorVersion:u()[U+8],minorVersion:u()[U+9],enableExtensionsByDefault:u()[U+10],explicitSwapControl:u()[U+11],proxyContextToMainThread:u()[U+12],renderViaOffscreenBackBuffer:u()[U+13]},he=Np(N);if(!he||pe.explicitSwapControl)return 0;var ve=Ct.createContext(he,pe);return ve}function xy(N,D){return by(N,D)}var tl={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var U=tl.buffers[N];D===0||D===10?((N===1?re:Z)(ia(U,0)),U.length=0):U.push(D)},varargs:void 0,get:function(){tl.varargs+=4;var N=u()[tl.varargs-4>>2];return N},getStr:function(N){var D=oa(N);return D},get64:function(N,D){return N}};function Zd(N){return C?zs(3,1,N):0}function Qd(N,D,U,Y,pe){if(C)return zs(4,1,N,D,U,Y,pe)}function eh(N,D,U,Y){if(C)return zs(5,1,N,D,U,Y);for(var pe=0,he=0;he>2],Ce=u()[D+4>>2];D+=8;for(var _t=0;_t>2]=pe,0}function vy(N){$e(N)}_e.init();var th,wy=[null,qd,Jd,Zd,Qd,eh],T1=!1,nh={__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:Jg,abort:Zg,emscripten_check_blocking_allowed:Qg,emscripten_get_heap_max:Xd,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:jd,fd_close:Zd,fd_seek:Qd,fd_write:eh,memory:Te||c.wasmMemory,setTempRet0:vy},C1=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)},Cy=c._dispose_data=function(){return(Cy=c._dispose_data=c.asm.dispose_data).apply(null,arguments)},_y=c._dispose=function(){return(_y=c._dispose=c.asm.dispose).apply(null,arguments)},Ey=c._Abs=function(){return(Ey=c._Abs=c.asm.Abs).apply(null,arguments)},Ay=c._Add=function(){return(Ay=c._Add=c.asm.Add).apply(null,arguments)},$y=c._AddN=function(){return($y=c._AddN=c.asm.AddN).apply(null,arguments)},Fy=c._All=function(){return(Fy=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)},Wy=c._Conv2DBackpropInput=function(){return(Wy=c._Conv2DBackpropInput=c.asm.Conv2DBackpropInput).apply(null,arguments)},By=c._Cos=function(){return(By=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)},Jy=c._FlipLeftRight=function(){return(Jy=c._FlipLeftRight=c.asm.FlipLeftRight).apply(null,arguments)},ah=c._Floor=function(){return(ah=c._Floor=c.asm.Floor).apply(null,arguments)},rh=c._FloorDiv=function(){return(rh=c._FloorDiv=c.asm.FloorDiv).apply(null,arguments)},Tp=c._FusedBatchNorm=function(){return(Tp=c._FusedBatchNorm=c.asm.FusedBatchNorm).apply(null,arguments)},Zy=c._FusedConv2D=function(){return(Zy=c._FusedConv2D=c.asm.FusedConv2D).apply(null,arguments)},Qy=c._FusedDepthwiseConv2D=function(){return(Qy=c._FusedDepthwiseConv2D=c.asm.FusedDepthwiseConv2D).apply(null,arguments)},nl=c._Gather=function(){return(nl=c._Gather=c.asm.Gather).apply(null,arguments)},Cp=c._GatherNd=function(){return(Cp=c._GatherNd=c.asm.GatherNd).apply(null,arguments)},_p=c._Greater=function(){return(_p=c._Greater=c.asm.Greater).apply(null,arguments)},_1=c._GreaterEqual=function(){return(_1=c._GreaterEqual=c.asm.GreaterEqual).apply(null,arguments)},al=c._LeakyRelu=function(){return(al=c._LeakyRelu=c.asm.LeakyRelu).apply(null,arguments)},rl=c._Less=function(){return(rl=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)},Ze=c._Maximum=function(){return(Ze=c._Maximum=c.asm.Maximum).apply(null,arguments)},rt=c._Mean=function(){return(rt=c._Mean=c.asm.Mean).apply(null,arguments)},Ue=c._Min=function(){return(Ue=c._Min=c.asm.Min).apply(null,arguments)},Be=c._Minimum=function(){return(Be=c._Minimum=c.asm.Minimum).apply(null,arguments)},Lt=c._MirrorPad=function(){return(Lt=c._MirrorPad=c.asm.MirrorPad).apply(null,arguments)},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)},sl=c._NonMaxSuppressionV3=function(){return(sl=c._NonMaxSuppressionV3=c.asm.NonMaxSuppressionV3).apply(null,arguments)},Ws=c._NonMaxSuppressionV4=function(){return(Ws=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)},Xr=c._OneHot=function(){return(Xr=c._OneHot=c.asm.OneHot).apply(null,arguments)},sh=c._PadV2=function(){return(sh=c._PadV2=c.asm.PadV2).apply(null,arguments)},UA=c._Pow=function(){return(UA=c._Pow=c.asm.Pow).apply(null,arguments)},GA=c._Prelu=function(){return(GA=c._Prelu=c.asm.Prelu).apply(null,arguments)},HA=c._Prod=function(){return(HA=c._Prod=c.asm.Prod).apply(null,arguments)},jA=c._RealDiv=function(){return(jA=c._RealDiv=c.asm.RealDiv).apply(null,arguments)},qA=c._Relu=function(){return(qA=c._Relu=c.asm.Relu).apply(null,arguments)},KA=c._Relu6=function(){return(KA=c._Relu6=c.asm.Relu6).apply(null,arguments)},XA=c._ResizeBilinear=function(){return(XA=c._ResizeBilinear=c.asm.ResizeBilinear).apply(null,arguments)},YA=c._Reverse=function(){return(YA=c._Reverse=c.asm.Reverse).apply(null,arguments)},JA=c._RotateWithOffset=function(){return(JA=c._RotateWithOffset=c.asm.RotateWithOffset).apply(null,arguments)},ZA=c._Round=function(){return(ZA=c._Round=c.asm.Round).apply(null,arguments)},QA=c._Rsqrt=function(){return(QA=c._Rsqrt=c.asm.Rsqrt).apply(null,arguments)},e$=c._ScatterNd=function(){return(e$=c._ScatterNd=c.asm.ScatterNd).apply(null,arguments)},t$=c._SelectV2=function(){return(t$=c._SelectV2=c.asm.SelectV2).apply(null,arguments)},n$=c._Sigmoid=function(){return(n$=c._Sigmoid=c.asm.Sigmoid).apply(null,arguments)},a$=c._Sin=function(){return(a$=c._Sin=c.asm.Sin).apply(null,arguments)},r$=c._Softmax=function(){return(r$=c._Softmax=c.asm.Softmax).apply(null,arguments)},s$=c._SparseFillEmptyRows=function(){return(s$=c._SparseFillEmptyRows=c.asm.SparseFillEmptyRows).apply(null,arguments)},i$=c._SparseReshape=function(){return(i$=c._SparseReshape=c.asm.SparseReshape).apply(null,arguments)},o$=c._SparseSegmentReduction=function(){return(o$=c._SparseSegmentReduction=c.asm.SparseSegmentReduction).apply(null,arguments)},l$=c._Sqrt=function(){return(l$=c._Sqrt=c.asm.Sqrt).apply(null,arguments)},u$=c._Square=function(){return(u$=c._Square=c.asm.Square).apply(null,arguments)},p$=c._SquaredDifference=function(){return(p$=c._SquaredDifference=c.asm.SquaredDifference).apply(null,arguments)},c$=c._Step=function(){return(c$=c._Step=c.asm.Step).apply(null,arguments)},d$=c._StridedSlice=function(){return(d$=c._StridedSlice=c.asm.StridedSlice).apply(null,arguments)},h$=c._Sub=function(){return(h$=c._Sub=c.asm.Sub).apply(null,arguments)},m$=c._Sum=function(){return(m$=c._Sum=c.asm.Sum).apply(null,arguments)},f$=c._Tan=function(){return(f$=c._Tan=c.asm.Tan).apply(null,arguments)},g$=c._Tanh=function(){return(g$=c._Tanh=c.asm.Tanh).apply(null,arguments)},y$=c._Tile=function(){return(y$=c._Tile=c.asm.Tile).apply(null,arguments)},b$=c._TopK=function(){return(b$=c._TopK=c.asm.TopK).apply(null,arguments)},x$=c._Transform=function(){return(x$=c._Transform=c.asm.Transform).apply(null,arguments)},v$=c._Transpose=function(){return(v$=c._Transpose=c.asm.Transpose).apply(null,arguments)},w$=c.__FusedMatMul=function(){return(w$=c.__FusedMatMul=c.asm._FusedMatMul).apply(null,arguments)},nb=c._malloc=function(){return(nb=c._malloc=c.asm.malloc).apply(null,arguments)},E1=c._free=function(){return(E1=c._free=c.asm.free).apply(null,arguments)},k$=c._emscripten_tls_init=function(){return(k$=c._emscripten_tls_init=c.asm.emscripten_tls_init).apply(null,arguments)},A1=c.___errno_location=function(){return(A1=c.___errno_location=c.asm.__errno_location).apply(null,arguments)},ih=c._pthread_self=function(){return(ih=c._pthread_self=c.asm.pthread_self).apply(null,arguments)},$1=c._emscripten_main_thread_process_queued_calls=function(){return($1=c._emscripten_main_thread_process_queued_calls=c.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},I$=c.__emscripten_thread_crashed=function(){return(I$=c.__emscripten_thread_crashed=c.asm._emscripten_thread_crashed).apply(null,arguments)},F1=c.__emscripten_thread_init=function(){return(F1=c.__emscripten_thread_init=c.asm._emscripten_thread_init).apply(null,arguments)},S$=c._emscripten_current_thread_process_queued_calls=function(){return(S$=c._emscripten_current_thread_process_queued_calls=c.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},N$=c._emscripten_main_browser_thread_id=function(){return(N$=c._emscripten_main_browser_thread_id=c.asm.emscripten_main_browser_thread_id).apply(null,arguments)},T$=c._emscripten_sync_run_in_main_thread_2=function(){return(T$=c._emscripten_sync_run_in_main_thread_2=c.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},D1=c._emscripten_sync_run_in_main_thread_4=function(){return(D1=c._emscripten_sync_run_in_main_thread_4=c.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},R1=c._emscripten_run_in_main_runtime_thread_js=function(){return(R1=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)},C$=c.__emscripten_thread_exit=function(){return(C$=c.__emscripten_thread_exit=c.asm._emscripten_thread_exit).apply(null,arguments)},_$=c._memalign=function(){return(_$=c._memalign=c.asm.memalign).apply(null,arguments)},M1=c._emscripten_stack_set_limits=function(){return(M1=c._emscripten_stack_set_limits=c.asm.emscripten_stack_set_limits).apply(null,arguments)},sb=c.stackSave=function(){return(sb=c.stackSave=c.asm.stackSave).apply(null,arguments)},oh=c.stackRestore=function(){return(oh=c.stackRestore=c.asm.stackRestore).apply(null,arguments)},il=c.stackAlloc=function(){return(il=c.stackAlloc=c.asm.stackAlloc).apply(null,arguments)},E$=c.dynCall_iijjiiii=function(){return(E$=c.dynCall_iijjiiii=c.asm.dynCall_iijjiiii).apply(null,arguments)},A$=c.dynCall_jiji=function(){return(A$=c.dynCall_jiji=c.asm.dynCall_jiji).apply(null,arguments)},P1=c.__emscripten_allow_main_runtime_queued_calls=21464;c.cwrap=Jt,c.keepRuntimeAlive=Ps,c.PThread=_e,c.PThread=_e,c.wasmMemory=Te,c.ExitStatus=Ep;var lh;function Ep(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Ma=function N(){lh||ib(),lh||(Ma=N)};function ib(N){if(N=N||y,Kr>0)return;if(C){h(c),vp(),postMessage({cmd:"loaded"});return}if(vn(),Kr>0)return;function D(){lh||(lh=!0,c.calledRun=!0,!ct&&(vp(),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 $$(N,D){if(bn=N,!D&&C)throw qd(N),"unwind";Ps()||Fg(),F$(N)}function F$(N){bn=N,Ps()||(_e.terminateAllThreads(),c.onExit&&c.onExit(N),ct=!0),x(N,new Ep(N))}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();ib();var uh;f&&(uh={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 ph;if(typeof WasmBackendModule!="undefined")ph=WasmBackendModule;else if(typeof r!="undefined")ph=r;else throw new Error("Could not find wasm module in post.js");if(uh){var D$=ph._dispose;ph._dispose=function(){D$(),uh.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),uh.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)}),mF=ft((e,t)=>{var n=(()=>{var a=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(a=a||__filename),function(r){r=r||{};var s=typeof r!="undefined"?r:{},i,o;s.ready=new Promise(function(G,te){i=G,o=te});var l;typeof process!="undefined"&&process.listeners&&(l={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var u=Object.assign({},s),p=[],d="./this.program",c=(G,te)=>{throw te},h=typeof window=="object",m=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function y(G){return s.locateFile?s.locateFile(G,g):g+G}var b,x,v,w;function T(G){G instanceof Cp||F("exiting due to exception: "+G)}var C,E,$;f?(m?g=Mh().dirname(g)+"/":g=__dirname+"/",$=()=>{E||(C=Ix(),E=Mh())},b=function(G,te){return $(),G=E.normalize(G),C.readFileSync(G,te?void 0:"utf8")},v=G=>{var te=b(G,!0);return te.buffer||(te=new Uint8Array(te)),te},x=(G,te,de)=>{$(),G=E.normalize(G),C.readFile(G,function(Se,Ze){Se?de(Se):te(Ze.buffer)})},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),p=process.argv.slice(2),process.on("uncaughtException",function(G){if(!(G instanceof Cp))throw G}),process.on("unhandledRejection",function(G){throw G}),c=(G,te)=>{if(xp())throw process.exitCode=G,te;T(te),process.exit(G)},s.inspect=function(){return"[Emscripten Module object]"}):(h||m)&&(m?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),a&&(g=a),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",b=G=>{var te=new XMLHttpRequest;return te.open("GET",G,!1),te.send(null),te.responseText},m&&(v=G=>{var te=new XMLHttpRequest;return te.open("GET",G,!1),te.responseType="arraybuffer",te.send(null),new Uint8Array(te.response)}),x=(G,te,de)=>{var Se=new XMLHttpRequest;Se.open("GET",G,!0),Se.responseType="arraybuffer",Se.onload=()=>{if(Se.status==200||Se.status==0&&Se.response){te(Se.response);return}de()},Se.onerror=de,Se.send(null)},w=G=>document.title=G);var P=s.print||console.log.bind(console),F=s.printErr||console.warn.bind(console);Object.assign(s,u),u=null,s.arguments&&(p=s.arguments),s.thisProgram&&(d=s.thisProgram),s.quit&&(c=s.quit);var S=4;function M(G){M.shown||(M.shown={}),M.shown[G]||(M.shown[G]=1,F(G))}function B(G,te){if(typeof WebAssembly.Function=="function"){for(var de={i:"i32",j:"i64",f:"f32",d:"f64"},Se={parameters:[],results:te[0]=="v"?[]:[de[te[0]]]},Ze=1;Ze{ee=G},Z;s.wasmBinary&&(Z=s.wasmBinary);var ie=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Ms("no native wasm support detected");var ae,le=!1,ue;function we(G,te){G||Ms(te)}function ye(G){var te=s["_"+G];return te}function Ie(G,te,de,Se,Ze){var rt={string:function(Mn){var Xr=0;if(Mn!=null&&Mn!==0){var sh=(Mn.length<<2)+1;Xr=Tp(sh),at(Mn,Xr,sh)}return Xr},array:function(Mn){var Xr=Tp(Mn.length);return ct(Mn,Xr),Xr}};function Ue(Mn){return te==="string"?st(Mn):te==="boolean"?Boolean(Mn):Mn}var Be=ye(G),Lt=[],Pa=0;if(Se)for(var Oa=0;Oa=Se);)++Ze;if(Ze-te>16&&G.subarray&&We)return We.decode(G.subarray(te,Ze));for(var rt="";te>10,56320|Pa&1023)}}return rt}function st(G,te){return G?je(Jt,G,te):""}function nt(G,te,de,Se){if(!(Se>0))return 0;for(var Ze=de,rt=de+Se-1,Ue=0;Ue=55296&&Be<=57343){var Lt=G.charCodeAt(++Ue);Be=65536+((Be&1023)<<10)|Lt&1023}if(Be<=127){if(de>=rt)break;te[de++]=Be}else if(Be<=2047){if(de+1>=rt)break;te[de++]=192|Be>>6,te[de++]=128|Be&63}else if(Be<=65535){if(de+2>=rt)break;te[de++]=224|Be>>12,te[de++]=128|Be>>6&63,te[de++]=128|Be&63}else{if(de+3>=rt)break;te[de++]=240|Be>>18,te[de++]=128|Be>>12&63,te[de++]=128|Be>>6&63,te[de++]=128|Be&63}}return te[de]=0,de-Ze}function at(G,te,de){return nt(G,Jt,te,de)}function Te(G){for(var te=0,de=0;de=55296&&Se<=57343&&(Se=65536+((Se&1023)<<10)|G.charCodeAt(++de)&1023),Se<=127?++te:Se<=2047?te+=2:Se<=65535?te+=3:te+=4}return te}var gt=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function ct(G,te){Ut.set(G,te)}function bn(G,te,de){for(var Se=0;Se>0]=G.charCodeAt(Se);de||(Ut[te>>0]=0)}function Yt(G,te){return G%te>0&&(G+=te-G%te),G}var Dn,Ut,Jt,Da,Rn,Gt,ia,oa,Hr;function Rs(G){Dn=G,s.HEAP8=Ut=new Int8Array(G),s.HEAP16=Da=new Int16Array(G),s.HEAP32=Gt=new Int32Array(G),s.HEAPU8=Jt=new Uint8Array(G),s.HEAPU16=Rn=new Uint16Array(G),s.HEAPU32=ia=new Uint32Array(G),s.HEAPF32=oa=new Float32Array(G),s.HEAPF64=Hr=new Float64Array(G)}var $d=s.INITIAL_MEMORY||16777216,jr,kr=[],bp=[],Xo=[],xn=!1,Fd=!1,Dd=0;function xp(){return ie||Dd>0}function Rd(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)Od(s.preRun.shift());wp(kr)}function Md(){xn=!0,wp(bp)}function y1(){Fd=!0}function Pd(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Ld(s.postRun.shift());wp(Xo)}function Od(G){kr.unshift(G)}function Ra(G){bp.unshift(G)}function Ld(G){Xo.unshift(G)}var la=0,Yo=null,qr=null;function Ag(G){la++,s.monitorRunDependencies&&s.monitorRunDependencies(la)}function zd(G){if(la--,s.monitorRunDependencies&&s.monitorRunDependencies(la),la==0&&(Yo!==null&&(clearInterval(Yo),Yo=null),qr)){var te=qr;qr=null,te()}}s.preloadedImages={},s.preloadedAudios={};function Ms(G){s.onAbort&&s.onAbort(G),G="Aborted("+G+")",F(G),le=!0,ue=1,G+=". Build with -s ASSERTIONS=1 for more info.";var te=new WebAssembly.RuntimeError(G);throw o(te),te}var $g="data:application/octet-stream;base64,";function Wd(G){return G.startsWith($g)}function Ps(G){return G.startsWith("file://")}var vn;vn="tfjs-backend-wasm.wasm",Wd(vn)||(vn=y(vn));function vp(G){try{if(G==vn&&Z)return new Uint8Array(Z);if(v)return v(G);throw"both async and sync fetching of the wasm failed"}catch(te){Ms(te)}}function Fg(){if(!Z&&(h||m)){if(typeof fetch=="function"&&!Ps(vn))return fetch(vn,{credentials:"same-origin"}).then(function(G){if(!G.ok)throw"failed to load wasm binary file at '"+vn+"'";return G.arrayBuffer()}).catch(function(){return vp(vn)});if(x)return new Promise(function(G,te){x(vn,function(de){G(new Uint8Array(de))},te)})}return Promise.resolve().then(function(){return vp(vn)})}function Dg(){var G={env:Qo,wasi_snapshot_preview1:Qo};function te(Ue,Be){var Lt=Ue.exports;s.asm=Lt,ae=s.asm.memory,Rs(ae.buffer),jr=s.asm.__indirect_function_table,Ra(s.asm.__wasm_call_ctors),zd("wasm-instantiate")}Ag("wasm-instantiate");function de(Ue){te(Ue.instance)}function Se(Ue){return Fg().then(function(Be){return WebAssembly.instantiate(Be,G)}).then(function(Be){return Be}).then(Ue,function(Be){F("failed to asynchronously prepare wasm: "+Be),Ms(Be)})}function Ze(){return!Z&&typeof WebAssembly.instantiateStreaming=="function"&&!Wd(vn)&&!Ps(vn)&&typeof fetch=="function"?fetch(vn,{credentials:"same-origin"}).then(function(Ue){var Be=WebAssembly.instantiateStreaming(Ue,G);return Be.then(de,function(Lt){return F("wasm streaming compile failed: "+Lt),F("falling back to ArrayBuffer instantiation"),Se(de)})}):Se(de)}if(s.instantiateWasm)try{var rt=s.instantiateWasm(G,te);return rt}catch(Ue){return F("Module.instantiateWasm callback failed with error: "+Ue),!1}return Ze().catch(o),{}}var b1,x1;function wp(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?kp(de)():kp(de)(te.arg):de(te.arg===void 0?null:te.arg)}}function Kr(G){return G}function Bd(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 kp(G){var te=Ma[G];return te||(G>=Ma.length&&(Ma.length=G+1),Ma[G]=te=jr.get(G)),te}function v1(){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 Jo(G,te){jr.set(G,te),Ma[G]=te}function Rg(){Ms("")}function Ip(){return 2147483648}function Vd(G,te,de){Jt.copyWithin(G,te,te+de)}function wn(G){try{return ae.grow(G-Dn.byteLength+65535>>>16),Rs(ae.buffer),1}catch(te){}}function Ud(G){var te=Jt.length;G=G>>>0;var de=Ip();if(G>de)return!1;for(var Se=1;Se<=4;Se*=2){var Ze=te*(1+.2/Se);Ze=Math.min(Ze,G+100663296);var rt=Math.min(de,Yt(Math.max(G,Ze),65536)),Ue=wn(rt);if(Ue)return!0}return!1}var Zo={mappings:{},buffers:[null,[],[]],printChar:function(G,te){var de=Zo.buffers[G];te===0||te===10?((G===1?P:F)(je(de,0)),de.length=0):de.push(te)},varargs:void 0,get:function(){Zo.varargs+=4;var G=Gt[Zo.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 w1(G,te,de,Se,Ze){}function k1(G,te,de,Se){for(var Ze=0,rt=0;rt>2],Be=Gt[te+4>>2];te+=8;for(var Lt=0;Lt>2]=Ze,0}function Pg(G){re(G)}var Gd=!1,Qo={abort:Rg,emscripten_get_heap_max:Ip,emscripten_memcpy_big:Vd,emscripten_resize_heap:Ud,fd_close:Mg,fd_seek:w1,fd_write:k1,setTempRet0:Pg},VA=Dg(),I1=s.___wasm_call_ctors=function(){return(I1=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)},Hd=s._get_threads_count=function(){return(Hd=s._get_threads_count=s.asm.get_threads_count).apply(null,arguments)},jd=s._register_tensor=function(){return(jd=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)},_e=s._dispose=function(){return(_e=s._dispose=s.asm.dispose).apply(null,arguments)},Wg=s._Abs=function(){return(Wg=s._Abs=s.asm.Abs).apply(null,arguments)},qd=s._Add=function(){return(qd=s._Add=s.asm.Add).apply(null,arguments)},Os=s._AddN=function(){return(Os=s._AddN=s.asm.AddN).apply(null,arguments)},el=s._All=function(){return(el=s._All=s.asm.All).apply(null,arguments)},Bg=s._Any=function(){return(Bg=s._Any=s.asm.Any).apply(null,arguments)},S1=s._ArgMax=function(){return(S1=s._ArgMax=s.asm.ArgMax).apply(null,arguments)},Vg=s._AvgPool=function(){return(Vg=s._AvgPool=s.asm.AvgPool).apply(null,arguments)},N1=s._BatchMatMul=function(){return(N1=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)},Kd=s._Cumprod=function(){return(Kd=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)},Jg=s._DepthwiseConv2dNative=function(){return(Jg=s._DepthwiseConv2dNative=s.asm.DepthwiseConv2dNative).apply(null,arguments)},Zg=s._Elu=function(){return(Zg=s._Elu=s.asm.Elu).apply(null,arguments)},Qg=s._Equal=function(){return(Qg=s._Equal=s.asm.Equal).apply(null,arguments)},Xd=s._Exp=function(){return(Xd=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)},Sp=s._FusedBatchNorm=function(){return(Sp=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)},Ve=s._GatherNd=function(){return(Ve=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)},Np=s._LogicalAnd=function(){return(Np=s._LogicalAnd=s.asm.LogicalAnd).apply(null,arguments)},Yd=s._Max=function(){return(Yd=s._Max=s.asm.Max).apply(null,arguments)},Jd=s._MaxPool=function(){return(Jd=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)},Ct=s._Neg=function(){return(Ct=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)},tl=s._NotEqual=function(){return(tl=s._NotEqual=s.asm.NotEqual).apply(null,arguments)},Zd=s._OneHot=function(){return(Zd=s._OneHot=s.asm.OneHot).apply(null,arguments)},Qd=s._PadV2=function(){return(Qd=s._PadV2=s.asm.PadV2).apply(null,arguments)},eh=s._Pow=function(){return(eh=s._Pow=s.asm.Pow).apply(null,arguments)},vy=s._Prelu=function(){return(vy=s._Prelu=s.asm.Prelu).apply(null,arguments)},th=s._Prod=function(){return(th=s._Prod=s.asm.Prod).apply(null,arguments)},wy=s._RealDiv=function(){return(wy=s._RealDiv=s.asm.RealDiv).apply(null,arguments)},T1=s._Relu=function(){return(T1=s._Relu=s.asm.Relu).apply(null,arguments)},nh=s._Relu6=function(){return(nh=s._Relu6=s.asm.Relu6).apply(null,arguments)},C1=s._ResizeBilinear=function(){return(C1=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)},Cy=s._SelectV2=function(){return(Cy=s._SelectV2=s.asm.SelectV2).apply(null,arguments)},_y=s._Sigmoid=function(){return(_y=s._Sigmoid=s.asm.Sigmoid).apply(null,arguments)},Ey=s._Sin=function(){return(Ey=s._Sin=s.asm.Sin).apply(null,arguments)},Ay=s._Softmax=function(){return(Ay=s._Softmax=s.asm.Softmax).apply(null,arguments)},$y=s._SparseFillEmptyRows=function(){return($y=s._SparseFillEmptyRows=s.asm.SparseFillEmptyRows).apply(null,arguments)},Fy=s._SparseReshape=function(){return(Fy=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)},Wy=s._Sum=function(){return(Wy=s._Sum=s.asm.Sum).apply(null,arguments)},By=s._Tan=function(){return(By=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)},Jy=s._emscripten_main_thread_process_queued_calls=function(){return(Jy=s._emscripten_main_thread_process_queued_calls=s.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},ah=s.stackSave=function(){return(ah=s.stackSave=s.asm.stackSave).apply(null,arguments)},rh=s.stackRestore=function(){return(rh=s.stackRestore=s.asm.stackRestore).apply(null,arguments)},Tp=s.stackAlloc=function(){return(Tp=s.stackAlloc=s.asm.stackAlloc).apply(null,arguments)},Zy=s.dynCall_iijjiiii=function(){return(Zy=s.dynCall_iijjiiii=s.asm.dynCall_iijjiiii).apply(null,arguments)},Qy=s.dynCall_jiji=function(){return(Qy=s.dynCall_jiji=s.asm.dynCall_jiji).apply(null,arguments)};s.cwrap=Ee;var nl;function Cp(G){this.name="ExitStatus",this.message="Program terminated with exit("+G+")",this.status=G}qr=function G(){nl||_p(),nl||(qr=G)};function _p(G){if(G=G||p,la>0||(Rd(),la>0))return;function te(){nl||(nl=!0,s.calledRun=!0,!le&&(Md(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),Pd()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),te()},1)):te()}s.run=_p;function _1(G){ue=G,xp()||(s.onExit&&s.onExit(G),le=!0),c(G,new Cp(G))}if(s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();_p();var al;l&&(al={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 rl;if(typeof r!="undefined")rl=r;else if(typeof WasmBackendModuleThreadedSimd!="undefined")rl=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(al){var eb=rl._dispose;rl._dispose=function(){eb(),al.uncaughtException.forEach(function(G){process.removeListener("uncaughtException",G)}),al.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)}),pm=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}},cc=class{refCount(e){return pa("refCount")}incRef(e){return pa("incRef")}timerAvailable(){return!0}time(e){return pa("time")}read(e){return pa("read")}readSync(e){return pa("readSync")}readToGPU(e,t){return pa("readToGPU")}numDataIds(){return pa("numDataIds")}disposeData(e,t){return pa("disposeData")}write(e,t,n){return pa("write")}move(e,t,n,a,r){return pa("move")}memory(){return pa("memory")}floatPrecision(){return pa("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return pa("dispose")}};function pa(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 yI(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,Ph(e,t,n)}function fF(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--,Ph(e,n,a),Ph(t,n,a)}function Xp(e,t,n){return Math.max(e,Math.min(t,n))}function gF(e){return e%2===0?e:e+1}function Ph(e,t,n){let a=e[t];e[t]=e[n],e[n]=a}function yF(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 NF(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 Ea(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=>xl(a)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(a=>a<0?n+a:a)}function bI(e,t){let n=[],a=[],r=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||r?null:Ea(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 xI(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 vI(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 wI(e,t){for(let n=0;nt+=n.length),t}function Qr(e){return typeof e=="string"||e instanceof String}function SI(e){return typeof e=="boolean"}function NI(e){return typeof e=="number"}function cm(e){return Array.isArray(e)?cm(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":NI(e)?"float32":Qr(e)?"string":SI(e)?"bool":"float32"}function ss(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Oh(e,t){for(let n=t;n=0;--a)n[a]=n[a+1]*e[a+1];return n}function TI(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 TI(0,e,t,n)}function Sx(e,t){let n=dm(e,t);for(let a=0;aa*r,1);if(t==null||t==="float32")return ml(e,new Float32Array(n));if(t==="int32")return ml(e,new Int32Array(n));if(t==="bool")return ml(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function Nx(e){e.forEach(t=>{R(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function _F(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]=FF(n,a)})}};function AF(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...a)=>($F(t,a[0],a[1]),a.join("="))),t}function $F(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function FF(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 Cx}var Cx=null;function DF(e){Cx=e}var lb;function _I(){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 RF(){let e=_I();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function _x(e,t){let n=RF();if(n.has(e))return n.get(e);{let a=t();return n.set(e,a),n.get(e)}}var Dl="Abs",Rl="Acos",Ml="Acosh",ys="Add",vi="AddN",Pl="All",Ol="Any",wi="ArgMax",dc="ArgMin",Ll="Asin",zl="Asinh",Wl="Atan",Bl="Atanh",Vl="Atan2",ki="AvgPool",hm="AvgPoolGrad",hc="AvgPool3D",mm="AvgPool3DGrad",Ii="BatchMatMul",Ul="BatchToSpaceND",fm="Bincount",EI="BroadcastTo",gm="BroadcastArgs",Si="Cast",Ni="Ceil",bs="ClipByValue",ym="Complex",mc="ComplexAbs",Gl="Concat",Ti="Conv2D",bm="Conv2DBackpropFilter",Ci="Conv2DBackpropInput",fc="Conv3D",xm="Conv3DBackpropFilterV2",vm="Conv3DBackpropInputV2",_i="Cos",Ei="Cosh",Hl="Cumprod",Ai="Cumsum",jl="CropAndResize",wm="DenseBincount",ql="DepthToSpace",$i="DepthwiseConv2dNative",km="DepthwiseConv2dNativeBackpropFilter",Im="DepthwiseConv2dNativeBackpropInput",Sm="Diag",gc="Dilation2D",Lh="Dilation2DBackpropInput",zh="Dilation2DBackpropFilter",Fi="RealDiv",Nm="Einsum",Di="Elu",Tm="EluGrad",Kl="Erf",Xl="Equal",Ri="Exp",Yl="ExpandDims",Jl="Expm1",Cm="FFT",yc="Fill",Zl="FlipLeftRight",Mi="Floor",Pi="FloorDiv",Oi="FusedBatchNorm",Ql="GatherV2",eu="GatherNd",tu="Greater",Li="GreaterEqual",zi="Identity",_m="IFFT",Em="Imag",nu="IsFinite",au="IsInf",ru="IsNan",Wi="LeakyRelu",su="Less",iu="LessEqual",Am="LinSpace",Bi="Log",ou="Log1p",lu="LogicalAnd",bc="LogicalNot",xc="LogicalOr",AI="LogSoftmax",vc="LRN",$m="LRNGrad",Vi="Max",Ui="Maximum",Gi="MaxPool",Fm="MaxPoolGrad",wc="MaxPool3D",Dm="MaxPool3DGrad",Rm="MaxPoolWithArgmax",Hi="Mean",ji="Min",qi="Minimum",Ki="MirrorPad",uu="Mod",Mm="Multinomial",Xi="Multiply",pu="Neg",cu="NotEqual",du="NonMaxSuppressionV3",hu="NonMaxSuppressionV4",mu="NonMaxSuppressionV5",fu="OnesLike",Yi="OneHot",gu="Pack",Ji="PadV2",MF="Pool",Zi="Pow",Qi="Prelu",yu="Prod",kc="Range",Pm="Real",bu="Reciprocal",eo="Relu",xu="Reshape",Ic="ResizeNearestNeighbor",Om="ResizeNearestNeighborGrad",to="ResizeBilinear",Lm="ResizeBilinearGrad",no="Relu6",ao="Reverse",ro="Round",so="Rsqrt",vu="ScatterNd",wu="Select",ku="Selu",Iu="Slice",io="Sin",Su="Sinh",Nu="Sign",oo="Sigmoid",Tu="Softplus",lo="Sqrt",uo="Sum",Cu="SpaceToBatchND",_u="SplitV",po="Softmax",Sc="SparseFillEmptyRows",Eu="SparseReshape",Nc="SparseSegmentMean",Tc="SparseSegmentSum",zm="SparseToDense",co="SquaredDifference",Cc="Square",Au="StridedSlice",Wm="StringNGrams",Bm="StringSplit",Vm="StringToHashBucketFast",ho="Sub",mo="Tan",fo="Tanh",xs="Tile",$u="TopK",Fu="Transform",go="Transpose",Um="Unique",Du="Unpack",_c="UnsortedSegmentSum",Ru="ZerosLike",vs="Step",Wh="FromPixels",Mu="RotateWithOffset",ni="_FusedMatMul",ai="FusedConv2D",ri="FusedDepthwiseConv2D";function Zr(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.warn(...e)}function PF(...e){X().getBool("IS_TEST")||X().getBool("PROD")||console.log(...e)}var vl=_x("kernelRegistry",()=>new Map),Yp=_x("gradRegistry",()=>new Map);function Bh(e,t){let n=Ex(e,t);return vl.get(n)}function Sb(e){return Yp.get(e)}function Vh(e){let t=vl.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 Ec(e){let{kernelName:t,backendName:n}=e,a=Ex(t,n);vl.has(a)&&Zr(`The kernel '${t}' for backend '${n}' is already registered`),vl.set(a,e)}function $I(e){let{kernelName:t}=e;Yp.has(t)&&X().getBool("DEBUG")&&Zr(`Overriding the gradient for '${t}'`),Yp.set(t,e)}function OF(e,t){let n=Ex(e,t);if(!vl.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);vl.delete(n)}function LF(e){if(!Yp.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Yp.delete(e)}function zF(e,t){Vh(e).forEach(n=>{let a=Object.assign({},n,{backendName:t});Ec(a)})}function Ex(e,t){return`${t}_${e}`}var k={};Re(k,{arraysEqual:()=>gs,assert:()=>R,assertNonNegativeIntegerDimensions:()=>Nx,assertNonNull:()=>xi,assertShapesMatch:()=>Tn,bytesFromStringArray:()=>II,bytesPerElement:()=>Ib,checkConversionForErrors:()=>wI,clamp:()=>Xp,computeStrides:()=>Fl,createScalarValue:()=>HF,createShuffledIndices:()=>IF,decodeString:()=>Uh,distSquared:()=>xF,encodeString:()=>$c,fetch:()=>qF,fingerPrint64:()=>GF,flatten:()=>ti,getArrayFromDType:()=>vI,getTypedArrayFromDType:()=>xI,hasEncodingLoss:()=>TF,hexToLong:()=>Ac,indexToLoc:()=>EF,inferDtype:()=>cm,inferFromImplicitShape:()=>NF,isBoolean:()=>SI,isFunction:()=>ss,isInt:()=>xl,isNumber:()=>NI,isPromise:()=>Tx,isScalarShape:()=>vF,isString:()=>Qr,isTypedArray:()=>hn,isValidDtype:()=>kI,locToIndex:()=>_F,makeOnesTypedArray:()=>Sx,makeZerosNestedTypedArray:()=>CF,makeZerosTypedArray:()=>dm,nearestDivisor:()=>Oh,nearestLargerEven:()=>gF,now:()=>Jp,parseAxisParam:()=>Ea,randUniform:()=>bF,repeatedTry:()=>SF,rightPad:()=>Hp,shuffle:()=>yI,shuffleCombo:()=>fF,sizeFromShape:()=>wt,sizeToSquarishShape:()=>kF,squeezeShape:()=>bI,sum:()=>yF,swap:()=>Ph,tanh:()=>wF,toNestedArray:()=>ml,toTypedArray:()=>Gm});var z1=bi(q$()),Hs=z1.default||z1;function Ac(e){return Hs.fromString(e,!0,16)}var FI=Ac("c3a5c85c97cb3127"),Us=Ac("b492b66fbe98f273"),kn=Ac("9ae16a3b2f90404f");function Nb(e){return e.xor(e.shru(47))}function DI(e,t,n){let a=e.slice(t,t+n);return Hs.fromBytes(Array.from(a),!0,!0)}function yt(e,t){return DI(e,t,8)}function W1(e,t){return DI(e,t,4)}function Zt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function ns(e,t,n=Ac("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 WF(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 hh(e,t,n,a){return WF(yt(e,t),yt(e,t+8),yt(e,t+16),yt(e,t+24),n,a)}function BF(e,t=e.length){if(t>=8){let n=kn.add(t*2),a=yt(e,0).add(kn),r=yt(e,t-8),s=Zt(r,37).mul(n).add(a),i=Zt(a,25).add(r).mul(n);return ns(s,i,n)}if(t>=4){let n=kn.add(t*2),a=W1(e,0);return ns(a.shl(3).add(t),W1(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 Nb(kn.mul(s).xor(FI.mul(i))).mul(kn)}return kn}function VF(e,t=e.length){let n=kn.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(kn);return ns(Zt(a.add(r),43).add(Zt(s,30)).add(i),a.add(Zt(r.add(kn),18)).add(s),n)}function UF(e,t=e.length){let n=kn.add(t*2),a=yt(e,0).mul(kn),r=yt(e,8),s=yt(e,t-8).mul(n),i=yt(e,t-16).mul(kn),o=Zt(a.add(r),43).add(Zt(s,30)).add(i),l=ns(o,a.add(Zt(r.add(kn),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 ns(Zt(u.add(p),43).add(Zt(d,30)).add(c),u.add(Zt(p.add(a),18)).add(d),n)}function GF(e,t=e.length){let n=Hs.fromNumber(81,!0);if(t<=32)return t<=16?BF(e,t):VF(e,t);if(t<=64)return UF(e,t);let a=n,r=n.mul(Us).add(113),s=Nb(r.mul(kn).add(113)).mul(kn),i=[Hs.UZERO,Hs.UZERO],o=[Hs.UZERO,Hs.UZERO];a=a.mul(kn).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=hh(e,l,i[1].mul(Us),a.add(o[0])),o=hh(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=hh(e,l,i[1].mul(d),a.add(o[0])),o=hh(e,l+32,s.add(o[1]),r.add(yt(e,l+16))),[s,a]=[a,s],ns(ns(i[0],o[0],d).add(Nb(r).mul(FI)).add(s),ns(i[1],o[1],d).add(a),d)}function HF(e,t){return t==="string"?$c(e):Gm([e],t)}function jF(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Gm(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")&&wI(e,t),jF(e,t))return e;if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool"){let n=new Uint8Array(e.length);for(let a=0;a{a=n()},s,i=Jp();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(r);else{r();for(let o of a)o.dataSync();s=Promise.resolve({kernelMs:Jp()-i})}if(X().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o{XF(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 XF(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 JF(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(!gs(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 B1=20,$p=3,ub=7;function QF(e,t,n,a){let r=Fl(t),s=eD(e,t,n,r),i=t.length,o=Sh(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 eD(e,t,n,a){let r=wt(t),s=a[a.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?Pp(e):e;if(o>1)for(let u=0;uB1){let g=$p*i,y=Array.from(e.slice(0,g)),b=Array.from(e.slice((o-$p)*i,o*i));return n==="complex64"&&(y=Pp(y),b=Pp(b)),["["+y.map((x,v)=>Mp(x,r[v],n)).join(", ")+", ..., "+b.map((x,v)=>Mp(x,r[o-$p+v],n)).join(", ")+"]"]}let f=n==="complex64"?Pp(e):Array.from(e);return["["+f.map((g,y)=>Mp(g,r[y],n)).join(", ")+"]"]}let u=t.slice(1),p=a.slice(1),d=a[0]*i,c=[];if(o>B1){for(let f=0;f<$p;f++){let g=f*d,y=g+d;c.push(...Sh(e.slice(g,y),u,n,p,r,!1))}c.push("...");for(let f=o-$p;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||vI(t,this.size),this.strides=Fl(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;aUh(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(),Wa().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=Wa().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Uh(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 Wa().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Wa().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return cl.print(this,e)}clone(){return this.throwIfDisposed(),cl.clone(this)}toString(e=!1){let t=this.dataSync();return QF(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),cl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Wa().makeVariable(this,e,t,n)}};Object.defineProperty(Ae,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ne(){return _x("Tensor",()=>Ae)}ne();var is=class extends Ae{constructor(e,t,n,a){super(e.shape,e.dtype,e.dataId,a),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!gs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Wa().disposeTensor(this),this.dataId=e.dataId,Wa().incRef(this,null)}dispose(){Wa().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(is,Symbol.hasInstance,{value:e=>e instanceof Ae&&e.assign!=null&&e.assign instanceof Function});var Ga={};Re(Ga,{assertTypesMatch:()=>MI,getTensorsInContainer:()=>Ax,isTensorInList:()=>iD,makeTypesMatch:()=>$t});var Tb;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Tb||(Tb={}));var Cb;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(Cb||(Cb={}));var _b;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(_b||(_b={}));var Eb;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(Eb||(Eb={}));var Ab;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(Ab||(Ab={}));var sD={float32:Eb,int32:Cb,bool:_b,complex64:Ab};function fa(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return sD[e][t]}function Hm(e){return fa(e,"int32")}function $t(e,t){if(e.dtype===t.dtype)return[e,t];let n=fa(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function MI(e,t){R(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function iD(e,t){return t.some(n=>n.id===e.id)}function Ax(e){let t=[];return PI(e,t,new Set),t}function PI(e,t,n){if(e==null)return;if(e instanceof Ae){t.push(e);return}if(!oD(e))return;let a=e;for(let r in a){let s=a[r];n.has(s)||(n.add(s),PI(s,t,n))}}function oD(e){return Array.isArray(e)||typeof e=="object"}function pb(e){return e.kernelName!=null}var V1=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()}},Zp=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new V1}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){Vh(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 cc)&&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 Zp.nextTensorId++}nextVariableId(){return Zp.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,Bh(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=Bh(h,this.backendName);R(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let y=this.backend.numDataIds();o=g.kernelFunc({inputs:m,attrs:f,backend:this.backend});let b=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,y,b);let x=b.map(v=>{if(v.rank!=null)return v;let{dataId:w,shape:T,dtype:C}=v;return this.makeTensorFromDataId(w,T,C)});if(a){let v=this.getTensorsForGradient(h,m,x);n=this.saveTensorsForBackwardMode(v)}return x}}else{let{forwardFunc:h}=e,m=f=>{!a||(n=f.map(g=>this.keep(this.clone(g))))};i=()=>{let f=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,m));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,f,g),g}}let{inputs:u,attrs:p}=e,d=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=Sb(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"&&Qr(e[0])&&(r=e.map(o=>$c(o)));let s=a.write(r,t,n),i=new Ae(t,n,s,this.nextTensorId());if(this.trackTensor(i,a),n==="string"){let o=this.state.tensorInfo.get(s),l=II(r);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,n,a){n=n||"float32";let r=new Ae(t,n,e,this.nextTensorId());return this.trackTensor(r,a),r}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),a!=null&&a!==e.dtype&&(e=e.cast(a));let r=new is(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*Ib(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 is||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*Ib(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=Sb(e);o!=null&&(a=o.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((u,p)=>{if(u==null){let d=n[p],c=dm(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=Ax(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===a.id&&this.track(r)})}gradients(e,t,n,a=!1){if(R(t.length>0,()=>"gradients() received an empty list of xs."),n!=null&&n.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);let r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));R(r instanceof Ae,()=>"The result y returned by f() must be a tensor.");let s=JF(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?lD(r.shape):n,ZF(i,s,l=>this.tidy(l),uD);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(ss(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{R(t.every(i=>i instanceof Ae),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,a={};t.forEach((i,o)=>{a[o]=i});let r=(i,o)=>(n=e(...t,o),R(n.value instanceof Ae,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),R(ss(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),s=(i,o)=>{let l=n.gradFunc(i,o),u=Array.isArray(l)?l:[l];R(u.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),R(u.every(d=>d instanceof Ae),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let p={};return u.forEach((d,c)=>{p[c]=()=>d}),p};return this.runKernelFunc({forwardFunc:r,backwardsFunc:s,inputs:a})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){let t=Jp(),n=await this.backend.time(e);return n.wallMs=Jp()-t,n}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new V1;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}};Zp.nextTensorId=0;Zp.nextVariableId=0;function lD(e){let t=Sx(wt(e),"float32");return L.makeTensor(t,e,"float32")}function OI(){let e=_I();if(e._tfengine==null){let t=new CI(e);e._tfengine=new Zp(t)}return DF(e._tfengine.ENV),nD(()=>e._tfengine),e._tfengine}var L=OI();function uD(e,t){let n={a:e,b:t};return L.runKernel(ys,n)}var Fc={};Re(Fc,{isBrowser:()=>LI,isMobile:()=>dD,mockIsMobile:()=>cD});function pD(){return typeof navigator!="undefined"&&navigator!=null}var $b;function cD(e){$b=e}function dD(e){if($b!==void 0)return $b;if(e||pD()){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 LI(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Ca=X();Ca.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.")});Ca.registerFlag("IS_BROWSER",()=>LI());Ca.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Ca.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Ca.registerFlag("PROD",()=>!1);Ca.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Ca.getBool("DEBUG"));Ca.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Ca.registerFlag("IS_TEST",()=>!1);Ca.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Ca.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Ca.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function pr(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")&&zI(e,a,[]),a}function zI(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),U1(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=pr(e,r);!hn(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Gm(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)=>A(r,`${t}[${s}]`,n,a))}var WI="__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+WI;let r=(...s)=>{L.startScope(n);try{let i=a(...s);return Tx(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 hD(e,t){let n=A(e,"real","complex"),a=A(t,"imag","complex");Tn(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(ym,r)}var os=z({complex_:hD});function ws(e,t,n,a){if(a==null&&(a=cm(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){Nx(t);let r=wt(t),s=wt(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"?Gm(e,a):ti(e,[],!0),L.makeTensor(e,t,a)}function Qn(e,t,n){let a=pr(e,n);return ws(e,t,a,n)}var Fb={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Gh=4;async function mD(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)+Gh*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 $x=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function G1(e){return $x?Buffer.byteLength(e):new Blob([e]).size}function gD(e){if($x)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 H1(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 VI(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 Dx(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 Dc(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:G1(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:G1(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function bD(){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 xD(){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 vD(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function wD(){let e=bD(),t=xD(),n=vD();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}},kD=e=>Dt.registerSaveRouter(e),ID=e=>Dt.registerLoadRouter(e),SD=e=>Dt.getSaveHandlers(e),ND=(e,t)=>Dt.getLoadHandlers(e,t),Db="tensorflowjs",Rb=1,Xs="models_store",es="model_info_store";function UI(){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 Mb(e){let t=e.result;t.createObjectStore(Xs,{keyPath:"modelPath"}),t.createObjectStore(es,{keyPath:"modelPath"})}var si=class{constructor(e){if(this.indexedDB=UI(),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(Db,Rb);r.onupgradeneeded=()=>Mb(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=Dc(t),o=s.transaction(es,"readwrite"),l=o.objectStore(es),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(es);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 GI=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(si.URL_SCHEME)?TD(e.slice(si.URL_SCHEME.length)):null;Dt.registerSaveRouter(GI);Dt.registerLoadRouter(GI);function TD(e){return new si(e)}function CD(e){return e.startsWith(si.URL_SCHEME)?e.slice(si.URL_SCHEME.length):e}var _D=class{constructor(){this.indexedDB=UI()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(Db,Rb);n.onupgradeneeded=()=>Mb(n),n.onsuccess=()=>{let a=n.result,r=a.transaction(es,"readonly"),s=r.objectStore(es).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=CD(e),new Promise((t,n)=>{let a=this.indexedDB.open(Db,Rb);a.onupgradeneeded=()=>Mb(a),a.onsuccess=()=>{let r=a.result,s=r.transaction(es,"readwrite"),i=s.objectStore(es),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)})}},Tr="/",dl="tensorflowjs_models",HI="info",ED="model_topology",AD="weight_specs",$D="weight_data",FD="model_metadata";function jI(e){return{info:[dl,e,HI].join(Tr),topology:[dl,e,ED].join(Tr),weightSpecs:[dl,e,AD].join(Tr),weightData:[dl,e,$D].join(Tr),modelMetadata:[dl,e,FD].join(Tr)}}function qI(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function DD(e){let t=e.split(Tr);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Tr)}function RD(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=jI(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=Dc(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,gD(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 qI(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=yD(s),t}};ii.URL_SCHEME="localstorage://";var KI=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ii.URL_SCHEME)?MD(e.slice(ii.URL_SCHEME.length)):null;Dt.registerSaveRouter(KI);Dt.registerLoadRouter(KI);function MD(e){return new ii(e)}var PD=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=dl+Tr,n=Tr+HI;for(let a=0;a"scheme must not be undefined or null."),e.endsWith(fl)&&(e=e.slice(0,e.indexOf(fl))),R(e.length>0,()=>"scheme must not be an empty string.");let n=ca.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 Nh(e){if(e.indexOf(fl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ca.getSchemes().join(",")}`);return{scheme:e.split(fl)[0],path:e.split(fl)[1]}}async function XI(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=Nh(e).scheme,l=Nh(e).path,u=o===Nh(e).scheme,p=await r.load();n&&u&&await ca.getManager(o).removeModel(l);let d=await i.save(p);return n&&!u&&await ca.getManager(o).removeModel(l),d.modelArtifactsInfo}async function OD(){let e=ca.getSchemes(),t={};for(let n of e){let a=await ca.getManager(n).listModels();for(let r in a){let s=n+fl+r;t[s]=a[r]}}return t}async function LD(e){let t=Nh(e);return ca.getManager(t.scheme).removeModel(t.path)}async function zD(e,t){return XI(e,t,!1)}async function WD(e,t){return XI(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{ca.registerManager(ii.URL_SCHEME,new PD)}catch(e){}try{ca.registerManager(si.URL_SCHEME,new _D)}catch(e){}}var VD={importFetch:()=>K$()},cb,UD=class{constructor(){this.util=X$(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(cb==null&&(cb=VD.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 UD);function He(e,t="float32",n){return t=t||"float32",Nx(e),new jt(e,t,n)}function GD(e,t){let n=A(e,"x","cast");if(!kI(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_:GD});function HD(e){let t={x:A(e,"x","clone","string_or_numeric")};return L.runKernel(zi,t)}var _r=z({clone_:HD});function YI(e,t=!1){console.log(e.toString(t))}OI();var jD={buffer:He,cast:oe,clone:_r,print:YI};aD(jD);var Qt={};Re(Qt,{browserFiles:()=>QD,browserHTTPRequest:()=>rR,concatenateArrayBuffers:()=>Fx,copyModel:()=>zD,decodeWeights:()=>BI,encodeWeights:()=>mD,fromMemory:()=>iR,getLoadHandlers:()=>ND,getModelArtifactsForJSON:()=>Dx,getModelArtifactsInfoForJSON:()=>Dc,getSaveHandlers:()=>SD,http:()=>Mx,isHTTPScheme:()=>Pb,listModels:()=>OD,loadWeights:()=>eR,moveModel:()=>WD,registerLoadRouter:()=>ID,registerSaveRouter:()=>kD,removeModel:()=>LD,weightsLoaderFactory:()=>ZI,withSaveHandler:()=>oR});var qD="model",KD=".json",XD=".weights.bin";function j1(e){return new Promise(t=>setTimeout(t)).then(e)}var wl=class{constructor(e){if(!X().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(wl.URL_SCHEME)&&(e=e.slice(wl.URL_SCHEME.length)),(e==null||e.length===0)&&(e=qD),this.modelJsonFileName=e+KD,this.weightDataFileName=e+XD}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=VI(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 j1(()=>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 j1(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Dc(e)}}}};wl.URL_SCHEME="downloads://";var YD=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=Dx(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,Fx(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=>H1(r.name)),a={};for(let r of e)r.paths.forEach(s=>{let i=H1(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}},JD=e=>X().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(wl.URL_SCHEME)?ZD(e.slice(wl.URL_SCHEME.length)):null;Dt.registerSaveRouter(JD);function ZD(e="model"){return new wl(e)}function QD(e){return new YD(e)}function q1(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 JI(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 q1(a,t.onProgress,r,s)).map(u=>u.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await q1(i,t.onProgress,o,l)}async function eR(e,t="",n,a){return ZI(r=>JI(r,{requestInit:a}))(e,t,n)}function ZI(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=Fb[y]*wt(g.shape),x=()=>{r[m]=!0,s[m]==null&&(s[m]=[]),s[m].push({manifestEntry:g,groupOffset:f,sizeBytes:b})};a!=null?a.forEach((v,w)=>{v===g.name&&(x(),i[w]=!0)}):x(),o.push(g.name),f+=b})}),!i.every(h=>h)){let h=a.filter((m,f)=>!i[f]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=r.reduce((h,m,f)=>(m&&h.push(f),h),[]),u=[];l.forEach(h=>{t[h].paths.forEach(m=>{let f=n+(n.endsWith("/")?"":"/")+m;u.push(f)})});let p=await e(u),d={},c=0;return l.forEach(h=>{let m=t[h].paths.length,f=0;for(let x=0;x{let v=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),w=BI(v,[x.manifestEntry]);for(let T in w)d[T]=w[T]}),c+=m}),d}}var tR="application/octet-stream",nR="application/json",Rx=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=VI(e,n);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:nR}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:tR}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Dc(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 Dx(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=aR(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 JI(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,Fx(l)]}};Rx.URL_SCHEME_REGEX=/^https?:\/\//;function aR(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function Pb(e){return e.match(Rx.URL_SCHEME_REGEX)!=null}var QI=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(a=>Pb(a)):n=Pb(e),n)return Mx(e,t)}return null};Dt.registerSaveRouter(QI);Dt.registerLoadRouter(QI);function Mx(e,t){return new Rx(e,t)}function rR(e,t){return Mx(e,t)}var db=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},sR=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function iR(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 oR(e){return new sR(e)}var eS={};Re(eS,{confusionMatrix:()=>dR});function lR(e,t,n=!1,a=!1){let r=A(e,"a","matMul"),s=A(t,"b","matMul");[r,s]=$t(r,s);let i={a:r,b:s},o={transposeA:n,transposeB:a};return L.runKernel(Ii,i,o)}var Fe=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:A(e,"indices","oneHot","int32")},s={depth:t,onValue:n,offValue:a};return L.runKernel(Yi,r,s)}var kl=z({oneHot_:uR});function pR(e,t){let n=A(e,"x","transpose");if(t==null&&(t=n.shape.map((s,i)=>i).reverse()),R(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(s=>{R(s>=0&&s`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let a={x:n},r={perm:t};return L.runKernel(go,a,r)}var Pe=z({transpose_:pR});function cR(e,t,n){let a=A(e,"labels","confusionMatrix"),r=A(t,"predictions","confusionMatrix");R(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),R(a.rank===1,()=>`Expected the rank of labels to be 1, but got ${a.rank}`),R(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),R(a.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${a.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),R(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let s=kl(oe(a,"int32"),n),i=kl(oe(r,"int32"),n),o=Pe(s),l=Fe(o,i);return oe(l,"int32")}var dR=z({confusionMatrix_:cR}),Pu={};Re(Pu,{assertAndGetBroadcastShape:()=>ht,getBroadcastDims:()=>tS,getReductionAxes:()=>Bt});function tS(e,t){let n=e.length,a=[];for(let r=0;r1&&i===1&&a.unshift(s)}return a}function Bt(e,t){let n=[];for(let a=0;a1)&&n.unshift(s)}return n}function ht(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;rxR,fromPixelsAsync:()=>yR,toPixels:()=>bR});function jm(e,t,n){if(xi(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let a=pr(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 ws(e,t,a,n)}var Bs;function nS(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