/* Human homepage: author: ' */ var YT=Object.create,Kd=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,Qw=Object.getOwnPropertyNames,ZT=Object.getPrototypeOf,JT=Object.prototype.hasOwnProperty,e$=e=>Kd(e,"__esModule",{value:!0}),Mt=(e,t)=>function(){return t||(0,e[Qw(e)[0]])((t={exports:{}}).exports,t),t.exports},Ee=(e,t)=>{for(var n in t)Kd(e,n,{get:t[n],enumerable:!0})},t$=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qw(t))!JT.call(e,r)&&(n||r!=="default")&&Kd(e,r,{get:()=>t[r],enumerable:!(s=QT(t,r))||s.enumerable});return e},wa=(e,t)=>t$(e$(Kd(e!=null?YT(ZT(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),n$=Mt({"src/node_modules/long/src/long.js"(e,t){t.exports=s;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(O){}function s(O,T,M){this.low=O|0,this.high=T|0,this.unsigned=!!M}s.prototype.__isLong__,Object.defineProperty(s.prototype,"__isLong__",{value:!0});function r(O){return(O&&O.__isLong__)===!0}s.isLong=r;var a={},i={};function o(O,T){var M,W,j;return T?(O>>>=0,(j=0<=O&&O<256)&&(W=i[O],W)?W:(M=l(O,(O|0)<0?-1:0,!0),j&&(i[O]=M),M)):(O|=0,(j=-128<=O&&O<128)&&(W=a[O],W)?W:(M=l(O,O<0?-1:0,!1),j&&(a[O]=M),M))}s.fromInt=o;function u(O,T){if(isNaN(O))return T?x:v;if(T){if(O<0)return x;if(O>=g)return E}else{if(O<=-b)return P;if(O+1>=b)return R}return O<0?u(-O,T).neg():l(O%m|0,O/m|0,T)}s.fromNumber=u;function l(O,T,M){return new s(O,T,M)}s.fromBits=l;var c=Math.pow;function p(O,T,M){if(O.length===0)throw Error("empty string");if(O==="NaN"||O==="Infinity"||O==="+Infinity"||O==="-Infinity")return v;if(typeof T=="number"?(M=T,T=!1):T=!!T,M=M||10,M<2||360)throw Error("interior hyphen");if(W===0)return p(O.substring(1),T,M).neg();for(var j=u(c(M,8)),X=v,Y=0;Y>>0:this.low},A.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},A.toString=function(T){if(T=T||10,T<2||36>>0,se=J.toString(T);if(Y=te,Y.isZero())return se+Z;for(;se.length<6;)se="0"+se;Z=""+se+Z}},A.getHighBits=function(){return this.high},A.getHighBitsUnsigned=function(){return this.high>>>0},A.getLowBits=function(){return this.low},A.getLowBitsUnsigned=function(){return this.low>>>0},A.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var T=this.high!=0?this.high:this.low,M=31;M>0&&(T&1<=0},A.isOdd=function(){return(this.low&1)===1},A.isEven=function(){return(this.low&1)===0},A.equals=function(T){return r(T)||(T=d(T)),this.unsigned!==T.unsigned&&this.high>>>31===1&&T.high>>>31===1?!1:this.high===T.high&&this.low===T.low},A.eq=A.equals,A.notEquals=function(T){return!this.eq(T)},A.neq=A.notEquals,A.ne=A.notEquals,A.lessThan=function(T){return this.comp(T)<0},A.lt=A.lessThan,A.lessThanOrEqual=function(T){return this.comp(T)<=0},A.lte=A.lessThanOrEqual,A.le=A.lessThanOrEqual,A.greaterThan=function(T){return this.comp(T)>0},A.gt=A.greaterThan,A.greaterThanOrEqual=function(T){return this.comp(T)>=0},A.gte=A.greaterThanOrEqual,A.ge=A.greaterThanOrEqual,A.compare=function(T){if(r(T)||(T=d(T)),this.eq(T))return 0;var M=this.isNegative(),W=T.isNegative();return M&&!W?-1:!M&&W?1:this.unsigned?T.high>>>0>this.high>>>0||T.high===this.high&&T.low>>>0>this.low>>>0?-1:1:this.sub(T).isNegative()?-1:1},A.comp=A.compare,A.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(k)},A.neg=A.negate,A.add=function(T){r(T)||(T=d(T));var M=this.high>>>16,W=this.high&65535,j=this.low>>>16,X=this.low&65535,Y=T.high>>>16,Z=T.high&65535,te=T.low>>>16,J=T.low&65535,se=0,ne=0,oe=0,ae=0;return ae+=X+J,oe+=ae>>>16,ae&=65535,oe+=j+te,ne+=oe>>>16,oe&=65535,ne+=W+Z,se+=ne>>>16,ne&=65535,se+=M+Y,se&=65535,l(oe<<16|ae,se<<16|ne,this.unsigned)},A.subtract=function(T){return r(T)||(T=d(T)),this.add(T.neg())},A.sub=A.subtract,A.multiply=function(T){if(this.isZero())return v;if(r(T)||(T=d(T)),n){var M=n.mul(this.low,this.high,T.low,T.high);return l(M,n.get_high(),this.unsigned)}if(T.isZero())return v;if(this.eq(P))return T.isOdd()?P:v;if(T.eq(P))return this.isOdd()?P:v;if(this.isNegative())return T.isNegative()?this.neg().mul(T.neg()):this.neg().mul(T).neg();if(T.isNegative())return this.mul(T.neg()).neg();if(this.lt(y)&&T.lt(y))return u(this.toNumber()*T.toNumber(),this.unsigned);var W=this.high>>>16,j=this.high&65535,X=this.low>>>16,Y=this.low&65535,Z=T.high>>>16,te=T.high&65535,J=T.low>>>16,se=T.low&65535,ne=0,oe=0,ae=0,de=0;return de+=Y*se,ae+=de>>>16,de&=65535,ae+=X*se,oe+=ae>>>16,ae&=65535,ae+=Y*J,oe+=ae>>>16,ae&=65535,oe+=j*se,ne+=oe>>>16,oe&=65535,oe+=X*J,ne+=oe>>>16,oe&=65535,oe+=Y*te,ne+=oe>>>16,oe&=65535,ne+=W*se+j*J+X*te+Y*Z,ne&=65535,l(ae<<16|de,ne<<16|oe,this.unsigned)},A.mul=A.multiply,A.divide=function(T){if(r(T)||(T=d(T)),T.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&T.low===-1&&T.high===-1)return this;var M=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,T.low,T.high);return l(M,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?x:v;var W,j,X;if(this.unsigned){if(T.unsigned||(T=T.toUnsigned()),T.gt(this))return x;if(T.gt(this.shru(1)))return I;X=x}else{if(this.eq(P)){if(T.eq(k)||T.eq($))return P;if(T.eq(P))return k;var Y=this.shr(1);return W=Y.div(T).shl(1),W.eq(v)?T.isNegative()?k:$:(j=this.sub(T.mul(W)),X=W.add(j.div(T)),X)}else if(T.eq(P))return this.unsigned?x:v;if(this.isNegative())return T.isNegative()?this.neg().div(T.neg()):this.neg().div(T).neg();if(T.isNegative())return this.div(T.neg()).neg();X=v}for(j=this;j.gte(T);){W=Math.max(1,Math.floor(j.toNumber()/T.toNumber()));for(var Z=Math.ceil(Math.log(W)/Math.LN2),te=Z<=48?1:c(2,Z-48),J=u(W),se=J.mul(T);se.isNegative()||se.gt(j);)W-=te,J=u(W,this.unsigned),se=J.mul(T);J.isZero()&&(J=k),X=X.add(J),j=j.sub(se)}return X},A.div=A.divide,A.modulo=function(T){if(r(T)||(T=d(T)),n){var M=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,T.low,T.high);return l(M,n.get_high(),this.unsigned)}return this.sub(this.div(T).mul(T))},A.mod=A.modulo,A.rem=A.modulo,A.not=function(){return l(~this.low,~this.high,this.unsigned)},A.and=function(T){return r(T)||(T=d(T)),l(this.low&T.low,this.high&T.high,this.unsigned)},A.or=function(T){return r(T)||(T=d(T)),l(this.low|T.low,this.high|T.high,this.unsigned)},A.xor=function(T){return r(T)||(T=d(T)),l(this.low^T.low,this.high^T.high,this.unsigned)},A.shiftLeft=function(T){return r(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?l(this.low<>>32-T,this.unsigned):l(0,this.low<>>T|this.high<<32-T,this.high>>T,this.unsigned):l(this.high>>T-32,this.high>=0?0:-1,this.unsigned)},A.shr=A.shiftRight,A.shiftRightUnsigned=function(T){if(r(T)&&(T=T.toInt()),T&=63,T===0)return this;var M=this.high;if(T<32){var W=this.low;return l(W>>>T|M<<32-T,M>>>T,this.unsigned)}else return T===32?l(M,0,this.unsigned):l(M>>>T-32,0,this.unsigned)},A.shru=A.shiftRightUnsigned,A.shr_u=A.shiftRightUnsigned,A.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},A.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},A.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},A.toBytesLE=function(){var T=this.high,M=this.low;return[M&255,M>>>8&255,M>>>16&255,M>>>24,T&255,T>>>8&255,T>>>16&255,T>>>24]},A.toBytesBE=function(){var T=this.high,M=this.low;return[T>>>24,T>>>16&255,T>>>8&255,T&255,M>>>24,M>>>16&255,M>>>8&255,M&255]},s.fromBytes=function(T,M,W){return W?s.fromBytesLE(T,M):s.fromBytesBE(T,M)},s.fromBytesLE=function(T,M){return new s(T[0]|T[1]<<8|T[2]<<16|T[3]<<24,T[4]|T[5]<<8|T[6]<<16|T[7]<<24,M)},s.fromBytesBE=function(T,M){return new s(T[4]<<24|T[5]<<16|T[6]<<8|T[7],T[0]<<24|T[1]<<16|T[2]<<8|T[3],M)}}}),s$=Mt({"(disabled):src/node_modules/node-fetch/browser.js"(){}}),r$=Mt({"(disabled):util"(){}}),a$=Mt({"src/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(l){var c=this,p=u();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=p(" "),c.s1=p(" "),c.s2=p(" "),c.s0-=p(l),c.s0<0&&(c.s0+=1),c.s1-=p(l),c.s1<0&&(c.s1+=1),c.s2-=p(l),c.s2<0&&(c.s2+=1),p=null}function i(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var p=new a(l),d=c&&c.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d=="object"&&i(d,p),h.state=function(){return i(p,{})}),h}function u(){var l=4022871197,c=function(p){p=String(p);for(var d=0;d>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),i$=Mt({"src/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var d=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^d^d>>>8},u===(u|0)?l.x=u:c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),o$=Mt({"src/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.next=function(){var d=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(d^d<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,u===(u|0)?l.x=u:c+=u;for(var p=0;p>>4),l.next()}function i(u,l){return l.x=u.x,l.y=u.y,l.z=u.z,l.w=u.w,l.v=u.v,l.d=u.d,l}function o(u,l){var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),u$=Mt({"src/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.x,d=l.i,h,f,m;return h=p[d],h^=h>>>7,f=h^h<<24,h=p[d+1&7],f^=h^h>>>10,h=p[d+3&7],f^=h^h>>>3,h=p[d+4&7],f^=h^h<<7,h=p[d+7&7],h=h^h<<13,f^=h^h<<9,p[d]=f,l.i=d+1&7,f};function c(p,d){var h,f,m=[];if(d===(d|0))f=m[0]=d;else for(d=""+d,h=0;h0;--h)p.next()}c(l,u)}function i(u,l){return l.x=u.x.slice(),l.i=u.i,l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.x&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),l$=Mt({"src/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.w,d=l.X,h=l.i,f,m;return l.w=p=p+1640531527|0,m=d[h+34&127],f=d[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=d[h]=m^f,l.i=h,m+(p^p>>>16)|0};function c(p,d){var h,f,m,g,b,y=[],v=128;for(d===(d|0)?(f=d,d=null):(d=d+"\0",f=0,v=Math.max(v,d.length)),m=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(b=b+1640531527|0,h=y[g&127]^=f+b,m=h==0?m+1:0);for(m>=128&&(y[(d&&d.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;p.w=b,p.X=y,p.i=m}c(l,u)}function i(u,l){return l.i=u.i,l.w=u.w,l.X=u.X.slice(),l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.X&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),c$=Mt({"src/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(u){var l=this,c="";l.next=function(){var d=l.b,h=l.c,f=l.d,m=l.a;return d=d<<25^d>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-d|0,l.b=d=d<<20^d>>>12^h,l.c=h=h-f|0,l.d=f<<16^h>>>16^m,l.a=m-d|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,u===Math.floor(u)?(l.a=u/4294967296|0,l.b=u|0):c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p=="object"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),d$=Mt({"(disabled):crypto"(){}}),p$=Mt({"src/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,s,r){var a=256,i=6,o=52,u="random",l=r.pow(a,i),c=r.pow(2,o),p=c*2,d=a-1,h;function f(k,I,$){var R=[];I=I==!0?{entropy:!0}:I||{};var E=y(b(I.entropy?[k,x(s)]:k==null?v():k,3),R),P=new m(R),A=function(){for(var O=P.g(i),T=l,M=0;O=p;)O/=2,T/=2,M>>>=1;return(O+M)/T};return A.int32=function(){return P.g(4)|0},A.quick=function(){return P.g(4)/4294967296},A.double=A,y(x(P.S),s),(I.pass||$||function(O,T,M,W){return W&&(W.S&&g(W,P),O.state=function(){return g(P,{})}),M?(r[u]=O,T):O})(A,E,"global"in I?I.global:this==r,I.state)}function m(k){var I,$=k.length,R=this,E=0,P=R.i=R.j=0,A=R.S=[];for($||(k=[$++]);E{var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};function a(){return Ce.buffer!=nn&&rs(Ce.buffer),lc}function i(){return Ce.buffer!=nn&&rs(Ce.buffer),cc}function o(){return Ce.buffer!=nn&&rs(Ce.buffer),gu}function u(){return Ce.buffer!=nn&&rs(Ce.buffer),dc}function l(){return Ce.buffer!=nn&&rs(Ce.buffer),pc}function c(){return Ce.buffer!=nn&&rs(Ce.buffer),hc}function p(){return Ce.buffer!=nn&&rs(Ce.buffer),fc}var d=typeof r!="undefined"?r:{},h,f;d.ready=new Promise(function(N,D){h=N,f=D});var m;typeof process!="undefined"&&process.listeners&&(m={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var g=Object.assign({},d),b=[],y="./this.program",v=(N,D)=>{throw D},x=typeof window=="object",k=typeof importScripts=="function",I=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",$=d.ENVIRONMENT_IS_PTHREAD||!1,R="";function E(N){return d.locateFile?d.locateFile(N,R):R+N}var P,A,O,T;function M(N){if(N instanceof Cu)return;J("exiting due to exception: "+N)}var W,j,X;if(I){k?R=gd().dirname(R)+"/":R=__dirname+"/",X=()=>{j||(W=ug(),j=gd())},P=function(B,Q){return X(),B=j.normalize(B),W.readFileSync(B,Q?void 0:"utf8")},O=D=>{var B=P(D,!0);return B.buffer||(B=new Uint8Array(B)),B},A=(D,B,Q)=>{X(),D=j.normalize(D),W.readFile(D,function(ue,pe){ue?Q(ue):B(pe.buffer)})},process.argv.length>1&&(y=process.argv[1].replace(/\\/g,"/")),b=process.argv.slice(2),process.on("uncaughtException",function(D){if(!(D instanceof Cu))throw D}),process.on("unhandledRejection",function(D){throw D}),v=(D,B)=>{if(Mr())throw process.exitCode=D,B;M(B),process.exit(D)},d.inspect=function(){return"[Emscripten Module object]"};let N;try{N=h$()}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(x||k)&&(k?R=self.location.href:typeof document!="undefined"&&document.currentScript&&(R=document.currentScript.src),typeof s!="undefined"&&s&&(R=s),R.indexOf("blob:")!==0?R=R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1):R="",I||(P=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.send(null),D.responseText},k&&(O=N=>{var D=new XMLHttpRequest;return D.open("GET",N,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),A=(N,D,B)=>{var Q=new XMLHttpRequest;Q.open("GET",N,!0),Q.responseType="arraybuffer",Q.onload=()=>{if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}B()},Q.onerror=B,Q.send(null)}),T=N=>document.title=N);I&&typeof performance=="undefined"&&(global.performance=f$().performance);var Y=console.log.bind(console),Z=console.warn.bind(console);I&&(X(),Y=N=>W.writeSync(1,N+` `),Z=N=>W.writeSync(2,N+` `));var te=d.print||Y,J=d.printErr||Z;Object.assign(d,g),g=null,d.arguments&&(b=d.arguments),d.thisProgram&&(y=d.thisProgram),d.quit&&(v=d.quit);var se=4;function ne(N){ne.shown||(ne.shown={}),ne.shown[N]||(ne.shown[N]=1,J(N))}function oe(N,D){if(typeof WebAssembly.Function=="function"){for(var B={i:"i32",j:"i64",f:"f32",d:"f64"},Q={parameters:[],results:D[0]=="v"?[]:[B[D[0]]]},ue=1;ue{Ie=N},Pe=Atomics.load,Xe=Atomics.store,Je=Atomics.compareExchange,Ye;d.wasmBinary&&(Ye=d.wasmBinary);var tt=d.noExitRuntime||!0;typeof WebAssembly!="object"&&Ni("no native wasm support detected");var Ce,ut,at=!1,Jt;function Nt(N,D){N||Ni(D)}function In(N){var D=d["_"+N];return D}function Rt(N,D,B,Q,ue){var pe={string:function(Tn){var Pi=0;if(Tn!=null&&Tn!==0){var ox=(Tn.length<<2)+1;Pi=Oi(ox),Ms(Tn,Pi,ox)}return Pi},array:function(Tn){var Pi=Oi(Tn.length);return Ls(Tn,Pi),Pi}};function ye(Tn){return D==="string"?tn(Tn):D==="boolean"?Boolean(Tn):Tn}var Te=In(N),bt=[],us=0;if(Q)for(var ls=0;ls(B.buffer instanceof SharedArrayBuffer&&(B=new Uint8Array(B)),D.decode.call(D,B))}var Yt=typeof TextDecoder!="undefined"?new Nn("utf8"):void 0;function Dn(N,D,B){for(var Q=D+B,ue=D;N[ue]&&!(ue>=Q);)++ue;if(ue-D>16&&N.subarray&&Yt)return Yt.decode(N.subarray(D,ue));for(var pe="";D>10,56320|us&1023)}}return pe}function tn(N,D){return N?Dn(i(),N,D):""}function zs(N,D,B,Q){if(!(Q>0))return 0;for(var ue=B,pe=B+Q-1,ye=0;ye=55296&&Te<=57343){var bt=N.charCodeAt(++ye);Te=65536+((Te&1023)<<10)|bt&1023}if(Te<=127){if(B>=pe)break;D[B++]=Te}else if(Te<=2047){if(B+1>=pe)break;D[B++]=192|Te>>6,D[B++]=128|Te&63}else if(Te<=65535){if(B+2>=pe)break;D[B++]=224|Te>>12,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}else{if(B+3>=pe)break;D[B++]=240|Te>>18,D[B++]=128|Te>>12&63,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}}return D[B]=0,B-ue}function Ms(N,D,B){return zs(N,i(),D,B)}function Si(N){for(var D=0,B=0;B=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|N.charCodeAt(++B)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}var Zs=typeof TextDecoder!="undefined"?new Nn("utf-16le"):void 0;function Ls(N,D){a().set(N,D)}function mu(N,D,B){for(var Q=0;Q>0]=N.charCodeAt(Q);B||(a()[D>>0]=0)}function Ii(N,D){return N%D>0&&(N+=D-N%D),N}var nn,lc,cc,gu,dc,pc,Vv,hc,fc;$&&(nn=d.buffer);function rs(N){nn=N,d.HEAP8=lc=new Int8Array(N),d.HEAP16=gu=new Int16Array(N),d.HEAP32=pc=new Int32Array(N),d.HEAPU8=cc=new Uint8Array(N),d.HEAPU16=dc=new Uint16Array(N),d.HEAPU32=Vv=new Uint32Array(N),d.HEAPF32=hc=new Float32Array(N),d.HEAPF64=fc=new Float64Array(N)}var mc=d.INITIAL_MEMORY||16777216;if($)Ce=d.wasmMemory,nn=d.buffer;else if(d.wasmMemory)Ce=d.wasmMemory;else if(Ce=new WebAssembly.Memory({initial:mc/65536,maximum:32768,shared:!0}),!(Ce.buffer instanceof SharedArrayBuffer))throw J("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),I&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Ce&&(nn=Ce.buffer),mc=nn.byteLength,rs(nn);var Fn,Ci=[],Js=[],lh=[],gc=[],zr=!1,ch=!1,bc=0;function Mr(){return tt||bc>0}function sn(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)Wv(d.preRun.shift());kc(Ci)}function bu(){zr=!0,!$&&kc(Js)}function dh(){$||($e.terminateAllThreads(),ch=!0)}function ph(){if(!$){if(d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)yu(d.postRun.shift());kc(gc)}}function Wv(N){Ci.unshift(N)}function Uv(N){Js.unshift(N)}function yu(N){gc.unshift(N)}var er=0,yc=null,as=null;function vu(N){er++,d.monitorRunDependencies&&d.monitorRunDependencies(er)}function Gv(N){if(er--,d.monitorRunDependencies&&d.monitorRunDependencies(er),er==0&&(yc!==null&&(clearInterval(yc),yc=null),as)){var D=as;as=null,D()}}d.preloadedImages={},d.preloadedAudios={};function Ni(N){$?postMessage({cmd:"onAbort",arg:N}):d.onAbort&&d.onAbort(N),N="Aborted("+N+")",J(N),at=!0,Jt=1,N+=". Build with -s ASSERTIONS=1 for more info.";var D=new WebAssembly.RuntimeError(N);throw f(D),D}var hh="data:application/octet-stream;base64,";function vc(N){return N.startsWith(hh)}function xc(N){return N.startsWith("file://")}var rn;rn="tfjs-backend-wasm-threaded-simd.wasm",vc(rn)||(rn=E(rn));function wc(N){try{if(N==rn&&Ye)return new Uint8Array(Ye);if(O)return O(N);throw"both async and sync fetching of the wasm failed"}catch(D){Ni(D)}}function Ti(){if(!Ye&&(x||k)){if(typeof fetch=="function"&&!xc(rn))return fetch(rn,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+rn+"'";return N.arrayBuffer()}).catch(function(){return wc(rn)});if(A)return new Promise(function(N,D){A(rn,function(B){N(new Uint8Array(B))},D)})}return Promise.resolve().then(function(){return wc(rn)})}function fh(){var N={env:Fc,wasi_snapshot_preview1:Fc};function D(ye,Te){var bt=ye.exports;if(d.asm=bt,wh(d.asm.emscripten_tls_init),Fn=d.asm.__indirect_function_table,Uv(d.asm.__wasm_call_ctors),ut=Te,!$){var us=$e.unusedWorkers.length;$e.unusedWorkers.forEach(function(ls){$e.loadWasmModuleToWorker(ls,function(){--us||Gv("wasm-instantiate")})})}}$||vu("wasm-instantiate");function B(ye){D(ye.instance,ye.module)}function Q(ye){return Ti().then(function(Te){return WebAssembly.instantiate(Te,N)}).then(function(Te){return Te}).then(ye,function(Te){J("failed to asynchronously prepare wasm: "+Te),Ni(Te)})}function ue(){return!Ye&&typeof WebAssembly.instantiateStreaming=="function"&&!vc(rn)&&!xc(rn)&&typeof fetch=="function"?fetch(rn,{credentials:"same-origin"}).then(function(ye){var Te=WebAssembly.instantiateStreaming(ye,N);return Te.then(B,function(bt){return J("wasm streaming compile failed: "+bt),J("falling back to ArrayBuffer instantiation"),Q(B)})}):Q(B)}if(d.instantiateWasm)try{var pe=d.instantiateWasm(N,D);return pe}catch(ye){return J("Module.instantiateWasm callback failed with error: "+ye),!1}return ue().catch(f),{}}var Hv,qv,mh={};function kc(N){for(;N.length>0;){var D=N.shift();if(typeof D=="function"){D(d);continue}var B=D.func;typeof B=="number"?D.arg===void 0?_i(B)():_i(B)(D.arg):B(D.arg===void 0?null:D.arg)}}function $i(N){var D=Lf(),B=N();return Lc(D),B}function sT(N){return N}function jv(N){var D=/\b_Z[\w\d_]+/g;return N.replace(D,function(B){var Q=B;return B===Q?B:Q+" ["+B+"]"})}function gh(N){l()[N>>2]=0;var D=$e.pthreads[N];delete $e.pthreads[N],D.worker.terminate(),Mf(N),$e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function bh(N){var D=$e.pthreads[N];D.worker.postMessage({cmd:"cancel"})}function Sc(N){var D=$e.pthreads[N];if(D){l()[N>>2]=0;var B=D.worker;$e.returnWorkerToPool(B)}}function Ic(N){qT(N)}function yh(N){if(N instanceof Cu||N=="unwind")return Jt;v(1,N)}var $e={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){$?$e.initWorker():$e.initMainThread()},initMainThread:function(){for(var N=8,D=0;D>2]=0;try{N()}finally{l()[ix>>2]=1}},receiveObjectTransfer:function(N){},threadInit:function(){for(var N in $e.tlsInitFunctions)$e.tlsInitFunctions[N]()},loadWasmModuleToWorker:function(N,D){N.onmessage=B=>{var Q=B.data,ue=Q.cmd;if(N.pthread&&($e.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),Q.targetThread&&Q.targetThread!=Mc()){var pe=$e.pthreads[Q.targetThread];pe?pe.worker.postMessage(Q,Q.transferList):J('Internal error! Worker sent a message "'+ue+'" to target pthread '+Q.targetThread+", but that thread no longer exists!"),$e.currentProxiedOperationCallerThread=void 0;return}ue==="processQueuedMainThreadWork"?tx():ue==="spawnThread"?Nc(Q):ue==="cleanupThread"?Sc(Q.thread):ue==="killThread"?gh(Q.thread):ue==="cancelThread"?bh(Q.thread):ue==="loaded"?(N.loaded=!0,D&&D(N),N.runPthread&&(N.runPthread(),delete N.runPthread)):ue==="print"?te("Thread "+Q.threadId+": "+Q.text):ue==="printErr"?J("Thread "+Q.threadId+": "+Q.text):ue==="alert"?alert("Thread "+Q.threadId+": "+Q.text):Q.target==="setimmediate"?N.postMessage(Q):ue==="onAbort"?d.onAbort&&d.onAbort(Q.arg):J("worker sent an unknown command "+ue),$e.currentProxiedOperationCallerThread=void 0},N.onerror=B=>{var Q="worker sent an error!";throw J(Q+" "+B.filename+":"+B.lineno+": "+B.message),B},I&&(N.on("message",function(B){N.onmessage({data:B})}),N.on("error",function(B){N.onerror(B)}),N.on("detachedExit",function(){})),N.postMessage({cmd:"load",urlOrBlob:d.mainScriptUrlOrBlob||s,wasmMemory:Ce,wasmModule:ut})},allocateUnusedWorker:function(){var N=E("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 vh(){var N=Mc(),D=l()[N+44>>2],B=l()[N+48>>2],Q=D-B;ax(D,Q),Lc(D)}d.establishStackSpace=vh;function Cc(N){if($)return Vr(1,0,N);try{Ic(N)}catch(D){yh(D)}}var Lr=[];function _i(N){var D=Lr[N];return D||(N>=Lr.length&&(Lr.length=N+1),Lr[N]=D=Fn.get(N)),D}function xh(N,D){return _i(N)(D)}d.invokeEntryPoint=xh;function Kv(){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 wh(N,D,B){$e.tlsInitFunctions.push(N)}function Xv(N,D){Fn.set(N,D),Lr[N]=D}var Br;I?Br=()=>{var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:$?Br=()=>performance.now()-d.__performance_now_clock_drift:Br=()=>performance.now();var kh=!0;function Sh(N){return l()[ex()>>2]=N,N}function Ih(N,D){var B;if(N===0)B=Date.now();else if((N===1||N===4)&&kh)B=Br();else return Sh(28),-1;return l()[D>>2]=B/1e3|0,l()[D+4>>2]=B%1e3*1e3*1e3|0,0}function Ch(N,D){return Ih(N,D)}function Nh(N){nx(N,!k,1,!x),$e.threadInit()}function Th(N){$?postMessage({cmd:"cleanupThread",thread:N}):Sc(N)}function Nc(N){var D=$e.getNewWorker();if(!D)return 6;$e.runningWorkers.push(D);var B=$e.pthreads[N.pthread_ptr]={worker:D,threadInfoStruct:N.pthread_ptr};D.pthread=B;var Q={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr};return D.runPthread=()=>{Q.time=performance.now(),D.postMessage(Q,N.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function $h(N,D,B,Q){if(typeof SharedArrayBuffer=="undefined")return J("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ue=[],pe=0;if($&&(ue.length===0||pe))return sx(687865856,N,D,B,Q);if(pe)return pe;var ye={startRoutine:B,pthread_ptr:N,arg:Q,transferList:ue};return $?(ye.cmd="spawnThread",postMessage(ye,ue),0):Nc(ye)}function _h(){return 2097152}function Ah(N,D){if(N==D)postMessage({cmd:"processQueuedMainThreadWork"});else if($)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var B=$e.pthreads[N],Q=B&&B.worker;if(!Q)return;Q.postMessage({cmd:"processThreadQueue"})}return 1}function Eh(){Ni("")}function Rh(){I||k||ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Tc(){return 2147483648}function Dh(N,D,B){i().copyWithin(N,D,D+B)}function Fh(){return I?m$().cpus().length:navigator.hardwareConcurrency}function Vr(N,D){var B=arguments.length-2,Q=arguments;return $i(function(){for(var ue=B,pe=Oi(ue*8),ye=pe>>3,Te=0;Te>3,ue=0;ue>>16),rs(Ce.buffer),1}catch(D){}}function zh(N){var D=i().length;if(N=N>>>0,N<=D)return!1;var B=Tc();if(N>B)return!1;for(var Q=1;Q<=4;Q*=2){var ue=D*(1+.2/Q);ue=Math.min(ue,N+100663296);var pe=Math.min(B,Ii(Math.max(N,ue),65536)),ye=Ph(pe);if(ye)return!0}return!1}var Me={inEventHandler:0,removeAllEventListeners:function(){for(var N=Me.eventHandlers.length-1;N>=0;--N)Me._removeHandler(N);Me.eventHandlers=[],Me.deferredCalls=[]},registerRemoveEventListeners:function(){Me.removeEventListenersRegistered||(lh.push(Me.removeAllEventListeners),Me.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,D,B){function Q(ye,Te){if(ye.length!=Te.length)return!1;for(var bt in ye)if(ye[bt]!=Te[bt])return!1;return!0}for(var ue in Me.deferredCalls){var pe=Me.deferredCalls[ue];if(pe.targetFunction==N&&Q(pe.argsList,B))return}Me.deferredCalls.push({targetFunction:N,precedence:D,argsList:B}),Me.deferredCalls.sort(function(ye,Te){return ye.precedence>2]=B,l()[pe+4>>2]=Q,l()[pe+8>>2]=ue,zf(N,637534208,D,Q,pe)})},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 Mh(N){var D=Si(N)+1,B=Pf(D);return Ms(N,B,D),B}function Lh(N,D,B,Q){$i(function(){var ue=Oi(12),pe=0;D&&(pe=Mh(D)),l()[ue>>2]=pe,l()[ue+4>>2]=B,l()[ue+8>>2]=Q,zf(N,657457152,0,pe,ue)})}function Bh(N,D,B,Q){D=D?tn(D):"",Lh(N,D,B,Q)}function Vh(N){return N>2?tn(N):N}var Wh=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Uh(N){N=Vh(N);var D=Wh[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return D}function wu(N){return Uh(N)}function $c(N,D,B){var Q=wu(N);if(!Q)return-4;if(Q.canvasSharedPtr&&(l()[Q.canvasSharedPtr>>2]=D,l()[Q.canvasSharedPtr+4>>2]=B),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var ue=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var pe=Q.GLctxObject.GLctx.getParameter(2978);ue=pe[0]===0&&pe[1]===0&&pe[2]===Q.width&&pe[3]===Q.height}Q.width=D,Q.height=B,ue&&Q.GLctxObject.GLctx.viewport(0,0,D,B)}else if(Q.canvasSharedPtr){var ye=l()[Q.canvasSharedPtr+8>>2];return Bh(ye,N,D,B),1}else return-4;return 0}function _c(N,D,B){return $?Vr(2,1,N,D,B):$c(N,D,B)}function Gh(N,D,B){var Q=wu(N);return Q?$c(N,D,B):_c(N,D,B)}function Hh(){throw"unwind"}function qh(N){var D=N.getExtension("ANGLE_instanced_arrays");if(D)return N.vertexAttribDivisor=function(B,Q){D.vertexAttribDivisorANGLE(B,Q)},N.drawArraysInstanced=function(B,Q,ue,pe){D.drawArraysInstancedANGLE(B,Q,ue,pe)},N.drawElementsInstanced=function(B,Q,ue,pe,ye){D.drawElementsInstancedANGLE(B,Q,ue,pe,ye)},1}function jh(N){var D=N.getExtension("OES_vertex_array_object");if(D)return N.createVertexArray=function(){return D.createVertexArrayOES()},N.deleteVertexArray=function(B){D.deleteVertexArrayOES(B)},N.bindVertexArray=function(B){D.bindVertexArrayOES(B)},N.isVertexArray=function(B){return D.isVertexArrayOES(B)},1}function Kh(N){var D=N.getExtension("WEBGL_draw_buffers");if(D)return N.drawBuffers=function(B,Q){D.drawBuffersWEBGL(B,Q)},1}function Xh(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var gt={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(D){gt.lastError||(gt.lastError=D)},getNewId:function(N){for(var D=gt.counter++,B=N.length;B>2]:-1;ue+=tn(l()[B+pe*4>>2],ye<0?void 0:ye)}return ue},createContext:function(N,D){N.getContextSafariWebGL2Fixed||(N.getContextSafariWebGL2Fixed=N.getContext,N.getContext=function(ue,pe){var ye=N.getContextSafariWebGL2Fixed(ue,pe);return ue=="webgl"==ye instanceof WebGLRenderingContext?ye:null});var B=N.getContext("webgl",D);if(!B)return 0;var Q=gt.registerContext(B,D);return Q},registerContext:function(N,D){var B=Pf(8);l()[B+4>>2]=Mc();var Q={handle:B,attributes:D,version:D.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=Q),gt.contexts[B]=Q,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&>.initExtensions(Q),B},makeContextCurrent:function(N){return gt.currentContext=gt.contexts[N],d.ctx=Dc=gt.currentContext&>.currentContext.GLctx,!(N&&!Dc)},getContext:function(N){return gt.contexts[N]},deleteContext:function(N){gt.currentContext===gt.contexts[N]&&(gt.currentContext=null),typeof Me=="object"&&Me.removeAllHandlersOnTarget(gt.contexts[N].GLctx.canvas),gt.contexts[N]&>.contexts[N].GLctx.canvas&&(gt.contexts[N].GLctx.canvas.GLctxObject=void 0),Jv(gt.contexts[N].handle),gt.contexts[N]=null},initExtensions:function(N){if(N||(N=gt.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var D=N.GLctx;qh(D),jh(D),Kh(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),Xh(D);var B=D.getSupportedExtensions()||[];B.forEach(function(Q){!Q.includes("lose_context")&&!Q.includes("debug")&&D.getExtension(Q)})}}},Yh=["default","low-power","high-performance"];function Qh(N,D){var B=D>>2,Q=l()[B+6],ue={alpha:!!l()[B+0],depth:!!l()[B+1],stencil:!!l()[B+2],antialias:!!l()[B+3],premultipliedAlpha:!!l()[B+4],preserveDrawingBuffer:!!l()[B+5],powerPreference:Yh[Q],failIfMajorPerformanceCaveat:!!l()[B+7],majorVersion:l()[B+8],minorVersion:l()[B+9],enableExtensionsByDefault:l()[B+10],explicitSwapControl:l()[B+11],proxyContextToMainThread:l()[B+12],renderViaOffscreenBackBuffer:l()[B+13]},pe=wu(N);if(!pe||ue.explicitSwapControl)return 0;var ye=gt.createContext(pe,ue);return ye}function Zh(N,D){return Qh(N,D)}var Ai={mappings:{},buffers:[null,[],[]],printChar:function(N,D){var B=Ai.buffers[N];D===0||D===10?((N===1?te:J)(Dn(B,0)),B.length=0):B.push(D)},varargs:void 0,get:function(){Ai.varargs+=4;var N=l()[Ai.varargs-4>>2];return N},getStr:function(N){var D=tn(N);return D},get64:function(N,D){return N}};function Ac(N){return $?Vr(3,1,N):0}function Ec(N,D,B,Q,ue){if($)return Vr(4,1,N,D,B,Q,ue)}function Rc(N,D,B,Q){if($)return Vr(5,1,N,D,B,Q);for(var ue=0,pe=0;pe>2],Te=l()[D+4>>2];D+=8;for(var bt=0;bt>2]=ue,0}function Jh(N){Re(N)}$e.init();var Dc,ef=[null,Cc,_c,Ac,Ec,Rc],Yv=!1,Fc={__clock_gettime:Ch,__emscripten_init_main_thread_js:Nh,__emscripten_thread_cleanup:Th,__pthread_create_js:$h,_emscripten_default_pthread_stack_size:_h,_emscripten_notify_thread_queue:Ah,abort:Eh,emscripten_check_blocking_allowed:Rh,emscripten_get_heap_max:Tc,emscripten_get_now:Br,emscripten_memcpy_big:Dh,emscripten_num_logical_cores:Fh,emscripten_receive_on_main_thread_js:Oh,emscripten_resize_heap:zh,emscripten_set_canvas_element_size:Gh,emscripten_unwind_to_js_event_loop:Hh,emscripten_webgl_create_context:Zh,exit:Ic,fd_close:Ac,fd_seek:Ec,fd_write:Rc,memory:Ce||d.wasmMemory,setTempRet0:Jh},Qv=fh(),tf=d.___wasm_call_ctors=function(){return(tf=d.___wasm_call_ctors=d.asm.__wasm_call_ctors).apply(null,arguments)},nf=d._init=function(){return(nf=d._init=d.asm.init).apply(null,arguments)},sf=d._init_with_threads_count=function(){return(sf=d._init_with_threads_count=d.asm.init_with_threads_count).apply(null,arguments)},rf=d._get_threads_count=function(){return(rf=d._get_threads_count=d.asm.get_threads_count).apply(null,arguments)},af=d._register_tensor=function(){return(af=d._register_tensor=d.asm.register_tensor).apply(null,arguments)},of=d._dispose_data=function(){return(of=d._dispose_data=d.asm.dispose_data).apply(null,arguments)},uf=d._dispose=function(){return(uf=d._dispose=d.asm.dispose).apply(null,arguments)},lf=d._Abs=function(){return(lf=d._Abs=d.asm.Abs).apply(null,arguments)},cf=d._Add=function(){return(cf=d._Add=d.asm.Add).apply(null,arguments)},df=d._AddN=function(){return(df=d._AddN=d.asm.AddN).apply(null,arguments)},pf=d._All=function(){return(pf=d._All=d.asm.All).apply(null,arguments)},hf=d._Any=function(){return(hf=d._Any=d.asm.Any).apply(null,arguments)},ff=d._ArgMax=function(){return(ff=d._ArgMax=d.asm.ArgMax).apply(null,arguments)},mf=d._AvgPool=function(){return(mf=d._AvgPool=d.asm.AvgPool).apply(null,arguments)},gf=d._BatchMatMul=function(){return(gf=d._BatchMatMul=d.asm.BatchMatMul).apply(null,arguments)},bf=d._Ceil=function(){return(bf=d._Ceil=d.asm.Ceil).apply(null,arguments)},yf=d._ClipByValue=function(){return(yf=d._ClipByValue=d.asm.ClipByValue).apply(null,arguments)},vf=d._Conv2D=function(){return(vf=d._Conv2D=d.asm.Conv2D).apply(null,arguments)},xf=d._Conv2DBackpropInput=function(){return(xf=d._Conv2DBackpropInput=d.asm.Conv2DBackpropInput).apply(null,arguments)},wf=d._Cos=function(){return(wf=d._Cos=d.asm.Cos).apply(null,arguments)},kf=d._Cosh=function(){return(kf=d._Cosh=d.asm.Cosh).apply(null,arguments)},Sf=d._CropAndResize=function(){return(Sf=d._CropAndResize=d.asm.CropAndResize).apply(null,arguments)},If=d._Cumprod=function(){return(If=d._Cumprod=d.asm.Cumprod).apply(null,arguments)},Cf=d._Cumsum=function(){return(Cf=d._Cumsum=d.asm.Cumsum).apply(null,arguments)},Nf=d._DepthToSpace=function(){return(Nf=d._DepthToSpace=d.asm.DepthToSpace).apply(null,arguments)},Tf=d._DepthwiseConv2dNative=function(){return(Tf=d._DepthwiseConv2dNative=d.asm.DepthwiseConv2dNative).apply(null,arguments)},$f=d._Elu=function(){return($f=d._Elu=d.asm.Elu).apply(null,arguments)},_f=d._Equal=function(){return(_f=d._Equal=d.asm.Equal).apply(null,arguments)},Af=d._Exp=function(){return(Af=d._Exp=d.asm.Exp).apply(null,arguments)},Ef=d._FlipLeftRight=function(){return(Ef=d._FlipLeftRight=d.asm.FlipLeftRight).apply(null,arguments)},Oc=d._Floor=function(){return(Oc=d._Floor=d.asm.Floor).apply(null,arguments)},Pc=d._FloorDiv=function(){return(Pc=d._FloorDiv=d.asm.FloorDiv).apply(null,arguments)},ku=d._FusedBatchNorm=function(){return(ku=d._FusedBatchNorm=d.asm.FusedBatchNorm).apply(null,arguments)},Rf=d._FusedConv2D=function(){return(Rf=d._FusedConv2D=d.asm.FusedConv2D).apply(null,arguments)},Df=d._FusedDepthwiseConv2D=function(){return(Df=d._FusedDepthwiseConv2D=d.asm.FusedDepthwiseConv2D).apply(null,arguments)},Ei=d._Gather=function(){return(Ei=d._Gather=d.asm.Gather).apply(null,arguments)},Su=d._GatherNd=function(){return(Su=d._GatherNd=d.asm.GatherNd).apply(null,arguments)},Iu=d._Greater=function(){return(Iu=d._Greater=d.asm.Greater).apply(null,arguments)},Zv=d._GreaterEqual=function(){return(Zv=d._GreaterEqual=d.asm.GreaterEqual).apply(null,arguments)},Ri=d._LeakyRelu=function(){return(Ri=d._LeakyRelu=d.asm.LeakyRelu).apply(null,arguments)},Di=d._Less=function(){return(Di=d._Less=d.asm.Less).apply(null,arguments)},Ff=d._LessEqual=function(){return(Ff=d._LessEqual=d.asm.LessEqual).apply(null,arguments)},H=d._Log=function(){return(H=d._Log=d.asm.Log).apply(null,arguments)},ee=d._LogicalAnd=function(){return(ee=d._LogicalAnd=d.asm.LogicalAnd).apply(null,arguments)},ce=d._Max=function(){return(ce=d._Max=d.asm.Max).apply(null,arguments)},Se=d._MaxPool=function(){return(Se=d._MaxPool=d.asm.MaxPool).apply(null,arguments)},Qe=d._Maximum=function(){return(Qe=d._Maximum=d.asm.Maximum).apply(null,arguments)},Ze=d._Mean=function(){return(Ze=d._Mean=d.asm.Mean).apply(null,arguments)},Le=d._Min=function(){return(Le=d._Min=d.asm.Min).apply(null,arguments)},ze=d._Minimum=function(){return(ze=d._Minimum=d.asm.Minimum).apply(null,arguments)},Tt=d._MirrorPad=function(){return(Tt=d._MirrorPad=d.asm.MirrorPad).apply(null,arguments)},is=d._Multiply=function(){return(is=d._Multiply=d.asm.Multiply).apply(null,arguments)},os=d._Neg=function(){return(os=d._Neg=d.asm.Neg).apply(null,arguments)},Fi=d._NonMaxSuppressionV3=function(){return(Fi=d._NonMaxSuppressionV3=d.asm.NonMaxSuppressionV3).apply(null,arguments)},Wr=d._NonMaxSuppressionV4=function(){return(Wr=d._NonMaxSuppressionV4=d.asm.NonMaxSuppressionV4).apply(null,arguments)},Of=d._NonMaxSuppressionV5=function(){return(Of=d._NonMaxSuppressionV5=d.asm.NonMaxSuppressionV5).apply(null,arguments)},an=d._NotEqual=function(){return(an=d._NotEqual=d.asm.NotEqual).apply(null,arguments)},tr=d._OneHot=function(){return(tr=d._OneHot=d.asm.OneHot).apply(null,arguments)},zc=d._PadV2=function(){return(zc=d._PadV2=d.asm.PadV2).apply(null,arguments)},rT=d._Pow=function(){return(rT=d._Pow=d.asm.Pow).apply(null,arguments)},aT=d._Prelu=function(){return(aT=d._Prelu=d.asm.Prelu).apply(null,arguments)},iT=d._Prod=function(){return(iT=d._Prod=d.asm.Prod).apply(null,arguments)},oT=d._RealDiv=function(){return(oT=d._RealDiv=d.asm.RealDiv).apply(null,arguments)},uT=d._Relu=function(){return(uT=d._Relu=d.asm.Relu).apply(null,arguments)},lT=d._Relu6=function(){return(lT=d._Relu6=d.asm.Relu6).apply(null,arguments)},cT=d._ResizeBilinear=function(){return(cT=d._ResizeBilinear=d.asm.ResizeBilinear).apply(null,arguments)},dT=d._Reverse=function(){return(dT=d._Reverse=d.asm.Reverse).apply(null,arguments)},pT=d._RotateWithOffset=function(){return(pT=d._RotateWithOffset=d.asm.RotateWithOffset).apply(null,arguments)},hT=d._Round=function(){return(hT=d._Round=d.asm.Round).apply(null,arguments)},fT=d._Rsqrt=function(){return(fT=d._Rsqrt=d.asm.Rsqrt).apply(null,arguments)},mT=d._ScatterNd=function(){return(mT=d._ScatterNd=d.asm.ScatterNd).apply(null,arguments)},gT=d._SelectV2=function(){return(gT=d._SelectV2=d.asm.SelectV2).apply(null,arguments)},bT=d._Sigmoid=function(){return(bT=d._Sigmoid=d.asm.Sigmoid).apply(null,arguments)},yT=d._Sin=function(){return(yT=d._Sin=d.asm.Sin).apply(null,arguments)},vT=d._Softmax=function(){return(vT=d._Softmax=d.asm.Softmax).apply(null,arguments)},xT=d._SparseFillEmptyRows=function(){return(xT=d._SparseFillEmptyRows=d.asm.SparseFillEmptyRows).apply(null,arguments)},wT=d._SparseReshape=function(){return(wT=d._SparseReshape=d.asm.SparseReshape).apply(null,arguments)},kT=d._SparseSegmentReduction=function(){return(kT=d._SparseSegmentReduction=d.asm.SparseSegmentReduction).apply(null,arguments)},ST=d._Sqrt=function(){return(ST=d._Sqrt=d.asm.Sqrt).apply(null,arguments)},IT=d._Square=function(){return(IT=d._Square=d.asm.Square).apply(null,arguments)},CT=d._SquaredDifference=function(){return(CT=d._SquaredDifference=d.asm.SquaredDifference).apply(null,arguments)},NT=d._Step=function(){return(NT=d._Step=d.asm.Step).apply(null,arguments)},TT=d._StridedSlice=function(){return(TT=d._StridedSlice=d.asm.StridedSlice).apply(null,arguments)},$T=d._Sub=function(){return($T=d._Sub=d.asm.Sub).apply(null,arguments)},_T=d._Sum=function(){return(_T=d._Sum=d.asm.Sum).apply(null,arguments)},AT=d._Tan=function(){return(AT=d._Tan=d.asm.Tan).apply(null,arguments)},ET=d._Tanh=function(){return(ET=d._Tanh=d.asm.Tanh).apply(null,arguments)},RT=d._Tile=function(){return(RT=d._Tile=d.asm.Tile).apply(null,arguments)},DT=d._TopK=function(){return(DT=d._TopK=d.asm.TopK).apply(null,arguments)},FT=d._Transform=function(){return(FT=d._Transform=d.asm.Transform).apply(null,arguments)},OT=d._Transpose=function(){return(OT=d._Transpose=d.asm.Transpose).apply(null,arguments)},PT=d.__FusedMatMul=function(){return(PT=d.__FusedMatMul=d.asm._FusedMatMul).apply(null,arguments)},Pf=d._malloc=function(){return(Pf=d._malloc=d.asm.malloc).apply(null,arguments)},Jv=d._free=function(){return(Jv=d._free=d.asm.free).apply(null,arguments)},zT=d._emscripten_tls_init=function(){return(zT=d._emscripten_tls_init=d.asm.emscripten_tls_init).apply(null,arguments)},ex=d.___errno_location=function(){return(ex=d.___errno_location=d.asm.__errno_location).apply(null,arguments)},Mc=d._pthread_self=function(){return(Mc=d._pthread_self=d.asm.pthread_self).apply(null,arguments)},tx=d._emscripten_main_thread_process_queued_calls=function(){return(tx=d._emscripten_main_thread_process_queued_calls=d.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},MT=d.__emscripten_thread_crashed=function(){return(MT=d.__emscripten_thread_crashed=d.asm._emscripten_thread_crashed).apply(null,arguments)},nx=d.__emscripten_thread_init=function(){return(nx=d.__emscripten_thread_init=d.asm._emscripten_thread_init).apply(null,arguments)},LT=d._emscripten_current_thread_process_queued_calls=function(){return(LT=d._emscripten_current_thread_process_queued_calls=d.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},BT=d._emscripten_main_browser_thread_id=function(){return(BT=d._emscripten_main_browser_thread_id=d.asm.emscripten_main_browser_thread_id).apply(null,arguments)},VT=d._emscripten_sync_run_in_main_thread_2=function(){return(VT=d._emscripten_sync_run_in_main_thread_2=d.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},sx=d._emscripten_sync_run_in_main_thread_4=function(){return(sx=d._emscripten_sync_run_in_main_thread_4=d.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},rx=d._emscripten_run_in_main_runtime_thread_js=function(){return(rx=d._emscripten_run_in_main_runtime_thread_js=d.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},zf=d._emscripten_dispatch_to_thread_=function(){return(zf=d._emscripten_dispatch_to_thread_=d.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},Mf=d.__emscripten_thread_free_data=function(){return(Mf=d.__emscripten_thread_free_data=d.asm._emscripten_thread_free_data).apply(null,arguments)},WT=d.__emscripten_thread_exit=function(){return(WT=d.__emscripten_thread_exit=d.asm._emscripten_thread_exit).apply(null,arguments)},UT=d._memalign=function(){return(UT=d._memalign=d.asm.memalign).apply(null,arguments)},ax=d._emscripten_stack_set_limits=function(){return(ax=d._emscripten_stack_set_limits=d.asm.emscripten_stack_set_limits).apply(null,arguments)},Lf=d.stackSave=function(){return(Lf=d.stackSave=d.asm.stackSave).apply(null,arguments)},Lc=d.stackRestore=function(){return(Lc=d.stackRestore=d.asm.stackRestore).apply(null,arguments)},Oi=d.stackAlloc=function(){return(Oi=d.stackAlloc=d.asm.stackAlloc).apply(null,arguments)},GT=d.dynCall_iijjiiii=function(){return(GT=d.dynCall_iijjiiii=d.asm.dynCall_iijjiiii).apply(null,arguments)},HT=d.dynCall_jiji=function(){return(HT=d.dynCall_jiji=d.asm.dynCall_jiji).apply(null,arguments)},ix=d.__emscripten_allow_main_runtime_queued_calls=21456;d.cwrap=en,d.keepRuntimeAlive=Mr,d.PThread=$e,d.PThread=$e,d.wasmMemory=Ce,d.ExitStatus=Cu;var Bc;function Cu(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}as=function N(){Bc||Bf(),Bc||(as=N)};function Bf(N){if(N=N||b,er>0)return;if($){h(d),bu(),postMessage({cmd:"loaded"});return}if(sn(),er>0)return;function D(){Bc||(Bc=!0,d.calledRun=!0,!at&&(bu(),h(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),ph()))}d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1),D()},1)):D()}d.run=Bf;function qT(N,D){if(Jt=N,!D&&$)throw Cc(N),"unwind";Mr()||dh(),jT(N)}function jT(N){Jt=N,Mr()||($e.terminateAllThreads(),d.onExit&&d.onExit(N),at=!0),v(N,new Cu(N))}if(d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();Bf();var Vc;m&&(Vc={uncaughtException:process.listeners("uncaughtException").filter(function(N){return!m.uncaughtException.indexOf(N)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(N){return!m.unhandledRejection.indexOf(N)>-1})});var Wc;if(typeof WasmBackendModule!="undefined")Wc=WasmBackendModule;else if(typeof r!="undefined")Wc=r;else throw new Error("Could not find wasm module in post.js");if(Vc){var KT=Wc._dispose;Wc._dispose=function(){KT(),Vc.uncaughtException.forEach(function(N){process.removeListener("uncaughtException",N)}),Vc.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)}}),b$=Mt({"src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var n=(()=>{var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};var a=typeof r!="undefined"?r:{},i,o;a.ready=new Promise(function(H,ee){i=H,o=ee});var u;typeof process!="undefined"&&process.listeners&&(u={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var l=Object.assign({},a),c=[],p="./this.program",d=(H,ee)=>{throw ee},h=typeof window=="object",f=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function b(H){return a.locateFile?a.locateFile(H,g):g+H}var y,v,x,k;function I(H){if(H instanceof Su)return;A("exiting due to exception: "+H)}var $,R,E;m?(f?g=gd().dirname(g)+"/":g=__dirname+"/",E=()=>{R||($=ug(),R=gd())},y=function(ee,ce){return E(),ee=R.normalize(ee),$.readFileSync(ee,ce?void 0:"utf8")},x=H=>{var ee=y(H,!0);return ee.buffer||(ee=new Uint8Array(ee)),ee},v=(H,ee,ce)=>{E(),H=R.normalize(H),$.readFile(H,function(Se,Qe){Se?ce(Se):ee(Qe.buffer)})},process.argv.length>1&&(p=process.argv[1].replace(/\\/g,"/")),c=process.argv.slice(2),process.on("uncaughtException",function(H){if(!(H instanceof Su))throw H}),process.on("unhandledRejection",function(H){throw H}),d=(H,ee)=>{if(gu())throw process.exitCode=H,ee;I(ee),process.exit(H)},a.inspect=function(){return"[Emscripten Module object]"}):(h||f)&&(f?g=self.location.href:typeof document!="undefined"&&document.currentScript&&(g=document.currentScript.src),s&&(g=s),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",y=H=>{var ee=new XMLHttpRequest;return ee.open("GET",H,!1),ee.send(null),ee.responseText},f&&(x=H=>{var ee=new XMLHttpRequest;return ee.open("GET",H,!1),ee.responseType="arraybuffer",ee.send(null),new Uint8Array(ee.response)}),v=(H,ee,ce)=>{var Se=new XMLHttpRequest;Se.open("GET",H,!0),Se.responseType="arraybuffer",Se.onload=()=>{if(Se.status==200||Se.status==0&&Se.response){ee(Se.response);return}ce()},Se.onerror=ce,Se.send(null)},k=H=>document.title=H);var P=a.print||console.log.bind(console),A=a.printErr||console.warn.bind(console);Object.assign(a,l),l=null,a.arguments&&(c=a.arguments),a.thisProgram&&(p=a.thisProgram),a.quit&&(d=a.quit);var O=4;function T(H){T.shown||(T.shown={}),T.shown[H]||(T.shown[H]=1,A(H))}function M(H,ee){if(typeof WebAssembly.Function=="function"){for(var ce={i:"i32",j:"i64",f:"f32",d:"f64"},Se={parameters:[],results:ee[0]=="v"?[]:[ce[ee[0]]]},Qe=1;Qe{Z=H},J;a.wasmBinary&&(J=a.wasmBinary);var se=a.noExitRuntime||!0;typeof WebAssembly!="object"&&zr("no native wasm support detected");var ne,oe=!1,ae;function de(H,ee){H||zr(ee)}function me(H){var ee=a["_"+H];return ee}function ke(H,ee,ce,Se,Qe){var Ze={string:function(an){var tr=0;if(an!=null&&an!==0){var zc=(an.length<<2)+1;tr=ku(zc),tt(an,tr,zc)}return tr},array:function(an){var tr=ku(an.length);return at(an,tr),tr}};function Le(an){return ee==="string"?Je(an):ee==="boolean"?Boolean(an):an}var ze=me(H),Tt=[],is=0;if(Se)for(var os=0;os=Se);)++Qe;if(Qe-ee>16&&H.subarray&&Pe)return Pe.decode(H.subarray(ee,Qe));for(var Ze="";ee>10,56320|is&1023)}}return Ze}function Je(H,ee){return H?Xe(en,H,ee):""}function Ye(H,ee,ce,Se){if(!(Se>0))return 0;for(var Qe=ce,Ze=ce+Se-1,Le=0;Le=55296&&ze<=57343){var Tt=H.charCodeAt(++Le);ze=65536+((ze&1023)<<10)|Tt&1023}if(ze<=127){if(ce>=Ze)break;ee[ce++]=ze}else if(ze<=2047){if(ce+1>=Ze)break;ee[ce++]=192|ze>>6,ee[ce++]=128|ze&63}else if(ze<=65535){if(ce+2>=Ze)break;ee[ce++]=224|ze>>12,ee[ce++]=128|ze>>6&63,ee[ce++]=128|ze&63}else{if(ce+3>=Ze)break;ee[ce++]=240|ze>>18,ee[ce++]=128|ze>>12&63,ee[ce++]=128|ze>>6&63,ee[ce++]=128|ze&63}}return ee[ce]=0,ce-Qe}function tt(H,ee,ce){return Ye(H,en,ee,ce)}function Ce(H){for(var ee=0,ce=0;ce=55296&&Se<=57343&&(Se=65536+((Se&1023)<<10)|H.charCodeAt(++ce)&1023),Se<=127?++ee:Se<=2047?ee+=2:Se<=65535?ee+=3:ee+=4}return ee}var ut=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function at(H,ee){Rt.set(H,ee)}function Jt(H,ee,ce){for(var Se=0;Se>0]=H.charCodeAt(Se);ce||(Rt[ee>>0]=0)}function Nt(H,ee){return H%ee>0&&(H+=ee-H%ee),H}var In,Rt,en,Cn,Nn,Yt,Dn,tn,zs;function Ms(H){In=H,a.HEAP8=Rt=new Int8Array(H),a.HEAP16=Cn=new Int16Array(H),a.HEAP32=Yt=new Int32Array(H),a.HEAPU8=en=new Uint8Array(H),a.HEAPU16=Nn=new Uint16Array(H),a.HEAPU32=Dn=new Uint32Array(H),a.HEAPF32=tn=new Float32Array(H),a.HEAPF64=zs=new Float64Array(H)}var Si=a.INITIAL_MEMORY||16777216,Zs,Ls=[],mu=[],Ii=[],nn=!1,lc=!1,cc=0;function gu(){return se||cc>0}function dc(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)fc(a.preRun.shift());yu(Ls)}function pc(){nn=!0,yu(mu)}function Vv(){lc=!0}function hc(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)mc(a.postRun.shift());yu(Ii)}function fc(H){Ls.unshift(H)}function rs(H){mu.unshift(H)}function mc(H){Ii.unshift(H)}var Fn=0,Ci=null,Js=null;function lh(H){Fn++,a.monitorRunDependencies&&a.monitorRunDependencies(Fn)}function gc(H){if(Fn--,a.monitorRunDependencies&&a.monitorRunDependencies(Fn),Fn==0&&(Ci!==null&&(clearInterval(Ci),Ci=null),Js)){var ee=Js;Js=null,ee()}}a.preloadedImages={},a.preloadedAudios={};function zr(H){a.onAbort&&a.onAbort(H),H="Aborted("+H+")",A(H),oe=!0,ae=1,H+=". Build with -s ASSERTIONS=1 for more info.";var ee=new WebAssembly.RuntimeError(H);throw o(ee),ee}var ch="data:application/octet-stream;base64,";function bc(H){return H.startsWith(ch)}function Mr(H){return H.startsWith("file://")}var sn;sn="tfjs-backend-wasm.wasm",bc(sn)||(sn=b(sn));function bu(H){try{if(H==sn&&J)return new Uint8Array(J);if(x)return x(H);throw"both async and sync fetching of the wasm failed"}catch(ee){zr(ee)}}function dh(){if(!J&&(h||f)){if(typeof fetch=="function"&&!Mr(sn))return fetch(sn,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+sn+"'";return H.arrayBuffer()}).catch(function(){return bu(sn)});if(v)return new Promise(function(H,ee){v(sn,function(ce){H(new Uint8Array(ce))},ee)})}return Promise.resolve().then(function(){return bu(sn)})}function ph(){var H={env:$i,wasi_snapshot_preview1:$i};function ee(Le,ze){var Tt=Le.exports;a.asm=Tt,ne=a.asm.memory,Ms(ne.buffer),Zs=a.asm.__indirect_function_table,rs(a.asm.__wasm_call_ctors),gc("wasm-instantiate")}lh("wasm-instantiate");function ce(Le){ee(Le.instance)}function Se(Le){return dh().then(function(ze){return WebAssembly.instantiate(ze,H)}).then(function(ze){return ze}).then(Le,function(ze){A("failed to asynchronously prepare wasm: "+ze),zr(ze)})}function Qe(){return!J&&typeof WebAssembly.instantiateStreaming=="function"&&!bc(sn)&&!Mr(sn)&&typeof fetch=="function"?fetch(sn,{credentials:"same-origin"}).then(function(Le){var ze=WebAssembly.instantiateStreaming(Le,H);return ze.then(ce,function(Tt){return A("wasm streaming compile failed: "+Tt),A("falling back to ArrayBuffer instantiation"),Se(ce)})}):Se(ce)}if(a.instantiateWasm)try{var Ze=a.instantiateWasm(H,ee);return Ze}catch(Le){return A("Module.instantiateWasm callback failed with error: "+Le),!1}return Qe().catch(o),{}}var Wv,Uv;function yu(H){for(;H.length>0;){var ee=H.shift();if(typeof ee=="function"){ee(a);continue}var ce=ee.func;typeof ce=="number"?ee.arg===void 0?vu(ce)():vu(ce)(ee.arg):ce(ee.arg===void 0?null:ee.arg)}}function er(H){return H}function yc(H){var ee=/\b_Z[\w\d_]+/g;return H.replace(ee,function(ce){var Se=ce;return ce===Se?ce:Se+" ["+ce+"]"})}var as=[];function vu(H){var ee=as[H];return ee||(H>=as.length&&(as.length=H+1),as[H]=ee=Zs.get(H)),ee}function Gv(){var H=new Error;if(!H.stack){try{throw new Error}catch(ee){H=ee}if(!H.stack)return"(no stack trace available)"}return H.stack.toString()}function Ni(H,ee){Zs.set(H,ee),as[H]=ee}function hh(){zr("")}function vc(H,ee,ce){en.copyWithin(H,ee,ee+ce)}function xc(){return 2147483648}function rn(H){try{return ne.grow(H-In.byteLength+65535>>>16),Ms(ne.buffer),1}catch(ee){}}function wc(H){var ee=en.length;H=H>>>0;var ce=xc();if(H>ce)return!1;for(var Se=1;Se<=4;Se*=2){var Qe=ee*(1+.2/Se);Qe=Math.min(Qe,H+100663296);var Ze=Math.min(ce,Nt(Math.max(H,Qe),65536)),Le=rn(Ze);if(Le)return!0}return!1}var Ti={mappings:{},buffers:[null,[],[]],printChar:function(H,ee){var ce=Ti.buffers[H];ee===0||ee===10?((H===1?P:A)(Xe(ce,0)),ce.length=0):ce.push(ee)},varargs:void 0,get:function(){Ti.varargs+=4;var H=Yt[Ti.varargs-4>>2];return H},getStr:function(H){var ee=Je(H);return ee},get64:function(H,ee){return H}};function fh(H){return 0}function Hv(H,ee,ce,Se,Qe){}function qv(H,ee,ce,Se){for(var Qe=0,Ze=0;Ze>2],ze=Yt[ee+4>>2];ee+=8;for(var Tt=0;Tt>2]=Qe,0}function mh(H){te(H)}var kc=!1,$i={abort:hh,emscripten_memcpy_big:vc,emscripten_resize_heap:wc,fd_close:fh,fd_seek:Hv,fd_write:qv,setTempRet0:mh},sT=ph(),jv=a.___wasm_call_ctors=function(){return(jv=a.___wasm_call_ctors=a.asm.__wasm_call_ctors).apply(null,arguments)},gh=a._init=function(){return(gh=a._init=a.asm.init).apply(null,arguments)},bh=a._init_with_threads_count=function(){return(bh=a._init_with_threads_count=a.asm.init_with_threads_count).apply(null,arguments)},Sc=a._get_threads_count=function(){return(Sc=a._get_threads_count=a.asm.get_threads_count).apply(null,arguments)},Ic=a._register_tensor=function(){return(Ic=a._register_tensor=a.asm.register_tensor).apply(null,arguments)},yh=a._dispose_data=function(){return(yh=a._dispose_data=a.asm.dispose_data).apply(null,arguments)},$e=a._dispose=function(){return($e=a._dispose=a.asm.dispose).apply(null,arguments)},vh=a._Abs=function(){return(vh=a._Abs=a.asm.Abs).apply(null,arguments)},Cc=a._Add=function(){return(Cc=a._Add=a.asm.Add).apply(null,arguments)},Lr=a._AddN=function(){return(Lr=a._AddN=a.asm.AddN).apply(null,arguments)},_i=a._All=function(){return(_i=a._All=a.asm.All).apply(null,arguments)},xh=a._Any=function(){return(xh=a._Any=a.asm.Any).apply(null,arguments)},Kv=a._ArgMax=function(){return(Kv=a._ArgMax=a.asm.ArgMax).apply(null,arguments)},wh=a._AvgPool=function(){return(wh=a._AvgPool=a.asm.AvgPool).apply(null,arguments)},Xv=a._BatchMatMul=function(){return(Xv=a._BatchMatMul=a.asm.BatchMatMul).apply(null,arguments)},Br=a._Ceil=function(){return(Br=a._Ceil=a.asm.Ceil).apply(null,arguments)},kh=a._ClipByValue=function(){return(kh=a._ClipByValue=a.asm.ClipByValue).apply(null,arguments)},Sh=a._Conv2D=function(){return(Sh=a._Conv2D=a.asm.Conv2D).apply(null,arguments)},Ih=a._Conv2DBackpropInput=function(){return(Ih=a._Conv2DBackpropInput=a.asm.Conv2DBackpropInput).apply(null,arguments)},Ch=a._Cos=function(){return(Ch=a._Cos=a.asm.Cos).apply(null,arguments)},Nh=a._Cosh=function(){return(Nh=a._Cosh=a.asm.Cosh).apply(null,arguments)},Th=a._CropAndResize=function(){return(Th=a._CropAndResize=a.asm.CropAndResize).apply(null,arguments)},Nc=a._Cumprod=function(){return(Nc=a._Cumprod=a.asm.Cumprod).apply(null,arguments)},$h=a._Cumsum=function(){return($h=a._Cumsum=a.asm.Cumsum).apply(null,arguments)},_h=a._DepthToSpace=function(){return(_h=a._DepthToSpace=a.asm.DepthToSpace).apply(null,arguments)},Ah=a._DepthwiseConv2dNative=function(){return(Ah=a._DepthwiseConv2dNative=a.asm.DepthwiseConv2dNative).apply(null,arguments)},Eh=a._Elu=function(){return(Eh=a._Elu=a.asm.Elu).apply(null,arguments)},Rh=a._Equal=function(){return(Rh=a._Equal=a.asm.Equal).apply(null,arguments)},Tc=a._Exp=function(){return(Tc=a._Exp=a.asm.Exp).apply(null,arguments)},Dh=a._FlipLeftRight=function(){return(Dh=a._FlipLeftRight=a.asm.FlipLeftRight).apply(null,arguments)},Fh=a._Floor=function(){return(Fh=a._Floor=a.asm.Floor).apply(null,arguments)},Vr=a._FloorDiv=function(){return(Vr=a._FloorDiv=a.asm.FloorDiv).apply(null,arguments)},xu=a._FusedBatchNorm=function(){return(xu=a._FusedBatchNorm=a.asm.FusedBatchNorm).apply(null,arguments)},Oh=a._FusedConv2D=function(){return(Oh=a._FusedConv2D=a.asm.FusedConv2D).apply(null,arguments)},Ph=a._FusedDepthwiseConv2D=function(){return(Ph=a._FusedDepthwiseConv2D=a.asm.FusedDepthwiseConv2D).apply(null,arguments)},zh=a._Gather=function(){return(zh=a._Gather=a.asm.Gather).apply(null,arguments)},Me=a._GatherNd=function(){return(Me=a._GatherNd=a.asm.GatherNd).apply(null,arguments)},Mh=a._Greater=function(){return(Mh=a._Greater=a.asm.Greater).apply(null,arguments)},Lh=a._GreaterEqual=function(){return(Lh=a._GreaterEqual=a.asm.GreaterEqual).apply(null,arguments)},Bh=a._LeakyRelu=function(){return(Bh=a._LeakyRelu=a.asm.LeakyRelu).apply(null,arguments)},Vh=a._Less=function(){return(Vh=a._Less=a.asm.Less).apply(null,arguments)},Wh=a._LessEqual=function(){return(Wh=a._LessEqual=a.asm.LessEqual).apply(null,arguments)},Uh=a._Log=function(){return(Uh=a._Log=a.asm.Log).apply(null,arguments)},wu=a._LogicalAnd=function(){return(wu=a._LogicalAnd=a.asm.LogicalAnd).apply(null,arguments)},$c=a._Max=function(){return($c=a._Max=a.asm.Max).apply(null,arguments)},_c=a._MaxPool=function(){return(_c=a._MaxPool=a.asm.MaxPool).apply(null,arguments)},Gh=a._Maximum=function(){return(Gh=a._Maximum=a.asm.Maximum).apply(null,arguments)},Hh=a._Mean=function(){return(Hh=a._Mean=a.asm.Mean).apply(null,arguments)},qh=a._Min=function(){return(qh=a._Min=a.asm.Min).apply(null,arguments)},jh=a._Minimum=function(){return(jh=a._Minimum=a.asm.Minimum).apply(null,arguments)},Kh=a._MirrorPad=function(){return(Kh=a._MirrorPad=a.asm.MirrorPad).apply(null,arguments)},Xh=a._Multiply=function(){return(Xh=a._Multiply=a.asm.Multiply).apply(null,arguments)},gt=a._Neg=function(){return(gt=a._Neg=a.asm.Neg).apply(null,arguments)},Yh=a._NonMaxSuppressionV3=function(){return(Yh=a._NonMaxSuppressionV3=a.asm.NonMaxSuppressionV3).apply(null,arguments)},Qh=a._NonMaxSuppressionV4=function(){return(Qh=a._NonMaxSuppressionV4=a.asm.NonMaxSuppressionV4).apply(null,arguments)},Zh=a._NonMaxSuppressionV5=function(){return(Zh=a._NonMaxSuppressionV5=a.asm.NonMaxSuppressionV5).apply(null,arguments)},Ai=a._NotEqual=function(){return(Ai=a._NotEqual=a.asm.NotEqual).apply(null,arguments)},Ac=a._OneHot=function(){return(Ac=a._OneHot=a.asm.OneHot).apply(null,arguments)},Ec=a._PadV2=function(){return(Ec=a._PadV2=a.asm.PadV2).apply(null,arguments)},Rc=a._Pow=function(){return(Rc=a._Pow=a.asm.Pow).apply(null,arguments)},Jh=a._Prelu=function(){return(Jh=a._Prelu=a.asm.Prelu).apply(null,arguments)},Dc=a._Prod=function(){return(Dc=a._Prod=a.asm.Prod).apply(null,arguments)},ef=a._RealDiv=function(){return(ef=a._RealDiv=a.asm.RealDiv).apply(null,arguments)},Yv=a._Relu=function(){return(Yv=a._Relu=a.asm.Relu).apply(null,arguments)},Fc=a._Relu6=function(){return(Fc=a._Relu6=a.asm.Relu6).apply(null,arguments)},Qv=a._ResizeBilinear=function(){return(Qv=a._ResizeBilinear=a.asm.ResizeBilinear).apply(null,arguments)},tf=a._Reverse=function(){return(tf=a._Reverse=a.asm.Reverse).apply(null,arguments)},nf=a._RotateWithOffset=function(){return(nf=a._RotateWithOffset=a.asm.RotateWithOffset).apply(null,arguments)},sf=a._Round=function(){return(sf=a._Round=a.asm.Round).apply(null,arguments)},rf=a._Rsqrt=function(){return(rf=a._Rsqrt=a.asm.Rsqrt).apply(null,arguments)},af=a._ScatterNd=function(){return(af=a._ScatterNd=a.asm.ScatterNd).apply(null,arguments)},of=a._SelectV2=function(){return(of=a._SelectV2=a.asm.SelectV2).apply(null,arguments)},uf=a._Sigmoid=function(){return(uf=a._Sigmoid=a.asm.Sigmoid).apply(null,arguments)},lf=a._Sin=function(){return(lf=a._Sin=a.asm.Sin).apply(null,arguments)},cf=a._Softmax=function(){return(cf=a._Softmax=a.asm.Softmax).apply(null,arguments)},df=a._SparseFillEmptyRows=function(){return(df=a._SparseFillEmptyRows=a.asm.SparseFillEmptyRows).apply(null,arguments)},pf=a._SparseReshape=function(){return(pf=a._SparseReshape=a.asm.SparseReshape).apply(null,arguments)},hf=a._SparseSegmentReduction=function(){return(hf=a._SparseSegmentReduction=a.asm.SparseSegmentReduction).apply(null,arguments)},ff=a._Sqrt=function(){return(ff=a._Sqrt=a.asm.Sqrt).apply(null,arguments)},mf=a._Square=function(){return(mf=a._Square=a.asm.Square).apply(null,arguments)},gf=a._SquaredDifference=function(){return(gf=a._SquaredDifference=a.asm.SquaredDifference).apply(null,arguments)},bf=a._Step=function(){return(bf=a._Step=a.asm.Step).apply(null,arguments)},yf=a._StridedSlice=function(){return(yf=a._StridedSlice=a.asm.StridedSlice).apply(null,arguments)},vf=a._Sub=function(){return(vf=a._Sub=a.asm.Sub).apply(null,arguments)},xf=a._Sum=function(){return(xf=a._Sum=a.asm.Sum).apply(null,arguments)},wf=a._Tan=function(){return(wf=a._Tan=a.asm.Tan).apply(null,arguments)},kf=a._Tanh=function(){return(kf=a._Tanh=a.asm.Tanh).apply(null,arguments)},Sf=a._Tile=function(){return(Sf=a._Tile=a.asm.Tile).apply(null,arguments)},If=a._TopK=function(){return(If=a._TopK=a.asm.TopK).apply(null,arguments)},Cf=a._Transform=function(){return(Cf=a._Transform=a.asm.Transform).apply(null,arguments)},Nf=a._Transpose=function(){return(Nf=a._Transpose=a.asm.Transpose).apply(null,arguments)},Tf=a.__FusedMatMul=function(){return(Tf=a.__FusedMatMul=a.asm._FusedMatMul).apply(null,arguments)},$f=a._malloc=function(){return($f=a._malloc=a.asm.malloc).apply(null,arguments)},_f=a._free=function(){return(_f=a._free=a.asm.free).apply(null,arguments)},Af=a.___errno_location=function(){return(Af=a.___errno_location=a.asm.__errno_location).apply(null,arguments)},Ef=a._emscripten_main_thread_process_queued_calls=function(){return(Ef=a._emscripten_main_thread_process_queued_calls=a.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Oc=a.stackSave=function(){return(Oc=a.stackSave=a.asm.stackSave).apply(null,arguments)},Pc=a.stackRestore=function(){return(Pc=a.stackRestore=a.asm.stackRestore).apply(null,arguments)},ku=a.stackAlloc=function(){return(ku=a.stackAlloc=a.asm.stackAlloc).apply(null,arguments)},Rf=a.dynCall_iijjiiii=function(){return(Rf=a.dynCall_iijjiiii=a.asm.dynCall_iijjiiii).apply(null,arguments)},Df=a.dynCall_jiji=function(){return(Df=a.dynCall_jiji=a.asm.dynCall_jiji).apply(null,arguments)};a.cwrap=Ie;var Ei;function Su(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}Js=function H(){Ei||Iu(),Ei||(Js=H)};function Iu(H){if(H=H||c,Fn>0||(dc(),Fn>0))return;function ee(){Ei||(Ei=!0,a.calledRun=!0,!oe&&(pc(),i(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),hc()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),ee()},1)):ee()}a.run=Iu;function Zv(H){ae=H,gu()||(a.onExit&&a.onExit(H),oe=!0),d(H,new Su(H))}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();Iu();var Ri;u&&(Ri={uncaughtException:process.listeners("uncaughtException").filter(function(H){return!u.uncaughtException.indexOf(H)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(H){return!u.unhandledRejection.indexOf(H)>-1})});var Di;if(typeof r!="undefined")Di=r;else if(typeof WasmBackendModuleThreadedSimd!="undefined")Di=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(Ri){var Ff=Di._dispose;Di._dispose=function(){Ff(),Ri.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),Ri.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}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)}}),y$=1e-7,v$=1e-4,Yd=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}},ol=class{refCount(e){return On("refCount")}incRef(e){return On("incRef")}timerAvailable(){return!0}time(e){return On("time")}read(e){return On("read")}readSync(e){return On("readSync")}readToGPU(e,t){return On("readToGPU")}numDataIds(){return On("numDataIds")}disposeData(e,t){return On("disposeData")}write(e,t,n){return On("write")}move(e,t,n,s,r){return On("move")}memory(){return On("memory")}floatPrecision(){return On("floatPrecision")}epsilon(){return this.floatPrecision()===32?y$:v$}dispose(){return On("dispose")}};function On(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 Jw(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,bd(e,t,n)}function x$(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,s=0;for(;n>0;)s=Math.random()*n|0,n--,bd(e,n,s),bd(t,n,s)}function Gu(e,t,n){return Math.max(e,Math.min(t,n))}function w$(e){return e%2===0?e:e+1}function bd(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function k$(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function ka(e){F(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function aa(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||Qt(e)&&!n)for(let s=0;s0,n){return new Promise((s,r)=>{let a=0,i=()=>{if(e()){s();return}a++;let o=t(a);if(n!=null&&a>=n){r();return}setTimeout(i,o)};i()})}function A$(e,t){let n=1,s=-1;for(let a=0;a=0)n*=e[a];else if(e[a]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`);s=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(s===-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[s]=t/n,r}function ts(e,t){let n=t.length;return e=e==null?t.map((s,r)=>r):[].concat(e),F(e.every(s=>s>=-n&&s`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),F(e.every(s=>Zi(s)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(s=>s<0?n+s:s)}function ek(e,t){let n=[],s=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:ts(t,e).sort(),i=0;for(let o=0;oo)&&e[o]===1&&(n.push(e[o]),s.push(o)),a[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),s.push(o))}return{newShape:n,keptDims:s}}function tk(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 nk(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 sk(e,t){for(let n=0;nt+=n.length),t}function ar(e){return typeof e=="string"||e instanceof String}function ik(e){return typeof e=="boolean"}function ok(e){return typeof e=="number"}function Qd(e){return Array.isArray(e)?Qd(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":ok(e)?"float32":ar(e)?"string":ik(e)?"bool":"float32"}function hr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function yd(e,t){for(let n=t;n=0;--s)n[s]=n[s+1]*e[s+1];return n}function uk(e,t,n,s=!1){let r=new Array;if(t.length===1){let a=t[0]*(s?2:1);for(let i=0;iu*l)*(s?2:1);for(let u=0;ur*a)*(n?2:1);if(s===0)return[];if(s!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return uk(0,e,t,n)}function lg(e,t){let n=Zd(e,t);for(let s=0;ss*r,1);if(t==null||t==="float32")return ji(e,new Float32Array(n));if(t==="int32")return ji(e,new Int32Array(n));if(t==="bool")return ji(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function cg(e){e.forEach(t=>{F(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function D$(e,t,n){if(t===0)return 0;if(t===1)return e[0];let s=e[e.length-1];for(let r=0;r{let[s,r]=n.split(":");this.urlFlags[s]=M$(s,r)})}};function P$(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(z$(t,s[0],s[1]),s.join("="))),t}function z$(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function M$(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 K(){return lk}var lk=null;function L$(e){lk=e}var Vf;function ck(){if(Vf==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");Vf=e}return Vf}function B$(){let e=ck();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function pg(e,t){let n=B$();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var lo="Abs",ul="Acos",ll="Acosh",Ir="Add",Sa="AddN",cl="All",dl="Any",Ia="ArgMax",pl="ArgMin",hl="Asin",fl="Asinh",ml="Atan",gl="Atanh",bl="Atan2",Ca="AvgPool",hg="AvgPoolGrad",Jd="AvgPool3D",fg="AvgPool3DGrad",Na="BatchMatMul",co="BatchToSpaceND",mg="Bincount",V$="BroadcastTo",gg="BroadcastArgs",Ta="Cast",$a="Ceil",Cr="ClipByValue",ep="Complex",tp="ComplexAbs",po="Concat",_a="Conv2D",bg="Conv2DBackpropFilter",Aa="Conv2DBackpropInput",np="Conv3D",yg="Conv3DBackpropFilterV2",vg="Conv3DBackpropInputV2",Ea="Cos",Ra="Cosh",ho="Cumprod",Da="Cumsum",fo="CropAndResize",xg="DenseBincount",mo="DepthToSpace",Fa="DepthwiseConv2dNative",wg="DepthwiseConv2dNativeBackpropFilter",kg="DepthwiseConv2dNativeBackpropInput",Sg="Diag",sp="Dilation2D",sm="Dilation2DBackpropInput",rm="Dilation2DBackpropFilter",Oa="RealDiv",rp="Einsum",Pa="Elu",Ig="EluGrad",yl="Erf",go="Equal",za="Exp",bo="ExpandDims",yo="Expm1",Cg="FFT",vl="Fill",vo="FlipLeftRight",Ma="Floor",La="FloorDiv",Ba="FusedBatchNorm",xo="GatherV2",wo="GatherNd",ko="Greater",Va="GreaterEqual",Wa="Identity",Ng="IFFT",ap="Imag",xl="IsFinite",wl="IsInf",kl="IsNan",Ua="LeakyRelu",So="Less",Io="LessEqual",Tg="LinSpace",Ga="Log",Sl="Log1p",Co="LogicalAnd",Il="LogicalNot",ip="LogicalOr",W$="LogSoftmax",dpe="LowerBound",op="LRN",$g="LRNGrad",Ha="Max",qa="Maximum",ja="MaxPool",_g="MaxPoolGrad",up="MaxPool3D",Ag="MaxPool3DGrad",Eg="MaxPoolWithArgmax",Ka="Mean",Xa="Min",Ya="Minimum",Qa="MirrorPad",Cl="Mod",Rg="Multinomial",Za="Multiply",No="Neg",To="NotEqual",$o="NonMaxSuppressionV3",Nl="NonMaxSuppressionV4",_o="NonMaxSuppressionV5",Ao="OnesLike",Eo="OneHot",Ro="Pack",Ja="PadV2",ppe="Pool",ei="Pow",ti="Prelu",ni="Prod",Tl="Range",lp="Real",$l="Reciprocal",si="Relu",Do="Reshape",_l="ResizeNearestNeighbor",Dg="ResizeNearestNeighborGrad",ri="ResizeBilinear",Fg="ResizeBilinearGrad",ai="Relu6",Fo="Reverse",Oo="Round",ii="Rsqrt",Po="ScatterNd",Og="SearchSorted",zo="Select",Al="Selu",Mo="Slice",oi="Sin",Lo="Sinh",El="Sign",ui="Sigmoid",Rl="Softplus",li="Sqrt",ci="Sum",Bo="SpaceToBatchND",Vo="SplitV",di="Softmax",cp="SparseFillEmptyRows",Dl="SparseReshape",dp="SparseSegmentMean",pp="SparseSegmentSum",hp="SparseToDense",pi="SquaredDifference",Fl="Square",Wo="StridedSlice",fp="StringNGrams",Pg="StringSplit",zg="StringToHashBucketFast",hi="Sub",Uo="Tan",fi="Tanh",Nr="Tile",Go="TopK",Ho="Transform",Hs="Transpose",Mg="Unique",qo="Unpack",mp="UnsortedSegmentSum",hpe="UpperBound",jo="ZerosLike",mi="Step",vd="FromPixels",Ko="RotateWithOffset",ia="_FusedMatMul",oa="FusedConv2D",ua="FusedDepthwiseConv2D";function rr(...e){K().getBool("IS_TEST")||K().getBool("PROD")||console.warn(...e)}function U$(...e){K().getBool("IS_TEST")||K().getBool("PROD")||console.log(...e)}var Ji=pg("kernelRegistry",()=>new Map),Hu=pg("gradRegistry",()=>new Map);function am(e,t){let n=Lg(e,t);return Ji.get(n)}function lx(e){return Hu.get(e)}function im(e){let t=Ji.entries(),n=[];for(;;){let{done:s,value:r}=t.next();if(s)break;let[a,i]=r,[o]=a.split("_");o===e&&n.push(i)}return n}function Ol(e){let{kernelName:t,backendName:n}=e,s=Lg(t,n);Ji.has(s)&&rr(`The kernel '${t}' for backend '${n}' is already registered`),Ji.set(s,e)}function G$(e){let{kernelName:t}=e;Hu.has(t)&&K().getBool("DEBUG")&&rr(`Overriding the gradient for '${t}'`),Hu.set(t,e)}function fpe(e,t){let n=Lg(e,t);if(!Ji.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Ji.delete(n)}function mpe(e){if(!Hu.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Hu.delete(e)}function gpe(e,t){im(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});Ol(r)})}function Lg(e,t){return`${t}_${e}`}var w={};Ee(w,{arraysEqual:()=>Sr,assert:()=>F,assertNonNegativeIntegerDimensions:()=>cg,assertNonNull:()=>ka,assertShapesMatch:()=>pn,bytesFromStringArray:()=>ak,bytesPerElement:()=>nm,checkConversionForErrors:()=>sk,clamp:()=>Gu,computeStrides:()=>uo,createScalarValue:()=>Y$,createShuffledIndices:()=>$$,decodeString:()=>xd,distSquared:()=>I$,encodeString:()=>zl,fetch:()=>Z$,fingerPrint64:()=>X$,flatten:()=>aa,getArrayFromDType:()=>nk,getTypedArrayFromDType:()=>tk,hasEncodingLoss:()=>E$,hexToLong:()=>Pl,indexToLoc:()=>F$,inferDtype:()=>Qd,inferFromImplicitShape:()=>A$,isBoolean:()=>ik,isFunction:()=>hr,isInt:()=>Zi,isNumber:()=>ok,isPromise:()=>dg,isScalarShape:()=>C$,isString:()=>ar,isTypedArray:()=>Qt,isValidDtype:()=>rk,locToIndex:()=>D$,makeOnesTypedArray:()=>lg,makeZerosNestedTypedArray:()=>R$,makeZerosTypedArray:()=>Zd,nearestDivisor:()=>yd,nearestLargerEven:()=>w$,now:()=>qu,parseAxisParam:()=>ts,randUniform:()=>S$,repeatedTry:()=>_$,rightPad:()=>Bu,shuffle:()=>Jw,shuffleCombo:()=>x$,sizeFromShape:()=>dt,sizeToSquarishShape:()=>T$,squeezeShape:()=>ek,sum:()=>k$,swap:()=>bd,tanh:()=>N$,toNestedArray:()=>ji,toTypedArray:()=>gp});var cx=wa(n$()),Kr=cx.default||cx;function Pl(e){return Kr.fromString(e,!0,16)}var dk=Pl("c3a5c85c97cb3127"),qr=Pl("b492b66fbe98f273"),on=Pl("9ae16a3b2f90404f");function om(e){return e.xor(e.shru(47))}function pk(e,t,n){let s=e.slice(t,t+n);return Kr.fromBytes(Array.from(s),!0,!0)}function lt(e,t){return pk(e,t,8)}function dx(e,t){return pk(e,t,4)}function Bt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function or(e,t,n=Pl("9ddfea08eb382d69")){let s=e.xor(t).mul(n);s=s.xor(s.shru(47));let r=t.xor(s).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function H$(e,t,n,s,r,a){r=r.add(e),a=Bt(a.add(r).add(s),21);let i=r;return r=r.add(t),r=r.add(n),a=a.add(Bt(r,44)),[r.add(s),a.add(i)]}function Gc(e,t,n,s){return H$(lt(e,t),lt(e,t+8),lt(e,t+16),lt(e,t+24),n,s)}function q$(e,t=e.length){if(t>=8){let n=on.add(t*2),s=lt(e,0).add(on),r=lt(e,t-8),a=Bt(r,37).mul(n).add(s),i=Bt(s,25).add(r).mul(n);return or(a,i,n)}if(t>=4){let n=on.add(t*2),s=dx(e,0);return or(s.shl(3).add(t),dx(e,t-4),n)}if(t>0){let n=e[0],s=e[t>>1],r=e[t-1],a=n+(s<<8),i=t+(r<<2);return om(on.mul(a).xor(dk.mul(i))).mul(on)}return on}function j$(e,t=e.length){let n=on.add(t*2),s=lt(e,0).mul(qr),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(on);return or(Bt(s.add(r),43).add(Bt(a,30)).add(i),s.add(Bt(r.add(on),18)).add(a),n)}function K$(e,t=e.length){let n=on.add(t*2),s=lt(e,0).mul(on),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(on),o=Bt(s.add(r),43).add(Bt(a,30)).add(i),u=or(o,s.add(Bt(r.add(on),18)).add(a),n),l=lt(e,16).mul(n),c=lt(e,24),p=o.add(lt(e,t-32)).mul(n),d=u.add(lt(e,t-24)).mul(n);return or(Bt(l.add(c),43).add(Bt(p,30)).add(d),l.add(Bt(c.add(s),18)).add(p),n)}function X$(e,t=e.length){let n=Kr.fromNumber(81,!0);if(t<=32)return t<=16?q$(e,t):j$(e,t);if(t<=64)return K$(e,t);let s=n,r=n.mul(qr).add(113),a=om(r.mul(on).add(113)).mul(on),i=[Kr.UZERO,Kr.UZERO],o=[Kr.UZERO,Kr.UZERO];s=s.mul(on).add(lt(e,0));let u=0,l=(t-1>>6)*64,c=l+(t-1&63)-63;do s=Bt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(qr),r=Bt(r.add(i[1]).add(lt(e,u+48)),42).mul(qr),s=s.xor(o[1]),r=r.add(i[0]).add(lt(e,u+40)),a=Bt(a.add(o[0]),33).mul(qr),i=Gc(e,u,i[1].mul(qr),s.add(o[0])),o=Gc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],u+=64;while(u!==l);let p=qr.add(a.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),s=Bt(s.add(r).add(i[0]).add(lt(e,u+8)),37).mul(p),r=Bt(r.add(i[1]).add(lt(e,u+48)),42).mul(p),s=s.xor(o[1].mul(9)),r=r.add(i[0].mul(9).add(lt(e,u+40))),a=Bt(a.add(o[0]),33).mul(p),i=Gc(e,u,i[1].mul(p),s.add(o[0])),o=Gc(e,u+32,a.add(o[1]),r.add(lt(e,u+16))),[a,s]=[s,a],or(or(i[0],o[0],p).add(om(r).mul(dk)).add(a),or(i[1],o[1],p).add(s),p)}function Y$(e,t){return t==="string"?zl(e):gp([e],t)}function Q$(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function gp(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=aa(e)),K().getBool("DEBUG")&&sk(e,t),Q$(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 s=0;s{s=n()},a,i=qu();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let u of s)u.dataSync();a=Promise.resolve({kernelMs:qu()-i})}if(K().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let u=0;u{e_(c,l.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:a.then(u=>u.kernelMs),extraInfo:a.then(u=>u.getExtraProfileInfo!=null?u.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:s,inputs:r,extraInfo:a}=e;n.forEach(i=>{Promise.all([i.data(),s,a]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function e_(e,t,n){if(t!=="float32")return!1;for(let s=0;s0?f:""} `}}console.log(`%c${o} %c${i} %c${u}D ${c} %c${l} %c${p} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function n_(e,t,n){let s={},r={};for(let u=0;us[m.id]=!0),h=!0,r[l.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let i={};for(let u=e.length-1;u>=0;u--){let l=e[u],c=l.inputs;for(let p=0;p=0;r--){let a=t[r],i=[];if(a.outputs.forEach(u=>{let l=e[u.id];l!=null?i.push(l):i.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let o=a.gradient(i);for(let u in a.inputs){if(!(u in o))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`);let l=n(()=>o[u]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);let c=a.inputs[u];if(!Sr(l.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=l;else{let p=e[c.id];e[c.id]=s(p,l),p.dispose()}}}}var px=20,Tu=3,Wf=7;function r_(e,t,n,s){let r=uo(t),a=a_(e,t,n,r),i=t.length,o=rd(e,t,n,r,a),u=["Tensor"];return s&&(u.push(` dtype: ${n}`),u.push(` rank: ${i}`),u.push(` shape: [${t}]`),u.push(" values:")),u.push(o.map(l=>" "+l).join(` `)),u.join(` `)}function a_(e,t,n,s){let r=dt(t),a=s[s.length-1],i=new Array(a).fill(0),o=t.length,u=n==="complex64"?Ru(e):e;if(o>1)for(let l=0;lpx){let g=Tu*i,b=Array.from(e.slice(0,g)),y=Array.from(e.slice((o-Tu)*i,o*i));return n==="complex64"&&(b=Ru(b),y=Ru(y)),["["+b.map((v,x)=>Eu(v,r[x],n)).join(", ")+", ..., "+y.map((v,x)=>Eu(v,r[o-Tu+x],n)).join(", ")+"]"]}let m=n==="complex64"?Ru(e):Array.from(e);return["["+m.map((g,b)=>Eu(g,r[b],n)).join(", ")+"]"]}let l=t.slice(1),c=s.slice(1),p=s[0]*i,d=[];if(o>px){for(let m=0;m`Length of values '${s}' 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||nk(t,this.size),this.strides=uo(e)}set(e,...t){t.length===0&&(t=[0]),F(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 s of e){if(s<0||s>=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 s=0;sxd(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(),cs().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=cs().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>xd(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 cs().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(cs().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Ui.print(this,e)}clone(){return this.throwIfDisposed(),Ui.clone(this)}toString(e=!1){let t=this.dataSync();return r_(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Ui.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),cs().makeVariable(this,e,t,n)}};Object.defineProperty(et,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function c_(){return pg("Tensor",()=>et)}c_();var wd=class extends et{constructor(e,t,n,s){super(e.shape,e.dtype,e.dataId,s),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(!Sr(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);cs().disposeTensor(this),this.dataId=e.dataId,cs().incRef(this,null)}dispose(){cs().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(wd,Symbol.hasInstance,{value:e=>e instanceof et&&e.assign!=null&&e.assign instanceof Function});var _s={};Ee(_s,{assertTypesMatch:()=>yk,getTensorsInContainer:()=>Bg,isTensorInList:()=>h_,makeTypesMatch:()=>xt});var d_=(e=>(e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6",e))(d_||{}),fk=(e=>(e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64",e))(fk||{}),mk=(e=>(e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64",e))(mk||{}),gk=(e=>(e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64",e))(gk||{}),bk=(e=>(e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64",e))(bk||{}),p_={float32:gk,int32:fk,bool:mk,complex64:bk};function cn(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return p_[e][t]}function bp(e){return cn(e,"int32")}function xt(e,t){if(e.dtype===t.dtype)return[e,t];let n=cn(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function yk(e,t){F(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function h_(e,t){return t.some(n=>n.id===e.id)}function Bg(e){let t=[];return vk(e,t,new Set),t}function vk(e,t,n){if(e==null)return;if(e instanceof et){t.push(e);return}if(!f_(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),vk(a,t,n))}}function f_(e){return Array.isArray(e)||typeof e=="object"}function Uf(e){return e.kernelName!=null}var hx=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()}},um=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new hx}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){im(e).forEach(n=>{n.disposeFunc!=null&&n.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 ol)&&typeof n.then=="function"){let s=++this.pendingBackendInitId,r=n.then(a=>s(sthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(n),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),s))}scopedRun(e,t,n){e();try{let s=n();return t(),s}catch(s){throw t(),s}}nextTensorId(){return um.nextTensorId++}nextVariableId(){return um.nextVariableId++}clone(e){let t=z.runKernel(Wa,{x:e}),n={x:e},s=a=>({x:()=>{let i="float32",o={x:a},u={dtype:i};return z.runKernel(Ta,o,u)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],s,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,!(am(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 s=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype==="complex64"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=s-t-r-a;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=[],s=this.isTapeOn(),r=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,u=Uf(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Uf(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=am(h,this.backendName);F(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let b=this.backend.numDataIds();o=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let y=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,b,y);let v=y.map(x=>x.rank!=null?x:this.makeTensorFromTensorInfo(x));if(s){let x=this.getTensorsForGradient(h,f,v);n=this.saveTensorsForBackwardMode(x)}return v}}else{let{forwardFunc:h}=e,f=m=>{!s||(n=m.map(g=>this.keep(this.clone(g))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,m,g),g}}let{inputs:l,attrs:c}=e,p=Uf(e)?null:e.backwardsFunc,d;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(d=this.profiler.profileKernel(u,l,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs)}),s&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map(h=>l[h]!=null?l[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let s=lx(e);if(s!=null){let r=s.inputsToSave||[],a=s.outputsToSave||[],i;s.saveAllInputs?(F(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(u=>t[u])):i=r.map(u=>t[u]);let o=n.filter((u,l)=>a[l]);return i.concat(o)}return[]}makeTensor(e,t,n,s){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",s=s||this.backend;let r=e;n==="string"&&ar(e[0])&&(r=e.map(o=>zl(o)));let a=s.write(r,t,n),i=new et(t,n,a,this.nextTensorId());if(this.trackTensor(i,s),n==="string"){let o=this.state.tensorInfo.get(a),u=ak(r);this.state.numBytes+=u-o.bytes,o.bytes=u}return i}makeTensorFromDataId(e,t,n,s){n=n||"float32";let r={dataId:e,shape:t,dtype:n};return this.makeTensorFromTensorInfo(r,s)}makeTensorFromTensorInfo(e,t){let{dataId:n,shape:s,dtype:r}=e,a=new et(s,r,n,this.nextTensorId());return this.trackTensor(a,t),a}makeVariable(e,t=!0,n,s){n=n||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));let r=new wd(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*nm(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 wd||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*nm(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(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,s,r,a){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},o=lx(e);o!=null&&(s=o.gradFunc),s!=null&&(i.gradient=u=>(u=u.map((l,c)=>{if(l==null){let p=n[c],d=Zd(p.size,p.dtype);return this.makeTensor(d,p.shape,p.dtype)}return l}),s(u.length>1?u:u[0],r,a))),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=Bg(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===s.id&&this.track(r)})}gradients(e,t,n,s=!1){if(F(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));F(r instanceof et,()=>"The result y returned by f() must be a tensor.");let a=n_(this.state.activeTape,t,r);if(!s&&a.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?m_(r.shape):n,s_(i,a,u=>this.tidy(u),g_);let o=t.map(u=>i[u.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(u=>{for(let l of u.saved)l.dispose()}),this.state.activeTape=null),{value:r,grads:o}})}customGrad(e){return F(hr(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{F(t.every(i=>i instanceof et),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,s={};t.forEach((i,o)=>{s[o]=i});let r=(i,o)=>(n=e(...t,o),F(n.value instanceof et,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),F(hr(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),a=(i,o)=>{let u=n.gradFunc(i,o),l=Array.isArray(u)?u:[u];F(l.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(...)."),F(l.every(p=>p instanceof et),()=>"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 c={};return l.forEach((p,d)=>{c[d]=()=>p}),c};return this.runKernelFunc({forwardFunc:r,backwardsFunc:a,inputs:s})}}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=qu(),n=await this.backend.time(e);return n.wallMs=qu()-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 hx;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}},Vg=um;Vg.nextTensorId=0;Vg.nextVariableId=0;function m_(e){let t=lg(dt(e),"float32");return z.makeTensor(t,e,"float32")}function xk(){let e=ck();if(e._tfengine==null){let t=new O$(e);e._tfengine=new Vg(t)}return L$(e._tfengine.ENV),o_(()=>e._tfengine),e._tfengine}var z=xk();function g_(e,t){let n={a:e,b:t};return z.runKernel(Ir,n)}var yp={};Ee(yp,{isBrowser:()=>wk,isMobile:()=>v_,mockIsMobile:()=>y_});function b_(){return typeof navigator!="undefined"&&navigator!=null}var lm;function y_(e){lm=e}function v_(e){if(lm!==void 0)return lm;if(e||b_()){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 wk(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Kn=K();Kn.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.")});Kn.registerFlag("IS_BROWSER",()=>wk());Kn.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Kn.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Kn.registerFlag("PROD",()=>!1);Kn.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Kn.getBool("DEBUG"));Kn.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Kn.registerFlag("IS_TEST",()=>!1);Kn.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Kn.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);Kn.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function Rs(e,t){let n=e;if(Qt(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let s=[];for(;Array.isArray(n)||Qt(n)&&t!=="string";)s.push(n.length),n=n[0];return Array.isArray(e)&&K().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&kk(e,s,[]),s}function kk(e,t,n){if(n=n||[],!Array.isArray(e)&&!Qt(e)){F(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}F(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),F(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let s=t.slice(1);for(let r=0;r=0&&(r=s),fx(s,r,t,n),e==null||!Qt(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let u=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`)}let a=Rs(e,r);!Qt(e)&&!Array.isArray(e)&&(e=[e]);let o=r!=="string"?gp(e,r):aa(e,[],!0);return z.makeTensor(o,a,r)}function ju(e,t,n,s="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,i)=>_(a,`${t}[${i}]`,n,s))}var x_="__op";function L(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],s=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+x_;let r=(...a)=>{z.startScope(n);try{let i=s(...a);return dg(i)&&console.error("Cannot return a Promise inside of tidy."),z.endScope(i),i}catch(i){throw z.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function w_(e,t){let n=_(e,"real","complex"),s=_(t,"imag","complex");pn(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);let r={real:n,imag:s};return z.runKernel(ep,r)}var fr=L({complex_:w_});function Tr(e,t,n,s){if(s==null&&(s=Qd(e)),s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Qt(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){cg(t);let r=dt(t),a=dt(n);F(r===a,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!Qt(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=s!=="string"?gp(e,s):aa(e,[],!0),z.makeTensor(e,t,s)}function ms(e,t,n){let s=Rs(e,n);return Tr(e,t,s,n)}var cm={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},kd=4;async function k_(e,t){let n=[],s=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let d=await u.bytes(),h=d.reduce((g,b)=>g+b.length,0)+kd*d.length,f=new Uint8Array(h),m=0;for(let g=0;g{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let s=new Uint8Array(t),r=0;return n.forEach(a=>{s.set(new Uint8Array(a.buffer),r),r+=a.byteLength}),s.buffer}var Wg=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function mx(e){return Wg?Buffer.byteLength(e):new Blob([e]).size}function I_(e){if(Wg)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let s=0,r=t.length;s{t+=r.byteLength});let n=new Uint8Array(t),s=0;return e.forEach(r=>{n.set(new Uint8Array(r),s),s+=r.byteLength}),n.buffer}function gx(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 Ik(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 Gg(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[s,r]=await t(e.weightsManifest);n.weightSpecs=s,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 Ml(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:mx(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:mx(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function N_(){let e=n=>{let s=n<<13,r=0;for(;(s&8388608)===0;)r-=8388608,s<<=1;return s&=-8388609,r+=947912704,s|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 T_(){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 $_(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function __(){let e=N_(),t=T_(),n=$_();return s=>{let r=new ArrayBuffer(4*s.length),a=new Uint32Array(r);for(let i=0;i>10]+(o&1023)]+t[o>>10];a[i]=u}return new Float32Array(r)}}var wt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return wt.instance==null&&(wt.instance=new wt),wt.instance}static registerSaveRouter(e){wt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){wt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return wt.getHandlers(e,"save")}static getLoadHandlers(e,t){return wt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let s=[];return(t==="load"?wt.getInstance().loadRouters:wt.getInstance().saveRouters).forEach(a=>{let i=a(e,n);i!==null&&s.push(i)}),s}},A_=e=>wt.registerSaveRouter(e),E_=e=>wt.registerLoadRouter(e),R_=e=>wt.getSaveHandlers(e),D_=(e,t)=>wt.getLoadHandlers(e,t),dm="tensorflowjs",pm=1,Zr="models_store",ir="model_info_store";function Ck(){if(!K().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 hm(e){let t=e.result;t.createObjectStore(Zr,{keyPath:"modelPath"}),t.createObjectStore(ir,{keyPath:"modelPath"})}var la=class{constructor(e){if(this.indexedDB=Ck(),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,s)=>{let r=this.indexedDB.open(dm,pm);r.onupgradeneeded=()=>hm(r),r.onsuccess=()=>{let a=r.result;if(t==null){let i=a.transaction(Zr,"readonly"),u=i.objectStore(Zr).get(this.modelPath);u.onsuccess=()=>{if(u.result==null)return a.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(u.result.modelArtifacts)},u.onerror=l=>(a.close(),s(u.error)),i.oncomplete=()=>a.close()}else{let i=Ml(t),o=a.transaction(ir,"readwrite"),u=o.objectStore(ir),l=u.put({modelPath:this.modelPath,modelArtifactsInfo:i}),c;l.onsuccess=()=>{c=a.transaction(Zr,"readwrite");let d=c.objectStore(Zr).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=h=>{u=o.objectStore(ir);let f=u.delete(this.modelPath);f.onsuccess=()=>(a.close(),s(d.error)),f.onerror=m=>(a.close(),s(d.error))}},l.onerror=p=>(a.close(),s(l.error)),o.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};la.URL_SCHEME="indexeddb://";var Nk=e=>K().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(la.URL_SCHEME)?F_(e.slice(la.URL_SCHEME.length)):null;wt.registerSaveRouter(Nk);wt.registerLoadRouter(Nk);function F_(e){return new la(e)}function O_(e){return e.startsWith(la.URL_SCHEME)?e.slice(la.URL_SCHEME.length):e}var P_=class{constructor(){this.indexedDB=Ck()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(dm,pm);n.onupgradeneeded=()=>hm(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(ir,"readonly"),i=r.objectStore(ir).getAll();i.onsuccess=()=>{let o={};for(let u of i.result)o[u.modelPath]=u.modelArtifactsInfo;e(o)},i.onerror=o=>(s.close(),t(i.error)),r.oncomplete=()=>s.close()},n.onerror=s=>t(n.error)})}async removeModel(e){return e=O_(e),new Promise((t,n)=>{let s=this.indexedDB.open(dm,pm);s.onupgradeneeded=()=>hm(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(ir,"readwrite"),i=a.objectStore(ir),o=i.get(e),u;o.onsuccess=()=>{if(o.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let l=i.delete(e),c=()=>{u=r.transaction(Zr,"readwrite");let d=u.objectStore(Zr).delete(e);d.onsuccess=()=>t(o.result.modelArtifactsInfo),d.onerror=h=>n(o.error)};l.onsuccess=c,l.onerror=p=>(c(),r.close(),n(o.error))}},o.onerror=l=>(r.close(),n(o.error)),a.oncomplete=()=>{u==null?r.close():u.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Us="/",Gi="tensorflowjs_models",Tk="info",z_="model_topology",M_="weight_specs",L_="weight_data",B_="model_metadata";function $k(e){return{info:[Gi,e,Tk].join(Us),topology:[Gi,e,z_].join(Us),weightSpecs:[Gi,e,M_].join(Us),weightData:[Gi,e,L_].join(Us),modelMetadata:[Gi,e,B_].join(Us)}}function _k(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function V_(e){let t=e.split(Us);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Us)}function W_(e){return e.startsWith(ca.URL_SCHEME)?e.slice(ca.URL_SCHEME.length):e}var ca=class{constructor(e){if(!K().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=$k(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),s=Ml(e);try{this.LS.setItem(this.keys.info,JSON.stringify(s)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,I_(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:s}}catch(r){throw _k(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=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.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 s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;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 a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=C_(a),t}};ca.URL_SCHEME="localstorage://";var Ak=e=>K().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ca.URL_SCHEME)?U_(e.slice(ca.URL_SCHEME.length)):null;wt.registerSaveRouter(Ak);wt.registerLoadRouter(Ak);function U_(e){return new ca(e)}var G_=class{constructor(){F(K().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),F(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Gi+Us,n=Us+Tk;for(let s=0;s"scheme must not be undefined or null."),e.endsWith(Ki)&&(e=e.slice(0,e.indexOf(Ki))),F(e.length>0,()=>"scheme must not be an empty string.");let n=zn.getInstance();F(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 ad(e){if(e.indexOf(Ki)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`);return{scheme:e.split(Ki)[0],path:e.split(Ki)[1]}}async function Ek(e,t,n=!1){F(e!==t,()=>`Old path and new path are the same: '${e}'`);let s=wt.getLoadHandlers(e);F(s.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),F(s.length<2,()=>`Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`);let r=s[0],a=wt.getSaveHandlers(t);F(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),F(a.length<2,()=>`Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`);let i=a[0],o=ad(e).scheme,u=ad(e).path,l=o===ad(e).scheme,c=await r.load();n&&l&&await zn.getManager(o).removeModel(u);let p=await i.save(c);return n&&!l&&await zn.getManager(o).removeModel(u),p.modelArtifactsInfo}async function H_(){let e=zn.getSchemes(),t={};for(let n of e){let s=await zn.getManager(n).listModels();for(let r in s){let a=n+Ki+r;t[a]=s[r]}}return t}async function q_(e){let t=ad(e);return zn.getManager(t.scheme).removeModel(t.path)}async function j_(e,t){return Ek(e,t,!1)}async function K_(e,t){return Ek(e,t,!0)}var X_=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(K().get("IS_BROWSER")){K().setPlatform("browser",new X_);try{zn.registerManager(ca.URL_SCHEME,new G_)}catch(e){}try{zn.registerManager(la.URL_SCHEME,new P_)}catch(e){}}var Y_={importFetch:()=>s$()},Gf,Q_=class{constructor(){this.util=r$(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return K().global.fetch!=null?K().global.fetch(e,t):(Gf==null&&(Gf=Y_.importFetch()),Gf(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)}};K().get("IS_NODE")&&!K().get("IS_BROWSER")&&K().setPlatform("node",new Q_);function Ae(e,t="float32",n){return t=t||"float32",cg(e),new Wt(e,t,n)}function Z_(e,t){let n=_(e,"x","cast");if(!rk(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 s={x:n},r={dtype:t};return z.runKernel(Ta,s,r)}var le=L({cast_:Z_});function J_(e){let n={x:_(e,"x","clone","string_or_numeric")};return z.runKernel(Wa,n)}var ur=L({clone_:J_});function eA(e,t=!1){console.log(e.toString(t))}xk();var tA={buffer:Ae,cast:le,clone:ur,print:eA};u_(tA);var An={};Ee(An,{browserFiles:()=>uA,browserHTTPRequest:()=>hA,concatenateArrayBuffers:()=>Ug,copyModel:()=>j_,decodeWeights:()=>Sk,encodeWeights:()=>k_,fromMemory:()=>mA,fromMemorySync:()=>Pk,getLoadHandlers:()=>D_,getModelArtifactsForJSON:()=>Gg,getModelArtifactsInfoForJSON:()=>Ml,getSaveHandlers:()=>R_,http:()=>qg,isHTTPScheme:()=>mm,listModels:()=>H_,loadWeights:()=>lA,moveModel:()=>K_,registerLoadRouter:()=>E_,registerSaveRouter:()=>A_,removeModel:()=>q_,weightsLoaderFactory:()=>Dk,withSaveHandler:()=>gA,withSaveHandlerSync:()=>bA});var nA="model",sA=".json",rA=".weights.bin";function bx(e){return new Promise(t=>setTimeout(t)).then(e)}var fm=class{constructor(e){if(!K().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(fm.URL_SCHEME)&&(e=e.slice(fm.URL_SCHEME.length)),(e==null||e.length===0)&&(e=nA),this.modelJsonFileName=e+sA,this.weightDataFileName=e+rA}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}],s=Ik(e,n),r=window.URL.createObjectURL(new Blob([JSON.stringify(s)],{type:"application/json"})),a=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await bx(()=>a.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 bx(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Ml(e)}}}},Sd=fm;Sd.URL_SCHEME="downloads://";var aA=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=s=>{let r=JSON.parse(s.target.result),a=r.modelTopology;if(a==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:a});return}let o=Gg(r,u=>this.loadWeights(u));e(o)},n.onerror=s=>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 a of e)t.push(...a.weights),n.push(...a.paths);let s=this.checkManifestAndWeightFiles(e),r=n.map(a=>this.loadWeightsFile(a,s[a]));return Promise.all(r).then(a=>[t,Ug(a)])}loadWeightsFile(e,t){return new Promise((n,s)=>{let r=new FileReader;r.onload=a=>{let i=a.target.result;n(i)},r.onerror=a=>s(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>gx(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let i=gx(a);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.`);s[a]=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 s}},iA=e=>K().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Sd.URL_SCHEME)?oA(e.slice(Sd.URL_SCHEME.length)):null;wt.registerSaveRouter(iA);function oA(e="model"){return new Sd(e)}function uA(e){return new aA(e)}function yx(e,t,n,s){i(e),n=n==null?0:n,s=s==null?1:s,o(n,s);let r=0,a=u=>(u.then(l=>{let c=n+ ++r/e.length*(s-n);return t(c),l}),u);function i(u){F(u!=null&&Array.isArray(u)&&u.length>0,()=>"promises must be a none empty array")}function o(u,l){F(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),F(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),F(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(e.map(a))}async function Rk(e,t){t==null&&(t={});let n=t.fetchFunc==null?K().platform.fetch:t.fetchFunc,s=e.map(p=>n(p,t.requestInit,{isBinary:!0})),r=0,a=.5,o=(t.onProgress==null?await Promise.all(s):await yx(s,t.onProgress,r,a)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(o):await yx(o,t.onProgress,u,l)}async function lA(e,t="",n,s){return Dk(i=>Rk(i,{requestInit:s}))(e,t,n)}function Dk(e){return async(t,n="",s)=>{let r=t.map(()=>!1),a={},i=s!=null?s.map(()=>!1):[],o=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let b="quantization"in g?g.quantization.dtype:g.dtype,y=cm[b]*dt(g.shape),v=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:y})};s!=null?s.forEach((x,k)=>{x===g.name&&(v(),i[k]=!0)}):v(),o.push(g.name),m+=y})}),!i.every(h=>h)){let h=s.filter((f,m)=>!i[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}. Manifest JSON has weights with names: ${o.join(", ")}.`)}let u=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),l=[];u.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;l.push(m)})});let c=await e(l),p={},d=0;return u.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x{let k=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),I=Sk(k,[x.manifestEntry]);for(let $ in I)p[$]=I[$]}),d+=f}),p}}var cA="application/octet-stream",dA="application/json",Hg=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?(F(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=K().platform.fetch,F(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&F(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}],s=Ik(e,n);t.body.append("model.json",new Blob([JSON.stringify(s)],{type:dA}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:cA}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Ml(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 a=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?a+=" 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.":a+=" Please make sure the server is serving valid JSON for this request.",new Error(a)}let n=t.modelTopology,s=t.weightsManifest;if(n==null&&s==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Gg(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=pA(t),r=this.weightPathPrefix||n,a=[];for(let l of e)a.push(...l.weights);let i=[],o=[];for(let l of e)for(let c of l.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(c)):i.push(r+c+s);this.weightUrlConverter&&i.push(...await Promise.all(o));let u=await Rk(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Ug(u)]}};Hg.URL_SCHEME_REGEX=/^https?:\/\//;function pA(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),s=e.substring(0,t),r=n>t?e.substring(n):"";return[s+"/",r]}function mm(e){return e.match(Hg.URL_SCHEME_REGEX)!=null}var Fk=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>mm(s)):n=mm(e),n)return qg(e,t)}return null};wt.registerSaveRouter(Fk);wt.registerLoadRouter(Fk);function qg(e,t){return new Hg(e,t)}function hA(e,t){return qg(e,t)}var Hf=class{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}},Ok=class{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}},fA=class{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}};function mA(e,t,n,s){let r=arguments;return new fA(Pk(...r))}function Pk(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new Hf(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 Hf({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 Hf({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function gA(e){return new Ok(e)}function bA(e){return new Ok(e)}var yA={};Ee(yA,{confusionMatrix:()=>TA});function vA(e,t,n=!1,s=!1){let r=_(e,"a","matMul"),a=_(t,"b","matMul");[r,a]=xt(r,a);let i={a:r,b:a},o={transposeA:n,transposeB:s};return z.runKernel(Na,i,o)}var Ve=L({matMul_:vA});function xA(e,t,n=1,s=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:_(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:s};return z.runKernel(Eo,a,i)}var Id=L({oneHot_:xA});function bpe(){K().set("PROD",!0)}function ype(){K().set("DEBUG",!0)}function vpe(){K().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function zk(e){K().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}l_(zk);function xpe(){z.disposeVariables()}function ds(){return z}function gm(){return z.memory()}function wpe(e){return z.profile(e)}function q(e,t){return z.tidy(e,t)}function De(e){Bg(e).forEach(n=>n.dispose())}function qt(e){return z.keep(e)}function kpe(e){return z.time(e)}function Spe(e){return z.setBackend(e)}function Ipe(){return z.ready()}function Cpe(){return z.backendName}function Npe(e){z.removeBackend(e)}function Tpe(e){return z.findBackend(e)}function $pe(e){return z.findBackendFactory(e)}function vp(e,t,n=1){return z.registerBackend(e,t,n)}function wA(){return z.backend}function _pe(e,t){K().setPlatform(e,t)}function kA(e){let n={input:_(e,"input","imag")};return z.runKernel(ap,n)}var xp=L({imag_:kA});function SA(e){let n={x:_(e,"x","neg")};return z.runKernel(No,n)}var vt=L({neg_:SA});function IA(e){let n={input:_(e,"input","real")};return z.runKernel(lp,n)}var Ku=L({real_:IA});function CA(e,t,n){let s=_(e,"x","transpose");if(t==null&&(t=s.shape.map((i,o)=>o).reverse()),F(s.rank===t.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${t}.`),t.forEach(i=>{F(i>=0&&i`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${t}`)}),s.rank<=1)return s.clone();let r={x:s},a={perm:t};return s.dtype==="complex64"?q(()=>{let i=Ku(s),o=xp(s);return i=z.runKernel(Hs,{x:i},a),o=z.runKernel(Hs,{x:o},a),n&&(o=vt(o)),fr(i,o)}):z.runKernel(Hs,r,a)}var Ge=L({transpose_:CA});function NA(e,t,n){let s=_(e,"labels","confusionMatrix"),r=_(t,"predictions","confusionMatrix");F(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),F(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}`),F(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),F(s.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),F(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=Id(le(s,"int32"),n),i=Id(le(r,"int32"),n),o=Ge(a),u=Ve(o,i);return le(u,"int32")}var TA=L({confusionMatrix_:NA}),Xo={};Ee(Xo,{assertAndGetBroadcastShape:()=>rt,getBroadcastDims:()=>Mk,getReductionAxes:()=>At});function Mk(e,t){let n=e.length,s=[];for(let r=0;r1&&i===1&&s.unshift(a)}return s}function At(e,t){let n=[];for(let s=0;s1)&&n.unshift(a)}return n}function rt(e,t){let n=[],s=Math.max(e.length,t.length);for(let r=0;rOA,fromPixelsAsync:()=>DA,toPixels:()=>FA});function $A(e,t,n){if(ka(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let s=Rs(e,n);if(s.length!==3&&s.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Tr(e,t,s,n)}var Ur;function Bk(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,s=!1,r=!1,a=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)s=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)a=!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