/* Face-API homepage: author: ' */ var mU=Object.create;var Iv=Object.defineProperty;var fU=Object.getOwnPropertyDescriptor;var dU=Object.getOwnPropertyNames;var hU=Object.getPrototypeOf,gU=Object.prototype.hasOwnProperty;var Oe=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Yt=(r,t)=>{for(var e in t)Iv(r,e,{get:t[e],enumerable:!0})},xU=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dU(t))!gU.call(r,o)&&o!==e&&Iv(r,o,{get:()=>t[o],enumerable:!(n=fU(t,o))||n.enumerable});return r};var xu=(r,t,e)=>(e=r!=null?mU(hU(r)):{},xU(t||!r||!r.__esModule?Iv(e,"default",{value:r,enumerable:!0}):e,r));var c1=Oe((Dat,u1)=>{u1.exports=Xe;var lo=null;try{lo=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(r){}function Xe(r,t,e){this.low=r|0,this.high=t|0,this.unsigned=!!e}Xe.prototype.__isLong__;Object.defineProperty(Xe.prototype,"__isLong__",{value:!0});function Pn(r){return(r&&r.__isLong__)===!0}Xe.isLong=Pn;var t1={},e1={};function Su(r,t){var e,n,o;return t?(r>>>=0,(o=0<=r&&r<256)&&(n=e1[r],n)?n:(e=Ye(r,(r|0)<0?-1:0,!0),o&&(e1[r]=e),e)):(r|=0,(o=-128<=r&&r<128)&&(n=t1[r],n)?n:(e=Ye(r,r<0?-1:0,!1),o&&(t1[r]=e),e))}Xe.fromInt=Su;function uo(r,t){if(isNaN(r))return t?Iu:co;if(t){if(r<0)return Iu;if(r>=s1)return l1}else{if(r<=-n1)return On;if(r+1>=n1)return a1}return r<0?uo(-r,t).neg():Ye(r%Vp|0,r/Vp|0,t)}Xe.fromNumber=uo;function Ye(r,t,e){return new Xe(r,t,e)}Xe.fromBits=Ye;var nx=Math.pow;function Pv(r,t,e){if(r.length===0)throw Error("empty string");if(r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return co;if(typeof t=="number"?(e=t,t=!1):t=!!t,e=e||10,e<2||360)throw Error("interior hyphen");if(n===0)return Pv(r.substring(1),t,e).neg();for(var o=uo(nx(e,8)),s=co,i=0;i>>0:this.low};yt.toNumber=function(){return this.unsigned?(this.high>>>0)*Vp+(this.low>>>0):this.high*Vp+(this.low>>>0)};yt.toString=function(t){if(t=t||10,t<2||36>>0,c=l.toString(t);if(i=u,i.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};yt.getHighBits=function(){return this.high};yt.getHighBitsUnsigned=function(){return this.high>>>0};yt.getLowBits=function(){return this.low};yt.getLowBitsUnsigned=function(){return this.low>>>0};yt.getNumBitsAbs=function(){if(this.isNegative())return this.eq(On)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&(t&1<=0};yt.isOdd=function(){return(this.low&1)===1};yt.isEven=function(){return(this.low&1)===0};yt.equals=function(t){return Pn(t)||(t=Gs(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};yt.eq=yt.equals;yt.notEquals=function(t){return!this.eq(t)};yt.neq=yt.notEquals;yt.ne=yt.notEquals;yt.lessThan=function(t){return this.comp(t)<0};yt.lt=yt.lessThan;yt.lessThanOrEqual=function(t){return this.comp(t)<=0};yt.lte=yt.lessThanOrEqual;yt.le=yt.lessThanOrEqual;yt.greaterThan=function(t){return this.comp(t)>0};yt.gt=yt.greaterThan;yt.greaterThanOrEqual=function(t){return this.comp(t)>=0};yt.gte=yt.greaterThanOrEqual;yt.ge=yt.greaterThanOrEqual;yt.compare=function(t){if(Pn(t)||(t=Gs(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?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};yt.comp=yt.compare;yt.negate=function(){return!this.unsigned&&this.eq(On)?On:this.not().add(Bp)};yt.neg=yt.negate;yt.add=function(t){Pn(t)||(t=Gs(t));var e=this.high>>>16,n=this.high&65535,o=this.low>>>16,s=this.low&65535,i=t.high>>>16,a=t.high&65535,u=t.low>>>16,l=t.low&65535,c=0,p=0,m=0,f=0;return f+=s+l,m+=f>>>16,f&=65535,m+=o+u,p+=m>>>16,m&=65535,p+=n+a,c+=p>>>16,p&=65535,c+=e+i,c&=65535,Ye(m<<16|f,c<<16|p,this.unsigned)};yt.subtract=function(t){return Pn(t)||(t=Gs(t)),this.add(t.neg())};yt.sub=yt.subtract;yt.multiply=function(t){if(this.isZero())return co;if(Pn(t)||(t=Gs(t)),lo){var e=lo.mul(this.low,this.high,t.low,t.high);return Ye(e,lo.get_high(),this.unsigned)}if(t.isZero())return co;if(this.eq(On))return t.isOdd()?On:co;if(t.eq(On))return this.isOdd()?On:co;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(o1)&&t.lt(o1))return uo(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,o=this.high&65535,s=this.low>>>16,i=this.low&65535,a=t.high>>>16,u=t.high&65535,l=t.low>>>16,c=t.low&65535,p=0,m=0,f=0,d=0;return d+=i*c,f+=d>>>16,d&=65535,f+=s*c,m+=f>>>16,f&=65535,f+=i*l,m+=f>>>16,f&=65535,m+=o*c,p+=m>>>16,m&=65535,m+=s*l,p+=m>>>16,m&=65535,m+=i*u,p+=m>>>16,m&=65535,p+=n*c+o*l+s*u+i*a,p&=65535,Ye(f<<16|d,p<<16|m,this.unsigned)};yt.mul=yt.multiply;yt.divide=function(t){if(Pn(t)||(t=Gs(t)),t.isZero())throw Error("division by zero");if(lo){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?lo.div_u:lo.div_s)(this.low,this.high,t.low,t.high);return Ye(e,lo.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Iu:co;var n,o,s;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Iu;if(t.gt(this.shru(1)))return i1;s=Iu}else{if(this.eq(On)){if(t.eq(Bp)||t.eq(Ov))return On;if(t.eq(On))return Bp;var i=this.shr(1);return n=i.div(t).shl(1),n.eq(co)?t.isNegative()?Bp:Ov:(o=this.sub(t.mul(n)),s=n.add(o.div(t)),s)}else if(t.eq(On))return this.unsigned?Iu:co;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();s=co}for(o=this;o.gte(t);){n=Math.max(1,Math.floor(o.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),u=a<=48?1:nx(2,a-48),l=uo(n),c=l.mul(t);c.isNegative()||c.gt(o);)n-=u,l=uo(n,this.unsigned),c=l.mul(t);l.isZero()&&(l=Bp),s=s.add(l),o=o.sub(c)}return s};yt.div=yt.divide;yt.modulo=function(t){if(Pn(t)||(t=Gs(t)),lo){var e=(this.unsigned?lo.rem_u:lo.rem_s)(this.low,this.high,t.low,t.high);return Ye(e,lo.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};yt.mod=yt.modulo;yt.rem=yt.modulo;yt.not=function(){return Ye(~this.low,~this.high,this.unsigned)};yt.and=function(t){return Pn(t)||(t=Gs(t)),Ye(this.low&t.low,this.high&t.high,this.unsigned)};yt.or=function(t){return Pn(t)||(t=Gs(t)),Ye(this.low|t.low,this.high|t.high,this.unsigned)};yt.xor=function(t){return Pn(t)||(t=Gs(t)),Ye(this.low^t.low,this.high^t.high,this.unsigned)};yt.shiftLeft=function(t){return Pn(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ye(this.low<>>32-t,this.unsigned):Ye(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):Ye(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};yt.shr=yt.shiftRight;yt.shiftRightUnsigned=function(t){if(Pn(t)&&(t=t.toInt()),t&=63,t===0)return this;var e=this.high;if(t<32){var n=this.low;return Ye(n>>>t|e<<32-t,e>>>t,this.unsigned)}else return t===32?Ye(e,0,this.unsigned):Ye(e>>>t-32,0,this.unsigned)};yt.shru=yt.shiftRightUnsigned;yt.shr_u=yt.shiftRightUnsigned;yt.toSigned=function(){return this.unsigned?Ye(this.low,this.high,!1):this};yt.toUnsigned=function(){return this.unsigned?this:Ye(this.low,this.high,!0)};yt.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};yt.toBytesLE=function(){var t=this.high,e=this.low;return[e&255,e>>>8&255,e>>>16&255,e>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};yt.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,e>>>24,e>>>16&255,e>>>8&255,e&255]};Xe.fromBytes=function(t,e,n){return n?Xe.fromBytesLE(t,e):Xe.fromBytesBE(t,e)};Xe.fromBytesLE=function(t,e){return new Xe(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};Xe.fromBytesBE=function(t,e){return new Xe(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}});var K1=Oe(()=>{});var j1=Oe(()=>{});var D_=Oe((A_,H0)=>{(function(r,t,e){function n(a){var u=this,l=i();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=l(" "),u.s1=l(" "),u.s2=l(" "),u.s0-=l(a),u.s0<0&&(u.s0+=1),u.s1-=l(a),u.s1<0&&(u.s1+=1),u.s2-=l(a),u.s2<0&&(u.s2+=1),l=null}function o(a,u){return u.c=a.c,u.s0=a.s0,u.s1=a.s1,u.s2=a.s2,u}function s(a,u){var l=new n(a),c=u&&u.state,p=l.next;return p.int32=function(){return l.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,c&&(typeof c=="object"&&o(c,l),p.state=function(){return o(l,{})}),p}function i(){var a=4022871197,u=function(l){l=l.toString();for(var c=0;c>>0,p-=a,p*=a,a=p>>>0,p-=a,a+=p*4294967296}return(a>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.alea=s})(A_,typeof H0=="object"&&H0,typeof define=="function"&&define)});var R_=Oe(($_,q0)=>{(function(r,t,e){function n(i){var a=this,u="";a.x=0,a.y=0,a.z=0,a.w=0,a.next=function(){var c=a.x^a.x<<11;return a.x=a.y,a.y=a.z,a.z=a.w,a.w^=a.w>>>19^c^c>>>8},i===(i|0)?a.x=i:u+=i;for(var l=0;l>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor128=s})($_,typeof q0=="object"&&q0,typeof define=="function"&&define)});var O_=Oe((F_,K0)=>{(function(r,t,e){function n(i){var a=this,u="";a.next=function(){var c=a.x^a.x>>>2;return a.x=a.y,a.y=a.z,a.z=a.w,a.w=a.v,(a.d=a.d+362437|0)+(a.v=a.v^a.v<<4^(c^c<<1))|0},a.x=0,a.y=0,a.z=0,a.w=0,a.v=0,i===(i|0)?a.x=i:u+=i;for(var l=0;l>>4),a.next()}function o(i,a){return a.x=i.x,a.y=i.y,a.z=i.z,a.w=i.w,a.v=i.v,a.d=i.d,a}function s(i,a){var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorwow=s})(F_,typeof K0=="object"&&K0,typeof define=="function"&&define)});var M_=Oe((P_,j0)=>{(function(r,t,e){function n(i){var a=this;a.next=function(){var l=a.x,c=a.i,p,m,f;return p=l[c],p^=p>>>7,m=p^p<<24,p=l[c+1&7],m^=p^p>>>10,p=l[c+3&7],m^=p^p>>>3,p=l[c+4&7],m^=p^p<<7,p=l[c+7&7],p=p^p<<13,m^=p^p<<9,l[c]=m,a.i=c+1&7,m};function u(l,c){var p,m,f=[];if(c===(c|0))m=f[0]=c;else for(c=""+c,p=0;p0;--p)l.next()}u(a,i)}function o(i,a){return a.x=i.x.slice(),a.i=i.i,a}function s(i,a){i==null&&(i=+new Date);var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(l.x&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorshift7=s})(P_,typeof j0=="object"&&j0,typeof define=="function"&&define)});var z_=Oe((L_,X0)=>{(function(r,t,e){function n(i){var a=this;a.next=function(){var l=a.w,c=a.X,p=a.i,m,f;return a.w=l=l+1640531527|0,f=c[p+34&127],m=c[p=p+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=c[p]=f^m,a.i=p,f+(l^l>>>16)|0};function u(l,c){var p,m,f,d,h,g=[],y=128;for(c===(c|0)?(m=c,c=null):(c=c+"\0",m=0,y=Math.max(y,c.length)),f=0,d=-32;d>>15,m^=m<<4,m^=m>>>13,d>=0&&(h=h+1640531527|0,p=g[d&127]^=m+h,f=p==0?f+1:0);for(f>=128&&(g[(c&&c.length||0)&127]=-1),f=127,d=4*128;d>0;--d)m=g[f+34&127],p=g[f=f+1&127],m^=m<<13,p^=p<<17,m^=m>>>15,p^=p>>>12,g[f]=m^p;l.w=h,l.X=g,l.i=f}u(a,i)}function o(i,a){return a.i=i.i,a.w=i.w,a.X=i.X.slice(),a}function s(i,a){i==null&&(i=+new Date);var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(l.X&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor4096=s})(L_,typeof X0=="object"&&X0,typeof define=="function"&&define)});var V_=Oe((B_,Y0)=>{(function(r,t,e){function n(i){var a=this,u="";a.next=function(){var c=a.b,p=a.c,m=a.d,f=a.a;return c=c<<25^c>>>7^p,p=p-m|0,m=m<<24^m>>>8^f,f=f-c|0,a.b=c=c<<20^c>>>12^p,a.c=p=p-m|0,a.d=m<<16^p>>>16^f,a.a=f-c|0},a.a=0,a.b=0,a.c=-1640531527,a.d=1367130551,i===Math.floor(i)?(a.a=i/4294967296|0,a.b=i|0):u+=i;for(var l=0;l>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.tychei=s})(B_,typeof Y0=="object"&&Y0,typeof define=="function"&&define)});var Z0=Oe(()=>{});var G_=Oe((pIt,Ix)=>{(function(r,t){var e=this,n=256,o=6,s=52,i="random",a=t.pow(n,o),u=t.pow(2,s),l=u*2,c=n-1,p;function m(w,v,k){var E=[];v=v==!0?{entropy:!0}:v||{};var D=g(h(v.entropy?[w,b(r)]:w==null?y():w,3),E),$=new f(E),R=function(){for(var M=$.g(o),W=a,U=0;M=l;)M/=2,W/=2,U>>>=1;return(M+U)/W};return R.int32=function(){return $.g(4)|0},R.quick=function(){return $.g(4)/4294967296},R.double=R,g(b($.S),r),(v.pass||k||function(M,W,U,q){return q&&(q.S&&d(q,$),M.state=function(){return d($,{})}),U?(t[i]=M,W):M})(R,D,"global"in v?v.global:this==t,v.state)}t["seed"+i]=m;function f(w){var v,k=w.length,E=this,D=0,$=E.i=E.j=0,R=E.S=[];for(k||(w=[k++]);D{var GK=D_(),WK=R_(),UK=O_(),HK=M_(),qK=z_(),KK=V_(),Hu=G_();Hu.alea=GK;Hu.xor128=WK;Hu.xorwow=UK;Hu.xorshift7=HK;Hu.xor4096=qK;Hu.tychei=KK;W_.exports=Hu});var k$=Oe((S$,VI)=>{(function(r,t,e){function n(a){var u=this,l=i();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=l(" "),u.s1=l(" "),u.s2=l(" "),u.s0-=l(a),u.s0<0&&(u.s0+=1),u.s1-=l(a),u.s1<0&&(u.s1+=1),u.s2-=l(a),u.s2<0&&(u.s2+=1),l=null}function o(a,u){return u.c=a.c,u.s0=a.s0,u.s1=a.s1,u.s2=a.s2,u}function s(a,u){var l=new n(a),c=u&&u.state,p=l.next;return p.int32=function(){return l.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,c&&(typeof c=="object"&&o(c,l),p.state=function(){return o(l,{})}),p}function i(){var a=4022871197,u=function(l){l=String(l);for(var c=0;c>>0,p-=a,p*=a,a=p>>>0,p-=a,a+=p*4294967296}return(a>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.alea=s})(S$,typeof VI=="object"&&VI,typeof define=="function"&&define)});var T$=Oe((N$,GI)=>{(function(r,t,e){function n(i){var a=this,u="";a.x=0,a.y=0,a.z=0,a.w=0,a.next=function(){var c=a.x^a.x<<11;return a.x=a.y,a.y=a.z,a.z=a.w,a.w^=a.w>>>19^c^c>>>8},i===(i|0)?a.x=i:u+=i;for(var l=0;l>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor128=s})(N$,typeof GI=="object"&&GI,typeof define=="function"&&define)});var E$=Oe((_$,WI)=>{(function(r,t,e){function n(i){var a=this,u="";a.next=function(){var c=a.x^a.x>>>2;return a.x=a.y,a.y=a.z,a.z=a.w,a.w=a.v,(a.d=a.d+362437|0)+(a.v=a.v^a.v<<4^(c^c<<1))|0},a.x=0,a.y=0,a.z=0,a.w=0,a.v=0,i===(i|0)?a.x=i:u+=i;for(var l=0;l>>4),a.next()}function o(i,a){return a.x=i.x,a.y=i.y,a.z=i.z,a.w=i.w,a.v=i.v,a.d=i.d,a}function s(i,a){var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorwow=s})(_$,typeof WI=="object"&&WI,typeof define=="function"&&define)});var D$=Oe((A$,UI)=>{(function(r,t,e){function n(i){var a=this;a.next=function(){var l=a.x,c=a.i,p,m,f;return p=l[c],p^=p>>>7,m=p^p<<24,p=l[c+1&7],m^=p^p>>>10,p=l[c+3&7],m^=p^p>>>3,p=l[c+4&7],m^=p^p<<7,p=l[c+7&7],p=p^p<<13,m^=p^p<<9,l[c]=m,a.i=c+1&7,m};function u(l,c){var p,m,f=[];if(c===(c|0))m=f[0]=c;else for(c=""+c,p=0;p0;--p)l.next()}u(a,i)}function o(i,a){return a.x=i.x.slice(),a.i=i.i,a}function s(i,a){i==null&&(i=+new Date);var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(l.x&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorshift7=s})(A$,typeof UI=="object"&&UI,typeof define=="function"&&define)});var R$=Oe(($$,HI)=>{(function(r,t,e){function n(i){var a=this;a.next=function(){var l=a.w,c=a.X,p=a.i,m,f;return a.w=l=l+1640531527|0,f=c[p+34&127],m=c[p=p+1&127],f^=f<<13,m^=m<<17,f^=f>>>15,m^=m>>>12,f=c[p]=f^m,a.i=p,f+(l^l>>>16)|0};function u(l,c){var p,m,f,d,h,g=[],y=128;for(c===(c|0)?(m=c,c=null):(c=c+"\0",m=0,y=Math.max(y,c.length)),f=0,d=-32;d>>15,m^=m<<4,m^=m>>>13,d>=0&&(h=h+1640531527|0,p=g[d&127]^=m+h,f=p==0?f+1:0);for(f>=128&&(g[(c&&c.length||0)&127]=-1),f=127,d=4*128;d>0;--d)m=g[f+34&127],p=g[f=f+1&127],m^=m<<13,p^=p<<17,m^=m>>>15,p^=p>>>12,g[f]=m^p;l.w=h,l.X=g,l.i=f}u(a,i)}function o(i,a){return a.i=i.i,a.w=i.w,a.X=i.X.slice(),a}function s(i,a){i==null&&(i=+new Date);var u=new n(i),l=a&&a.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(l.X&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor4096=s})($$,typeof HI=="object"&&HI,typeof define=="function"&&define)});var O$=Oe((F$,qI)=>{(function(r,t,e){function n(i){var a=this,u="";a.next=function(){var c=a.b,p=a.c,m=a.d,f=a.a;return c=c<<25^c>>>7^p,p=p-m|0,m=m<<24^m>>>8^f,f=f-c|0,a.b=c=c<<20^c>>>12^p,a.c=p=p-m|0,a.d=m<<16^p>>>16^f,a.a=f-c|0},a.a=0,a.b=0,a.c=-1640531527,a.d=1367130551,i===Math.floor(i)?(a.a=i/4294967296|0,a.b=i|0):u+=i;for(var l=0;l>>0)/4294967296};return c.double=function(){do var p=u.next()>>>11,m=(u.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=u.next,c.quick=c,l&&(typeof l=="object"&&o(l,u),c.state=function(){return o(u,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.tychei=s})(F$,typeof qI=="object"&&qI,typeof define=="function"&&define)});var M$=Oe((P$,Ry)=>{(function(r,t,e){var n=256,o=6,s=52,i="random",a=e.pow(n,o),u=e.pow(2,s),l=u*2,c=n-1,p;function m(w,v,k){var E=[];v=v==!0?{entropy:!0}:v||{};var D=g(h(v.entropy?[w,b(t)]:w==null?y():w,3),E),$=new f(E),R=function(){for(var M=$.g(o),W=a,U=0;M=l;)M/=2,W/=2,U>>>=1;return(M+U)/W};return R.int32=function(){return $.g(4)|0},R.quick=function(){return $.g(4)/4294967296},R.double=R,g(b($.S),t),(v.pass||k||function(M,W,U,q){return q&&(q.S&&d(q,$),M.state=function(){return d($,{})}),U?(e[i]=M,W):M})(R,D,"global"in v?v.global:this==e,v.state)}function f(w){var v,k=w.length,E=this,D=0,$=E.i=E.j=0,R=E.S=[];for(k||(w=[k++]);D{var aZ=k$(),lZ=T$(),uZ=E$(),cZ=D$(),pZ=R$(),mZ=O$(),Ic=M$();Ic.alea=aZ;Ic.xor128=lZ;Ic.xorwow=uZ;Ic.xorshift7=cZ;Ic.xor4096=pZ;Ic.tychei=mZ;L$.exports=Ic});var jI=Oe(()=>{});var By=Oe(()=>{});var xg=Oe(()=>{});var uW=Oe(()=>{});var cW=Oe(()=>{});var pW=Oe(()=>{});var mW=Oe((Gb,xT)=>{var gT=(()=>{var r=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(r=r||__filename),function(t){t=t||{};function e(){return Ot.buffer!=gr&&Bo(Ot.buffer),Uc}function n(){return Ot.buffer!=gr&&Bo(Ot.buffer),Hc}function o(){return Ot.buffer!=gr&&Bo(Ot.buffer),ef}function s(){return Ot.buffer!=gr&&Bo(Ot.buffer),vg}function i(){return Ot.buffer!=gr&&Bo(Ot.buffer),Cg}function a(){return Ot.buffer!=gr&&Bo(Ot.buffer),Ig}function u(){return Ot.buffer!=gr&&Bo(Ot.buffer),Sg}var l=typeof t!="undefined"?t:{},c,p;l.ready=new Promise(function(T,F){c=T,p=F});var m;typeof process!="undefined"&&process.listeners&&(m={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var f=Object.assign({},l),d=[],h="./this.program",g=(T,F)=>{throw F},y=typeof window=="object",b=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v=l.ENVIRONMENT_IS_PTHREAD||!1,k="";function E(T){return l.locateFile?l.locateFile(T,k):k+T}var D,$,R,M;function W(T){if(T instanceof mf)return;X("exiting due to exception: "+T)}var U,q,K;if(w){b?k=xg().dirname(k)+"/":k=__dirname+"/",K=()=>{q||(U=By(),q=xg())},D=function(G,Y){return K(),G=q.normalize(G),U.readFileSync(G,Y?void 0:"utf8")},R=F=>{var G=D(F,!0);return G.buffer||(G=new Uint8Array(G)),G},$=(F,G,Y)=>{K(),F=q.normalize(F),U.readFile(F,function(ht,wt){ht?Y(ht):G(wt.buffer)})},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),d=process.argv.slice(2),process.on("uncaughtException",function(F){if(!(F instanceof mf))throw F}),process.on("unhandledRejection",function(F){throw F}),g=(F,G)=>{if(mu())throw process.exitCode=F,G;W(G),process.exit(F)},l.inspect=function(){return"[Emscripten Module object]"};let T;try{T=uW()}catch(F){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),F}global.Worker=T.Worker}else(y||b)&&(b?k=self.location.href:typeof document!="undefined"&&document.currentScript&&(k=document.currentScript.src),typeof r!="undefined"&&r&&(k=r),k.indexOf("blob:")!==0?k=k.substr(0,k.replace(/[?#].*/,"").lastIndexOf("/")+1):k="",w||(D=T=>{var F=new XMLHttpRequest;return F.open("GET",T,!1),F.send(null),F.responseText},b&&(R=T=>{var F=new XMLHttpRequest;return F.open("GET",T,!1),F.responseType="arraybuffer",F.send(null),new Uint8Array(F.response)}),$=(T,F,G)=>{var Y=new XMLHttpRequest;Y.open("GET",T,!0),Y.responseType="arraybuffer",Y.onload=()=>{if(Y.status==200||Y.status==0&&Y.response){F(Y.response);return}G()},Y.onerror=G,Y.send(null)}),M=T=>document.title=T);w&&typeof performance=="undefined"&&(global.performance=cW().performance);var j=console.log.bind(console),Q=console.warn.bind(console);w&&(K(),j=T=>U.writeSync(1,T+` `),Q=T=>U.writeSync(2,T+` `));var rt=l.print||j,X=l.printErr||Q;Object.assign(l,f),f=null,l.arguments&&(d=l.arguments),l.thisProgram&&(h=l.thisProgram),l.quit&&(g=l.quit);var ot=4;function st(T){st.shown||(st.shown={}),st.shown[T]||(st.shown[T]=1,X(T))}function it(T,F){if(typeof WebAssembly.Function=="function"){for(var G={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:F[0]=="v"?[]:[G[F[0]]]},ht=1;ht{bt=T},At=Atomics.load,$t=Atomics.store,qt=Atomics.compareExchange,Kt;l.wasmBinary&&(Kt=l.wasmBinary);var ce=l.noExitRuntime||!0;typeof WebAssembly!="object"&&Kc("no native wasm support detected");var Ot,Ae,Ie=!1,ae;function je(T,F){T||Kc(F)}function Fe(T){var F=l["_"+T];return F}function Jr(T,F,G,Y,ht){var wt={string:function(Rn){var np=0;if(Rn!=null&&Rn!==0){var WT=(Rn.length<<2)+1;np=rp(WT),$n(Rn,np,WT)}return np},array:function(Rn){var np=rp(Rn.length);return gl(Rn,np),np}};function Nt(Rn){return F==="string"?Hr(Rn):F==="boolean"?Boolean(Rn):Rn}var Bt=Fe(T),or=[],Uo=0;if(Y)for(var Ho=0;Ho(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),F.decode.call(F,G))}var Qr=typeof TextDecoder!="undefined"?new Fr("utf8"):void 0;function tn(T,F,G){for(var Y=F+G,ht=F;T[ht]&&!(ht>=Y);)++ht;if(ht-F>16&&T.subarray&&Qr)return Qr.decode(T.subarray(F,ht));for(var wt="";F>10,56320|Uo&1023)}}return wt}function Hr(T,F){return T?tn(n(),T,F):""}function ro(T,F,G,Y){if(!(Y>0))return 0;for(var ht=G,wt=G+Y-1,Nt=0;Nt=55296&&Bt<=57343){var or=T.charCodeAt(++Nt);Bt=65536+((Bt&1023)<<10)|or&1023}if(Bt<=127){if(G>=wt)break;F[G++]=Bt}else if(Bt<=2047){if(G+1>=wt)break;F[G++]=192|Bt>>6,F[G++]=128|Bt&63}else if(Bt<=65535){if(G+2>=wt)break;F[G++]=224|Bt>>12,F[G++]=128|Bt>>6&63,F[G++]=128|Bt&63}else{if(G+3>=wt)break;F[G++]=240|Bt>>18,F[G++]=128|Bt>>12&63,F[G++]=128|Bt>>6&63,F[G++]=128|Bt&63}}return F[G]=0,G-ht}function $n(T,F,G){return ro(T,n(),F,G)}function zo(T){for(var F=0,G=0;G=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|T.charCodeAt(++G)&1023),Y<=127?++F:Y<=2047?F+=2:Y<=65535?F+=3:F+=4}return F}var no=typeof TextDecoder!="undefined"?new Fr("utf-16le"):void 0;function gl(T,F){e().set(T,F)}function cu(T,F,G){for(var Y=0;Y>0]=T.charCodeAt(Y);G||(e()[F>>0]=0)}function Wc(T,F){return T%F>0&&(T+=F-T%F),T}var gr,Uc,Hc,ef,vg,Cg,IT,Ig,Sg;v&&(gr=l.buffer);function Bo(T){gr=T,l.HEAP8=Uc=new Int8Array(T),l.HEAP16=ef=new Int16Array(T),l.HEAP32=Cg=new Int32Array(T),l.HEAPU8=Hc=new Uint8Array(T),l.HEAPU16=vg=new Uint16Array(T),l.HEAPU32=IT=new Uint32Array(T),l.HEAPF32=Ig=new Float32Array(T),l.HEAPF64=Sg=new Float64Array(T)}var kg=l.INITIAL_MEMORY||16777216;if(v)Ot=l.wasmMemory,gr=l.buffer;else if(l.wasmMemory)Ot=l.wasmMemory;else if(Ot=new WebAssembly.Memory({initial:kg/65536,maximum:32768,shared:!0}),!(Ot.buffer instanceof SharedArrayBuffer))throw X("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"),w&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Ot&&(gr=Ot.buffer),kg=gr.byteLength,Bo(gr);var Un,qc=[],xl=[],qb=[],Ng=[],pu=!1,Kb=!1,Tg=0;function mu(){return ce||Tg>0}function en(){if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)ST(l.preRun.shift());Dg(qc)}function rf(){pu=!0,!v&&Dg(xl)}function jb(){v||(Ht.terminateAllThreads(),Kb=!0)}function Xb(){if(!v){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;)nf(l.postRun.shift());Dg(Ng)}}function ST(T){qc.unshift(T)}function kT(T){xl.unshift(T)}function nf(T){Ng.unshift(T)}var yl=0,_g=null,Vo=null;function of(T){yl++,l.monitorRunDependencies&&l.monitorRunDependencies(yl)}function NT(T){if(yl--,l.monitorRunDependencies&&l.monitorRunDependencies(yl),yl==0&&(_g!==null&&(clearInterval(_g),_g=null),Vo)){var F=Vo;Vo=null,F()}}l.preloadedImages={},l.preloadedAudios={};function Kc(T){v?postMessage({cmd:"onAbort",arg:T}):l.onAbort&&l.onAbort(T),T="Aborted("+T+")",X(T),Ie=!0,ae=1,T+=". Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(T);throw p(F),F}var Yb="data:application/octet-stream;base64,";function sf(T){return T.startsWith(Yb)}function Eg(T){return T.startsWith("file://")}var rn;rn="tfjs-backend-wasm-threaded-simd.wasm",sf(rn)||(rn=E(rn));function Ag(T){try{if(T==rn&&Kt)return new Uint8Array(Kt);if(R)return R(T);throw"both async and sync fetching of the wasm failed"}catch(F){Kc(F)}}function jc(){if(!Kt&&(y||b)){if(typeof fetch=="function"&&!Eg(rn))return fetch(rn,{credentials:"same-origin"}).then(function(T){if(!T.ok)throw"failed to load wasm binary file at '"+rn+"'";return T.arrayBuffer()}).catch(function(){return Ag(rn)});if($)return new Promise(function(T,F){$(rn,function(G){T(new Uint8Array(G))},F)})}return Promise.resolve().then(function(){return Ag(rn)})}function Zb(){var T={env:Wg,wasi_snapshot_preview1:Wg};function F(Nt,Bt){var or=Nt.exports;if(l.asm=or,ow(l.asm.emscripten_tls_init),Un=l.asm.__indirect_function_table,kT(l.asm.__wasm_call_ctors),Ae=Bt,!v){var Uo=Ht.unusedWorkers.length;Ht.unusedWorkers.forEach(function(Ho){Ht.loadWasmModuleToWorker(Ho,function(){--Uo||NT("wasm-instantiate")})})}}v||of("wasm-instantiate");function G(Nt){F(Nt.instance,Nt.module)}function Y(Nt){return jc().then(function(Bt){return WebAssembly.instantiate(Bt,T)}).then(function(Bt){return Bt}).then(Nt,function(Bt){X("failed to asynchronously prepare wasm: "+Bt),Kc(Bt)})}function ht(){return!Kt&&typeof WebAssembly.instantiateStreaming=="function"&&!sf(rn)&&!Eg(rn)&&typeof fetch=="function"?fetch(rn,{credentials:"same-origin"}).then(function(Nt){var Bt=WebAssembly.instantiateStreaming(Nt,T);return Bt.then(G,function(or){return X("wasm streaming compile failed: "+or),X("falling back to ArrayBuffer instantiation"),Y(G)})}):Y(G)}if(l.instantiateWasm)try{var wt=l.instantiateWasm(T,F);return wt}catch(Nt){return X("Module.instantiateWasm callback failed with error: "+Nt),!1}return ht().catch(p),{}}var TT,_T,Jb={};function Dg(T){for(;T.length>0;){var F=T.shift();if(typeof F=="function"){F(l);continue}var G=F.func;typeof G=="number"?F.arg===void 0?Yc(G)():Yc(G)(F.arg):G(F.arg===void 0?null:F.arg)}}function Xc(T){var F=vv(),G=T();return jg(F),G}function bW(T){return T}function ET(T){var F=/\b_Z[\w\d_]+/g;return T.replace(F,function(G){var Y=G;return G===Y?G:Y+" ["+G+"]"})}function Qb(T){i()[T>>2]=0;var F=Ht.pthreads[T];delete Ht.pthreads[T],F.worker.terminate(),wv(T),Ht.runningWorkers.splice(Ht.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function tw(T){var F=Ht.pthreads[T];F.worker.postMessage({cmd:"cancel"})}function $g(T){var F=Ht.pthreads[T];if(F){i()[T>>2]=0;var G=F.worker;Ht.returnWorkerToPool(G)}}function Rg(T){lU(T)}function ew(T){if(T instanceof mf||T=="unwind")return ae;g(1,T)}var Ht={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){v?Ht.initWorker():Ht.initMainThread()},initMainThread:function(){for(var T=8,F=0;F>2]=0;try{T()}finally{i()[GT>>2]=1}},receiveObjectTransfer:function(T){},threadInit:function(){for(var T in Ht.tlsInitFunctions)Ht.tlsInitFunctions[T]()},loadWasmModuleToWorker:function(T,F){T.onmessage=G=>{var Y=G.data,ht=Y.cmd;if(T.pthread&&(Ht.currentProxiedOperationCallerThread=T.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=Kg()){var wt=Ht.pthreads[Y.targetThread];wt?wt.worker.postMessage(Y,Y.transferList):X('Internal error! Worker sent a message "'+ht+'" to target pthread '+Y.targetThread+", but that thread no longer exists!"),Ht.currentProxiedOperationCallerThread=void 0;return}ht==="processQueuedMainThreadWork"?MT():ht==="spawnThread"?Og(Y):ht==="cleanupThread"?$g(Y.thread):ht==="killThread"?Qb(Y.thread):ht==="cancelThread"?tw(Y.thread):ht==="loaded"?(T.loaded=!0,F&&F(T),T.runPthread&&(T.runPthread(),delete T.runPthread)):ht==="print"?rt("Thread "+Y.threadId+": "+Y.text):ht==="printErr"?X("Thread "+Y.threadId+": "+Y.text):ht==="alert"?alert("Thread "+Y.threadId+": "+Y.text):Y.target==="setimmediate"?T.postMessage(Y):ht==="onAbort"?l.onAbort&&l.onAbort(Y.arg):X("worker sent an unknown command "+ht),Ht.currentProxiedOperationCallerThread=void 0},T.onerror=G=>{var Y="worker sent an error!";throw X(Y+" "+G.filename+":"+G.lineno+": "+G.message),G},w&&(T.on("message",function(G){T.onmessage({data:G})}),T.on("error",function(G){T.onerror(G)}),T.on("detachedExit",function(){})),T.postMessage({cmd:"load",urlOrBlob:l.mainScriptUrlOrBlob||r,wasmMemory:Ot,wasmModule:Ae})},allocateUnusedWorker:function(){var T=E("tfjs-backend-wasm-threaded-simd.worker.js");Ht.unusedWorkers.push(new Worker(T))},getNewWorker:function(){return Ht.unusedWorkers.length==0&&(Ht.allocateUnusedWorker(),Ht.loadWasmModuleToWorker(Ht.unusedWorkers[0])),Ht.unusedWorkers.pop()}};function rw(){var T=Kg(),F=i()[T+44>>2],G=i()[T+48>>2],Y=F-G;VT(F,Y),jg(F)}l.establishStackSpace=rw;function Fg(T){if(v)return hu(1,0,T);try{Rg(T)}catch(F){ew(F)}}var fu=[];function Yc(T){var F=fu[T];return F||(T>=fu.length&&(fu.length=T+1),fu[T]=F=Un.get(T)),F}function nw(T,F){return Yc(T)(F)}l.invokeEntryPoint=nw;function AT(){var T=new Error;if(!T.stack){try{throw new Error}catch(F){T=F}if(!T.stack)return"(no stack trace available)"}return T.stack.toString()}function ow(T,F,G){Ht.tlsInitFunctions.push(T)}function DT(T,F){Un.set(T,F),fu[T]=F}var du;w?du=()=>{var T=process.hrtime();return T[0]*1e3+T[1]/1e6}:v?du=()=>performance.now()-l.__performance_now_clock_drift:du=()=>performance.now();var sw=!0;function iw(T){return i()[PT()>>2]=T,T}function aw(T,F){var G;if(T===0)G=Date.now();else if((T===1||T===4)&&sw)G=du();else return iw(28),-1;return i()[F>>2]=G/1e3|0,i()[F+4>>2]=G%1e3*1e3*1e3|0,0}function lw(T,F){return aw(T,F)}function uw(T){LT(T,!b,1,!y),Ht.threadInit()}function cw(T){v?postMessage({cmd:"cleanupThread",thread:T}):$g(T)}function Og(T){var F=Ht.getNewWorker();if(!F)return 6;Ht.runningWorkers.push(F);var G=Ht.pthreads[T.pthread_ptr]={worker:F,threadInfoStruct:T.pthread_ptr};F.pthread=G;var Y={cmd:"run",start_routine:T.startRoutine,arg:T.arg,threadInfoStruct:T.pthread_ptr};return F.runPthread=()=>{Y.time=performance.now(),F.postMessage(Y,T.transferList)},F.loaded&&(F.runPthread(),delete F.runPthread),0}function pw(T,F,G,Y){if(typeof SharedArrayBuffer=="undefined")return X("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ht=[],wt=0;if(v&&(ht.length===0||wt))return zT(687865856,T,F,G,Y);if(wt)return wt;var Nt={startRoutine:G,pthread_ptr:T,arg:Y,transferList:ht};return v?(Nt.cmd="spawnThread",postMessage(Nt,ht),0):Og(Nt)}function mw(){return 2097152}function fw(T,F){if(T==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(v)postMessage({targetThread:T,cmd:"processThreadQueue"});else{var G=Ht.pthreads[T],Y=G&&G.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function dw(){Kc("")}function hw(){w||b||st("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function Pg(){return 2147483648}function gw(T,F,G){n().copyWithin(T,F,F+G)}function xw(){return w?pW().cpus().length:navigator.hardwareConcurrency}function hu(T,F){var G=arguments.length-2,Y=arguments;return Xc(function(){for(var ht=G,wt=rp(ht*8),Nt=wt>>3,Bt=0;Bt>3,ht=0;ht>>16),Bo(Ot.buffer),1}catch(F){}}function ww(T){var F=n().length;if(T=T>>>0,T<=F)return!1;var G=Pg();if(T>G)return!1;for(var Y=1;Y<=4;Y*=2){var ht=F*(1+.2/Y);ht=Math.min(ht,T+100663296);var wt=Math.min(G,Wc(Math.max(T,ht),65536)),Nt=bw(wt);if(Nt)return!0}return!1}var ee={inEventHandler:0,removeAllEventListeners:function(){for(var T=ee.eventHandlers.length-1;T>=0;--T)ee._removeHandler(T);ee.eventHandlers=[],ee.deferredCalls=[]},registerRemoveEventListeners:function(){ee.removeEventListenersRegistered||(qb.push(ee.removeAllEventListeners),ee.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(T,F,G){function Y(Nt,Bt){if(Nt.length!=Bt.length)return!1;for(var or in Nt)if(Nt[or]!=Bt[or])return!1;return!0}for(var ht in ee.deferredCalls){var wt=ee.deferredCalls[ht];if(wt.targetFunction==T&&Y(wt.argsList,G))return}ee.deferredCalls.push({targetFunction:T,precedence:F,argsList:G}),ee.deferredCalls.sort(function(Nt,Bt){return Nt.precedence>2]=G,i()[wt+4>>2]=Y,i()[wt+8>>2]=ht,bv(T,637534208,F,Y,wt)})},getTargetThreadForEventCallback:function(T){switch(T){case 1:return 0;case 2:return Ht.currentProxiedOperationCallerThread;default:return T}},getNodeNameForTarget:function(T){return T?T==window?"#window":T==screen?"#screen":T&&T.nodeName?T.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function vw(T){var F=zo(T)+1,G=yv(F);return $n(T,G,F),G}function Cw(T,F,G,Y){Xc(function(){var ht=rp(12),wt=0;F&&(wt=vw(F)),i()[ht>>2]=wt,i()[ht+4>>2]=G,i()[ht+8>>2]=Y,bv(T,657457152,0,wt,ht)})}function Iw(T,F,G,Y){F=F?Hr(F):"",Cw(T,F,G,Y)}function Sw(T){return T>2?Hr(T):T}var kw=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Nw(T){T=Sw(T);var F=kw[T]||(typeof document!="undefined"?document.querySelector(T):void 0);return F}function lf(T){return Nw(T)}function Mg(T,F,G){var Y=lf(T);if(!Y)return-4;if(Y.canvasSharedPtr&&(i()[Y.canvasSharedPtr>>2]=F,i()[Y.canvasSharedPtr+4>>2]=G),Y.offscreenCanvas||!Y.controlTransferredOffscreen){Y.offscreenCanvas&&(Y=Y.offscreenCanvas);var ht=!1;if(Y.GLctxObject&&Y.GLctxObject.GLctx){var wt=Y.GLctxObject.GLctx.getParameter(2978);ht=wt[0]===0&&wt[1]===0&&wt[2]===Y.width&&wt[3]===Y.height}Y.width=F,Y.height=G,ht&&Y.GLctxObject.GLctx.viewport(0,0,F,G)}else if(Y.canvasSharedPtr){var Nt=i()[Y.canvasSharedPtr+8>>2];return Iw(Nt,T,F,G),1}else return-4;return 0}function Lg(T,F,G){return v?hu(2,1,T,F,G):Mg(T,F,G)}function Tw(T,F,G){var Y=lf(T);return Y?Mg(T,F,G):Lg(T,F,G)}function _w(){throw"unwind"}function Ew(T){var F=T.getExtension("ANGLE_instanced_arrays");if(F)return T.vertexAttribDivisor=function(G,Y){F.vertexAttribDivisorANGLE(G,Y)},T.drawArraysInstanced=function(G,Y,ht,wt){F.drawArraysInstancedANGLE(G,Y,ht,wt)},T.drawElementsInstanced=function(G,Y,ht,wt,Nt){F.drawElementsInstancedANGLE(G,Y,ht,wt,Nt)},1}function Aw(T){var F=T.getExtension("OES_vertex_array_object");if(F)return T.createVertexArray=function(){return F.createVertexArrayOES()},T.deleteVertexArray=function(G){F.deleteVertexArrayOES(G)},T.bindVertexArray=function(G){F.bindVertexArrayOES(G)},T.isVertexArray=function(G){return F.isVertexArrayOES(G)},1}function Dw(T){var F=T.getExtension("WEBGL_draw_buffers");if(F)return T.drawBuffers=function(G,Y){F.drawBuffersWEBGL(G,Y)},1}function $w(T){return!!(T.multiDrawWebgl=T.getExtension("WEBGL_multi_draw"))}var nr={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(F){nr.lastError||(nr.lastError=F)},getNewId:function(T){for(var F=nr.counter++,G=T.length;G>2]:-1;ht+=Hr(i()[G+wt*4>>2],Nt<0?void 0:Nt)}return ht},createContext:function(T,F){T.getContextSafariWebGL2Fixed||(T.getContextSafariWebGL2Fixed=T.getContext,T.getContext=function(ht,wt){var Nt=T.getContextSafariWebGL2Fixed(ht,wt);return ht=="webgl"==Nt instanceof WebGLRenderingContext?Nt:null});var G=T.getContext("webgl",F);if(!G)return 0;var Y=nr.registerContext(G,F);return Y},registerContext:function(T,F){var G=yv(8);i()[G+4>>2]=Kg();var Y={handle:G,attributes:F,version:F.majorVersion,GLctx:T};return T.canvas&&(T.canvas.GLctxObject=Y),nr.contexts[G]=Y,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&nr.initExtensions(Y),G},makeContextCurrent:function(T){return nr.currentContext=nr.contexts[T],l.ctx=Gg=nr.currentContext&&nr.currentContext.GLctx,!(T&&!Gg)},getContext:function(T){return nr.contexts[T]},deleteContext:function(T){nr.currentContext===nr.contexts[T]&&(nr.currentContext=null),typeof ee=="object"&&ee.removeAllHandlersOnTarget(nr.contexts[T].GLctx.canvas),nr.contexts[T]&&nr.contexts[T].GLctx.canvas&&(nr.contexts[T].GLctx.canvas.GLctxObject=void 0),OT(nr.contexts[T].handle),nr.contexts[T]=null},initExtensions:function(T){if(T||(T=nr.currentContext),!T.initExtensionsDone){T.initExtensionsDone=!0;var F=T.GLctx;Ew(F),Aw(F),Dw(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),$w(F);var G=F.getSupportedExtensions()||[];G.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&F.getExtension(Y)})}}},Rw=["default","low-power","high-performance"];function Fw(T,F){var G=F>>2,Y=i()[G+6],ht={alpha:!!i()[G+0],depth:!!i()[G+1],stencil:!!i()[G+2],antialias:!!i()[G+3],premultipliedAlpha:!!i()[G+4],preserveDrawingBuffer:!!i()[G+5],powerPreference:Rw[Y],failIfMajorPerformanceCaveat:!!i()[G+7],majorVersion:i()[G+8],minorVersion:i()[G+9],enableExtensionsByDefault:i()[G+10],explicitSwapControl:i()[G+11],proxyContextToMainThread:i()[G+12],renderViaOffscreenBackBuffer:i()[G+13]},wt=lf(T);if(!wt||ht.explicitSwapControl)return 0;var Nt=nr.createContext(wt,ht);return Nt}function Ow(T,F){return Fw(T,F)}var Zc={mappings:{},buffers:[null,[],[]],printChar:function(T,F){var G=Zc.buffers[T];F===0||F===10?((T===1?rt:X)(tn(G,0)),G.length=0):G.push(F)},varargs:void 0,get:function(){Zc.varargs+=4;var T=i()[Zc.varargs-4>>2];return T},getStr:function(T){var F=Hr(T);return F},get64:function(T,F){return T}};function zg(T){return v?hu(3,1,T):0}function Bg(T,F,G,Y,ht){if(v)return hu(4,1,T,F,G,Y,ht)}function Vg(T,F,G,Y){if(v)return hu(5,1,T,F,G,Y);for(var ht=0,wt=0;wt>2],Bt=i()[F+4>>2];F+=8;for(var or=0;or>2]=ht,0}function Pw(T){kt(T)}Ht.init();var Gg,Mw=[null,Fg,Lg,zg,Bg,Vg],$T=!1,Wg={__clock_gettime:lw,__emscripten_init_main_thread_js:uw,__emscripten_thread_cleanup:cw,__pthread_create_js:pw,_emscripten_default_pthread_stack_size:mw,_emscripten_notify_thread_queue:fw,abort:dw,emscripten_check_blocking_allowed:hw,emscripten_get_heap_max:Pg,emscripten_get_now:du,emscripten_memcpy_big:gw,emscripten_num_logical_cores:xw,emscripten_receive_on_main_thread_js:yw,emscripten_resize_heap:ww,emscripten_set_canvas_element_size:Tw,emscripten_unwind_to_js_event_loop:_w,emscripten_webgl_create_context:Ow,exit:Rg,fd_close:zg,fd_seek:Bg,fd_write:Vg,memory:Ot||l.wasmMemory,setTempRet0:Pw},RT=Zb(),Lw=l.___wasm_call_ctors=function(){return(Lw=l.___wasm_call_ctors=l.asm.__wasm_call_ctors).apply(null,arguments)},zw=l._init=function(){return(zw=l._init=l.asm.init).apply(null,arguments)},Bw=l._init_with_threads_count=function(){return(Bw=l._init_with_threads_count=l.asm.init_with_threads_count).apply(null,arguments)},Vw=l._get_threads_count=function(){return(Vw=l._get_threads_count=l.asm.get_threads_count).apply(null,arguments)},Gw=l._register_tensor=function(){return(Gw=l._register_tensor=l.asm.register_tensor).apply(null,arguments)},Ww=l._dispose_data=function(){return(Ww=l._dispose_data=l.asm.dispose_data).apply(null,arguments)},Uw=l._dispose=function(){return(Uw=l._dispose=l.asm.dispose).apply(null,arguments)},Hw=l._Abs=function(){return(Hw=l._Abs=l.asm.Abs).apply(null,arguments)},qw=l._Add=function(){return(qw=l._Add=l.asm.Add).apply(null,arguments)},Kw=l._AddN=function(){return(Kw=l._AddN=l.asm.AddN).apply(null,arguments)},jw=l._All=function(){return(jw=l._All=l.asm.All).apply(null,arguments)},Xw=l._Any=function(){return(Xw=l._Any=l.asm.Any).apply(null,arguments)},Yw=l._ArgMax=function(){return(Yw=l._ArgMax=l.asm.ArgMax).apply(null,arguments)},Zw=l._AvgPool=function(){return(Zw=l._AvgPool=l.asm.AvgPool).apply(null,arguments)},Jw=l._BatchMatMul=function(){return(Jw=l._BatchMatMul=l.asm.BatchMatMul).apply(null,arguments)},Qw=l._Ceil=function(){return(Qw=l._Ceil=l.asm.Ceil).apply(null,arguments)},tv=l._ClipByValue=function(){return(tv=l._ClipByValue=l.asm.ClipByValue).apply(null,arguments)},ev=l._Conv2D=function(){return(ev=l._Conv2D=l.asm.Conv2D).apply(null,arguments)},rv=l._Conv2DBackpropInput=function(){return(rv=l._Conv2DBackpropInput=l.asm.Conv2DBackpropInput).apply(null,arguments)},nv=l._Cos=function(){return(nv=l._Cos=l.asm.Cos).apply(null,arguments)},ov=l._Cosh=function(){return(ov=l._Cosh=l.asm.Cosh).apply(null,arguments)},sv=l._CropAndResize=function(){return(sv=l._CropAndResize=l.asm.CropAndResize).apply(null,arguments)},iv=l._Cumprod=function(){return(iv=l._Cumprod=l.asm.Cumprod).apply(null,arguments)},av=l._Cumsum=function(){return(av=l._Cumsum=l.asm.Cumsum).apply(null,arguments)},lv=l._DepthToSpace=function(){return(lv=l._DepthToSpace=l.asm.DepthToSpace).apply(null,arguments)},uv=l._DepthwiseConv2dNative=function(){return(uv=l._DepthwiseConv2dNative=l.asm.DepthwiseConv2dNative).apply(null,arguments)},cv=l._Elu=function(){return(cv=l._Elu=l.asm.Elu).apply(null,arguments)},pv=l._Equal=function(){return(pv=l._Equal=l.asm.Equal).apply(null,arguments)},mv=l._Exp=function(){return(mv=l._Exp=l.asm.Exp).apply(null,arguments)},fv=l._FlipLeftRight=function(){return(fv=l._FlipLeftRight=l.asm.FlipLeftRight).apply(null,arguments)},Ug=l._Floor=function(){return(Ug=l._Floor=l.asm.Floor).apply(null,arguments)},Hg=l._FloorDiv=function(){return(Hg=l._FloorDiv=l.asm.FloorDiv).apply(null,arguments)},uf=l._FusedBatchNorm=function(){return(uf=l._FusedBatchNorm=l.asm.FusedBatchNorm).apply(null,arguments)},dv=l._FusedConv2D=function(){return(dv=l._FusedConv2D=l.asm.FusedConv2D).apply(null,arguments)},hv=l._FusedDepthwiseConv2D=function(){return(hv=l._FusedDepthwiseConv2D=l.asm.FusedDepthwiseConv2D).apply(null,arguments)},Jc=l._Gather=function(){return(Jc=l._Gather=l.asm.Gather).apply(null,arguments)},cf=l._GatherNd=function(){return(cf=l._GatherNd=l.asm.GatherNd).apply(null,arguments)},pf=l._Greater=function(){return(pf=l._Greater=l.asm.Greater).apply(null,arguments)},FT=l._GreaterEqual=function(){return(FT=l._GreaterEqual=l.asm.GreaterEqual).apply(null,arguments)},Qc=l._LeakyRelu=function(){return(Qc=l._LeakyRelu=l.asm.LeakyRelu).apply(null,arguments)},tp=l._Less=function(){return(tp=l._Less=l.asm.Less).apply(null,arguments)},gv=l._LessEqual=function(){return(gv=l._LessEqual=l.asm.LessEqual).apply(null,arguments)},H=l._Log=function(){return(H=l._Log=l.asm.Log).apply(null,arguments)},tt=l._LogicalAnd=function(){return(tt=l._LogicalAnd=l.asm.LogicalAnd).apply(null,arguments)},gt=l._Max=function(){return(gt=l._Max=l.asm.Max).apply(null,arguments)},Dt=l._MaxPool=function(){return(Dt=l._MaxPool=l.asm.MaxPool).apply(null,arguments)},fe=l._Maximum=function(){return(fe=l._Maximum=l.asm.Maximum).apply(null,arguments)},he=l._Mean=function(){return(he=l._Mean=l.asm.Mean).apply(null,arguments)},oe=l._Min=function(){return(oe=l._Min=l.asm.Min).apply(null,arguments)},Qt=l._Minimum=function(){return(Qt=l._Minimum=l.asm.Minimum).apply(null,arguments)},xr=l._MirrorPad=function(){return(xr=l._MirrorPad=l.asm.MirrorPad).apply(null,arguments)},Go=l._Multiply=function(){return(Go=l._Multiply=l.asm.Multiply).apply(null,arguments)},Wo=l._Neg=function(){return(Wo=l._Neg=l.asm.Neg).apply(null,arguments)},ep=l._NonMaxSuppressionV3=function(){return(ep=l._NonMaxSuppressionV3=l.asm.NonMaxSuppressionV3).apply(null,arguments)},gu=l._NonMaxSuppressionV4=function(){return(gu=l._NonMaxSuppressionV4=l.asm.NonMaxSuppressionV4).apply(null,arguments)},xv=l._NonMaxSuppressionV5=function(){return(xv=l._NonMaxSuppressionV5=l.asm.NonMaxSuppressionV5).apply(null,arguments)},nn=l._NotEqual=function(){return(nn=l._NotEqual=l.asm.NotEqual).apply(null,arguments)},bl=l._OneHot=function(){return(bl=l._OneHot=l.asm.OneHot).apply(null,arguments)},qg=l._PadV2=function(){return(qg=l._PadV2=l.asm.PadV2).apply(null,arguments)},wW=l._Pow=function(){return(wW=l._Pow=l.asm.Pow).apply(null,arguments)},vW=l._Prelu=function(){return(vW=l._Prelu=l.asm.Prelu).apply(null,arguments)},CW=l._Prod=function(){return(CW=l._Prod=l.asm.Prod).apply(null,arguments)},IW=l._RealDiv=function(){return(IW=l._RealDiv=l.asm.RealDiv).apply(null,arguments)},SW=l._Relu=function(){return(SW=l._Relu=l.asm.Relu).apply(null,arguments)},kW=l._Relu6=function(){return(kW=l._Relu6=l.asm.Relu6).apply(null,arguments)},NW=l._ResizeBilinear=function(){return(NW=l._ResizeBilinear=l.asm.ResizeBilinear).apply(null,arguments)},TW=l._Reverse=function(){return(TW=l._Reverse=l.asm.Reverse).apply(null,arguments)},_W=l._RotateWithOffset=function(){return(_W=l._RotateWithOffset=l.asm.RotateWithOffset).apply(null,arguments)},EW=l._Round=function(){return(EW=l._Round=l.asm.Round).apply(null,arguments)},AW=l._Rsqrt=function(){return(AW=l._Rsqrt=l.asm.Rsqrt).apply(null,arguments)},DW=l._ScatterNd=function(){return(DW=l._ScatterNd=l.asm.ScatterNd).apply(null,arguments)},$W=l._SelectV2=function(){return($W=l._SelectV2=l.asm.SelectV2).apply(null,arguments)},RW=l._Sigmoid=function(){return(RW=l._Sigmoid=l.asm.Sigmoid).apply(null,arguments)},FW=l._Sin=function(){return(FW=l._Sin=l.asm.Sin).apply(null,arguments)},OW=l._Softmax=function(){return(OW=l._Softmax=l.asm.Softmax).apply(null,arguments)},PW=l._SparseFillEmptyRows=function(){return(PW=l._SparseFillEmptyRows=l.asm.SparseFillEmptyRows).apply(null,arguments)},MW=l._SparseReshape=function(){return(MW=l._SparseReshape=l.asm.SparseReshape).apply(null,arguments)},LW=l._SparseSegmentReduction=function(){return(LW=l._SparseSegmentReduction=l.asm.SparseSegmentReduction).apply(null,arguments)},zW=l._Sqrt=function(){return(zW=l._Sqrt=l.asm.Sqrt).apply(null,arguments)},BW=l._Square=function(){return(BW=l._Square=l.asm.Square).apply(null,arguments)},VW=l._SquaredDifference=function(){return(VW=l._SquaredDifference=l.asm.SquaredDifference).apply(null,arguments)},GW=l._Step=function(){return(GW=l._Step=l.asm.Step).apply(null,arguments)},WW=l._StridedSlice=function(){return(WW=l._StridedSlice=l.asm.StridedSlice).apply(null,arguments)},UW=l._Sub=function(){return(UW=l._Sub=l.asm.Sub).apply(null,arguments)},HW=l._Sum=function(){return(HW=l._Sum=l.asm.Sum).apply(null,arguments)},qW=l._Tan=function(){return(qW=l._Tan=l.asm.Tan).apply(null,arguments)},KW=l._Tanh=function(){return(KW=l._Tanh=l.asm.Tanh).apply(null,arguments)},jW=l._Tile=function(){return(jW=l._Tile=l.asm.Tile).apply(null,arguments)},XW=l._TopK=function(){return(XW=l._TopK=l.asm.TopK).apply(null,arguments)},YW=l._Transform=function(){return(YW=l._Transform=l.asm.Transform).apply(null,arguments)},ZW=l._Transpose=function(){return(ZW=l._Transpose=l.asm.Transpose).apply(null,arguments)},JW=l.__FusedMatMul=function(){return(JW=l.__FusedMatMul=l.asm._FusedMatMul).apply(null,arguments)},yv=l._malloc=function(){return(yv=l._malloc=l.asm.malloc).apply(null,arguments)},OT=l._free=function(){return(OT=l._free=l.asm.free).apply(null,arguments)},QW=l._emscripten_tls_init=function(){return(QW=l._emscripten_tls_init=l.asm.emscripten_tls_init).apply(null,arguments)},PT=l.___errno_location=function(){return(PT=l.___errno_location=l.asm.__errno_location).apply(null,arguments)},Kg=l._pthread_self=function(){return(Kg=l._pthread_self=l.asm.pthread_self).apply(null,arguments)},MT=l._emscripten_main_thread_process_queued_calls=function(){return(MT=l._emscripten_main_thread_process_queued_calls=l.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},tU=l.__emscripten_thread_crashed=function(){return(tU=l.__emscripten_thread_crashed=l.asm._emscripten_thread_crashed).apply(null,arguments)},LT=l.__emscripten_thread_init=function(){return(LT=l.__emscripten_thread_init=l.asm._emscripten_thread_init).apply(null,arguments)},eU=l._emscripten_current_thread_process_queued_calls=function(){return(eU=l._emscripten_current_thread_process_queued_calls=l.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},rU=l._emscripten_main_browser_thread_id=function(){return(rU=l._emscripten_main_browser_thread_id=l.asm.emscripten_main_browser_thread_id).apply(null,arguments)},nU=l._emscripten_sync_run_in_main_thread_2=function(){return(nU=l._emscripten_sync_run_in_main_thread_2=l.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},zT=l._emscripten_sync_run_in_main_thread_4=function(){return(zT=l._emscripten_sync_run_in_main_thread_4=l.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},BT=l._emscripten_run_in_main_runtime_thread_js=function(){return(BT=l._emscripten_run_in_main_runtime_thread_js=l.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},bv=l._emscripten_dispatch_to_thread_=function(){return(bv=l._emscripten_dispatch_to_thread_=l.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},wv=l.__emscripten_thread_free_data=function(){return(wv=l.__emscripten_thread_free_data=l.asm._emscripten_thread_free_data).apply(null,arguments)},oU=l.__emscripten_thread_exit=function(){return(oU=l.__emscripten_thread_exit=l.asm._emscripten_thread_exit).apply(null,arguments)},sU=l._memalign=function(){return(sU=l._memalign=l.asm.memalign).apply(null,arguments)},VT=l._emscripten_stack_set_limits=function(){return(VT=l._emscripten_stack_set_limits=l.asm.emscripten_stack_set_limits).apply(null,arguments)},vv=l.stackSave=function(){return(vv=l.stackSave=l.asm.stackSave).apply(null,arguments)},jg=l.stackRestore=function(){return(jg=l.stackRestore=l.asm.stackRestore).apply(null,arguments)},rp=l.stackAlloc=function(){return(rp=l.stackAlloc=l.asm.stackAlloc).apply(null,arguments)},iU=l.dynCall_iijjiiii=function(){return(iU=l.dynCall_iijjiiii=l.asm.dynCall_iijjiiii).apply(null,arguments)},aU=l.dynCall_jiji=function(){return(aU=l.dynCall_jiji=l.asm.dynCall_jiji).apply(null,arguments)},GT=l.__emscripten_allow_main_runtime_queued_calls=21464;l.cwrap=ze,l.keepRuntimeAlive=mu,l.PThread=Ht,l.PThread=Ht,l.wasmMemory=Ot,l.ExitStatus=mf;var Xg;function mf(T){this.name="ExitStatus",this.message="Program terminated with exit("+T+")",this.status=T}Vo=function T(){Xg||Cv(),Xg||(Vo=T)};function Cv(T){if(T=T||d,yl>0)return;if(v){c(l),rf(),postMessage({cmd:"loaded"});return}if(en(),yl>0)return;function F(){Xg||(Xg=!0,l.calledRun=!0,!Ie&&(rf(),c(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),Xb()))}l.setStatus?(l.setStatus("Running..."),setTimeout(function(){setTimeout(function(){l.setStatus("")},1),F()},1)):F()}l.run=Cv;function lU(T,F){if(ae=T,!F&&v)throw Fg(T),"unwind";mu()||jb(),uU(T)}function uU(T){ae=T,mu()||(Ht.terminateAllThreads(),l.onExit&&l.onExit(T),Ie=!0),g(T,new mf(T))}if(l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();Cv();var Yg;m&&(Yg={uncaughtException:process.listeners("uncaughtException").filter(function(T){return!m.uncaughtException.indexOf(T)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(T){return!m.unhandledRejection.indexOf(T)>-1})});var Zg;if(typeof WasmBackendModule!="undefined")Zg=WasmBackendModule;else if(typeof t!="undefined")Zg=t;else throw new Error("Could not find wasm module in post.js");if(Yg){var cU=Zg._dispose;Zg._dispose=function(){cU(),Yg.uncaughtException.forEach(function(T){process.removeListener("uncaughtException",T)}),Yg.unhandledRejection.forEach(function(T){process.removeListener("unhandledRejection",T)})}}return t.ready}})();typeof Gb=="object"&&typeof xT=="object"?xT.exports=gT:typeof define=="function"&&define.amd?define([],function(){return gT}):typeof Gb=="object"&&(Gb.WasmBackendModuleThreadedSimd=gT)});var dW=Oe((Wb,bT)=>{var yT=(()=>{var r=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(r=r||__filename),function(t){t=t||{};var e=typeof t!="undefined"?t:{},n,o;e.ready=new Promise(function(H,tt){n=H,o=tt});var s;typeof process!="undefined"&&process.listeners&&(s={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var i=Object.assign({},e),a=[],u="./this.program",l=(H,tt)=>{throw tt},c=typeof window=="object",p=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",f="";function d(H){return e.locateFile?e.locateFile(H,f):f+H}var h,g,y,b;function w(H){if(H instanceof cf)return;$("exiting due to exception: "+H)}var v,k,E;m?(p?f=xg().dirname(f)+"/":f=__dirname+"/",E=()=>{k||(v=By(),k=xg())},h=function(tt,gt){return E(),tt=k.normalize(tt),v.readFileSync(tt,gt?void 0:"utf8")},y=H=>{var tt=h(H,!0);return tt.buffer||(tt=new Uint8Array(tt)),tt},g=(H,tt,gt)=>{E(),H=k.normalize(H),v.readFile(H,function(Dt,fe){Dt?gt(Dt):tt(fe.buffer)})},process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),a=process.argv.slice(2),process.on("uncaughtException",function(H){if(!(H instanceof cf))throw H}),process.on("unhandledRejection",function(H){throw H}),l=(H,tt)=>{if(ef())throw process.exitCode=H,tt;w(tt),process.exit(H)},e.inspect=function(){return"[Emscripten Module object]"}):(c||p)&&(p?f=self.location.href:typeof document!="undefined"&&document.currentScript&&(f=document.currentScript.src),r&&(f=r),f.indexOf("blob:")!==0?f=f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):f="",h=H=>{var tt=new XMLHttpRequest;return tt.open("GET",H,!1),tt.send(null),tt.responseText},p&&(y=H=>{var tt=new XMLHttpRequest;return tt.open("GET",H,!1),tt.responseType="arraybuffer",tt.send(null),new Uint8Array(tt.response)}),g=(H,tt,gt)=>{var Dt=new XMLHttpRequest;Dt.open("GET",H,!0),Dt.responseType="arraybuffer",Dt.onload=()=>{if(Dt.status==200||Dt.status==0&&Dt.response){tt(Dt.response);return}gt()},Dt.onerror=gt,Dt.send(null)},b=H=>document.title=H);var D=e.print||console.log.bind(console),$=e.printErr||console.warn.bind(console);Object.assign(e,i),i=null,e.arguments&&(a=e.arguments),e.thisProgram&&(u=e.thisProgram),e.quit&&(l=e.quit);var R=4;function M(H){M.shown||(M.shown={}),M.shown[H]||(M.shown[H]=1,$(H))}function W(H,tt){if(typeof WebAssembly.Function=="function"){for(var gt={i:"i32",j:"i64",f:"f32",d:"f64"},Dt={parameters:[],results:tt[0]=="v"?[]:[gt[tt[0]]]},fe=1;fe{Q=H},X;e.wasmBinary&&(X=e.wasmBinary);var ot=e.noExitRuntime||!0;typeof WebAssembly!="object"&&pu("no native wasm support detected");var st,it=!1,ft;function at(H,tt){H||pu(tt)}function xt(H){var tt=e["_"+H];return tt}function dt(H,tt,gt,Dt,fe){var he={string:function(nn){var bl=0;if(nn!=null&&nn!==0){var qg=(nn.length<<2)+1;bl=uf(qg),ce(nn,bl,qg)}return bl},array:function(nn){var bl=uf(nn.length);return Ie(nn,bl),bl}};function oe(nn){return tt==="string"?qt(nn):tt==="boolean"?Boolean(nn):nn}var Qt=xt(H),xr=[],Go=0;if(Dt)for(var Wo=0;Wo=Dt);)++fe;if(fe-tt>16&&H.subarray&&At)return At.decode(H.subarray(tt,fe));for(var he="";tt>10,56320|Go&1023)}}return he}function qt(H,tt){return H?$t(ze,H,tt):""}function Kt(H,tt,gt,Dt){if(!(Dt>0))return 0;for(var fe=gt,he=gt+Dt-1,oe=0;oe=55296&&Qt<=57343){var xr=H.charCodeAt(++oe);Qt=65536+((Qt&1023)<<10)|xr&1023}if(Qt<=127){if(gt>=he)break;tt[gt++]=Qt}else if(Qt<=2047){if(gt+1>=he)break;tt[gt++]=192|Qt>>6,tt[gt++]=128|Qt&63}else if(Qt<=65535){if(gt+2>=he)break;tt[gt++]=224|Qt>>12,tt[gt++]=128|Qt>>6&63,tt[gt++]=128|Qt&63}else{if(gt+3>=he)break;tt[gt++]=240|Qt>>18,tt[gt++]=128|Qt>>12&63,tt[gt++]=128|Qt>>6&63,tt[gt++]=128|Qt&63}}return tt[gt]=0,gt-fe}function ce(H,tt,gt){return Kt(H,ze,tt,gt)}function Ot(H){for(var tt=0,gt=0;gt=55296&&Dt<=57343&&(Dt=65536+((Dt&1023)<<10)|H.charCodeAt(++gt)&1023),Dt<=127?++tt:Dt<=2047?tt+=2:Dt<=65535?tt+=3:tt+=4}return tt}var Ae=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function Ie(H,tt){Jr.set(H,tt)}function ae(H,tt,gt){for(var Dt=0;Dt>0]=H.charCodeAt(Dt);gt||(Jr[tt>>0]=0)}function je(H,tt){return H%tt>0&&(H+=tt-H%tt),H}var Fe,Jr,ze,Lo,Fr,Qr,tn,Hr,ro;function $n(H){Fe=H,e.HEAP8=Jr=new Int8Array(H),e.HEAP16=Lo=new Int16Array(H),e.HEAP32=Qr=new Int32Array(H),e.HEAPU8=ze=new Uint8Array(H),e.HEAPU16=Fr=new Uint16Array(H),e.HEAPU32=tn=new Uint32Array(H),e.HEAPF32=Hr=new Float32Array(H),e.HEAPF64=ro=new Float64Array(H)}var zo=e.INITIAL_MEMORY||16777216,no,gl=[],cu=[],Wc=[],gr=!1,Uc=!1,Hc=0;function ef(){return ot||Hc>0}function vg(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Sg(e.preRun.shift());nf(gl)}function Cg(){gr=!0,nf(cu)}function IT(){Uc=!0}function Ig(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)kg(e.postRun.shift());nf(Wc)}function Sg(H){gl.unshift(H)}function Bo(H){cu.unshift(H)}function kg(H){Wc.unshift(H)}var Un=0,qc=null,xl=null;function qb(H){Un++,e.monitorRunDependencies&&e.monitorRunDependencies(Un)}function Ng(H){if(Un--,e.monitorRunDependencies&&e.monitorRunDependencies(Un),Un==0&&(qc!==null&&(clearInterval(qc),qc=null),xl)){var tt=xl;xl=null,tt()}}e.preloadedImages={},e.preloadedAudios={};function pu(H){e.onAbort&&e.onAbort(H),H="Aborted("+H+")",$(H),it=!0,ft=1,H+=". Build with -s ASSERTIONS=1 for more info.";var tt=new WebAssembly.RuntimeError(H);throw o(tt),tt}var Kb="data:application/octet-stream;base64,";function Tg(H){return H.startsWith(Kb)}function mu(H){return H.startsWith("file://")}var en;en="tfjs-backend-wasm.wasm",Tg(en)||(en=d(en));function rf(H){try{if(H==en&&X)return new Uint8Array(X);if(y)return y(H);throw"both async and sync fetching of the wasm failed"}catch(tt){pu(tt)}}function jb(){if(!X&&(c||p)){if(typeof fetch=="function"&&!mu(en))return fetch(en,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+en+"'";return H.arrayBuffer()}).catch(function(){return rf(en)});if(g)return new Promise(function(H,tt){g(en,function(gt){H(new Uint8Array(gt))},tt)})}return Promise.resolve().then(function(){return rf(en)})}function Xb(){var H={env:Xc,wasi_snapshot_preview1:Xc};function tt(oe,Qt){var xr=oe.exports;e.asm=xr,st=e.asm.memory,$n(st.buffer),no=e.asm.__indirect_function_table,Bo(e.asm.__wasm_call_ctors),Ng("wasm-instantiate")}qb("wasm-instantiate");function gt(oe){tt(oe.instance)}function Dt(oe){return jb().then(function(Qt){return WebAssembly.instantiate(Qt,H)}).then(function(Qt){return Qt}).then(oe,function(Qt){$("failed to asynchronously prepare wasm: "+Qt),pu(Qt)})}function fe(){return!X&&typeof WebAssembly.instantiateStreaming=="function"&&!Tg(en)&&!mu(en)&&typeof fetch=="function"?fetch(en,{credentials:"same-origin"}).then(function(oe){var Qt=WebAssembly.instantiateStreaming(oe,H);return Qt.then(gt,function(xr){return $("wasm streaming compile failed: "+xr),$("falling back to ArrayBuffer instantiation"),Dt(gt)})}):Dt(gt)}if(e.instantiateWasm)try{var he=e.instantiateWasm(H,tt);return he}catch(oe){return $("Module.instantiateWasm callback failed with error: "+oe),!1}return fe().catch(o),{}}var ST,kT;function nf(H){for(;H.length>0;){var tt=H.shift();if(typeof tt=="function"){tt(e);continue}var gt=tt.func;typeof gt=="number"?tt.arg===void 0?of(gt)():of(gt)(tt.arg):gt(tt.arg===void 0?null:tt.arg)}}function yl(H){return H}function _g(H){var tt=/\b_Z[\w\d_]+/g;return H.replace(tt,function(gt){var Dt=gt;return gt===Dt?gt:Dt+" ["+gt+"]"})}var Vo=[];function of(H){var tt=Vo[H];return tt||(H>=Vo.length&&(Vo.length=H+1),Vo[H]=tt=no.get(H)),tt}function NT(){var H=new Error;if(!H.stack){try{throw new Error}catch(tt){H=tt}if(!H.stack)return"(no stack trace available)"}return H.stack.toString()}function Kc(H,tt){no.set(H,tt),Vo[H]=tt}function Yb(){pu("")}function sf(){return 2147483648}function Eg(H,tt,gt){ze.copyWithin(H,tt,tt+gt)}function rn(H){try{return st.grow(H-Fe.byteLength+65535>>>16),$n(st.buffer),1}catch(tt){}}function Ag(H){var tt=ze.length;H=H>>>0;var gt=sf();if(H>gt)return!1;for(var Dt=1;Dt<=4;Dt*=2){var fe=tt*(1+.2/Dt);fe=Math.min(fe,H+100663296);var he=Math.min(gt,je(Math.max(H,fe),65536)),oe=rn(he);if(oe)return!0}return!1}var jc={mappings:{},buffers:[null,[],[]],printChar:function(H,tt){var gt=jc.buffers[H];tt===0||tt===10?((H===1?D:$)($t(gt,0)),gt.length=0):gt.push(tt)},varargs:void 0,get:function(){jc.varargs+=4;var H=Qr[jc.varargs-4>>2];return H},getStr:function(H){var tt=qt(H);return tt},get64:function(H,tt){return H}};function Zb(H){return 0}function TT(H,tt,gt,Dt,fe){}function _T(H,tt,gt,Dt){for(var fe=0,he=0;he>2],Qt=Qr[tt+4>>2];tt+=8;for(var xr=0;xr>2]=fe,0}function Jb(H){rt(H)}var Dg=!1,Xc={abort:Yb,emscripten_get_heap_max:sf,emscripten_memcpy_big:Eg,emscripten_resize_heap:Ag,fd_close:Zb,fd_seek:TT,fd_write:_T,setTempRet0:Jb},bW=Xb(),ET=e.___wasm_call_ctors=function(){return(ET=e.___wasm_call_ctors=e.asm.__wasm_call_ctors).apply(null,arguments)},Qb=e._init=function(){return(Qb=e._init=e.asm.init).apply(null,arguments)},tw=e._init_with_threads_count=function(){return(tw=e._init_with_threads_count=e.asm.init_with_threads_count).apply(null,arguments)},$g=e._get_threads_count=function(){return($g=e._get_threads_count=e.asm.get_threads_count).apply(null,arguments)},Rg=e._register_tensor=function(){return(Rg=e._register_tensor=e.asm.register_tensor).apply(null,arguments)},ew=e._dispose_data=function(){return(ew=e._dispose_data=e.asm.dispose_data).apply(null,arguments)},Ht=e._dispose=function(){return(Ht=e._dispose=e.asm.dispose).apply(null,arguments)},rw=e._Abs=function(){return(rw=e._Abs=e.asm.Abs).apply(null,arguments)},Fg=e._Add=function(){return(Fg=e._Add=e.asm.Add).apply(null,arguments)},fu=e._AddN=function(){return(fu=e._AddN=e.asm.AddN).apply(null,arguments)},Yc=e._All=function(){return(Yc=e._All=e.asm.All).apply(null,arguments)},nw=e._Any=function(){return(nw=e._Any=e.asm.Any).apply(null,arguments)},AT=e._ArgMax=function(){return(AT=e._ArgMax=e.asm.ArgMax).apply(null,arguments)},ow=e._AvgPool=function(){return(ow=e._AvgPool=e.asm.AvgPool).apply(null,arguments)},DT=e._BatchMatMul=function(){return(DT=e._BatchMatMul=e.asm.BatchMatMul).apply(null,arguments)},du=e._Ceil=function(){return(du=e._Ceil=e.asm.Ceil).apply(null,arguments)},sw=e._ClipByValue=function(){return(sw=e._ClipByValue=e.asm.ClipByValue).apply(null,arguments)},iw=e._Conv2D=function(){return(iw=e._Conv2D=e.asm.Conv2D).apply(null,arguments)},aw=e._Conv2DBackpropInput=function(){return(aw=e._Conv2DBackpropInput=e.asm.Conv2DBackpropInput).apply(null,arguments)},lw=e._Cos=function(){return(lw=e._Cos=e.asm.Cos).apply(null,arguments)},uw=e._Cosh=function(){return(uw=e._Cosh=e.asm.Cosh).apply(null,arguments)},cw=e._CropAndResize=function(){return(cw=e._CropAndResize=e.asm.CropAndResize).apply(null,arguments)},Og=e._Cumprod=function(){return(Og=e._Cumprod=e.asm.Cumprod).apply(null,arguments)},pw=e._Cumsum=function(){return(pw=e._Cumsum=e.asm.Cumsum).apply(null,arguments)},mw=e._DepthToSpace=function(){return(mw=e._DepthToSpace=e.asm.DepthToSpace).apply(null,arguments)},fw=e._DepthwiseConv2dNative=function(){return(fw=e._DepthwiseConv2dNative=e.asm.DepthwiseConv2dNative).apply(null,arguments)},dw=e._Elu=function(){return(dw=e._Elu=e.asm.Elu).apply(null,arguments)},hw=e._Equal=function(){return(hw=e._Equal=e.asm.Equal).apply(null,arguments)},Pg=e._Exp=function(){return(Pg=e._Exp=e.asm.Exp).apply(null,arguments)},gw=e._FlipLeftRight=function(){return(gw=e._FlipLeftRight=e.asm.FlipLeftRight).apply(null,arguments)},xw=e._Floor=function(){return(xw=e._Floor=e.asm.Floor).apply(null,arguments)},hu=e._FloorDiv=function(){return(hu=e._FloorDiv=e.asm.FloorDiv).apply(null,arguments)},af=e._FusedBatchNorm=function(){return(af=e._FusedBatchNorm=e.asm.FusedBatchNorm).apply(null,arguments)},yw=e._FusedConv2D=function(){return(yw=e._FusedConv2D=e.asm.FusedConv2D).apply(null,arguments)},bw=e._FusedDepthwiseConv2D=function(){return(bw=e._FusedDepthwiseConv2D=e.asm.FusedDepthwiseConv2D).apply(null,arguments)},ww=e._Gather=function(){return(ww=e._Gather=e.asm.Gather).apply(null,arguments)},ee=e._GatherNd=function(){return(ee=e._GatherNd=e.asm.GatherNd).apply(null,arguments)},vw=e._Greater=function(){return(vw=e._Greater=e.asm.Greater).apply(null,arguments)},Cw=e._GreaterEqual=function(){return(Cw=e._GreaterEqual=e.asm.GreaterEqual).apply(null,arguments)},Iw=e._LeakyRelu=function(){return(Iw=e._LeakyRelu=e.asm.LeakyRelu).apply(null,arguments)},Sw=e._Less=function(){return(Sw=e._Less=e.asm.Less).apply(null,arguments)},kw=e._LessEqual=function(){return(kw=e._LessEqual=e.asm.LessEqual).apply(null,arguments)},Nw=e._Log=function(){return(Nw=e._Log=e.asm.Log).apply(null,arguments)},lf=e._LogicalAnd=function(){return(lf=e._LogicalAnd=e.asm.LogicalAnd).apply(null,arguments)},Mg=e._Max=function(){return(Mg=e._Max=e.asm.Max).apply(null,arguments)},Lg=e._MaxPool=function(){return(Lg=e._MaxPool=e.asm.MaxPool).apply(null,arguments)},Tw=e._Maximum=function(){return(Tw=e._Maximum=e.asm.Maximum).apply(null,arguments)},_w=e._Mean=function(){return(_w=e._Mean=e.asm.Mean).apply(null,arguments)},Ew=e._Min=function(){return(Ew=e._Min=e.asm.Min).apply(null,arguments)},Aw=e._Minimum=function(){return(Aw=e._Minimum=e.asm.Minimum).apply(null,arguments)},Dw=e._MirrorPad=function(){return(Dw=e._MirrorPad=e.asm.MirrorPad).apply(null,arguments)},$w=e._Multiply=function(){return($w=e._Multiply=e.asm.Multiply).apply(null,arguments)},nr=e._Neg=function(){return(nr=e._Neg=e.asm.Neg).apply(null,arguments)},Rw=e._NonMaxSuppressionV3=function(){return(Rw=e._NonMaxSuppressionV3=e.asm.NonMaxSuppressionV3).apply(null,arguments)},Fw=e._NonMaxSuppressionV4=function(){return(Fw=e._NonMaxSuppressionV4=e.asm.NonMaxSuppressionV4).apply(null,arguments)},Ow=e._NonMaxSuppressionV5=function(){return(Ow=e._NonMaxSuppressionV5=e.asm.NonMaxSuppressionV5).apply(null,arguments)},Zc=e._NotEqual=function(){return(Zc=e._NotEqual=e.asm.NotEqual).apply(null,arguments)},zg=e._OneHot=function(){return(zg=e._OneHot=e.asm.OneHot).apply(null,arguments)},Bg=e._PadV2=function(){return(Bg=e._PadV2=e.asm.PadV2).apply(null,arguments)},Vg=e._Pow=function(){return(Vg=e._Pow=e.asm.Pow).apply(null,arguments)},Pw=e._Prelu=function(){return(Pw=e._Prelu=e.asm.Prelu).apply(null,arguments)},Gg=e._Prod=function(){return(Gg=e._Prod=e.asm.Prod).apply(null,arguments)},Mw=e._RealDiv=function(){return(Mw=e._RealDiv=e.asm.RealDiv).apply(null,arguments)},$T=e._Relu=function(){return($T=e._Relu=e.asm.Relu).apply(null,arguments)},Wg=e._Relu6=function(){return(Wg=e._Relu6=e.asm.Relu6).apply(null,arguments)},RT=e._ResizeBilinear=function(){return(RT=e._ResizeBilinear=e.asm.ResizeBilinear).apply(null,arguments)},Lw=e._Reverse=function(){return(Lw=e._Reverse=e.asm.Reverse).apply(null,arguments)},zw=e._RotateWithOffset=function(){return(zw=e._RotateWithOffset=e.asm.RotateWithOffset).apply(null,arguments)},Bw=e._Round=function(){return(Bw=e._Round=e.asm.Round).apply(null,arguments)},Vw=e._Rsqrt=function(){return(Vw=e._Rsqrt=e.asm.Rsqrt).apply(null,arguments)},Gw=e._ScatterNd=function(){return(Gw=e._ScatterNd=e.asm.ScatterNd).apply(null,arguments)},Ww=e._SelectV2=function(){return(Ww=e._SelectV2=e.asm.SelectV2).apply(null,arguments)},Uw=e._Sigmoid=function(){return(Uw=e._Sigmoid=e.asm.Sigmoid).apply(null,arguments)},Hw=e._Sin=function(){return(Hw=e._Sin=e.asm.Sin).apply(null,arguments)},qw=e._Softmax=function(){return(qw=e._Softmax=e.asm.Softmax).apply(null,arguments)},Kw=e._SparseFillEmptyRows=function(){return(Kw=e._SparseFillEmptyRows=e.asm.SparseFillEmptyRows).apply(null,arguments)},jw=e._SparseReshape=function(){return(jw=e._SparseReshape=e.asm.SparseReshape).apply(null,arguments)},Xw=e._SparseSegmentReduction=function(){return(Xw=e._SparseSegmentReduction=e.asm.SparseSegmentReduction).apply(null,arguments)},Yw=e._Sqrt=function(){return(Yw=e._Sqrt=e.asm.Sqrt).apply(null,arguments)},Zw=e._Square=function(){return(Zw=e._Square=e.asm.Square).apply(null,arguments)},Jw=e._SquaredDifference=function(){return(Jw=e._SquaredDifference=e.asm.SquaredDifference).apply(null,arguments)},Qw=e._Step=function(){return(Qw=e._Step=e.asm.Step).apply(null,arguments)},tv=e._StridedSlice=function(){return(tv=e._StridedSlice=e.asm.StridedSlice).apply(null,arguments)},ev=e._Sub=function(){return(ev=e._Sub=e.asm.Sub).apply(null,arguments)},rv=e._Sum=function(){return(rv=e._Sum=e.asm.Sum).apply(null,arguments)},nv=e._Tan=function(){return(nv=e._Tan=e.asm.Tan).apply(null,arguments)},ov=e._Tanh=function(){return(ov=e._Tanh=e.asm.Tanh).apply(null,arguments)},sv=e._Tile=function(){return(sv=e._Tile=e.asm.Tile).apply(null,arguments)},iv=e._TopK=function(){return(iv=e._TopK=e.asm.TopK).apply(null,arguments)},av=e._Transform=function(){return(av=e._Transform=e.asm.Transform).apply(null,arguments)},lv=e._Transpose=function(){return(lv=e._Transpose=e.asm.Transpose).apply(null,arguments)},uv=e.__FusedMatMul=function(){return(uv=e.__FusedMatMul=e.asm._FusedMatMul).apply(null,arguments)},cv=e._malloc=function(){return(cv=e._malloc=e.asm.malloc).apply(null,arguments)},pv=e._free=function(){return(pv=e._free=e.asm.free).apply(null,arguments)},mv=e.___errno_location=function(){return(mv=e.___errno_location=e.asm.__errno_location).apply(null,arguments)},fv=e._emscripten_main_thread_process_queued_calls=function(){return(fv=e._emscripten_main_thread_process_queued_calls=e.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Ug=e.stackSave=function(){return(Ug=e.stackSave=e.asm.stackSave).apply(null,arguments)},Hg=e.stackRestore=function(){return(Hg=e.stackRestore=e.asm.stackRestore).apply(null,arguments)},uf=e.stackAlloc=function(){return(uf=e.stackAlloc=e.asm.stackAlloc).apply(null,arguments)},dv=e.dynCall_iijjiiii=function(){return(dv=e.dynCall_iijjiiii=e.asm.dynCall_iijjiiii).apply(null,arguments)},hv=e.dynCall_jiji=function(){return(hv=e.dynCall_jiji=e.asm.dynCall_jiji).apply(null,arguments)};e.cwrap=bt;var Jc;function cf(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}xl=function H(){Jc||pf(),Jc||(xl=H)};function pf(H){if(H=H||a,Un>0||(vg(),Un>0))return;function tt(){Jc||(Jc=!0,e.calledRun=!0,!it&&(Cg(),n(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Ig()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),tt()},1)):tt()}e.run=pf;function FT(H){ft=H,ef()||(e.onExit&&e.onExit(H),it=!0),l(H,new cf(H))}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();pf();var Qc;s&&(Qc={uncaughtException:process.listeners("uncaughtException").filter(function(H){return!s.uncaughtException.indexOf(H)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(H){return!s.unhandledRejection.indexOf(H)>-1})});var tp;if(typeof t!="undefined")tp=t;else if(typeof WasmBackendModuleThreadedSimd!="undefined")tp=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(Qc){var gv=tp._dispose;tp._dispose=function(){gv(),Qc.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),Qc.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}return t.ready}})();typeof Wb=="object"&&typeof bT=="object"?bT.exports=yT:typeof define=="function"&&define.amd?define([],function(){return yT}):typeof Wb=="object"&&(Wb.WasmBackendModule=yT)});var wl=class{constructor(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}get(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)}set(t,e){this.dataIdsCount++,this.data.set(t,e)}has(t){return this.data.has(t)}delete(t){return this.dataIdsCount--,this.data.delete(t)}numDataIds(){return this.dataIdsCount}},mi=class{refCount(t){return Hn("refCount")}incRef(t){return Hn("incRef")}timerAvailable(){return!0}time(t){return Hn("time")}read(t){return Hn("read")}readSync(t){return Hn("readSync")}readToGPU(t,e){return Hn("readToGPU")}numDataIds(){return Hn("numDataIds")}disposeData(t,e){return Hn("disposeData")}write(t,e,n){return Hn("write")}move(t,e,n,o,s){return Hn("move")}memory(){return Hn("memory")}floatPrecision(){return Hn("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return Hn("dispose")}};function Hn(r){throw new Error(`'${r}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function UT(r){let t=r.length,e=0;for(;t>0;)e=Math.random()*t|0,t--,Qg(r,t,e)}function yU(r,t){if(r.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${r.length}Second array length was ${t.length}`);let e=r.length,n=0;for(;e>0;)n=Math.random()*e|0,e--,Qg(r,e,n),Qg(t,e,n)}function op(r,t,e){return Math.max(r,Math.min(t,e))}function bU(r){return r%2===0?r:r+1}function Qg(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}function wU(r){let t=0;for(let e=0;ee+` Shapes ${r} and ${t} must match`)}function qn(r){A(r!=null,()=>"The input to the tensor constructor must be a non-null value.")}function qo(r,t=[],e=!1){if(t==null&&(t=[]),Array.isArray(r)||yr(r)&&!e)for(let n=0;n0,e){return new Promise((n,o)=>{let s=0,i=()=>{if(r()){n();return}s++;let a=t(s);if(e!=null&&s>=e){o();return}setTimeout(i,a)};i()})}function _U(r,t){let e=1,n=-1;for(let s=0;s=0)e*=r[s];else if(r[s]===-1){if(n!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${s}`);n=s}else if(r[s]<0)throw Error(`Shapes can not be < 0. Found ${r[s]} at dim ${s}`);if(n===-1){if(t>0&&t!==e)throw Error(`Size(${t}) must match the product of shape ${r}`);return r}if(e===0)throw Error(`Cannot infer the missing size in [${r}] when there are 0 elements`);if(t%e!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${e}`);let o=r.slice();return o[n]=t/e,o}function mr(r,t){let e=t.length;return r=r==null?t.map((n,o)=>o):[].concat(r),A(r.every(n=>n>=-e&&n`All values in axis param must be in range [-${e}, ${e}) but got axis ${r}`),A(r.every(n=>Ki(n)),()=>`All values in axis param must be integers but got axis ${r}`),r.map(n=>n<0?e+n:n)}function Sv(r,t){let e=[],n=[],o=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||o?null:mr(t,r).sort(),i=0;for(let a=0;aa)&&r[a]===1&&(e.push(r[a]),n.push(a)),s[i]<=a&&i++}r[a]!==1&&(e.push(r[a]),n.push(a))}return{newShape:e,keptDims:n}}function kv(r,t){let e=null;if(r==null||r==="float32")e=new Float32Array(t);else if(r==="int32")e=new Int32Array(t);else if(r==="bool")e=new Uint8Array(t);else throw new Error(`Unknown data type ${r}`);return e}function Nv(r,t){let e=null;if(r==null||r==="float32")e=new Float32Array(t);else if(r==="int32")e=new Int32Array(t);else if(r==="bool")e=new Uint8Array(t);else if(r==="string")e=new Array(t);else throw new Error(`Unknown data type ${r}`);return e}function Tv(r,t){for(let e=0;et+=e.length),t}function Ko(r){return typeof r=="string"||r instanceof String}function HT(r){return typeof r=="boolean"}function qT(r){return typeof r=="number"}function sp(r){return Array.isArray(r)?sp(r[0]):r instanceof Float32Array?"float32":r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray?"int32":qT(r)?"float32":Ko(r)?"string":HT(r)?"bool":"float32"}function fi(r){return!!(r&&r.constructor&&r.call&&r.apply)}function ip(r,t){for(let e=t;e=0;--n)e[n]=e[n+1]*r[n+1];return e}function KT(r,t,e,n=!1){let o=new Array;if(t.length===1){let s=t[0]*(n?2:1);for(let i=0;iu*l)*(n?2:1);for(let u=0;uo*s)*(e?2:1);if(n===0)return[];if(n!==t.length)throw new Error(`[${r}] does not match the input size ${t.length}${e?" for a complex tensor":""}.`);return KT(0,r,t,e)}function df(r,t){let e=ap(r,t);for(let n=0;nn*o,1);if(t==null||t==="float32")return yu(r,new Float32Array(e));if(t==="int32")return yu(r,new Int32Array(e));if(t==="bool")return yu(r,new Uint8Array(e));throw new Error(`Unknown data type ${t}`)}function hf(r){r.forEach(t=>{A(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${r}].`)})}function DU(r,t,e){if(t===0)return 0;if(t===1)return r[0];let n=r[r.length-1];for(let o=0;o{let[o,s]=n.split(":");this.urlFlags[o]=PU(o,s)})}};function FU(r){let t={};return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...n)=>(OU(t,n[0],n[1]),n.join("="))),t}function OU(r,t,e){r[decodeURIComponent(t)]=decodeURIComponent(e||"")}function PU(r,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 ${r}.`)}function V(){return Av}var Av=null;function XT(r){Av=r}var Dv;function $v(){if(Dv==null){let r;if(typeof window!="undefined")r=window;else if(typeof global!="undefined")r=global;else if(typeof process!="undefined")r=process;else if(typeof self!="undefined")r=self;else throw new Error("Could not find a global object");Dv=r}return Dv}function MU(){let r=$v();return r._tfGlobals==null&&(r._tfGlobals=new Map),r._tfGlobals}function xf(r,t){let e=MU();if(e.has(r))return e.get(r);{let n=t();return e.set(r,n),e.get(r)}}var hi="Abs",ji="Acos",Xi="Acosh",Kn="Add",jo="AddN",Yi="All",Zi="Any",Xo="ArgMax",vl="ArgMin",Ji="Asin",Qi="Asinh",ta="Atan",ea="Atanh",ra="Atan2",Yo="AvgPool",lp="AvgPoolGrad",Cl="AvgPool3D",up="AvgPool3DGrad",Zo="BatchMatMul",gi="BatchToSpaceND",cp="Bincount",YT="BroadcastTo",pp="BroadcastArgs",oo="Cast",Jo="Ceil",so="ClipByValue",mp="Complex",Il="ComplexAbs",xi="Concat",Qo="Conv2D",fp="Conv2DBackpropFilter",ts="Conv2DBackpropInput",Sl="Conv3D",dp="Conv3DBackpropFilterV2",hp="Conv3DBackpropInputV2",es="Cos",rs="Cosh",na="Cumprod",ns="Cumsum",oa="CropAndResize",gp="DenseBincount",sa="DepthToSpace",os="DepthwiseConv2dNative",xp="DepthwiseConv2dNativeBackpropFilter",yp="DepthwiseConv2dNativeBackpropInput",bp="Diag",kl="Dilation2D",yf="Dilation2DBackpropInput",bf="Dilation2DBackpropFilter",ss="RealDiv",wp="Einsum",is="Elu",vp="EluGrad",ia="Erf",aa="Equal",as="Exp",yi="ExpandDims",la="Expm1",Cp="FFT",Nl="Fill",ua="FlipLeftRight",ls="Floor",us="FloorDiv",cs="FusedBatchNorm",bi="GatherV2",ca="GatherNd",pa="Greater",ps="GreaterEqual",io="Identity",Ip="IFFT",Sp="Imag",ma="IsFinite",fa="IsInf",da="IsNan",ms="LeakyRelu",ha="Less",ga="LessEqual",kp="LinSpace",fs="Log",xa="Log1p",ya="LogicalAnd",wu="LogicalNot",vu="LogicalOr",ZT="LogSoftmax",Tl="LRN",Np="LRNGrad",ds="Max",hs="Maximum",gs="MaxPool",Tp="MaxPoolGrad",_l="MaxPool3D",_p="MaxPool3DGrad",Ep="MaxPoolWithArgmax",xs="Mean",ys="Min",bs="Minimum",ws="MirrorPad",ba="Mod",Ap="Multinomial",vs="Multiply",wi="Neg",wa="NotEqual",va="NonMaxSuppressionV3",Ca="NonMaxSuppressionV4",Ia="NonMaxSuppressionV5",vi="OnesLike",Cs="OneHot",Ci="Pack",Is="PadV2",Cat="Pool",Ss="Pow",ks="Prelu",Sa="Prod",El="Range",Dp="Real",ka="Reciprocal",Ns="Relu",Ii="Reshape",Al="ResizeNearestNeighbor",$p="ResizeNearestNeighborGrad",Ts="ResizeBilinear",Rp="ResizeBilinearGrad",_s="Relu6",Es="Reverse",As="Round",Ds="Rsqrt",Na="ScatterNd",Si="Select",Ta="Selu",ki="Slice",$s="Sin",_a="Sinh",Ea="Sign",Rs="Sigmoid",Aa="Softplus",Fs="Sqrt",Os="Sum",Ni="SpaceToBatchND",Ti="SplitV",Ps="Softmax",Dl="SparseFillEmptyRows",Da="SparseReshape",$l="SparseSegmentMean",Rl="SparseSegmentSum",Fp="SparseToDense",Ms="SquaredDifference",Fl="Square",$a="StridedSlice",Op="StringNGrams",Pp="StringSplit",Mp="StringToHashBucketFast",Ls="Sub",zs="Tan",Bs="Tanh",jn="Tile",Ra="TopK",Fa="Transform",Vs="Transpose",Lp="Unique",_i="Unpack",Ol="UnsortedSegmentSum",Ei="ZerosLike",ao="Step",wf="FromPixels",Oa="RotateWithOffset",Ai="_FusedMatMul",Di="FusedConv2D",$i="FusedDepthwiseConv2D";function Ri(...r){V().getBool("IS_TEST")||V().getBool("PROD")||console.warn(...r)}function LU(...r){V().getBool("IS_TEST")||V().getBool("PROD")||console.log(...r)}var zp=xf("kernelRegistry",()=>new Map),vf=xf("gradRegistry",()=>new Map);function Cf(r,t){let e=Fv(r,t);return zp.get(e)}function Rv(r){return vf.get(r)}function rx(r){let t=zp.entries(),e=[];for(;;){let{done:n,value:o}=t.next();if(n)break;let[s,i]=o,[a]=s.split("_");a===r&&e.push(i)}return e}function Cu(r){let{kernelName:t,backendName:e}=r,n=Fv(t,e);zp.has(n)&&Ri(`The kernel '${t}' for backend '${e}' is already registered`),zp.set(n,r)}function QT(r){let{kernelName:t}=r;vf.has(t)&&V().getBool("DEBUG")&&Ri(`Overriding the gradient for '${t}'`),vf.set(t,r)}function Tat(r,t){let e=Fv(r,t);if(!zp.has(e))throw new Error(`The kernel '${r}' for backend '${t}' is not registered`);zp.delete(e)}function _at(r){if(!vf.has(r))throw new Error(`The gradient '${r}' for backend is not registered`);vf.delete(r)}function Eat(r,t){rx(r).forEach(n=>{let o=Object.assign({},n,{backendName:t});Cu(o)})}function Fv(r,t){return`${t}_${r}`}var x={};Yt(x,{arraysEqual:()=>Fn,assert:()=>A,assertNonNegativeIntegerDimensions:()=>hf,assertNonNull:()=>qn,assertShapesMatch:()=>Pe,bytesFromStringArray:()=>Ev,bytesPerElement:()=>tx,checkConversionForErrors:()=>Tv,clamp:()=>op,computeStrides:()=>di,createScalarValue:()=>HU,createShuffledIndices:()=>NU,decodeString:()=>Wp,distSquared:()=>CU,encodeString:()=>Ml,fetch:()=>KU,fingerPrint64:()=>UU,flatten:()=>qo,getArrayFromDType:()=>Nv,getTypedArrayFromDType:()=>kv,hasEncodingLoss:()=>EU,hexToLong:()=>If,indexToLoc:()=>$U,inferDtype:()=>sp,inferFromImplicitShape:()=>_U,isBoolean:()=>HT,isFunction:()=>fi,isInt:()=>Ki,isNumber:()=>qT,isPromise:()=>gf,isScalarShape:()=>IU,isString:()=>Ko,isTypedArray:()=>yr,isValidDtype:()=>_v,locToIndex:()=>DU,makeOnesTypedArray:()=>df,makeZerosNestedTypedArray:()=>AU,makeZerosTypedArray:()=>ap,nearestDivisor:()=>ip,nearestLargerEven:()=>bU,now:()=>Tu,parseAxisParam:()=>mr,randUniform:()=>vU,repeatedTry:()=>TU,rightPad:()=>bu,shuffle:()=>UT,shuffleCombo:()=>yU,sizeFromShape:()=>re,sizeToSquarishShape:()=>kU,squeezeShape:()=>Sv,sum:()=>wU,swap:()=>Qg,tanh:()=>SU,toNestedArray:()=>yu,toTypedArray:()=>Gp});var Lv=xu(c1());var Nu=Lv.default||Lv;function If(r){return Nu.fromString(r,!0,16)}var m1=If("c3a5c85c97cb3127"),ku=If("b492b66fbe98f273"),on=If("9ae16a3b2f90404f");function Mv(r){return r.xor(r.shru(47))}function f1(r,t,e){let n=r.slice(t,t+e);return Nu.fromBytes(Array.from(n),!0,!0)}function Be(r,t){return f1(r,t,8)}function p1(r,t){return f1(r,t,4)}function Er(r,t){return t===0?r:r.shru(t).or(r.shl(64-t))}function Pl(r,t,e=If("9ddfea08eb382d69")){let n=r.xor(t).mul(e);n=n.xor(n.shru(47));let o=t.xor(n).mul(e);return o=o.xor(o.shru(47)),o=o.mul(e),o}function BU(r,t,e,n,o,s){o=o.add(r),s=Er(s.add(o).add(n),21);let i=o;return o=o.add(t),o=o.add(e),s=s.add(Er(o,44)),[o.add(n),s.add(i)]}function ox(r,t,e,n){return BU(Be(r,t),Be(r,t+8),Be(r,t+16),Be(r,t+24),e,n)}function VU(r,t=r.length){if(t>=8){let e=on.add(t*2),n=Be(r,0).add(on),o=Be(r,t-8),s=Er(o,37).mul(e).add(n),i=Er(n,25).add(o).mul(e);return Pl(s,i,e)}if(t>=4){let e=on.add(t*2),n=p1(r,0);return Pl(n.shl(3).add(t),p1(r,t-4),e)}if(t>0){let e=r[0],n=r[t>>1],o=r[t-1],s=e+(n<<8),i=t+(o<<2);return Mv(on.mul(s).xor(m1.mul(i))).mul(on)}return on}function GU(r,t=r.length){let e=on.add(t*2),n=Be(r,0).mul(ku),o=Be(r,8),s=Be(r,t-8).mul(e),i=Be(r,t-16).mul(on);return Pl(Er(n.add(o),43).add(Er(s,30)).add(i),n.add(Er(o.add(on),18)).add(s),e)}function WU(r,t=r.length){let e=on.add(t*2),n=Be(r,0).mul(on),o=Be(r,8),s=Be(r,t-8).mul(e),i=Be(r,t-16).mul(on),a=Er(n.add(o),43).add(Er(s,30)).add(i),u=Pl(a,n.add(Er(o.add(on),18)).add(s),e),l=Be(r,16).mul(e),c=Be(r,24),p=a.add(Be(r,t-32)).mul(e),m=u.add(Be(r,t-24)).mul(e);return Pl(Er(l.add(c),43).add(Er(p,30)).add(m),l.add(Er(c.add(n),18)).add(p),e)}function UU(r,t=r.length){let e=Nu.fromNumber(81,!0);if(t<=32)return t<=16?VU(r,t):GU(r,t);if(t<=64)return WU(r,t);let n=e,o=e.mul(ku).add(113),s=Mv(o.mul(on).add(113)).mul(on),i=[Nu.UZERO,Nu.UZERO],a=[Nu.UZERO,Nu.UZERO];n=n.mul(on).add(Be(r,0));let u=0,l=(t-1>>6)*64,c=l+(t-1&63)-63;do n=Er(n.add(o).add(i[0]).add(Be(r,u+8)),37).mul(ku),o=Er(o.add(i[1]).add(Be(r,u+48)),42).mul(ku),n=n.xor(a[1]),o=o.add(i[0]).add(Be(r,u+40)),s=Er(s.add(a[0]),33).mul(ku),i=ox(r,u,i[1].mul(ku),n.add(a[0])),a=ox(r,u+32,s.add(a[1]),o.add(Be(r,u+16))),[s,n]=[n,s],u+=64;while(u!==l);let p=ku.add(s.and(255).shl(1));return u=c,a[0]=a[0].add(t-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),n=Er(n.add(o).add(i[0]).add(Be(r,u+8)),37).mul(p),o=Er(o.add(i[1]).add(Be(r,u+48)),42).mul(p),n=n.xor(a[1].mul(9)),o=o.add(i[0].mul(9).add(Be(r,u+40))),s=Er(s.add(a[0]),33).mul(p),i=ox(r,u,i[1].mul(p),n.add(a[0])),a=ox(r,u+32,s.add(a[1]),o.add(Be(r,u+16))),[s,n]=[n,s],Pl(Pl(i[0],a[0],p).add(Mv(o).mul(m1)).add(s),Pl(i[1],a[1],p).add(n),p)}function HU(r,t){return t==="string"?Ml(r):Gp([r],t)}function qU(r,t){return r instanceof Float32Array&&t==="float32"||r instanceof Int32Array&&t==="int32"||r instanceof Uint8Array&&t==="bool"}function Gp(r,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(r)&&(r=qo(r)),V().getBool("DEBUG")&&Tv(r,t),qU(r,t))return r;if(t==null||t==="float32"||t==="complex64")return new Float32Array(r);if(t==="int32")return new Int32Array(r);if(t==="bool"){let e=new Uint8Array(r.length);for(let n=0;n{o=n()},i,a=Tu();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(s);else{s();for(let l of o)l.dataSync();i=Promise.resolve({kernelMs:Tu()-a})}if(V().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l{jU(p,c.dtype,t)})}return{kernelName:t,outputs:o,inputs:e,timeMs:i.then(l=>l.kernelMs),extraInfo:i.then(l=>l.getExtraProfileInfo!=null?l.getExtraProfileInfo():"")}}logKernelProfile(t){let{kernelName:e,outputs:n,timeMs:o,inputs:s,extraInfo:i}=t;n.forEach(a=>{Promise.all([a.data(),o,i]).then(u=>{this.logger.logKernelProfile(e,a,u[0],u[1],s,u[2])})})}};function jU(r,t,e){if(t!=="float32")return!1;for(let n=0;n0?h:""} `}}console.log(`%c${u} %c${a} %c${l}D ${p} %c${c} %c${m} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function h1(r,t,e){let n={},o={};for(let u=0;un[h.id]=!0),f=!0,o[l.id]=!0;break}if(f)break}}let s={};s[e.id]=!0;let i={};for(let u=r.length-1;u>=0;u--){let l=r[u],c=l.inputs;for(let p=0;p=0;o--){let s=t[o],i=[];if(s.outputs.forEach(u=>{let l=r[u.id];l!=null?i.push(l):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let a=s.gradient(i);for(let u in s.inputs){if(!(u in a))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(a)}.`);let l=e(()=>a[u]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);let c=s.inputs[u];if(!Fn(l.shape,c.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(r[c.id]==null)r[c.id]=l;else{let p=r[c.id];r[c.id]=n(p,l),p.dispose()}}}}var x1=20,Sf=3,Bv=7;function y1(r,t,e,n){let o=di(t),s=XU(r,t,e,o),i=t.length,a=sx(r,t,e,o,s),u=["Tensor"];return n&&(u.push(` dtype: ${e}`),u.push(` rank: ${i}`),u.push(` shape: [${t}]`),u.push(" values:")),u.push(a.map(l=>" "+l).join(` `)),u.join(` `)}function XU(r,t,e,n){let o=re(t),s=n[n.length-1],i=new Array(s).fill(0),a=t.length,u=e==="complex64"?Nf(r):r;if(a>1)for(let l=0;lx1){let g=Sf*i,y=Array.from(r.slice(0,g)),b=Array.from(r.slice((a-Sf)*i,a*i));return e==="complex64"&&(y=Nf(y),b=Nf(b)),["["+y.map((w,v)=>kf(w,o[v],e)).join(", ")+", ..., "+b.map((w,v)=>kf(w,o[a-Sf+v],e)).join(", ")+"]"]}let h=e==="complex64"?Nf(r):Array.from(r);return["["+h.map((g,y)=>kf(g,o[y],e)).join(", ")+"]"]}let l=t.slice(1),c=n.slice(1),p=n[0]*i,m=[];if(a>x1){for(let h=0;h`Length of values '${o}' does not match the size inferred by the shape '${this.size}'.`)}if(e==="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||Nv(e,this.size),this.strides=di(t)}set(t,...e){e.length===0&&(e=[0]),A(e.length===this.rank,()=>`The number of provided coordinates (${e.length}) must match the rank (${this.rank})`);let n=this.locToIndex(e);this.values[n]=t}get(...t){t.length===0&&(t=[0]);let e=0;for(let o of t){if(o<0||o>=this.shape[e]){let s=`Requested out of range element at ${t}. Buffer shape=${this.shape}`;throw new Error(s)}e++}let n=t[t.length-1];for(let o=0;oWp(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataToGPU(t){return this.throwIfDisposed(),Ws().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();let t=Ws().readSync(this.dataId);if(this.dtype==="string")try{return t.map(e=>Wp(e))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t}async bytes(){this.throwIfDisposed();let t=await Ws().read(this.dataId);return this.dtype==="string"?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(Ws().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return Up.print(this,t)}clone(){return this.throwIfDisposed(),Up.clone(this)}toString(t=!1){let e=this.dataSync();return y1(e,this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),Up.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),Ws().makeVariable(this,t,e,n)}};Object.defineProperty(Vt,Symbol.hasInstance,{value:r=>!!r&&r.data!=null&&r.dataSync!=null&&r.throwIfDisposed!=null});function L(){return xf("Tensor",()=>Vt)}L();var Ll=class extends Vt{constructor(t,e,n,o){super(t.shape,t.dtype,t.dataId,o);this.trainable=e,this.name=n}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);if(!Fn(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);Ws().disposeTensor(this),this.dataId=t.dataId,Ws().incRef(this,null)}dispose(){Ws().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Ll,Symbol.hasInstance,{value:r=>r instanceof Vt&&r.assign!=null&&r.assign instanceof Function});var po={};Yt(po,{assertTypesMatch:()=>qv,getTensorsInContainer:()=>Tf,isTensorInList:()=>JU,makeTypesMatch:()=>jt});var Vv;(function(r){r.R0="R0",r.R1="R1",r.R2="R2",r.R3="R3",r.R4="R4",r.R5="R5",r.R6="R6"})(Vv||(Vv={}));var Gv;(function(r){r.float32="float32",r.int32="int32",r.bool="int32",r.complex64="complex64"})(Gv||(Gv={}));var Wv;(function(r){r.float32="float32",r.int32="int32",r.bool="bool",r.complex64="complex64"})(Wv||(Wv={}));var Uv;(function(r){r.float32="float32",r.int32="float32",r.bool="float32",r.complex64="complex64"})(Uv||(Uv={}));var Hv;(function(r){r.float32="complex64",r.int32="complex64",r.bool="complex64",r.complex64="complex64"})(Hv||(Hv={}));var ZU={float32:Uv,int32:Gv,bool:Wv,complex64:Hv};function ar(r,t){if(r==="string"||t==="string"){if(r==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${r} with ${t}`)}return ZU[r][t]}function _u(r){return ar(r,"int32")}function jt(r,t){if(r.dtype===t.dtype)return[r,t];let e=ar(r.dtype,t.dtype);return[r.cast(e),t.cast(e)]}function qv(r,t){A(r.dtype===t.dtype,()=>`The dtypes of the first(${r.dtype}) and second(${t.dtype}) input must match`)}function JU(r,t){return t.some(e=>e.id===r.id)}function Tf(r){let t=[];return I1(r,t,new Set),t}function I1(r,t,e){if(r==null)return;if(r instanceof Vt){t.push(r);return}if(!QU(r))return;let n=r;for(let o in n){let s=n[o];e.has(s)||(e.add(s),I1(s,t,e))}}function QU(r){return Array.isArray(r)||typeof r=="object"}function Kv(r){return r.kernelName!=null}var jv=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(t=>t.name)))}}}dispose(){for(let t in this.registeredVariables)this.registeredVariables[t].dispose()}},Eu=class{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new jv}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let t=this.getSortedBackends();for(let e=0;e{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(t){rx(t).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[t])})}initializeBackend(t){let e=this.registryFactory[t];if(e==null)throw new Error(`Cannot initialize backend ${t}, no registration found.`);try{let n=e.factory();if(n&&!(n instanceof mi)&&typeof n.then=="function"){let o=++this.pendingBackendInitId,s=n.then(i=>o(othis.registryFactory[e].priority-this.registryFactory[t].priority)}initializeBackendsAndReturnBest(){let t=this.getSortedBackends();for(let e=0;ethis.startScope(n),()=>this.endScope(o),()=>(o=e(),o instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),o))}scopedRun(t,e,n){t();try{let o=n();return e(),o}catch(o){throw e(),o}}nextTensorId(){return Eu.nextTensorId++}nextVariableId(){return Eu.nextVariableId++}clone(t){let e=_.runKernel(io,{x:t}),n={x:t},o=i=>({x:()=>{let a="float32",u={x:i},l={dtype:a};return _.runKernel(oo,u,l)}}),s=[];return this.addTapeNode(this.state.activeScope.name,n,[e],o,s,{}),e}runKernel(t,e,n){if(this.backendName==null&&this.backend,!(Cf(t,this.backendName)!=null))throw new Error(`Kernel '${t}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:t,inputs:e,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(t,e,n){let o=this.backend.numDataIds(),s=0;n.forEach(u=>{s+=u.dtype==="complex64"?3:1});let i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=o-e-s-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${t}'`)}runKernelFunc(t){let e,n=[],o=this.isTapeOn(),s=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let u,l=Kv(t)?t.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Kv(t)){let{kernelName:d,inputs:h,attrs:g}=t;this.backendName==null&&this.backend;let y=Cf(d,this.backendName);A(y!=null,()=>`Cannot find registered kernel '${d}' for backend '${this.backendName}'`),a=()=>{let b=this.backend.numDataIds();u=y.kernelFunc({inputs:h,attrs:g,backend:this.backend});let w=Array.isArray(u)?u:[u];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(d,b,w);let v=w.map(k=>{if(k.rank!=null)return k;let{dataId:E,shape:D,dtype:$}=k;return this.makeTensorFromDataId(E,D,$)});if(o){let k=this.getTensorsForGradient(d,h,v);n=this.saveTensorsForBackwardMode(k)}return v}}else{let{forwardFunc:d}=t,h=g=>{!o||(n=g.map(y=>this.keep(this.clone(y))))};a=()=>{let g=this.backend.numDataIds();u=this.tidy(()=>d(this.backend,h));let y=Array.isArray(u)?u:[u];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,g,y),y}}let{inputs:c,attrs:p}=t,m=Kv(t)?null:t.backwardsFunc,f;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?e=a():(f=this.profiler.profileKernel(l,c,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(f),e=f.outputs)}),o&&this.addTapeNode(l,c,e,m,n,p),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map(d=>c[d]!=null?c[d].shape:null),outputShapes:e.map(d=>d.shape),kernelTimeMs:f.timeMs,extraInfo:f.extraInfo}),Array.isArray(u)?e:e[0]}saveTensorsForBackwardMode(t){return t.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(t,e,n){let o=Rv(t);if(o!=null){let s=o.inputsToSave||[],i=o.outputsToSave||[],a;o.saveAllInputs?(A(Array.isArray(e),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(e).map(l=>e[l])):a=s.map(l=>e[l]);let u=n.filter((l,c)=>i[c]);return a.concat(u)}return[]}makeTensor(t,e,n,o){if(t==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",o=o||this.backend;let s=t;n==="string"&&Ko(t[0])&&(s=t.map(u=>Ml(u)));let i=o.write(s,e,n),a=new Vt(e,n,i,this.nextTensorId());if(this.trackTensor(a,o),n==="string"){let u=this.state.tensorInfo.get(i),l=Ev(s);this.state.numBytes+=l-u.bytes,u.bytes=l}return a}makeTensorFromDataId(t,e,n,o){n=n||"float32";let s=new Vt(e,n,t,this.nextTensorId());return this.trackTensor(s,o),s}makeVariable(t,e=!0,n,o){n=n||this.nextVariableId().toString(),o!=null&&o!==t.dtype&&(t=t.cast(o));let s=new Ll(t,e,n,this.nextTensorId());if(this.state.registeredVariables[s.name]!=null)throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(t,e){this.state.numTensors++,t.dtype==="string"&&this.state.numStringTensors++;let n=0;t.dtype!=="complex64"&&t.dtype!=="string"&&(n=t.size*tx(t.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(t.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:n})),t instanceof Ll||this.track(t)}incRef(t,e){this.trackTensor(t,e),this.backend.incRef(t.dataId)}removeDataId(t,e){this.state.tensorInfo.has(t)&&this.state.tensorInfo.get(t).backend===e&&(this.state.tensorInfo.delete(t),this.state.numDataBuffers--)}disposeTensor(t){if(!this.state.tensorInfo.has(t.dataId))return;let e=this.state.tensorInfo.get(t.dataId);if(this.state.numTensors--,t.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=e.bytes),t.dtype!=="complex64"&&t.dtype!=="string"){let n=t.size*tx(t.dtype);this.state.numBytes-=n}e.backend.disposeData(t.dataId)&&this.removeDataId(t.dataId,e.backend)}disposeVariables(){for(let t in this.state.registeredVariables){let e=this.state.registeredVariables[t];this.disposeVariable(e)}}disposeVariable(t){this.disposeTensor(t),this.state.registeredVariables[t.name]!=null&&delete this.state.registeredVariables[t.name]}memory(){let t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,t.reasons==null&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t}async profile(t){this.state.profiling=!0;let e=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(o=>o.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let o of this.state.activeProfile.kernels)o.kernelTimeMs=await o.kernelTimeMs,o.extraInfo=await o.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(t,e,n,o,s,i){let a={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:s},u=Rv(t);u!=null&&(o=u.gradFunc),o!=null&&(a.gradient=l=>(l=l.map((c,p)=>{if(c==null){let m=n[p],f=ap(m.size,m.dtype);return this.makeTensor(f,m.shape,m.dtype)}return c}),o(l.length>1?l:l[0],s,i))),this.state.activeTape.push(a)}keep(t){return t.kept=!0,t}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(t){let e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e}endScope(t){let e=Tf(t),n=new Set(e.map(s=>s.id));for(let s=0;s{!s.kept&&s.scopeId===o.id&&this.track(s)})}gradients(t,e,n,o=!1){if(A(e.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 s=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",t));A(s instanceof Vt,()=>"The result y returned by f() must be a tensor.");let i=h1(this.state.activeTape,e,s);if(!o&&i.length===0&&e.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 a={};a[s.id]=n==null?t4(s.shape):n,g1(a,i,l=>this.tidy(l),e4);let u=e.map(l=>a[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let c of l.saved)c.dispose()}),this.state.activeTape=null),{value:s,grads:u}})}customGrad(t){return A(fi(t),()=>"The f passed in customGrad(f) must be a function."),(...e)=>{A(e.every(a=>a instanceof Vt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,o={};e.forEach((a,u)=>{o[u]=a});let s=(a,u)=>(n=t(...e,u),A(n.value instanceof Vt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),A(fi(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),i=(a,u)=>{let l=n.gradFunc(a,u),c=Array.isArray(l)?l:[l];A(c.length===e.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(...)."),A(c.every(m=>m instanceof Vt),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let p={};return c.forEach((m,f)=>{p[f]=()=>m}),p};return this.runKernelFunc({forwardFunc:s,backwardsFunc:i,inputs:o})}}readSync(t){return this.state.tensorInfo.get(t).backend.readSync(t)}read(t){return this.state.tensorInfo.get(t).backend.read(t)}readToGPU(t,e){return this.state.tensorInfo.get(t).backend.readToGPU(t,e)}async time(t){let e=Tu(),n=await this.backend.time(t);return n.wallMs=Tu()-e,n}track(t){return this.state.activeScope!=null&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new jv;for(let t in this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}};Eu.nextTensorId=0;Eu.nextVariableId=0;function t4(r){let t=df(re(r),"float32");return _.makeTensor(t,r,"float32")}function Xv(){let r=$v();if(r._tfengine==null){let t=new ex(r);r._tfengine=new Eu(t)}return XT(r._tfengine.ENV),w1(()=>r._tfengine),r._tfengine}var _=Xv();function e4(r,t){let e={a:r,b:t};return _.runKernel(Kn,e)}var zl={};Yt(zl,{isBrowser:()=>Zv,isMobile:()=>o4,mockIsMobile:()=>n4});function r4(){return typeof navigator!="undefined"&&navigator!=null}var Yv;function n4(r){Yv=r}function o4(r){if(Yv!==void 0)return Yv;if(r||r4()){if(r||(r=navigator),r.product==="ReactNative")return!0;let t=r.userAgent||r.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let e=r;return e.userAgentData&&e.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 Zv(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var mo=V();mo.registerFlag("DEBUG",()=>!1,r=>{r&&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.")});mo.registerFlag("IS_BROWSER",()=>Zv());mo.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");mo.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));mo.registerFlag("PROD",()=>!1);mo.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>mo.getBool("DEBUG"));mo.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);mo.registerFlag("IS_TEST",()=>!1);mo.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);mo.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);mo.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function Or(r,t){let e=r;if(yr(r))return t==="string"?[]:[r.length];if(!Array.isArray(r))return[];let n=[];for(;Array.isArray(e)||yr(e)&&t!=="string";)n.push(e.length),e=e[0];return Array.isArray(r)&&V().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&k1(r,n,[]),n}function k1(r,t,e){if(e=e||[],!Array.isArray(r)&&!yr(r)){A(t.length===0,()=>`Element arr[${e.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}A(t.length>0,()=>`Element arr[${e.join("][")}] should be a primitive, but is an array of ${r.length} elements`),A(r.length===t[0],()=>`Element arr[${e.join("][")}] should have ${t[0]} elements, but has ${r.length} elements`);let n=t.slice(1);for(let o=0;o=0&&(o=n),S1(n,o,t,e),r==null||!yr(r)&&!Array.isArray(r)&&typeof r!="number"&&typeof r!="boolean"&&typeof r!="string"){let u=r==null?"null":r.constructor.name;throw new Error(`Argument '${t}' passed to '${e}' must be a Tensor or TensorLike, but got '${u}'`)}let s=Or(r,o);!yr(r)&&!Array.isArray(r)&&(r=[r]);let a=o!=="string"?Gp(r,o):qo(r,[],!0);return _.makeTensor(a,s,o)}function Pa(r,t,e,n="numeric"){if(!Array.isArray(r))throw new Error(`Argument ${t} passed to ${e} must be a \`Tensor[]\` or \`TensorLike[]\``);return r.map((s,i)=>C(s,`${t}[${i}]`,e,n))}var N1="__op";function N(r){let t=Object.keys(r);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 e=t[0],n=r[e];e.endsWith("_")&&(e=e.substring(0,e.length-1)),e=e+N1;let o=(...s)=>{_.startScope(e);try{let i=n(...s);return gf(i)&&console.error("Cannot return a Promise inside of tidy."),_.endScope(i),i}catch(i){throw _.endScope(null),i}};return Object.defineProperty(o,"name",{value:e,configurable:!0}),o}function s4(r,t){let e=C(r,"real","complex"),n=C(t,"imag","complex");Pe(e.shape,n.shape,`real and imag shapes, ${e.shape} and ${n.shape}, must match in call to tf.complex().`);let o={real:e,imag:n};return _.runKernel(mp,o)}var Mn=N({complex_:s4});function sn(r,t,e,n){if(n==null&&(n=sp(r)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!yr(r)&&!Array.isArray(r)&&typeof r!="number"&&typeof r!="boolean"&&typeof r!="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){hf(t);let o=re(t),s=re(e);A(o===s,()=>`Based on the provided shape, [${t}], the tensor should have ${o} values but has ${s}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${e}) does not match the provided shape (${t}). `)}}return!yr(r)&&!Array.isArray(r)&&(r=[r]),t=t||e,r=n!=="string"?Gp(r,n):qo(r,[],!0),_.makeTensor(r,t,n)}function Ar(r,t,e){let n=Or(r,e);return sn(r,t,n,e)}var _f={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};var ix=4;async function _1(r,t){let e=[],n=[],o=Array.isArray(r)?r.map(i=>i.name):Object.keys(r);for(let i=0;i{let m=await u.bytes(),f=m.reduce((g,y)=>g+y.length,0)+ix*m.length,d=new Uint8Array(f),h=0;for(let g=0;g{if(t+=s.byteLength,e.push(s.byteLength===s.buffer.byteLength?s:new s.constructor(s)),!(s instanceof Float32Array||s instanceof Int32Array||s instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`)});let n=new Uint8Array(t),o=0;return e.forEach(s=>{n.set(new Uint8Array(s.buffer),o),o+=s.byteLength}),n.buffer}var Jv=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function T1(r){return Jv?Buffer.byteLength(r):new Blob([r]).size}function E1(r){if(Jv)return Buffer.from(r).toString("base64");let t=new Uint8Array(r),e="";for(let n=0,o=t.length;n{t+=o.byteLength});let e=new Uint8Array(t),n=0;return r.forEach(o=>{e.set(new Uint8Array(o),n),n+=o.byteLength}),e.buffer}function Qv(r){let t="/";for(r=r.trim();r.endsWith(t);)r=r.slice(0,r.length-1);let e=r.split(t);return e[e.length-1]}function lx(r,t){let e={modelTopology:r.modelTopology,format:r.format,generatedBy:r.generatedBy,convertedBy:r.convertedBy,weightsManifest:t};return r.signature!=null&&(e.signature=r.signature),r.userDefinedMetadata!=null&&(e.userDefinedMetadata=r.userDefinedMetadata),r.modelInitializer!=null&&(e.modelInitializer=r.modelInitializer),r.trainingConfig!=null&&(e.trainingConfig=r.trainingConfig),e}async function qp(r,t){let e={modelTopology:r.modelTopology,format:r.format,generatedBy:r.generatedBy,convertedBy:r.convertedBy};if(r.trainingConfig!=null&&(e.trainingConfig=r.trainingConfig),r.weightsManifest!=null){let[n,o]=await t(r.weightsManifest);e.weightSpecs=n,e.weightData=o}return r.signature!=null&&(e.signature=r.signature),r.userDefinedMetadata!=null&&(e.userDefinedMetadata=r.userDefinedMetadata),r.modelInitializer!=null&&(e.modelInitializer=r.modelInitializer),e}function Fi(r){if(r.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:r.modelTopology==null?0:T1(JSON.stringify(r.modelTopology)),weightSpecsBytes:r.weightSpecs==null?0:T1(JSON.stringify(r.weightSpecs)),weightDataBytes:r.weightData==null?0:r.weightData.byteLength}}function a4(){let r=e=>{let n=e<<13,o=0;for(;(n&8388608)===0;)o-=8388608,n<<=1;return n&=-8388609,o+=947912704,n|o},t=new Uint32Array(2048);t[0]=0;for(let e=1;e<1024;e++)t[e]=r(e);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}function l4(){let r=new Uint32Array(64);r[0]=0,r[31]=1199570944,r[32]=2147483648,r[63]=3347054592;for(let t=1;t<31;t++)r[t]=t<<23;for(let t=33;t<63;t++)r[t]=2147483648+(t-32<<23);return r}function u4(){let r=new Uint32Array(64);for(let t=0;t<64;t++)r[t]=1024;return r[0]=r[32]=0,r}function c4(){let r=a4(),t=l4(),e=u4();return n=>{let o=new ArrayBuffer(4*n.length),s=new Uint32Array(o);for(let i=0;i>10]+(a&1023)]+t[a>>10];s[i]=u}return new Float32Array(o)}}var De=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return De.instance==null&&(De.instance=new De),De.instance}static registerSaveRouter(t){De.getInstance().saveRouters.push(t)}static registerLoadRouter(t){De.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return De.getHandlers(t,"save")}static getLoadHandlers(t,e){return De.getHandlers(t,"load",e)}static getHandlers(t,e,n){let o=[];return(e==="load"?De.getInstance().loadRouters:De.getInstance().saveRouters).forEach(i=>{let a=i(t,n);a!==null&&o.push(a)}),o}},D1=r=>De.registerSaveRouter(r),$1=r=>De.registerLoadRouter(r),R1=r=>De.getSaveHandlers(r),F1=(r,t)=>De.getLoadHandlers(r,t);var t0="tensorflowjs",e0=1,Au="models_store",Bl="model_info_store";function O1(){if(!V().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let r=typeof window=="undefined"?self:window,t=r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB||r.shimIndexedDB;if(t==null)throw new Error("The current browser does not appear to support IndexedDB.");return t}function r0(r){let t=r.result;t.createObjectStore(Au,{keyPath:"modelPath"}),t.createObjectStore(Bl,{keyPath:"modelPath"})}var Ma=class{constructor(t){if(this.indexedDB=O1(),t==null||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,t)}async load(){return this.databaseAction(this.modelPath)}databaseAction(t,e){return new Promise((n,o)=>{let s=this.indexedDB.open(t0,e0);s.onupgradeneeded=()=>r0(s),s.onsuccess=()=>{let i=s.result;if(e==null){let a=i.transaction(Au,"readonly"),l=a.objectStore(Au).get(this.modelPath);l.onsuccess=()=>{if(l.result==null)return i.close(),o(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(l.result.modelArtifacts)},l.onerror=c=>(i.close(),o(l.error)),a.oncomplete=()=>i.close()}else{let a=Fi(e),u=i.transaction(Bl,"readwrite"),l=u.objectStore(Bl),c=l.put({modelPath:this.modelPath,modelArtifactsInfo:a}),p;c.onsuccess=()=>{p=i.transaction(Au,"readwrite");let f=p.objectStore(Au).put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:a});f.onsuccess=()=>n({modelArtifactsInfo:a}),f.onerror=d=>{l=u.objectStore(Bl);let h=l.delete(this.modelPath);h.onsuccess=()=>(i.close(),o(f.error)),h.onerror=g=>(i.close(),o(f.error))}},c.onerror=m=>(i.close(),o(c.error)),u.oncomplete=()=>{p==null?i.close():p.oncomplete=()=>i.close()}}},s.onerror=i=>o(s.error)})}};Ma.URL_SCHEME="indexeddb://";var P1=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Ma.URL_SCHEME)?p4(r.slice(Ma.URL_SCHEME.length)):null;De.registerSaveRouter(P1);De.registerLoadRouter(P1);function p4(r){return new Ma(r)}function m4(r){return r.startsWith(Ma.URL_SCHEME)?r.slice(Ma.URL_SCHEME.length):r}var n0=class{constructor(){this.indexedDB=O1()}async listModels(){return new Promise((t,e)=>{let n=this.indexedDB.open(t0,e0);n.onupgradeneeded=()=>r0(n),n.onsuccess=()=>{let o=n.result,s=o.transaction(Bl,"readonly"),a=s.objectStore(Bl).getAll();a.onsuccess=()=>{let u={};for(let l of a.result)u[l.modelPath]=l.modelArtifactsInfo;t(u)},a.onerror=u=>(o.close(),e(a.error)),s.oncomplete=()=>o.close()},n.onerror=o=>e(n.error)})}async removeModel(t){return t=m4(t),new Promise((e,n)=>{let o=this.indexedDB.open(t0,e0);o.onupgradeneeded=()=>r0(o),o.onsuccess=()=>{let s=o.result,i=s.transaction(Bl,"readwrite"),a=i.objectStore(Bl),u=a.get(t),l;u.onsuccess=()=>{if(u.result==null)return s.close(),n(new Error(`Cannot find model with path '${t}' in IndexedDB.`));{let c=a.delete(t),p=()=>{l=s.transaction(Au,"readwrite");let f=l.objectStore(Au).delete(t);f.onsuccess=()=>e(u.result.modelArtifactsInfo),f.onerror=d=>n(u.error)};c.onsuccess=p,c.onerror=m=>(p(),s.close(),n(u.error))}},u.onerror=c=>(s.close(),n(u.error)),i.oncomplete=()=>{l==null?s.close():l.oncomplete=()=>s.close()}},o.onerror=s=>n(o.error)})}};var La="/",Kp="tensorflowjs_models",M1="info",f4="model_topology",d4="weight_specs",h4="weight_data",g4="model_metadata";function L1(r){return{info:[Kp,r,M1].join(La),topology:[Kp,r,f4].join(La),weightSpecs:[Kp,r,d4].join(La),weightData:[Kp,r,h4].join(La),modelMetadata:[Kp,r,g4].join(La)}}function z1(r){for(let t of Object.values(r))window.localStorage.removeItem(t)}function x4(r){let t=r.split(La);if(t.length<3)throw new Error(`Invalid key format: ${r}`);return t.slice(1,t.length-1).join(La)}function y4(r){return r.startsWith(za.URL_SCHEME)?r.slice(za.URL_SCHEME.length):r}var za=class{constructor(t){if(!V().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,t==null||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=L1(this.modelPath)}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{let e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),o=Fi(t);try{this.LS.setItem(this.keys.info,JSON.stringify(o)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,E1(t.weightData));let s={format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,signature:t.signature!=null?t.signature:void 0,userDefinedMetadata:t.userDefinedMetadata!=null?t.userDefinedMetadata:void 0,modelInitializer:t.modelInitializer!=null?t.modelInitializer:void 0,trainingConfig:t.trainingConfig!=null?t.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:o}}catch(s){throw z1(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=${o.modelTopologyBytes}, weightSpecsBytes=${o.weightSpecsBytes}, weightDataBytes=${o.weightDataBytes}.`)}}}async load(){let t=JSON.parse(this.LS.getItem(this.keys.info));if(t==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(t.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let e={},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.`);e.modelTopology=n;let o=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(o==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);e.weightSpecs=o;let s=this.LS.getItem(this.keys.modelMetadata);if(s!=null){let a=JSON.parse(s);e.format=a.format,e.generatedBy=a.generatedBy,e.convertedBy=a.convertedBy,a.signature!=null&&(e.signature=a.signature),a.userDefinedMetadata!=null&&(e.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(e.modelInitializer=a.modelInitializer),a.trainingConfig!=null&&(e.trainingConfig=a.trainingConfig)}let i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return e.weightData=A1(i),e}};za.URL_SCHEME="localstorage://";var B1=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(za.URL_SCHEME)?b4(r.slice(za.URL_SCHEME.length)):null;De.registerSaveRouter(B1);De.registerLoadRouter(B1);function b4(r){return new za(r)}var o0=class{constructor(){A(V().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),A(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let t={},e=Kp+La,n=La+M1;for(let o=0;o"scheme must not be undefined or null."),t.endsWith(jp)&&(t=t.slice(0,t.indexOf(jp))),A(t.length>0,()=>"scheme must not be an empty string.");let n=an.getInstance();A(n.managers[t]==null,()=>`A model store manager is already registered for scheme '${t}'.`),n.managers[t]=e}static getManager(t){let e=this.getInstance().managers[t];if(e==null)throw new Error(`Cannot find model manager for scheme '${t}'`);return e}static getSchemes(){return Object.keys(this.getInstance().managers)}};function ux(r){if(r.indexOf(jp)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${an.getSchemes().join(",")}`);return{scheme:r.split(jp)[0],path:r.split(jp)[1]}}async function V1(r,t,e=!1){A(r!==t,()=>`Old path and new path are the same: '${r}'`);let n=De.getLoadHandlers(r);A(n.length>0,()=>`Copying failed because no load handler is found for source URL ${r}.`),A(n.length<2,()=>`Copying failed because more than one (${n.length}) load handlers for source URL ${r}.`);let o=n[0],s=De.getSaveHandlers(t);A(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),A(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],a=ux(r).scheme,u=ux(r).path,l=a===ux(r).scheme,c=await o.load();e&&l&&await an.getManager(a).removeModel(u);let p=await i.save(c);return e&&!l&&await an.getManager(a).removeModel(u),p.modelArtifactsInfo}async function G1(){let r=an.getSchemes(),t={};for(let e of r){let n=await an.getManager(e).listModels();for(let o in n){let s=e+jp+o;t[s]=n[o]}}return t}async function W1(r){let t=ux(r);return an.getManager(t.scheme).removeModel(t.path)}async function U1(r,t){return V1(r,t,!1)}async function H1(r,t){return V1(r,t,!0)}var q1=class{fetch(t,e){return fetch(t,e)}now(){return performance.now()}encode(t,e){if(e!=="utf-8"&&e!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${e}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)}decode(t,e){return new TextDecoder(e).decode(t)}};if(V().get("IS_BROWSER")){V().setPlatform("browser",new q1);try{an.registerManager(za.URL_SCHEME,new o0)}catch(r){}try{an.registerManager(Ma.URL_SCHEME,new n0)}catch(r){}}var w4={importFetch:()=>K1()},s0;var X1=class{constructor(){this.util=j1(),this.textEncoder=new this.util.TextEncoder}fetch(t,e){return V().global.fetch!=null?V().global.fetch(t,e):(s0==null&&(s0=w4.importFetch()),s0(t,e))}now(){let t=process.hrtime();return t[0]*1e3+t[1]/1e6}encode(t,e){if(e!=="utf-8"&&e!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${e}`);return this.textEncoder.encode(t)}decode(t,e){return t.length===0?"":new this.util.TextDecoder(e).decode(t)}};V().get("IS_NODE")&&!V().get("IS_BROWSER")&&V().setPlatform("node",new X1);function It(r,t="float32",e){return t=t||"float32",hf(r),new me(r,t,e)}function v4(r,t){let e=C(r,"x","cast");if(!_v(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&e.dtype!=="string"||t!=="string"&&e.dtype==="string")throw new Error("Only strings can be casted to strings");let n={x:e},o={dtype:t};return _.runKernel(oo,n,o)}var Z=N({cast_:v4});function C4(r){let e={x:C(r,"x","clone","string_or_numeric")};return _.runKernel(io,e)}var In=N({clone_:C4});function i0(r,t=!1){console.log(r.toString(t))}Xv();var I4={buffer:It,cast:Z,clone:In,print:i0};v1(I4);var Pr={};Yt(Pr,{browserFiles:()=>J1,browserHTTPRequest:()=>e_,concatenateArrayBuffers:()=>Hp,copyModel:()=>U1,decodeWeights:()=>ax,encodeWeights:()=>_1,fromMemory:()=>n_,getLoadHandlers:()=>F1,getModelArtifactsForJSON:()=>qp,getModelArtifactsInfoForJSON:()=>Fi,getSaveHandlers:()=>R1,http:()=>mx,isHTTPScheme:()=>cx,listModels:()=>G1,loadWeights:()=>Q1,moveModel:()=>H1,registerLoadRouter:()=>$1,registerSaveRouter:()=>D1,removeModel:()=>W1,weightsLoaderFactory:()=>u0,withSaveHandler:()=>o_});var S4="model",k4=".json",N4=".weights.bin";function Y1(r){return new Promise(t=>setTimeout(t)).then(r)}var Vl=class{constructor(t){if(!V().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(Vl.URL_SCHEME)&&(t=t.slice(Vl.URL_SCHEME.length)),(t==null||t.length===0)&&(t=S4),this.modelJsonFileName=t+k4,this.weightDataFileName=t+N4}async save(t){if(typeof document=="undefined")throw new Error("Browser downloads are not supported in this environment since `document` is not present");let e=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"}));if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{let n=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],o=lx(t,n),s=window.URL.createObjectURL(new Blob([JSON.stringify(o)],{type:"application/json"})),i=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(i.download=this.modelJsonFileName,i.href=s,await Y1(()=>i.dispatchEvent(new MouseEvent("click"))),t.weightData!=null){let a=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;a.download=this.weightDataFileName,a.href=e,await Y1(()=>a.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Fi(t)}}}};Vl.URL_SCHEME="downloads://";var Z1=class{constructor(t){if(t==null||t.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${t}`);this.jsonFile=t[0],this.weightsFiles=t.slice(1)}async load(){return new Promise((t,e)=>{let n=new FileReader;n.onload=o=>{let s=JSON.parse(o.target.result),i=s.modelTopology;if(i==null){e(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(s.weightsManifest==null){e(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){t({modelTopology:i});return}let u=qp(s,l=>this.loadWeights(l));t(u)},n.onerror=o=>e(`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(t){let e=[],n=[];for(let i of t)e.push(...i.weights),n.push(...i.paths);let o=this.checkManifestAndWeightFiles(t),s=n.map(i=>this.loadWeightsFile(i,o[i]));return Promise.all(s).then(i=>[e,Hp(i)])}loadWeightsFile(t,e){return new Promise((n,o)=>{let s=new FileReader;s.onload=i=>{let a=i.target.result;n(a)},s.onerror=i=>o(`Failed to weights data from file of path '${t}'.`),s.readAsArrayBuffer(e)})}checkManifestAndWeightFiles(t){let e=[],n=this.weightsFiles.map(s=>Qv(s.name)),o={};for(let s of t)s.paths.forEach(i=>{let a=Qv(i);if(e.indexOf(a)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(e.push(a),n.indexOf(a)===-1)throw new Error(`Weight file with basename '${a}' is not provided.`);o[i]=this.weightsFiles[n.indexOf(a)]});if(e.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${e.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return o}},T4=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Vl.URL_SCHEME)?_4(r.slice(Vl.URL_SCHEME.length)):null;De.registerSaveRouter(T4);function _4(r="model"){return new Vl(r)}function J1(r){return new Z1(r)}function a0(r,t,e,n){i(r),e=e==null?0:e,n=n==null?1:n,a(e,n);let o=0,s=u=>(u.then(l=>{let c=e+ ++o/r.length*(n-e);return t(c),l}),u);function i(u){A(u!=null&&Array.isArray(u)&&u.length>0,()=>"promises must be a none empty array")}function a(u,l){A(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),A(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),A(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(r.map(s))}async function l0(r,t){t==null&&(t={});let e=t.fetchFunc==null?V().platform.fetch:t.fetchFunc,n=r.map(p=>e(p,t.requestInit,{isBinary:!0})),o=0,s=.5,a=(t.onProgress==null?await Promise.all(n):await a0(n,t.onProgress,o,s)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(a):await a0(a,t.onProgress,u,l)}async function Q1(r,t="",e,n){return u0(i=>l0(i,{requestInit:n}))(r,t,e)}function u0(r){return async(t,e="",n)=>{let o=t.map(()=>!1),s={},i=n!=null?n.map(()=>!1):[],a=[];if(t.forEach((f,d)=>{let h=0;f.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,b=_f[y]*re(g.shape),w=()=>{o[d]=!0,s[d]==null&&(s[d]=[]),s[d].push({manifestEntry:g,groupOffset:h,sizeBytes:b})};n!=null?n.forEach((v,k)=>{v===g.name&&(w(),i[k]=!0)}):w(),a.push(g.name),h+=b})}),!i.every(f=>f)){let f=n.filter((d,h)=>!i[h]);throw new Error(`Could not find weights in manifest with names: ${f.join(", ")}. Manifest JSON has weights with names: ${a.join(", ")}.`)}let u=o.reduce((f,d,h)=>(d&&f.push(h),f),[]),l=[];u.forEach(f=>{t[f].paths.forEach(d=>{let h=e+(e.endsWith("/")?"":"/")+d;l.push(h)})});let c=await r(l),p={},m=0;return u.forEach(f=>{let d=t[f].paths.length,h=0;for(let v=0;v{let k=g.slice(v.groupOffset,v.groupOffset+v.sizeBytes),E=ax(k,[v.manifestEntry]);for(let D in E)p[D]=E[D]}),m+=d}),p}}var E4="application/octet-stream",A4="application/json",px=class{constructor(t,e){if(this.DEFAULT_METHOD="POST",e==null&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,this.weightUrlConverter=e.weightUrlConverter,e.fetchFunc!=null?(A(typeof e.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=e.fetchFunc):this.fetch=V().platform.fetch,A(t!=null&&t.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(t)&&A(t.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${t.length}).`),this.path=t,e.requestInit!=null&&e.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{}}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);e.body=new FormData;let n=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],o=lx(t,n);e.body.append("model.json",new Blob([JSON.stringify(o)],{type:A4}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:E4}),"model.weights.bin");let s=await this.fetch(this.path,e);if(s.ok)return{modelArtifactsInfo:Fi(t),responses:[s]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.status}.`)}async load(){let t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw new Error(`Request to ${this.path} failed with status code ${t.status}. Please verify this URL points to the model JSON of the model to load.`);let e;try{e=await t.json()}catch(s){let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}let n=e.modelTopology,o=e.weightsManifest;if(n==null&&o==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return qp(e,s=>this.loadWeights(s))}async loadWeights(t){let e=Array.isArray(this.path)?this.path[1]:this.path,[n,o]=D4(e),s=this.weightPathPrefix||n,i=[];for(let c of t)i.push(...c.weights);let a=[],u=[];for(let c of t)for(let p of c.paths)this.weightUrlConverter!=null?u.push(this.weightUrlConverter(p)):a.push(s+p+o);this.weightUrlConverter&&a.push(...await Promise.all(u));let l=await l0(a,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[i,Hp(l)]}};px.URL_SCHEME_REGEX=/^https?:\/\//;function D4(r){let t=r.lastIndexOf("/"),e=r.lastIndexOf("?"),n=r.substring(0,t),o=e>t?r.substring(e):"";return[n+"/",o]}function cx(r){return r.match(px.URL_SCHEME_REGEX)!=null}var t_=(r,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let e=!0;if(Array.isArray(r)?e=r.every(n=>cx(n)):e=cx(r),e)return mx(r,t)}return null};De.registerSaveRouter(t_);De.registerLoadRouter(t_);function mx(r,t){return new px(r,t)}function e_(r,t){return mx(r,t)}var fx=class{constructor(t){this.modelArtifacts=t}async load(){return this.modelArtifacts}},r_=class{constructor(t){this.saveHandler=t}async save(t){return this.saveHandler(t)}};function n_(r,t,e,n){return arguments.length===1?r.modelTopology!=null||r.weightSpecs!=null?new fx(r):(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 fx({modelTopology:r})):(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 fx({modelTopology:r,weightSpecs:t,weightData:e,trainingConfig:n}))}function o_(r){return new r_(r)}var i_={};Yt(i_,{confusionMatrix:()=>s_});function $4(r,t,e=!1,n=!1){let o=C(r,"a","matMul"),s=C(t,"b","matMul");[o,s]=jt(o,s);let i={a:o,b:s},a={transposeA:e,transposeB:n};return _.runKernel(Zo,i,a)}var Mt=N({matMul_:$4});function R4(r,t,e=1,n=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let s={indices:C(r,"indices","oneHot","int32")},i={depth:t,onValue:e,offValue:n};return _.runKernel(Cs,s,i)}var Us=N({oneHot_:R4});function F4(r,t){let e=C(r,"x","transpose");if(t==null&&(t=e.shape.map((s,i)=>i).reverse()),A(e.rank===t.length,()=>`Error in transpose: rank of input ${e.rank} must match length of perm ${t}.`),t.forEach(s=>{A(s>=0&&s`All entries in 'perm' must be between 0 and ${e.rank-1} but got ${t}`)}),e.rank<=1)return e.clone();let n={x:e},o={perm:t};return _.runKernel(Vs,n,o)}var Gt=N({transpose_:F4});function O4(r,t,e){let n=C(r,"labels","confusionMatrix"),o=C(t,"predictions","confusionMatrix");A(e==null||e>0&&Number.isInteger(e),()=>`If provided, numClasses must be a positive integer, but got ${e}`),A(n.rank===1,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),A(o.rank===1,()=>`Expected the rank of predictions to be 1, but got ${o.rank}`),A(n.shape[0]===o.shape[0],()=>`Mismatch in the number of examples: ${n.shape[0]} vs. ${o.shape[0]}. Labels and predictions should have the same number of elements.`),A(e>0&&Number.isInteger(e),()=>`numClasses is required to be a positive integer, but got ${e}`);let s=Us(Z(n,"int32"),e),i=Us(Z(o,"int32"),e),a=Gt(s),u=Mt(a,i);return Z(u,"int32")}var s_=N({confusionMatrix_:O4});var Mr={};Yt(Mr,{assertAndGetBroadcastShape:()=>Lt,getBroadcastDims:()=>a_,getReductionAxes:()=>ge});function a_(r,t){let e=r.length,n=[];for(let o=0;o1&&i===1&&n.unshift(s)}return n}function ge(r,t){let e=[];for(let n=0;n1)&&e.unshift(s)}return e}function Lt(r,t){let e=[],n=Math.max(r.length,t.length);for(let o=0;oG4,fromPixelsAsync:()=>B4,toPixels:()=>V4});function c0(r,t,e){if(qn(r),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=Or(r,e);if(n.length!==3&&n.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(n.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return sn(r,t,n,e)}var Du;function l_(r,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(r==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let e=!1,n=!1,o=!1,s=!1,i=!1,a=!1;if(r.data instanceof Uint8Array)e=!0;else if(typeof ImageData!="undefined"&&r instanceof ImageData)n=!0;else if(typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement)o=!0;else if(typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement)s=!0;else if(r.getContext!=null)i=!0;else if(typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap)a=!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 ${r.constructor.name}`);if(o&&o&&r.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the