UNPKG

facezk-core

Version:

ZKP-AI Proof of Humanity: Live Selfie Check with Biometric Template Extraction and Fuzzy Hashing

5 lines 1.79 MB
var l_=Object.create;var ly=Object.defineProperty;var u_=Object.getOwnPropertyDescriptor;var c_=Object.getOwnPropertyNames;var p_=Object.getPrototypeOf,m_=Object.prototype.hasOwnProperty;var Hr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),to=(r,t)=>{for(var e in t)ly(r,e,{get:t[e],enumerable:!0})},f_=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c_(t))!m_.call(r,n)&&n!==e&&ly(r,n,{get:()=>t[n],enumerable:!(o=u_(t,n))||o.enumerable});return r};var Rc=(r,t,e)=>(e=r!=null?l_(p_(r)):{},f_(t||!r||!r.__esModule?ly(e,"default",{value:r,enumerable:!0}):e,r));var _C=Hr((bX,FC)=>{"use strict";FC.exports=fe;var eo=null;try{eo=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{}function fe(r,t,e){this.low=r|0,this.high=t|0,this.unsigned=!!e}fe.prototype.__isLong__;Object.defineProperty(fe.prototype,"__isLong__",{value:!0});function $r(r){return(r&&r.__isLong__)===!0}fe.isLong=$r;var NC={},vC={};function xa(r,t){var e,o,n;return t?(r>>>=0,(n=0<=r&&r<256)&&(o=vC[r],o)?o:(e=he(r,(r|0)<0?-1:0,!0),n&&(vC[r]=e),e)):(r|=0,(n=-128<=r&&r<128)&&(o=NC[r],o)?o:(e=he(r,r<0?-1:0,!1),n&&(NC[r]=e),e))}fe.fromInt=xa;function ro(r,t){if(isNaN(r))return t?ga:oo;if(t){if(r<0)return ga;if(r>=AC)return RC}else{if(r<=-kC)return Ar;if(r+1>=kC)return DC}return r<0?ro(-r,t).neg():he(r%ru|0,r/ru|0,t)}fe.fromNumber=ro;function he(r,t,e){return new fe(r,t,e)}fe.fromBits=he;var th=Math.pow;function Cy(r,t,e){if(r.length===0)throw Error("empty string");if(r==="NaN"||r==="Infinity"||r==="+Infinity"||r==="-Infinity")return oo;if(typeof t=="number"?(e=t,t=!1):t=!!t,e=e||10,e<2||36<e)throw RangeError("radix");var o;if((o=r.indexOf("-"))>0)throw Error("interior hyphen");if(o===0)return Cy(r.substring(1),t,e).neg();for(var n=ro(th(e,8)),s=oo,i=0;i<r.length;i+=8){var a=Math.min(8,r.length-i),l=parseInt(r.substring(i,i+a),e);if(a<8){var u=ro(th(e,a));s=s.mul(u).add(ro(l))}else s=s.mul(n),s=s.add(ro(l))}return s.unsigned=t,s}fe.fromString=Cy;function No(r,t){return typeof r=="number"?ro(r,t):typeof r=="string"?Cy(r,t):he(r.low,r.high,typeof t=="boolean"?t:r.unsigned)}fe.fromValue=No;var TC=65536,z_=1<<24,ru=TC*TC,AC=ru*ru,kC=AC/2,EC=xa(z_),oo=xa(0);fe.ZERO=oo;var ga=xa(0,!0);fe.UZERO=ga;var eu=xa(1);fe.ONE=eu;var $C=xa(1,!0);fe.UONE=$C;var wy=xa(-1);fe.NEG_ONE=wy;var DC=he(-1,2147483647,!1);fe.MAX_VALUE=DC;var RC=he(-1,-1,!0);fe.MAX_UNSIGNED_VALUE=RC;var Ar=he(0,-2147483648,!1);fe.MIN_VALUE=Ar;var it=fe.prototype;it.toInt=function(){return this.unsigned?this.low>>>0:this.low};it.toNumber=function(){return this.unsigned?(this.high>>>0)*ru+(this.low>>>0):this.high*ru+(this.low>>>0)};it.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ar)){var e=ro(t),o=this.div(e),n=o.mul(e).sub(this);return o.toString(t)+n.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var s=ro(th(t,6),this.unsigned),i=this,a="";;){var l=i.div(s),u=i.sub(l.mul(s)).toInt()>>>0,c=u.toString(t);if(i=l,i.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};it.getHighBits=function(){return this.high};it.getHighBitsUnsigned=function(){return this.high>>>0};it.getLowBits=function(){return this.low};it.getLowBitsUnsigned=function(){return this.low>>>0};it.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ar)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&!(t&1<<e);e--);return this.high!=0?e+33:e+1};it.isZero=function(){return this.high===0&&this.low===0};it.eqz=it.isZero;it.isNegative=function(){return!this.unsigned&&this.high<0};it.isPositive=function(){return this.unsigned||this.high>=0};it.isOdd=function(){return(this.low&1)===1};it.isEven=function(){return(this.low&1)===0};it.equals=function(t){return $r(t)||(t=No(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};it.eq=it.equals;it.notEquals=function(t){return!this.eq(t)};it.neq=it.notEquals;it.ne=it.notEquals;it.lessThan=function(t){return this.comp(t)<0};it.lt=it.lessThan;it.lessThanOrEqual=function(t){return this.comp(t)<=0};it.lte=it.lessThanOrEqual;it.le=it.lessThanOrEqual;it.greaterThan=function(t){return this.comp(t)>0};it.gt=it.greaterThan;it.greaterThanOrEqual=function(t){return this.comp(t)>=0};it.gte=it.greaterThanOrEqual;it.ge=it.greaterThanOrEqual;it.compare=function(t){if($r(t)||(t=No(t)),this.eq(t))return 0;var e=this.isNegative(),o=t.isNegative();return e&&!o?-1:!e&&o?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};it.comp=it.compare;it.negate=function(){return!this.unsigned&&this.eq(Ar)?Ar:this.not().add(eu)};it.neg=it.negate;it.add=function(t){$r(t)||(t=No(t));var e=this.high>>>16,o=this.high&65535,n=this.low>>>16,s=this.low&65535,i=t.high>>>16,a=t.high&65535,l=t.low>>>16,u=t.low&65535,c=0,p=0,m=0,f=0;return f+=s+u,m+=f>>>16,f&=65535,m+=n+l,p+=m>>>16,m&=65535,p+=o+a,c+=p>>>16,p&=65535,c+=e+i,c&=65535,he(m<<16|f,c<<16|p,this.unsigned)};it.subtract=function(t){return $r(t)||(t=No(t)),this.add(t.neg())};it.sub=it.subtract;it.multiply=function(t){if(this.isZero())return oo;if($r(t)||(t=No(t)),eo){var e=eo.mul(this.low,this.high,t.low,t.high);return he(e,eo.get_high(),this.unsigned)}if(t.isZero())return oo;if(this.eq(Ar))return t.isOdd()?Ar:oo;if(t.eq(Ar))return this.isOdd()?Ar:oo;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(EC)&&t.lt(EC))return ro(this.toNumber()*t.toNumber(),this.unsigned);var o=this.high>>>16,n=this.high&65535,s=this.low>>>16,i=this.low&65535,a=t.high>>>16,l=t.high&65535,u=t.low>>>16,c=t.low&65535,p=0,m=0,f=0,h=0;return h+=i*c,f+=h>>>16,h&=65535,f+=s*c,m+=f>>>16,f&=65535,f+=i*u,m+=f>>>16,f&=65535,m+=n*c,p+=m>>>16,m&=65535,m+=s*u,p+=m>>>16,m&=65535,m+=i*l,p+=m>>>16,m&=65535,p+=o*c+n*u+s*l+i*a,p&=65535,he(f<<16|h,p<<16|m,this.unsigned)};it.mul=it.multiply;it.divide=function(t){if($r(t)||(t=No(t)),t.isZero())throw Error("division by zero");if(eo){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?eo.div_u:eo.div_s)(this.low,this.high,t.low,t.high);return he(e,eo.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ga:oo;var o,n,s;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return ga;if(t.gt(this.shru(1)))return $C;s=ga}else{if(this.eq(Ar)){if(t.eq(eu)||t.eq(wy))return Ar;if(t.eq(Ar))return eu;var i=this.shr(1);return o=i.div(t).shl(1),o.eq(oo)?t.isNegative()?eu:wy:(n=this.sub(t.mul(o)),s=o.add(n.div(t)),s)}else if(t.eq(Ar))return this.unsigned?ga:oo;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=oo}for(n=this;n.gte(t);){o=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(o)/Math.LN2),l=a<=48?1:th(2,a-48),u=ro(o),c=u.mul(t);c.isNegative()||c.gt(n);)o-=l,u=ro(o,this.unsigned),c=u.mul(t);u.isZero()&&(u=eu),s=s.add(u),n=n.sub(c)}return s};it.div=it.divide;it.modulo=function(t){if($r(t)||(t=No(t)),eo){var e=(this.unsigned?eo.rem_u:eo.rem_s)(this.low,this.high,t.low,t.high);return he(e,eo.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};it.mod=it.modulo;it.rem=it.modulo;it.not=function(){return he(~this.low,~this.high,this.unsigned)};it.and=function(t){return $r(t)||(t=No(t)),he(this.low&t.low,this.high&t.high,this.unsigned)};it.or=function(t){return $r(t)||(t=No(t)),he(this.low|t.low,this.high|t.high,this.unsigned)};it.xor=function(t){return $r(t)||(t=No(t)),he(this.low^t.low,this.high^t.high,this.unsigned)};it.shiftLeft=function(t){return $r(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?he(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):he(0,this.low<<t-32,this.unsigned)};it.shl=it.shiftLeft;it.shiftRight=function(t){return $r(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?he(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):he(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};it.shr=it.shiftRight;it.shiftRightUnsigned=function(t){if($r(t)&&(t=t.toInt()),t&=63,t===0)return this;var e=this.high;if(t<32){var o=this.low;return he(o>>>t|e<<32-t,e>>>t,this.unsigned)}else return t===32?he(e,0,this.unsigned):he(e>>>t-32,0,this.unsigned)};it.shru=it.shiftRightUnsigned;it.shr_u=it.shiftRightUnsigned;it.toSigned=function(){return this.unsigned?he(this.low,this.high,!1):this};it.toUnsigned=function(){return this.unsigned?this:he(this.low,this.high,!0)};it.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};it.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]};it.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]};fe.fromBytes=function(t,e,o){return o?fe.fromBytesLE(t,e):fe.fromBytesBE(t,e)};fe.fromBytesLE=function(t,e){return new fe(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};fe.fromBytesBE=function(t,e){return new fe(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}});var yS=Hr(()=>{"use strict"});var bS=Hr(()=>{"use strict"});var GS=Hr((VS,Sb)=>{"use strict";(function(r,t,e){function o(a){var l=this,u=i();l.next=function(){var c=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=c-(l.c=c|0)},l.c=1,l.s0=u(" "),l.s1=u(" "),l.s2=u(" "),l.s0-=u(a),l.s0<0&&(l.s0+=1),l.s1-=u(a),l.s1<0&&(l.s1+=1),l.s2-=u(a),l.s2<0&&(l.s2+=1),u=null}function n(a,l){return l.c=a.c,l.s0=a.s0,l.s1=a.s1,l.s2=a.s2,l}function s(a,l){var u=new o(a),c=l&&l.state,p=u.next;return p.int32=function(){return u.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,c&&(typeof c=="object"&&n(c,u),p.state=function(){return n(u,{})}),p}function i(){var a=4022871197,l=function(u){u=String(u);for(var c=0;c<u.length;c++){a+=u.charCodeAt(c);var p=.02519603282416938*a;a=p>>>0,p-=a,p*=a,a=p>>>0,p-=a,a+=p*4294967296}return(a>>>0)*23283064365386963e-26};return l}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.alea=s})(VS,typeof Sb=="object"&&Sb,typeof define=="function"&&define)});var US=Hr((WS,Ib)=>{"use strict";(function(r,t,e){function o(i){var a=this,l="";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:l+=i;for(var u=0;u<l.length+64;u++)a.x^=l.charCodeAt(u)|0,a.next()}function n(i,a){return a.x=i.x,a.y=i.y,a.z=i.z,a.w=i.w,a}function s(i,a){var l=new o(i),u=a&&a.state,c=function(){return(l.next()>>>0)/4294967296};return c.double=function(){do var p=l.next()>>>11,m=(l.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=l.next,c.quick=c,u&&(typeof u=="object"&&n(u,l),c.state=function(){return n(l,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor128=s})(WS,typeof Ib=="object"&&Ib,typeof define=="function"&&define)});var KS=Hr((HS,Nb)=>{"use strict";(function(r,t,e){function o(i){var a=this,l="";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:l+=i;for(var u=0;u<l.length+64;u++)a.x^=l.charCodeAt(u)|0,u==l.length&&(a.d=a.x<<10^a.x>>>4),a.next()}function n(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 l=new o(i),u=a&&a.state,c=function(){return(l.next()>>>0)/4294967296};return c.double=function(){do var p=l.next()>>>11,m=(l.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=l.next,c.quick=c,u&&(typeof u=="object"&&n(u,l),c.state=function(){return n(l,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorwow=s})(HS,typeof Nb=="object"&&Nb,typeof define=="function"&&define)});var jS=Hr((qS,vb)=>{"use strict";(function(r,t,e){function o(i){var a=this;a.next=function(){var u=a.x,c=a.i,p,m,f;return p=u[c],p^=p>>>7,m=p^p<<24,p=u[c+1&7],m^=p^p>>>10,p=u[c+3&7],m^=p^p>>>3,p=u[c+4&7],m^=p^p<<7,p=u[c+7&7],p=p^p<<13,m^=p^p<<9,u[c]=m,a.i=c+1&7,m};function l(u,c){var p,m,f=[];if(c===(c|0))m=f[0]=c;else for(c=""+c,p=0;p<c.length;++p)f[p&7]=f[p&7]<<15^c.charCodeAt(p)+f[p+1&7]<<13;for(;f.length<8;)f.push(0);for(p=0;p<8&&f[p]===0;++p);for(p==8?m=f[7]=-1:m=f[p],u.x=f,u.i=0,p=256;p>0;--p)u.next()}l(a,i)}function n(i,a){return a.x=i.x.slice(),a.i=i.i,a}function s(i,a){i==null&&(i=+new Date);var l=new o(i),u=a&&a.state,c=function(){return(l.next()>>>0)/4294967296};return c.double=function(){do var p=l.next()>>>11,m=(l.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=l.next,c.quick=c,u&&(u.x&&n(u,l),c.state=function(){return n(l,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xorshift7=s})(qS,typeof vb=="object"&&vb,typeof define=="function"&&define)});var YS=Hr((XS,Tb)=>{"use strict";(function(r,t,e){function o(i){var a=this;a.next=function(){var u=a.w,c=a.X,p=a.i,m,f;return a.w=u=u+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+(u^u>>>16)|0};function l(u,c){var p,m,f,h,d,g=[],x=128;for(c===(c|0)?(m=c,c=null):(c=c+"\0",m=0,x=Math.max(x,c.length)),f=0,h=-32;h<x;++h)c&&(m^=c.charCodeAt((h+32)%c.length)),h===0&&(d=m),m^=m<<10,m^=m>>>15,m^=m<<4,m^=m>>>13,h>=0&&(d=d+1640531527|0,p=g[h&127]^=m+d,f=p==0?f+1:0);for(f>=128&&(g[(c&&c.length||0)&127]=-1),f=127,h=4*128;h>0;--h)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;u.w=d,u.X=g,u.i=f}l(a,i)}function n(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 l=new o(i),u=a&&a.state,c=function(){return(l.next()>>>0)/4294967296};return c.double=function(){do var p=l.next()>>>11,m=(l.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=l.next,c.quick=c,u&&(u.X&&n(u,l),c.state=function(){return n(l,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.xor4096=s})(XS,typeof Tb=="object"&&Tb,typeof define=="function"&&define)});var JS=Hr((ZS,kb)=>{"use strict";(function(r,t,e){function o(i){var a=this,l="";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):l+=i;for(var u=0;u<l.length+20;u++)a.b^=l.charCodeAt(u)|0,a.next()}function n(i,a){return a.a=i.a,a.b=i.b,a.c=i.c,a.d=i.d,a}function s(i,a){var l=new o(i),u=a&&a.state,c=function(){return(l.next()>>>0)/4294967296};return c.double=function(){do var p=l.next()>>>11,m=(l.next()>>>0)/4294967296,f=(p+m)/(1<<21);while(f===0);return f},c.int32=l.next,c.quick=c,u&&(typeof u=="object"&&n(u,l),c.state=function(){return n(l,{})}),c}t&&t.exports?t.exports=s:e&&e.amd?e(function(){return s}):this.tychei=s})(ZS,typeof kb=="object"&&kb,typeof define=="function"&&define)});var QS=Hr(()=>{"use strict"});var eI=Hr((tI,wh)=>{"use strict";(function(r,t,e){var o=256,n=6,s=52,i="random",a=e.pow(o,n),l=e.pow(2,s),u=l*2,c=o-1,p;function m(C,w,S){var E=[];w=w==!0?{entropy:!0}:w||{};var A=g(d(w.entropy?[C,b(t)]:C??x(),3),E),$=new f(E),_=function(){for(var L=$.g(n),M=a,B=0;L<l;)L=(L+B)*o,M*=o,B=$.g(1);for(;L>=u;)L/=2,M/=2,B>>>=1;return(L+B)/M};return _.int32=function(){return $.g(4)|0},_.quick=function(){return $.g(4)/4294967296},_.double=_,g(b($.S),t),(w.pass||S||function(L,M,B,V){return V&&(V.S&&h(V,$),L.state=function(){return h($,{})}),B?(e[i]=L,M):L})(_,A,"global"in w?w.global:this==e,w.state)}function f(C){var w,S=C.length,E=this,A=0,$=E.i=E.j=0,_=E.S=[];for(S||(C=[S++]);A<o;)_[A]=A++;for(A=0;A<o;A++)_[A]=_[$=c&$+C[A%S]+(w=_[A])],_[$]=w;(E.g=function(L){for(var M,B=0,V=E.i,W=E.j,G=E.S;L--;)M=G[V=c&V+1],B=B*o+G[c&(G[V]=G[W=c&W+M])+(G[W]=M)];return E.i=V,E.j=W,B})(o)}function h(C,w){return w.i=C.i,w.j=C.j,w.S=C.S.slice(),w}function d(C,w){var S=[],E=typeof C,A;if(w&&E=="object")for(A in C)try{S.push(d(C[A],w-1))}catch{}return S.length?S:E=="string"?C:C+"\0"}function g(C,w){for(var S=C+"",E,A=0;A<S.length;)w[c&A]=c&(E^=w[c&A]*19)+S.charCodeAt(A++);return b(w)}function x(){try{var C;return p&&(C=p.randomBytes)?C=C(o):(C=new Uint8Array(o),(r.crypto||r.msCrypto).getRandomValues(C)),b(C)}catch{var w=r.navigator,S=w&&w.plugins;return[+new Date,r,S,r.screen,b(t)]}}function b(C){return String.fromCharCode.apply(0,C)}if(g(e.random(),t),typeof wh=="object"&&wh.exports){wh.exports=m;try{p=QS()}catch{}}else typeof define=="function"&&define.amd?define(function(){return m}):e["seed"+i]=m})(typeof self<"u"?self:tI,[],Math)});var ip=Hr((rit,rI)=>{"use strict";var UP=GS(),HP=US(),KP=KS(),qP=jS(),jP=YS(),XP=JS(),_a=eI();_a.alea=UP;_a.xor128=HP;_a.xorwow=KP;_a.xorshift7=qP;_a.xor4096=jP;_a.tychei=XP;rI.exports=_a});var XT=Hr(()=>{"use strict"});var ea=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}},hn=class{refCount(t){return Er("refCount")}incRef(t){return Er("incRef")}timerAvailable(){return!0}time(t){return Er("time")}read(t){return Er("read")}readSync(t){return Er("readSync")}readToGPU(t,e){return Er("readToGPU")}numDataIds(){return Er("numDataIds")}disposeData(t,e){return Er("disposeData")}write(t,e,o){return Er("write")}move(t,e,o,n,s){return Er("move")}createTensorFromGPUData(t,e,o){return Er("createTensorFromGPUData")}memory(){return Er("memory")}floatPrecision(){return Er("floatPrecision")}epsilon(){return this.floatPrecision()===32?1e-7:1e-4}dispose(){return Er("dispose")}};function Er(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 pC(r){let t=r.length,e=0;for(;t>0;)e=Math.random()*t|0,t--,Ef(r,t,e)}function h_(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,o=0;for(;e>0;)o=Math.random()*e|0,e--,Ef(r,e,o),Ef(t,e,o)}function cl(r,t,e){return Math.max(r,Math.min(t,e))}function d_(r){return r%2===0?r:r+1}function Ef(r,t,e){let o=r[t];r[t]=r[e],r[e]=o}function g_(r){let t=0;for(let e=0;e<r.length;e++)t+=r[e];return t}function x_(r,t){let e=Math.random();return t*e+(1-e)*r}function y_(r,t){let e=0;for(let o=0;o<r.length;o++){let n=Number(r[o])-Number(t[o]);e+=n*n}return e}function v(r,t){if(!r)throw new Error(typeof t=="string"?t:t())}function Af(r,t,e=""){v(Os(r,t),()=>e+` Shapes ${r} and ${t} must match`)}function Fc(r){v(r!=null,()=>"The input to the tensor constructor must be a non-null value.")}function zt(r){if(r.length===0)return 1;let t=r[0];for(let e=1;e<r.length;e++)t*=r[e];return t}function b_(r){return r.length===0}function w_(r,t){if(r===t)return!0;if(r==null||t==null||r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==null&&t[e]!==null&&r[e]!==t[e])return!1;return!0}function Os(r,t){if(r===t)return!0;if(r==null||t==null||r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}function dn(r){return r%1===0}function C_(r){if(Math.tanh!=null)return Math.tanh(r);if(r===1/0)return 1;if(r===-1/0)return-1;{let t=Math.exp(2*r);return(t-1)/(t+1)}}function S_(r){let t=Math.ceil(Math.sqrt(r));return[t,Math.ceil(r/t)]}function I_(r){let t=new Uint32Array(r);for(let e=0;e<r;++e)t[e]=e;return pC(t),t}function oa(r,t){return t<=r.length?r:r+" ".repeat(t-r.length)}function N_(r,t=n=>0,e,o){return new Promise((n,s)=>{let i=0,a=()=>{if(r()){n();return}i++;let l=t(i);if(e!=null&&i>=e){s();return}o!=null?o(a,l):setTimeout(a,l)};a()})}function v_(r,t){let e=1,o=-1;for(let s=0;s<r.length;++s)if(r[s]>=0)e*=r[s];else if(r[s]===-1){if(o!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${o} and dim ${s}`);o=s}else if(r[s]<0)throw Error(`Shapes can not be < 0. Found ${r[s]} at dim ${s}`);if(o===-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 n=r.slice();return n[o]=t/e,n}function Ae(r,t){let e=t.length;return r=r==null?t.map((o,n)=>n):[].concat(r),v(r.every(o=>o>=-e&&o<e),()=>`All values in axis param must be in range [-${e}, ${e}) but got axis ${r}`),v(r.every(o=>dn(o)),()=>`All values in axis param must be integers but got axis ${r}`),r.map(o=>o<0?e+o:o)}function uy(r,t){let e=[],o=[],n=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||n?null:Ae(t,r).sort(),i=0;for(let a=0;a<r.length;++a){if(s!=null){if(s[i]===a&&r[a]!==1)throw new Error(`Can't squeeze axis ${a} since its dim '${r[a]}' is not 1`);(s[i]==null||s[i]>a)&&r[a]===1&&(e.push(r[a]),o.push(a)),s[i]<=a&&i++}r[a]!==1&&(e.push(r[a]),o.push(a))}return{newShape:e,keptDims:o}}function T_(r,t){return $f(r,t)}function $f(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 cy(r,t){for(let e=0;e<r.length;e++){let o=r[e];if(isNaN(o)||!isFinite(o))throw Error(`A tensor of type ${t} being uploaded contains ${o}.`)}}function py(r){return r==="bool"||r==="complex64"||r==="float32"||r==="int32"||r==="string"}function k_(r,t){return!(t==="complex64"||t==="float32"&&r!=="complex64"||t==="int32"&&r!=="float32"&&r!=="complex64"||t==="bool"&&r==="bool")}function pl(r){if(r==="float32"||r==="int32")return 4;if(r==="complex64")return 8;if(r==="bool")return 1;throw new Error(`Unknown dtype ${r}`)}function my(r){if(r==null)return 0;let t=0;return r.forEach(e=>t+=e.length),t}function ml(r){return typeof r=="string"||r instanceof String}function mC(r){return typeof r=="boolean"}function fC(r){return typeof r=="number"}function Ls(r){return Array.isArray(r)?Ls(r[0]):r instanceof Float32Array?"float32":r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray?"int32":fC(r)?"float32":ml(r)?"string":mC(r)?"bool":"float32"}function fl(r){return!!(r&&r.constructor&&r.call&&r.apply)}function hl(r,t){for(let e=t;e<r;++e)if(r%e===0)return e;return r}function Go(r){let t=r.length;if(t<2)return[];let e=new Array(t-1);e[t-2]=r[t-1];for(let o=t-3;o>=0;--o)e[o]=e[o+1]*r[o+1];return e}function hC(r,t,e,o=!1){let n=new Array;if(t.length===1){let s=t[0]*(o?2:1);for(let i=0;i<s;i++)n[i]=e[r+i]}else{let s=t[0],i=t.slice(1),a=i.reduce((l,u)=>l*u)*(o?2:1);for(let l=0;l<s;l++)n[l]=hC(r+l*a,i,e,o)}return n}function ra(r,t,e=!1){if(r.length===0)return t[0];let o=r.reduce((n,s)=>n*s)*(e?2:1);if(o===0)return[];if(o!==t.length)throw new Error(`[${r}] does not match the input size ${t.length}${e?" for a complex tensor":""}.`);return hC(0,r,t,e)}function E_(r,t){if(Array.isArray(r))return r;if(t==="float32")return r instanceof Float32Array?r:new Float32Array(r);if(t==="int32")return r instanceof Int32Array?r:new Int32Array(r);if(t==="bool"||t==="string")return Uint8Array.from(new Int32Array(r));throw new Error(`Unknown dtype ${t}`)}function _c(r,t){let e=dl(r,t);for(let o=0;o<e.length;o++)e[o]=1;return e}function dl(r,t){if(t==null||t==="float32"||t==="complex64")return new Float32Array(r);if(t==="int32")return new Int32Array(r);if(t==="bool")return new Uint8Array(r);throw new Error(`Unknown data type ${t}`)}function A_(r,t){let e=r.reduce((o,n)=>o*n,1);if(t==null||t==="float32")return ra(r,new Float32Array(e));if(t==="int32")return ra(r,new Int32Array(e));if(t==="bool")return ra(r,new Uint8Array(e));throw new Error(`Unknown data type ${t}`)}function Ge(r){r.forEach(t=>{v(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${r}].`)})}function $_(r,t,e){if(t===0)return 0;if(t===1)return r[0];let o=r[r.length-1];for(let n=0;n<r.length-1;++n)o+=e[n]*r[n];return o}function D_(r,t,e){if(t===0)return[];if(t===1)return[r];let o=new Array(t);for(let n=0;n<o.length-1;++n)o[n]=Math.floor(r/e[n]),r-=o[n]*e[n];return o[o.length-1]=r,o}function na(r){return r&&r.then&&typeof r.then=="function"}var dC="tfjsflags",Oc=class{constructor(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=F_,this.populateURLFlags()}setPlatform(t,e){this.platform!=null&&(P().getBool("IS_TEST")||P().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)),this.platformName=t,this.platform=e}registerFlag(t,e,o){if(this.flagRegistry[t]={evaluationFn:e,setHook:o},this.urlFlags[t]!=null){let n=this.urlFlags[t];P().getBool("IS_TEST")||P().getBool("PROD")||console.warn(`Setting feature override from URL ${t}: ${n}.`),this.set(t,n)}}async getAsync(t){return t in this.flags?this.flags[t]:(this.flags[t]=await this.evaluateFlag(t),this.flags[t])}get(t){if(t in this.flags)return this.flags[t];let e=this.evaluateFlag(t);if(na(e))throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[t]=e,this.flags[t]}getNumber(t){return this.get(t)}getBool(t){return this.get(t)}getString(t){return this.get(t)}getFlags(){return this.flags}get features(){return this.flags}set(t,e){if(this.flagRegistry[t]==null)throw new Error(`Cannot set flag ${t} as it has not been registered.`);this.flags[t]=e,this.flagRegistry[t].setHook!=null&&this.flagRegistry[t].setHook(e)}evaluateFlag(t){if(this.flagRegistry[t]==null)throw new Error(`Cannot evaluate flag '${t}': no evaluation function found.`);return this.flagRegistry[t].evaluationFn()}setFlags(t){this.flags=Object.assign({},t)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;let t=this.getQueryParams(this.global.location.search);dC in t&&t[dC].split(",").forEach(o=>{let[n,s]=o.split(":");this.urlFlags[n]=O_(n,s)})}};function F_(r){let t={};return r.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...o)=>(__(t,o[0],o[1]),o.join("="))),t}function __(r,t,e){r[decodeURIComponent(t)]=decodeURIComponent(e||"")}function O_(r,t){let e=t.toLowerCase();return e==="true"||e==="false"?e==="true":`${+e}`===e?+e:t}function P(){return fy}var fy=null;function gC(r){fy=r}var hy;function dy(){if(hy==null){let r;if(typeof window<"u")r=window;else if(typeof global<"u")r=global;else if(typeof process<"u")r=process;else if(typeof self<"u")r=self;else throw new Error("Could not find a global object");hy=r}return hy}function L_(){let r=dy();return r._tfGlobals==null&&(r._tfGlobals=new Map),r._tfGlobals}function Lc(r,t){let e=L_();if(e.has(r))return e.get(r);{let o=t();return e.set(r,o),e.get(r)}}var Ps="Abs",gn="Acos",xn="Acosh",Io="Add",gl="AddN",xl="All",yl="Any",zs="ArgMax",Ms="ArgMin",yn="Asin",bn="Asinh",wn="Atan",Cn="Atanh",Sn="Atan2",Bs="AvgPool",bl="AvgPoolGrad",Vs="AvgPool3D",wl="AvgPool3DGrad",Gs="BatchMatMul",Ws="BatchToSpaceND",Cl="Bincount",Pc="BitwiseAnd",xC="BroadcastTo",Df="BroadcastArgs",Wo="Cast",In="Ceil",Nn="ClipByValue",Sl="Complex",Us="ComplexAbs",Hs="Concat",Ks="Conv2D",Il="Conv2DBackpropFilter",qs="Conv2DBackpropInput",js="Conv3D",Nl="Conv3DBackpropFilterV2",vl="Conv3DBackpropInputV2",vn="Cos",Tn="Cosh",Tl="Cumprod",Xs="Cumsum",kl="CropAndResize",El="DenseBincount",Al="DepthToSpace",Ys="DepthwiseConv2dNative",$l="DepthwiseConv2dNativeBackpropFilter",Dl="DepthwiseConv2dNativeBackpropInput",Rf="Diag",Zs="Dilation2D",zc="Dilation2DBackpropInput",Mc="Dilation2DBackpropFilter",yC="Draw",kn="RealDiv",Rl="Einsum",En="Elu",Fl="EluGrad",An="Erf",sa="Equal",$n="Exp",Js="ExpandDims",Dn="Expm1",_l="FFT",Ol="Fill",Ll="FlipLeftRight",Rn="Floor",Fn="FloorDiv",Qs="FusedBatchNorm",ti="GatherV2",Ff="GatherNd",ia="Greater",_n="GreaterEqual",Uo="Identity",Pl="IFFT",zl="Imag",On="IsFinite",Ln="IsInf",Pn="IsNan",ei="LeakyRelu",aa="Less",la="LessEqual",_f="LinSpace",zn="Log",Mn="Log1p",ua="LogicalAnd",ca="LogicalNot",pa="LogicalOr";var bC="LogSoftmax";var ri="LRN",Ml="LRNGrad";var oi="Max",Bn="Maximum",ni="MaxPool",Bl="MaxPoolGrad",si="MaxPool3D",Vl="MaxPool3DGrad",Of="MaxPoolWithArgmax",ii="Mean",ai="Min",Vn="Minimum",li="MirrorPad",Gn="Mod",Lf="Multinomial",Wn="Multiply",ui="Neg",ma="NotEqual",Gl="NonMaxSuppressionV3",Wl="NonMaxSuppressionV4",Ul="NonMaxSuppressionV5",ci="OnesLike",pi="OneHot",mi="Pack",fi="PadV2";var Un="Pow",hi="Prelu",di="Prod",Pf="RaggedGather",zf="RaggedRange",Mf="RaggedTensorToTensor",Hl="Range",Kl="Real",Hn="Reciprocal",Kn="Relu",gi="Reshape",xi="ResizeNearestNeighbor",ql="ResizeNearestNeighborGrad",yi="ResizeBilinear",jl="ResizeBilinearGrad",qn="Relu6",bi="Reverse",jn="Round",Xn="Rsqrt",Bf="ScatterNd",Vf="TensorScatterUpdate",Gf="SearchSorted",wi="Select",Yn="Selu",Ci="Slice",Zn="Sin",Jn="Sinh",Qn="Sign",ts="Sigmoid",es="Softplus",rs="Sqrt",Si="Sum",Ii="SpaceToBatchND",Ni="SplitV",vi="Softmax",Wf="SparseFillEmptyRows",Uf="SparseReshape",Hf="SparseSegmentMean",Kf="SparseSegmentSum",qf="SparseToDense",os="SquaredDifference",Xl="Square",Bc="StaticRegexReplace",Yl="StridedSlice",jf="StringNGrams",Xf="StringSplit",Yf="StringToHashBucketFast",ns="Sub",ss="Tan",is="Tanh",Ho="Tile",Zl="TopK",Jl="Transform",Ko="Transpose",Ql="Unique",Ti="Unpack",ki="UnsortedSegmentSum";var Ei="ZerosLike",as="Step",wC="FromPixels",tu="RotateWithOffset",fa="_FusedMatMul",ha="FusedConv2D",da="FusedDepthwiseConv2D";function qo(...r){P().getBool("IS_TEST")||P().getBool("PROD")||console.warn(...r)}function P_(...r){P().getBool("IS_TEST")||P().getBool("PROD")||console.log(...r)}var Zf=Lc("kernelRegistry",()=>new Map),gy=Lc("gradRegistry",()=>new Map);function xy(r,t){let e=IC(r,t);return Zf.get(e)}function yy(r){return gy.get(r)}function by(r){let t=Zf.entries(),e=[];for(;;){let{done:o,value:n}=t.next();if(o)break;let[s,i]=n,[a]=s.split("_");a===r&&e.push(i)}return e}function Jf(r){let{kernelName:t,backendName:e}=r,o=IC(t,e);Zf.has(o)&&qo(`The kernel '${t}' for backend '${e}' is already registered`),Zf.set(o,r)}function SC(r){let{kernelName:t}=r;gy.has(t)&&P().getBool("DEBUG")&&qo(`Overriding the gradient for '${t}'`),gy.set(t,r)}function IC(r,t){return`${t}_${r}`}var y={};to(y,{arraysEqual:()=>Os,arraysEqualWithNull:()=>w_,assert:()=>v,assertNonNegativeIntegerDimensions:()=>Ge,assertNonNull:()=>Fc,assertShapesMatch:()=>Af,bytesFromStringArray:()=>my,bytesPerElement:()=>pl,checkConversionForErrors:()=>cy,clamp:()=>cl,computeStrides:()=>Go,convertBackendValuesAndArrayBuffer:()=>E_,createScalarValue:()=>U_,createShuffledIndices:()=>I_,decodeString:()=>su,distSquared:()=>y_,encodeString:()=>nu,fetch:()=>K_,fingerPrint64:()=>W_,flatten:()=>$i,getArrayFromDType:()=>$f,getTypedArrayFromDType:()=>T_,hasEncodingLoss:()=>k_,hexToLong:()=>Vc,indexToLoc:()=>D_,inferDtype:()=>Ls,inferFromImplicitShape:()=>v_,isBoolean:()=>mC,isFunction:()=>fl,isInt:()=>dn,isNumber:()=>fC,isPromise:()=>na,isScalarShape:()=>b_,isString:()=>ml,isTypedArray:()=>nr,isValidDtype:()=>py,locToIndex:()=>$_,makeOnesTypedArray:()=>_c,makeZerosNestedTypedArray:()=>A_,makeZerosTypedArray:()=>dl,nearestDivisor:()=>hl,nearestLargerEven:()=>d_,now:()=>wa,parseAxisParam:()=>Ae,randUniform:()=>x_,repeatedTry:()=>N_,rightPad:()=>oa,shuffle:()=>pC,shuffleCombo:()=>h_,sizeFromShape:()=>zt,sizeToSquarishShape:()=>S_,squeezeShape:()=>uy,sum:()=>g_,swap:()=>Ef,tanh:()=>C_,toNestedArray:()=>ra,toTypedArray:()=>ou});function Qf(r){return r instanceof Float32Array||r instanceof Int32Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray}var Iy=Rc(_C());var ba=Iy.default||Iy;function Vc(r){return ba.fromString(r,!0,16)}var LC=Vc("c3a5c85c97cb3127"),ya=Vc("b492b66fbe98f273"),cr=Vc("9ae16a3b2f90404f");function Sy(r){return r.xor(r.shru(47))}function PC(r,t,e){let o=r.slice(t,t+e);return ba.fromBytes(Array.from(o),!0,!0)}function le(r,t){return PC(r,t,8)}function OC(r,t){return PC(r,t,4)}function We(r,t){return t===0?r:r.shru(t).or(r.shl(64-t))}function Ai(r,t,e=Vc("9ddfea08eb382d69")){let o=r.xor(t).mul(e);o=o.xor(o.shru(47));let n=t.xor(o).mul(e);return n=n.xor(n.shru(47)),n=n.mul(e),n}function M_(r,t,e,o,n,s){n=n.add(r),s=We(s.add(n).add(o),21);let i=n;return n=n.add(t),n=n.add(e),s=s.add(We(n,44)),[n.add(o),s.add(i)]}function eh(r,t,e,o){return M_(le(r,t),le(r,t+8),le(r,t+16),le(r,t+24),e,o)}function B_(r,t=r.length){if(t>=8){let e=cr.add(t*2),o=le(r,0).add(cr),n=le(r,t-8),s=We(n,37).mul(e).add(o),i=We(o,25).add(n).mul(e);return Ai(s,i,e)}if(t>=4){let e=cr.add(t*2),o=OC(r,0);return Ai(o.shl(3).add(t),OC(r,t-4),e)}if(t>0){let e=r[0],o=r[t>>1],n=r[t-1],s=e+(o<<8),i=t+(n<<2);return Sy(cr.mul(s).xor(LC.mul(i))).mul(cr)}return cr}function V_(r,t=r.length){let e=cr.add(t*2),o=le(r,0).mul(ya),n=le(r,8),s=le(r,t-8).mul(e),i=le(r,t-16).mul(cr);return Ai(We(o.add(n),43).add(We(s,30)).add(i),o.add(We(n.add(cr),18)).add(s),e)}function G_(r,t=r.length){let e=cr.add(t*2),o=le(r,0).mul(cr),n=le(r,8),s=le(r,t-8).mul(e),i=le(r,t-16).mul(cr),a=We(o.add(n),43).add(We(s,30)).add(i),l=Ai(a,o.add(We(n.add(cr),18)).add(s),e),u=le(r,16).mul(e),c=le(r,24),p=a.add(le(r,t-32)).mul(e),m=l.add(le(r,t-24)).mul(e);return Ai(We(u.add(c),43).add(We(p,30)).add(m),u.add(We(c.add(o),18)).add(p),e)}function W_(r,t=r.length){let e=ba.fromNumber(81,!0);if(t<=32)return t<=16?B_(r,t):V_(r,t);if(t<=64)return G_(r,t);let o=e,n=e.mul(ya).add(113),s=Sy(n.mul(cr).add(113)).mul(cr),i=[ba.UZERO,ba.UZERO],a=[ba.UZERO,ba.UZERO];o=o.mul(cr).add(le(r,0));let l=0,u=(t-1>>6)*64,c=u+(t-1&63)-63;do o=We(o.add(n).add(i[0]).add(le(r,l+8)),37).mul(ya),n=We(n.add(i[1]).add(le(r,l+48)),42).mul(ya),o=o.xor(a[1]),n=n.add(i[0]).add(le(r,l+40)),s=We(s.add(a[0]),33).mul(ya),i=eh(r,l,i[1].mul(ya),o.add(a[0])),a=eh(r,l+32,s.add(a[1]),n.add(le(r,l+16))),[s,o]=[o,s],l+=64;while(l!==u);let p=ya.add(s.and(255).shl(1));return l=c,a[0]=a[0].add(t-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),o=We(o.add(n).add(i[0]).add(le(r,l+8)),37).mul(p),n=We(n.add(i[1]).add(le(r,l+48)),42).mul(p),o=o.xor(a[1].mul(9)),n=n.add(i[0].mul(9).add(le(r,l+40))),s=We(s.add(a[0]),33).mul(p),i=eh(r,l,i[1].mul(p),o.add(a[0])),a=eh(r,l+32,s.add(a[1]),n.add(le(r,l+16))),[s,o]=[o,s],Ai(Ai(i[0],a[0],p).add(Sy(n).mul(LC)).add(s),Ai(i[1],a[1],p).add(o),p)}function U_(r,t){return t==="string"?nu(r):ou([r],t)}function H_(r,t){return r instanceof Float32Array&&t==="float32"||r instanceof Int32Array&&t==="int32"||r instanceof Uint8Array&&t==="bool"}function ou(r,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(r)&&(r=$i(r)),P().getBool("DEBUG")&&cy(r,t),H_(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 o=0;o<e.length;++o)Math.round(r[o])!==0&&(e[o]=1);return e}else throw new Error(`Unknown data type ${t}`)}function wa(){return P().platform.now()}function K_(r,t){return P().platform.fetch(r,t)}function nu(r,t="utf-8"){return t=t||"utf-8",P().platform.encode(r,t)}function su(r,t="utf-8"){return t=t||"utf-8",P().platform.decode(r,t)}function nr(r){return P().platform.isTypedArray!=null?P().platform.isTypedArray(r):Qf(r)}function $i(r,t=[],e=!1){if(t==null&&(t=[]),typeof r=="boolean"||typeof r=="number"||typeof r=="string"||na(r)||r==null||nr(r)&&e)t.push(r);else if(Array.isArray(r)||nr(r))for(let o=0;o<r.length;++o)$i(r[o],t,e);else{let o=-1;for(let n of Object.keys(r))/^([1-9]+[0-9]*|0)$/.test(n)&&(o=Math.max(o,Number(n)));for(let n=0;n<=o;n++)$i(r[n],t,e)}return t}var rh=class{constructor(t,e){this.backendTimer=t,this.logger=e,e==null&&(this.logger=new Ny)}profileKernel(t,e,o){let n,s=()=>{n=o()},i,a=wa();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(s);else{s();for(let u of n)u.dataSync();i=Promise.resolve({kernelMs:wa()-a})}if(P().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let u=0;u<n.length;u++){let c=n[u];c.data().then(p=>{q_(p,c.dtype,t)})}return{kernelName:t,outputs:n,inputs:e,timeMs:i.then(u=>u.kernelMs),extraInfo:i.then(u=>u.getExtraProfileInfo!=null?u.getExtraProfileInfo():"")}}logKernelProfile(t){let{kernelName:e,outputs:o,timeMs:n,inputs:s,extraInfo:i}=t;o.forEach(a=>{Promise.all([a.data(),n,i]).then(l=>{this.logger.logKernelProfile(e,a,l[0],l[1],s,l[2])})})}};function q_(r,t,e){if(t!=="float32")return!1;for(let o=0;o<r.length;o++){let n=r[o];if(isNaN(n)||!isFinite(n))return console.warn(`Found ${n} in the result of '${e}'`),!0}return!1}var Ny=class{logKernelProfile(t,e,o,n,s,i){let a=typeof n=="number"?oa(`${n}ms`,9):n.error,l=oa(t,25),u=e.rank,c=e.size,p=oa(e.shape.toString(),14),m="";for(let f in s){let h=s[f];if(h!=null){let d=h.shape||e.shape,g=d.length;m+=`${f}: ${g}D ${g>0?d:""} `}}console.log(`%c${l} %c${a} %c${u}D ${p} %c${c} %c${m} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function zC(r,t,e){let o={},n={};for(let l=0;l<t.length;l++)o[t[l].id]=!0;for(let l=0;l<r.length;l++){let u=r[l],c=u.inputs;for(let p in c){let m=c[p],f=!1;for(let h=0;h<t.length;h++)if(o[m.id]){u.outputs.forEach(d=>o[d.id]=!0),f=!0,n[u.id]=!0;break}if(f)break}}let s={};s[e.id]=!0;let i={};for(let l=r.length-1;l>=0;l--){let u=r[l],c=u.inputs;for(let p=0;p<u.outputs.length;p++)if(s[u.outputs[p].id]){for(let m in c)s[c[m].id]=!0,i[u.id]=!0;break}}let a=[];for(let l=0;l<r.length;l++){let u=r[l];if(n[u.id]&&i[u.id]){let c={};for(let m in u.inputs){let f=u.inputs[m];o[f.id]&&(c[m]=f)}let p=Object.assign({},u);p.inputs=c,p.outputs=u.outputs,a.push(p)}}return a}function MC(r,t,e,o){for(let n=t.length-1;n>=0;n--){let s=t[n],i=[];if(s.outputs.forEach(l=>{let u=r[l.id];u!=null?i.push(u):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let a=s.gradient(i);for(let l in s.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);let u=e(()=>a[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let c=s.inputs[l];if(!Os(u.shape,c.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`);if(r[c.id]==null)r[c.id]=u;else{let p=r[c.id];r[c.id]=o(p,u),p.dispose()}}}}var BC=20,Gc=3,vy=7;function VC(r,t,e,o){let n=Go(t),s=j_(r,t,e,n),i=t.length,a=oh(r,t,e,n,s),l=["Tensor"];return o&&(l.push(` dtype: ${e}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(a.map(u=>" "+u).join(` `)),l.join(` `)}function j_(r,t,e,o){let n=zt(t),s=o[o.length-1],i=new Array(s).fill(0),a=t.length,l=e==="complex64"?Uc(r):r;if(a>1)for(let u=0;u<n/s;u++){let c=u*s;for(let p=0;p<s;p++)i[p]=Math.max(i[p],Wc(l[c+p],0,e).length)}return i}function Wc(r,t,e){let o;return Array.isArray(r)?o=`${parseFloat(r[0].toFixed(vy))} + ${parseFloat(r[1].toFixed(vy))}j`:ml(r)?o=`'${r}'`:e==="bool"?o=GC(r):o=parseFloat(r.toFixed(vy)).toString(),oa(o,t)}function GC(r){return r===0?"false":"true"}function oh(r,t,e,o,n,s=!0){let i=e==="complex64"?2:1,a=t[0],l=t.length;if(l===0){if(e==="complex64"){let d=Uc(r);return[Wc(d[0],0,e)]}return e==="bool"?[GC(r[0])]:[r[0].toString()]}if(l===1){if(a>BC){let g=Gc*i,x=Array.from(r.slice(0,g)),b=Array.from(r.slice((a-Gc)*i,a*i));return e==="complex64"&&(x=Uc(x),b=Uc(b)),["["+x.map((C,w)=>Wc(C,n[w],e)).join(", ")+", ..., "+b.map((C,w)=>Wc(C,n[a-Gc+w],e)).join(", ")+"]"]}return["["+(e==="complex64"?Uc(r):Array.from(r)).map((g,x)=>Wc(g,n[x],e)).join(", ")+"]"]}let u=t.slice(1),c=o.slice(1),p=o[0]*i,m=[];if(a>BC){for(let d=0;d<Gc;d++){let g=d*p,x=g+p;m.push(...oh(r.slice(g,x),u,e,c,n,!1))}m.push("...");for(let d=a-Gc;d<a;d++){let g=d*p,x=g+p;m.push(...oh(r.slice(g,x),u,e,c,n,d===a-1))}}else for(let d=0;d<a;d++){let g=d*p,x=g+p;m.push(...oh(r.slice(g,x),u,e,c,n,d===a-1))}let f=l===2?",":"";m[0]="["+(a>0?m[0]+f:"");for(let d=1;d<m.length-1;d++)m[d]=" "+m[d]+f;let h=`, `;for(let d=2;d<l;d++)h+=` `;return m[m.length-1]=" "+m[m.length-1]+"]"+(s?"":h),m}function Uc(r){let t=[];for(let e=0;e<r.length;e+=2)t.push([r[e],r[e+1]]);return t}var Wt=class{constructor(t,e,o){if(this.dtype=e,this.shape=t.slice(),this.size=zt(t),o!=null){let n=o.length;v(n===this.size,()=>`Length of values '${n}' 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=o||$f(e,this.size),this.strides=Go(t)}set(t,...e){e.length===0&&(e=[0]),v(e.length===this.rank,()=>`The number of provided coordinates (${e.length}) must match the rank (${this.rank})`);let o=this.locToIndex(e);this.values[o]=t}get(...t){t.length===0&&(t=[0]);let e=0;for(let n of t){if(n<0||n>=this.shape[e]){let s=`Requested out of range element at ${t}. Buffer shape=${this.shape}`;throw new Error(s)}e++}let o=t[t.length-1];for(let n=0;n<t.length-1;++n)o+=this.strides[n]*t[n];return this.values[o]}locToIndex(t){if(this.rank===0)return 0;if(this.rank===1)return t[0];let e=t[t.length-1];for(let o=0;o<t.length-1;++o)e+=this.strides[o]*t[o];return e}indexToLoc(t){if(this.rank===0)return[];if(this.rank===1)return[t];let e=new Array(this.shape.length);for(let o=0;o<e.length-1;++o)e[o]=Math.floor(t/this.strides[o]),t-=e[o]*this.strides[o];return e[e.length-1]=t,e}get rank(){return this.shape.length}toTensor(){return vo().makeTensor(this.values,this.shape,this.dtype)}},vo=null,iu=null,X_=null;function WC(r){vo=r}function UC(r){iu=r}function HC(r){X_=r}var Lt=class{constructor(t,e,o,n){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=zt(t),this.strides=Go(t),this.dataId=o,this.id=n,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let t=await this.data();return iu.buffer(this.shape,this.dtype,t)}bufferSync(){return iu.buffer(this.shape,this.dtype,this.dataSync())}async array(){let t=await this.data();return ra(this.shape,t,this.dtype==="complex64")}arraySync(){return ra(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let t=vo().read(this.dataId);if(this.dtype==="string"){let e=await t;try{return e.map(o=>su(o))}catch{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(),vo().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();let t=vo().readSync(this.dataId);if(this.dtype==="string")try{return t.map(e=>su(e))}catch{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 vo().read(this.dataId);return this.dtype==="string"?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),vo().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return iu.print(this,t)}clone(){return this.throwIfDisposed(),iu.clone(this)}toString(t=!1){let e=this.dataSync();return VC(e,this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),iu.cast(this,t)}variable(t=!0,e,o){return this.throwIfDisposed(),vo().makeVariable(this,t,e,o)}};Object.defineProperty(Lt,Symbol.hasInstance,{value:r=>!!r&&r.data!=null&&r.dataSync!=null&&r.throwIfDisposed!=null});function D(){return Lc("Tensor",()=>Lt)}D();var ls=class extends Lt{constructor(t,e,o,n){super(t.shape,t.dtype,t.dataId,n),this.trainable=e,this.name=o}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(!Os(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);vo().disposeTensor(this),this.dataId=t.dataId,vo().incRef(this,null)}dispose(){vo().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(ls,Symbol.hasInstance,{value:r=>r instanceof Lt&&r.assign!=null&&r.assign instanceof Function});var no={};to(no,{assertTypesMatch:()=>Z_,getTensorsInContainer:()=>Hc,isTensorInList:()=>J_,makeTypesMatch:()=>At});var Ty;(function(r){r.R0="R0",r.R1="R1",r.R2="R2",r.R3="R3",r.R4="R4",r.R5="R5",r.R6="R6"})(Ty||(Ty={}));var ky;(function(r){r.float32="float32",r.int32="int32",r.bool="int32",r.complex64="complex64"})(ky||(ky={}));var Ey;(function(r){r.float32="float32",r.int32="int32",r.bool="bool",r.complex64="complex64"})(Ey||(Ey={}));var Ay;(function(r){r.float32="float32",r.int32="float32",r.bool="float32",r.complex64="complex64"})(Ay||(Ay={}));var $y;(function(r){r.float32="complex64",r.int32="complex64",r.bool="complex64",r.complex64="complex64"})($y||($y={}));var Y_={float32:Ay,int32:ky,bool:Ey,complex64:$y};function ve(r,t){if(r==="string"||t==="string"){if(r==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${r} with ${t}`)}return Y_[r][t]}function Ca(r){return ve(r,"int32")}function nh(r){return r!=null&&typeof r=="object"&&"texture"in r&&r.texture instanceof WebGLTexture}function sh(r){return typeof GPUBuffer<"u"&&r!=null&&typeof r=="object"&&"buffer"in r&&r.buffer instanceof GPUBuffer}function At(r,t){if(r.dtype===t.dtype)return[r,t];let e=ve(r.dtype,t.dtype);return[r.cast(e),t.cast(e)]}function Z_(r,t){v(r.dtype===t.dtype,()=>`The dtypes of the first(${r.dtype}) and second(${t.dtype}) input must match`)}function J_(r,t){return t.some(e=>e.id===r.id)}function Hc(r){let t=[];return KC(r,t,new Set),t}function KC(r,t,e){if(r==null)return;if(r instanceof Lt){t.push(r);return}if(!Q_(r))return;let o=r;for(let n in o){let s=o[n];e.has(s)||(e.add(s),KC(s,t,e))}}function Q_(r){return Array.isArray(r)||typeof r=="object"}function Dy(r){return r.kernelName!=null}var ih=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()}},Kc=class r{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new ih}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let t=this.getSortedBackends();for(let e=0;e<t.length;e++){let o=t[e];if(await this.initializeBackend(o).success){await this.setBackend(o);return}}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(this.pendingBackendInit!=null)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(this.backendInstance==null){let{name:t,asyncInit:e}=this.initializeBackendsAndReturnBest();if(e)throw new Error(`The highest priority backend '${t}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(t)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(t){if(!(t in this.registry))if(t in this.registryFactory){let{asyncInit:e}=this.initializeBackend(t);if(e)return null}else return null;return this.registry[t]}findBackendFactory(t){return t in this.registryFactory?this.registryFactory[t].factory:null}registerBackend(t,e,o=1){return t in this.registryFactory?(qo(`${t} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[t]={factory:e,priority:o},!0)}async setBackend(t){if(this.registryFactory[t]==null)throw new Error(`Backend name '${t}' not found in registry`);if(this.backendName=t,this.registry[t]==null){this.backendInstance=null;let{success:e,asyncInit:o}=this.initializeBackend(t);if(!(o?await e:e))return!1}return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new rh(this.backendInstance),!0}setupRegisteredKernels(){by(this.backendName).forEach(e=>{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(t){by(t).forEach(o=>{o.disposeFunc!=null&&o.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 o=e.factory();if(o&