/* Face-API homepage: author: ' */ var LU=Object.create;var o0=Object.defineProperty;var PU=Object.getOwnPropertyDescriptor;var MU=Object.getOwnPropertyNames;var zU=Object.getPrototypeOf,BU=Object.prototype.hasOwnProperty;var gr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),jt=(r,t)=>{for(var e in t)o0(r,e,{get:t[e],enumerable:!0})},VU=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of MU(t))!BU.call(r,o)&&o!==e&&o0(r,o,{get:()=>t[o],enumerable:!(n=PU(t,o))||n.enumerable});return r};var vl=(r,t,e)=>(e=r!=null?LU(zU(r)):{},VU(t||!r||!r.__esModule?o0(e,"default",{value:r,enumerable:!0}):e,r));var F1=gr((clt,D1)=>{D1.exports=Ke;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 Ke(r,t,e){this.low=r|0,this.high=t|0,this.unsigned=!!e}Ke.prototype.__isLong__;Object.defineProperty(Ke.prototype,"__isLong__",{value:!0});function On(r){return(r&&r.__isLong__)===!0}Ke.isLong=On;var I1={},S1={};function Wu(r,t){var e,n,o;return t?(r>>>=0,(o=0<=r&&r<256)&&(n=S1[r],n)?n:(e=je(r,(r|0)<0?-1:0,!0),o&&(S1[r]=e),e)):(r|=0,(o=-128<=r&&r<128)&&(n=I1[r],n)?n:(e=je(r,r<0?-1:0,!1),o&&(I1[r]=e),e))}Ke.fromInt=Wu;function po(r,t){if(isNaN(r))return t?Gu:mo;if(t){if(r<0)return Gu;if(r>=_1)return $1}else{if(r<=-k1)return Rn;if(r+1>=k1)return A1}return r<0?po(-r,t).neg():je(r%Zp|0,r/Zp|0,t)}Ke.fromNumber=po;function je(r,t,e){return new Ke(r,t,e)}Ke.fromBits=je;var Yg=Math.pow;function x0(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 x0(r.substring(1),t,e).neg();for(var o=po(Yg(e,8)),s=mo,i=0;i>>0:this.low};yt.toNumber=function(){return this.unsigned?(this.high>>>0)*Zp+(this.low>>>0):this.high*Zp+(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(Rn)?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 On(t)||(t=Gs(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};yt.eq=yt.equals;yt.notEquals=function(t){return!this.eq(t)};yt.neq=yt.notEquals;yt.ne=yt.notEquals;yt.lessThan=function(t){return this.comp(t)<0};yt.lt=yt.lessThan;yt.lessThanOrEqual=function(t){return this.comp(t)<=0};yt.lte=yt.lessThanOrEqual;yt.le=yt.lessThanOrEqual;yt.greaterThan=function(t){return this.comp(t)>0};yt.gt=yt.greaterThan;yt.greaterThanOrEqual=function(t){return this.comp(t)>=0};yt.gte=yt.greaterThanOrEqual;yt.ge=yt.greaterThanOrEqual;yt.compare=function(t){if(On(t)||(t=Gs(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};yt.comp=yt.compare;yt.negate=function(){return!this.unsigned&&this.eq(Rn)?Rn:this.not().add(Yp)};yt.neg=yt.negate;yt.add=function(t){On(t)||(t=Gs(t));var e=this.high>>>16,n=this.high&65535,o=this.low>>>16,s=this.low&65535,i=t.high>>>16,a=t.high&65535,u=t.low>>>16,l=t.low&65535,c=0,p=0,m=0,f=0;return f+=s+l,m+=f>>>16,f&=65535,m+=o+u,p+=m>>>16,m&=65535,p+=n+a,c+=p>>>16,p&=65535,c+=e+i,c&=65535,je(m<<16|f,c<<16|p,this.unsigned)};yt.subtract=function(t){return On(t)||(t=Gs(t)),this.add(t.neg())};yt.sub=yt.subtract;yt.multiply=function(t){if(this.isZero())return mo;if(On(t)||(t=Gs(t)),co){var e=co.mul(this.low,this.high,t.low,t.high);return je(e,co.get_high(),this.unsigned)}if(t.isZero())return mo;if(this.eq(Rn))return t.isOdd()?Rn:mo;if(t.eq(Rn))return this.isOdd()?Rn: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(T1)&&t.lt(T1))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,je(f<<16|d,p<<16|m,this.unsigned)};yt.mul=yt.multiply;yt.divide=function(t){if(On(t)||(t=Gs(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 je(e,co.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Gu:mo;var n,o,s;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Gu;if(t.gt(this.shru(1)))return E1;s=Gu}else{if(this.eq(Rn)){if(t.eq(Yp)||t.eq(g0))return Rn;if(t.eq(Rn))return Yp;var i=this.shr(1);return n=i.div(t).shl(1),n.eq(mo)?t.isNegative()?Yp:g0:(o=this.sub(t.mul(n)),s=n.add(o.div(t)),s)}else if(t.eq(Rn))return this.unsigned?Gu: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:Yg(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=Yp),s=s.add(l),o=o.sub(c)}return s};yt.div=yt.divide;yt.modulo=function(t){if(On(t)||(t=Gs(t)),co){var e=(this.unsigned?co.rem_u:co.rem_s)(this.low,this.high,t.low,t.high);return je(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 je(~this.low,~this.high,this.unsigned)};yt.and=function(t){return On(t)||(t=Gs(t)),je(this.low&t.low,this.high&t.high,this.unsigned)};yt.or=function(t){return On(t)||(t=Gs(t)),je(this.low|t.low,this.high|t.high,this.unsigned)};yt.xor=function(t){return On(t)||(t=Gs(t)),je(this.low^t.low,this.high^t.high,this.unsigned)};yt.shiftLeft=function(t){return On(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?je(this.low<>>32-t,this.unsigned):je(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):je(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};yt.shr=yt.shiftRight;yt.shiftRightUnsigned=function(t){if(On(t)&&(t=t.toInt()),t&=63,t===0)return this;var e=this.high;if(t<32){var n=this.low;return je(n>>>t|e<<32-t,e>>>t,this.unsigned)}else return t===32?je(e,0,this.unsigned):je(e>>>t-32,0,this.unsigned)};yt.shru=yt.shiftRightUnsigned;yt.shr_u=yt.shiftRightUnsigned;yt.toSigned=function(){return this.unsigned?je(this.low,this.high,!1):this};yt.toUnsigned=function(){return this.unsigned?this:je(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]};Ke.fromBytes=function(t,e,n){return n?Ke.fromBytesLE(t,e):Ke.fromBytesBE(t,e)};Ke.fromBytesLE=function(t,e){return new Ke(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};Ke.fromBytesBE=function(t,e){return new Ke(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}});var f_=gr(()=>{});var d_=gr(()=>{});var dE=gr((fE,iS)=>{(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})(fE,typeof iS=="object"&&iS,typeof define=="function"&&define)});var gE=gr((hE,aS)=>{(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})(hE,typeof aS=="object"&&aS,typeof define=="function"&&define)});var yE=gr((xE,lS)=>{(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})(xE,typeof lS=="object"&&lS,typeof define=="function"&&define)});var wE=gr((bE,uS)=>{(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})(bE,typeof uS=="object"&&uS,typeof define=="function"&&define)});var CE=gr((vE,cS)=>{(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})(vE,typeof cS=="object"&&cS,typeof define=="function"&&define)});var SE=gr((IE,pS)=>{(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})(IE,typeof pS=="object"&&pS,typeof define=="function"&&define)});var NE=gr(()=>{});var TE=gr((kE,sy)=>{(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,N){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),L=function(){for(var M=D.g(o),G=a,H=0;M=l;)M/=2,G/=2,H>>>=1;return(M+H)/G};return L.int32=function(){return D.g(4)|0},L.quick=function(){return D.g(4)/4294967296},L.double=L,g(b(D.S),t),(v.pass||N||function(M,G,H,q){return q&&(q.S&&d(q,D),M.state=function(){return d(D,{})}),H?(e[i]=M,G):M})(L,$,"global"in v?v.global:this==e,v.state)}function f(w){var v,N=w.length,E=this,$=0,D=E.i=E.j=0,L=E.S=[];for(N||(w=[N++]);${var aj=dE(),lj=gE(),uj=yE(),cj=wE(),pj=CE(),mj=SE(),nc=TE();nc.alea=aj;nc.xor128=lj;nc.xorwow=uj;nc.xorshift7=cj;nc.xor4096=pj;nc.tychei=mj;_E.exports=nc});var wN=gr(()=>{});var iw=gr(()=>{});var cg=gr(()=>{});var $W=gr(()=>{});var DW=gr(()=>{});var FW=gr(()=>{});var RW=gr((wC,MT)=>{var PT=(()=>{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 Rt.buffer!=dr&&Mo(Rt.buffer),rp}function n(){return Rt.buffer!=dr&&Mo(Rt.buffer),np}function o(){return Rt.buffer!=dr&&Mo(Rt.buffer),Ld}function s(){return Rt.buffer!=dr&&Mo(Rt.buffer),hg}function i(){return Rt.buffer!=dr&&Mo(Rt.buffer),gg}function a(){return Rt.buffer!=dr&&Mo(Rt.buffer),xg}function u(){return Rt.buffer!=dr&&Mo(Rt.buffer),yg}var l=typeof t!="undefined"?t:{},c,p;l.ready=new Promise(function(T,F){c=T,p=F});var m;typeof process!="undefined"&&process.listeners&&(m={uncaughtException:process.listeners("uncaughtException"),unhandledRejection:process.listeners("unhandledRejection")});var f=Object.assign({},l),d=[],h="./this.program",g=(T,F)=>{throw F},y=typeof window=="object",b=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v=l.ENVIRONMENT_IS_PTHREAD||!1,N="";function E(T){return l.locateFile?l.locateFile(T,N):N+T}var $,D,L,M;function G(T){if(T instanceof qd)return;K("exiting due to exception: "+T)}var H,q,X;if(w){b?N=cg().dirname(N)+"/":N=__dirname+"/",X=()=>{q||(H=iw(),q=cg())},$=function(V,Y){return X(),V=q.normalize(V),H.readFileSync(V,Y?void 0:"utf8")},L=F=>{var V=$(F,!0);return V.buffer||(V=new Uint8Array(V)),V},D=(F,V,Y)=>{X(),F=q.normalize(F),H.readFile(F,function(ht,wt){ht?Y(ht):V(wt.buffer)})},process.argv.length>1&&(h=process.argv[1].replace(/\\/g,"/")),d=process.argv.slice(2),process.on("uncaughtException",function(F){if(!(F instanceof qd))throw F}),process.on("unhandledRejection",function(F){throw F}),g=(F,V)=>{if(Ru())throw process.exitCode=F,V;G(V),process.exit(F)},l.inspect=function(){return"[Emscripten Module object]"};let T;try{T=$W()}catch(F){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),F}global.Worker=T.Worker}else(y||b)&&(b?N=self.location.href:typeof document!="undefined"&&document.currentScript&&(N=document.currentScript.src),typeof r!="undefined"&&r&&(N=r),N.indexOf("blob:")!==0?N=N.substr(0,N.replace(/[?#].*/,"").lastIndexOf("/")+1):N="",w||($=T=>{var F=new XMLHttpRequest;return F.open("GET",T,!1),F.send(null),F.responseText},b&&(L=T=>{var F=new XMLHttpRequest;return F.open("GET",T,!1),F.responseType="arraybuffer",F.send(null),new Uint8Array(F.response)}),D=(T,F,V)=>{var Y=new XMLHttpRequest;Y.open("GET",T,!0),Y.responseType="arraybuffer",Y.onload=()=>{if(Y.status==200||Y.status==0&&Y.response){F(Y.response);return}V()},Y.onerror=V,Y.send(null)}),M=T=>document.title=T);w&&typeof performance=="undefined"&&(global.performance=DW().performance);var j=console.log.bind(console),J=console.warn.bind(console);w&&(X(),j=T=>H.writeSync(1,T+` `),J=T=>H.writeSync(2,T+` `));var nt=l.print||j,K=l.printErr||J;Object.assign(l,f),f=null,l.arguments&&(d=l.arguments),l.thisProgram&&(h=l.thisProgram),l.quit&&(g=l.quit);var ot=4;function st(T){st.shown||(st.shown={}),st.shown[T]||(st.shown[T]=1,K(T))}function it(T,F){if(typeof WebAssembly.Function=="function"){for(var V={i:"i32",j:"i64",f:"f32",d:"f64"},Y={parameters:[],results:F[0]=="v"?[]:[V[F[0]]]},ht=1;ht{bt=T},At=Atomics.load,Dt=Atomics.store,qt=Atomics.compareExchange,Kt;l.wasmBinary&&(Kt=l.wasmBinary);var me=l.noExitRuntime||!0;typeof WebAssembly!="object"&&sp("no native wasm support detected");var Rt,Ee,Ce=!1,le;function qe(T,F){T||sp(F)}function Fe(T){var F=l["_"+T];return F}function Jr(T,F,V,Y,ht){var wt={string:function(Dn){var hp=0;if(Dn!=null&&Dn!==0){var p1=(Dn.length<<2)+1;hp=dp(p1),$n(Dn,hp,p1)}return hp},array:function(Dn){var hp=dp(Dn.length);return xl(Dn,hp),hp}};function Tt(Dn){return F==="string"?qr(Dn):F==="boolean"?Boolean(Dn):Dn}var Vt=Fe(T),nr=[],Go=0;if(Y)for(var Wo=0;Wo(V.buffer instanceof SharedArrayBuffer&&(V=new Uint8Array(V)),F.decode.call(F,V))}var Qr=typeof TextDecoder!="undefined"?new Or("utf8"):void 0;function tn(T,F,V){for(var Y=F+V,ht=F;T[ht]&&!(ht>=Y);)++ht;if(ht-F>16&&T.subarray&&Qr)return Qr.decode(T.subarray(F,ht));for(var wt="";F>10,56320|Go&1023)}}return wt}function qr(T,F){return T?tn(n(),T,F):""}function oo(T,F,V,Y){if(!(Y>0))return 0;for(var ht=V,wt=V+Y-1,Tt=0;Tt=55296&&Vt<=57343){var nr=T.charCodeAt(++Tt);Vt=65536+((Vt&1023)<<10)|nr&1023}if(Vt<=127){if(V>=wt)break;F[V++]=Vt}else if(Vt<=2047){if(V+1>=wt)break;F[V++]=192|Vt>>6,F[V++]=128|Vt&63}else if(Vt<=65535){if(V+2>=wt)break;F[V++]=224|Vt>>12,F[V++]=128|Vt>>6&63,F[V++]=128|Vt&63}else{if(V+3>=wt)break;F[V++]=240|Vt>>18,F[V++]=128|Vt>>12&63,F[V++]=128|Vt>>6&63,F[V++]=128|Vt&63}}return F[V]=0,V-ht}function $n(T,F,V){return oo(T,n(),F,V)}function Po(T){for(var F=0,V=0;V=55296&&Y<=57343&&(Y=65536+((Y&1023)<<10)|T.charCodeAt(++V)&1023),Y<=127?++F:Y<=2047?F+=2:Y<=65535?F+=3:F+=4}return F}var so=typeof TextDecoder!="undefined"?new Or("utf-16le"):void 0;function xl(T,F){e().set(T,F)}function Du(T,F,V){for(var Y=0;Y>0]=T.charCodeAt(Y);V||(e()[F>>0]=0)}function ep(T,F){return T%F>0&&(T+=F-T%F),T}var dr,rp,np,Ld,hg,gg,HT,xg,yg;v&&(dr=l.buffer);function Mo(T){dr=T,l.HEAP8=rp=new Int8Array(T),l.HEAP16=Ld=new Int16Array(T),l.HEAP32=gg=new Int32Array(T),l.HEAPU8=np=new Uint8Array(T),l.HEAPU16=hg=new Uint16Array(T),l.HEAPU32=HT=new Uint32Array(T),l.HEAPF32=xg=new Float32Array(T),l.HEAPF64=yg=new Float64Array(T)}var bg=l.INITIAL_MEMORY||16777216;if(v)Rt=l.wasmMemory,dr=l.buffer;else if(l.wasmMemory)Rt=l.wasmMemory;else if(Rt=new WebAssembly.Memory({initial:bg/65536,maximum:32768,shared:!0}),!(Rt.buffer instanceof SharedArrayBuffer))throw K("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");Rt&&(dr=Rt.buffer),bg=dr.byteLength,Mo(dr);var Hn,op=[],yl=[],IC=[],wg=[],Fu=!1,SC=!1,vg=0;function Ru(){return me||vg>0}function en(){if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)qT(l.preRun.shift());Ng(op)}function Pd(){Fu=!0,!v&&Ng(yl)}function NC(){v||(Ut.terminateAllThreads(),SC=!0)}function kC(){if(!v){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;)Md(l.postRun.shift());Ng(wg)}}function qT(T){op.unshift(T)}function KT(T){yl.unshift(T)}function Md(T){wg.unshift(T)}var bl=0,Cg=null,zo=null;function zd(T){bl++,l.monitorRunDependencies&&l.monitorRunDependencies(bl)}function jT(T){if(bl--,l.monitorRunDependencies&&l.monitorRunDependencies(bl),bl==0&&(Cg!==null&&(clearInterval(Cg),Cg=null),zo)){var F=zo;zo=null,F()}}l.preloadedImages={},l.preloadedAudios={};function sp(T){v?postMessage({cmd:"onAbort",arg:T}):l.onAbort&&l.onAbort(T),T="Aborted("+T+")",K(T),Ce=!0,le=1,T+=". Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(T);throw p(F),F}var TC="data:application/octet-stream;base64,";function Bd(T){return T.startsWith(TC)}function Ig(T){return T.startsWith("file://")}var rn;rn="tfjs-backend-wasm-threaded-simd.wasm",Bd(rn)||(rn=E(rn));function Sg(T){try{if(T==rn&&Kt)return new Uint8Array(Kt);if(L)return L(T);throw"both async and sync fetching of the wasm failed"}catch(F){sp(F)}}function ip(){if(!Kt&&(y||b)){if(typeof fetch=="function"&&!Ig(rn))return fetch(rn,{credentials:"same-origin"}).then(function(T){if(!T.ok)throw"failed to load wasm binary file at '"+rn+"'";return T.arrayBuffer()}).catch(function(){return Sg(rn)});if(D)return new Promise(function(T,F){D(rn,function(V){T(new Uint8Array(V))},F)})}return Promise.resolve().then(function(){return Sg(rn)})}function _C(){var T={env:Pg,wasi_snapshot_preview1:Pg};function F(Tt,Vt){var nr=Tt.exports;if(l.asm=nr,OC(l.asm.emscripten_tls_init),Hn=l.asm.__indirect_function_table,KT(l.asm.__wasm_call_ctors),Ee=Vt,!v){var Go=Ut.unusedWorkers.length;Ut.unusedWorkers.forEach(function(Wo){Ut.loadWasmModuleToWorker(Wo,function(){--Go||jT("wasm-instantiate")})})}}v||zd("wasm-instantiate");function V(Tt){F(Tt.instance,Tt.module)}function Y(Tt){return ip().then(function(Vt){return WebAssembly.instantiate(Vt,T)}).then(function(Vt){return Vt}).then(Tt,function(Vt){K("failed to asynchronously prepare wasm: "+Vt),sp(Vt)})}function ht(){return!Kt&&typeof WebAssembly.instantiateStreaming=="function"&&!Bd(rn)&&!Ig(rn)&&typeof fetch=="function"?fetch(rn,{credentials:"same-origin"}).then(function(Tt){var Vt=WebAssembly.instantiateStreaming(Tt,T);return Vt.then(V,function(nr){return K("wasm streaming compile failed: "+nr),K("falling back to ArrayBuffer instantiation"),Y(V)})}):Y(V)}if(l.instantiateWasm)try{var wt=l.instantiateWasm(T,F);return wt}catch(Tt){return K("Module.instantiateWasm callback failed with error: "+Tt),!1}return ht().catch(p),{}}var XT,YT,EC={};function Ng(T){for(;T.length>0;){var F=T.shift();if(typeof F=="function"){F(l);continue}var V=F.func;typeof V=="number"?F.arg===void 0?lp(V)():lp(V)(F.arg):V(F.arg===void 0?null:F.arg)}}function ap(T){var F=r0(),V=T();return Gg(F),V}function WW(T){return T}function ZT(T){var F=/\b_Z[\w\d_]+/g;return T.replace(F,function(V){var Y=V;return V===Y?V:Y+" ["+V+"]"})}function AC(T){i()[T>>2]=0;var F=Ut.pthreads[T];delete Ut.pthreads[T],F.worker.terminate(),e0(T),Ut.runningWorkers.splice(Ut.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function $C(T){var F=Ut.pthreads[T];F.worker.postMessage({cmd:"cancel"})}function kg(T){var F=Ut.pthreads[T];if(F){i()[T>>2]=0;var V=F.worker;Ut.returnWorkerToPool(V)}}function Tg(T){DU(T)}function DC(T){if(T instanceof qd||T=="unwind")return le;g(1,T)}var Ut={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){v?Ut.initWorker():Ut.initMainThread()},initMainThread:function(){for(var T=8,F=0;F>2]=0;try{T()}finally{i()[c1>>2]=1}},receiveObjectTransfer:function(T){},threadInit:function(){for(var T in Ut.tlsInitFunctions)Ut.tlsInitFunctions[T]()},loadWasmModuleToWorker:function(T,F){T.onmessage=V=>{var Y=V.data,ht=Y.cmd;if(T.pthread&&(Ut.currentProxiedOperationCallerThread=T.pthread.threadInfoStruct),Y.targetThread&&Y.targetThread!=Vg()){var wt=Ut.pthreads[Y.targetThread];wt?wt.worker.postMessage(Y,Y.transferList):K('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"?s1():ht==="spawnThread"?Eg(Y):ht==="cleanupThread"?kg(Y.thread):ht==="killThread"?AC(Y.thread):ht==="cancelThread"?$C(Y.thread):ht==="loaded"?(T.loaded=!0,F&&F(T),T.runPthread&&(T.runPthread(),delete T.runPthread)):ht==="print"?nt("Thread "+Y.threadId+": "+Y.text):ht==="printErr"?K("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):K("worker sent an unknown command "+ht),Ut.currentProxiedOperationCallerThread=void 0},T.onerror=V=>{var Y="worker sent an error!";throw K(Y+" "+V.filename+":"+V.lineno+": "+V.message),V},w&&(T.on("message",function(V){T.onmessage({data:V})}),T.on("error",function(V){T.onerror(V)}),T.on("detachedExit",function(){})),T.postMessage({cmd:"load",urlOrBlob:l.mainScriptUrlOrBlob||r,wasmMemory:Rt,wasmModule:Ee})},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 FC(){var T=Vg(),F=i()[T+44>>2],V=i()[T+48>>2],Y=F-V;u1(F,Y),Gg(F)}l.establishStackSpace=FC;function _g(T){if(v)return Pu(1,0,T);try{Tg(T)}catch(F){DC(F)}}var Ou=[];function lp(T){var F=Ou[T];return F||(T>=Ou.length&&(Ou.length=T+1),Ou[T]=F=Hn.get(T)),F}function RC(T,F){return lp(T)(F)}l.invokeEntryPoint=RC;function JT(){var T=new Error;if(!T.stack){try{throw new Error}catch(F){T=F}if(!T.stack)return"(no stack trace available)"}return T.stack.toString()}function OC(T,F,V){Ut.tlsInitFunctions.push(T)}function QT(T,F){Hn.set(T,F),Ou[T]=F}var Lu;w?Lu=()=>{var T=process.hrtime();return T[0]*1e3+T[1]/1e6}:v?Lu=()=>performance.now()-l.__performance_now_clock_drift:Lu=()=>performance.now();var LC=!0;function PC(T){return i()[o1()>>2]=T,T}function MC(T,F){var V;if(T===0)V=Date.now();else if((T===1||T===4)&&LC)V=Lu();else return PC(28),-1;return i()[F>>2]=V/1e3|0,i()[F+4>>2]=V%1e3*1e3*1e3|0,0}function zC(T,F){return MC(T,F)}function BC(T){i1(T,!b,1,!y),Ut.threadInit()}function VC(T){v?postMessage({cmd:"cleanupThread",thread:T}):kg(T)}function Eg(T){var F=Ut.getNewWorker();if(!F)return 6;Ut.runningWorkers.push(F);var V=Ut.pthreads[T.pthread_ptr]={worker:F,threadInfoStruct:T.pthread_ptr};F.pthread=V;var Y={cmd:"run",start_routine:T.startRoutine,arg:T.arg,threadInfoStruct:T.pthread_ptr};return F.runPthread=()=>{Y.time=performance.now(),F.postMessage(Y,T.transferList)},F.loaded&&(F.runPthread(),delete F.runPthread),0}function GC(T,F,V,Y){if(typeof SharedArrayBuffer=="undefined")return K("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var ht=[],wt=0;if(v&&(ht.length===0||wt))return a1(687865856,T,F,V,Y);if(wt)return wt;var Tt={startRoutine:V,pthread_ptr:T,arg:Y,transferList:ht};return v?(Tt.cmd="spawnThread",postMessage(Tt,ht),0):Eg(Tt)}function WC(){return 2097152}function UC(T,F){if(T==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(v)postMessage({targetThread:T,cmd:"processThreadQueue"});else{var V=Ut.pthreads[T],Y=V&&V.worker;if(!Y)return;Y.postMessage({cmd:"processThreadQueue"})}return 1}function HC(){sp("")}function qC(){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 Ag(){return 2147483648}function KC(T,F,V){n().copyWithin(T,F,F+V)}function jC(){return w?FW().cpus().length:navigator.hardwareConcurrency}function Pu(T,F){var V=arguments.length-2,Y=arguments;return ap(function(){for(var ht=V,wt=dp(ht*8),Tt=wt>>3,Vt=0;Vt>3,ht=0;ht>>16),Mo(Rt.buffer),1}catch(F){}}function ZC(T){var F=n().length;if(T=T>>>0,T<=F)return!1;var V=Ag();if(T>V)return!1;for(var Y=1;Y<=4;Y*=2){var ht=F*(1+.2/Y);ht=Math.min(ht,T+100663296);var wt=Math.min(V,ep(Math.max(T,ht),65536)),Tt=YC(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||(IC.push(ne.removeAllEventListeners),ne.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(T,F,V){function Y(Tt,Vt){if(Tt.length!=Vt.length)return!1;for(var nr in Tt)if(Tt[nr]!=Vt[nr])return!1;return!0}for(var ht in ne.deferredCalls){var wt=ne.deferredCalls[ht];if(wt.targetFunction==T&&Y(wt.argsList,V))return}ne.deferredCalls.push({targetFunction:T,precedence:F,argsList:V}),ne.deferredCalls.sort(function(Tt,Vt){return Tt.precedence>2]=V,i()[wt+4>>2]=Y,i()[wt+8>>2]=ht,t0(T,637534208,F,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 JC(T){var F=Po(T)+1,V=QI(F);return $n(T,V,F),V}function QC(T,F,V,Y){ap(function(){var ht=dp(12),wt=0;F&&(wt=JC(F)),i()[ht>>2]=wt,i()[ht+4>>2]=V,i()[ht+8>>2]=Y,t0(T,657457152,0,wt,ht)})}function tI(T,F,V,Y){F=F?qr(F):"",QC(T,F,V,Y)}function eI(T){return T>2?qr(T):T}var rI=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function nI(T){T=eI(T);var F=rI[T]||(typeof document!="undefined"?document.querySelector(T):void 0);return F}function Gd(T){return nI(T)}function $g(T,F,V){var Y=Gd(T);if(!Y)return-4;if(Y.canvasSharedPtr&&(i()[Y.canvasSharedPtr>>2]=F,i()[Y.canvasSharedPtr+4>>2]=V),Y.offscreenCanvas||!Y.controlTransferredOffscreen){Y.offscreenCanvas&&(Y=Y.offscreenCanvas);var ht=!1;if(Y.GLctxObject&&Y.GLctxObject.GLctx){var wt=Y.GLctxObject.GLctx.getParameter(2978);ht=wt[0]===0&&wt[1]===0&&wt[2]===Y.width&&wt[3]===Y.height}Y.width=F,Y.height=V,ht&&Y.GLctxObject.GLctx.viewport(0,0,F,V)}else if(Y.canvasSharedPtr){var Tt=i()[Y.canvasSharedPtr+8>>2];return tI(Tt,T,F,V),1}else return-4;return 0}function Dg(T,F,V){return v?Pu(2,1,T,F,V):$g(T,F,V)}function oI(T,F,V){var Y=Gd(T);return Y?$g(T,F,V):Dg(T,F,V)}function sI(){throw"unwind"}function iI(T){var F=T.getExtension("ANGLE_instanced_arrays");if(F)return T.vertexAttribDivisor=function(V,Y){F.vertexAttribDivisorANGLE(V,Y)},T.drawArraysInstanced=function(V,Y,ht,wt){F.drawArraysInstancedANGLE(V,Y,ht,wt)},T.drawElementsInstanced=function(V,Y,ht,wt,Tt){F.drawElementsInstancedANGLE(V,Y,ht,wt,Tt)},1}function aI(T){var F=T.getExtension("OES_vertex_array_object");if(F)return T.createVertexArray=function(){return F.createVertexArrayOES()},T.deleteVertexArray=function(V){F.deleteVertexArrayOES(V)},T.bindVertexArray=function(V){F.bindVertexArrayOES(V)},T.isVertexArray=function(V){return F.isVertexArrayOES(V)},1}function lI(T){var F=T.getExtension("WEBGL_draw_buffers");if(F)return T.drawBuffers=function(V,Y){F.drawBuffersWEBGL(V,Y)},1}function uI(T){return!!(T.multiDrawWebgl=T.getExtension("WEBGL_multi_draw"))}var rr={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(F){rr.lastError||(rr.lastError=F)},getNewId:function(T){for(var F=rr.counter++,V=T.length;V>2]:-1;ht+=qr(i()[V+wt*4>>2],Tt<0?void 0:Tt)}return ht},createContext:function(T,F){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 V=T.getContext("webgl",F);if(!V)return 0;var Y=rr.registerContext(V,F);return Y},registerContext:function(T,F){var V=QI(8);i()[V+4>>2]=Vg();var Y={handle:V,attributes:F,version:F.majorVersion,GLctx:T};return T.canvas&&(T.canvas.GLctxObject=Y),rr.contexts[V]=Y,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&rr.initExtensions(Y),V},makeContextCurrent:function(T){return rr.currentContext=rr.contexts[T],l.ctx=Lg=rr.currentContext&&rr.currentContext.GLctx,!(T&&!Lg)},getContext:function(T){return rr.contexts[T]},deleteContext:function(T){rr.currentContext===rr.contexts[T]&&(rr.currentContext=null),typeof ne=="object"&&ne.removeAllHandlersOnTarget(rr.contexts[T].GLctx.canvas),rr.contexts[T]&&rr.contexts[T].GLctx.canvas&&(rr.contexts[T].GLctx.canvas.GLctxObject=void 0),n1(rr.contexts[T].handle),rr.contexts[T]=null},initExtensions:function(T){if(T||(T=rr.currentContext),!T.initExtensionsDone){T.initExtensionsDone=!0;var F=T.GLctx;iI(F),aI(F),lI(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),uI(F);var V=F.getSupportedExtensions()||[];V.forEach(function(Y){!Y.includes("lose_context")&&!Y.includes("debug")&&F.getExtension(Y)})}}},cI=["default","low-power","high-performance"];function pI(T,F){var V=F>>2,Y=i()[V+6],ht={alpha:!!i()[V+0],depth:!!i()[V+1],stencil:!!i()[V+2],antialias:!!i()[V+3],premultipliedAlpha:!!i()[V+4],preserveDrawingBuffer:!!i()[V+5],powerPreference:cI[Y],failIfMajorPerformanceCaveat:!!i()[V+7],majorVersion:i()[V+8],minorVersion:i()[V+9],enableExtensionsByDefault:i()[V+10],explicitSwapControl:i()[V+11],proxyContextToMainThread:i()[V+12],renderViaOffscreenBackBuffer:i()[V+13]},wt=Gd(T);if(!wt||ht.explicitSwapControl)return 0;var Tt=rr.createContext(wt,ht);return Tt}function mI(T,F){return pI(T,F)}var up={mappings:{},buffers:[null,[],[]],printChar:function(T,F){var V=up.buffers[T];F===0||F===10?((T===1?nt:K)(tn(V,0)),V.length=0):V.push(F)},varargs:void 0,get:function(){up.varargs+=4;var T=i()[up.varargs-4>>2];return T},getStr:function(T){var F=qr(T);return F},get64:function(T,F){return T}};function Fg(T){return v?Pu(3,1,T):0}function Rg(T,F,V,Y,ht){if(v)return Pu(4,1,T,F,V,Y,ht)}function Og(T,F,V,Y){if(v)return Pu(5,1,T,F,V,Y);for(var ht=0,wt=0;wt>2],Vt=i()[F+4>>2];F+=8;for(var nr=0;nr>2]=ht,0}function fI(T){Nt(T)}Ut.init();var Lg,dI=[null,_g,Dg,Fg,Rg,Og],t1=!1,Pg={__clock_gettime:zC,__emscripten_init_main_thread_js:BC,__emscripten_thread_cleanup:VC,__pthread_create_js:GC,_emscripten_default_pthread_stack_size:WC,_emscripten_notify_thread_queue:UC,abort:HC,emscripten_check_blocking_allowed:qC,emscripten_get_heap_max:Ag,emscripten_get_now:Lu,emscripten_memcpy_big:KC,emscripten_num_logical_cores:jC,emscripten_receive_on_main_thread_js:XC,emscripten_resize_heap:ZC,emscripten_set_canvas_element_size:oI,emscripten_unwind_to_js_event_loop:sI,emscripten_webgl_create_context:mI,exit:Tg,fd_close:Fg,fd_seek:Rg,fd_write:Og,memory:Rt||l.wasmMemory,setTempRet0:fI},e1=_C(),hI=l.___wasm_call_ctors=function(){return(hI=l.___wasm_call_ctors=l.asm.__wasm_call_ctors).apply(null,arguments)},gI=l._init=function(){return(gI=l._init=l.asm.init).apply(null,arguments)},xI=l._init_with_threads_count=function(){return(xI=l._init_with_threads_count=l.asm.init_with_threads_count).apply(null,arguments)},yI=l._get_threads_count=function(){return(yI=l._get_threads_count=l.asm.get_threads_count).apply(null,arguments)},bI=l._register_tensor=function(){return(bI=l._register_tensor=l.asm.register_tensor).apply(null,arguments)},wI=l._dispose_data=function(){return(wI=l._dispose_data=l.asm.dispose_data).apply(null,arguments)},vI=l._dispose=function(){return(vI=l._dispose=l.asm.dispose).apply(null,arguments)},CI=l._Abs=function(){return(CI=l._Abs=l.asm.Abs).apply(null,arguments)},II=l._Add=function(){return(II=l._Add=l.asm.Add).apply(null,arguments)},SI=l._AddN=function(){return(SI=l._AddN=l.asm.AddN).apply(null,arguments)},NI=l._All=function(){return(NI=l._All=l.asm.All).apply(null,arguments)},kI=l._Any=function(){return(kI=l._Any=l.asm.Any).apply(null,arguments)},TI=l._ArgMax=function(){return(TI=l._ArgMax=l.asm.ArgMax).apply(null,arguments)},_I=l._AvgPool=function(){return(_I=l._AvgPool=l.asm.AvgPool).apply(null,arguments)},EI=l._BatchMatMul=function(){return(EI=l._BatchMatMul=l.asm.BatchMatMul).apply(null,arguments)},AI=l._Ceil=function(){return(AI=l._Ceil=l.asm.Ceil).apply(null,arguments)},$I=l._ClipByValue=function(){return($I=l._ClipByValue=l.asm.ClipByValue).apply(null,arguments)},DI=l._Conv2D=function(){return(DI=l._Conv2D=l.asm.Conv2D).apply(null,arguments)},FI=l._Conv2DBackpropInput=function(){return(FI=l._Conv2DBackpropInput=l.asm.Conv2DBackpropInput).apply(null,arguments)},RI=l._Cos=function(){return(RI=l._Cos=l.asm.Cos).apply(null,arguments)},OI=l._Cosh=function(){return(OI=l._Cosh=l.asm.Cosh).apply(null,arguments)},LI=l._CropAndResize=function(){return(LI=l._CropAndResize=l.asm.CropAndResize).apply(null,arguments)},PI=l._Cumprod=function(){return(PI=l._Cumprod=l.asm.Cumprod).apply(null,arguments)},MI=l._Cumsum=function(){return(MI=l._Cumsum=l.asm.Cumsum).apply(null,arguments)},zI=l._DepthToSpace=function(){return(zI=l._DepthToSpace=l.asm.DepthToSpace).apply(null,arguments)},BI=l._DepthwiseConv2dNative=function(){return(BI=l._DepthwiseConv2dNative=l.asm.DepthwiseConv2dNative).apply(null,arguments)},VI=l._Elu=function(){return(VI=l._Elu=l.asm.Elu).apply(null,arguments)},GI=l._Equal=function(){return(GI=l._Equal=l.asm.Equal).apply(null,arguments)},WI=l._Exp=function(){return(WI=l._Exp=l.asm.Exp).apply(null,arguments)},UI=l._FlipLeftRight=function(){return(UI=l._FlipLeftRight=l.asm.FlipLeftRight).apply(null,arguments)},HI=l._Floor=function(){return(HI=l._Floor=l.asm.Floor).apply(null,arguments)},qI=l._FloorDiv=function(){return(qI=l._FloorDiv=l.asm.FloorDiv).apply(null,arguments)},KI=l._FusedBatchNorm=function(){return(KI=l._FusedBatchNorm=l.asm.FusedBatchNorm).apply(null,arguments)},jI=l._FusedConv2D=function(){return(jI=l._FusedConv2D=l.asm.FusedConv2D).apply(null,arguments)},Mg=l._FusedDepthwiseConv2D=function(){return(Mg=l._FusedDepthwiseConv2D=l.asm.FusedDepthwiseConv2D).apply(null,arguments)},zg=l._Gather=function(){return(zg=l._Gather=l.asm.Gather).apply(null,arguments)},Wd=l._GatherNd=function(){return(Wd=l._GatherNd=l.asm.GatherNd).apply(null,arguments)},XI=l._Greater=function(){return(XI=l._Greater=l.asm.Greater).apply(null,arguments)},YI=l._GreaterEqual=function(){return(YI=l._GreaterEqual=l.asm.GreaterEqual).apply(null,arguments)},cp=l._LeakyRelu=function(){return(cp=l._LeakyRelu=l.asm.LeakyRelu).apply(null,arguments)},Ud=l._Less=function(){return(Ud=l._Less=l.asm.Less).apply(null,arguments)},Hd=l._LessEqual=function(){return(Hd=l._LessEqual=l.asm.LessEqual).apply(null,arguments)},r1=l._Log=function(){return(r1=l._Log=l.asm.Log).apply(null,arguments)},pp=l._LogicalAnd=function(){return(pp=l._LogicalAnd=l.asm.LogicalAnd).apply(null,arguments)},mp=l._LogicalNot=function(){return(mp=l._LogicalNot=l.asm.LogicalNot).apply(null,arguments)},ZI=l._LogicalOr=function(){return(ZI=l._LogicalOr=l.asm.LogicalOr).apply(null,arguments)},U=l._LogicalXor=function(){return(U=l._LogicalXor=l.asm.LogicalXor).apply(null,arguments)},Q=l._Max=function(){return(Q=l._Max=l.asm.Max).apply(null,arguments)},gt=l._MaxPool=function(){return(gt=l._MaxPool=l.asm.MaxPool).apply(null,arguments)},$t=l._Maximum=function(){return($t=l._Maximum=l.asm.Maximum).apply(null,arguments)},he=l._Mean=function(){return(he=l._Mean=l.asm.Mean).apply(null,arguments)},xe=l._Min=function(){return(xe=l._Min=l.asm.Min).apply(null,arguments)},oe=l._Minimum=function(){return(oe=l._Minimum=l.asm.Minimum).apply(null,arguments)},ee=l._MirrorPad=function(){return(ee=l._MirrorPad=l.asm.MirrorPad).apply(null,arguments)},hr=l._Multiply=function(){return(hr=l._Multiply=l.asm.Multiply).apply(null,arguments)},Bo=l._Neg=function(){return(Bo=l._Neg=l.asm.Neg).apply(null,arguments)},Vo=l._NonMaxSuppressionV3=function(){return(Vo=l._NonMaxSuppressionV3=l.asm.NonMaxSuppressionV3).apply(null,arguments)},fp=l._NonMaxSuppressionV4=function(){return(fp=l._NonMaxSuppressionV4=l.asm.NonMaxSuppressionV4).apply(null,arguments)},Mu=l._NonMaxSuppressionV5=function(){return(Mu=l._NonMaxSuppressionV5=l.asm.NonMaxSuppressionV5).apply(null,arguments)},JI=l._NotEqual=function(){return(JI=l._NotEqual=l.asm.NotEqual).apply(null,arguments)},nn=l._OneHot=function(){return(nn=l._OneHot=l.asm.OneHot).apply(null,arguments)},wl=l._PadV2=function(){return(wl=l._PadV2=l.asm.PadV2).apply(null,arguments)},Bg=l._Pow=function(){return(Bg=l._Pow=l.asm.Pow).apply(null,arguments)},UW=l._Prelu=function(){return(UW=l._Prelu=l.asm.Prelu).apply(null,arguments)},HW=l._Prod=function(){return(HW=l._Prod=l.asm.Prod).apply(null,arguments)},qW=l._RealDiv=function(){return(qW=l._RealDiv=l.asm.RealDiv).apply(null,arguments)},KW=l._Relu=function(){return(KW=l._Relu=l.asm.Relu).apply(null,arguments)},jW=l._Relu6=function(){return(jW=l._Relu6=l.asm.Relu6).apply(null,arguments)},XW=l._ResizeBilinear=function(){return(XW=l._ResizeBilinear=l.asm.ResizeBilinear).apply(null,arguments)},YW=l._ResizeNearestNeighbor=function(){return(YW=l._ResizeNearestNeighbor=l.asm.ResizeNearestNeighbor).apply(null,arguments)},ZW=l._Reverse=function(){return(ZW=l._Reverse=l.asm.Reverse).apply(null,arguments)},JW=l._RotateWithOffset=function(){return(JW=l._RotateWithOffset=l.asm.RotateWithOffset).apply(null,arguments)},QW=l._Round=function(){return(QW=l._Round=l.asm.Round).apply(null,arguments)},tU=l._Rsqrt=function(){return(tU=l._Rsqrt=l.asm.Rsqrt).apply(null,arguments)},eU=l._ScatterNd=function(){return(eU=l._ScatterNd=l.asm.ScatterNd).apply(null,arguments)},rU=l._SelectV2=function(){return(rU=l._SelectV2=l.asm.SelectV2).apply(null,arguments)},nU=l._Sigmoid=function(){return(nU=l._Sigmoid=l.asm.Sigmoid).apply(null,arguments)},oU=l._Sin=function(){return(oU=l._Sin=l.asm.Sin).apply(null,arguments)},sU=l._Softmax=function(){return(sU=l._Softmax=l.asm.Softmax).apply(null,arguments)},iU=l._SparseFillEmptyRows=function(){return(iU=l._SparseFillEmptyRows=l.asm.SparseFillEmptyRows).apply(null,arguments)},aU=l._SparseReshape=function(){return(aU=l._SparseReshape=l.asm.SparseReshape).apply(null,arguments)},lU=l._SparseSegmentReduction=function(){return(lU=l._SparseSegmentReduction=l.asm.SparseSegmentReduction).apply(null,arguments)},uU=l._Sqrt=function(){return(uU=l._Sqrt=l.asm.Sqrt).apply(null,arguments)},cU=l._Square=function(){return(cU=l._Square=l.asm.Square).apply(null,arguments)},pU=l._SquaredDifference=function(){return(pU=l._SquaredDifference=l.asm.SquaredDifference).apply(null,arguments)},mU=l._Step=function(){return(mU=l._Step=l.asm.Step).apply(null,arguments)},fU=l._StridedSlice=function(){return(fU=l._StridedSlice=l.asm.StridedSlice).apply(null,arguments)},dU=l._Sub=function(){return(dU=l._Sub=l.asm.Sub).apply(null,arguments)},hU=l._Sum=function(){return(hU=l._Sum=l.asm.Sum).apply(null,arguments)},gU=l._Tan=function(){return(gU=l._Tan=l.asm.Tan).apply(null,arguments)},xU=l._Tanh=function(){return(xU=l._Tanh=l.asm.Tanh).apply(null,arguments)},yU=l._Tile=function(){return(yU=l._Tile=l.asm.Tile).apply(null,arguments)},bU=l._TopK=function(){return(bU=l._TopK=l.asm.TopK).apply(null,arguments)},wU=l._Transform=function(){return(wU=l._Transform=l.asm.Transform).apply(null,arguments)},vU=l._Transpose=function(){return(vU=l._Transpose=l.asm.Transpose).apply(null,arguments)},CU=l.__FusedMatMul=function(){return(CU=l.__FusedMatMul=l.asm._FusedMatMul).apply(null,arguments)},QI=l._malloc=function(){return(QI=l._malloc=l.asm.malloc).apply(null,arguments)},n1=l._free=function(){return(n1=l._free=l.asm.free).apply(null,arguments)},IU=l._emscripten_tls_init=function(){return(IU=l._emscripten_tls_init=l.asm.emscripten_tls_init).apply(null,arguments)},o1=l.___errno_location=function(){return(o1=l.___errno_location=l.asm.__errno_location).apply(null,arguments)},Vg=l._pthread_self=function(){return(Vg=l._pthread_self=l.asm.pthread_self).apply(null,arguments)},s1=l._emscripten_main_thread_process_queued_calls=function(){return(s1=l._emscripten_main_thread_process_queued_calls=l.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},SU=l.__emscripten_thread_crashed=function(){return(SU=l.__emscripten_thread_crashed=l.asm._emscripten_thread_crashed).apply(null,arguments)},i1=l.__emscripten_thread_init=function(){return(i1=l.__emscripten_thread_init=l.asm._emscripten_thread_init).apply(null,arguments)},NU=l._emscripten_current_thread_process_queued_calls=function(){return(NU=l._emscripten_current_thread_process_queued_calls=l.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},kU=l._emscripten_main_browser_thread_id=function(){return(kU=l._emscripten_main_browser_thread_id=l.asm.emscripten_main_browser_thread_id).apply(null,arguments)},TU=l._emscripten_sync_run_in_main_thread_2=function(){return(TU=l._emscripten_sync_run_in_main_thread_2=l.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},a1=l._emscripten_sync_run_in_main_thread_4=function(){return(a1=l._emscripten_sync_run_in_main_thread_4=l.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},l1=l._emscripten_run_in_main_runtime_thread_js=function(){return(l1=l._emscripten_run_in_main_runtime_thread_js=l.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},t0=l._emscripten_dispatch_to_thread_=function(){return(t0=l._emscripten_dispatch_to_thread_=l.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},e0=l.__emscripten_thread_free_data=function(){return(e0=l.__emscripten_thread_free_data=l.asm._emscripten_thread_free_data).apply(null,arguments)},_U=l.__emscripten_thread_exit=function(){return(_U=l.__emscripten_thread_exit=l.asm._emscripten_thread_exit).apply(null,arguments)},EU=l._memalign=function(){return(EU=l._memalign=l.asm.memalign).apply(null,arguments)},u1=l._emscripten_stack_set_limits=function(){return(u1=l._emscripten_stack_set_limits=l.asm.emscripten_stack_set_limits).apply(null,arguments)},r0=l.stackSave=function(){return(r0=l.stackSave=l.asm.stackSave).apply(null,arguments)},Gg=l.stackRestore=function(){return(Gg=l.stackRestore=l.asm.stackRestore).apply(null,arguments)},dp=l.stackAlloc=function(){return(dp=l.stackAlloc=l.asm.stackAlloc).apply(null,arguments)},AU=l.dynCall_iijjiiii=function(){return(AU=l.dynCall_iijjiiii=l.asm.dynCall_iijjiiii).apply(null,arguments)},$U=l.dynCall_jiji=function(){return($U=l.dynCall_jiji=l.asm.dynCall_jiji).apply(null,arguments)},c1=l.__emscripten_allow_main_runtime_queued_calls=21672;l.cwrap=Me,l.keepRuntimeAlive=Ru,l.PThread=Ut,l.PThread=Ut,l.wasmMemory=Rt,l.ExitStatus=qd;var Wg;function qd(T){this.name="ExitStatus",this.message="Program terminated with exit("+T+")",this.status=T}zo=function T(){Wg||n0(),Wg||(zo=T)};function n0(T){if(T=T||d,bl>0)return;if(v){c(l),Pd(),postMessage({cmd:"loaded"});return}if(en(),bl>0)return;function F(){Wg||(Wg=!0,l.calledRun=!0,!Ce&&(Pd(),c(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),kC()))}l.setStatus?(l.setStatus("Running..."),setTimeout(function(){setTimeout(function(){l.setStatus("")},1),F()},1)):F()}l.run=n0;function DU(T,F){if(le=T,!F&&v)throw _g(T),"unwind";Ru()||NC(),FU(T)}function FU(T){le=T,Ru()||(Ut.terminateAllThreads(),l.onExit&&l.onExit(T),Ce=!0),g(T,new qd(T))}if(l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();n0();var Ug;m&&(Ug={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 Hg;if(typeof WasmBackendModule!="undefined")Hg=WasmBackendModule;else if(typeof t!="undefined")Hg=t;else throw new Error("Could not find wasm module in post.js");if(Ug){var RU=Hg._dispose;Hg._dispose=function(){RU(),Ug.uncaughtException.forEach(function(T){process.removeListener("uncaughtException",T)}),Ug.unhandledRejection.forEach(function(T){process.removeListener("unhandledRejection",T)})}}return t.ready}})();typeof wC=="object"&&typeof MT=="object"?MT.exports=PT:typeof define=="function"&&define.amd?define([],function(){return PT}):typeof wC=="object"&&(wC.WasmBackendModuleThreadedSimd=PT)});var LW=gr((W6e,OW)=>{OW.exports.wasmWorkerContents=`"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+" ");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=((info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports});self.onmessage=(e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else if(e.data.cmd==="processProxyingQueue"){if(Module["_pthread_self"]()){Module["_emscripten_proxy_execute_queue"](e.data.queue)}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}});`});var PW=gr((vC,BT)=>{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(U,Q){n=U,o=Q});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=(U,Q)=>{throw Q},c=typeof window=="object",p=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",f="";function d(U){return e.locateFile?e.locateFile(U,f):f+U}var h,g,y,b;function w(U){if(U instanceof Ud)return;D("exiting due to exception: "+U)}var v,N,E;m?(p?f=cg().dirname(f)+"/":f=__dirname+"/",E=()=>{N||(v=iw(),N=cg())},h=function(Q,gt){return E(),Q=N.normalize(Q),v.readFileSync(Q,gt?void 0:"utf8")},y=U=>{var Q=h(U,!0);return Q.buffer||(Q=new Uint8Array(Q)),Q},g=(U,Q,gt)=>{E(),U=N.normalize(U),v.readFile(U,function($t,he){$t?gt($t):Q(he.buffer)})},process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),a=process.argv.slice(2),process.on("uncaughtException",function(U){if(!(U instanceof Ud))throw U}),process.on("unhandledRejection",function(U){throw U}),l=(U,Q)=>{if(Ld())throw process.exitCode=U,Q;w(Q),process.exit(U)},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=U=>{var Q=new XMLHttpRequest;return Q.open("GET",U,!1),Q.send(null),Q.responseText},p&&(y=U=>{var Q=new XMLHttpRequest;return Q.open("GET",U,!1),Q.responseType="arraybuffer",Q.send(null),new Uint8Array(Q.response)}),g=(U,Q,gt)=>{var $t=new XMLHttpRequest;$t.open("GET",U,!0),$t.responseType="arraybuffer",$t.onload=()=>{if($t.status==200||$t.status==0&&$t.response){Q($t.response);return}gt()},$t.onerror=gt,$t.send(null)},b=U=>document.title=U);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 L=4;function M(U){M.shown||(M.shown={}),M.shown[U]||(M.shown[U]=1,D(U))}function G(U,Q){if(typeof WebAssembly.Function=="function"){for(var gt={i:"i32",j:"i64",f:"f32",d:"f64"},$t={parameters:[],results:Q[0]=="v"?[]:[gt[Q[0]]]},he=1;he{J=U},K;e.wasmBinary&&(K=e.wasmBinary);var ot=e.noExitRuntime||!0;typeof WebAssembly!="object"&&Fu("no native wasm support detected");var st,it=!1,ft;function lt(U,Q){U||Fu(Q)}function xt(U){var Q=e["_"+U];return Q}function dt(U,Q,gt,$t,he){var xe={string:function(nn){var wl=0;if(nn!=null&&nn!==0){var Bg=(nn.length<<2)+1;wl=Wd(Bg),me(nn,wl,Bg)}return wl},array:function(nn){var wl=Wd(nn.length);return Ce(nn,wl),wl}};function oe(nn){return Q==="string"?qt(nn):Q==="boolean"?Boolean(nn):nn}var ee=xt(U),hr=[],Bo=0;if($t)for(var Vo=0;Vo<$t.length;Vo++){var fp=xe[gt[Vo]];fp?(Bo===0&&(Bo=Mg()),hr[Vo]=fp($t[Vo])):hr[Vo]=$t[Vo]}var Mu=ee.apply(null,hr);function JI(nn){return Bo!==0&&zg(Bo),oe(nn)}return Mu=JI(Mu),Mu}function bt(U,Q,gt,$t){gt=gt||[];var he=gt.every(function(oe){return oe==="number"}),xe=Q!=="string";return xe&&he&&!$t?xt(U):function(){return dt(U,Q,gt,arguments,$t)}}var Nt=1,At=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Dt(U,Q,gt){for(var $t=Q+gt,he=Q;U[he]&&!(he>=$t);)++he;if(he-Q>16&&U.subarray&&At)return At.decode(U.subarray(Q,he));for(var xe="";Q>10,56320|Bo&1023)}}return xe}function qt(U,Q){return U?Dt(Me,U,Q):""}function Kt(U,Q,gt,$t){if(!($t>0))return 0;for(var he=gt,xe=gt+$t-1,oe=0;oe=55296&&ee<=57343){var hr=U.charCodeAt(++oe);ee=65536+((ee&1023)<<10)|hr&1023}if(ee<=127){if(gt>=xe)break;Q[gt++]=ee}else if(ee<=2047){if(gt+1>=xe)break;Q[gt++]=192|ee>>6,Q[gt++]=128|ee&63}else if(ee<=65535){if(gt+2>=xe)break;Q[gt++]=224|ee>>12,Q[gt++]=128|ee>>6&63,Q[gt++]=128|ee&63}else{if(gt+3>=xe)break;Q[gt++]=240|ee>>18,Q[gt++]=128|ee>>12&63,Q[gt++]=128|ee>>6&63,Q[gt++]=128|ee&63}}return Q[gt]=0,gt-he}function me(U,Q,gt){return Kt(U,Me,Q,gt)}function Rt(U){for(var Q=0,gt=0;gt=55296&&$t<=57343&&($t=65536+(($t&1023)<<10)|U.charCodeAt(++gt)&1023),$t<=127?++Q:$t<=2047?Q+=2:$t<=65535?Q+=3:Q+=4}return Q}var Ee=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function Ce(U,Q){Jr.set(U,Q)}function le(U,Q,gt){for(var $t=0;$t>0]=U.charCodeAt($t);gt||(Jr[Q>>0]=0)}function qe(U,Q){return U%Q>0&&(U+=Q-U%Q),U}var Fe,Jr,Me,Lo,Or,Qr,tn,qr,oo;function $n(U){Fe=U,e.HEAP8=Jr=new Int8Array(U),e.HEAP16=Lo=new Int16Array(U),e.HEAP32=Qr=new Int32Array(U),e.HEAPU8=Me=new Uint8Array(U),e.HEAPU16=Or=new Uint16Array(U),e.HEAPU32=tn=new Uint32Array(U),e.HEAPF32=qr=new Float32Array(U),e.HEAPF64=oo=new Float64Array(U)}var Po=e.INITIAL_MEMORY||16777216,so,xl=[],Du=[],ep=[],dr=!1,rp=!1,np=0;function Ld(){return ot||np>0}function hg(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)yg(e.preRun.shift());Md(xl)}function gg(){dr=!0,Md(Du)}function HT(){rp=!0}function xg(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)bg(e.postRun.shift());Md(ep)}function yg(U){xl.unshift(U)}function Mo(U){Du.unshift(U)}function bg(U){ep.unshift(U)}var Hn=0,op=null,yl=null;function IC(U){Hn++,e.monitorRunDependencies&&e.monitorRunDependencies(Hn)}function wg(U){if(Hn--,e.monitorRunDependencies&&e.monitorRunDependencies(Hn),Hn==0&&(op!==null&&(clearInterval(op),op=null),yl)){var Q=yl;yl=null,Q()}}e.preloadedImages={},e.preloadedAudios={};function Fu(U){e.onAbort&&e.onAbort(U),U="Aborted("+U+")",D(U),it=!0,ft=1,U+=". Build with -s ASSERTIONS=1 for more info.";var Q=new WebAssembly.RuntimeError(U);throw o(Q),Q}var SC="data:application/octet-stream;base64,";function vg(U){return U.startsWith(SC)}function Ru(U){return U.startsWith("file://")}var en;en="tfjs-backend-wasm.wasm",vg(en)||(en=d(en));function Pd(U){try{if(U==en&&K)return new Uint8Array(K);if(y)return y(U);throw"both async and sync fetching of the wasm failed"}catch(Q){Fu(Q)}}function NC(){if(!K&&(c||p)){if(typeof fetch=="function"&&!Ru(en))return fetch(en,{credentials:"same-origin"}).then(function(U){if(!U.ok)throw"failed to load wasm binary file at '"+en+"'";return U.arrayBuffer()}).catch(function(){return Pd(en)});if(g)return new Promise(function(U,Q){g(en,function(gt){U(new Uint8Array(gt))},Q)})}return Promise.resolve().then(function(){return Pd(en)})}function kC(){var U={env:ap,wasi_snapshot_preview1:ap};function Q(oe,ee){var hr=oe.exports;e.asm=hr,st=e.asm.memory,$n(st.buffer),so=e.asm.__indirect_function_table,Mo(e.asm.__wasm_call_ctors),wg("wasm-instantiate")}IC("wasm-instantiate");function gt(oe){Q(oe.instance)}function $t(oe){return NC().then(function(ee){return WebAssembly.instantiate(ee,U)}).then(function(ee){return ee}).then(oe,function(ee){D("failed to asynchronously prepare wasm: "+ee),Fu(ee)})}function he(){return!K&&typeof WebAssembly.instantiateStreaming=="function"&&!vg(en)&&!Ru(en)&&typeof fetch=="function"?fetch(en,{credentials:"same-origin"}).then(function(oe){var ee=WebAssembly.instantiateStreaming(oe,U);return ee.then(gt,function(hr){return D("wasm streaming compile failed: "+hr),D("falling back to ArrayBuffer instantiation"),$t(gt)})}):$t(gt)}if(e.instantiateWasm)try{var xe=e.instantiateWasm(U,Q);return xe}catch(oe){return D("Module.instantiateWasm callback failed with error: "+oe),!1}return he().catch(o),{}}var qT,KT;function Md(U){for(;U.length>0;){var Q=U.shift();if(typeof Q=="function"){Q(e);continue}var gt=Q.func;typeof gt=="number"?Q.arg===void 0?zd(gt)():zd(gt)(Q.arg):gt(Q.arg===void 0?null:Q.arg)}}function bl(U){return U}function Cg(U){var Q=/\b_Z[\w\d_]+/g;return U.replace(Q,function(gt){var $t=gt;return gt===$t?gt:$t+" ["+gt+"]"})}var zo=[];function zd(U){var Q=zo[U];return Q||(U>=zo.length&&(zo.length=U+1),zo[U]=Q=so.get(U)),Q}function jT(){var U=new Error;if(!U.stack){try{throw new Error}catch(Q){U=Q}if(!U.stack)return"(no stack trace available)"}return U.stack.toString()}function sp(U,Q){so.set(U,Q),zo[U]=Q}function TC(){Fu("")}function Bd(){return 2147483648}function Ig(U,Q,gt){Me.copyWithin(U,Q,Q+gt)}function rn(U){try{return st.grow(U-Fe.byteLength+65535>>>16),$n(st.buffer),1}catch(Q){}}function Sg(U){var Q=Me.length;U=U>>>0;var gt=Bd();if(U>gt)return!1;for(var $t=1;$t<=4;$t*=2){var he=Q*(1+.2/$t);he=Math.min(he,U+100663296);var xe=Math.min(gt,qe(Math.max(U,he),65536)),oe=rn(xe);if(oe)return!0}return!1}var ip={mappings:{},buffers:[null,[],[]],printChar:function(U,Q){var gt=ip.buffers[U];Q===0||Q===10?((U===1?$:D)(Dt(gt,0)),gt.length=0):gt.push(Q)},varargs:void 0,get:function(){ip.varargs+=4;var U=Qr[ip.varargs-4>>2];return U},getStr:function(U){var Q=qt(U);return Q},get64:function(U,Q){return U}};function _C(U){return 0}function XT(U,Q,gt,$t,he){}function YT(U,Q,gt,$t){for(var he=0,xe=0;xe>2],ee=Qr[Q+4>>2];Q+=8;for(var hr=0;hr>2]=he,0}function EC(U){nt(U)}var Ng=!1,ap={abort:TC,emscripten_get_heap_max:Bd,emscripten_memcpy_big:Ig,emscripten_resize_heap:Sg,fd_close:_C,fd_seek:XT,fd_write:YT,setTempRet0:EC},WW=kC(),ZT=e.___wasm_call_ctors=function(){return(ZT=e.___wasm_call_ctors=e.asm.__wasm_call_ctors).apply(null,arguments)},AC=e._init=function(){return(AC=e._init=e.asm.init).apply(null,arguments)},$C=e._init_with_threads_count=function(){return($C=e._init_with_threads_count=e.asm.init_with_threads_count).apply(null,arguments)},kg=e._get_threads_count=function(){return(kg=e._get_threads_count=e.asm.get_threads_count).apply(null,arguments)},Tg=e._register_tensor=function(){return(Tg=e._register_tensor=e.asm.register_tensor).apply(null,arguments)},DC=e._dispose_data=function(){return(DC=e._dispose_data=e.asm.dispose_data).apply(null,arguments)},Ut=e._dispose=function(){return(Ut=e._dispose=e.asm.dispose).apply(null,arguments)},FC=e._Abs=function(){return(FC=e._Abs=e.asm.Abs).apply(null,arguments)},_g=e._Add=function(){return(_g=e._Add=e.asm.Add).apply(null,arguments)},Ou=e._AddN=function(){return(Ou=e._AddN=e.asm.AddN).apply(null,arguments)},lp=e._All=function(){return(lp=e._All=e.asm.All).apply(null,arguments)},RC=e._Any=function(){return(RC=e._Any=e.asm.Any).apply(null,arguments)},JT=e._ArgMax=function(){return(JT=e._ArgMax=e.asm.ArgMax).apply(null,arguments)},OC=e._AvgPool=function(){return(OC=e._AvgPool=e.asm.AvgPool).apply(null,arguments)},QT=e._BatchMatMul=function(){return(QT=e._BatchMatMul=e.asm.BatchMatMul).apply(null,arguments)},Lu=e._Ceil=function(){return(Lu=e._Ceil=e.asm.Ceil).apply(null,arguments)},LC=e._ClipByValue=function(){return(LC=e._ClipByValue=e.asm.ClipByValue).apply(null,arguments)},PC=e._Conv2D=function(){return(PC=e._Conv2D=e.asm.Conv2D).apply(null,arguments)},MC=e._Conv2DBackpropInput=function(){return(MC=e._Conv2DBackpropInput=e.asm.Conv2DBackpropInput).apply(null,arguments)},zC=e._Cos=function(){return(zC=e._Cos=e.asm.Cos).apply(null,arguments)},BC=e._Cosh=function(){return(BC=e._Cosh=e.asm.Cosh).apply(null,arguments)},VC=e._CropAndResize=function(){return(VC=e._CropAndResize=e.asm.CropAndResize).apply(null,arguments)},Eg=e._Cumprod=function(){return(Eg=e._Cumprod=e.asm.Cumprod).apply(null,arguments)},GC=e._Cumsum=function(){return(GC=e._Cumsum=e.asm.Cumsum).apply(null,arguments)},WC=e._DepthToSpace=function(){return(WC=e._DepthToSpace=e.asm.DepthToSpace).apply(null,arguments)},UC=e._DepthwiseConv2dNative=function(){return(UC=e._DepthwiseConv2dNative=e.asm.DepthwiseConv2dNative).apply(null,arguments)},HC=e._Elu=function(){return(HC=e._Elu=e.asm.Elu).apply(null,arguments)},qC=e._Equal=function(){return(qC=e._Equal=e.asm.Equal).apply(null,arguments)},Ag=e._Exp=function(){return(Ag=e._Exp=e.asm.Exp).apply(null,arguments)},KC=e._FlipLeftRight=function(){return(KC=e._FlipLeftRight=e.asm.FlipLeftRight).apply(null,arguments)},jC=e._Floor=function(){return(jC=e._Floor=e.asm.Floor).apply(null,arguments)},Pu=e._FloorDiv=function(){return(Pu=e._FloorDiv=e.asm.FloorDiv).apply(null,arguments)},Vd=e._FusedBatchNorm=function(){return(Vd=e._FusedBatchNorm=e.asm.FusedBatchNorm).apply(null,arguments)},XC=e._FusedConv2D=function(){return(XC=e._FusedConv2D=e.asm.FusedConv2D).apply(null,arguments)},YC=e._FusedDepthwiseConv2D=function(){return(YC=e._FusedDepthwiseConv2D=e.asm.FusedDepthwiseConv2D).apply(null,arguments)},ZC=e._Gather=function(){return(ZC=e._Gather=e.asm.Gather).apply(null,arguments)},ne=e._GatherNd=function(){return(ne=e._GatherNd=e.asm.GatherNd).apply(null,arguments)},JC=e._Greater=function(){return(JC=e._Greater=e.asm.Greater).apply(null,arguments)},QC=e._GreaterEqual=function(){return(QC=e._GreaterEqual=e.asm.GreaterEqual).apply(null,arguments)},tI=e._LeakyRelu=function(){return(tI=e._LeakyRelu=e.asm.LeakyRelu).apply(null,arguments)},eI=e._Less=function(){return(eI=e._Less=e.asm.Less).apply(null,arguments)},rI=e._LessEqual=function(){return(rI=e._LessEqual=e.asm.LessEqual).apply(null,arguments)},nI=e._Log=function(){return(nI=e._Log=e.asm.Log).apply(null,arguments)},Gd=e._LogicalAnd=function(){return(Gd=e._LogicalAnd=e.asm.LogicalAnd).apply(null,arguments)},$g=e._LogicalNot=function(){return($g=e._LogicalNot=e.asm.LogicalNot).apply(null,arguments)},Dg=e._LogicalOr=function(){return(Dg=e._LogicalOr=e.asm.LogicalOr).apply(null,arguments)},oI=e._LogicalXor=function(){return(oI=e._LogicalXor=e.asm.LogicalXor).apply(null,arguments)},sI=e._Max=function(){return(sI=e._Max=e.asm.Max).apply(null,arguments)},iI=e._MaxPool=function(){return(iI=e._MaxPool=e.asm.MaxPool).apply(null,arguments)},aI=e._Maximum=function(){return(aI=e._Maximum=e.asm.Maximum).apply(null,arguments)},lI=e._Mean=function(){return(lI=e._Mean=e.asm.Mean).apply(null,arguments)},uI=e._Min=function(){return(uI=e._Min=e.asm.Min).apply(null,arguments)},rr=e._Minimum=function(){return(rr=e._Minimum=e.asm.Minimum).apply(null,arguments)},cI=e._MirrorPad=function(){return(cI=e._MirrorPad=e.asm.MirrorPad).apply(null,arguments)},pI=e._Multiply=function(){return(pI=e._Multiply=e.asm.Multiply).apply(null,arguments)},mI=e._Neg=function(){return(mI=e._Neg=e.asm.Neg).apply(null,arguments)},up=e._NonMaxSuppressionV3=function(){return(up=e._NonMaxSuppressionV3=e.asm.NonMaxSuppressionV3).apply(null,arguments)},Fg=e._NonMaxSuppressionV4=function(){return(Fg=e._NonMaxSuppressionV4=e.asm.NonMaxSuppressionV4).apply(null,arguments)},Rg=e._NonMaxSuppressionV5=function(){return(Rg=e._NonMaxSuppressionV5=e.asm.NonMaxSuppressionV5).apply(null,arguments)},Og=e._NotEqual=function(){return(Og=e._NotEqual=e.asm.NotEqual).apply(null,arguments)},fI=e._OneHot=function(){return(fI=e._OneHot=e.asm.OneHot).apply(null,arguments)},Lg=e._PadV2=function(){return(Lg=e._PadV2=e.asm.PadV2).apply(null,arguments)},dI=e._Pow=function(){return(dI=e._Pow=e.asm.Pow).apply(null,arguments)},t1=e._Prelu=function(){return(t1=e._Prelu=e.asm.Prelu).apply(null,arguments)},Pg=e._Prod=function(){return(Pg=e._Prod=e.asm.Prod).apply(null,arguments)},e1=e._RealDiv=function(){return(e1=e._RealDiv=e.asm.RealDiv).apply(null,arguments)},hI=e._Relu=function(){return(hI=e._Relu=e.asm.Relu).apply(null,arguments)},gI=e._Relu6=function(){return(gI=e._Relu6=e.asm.Relu6).apply(null,arguments)},xI=e._ResizeBilinear=function(){return(xI=e._ResizeBilinear=e.asm.ResizeBilinear).apply(null,arguments)},yI=e._ResizeNearestNeighbor=function(){return(yI=e._ResizeNearestNeighbor=e.asm.ResizeNearestNeighbor).apply(null,arguments)},bI=e._Reverse=function(){return(bI=e._Reverse=e.asm.Reverse).apply(null,arguments)},wI=e._RotateWithOffset=function(){return(wI=e._RotateWithOffset=e.asm.RotateWithOffset).apply(null,arguments)},vI=e._Round=function(){return(vI=e._Round=e.asm.Round).apply(null,arguments)},CI=e._Rsqrt=function(){return(CI=e._Rsqrt=e.asm.Rsqrt).apply(null,arguments)},II=e._ScatterNd=function(){return(II=e._ScatterNd=e.asm.ScatterNd).apply(null,arguments)},SI=e._SelectV2=function(){return(SI=e._SelectV2=e.asm.SelectV2).apply(null,arguments)},NI=e._Sigmoid=function(){return(NI=e._Sigmoid=e.asm.Sigmoid).apply(null,arguments)},kI=e._Sin=function(){return(kI=e._Sin=e.asm.Sin).apply(null,arguments)},TI=e._Softmax=function(){return(TI=e._Softmax=e.asm.Softmax).apply(null,arguments)},_I=e._SparseFillEmptyRows=function(){return(_I=e._SparseFillEmptyRows=e.asm.SparseFillEmptyRows).apply(null,arguments)},EI=e._SparseReshape=function(){return(EI=e._SparseReshape=e.asm.SparseReshape).apply(null,arguments)},AI=e._SparseSegmentReduction=function(){return(AI=e._SparseSegmentReduction=e.asm.SparseSegmentReduction).apply(null,arguments)},$I=e._Sqrt=function(){return($I=e._Sqrt=e.asm.Sqrt).apply(null,arguments)},DI=e._Square=function(){return(DI=e._Square=e.asm.Square).apply(null,arguments)},FI=e._SquaredDifference=function(){return(FI=e._SquaredDifference=e.asm.SquaredDifference).apply(null,arguments)},RI=e._Step=function(){return(RI=e._Step=e.asm.Step).apply(null,arguments)},OI=e._StridedSlice=function(){return(OI=e._StridedSlice=e.asm.StridedSlice).apply(null,arguments)},LI=e._Sub=function(){return(LI=e._Sub=e.asm.Sub).apply(null,arguments)},PI=e._Sum=function(){return(PI=e._Sum=e.asm.Sum).apply(null,arguments)},MI=e._Tan=function(){return(MI=e._Tan=e.asm.Tan).apply(null,arguments)},zI=e._Tanh=function(){return(zI=e._Tanh=e.asm.Tanh).apply(null,arguments)},BI=e._Tile=function(){return(BI=e._Tile=e.asm.Tile).apply(null,arguments)},VI=e._TopK=function(){return(VI=e._TopK=e.asm.TopK).apply(null,arguments)},GI=e._Transform=function(){return(GI=e._Transform=e.asm.Transform).apply(null,arguments)},WI=e._Transpose=function(){return(WI=e._Transpose=e.asm.Transpose).apply(null,arguments)},UI=e.__FusedMatMul=function(){return(UI=e.__FusedMatMul=e.asm._FusedMatMul).apply(null,arguments)},HI=e._malloc=function(){return(HI=e._malloc=e.asm.malloc).apply(null,arguments)},qI=e._free=function(){return(qI=e._free=e.asm.free).apply(null,arguments)},KI=e.___errno_location=function(){return(KI=e.___errno_location=e.asm.__errno_location).apply(null,arguments)},jI=e._emscripten_main_thread_process_queued_calls=function(){return(jI=e._emscripten_main_thread_process_queued_calls=e.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},Mg=e.stackSave=function(){return(Mg=e.stackSave=e.asm.stackSave).apply(null,arguments)},zg=e.stackRestore=function(){return(zg=e.stackRestore=e.asm.stackRestore).apply(null,arguments)},Wd=e.stackAlloc=function(){return(Wd=e.stackAlloc=e.asm.stackAlloc).apply(null,arguments)},XI=e.dynCall_iijjiiii=function(){return(XI=e.dynCall_iijjiiii=e.asm.dynCall_iijjiiii).apply(null,arguments)},YI=e.dynCall_jiji=function(){return(YI=e.dynCall_jiji=e.asm.dynCall_jiji).apply(null,arguments)};e.cwrap=bt;var cp;function Ud(U){this.name="ExitStatus",this.message="Program terminated with exit("+U+")",this.status=U}yl=function U(){cp||Hd(),cp||(yl=U)};function Hd(U){if(U=U||a,Hn>0||(hg(),Hn>0))return;function Q(){cp||(cp=!0,e.calledRun=!0,!it&&(gg(),n(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),xg()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),Q()},1)):Q()}e.run=Hd;function r1(U){ft=U,Ld()||(e.onExit&&e.onExit(U),it=!0),l(U,new Ud(U))}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();Hd();var pp;s&&(pp={uncaughtException:process.listeners("uncaughtException").filter(function(U){return!s.uncaughtException.indexOf(U)>-1}),unhandledRejection:process.listeners("unhandledRejection").filter(function(U){return!s.unhandledRejection.indexOf(U)>-1})});var mp;if(typeof t!="undefined")mp=t;else if(typeof WasmBackendModuleThreadedSimd!="undefined")mp=WasmBackendModuleThreadedSimd;else throw new Error("Could not find wasm module in post.js");if(pp){var ZI=mp._dispose;mp._dispose=function(){ZI(),pp.uncaughtException.forEach(function(U){process.removeListener("uncaughtException",U)}),pp.unhandledRejection.forEach(function(U){process.removeListener("unhandledRejection",U)})}}return t.ready}})();typeof vC=="object"&&typeof BT=="object"?BT.exports=zT:typeof define=="function"&&define.amd?define([],function(){return zT}):typeof vC=="object"&&(vC.WasmBackendModule=zT)});var Qi=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}},Uo=class{refCount(t){return qn("refCount")}incRef(t){return qn("incRef")}timerAvailable(){return!0}time(t){return qn("time")}read(t){return qn("read")}readSync(t){return qn("readSync")}readToGPU(t,e){return qn("readToGPU")}numDataIds(){return qn("numDataIds")}disposeData(t,e){return qn("disposeData")}write(t,e,n){return qn("write")}move(t,e,n,o,s){return qn("move")}memory(){return qn("memory")}floatPrecision(){return qn("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return qn("dispose")}};function qn(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 m1(r){let t=r.length,e=0;for(;t>0;)e=Math.random()*t|0,t--,Kg(r,t,e)}function GU(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--,Kg(r,e,n),Kg(t,e,n)}function gp(r,t,e){return Math.max(r,Math.min(t,e))}function WU(r){return r%2===0?r:r+1}function Kg(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}function UU(r){let t=0;for(let e=0;ee+` Shapes ${r} and ${t} must match`)}function Kn(r){A(r!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Ho(r,t=[],e=!1){if(t==null&&(t=[]),Array.isArray(r)||xr(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 JU(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 ur(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=>ta(n)),()=>`All values in axis param must be integers but got axis ${r}`),r.map(n=>n<0?e+n:n)}function s0(r,t){let e=[],n=[],o=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||o?null:ur(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 i0(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 a0(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 l0(r,t){for(let e=0;et+=e.length),t}function qo(r){return typeof r=="string"||r instanceof String}function f1(r){return typeof r=="boolean"}function d1(r){return typeof r=="number"}function xp(r){return Array.isArray(r)?xp(r[0]):r instanceof Float32Array?"float32":r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray?"int32":d1(r)?"float32":qo(r)?"string":f1(r)?"bool":"float32"}function li(r){return!!(r&&r.constructor&&r.call&&r.apply)}function yp(r,t){for(let e=t;e=0;--n)e[n]=e[n+1]*r[n+1];return e}function h1(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 h1(0,r,t,e)}function jd(r,t){let e=bp(r,t);for(let n=0;nn*o,1);if(t==null||t==="float32")return zu(r,new Float32Array(e));if(t==="int32")return zu(r,new Int32Array(e));if(t==="bool")return zu(r,new Uint8Array(e));throw new Error(`Unknown data type ${t}`)}function Xd(r){r.forEach(t=>{A(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${r}].`)})}function e4(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]=i4(o,s)})}};function o4(r){let t={};return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...n)=>(s4(t,n[0],n[1]),n.join("="))),t}function s4(r,t,e){r[decodeURIComponent(t)]=decodeURIComponent(e||"")}function i4(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 B(){return p0}var p0=null;function x1(r){p0=r}var m0;function f0(){if(m0==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");m0=r}return m0}function a4(){let r=f0();return r._tfGlobals==null&&(r._tfGlobals=new Map),r._tfGlobals}function Jd(r,t){let e=a4();if(e.has(r))return e.get(r);{let n=t();return e.set(r,n),e.get(r)}}var ci="Abs",ea="Acos",ra="Acosh",jn="Add",Ko="AddN",na="All",oa="Any",jo="ArgMax",Cl="ArgMin",sa="Asin",ia="Asinh",aa="Atan",la="Atanh",ua="Atan2",Xo="AvgPool",wp="AvgPoolGrad",Il="AvgPool3D",vp="AvgPool3DGrad",Yo="BatchMatMul",pi="BatchToSpaceND",Cp="Bincount",y1="BroadcastTo",Ip="BroadcastArgs",io="Cast",Zo="Ceil",ao="ClipByValue",Sp="Complex",Sl="ComplexAbs",mi="Concat",Jo="Conv2D",Np="Conv2DBackpropFilter",Qo="Conv2DBackpropInput",Nl="Conv3D",kp="Conv3DBackpropFilterV2",Tp="Conv3DBackpropInputV2",ts="Cos",es="Cosh",ca="Cumprod",rs="Cumsum",pa="CropAndResize",_p="DenseBincount",ma="DepthToSpace",ns="DepthwiseConv2dNative",Ep="DepthwiseConv2dNativeBackpropFilter",Ap="DepthwiseConv2dNativeBackpropInput",$p="Diag",kl="Dilation2D",Qd="Dilation2DBackpropInput",th="Dilation2DBackpropFilter",os="RealDiv",Dp="Einsum",ss="Elu",Fp="EluGrad",fa="Erf",da="Equal",is="Exp",fi="ExpandDims",ha="Expm1",Rp="FFT",Tl="Fill",ga="FlipLeftRight",as="Floor",ls="FloorDiv",us="FusedBatchNorm",di="GatherV2",xa="GatherNd",ya="Greater",cs="GreaterEqual",lo="Identity",Op="IFFT",Lp="Imag",ba="IsFinite",wa="IsInf",va="IsNan",ps="LeakyRelu",Ca="Less",Ia="LessEqual",Pp="LinSpace",ms="Log",Sa="Log1p",Na="LogicalAnd",ka="LogicalNot",Ta="LogicalOr",b1="LogicalXor",w1="LogSoftmax",Qat="LowerBound",_l="LRN",Mp="LRNGrad",fs="Max",ds="Maximum",hs="MaxPool",zp="MaxPoolGrad",El="MaxPool3D",Bp="MaxPool3DGrad",Vp="MaxPoolWithArgmax",gs="Mean",xs="Min",ys="Minimum",bs="MirrorPad",_a="Mod",Gp="Multinomial",ws="Multiply",hi="Neg",Ea="NotEqual",Aa="NonMaxSuppressionV3",$a="NonMaxSuppressionV4",Da="NonMaxSuppressionV5",gi="OnesLike",vs="OneHot",xi="Pack",Cs="PadV2",tlt="Pool",Is="Pow",Ss="Prelu",Ns="Prod",Al="Range",Wp="Real",Fa="Reciprocal",ks="Relu",yi="Reshape",Ts="ResizeNearestNeighbor",Up="ResizeNearestNeighborGrad",_s="ResizeBilinear",Hp="ResizeBilinearGrad",Es="Relu6",As="Reverse",$s="Round",Ds="Rsqrt",Ra="ScatterNd",qp="SearchSorted",bi="Select",Oa="Selu",wi="Slice",Fs="Sin",La="Sinh",Pa="Sign",Rs="Sigmoid",Ma="Softplus",Os="Sqrt",Ls="Sum",vi="SpaceToBatchND",Ci="SplitV",Ps="Softmax",$l="SparseFillEmptyRows",za="SparseReshape",Dl="SparseSegmentMean",Fl="SparseSegmentSum",Kp="SparseToDense",Ms="SquaredDifference",Rl="Square",Ba="StridedSlice",Ol="StringNGrams",Ll="StringSplit",Pl="StringToHashBucketFast",zs="Sub",Bs="Tan",Vs="Tanh",Xn="Tile",Va="TopK",Ga="Transform",Yn="Transpose",jp="Unique",Ii="Unpack",Ml="UnsortedSegmentSum",elt="UpperBound",Si="ZerosLike",uo="Step",eh="FromPixels",Wa="RotateWithOffset",Ni="_FusedMatMul",ki="FusedConv2D",Ti="FusedDepthwiseConv2D";function _i(...r){B().getBool("IS_TEST")||B().getBool("PROD")||console.warn(...r)}function l4(...r){B().getBool("IS_TEST")||B().getBool("PROD")||console.log(...r)}var Xp=Jd("kernelRegistry",()=>new Map),rh=Jd("gradRegistry",()=>new Map);function nh(r,t){let e=h0(r,t);return Xp.get(e)}function d0(r){return rh.get(r)}function Xg(r){let t=Xp.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 Vu(r){let{kernelName:t,backendName:e}=r,n=h0(t,e);Xp.has(n)&&_i(`The kernel '${t}' for backend '${e}' is already registered`),Xp.set(n,r)}function C1(r){let{kernelName:t}=r;rh.has(t)&&B().getBool("DEBUG")&&_i(`Overriding the gradient for '${t}'`),rh.set(t,r)}function ilt(r,t){let e=h0(r,t);if(!Xp.has(e))throw new Error(`The kernel '${r}' for backend '${t}' is not registered`);Xp.delete(e)}function alt(r){if(!rh.has(r))throw new Error(`The gradient '${r}' for backend is not registered`);rh.delete(r)}function llt(r,t){Xg(r).forEach(n=>{let o=Object.assign({},n,{backendName:t});Vu(o)})}function h0(r,t){return`${t}_${r}`}var x={};jt(x,{arraysEqual:()=>Fn,assert:()=>A,assertNonNegativeIntegerDimensions:()=>Xd,assertNonNull:()=>Kn,assertShapesMatch:()=>Re,bytesFromStringArray:()=>c0,bytesPerElement:()=>jg,checkConversionForErrors:()=>l0,clamp:()=>gp,computeStrides:()=>ui,createScalarValue:()=>h4,createShuffledIndices:()=>YU,decodeString:()=>Qp,distSquared:()=>qU,encodeString:()=>Bl,fetch:()=>x4,fingerPrint64:()=>d4,flatten:()=>Ho,getArrayFromDType:()=>a0,getTypedArrayFromDType:()=>i0,hasEncodingLoss:()=>QU,hexToLong:()=>oh,indexToLoc:()=>r4,inferDtype:()=>xp,inferFromImplicitShape:()=>JU,isBoolean:()=>f1,isFunction:()=>li,isInt:()=>ta,isNumber:()=>d1,isPromise:()=>Yd,isScalarShape:()=>KU,isString:()=>qo,isTypedArray:()=>xr,isValidDtype:()=>u0,locToIndex:()=>e4,makeOnesTypedArray:()=>jd,makeZerosNestedTypedArray:()=>t4,makeZerosTypedArray:()=>bp,nearestDivisor:()=>yp,nearestLargerEven:()=>WU,now:()=>qu,parseAxisParam:()=>ur,randUniform:()=>HU,repeatedTry:()=>ZU,rightPad:()=>Bu,shuffle:()=>m1,shuffleCombo:()=>GU,sizeFromShape:()=>Qt,sizeToSquarishShape:()=>XU,squeezeShape:()=>s0,sum:()=>UU,swap:()=>Kg,tanh:()=>jU,toNestedArray:()=>zu,toTypedArray:()=>Jp});var b0=vl(F1());var Hu=b0.default||b0;function oh(r){return Hu.fromString(r,!0,16)}var O1=oh("c3a5c85c97cb3127"),Uu=oh("b492b66fbe98f273"),on=oh("9ae16a3b2f90404f");function y0(r){return r.xor(r.shru(47))}function L1(r,t,e){let n=r.slice(t,t+e);return Hu.fromBytes(Array.from(n),!0,!0)}function ze(r,t){return L1(r,t,8)}function R1(r,t){return L1(r,t,4)}function Tr(r,t){return t===0?r:r.shru(t).or(r.shl(64-t))}function zl(r,t,e=oh("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 c4(r,t,e,n,o,s){o=o.add(r),s=Tr(s.add(o).add(n),21);let i=o;return o=o.add(t),o=o.add(e),s=s.add(Tr(o,44)),[o.add(n),s.add(i)]}function Zg(r,t,e,n){return c4(ze(r,t),ze(r,t+8),ze(r,t+16),ze(r,t+24),e,n)}function p4(r,t=r.length){if(t>=8){let e=on.add(t*2),n=ze(r,0).add(on),o=ze(r,t-8),s=Tr(o,37).mul(e).add(n),i=Tr(n,25).add(o).mul(e);return zl(s,i,e)}if(t>=4){let e=on.add(t*2),n=R1(r,0);return zl(n.shl(3).add(t),R1(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 y0(on.mul(s).xor(O1.mul(i))).mul(on)}return on}function m4(r,t=r.length){let e=on.add(t*2),n=ze(r,0).mul(Uu),o=ze(r,8),s=ze(r,t-8).mul(e),i=ze(r,t-16).mul(on);return zl(Tr(n.add(o),43).add(Tr(s,30)).add(i),n.add(Tr(o.add(on),18)).add(s),e)}function f4(r,t=r.length){let e=on.add(t*2),n=ze(r,0).mul(on),o=ze(r,8),s=ze(r,t-8).mul(e),i=ze(r,t-16).mul(on),a=Tr(n.add(o),43).add(Tr(s,30)).add(i),u=zl(a,n.add(Tr(o.add(on),18)).add(s),e),l=ze(r,16).mul(e),c=ze(r,24),p=a.add(ze(r,t-32)).mul(e),m=u.add(ze(r,t-24)).mul(e);return zl(Tr(l.add(c),43).add(Tr(p,30)).add(m),l.add(Tr(c.add(n),18)).add(p),e)}function d4(r,t=r.length){let e=Hu.fromNumber(81,!0);if(t<=32)return t<=16?p4(r,t):m4(r,t);if(t<=64)return f4(r,t);let n=e,o=e.mul(Uu).add(113),s=y0(o.mul(on).add(113)).mul(on),i=[Hu.UZERO,Hu.UZERO],a=[Hu.UZERO,Hu.UZERO];n=n.mul(on).add(ze(r,0));let u=0,l=(t-1>>6)*64,c=l+(t-1&63)-63;do n=Tr(n.add(o).add(i[0]).add(ze(r,u+8)),37).mul(Uu),o=Tr(o.add(i[1]).add(ze(r,u+48)),42).mul(Uu),n=n.xor(a[1]),o=o.add(i[0]).add(ze(r,u+40)),s=Tr(s.add(a[0]),33).mul(Uu),i=Zg(r,u,i[1].mul(Uu),n.add(a[0])),a=Zg(r,u+32,s.add(a[1]),o.add(ze(r,u+16))),[s,n]=[n,s],u+=64;while(u!==l);let p=Uu.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=Tr(n.add(o).add(i[0]).add(ze(r,u+8)),37).mul(p),o=Tr(o.add(i[1]).add(ze(r,u+48)),42).mul(p),n=n.xor(a[1].mul(9)),o=o.add(i[0].mul(9).add(ze(r,u+40))),s=Tr(s.add(a[0]),33).mul(p),i=Zg(r,u,i[1].mul(p),n.add(a[0])),a=Zg(r,u+32,s.add(a[1]),o.add(ze(r,u+16))),[s,n]=[n,s],zl(zl(i[0],a[0],p).add(y0(o).mul(O1)).add(s),zl(i[1],a[1],p).add(n),p)}function h4(r,t){return t==="string"?Bl(r):Jp([r],t)}function g4(r,t){return r instanceof Float32Array&&t==="float32"||r instanceof Int32Array&&t==="int32"||r instanceof Uint8Array&&t==="bool"}function Jp(r,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(r)&&(r=Ho(r)),B().getBool("DEBUG")&&l0(r,t),g4(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=qu();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(s);else{s();for(let l of o)l.dataSync();i=Promise.resolve({kernelMs:qu()-a})}if(B().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l{y4(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 y4(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 P1(r,t,e){let n={},o={};for(let u=0;un[h.id]=!0),f=!0,o[l.id]=!0;break}if(f)break}}let s={};s[e.id]=!0;let i={};for(let u=r.length-1;u>=0;u--){let l=r[u],c=l.inputs;for(let p=0;p=0;o--){let s=t[o],i=[];if(s.outputs.forEach(u=>{let l=r[u.id];l!=null?i.push(l):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let a=s.gradient(i);for(let u in s.inputs){if(!(u in a))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(a)}.`);let l=e(()=>a[u]());if(l.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`);let c=s.inputs[u];if(!Fn(l.shape,c.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`);if(r[c.id]==null)r[c.id]=l;else{let p=r[c.id];r[c.id]=n(p,l),p.dispose()}}}}var z1=20,sh=3,v0=7;function B1(r,t,e,n){let o=ui(t),s=b4(r,t,e,o),i=t.length,a=Qg(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 b4(r,t,e,n){let o=Qt(t),s=n[n.length-1],i=new Array(s).fill(0),a=t.length,u=e==="complex64"?ah(r):r;if(a>1)for(let l=0;lz1){let g=sh*i,y=Array.from(r.slice(0,g)),b=Array.from(r.slice((a-sh)*i,a*i));return e==="complex64"&&(y=ah(y),b=ah(b)),["["+y.map((w,v)=>ih(w,o[v],e)).join(", ")+", ..., "+b.map((w,v)=>ih(w,o[a-sh+v],e)).join(", ")+"]"]}let h=e==="complex64"?ah(r):Array.from(r);return["["+h.map((g,y)=>ih(g,o[y],e)).join(", ")+"]"]}let l=t.slice(1),c=n.slice(1),p=n[0]*i,m=[];if(a>z1){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||a0(e,this.size),this.strides=ui(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;oQp(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataToGPU(t){return this.throwIfDisposed(),Ws().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();let t=Ws().readSync(this.dataId);if(this.dtype==="string")try{return t.map(e=>Qp(e))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t}async bytes(){this.throwIfDisposed();let t=await Ws().read(this.dataId);return this.dtype==="string"?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(Ws().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return tm.print(this,t)}clone(){return this.throwIfDisposed(),tm.clone(this)}toString(t=!1){let e=this.dataSync();return B1(e,this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),tm.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),Ws().makeVariable(this,t,e,n)}};Object.defineProperty(Pt,Symbol.hasInstance,{value:r=>!!r&&r.data!=null&&r.dataSync!=null&&r.throwIfDisposed!=null});function P(){return Jd("Tensor",()=>Pt)}P();var Ua=class extends Pt{constructor(t,e,n,o){super(t.shape,t.dtype,t.dataId,o),this.trainable=e,this.name=n}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);if(!Fn(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);Ws().disposeTensor(this),this.dataId=t.dataId,Ws().incRef(this,null)}dispose(){Ws().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Ua,Symbol.hasInstance,{value:r=>r instanceof Pt&&r.assign!=null&&r.assign instanceof Function});var fo={};jt(fo,{assertTypesMatch:()=>T0,getTensorsInContainer:()=>lh,isTensorInList:()=>C4,makeTypesMatch:()=>Xt});var C0;(function(r){r.R0="R0",r.R1="R1",r.R2="R2",r.R3="R3",r.R4="R4",r.R5="R5",r.R6="R6"})(C0||(C0={}));var I0;(function(r){r.float32="float32",r.int32="int32",r.bool="int32",r.complex64="complex64"})(I0||(I0={}));var S0;(function(r){r.float32="float32",r.int32="int32",r.bool="bool",r.complex64="complex64"})(S0||(S0={}));var N0;(function(r){r.float32="float32",r.int32="float32",r.bool="float32",r.complex64="complex64"})(N0||(N0={}));var k0;(function(r){r.float32="complex64",r.int32="complex64",r.bool="complex64",r.complex64="complex64"})(k0||(k0={}));var v4={float32:N0,int32:I0,bool:S0,complex64:k0};function ir(r,t){if(r==="string"||t==="string"){if(r==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${r} with ${t}`)}return v4[r][t]}function Ku(r){return ir(r,"int32")}function Xt(r,t){if(r.dtype===t.dtype)return[r,t];let e=ir(r.dtype,t.dtype);return[r.cast(e),t.cast(e)]}function T0(r,t){A(r.dtype===t.dtype,()=>`The dtypes of the first(${r.dtype}) and second(${t.dtype}) input must match`)}function C4(r,t){return t.some(e=>e.id===r.id)}function lh(r){let t=[];return H1(r,t,new Set),t}function H1(r,t,e){if(r==null)return;if(r instanceof Pt){t.push(r);return}if(!I4(r))return;let n=r;for(let o in n){let s=n[o];e.has(s)||(e.add(s),H1(s,t,e))}}function I4(r){return Array.isArray(r)||typeof r=="object"}function _0(r){return r.kernelName!=null}var tx=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()}},Vl=class{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new tx}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){Xg(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 Uo)&&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 Vl.nextTensorId++}nextVariableId(){return Vl.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,!(nh(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=_0(t)?t.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(_0(t)){let{kernelName:d,inputs:h,attrs:g}=t;this.backendName==null&&this.backend;let y=nh(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(N=>N.rank!=null?N:this.makeTensorFromTensorInfo(N));if(o){let N=this.getTensorsForGradient(d,h,v);n=this.saveTensorsForBackwardMode(N)}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=_0(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=d0(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"&&qo(t[0])&&(s=t.map(u=>Bl(u)));let i=o.write(s,e,n),a=new Pt(e,n,i,this.nextTensorId());if(this.trackTensor(a,o),n==="string"){let u=this.state.tensorInfo.get(i),l=c0(s);this.state.numBytes+=l-u.bytes,u.bytes=l}return a}makeTensorFromDataId(t,e,n,o){n=n||"float32";let s={dataId:t,shape:e,dtype:n};return this.makeTensorFromTensorInfo(s,o)}makeTensorFromTensorInfo(t,e){let{dataId:n,shape:o,dtype:s}=t,i=new Pt(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 Ua(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*jg(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 Ua||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*jg(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=d0(t);u!=null&&(o=u.gradFunc),o!=null&&(a.gradient=l=>(l=l.map((c,p)=>{if(c==null){let m=n[p],f=bp(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=lh(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 Pt,()=>"The result y returned by f() must be a tensor.");let i=P1(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?S4(s.shape):n,M1(a,i,l=>this.tidy(l),N4);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(li(t),()=>"The f passed in customGrad(f) must be a function."),(...e)=>{A(e.every(a=>a instanceof Pt),()=>"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 Pt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),A(li(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 Pt),()=>"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=qu(),n=await this.backend.time(t);return n.wallMs=qu()-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 tx;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}};Vl.nextTensorId=0;Vl.nextVariableId=0;function S4(r){let t=jd(Qt(r),"float32");return _.makeTensor(t,r,"float32")}function E0(){let r=f0();if(r._tfengine==null){let t=new Zd(r);r._tfengine=new Vl(t)}return x1(r._tfengine.ENV),G1(()=>r._tfengine),r._tfengine}var _=E0();function N4(r,t){let e={a:r,b:t};return _.runKernel(jn,e)}var Gl={};jt(Gl,{isBrowser:()=>$0,isMobile:()=>_4,mockIsMobile:()=>T4});function k4(){return typeof navigator!="undefined"&&navigator!=null}var A0;function T4(r){A0=r}function _4(r){if(A0!==void 0)return A0;if(r||k4()){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 $0(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var ho=B();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",()=>$0());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 Lr(r,t){let e=r;if(xr(r))return t==="string"?[]:[r.length];if(!Array.isArray(r))return[];let n=[];for(;Array.isArray(e)||xr(e)&&t!=="string";)n.push(e.length),e=e[0];return Array.isArray(r)&&B().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&K1(r,n,[]),n}function K1(r,t,e){if(e=e||[],!Array.isArray(r)&&!xr(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),q1(n,o,t,e),r==null||!xr(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=Lr(r,o);!xr(r)&&!Array.isArray(r)&&(r=[r]);let a=o!=="string"?Jp(r,o):Ho(r,[],!0);return _.makeTensor(a,s,o)}function Ha(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)=>I(s,`${t}[${i}]`,e,n))}var D0="__op";function k(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+D0;let o=(...s)=>{_.startScope(e);try{let i=n(...s);return Yd(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 E4(r,t){let e=I(r,"real","complex"),n=I(t,"imag","complex");Re(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(Sp,o)}var vn=k({complex_:E4});function sn(r,t,e,n){if(n==null&&(n=xp(r)),n==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!xr(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){Xd(t);let o=Qt(t),s=Qt(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!xr(r)&&!Array.isArray(r)&&(r=[r]),t=t||e,r=n!=="string"?Jp(r,n):Ho(r,[],!0),_.makeTensor(r,t,n)}function Cr(r,t,e){let n=Lr(r,e);return sn(r,t,n,e)}var uh={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};var ex=4;async function X1(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)+ex*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 F0=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function j1(r){return F0?Buffer.byteLength(r):new Blob([r]).size}function Y1(r){if(F0)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 R0(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 nx(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 rm(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 Ei(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:j1(JSON.stringify(r.modelTopology)),weightSpecsBytes:r.weightSpecs==null?0:j1(JSON.stringify(r.weightSpecs)),weightDataBytes:r.weightData==null?0:r.weightData.byteLength}}function $4(){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 D4(){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 F4(){let r=new Uint32Array(64);for(let t=0;t<64;t++)r[t]=1024;return r[0]=r[32]=0,r}function R4(){let r=$4(),t=D4(),e=F4();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 Ie=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Ie.instance==null&&(Ie.instance=new Ie),Ie.instance}static registerSaveRouter(t){Ie.getInstance().saveRouters.push(t)}static registerLoadRouter(t){Ie.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return Ie.getHandlers(t,"save")}static getLoadHandlers(t,e){return Ie.getHandlers(t,"load",e)}static getHandlers(t,e,n){let o=[];return(e==="load"?Ie.getInstance().loadRouters:Ie.getInstance().saveRouters).forEach(i=>{let a=i(t,n);a!==null&&o.push(a)}),o}},J1=r=>Ie.registerSaveRouter(r),Q1=r=>Ie.registerLoadRouter(r),t_=r=>Ie.getSaveHandlers(r),e_=(r,t)=>Ie.getLoadHandlers(r,t);var O0="tensorflowjs",L0=1,ju="models_store",Wl="model_info_store";function r_(){if(!B().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 P0(r){let t=r.result;t.createObjectStore(ju,{keyPath:"modelPath"}),t.createObjectStore(Wl,{keyPath:"modelPath"})}var Ai=class{constructor(t){if(this.indexedDB=r_(),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(O0,L0);s.onupgradeneeded=()=>P0(s),s.onsuccess=()=>{let i=s.result;if(e==null){let a=i.transaction(ju,"readonly"),l=a.objectStore(ju).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=Ei(e),u=i.transaction(Wl,"readwrite"),l=u.objectStore(Wl),c=l.put({modelPath:this.modelPath,modelArtifactsInfo:a}),p;c.onsuccess=()=>{p=i.transaction(ju,"readwrite");let f=p.objectStore(ju).put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:a});f.onsuccess=()=>n({modelArtifactsInfo:a}),f.onerror=d=>{l=u.objectStore(Wl);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)})}};Ai.URL_SCHEME="indexeddb://";var n_=r=>B().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Ai.URL_SCHEME)?O4(r.slice(Ai.URL_SCHEME.length)):null;Ie.registerSaveRouter(n_);Ie.registerLoadRouter(n_);function O4(r){return new Ai(r)}function L4(r){return r.startsWith(Ai.URL_SCHEME)?r.slice(Ai.URL_SCHEME.length):r}var ox=class{constructor(){this.indexedDB=r_()}async listModels(){return new Promise((t,e)=>{let n=this.indexedDB.open(O0,L0);n.onupgradeneeded=()=>P0(n),n.onsuccess=()=>{let o=n.result,s=o.transaction(Wl,"readonly"),a=s.objectStore(Wl).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=L4(t),new Promise((e,n)=>{let o=this.indexedDB.open(O0,L0);o.onupgradeneeded=()=>P0(o),o.onsuccess=()=>{let s=o.result,i=s.transaction(Wl,"readwrite"),a=i.objectStore(Wl),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(ju,"readwrite");let f=l.objectStore(ju).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 qa="/",nm="tensorflowjs_models",o_="info",P4="model_topology",M4="weight_specs",z4="weight_data",B4="model_metadata";function s_(r){return{info:[nm,r,o_].join(qa),topology:[nm,r,P4].join(qa),weightSpecs:[nm,r,M4].join(qa),weightData:[nm,r,z4].join(qa),modelMetadata:[nm,r,B4].join(qa)}}function i_(r){for(let t of Object.values(r))window.localStorage.removeItem(t)}function V4(r){let t=r.split(qa);if(t.length<3)throw new Error(`Invalid key format: ${r}`);return t.slice(1,t.length-1).join(qa)}function G4(r){return r.startsWith($i.URL_SCHEME)?r.slice($i.URL_SCHEME.length):r}var $i=class{constructor(t){if(!B().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=s_(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=Ei(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,Y1(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 i_(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=Z1(i),e}};$i.URL_SCHEME="localstorage://";var a_=r=>B().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith($i.URL_SCHEME)?W4(r.slice($i.URL_SCHEME.length)):null;Ie.registerSaveRouter(a_);Ie.registerLoadRouter(a_);function W4(r){return new $i(r)}var sx=class{constructor(){A(B().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=nm+qa,n=qa+o_;for(let o=0;o"scheme must not be undefined or null."),t.endsWith(om)&&(t=t.slice(0,t.indexOf(om))),A(t.length>0,()=>"scheme must not be an empty string.");let n=_r.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=_r.getInstance().managers[t];if(e==null)throw new Error(`Cannot find model manager for scheme '${t}'`);return e}static getSchemes(){return Object.keys(_r.getInstance().managers)}};function ix(r){if(r.indexOf(om)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${_r.getSchemes().join(",")}`);return{scheme:r.split(om)[0],path:r.split(om)[1]}}async function l_(r,t,e=!1){A(r!==t,()=>`Old path and new path are the same: '${r}'`);let n=Ie.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=Ie.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=ix(r).scheme,u=ix(r).path,l=a===ix(r).scheme,c=await o.load();e&&l&&await _r.getManager(a).removeModel(u);let p=await i.save(c);return e&&!l&&await _r.getManager(a).removeModel(u),p.modelArtifactsInfo}async function u_(){let r=_r.getSchemes(),t={};for(let e of r){let n=await _r.getManager(e).listModels();for(let o in n){let s=e+om+o;t[s]=n[o]}}return t}async function c_(r){let t=ix(r);return _r.getManager(t.scheme).removeModel(t.path)}async function p_(r,t){return l_(r,t,!1)}async function m_(r,t){return l_(r,t,!0)}var M0=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(B().get("IS_BROWSER")){B().setPlatform("browser",new M0);try{_r.registerManager($i.URL_SCHEME,new sx)}catch(r){}try{_r.registerManager(Ai.URL_SCHEME,new ox)}catch(r){}}var U4={importFetch:()=>f_()},z0;var B0=class{constructor(){this.util=d_(),this.textEncoder=new this.util.TextEncoder}fetch(t,e){return B().global.fetch!=null?B().global.fetch(t,e):(z0==null&&(z0=U4.importFetch()),z0(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)}};B().get("IS_NODE")&&!B().get("IS_BROWSER")&&B().setPlatform("node",new B0);function Ct(r,t="float32",e){return t=t||"float32",Xd(r),new fe(r,t,e)}function H4(r,t){let e=I(r,"x","cast");if(!u0(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 tt=k({cast_:H4});function q4(r){let e={x:I(r,"x","clone","string_or_numeric")};return _.runKernel(lo,e)}var an=k({clone_:q4});function ax(r,t=!1){console.log(r.toString(t))}E0();var K4={buffer:Ct,cast:tt,clone:an,print:ax};W1(K4);var Cn={};jt(Cn,{browserFiles:()=>g_,browserHTTPRequest:()=>b_,concatenateArrayBuffers:()=>em,copyModel:()=>p_,decodeWeights:()=>rx,encodeWeights:()=>X1,fromMemory:()=>w_,fromMemorySync:()=>q0,getLoadHandlers:()=>e_,getModelArtifactsForJSON:()=>rm,getModelArtifactsInfoForJSON:()=>Ei,getSaveHandlers:()=>t_,http:()=>ux,isHTTPScheme:()=>lx,listModels:()=>u_,loadWeights:()=>x_,moveModel:()=>m_,registerLoadRouter:()=>Q1,registerSaveRouter:()=>J1,removeModel:()=>c_,weightsLoaderFactory:()=>U0,withSaveHandler:()=>v_,withSaveHandlerSync:()=>C_});var j4="model",X4=".json",Y4=".weights.bin";function h_(r){return new Promise(t=>setTimeout(t)).then(r)}var Ka=class{constructor(t){if(!B().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(Ka.URL_SCHEME)&&(t=t.slice(Ka.URL_SCHEME.length)),(t==null||t.length===0)&&(t=j4),this.modelJsonFileName=t+X4,this.weightDataFileName=t+Y4}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=nx(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 h_(()=>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 h_(()=>a.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Ei(t)}}}};Ka.URL_SCHEME="downloads://";var V0=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=rm(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,em(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=>R0(s.name)),o={};for(let s of t)s.paths.forEach(i=>{let a=R0(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}},Z4=r=>B().getBool("IS_BROWSER")&&!Array.isArray(r)&&r.startsWith(Ka.URL_SCHEME)?J4(r.slice(Ka.URL_SCHEME.length)):null;Ie.registerSaveRouter(Z4);function J4(r="model"){return new Ka(r)}function g_(r){return new V0(r)}function G0(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 W0(r,t){t==null&&(t={});let e=t.fetchFunc==null?B().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 G0(n,t.onProgress,o,s)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(a):await G0(a,t.onProgress,u,l)}async function x_(r,t="",e,n){return U0(i=>W0(i,{requestInit:n}))(r,t,e)}function U0(r){return async(t,e="",n)=>{let o=t.map(()=>!1),s={},i=n!=null?n.map(()=>!1):[],a=[];if(t.forEach((f,d)=>{let h=0;f.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,b=uh[y]*Qt(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,N)=>{v===g.name&&(w(),i[N]=!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 N=g.slice(v.groupOffset,v.groupOffset+v.sizeBytes),E=rx(N,[v.manifestEntry]);for(let $ in E)p[$]=E[$]}),m+=d}),p}}var Q4="application/octet-stream",tH="application/json",ch=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=B().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=nx(t,n);e.body.append("model.json",new Blob([JSON.stringify(o)],{type:tH}),"model.json"),t.weightData!=null&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:Q4}),"model.weights.bin");let s=await this.fetch(this.path,e);if(s.ok)return{modelArtifactsInfo:Ei(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 rm(e,s=>this.loadWeights(s))}async loadWeights(t){let e=Array.isArray(this.path)?this.path[1]:this.path,[n,o]=eH(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 W0(a,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[i,em(l)]}};ch.URL_SCHEME_REGEX=/^https?:\/\//;function eH(r){let t=r.lastIndexOf("/"),e=r.lastIndexOf("?"),n=r.substring(0,t),o=e>t?r.substring(e):"";return[n+"/",o]}function lx(r){return r.match(ch.URL_SCHEME_REGEX)!=null}var y_=(r,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let e=!0;if(Array.isArray(r)?e=r.every(n=>lx(n)):e=lx(r),e)return ux(r,t)}return null};Ie.registerSaveRouter(y_);Ie.registerLoadRouter(y_);function ux(r,t){return new ch(r,t)}function b_(r,t){return ux(r,t)}var ph=class{constructor(t){this.modelArtifacts=t}load(){return this.modelArtifacts}},cx=class{constructor(t){this.saveHandler=t}save(t){return this.saveHandler(t)}},H0=class{constructor(t){t.load&&(this.load=()=>Promise.resolve(t.load())),t.save&&(this.save=e=>Promise.resolve(t.save(e)))}};function w_(r,t,e,n){let o=arguments;return new H0(q0(...o))}function q0(r,t,e,n){return arguments.length===1?r.modelTopology!=null||r.weightSpecs!=null?new ph(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 ph({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 ph({modelTopology:r,weightSpecs:t,weightData:e,trainingConfig:n}))}function v_(r){return new cx(r)}function C_(r){return new cx(r)}var N_={};jt(N_,{confusionMatrix:()=>S_});function rH(r,t,e=!1,n=!1){let o=I(r,"a","matMul"),s=I(t,"b","matMul");[o,s]=Xt(o,s);let i={a:o,b:s},a={transposeA:e,transposeB:n};return _.runKernel(Yo,i,a)}var Gt=k({matMul_:rH});function nH(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:I(r,"indices","oneHot","int32")},i={depth:t,onValue:e,offValue:n};return _.runKernel(vs,s,i)}var Di=k({oneHot_:nH});function Yct(){B().set("PROD",!0)}function Zct(){B().set("DEBUG",!0)}function Jct(){B().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function K0(r){B().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(r+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}U1(K0);function Qct(){_.disposeVariables()}function go(){return _}function mh(){return _.memory()}function tpt(r){return _.profile(r)}function W(r,t){return _.tidy(r,t)}function _t(r){lh(r).forEach(e=>e.dispose())}function Oe(r){return _.keep(r)}function ept(r){return _.time(r)}function oH(r){return _.setBackend(r)}function rpt(){return _.ready()}function npt(){return _.backendName}function opt(r){_.removeBackend(r)}function spt(r){return _.findBackend(r)}function ipt(r){return _.findBackendFactory(r)}function sm(r,t,e=1){return _.registerBackend(r,t,e)}function I_(){return _.backend}function apt(r,t){B().setPlatform(r,t)}function sH(r){let e={input:I(r,"input","imag")};return _.runKernel(Lp,e)}var Ul=k({imag_:sH});function iH(r){let e={x:I(r,"x","neg")};return _.runKernel(hi,e)}var Yt=k({neg_:iH});function aH(r){let e={input:I(r,"input","real")};return _.runKernel(Wp,e)}var ja=k({real_:aH});function lH(r,t,e){let n=I(r,"x","transpose");if(t==null&&(t=n.shape.map((i,a)=>a).reverse()),A(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(i=>{A(i>=0&&i`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let o={x:n},s={perm:t};return n.dtype==="complex64"?W(()=>{let i=ja(n),a=Ul(n);return i=_.runKernel(Yn,{x:i},s),a=_.runKernel(Yn,{x:a},s),e&&(a=Yt(a)),vn(i,a)}):_.runKernel(Yn,o,s)}var Mt=k({transpose_:lH});function uH(r,t,e){let n=I(r,"labels","confusionMatrix"),o=I(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=Di(tt(n,"int32"),e),i=Di(tt(o,"int32"),e),a=Mt(s),u=Gt(a,i);return tt(u,"int32")}var S_=k({confusionMatrix_:uH});var Pr={};jt(Pr,{assertAndGetBroadcastShape:()=>zt,getBroadcastDims:()=>k_,getReductionAxes:()=>ye});function k_(r,t){let e=r.length,n=[];for(let o=0;o1&&i===1&&n.unshift(s)}return n}function ye(r,t){let e=[];for(let n=0;n1)&&e.unshift(s)}return e}function zt(r,t){let e=[],n=Math.max(r.length,t.length);for(let o=0;ogH,fromPixelsAsync:()=>dH,toPixels:()=>hH});function px(r,t,e){if(Kn(r),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let n=Lr(r,e);if(n.length!==3&&n.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(n.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return sn(r,t,n,e)}var Xu;function T_(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