/* Face-API homepage: author: ' */ var NU=Object.create;var zC=Object.defineProperty;var TU=Object.getOwnPropertyDescriptor;var _U=Object.getOwnPropertyNames;var EU=Object.getPrototypeOf,AU=Object.prototype.hasOwnProperty;var Oe=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Yt=(r,t)=>{for(var e in t)zC(r,e,{get:t[e],enumerable:!0})},$U=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _U(t))!AU.call(r,o)&&o!==e&&zC(r,o,{get:()=>t[o],enumerable:!(n=TU(t,o))||n.enumerable});return r};var Ou=(r,t,e)=>(e=r!=null?NU(EU(r)):{},$U(t||!r||!r.__esModule?zC(e,"default",{value:r,enumerable:!0}):e,r));var W1=Oe((rlt,G1)=>{G1.exports=je;var co=null;try{co=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 je(r,t,e){this.low=r|0,this.high=t|0,this.unsigned=!!e}je.prototype.__isLong__;Object.defineProperty(je.prototype,"__isLong__",{value:!0});function Ln(r){return(r&&r.__isLong__)===!0}je.isLong=Ln;var F1={},R1={};function Gu(r,t){var e,n,o;return t?(r>>>=0,(o=0<=r&&r<256)&&(n=R1[r],n)?n:(e=Xe(r,(r|0)<0?-1:0,!0),o&&(R1[r]=e),e)):(r|=0,(o=-128<=r&&r<128)&&(n=F1[r],n)?n:(e=Xe(r,r<0?-1:0,!1),o&&(F1[r]=e),e))}je.fromInt=Gu;function po(r,t){if(isNaN(r))return t?Vu:mo;if(t){if(r<0)return Vu;if(r>=L1)return V1}else{if(r<=-M1)return Pn;if(r+1>=M1)return B1}return r<0?po(-r,t).neg():Xe(r%cm|0,r/cm|0,t)}je.fromNumber=po;function Xe(r,t,e){return new je(r,t,e)}je.fromBits=Xe;var wx=Math.pow;function JC(r,t,e){if(r.length===0)throw Error("empty string");if(r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return mo;if(typeof t=="number"?(e=t,t=!1):t=!!t,e=e||10,e<2||360)throw Error("interior hyphen");if(n===0)return JC(r.substring(1),t,e).neg();for(var o=po(wx(e,8)),s=mo,i=0;i>>0:this.low};yt.toNumber=function(){return this.unsigned?(this.high>>>0)*cm+(this.low>>>0):this.high*cm+(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(Pn)?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 Ln(t)||(t=qs(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(Ln(t)||(t=qs(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(Pn)?Pn:this.not().add(um)};yt.neg=yt.negate;yt.add=function(t){Ln(t)||(t=qs(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,Xe(m<<16|f,c<<16|p,this.unsigned)};yt.subtract=function(t){return Ln(t)||(t=qs(t)),this.add(t.neg())};yt.sub=yt.subtract;yt.multiply=function(t){if(this.isZero())return mo;if(Ln(t)||(t=qs(t)),co){var e=co.mul(this.low,this.high,t.low,t.high);return Xe(e,co.get_high(),this.unsigned)}if(t.isZero())return mo;if(this.eq(Pn))return t.isOdd()?Pn:mo;if(t.eq(Pn))return this.isOdd()?Pn:mo;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(P1)&&t.lt(P1))return po(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,Xe(f<<16|d,p<<16|m,this.unsigned)};yt.mul=yt.multiply;yt.divide=function(t){if(Ln(t)||(t=qs(t)),t.isZero())throw Error("division by zero");if(co){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?co.div_u:co.div_s)(this.low,this.high,t.low,t.high);return Xe(e,co.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Vu:mo;var n,o,s;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Vu;if(t.gt(this.shru(1)))return z1;s=Vu}else{if(this.eq(Pn)){if(t.eq(um)||t.eq(ZC))return Pn;if(t.eq(Pn))return um;var i=this.shr(1);return n=i.div(t).shl(1),n.eq(mo)?t.isNegative()?um:ZC:(o=this.sub(t.mul(n)),s=n.add(o.div(t)),s)}else if(t.eq(Pn))return this.unsigned?Vu:mo;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=mo}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:wx(2,a-48),l=po(n),c=l.mul(t);c.isNegative()||c.gt(o);)n-=u,l=po(n,this.unsigned),c=l.mul(t);l.isZero()&&(l=um),s=s.add(l),o=o.sub(c)}return s};yt.div=yt.divide;yt.modulo=function(t){if(Ln(t)||(t=qs(t)),co){var e=(this.unsigned?co.rem_u:co.rem_s)(this.low,this.high,t.low,t.high);return Xe(e,co.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};yt.mod=yt.modulo;yt.rem=yt.modulo;yt.not=function(){return Xe(~this.low,~this.high,this.unsigned)};yt.and=function(t){return Ln(t)||(t=qs(t)),Xe(this.low&t.low,this.high&t.high,this.unsigned)};yt.or=function(t){return Ln(t)||(t=qs(t)),Xe(this.low|t.low,this.high|t.high,this.unsigned)};yt.xor=function(t){return Ln(t)||(t=qs(t)),Xe(this.low^t.low,this.high^t.high,this.unsigned)};yt.shiftLeft=function(t){return Ln(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Xe(this.low<>>32-t,this.unsigned):Xe(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):Xe(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};yt.shr=yt.shiftRight;yt.shiftRightUnsigned=function(t){if(Ln(t)&&(t=t.toInt()),t&=63,t===0)return this;var e=this.high;if(t<32){var n=this.low;return Xe(n>>>t|e<<32-t,e>>>t,this.unsigned)}else return t===32?Xe(e,0,this.unsigned):Xe(e>>>t-32,0,this.unsigned)};yt.shru=yt.shiftRightUnsigned;yt.shr_u=yt.shiftRightUnsigned;yt.toSigned=function(){return this.unsigned?Xe(this.low,this.high,!1):this};yt.toUnsigned=function(){return this.unsigned?this:Xe(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]};je.fromBytes=function(t,e,n){return n?je.fromBytesLE(t,e):je.fromBytesBE(t,e)};je.fromBytesLE=function(t,e){return new je(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};je.fromBytesBE=function(t,e){return new je(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}});var S_=Oe(()=>{});var k_=Oe(()=>{});var iE=Oe((sE,uS)=>{(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})(sE,typeof uS=="object"&&uS,typeof define=="function"&&define)});var lE=Oe((aE,cS)=>{(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})(aE,typeof cS=="object"&&cS,typeof define=="function"&&define)});var cE=Oe((uE,pS)=>{(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})(uE,typeof pS=="object"&&pS,typeof define=="function"&&define)});var mE=Oe((pE,mS)=>{(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})(pE,typeof mS=="object"&&mS,typeof define=="function"&&define)});var dE=Oe((fE,fS)=>{(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})(fE,typeof fS=="object"&&fS,typeof define=="function"&&define)});var gE=Oe((hE,dS)=>{(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})(hE,typeof dS=="object"&&dS,typeof define=="function"&&define)});var hS=Oe(()=>{});var xE=Oe((hSt,Wx)=>{(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 $=g(h(v.entropy?[w,b(r)]:w==null?y():w,3),E),D=new f(E),F=function(){for(var P=D.g(o),W=a,U=0;P=l;)P/=2,W/=2,U>>>=1;return(P+U)/W};return F.int32=function(){return D.g(4)|0},F.quick=function(){return D.g(4)/4294967296},F.double=F,g(b(D.S),r),(v.pass||k||function(P,W,U,q){return q&&(q.S&&d(q,D),P.state=function(){return d(D,{})}),U?(t[i]=P,W):P})(F,$,"global"in v?v.global:this==t,v.state)}t["seed"+i]=m;function f(w){var v,k=w.length,E=this,$=0,D=E.i=E.j=0,F=E.S=[];for(k||(w=[k++]);${var ij=iE(),aj=lE(),lj=cE(),uj=mE(),cj=dE(),pj=gE(),lc=xE();lc.alea=ij;lc.xor128=aj;lc.xorwow=lj;lc.xorshift7=uj;lc.xor4096=cj;lc.tychei=pj;yE.exports=lc});var QD=Oe((JD,kk)=>{(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})(JD,typeof kk=="object"&&kk,typeof define=="function"&&define)});var eF=Oe((tF,Nk)=>{(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})(tF,typeof Nk=="object"&&Nk,typeof define=="function"&&define)});var nF=Oe((rF,Tk)=>{(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})(rF,typeof Tk=="object"&&Tk,typeof define=="function"&&define)});var sF=Oe((oF,_k)=>{(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})(oF,typeof _k=="object"&&_k,typeof define=="function"&&define)});var aF=Oe((iF,Ek)=>{(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})(iF,typeof Ek=="object"&&Ek,typeof define=="function"&&define)});var uF=Oe((lF,Ak)=>{(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})(lF,typeof Ak=="object"&&Ak,typeof define=="function"&&define)});var pF=Oe((cF,Fb)=>{(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 $=g(h(v.entropy?[w,b(t)]:w==null?y():w,3),E),D=new f(E),F=function(){for(var P=D.g(o),W=a,U=0;P=l;)P/=2,W/=2,U>>>=1;return(P+U)/W};return F.int32=function(){return D.g(4)|0},F.quick=function(){return D.g(4)/4294967296},F.double=F,g(b(D.S),t),(v.pass||k||function(P,W,U,q){return q&&(q.S&&d(q,D),P.state=function(){return d(D,{})}),U?(e[i]=P,W):P})(F,$,"global"in v?v.global:this==e,v.state)}function f(w){var v,k=w.length,E=this,$=0,D=E.i=E.j=0,F=E.S=[];for(k||(w=[k++]);${var NZ=QD(),TZ=eF(),_Z=nF(),EZ=sF(),AZ=aF(),$Z=uF(),Uc=pF();Uc.alea=NZ;Uc.xor128=TZ;Uc.xorwow=_Z;Uc.xorshift7=EZ;Uc.xor4096=AZ;Uc.tychei=$Z;mF.exports=Uc});var Dk=Oe(()=>{});var Wb=Oe(()=>{});var Rg=Oe(()=>{});var IW=Oe(()=>{});var SW=Oe(()=>{});var kW=Oe(()=>{});var NW=Oe((s0,YT)=>{var XT=(()=>{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&&Go(Ot.buffer),mp}function n(){return Ot.buffer!=gr&&Go(Ot.buffer),fp}function o(){return Ot.buffer!=gr&&Go(Ot.buffer),Ad}function s(){return Ot.buffer!=gr&&Go(Ot.buffer),zg}function i(){return Ot.buffer!=gr&&Go(Ot.buffer),Bg}function a(){return Ot.buffer!=gr&&Go(Ot.buffer),Vg}function u(){return Ot.buffer!=gr&&Go(Ot.buffer),Gg}var l=typeof t!="undefined"?t:{},c,p;l.ready=new Promise(function(T,O){c=T,p=O});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,O)=>{throw O},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,F,P;function W(T){if(T instanceof Bd)return;X("exiting due to exception: "+T)}var U,q,K;if(w){b?k=Rg().dirname(k)+"/":k=__dirname+"/",K=()=>{q||(U=Wb(),q=Rg())},$=function(G,Y){return K(),G=q.normalize(G),U.readFileSync(G,Y?void 0:"utf8")},F=O=>{var G=$(O,!0);return G.buffer||(G=new Uint8Array(G)),G},D=(O,G,Y)=>{K(),O=q.normalize(O),U.readFile(O,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(O){if(!(O instanceof Bd))throw O}),process.on("unhandledRejection",function(O){throw O}),g=(O,G)=>{if(Au())throw process.exitCode=O,G;W(G),process.exit(O)},l.inspect=function(){return"[Emscripten Module object]"};let T;try{T=IW()}catch(O){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),O}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||($=T=>{var O=new XMLHttpRequest;return O.open("GET",T,!1),O.send(null),O.responseText},b&&(F=T=>{var O=new XMLHttpRequest;return O.open("GET",T,!1),O.responseType="arraybuffer",O.send(null),new Uint8Array(O.response)}),D=(T,O,G)=>{var Y=new XMLHttpRequest;Y.open("GET",T,!0),Y.responseType="arraybuffer",Y.onload=()=>{if(Y.status==200||Y.status==0&&Y.response){O(Y.response);return}G()},Y.onerror=G,Y.send(null)}),P=T=>document.title=T);w&&typeof performance=="undefined"&&(global.performance=SW().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 nt=4;function st(T){st.shown||(st.shown={}),st.shown[T]||(st.shown[T]=1,X(T))}function it(T,O){if(typeof WebAssembly.Function=="function"){for(var G={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:O[0]=="v"?[]:[G[O[0]]]},ht=1;ht{bt=T},At=Atomics.load,Dt=Atomics.store,qt=Atomics.compareExchange,Kt;l.wasmBinary&&(Kt=l.wasmBinary);var ce=l.noExitRuntime||!0;typeof WebAssembly!="object"&&hp("no native wasm support detected");var Ot,$e,ke=!1,ae;function Ke(T,O){T||hp(O)}function Re(T){var O=l["_"+T];return O}function rn(T,O,G,Y,ht){var wt={string:function(On){var kp=0;if(On!=null&&On!==0){var C1=(On.length<<2)+1;kp=Sp(C1),Rn(On,kp,C1)}return kp},array:function(On){var kp=Sp(On.length);return _l(On,kp),kp}};function Tt(On){return O==="string"?jr(On):O==="boolean"?Boolean(On):On}var Gt=Re(T),sr=[],qo=0;if(Y)for(var Ko=0;Ko(G.buffer instanceof SharedArrayBuffer&&(G=new Uint8Array(G)),O.decode.call(O,G))}var nn=typeof TextDecoder!="undefined"?new Or("utf8"):void 0;function on(T,O,G){for(var Y=O+G,ht=O;T[ht]&&!(ht>=Y);)++ht;if(ht-O>16&&T.subarray&&nn)return nn.decode(T.subarray(O,ht));for(var wt="";O>10,56320|qo&1023)}}return wt}function jr(T,O){return T?on(n(),T,O):""}function oo(T,O,G,Y){if(!(Y>0))return 0;for(var ht=G,wt=G+Y-1,Tt=0;Tt=55296&&Gt<=57343){var sr=T.charCodeAt(++Tt);Gt=65536+((Gt&1023)<<10)|sr&1023}if(Gt<=127){if(G>=wt)break;O[G++]=Gt}else if(Gt<=2047){if(G+1>=wt)break;O[G++]=192|Gt>>6,O[G++]=128|Gt&63}else if(Gt<=65535){if(G+2>=wt)break;O[G++]=224|Gt>>12,O[G++]=128|Gt>>6&63,O[G++]=128|Gt&63}else{if(G+3>=wt)break;O[G++]=240|Gt>>18,O[G++]=128|Gt>>12&63,O[G++]=128|Gt>>6&63,O[G++]=128|Gt&63}}return O[G]=0,G-ht}function Rn(T,O,G){return oo(T,n(),O,G)}function Vo(T){for(var O=0,G=0;G=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|T.charCodeAt(++G)&1023),Y<=127?++O:Y<=2047?O+=2:Y<=65535?O+=3:O+=4}return O}var so=typeof TextDecoder!="undefined"?new Or("utf-16le"):void 0;function _l(T,O){e().set(T,O)}function _u(T,O,G){for(var Y=0;Y>0]=T.charCodeAt(Y);G||(e()[O>>0]=0)}function pp(T,O){return T%O>0&&(T+=O-T%O),T}var gr,mp,fp,Ad,zg,Bg,r1,Vg,Gg;v&&(gr=l.buffer);function Go(T){gr=T,l.HEAP8=mp=new Int8Array(T),l.HEAP16=Ad=new Int16Array(T),l.HEAP32=Bg=new Int32Array(T),l.HEAPU8=fp=new Uint8Array(T),l.HEAPU16=zg=new Uint16Array(T),l.HEAPU32=r1=new Uint32Array(T),l.HEAPF32=Vg=new Float32Array(T),l.HEAPF64=Gg=new Float64Array(T)}var Wg=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:Wg/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),Wg=gr.byteLength,Go(gr);var qn,dp=[],El=[],l0=[],Ug=[],Eu=!1,u0=!1,Hg=0;function Au(){return ce||Hg>0}function sn(){if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)n1(l.preRun.shift());Xg(dp)}function $d(){Eu=!0,!v&&Xg(El)}function c0(){v||(Ut.terminateAllThreads(),u0=!0)}function p0(){if(!v){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;)Dd(l.postRun.shift());Xg(Ug)}}function n1(T){dp.unshift(T)}function o1(T){El.unshift(T)}function Dd(T){Ug.unshift(T)}var Al=0,qg=null,Wo=null;function Fd(T){Al++,l.monitorRunDependencies&&l.monitorRunDependencies(Al)}function s1(T){if(Al--,l.monitorRunDependencies&&l.monitorRunDependencies(Al),Al==0&&(qg!==null&&(clearInterval(qg),qg=null),Wo)){var O=Wo;Wo=null,O()}}l.preloadedImages={},l.preloadedAudios={};function hp(T){v?postMessage({cmd:"onAbort",arg:T}):l.onAbort&&l.onAbort(T),T="Aborted("+T+")",X(T),ke=!0,ae=1,T+=". Build with -s ASSERTIONS=1 for more info.";var O=new WebAssembly.RuntimeError(T);throw p(O),O}var m0="data:application/octet-stream;base64,";function Rd(T){return T.startsWith(m0)}function Kg(T){return T.startsWith("file://")}var an;an="tfjs-backend-wasm-threaded-simd.wasm",Rd(an)||(an=E(an));function jg(T){try{if(T==an&&Kt)return new Uint8Array(Kt);if(F)return F(T);throw"both async and sync fetching of the wasm failed"}catch(O){hp(O)}}function gp(){if(!Kt&&(y||b)){if(typeof fetch=="function"&&!Kg(an))return fetch(an,{credentials:"same-origin"}).then(function(T){if(!T.ok)throw"failed to load wasm binary file at '"+an+"'";return T.arrayBuffer()}).catch(function(){return jg(an)});if(D)return new Promise(function(T,O){D(an,function(G){T(new Uint8Array(G))},O)})}return Promise.resolve().then(function(){return jg(an)})}function f0(){var T={env:ax,wasi_snapshot_preview1:ax};function O(Tt,Gt){var sr=Tt.exports;if(l.asm=sr,w0(l.asm.emscripten_tls_init),qn=l.asm.__indirect_function_table,o1(l.asm.__wasm_call_ctors),$e=Gt,!v){var qo=Ut.unusedWorkers.length;Ut.unusedWorkers.forEach(function(Ko){Ut.loadWasmModuleToWorker(Ko,function(){--qo||s1("wasm-instantiate")})})}}v||Fd("wasm-instantiate");function G(Tt){O(Tt.instance,Tt.module)}function Y(Tt){return gp().then(function(Gt){return WebAssembly.instantiate(Gt,T)}).then(function(Gt){return Gt}).then(Tt,function(Gt){X("failed to asynchronously prepare wasm: "+Gt),hp(Gt)})}function ht(){return!Kt&&typeof WebAssembly.instantiateStreaming=="function"&&!Rd(an)&&!Kg(an)&&typeof fetch=="function"?fetch(an,{credentials:"same-origin"}).then(function(Tt){var Gt=WebAssembly.instantiateStreaming(Tt,T);return Gt.then(G,function(sr){return X("wasm streaming compile failed: "+sr),X("falling back to ArrayBuffer instantiation"),Y(G)})}):Y(G)}if(l.instantiateWasm)try{var wt=l.instantiateWasm(T,O);return wt}catch(Tt){return X("Module.instantiateWasm callback failed with error: "+Tt),!1}return ht().catch(p),{}}var i1,a1,d0={};function Xg(T){for(;T.length>0;){var O=T.shift();if(typeof O=="function"){O(l);continue}var G=O.func;typeof G=="number"?O.arg===void 0?yp(G)():yp(G)(O.arg):G(O.arg===void 0?null:O.arg)}}function xp(T){var O=PC(),G=T();return mx(O),G}function FW(T){return T}function l1(T){var O=/\b_Z[\w\d_]+/g;return T.replace(O,function(G){var Y=G;return G===Y?G:Y+" ["+G+"]"})}function h0(T){i()[T>>2]=0;var O=Ut.pthreads[T];delete Ut.pthreads[T],O.worker.terminate(),MC(T),Ut.runningWorkers.splice(Ut.runningWorkers.indexOf(O.worker),1),O.worker.pthread=void 0}function g0(T){var O=Ut.pthreads[T];O.worker.postMessage({cmd:"cancel"})}function Yg(T){var O=Ut.pthreads[T];if(O){i()[T>>2]=0;var G=O.worker;Ut.returnWorkerToPool(G)}}function Zg(T){CU(T)}function x0(T){if(T instanceof Bd||T=="unwind")return ae;g(1,T)}var Ut={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){v?Ut.initWorker():Ut.initMainThread()},initMainThread:function(){for(var T=8,O=0;O>2]=0;try{T()}finally{i()[v1>>2]=1}},receiveObjectTransfer:function(T){},threadInit:function(){for(var T in Ut.tlsInitFunctions)Ut.tlsInitFunctions[T]()},loadWasmModuleToWorker:function(T,O){T.onmessage=G=>{var Y=G.data,ht=Y.cmd;if(T.pthread&&(Ut.currentProxiedOperationCallerThread=T.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=px()){var wt=Ut.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!"),Ut.currentProxiedOperationCallerThread=void 0;return}ht==="processQueuedMainThreadWork"?g1():ht==="spawnThread"?Qg(Y):ht==="cleanupThread"?Yg(Y.thread):ht==="killThread"?h0(Y.thread):ht==="cancelThread"?g0(Y.thread):ht==="loaded"?(T.loaded=!0,O&&O(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),Ut.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:$e})},allocateUnusedWorker:function(){var T=E("tfjs-backend-wasm-threaded-simd.worker.js");Ut.unusedWorkers.push(new Worker(T))},getNewWorker:function(){return Ut.unusedWorkers.length==0&&(Ut.allocateUnusedWorker(),Ut.loadWasmModuleToWorker(Ut.unusedWorkers[0])),Ut.unusedWorkers.pop()}};function y0(){var T=px(),O=i()[T+44>>2],G=i()[T+48>>2],Y=O-G;w1(O,Y),mx(O)}l.establishStackSpace=y0;function Jg(T){if(v)return Fu(1,0,T);try{Zg(T)}catch(O){x0(O)}}var $u=[];function yp(T){var O=$u[T];return O||(T>=$u.length&&($u.length=T+1),$u[T]=O=qn.get(T)),O}function b0(T,O){return yp(T)(O)}l.invokeEntryPoint=b0;function u1(){var T=new Error;if(!T.stack){try{throw new Error}catch(O){T=O}if(!T.stack)return"(no stack trace available)"}return T.stack.toString()}function w0(T,O,G){Ut.tlsInitFunctions.push(T)}function c1(T,O){qn.set(T,O),$u[T]=O}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 v0=!0;function C0(T){return i()[h1()>>2]=T,T}function I0(T,O){var G;if(T===0)G=Date.now();else if((T===1||T===4)&&v0)G=Du();else return C0(28),-1;return i()[O>>2]=G/1e3|0,i()[O+4>>2]=G%1e3*1e3*1e3|0,0}function S0(T,O){return I0(T,O)}function k0(T){x1(T,!b,1,!y),Ut.threadInit()}function N0(T){v?postMessage({cmd:"cleanupThread",thread:T}):Yg(T)}function Qg(T){var O=Ut.getNewWorker();if(!O)return 6;Ut.runningWorkers.push(O);var G=Ut.pthreads[T.pthread_ptr]={worker:O,threadInfoStruct:T.pthread_ptr};O.pthread=G;var Y={cmd:"run",start_routine:T.startRoutine,arg:T.arg,threadInfoStruct:T.pthread_ptr};return O.runPthread=()=>{Y.time=performance.now(),O.postMessage(Y,T.transferList)},O.loaded&&(O.runPthread(),delete O.runPthread),0}function T0(T,O,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 y1(687865856,T,O,G,Y);if(wt)return wt;var Tt={startRoutine:G,pthread_ptr:T,arg:Y,transferList:ht};return v?(Tt.cmd="spawnThread",postMessage(Tt,ht),0):Qg(Tt)}function _0(){return 2097152}function E0(T,O){if(T==O)postMessage({cmd:"processQueuedMainThreadWork"});else if(v)postMessage({targetThread:T,cmd:"processThreadQueue"});else{var G=Ut.pthreads[T],Y=G&&G.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function A0(){hp("")}function $0(){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 tx(){return 2147483648}function D0(T,O,G){n().copyWithin(T,O,O+G)}function F0(){return w?kW().cpus().length:navigator.hardwareConcurrency}function Fu(T,O){var G=arguments.length-2,Y=arguments;return xp(function(){for(var ht=G,wt=Sp(ht*8),Tt=wt>>3,Gt=0;Gt>3,ht=0;ht>>16),Go(Ot.buffer),1}catch(O){}}function M0(T){var O=n().length;if(T=T>>>0,T<=O)return!1;var G=tx();if(T>G)return!1;for(var Y=1;Y<=4;Y*=2){var ht=O*(1+.2/Y);ht=Math.min(ht,T+100663296);var wt=Math.min(G,pp(Math.max(T,ht),65536)),Tt=O0(wt);if(Tt)return!0}return!1}var ne={inEventHandler:0,removeAllEventListeners:function(){for(var T=ne.eventHandlers.length-1;T>=0;--T)ne._removeHandler(T);ne.eventHandlers=[],ne.deferredCalls=[]},registerRemoveEventListeners:function(){ne.removeEventListenersRegistered||(l0.push(ne.removeAllEventListeners),ne.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(T,O,G){function Y(Tt,Gt){if(Tt.length!=Gt.length)return!1;for(var sr in Tt)if(Tt[sr]!=Gt[sr])return!1;return!0}for(var ht in ne.deferredCalls){var wt=ne.deferredCalls[ht];if(wt.targetFunction==T&&Y(wt.argsList,G))return}ne.deferredCalls.push({targetFunction:T,precedence:O,argsList:G}),ne.deferredCalls.sort(function(Tt,Gt){return Tt.precedence>2]=G,i()[wt+4>>2]=Y,i()[wt+8>>2]=ht,OC(T,637534208,O,Y,wt)})},getTargetThreadForEventCallback:function(T){switch(T){case 1:return 0;case 2:return Ut.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 P0(T){var O=Vo(T)+1,G=RC(O);return Rn(T,G,O),G}function L0(T,O,G,Y){xp(function(){var ht=Sp(12),wt=0;O&&(wt=P0(O)),i()[ht>>2]=wt,i()[ht+4>>2]=G,i()[ht+8>>2]=Y,OC(T,657457152,0,wt,ht)})}function z0(T,O,G,Y){O=O?jr(O):"",L0(T,O,G,Y)}function B0(T){return T>2?jr(T):T}var V0=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function G0(T){T=B0(T);var O=V0[T]||(typeof document!="undefined"?document.querySelector(T):void 0);return O}function Md(T){return G0(T)}function ex(T,O,G){var Y=Md(T);if(!Y)return-4;if(Y.canvasSharedPtr&&(i()[Y.canvasSharedPtr>>2]=O,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=O,Y.height=G,ht&&Y.GLctxObject.GLctx.viewport(0,0,O,G)}else if(Y.canvasSharedPtr){var Tt=i()[Y.canvasSharedPtr+8>>2];return z0(Tt,T,O,G),1}else return-4;return 0}function rx(T,O,G){return v?Fu(2,1,T,O,G):ex(T,O,G)}function W0(T,O,G){var Y=Md(T);return Y?ex(T,O,G):rx(T,O,G)}function U0(){throw"unwind"}function H0(T){var O=T.getExtension("ANGLE_instanced_arrays");if(O)return T.vertexAttribDivisor=function(G,Y){O.vertexAttribDivisorANGLE(G,Y)},T.drawArraysInstanced=function(G,Y,ht,wt){O.drawArraysInstancedANGLE(G,Y,ht,wt)},T.drawElementsInstanced=function(G,Y,ht,wt,Tt){O.drawElementsInstancedANGLE(G,Y,ht,wt,Tt)},1}function q0(T){var O=T.getExtension("OES_vertex_array_object");if(O)return T.createVertexArray=function(){return O.createVertexArrayOES()},T.deleteVertexArray=function(G){O.deleteVertexArrayOES(G)},T.bindVertexArray=function(G){O.bindVertexArrayOES(G)},T.isVertexArray=function(G){return O.isVertexArrayOES(G)},1}function K0(T){var O=T.getExtension("WEBGL_draw_buffers");if(O)return T.drawBuffers=function(G,Y){O.drawBuffersWEBGL(G,Y)},1}function j0(T){return!!(T.multiDrawWebgl=T.getExtension("WEBGL_multi_draw"))}var or={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(O){or.lastError||(or.lastError=O)},getNewId:function(T){for(var O=or.counter++,G=T.length;G>2]:-1;ht+=jr(i()[G+wt*4>>2],Tt<0?void 0:Tt)}return ht},createContext:function(T,O){T.getContextSafariWebGL2Fixed||(T.getContextSafariWebGL2Fixed=T.getContext,T.getContext=function(ht,wt){var Tt=T.getContextSafariWebGL2Fixed(ht,wt);return ht=="webgl"==Tt instanceof WebGLRenderingContext?Tt:null});var G=T.getContext("webgl",O);if(!G)return 0;var Y=or.registerContext(G,O);return Y},registerContext:function(T,O){var G=RC(8);i()[G+4>>2]=px();var Y={handle:G,attributes:O,version:O.majorVersion,GLctx:T};return T.canvas&&(T.canvas.GLctxObject=Y),or.contexts[G]=Y,(typeof O.enableExtensionsByDefault=="undefined"||O.enableExtensionsByDefault)&&or.initExtensions(Y),G},makeContextCurrent:function(T){return or.currentContext=or.contexts[T],l.ctx=ix=or.currentContext&&or.currentContext.GLctx,!(T&&!ix)},getContext:function(T){return or.contexts[T]},deleteContext:function(T){or.currentContext===or.contexts[T]&&(or.currentContext=null),typeof ne=="object"&&ne.removeAllHandlersOnTarget(or.contexts[T].GLctx.canvas),or.contexts[T]&&or.contexts[T].GLctx.canvas&&(or.contexts[T].GLctx.canvas.GLctxObject=void 0),d1(or.contexts[T].handle),or.contexts[T]=null},initExtensions:function(T){if(T||(T=or.currentContext),!T.initExtensionsDone){T.initExtensionsDone=!0;var O=T.GLctx;H0(O),q0(O),K0(O),O.disjointTimerQueryExt=O.getExtension("EXT_disjoint_timer_query"),j0(O);var G=O.getSupportedExtensions()||[];G.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&O.getExtension(Y)})}}},X0=["default","low-power","high-performance"];function Y0(T,O){var G=O>>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:X0[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=Md(T);if(!wt||ht.explicitSwapControl)return 0;var Tt=or.createContext(wt,ht);return Tt}function Z0(T,O){return Y0(T,O)}var bp={mappings:{},buffers:[null,[],[]],printChar:function(T,O){var G=bp.buffers[T];O===0||O===10?((T===1?rt:X)(on(G,0)),G.length=0):G.push(O)},varargs:void 0,get:function(){bp.varargs+=4;var T=i()[bp.varargs-4>>2];return T},getStr:function(T){var O=jr(T);return O},get64:function(T,O){return T}};function nx(T){return v?Fu(3,1,T):0}function ox(T,O,G,Y,ht){if(v)return Fu(4,1,T,O,G,Y,ht)}function sx(T,O,G,Y){if(v)return Fu(5,1,T,O,G,Y);for(var ht=0,wt=0;wt>2],Gt=i()[O+4>>2];O+=8;for(var sr=0;sr>2]=ht,0}function J0(T){kt(T)}Ut.init();var ix,Q0=[null,Jg,rx,nx,ox,sx],p1=!1,ax={__clock_gettime:S0,__emscripten_init_main_thread_js:k0,__emscripten_thread_cleanup:N0,__pthread_create_js:T0,_emscripten_default_pthread_stack_size:_0,_emscripten_notify_thread_queue:E0,abort:A0,emscripten_check_blocking_allowed:$0,emscripten_get_heap_max:tx,emscripten_get_now:Du,emscripten_memcpy_big:D0,emscripten_num_logical_cores:F0,emscripten_receive_on_main_thread_js:R0,emscripten_resize_heap:M0,emscripten_set_canvas_element_size:W0,emscripten_unwind_to_js_event_loop:U0,emscripten_webgl_create_context:Z0,exit:Zg,fd_close:nx,fd_seek:ox,fd_write:sx,memory:Ot||l.wasmMemory,setTempRet0:J0},m1=f0(),tC=l.___wasm_call_ctors=function(){return(tC=l.___wasm_call_ctors=l.asm.__wasm_call_ctors).apply(null,arguments)},eC=l._init=function(){return(eC=l._init=l.asm.init).apply(null,arguments)},rC=l._init_with_threads_count=function(){return(rC=l._init_with_threads_count=l.asm.init_with_threads_count).apply(null,arguments)},nC=l._get_threads_count=function(){return(nC=l._get_threads_count=l.asm.get_threads_count).apply(null,arguments)},oC=l._register_tensor=function(){return(oC=l._register_tensor=l.asm.register_tensor).apply(null,arguments)},sC=l._dispose_data=function(){return(sC=l._dispose_data=l.asm.dispose_data).apply(null,arguments)},iC=l._dispose=function(){return(iC=l._dispose=l.asm.dispose).apply(null,arguments)},aC=l._Abs=function(){return(aC=l._Abs=l.asm.Abs).apply(null,arguments)},lC=l._Add=function(){return(lC=l._Add=l.asm.Add).apply(null,arguments)},uC=l._AddN=function(){return(uC=l._AddN=l.asm.AddN).apply(null,arguments)},cC=l._All=function(){return(cC=l._All=l.asm.All).apply(null,arguments)},pC=l._Any=function(){return(pC=l._Any=l.asm.Any).apply(null,arguments)},mC=l._ArgMax=function(){return(mC=l._ArgMax=l.asm.ArgMax).apply(null,arguments)},fC=l._AvgPool=function(){return(fC=l._AvgPool=l.asm.AvgPool).apply(null,arguments)},dC=l._BatchMatMul=function(){return(dC=l._BatchMatMul=l.asm.BatchMatMul).apply(null,arguments)},hC=l._Ceil=function(){return(hC=l._Ceil=l.asm.Ceil).apply(null,arguments)},gC=l._ClipByValue=function(){return(gC=l._ClipByValue=l.asm.ClipByValue).apply(null,arguments)},xC=l._Conv2D=function(){return(xC=l._Conv2D=l.asm.Conv2D).apply(null,arguments)},yC=l._Conv2DBackpropInput=function(){return(yC=l._Conv2DBackpropInput=l.asm.Conv2DBackpropInput).apply(null,arguments)},bC=l._Cos=function(){return(bC=l._Cos=l.asm.Cos).apply(null,arguments)},wC=l._Cosh=function(){return(wC=l._Cosh=l.asm.Cosh).apply(null,arguments)},vC=l._CropAndResize=function(){return(vC=l._CropAndResize=l.asm.CropAndResize).apply(null,arguments)},CC=l._Cumprod=function(){return(CC=l._Cumprod=l.asm.Cumprod).apply(null,arguments)},IC=l._Cumsum=function(){return(IC=l._Cumsum=l.asm.Cumsum).apply(null,arguments)},SC=l._DepthToSpace=function(){return(SC=l._DepthToSpace=l.asm.DepthToSpace).apply(null,arguments)},kC=l._DepthwiseConv2dNative=function(){return(kC=l._DepthwiseConv2dNative=l.asm.DepthwiseConv2dNative).apply(null,arguments)},NC=l._Elu=function(){return(NC=l._Elu=l.asm.Elu).apply(null,arguments)},TC=l._Equal=function(){return(TC=l._Equal=l.asm.Equal).apply(null,arguments)},_C=l._Exp=function(){return(_C=l._Exp=l.asm.Exp).apply(null,arguments)},EC=l._FlipLeftRight=function(){return(EC=l._FlipLeftRight=l.asm.FlipLeftRight).apply(null,arguments)},lx=l._Floor=function(){return(lx=l._Floor=l.asm.Floor).apply(null,arguments)},ux=l._FloorDiv=function(){return(ux=l._FloorDiv=l.asm.FloorDiv).apply(null,arguments)},Pd=l._FusedBatchNorm=function(){return(Pd=l._FusedBatchNorm=l.asm.FusedBatchNorm).apply(null,arguments)},AC=l._FusedConv2D=function(){return(AC=l._FusedConv2D=l.asm.FusedConv2D).apply(null,arguments)},$C=l._FusedDepthwiseConv2D=function(){return($C=l._FusedDepthwiseConv2D=l.asm.FusedDepthwiseConv2D).apply(null,arguments)},wp=l._Gather=function(){return(wp=l._Gather=l.asm.Gather).apply(null,arguments)},Ld=l._GatherNd=function(){return(Ld=l._GatherNd=l.asm.GatherNd).apply(null,arguments)},zd=l._Greater=function(){return(zd=l._Greater=l.asm.Greater).apply(null,arguments)},f1=l._GreaterEqual=function(){return(f1=l._GreaterEqual=l.asm.GreaterEqual).apply(null,arguments)},vp=l._LeakyRelu=function(){return(vp=l._LeakyRelu=l.asm.LeakyRelu).apply(null,arguments)},Cp=l._Less=function(){return(Cp=l._Less=l.asm.Less).apply(null,arguments)},DC=l._LessEqual=function(){return(DC=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)},$t=l._MaxPool=function(){return($t=l._MaxPool=l.asm.MaxPool).apply(null,arguments)},fe=l._Maximum=function(){return(fe=l._Maximum=l.asm.Maximum).apply(null,arguments)},ge=l._Mean=function(){return(ge=l._Mean=l.asm.Mean).apply(null,arguments)},oe=l._Min=function(){return(oe=l._Min=l.asm.Min).apply(null,arguments)},ee=l._Minimum=function(){return(ee=l._Minimum=l.asm.Minimum).apply(null,arguments)},xr=l._MirrorPad=function(){return(xr=l._MirrorPad=l.asm.MirrorPad).apply(null,arguments)},Uo=l._Multiply=function(){return(Uo=l._Multiply=l.asm.Multiply).apply(null,arguments)},Ho=l._Neg=function(){return(Ho=l._Neg=l.asm.Neg).apply(null,arguments)},Ip=l._NonMaxSuppressionV3=function(){return(Ip=l._NonMaxSuppressionV3=l.asm.NonMaxSuppressionV3).apply(null,arguments)},Ru=l._NonMaxSuppressionV4=function(){return(Ru=l._NonMaxSuppressionV4=l.asm.NonMaxSuppressionV4).apply(null,arguments)},FC=l._NonMaxSuppressionV5=function(){return(FC=l._NonMaxSuppressionV5=l.asm.NonMaxSuppressionV5).apply(null,arguments)},ln=l._NotEqual=function(){return(ln=l._NotEqual=l.asm.NotEqual).apply(null,arguments)},$l=l._OneHot=function(){return($l=l._OneHot=l.asm.OneHot).apply(null,arguments)},cx=l._PadV2=function(){return(cx=l._PadV2=l.asm.PadV2).apply(null,arguments)},RW=l._Pow=function(){return(RW=l._Pow=l.asm.Pow).apply(null,arguments)},OW=l._Prelu=function(){return(OW=l._Prelu=l.asm.Prelu).apply(null,arguments)},MW=l._Prod=function(){return(MW=l._Prod=l.asm.Prod).apply(null,arguments)},PW=l._RealDiv=function(){return(PW=l._RealDiv=l.asm.RealDiv).apply(null,arguments)},LW=l._Relu=function(){return(LW=l._Relu=l.asm.Relu).apply(null,arguments)},zW=l._Relu6=function(){return(zW=l._Relu6=l.asm.Relu6).apply(null,arguments)},BW=l._ResizeBilinear=function(){return(BW=l._ResizeBilinear=l.asm.ResizeBilinear).apply(null,arguments)},VW=l._Reverse=function(){return(VW=l._Reverse=l.asm.Reverse).apply(null,arguments)},GW=l._RotateWithOffset=function(){return(GW=l._RotateWithOffset=l.asm.RotateWithOffset).apply(null,arguments)},WW=l._Round=function(){return(WW=l._Round=l.asm.Round).apply(null,arguments)},UW=l._Rsqrt=function(){return(UW=l._Rsqrt=l.asm.Rsqrt).apply(null,arguments)},HW=l._ScatterNd=function(){return(HW=l._ScatterNd=l.asm.ScatterNd).apply(null,arguments)},qW=l._SelectV2=function(){return(qW=l._SelectV2=l.asm.SelectV2).apply(null,arguments)},KW=l._Sigmoid=function(){return(KW=l._Sigmoid=l.asm.Sigmoid).apply(null,arguments)},jW=l._Sin=function(){return(jW=l._Sin=l.asm.Sin).apply(null,arguments)},XW=l._Softmax=function(){return(XW=l._Softmax=l.asm.Softmax).apply(null,arguments)},YW=l._SparseFillEmptyRows=function(){return(YW=l._SparseFillEmptyRows=l.asm.SparseFillEmptyRows).apply(null,arguments)},ZW=l._SparseReshape=function(){return(ZW=l._SparseReshape=l.asm.SparseReshape).apply(null,arguments)},JW=l._SparseSegmentReduction=function(){return(JW=l._SparseSegmentReduction=l.asm.SparseSegmentReduction).apply(null,arguments)},QW=l._Sqrt=function(){return(QW=l._Sqrt=l.asm.Sqrt).apply(null,arguments)},tU=l._Square=function(){return(tU=l._Square=l.asm.Square).apply(null,arguments)},eU=l._SquaredDifference=function(){return(eU=l._SquaredDifference=l.asm.SquaredDifference).apply(null,arguments)},rU=l._Step=function(){return(rU=l._Step=l.asm.Step).apply(null,arguments)},nU=l._StridedSlice=function(){return(nU=l._StridedSlice=l.asm.StridedSlice).apply(null,arguments)},oU=l._Sub=function(){return(oU=l._Sub=l.asm.Sub).apply(null,arguments)},sU=l._Sum=function(){return(sU=l._Sum=l.asm.Sum).apply(null,arguments)},iU=l._Tan=function(){return(iU=l._Tan=l.asm.Tan).apply(null,arguments)},aU=l._Tanh=function(){return(aU=l._Tanh=l.asm.Tanh).apply(null,arguments)},lU=l._Tile=function(){return(lU=l._Tile=l.asm.Tile).apply(null,arguments)},uU=l._TopK=function(){return(uU=l._TopK=l.asm.TopK).apply(null,arguments)},cU=l._Transform=function(){return(cU=l._Transform=l.asm.Transform).apply(null,arguments)},pU=l._Transpose=function(){return(pU=l._Transpose=l.asm.Transpose).apply(null,arguments)},mU=l.__FusedMatMul=function(){return(mU=l.__FusedMatMul=l.asm._FusedMatMul).apply(null,arguments)},RC=l._malloc=function(){return(RC=l._malloc=l.asm.malloc).apply(null,arguments)},d1=l._free=function(){return(d1=l._free=l.asm.free).apply(null,arguments)},fU=l._emscripten_tls_init=function(){return(fU=l._emscripten_tls_init=l.asm.emscripten_tls_init).apply(null,arguments)},h1=l.___errno_location=function(){return(h1=l.___errno_location=l.asm.__errno_location).apply(null,arguments)},px=l._pthread_self=function(){return(px=l._pthread_self=l.asm.pthread_self).apply(null,arguments)},g1=l._emscripten_main_thread_process_queued_calls=function(){return(g1=l._emscripten_main_thread_process_queued_calls=l.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},dU=l.__emscripten_thread_crashed=function(){return(dU=l.__emscripten_thread_crashed=l.asm._emscripten_thread_crashed).apply(null,arguments)},x1=l.__emscripten_thread_init=function(){return(x1=l.__emscripten_thread_init=l.asm._emscripten_thread_init).apply(null,arguments)},hU=l._emscripten_current_thread_process_queued_calls=function(){return(hU=l._emscripten_current_thread_process_queued_calls=l.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},gU=l._emscripten_main_browser_thread_id=function(){return(gU=l._emscripten_main_browser_thread_id=l.asm.emscripten_main_browser_thread_id).apply(null,arguments)},xU=l._emscripten_sync_run_in_main_thread_2=function(){return(xU=l._emscripten_sync_run_in_main_thread_2=l.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},y1=l._emscripten_sync_run_in_main_thread_4=function(){return(y1=l._emscripten_sync_run_in_main_thread_4=l.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},b1=l._emscripten_run_in_main_runtime_thread_js=function(){return(b1=l._emscripten_run_in_main_runtime_thread_js=l.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},OC=l._emscripten_dispatch_to_thread_=function(){return(OC=l._emscripten_dispatch_to_thread_=l.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},MC=l.__emscripten_thread_free_data=function(){return(MC=l.__emscripten_thread_free_data=l.asm._emscripten_thread_free_data).apply(null,arguments)},yU=l.__emscripten_thread_exit=function(){return(yU=l.__emscripten_thread_exit=l.asm._emscripten_thread_exit).apply(null,arguments)},bU=l._memalign=function(){return(bU=l._memalign=l.asm.memalign).apply(null,arguments)},w1=l._emscripten_stack_set_limits=function(){return(w1=l._emscripten_stack_set_limits=l.asm.emscripten_stack_set_limits).apply(null,arguments)},PC=l.stackSave=function(){return(PC=l.stackSave=l.asm.stackSave).apply(null,arguments)},mx=l.stackRestore=function(){return(mx=l.stackRestore=l.asm.stackRestore).apply(null,arguments)},Sp=l.stackAlloc=function(){return(Sp=l.stackAlloc=l.asm.stackAlloc).apply(null,arguments)},wU=l.dynCall_iijjiiii=function(){return(wU=l.dynCall_iijjiiii=l.asm.dynCall_iijjiiii).apply(null,arguments)},vU=l.dynCall_jiji=function(){return(vU=l.dynCall_jiji=l.asm.dynCall_jiji).apply(null,arguments)},v1=l.__emscripten_allow_main_runtime_queued_calls=21464;l.cwrap=ze,l.keepRuntimeAlive=Au,l.PThread=Ut,l.PThread=Ut,l.wasmMemory=Ot,l.ExitStatus=Bd;var fx;function Bd(T){this.name="ExitStatus",this.message="Program terminated with exit("+T+")",this.status=T}Wo=function T(){fx||LC(),fx||(Wo=T)};function LC(T){if(T=T||d,Al>0)return;if(v){c(l),$d(),postMessage({cmd:"loaded"});return}if(sn(),Al>0)return;function O(){fx||(fx=!0,l.calledRun=!0,!ke&&($d(),c(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),p0()))}l.setStatus?(l.setStatus("Running..."),setTimeout(function(){setTimeout(function(){l.setStatus("")},1),O()},1)):O()}l.run=LC;function CU(T,O){if(ae=T,!O&&v)throw Jg(T),"unwind";Au()||c0(),IU(T)}function IU(T){ae=T,Au()||(Ut.terminateAllThreads(),l.onExit&&l.onExit(T),ke=!0),g(T,new Bd(T))}if(l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();LC();var dx;m&&(dx={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 hx;if(typeof WasmBackendModule!="undefined")hx=WasmBackendModule;else if(typeof t!="undefined")hx=t;else throw new Error("Could not find wasm module in post.js");if(dx){var SU=hx._dispose;hx._dispose=function(){SU(),dx.uncaughtException.forEach(function(T){process.removeListener("uncaughtException",T)}),dx.unhandledRejection.forEach(function(T){process.removeListener("unhandledRejection",T)})}}return t.ready}})();typeof s0=="object"&&typeof YT=="object"?YT.exports=XT:typeof define=="function"&&define.amd?define([],function(){return XT}):typeof s0=="object"&&(s0.WasmBackendModuleThreadedSimd=XT)});var _W=Oe((i0,JT)=>{var ZT=(()=>{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 Ld)return;D("exiting due to exception: "+H)}var v,k,E;m?(p?f=Rg().dirname(f)+"/":f=__dirname+"/",E=()=>{k||(v=Wb(),k=Rg())},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($t,fe){$t?gt($t):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 Ld))throw H}),process.on("unhandledRejection",function(H){throw H}),l=(H,tt)=>{if(Ad())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 $t=new XMLHttpRequest;$t.open("GET",H,!0),$t.responseType="arraybuffer",$t.onload=()=>{if($t.status==200||$t.status==0&&$t.response){tt($t.response);return}gt()},$t.onerror=gt,$t.send(null)},b=H=>document.title=H);var $=e.print||console.log.bind(console),D=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 F=4;function P(H){P.shown||(P.shown={}),P.shown[H]||(P.shown[H]=1,D(H))}function W(H,tt){if(typeof WebAssembly.Function=="function"){for(var gt={i:"i32",j:"i64",f:"f32",d:"f64"},$t={parameters:[],results:tt[0]=="v"?[]:[gt[tt[0]]]},fe=1;fe{Q=H},X;e.wasmBinary&&(X=e.wasmBinary);var nt=e.noExitRuntime||!0;typeof WebAssembly!="object"&&Eu("no native wasm support detected");var st,it=!1,ft;function at(H,tt){H||Eu(tt)}function xt(H){var tt=e["_"+H];return tt}function dt(H,tt,gt,$t,fe){var ge={string:function(ln){var $l=0;if(ln!=null&&ln!==0){var cx=(ln.length<<2)+1;$l=Pd(cx),ce(ln,$l,cx)}return $l},array:function(ln){var $l=Pd(ln.length);return ke(ln,$l),$l}};function oe(ln){return tt==="string"?qt(ln):tt==="boolean"?Boolean(ln):ln}var ee=xt(H),xr=[],Uo=0;if($t)for(var Ho=0;Ho<$t.length;Ho++){var Ip=ge[gt[Ho]];Ip?(Uo===0&&(Uo=lx()),xr[Ho]=Ip($t[Ho])):xr[Ho]=$t[Ho]}var Ru=ee.apply(null,xr);function FC(ln){return Uo!==0&&ux(Uo),oe(ln)}return Ru=FC(Ru),Ru}function bt(H,tt,gt,$t){gt=gt||[];var fe=gt.every(function(oe){return oe==="number"}),ge=tt!=="string";return ge&&fe&&!$t?xt(H):function(){return dt(H,tt,gt,arguments,$t)}}var kt=1,At=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Dt(H,tt,gt){for(var $t=tt+gt,fe=tt;H[fe]&&!(fe>=$t);)++fe;if(fe-tt>16&&H.subarray&&At)return At.decode(H.subarray(tt,fe));for(var ge="";tt>10,56320|Uo&1023)}}return ge}function qt(H,tt){return H?Dt(ze,H,tt):""}function Kt(H,tt,gt,$t){if(!($t>0))return 0;for(var fe=gt,ge=gt+$t-1,oe=0;oe=55296&&ee<=57343){var xr=H.charCodeAt(++oe);ee=65536+((ee&1023)<<10)|xr&1023}if(ee<=127){if(gt>=ge)break;tt[gt++]=ee}else if(ee<=2047){if(gt+1>=ge)break;tt[gt++]=192|ee>>6,tt[gt++]=128|ee&63}else if(ee<=65535){if(gt+2>=ge)break;tt[gt++]=224|ee>>12,tt[gt++]=128|ee>>6&63,tt[gt++]=128|ee&63}else{if(gt+3>=ge)break;tt[gt++]=240|ee>>18,tt[gt++]=128|ee>>12&63,tt[gt++]=128|ee>>6&63,tt[gt++]=128|ee&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&&$t<=57343&&($t=65536+(($t&1023)<<10)|H.charCodeAt(++gt)&1023),$t<=127?++tt:$t<=2047?tt+=2:$t<=65535?tt+=3:tt+=4}return tt}var $e=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function ke(H,tt){rn.set(H,tt)}function ae(H,tt,gt){for(var $t=0;$t>0]=H.charCodeAt($t);gt||(rn[tt>>0]=0)}function Ke(H,tt){return H%tt>0&&(H+=tt-H%tt),H}var Re,rn,ze,Bo,Or,nn,on,jr,oo;function Rn(H){Re=H,e.HEAP8=rn=new Int8Array(H),e.HEAP16=Bo=new Int16Array(H),e.HEAP32=nn=new Int32Array(H),e.HEAPU8=ze=new Uint8Array(H),e.HEAPU16=Or=new Uint16Array(H),e.HEAPU32=on=new Uint32Array(H),e.HEAPF32=jr=new Float32Array(H),e.HEAPF64=oo=new Float64Array(H)}var Vo=e.INITIAL_MEMORY||16777216,so,_l=[],_u=[],pp=[],gr=!1,mp=!1,fp=0;function Ad(){return nt||fp>0}function zg(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Gg(e.preRun.shift());Dd(_l)}function Bg(){gr=!0,Dd(_u)}function r1(){mp=!0}function Vg(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Wg(e.postRun.shift());Dd(pp)}function Gg(H){_l.unshift(H)}function Go(H){_u.unshift(H)}function Wg(H){pp.unshift(H)}var qn=0,dp=null,El=null;function l0(H){qn++,e.monitorRunDependencies&&e.monitorRunDependencies(qn)}function Ug(H){if(qn--,e.monitorRunDependencies&&e.monitorRunDependencies(qn),qn==0&&(dp!==null&&(clearInterval(dp),dp=null),El)){var tt=El;El=null,tt()}}e.preloadedImages={},e.preloadedAudios={};function Eu(H){e.onAbort&&e.onAbort(H),H="Aborted("+H+")",D(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 u0="data:application/octet-stream;base64,";function Hg(H){return H.startsWith(u0)}function Au(H){return H.startsWith("file://")}var sn;sn="tfjs-backend-wasm.wasm",Hg(sn)||(sn=d(sn));function $d(H){try{if(H==sn&&X)return new Uint8Array(X);if(y)return y(H);throw"both async and sync fetching of the wasm failed"}catch(tt){Eu(tt)}}function c0(){if(!X&&(c||p)){if(typeof fetch=="function"&&!Au(sn))return fetch(sn,{credentials:"same-origin"}).then(function(H){if(!H.ok)throw"failed to load wasm binary file at '"+sn+"'";return H.arrayBuffer()}).catch(function(){return $d(sn)});if(g)return new Promise(function(H,tt){g(sn,function(gt){H(new Uint8Array(gt))},tt)})}return Promise.resolve().then(function(){return $d(sn)})}function p0(){var H={env:xp,wasi_snapshot_preview1:xp};function tt(oe,ee){var xr=oe.exports;e.asm=xr,st=e.asm.memory,Rn(st.buffer),so=e.asm.__indirect_function_table,Go(e.asm.__wasm_call_ctors),Ug("wasm-instantiate")}l0("wasm-instantiate");function gt(oe){tt(oe.instance)}function $t(oe){return c0().then(function(ee){return WebAssembly.instantiate(ee,H)}).then(function(ee){return ee}).then(oe,function(ee){D("failed to asynchronously prepare wasm: "+ee),Eu(ee)})}function fe(){return!X&&typeof WebAssembly.instantiateStreaming=="function"&&!Hg(sn)&&!Au(sn)&&typeof fetch=="function"?fetch(sn,{credentials:"same-origin"}).then(function(oe){var ee=WebAssembly.instantiateStreaming(oe,H);return ee.then(gt,function(xr){return D("wasm streaming compile failed: "+xr),D("falling back to ArrayBuffer instantiation"),$t(gt)})}):$t(gt)}if(e.instantiateWasm)try{var ge=e.instantiateWasm(H,tt);return ge}catch(oe){return D("Module.instantiateWasm callback failed with error: "+oe),!1}return fe().catch(o),{}}var n1,o1;function Dd(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?Fd(gt)():Fd(gt)(tt.arg):gt(tt.arg===void 0?null:tt.arg)}}function Al(H){return H}function qg(H){var tt=/\b_Z[\w\d_]+/g;return H.replace(tt,function(gt){var $t=gt;return gt===$t?gt:$t+" ["+gt+"]"})}var Wo=[];function Fd(H){var tt=Wo[H];return tt||(H>=Wo.length&&(Wo.length=H+1),Wo[H]=tt=so.get(H)),tt}function s1(){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 hp(H,tt){so.set(H,tt),Wo[H]=tt}function m0(){Eu("")}function Rd(){return 2147483648}function Kg(H,tt,gt){ze.copyWithin(H,tt,tt+gt)}function an(H){try{return st.grow(H-Re.byteLength+65535>>>16),Rn(st.buffer),1}catch(tt){}}function jg(H){var tt=ze.length;H=H>>>0;var gt=Rd();if(H>gt)return!1;for(var $t=1;$t<=4;$t*=2){var fe=tt*(1+.2/$t);fe=Math.min(fe,H+100663296);var ge=Math.min(gt,Ke(Math.max(H,fe),65536)),oe=an(ge);if(oe)return!0}return!1}var gp={mappings:{},buffers:[null,[],[]],printChar:function(H,tt){var gt=gp.buffers[H];tt===0||tt===10?((H===1?$:D)(Dt(gt,0)),gt.length=0):gt.push(tt)},varargs:void 0,get:function(){gp.varargs+=4;var H=nn[gp.varargs-4>>2];return H},getStr:function(H){var tt=qt(H);return tt},get64:function(H,tt){return H}};function f0(H){return 0}function i1(H,tt,gt,$t,fe){}function a1(H,tt,gt,$t){for(var fe=0,ge=0;ge>2],ee=nn[tt+4>>2];tt+=8;for(var xr=0;xr>2]=fe,0}function d0(H){rt(H)}var Xg=!1,xp={abort:m0,emscripten_get_heap_max:Rd,emscripten_memcpy_big:Kg,emscripten_resize_heap:jg,fd_close:f0,fd_seek:i1,fd_write:a1,setTempRet0:d0},FW=p0(),l1=e.___wasm_call_ctors=function(){return(l1=e.___wasm_call_ctors=e.asm.__wasm_call_ctors).apply(null,arguments)},h0=e._init=function(){return(h0=e._init=e.asm.init).apply(null,arguments)},g0=e._init_with_threads_count=function(){return(g0=e._init_with_threads_count=e.asm.init_with_threads_count).apply(null,arguments)},Yg=e._get_threads_count=function(){return(Yg=e._get_threads_count=e.asm.get_threads_count).apply(null,arguments)},Zg=e._register_tensor=function(){return(Zg=e._register_tensor=e.asm.register_tensor).apply(null,arguments)},x0=e._dispose_data=function(){return(x0=e._dispose_data=e.asm.dispose_data).apply(null,arguments)},Ut=e._dispose=function(){return(Ut=e._dispose=e.asm.dispose).apply(null,arguments)},y0=e._Abs=function(){return(y0=e._Abs=e.asm.Abs).apply(null,arguments)},Jg=e._Add=function(){return(Jg=e._Add=e.asm.Add).apply(null,arguments)},$u=e._AddN=function(){return($u=e._AddN=e.asm.AddN).apply(null,arguments)},yp=e._All=function(){return(yp=e._All=e.asm.All).apply(null,arguments)},b0=e._Any=function(){return(b0=e._Any=e.asm.Any).apply(null,arguments)},u1=e._ArgMax=function(){return(u1=e._ArgMax=e.asm.ArgMax).apply(null,arguments)},w0=e._AvgPool=function(){return(w0=e._AvgPool=e.asm.AvgPool).apply(null,arguments)},c1=e._BatchMatMul=function(){return(c1=e._BatchMatMul=e.asm.BatchMatMul).apply(null,arguments)},Du=e._Ceil=function(){return(Du=e._Ceil=e.asm.Ceil).apply(null,arguments)},v0=e._ClipByValue=function(){return(v0=e._ClipByValue=e.asm.ClipByValue).apply(null,arguments)},C0=e._Conv2D=function(){return(C0=e._Conv2D=e.asm.Conv2D).apply(null,arguments)},I0=e._Conv2DBackpropInput=function(){return(I0=e._Conv2DBackpropInput=e.asm.Conv2DBackpropInput).apply(null,arguments)},S0=e._Cos=function(){return(S0=e._Cos=e.asm.Cos).apply(null,arguments)},k0=e._Cosh=function(){return(k0=e._Cosh=e.asm.Cosh).apply(null,arguments)},N0=e._CropAndResize=function(){return(N0=e._CropAndResize=e.asm.CropAndResize).apply(null,arguments)},Qg=e._Cumprod=function(){return(Qg=e._Cumprod=e.asm.Cumprod).apply(null,arguments)},T0=e._Cumsum=function(){return(T0=e._Cumsum=e.asm.Cumsum).apply(null,arguments)},_0=e._DepthToSpace=function(){return(_0=e._DepthToSpace=e.asm.DepthToSpace).apply(null,arguments)},E0=e._DepthwiseConv2dNative=function(){return(E0=e._DepthwiseConv2dNative=e.asm.DepthwiseConv2dNative).apply(null,arguments)},A0=e._Elu=function(){return(A0=e._Elu=e.asm.Elu).apply(null,arguments)},$0=e._Equal=function(){return($0=e._Equal=e.asm.Equal).apply(null,arguments)},tx=e._Exp=function(){return(tx=e._Exp=e.asm.Exp).apply(null,arguments)},D0=e._FlipLeftRight=function(){return(D0=e._FlipLeftRight=e.asm.FlipLeftRight).apply(null,arguments)},F0=e._Floor=function(){return(F0=e._Floor=e.asm.Floor).apply(null,arguments)},Fu=e._FloorDiv=function(){return(Fu=e._FloorDiv=e.asm.FloorDiv).apply(null,arguments)},Od=e._FusedBatchNorm=function(){return(Od=e._FusedBatchNorm=e.asm.FusedBatchNorm).apply(null,arguments)},R0=e._FusedConv2D=function(){return(R0=e._FusedConv2D=e.asm.FusedConv2D).apply(null,arguments)},O0=e._FusedDepthwiseConv2D=function(){return(O0=e._FusedDepthwiseConv2D=e.asm.FusedDepthwiseConv2D).apply(null,arguments)},M0=e._Gather=function(){return(M0=e._Gather=e.asm.Gather).apply(null,arguments)},ne=e._GatherNd=function(){return(ne=e._GatherNd=e.asm.GatherNd).apply(null,arguments)},P0=e._Greater=function(){return(P0=e._Greater=e.asm.Greater).apply(null,arguments)},L0=e._GreaterEqual=function(){return(L0=e._GreaterEqual=e.asm.GreaterEqual).apply(null,arguments)},z0=e._LeakyRelu=function(){return(z0=e._LeakyRelu=e.asm.LeakyRelu).apply(null,arguments)},B0=e._Less=function(){return(B0=e._Less=e.asm.Less).apply(null,arguments)},V0=e._LessEqual=function(){return(V0=e._LessEqual=e.asm.LessEqual).apply(null,arguments)},G0=e._Log=function(){return(G0=e._Log=e.asm.Log).apply(null,arguments)},Md=e._LogicalAnd=function(){return(Md=e._LogicalAnd=e.asm.LogicalAnd).apply(null,arguments)},ex=e._Max=function(){return(ex=e._Max=e.asm.Max).apply(null,arguments)},rx=e._MaxPool=function(){return(rx=e._MaxPool=e.asm.MaxPool).apply(null,arguments)},W0=e._Maximum=function(){return(W0=e._Maximum=e.asm.Maximum).apply(null,arguments)},U0=e._Mean=function(){return(U0=e._Mean=e.asm.Mean).apply(null,arguments)},H0=e._Min=function(){return(H0=e._Min=e.asm.Min).apply(null,arguments)},q0=e._Minimum=function(){return(q0=e._Minimum=e.asm.Minimum).apply(null,arguments)},K0=e._MirrorPad=function(){return(K0=e._MirrorPad=e.asm.MirrorPad).apply(null,arguments)},j0=e._Multiply=function(){return(j0=e._Multiply=e.asm.Multiply).apply(null,arguments)},or=e._Neg=function(){return(or=e._Neg=e.asm.Neg).apply(null,arguments)},X0=e._NonMaxSuppressionV3=function(){return(X0=e._NonMaxSuppressionV3=e.asm.NonMaxSuppressionV3).apply(null,arguments)},Y0=e._NonMaxSuppressionV4=function(){return(Y0=e._NonMaxSuppressionV4=e.asm.NonMaxSuppressionV4).apply(null,arguments)},Z0=e._NonMaxSuppressionV5=function(){return(Z0=e._NonMaxSuppressionV5=e.asm.NonMaxSuppressionV5).apply(null,arguments)},bp=e._NotEqual=function(){return(bp=e._NotEqual=e.asm.NotEqual).apply(null,arguments)},nx=e._OneHot=function(){return(nx=e._OneHot=e.asm.OneHot).apply(null,arguments)},ox=e._PadV2=function(){return(ox=e._PadV2=e.asm.PadV2).apply(null,arguments)},sx=e._Pow=function(){return(sx=e._Pow=e.asm.Pow).apply(null,arguments)},J0=e._Prelu=function(){return(J0=e._Prelu=e.asm.Prelu).apply(null,arguments)},ix=e._Prod=function(){return(ix=e._Prod=e.asm.Prod).apply(null,arguments)},Q0=e._RealDiv=function(){return(Q0=e._RealDiv=e.asm.RealDiv).apply(null,arguments)},p1=e._Relu=function(){return(p1=e._Relu=e.asm.Relu).apply(null,arguments)},ax=e._Relu6=function(){return(ax=e._Relu6=e.asm.Relu6).apply(null,arguments)},m1=e._ResizeBilinear=function(){return(m1=e._ResizeBilinear=e.asm.ResizeBilinear).apply(null,arguments)},tC=e._Reverse=function(){return(tC=e._Reverse=e.asm.Reverse).apply(null,arguments)},eC=e._RotateWithOffset=function(){return(eC=e._RotateWithOffset=e.asm.RotateWithOffset).apply(null,arguments)},rC=e._Round=function(){return(rC=e._Round=e.asm.Round).apply(null,arguments)},nC=e._Rsqrt=function(){return(nC=e._Rsqrt=e.asm.Rsqrt).apply(null,arguments)},oC=e._ScatterNd=function(){return(oC=e._ScatterNd=e.asm.ScatterNd).apply(null,arguments)},sC=e._SelectV2=function(){return(sC=e._SelectV2=e.asm.SelectV2).apply(null,arguments)},iC=e._Sigmoid=function(){return(iC=e._Sigmoid=e.asm.Sigmoid).apply(null,arguments)},aC=e._Sin=function(){return(aC=e._Sin=e.asm.Sin).apply(null,arguments)},lC=e._Softmax=function(){return(lC=e._Softmax=e.asm.Softmax).apply(null,arguments)},uC=e._SparseFillEmptyRows=function(){return(uC=e._SparseFillEmptyRows=e.asm.SparseFillEmptyRows).apply(null,arguments)},cC=e._SparseReshape=function(){return(cC=e._SparseReshape=e.asm.SparseReshape).apply(null,arguments)},pC=e._SparseSegmentReduction=function(){return(pC=e._SparseSegmentReduction=e.asm.SparseSegmentReduction).apply(null,arguments)},mC=e._Sqrt=function(){return(mC=e._Sqrt=e.asm.Sqrt).apply(null,arguments)},fC=e._Square=function(){return(fC=e._Square=e.asm.Square).apply(null,arguments)},dC=e._SquaredDifference=function(){return(dC=e._SquaredDifference=e.asm.SquaredDifference).apply(null,arguments)},hC=e._Step=function(){return(hC=e._Step=e.asm.Step).apply(null,arguments)},gC=e._StridedSlice=function(){return(gC=e._StridedSlice=e.asm.StridedSlice).apply(null,arguments)},xC=e._Sub=function(){return(xC=e._Sub=e.asm.Sub).apply(null,arguments)},yC=e._Sum=function(){return(yC=e._Sum=e.asm.Sum).apply(null,arguments)},bC=e._Tan=function(){return(bC=e._Tan=e.asm.Tan).apply(null,arguments)},wC=e._Tanh=function(){return(wC=e._Tanh=e.asm.Tanh).apply(null,arguments)},vC=e._Tile=function(){return(vC=e._Tile=e.asm.Tile).apply(null,arguments)},CC=e._TopK=function(){return(CC=e._TopK=e.asm.TopK).apply(null,arguments)},IC=e._Transform=function(){return(IC=e._Transform=e.asm.Transform).apply(null,arguments)},SC=e._Transpose=function(){return(SC=e._Transpose=e.asm.Transpose).apply(null,arguments)},kC=e.__FusedMatMul=function(){return(kC=e.__FusedMatMul=e.asm._FusedMatMul).apply(null,arguments)},NC=e._malloc=function(){return(NC=e._malloc=e.asm.malloc).apply(null,arguments)},TC=e._free=function(){return(TC=e._free=e.asm.free).apply(null,arguments)},_C=e.___errno_location=function(){return(_C=e.___errno_location=e.asm.__errno_location).apply(null,arguments)},EC=e._emscripten_main_thread_process_queued_calls=function(){return(EC=e._emscripten_main_thread_process_queued_calls=e.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},lx=e.stackSave=function(){return(lx=e.stackSave=e.asm.stackSave).apply(null,arguments)},ux=e.stackRestore=function(){return(ux=e.stackRestore=e.asm.stackRestore).apply(null,arguments)},Pd=e.stackAlloc=function(){return(Pd=e.stackAlloc=e.asm.stackAlloc).apply(null,arguments)},AC=e.dynCall_iijjiiii=function(){return(AC=e.dynCall_iijjiiii=e.asm.dynCall_iijjiiii).apply(null,arguments)},$C=e.dynCall_jiji=function(){return($C=e.dynCall_jiji=e.asm.dynCall_jiji).apply(null,arguments)};e.cwrap=bt;var wp;function Ld(H){this.name="ExitStatus",this.message="Program terminated with exit("+H+")",this.status=H}El=function H(){wp||zd(),wp||(El=H)};function zd(H){if(H=H||a,qn>0||(zg(),qn>0))return;function tt(){wp||(wp=!0,e.calledRun=!0,!it&&(Bg(),n(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Vg()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),tt()},1)):tt()}e.run=zd;function f1(H){ft=H,Ad()||(e.onExit&&e.onExit(H),it=!0),l(H,new Ld(H))}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();zd();var vp;s&&(vp={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 Cp;if(typeof t!="undefined")Cp=t;else if(typeof WasmBackendModuleThreadedSimd!="undefined")Cp=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(vp){var DC=Cp._dispose;Cp._dispose=function(){DC(),vp.uncaughtException.forEach(function(H){process.removeListener("uncaughtException",H)}),vp.unhandledRejection.forEach(function(H){process.removeListener("unhandledRejection",H)})}}return t.ready}})();typeof i0=="object"&&typeof JT=="object"?JT.exports=ZT:typeof define=="function"&&define.amd?define([],function(){return ZT}):typeof i0=="object"&&(i0.WasmBackendModule=ZT)});var ta=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}},jo=class{refCount(t){return Kn("refCount")}incRef(t){return Kn("incRef")}timerAvailable(){return!0}time(t){return Kn("time")}read(t){return Kn("read")}readSync(t){return Kn("readSync")}readToGPU(t,e){return Kn("readToGPU")}numDataIds(){return Kn("numDataIds")}disposeData(t,e){return Kn("disposeData")}write(t,e,n){return Kn("write")}move(t,e,n,o,s){return Kn("move")}memory(){return Kn("memory")}floatPrecision(){return Kn("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return Kn("dispose")}};function Kn(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 I1(r){let t=r.length,e=0;for(;t>0;)e=Math.random()*t|0,t--,xx(r,t,e)}function DU(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--,xx(r,e,n),xx(t,e,n)}function Np(r,t,e){return Math.max(r,Math.min(t,e))}function FU(r){return r%2===0?r:r+1}function xx(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}function RU(r){let t=0;for(let e=0;ee+` Shapes ${r} and ${t} must match`)}function jn(r){A(r!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Xo(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 GU(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=>ea(n)),()=>`All values in axis param must be integers but got axis ${r}`),r.map(n=>n<0?e+n:n)}function BC(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 VC(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 GC(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 WC(r,t){for(let e=0;et+=e.length),t}function Yo(r){return typeof r=="string"||r instanceof String}function S1(r){return typeof r=="boolean"}function k1(r){return typeof r=="number"}function Tp(r){return Array.isArray(r)?Tp(r[0]):r instanceof Float32Array?"float32":r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray?"int32":k1(r)?"float32":Yo(r)?"string":S1(r)?"bool":"float32"}function yi(r){return!!(r&&r.constructor&&r.call&&r.apply)}function _p(r,t){for(let e=t;e=0;--n)e[n]=e[n+1]*r[n+1];return e}function N1(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 N1(0,r,t,e)}function Gd(r,t){let e=Ep(r,t);for(let n=0;nn*o,1);if(t==null||t==="float32")return Mu(r,new Float32Array(e));if(t==="int32")return Mu(r,new Int32Array(e));if(t==="bool")return Mu(r,new Uint8Array(e));throw new Error(`Unknown data type ${t}`)}function Wd(r){r.forEach(t=>{A(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${r}].`)})}function HU(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]=YU(o,s)})}};function jU(r){let t={};return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...n)=>(XU(t,n[0],n[1]),n.join("="))),t}function XU(r,t,e){r[decodeURIComponent(t)]=decodeURIComponent(e||"")}function YU(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 qC}var qC=null;function _1(r){qC=r}var KC;function jC(){if(KC==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");KC=r}return KC}function ZU(){let r=jC();return r._tfGlobals==null&&(r._tfGlobals=new Map),r._tfGlobals}function qd(r,t){let e=ZU();if(e.has(r))return e.get(r);{let n=t();return e.set(r,n),e.get(r)}}var wi="Abs",ra="Acos",na="Acosh",Xn="Add",Zo="AddN",oa="All",sa="Any",Jo="ArgMax",Dl="ArgMin",ia="Asin",aa="Asinh",la="Atan",ua="Atanh",ca="Atan2",Qo="AvgPool",Ap="AvgPoolGrad",Fl="AvgPool3D",$p="AvgPool3DGrad",ts="BatchMatMul",vi="BatchToSpaceND",Dp="Bincount",E1="BroadcastTo",Fp="BroadcastArgs",io="Cast",es="Ceil",ao="ClipByValue",Rp="Complex",Rl="ComplexAbs",Ci="Concat",rs="Conv2D",Op="Conv2DBackpropFilter",ns="Conv2DBackpropInput",Ol="Conv3D",Mp="Conv3DBackpropFilterV2",Pp="Conv3DBackpropInputV2",os="Cos",ss="Cosh",pa="Cumprod",is="Cumsum",ma="CropAndResize",Lp="DenseBincount",fa="DepthToSpace",as="DepthwiseConv2dNative",zp="DepthwiseConv2dNativeBackpropFilter",Bp="DepthwiseConv2dNativeBackpropInput",Vp="Diag",Ml="Dilation2D",Kd="Dilation2DBackpropInput",jd="Dilation2DBackpropFilter",ls="RealDiv",Gp="Einsum",us="Elu",Wp="EluGrad",da="Erf",ha="Equal",cs="Exp",Ii="ExpandDims",ga="Expm1",Up="FFT",Pl="Fill",xa="FlipLeftRight",ps="Floor",ms="FloorDiv",fs="FusedBatchNorm",Si="GatherV2",ya="GatherNd",ba="Greater",ds="GreaterEqual",lo="Identity",Hp="IFFT",qp="Imag",wa="IsFinite",va="IsInf",Ca="IsNan",hs="LeakyRelu",Ia="Less",Sa="LessEqual",Kp="LinSpace",gs="Log",ka="Log1p",Na="LogicalAnd",Lu="LogicalNot",zu="LogicalOr",A1="LogSoftmax",Hat="LowerBound",Ll="LRN",jp="LRNGrad",xs="Max",ys="Maximum",bs="MaxPool",Xp="MaxPoolGrad",zl="MaxPool3D",Yp="MaxPool3DGrad",Zp="MaxPoolWithArgmax",ws="Mean",vs="Min",Cs="Minimum",Is="MirrorPad",Ta="Mod",Jp="Multinomial",Ss="Multiply",ki="Neg",_a="NotEqual",Ea="NonMaxSuppressionV3",Aa="NonMaxSuppressionV4",$a="NonMaxSuppressionV5",Ni="OnesLike",ks="OneHot",Ti="Pack",Ns="PadV2",qat="Pool",Ts="Pow",_s="Prelu",Es="Prod",Bl="Range",Qp="Real",Da="Reciprocal",As="Relu",_i="Reshape",Vl="ResizeNearestNeighbor",tm="ResizeNearestNeighborGrad",$s="ResizeBilinear",em="ResizeBilinearGrad",Ds="Relu6",Fs="Reverse",Rs="Round",Os="Rsqrt",Fa="ScatterNd",rm="SearchSorted",Ei="Select",Ra="Selu",Ai="Slice",Ms="Sin",Oa="Sinh",Ma="Sign",Ps="Sigmoid",Pa="Softplus",Ls="Sqrt",zs="Sum",$i="SpaceToBatchND",Di="SplitV",Bs="Softmax",Gl="SparseFillEmptyRows",La="SparseReshape",Wl="SparseSegmentMean",Ul="SparseSegmentSum",nm="SparseToDense",Vs="SquaredDifference",Hl="Square",za="StridedSlice",om="StringNGrams",sm="StringSplit",im="StringToHashBucketFast",Gs="Sub",Ws="Tan",Us="Tanh",Yn="Tile",Ba="TopK",Va="Transform",Hs="Transpose",am="Unique",Fi="Unpack",ql="UnsortedSegmentSum",Kat="UpperBound",Ri="ZerosLike",uo="Step",Xd="FromPixels",Ga="RotateWithOffset",Oi="_FusedMatMul",Mi="FusedConv2D",Pi="FusedDepthwiseConv2D";function Li(...r){V().getBool("IS_TEST")||V().getBool("PROD")||console.warn(...r)}function JU(...r){V().getBool("IS_TEST")||V().getBool("PROD")||console.log(...r)}var lm=qd("kernelRegistry",()=>new Map),Yd=qd("gradRegistry",()=>new Map);function Zd(r,t){let e=YC(r,t);return lm.get(e)}function XC(r){return Yd.get(r)}function bx(r){let t=lm.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 Bu(r){let{kernelName:t,backendName:e}=r,n=YC(t,e);lm.has(n)&&Li(`The kernel '${t}' for backend '${e}' is already registered`),lm.set(n,r)}function D1(r){let{kernelName:t}=r;Yd.has(t)&&V().getBool("DEBUG")&&Li(`Overriding the gradient for '${t}'`),Yd.set(t,r)}function Jat(r,t){let e=YC(r,t);if(!lm.has(e))throw new Error(`The kernel '${r}' for backend '${t}' is not registered`);lm.delete(e)}function Qat(r){if(!Yd.has(r))throw new Error(`The gradient '${r}' for backend is not registered`);Yd.delete(r)}function tlt(r,t){bx(r).forEach(n=>{let o=Object.assign({},n,{backendName:t});Bu(o)})}function YC(r,t){return`${t}_${r}`}var x={};Yt(x,{arraysEqual:()=>Mn,assert:()=>A,assertNonNegativeIntegerDimensions:()=>Wd,assertNonNull:()=>jn,assertShapesMatch:()=>Me,bytesFromStringArray:()=>HC,bytesPerElement:()=>yx,checkConversionForErrors:()=>WC,clamp:()=>Np,computeStrides:()=>bi,createScalarValue:()=>s4,createShuffledIndices:()=>BU,decodeString:()=>mm,distSquared:()=>MU,encodeString:()=>jl,fetch:()=>a4,fingerPrint64:()=>o4,flatten:()=>Xo,getArrayFromDType:()=>GC,getTypedArrayFromDType:()=>VC,hasEncodingLoss:()=>WU,hexToLong:()=>Jd,indexToLoc:()=>qU,inferDtype:()=>Tp,inferFromImplicitShape:()=>GU,isBoolean:()=>S1,isFunction:()=>yi,isInt:()=>ea,isNumber:()=>k1,isPromise:()=>Ud,isScalarShape:()=>PU,isString:()=>Yo,isTypedArray:()=>yr,isValidDtype:()=>UC,locToIndex:()=>HU,makeOnesTypedArray:()=>Gd,makeZerosNestedTypedArray:()=>UU,makeZerosTypedArray:()=>Ep,nearestDivisor:()=>_p,nearestLargerEven:()=>FU,now:()=>Hu,parseAxisParam:()=>mr,randUniform:()=>OU,repeatedTry:()=>VU,rightPad:()=>Pu,shuffle:()=>I1,shuffleCombo:()=>DU,sizeFromShape:()=>Jt,sizeToSquarishShape:()=>zU,squeezeShape:()=>BC,sum:()=>RU,swap:()=>xx,tanh:()=>LU,toNestedArray:()=>Mu,toTypedArray:()=>pm});var tI=Ou(W1());var Uu=tI.default||tI;function Jd(r){return Uu.fromString(r,!0,16)}var H1=Jd("c3a5c85c97cb3127"),Wu=Jd("b492b66fbe98f273"),un=Jd("9ae16a3b2f90404f");function QC(r){return r.xor(r.shru(47))}function q1(r,t,e){let n=r.slice(t,t+e);return Uu.fromBytes(Array.from(n),!0,!0)}function Be(r,t){return q1(r,t,8)}function U1(r,t){return q1(r,t,4)}function Ar(r,t){return t===0?r:r.shru(t).or(r.shl(64-t))}function Kl(r,t,e=Jd("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 t4(r,t,e,n,o,s){o=o.add(r),s=Ar(s.add(o).add(n),21);let i=o;return o=o.add(t),o=o.add(e),s=s.add(Ar(o,44)),[o.add(n),s.add(i)]}function vx(r,t,e,n){return t4(Be(r,t),Be(r,t+8),Be(r,t+16),Be(r,t+24),e,n)}function e4(r,t=r.length){if(t>=8){let e=un.add(t*2),n=Be(r,0).add(un),o=Be(r,t-8),s=Ar(o,37).mul(e).add(n),i=Ar(n,25).add(o).mul(e);return Kl(s,i,e)}if(t>=4){let e=un.add(t*2),n=U1(r,0);return Kl(n.shl(3).add(t),U1(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 QC(un.mul(s).xor(H1.mul(i))).mul(un)}return un}function r4(r,t=r.length){let e=un.add(t*2),n=Be(r,0).mul(Wu),o=Be(r,8),s=Be(r,t-8).mul(e),i=Be(r,t-16).mul(un);return Kl(Ar(n.add(o),43).add(Ar(s,30)).add(i),n.add(Ar(o.add(un),18)).add(s),e)}function n4(r,t=r.length){let e=un.add(t*2),n=Be(r,0).mul(un),o=Be(r,8),s=Be(r,t-8).mul(e),i=Be(r,t-16).mul(un),a=Ar(n.add(o),43).add(Ar(s,30)).add(i),u=Kl(a,n.add(Ar(o.add(un),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 Kl(Ar(l.add(c),43).add(Ar(p,30)).add(m),l.add(Ar(c.add(n),18)).add(p),e)}function o4(r,t=r.length){let e=Uu.fromNumber(81,!0);if(t<=32)return t<=16?e4(r,t):r4(r,t);if(t<=64)return n4(r,t);let n=e,o=e.mul(Wu).add(113),s=QC(o.mul(un).add(113)).mul(un),i=[Uu.UZERO,Uu.UZERO],a=[Uu.UZERO,Uu.UZERO];n=n.mul(un).add(Be(r,0));let u=0,l=(t-1>>6)*64,c=l+(t-1&63)-63;do n=Ar(n.add(o).add(i[0]).add(Be(r,u+8)),37).mul(Wu),o=Ar(o.add(i[1]).add(Be(r,u+48)),42).mul(Wu),n=n.xor(a[1]),o=o.add(i[0]).add(Be(r,u+40)),s=Ar(s.add(a[0]),33).mul(Wu),i=vx(r,u,i[1].mul(Wu),n.add(a[0])),a=vx(r,u+32,s.add(a[1]),o.add(Be(r,u+16))),[s,n]=[n,s],u+=64;while(u!==l);let p=Wu.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=Ar(n.add(o).add(i[0]).add(Be(r,u+8)),37).mul(p),o=Ar(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=Ar(s.add(a[0]),33).mul(p),i=vx(r,u,i[1].mul(p),n.add(a[0])),a=vx(r,u+32,s.add(a[1]),o.add(Be(r,u+16))),[s,n]=[n,s],Kl(Kl(i[0],a[0],p).add(QC(o).mul(H1)).add(s),Kl(i[1],a[1],p).add(n),p)}function s4(r,t){return t==="string"?jl(r):pm([r],t)}function i4(r,t){return r instanceof Float32Array&&t==="float32"||r instanceof Int32Array&&t==="int32"||r instanceof Uint8Array&&t==="bool"}function pm(r,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(r)&&(r=Xo(r)),V().getBool("DEBUG")&&WC(r,t),i4(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=Hu();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(s);else{s();for(let l of o)l.dataSync();i=Promise.resolve({kernelMs:Hu()-a})}if(V().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l{l4(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 l4(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 K1(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(!Mn(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,Qd=3,rI=7;function Y1(r,t,e,n){let o=bi(t),s=u4(r,t,e,o),i=t.length,a=Ix(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 u4(r,t,e,n){let o=Jt(t),s=n[n.length-1],i=new Array(s).fill(0),a=t.length,u=e==="complex64"?eh(r):r;if(a>1)for(let l=0;lX1){let g=Qd*i,y=Array.from(r.slice(0,g)),b=Array.from(r.slice((a-Qd)*i,a*i));return e==="complex64"&&(y=eh(y),b=eh(b)),["["+y.map((w,v)=>th(w,o[v],e)).join(", ")+", ..., "+b.map((w,v)=>th(w,o[a-Qd+v],e)).join(", ")+"]"]}let h=e==="complex64"?eh(r):Array.from(r);return["["+h.map((g,y)=>th(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||GC(e,this.size),this.strides=bi(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;omm(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(),Ks().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();let t=Ks().readSync(this.dataId);if(this.dtype==="string")try{return t.map(e=>mm(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 Ks().read(this.dataId);return this.dtype==="string"?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(Ks().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return fm.print(this,t)}clone(){return this.throwIfDisposed(),fm.clone(this)}toString(t=!1){let e=this.dataSync();return Y1(e,this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),fm.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),Ks().makeVariable(this,t,e,n)}};Object.defineProperty(Lt,Symbol.hasInstance,{value:r=>!!r&&r.data!=null&&r.dataSync!=null&&r.throwIfDisposed!=null});function L(){return qd("Tensor",()=>Lt)}L();var Wa=class extends Lt{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(!Mn(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);Ks().disposeTensor(this),this.dataId=t.dataId,Ks().incRef(this,null)}dispose(){Ks().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Wa,Symbol.hasInstance,{value:r=>r instanceof Lt&&r.assign!=null&&r.assign instanceof Function});var fo={};Yt(fo,{assertTypesMatch:()=>lI,getTensorsInContainer:()=>rh,isTensorInList:()=>m4,makeTypesMatch:()=>jt});var nI;(function(r){r.R0="R0",r.R1="R1",r.R2="R2",r.R3="R3",r.R4="R4",r.R5="R5",r.R6="R6"})(nI||(nI={}));var oI;(function(r){r.float32="float32",r.int32="int32",r.bool="int32",r.complex64="complex64"})(oI||(oI={}));var sI;(function(r){r.float32="float32",r.int32="int32",r.bool="bool",r.complex64="complex64"})(sI||(sI={}));var iI;(function(r){r.float32="float32",r.int32="float32",r.bool="float32",r.complex64="complex64"})(iI||(iI={}));var aI;(function(r){r.float32="complex64",r.int32="complex64",r.bool="complex64",r.complex64="complex64"})(aI||(aI={}));var p4={float32:iI,int32:oI,bool:sI,complex64:aI};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 p4[r][t]}function qu(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 lI(r,t){A(r.dtype===t.dtype,()=>`The dtypes of the first(${r.dtype}) and second(${t.dtype}) input must match`)}function m4(r,t){return t.some(e=>e.id===r.id)}function rh(r){let t=[];return e_(r,t,new Set),t}function e_(r,t,e){if(r==null)return;if(r instanceof Lt){t.push(r);return}if(!f4(r))return;let n=r;for(let o in n){let s=n[o];e.has(s)||(e.add(s),e_(s,t,e))}}function f4(r){return Array.isArray(r)||typeof r=="object"}function uI(r){return r.kernelName!=null}var Sx=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()}},Xl=class{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Sx}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){bx(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 jo)&&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 Xl.nextTensorId++}nextVariableId(){return Xl.nextVariableId++}clone(t){let e=_.runKernel(lo,{x:t}),n={x:t},o=i=>({x:()=>{let a="float32",u={x:i},l={dtype:a};return _.runKernel(io,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,!(Zd(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=uI(t)?t.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(uI(t)){let{kernelName:d,inputs:h,attrs:g}=t;this.backendName==null&&this.backend;let y=Zd(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=>k.rank!=null?k:this.makeTensorFromTensorInfo(k));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=uI(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=XC(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"&&Yo(t[0])&&(s=t.map(u=>jl(u)));let i=o.write(s,e,n),a=new Lt(e,n,i,this.nextTensorId());if(this.trackTensor(a,o),n==="string"){let u=this.state.tensorInfo.get(i),l=HC(s);this.state.numBytes+=l-u.bytes,u.bytes=l}return a}makeTensorFromTensorInfo(t,e){let{dataId:n,shape:o,dtype:s}=t,i=new Lt(o,s,n,this.nextTensorId());return this.trackTensor(i,e),i}makeVariable(t,e=!0,n,o){n=n||this.nextVariableId().toString(),o!=null&&o!==t.dtype&&(t=t.cast(o));let s=new Wa(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*yx(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 Wa||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*yx(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=XC(t);u!=null&&(o=u.gradFunc),o!=null&&(a.gradient=l=>(l=l.map((c,p)=>{if(c==null){let m=n[p],f=Ep(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=rh(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 Lt,()=>"The result y returned by f() must be a tensor.");let i=K1(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?d4(s.shape):n,j1(a,i,l=>this.tidy(l),h4);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(yi(t),()=>"The f passed in customGrad(f) must be a function."),(...e)=>{A(e.every(a=>a instanceof Lt),()=>"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 Lt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),A(yi(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 Lt),()=>"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=Hu(),n=await this.backend.time(t);return n.wallMs=Hu()-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 Sx;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}};Xl.nextTensorId=0;Xl.nextVariableId=0;function d4(r){let t=Gd(Jt(r),"float32");return _.makeTensor(t,r,"float32")}function cI(){let r=jC();if(r._tfengine==null){let t=new Hd(r);r._tfengine=new Xl(t)}return _1(r._tfengine.ENV),J1(()=>r._tfengine),r._tfengine}var _=cI();function h4(r,t){let e={a:r,b:t};return _.runKernel(Xn,e)}var Yl={};Yt(Yl,{isBrowser:()=>mI,isMobile:()=>y4,mockIsMobile:()=>x4});function g4(){return typeof navigator!="undefined"&&navigator!=null}var pI;function x4(r){pI=r}function y4(r){if(pI!==void 0)return pI;if(r||g4()){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 mI(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var ho=V();ho.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.")});ho.registerFlag("IS_BROWSER",()=>mI());ho.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");ho.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));ho.registerFlag("PROD",()=>!1);ho.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>ho.getBool("DEBUG"));ho.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);ho.registerFlag("IS_TEST",()=>!1);ho.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);ho.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);ho.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function Mr(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")&&n_(r,n,[]),n}function n_(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),r_(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=Mr(r,o);!yr(r)&&!Array.isArray(r)&&(r=[r]);let a=o!=="string"?pm(r,o):Xo(r,[],!0);return _.makeTensor(a,s,o)}function Ua(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 o_="__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+o_;let o=(...s)=>{_.startScope(e);try{let i=n(...s);return Ud(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 b4(r,t){let e=C(r,"real","complex"),n=C(t,"imag","complex");Me(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(Rp,o)}var zn=N({complex_:b4});function cn(r,t,e,n){if(n==null&&(n=Tp(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){Wd(t);let o=Jt(t),s=Jt(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"?pm(r,n):Xo(r,[],!0),_.makeTensor(r,t,n)}function $r(r,t,e){let n=Mr(r,e);return cn(r,t,n,e)}var nh={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};var kx=4;async function i_(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)+kx*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 fI=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function s_(r){return fI?Buffer.byteLength(r):new Blob([r]).size}function a_(r){if(fI)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 dI(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 Tx(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 hm(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 zi(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:s_(JSON.stringify(r.modelTopology)),weightSpecsBytes:r.weightSpecs==null?0:s_(JSON.stringify(r.weightSpecs)),weightDataBytes:r.weightData==null?0:r.weightData.byteLength}}function v4(){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 C4(){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 I4(){let r=new Uint32Array(64);for(let t=0;t<64;t++)r[t]=1024;return r[0]=r[32]=0,r}function S4(){let r=v4(),t=C4(),e=I4();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 Ne=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Ne.instance==null&&(Ne.instance=new Ne),Ne.instance}static registerSaveRouter(t){Ne.getInstance().saveRouters.push(t)}static registerLoadRouter(t){Ne.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return Ne.getHandlers(t,"save")}static getLoadHandlers(t,e){return Ne.getHandlers(t,"load",e)}static getHandlers(t,e,n){let o=[];return(e==="load"?Ne.getInstance().loadRouters:Ne.getInstance().saveRouters).forEach(i=>{let a=i(t,n);a!==null&&o.push(a)}),o}},u_=r=>Ne.registerSaveRouter(r),c_=r=>Ne.registerLoadRouter(r),p_=r=>Ne.getSaveHandlers(r),m_=(r,t)=>Ne.getLoadHandlers(r,t);var hI="tensorflowjs",gI=1,Ku="models_store",Zl="model_info_store";function f_(){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 xI(r){let t=r.result;t.createObjectStore(Ku,{keyPath:"modelPath"}),t.createObjectStore(Zl,{keyPath:"modelPath"})}var Bi=class{constructor(t){if(this.indexedDB=f_(),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(hI,gI);s.onupgradeneeded=()=>xI(s),s.onsuccess=()=>{let i=s.result;if(e==null){let a=i.transaction(Ku,"readonly"),l=a.objectStore(Ku).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=zi(e),u=i.transaction(Zl,"readwrite"),l=u.objectStore(Zl),c=l.put({modelPath:this.modelPath,modelArtifactsInfo:a}),p;c.onsuccess=()=>{p=i.transaction(Ku,"readwrite");let f=p.objectStore(Ku).put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:a});f.onsuccess=()=>n({modelArtifactsInfo:a}),f.onerror=d=>{l=u.objectStore(Zl);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)})}};Bi.URL_SCHEME="indexeddb://";var d_=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Bi.URL_SCHEME)?k4(r.slice(Bi.URL_SCHEME.length)):null;Ne.registerSaveRouter(d_);Ne.registerLoadRouter(d_);function k4(r){return new Bi(r)}function N4(r){return r.startsWith(Bi.URL_SCHEME)?r.slice(Bi.URL_SCHEME.length):r}var _x=class{constructor(){this.indexedDB=f_()}async listModels(){return new Promise((t,e)=>{let n=this.indexedDB.open(hI,gI);n.onupgradeneeded=()=>xI(n),n.onsuccess=()=>{let o=n.result,s=o.transaction(Zl,"readonly"),a=s.objectStore(Zl).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=N4(t),new Promise((e,n)=>{let o=this.indexedDB.open(hI,gI);o.onupgradeneeded=()=>xI(o),o.onsuccess=()=>{let s=o.result,i=s.transaction(Zl,"readwrite"),a=i.objectStore(Zl),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(Ku,"readwrite");let f=l.objectStore(Ku).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 Ha="/",gm="tensorflowjs_models",h_="info",T4="model_topology",_4="weight_specs",E4="weight_data",A4="model_metadata";function g_(r){return{info:[gm,r,h_].join(Ha),topology:[gm,r,T4].join(Ha),weightSpecs:[gm,r,_4].join(Ha),weightData:[gm,r,E4].join(Ha),modelMetadata:[gm,r,A4].join(Ha)}}function x_(r){for(let t of Object.values(r))window.localStorage.removeItem(t)}function $4(r){let t=r.split(Ha);if(t.length<3)throw new Error(`Invalid key format: ${r}`);return t.slice(1,t.length-1).join(Ha)}function D4(r){return r.startsWith(Vi.URL_SCHEME)?r.slice(Vi.URL_SCHEME.length):r}var Vi=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=g_(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=zi(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,a_(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 x_(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=l_(i),e}};Vi.URL_SCHEME="localstorage://";var y_=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Vi.URL_SCHEME)?F4(r.slice(Vi.URL_SCHEME.length)):null;Ne.registerSaveRouter(y_);Ne.registerLoadRouter(y_);function F4(r){return new Vi(r)}var Ex=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=gm+Ha,n=Ha+h_;for(let o=0;o"scheme must not be undefined or null."),t.endsWith(xm)&&(t=t.slice(0,t.indexOf(xm))),A(t.length>0,()=>"scheme must not be an empty string.");let n=Xr.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 Ax(r){if(r.indexOf(xm)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Xr.getSchemes().join(",")}`);return{scheme:r.split(xm)[0],path:r.split(xm)[1]}}async function b_(r,t,e=!1){A(r!==t,()=>`Old path and new path are the same: '${r}'`);let n=Ne.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=Ne.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=Ax(r).scheme,u=Ax(r).path,l=a===Ax(r).scheme,c=await o.load();e&&l&&await Xr.getManager(a).removeModel(u);let p=await i.save(c);return e&&!l&&await Xr.getManager(a).removeModel(u),p.modelArtifactsInfo}async function w_(){let r=Xr.getSchemes(),t={};for(let e of r){let n=await Xr.getManager(e).listModels();for(let o in n){let s=e+xm+o;t[s]=n[o]}}return t}async function v_(r){let t=Ax(r);return Xr.getManager(t.scheme).removeModel(t.path)}async function C_(r,t){return b_(r,t,!1)}async function I_(r,t){return b_(r,t,!0)}var yI=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 yI);try{Xr.registerManager(Vi.URL_SCHEME,new Ex)}catch(r){}try{Xr.registerManager(Bi.URL_SCHEME,new _x)}catch(r){}}var R4={importFetch:()=>S_()},bI;var wI=class{constructor(){this.util=k_(),this.textEncoder=new this.util.TextEncoder}fetch(t,e){return V().global.fetch!=null?V().global.fetch(t,e):(bI==null&&(bI=R4.importFetch()),bI(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 wI);function Ct(r,t="float32",e){return t=t||"float32",Wd(r),new pe(r,t,e)}function O4(r,t){let e=C(r,"x","cast");if(!UC(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(io,n,o)}var Z=N({cast_:O4});function M4(r){let e={x:C(r,"x","clone","string_or_numeric")};return _.runKernel(lo,e)}var kn=N({clone_:M4});function vI(r,t=!1){console.log(r.toString(t))}cI();var P4={buffer:Ct,cast:Z,clone:kn,print:vI};Q1(P4);var Pr={};Yt(Pr,{browserFiles:()=>T_,browserHTTPRequest:()=>A_,concatenateArrayBuffers:()=>dm,copyModel:()=>C_,decodeWeights:()=>Nx,encodeWeights:()=>i_,fromMemory:()=>$_,getLoadHandlers:()=>m_,getModelArtifactsForJSON:()=>hm,getModelArtifactsInfoForJSON:()=>zi,getSaveHandlers:()=>p_,http:()=>Dx,isHTTPScheme:()=>$x,listModels:()=>w_,loadWeights:()=>__,moveModel:()=>I_,registerLoadRouter:()=>c_,registerSaveRouter:()=>u_,removeModel:()=>v_,weightsLoaderFactory:()=>kI,withSaveHandler:()=>D_});var L4="model",z4=".json",B4=".weights.bin";function N_(r){return new Promise(t=>setTimeout(t)).then(r)}var qa=class{constructor(t){if(!V().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(qa.URL_SCHEME)&&(t=t.slice(qa.URL_SCHEME.length)),(t==null||t.length===0)&&(t=L4),this.modelJsonFileName=t+z4,this.weightDataFileName=t+B4}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=Tx(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 N_(()=>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 N_(()=>a.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:zi(t)}}}};qa.URL_SCHEME="downloads://";var CI=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=hm(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,dm(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=>dI(s.name)),o={};for(let s of t)s.paths.forEach(i=>{let a=dI(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}},V4=r=>V().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(qa.URL_SCHEME)?G4(r.slice(qa.URL_SCHEME.length)):null;Ne.registerSaveRouter(V4);function G4(r="model"){return new qa(r)}function T_(r){return new CI(r)}function II(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 SI(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 II(n,t.onProgress,o,s)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(a):await II(a,t.onProgress,u,l)}async function __(r,t="",e,n){return kI(i=>SI(i,{requestInit:n}))(r,t,e)}function kI(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=nh[y]*Jt(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=Nx(k,[v.manifestEntry]);for(let $ in E)p[$]=E[$]}),m+=d}),p}}var W4="application/octet-stream",U4="application/json",oh=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=Tx(t,n);e.body.append("model.json",new Blob([JSON.stringify(o)],{type:U4}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:W4}),"model.weights.bin");let s=await this.fetch(this.path,e);if(s.ok)return{modelArtifactsInfo:zi(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 hm(e,s=>this.loadWeights(s))}async loadWeights(t){let e=Array.isArray(this.path)?this.path[1]:this.path,[n,o]=H4(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 SI(a,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[i,dm(l)]}};oh.URL_SCHEME_REGEX=/^https?:\/\//;function H4(r){let t=r.lastIndexOf("/"),e=r.lastIndexOf("?"),n=r.substring(0,t),o=e>t?r.substring(e):"";return[n+"/",o]}function $x(r){return r.match(oh.URL_SCHEME_REGEX)!=null}var E_=(r,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let e=!0;if(Array.isArray(r)?e=r.every(n=>$x(n)):e=$x(r),e)return Dx(r,t)}return null};Ne.registerSaveRouter(E_);Ne.registerLoadRouter(E_);function Dx(r,t){return new oh(r,t)}function A_(r,t){return Dx(r,t)}var sh=class{constructor(t){this.modelArtifacts=t}async load(){return this.modelArtifacts}},NI=class{constructor(t){this.saveHandler=t}async save(t){return this.saveHandler(t)}};function $_(r,t,e,n){return arguments.length===1?r.modelTopology!=null||r.weightSpecs!=null?new sh(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 sh({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 sh({modelTopology:r,weightSpecs:t,weightData:e,trainingConfig:n}))}function D_(r){return new NI(r)}var R_={};Yt(R_,{confusionMatrix:()=>F_});function q4(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(ts,i,a)}var zt=N({matMul_:q4});function K4(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(ks,s,i)}var js=N({oneHot_:K4});function j4(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(Hs,n,o)}var Mt=N({transpose_:j4});function X4(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=js(Z(n,"int32"),e),i=js(Z(o,"int32"),e),a=Mt(s),u=zt(a,i);return Z(u,"int32")}var F_=N({confusionMatrix_:X4});var Sr={};Yt(Sr,{assertAndGetBroadcastShape:()=>Bt,getBroadcastDims:()=>O_,getReductionAxes:()=>xe});function O_(r,t){let e=r.length,n=[];for(let o=0;o1&&i===1&&n.unshift(s)}return n}function xe(r,t){let e=[];for(let n=0;n1)&&e.unshift(s)}return e}function Bt(r,t){let e=[],n=Math.max(r.length,t.length);for(let o=0;orH,fromPixelsAsync:()=>tH,toPixels:()=>eH});function TI(r,t,e){if(jn(r),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=Mr(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 cn(r,t,n,e)}var ju;function M_(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